Xenova HF staff commited on
Commit
e0d82ff
1 Parent(s): fd2ccd3

Upload index-DEHDscMv.js

Browse files
Files changed (1) hide show
  1. assets/index-DEHDscMv.js +1 -1
assets/index-DEHDscMv.js CHANGED
@@ -83,4 +83,4 @@ ${t}</tr>
83
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){const l=ba(t);if(l===null)return r;t=l;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+r+"</a>",i}image(t,n,r){const l=ba(t);if(l===null)return r;t=l;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${n}"`),i+=">",i}text(t){return t}}class gu{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class ft{constructor(t){K(this,"options");K(this,"renderer");K(this,"textRenderer");this.options=t||hn,this.options.renderer=this.options.renderer||new pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new gu}static parse(t,n){return new ft(n).parse(t)}static parseInline(t,n){return new ft(n).parseInline(t)}parse(t,n=!0){let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){r+=s||"";continue}}switch(i.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{const o=i;r+=this.renderer.heading(this.parseInline(o.tokens),o.depth,Am(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=i;r+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=i;let s="",u="";for(let m=0;m<o.header.length;m++)u+=this.renderer.tablecell(this.parseInline(o.header[m].tokens),{header:!0,align:o.align[m]});s+=this.renderer.tablerow(u);let a="";for(let m=0;m<o.rows.length;m++){const g=o.rows[m];u="";for(let p=0;p<g.length;p++)u+=this.renderer.tablecell(this.parseInline(g[p].tokens),{header:!1,align:o.align[p]});a+=this.renderer.tablerow(u)}r+=this.renderer.table(s,a);continue}case"blockquote":{const o=i,s=this.parse(o.tokens);r+=this.renderer.blockquote(s);continue}case"list":{const o=i,s=o.ordered,u=o.start,a=o.loose;let m="";for(let g=0;g<o.items.length;g++){const p=o.items[g],v=p.checked,x=p.task;let E="";if(p.task){const F=this.renderer.checkbox(!!v);a?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=F+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=F+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:F+" "}):E+=F+" "}E+=this.parse(p.tokens,a),m+=this.renderer.listitem(E,x,!!v)}r+=this.renderer.list(m,s,u);continue}case"html":{const o=i;r+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=i;r+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=i,s=o.tokens?this.parseInline(o.tokens):o.text;for(;l+1<t.length&&t[l+1].type==="text";)o=t[++l],s+=`
84
  `+(o.tokens?this.parseInline(o.tokens):o.text);r+=n?this.renderer.paragraph(s):s;continue}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(t,n){n=n||this.renderer;let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}switch(i.type){case"escape":{const o=i;r+=n.text(o.text);break}case"html":{const o=i;r+=n.html(o.text);break}case"link":{const o=i;r+=n.link(o.href,o.title,this.parseInline(o.tokens,n));break}case"image":{const o=i;r+=n.image(o.href,o.title,o.text);break}case"strong":{const o=i;r+=n.strong(this.parseInline(o.tokens,n));break}case"em":{const o=i;r+=n.em(this.parseInline(o.tokens,n));break}case"codespan":{const o=i;r+=n.codespan(o.text);break}case"br":{r+=n.br();break}case"del":{const o=i;r+=n.del(this.parseInline(o.tokens,n));break}case"text":{const o=i;r+=n.text(o.text);break}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}}class Ar{constructor(t){K(this,"options");this.options=t||hn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}}K(Ar,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var fn,ps,Md;class og{constructor(...t){Bu(this,fn);K(this,"defaults",cu());K(this,"options",this.setOptions);K(this,"parse",ol(this,fn,ps).call(this,ct.lex,ft.parse));K(this,"parseInline",ol(this,fn,ps).call(this,ct.lexInline,ft.parseInline));K(this,"Parser",ft);K(this,"Renderer",pi);K(this,"TextRenderer",gu);K(this,"Lexer",ct);K(this,"Tokenizer",fi);K(this,"Hooks",Ar);this.use(...t)}walkTokens(t,n){var l,i;let r=[];for(const o of t)switch(r=r.concat(n.call(this,o)),o.type){case"table":{const s=o;for(const u of s.header)r=r.concat(this.walkTokens(u.tokens,n));for(const u of s.rows)for(const a of u)r=r.concat(this.walkTokens(a.tokens,n));break}case"list":{const s=o;r=r.concat(this.walkTokens(s.items,n));break}default:{const s=o;(i=(l=this.defaults.extensions)==null?void 0:l.childTokens)!=null&&i[s.type]?this.defaults.extensions.childTokens[s.type].forEach(u=>{const a=s[u].flat(1/0);r=r.concat(this.walkTokens(a,n))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,n)))}}return r}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const l={...r};if(l.async=this.defaults.async||l.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const o=n.renderers[i.name];o?n.renderers[i.name]=function(...s){let u=i.renderer.apply(this,s);return u===!1&&(u=o.apply(this,s)),u}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=n[i.level];o?o.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),l.extensions=n),r.renderer){const i=this.defaults.renderer||new pi(this.defaults);for(const o in r.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.renderer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g||""}}l.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new fi(this.defaults);for(const o in r.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const s=o,u=r.tokenizer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Ar;for(const o in r.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.hooks[s],a=i[s];Ar.passThroughHooks.has(o)?i[s]=m=>{if(this.defaults.async)return Promise.resolve(u.call(i,m)).then(p=>a.call(i,p));const g=u.call(i,m);return a.call(i,g)}:i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,o=r.walkTokens;l.walkTokens=function(s){let u=[];return u.push(o.call(this,s)),i&&(u=u.concat(i.call(this,s))),u}}this.defaults={...this.defaults,...l}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return ct.lex(t,n??this.defaults)}parser(t,n){return ft.parse(t,n??this.defaults)}}fn=new WeakSet,ps=function(t,n){return(r,l)=>{const i={...l},o={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const s=ol(this,fn,Md).call(this,!!o.silent,!!o.async);if(typeof r>"u"||r===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(u=>t(u,o)).then(u=>o.hooks?o.hooks.processAllTokens(u):u).then(u=>o.walkTokens?Promise.all(this.walkTokens(u,o.walkTokens)).then(()=>u):u).then(u=>n(u,o)).then(u=>o.hooks?o.hooks.postprocess(u):u).catch(s);try{o.hooks&&(r=o.hooks.preprocess(r));let u=t(r,o);o.hooks&&(u=o.hooks.processAllTokens(u)),o.walkTokens&&this.walkTokens(u,o.walkTokens);let a=n(u,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(u){return s(u)}}},Md=function(t,n){return r=>{if(r.message+=`
85
  Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+De(r.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(r);throw r}};const cn=new og;function U(e,t){return cn.parse(e,t)}U.options=U.setOptions=function(e){return cn.setOptions(e),U.defaults=cn.defaults,Td(U.defaults),U};U.getDefaults=cu;U.defaults=hn;U.use=function(...e){return cn.use(...e),U.defaults=cn.defaults,Td(U.defaults),U};U.walkTokens=function(e,t){return cn.walkTokens(e,t)};U.parseInline=cn.parseInline;U.Parser=ft;U.parser=ft.parse;U.Renderer=pi;U.TextRenderer=gu;U.Lexer=ct;U.lexer=ct.lex;U.Tokenizer=fi;U.Hooks=Ar;U.parse=U;U.options;U.setOptions;U.use;U.walkTokens;U.parseInline;ft.parse;ct.lex;/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */const{entries:Dd,setPrototypeOf:rc,isFrozen:sg,getPrototypeOf:ug,getOwnPropertyDescriptor:ag}=Object;let{freeze:Te,seal:Xe,create:jd}=Object,{apply:hs,construct:ms}=typeof Reflect<"u"&&Reflect;Te||(Te=function(t){return t});Xe||(Xe=function(t){return t});hs||(hs=function(t,n,r){return t.apply(n,r)});ms||(ms=function(t,n){return new t(...n)});const Cl=Ue(Array.prototype.forEach),lc=Ue(Array.prototype.pop),fr=Ue(Array.prototype.push),Ul=Ue(String.prototype.toLowerCase),ho=Ue(String.prototype.toString),ic=Ue(String.prototype.match),dr=Ue(String.prototype.replace),cg=Ue(String.prototype.indexOf),fg=Ue(String.prototype.trim),qe=Ue(Object.prototype.hasOwnProperty),Se=Ue(RegExp.prototype.test),pr=dg(TypeError);function Ue(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return hs(e,t,r)}}function dg(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ms(e,n)}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ul;rc&&rc(e,null);let r=t.length;for(;r--;){let l=t[r];if(typeof l=="string"){const i=n(l);i!==l&&(sg(t)||(t[r]=i),l=i)}e[l]=!0}return e}function pg(e){for(let t=0;t<e.length;t++)qe(e,t)||(e[t]=null);return e}function Jt(e){const t=jd(null);for(const[n,r]of Dd(e))qe(e,n)&&(Array.isArray(r)?t[n]=pg(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Jt(r):t[n]=r);return t}function hr(e,t){for(;e!==null;){const r=ag(e,t);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}e=ug(e)}function n(){return null}return n}const oc=Te(["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"]),mo=Te(["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"]),go=Te(["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"]),hg=Te(["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"]),yo=Te(["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"]),mg=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sc=Te(["#text"]),uc=Te(["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"]),vo=Te(["accent-height","accumulate","additive","alignment-baseline","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","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","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","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","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"]),ac=Te(["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"]),Nl=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),gg=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),yg=Xe(/<%[\w\W]*|[\w\W]*%>/gm),vg=Xe(/\${[\w\W]*}/gm),kg=Xe(/^data-[\-\w.\u00B7-\uFFFF]/),wg=Xe(/^aria-[\-\w]+$/),Fd=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),xg=Xe(/^(?:\w+script|data):/i),Sg=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$d=Xe(/^html$/i),Eg=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var cc=Object.freeze({__proto__:null,MUSTACHE_EXPR:gg,ERB_EXPR:yg,TMPLIT_EXPR:vg,DATA_ATTR:kg,ARIA_ATTR:wg,IS_ALLOWED_URI:Fd,IS_SCRIPT_OR_DATA:xg,ATTR_WHITESPACE:Sg,DOCTYPE_NAME:$d,CUSTOM_ELEMENT:Eg});const mr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_g=function(){return typeof window>"u"?null:window},Tg=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(r=n.getAttribute(l));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function Ud(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_g();const t=P=>Ud(P);if(t.version="3.1.6",t.removed=[],!e||!e.document||e.document.nodeType!==mr.document)return t.isSupported=!1,t;let{document:n}=e;const r=n,l=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:s,Element:u,NodeFilter:a,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:g,DOMParser:p,trustedTypes:v}=e,x=u.prototype,E=hr(x,"cloneNode"),F=hr(x,"remove"),d=hr(x,"nextSibling"),c=hr(x,"childNodes"),h=hr(x,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let y,_="";const{implementation:N,createNodeIterator:R,createDocumentFragment:A,getElementsByTagName:Q}=n,{importNode:I}=r;let G={};t.isSupported=typeof Dd=="function"&&typeof h=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ht,ERB_EXPR:mt,TMPLIT_EXPR:mn,DATA_ATTR:Pi,ARIA_ATTR:qn,IS_SCRIPT_OR_DATA:Jn,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:z}=cc;let{IS_ALLOWED_URI:O}=cc,M=null;const re=D({},[...oc,...mo,...go,...yo,...sc]);let J=null;const lt=D({},[...uc,...vo,...ac,...Nl]);let Y=Object.seal(jd(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}})),Oe=null,Rt=null,yu=!0,zi=!0,vu=!1,ku=!0,gn=!1,Ii=!0,Xt=!1,Oi=!1,Mi=!1,yn=!1,tl=!1,nl=!1,wu=!0,xu=!1;const Hd="user-content-";let Di=!0,bn=!1,vn={},kn=null;const Su=D({},["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 Eu=null;const _u=D({},["audio","video","img","source","image","track"]);let ji=null;const Tu=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rl="http://www.w3.org/1998/Math/MathML",ll="http://www.w3.org/2000/svg",gt="http://www.w3.org/1999/xhtml";let wn=gt,Fi=!1,$i=null;const Bd=D({},[rl,ll,gt],ho);let er=null;const Wd=["application/xhtml+xml","text/html"],Vd="text/html";let ue=null,xn=null;const Qd=n.createElement("form"),Cu=function(f){return f instanceof RegExp||f instanceof Function},Ui=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xn&&xn===f)){if((!f||typeof f!="object")&&(f={}),f=Jt(f),er=Wd.indexOf(f.PARSER_MEDIA_TYPE)===-1?Vd:f.PARSER_MEDIA_TYPE,ue=er==="application/xhtml+xml"?ho:Ul,M=qe(f,"ALLOWED_TAGS")?D({},f.ALLOWED_TAGS,ue):re,J=qe(f,"ALLOWED_ATTR")?D({},f.ALLOWED_ATTR,ue):lt,$i=qe(f,"ALLOWED_NAMESPACES")?D({},f.ALLOWED_NAMESPACES,ho):Bd,ji=qe(f,"ADD_URI_SAFE_ATTR")?D(Jt(Tu),f.ADD_URI_SAFE_ATTR,ue):Tu,Eu=qe(f,"ADD_DATA_URI_TAGS")?D(Jt(_u),f.ADD_DATA_URI_TAGS,ue):_u,kn=qe(f,"FORBID_CONTENTS")?D({},f.FORBID_CONTENTS,ue):Su,Oe=qe(f,"FORBID_TAGS")?D({},f.FORBID_TAGS,ue):{},Rt=qe(f,"FORBID_ATTR")?D({},f.FORBID_ATTR,ue):{},vn=qe(f,"USE_PROFILES")?f.USE_PROFILES:!1,yu=f.ALLOW_ARIA_ATTR!==!1,zi=f.ALLOW_DATA_ATTR!==!1,vu=f.ALLOW_UNKNOWN_PROTOCOLS||!1,ku=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gn=f.SAFE_FOR_TEMPLATES||!1,Ii=f.SAFE_FOR_XML!==!1,Xt=f.WHOLE_DOCUMENT||!1,yn=f.RETURN_DOM||!1,tl=f.RETURN_DOM_FRAGMENT||!1,nl=f.RETURN_TRUSTED_TYPE||!1,Mi=f.FORCE_BODY||!1,wu=f.SANITIZE_DOM!==!1,xu=f.SANITIZE_NAMED_PROPS||!1,Di=f.KEEP_CONTENT!==!1,bn=f.IN_PLACE||!1,O=f.ALLOWED_URI_REGEXP||Fd,wn=f.NAMESPACE||gt,Y=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&Cu(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&Cu(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),gn&&(zi=!1),tl&&(yn=!0),vn&&(M=D({},sc),J=[],vn.html===!0&&(D(M,oc),D(J,uc)),vn.svg===!0&&(D(M,mo),D(J,vo),D(J,Nl)),vn.svgFilters===!0&&(D(M,go),D(J,vo),D(J,Nl)),vn.mathMl===!0&&(D(M,yo),D(J,ac),D(J,Nl))),f.ADD_TAGS&&(M===re&&(M=Jt(M)),D(M,f.ADD_TAGS,ue)),f.ADD_ATTR&&(J===lt&&(J=Jt(J)),D(J,f.ADD_ATTR,ue)),f.ADD_URI_SAFE_ATTR&&D(ji,f.ADD_URI_SAFE_ATTR,ue),f.FORBID_CONTENTS&&(kn===Su&&(kn=Jt(kn)),D(kn,f.FORBID_CONTENTS,ue)),Di&&(M["#text"]=!0),Xt&&D(M,["html","head","body"]),M.table&&(D(M,["tbody"]),delete Oe.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw pr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw pr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=f.TRUSTED_TYPES_POLICY,_=y.createHTML("")}else y===void 0&&(y=Tg(v,l)),y!==null&&typeof _=="string"&&(_=y.createHTML(""));Te&&Te(f),xn=f}},Nu=D({},["mi","mo","mn","ms","mtext"]),Ru=D({},["foreignobject","annotation-xml"]),Gd=D({},["title","style","font","a","script"]),Lu=D({},[...mo,...go,...hg]),Au=D({},[...yo,...mg]),Yd=function(f){let S=h(f);(!S||!S.tagName)&&(S={namespaceURI:wn,tagName:"template"});const L=Ul(f.tagName),W=Ul(S.tagName);return $i[f.namespaceURI]?f.namespaceURI===ll?S.namespaceURI===gt?L==="svg":S.namespaceURI===rl?L==="svg"&&(W==="annotation-xml"||Nu[W]):!!Lu[L]:f.namespaceURI===rl?S.namespaceURI===gt?L==="math":S.namespaceURI===ll?L==="math"&&Ru[W]:!!Au[L]:f.namespaceURI===gt?S.namespaceURI===ll&&!Ru[W]||S.namespaceURI===rl&&!Nu[W]?!1:!Au[L]&&(Gd[L]||!Lu[L]):!!(er==="application/xhtml+xml"&&$i[f.namespaceURI]):!1},it=function(f){fr(t.removed,{element:f});try{h(f).removeChild(f)}catch{F(f)}},il=function(f,S){try{fr(t.removed,{attribute:S.getAttributeNode(f),from:S})}catch{fr(t.removed,{attribute:null,from:S})}if(S.removeAttribute(f),f==="is"&&!J[f])if(yn||tl)try{it(S)}catch{}else try{S.setAttribute(f,"")}catch{}},Pu=function(f){let S=null,L=null;if(Mi)f="<remove></remove>"+f;else{const fe=ic(f,/^[\r\n\t ]+/);L=fe&&fe[0]}er==="application/xhtml+xml"&&wn===gt&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const W=y?y.createHTML(f):f;if(wn===gt)try{S=new p().parseFromString(W,er)}catch{}if(!S||!S.documentElement){S=N.createDocument(wn,"template",null);try{S.documentElement.innerHTML=Fi?_:W}catch{}}const ge=S.body||S.documentElement;return f&&L&&ge.insertBefore(n.createTextNode(L),ge.childNodes[0]||null),wn===gt?Q.call(S,Xt?"html":"body")[0]:Xt?S.documentElement:ge},zu=function(f){return R.call(f.ownerDocument||f,f,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Iu=function(f){return f instanceof g&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof m)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Ou=function(f){return typeof s=="function"&&f instanceof s},yt=function(f,S,L){G[f]&&Cl(G[f],W=>{W.call(t,S,L,xn)})},Mu=function(f){let S=null;if(yt("beforeSanitizeElements",f,null),Iu(f))return it(f),!0;const L=ue(f.nodeName);if(yt("uponSanitizeElement",f,{tagName:L,allowedTags:M}),f.hasChildNodes()&&!Ou(f.firstElementChild)&&Se(/<[/\w]/g,f.innerHTML)&&Se(/<[/\w]/g,f.textContent)||f.nodeType===mr.progressingInstruction||Ii&&f.nodeType===mr.comment&&Se(/<[/\w]/g,f.data))return it(f),!0;if(!M[L]||Oe[L]){if(!Oe[L]&&ju(L)&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L)))return!1;if(Di&&!kn[L]){const W=h(f)||f.parentNode,ge=c(f)||f.childNodes;if(ge&&W){const fe=ge.length;for(let Re=fe-1;Re>=0;--Re){const ot=E(ge[Re],!0);ot.__removalCount=(f.__removalCount||0)+1,W.insertBefore(ot,d(f))}}}return it(f),!0}return f instanceof u&&!Yd(f)||(L==="noscript"||L==="noembed"||L==="noframes")&&Se(/<\/no(script|embed|frames)/i,f.innerHTML)?(it(f),!0):(gn&&f.nodeType===mr.text&&(S=f.textContent,Cl([ht,mt,mn],W=>{S=dr(S,W," ")}),f.textContent!==S&&(fr(t.removed,{element:f.cloneNode()}),f.textContent=S)),yt("afterSanitizeElements",f,null),!1)},Du=function(f,S,L){if(wu&&(S==="id"||S==="name")&&(L in n||L in Qd))return!1;if(!(zi&&!Rt[S]&&Se(Pi,S))){if(!(yu&&Se(qn,S))){if(!J[S]||Rt[S]){if(!(ju(f)&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,f)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(f))&&(Y.attributeNameCheck instanceof RegExp&&Se(Y.attributeNameCheck,S)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(S))||S==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L))))return!1}else if(!ji[S]){if(!Se(O,dr(L,T,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&f!=="script"&&cg(L,"data:")===0&&Eu[f])){if(!(vu&&!Se(Jn,dr(L,T,"")))){if(L)return!1}}}}}}return!0},ju=function(f){return f!=="annotation-xml"&&ic(f,z)},Fu=function(f){yt("beforeSanitizeAttributes",f,null);const{attributes:S}=f;if(!S)return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J};let W=S.length;for(;W--;){const ge=S[W],{name:fe,namespaceURI:Re,value:ot}=ge,tr=ue(fe);let xe=fe==="value"?ot:fg(ot);if(L.attrName=tr,L.attrValue=xe,L.keepAttr=!0,L.forceKeepAttr=void 0,yt("uponSanitizeAttribute",f,L),xe=L.attrValue,Ii&&Se(/((--!?|])>)|<\/(style|title)/i,xe)){il(fe,f);continue}if(L.forceKeepAttr||(il(fe,f),!L.keepAttr))continue;if(!ku&&Se(/\/>/i,xe)){il(fe,f);continue}gn&&Cl([ht,mt,mn],Uu=>{xe=dr(xe,Uu," ")});const $u=ue(f.nodeName);if(Du($u,tr,xe)){if(xu&&(tr==="id"||tr==="name")&&(il(fe,f),xe=Hd+xe),y&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Re)switch(v.getAttributeType($u,tr)){case"TrustedHTML":{xe=y.createHTML(xe);break}case"TrustedScriptURL":{xe=y.createScriptURL(xe);break}}try{Re?f.setAttributeNS(Re,fe,xe):f.setAttribute(fe,xe),Iu(f)?it(f):lc(t.removed)}catch{}}}yt("afterSanitizeAttributes",f,null)},Kd=function P(f){let S=null;const L=zu(f);for(yt("beforeSanitizeShadowDOM",f,null);S=L.nextNode();)yt("uponSanitizeShadowNode",S,null),!Mu(S)&&(S.content instanceof i&&P(S.content),Fu(S));yt("afterSanitizeShadowDOM",f,null)};return t.sanitize=function(P){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,L=null,W=null,ge=null;if(Fi=!P,Fi&&(P="<!-->"),typeof P!="string"&&!Ou(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw pr("dirty is not a string, aborting")}else throw pr("toString is not a function");if(!t.isSupported)return P;if(Oi||Ui(f),t.removed=[],typeof P=="string"&&(bn=!1),bn){if(P.nodeName){const ot=ue(P.nodeName);if(!M[ot]||Oe[ot])throw pr("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof s)S=Pu("<!---->"),L=S.ownerDocument.importNode(P,!0),L.nodeType===mr.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?S=L:S.appendChild(L);else{if(!yn&&!gn&&!Xt&&P.indexOf("<")===-1)return y&&nl?y.createHTML(P):P;if(S=Pu(P),!S)return yn?null:nl?_:""}S&&Mi&&it(S.firstChild);const fe=zu(bn?P:S);for(;W=fe.nextNode();)Mu(W)||(W.content instanceof i&&Kd(W.content),Fu(W));if(bn)return P;if(yn){if(tl)for(ge=A.call(S.ownerDocument);S.firstChild;)ge.appendChild(S.firstChild);else ge=S;return(J.shadowroot||J.shadowrootmode)&&(ge=I.call(r,ge,!0)),ge}let Re=Xt?S.outerHTML:S.innerHTML;return Xt&&M["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&Se($d,S.ownerDocument.doctype.name)&&(Re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
86
- `+Re),gn&&Cl([ht,mt,mn],ot=>{Re=dr(Re,ot," ")}),y&&nl?y.createHTML(Re):Re},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ui(P),Oi=!0},t.clearConfig=function(){xn=null,Oi=!1},t.isValidAttribute=function(P,f,S){xn||Ui({});const L=ue(P),W=ue(f);return Du(L,W,S)},t.addHook=function(P,f){typeof f=="function"&&(G[P]=G[P]||[],fr(G[P],f))},t.removeHook=function(P){if(G[P])return lc(G[P])},t.removeHooks=function(P){G[P]&&(G[P]=[])},t.removeAllHooks=function(){G={}},t}var Cg=Ud();function Ng(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M12 8V4H8"}),k.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),k.jsx("path",{d:"M2 14h2"}),k.jsx("path",{d:"M20 14h2"}),k.jsx("path",{d:"M15 13v2"}),k.jsx("path",{d:"M9 13v2"})]})}function Rg(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),k.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Lg({messages:e}){const t=e.length===0;return k.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${t?"flex flex-col items-center justify-end":"space-y-4"}`,children:t?k.jsx("div",{className:"text-xl",children:"Ready!"}):e.map((n,r)=>k.jsx("div",{className:"flex items-start space-x-4",children:n.role==="assistant"?k.jsxs(k.Fragment,{children:[k.jsx(Ng,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),k.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:k.jsx("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:n.content.length>0?k.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Cg.sanitize(U.parse(n.content))}}):k.jsxs("span",{className:"h-6 flex items-center gap-1",children:[k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):k.jsxs(k.Fragment,{children:[k.jsx(Rg,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),k.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:k.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:n.content})})]})},`message-${r}`))})}function fc(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M5 12h14"}),k.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Ag(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),k.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"})]})}const Pg=!!window.ai,zg=120;function Ig(){const e=de.useRef(null),t=de.useRef(null),n=de.useRef(null),[r,l]=de.useState(null),[i,o]=de.useState(""),[s,u]=de.useState(!1),[a,m]=de.useState(""),[g,p]=de.useState([]),[v,x]=de.useState(null),[E,F]=de.useState(null);function d(y){p(_=>[..._,{role:"user",content:y}]),x(null),u(!0),m("")}de.useEffect(()=>{h()},[a]);function c(){e.current.postMessage({type:"interrupt"})}function h(){if(!t.current)return;const y=t.current;y.style.height="auto";const _=Math.min(Math.max(y.scrollHeight,24),200);y.style.height=`${_}px`}return de.useEffect(()=>{e.current||(e.current=new Worker(new URL("/assets/worker-GhnNjvp1.js",import.meta.url),{type:"module"}));const y=_=>{switch(_.data.status){case"loading":l("loading"),o(_.data.data);break;case"ready":l("ready");break;case"start":p(N=>[...N,{role:"assistant",content:""}]);break;case"update":{const{output:N,tps:R,numTokens:A}=_.data;x(R),F(A),p(Q=>{const I=[...Q],G=I.at(-1);return I[I.length-1]={...G,content:G.content+N},I})}break;case"complete":u(!1);break;case"error":alert(_.data.data);break}};return e.current.addEventListener("message",y),()=>{e.current.removeEventListener("message",y)}},[]),de.useEffect(()=>{g.filter(y=>y.role==="user").length!==0&&g.at(-1).role!=="assistant"&&(x(null),e.current.postMessage({type:"generate",data:g}))},[g,s]),de.useEffect(()=>{if(n.current&&s){const y=n.current;y.scrollHeight-y.scrollTop-y.clientHeight<zg&&(y.scrollTop=y.scrollHeight)}},[g,s]),Pg?k.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:[r===null&&g.length===0&&k.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[k.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[600px] text-center",children:[k.jsx("img",{src:"logo.png",width:"100%",height:"auto",className:"block max-w-[200px] m-2"}),k.jsx("h1",{className:"text-5xl font-bold mb-1",children:"Built-in AI chat demo"}),k.jsxs("h2",{className:"font-semibold",children:["Run ",k.jsx("a",{className:"underline",href:"https://deepmind.google/technologies/gemini/nano/",target:"_blank",rel:"noreferrer",children:"Gemini Nano"})," locally in your browser with ",k.jsx("a",{className:"underline",href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",children:"🤗 Transformers.js"})]})]}),k.jsxs("div",{className:"flex flex-col items-center px-4",children:[k.jsxs("div",{className:"max-w-[608px] m-4",children:["This demo uses Chrome's new ",k.jsx("a",{href:"https://developer.chrome.com/docs/ai/built-in",className:"underline",target:"_blank",rel:"noreferrer",children:"Built-in AI API"})," to run Gemini Nano, a 3.25 billion parameter LLM, locally in your browser. To use the model with Transformers.js, you can install our ",k.jsx("a",{href:"https://github.com/xenova/transformers.js/pull/840",className:"underline",target:"_blank",rel:"noreferrer",children:"experimental branch"})," from GitHub with:",k.jsx("span",{className:"markdown",children:k.jsx("pre",{children:k.jsx("code",{className:"language-javascript",children:"npm install xenova/transformers.js#chrome-built-in-ai"})})}),"Followed by:",k.jsx("span",{className:"font-mono"}),k.jsx("span",{className:"markdown",children:k.jsx("pre",{children:k.jsxs("code",{className:"language-javascript",children:["import { pipeline } from '@xenova/transformers';",k.jsx("br",{}),"const generator = await pipeline('text-generation', 'Xenova/gemini-nano');",k.jsx("br",{}),"const output = await generator('Tell me a joke!');"]})})}),"Since inference happens on-device, none of your conversations are sent to a server. You can even disconnect from the internet after the model has loaded. Try it out! 👇"]}),k.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:()=>{e.current.postMessage({type:"load"}),l("loading")},disabled:r!==null,children:"Load model"})]})]}),r==="loading"&&k.jsx(k.Fragment,{children:k.jsx("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:k.jsx("p",{className:"text-center mb-1",children:i})})}),r==="ready"&&k.jsxs("div",{ref:n,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[k.jsx(Lg,{messages:g}),k.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:v&&g.length>0&&k.jsxs(k.Fragment,{children:[!s&&k.jsxs("span",{children:["Generated ",E," tokens in ",(E/v).toFixed(2)," seconds ("]}),k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:v.toFixed(2)}),k.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!s&&k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"mr-1",children:")."}),k.jsx("span",{className:"underline cursor-pointer",onClick:()=>{e.current.postMessage({type:"reset"}),p([])},children:"Reset"})]})]})})]}),k.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:[k.jsx("textarea",{ref:t,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:"Type your message...",type:"text",rows:1,value:a,disabled:r!=="ready",title:r==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:y=>{a.length>0&&!s&&y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),d(a))},onInput:y=>m(y.target.value)}),s?k.jsx("div",{className:"cursor-pointer",onClick:c,children:k.jsx(Ag,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):a.length>0?k.jsx("div",{className:"cursor-pointer",onClick:()=>d(a),children:k.jsx(fc,{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"})}):k.jsx("div",{children:k.jsx(fc,{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"})})]}),k.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):k.jsxs("div",{className:"fixed flex flex-col justify-center items-center w-screen h-screen text-lg",children:[k.jsxs("p",{className:"text-4xl mb-4 text-center",children:["Your browser does not support ",k.jsx("br",{})," the ",k.jsx("a",{className:"underline",href:"https://developer.chrome.com/docs/ai/built-in",target:"_blank",rel:"noreferrer",children:"built-in AI API"})," (",k.jsx("code",{children:"window.ai"}),")"]}),k.jsxs("ul",{className:"list-disc list-outside pl-8 max-w-[650px]",children:[k.jsxs("li",{children:["Upgrade to Chrome (",k.jsx("a",{className:"underline",href:"https://www.google.com/chrome/dev/",target:"_blank",rel:"noreferrer",children:"Dev"})," / ",k.jsx("a",{className:"underline",href:"https://www.google.com/chrome/canary/",target:"_blank",rel:"noreferrer",children:"Canary"}),") version 127 or higher."]}),k.jsxs("li",{children:["Enable the following experimental flags:",k.jsxs("ul",{className:"list-disc list-outside pl-8",children:[k.jsxs("li",{children:["Set ",k.jsx("code",{className:"underline",children:"chrome://flags/#prompt-api-for-gemini-nano"}),' to "Enabled"']}),k.jsxs("li",{children:["Set ",k.jsx("code",{className:"underline",children:"chrome://flags/#optimization-guide-on-device-model"}),' to "Enabled BypassPrefRequirement"']}),k.jsxs("li",{children:["Go to ",k.jsx("code",{className:"underline",children:"chrome://components"}),' and click "Check for Update" on "Optimization Guide On Device Model"']})]})]})]}),k.jsxs("span",{className:"text-base mt-2",children:["Learn more ",k.jsx("a",{className:"underline",href:"https://developer.chrome.com/docs/ai/built-in",target:"_blank",rel:"noreferrer",children:"here"}),"."]})]})}ko.createRoot(document.getElementById("root")).render(k.jsx(hp.StrictMode,{children:k.jsx(Ig,{})}));
 
83
  `}strong(t){return`<strong>${t}</strong>`}em(t){return`<em>${t}</em>`}codespan(t){return`<code>${t}</code>`}br(){return"<br>"}del(t){return`<del>${t}</del>`}link(t,n,r){const l=ba(t);if(l===null)return r;t=l;let i='<a href="'+t+'"';return n&&(i+=' title="'+n+'"'),i+=">"+r+"</a>",i}image(t,n,r){const l=ba(t);if(l===null)return r;t=l;let i=`<img src="${t}" alt="${r}"`;return n&&(i+=` title="${n}"`),i+=">",i}text(t){return t}}class gu{strong(t){return t}em(t){return t}codespan(t){return t}del(t){return t}html(t){return t}text(t){return t}link(t,n,r){return""+r}image(t,n,r){return""+r}br(){return""}}class ft{constructor(t){K(this,"options");K(this,"renderer");K(this,"textRenderer");this.options=t||hn,this.options.renderer=this.options.renderer||new pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new gu}static parse(t,n){return new ft(n).parse(t)}static parseInline(t,n){return new ft(n).parseInline(t)}parse(t,n=!0){let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=i,s=this.options.extensions.renderers[o.type].call({parser:this},o);if(s!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(o.type)){r+=s||"";continue}}switch(i.type){case"space":continue;case"hr":{r+=this.renderer.hr();continue}case"heading":{const o=i;r+=this.renderer.heading(this.parseInline(o.tokens),o.depth,Am(this.parseInline(o.tokens,this.textRenderer)));continue}case"code":{const o=i;r+=this.renderer.code(o.text,o.lang,!!o.escaped);continue}case"table":{const o=i;let s="",u="";for(let m=0;m<o.header.length;m++)u+=this.renderer.tablecell(this.parseInline(o.header[m].tokens),{header:!0,align:o.align[m]});s+=this.renderer.tablerow(u);let a="";for(let m=0;m<o.rows.length;m++){const g=o.rows[m];u="";for(let p=0;p<g.length;p++)u+=this.renderer.tablecell(this.parseInline(g[p].tokens),{header:!1,align:o.align[p]});a+=this.renderer.tablerow(u)}r+=this.renderer.table(s,a);continue}case"blockquote":{const o=i,s=this.parse(o.tokens);r+=this.renderer.blockquote(s);continue}case"list":{const o=i,s=o.ordered,u=o.start,a=o.loose;let m="";for(let g=0;g<o.items.length;g++){const p=o.items[g],v=p.checked,x=p.task;let E="";if(p.task){const F=this.renderer.checkbox(!!v);a?p.tokens.length>0&&p.tokens[0].type==="paragraph"?(p.tokens[0].text=F+" "+p.tokens[0].text,p.tokens[0].tokens&&p.tokens[0].tokens.length>0&&p.tokens[0].tokens[0].type==="text"&&(p.tokens[0].tokens[0].text=F+" "+p.tokens[0].tokens[0].text)):p.tokens.unshift({type:"text",text:F+" "}):E+=F+" "}E+=this.parse(p.tokens,a),m+=this.renderer.listitem(E,x,!!v)}r+=this.renderer.list(m,s,u);continue}case"html":{const o=i;r+=this.renderer.html(o.text,o.block);continue}case"paragraph":{const o=i;r+=this.renderer.paragraph(this.parseInline(o.tokens));continue}case"text":{let o=i,s=o.tokens?this.parseInline(o.tokens):o.text;for(;l+1<t.length&&t[l+1].type==="text";)o=t[++l],s+=`
84
  `+(o.tokens?this.parseInline(o.tokens):o.text);r+=n?this.renderer.paragraph(s):s;continue}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}parseInline(t,n){n=n||this.renderer;let r="";for(let l=0;l<t.length;l++){const i=t[l];if(this.options.extensions&&this.options.extensions.renderers&&this.options.extensions.renderers[i.type]){const o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){r+=o||"";continue}}switch(i.type){case"escape":{const o=i;r+=n.text(o.text);break}case"html":{const o=i;r+=n.html(o.text);break}case"link":{const o=i;r+=n.link(o.href,o.title,this.parseInline(o.tokens,n));break}case"image":{const o=i;r+=n.image(o.href,o.title,o.text);break}case"strong":{const o=i;r+=n.strong(this.parseInline(o.tokens,n));break}case"em":{const o=i;r+=n.em(this.parseInline(o.tokens,n));break}case"codespan":{const o=i;r+=n.codespan(o.text);break}case"br":{r+=n.br();break}case"del":{const o=i;r+=n.del(this.parseInline(o.tokens,n));break}case"text":{const o=i;r+=n.text(o.text);break}default:{const o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return r}}class Ar{constructor(t){K(this,"options");this.options=t||hn}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}}K(Ar,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens"]));var fn,ps,Md;class og{constructor(...t){Bu(this,fn);K(this,"defaults",cu());K(this,"options",this.setOptions);K(this,"parse",ol(this,fn,ps).call(this,ct.lex,ft.parse));K(this,"parseInline",ol(this,fn,ps).call(this,ct.lexInline,ft.parseInline));K(this,"Parser",ft);K(this,"Renderer",pi);K(this,"TextRenderer",gu);K(this,"Lexer",ct);K(this,"Tokenizer",fi);K(this,"Hooks",Ar);this.use(...t)}walkTokens(t,n){var l,i;let r=[];for(const o of t)switch(r=r.concat(n.call(this,o)),o.type){case"table":{const s=o;for(const u of s.header)r=r.concat(this.walkTokens(u.tokens,n));for(const u of s.rows)for(const a of u)r=r.concat(this.walkTokens(a.tokens,n));break}case"list":{const s=o;r=r.concat(this.walkTokens(s.items,n));break}default:{const s=o;(i=(l=this.defaults.extensions)==null?void 0:l.childTokens)!=null&&i[s.type]?this.defaults.extensions.childTokens[s.type].forEach(u=>{const a=s[u].flat(1/0);r=r.concat(this.walkTokens(a,n))}):s.tokens&&(r=r.concat(this.walkTokens(s.tokens,n)))}}return r}use(...t){const n=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(r=>{const l={...r};if(l.async=this.defaults.async||l.async||!1,r.extensions&&(r.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const o=n.renderers[i.name];o?n.renderers[i.name]=function(...s){let u=i.renderer.apply(this,s);return u===!1&&(u=o.apply(this,s)),u}:n.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const o=n[i.level];o?o.unshift(i.tokenizer):n[i.level]=[i.tokenizer],i.start&&(i.level==="block"?n.startBlock?n.startBlock.push(i.start):n.startBlock=[i.start]:i.level==="inline"&&(n.startInline?n.startInline.push(i.start):n.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(n.childTokens[i.name]=i.childTokens)}),l.extensions=n),r.renderer){const i=this.defaults.renderer||new pi(this.defaults);for(const o in r.renderer){if(!(o in i))throw new Error(`renderer '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.renderer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g||""}}l.renderer=i}if(r.tokenizer){const i=this.defaults.tokenizer||new fi(this.defaults);for(const o in r.tokenizer){if(!(o in i))throw new Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;const s=o,u=r.tokenizer[s],a=i[s];i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.tokenizer=i}if(r.hooks){const i=this.defaults.hooks||new Ar;for(const o in r.hooks){if(!(o in i))throw new Error(`hook '${o}' does not exist`);if(o==="options")continue;const s=o,u=r.hooks[s],a=i[s];Ar.passThroughHooks.has(o)?i[s]=m=>{if(this.defaults.async)return Promise.resolve(u.call(i,m)).then(p=>a.call(i,p));const g=u.call(i,m);return a.call(i,g)}:i[s]=(...m)=>{let g=u.apply(i,m);return g===!1&&(g=a.apply(i,m)),g}}l.hooks=i}if(r.walkTokens){const i=this.defaults.walkTokens,o=r.walkTokens;l.walkTokens=function(s){let u=[];return u.push(o.call(this,s)),i&&(u=u.concat(i.call(this,s))),u}}this.defaults={...this.defaults,...l}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,n){return ct.lex(t,n??this.defaults)}parser(t,n){return ft.parse(t,n??this.defaults)}}fn=new WeakSet,ps=function(t,n){return(r,l)=>{const i={...l},o={...this.defaults,...i};this.defaults.async===!0&&i.async===!1&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);const s=ol(this,fn,Md).call(this,!!o.silent,!!o.async);if(typeof r>"u"||r===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(u=>t(u,o)).then(u=>o.hooks?o.hooks.processAllTokens(u):u).then(u=>o.walkTokens?Promise.all(this.walkTokens(u,o.walkTokens)).then(()=>u):u).then(u=>n(u,o)).then(u=>o.hooks?o.hooks.postprocess(u):u).catch(s);try{o.hooks&&(r=o.hooks.preprocess(r));let u=t(r,o);o.hooks&&(u=o.hooks.processAllTokens(u)),o.walkTokens&&this.walkTokens(u,o.walkTokens);let a=n(u,o);return o.hooks&&(a=o.hooks.postprocess(a)),a}catch(u){return s(u)}}},Md=function(t,n){return r=>{if(r.message+=`
85
  Please report this to https://github.com/markedjs/marked.`,t){const l="<p>An error occurred:</p><pre>"+De(r.message+"",!0)+"</pre>";return n?Promise.resolve(l):l}if(n)return Promise.reject(r);throw r}};const cn=new og;function U(e,t){return cn.parse(e,t)}U.options=U.setOptions=function(e){return cn.setOptions(e),U.defaults=cn.defaults,Td(U.defaults),U};U.getDefaults=cu;U.defaults=hn;U.use=function(...e){return cn.use(...e),U.defaults=cn.defaults,Td(U.defaults),U};U.walkTokens=function(e,t){return cn.walkTokens(e,t)};U.parseInline=cn.parseInline;U.Parser=ft;U.parser=ft.parse;U.Renderer=pi;U.TextRenderer=gu;U.Lexer=ct;U.lexer=ct.lex;U.Tokenizer=fi;U.Hooks=Ar;U.parse=U;U.options;U.setOptions;U.use;U.walkTokens;U.parseInline;ft.parse;ct.lex;/*! @license DOMPurify 3.1.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.1.6/LICENSE */const{entries:Dd,setPrototypeOf:rc,isFrozen:sg,getPrototypeOf:ug,getOwnPropertyDescriptor:ag}=Object;let{freeze:Te,seal:Xe,create:jd}=Object,{apply:hs,construct:ms}=typeof Reflect<"u"&&Reflect;Te||(Te=function(t){return t});Xe||(Xe=function(t){return t});hs||(hs=function(t,n,r){return t.apply(n,r)});ms||(ms=function(t,n){return new t(...n)});const Cl=Ue(Array.prototype.forEach),lc=Ue(Array.prototype.pop),fr=Ue(Array.prototype.push),Ul=Ue(String.prototype.toLowerCase),ho=Ue(String.prototype.toString),ic=Ue(String.prototype.match),dr=Ue(String.prototype.replace),cg=Ue(String.prototype.indexOf),fg=Ue(String.prototype.trim),qe=Ue(Object.prototype.hasOwnProperty),Se=Ue(RegExp.prototype.test),pr=dg(TypeError);function Ue(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return hs(e,t,r)}}function dg(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return ms(e,n)}}function D(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ul;rc&&rc(e,null);let r=t.length;for(;r--;){let l=t[r];if(typeof l=="string"){const i=n(l);i!==l&&(sg(t)||(t[r]=i),l=i)}e[l]=!0}return e}function pg(e){for(let t=0;t<e.length;t++)qe(e,t)||(e[t]=null);return e}function Jt(e){const t=jd(null);for(const[n,r]of Dd(e))qe(e,n)&&(Array.isArray(r)?t[n]=pg(r):r&&typeof r=="object"&&r.constructor===Object?t[n]=Jt(r):t[n]=r);return t}function hr(e,t){for(;e!==null;){const r=ag(e,t);if(r){if(r.get)return Ue(r.get);if(typeof r.value=="function")return Ue(r.value)}e=ug(e)}function n(){return null}return n}const oc=Te(["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"]),mo=Te(["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"]),go=Te(["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"]),hg=Te(["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"]),yo=Te(["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"]),mg=Te(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),sc=Te(["#text"]),uc=Te(["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"]),vo=Te(["accent-height","accumulate","additive","alignment-baseline","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","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","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","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","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"]),ac=Te(["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"]),Nl=Te(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),gg=Xe(/\{\{[\w\W]*|[\w\W]*\}\}/gm),yg=Xe(/<%[\w\W]*|[\w\W]*%>/gm),vg=Xe(/\${[\w\W]*}/gm),kg=Xe(/^data-[\-\w.\u00B7-\uFFFF]/),wg=Xe(/^aria-[\-\w]+$/),Fd=Xe(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),xg=Xe(/^(?:\w+script|data):/i),Sg=Xe(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$d=Xe(/^html$/i),Eg=Xe(/^[a-z][.\w]*(-[.\w]+)+$/i);var cc=Object.freeze({__proto__:null,MUSTACHE_EXPR:gg,ERB_EXPR:yg,TMPLIT_EXPR:vg,DATA_ATTR:kg,ARIA_ATTR:wg,IS_ALLOWED_URI:Fd,IS_SCRIPT_OR_DATA:xg,ATTR_WHITESPACE:Sg,DOCTYPE_NAME:$d,CUSTOM_ELEMENT:Eg});const mr={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_g=function(){return typeof window>"u"?null:window},Tg=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const l="data-tt-policy-suffix";n&&n.hasAttribute(l)&&(r=n.getAttribute(l));const i="dompurify"+(r?"#"+r:"");try{return t.createPolicy(i,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}};function Ud(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_g();const t=P=>Ud(P);if(t.version="3.1.6",t.removed=[],!e||!e.document||e.document.nodeType!==mr.document)return t.isSupported=!1,t;let{document:n}=e;const r=n,l=r.currentScript,{DocumentFragment:i,HTMLTemplateElement:o,Node:s,Element:u,NodeFilter:a,NamedNodeMap:m=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:g,DOMParser:p,trustedTypes:v}=e,x=u.prototype,E=hr(x,"cloneNode"),F=hr(x,"remove"),d=hr(x,"nextSibling"),c=hr(x,"childNodes"),h=hr(x,"parentNode");if(typeof o=="function"){const P=n.createElement("template");P.content&&P.content.ownerDocument&&(n=P.content.ownerDocument)}let y,_="";const{implementation:N,createNodeIterator:R,createDocumentFragment:A,getElementsByTagName:Q}=n,{importNode:I}=r;let G={};t.isSupported=typeof Dd=="function"&&typeof h=="function"&&N&&N.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ht,ERB_EXPR:mt,TMPLIT_EXPR:mn,DATA_ATTR:Pi,ARIA_ATTR:qn,IS_SCRIPT_OR_DATA:Jn,ATTR_WHITESPACE:T,CUSTOM_ELEMENT:z}=cc;let{IS_ALLOWED_URI:O}=cc,M=null;const re=D({},[...oc,...mo,...go,...yo,...sc]);let J=null;const lt=D({},[...uc,...vo,...ac,...Nl]);let Y=Object.seal(jd(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}})),Oe=null,Rt=null,yu=!0,zi=!0,vu=!1,ku=!0,gn=!1,Ii=!0,Xt=!1,Oi=!1,Mi=!1,yn=!1,tl=!1,nl=!1,wu=!0,xu=!1;const Hd="user-content-";let Di=!0,bn=!1,vn={},kn=null;const Su=D({},["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 Eu=null;const _u=D({},["audio","video","img","source","image","track"]);let ji=null;const Tu=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),rl="http://www.w3.org/1998/Math/MathML",ll="http://www.w3.org/2000/svg",gt="http://www.w3.org/1999/xhtml";let wn=gt,Fi=!1,$i=null;const Bd=D({},[rl,ll,gt],ho);let er=null;const Wd=["application/xhtml+xml","text/html"],Vd="text/html";let ue=null,xn=null;const Qd=n.createElement("form"),Cu=function(f){return f instanceof RegExp||f instanceof Function},Ui=function(){let f=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(xn&&xn===f)){if((!f||typeof f!="object")&&(f={}),f=Jt(f),er=Wd.indexOf(f.PARSER_MEDIA_TYPE)===-1?Vd:f.PARSER_MEDIA_TYPE,ue=er==="application/xhtml+xml"?ho:Ul,M=qe(f,"ALLOWED_TAGS")?D({},f.ALLOWED_TAGS,ue):re,J=qe(f,"ALLOWED_ATTR")?D({},f.ALLOWED_ATTR,ue):lt,$i=qe(f,"ALLOWED_NAMESPACES")?D({},f.ALLOWED_NAMESPACES,ho):Bd,ji=qe(f,"ADD_URI_SAFE_ATTR")?D(Jt(Tu),f.ADD_URI_SAFE_ATTR,ue):Tu,Eu=qe(f,"ADD_DATA_URI_TAGS")?D(Jt(_u),f.ADD_DATA_URI_TAGS,ue):_u,kn=qe(f,"FORBID_CONTENTS")?D({},f.FORBID_CONTENTS,ue):Su,Oe=qe(f,"FORBID_TAGS")?D({},f.FORBID_TAGS,ue):{},Rt=qe(f,"FORBID_ATTR")?D({},f.FORBID_ATTR,ue):{},vn=qe(f,"USE_PROFILES")?f.USE_PROFILES:!1,yu=f.ALLOW_ARIA_ATTR!==!1,zi=f.ALLOW_DATA_ATTR!==!1,vu=f.ALLOW_UNKNOWN_PROTOCOLS||!1,ku=f.ALLOW_SELF_CLOSE_IN_ATTR!==!1,gn=f.SAFE_FOR_TEMPLATES||!1,Ii=f.SAFE_FOR_XML!==!1,Xt=f.WHOLE_DOCUMENT||!1,yn=f.RETURN_DOM||!1,tl=f.RETURN_DOM_FRAGMENT||!1,nl=f.RETURN_TRUSTED_TYPE||!1,Mi=f.FORCE_BODY||!1,wu=f.SANITIZE_DOM!==!1,xu=f.SANITIZE_NAMED_PROPS||!1,Di=f.KEEP_CONTENT!==!1,bn=f.IN_PLACE||!1,O=f.ALLOWED_URI_REGEXP||Fd,wn=f.NAMESPACE||gt,Y=f.CUSTOM_ELEMENT_HANDLING||{},f.CUSTOM_ELEMENT_HANDLING&&Cu(f.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Y.tagNameCheck=f.CUSTOM_ELEMENT_HANDLING.tagNameCheck),f.CUSTOM_ELEMENT_HANDLING&&Cu(f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Y.attributeNameCheck=f.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),f.CUSTOM_ELEMENT_HANDLING&&typeof f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Y.allowCustomizedBuiltInElements=f.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),gn&&(zi=!1),tl&&(yn=!0),vn&&(M=D({},sc),J=[],vn.html===!0&&(D(M,oc),D(J,uc)),vn.svg===!0&&(D(M,mo),D(J,vo),D(J,Nl)),vn.svgFilters===!0&&(D(M,go),D(J,vo),D(J,Nl)),vn.mathMl===!0&&(D(M,yo),D(J,ac),D(J,Nl))),f.ADD_TAGS&&(M===re&&(M=Jt(M)),D(M,f.ADD_TAGS,ue)),f.ADD_ATTR&&(J===lt&&(J=Jt(J)),D(J,f.ADD_ATTR,ue)),f.ADD_URI_SAFE_ATTR&&D(ji,f.ADD_URI_SAFE_ATTR,ue),f.FORBID_CONTENTS&&(kn===Su&&(kn=Jt(kn)),D(kn,f.FORBID_CONTENTS,ue)),Di&&(M["#text"]=!0),Xt&&D(M,["html","head","body"]),M.table&&(D(M,["tbody"]),delete Oe.tbody),f.TRUSTED_TYPES_POLICY){if(typeof f.TRUSTED_TYPES_POLICY.createHTML!="function")throw pr('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof f.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw pr('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=f.TRUSTED_TYPES_POLICY,_=y.createHTML("")}else y===void 0&&(y=Tg(v,l)),y!==null&&typeof _=="string"&&(_=y.createHTML(""));Te&&Te(f),xn=f}},Nu=D({},["mi","mo","mn","ms","mtext"]),Ru=D({},["foreignobject","annotation-xml"]),Gd=D({},["title","style","font","a","script"]),Lu=D({},[...mo,...go,...hg]),Au=D({},[...yo,...mg]),Yd=function(f){let S=h(f);(!S||!S.tagName)&&(S={namespaceURI:wn,tagName:"template"});const L=Ul(f.tagName),W=Ul(S.tagName);return $i[f.namespaceURI]?f.namespaceURI===ll?S.namespaceURI===gt?L==="svg":S.namespaceURI===rl?L==="svg"&&(W==="annotation-xml"||Nu[W]):!!Lu[L]:f.namespaceURI===rl?S.namespaceURI===gt?L==="math":S.namespaceURI===ll?L==="math"&&Ru[W]:!!Au[L]:f.namespaceURI===gt?S.namespaceURI===ll&&!Ru[W]||S.namespaceURI===rl&&!Nu[W]?!1:!Au[L]&&(Gd[L]||!Lu[L]):!!(er==="application/xhtml+xml"&&$i[f.namespaceURI]):!1},it=function(f){fr(t.removed,{element:f});try{h(f).removeChild(f)}catch{F(f)}},il=function(f,S){try{fr(t.removed,{attribute:S.getAttributeNode(f),from:S})}catch{fr(t.removed,{attribute:null,from:S})}if(S.removeAttribute(f),f==="is"&&!J[f])if(yn||tl)try{it(S)}catch{}else try{S.setAttribute(f,"")}catch{}},Pu=function(f){let S=null,L=null;if(Mi)f="<remove></remove>"+f;else{const fe=ic(f,/^[\r\n\t ]+/);L=fe&&fe[0]}er==="application/xhtml+xml"&&wn===gt&&(f='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+f+"</body></html>");const W=y?y.createHTML(f):f;if(wn===gt)try{S=new p().parseFromString(W,er)}catch{}if(!S||!S.documentElement){S=N.createDocument(wn,"template",null);try{S.documentElement.innerHTML=Fi?_:W}catch{}}const ge=S.body||S.documentElement;return f&&L&&ge.insertBefore(n.createTextNode(L),ge.childNodes[0]||null),wn===gt?Q.call(S,Xt?"html":"body")[0]:Xt?S.documentElement:ge},zu=function(f){return R.call(f.ownerDocument||f,f,a.SHOW_ELEMENT|a.SHOW_COMMENT|a.SHOW_TEXT|a.SHOW_PROCESSING_INSTRUCTION|a.SHOW_CDATA_SECTION,null)},Iu=function(f){return f instanceof g&&(typeof f.nodeName!="string"||typeof f.textContent!="string"||typeof f.removeChild!="function"||!(f.attributes instanceof m)||typeof f.removeAttribute!="function"||typeof f.setAttribute!="function"||typeof f.namespaceURI!="string"||typeof f.insertBefore!="function"||typeof f.hasChildNodes!="function")},Ou=function(f){return typeof s=="function"&&f instanceof s},yt=function(f,S,L){G[f]&&Cl(G[f],W=>{W.call(t,S,L,xn)})},Mu=function(f){let S=null;if(yt("beforeSanitizeElements",f,null),Iu(f))return it(f),!0;const L=ue(f.nodeName);if(yt("uponSanitizeElement",f,{tagName:L,allowedTags:M}),f.hasChildNodes()&&!Ou(f.firstElementChild)&&Se(/<[/\w]/g,f.innerHTML)&&Se(/<[/\w]/g,f.textContent)||f.nodeType===mr.progressingInstruction||Ii&&f.nodeType===mr.comment&&Se(/<[/\w]/g,f.data))return it(f),!0;if(!M[L]||Oe[L]){if(!Oe[L]&&ju(L)&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L)))return!1;if(Di&&!kn[L]){const W=h(f)||f.parentNode,ge=c(f)||f.childNodes;if(ge&&W){const fe=ge.length;for(let Re=fe-1;Re>=0;--Re){const ot=E(ge[Re],!0);ot.__removalCount=(f.__removalCount||0)+1,W.insertBefore(ot,d(f))}}}return it(f),!0}return f instanceof u&&!Yd(f)||(L==="noscript"||L==="noembed"||L==="noframes")&&Se(/<\/no(script|embed|frames)/i,f.innerHTML)?(it(f),!0):(gn&&f.nodeType===mr.text&&(S=f.textContent,Cl([ht,mt,mn],W=>{S=dr(S,W," ")}),f.textContent!==S&&(fr(t.removed,{element:f.cloneNode()}),f.textContent=S)),yt("afterSanitizeElements",f,null),!1)},Du=function(f,S,L){if(wu&&(S==="id"||S==="name")&&(L in n||L in Qd))return!1;if(!(zi&&!Rt[S]&&Se(Pi,S))){if(!(yu&&Se(qn,S))){if(!J[S]||Rt[S]){if(!(ju(f)&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,f)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(f))&&(Y.attributeNameCheck instanceof RegExp&&Se(Y.attributeNameCheck,S)||Y.attributeNameCheck instanceof Function&&Y.attributeNameCheck(S))||S==="is"&&Y.allowCustomizedBuiltInElements&&(Y.tagNameCheck instanceof RegExp&&Se(Y.tagNameCheck,L)||Y.tagNameCheck instanceof Function&&Y.tagNameCheck(L))))return!1}else if(!ji[S]){if(!Se(O,dr(L,T,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&f!=="script"&&cg(L,"data:")===0&&Eu[f])){if(!(vu&&!Se(Jn,dr(L,T,"")))){if(L)return!1}}}}}}return!0},ju=function(f){return f!=="annotation-xml"&&ic(f,z)},Fu=function(f){yt("beforeSanitizeAttributes",f,null);const{attributes:S}=f;if(!S)return;const L={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:J};let W=S.length;for(;W--;){const ge=S[W],{name:fe,namespaceURI:Re,value:ot}=ge,tr=ue(fe);let xe=fe==="value"?ot:fg(ot);if(L.attrName=tr,L.attrValue=xe,L.keepAttr=!0,L.forceKeepAttr=void 0,yt("uponSanitizeAttribute",f,L),xe=L.attrValue,Ii&&Se(/((--!?|])>)|<\/(style|title)/i,xe)){il(fe,f);continue}if(L.forceKeepAttr||(il(fe,f),!L.keepAttr))continue;if(!ku&&Se(/\/>/i,xe)){il(fe,f);continue}gn&&Cl([ht,mt,mn],Uu=>{xe=dr(xe,Uu," ")});const $u=ue(f.nodeName);if(Du($u,tr,xe)){if(xu&&(tr==="id"||tr==="name")&&(il(fe,f),xe=Hd+xe),y&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Re)switch(v.getAttributeType($u,tr)){case"TrustedHTML":{xe=y.createHTML(xe);break}case"TrustedScriptURL":{xe=y.createScriptURL(xe);break}}try{Re?f.setAttributeNS(Re,fe,xe):f.setAttribute(fe,xe),Iu(f)?it(f):lc(t.removed)}catch{}}}yt("afterSanitizeAttributes",f,null)},Kd=function P(f){let S=null;const L=zu(f);for(yt("beforeSanitizeShadowDOM",f,null);S=L.nextNode();)yt("uponSanitizeShadowNode",S,null),!Mu(S)&&(S.content instanceof i&&P(S.content),Fu(S));yt("afterSanitizeShadowDOM",f,null)};return t.sanitize=function(P){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,L=null,W=null,ge=null;if(Fi=!P,Fi&&(P="<!-->"),typeof P!="string"&&!Ou(P))if(typeof P.toString=="function"){if(P=P.toString(),typeof P!="string")throw pr("dirty is not a string, aborting")}else throw pr("toString is not a function");if(!t.isSupported)return P;if(Oi||Ui(f),t.removed=[],typeof P=="string"&&(bn=!1),bn){if(P.nodeName){const ot=ue(P.nodeName);if(!M[ot]||Oe[ot])throw pr("root node is forbidden and cannot be sanitized in-place")}}else if(P instanceof s)S=Pu("<!---->"),L=S.ownerDocument.importNode(P,!0),L.nodeType===mr.element&&L.nodeName==="BODY"||L.nodeName==="HTML"?S=L:S.appendChild(L);else{if(!yn&&!gn&&!Xt&&P.indexOf("<")===-1)return y&&nl?y.createHTML(P):P;if(S=Pu(P),!S)return yn?null:nl?_:""}S&&Mi&&it(S.firstChild);const fe=zu(bn?P:S);for(;W=fe.nextNode();)Mu(W)||(W.content instanceof i&&Kd(W.content),Fu(W));if(bn)return P;if(yn){if(tl)for(ge=A.call(S.ownerDocument);S.firstChild;)ge.appendChild(S.firstChild);else ge=S;return(J.shadowroot||J.shadowrootmode)&&(ge=I.call(r,ge,!0)),ge}let Re=Xt?S.outerHTML:S.innerHTML;return Xt&&M["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&Se($d,S.ownerDocument.doctype.name)&&(Re="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
86
+ `+Re),gn&&Cl([ht,mt,mn],ot=>{Re=dr(Re,ot," ")}),y&&nl?y.createHTML(Re):Re},t.setConfig=function(){let P=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ui(P),Oi=!0},t.clearConfig=function(){xn=null,Oi=!1},t.isValidAttribute=function(P,f,S){xn||Ui({});const L=ue(P),W=ue(f);return Du(L,W,S)},t.addHook=function(P,f){typeof f=="function"&&(G[P]=G[P]||[],fr(G[P],f))},t.removeHook=function(P){if(G[P])return lc(G[P])},t.removeHooks=function(P){G[P]&&(G[P]=[])},t.removeAllHooks=function(){G={}},t}var Cg=Ud();function Ng(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M12 8V4H8"}),k.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),k.jsx("path",{d:"M2 14h2"}),k.jsx("path",{d:"M20 14h2"}),k.jsx("path",{d:"M15 13v2"}),k.jsx("path",{d:"M9 13v2"})]})}function Rg(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),k.jsx("circle",{cx:"12",cy:"7",r:"4"})]})}function Lg({messages:e}){const t=e.length===0;return k.jsx("div",{className:`flex-1 p-6 max-w-[960px] w-full ${t?"flex flex-col items-center justify-end":"space-y-4"}`,children:t?k.jsx("div",{className:"text-xl",children:"Ready!"}):e.map((n,r)=>k.jsx("div",{className:"flex items-start space-x-4",children:n.role==="assistant"?k.jsxs(k.Fragment,{children:[k.jsx(Ng,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),k.jsx("div",{className:"bg-gray-200 dark:bg-gray-700 rounded-lg p-4",children:k.jsx("p",{className:"min-h-6 text-gray-800 dark:text-gray-200 overflow-wrap-anywhere",children:n.content.length>0?k.jsx("span",{className:"markdown",dangerouslySetInnerHTML:{__html:Cg.sanitize(U.parse(n.content))}}):k.jsxs("span",{className:"h-6 flex items-center gap-1",children:[k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse"}),k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-200"}),k.jsx("span",{className:"w-2.5 h-2.5 bg-gray-600 dark:bg-gray-300 rounded-full animate-pulse animation-delay-400"})]})})})]}):k.jsxs(k.Fragment,{children:[k.jsx(Rg,{className:"h-6 w-6 min-h-6 min-w-6 my-3 text-gray-500 dark:text-gray-300"}),k.jsx("div",{className:"bg-blue-500 text-white rounded-lg p-4",children:k.jsx("p",{className:"min-h-6 overflow-wrap-anywhere",children:n.content})})]})},`message-${r}`))})}function fc(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M5 12h14"}),k.jsx("path",{d:"m12 5 7 7-7 7"})]})}function Ag(e){return k.jsxs("svg",{...e,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:[k.jsx("path",{d:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"}),k.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"})]})}const Pg=!!window.ai,zg=120;function Ig(){const e=de.useRef(null),t=de.useRef(null),n=de.useRef(null),[r,l]=de.useState(null),[i,o]=de.useState(""),[s,u]=de.useState(!1),[a,m]=de.useState(""),[g,p]=de.useState([]),[v,x]=de.useState(null),[E,F]=de.useState(null);function d(y){p(_=>[..._,{role:"user",content:y}]),x(null),u(!0),m("")}de.useEffect(()=>{h()},[a]);function c(){e.current.postMessage({type:"interrupt"})}function h(){if(!t.current)return;const y=t.current;y.style.height="auto";const _=Math.min(Math.max(y.scrollHeight,24),200);y.style.height=`${_}px`}return de.useEffect(()=>{e.current||(e.current=new Worker(new URL("/assets/worker-GhnNjvp1.js",import.meta.url),{type:"module"}));const y=_=>{switch(_.data.status){case"loading":l("loading"),o(_.data.data);break;case"ready":l("ready");break;case"start":p(N=>[...N,{role:"assistant",content:""}]);break;case"update":{const{output:N,tps:R,numTokens:A}=_.data;x(R),F(A),p(Q=>{const I=[...Q],G=I.at(-1);return I[I.length-1]={...G,content:G.content+N},I})}break;case"complete":u(!1);break;case"error":alert(_.data.data);break}};return e.current.addEventListener("message",y),()=>{e.current.removeEventListener("message",y)}},[]),de.useEffect(()=>{g.filter(y=>y.role==="user").length!==0&&g.at(-1).role!=="assistant"&&(x(null),e.current.postMessage({type:"generate",data:g}))},[g,s]),de.useEffect(()=>{if(n.current&&s){const y=n.current;y.scrollHeight-y.scrollTop-y.clientHeight<zg&&(y.scrollTop=y.scrollHeight)}},[g,s]),Pg?k.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:[r===null&&g.length===0&&k.jsxs("div",{className:"h-full overflow-auto scrollbar-thin flex justify-center items-center flex-col relative",children:[k.jsxs("div",{className:"flex flex-col items-center mb-1 max-w-[600px] text-center",children:[k.jsx("img",{src:"logo.png",width:"100%",height:"auto",className:"block max-w-[200px] m-2"}),k.jsx("h1",{className:"text-5xl font-bold mb-1",children:"Built-in AI chat demo"}),k.jsxs("h2",{className:"font-semibold",children:["Run ",k.jsx("a",{className:"underline",href:"https://deepmind.google/technologies/gemini/nano/",target:"_blank",rel:"noreferrer",children:"Gemini Nano"})," locally in your browser with ",k.jsx("a",{className:"underline",href:"https://huggingface.co/docs/transformers.js",target:"_blank",rel:"noreferrer",children:"🤗 Transformers.js"})]})]}),k.jsxs("div",{className:"flex flex-col items-center px-4",children:[k.jsxs("div",{className:"max-w-[608px] m-4",children:["This demo uses Chrome's new ",k.jsx("a",{href:"https://developer.chrome.com/docs/ai/built-in",className:"underline",target:"_blank",rel:"noreferrer",children:"Built-in AI API"})," to run Gemini Nano, a 3.25 billion parameter LLM, locally in your browser. To use the model with Transformers.js, you can install our ",k.jsx("a",{href:"https://github.com/xenova/transformers.js/pull/840",className:"underline",target:"_blank",rel:"noreferrer",children:"experimental branch"})," from GitHub with:",k.jsx("span",{className:"markdown",children:k.jsx("pre",{children:k.jsx("code",{className:"language-javascript",children:"npm install xenova/transformers.js#chrome-built-in-ai"})})}),"Followed by:",k.jsx("span",{className:"font-mono"}),k.jsx("span",{className:"markdown",children:k.jsx("pre",{children:k.jsxs("code",{className:"language-javascript",children:["import { pipeline } from '@xenova/transformers';",k.jsx("br",{}),"const generator = await pipeline('text-generation', 'Xenova/gemini-nano');",k.jsx("br",{}),"const output = await generator('Tell me a joke!');"]})})}),"Since inference happens on-device, none of your conversations are sent to a server. You can even disconnect from the internet after the model has loaded. Try it out! 👇"]}),k.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:()=>{e.current.postMessage({type:"load"}),l("loading")},disabled:r!==null,children:"Load model"})]})]}),r==="loading"&&k.jsx(k.Fragment,{children:k.jsx("div",{className:"w-full max-w-[500px] text-left mx-auto p-4 bottom-0 mt-auto",children:k.jsx("p",{className:"text-center mb-1",children:i})})}),r==="ready"&&k.jsxs("div",{ref:n,className:"overflow-y-auto scrollbar-thin w-full flex flex-col items-center h-full",children:[k.jsx(Lg,{messages:g}),k.jsx("p",{className:"text-center text-sm min-h-6 text-gray-500 dark:text-gray-300",children:v&&g.length>0&&k.jsxs(k.Fragment,{children:[!s&&k.jsxs("span",{children:["Generated ",E," tokens in ",(E/v).toFixed(2)," seconds ("]}),k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"font-medium text-center mr-1 text-black dark:text-white",children:v.toFixed(2)}),k.jsx("span",{className:"text-gray-500 dark:text-gray-300",children:"tokens/second"})]}),!s&&k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"mr-1",children:")."}),k.jsx("span",{className:"underline cursor-pointer",onClick:()=>{e.current.postMessage({type:"reset"}),p([])},children:"Reset"})]})]})})]}),k.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:[k.jsx("textarea",{ref:t,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:"Type your message...",type:"text",rows:1,value:a,disabled:r!=="ready",title:r==="ready"?"Model is ready":"Model not loaded yet",onKeyDown:y=>{a.length>0&&!s&&y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),d(a))},onInput:y=>m(y.target.value)}),s?k.jsx("div",{className:"cursor-pointer",onClick:c,children:k.jsx(Ag,{className:"h-8 w-8 p-1 rounded-md text-gray-800 dark:text-gray-100 absolute right-3 bottom-3"})}):a.length>0?k.jsx("div",{className:"cursor-pointer",onClick:()=>d(a),children:k.jsx(fc,{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"})}):k.jsx("div",{children:k.jsx(fc,{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"})})]}),k.jsx("p",{className:"text-xs text-gray-400 text-center mb-3",children:"Disclaimer: Generated content may be inaccurate or false."})]}):k.jsxs("div",{className:"fixed flex flex-col justify-center items-center w-screen h-screen text-lg",children:[k.jsxs("p",{className:"text-4xl mb-4 text-center",children:["Your browser does not support ",k.jsx("br",{})," the ",k.jsx("a",{className:"underline",href:"https://developer.chrome.com/docs/ai/built-in",target:"_blank",rel:"noreferrer",children:"built-in AI API"})," (",k.jsx("code",{children:"window.ai"}),")"]}),k.jsxs("ul",{className:"list-disc list-outside pl-8 max-w-[650px]",children:[k.jsxs("li",{children:["Upgrade to Chrome (",k.jsx("a",{className:"underline",href:"https://www.google.com/chrome/dev/",target:"_blank",rel:"noreferrer",children:"Dev"})," / ",k.jsx("a",{className:"underline",href:"https://www.google.com/chrome/canary/",target:"_blank",rel:"noreferrer",children:"Canary"}),") version 127 or higher."]}),k.jsxs("li",{children:["Enable the following experimental flags:",k.jsxs("ul",{className:"list-disc list-outside pl-8",children:[k.jsxs("li",{children:["Set ",k.jsx("code",{className:"underline",children:"chrome://flags/#prompt-api-for-gemini-nano"}),' to "Enabled"']}),k.jsxs("li",{children:["Set ",k.jsx("code",{className:"underline",children:"chrome://flags/#optimization-guide-on-device-model"}),' to "Enabled BypassPrefRequirement"']}),k.jsxs("li",{children:["Go to ",k.jsx("code",{className:"underline",children:"chrome://components"}),' and click "Check for Update" on "Optimization Guide On Device Model"']})]})]})]}),k.jsxs("span",{className:"text-base mt-2",children:["Learn more ",k.jsx("a",{className:"underline",href:"https://huggingface.co/blog/Xenova/run-gemini-nano-in-your-browser",target:"_blank",rel:"noreferrer",children:"here"}),"."]})]})}ko.createRoot(document.getElementById("root")).render(k.jsx(hp.StrictMode,{children:k.jsx(Ig,{})}));