@waniwani/sdk 0.11.26 → 0.11.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -78,7 +78,7 @@ import{a as Sr,b as yr,c as kr,d as pt,e as mt,f as la,g as br,h as Tr,i as Pr,j
78
78
  \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function ei(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),l=[],i;r.space==="html"&&e.tagName==="svg"&&(o.schema=ua);let u=Kc(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!Yn(e,t,a))&&(l.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(i=u.charAt(u.length-1),(!o.settings.tightSelfClosing||i==="/"||i&&i!=='"'&&i!=="'")&&l.push(" "),l.push("/")),l.push(">")),l.push(c),!n&&(!s||!Zt(e,t,a))&&l.push("</"+e.tagName+">"),l.join("")}function Kc(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=Qc(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function Qc(e,t,a){let o=Pr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,l;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let i=qe(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ea.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Rr:Mr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?i:(e.settings.preferUnquoted&&(l=qe(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ea.unquoted[r][s]}))),l!==a&&(e.settings.quoteSmart&&lo(a,n)>lo(a,e.alternative)&&(n=e.alternative),l=n+qe(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Ea.single:Ea.double)[r][s],attribute:!0}))+n),i+(l&&"="+l))}f();f();var Jc=["<","&"];function _a(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:qe(e.value,Object.assign({},o.settings.characterReferences,{subset:Jc}))}function ti(e,t,a,o){return o.settings.allowDangerousHtml?e.value:_a(e,t,a,o)}f();function ai(e,t,a,o){return o.all(e)}var oi=Ar("type",{invalid:Zc,unknown:Yc,handlers:{comment:Xn,doctype:Kn,element:ei,raw:ti,root:ai,text:_a}});function Zc(e){throw new Error("Expected node, not `"+e+"`")}function Yc(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var ef={},tf={},af=[];function Ho(e,t){let a=t||ef,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:of,all:rf,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||Tr,characterReferences:a.characterReferences||tf,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ua:vr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function of(e,t,a){return oi(e,t,a,this)}function rf(e){let t=[],a=e&&e.children||af,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Na(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Je(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function sf(e){return Array.isArray(e)?e:[e]}async function di(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Vo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function ci(e){return e==="ansi"||Vo(e)}function $o(e){return e==="none"}function fi(e){return $o(e)}function pi(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function Wa(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function nf(e){let t=Wa(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let l of t){if(s<l.length)break;s-=l.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let l=0;l<r;l++)n+=t[l].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function mi(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),l=n.includes("/")?n.split("/").pop():n;l&&o.add(l)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var Xo="light-dark()",lf=["color","background-color"];function uf(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function df(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,l)=>n-l);return s.length?uf(r,s):r})):e}function cf(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>Oa(e.variants[c])),l=new Set(n.flatMap(c=>Object.keys(c))),i={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return n.forEach((c,d)=>{for(let p of l){let m=c[p]||"inherit";if(d===0&&o&&lf.includes(p))if(o===Xo&&n.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",S=n[I][p]||"inherit";i[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(i[u(d,p)]=m)}else i[p]=m;else r==="css-vars"&&(i[u(d,p)]=m)}}),s.htmlStyle=i,s}function Oa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&pe.Italic&&(t["font-style"]="italic"),e.fontStyle&pe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&pe.Underline&&a.push("underline"),e.fontStyle&pe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Go(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var hi=new WeakMap;function Ga(e,t){hi.set(e,t)}function ea(e){return hi.get(e)}var Ct=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(sf(a).map(o=>[o,Ma])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return ff(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function ff(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function pf(e,t){if(!(e instanceof Ct))throw new J("Invalid grammar state");return e.getInternalStack(t)}function mf(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new J(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let l=r.lines[n.line];if(l===void 0)throw new J(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let i=n.character;if(i<0&&(i=l.length+i),i<0||i>l.length)throw new J(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${l.length}`);return{...n,character:i,offset:r.posToIndex(n.line,i)}}},r=nf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));hf(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return df(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new J(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=gi(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new J(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new J(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)l(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")l(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};l(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=l(r[c],d,"line")}function l(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&pi(c,d.properties.class),c=h(c,p)||c,c}let i=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)i.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}i.forEach(c=>c())}}}function hf(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new J(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,l=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,i=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||l||i){if(s&&n||l&&i||l&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new J(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function gi(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(gi).join(""):""}var gf=[mf()];function Ua(e){let t=wf(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...gf]}function wf(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var lt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],qo={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function xf(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function ri(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function Lf(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)qo[o]&&t.push({type:"setDecoration",value:qo[o]});else if(o<=29){let r=qo[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-30]}});else if(o===38){let r=ri(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-40]}});else if(o===48){let r=ri(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-100+8]}})}return t}function Cf(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=xf(o,s),l=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(l.length>0&&r.push({value:l,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let i=Lf(n.sequence);for(let u of i)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of i)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var If={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Sf(e=If){function t(l){return e[l]}function a(l){return`#${l.map(i=>Math.max(0,Math.min(i,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<lt.length;u++)o.push(t(lt[u]));let l=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([l[u],l[c],l[d]]));let i=8;for(let u=0;u<24;u++,i+=10)o.push(a([i,i,i]));return o}function s(l){return r()[l]}function n(l){switch(l.type){case"named":return t(l.name);case"rgb":return a(l.rgb);case"table":return s(l.index)}}return{value:n}}var yf={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function kf(e,t,a){let o=Na(e,a),r=Wa(t),s=Object.fromEntries(lt.map(i=>{let u=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`,c=e.colors?.[u];return[i,c||yf[i]]})),n=Sf(s),l=Cf();return r.map(i=>l.parse(i[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=Je(c,o),d=Je(d,o),u.decorations.has("dim")&&(c=bf(c));let p=pe.None;return u.decorations.has("bold")&&(p|=pe.Bold),u.decorations.has("italic")&&(p|=pe.Italic),u.decorations.has("underline")&&(p|=pe.Underline),u.decorations.has("strikethrough")&&(p|=pe.Strikethrough),{content:u.value,offset:i[1],color:c,bgColor:d,fontStyle:p}}))}function bf(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],l=o[3],i=Math.round(Number.parseInt(`${l}${l}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${i}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Ko(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(Vo(r)||$o(o))return Wa(t).map(i=>[{content:i[0],offset:i[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return kf(s,t,a);let l=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==l.name)throw new J(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${l.name}"`);if(!a.grammarState.themes.includes(s.name))throw new J(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return Pf(t,l,s,n,a)}function Tf(...e){if(e.length===2)return ea(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Vo(r)||$o(s))throw new J("Plain language does not have grammar state");if(r==="ansi")throw new J("ANSI language does not have grammar state");let{theme:n,colorMap:l}=t.setTheme(s),i=t.getLanguage(r);return new Ct(Qo(a,i,n,l,o).stateStack,i.name,n.name)}function Pf(e,t,a,o,r){let s=Qo(e,t,a,o,r),n=new Ct(s.stateStack,t.name,a.name);return Ga(s.tokens,n),s.tokens}function Qo(e,t,a,o,r){let s=Na(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:l=500}=r,i=Wa(e),u=r.grammarState?pf(r.grammarState,a.name)??Ma:r.grammarContextCode!=null?Qo(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ma,c=[],d=[];for(let p=0,m=i.length;p<m;p++){let[h,I]=i[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,l),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,l),y=g.tokens.length/2;for(let T=0;T<y;T++){let v=g.tokens[2*T],R=T+1<y?g.tokens[2*T+2]:h.length;if(v===R)continue;let k=g.tokens[2*T+1],_=Je(o[it.getForeground(k)],s),A=it.getFontStyle(k),E={content:h.substring(v,R),offset:I+v,color:_,fontStyle:A};if(r.includeExplanation){let P=[];if(r.includeExplanation!=="scopeName")for(let O of a.settings){let F;switch(typeof O.scope){case"string":F=O.scope.split(/,/).map(j=>j.trim());break;case"object":F=O.scope;break;default:continue}P.push({settings:O,selectors:F.map(j=>j.split(/ /))})}E.explanation=[];let M=0;for(;v+M<R;){let O=S[C],F=h.substring(O.startIndex,O.endIndex);M+=F.length,E.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?vf(O.scopes):Af(P,O.scopes)}),C+=1}}c.push(E)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function vf(e){return e.map(t=>({scopeName:t}))}function Af(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Mf(e,s,t.slice(0,o))}}return a}function si(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Rf(e,t,a){if(!si(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)si(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Mf(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Rf(n,t,a)){o.push(s);break}return o}function wi(e,t,a){let o=Object.entries(a.themes).filter(i=>i[1]).map(i=>({color:i[0],theme:i[1]})),r=o.map(i=>{let u=Ko(e,t,{...a,theme:i.theme}),c=ea(u),d=typeof i.theme=="string"?i.theme:i.theme.name;return{tokens:u,state:c,theme:d}}),s=Ff(...r.map(i=>i.tokens)),n=s[0].map((i,u)=>i.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),s.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),l=r[0].state?new Ct(Object.fromEntries(r.map(i=>[i.theme,i.state?.getInternalStack(i.theme)])),r[0].state.lang):void 0;return l&&Ga(n,l),n}function Ff(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(i=>i[o]),s=t.map(()=>[]);t.forEach((i,u)=>i.push(s[u]));let n=r.map(()=>0),l=r.map(i=>i[0]);for(;l.every(i=>i);){let i=Math.min(...l.map(u=>u.content.length));for(let u=0;u<a;u++){let c=l[u];c.content.length===i?(s[u].push(c),n[u]+=1,l[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,i)}),l[u]={...c,content:c.content.slice(i),offset:c.offset+i})}}}return t}function Ha(e,t,a){let o,r,s,n,l,i;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new J("`themes` option must not be empty");let m=wi(e,t,a);if(i=ea(m),u&&Xo!==u&&!p.find(S=>S.color===u))throw new J(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);s=m.map(S=>S.map(C=>cf(C,I,c,u,d))),i&&Ga(s,i);let L=p.map(S=>Na(S.theme,a));r=ni(p,h,L,c,u,"fg",d),o=ni(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(S=>S.name).join(" ")}`,l=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Na(a.theme,a);s=Ko(e,t,a);let c=e.getTheme(a.theme);o=Je(c.bg,u),r=Je(c.fg,u),n=c.name,i=ea(s)}else throw new J("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:l,grammarState:i}}function ni(e,t,a,o,r,s,n){return e.map((l,i)=>{let u=Je(t[i][s],a[i])||"inherit",c=`${o+l.color}${s==="bg"?"-bg":""}:${u}`;if(i===0&&r){if(r===Xo&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new J('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=Je(t[d][s],a[d])||"inherit",h=Je(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(l=>!!l).join(";")}function qa(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>qa(e,r,s),codeToTokens:(r,s)=>Ha(e,r,s)}){let r=t;for(let h of Ua(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:l,themeName:i,rootStyle:u,grammarState:c}=Ha(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=Bf(s):d==="never"&&(s=Ef(s)),p&&(s=_f(s));let m={...o,get source(){return r}};for(let h of Ua(a))s=h.tokens?.call(m,s)||s;return Df(s,{...a,fg:n,bg:l,themeName:i,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Df(e,t,a,o=ea(e)){let r=Ua(t),s=[],n={type:"root",children:[]},{structure:l="classic",tabindex:i="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),i!==!1&&i!=null&&(u.tabindex=i.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:l,addClassToHast:pi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(l==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):l==="classic"&&s.push({type:"text",value:`
79
79
  `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let y={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},T=Go(g.htmlStyle||Oa(g));T&&(y.properties.style=T);for(let v of r)y=v?.span?.call(m,y,L+1,C,S,g)||y;l==="inline"?n.children.push(y):l==="classic"&&S.children.push(y),C+=g.content.length}if(l==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else l==="inline"&&p.push(S)}),l==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(l==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[g];y.type==="element"&&n.children.push(...y.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&Ga(h,o),h}function Bf(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let i=!(s.fontStyle&&(s.fontStyle&pe.Underline||s.fontStyle&pe.Strikethrough));i&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(i?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function Ef(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let l=[{...a,offset:a.offset+r.length,content:s}];return r&&l.unshift({content:r,offset:a.offset}),n&&l.push({content:n,offset:a.offset+r.length+s.length}),l}))}function _f(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=Go(r.htmlStyle||Oa(r)),n=Go(o.htmlStyle||Oa(o)),l=r.fontStyle&&(r.fontStyle&pe.Underline||r.fontStyle&pe.Strikethrough),i=o.fontStyle&&(o.fontStyle&pe.Underline||o.fontStyle&pe.Strikethrough);!l&&!i&&s===n?r.content+=o.content:a.push({...o})}return a})}var Nf=Ho;function Of(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>qa(e,s,n),codeToTokens:(s,n)=>Ha(e,s,n)},r=Nf(qa(e,t,a,o));for(let s of Ua(a))r=s.postprocess?.call(o,r,a)||r;return r}var ii={light:"#333333",dark:"#bbbbbb"},li={light:"#fffffe",dark:"#1e1e1e"},ui="__shiki_resolved";function Jo(e){if(e?.[ui])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let l=t.settings?t.settings.find(i=>!i.name&&!i.scope):void 0;l?.settings?.foreground&&(o=l.settings.foreground),l?.settings?.background&&(a=l.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?ii.light:ii.dark),a||(a=t.type==="light"?li.light:li.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(l){if(s.has(l))return s.get(l);r+=1;let i=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${i}`]?n(l):(s.set(l,i),i)}t.settings=t.settings.map(l=>{let i=l.settings?.foreground&&!l.settings.foreground.startsWith("#"),u=l.settings?.background&&!l.settings.background.startsWith("#");if(!i&&!u)return l;let c={...l,settings:{...l.settings}};if(i){let d=n(l.settings.foreground);t.colorReplacements[d]=l.settings.foreground,c.settings.foreground=d}if(u){let d=n(l.settings.background);t.colorReplacements[d]=l.settings.background,c.settings.background=d}return c});for(let l of Object.keys(t.colors||{}))if((l==="editor.foreground"||l==="editor.background"||l.startsWith("terminal.ansi"))&&!t.colors[l]?.startsWith("#")){let i=n(t.colors[l]);t.colorReplacements[i]=t.colors[l],t.colors[l]=i}return Object.defineProperty(t,ui,{enumerable:!1,writable:!1,value:!0}),t}async function xi(e){return Array.from(new Set((await Promise.all(e.filter(t=>!ci(t)).map(async t=>await di(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Li(e){return(await Promise.all(e.map(async a=>fi(a)?null:Jo(await di(a))))).filter(a=>!!a)}var Wo=3,Uf=!1;function Hf(e,t=3){if(Wo&&!(typeof Wo=="number"&&t>Wo)){if(Uf)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Qe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ci(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new Qe(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var jo=class extends On{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=Jo(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=$t.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Ci(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(i=>o.map(([u])=>u).includes(i)):!1).filter(s=>!o.includes(s));throw new Qe(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},zo=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},Yt=0;function qf(e){Yt+=1,e.warnings!==!1&&Yt>=10&&Yt%10===0&&console.warn(`[Shiki] ${Yt} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Qe("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Jo),r=new zo(e.engine,a),s=new jo(r,o,a,e.langAlias),n;function l(g){return Ci(g,e.langAlias)}function i(g){S();let y=s.getGrammar(typeof g=="string"?g:g.name);if(!y)throw new Qe(`Language \`${g}\` not found, you may need to load it first`);return y}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=s.getTheme(g);if(!y)throw new Qe(`Theme \`${g}\` not found, you may need to load it first`);return y}function c(g){S();let y=u(g);n!==g&&(s.setTheme(y),n=g);let T=s.getColorMap();return{theme:y,colorMap:T}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await xi(g))}function I(...g){S();for(let y of g.flat(1))s.loadTheme(y)}async function L(...g){return S(),I(await Li(g))}function S(){if(t)throw new Qe("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),Yt-=1)}return{setTheme:c,getTheme:u,getLanguage:i,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:l,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function Wf(e){e.engine||Hf("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Li(e.themes||[]),xi(e.langs||[]),e.engine]);return qf({...e,themes:t,langs:a,engine:o})}async function Gf(e){let t=await Wf(e);return{getLastGrammarState:(...a)=>Tf(t,...a),codeToTokensBase:(a,o)=>Ko(t,a,o),codeToTokensWithThemes:(a,o)=>wi(t,a,o),codeToTokens:(a,o)=>Ha(t,a,o),codeToHast:(a,o)=>qa(t,a,o),codeToHtml:(a,o)=>Of(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Ii(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,ci(d))return[];let p=t[d];if(!p)throw new J(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function l(d){if(fi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new J(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let i=(s.themes??[]).map(d=>l(d)),u=(s.langs??[]).map(d=>n(d)),c=await Gf({engine:s.engine??o(),...s,themes:i,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(l))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function jf(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Si(e,t){let a=jf(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),l=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return l&&await n.loadLanguage(...l),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var Zo=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],yi=Object.fromEntries(Zo.map(e=>[e.id,e.import])),ki=Object.fromEntries(Zo.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ta={...yi,...ki};f();var zf=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],bi=Object.fromEntries(zf.map(e=>[e.id,e.import]));f();var aa=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Vf(){return 2147483648}function $f(){return typeof performance<"u"?performance.now():Date.now()}var Xf=(e,t)=>e+(t-e%t)%t;async function Kf(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function l(m){let h=o.HEAPU8.length;m=m>>>0;let I=Vf();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,Xf(Math.max(m,S),65536));if(n(C))return!0}return!1}let i=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&i)return i.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let y=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|y);continue}let T=m[h++]&63;if((g&240)===224?g=(g&15)<<12|y<<6|T:g=(g&7)<<18|y<<12|T<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let v=g-65536;C+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:$f,emscripten_memcpy_big:s,emscripten_resize_heap:l,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var Qf=Object.defineProperty,Jf=(e,t,a)=>t in e?Qf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ne=(e,t,a)=>Jf(e,typeof t!="symbol"?t+"":t,a),ie=null;function Zf(e){throw new aa(e.UTF8ToString(e.getLastOnigError()))}var za=class e{constructor(t){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let l=new Uint8Array(o),i=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=i,p&&(s[u+1]=i),d<=127?n[i+0]=u:d<=2047?(n[i+0]=u,n[i+1]=u):d<=65535?(n[i+0]=u,n[i+1]=u,n[i+2]=u):(n[i+0]=u,n[i+1]=u,n[i+2]=u,n[i+3]=u)),d<=127?l[i++]=d:d<=2047?(l[i++]=192|(d&1984)>>>6,l[i++]=128|(d&63)>>>0):d<=65535?(l[i++]=224|(d&61440)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0):(l[i++]=240|(d&1835008)>>>18,l[i++]=128|(d&258048)>>>12,l[i++]=128|(d&4032)>>>6,l[i++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=l,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,l=!1;if(s>=55296&&s<=56319&&o+1<r){let i=t.charCodeAt(o+1);i>=56320&&i<=57343&&(n=(s-55296<<10)+65536|i-56320,l=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,l&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},Va=class Ne{constructor(t){if(ne(this,"id",++Ne.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!ie)throw new aa("Must invoke loadWasm first.");this._onigBinding=ie,this.content=t;let a=new za(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ne._sharedPtrInUse?(Ne._sharedPtr||(Ne._sharedPtr=ie.omalloc(1e4)),Ne._sharedPtrInUse=!0,ie.HEAPU8.set(a.utf8Value,Ne._sharedPtr),this.ptr=Ne._sharedPtr):this.ptr=a.createString(ie)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ne._sharedPtr?Ne._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne(Va,"LAST_ID",0);ne(Va,"_sharedPtr",0);ne(Va,"_sharedPtrInUse",!1);var Ti=Va,er=class{constructor(t){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!ie)throw new aa("Must invoke loadWasm first.");let a=[],o=[];for(let l=0,i=t.length;l<i;l++){let u=new za(t[l]);a[l]=u.createString(ie),o[l]=u.utf8Length}let r=ie.omalloc(4*t.length);ie.HEAPU32.set(a,r/4);let s=ie.omalloc(4*t.length);ie.HEAPU32.set(o,s/4);let n=ie.createOnigScanner(r,s,t.length);for(let l=0,i=t.length;l<i;l++)ie.ofree(a[l]);ie.ofree(s),ie.ofree(r),n===0&&Zf(ie),this._onigBinding=ie,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Ti(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let l=s.HEAPU32,i=n/4,u=l[i++],c=l[i++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(l[i++]),h=t.convertUtf8OffsetToUtf16(l[i++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Yf(e){return typeof e.instantiator=="function"}function ep(e){return typeof e.default=="function"}function tp(e){return typeof e.data<"u"}function ap(e){return typeof Response<"u"&&e instanceof Response}function op(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var ja;function rp(e){if(ja)return ja;async function t(){ie=await Kf(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Yf(o)?o=await o.instantiator(a):ep(o)?o=await o.default(a):(tp(o)&&(o=o.data),ap(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await sp(o)(a):o=await np(o)(a):op(o)?o=await Yo(o)(a):o instanceof WebAssembly.Module?o=await Yo(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await Yo(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return ja=t(),ja}function Yo(e){return t=>WebAssembly.instantiate(e,t)}function sp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function np(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Pi(e){return e&&await rp(e),{createScanner(t){return new er(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Ti(t)}}}var $a=Ii({langs:ta,themes:bi,engine:()=>Pi(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:ip,codeToHast:lp,codeToTokens:up,codeToTokensBase:dp,codeToTokensWithThemes:cp,getSingletonHighlighter:fp,getLastGrammarState:pp}=Si($a,{guessEmbeddedLanguages:mi});var vi=new Set(Object.keys(ta)),tr=new Map,ar=new Map,It=new Map,mp=(e,t)=>`${e}-${t[0]}-${t[1]}`,hp=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},gp=(e,t)=>{let a=mp(e,t);if(tr.has(a))return tr.get(a);let o=$a({themes:t,langs:[e]});return tr.set(a,o),o};function wp(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return vi.has(o)},getSupportedLanguages(){return Array.from(vi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let l=hp(o,r,s);return ar.has(l)?ar.get(l):(n&&(It.has(l)||It.set(l,new Set),It.get(l).add(n)),gp(r,s).then(i=>{let u=i.getLoadedLanguages().includes(r)?r:"text",c=i.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});ar.set(l,c);let d=It.get(l);if(d){for(let p of d)p(c);It.delete(l)}}).catch(i=>{console.error("[Streamdown Code] Failed to highlight code:",i),It.delete(l)}),null)}}}var Ai=wp();import{memo as xp}from"react";f();import{jsx as Xa}from"react/jsx-runtime";var Ka=({className:e,from:t,children:a,...o})=>Xa("div",{className:B("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:Xa("div",{className:B("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Qa=({children:e,className:t,...a})=>Xa("div",{className:B("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),Lp={cjk:fn,code:Ai},Cp={enabled:!1},Ja=xp(({className:e,linkSafety:t,...a})=>Xa(uo,{className:B("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??Cp,plugins:Lp,...a}),(e,t)=>e.children===t.children);Ja.displayName="MessageResponse";f();import{jsx as Ip}from"react/jsx-runtime";function Ri({className:e,text:t,...a}){return t?Ip("pre",{className:B("ww:mb-2 ww:overflow-x-auto ww:whitespace-pre-wrap ww:break-words ww:text-xs ww:font-mono ww:text-muted-foreground",e),...a,children:t}):null}f();import{createContext as Sp,useCallback as yp,useContext as Bi,useEffect as kp,useMemo as rr,useRef as bp,useState as sr}from"react";import{Fragment as Di,jsx as $,jsxs as We}from"react/jsx-runtime";function Tp(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,l]of o){if(s<=8)break;let i=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof l=="string"?u=l.length>2?`'${l.slice(0,1)}\u2026`:`'${l}'`:Array.isArray(l)?u=`Array(${l.length})`:typeof l=="object"&&l!==null?u="{\u2026}":u=String(l);let c=`${i}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Pp({text:e,className:t}){let[a,o]=sr(!1),r=bp(null);kp(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=yp(async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return $(Be,{variant:"ghost",size:"sm",onClick:s,className:B("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:a?We(Di,{children:[$(Dt,{className:"ww:size-3.5"}),$("span",{children:"Copied"})]}):We(Di,{children:[$(_t,{className:"ww:size-3.5"}),$("span",{children:"Copy"})]})})}function Ei({data:e,label:t,className:a,...o}){let[r,s]=sr(!1),n=rr(()=>JSON.stringify(e,null,2),[e]),l=Tp(e);return We("div",{className:B("ww:rounded-lg ww:bg-tool-card",a),...o,children:[We("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[$("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),$(Pp,{text:n})]}),We("button",{type:"button",onClick:()=>s(i=>!i),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[$(Et,{className:B("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?$("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:$("code",{children:n})}):$("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:l})]})]})}var nr=Sp({open:!1,toggle:()=>{}});function _i({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=sr(t);return $(nr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:$("div",{className:B("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",...o,children:a})})}function Ni({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=Bi(nr),n=a==="input-available"||a==="input-streaming";return We("button",{type:"button",onClick:s,className:B("ww:flex ww:w-full ww:items-center ww:justify-between ww:gap-3 ww:py-1.5",e),"aria-expanded":r,...o,children:[We("div",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-2",children:[$($e,{className:"ww:size-4 ww:shrink-0 ww:text-muted-foreground"}),$("span",{className:"ww:truncate ww:text-sm ww:font-medium",children:t}),n&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]}),$(Bt,{className:B("ww:size-4 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Oi({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming";return We("div",{className:B("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:py-1.5 ww:text-sm ww:text-muted-foreground ww:italic",e),...o,children:[$("span",{className:"ww:truncate",children:t}),r&&$("span",{className:"ww:size-2 ww:shrink-0 ww:rounded-full ww:bg-primary ww:animate-pulse"})]})}function Ui({className:e,children:t,...a}){let{open:o}=Bi(nr);return $("div",{className:B("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:$("div",{className:"ww:min-h-0 ww:overflow-hidden",children:$("div",{className:B("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Hi({className:e,input:t,debug:a,...o}){let r=rr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return $(Ei,{data:r,label:"Request",className:e,...o})}function or(e){if(!(typeof e!="object"||e===null))return e}function qi(e){return or(e?.ui)}function Wi(e){return or(or(e)?._meta)}function Mi(e){if(!e)return;let t=qi(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function Fi(e){return qi(e)?.autoHeight===!0}function Za(e,t,a){if(e){let o=Mi(a?.[e]?._meta);if(o)return o}return Mi(Wi(t))}function Gi(e,t,a){return e&&Fi(a?.[e]?._meta)?!0:Fi(Wi(t))}function ji({className:e,output:t,errorText:a,debug:o,...r}){let s=rr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...l}=t;return l}return t},[t,o]);return t||a?a?We("div",{className:B("ww:space-y-2",e),...r,children:[$("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),$("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):$(Ei,{data:s,label:"Response",className:e,...r}):null}f();import{useCallback as vp,useEffect as zi,useMemo as Ap,useRef as Ce,useState as Vi}from"react";import{jsx as Hp}from"react/jsx-runtime";var Rp="/api/mcp/resource",Mp=500,Fp=0,Dp=16,Bp="2026-01-26",Ep=300,_p=3e3,Np=3;function Op(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Up(e,t,a){return Za(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function $i({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Rp,chatSessionId:r,isDark:s=!1,className:n,autoHeight:l=!1,onOpenLink:i,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=Ce(null),I=Ce(t),L=Ce(a),S=Ce({width:0,height:0}),C=Ce(null),g=Ce(!1),y=Ce(0),T=Ce("inline"),[v,R]=Vi(Fp),[k,_]=Vi(void 0),A=Ce(i),E=Ce(u),P=Ce(c),M=Ce(d),O=Ce(r),F=Ce(m);I.current=t,L.current=a,A.current=i,E.current=u,P.current=c,M.current=d,O.current=r,F.current=m;let j=vp(te=>l?Math.max(te+Dp,0):Math.min(Math.max(te,50),Mp),[l]),be=Ap(()=>{let te=o.includes("?")?"&":"?";return`${o}${te}uri=${encodeURIComponent(e)}`},[o,e]),ue=Ce(s);return ue.current=s,zi(()=>{if(!g.current)return;let te=h.current;te?.contentWindow&&te.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),zi(()=>{let te=h.current;if(!te)return;let ge=!1,q=!1,ae=null,de=null,Ge=setTimeout(()=>{if(ge||q||y.current>=Np)return;y.current+=1;let ce=new URL(te.src);ce.searchParams.set("_retry",String(y.current)),te.src=ce.toString()},_p),we=ce=>{te.contentWindow?.postMessage(ce,"*")},je=ce=>{if(ge||ce.source!==te.contentWindow)return;let Z=ce.data;if(!Z||typeof Z!="object"||Z.jsonrpc!=="2.0")return;let oe=Z.method,W=Z.id;if(oe==="ui/initialize"&&W!=null){q=!0,clearTimeout(Ge),we({jsonrpc:"2.0",id:W,result:{protocolVersion:Z.params?.protocolVersion??Bp,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:ue.current?"dark":"light",displayMode:T.current}}});return}if(oe==="ui/notifications/initialized"){g.current=!0;let z=I.current,X=L.current,H=X._meta&&typeof X._meta=="object"?X._meta:null,K=Op(O.current),re=H&&typeof H.waniwani=="object"&&H.waniwani!==null?H.waniwani:null,Te=re||K?{...re??{},...K?{sessionId:K}:{}}:void 0,ze=H||Te?{...H??{},...Te?{waniwani:Te}:{}}:void 0;we({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:z}});let dt=X.content??[{type:"text",text:JSON.stringify(X)}];we({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:dt,structuredContent:X.structuredContent,_meta:ze,meta:ze}});return}if(oe==="ui/notifications/size-changed"){let z=Z.params,X=typeof z?.height=="number"?z.height:void 0,H=typeof z?.width=="number"?z.width:void 0,K=S.current,re=X!==void 0&&X!==K.height,Te=H!==void 0&&H!==K.width;if(!re&&!Te)return;if(re&&X!==void 0){K.height=X;let ze=j(X),dt=te.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),R(ze),te.animate&&Math.abs(dt-ze)>2){let ct=te.animate([{height:`${dt}px`},{height:`${ze}px`}],{duration:Ep,easing:"ease-out",fill:"forwards"});C.current=ct,ct.onfinish=()=>{C.current===ct&&(ct.cancel(),C.current=null)}}}Te&&l&&H!==void 0&&(K.width=H,_(H));return}if(oe==="ui/open-link"&&W!=null){let z=Z.params?.url;typeof z=="string"&&(A.current?A.current(z):window.open(z,"_blank","noopener,noreferrer")),we({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/message"&&W!=null){if(E.current&&Z.params){let z=Z.params,X=ae;if(ae=null,de){clearTimeout(de.timer);let H=de.text;de=null;let K=(z.content??[]).map(re=>re.text??"").join("").trim();z={...z,content:[{type:"text",text:`${K}
80
80
 
81
- ${H}`}]}}E.current({...z,...X?{modelContext:X}:{}})}we({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/update-model-context"&&W!=null){ae=Cr(ae,Z.params),we({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="tools/call"&&W!=null){let z=P.current;if(!z){we({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let X=Z.params?.name;z({name:X,arguments:Z.params?.arguments??{}}).then(H=>{we({jsonrpc:"2.0",id:W,result:H});let K=H.content?.map(re=>re.text??"").join("").trim();K&&Up(X,H,F.current)&&(de&&clearTimeout(de.timer),de={text:K,timer:setTimeout(()=>{if(ge)return;let re=ae;ae=null,de=null,E.current?.({role:"user",content:[{type:"text",text:K}],...re?{modelContext:re}:{}})},500)})}).catch(H=>{let K=H instanceof Error?H.message:"Tool call failed";we({jsonrpc:"2.0",id:W,error:{code:-32e3,message:K}})});return}if(oe==="ui/request-display-mode"&&W!=null){let z=Z.params?.mode,X=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";T.current=X,we({jsonrpc:"2.0",id:W,result:{mode:X}}),we({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),M.current?.(X);return}if(oe==="ui/resource-teardown"&&W!=null){we({jsonrpc:"2.0",id:W,result:{}});return}oe==="ping"&&W!=null&&we({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",je),()=>{ge=!0,clearTimeout(Ge),de&&clearTimeout(de.timer),window.removeEventListener("message",je)}},[l,j]),Hp("iframe",{ref:h,src:be,sandbox:"allow-scripts allow-forms allow-same-origin",className:B(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":v,minWidth:p||!k?void 0:`min(${k}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as oa,jsxs as qp}from"react/jsx-runtime";function Xi({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return qp("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&oa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),oa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&oa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&oa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>oa("button",{type:"button",onClick:()=>r?.(s),className:B("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as Wp}from"react";import{jsx as Ki,jsxs as Gp}from"react/jsx-runtime";var Ya=class extends Wp{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?Gp("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[Ki("span",{children:"Widget failed to load"}),Ki("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as jp,jsx as se,jsxs as St}from"react/jsx-runtime";function Qi(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Ji({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=t==="submitted"||t==="streaming",L=e[e.length-1],S=e.length>0,C=I&&(!S||L.role==="user"),g=d!=null;return St(jp,{children:[!g&&(!S&&o?se(Xi,{...o,onSuggestionSelect:r}):a&&se(Ka,{from:"assistant",children:se(Qa,{children:se(Ja,{children:a})})})),e.map(y=>{let T=y.parts.filter(P=>P.type==="text"),v=y.parts.filter(P=>P.type==="reasoning"),R=y.parts.filter(P=>P.type==="file"),k=y.parts.filter(P=>"toolCallId"in P),_=y===L&&y.role==="assistant",A=T.length>0,E=g?k.some(P=>P.toolCallId===d):!1;return g&&!E?se("div",{style:{display:"none"}},y.id):St(Ka,{from:y.role,children:[!E&&v.map((P,M)=>se(Ri,{text:P.text},`reasoning-${y.id}-${M}`)),k.map(P=>{let M="output"in P?P.output:void 0,O=Za(P.toolName,M,h),F=Gi(P.toolName,M,h),j=P.toolCallId===d;return St("div",{style:j?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[se("div",{style:j?{display:"none"}:void 0,children:m?St(_i,{children:[se(Ni,{title:P.title??Qi(P.toolName),state:P.state}),St(Ui,{children:[se(Hi,{input:P.input,debug:p}),M!==void 0&&se(ji,{output:M,errorText:"errorText"in P?P.errorText:void 0,debug:p})]})]}):se(Oi,{title:P.title??Qi(P.toolName),state:P.state})}),O&&s&&M!==void 0&&se(Ya,{children:se($i,{isFullscreen:j,resourceUri:O,toolInput:P.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:F,toolDefinitions:h,onFollowUp:i,onCallTool:u,onDisplayModeChange:c?be=>c(be,{toolCallId:P.toolCallId,resourceUri:O,toolInput:P.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:F}):void 0})})]},P.toolCallId)}),!E&&se("div",{children:St(Qa,{children:[R.length>0&&se(Qs,{files:R}),A?T.map((P,M)=>se(Ja,{children:P.type==="text"?P.text:""},`${y.id}-${M}`)):_&&I&&se(ko,{})]})})]},y.id)}),!g&&C&&se(Ka,{from:"assistant",children:se(Qa,{children:se(ko,{})})})]})}f();import{jsx as ir,jsxs as $p}from"react/jsx-runtime";var zp="https://app.waniwani.ai/assets/waniwani-logo.svg",Vp="https://waniwani.ai";function Zi(){return ir("div",{className:"ww:pt-2 ww:pb-1 ww:flex ww:justify-center",children:$p("a",{href:Vp,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[ir("span",{children:"powered by"}),ir("img",{src:zp,alt:"WaniWani",width:72,height:10,className:"ww:h-2.5 ww:w-auto"})]})})}f();import{jsx as eo}from"react/jsx-runtime";function Yi({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:eo("div",{className:B("ww:px-4 ww:py-2",o),...r,children:eo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>eo("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>eo("button",{type:"button",onClick:()=>a(s),className:B("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as Xp,useRef as Kp,useState as Qp}from"react";import{jsx as Y,jsxs as Ze}from"react/jsx-runtime";var el=20;function Jp(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let a=Date.now()-t;return a<6e4?"just now":a<60*6e4?`${Math.floor(a/6e4)}m ago`:a<1440*6e4?`${Math.floor(a/(60*6e4))}h ago`:`${Math.floor(a/(1440*6e4))}d ago`}function Zp(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"New chat",children:[Y("title",{children:"New chat"}),Y("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Y("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Yp(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Thread history",children:[Y("title",{children:"Thread history"}),Y("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),Y("polyline",{points:"3 4 3 9 8 9"}),Y("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),Y("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function em(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Delete thread",children:[Y("title",{children:"Delete thread"}),Y("polyline",{points:"3 6 5 6 21 6"}),Y("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),Y("path",{d:"M10 11v6"}),Y("path",{d:"M14 11v6"})]})}function tl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=Qp(!1),l=Kp(null);Xp(()=>{if(!s)return;let c=d=>{let p=l.current;p&&(d.composedPath().includes(p)||n(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let i=e.slice(0,el),u=Math.max(0,e.length-el);return Ze("div",{ref:l,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[Y("button",{type:"button",onClick:a,title:"New chat","aria-label":"New chat",className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(Zp,{})}),Y("button",{type:"button",onClick:()=>n(c=>!c),title:"Thread history","aria-label":"Thread history","aria-expanded":s,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(Yp,{})}),s&&Ze("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[i.length===0&&Y("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),i.map(c=>{let d=c.threadId===t;return Ze("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${d?"ww:bg-foreground/5":""}`,children:[Ze("button",{type:"button",onClick:()=>{o(c.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[Y("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),Y("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Jp(c.updatedAt)})]}),Y("button",{type:"button",onClick:p=>{p.stopPropagation(),r(c.threadId)},title:"Delete thread","aria-label":"Delete thread",className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:Y(em,{})})]},c.threadId)}),u>0&&Ze("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:[u," older thread",u===1?"":"s"," hidden"]})]})]})}f();import{useCallback as tm,useRef as am}from"react";function al(e){let t=am(e);return t.current=e,tm(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let l=`${o??"/api/waniwani"}/tool`,i=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...i?{"X-Session-Id":i}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as Lm}from"@ai-sdk/react";import{useCallback as me,useEffect as Me,useRef as le,useState as ut}from"react";f();import{DefaultChatTransport as om,uiMessageChunkSchema as rm}from"ai";function sm(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(l=>(l.code==="invalid_value"||l.code==="invalid_literal")&&l.path?.[0]==="type"))continue;let n=r.filter(l=>l.code==="unrecognized_keys").flatMap(l=>l.keys??[]);if(n.length>0)return n}return null}var to=class extends om{processResponseStream(t){let a="",o=rm(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
81
+ ${H}`}]}}E.current({...z,...X?{modelContext:X}:{}})}we({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/update-model-context"&&W!=null){ae=Cr(ae,Z.params),we({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="tools/call"&&W!=null){let z=P.current;if(!z){we({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let X=Z.params?.name;z({name:X,arguments:Z.params?.arguments??{}}).then(H=>{we({jsonrpc:"2.0",id:W,result:H});let K=H.content?.map(re=>re.text??"").join("").trim();K&&Up(X,H,F.current)&&(de&&clearTimeout(de.timer),de={text:K,timer:setTimeout(()=>{if(ge)return;let re=ae;ae=null,de=null,E.current?.({role:"user",content:[{type:"text",text:K}],...re?{modelContext:re}:{}})},500)})}).catch(H=>{let K=H instanceof Error?H.message:"Tool call failed";we({jsonrpc:"2.0",id:W,error:{code:-32e3,message:K}})});return}if(oe==="ui/request-display-mode"&&W!=null){let z=Z.params?.mode,X=z==="fullscreen"||z==="inline"||z==="pip"?z:"inline";T.current=X,we({jsonrpc:"2.0",id:W,result:{mode:X}}),we({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),M.current?.(X);return}if(oe==="ui/resource-teardown"&&W!=null){we({jsonrpc:"2.0",id:W,result:{}});return}oe==="ping"&&W!=null&&we({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",je),()=>{ge=!0,clearTimeout(Ge),de&&clearTimeout(de.timer),window.removeEventListener("message",je)}},[l,j]),Hp("iframe",{ref:h,src:be,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:B(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":v,minWidth:p||!k?void 0:`min(${k}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as oa,jsxs as qp}from"react/jsx-runtime";function Xi({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return qp("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&oa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),oa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&oa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&oa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>oa("button",{type:"button",onClick:()=>r?.(s),className:B("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as Wp}from"react";import{jsx as Ki,jsxs as Gp}from"react/jsx-runtime";var Ya=class extends Wp{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?Gp("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[Ki("span",{children:"Widget failed to load"}),Ki("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as jp,jsx as se,jsxs as St}from"react/jsx-runtime";function Qi(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Ji({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:l,onFollowUp:i,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=t==="submitted"||t==="streaming",L=e[e.length-1],S=e.length>0,C=I&&(!S||L.role==="user"),g=d!=null;return St(jp,{children:[!g&&(!S&&o?se(Xi,{...o,onSuggestionSelect:r}):a&&se(Ka,{from:"assistant",children:se(Qa,{children:se(Ja,{children:a})})})),e.map(y=>{let T=y.parts.filter(P=>P.type==="text"),v=y.parts.filter(P=>P.type==="reasoning"),R=y.parts.filter(P=>P.type==="file"),k=y.parts.filter(P=>"toolCallId"in P),_=y===L&&y.role==="assistant",A=T.length>0,E=g?k.some(P=>P.toolCallId===d):!1;return g&&!E?se("div",{style:{display:"none"}},y.id):St(Ka,{from:y.role,children:[!E&&v.map((P,M)=>se(Ri,{text:P.text},`reasoning-${y.id}-${M}`)),k.map(P=>{let M="output"in P?P.output:void 0,O=Za(P.toolName,M,h),F=Gi(P.toolName,M,h),j=P.toolCallId===d;return St("div",{style:j?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[se("div",{style:j?{display:"none"}:void 0,children:m?St(_i,{children:[se(Ni,{title:P.title??Qi(P.toolName),state:P.state}),St(Ui,{children:[se(Hi,{input:P.input,debug:p}),M!==void 0&&se(ji,{output:M,errorText:"errorText"in P?P.errorText:void 0,debug:p})]})]}):se(Oi,{title:P.title??Qi(P.toolName),state:P.state})}),O&&s&&M!==void 0&&se(Ya,{children:se($i,{isFullscreen:j,resourceUri:O,toolInput:P.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:l,autoHeight:F,toolDefinitions:h,onFollowUp:i,onCallTool:u,onDisplayModeChange:c?be=>c(be,{toolCallId:P.toolCallId,resourceUri:O,toolInput:P.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:F}):void 0})})]},P.toolCallId)}),!E&&se("div",{children:St(Qa,{children:[R.length>0&&se(Qs,{files:R}),A?T.map((P,M)=>se(Ja,{children:P.type==="text"?P.text:""},`${y.id}-${M}`)):_&&I&&se(ko,{})]})})]},y.id)}),!g&&C&&se(Ka,{from:"assistant",children:se(Qa,{children:se(ko,{})})})]})}f();import{jsx as ir,jsxs as $p}from"react/jsx-runtime";var zp="https://app.waniwani.ai/assets/waniwani-logo.svg",Vp="https://waniwani.ai";function Zi(){return ir("div",{className:"ww:pt-2 ww:pb-1 ww:flex ww:justify-center",children:$p("a",{href:Vp,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[ir("span",{children:"powered by"}),ir("img",{src:zp,alt:"WaniWani",width:72,height:10,className:"ww:h-2.5 ww:w-auto"})]})})}f();import{jsx as eo}from"react/jsx-runtime";function Yi({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:eo("div",{className:B("ww:px-4 ww:py-2",o),...r,children:eo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>eo("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>eo("button",{type:"button",onClick:()=>a(s),className:B("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as Xp,useRef as Kp,useState as Qp}from"react";import{jsx as Y,jsxs as Ze}from"react/jsx-runtime";var el=20;function Jp(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let a=Date.now()-t;return a<6e4?"just now":a<60*6e4?`${Math.floor(a/6e4)}m ago`:a<1440*6e4?`${Math.floor(a/(60*6e4))}h ago`:`${Math.floor(a/(1440*6e4))}d ago`}function Zp(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"New chat",children:[Y("title",{children:"New chat"}),Y("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),Y("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Yp(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Thread history",children:[Y("title",{children:"Thread history"}),Y("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),Y("polyline",{points:"3 4 3 9 8 9"}),Y("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),Y("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function em(){return Ze("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Delete thread",children:[Y("title",{children:"Delete thread"}),Y("polyline",{points:"3 6 5 6 21 6"}),Y("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),Y("path",{d:"M10 11v6"}),Y("path",{d:"M14 11v6"})]})}function tl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=Qp(!1),l=Kp(null);Xp(()=>{if(!s)return;let c=d=>{let p=l.current;p&&(d.composedPath().includes(p)||n(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let i=e.slice(0,el),u=Math.max(0,e.length-el);return Ze("div",{ref:l,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[Y("button",{type:"button",onClick:a,title:"New chat","aria-label":"New chat",className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(Zp,{})}),Y("button",{type:"button",onClick:()=>n(c=>!c),title:"Thread history","aria-label":"Thread history","aria-expanded":s,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:Y(Yp,{})}),s&&Ze("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[i.length===0&&Y("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),i.map(c=>{let d=c.threadId===t;return Ze("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${d?"ww:bg-foreground/5":""}`,children:[Ze("button",{type:"button",onClick:()=>{o(c.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[Y("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),Y("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Jp(c.updatedAt)})]}),Y("button",{type:"button",onClick:p=>{p.stopPropagation(),r(c.threadId)},title:"Delete thread","aria-label":"Delete thread",className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:Y(em,{})})]},c.threadId)}),u>0&&Ze("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:[u," older thread",u===1?"":"s"," hidden"]})]})]})}f();import{useCallback as tm,useRef as am}from"react";function al(e){let t=am(e);return t.current=e,tm(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let l=`${o??"/api/waniwani"}/tool`,i=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",...i?{"X-Session-Id":i}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as Lm}from"@ai-sdk/react";import{useCallback as me,useEffect as Me,useRef as le,useState as ut}from"react";f();import{DefaultChatTransport as om,uiMessageChunkSchema as rm}from"ai";function sm(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(l=>(l.code==="invalid_value"||l.code==="invalid_literal")&&l.path?.[0]==="type"))continue;let n=r.filter(l=>l.code==="unrecognized_keys").flatMap(l=>l.keys??[]);if(n.length>0)return n}return null}var to=class extends om{processResponseStream(t){let a="",o=rm(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let l=a.split(`
82
82
  `);a=l.pop()??"";for(let i of l){let u=i.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=sm(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var nm="waniwani-memory";var ke="threads",ao="by_memoryUserId",im="by_updatedAt";var rl="memoryUserId",ol="waniwani-memory-user-id",lr=null;function ur(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function lm(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(ke)){let a=e.createObjectStore(ke,{keyPath:"threadId"});a.createIndex(ao,"memoryUserId",{unique:!1}),a.createIndex(im,"updatedAt",{unique:!1})}}async function dr(){return new Promise((e,t)=>{let a=indexedDB.open(nm,2);a.onupgradeneeded=o=>{lm(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function um(){return dr()}async function dm(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(rl);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function cm(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,rl);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function fm(){if(typeof indexedDB>"u")return null;try{let e=await um();try{let t=await dm(e);if(t)return t;let a=ur();return await cm(e,a),a}finally{e.close()}}catch{return null}}function pm(){try{let e=localStorage.getItem(ol);if(e)return e;let t=ur();return localStorage.setItem(ol,t),t}catch{return null}}async function sl(){let e=await fm();if(e)return e;let t=pm();return t||(lr||(lr=ur()),lr)}var nl=50,il=1e3;function oo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function ro(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await dr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function cr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function fr(e){return await ro(async a=>{let s=a.transaction(ke,"readonly").objectStore(ke).index(ao),l=(await cr(s.getAll(e))??[]).filter(oo);return l.sort((i,u)=>i.updatedAt<u.updatedAt?1:-1),l})??[]}async function pr(e){return await ro(async a=>{let r=a.transaction(ke,"readonly").objectStore(ke),s=await cr(r.get(e));return oo(s)?s:null})??null}async function mr(e){if(!oo(e))return;let t=e.messages.length>il?{...e,messages:e.messages.slice(e.messages.length-il)}:e;await ro(async a=>{await new Promise((i,u)=>{let c=a.transaction(ke,"readwrite");c.oncomplete=()=>i(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(ke).put(t)});let o=a.transaction(ke,"readwrite"),r=o.objectStore(ke),s=r.index(ao),l=(await cr(s.getAll(t.memoryUserId))??[]).filter(oo);if(l.length>nl){l.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let i=l.slice(0,l.length-nl);for(let u of i)r.delete(u.threadId)}return await new Promise((i,u)=>{o.oncomplete=()=>i(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function ll(e){await ro(async t=>(await new Promise((a,o)=>{let r=t.transaction(ke,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(ke).delete(e)}),null))}async function ul(e){return(await fr(e))[0]?.threadId??null}function dl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var cl="waniwani-visitor-id";function fl(e,t){return e.match(t)?.[1]??null}function mm(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=fl(e,o);if(r)return{name:a,version:r}}return null}function hm(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=fl(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function gm(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function wm(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function xm(){try{let a=localStorage.getItem(cl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await wm(e);try{localStorage.setItem(cl,t)}catch{}return t}async function pl(){let e=navigator.userAgent,[t,a]=await Promise.all([xm(),sl()]);return{userAgent:e,browser:mm(e),os:hm(e),deviceType:gm(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var Cm="x-session-id",Im=250;function ml(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Wt()}function so(){return new Date().toISOString()}function hl(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Sm(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function gl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:l,onThreadChange:i}=e,u=le(a),c=le(o),d=le(n);Me(()=>{d.current=n},[n]);let p=le(void 0),m=le(null),[h,I]=ut(void 0),L=le(h),[S,C]=ut(l),g=le(S),[y,T]=ut([]),[v,R]=ut(!n),k=le(void 0),_=le(void 0),A=le(void 0),E=le(void 0),P=le(0),M=le(i);Me(()=>{M.current=i},[i]);let O=me(b=>{g.current=b,C(b),b&&M.current?.(b)},[]),F=me(async()=>{if(!n)return;let b=m.current?.memoryUserId;if(!b)return;let N=await fr(b);T(N)},[n]),j=me(()=>L.current,[]),be=me(b=>{let N=hl(b);N&&L.current!==N&&(L.current=N,I(N))},[]),ue=me(()=>{L.current=void 0,I(void 0)},[]);Me(()=>{u.current=a},[a]),Me(()=>{c.current=o},[o]),Me(()=>{let b=!1,N=P.current;return(async()=>{try{let Pe=await pl();if(b)return;m.current=Pe}catch{}if(!n)return;let U=m.current?.memoryUserId;if(!U){R(!0);return}try{let Pe=l??await ul(U);if(b||N!==P.current)return;if(Pe){let Le=await pr(Pe);if(b||N!==P.current)return;Le&&Le.memoryUserId===U&&(g.current=Le.threadId,C(Le.threadId),k.current=Le.createdAt,_.current=Le.title,Le.sessionId&&(L.current=Le.sessionId,I(Le.sessionId)),oe(Le.messages))}await F()}finally{b||R(!0)}})(),()=>{b=!0}},[]);let te=le(new to({api:t,headers:()=>({...u.current}),body:()=>{let b={...c.current??{}},N=Object.hasOwn(b,"sessionId"),U=hl(b.sessionId);if(U)be(U),b.sessionId=U;else if(N)ue(),delete b.sessionId;else{let Ae=j();Ae&&(b.sessionId=Ae)}if(ft(p.current)&&(b.modelContext=p.current),m.current){let Ae=m.current;b.visitorContext={timezone:Ae.timezone,language:Ae.language,languages:Ae.languages,deviceType:Ae.deviceType,referrer:Ae.referrer,visitorId:Ae.visitorId};let Oe=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},_l=typeof Oe.client=="object"&&Oe.client!==null?Oe.client:{};b.visitor={...Oe,client:{..._l,memoryUserId:Ae.memoryUserId}}}let Pe=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,Le=m.current?.memoryUserId,Ve=m.current?.language,ia={};if(Le&&(ia.memoryUserId=Le),Ve&&(ia.locale=Ve),(Object.keys(ia).length>0||Pe)&&(b.extra={...ia,...Pe??{}}),d.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(g.current=b.threadId);else{let Oe=g.current;Oe||(Oe=ml(),k.current=so(),_.current=void 0,O(Oe)),b.threadId=Oe}return b},fetch:(async(b,N)=>{let U=await fetch(b,N);return p.current=void 0,be(U.headers.get(Cm)),U})})),ge=le(null),q=le(null),ae=le({}),[de,Ge]=ut(0),we=e.skipRemoteConfig===!0,je=me(async()=>{if(!we)try{let b=await Sm(t,u.current);ae.current=b,Ge(N=>N+1)}catch(b){console.warn("[WaniWani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,we]);Me(()=>{je()},[je]);let{messages:ce,sendMessage:Z,setMessages:oe,status:W}=Lm({messages:e.initialMessages,transport:te.current,onFinish({message:b}){s?.(),ge.current&&(q.current=b)},onError(b){console.warn("[WaniWani] Chat error:",b.message),ge.current&&(ge.current.reject(b),ge.current=null)}}),z=le(ce);Me(()=>{z.current=ce},[ce]),Me(()=>{if(W==="ready"&&ge.current&&q.current){let b=ge.current,N=q.current;ge.current=null,q.current=null,b.resolve(N)}},[W]);let[X,H]=ut(""),[K,re]=ut([]),Te=W==="submitted"||W==="streaming",ze=me(b=>{re(N=>N.filter(U=>U.id!==b))},[]),dt=Te&&K.length>0,ct=me(b=>{let N=!!b.text?.trim(),U=!!b.files?.length;if(N||U){if(Te){if(K.length>0)return;re(Pe=>[...Pe,{id:Wt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),H("");return}p.current=b.modelContext,Z({text:b.text||"",files:b.files}),r?.(b.text||""),H("")}},[Z,r,Te,K.length]),Al=me(b=>new Promise((N,U)=>{ge.current={resolve:N,reject:U},Z({text:b}),r?.(b)}),[Z,r]);Me(()=>{if(W!=="ready"||K.length===0)return;let[b,...N]=K;re(N),p.current=b.modelContext,Z({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text)},[W,Z,r,K]);let Rl=me(()=>{oe([]),re([]),ue(),H(""),ae.current={},Ge(b=>b+1),je()},[oe,ue,je]),sa=me(()=>{if(!d.current)return;let b=m.current?.memoryUserId,N=g.current,U=z.current;if(!(!b||!N||U.length===0)){if(k.current||(k.current=so()),!_.current){let Pe=U.find(Ve=>Ve.role==="user"),Le=Pe?Pe.parts.map(Ve=>"text"in Ve&&typeof Ve.text=="string"?Ve.text:"").join(" "):"";_.current=dl(Le)}return{threadId:N,memoryUserId:b,title:_.current,messages:U,sessionId:L.current,createdAt:k.current,updatedAt:so()}}},[]),wr=me(async()=>{let b=sa();b&&(await mr(b),await F())},[sa,F]);Me(()=>{if(n&&v&&!(W==="submitted"||W==="streaming")&&ce.length!==0)return A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{A.current=void 0;let b=wr().finally(()=>{E.current===b&&(E.current=void 0)});E.current=b},Im),()=>{A.current&&clearTimeout(A.current)}},[n,v,ce,W,wr]);let na=me(()=>{let b=E.current,N=A.current,U=N?sa():void 0;return N&&(clearTimeout(N),A.current=void 0),(async()=>{b&&await b,U&&(await mr(U),await F())})()},[sa,F]),Ml=me(()=>{P.current+=1,na(),oe([]),re([]),ue(),H("");let b=ml();return k.current=so(),_.current=void 0,O(b),F(),b},[oe,ue,O,F,na]),no=me(async b=>{P.current+=1;let N=P.current;if(await na(),N!==P.current)return;let U=await pr(b);N===P.current&&U&&(O(U.threadId),k.current=U.createdAt,_.current=U.title,U.sessionId?(L.current=U.sessionId,I(U.sessionId)):ue(),oe(U.messages),re([]),H(""))},[oe,ue,O,na]),Fl=me(async b=>{if(g.current===b){P.current+=1,A.current&&(clearTimeout(A.current),A.current=void 0);let N=E.current;N&&await N}await ll(b),await F(),g.current===b&&(oe([]),re([]),ue(),H(""),g.current=void 0,C(void 0),k.current=void 0,_.current=void 0)},[oe,ue,F]);Me(()=>{n&&v&&l!==void 0&&l!==g.current&&no(l)},[l,n,v,no]);let Dl=me(b=>{H(b.target.value)},[]),xr=ce[ce.length-1],Lr=ce.length>0,Bl=Te&&(!Lr||xr.role==="user"),El=ae.current;return{messages:ce,status:W,text:X,setText:H,handleSubmit:ct,handleTextChange:Dl,isLoading:Te,showLoaderBubble:Bl,lastMessage:xr,hasMessages:Lr,sendMessage:Z,sendMessageAndWait:Al,reset:Rl,queuedMessages:K,queueFull:dt,removeQueuedMessage:ze,sessionId:h,toolDefinitions:El,refreshToolDefinitions:je,threads:y,activeThreadId:S,isThreadHistoryReady:v,startNewThread:Ml,switchThread:no,deleteThread:Fl}}f();import{useEffect as wl,useRef as ym,useState as km}from"react";var bm={debug:!1,eval:!1};function xl(e="/api/waniwani",t,a=!1){let[o,r]=km(bm),s=ym(t);return wl(()=>{s.current=t},[t]),wl(()=>{a||(async()=>{try{let n=s.current,i=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:i.debug===!0,eval:i.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as Tm,useEffect as hr,useRef as Pm,useState as vm}from"react";function Am(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Ll(e){return typeof e=="object"&&e!==null&&"initial"in e}function Cl(e){let{messages:t,status:a,config:o}=e,r=Ll(o)&&o.initial?o.initial:void 0,[s,n]=vm(r??[]),l=Pm(a),i=o===!0||Ll(o)&&o.dynamic!==!1,u=Tm(()=>{n([])},[]),c=t.length>0;hr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return hr(()=>{d?.role==="user"&&u()},[d,u]),hr(()=>{let p=l.current;if(l.current=a,p==="streaming"&&a==="ready"&&i){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=Am(m);h&&n(h)}},[a,i,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as Rm,useRef as Mm,useState as Fm}from"react";var Dm=50,Bm=30,Em=2e3,Il=500;function Sl(e,t=!0){let[a,o]=Fm(""),r=Mm(void 0);return Rm(()=>{if(!t){o("");return}let s=0,n=!1,l=!1,i=()=>{l||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(i,Il)):r.current=setTimeout(i,Bm)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(i,Em)):r.current=setTimeout(i,Dm)))};return r.current=setTimeout(i,Il),()=>{l=!0,clearTimeout(r.current)}},[e,t]),a}f();function yl(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var _m={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var Nm={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function kl(e){return{..._m,...e}}function bl(e){let t=e.backgroundColor.replace("#",""),a=parseInt(t.substring(0,2),16),o=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16);return(a*299+o*587+r*114)/1e3<128}function Tl(e){let t={};for(let[a,o]of Object.entries(Nm)){let r=e[a],s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as he,jsxs as ra}from"react/jsx-runtime";var qm=Om(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:l,allowAttachments:i=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=yl(S,t.headers),g=kl(o),y=Tl(g),T=bl(g),v=xl(S,t.headers,t.skipRemoteConfig),R=h??v.debug,k=gl({...t,api:S}),_=al({...t,api:S,sessionId:k.sessionId}),A=Sl(d,!k.text),[E,P]=vl(!1),[M,O]=vl(null),F=Pl(null),j=Pl(void 0),be=gr(()=>{let q=F.current;if(!q)return;q.scrollIntoView({behavior:"smooth",block:"center"});let ae=q.querySelector("textarea");ae&&setTimeout(()=>ae.focus(),300),P(!0),clearTimeout(j.current),j.current=setTimeout(()=>P(!1),2e3)},[]),ue=Cl({messages:k.messages,status:k.status,config:t.suggestions}),te=gr(q=>{let ae=q.content.map(de=>de.text??"").join("").trim();ae&&k.handleSubmit({text:ae,files:[],modelContext:q.modelContext})},[k.handleSubmit]),ge=gr(q=>{ue.clear(),k.handleSubmit({text:q,files:[]})},[ue.clear,k.handleSubmit]);return Hm(a,()=>({sendMessage:q=>{k.handleSubmit({text:q,files:[]}),be()},sendMessageAndWait:q=>k.sendMessageAndWait(q),reset:k.reset,focus:be,get messages(){return k.messages}}),[k.handleSubmit,k.sendMessageAndWait,k.reset,k.messages,be]),Um(()=>{if(!p)return;let q=ae=>{let de=ae.detail,Ge=typeof de?.message=="string"?de.message:void 0;Ge&&k.handleSubmit({text:Ge,files:[]}),be()};return window.addEventListener(p,q),()=>window.removeEventListener(p,q)},[p,k.handleSubmit,be]),ra("div",{ref:F,style:{...y,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...T?{"data-waniwani-dark":""}:{},className:B("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",E&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",l),children:[ra("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[he("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),he(Ks,{messages:k.messages,evalEnabled:v.eval,api:S}),I&&he(tl,{threads:k.threads,activeThreadId:k.activeThreadId,onNewThread:k.startNewThread,onSelectThread:q=>{k.switchThread(q)},onDeleteThread:q=>{k.deleteThread(q)}})]}),ra(Ps,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[he(vs,{scrollClassName:M?"ww:!relative ww:!overflow-hidden":void 0,children:he(Ji,{messages:k.messages,status:k.status,welcomeMessage:u,welcome:c,onSuggestionSelect:ge,resourceEndpoint:C,chatSessionId:k.sessionId,isDark:T,onFollowUp:te,onCallTool:_,fullscreenToolCallId:M,debug:R,showToolCalls:L,toolDefinitions:k.toolDefinitions,onWidgetDisplayModeChange:(q,ae)=>{O(q==="fullscreen"?ae.toolCallId:null)}})}),he(As,{})]}),he("div",{style:M?{display:"none"}:void 0,children:he(Yi,{suggestions:ue.suggestions,isLoading:ue.isLoading,onSelect:ge})}),he("div",{style:M?{display:"none"}:void 0,children:he($s,{queuedMessages:k.queuedMessages,onRemove:k.removeQueuedMessage})}),he("div",{style:M?{display:"none"}:void 0,children:he("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ra("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[he(Es,{onSubmit:k.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ra("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&he(Os,{}),he(_s,{onChange:k.handleTextChange,value:k.text,placeholder:A,className:"ww:min-h-0 ww:py-1 ww:px-0"}),he(Ns,{status:k.status,disabled:k.queueFull})]})}),he(Zi,{})]})})})]})});export{qm as ChatCard,Hr as DevModeProvider,jl as InitializeNextJsInIframe,hu as LoadingWidget,jr as WidgetProvider,Er as createResource,Hl as createTool,io as detectPlatform,fa as getMockState,Tt as initializeMockOpenAI,Ol as isMCPApps,Nl as isOpenAI,ql as registerTools,$w as toNextJsHandler,vt as updateMockDisplayMode,Ye as updateMockGlobal,At as updateMockTheme,Pt as updateMockToolOutput,zr as useCallTool,Vr as useDisplayMode,$r as useFlowAction,Xr as useIsChatGptApp,Kr as useLocale,Qr as useMaxHeight,Jr as useOpenExternal,Zr as useRequestDisplayMode,Yr as useSafeArea,es as useSendFollowUp,ts as useTheme,ma as useToolOutput,as as useToolResponseMetadata,os as useUpdateModelContext,G as useWidgetClient,rs as useWidgetState};
83
83
  /*! Bundled license information:
84
84