@waniwani/sdk 0.19.2 → 0.19.3

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,8 +78,8 @@ import{a as ko,b as Wu,c as Gu}from"../chunk-R6LESDWJ.js";import{b as Mt,c as Ct
78
78
  \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Qi(e,t,a,o){let r=o.schema,n=r.space==="svg"?!1:o.settings.omitOptionalTags,s=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ba);let u=_p(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(s=!1),(u||!n||!Ki(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),s&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!s&&(!n||!fa(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function _p(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let n=Op(e,r,t[r]);n&&a.push(n)}}for(;++o<a.length;){let n=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&n!=='"'&&n!=="'"&&(a[o]+=" ")}return a.join("")}function Op(e,t,a){let o=un(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,n=e.settings.allowDangerousCharacters?0:1,s=e.quote,i;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 l=Qe(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ja.name[r][n]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?cn:fn)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=Qe(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ja.unquoted[r][n]}))),i!==a&&(e.settings.quoteSmart&&To(a,s)>To(a,e.alternative)&&(s=e.alternative),i=s+Qe(a,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Ja.single:Ja.double)[r][n],attribute:!0}))+s),l+(i&&"="+i))}f();f();var Np=["<","&"];function Ya(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:Np}))}function Ji(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ya(e,t,a,o)}f();function Yi(e,t,a,o){return o.all(e)}var Zi=pn("type",{invalid:Up,unknown:Hp,handlers:{comment:ji,doctype:zi,element:Qi,raw:Ji,root:Yi,text:Ya}});function Up(e){throw new Error("Expected node, not `"+e+"`")}function Hp(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var qp={},Wp={},Gp=[];function cr(e,t){let a=t||qp,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:jp,all:zp,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||mn,characterReferences:a.characterReferences||Wp,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ba:dn,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function jp(e,t,a){return Zi(e,t,a,this)}function zp(e){let t=[],a=e&&e.children||Gp,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Za(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,n]of Object.entries(t?.colorReplacements||{}))typeof n=="string"?a[r]=n:r===o&&Object.assign(a,n);return a}function ot(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Vp(e){return Array.isArray(e)?e:[e]}async function sl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function wr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function il(e){return e==="ansi"||wr(e)}function xr(e){return e==="none"}function ll(e){return xr(e)}function ul(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 ro(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let n=0;n<a.length;n+=2){let s=t?a[n]+(a[n+1]||""):a[n];r.push([s,o]),o+=a[n].length,o+=a[n+1]?.length||0}return r}function $p(e){let t=ro(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let n=r,s=0;for(let i of t){if(n<i.length)break;n-=i.length,s++}return{line:s,character:n}}function o(r,n){let s=0;for(let i=0;i<r;i++)s+=t[i].length;return s+=n,s}return{lines:t,indexToPos:a,posToIndex:o}}function dl(e,t,a){let o=new Set;for(let n of e.matchAll(/:?lang=["']([^"']+)["']/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/\\begin\{([\w-]+)\}/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let s=n[1].toLowerCase().trim(),i=s.includes("/")?s.split("/").pop():s;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(n=>n&&r[n])}var Cr="light-dark()",Xp=["color","background-color"];function Kp(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 Qp(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 n=a.filter(s=>r.offset<s&&s<r.offset+r.content.length).map(s=>s-r.offset).sort((s,i)=>s-i);return n.length?Kp(r,n):r})):e}function Jp(e,t,a,o,r="css-vars"){let n={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(c=>eo(e.variants[c])),i=new Set(s.flatMap(c=>Object.keys(c))),l={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return s.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&Xp.includes(p))if(o===Cr&&s.length>1){let g=t.findIndex(x=>x==="light"),I=t.findIndex(x=>x==="dark");if(g===-1||I===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let C=s[g][p]||"inherit",S=s[I][p]||"inherit";l[p]=`light-dark(${C}, ${S})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),n.htmlStyle=l,n}function eo(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&xe.Italic&&(t["font-style"]="italic"),e.fontStyle&xe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&xe.Underline&&a.push("underline"),e.fontStyle&xe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function mr(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var cl=new WeakMap;function no(e,t){cl.set(e,t)}function ma(e){return cl.get(e)}var vt=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(Vp(a).map(o=>[o,$a])),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 Yp(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Yp(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let n=r?.nameScopesList?.scopeName;n&&t.push(n),r.parent&&o(r.parent)}return o(e),t}function Zp(e,t){if(!(e instanceof vt))throw new re("Invalid grammar state");return e.getInternalStack(t)}function em(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(s){if(typeof s=="number"){if(s<0||s>a.source.length)throw new re(`Invalid decoration offset: ${s}. Code length: ${a.source.length}`);return{...r.indexToPos(s),offset:s}}else{let i=r.lines[s.line];if(i===void 0)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${i.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=$p(a.source),n=(a.options.decorations||[]).map(s=>({...s,start:o(s.start),end:o(s.end)}));tm(n),e.set(a.meta,{decorations:n,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(s=>[s.start.offset,s.end.offset]);return Qp(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 re(`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 n(c,d,p,m){let g=r[c],I="",C=-1,S=-1;if(d===0&&(C=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=g.children.length),C===-1||S===-1)for(let L=0;L<g.children.length;L++)I+=fl(g.children[L]),C===-1&&I.length===d&&(C=L+1),S===-1&&I.length===p&&(S=L+1);if(C===-1)throw new re(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new re(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let x=g.children.slice(C,S);if(!m.alwaysWrap&&x.length===g.children.length)i(g,m,"line");else if(!m.alwaysWrap&&x.length===1&&x[0].type==="element")i(x[0],m,"token");else{let L={type:"element",tagName:"span",properties:{},children:x};i(L,m,"wrapper"),g.children.splice(C,x.length,L)}}function s(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},g=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&ul(c,d.properties.class),c=g(c,p)||c,c}let l=[],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)n(d.line,d.character,p.character,c);else if(d.line<p.line){n(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>s(m,c));n(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function tm(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new re(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],n=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,s=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(n||s||i||l){if(n&&s||i&&l||i&&a.start.offset===a.end.offset||s&&r.start.offset===r.end.offset)continue;throw new re(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function fl(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(fl).join(""):""}var am=[em()];function to(e){let t=om(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...am]}function om(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 mt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],fr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function rm(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 el(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 nm(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)fr[o]&&t.push({type:"setDecoration",value:fr[o]});else if(o<=29){let r=fr[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:mt[o-30]}});else if(o===38){let r=el(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:mt[o-40]}});else if(o===48){let r=el(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:mt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-100+8]}})}return t}function sm(){let e=null,t=null,a=new Set;return{parse(o){let r=[],n=0;do{let s=rm(o,n),i=s.sequence?o.substring(n,s.startPosition):o.substring(n);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),s.sequence){let l=nm(s.sequence);for(let u of l)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 l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}n=s.position}while(n<o.length);return r}}}var im={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 lm(e=im){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<mt.length;u++)o.push(t(mt[u]));let i=[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([i[u],i[c],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function n(i){return r()[i]}function s(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return n(i.index)}}return{value:s}}var um={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 dm(e,t,a){let o=Za(e,a),r=ro(t),n=Object.fromEntries(mt.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||um[l]]})),s=lm(n),i=sm();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?s.value(u.background):e.bg,d=u.foreground?s.value(u.foreground):e.fg):(c=u.foreground?s.value(u.foreground):e.fg,d=u.background?s.value(u.background):void 0),c=ot(c,o),d=ot(d,o),u.decorations.has("dim")&&(c=cm(c));let p=xe.None;return u.decorations.has("bold")&&(p|=xe.Bold),u.decorations.has("italic")&&(p|=xe.Italic),u.decorations.has("underline")&&(p|=xe.Underline),u.decorations.has("strikethrough")&&(p|=xe.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function cm(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],n=o[1],s=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${n}${n}${s}${s}${l}`}else if(o.length===3){let r=o[0],n=o[1],s=o[2];return`#${r}${r}${n}${n}${s}${s}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Lr(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(wr(r)||xr(o))return ro(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:n,colorMap:s}=e.setTheme(o);if(r==="ansi")return dm(n,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new re(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new re(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return pm(t,i,n,s,a)}function fm(...e){if(e.length===2)return ma(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:n=t.getLoadedThemes()[0]}=o;if(wr(r)||xr(n))throw new re("Plain language does not have grammar state");if(r==="ansi")throw new re("ANSI language does not have grammar state");let{theme:s,colorMap:i}=t.setTheme(n),l=t.getLanguage(r);return new vt(Ir(a,l,s,i,o).stateStack,l.name,s.name)}function pm(e,t,a,o,r){let n=Ir(e,t,a,o,r),s=new vt(n.stateStack,t.name,a.name);return no(n.tokens,s),n.tokens}function Ir(e,t,a,o,r){let n=Za(a,r),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:i=500}=r,l=ro(e),u=r.grammarState?Zp(r.grammarState,a.name)??$a:r.grammarContextCode!=null?Ir(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:$a,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[g,I]=l[p];if(g===""){c=[],d.push([]);continue}if(s>0&&g.length>=s){c=[],d.push([{content:g,offset:I,color:"",fontStyle:0}]);continue}let C,S,x;r.includeExplanation&&(C=t.tokenizeLine(g,u,i),S=C.tokens,x=0);let L=t.tokenizeLine2(g,u,i),y=L.tokens.length/2;for(let k=0;k<y;k++){let P=L.tokens[2*k],F=k+1<y?L.tokens[2*k+2]:g.length;if(P===F)continue;let R=L.tokens[2*k+1],_=ot(o[pt.getForeground(R)],n),M=pt.getFontStyle(R),E={content:g.substring(P,F),offset:I+P,color:_,fontStyle:M};if(r.includeExplanation){let v=[];if(r.includeExplanation!=="scopeName")for(let H of a.settings){let T;switch(typeof H.scope){case"string":T=H.scope.split(/,/).map(O=>O.trim());break;case"object":T=H.scope;break;default:continue}v.push({settings:H,selectors:T.map(O=>O.split(/ /))})}E.explanation=[];let D=0;for(;P+D<F;){let H=S[x],T=g.substring(H.startIndex,H.endIndex);D+=T.length,E.explanation.push({content:T,scopes:r.includeExplanation==="scopeName"?mm(H.scopes):gm(v,H.scopes)}),x+=1}}c.push(E)}d.push(c),c=[],u=L.ruleStack}return{tokens:d,stateStack:u}}function mm(e){return e.map(t=>({scopeName:t}))}function gm(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let n=t[o];a[o]={scopeName:n,themeMatches:wm(e,n,t.slice(0,o))}}return a}function tl(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function hm(e,t,a){if(!tl(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)tl(e[o],a[r])&&(o-=1),r-=1;return o===-1}function wm(e,t,a){let o=[];for(let{selectors:r,settings:n}of e)for(let s of r)if(hm(s,t,a)){o.push(n);break}return o}function pl(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=Lr(e,t,{...a,theme:l.theme}),c=ma(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),n=xm(...r.map(l=>l.tokens)),s=n[0].map((l,u)=>l.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),n.forEach((m,g)=>{let{content:I,explanation:C,offset:S,...x}=m[u][d];p.variants[o[g].color]=x}),p})),i=r[0].state?new vt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&no(s,i),s}function xm(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),n=t.map(()=>[]);t.forEach((l,u)=>l.push(n[u]));let s=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(n[u].push(c),s[u]+=1,i[u]=r[u][s[u]]):(n[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function ao(e,t,a){let o,r,n,s,i,l;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,x)=>S.color===u?-1:x.color===u?1:0);if(p.length===0)throw new re("`themes` option must not be empty");let m=pl(e,t,a);if(l=ma(m),u&&Cr!==u&&!p.find(S=>S.color===u))throw new re(`\`themes\` option must contain the defaultColor key \`${u}\``);let g=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);n=m.map(S=>S.map(x=>Jp(x,I,c,u,d))),l&&no(n,l);let C=p.map(S=>Za(S.theme,a));r=al(p,g,C,c,u,"fg",d),o=al(p,g,C,c,u,"bg",d),s=`shiki-themes ${g.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Za(a.theme,a);n=Lr(e,t,a);let c=e.getTheme(a.theme);o=ot(c.bg,u),r=ot(c.fg,u),s=c.name,l=ma(n)}else throw new re("Invalid options, either `theme` or `themes` must be provided");return{tokens:n,fg:r,bg:o,themeName:s,rootStyle:i,grammarState:l}}function al(e,t,a,o,r,n,s){return e.map((i,l)=>{let u=ot(t[l][n],a[l])||"inherit",c=`${o+i.color}${n==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===Cr&&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 re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=ot(t[d][n],a[d])||"inherit",g=ot(t[p][n],a[p])||"inherit";return`light-dark(${m}, ${g});${c}`}return u}return s==="css-vars"?c:null}).filter(i=>!!i).join(";")}function oo(e,t,a,o={meta:{},options:a,codeToHast:(r,n)=>oo(e,r,n),codeToTokens:(r,n)=>ao(e,r,n)}){let r=t;for(let g of to(a))r=g.preprocess?.call(o,r,a)||r;let{tokens:n,fg:s,bg:i,themeName:l,rootStyle:u,grammarState:c}=ao(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?n=Lm(n):d==="never"&&(n=Im(n)),p&&(n=Sm(n));let m={...o,get source(){return r}};for(let g of to(a))n=g.tokens?.call(m,n)||n;return Cm(n,{...a,fg:s,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Cm(e,t,a,o=ma(e)){let r=to(t),n=[],s={type:"root",children:[]},{structure:i="classic",tabindex:l="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}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,C]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=C);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:n},p=[],m={...a,structure:i,addClassToHast:ul,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,C)=>{C&&(i==="inline"?s.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&n.push({type:"text",value:`
79
79
  `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},x=0;for(let L of I){let y={type:"element",tagName:"span",properties:{...L.htmlAttrs},children:[{type:"text",value:L.content}]},k=mr(L.htmlStyle||eo(L));k&&(y.properties.style=k);for(let P of r)y=P?.span?.call(m,y,C+1,x,S,L)||y;i==="inline"?s.children.push(y):i==="classic"&&S.children.push(y),x+=L.content.length}if(i==="classic"){for(let L of r)S=L?.line?.call(m,S,C+1)||S;p.push(S),n.push(S)}else i==="inline"&&p.push(S)}),i==="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;s.children.push(c)}else if(i==="inline"){let I=[],C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let L of s.children)L.type==="element"&&L.tagName==="br"?(I.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(L.type==="element"||L.type==="text")&&C.children.push(L);I.push(C);let x={type:"element",tagName:"code",properties:{},children:I};for(let L of r)x=L?.code?.call(m,x)||x;s.children=[];for(let L=0;L<x.children.length;L++){L>0&&s.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=x.children[L];y.type==="element"&&s.children.push(...y.children)}}let g=s;for(let I of r)g=I?.root?.call(m,g)||g;return o&&no(g,o),g}function Lm(e){return e.map(t=>{let a=[],o="",r;return t.forEach((n,s)=>{let l=!(n.fontStyle&&(n.fontStyle&xe.Underline||n.fontStyle&xe.Strikethrough));l&&n.content.match(/^\s+$/)&&t[s+1]?(r===void 0&&(r=n.offset),o+=n.content):o?(l?a.push({...n,offset:r,content:o+n.content}):a.push({content:o,offset:r},n),r=void 0,o=""):a.push(n)}),a})}function Im(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,n,s]=o;if(!r&&!s)return a;let i=[{...a,offset:a.offset+r.length,content:n}];return r&&i.unshift({content:r,offset:a.offset}),s&&i.push({content:s,offset:a.offset+r.length+n.length}),i}))}function Sm(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],n=mr(r.htmlStyle||eo(r)),s=mr(o.htmlStyle||eo(o)),i=r.fontStyle&&(r.fontStyle&xe.Underline||r.fontStyle&xe.Strikethrough),l=o.fontStyle&&(o.fontStyle&xe.Underline||o.fontStyle&xe.Strikethrough);!i&&!l&&n===s?r.content+=o.content:a.push({...o})}return a})}var ym=cr;function bm(e,t,a){let o={meta:{},options:a,codeToHast:(n,s)=>oo(e,n,s),codeToTokens:(n,s)=>ao(e,n,s)},r=ym(oo(e,t,a,o));for(let n of to(a))r=n.postprocess?.call(o,r,a)||r;return r}var ol={light:"#333333",dark:"#bbbbbb"},rl={light:"#fffffe",dark:"#1e1e1e"},nl="__shiki_resolved";function Sr(e){if(e?.[nl])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 i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.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"?ol.light:ol.dark),a||(a=t.type==="light"?rl.light:rl.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,n=new Map;function s(i){if(n.has(i))return n.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?s(i):(n.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=s(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=s(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=s(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,nl,{enumerable:!1,writable:!1,value:!0}),t}async function ml(e){return Array.from(new Set((await Promise.all(e.filter(t=>!il(t)).map(async t=>await sl(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function gl(e){return(await Promise.all(e.map(async a=>ll(a)?null:Sr(await sl(a))))).filter(a=>!!a)}var pr=3,km=!1;function Tm(e,t=3){if(pr&&!(typeof pr=="number"&&t>pr)){if(km)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var at=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function hl(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 at(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var gr=class extends Bi{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(n=>this.loadTheme(n)),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=Sr(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=ia.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=hl(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(n=>n.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(n=>{this._alias[n]=t.name}),this._loadedLanguagesCache=null,a.size)for(let n of a)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.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,n])=>!n);if(o.length){let r=a.filter(([n,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(n=>!o.includes(n));throw new at(`Missing languages ${o.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of a)this._resolver.addLanguage(n);for(let[r,n]of a)this.loadLanguage(n)}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))}},hr=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 n=a.slice(0,r).join(".");o=[...o,...this._injections.get(n)||[]]}return o}},pa=0;function vm(e){pa+=1,e.warnings!==!1&&pa>=10&&pa%10===0&&console.warn(`[Shiki] ${pa} 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 at("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Sr),r=new hr(e.engine,a),n=new gr(r,o,a,e.langAlias),s;function i(L){return hl(L,e.langAlias)}function l(L){S();let y=n.getGrammar(typeof L=="string"?L:L.name);if(!y)throw new at(`Language \`${L}\` not found, you may need to load it first`);return y}function u(L){if(L==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=n.getTheme(L);if(!y)throw new at(`Theme \`${L}\` not found, you may need to load it first`);return y}function c(L){S();let y=u(L);s!==L&&(n.setTheme(y),s=L);let k=n.getColorMap();return{theme:y,colorMap:k}}function d(){return S(),n.getLoadedThemes()}function p(){return S(),n.getLoadedLanguages()}function m(...L){S(),n.loadLanguages(L.flat(1))}async function g(...L){return m(await ml(L))}function I(...L){S();for(let y of L.flat(1))n.loadTheme(y)}async function C(...L){return S(),I(await gl(L))}function S(){if(t)throw new at("Shiki instance has been disposed")}function x(){t||(t=!0,n.dispose(),pa-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:g,loadLanguageSync:m,loadTheme:C,loadThemeSync:I,dispose:x,[Symbol.dispose]:x}}async function Pm(e){e.engine||Tm("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([gl(e.themes||[]),ml(e.langs||[]),e.engine]);return vm({...e,themes:t,langs:a,engine:o})}async function Am(e){let t=await Pm(e);return{getLastGrammarState:(...a)=>fm(t,...a),codeToTokensBase:(a,o)=>Lr(t,a,o),codeToTokensWithThemes:(a,o)=>pl(t,a,o),codeToTokens:(a,o)=>ao(t,a,o),codeToHast:(a,o)=>oo(t,a,o),codeToHtml:(a,o)=>bm(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function wl(e){let t=e.langs,a=e.themes,o=e.engine;async function r(n){function s(d){if(typeof d=="string"){if(d=n.langAlias?.[d]||d,il(d))return[];let p=t[d];if(!p)throw new re(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(ll(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new re(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(n.themes??[]).map(d=>i(d)),u=(n.langs??[]).map(d=>s(d)),c=await Am({engine:n.engine??o(),...n,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(s))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Rm(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 xl(e,t){let a=Rm(e);async function o(r,n){let s=await a({langs:[n.lang],themes:"theme"in n?[n.theme]:Object.values(n.themes)}),i=await t?.guessEmbeddedLanguages?.(r,n.lang,s);return i&&await s.loadLanguage(...i),s}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,n){return(await o(r,n)).codeToHtml(r,n)},async codeToHast(r,n){return(await o(r,n)).codeToHast(r,n)},async codeToTokens(r,n){return(await o(r,n)).codeToTokens(r,n)},async codeToTokensBase(r,n){return(await o(r,n)).codeToTokensBase(r,n)},async codeToTokensWithThemes(r,n){return(await o(r,n)).codeToTokensWithThemes(r,n)},async getLastGrammarState(r,n){return(await a({langs:[n.lang],themes:[n.theme]})).getLastGrammarState(r,n)}}}f();var yr=[{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-GK625GFM.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-BBPQXDS2.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-JGB4KP74.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-K7JGTCPV.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-RWJJQSLU.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-ZFZ6ZP6X.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-HLYUQ6RF.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-UPNOBGN4.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-XE5XFLFP.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-EXRA4QJX.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-LRUOJBTB.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-JA25I4AE.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-CKELYRRF.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-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-QIUJFE3G.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-JQIESO7E.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-UBV5AWUH.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-AWDHWPK7.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-QY3ZIV7G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-BZB5LDD5.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-AEVQQKWS.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-75QR2XDN.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-S4LVU77Y.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-NDTDGSIG.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-Z6EEJ7SX.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-5IQEFQG3.js"))},{id:"php",name:"PHP",import:(()=>import("../php-UQGWKJAF.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-XHTBJJNO.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-UMC4HKIF.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-HCGHBPBZ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-ML25RVXY.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-ALTWCQTO.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-6TT7H4YP.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-WN3SJLUV.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-NAJDOQCO.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-GIY7NVAA.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-V6GLJNYA.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-KB45C76H.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"))}],Cl=Object.fromEntries(yr.map(e=>[e.id,e.import])),Ll=Object.fromEntries(yr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ga={...Cl,...Ll};f();var Mm=[{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"))}],Il=Object.fromEntries(Mm.map(e=>[e.id,e.import]));f();var ha=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Fm(){return 2147483648}function Dm(){return typeof performance<"u"?performance.now():Date.now()}var Bm=(e,t)=>e+(t-e%t)%t;async function Em(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function n(m,g,I){o.HEAPU8.copyWithin(m,g,g+I)}function s(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let g=o.HEAPU8.length;m=m>>>0;let I=Fm();if(m>I)return!1;for(let C=1;C<=4;C*=2){let S=g*(1+.2/C);S=Math.min(S,m+100663296);let x=Math.min(I,Bm(Math.max(m,S),65536));if(s(x))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,g,I=1024){let C=g+I,S=g;for(;m[S]&&!(S>=C);)++S;if(S-g>16&&m.buffer&&l)return l.decode(m.subarray(g,S));let x="";for(;g<S;){let L=m[g++];if(!(L&128)){x+=String.fromCharCode(L);continue}let y=m[g++]&63;if((L&224)===192){x+=String.fromCharCode((L&31)<<6|y);continue}let k=m[g++]&63;if((L&240)===224?L=(L&15)<<12|y<<6|k:L=(L&7)<<18|y<<12|k<<6|m[g++]&63,L<65536)x+=String.fromCharCode(L);else{let P=L-65536;x+=String.fromCharCode(55296|P>>10,56320|P&1023)}}return x}function c(m,g){return m?u(o.HEAPU8,m,g):""}let d={emscripten_get_now:Dm,emscripten_memcpy_big:n,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let g=await e({env:d,wasi_snapshot_preview1:d});t=g.memory,r(t.buffer),Object.assign(o,g),o.UTF8ToString=c}return await p(),o}var _m=Object.defineProperty,Om=(e,t,a)=>t in e?_m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,de=(e,t,a)=>Om(e,typeof t!="symbol"?t+"":t,a),ge=null;function Nm(e){throw new ha(e.UTF8ToString(e.getLastOnigError()))}var io=class e{constructor(t){de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16Value"),de(this,"utf8Value"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,n=r?new Uint32Array(a+1):null;r&&(n[a]=o);let s=r?new Uint32Array(o+1):null;r&&(s[o]=a);let i=new Uint8Array(o),l=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&&(n[u]=l,p&&(n[u+1]=l),d<=127?s[l+0]=u:d<=2047?(s[l+0]=u,s[l+1]=u):d<=65535?(s[l+0]=u,s[l+1]=u,s[l+2]=u):(s[l+0]=u,s[l+1]=u,s[l+2]=u,s[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=n,this.utf8OffsetToUtf16=s}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let n=t.charCodeAt(o),s=n,i=!1;if(n>=55296&&n<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(s=(n-55296<<10)+65536|l-56320,i=!0)}s<=127?a+=1:s<=2047?a+=2:s<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},lo=class Ve{constructor(t){if(de(this,"id",++Ve.LAST_ID),de(this,"_onigBinding"),de(this,"content"),de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16"),de(this,"ptr"),!ge)throw new ha("Must invoke loadWasm first.");this._onigBinding=ge,this.content=t;let a=new io(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ve._sharedPtrInUse?(Ve._sharedPtr||(Ve._sharedPtr=ge.omalloc(1e4)),Ve._sharedPtrInUse=!0,ge.HEAPU8.set(a.utf8Value,Ve._sharedPtr),this.ptr=Ve._sharedPtr):this.ptr=a.createString(ge)}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===Ve._sharedPtr?Ve._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};de(lo,"LAST_ID",0);de(lo,"_sharedPtr",0);de(lo,"_sharedPtrInUse",!1);var Sl=lo,kr=class{constructor(t){if(de(this,"_onigBinding"),de(this,"_ptr"),!ge)throw new ha("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new io(t[i]);a[i]=u.createString(ge),o[i]=u.utf8Length}let r=ge.omalloc(4*t.length);ge.HEAPU32.set(a,r/4);let n=ge.omalloc(4*t.length);ge.HEAPU32.set(o,n/4);let s=ge.createOnigScanner(r,n,t.length);for(let i=0,l=t.length;i<l;i++)ge.ofree(a[i]);ge.ofree(n),ge.ofree(r),s===0&&Nm(ge),this._onigBinding=ge,this._ptr=s}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Sl(t);let n=this._findNextMatchSync(t,a,!1,r);return t.dispose(),n}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let n=this._onigBinding,s=n.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(s===0)return null;let i=n.HEAPU32,l=s/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),g=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:g,length:g-m}}return{index:u,captureIndices:d}}};function Um(e){return typeof e.instantiator=="function"}function Hm(e){return typeof e.default=="function"}function qm(e){return typeof e.data<"u"}function Wm(e){return typeof Response<"u"&&e instanceof Response}function Gm(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 so;function jm(e){if(so)return so;async function t(){ge=await Em(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Um(o)?o=await o.instantiator(a):Hm(o)?o=await o.default(a):(qm(o)&&(o=o.data),Wm(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await zm(o)(a):o=await Vm(o)(a):Gm(o)?o=await br(o)(a):o instanceof WebAssembly.Module?o=await br(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await br(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return so=t(),so}function br(e){return t=>WebAssembly.instantiate(e,t)}function zm(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Vm(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function yl(e){return e&&await jm(e),{createScanner(t){return new kr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Sl(t)}}}var uo=wl({langs:ga,themes:Il,engine:()=>yl(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:$m,codeToHast:Xm,codeToTokens:Km,codeToTokensBase:Qm,codeToTokensWithThemes:Jm,getSingletonHighlighter:Ym,getLastGrammarState:Zm}=xl(uo,{guessEmbeddedLanguages:dl});var bl=new Set(Object.keys(ga)),Tr=new Map,vr=new Map,Pt=new Map,eg=(e,t)=>`${e}-${t[0]}-${t[1]}`,tg=(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}`},ag=(e,t)=>{let a=eg(e,t);if(Tr.has(a))return Tr.get(a);let o=uo({themes:t,langs:[e]});return Tr.set(a,o),o};function og(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return bl.has(o)},getSupportedLanguages(){return Array.from(bl)},getThemes(){return a},highlight({code:o,language:r,themes:n},s){let i=tg(o,r,n);return vr.has(i)?vr.get(i):(s&&(Pt.has(i)||Pt.set(i,new Set),Pt.get(i).add(s)),ag(r,n).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:n[0],dark:n[1]}});vr.set(i,c);let d=Pt.get(i);if(d){for(let p of d)p(c);Pt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),Pt.delete(i)}),null)}}}var kl=og();import{memo as ig}from"react";f();import{useEffect as rg,useRef as co,useState as ng}from"react";var sg=5,Tl=400;function vl(e,t,a={}){let{msPerChar:o=sg}=a,[r,n]=ng(t?"":e),s=co(e),i=co(t?0:e.length),l=co(0),u=co(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),s.current=e,rg(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,n(e);return}if(s.current.length-i.current>Tl&&(i.current=s.current.length-Tl),u.current!==null)return;let d=p=>{let m=s.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let g=p-l.current;if(g>=o){let I=Math.min(Math.floor(g/o),m.length-i.current);i.current+=I,n(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as fo}from"react/jsx-runtime";var Pr=({className:e,from:t,children:a,...o})=>fo("div",{className:A("ww-message ww:group ww:flex ww:w-full",t==="user"?"ww-message-user is-user ww:ml-auto ww:flex-col ww:items-end ww:[max-width:var(--ww-msg-max-width,80%)]":"ww-message-assistant is-assistant ww:flex-col",e),...o,children:fo("div",{className:A("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ar=({children:e,className:t,...a})=>fo("div",{className:A("ww-bubble ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden","ww:[font-size:var(--ww-font-size,1rem)] ww:[line-height:var(--ww-line-height,1.5)]","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:[color:var(--ww-color-user-bubble-text)] ww:group-[.is-user]:[border-radius:var(--ww-msg-radius,8px)] ww:group-[.is-user]:[padding:var(--ww-msg-pad-y,12px)_var(--ww-msg-pad-x,16px)]","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),lg={cjk:Jo,code:kl},ug={cjk:Jo},dg={enabled:!1};function cg({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let s=vl(typeof o=="string"?o:"",!!a),i=typeof o=="string"?s:o;return fo(Ft,{className:A("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??dg,plugins:a?ug:lg,...r,children:i})}var po=ig(cg,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);po.displayName="MessageResponse";f();import{createContext as fg,useCallback as pg,useContext as Ml,useEffect as mg,useMemo as Mr,useRef as gg,useState as Fr}from"react";import{Fragment as Rl,jsx as K,jsxs as gt}from"react/jsx-runtime";function hg(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=[],n=t-2;for(let[s,i]of o){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),n-=c.length+3}return`{${r.join(", ")}}`}function wg({text:e,className:t}){let{t:a}=V(),[o,r]=Fr(!1),n=gg(null);mg(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=pg(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return K(Ge,{variant:"ghost",size:"sm",onClick:s,className:A("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:o?gt(Rl,{children:[K(Gt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copied})]}):gt(Rl,{children:[K(zt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copy})]})})}function Fl({data:e,label:t,className:a,...o}){let[r,n]=Fr(!1),s=Mr(()=>JSON.stringify(e,null,2),[e]),i=hg(e);return gt("div",{className:A("ww:rounded-lg ww:bg-tool-card",a),...o,children:[gt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[K("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),K(wg,{text:s})]}),gt("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[K(jt,{className:A("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?K("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:K("code",{children:s})}):K("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Dr=fg({open:!1,toggle:()=>{}});function Dl({className:e,defaultOpen:t=!1,children:a,...o}){let[r,n]=Fr(t);return K(Dr.Provider,{value:{open:r,toggle:()=>n(s=>!s)},children:K("div",{className:A("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:a})})}function Bl({className:e,title:t,state:a,...o}){let{open:r,toggle:n}=Ml(Dr),s=a==="input-available"||a==="input-streaming",i=t??"";return gt("button",{type:"button",onClick:n,className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...o,children:[K(it,{className:"ww:size-4 ww:shrink-0"}),K("span",{className:"ww:truncate",children:s?K(Oe,{duration:1.6,children:i}):i}),K(Je,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function El({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",n=t??"";return K("div",{className:A("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:K("span",{className:"ww:truncate",children:r?K(Oe,{duration:1.6,children:n}):n})})}function _l({className:e,children:t,...a}){let{open:o}=Ml(Dr);return K("div",{className:A("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:K("div",{className:"ww:min-h-0 ww:overflow-hidden",children:K("div",{className:A("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 Br({className:e,input:t,debug:a,...o}){let{t:r}=V(),n=Mr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return K(Fl,{data:n,label:r.tool.request,className:e,...o})}function Rr(e){if(!(typeof e!="object"||e===null))return e}function Ol(e){return Rr(e?.ui)}function Nl(e){return Rr(Rr(e)?._meta)}function Pl(e){if(!e)return;let t=Ol(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 Al(e){return Ol(e)?.autoHeight===!0}function wa(e,t,a){if(e){let o=Pl(a?.[e]?._meta);if(o)return o}return Pl(Nl(t))}function Ul(e,t,a){return e&&Al(a?.[e]?._meta)?!0:Al(Nl(t))}function Er({className:e,output:t,errorText:a,debug:o,...r}){let{t:n}=V(),s=Mr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?gt("div",{className:A("ww:space-y-2",e),...r,children:[K("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),K("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):K(Fl,{data:s,label:n.tool.response,className:e,...r}):null}f();import{jsx as Hl,jsxs as xg}from"react/jsx-runtime";function ql(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function Wl(e){return e.parts.some(ql)}function Gl(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let o=e[e.length-1];return!o||o.role!=="assistant"?!0:!o.parts.some(n=>!(!ql(n)||a?.ignoreToolParts&&"toolCallId"in n||a?.ignoreReasoningParts&&n.type==="reasoning"))}function jl({className:e,...t}){let{t:a}=V();return xg("div",{"aria-live":"polite",className:A("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[Hl(Jt,{className:"ww:size-4 ww:shrink-0"}),Hl(Oe,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as Cg,useEffect as _r,useMemo as Lg,useRef as ye,useState as zl}from"react";import{jsx as Mg}from"react/jsx-runtime";var Ig="/api/mcp/resource",Sg=500,yg=0,bg=16,kg="2026-01-26",Tg=300,vg=3e3,Pg=3;function Ag(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Rg(e,t,a){return wa(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Vl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Ig,chatSessionId:r,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let g=ye(null),I=ye(t),C=ye(a),S=ye({width:0,height:0}),x=ye(null),L=ye(!1),y=ye(0),k=ye("inline"),[P,F]=zl(yg),[R,_]=zl(void 0),M=ye(l),E=ye(u),v=ye(c),D=ye(d),H=ye(r),T=ye(m);I.current=t,C.current=a,M.current=l,E.current=u,v.current=c,D.current=d,H.current=r,T.current=m;let O=Cg(W=>i?Math.max(W+bg,0):Math.min(Math.max(W,50),Sg),[i]),U=Lg(()=>{let W=o.includes("?")?"&":"?";return`${o}${W}uri=${encodeURIComponent(e)}`},[o,e]),Be=ye(n);Be.current=n;let be=ye(p);return _r(()=>{be.current=p,S.current.height=-1,x.current&&(x.current.cancel(),x.current=null)},[p]),_r(()=>{if(!L.current)return;let W=g.current;W?.contentWindow&&W.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),_r(()=>{let W=g.current;if(!W)return;let ke=!1,ue=!1,Ae=null,he=null,Q=setTimeout(()=>{if(ke||ue||y.current>=Pg)return;y.current+=1;let Ie=new URL(W.src);Ie.searchParams.set("_retry",String(y.current)),W.src=Ie.toString()},vg),J=Ie=>{W.contentWindow?.postMessage(Ie,"*")},Ue=Ie=>{if(ke||Ie.source!==W.contentWindow)return;let te=Ie.data;if(!te||typeof te!="object"||te.jsonrpc!=="2.0")return;let fe=te.method,z=te.id;if(fe==="ui/initialize"&&z!=null){ue=!0,clearTimeout(Q),J({jsonrpc:"2.0",id:z,result:{protocolVersion:te.params?.protocolVersion??kg,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Be.current?"dark":"light",displayMode:k.current}}});return}if(fe==="ui/notifications/initialized"){L.current=!0;let G=I.current,X=C.current,ae=X._meta&&typeof X._meta=="object"?X._meta:null,pe=Ag(H.current),se=ae&&typeof ae.waniwani=="object"&&ae.waniwani!==null?ae.waniwani:null,Te=se||pe?{...se??{},...pe?{sessionId:pe}:{}}:void 0,ve=ae||Te?{...ae??{},...Te?{waniwani:Te}:{}}:void 0;J({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:G}});let He=X.content??[{type:"text",text:JSON.stringify(X)}];J({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:He,structuredContent:X.structuredContent,_meta:ve,meta:ve}});return}if(fe==="ui/notifications/size-changed"){let G=te.params,X=typeof G?.height=="number"?G.height:void 0,ae=typeof G?.width=="number"?G.width:void 0,pe=S.current,se=X!==void 0&&X!==pe.height,Te=ae!==void 0&&ae!==pe.width;if(!se&&!Te)return;if(se&&X!==void 0){if(pe.height=X,be.current)return;let ve=O(X),He=W.getBoundingClientRect().height;if(x.current&&(x.current.cancel(),x.current=null),F(ve),W.animate&&Math.abs(He-ve)>2){let xt=W.animate([{height:`${He}px`},{height:`${ve}px`}],{duration:Tg,easing:"ease-out",fill:"forwards"});x.current=xt,xt.onfinish=()=>{x.current===xt&&(xt.cancel(),x.current=null)}}}Te&&i&&ae!==void 0&&(pe.width=ae,_(ae));return}if(fe==="ui/open-link"&&z!=null){let G=te.params?.url;typeof G=="string"&&(M.current?M.current(G):window.open(G,"_blank","noopener,noreferrer")),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/message"&&z!=null){if(E.current&&te.params){let G=te.params,X=Ae;if(Ae=null,he){clearTimeout(he.timer);let ae=he.text;he=null;let pe=(G.content??[]).map(se=>se.text??"").join("").trim();G={...G,content:[{type:"text",text:`${pe}
80
80
 
81
- ${ae}`}]}}E.current({...G,...X?{modelContext:X}:{}})}J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/update-model-context"&&z!=null){Ae=on(Ae,te.params),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="tools/call"&&z!=null){let G=v.current;if(!G){J({jsonrpc:"2.0",id:z,error:{code:-32601,message:"tools/call not supported"}});return}let X=te.params?.name;G({name:X,arguments:te.params?.arguments??{}}).then(ae=>{J({jsonrpc:"2.0",id:z,result:ae});let pe=ae.content?.map(se=>se.text??"").join("").trim();pe&&Rg(X,ae,T.current)&&(he&&clearTimeout(he.timer),he={text:pe,timer:setTimeout(()=>{if(ke)return;let se=Ae;Ae=null,he=null,E.current?.({role:"user",content:[{type:"text",text:pe}],...se?{modelContext:se}:{}})},500)})}).catch(ae=>{let pe=ae instanceof Error?ae.message:"Tool call failed";J({jsonrpc:"2.0",id:z,error:{code:-32e3,message:pe}})});return}if(fe==="ui/request-display-mode"&&z!=null){let G=te.params?.mode,X=G==="fullscreen"||G==="inline"||G==="pip"?G:"inline";k.current=X,J({jsonrpc:"2.0",id:z,result:{mode:X}}),J({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),D.current?.(X);return}if(fe==="ui/resource-teardown"&&z!=null){J({jsonrpc:"2.0",id:z,result:{}});return}fe==="ping"&&z!=null&&J({jsonrpc:"2.0",id:z,result:{}})};return window.addEventListener("message",Ue),()=>{ke=!0,clearTimeout(Q),he&&clearTimeout(he.timer),window.removeEventListener("message",Ue)}},[i,O]),Mg("iframe",{ref:g,src:U,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:A(!p&&"ww:rounded-md ww:border ww:border-border",s),style:{height:p?"100%":P,minWidth:p||!R?void 0:`min(${R}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}f();import{jsx as xa,jsxs as Fg}from"react/jsx-runtime";function $l({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Fg("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&&xa("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}),xa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&xa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&xa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((n,s)=>xa("button",{type:"button",onClick:()=>r?.(n),className:A("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:`${s*50}ms`},children:n},n))})]})}f();import{Component as Dg}from"react";import{jsx as Or,jsxs as Eg}from"react/jsx-runtime";function Bg({onRetry:e}){let{t}=V();return Eg("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:[Or("span",{children:t.widgetErrorBoundary.failedToLoad}),Or("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var mo=class extends Dg{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?Or(Bg,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as _g,jsx as ee,jsxs as rt}from"react/jsx-runtime";function Nr(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Xl(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?$t:it}function Kl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:n,chatSessionId:s,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:g,messageClassNames:I}){let{t:C}=V(),S=e[e.length-1],x=e.length>0,L=d!=null,y=!L&&Gl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return rt(_g,{children:[!L&&(!x&&o?ee($l,{...o,onSuggestionSelect:r}):a&&ee(Pr,{from:"assistant",children:ee(Ar,{children:ee(po,{children:a})})})),e.map(k=>{let P=k.parts.filter(T=>T.type==="text"),F=k.parts.filter(T=>T.type==="reasoning"),R=k.parts.filter(T=>T.type==="file"),_=k.parts.filter(T=>"toolCallId"in T),M=k.parts.filter(T=>T.type==="reasoning"||"toolCallId"in T),E=k===S&&k.role==="assistant",v=P.length>0,D=L?_.some(T=>T.toolCallId===d):!1,H=m!==!1&&!D&&M.length>=2;return L&&!D?ee("div",{style:{display:"none"}},k.id):k.role==="assistant"&&!Wl(k)?ee("div",{style:{display:"none"}},k.id):m===!1&&k.role==="assistant"&&!v&&R.length===0&&_.every(T=>{let O="output"in T?T.output:void 0;return O===void 0||!n||!wa(T.toolName,O,g)})?ee("div",{style:{display:"none"}},k.id):rt(Pr,{from:k.role,className:I?.message,children:[m!==!1&&!D&&!H&&F.map((T,O)=>rt(ta,{isStreaming:T.state==="streaming",children:[ee(aa,{}),ee(oa,{children:T.text})]},`reasoning-${k.id}-${O}`)),H&&(()=>{let T=M[M.length-1],O=T.type==="reasoning"?{icon:Xe,label:C.reasoning.thinking}:{icon:Xl(T.toolName),label:T.title??Nr(T.toolName)};return rt(zs,{isWorking:E&&(t==="streaming"||t==="submitted"),activeStep:O,children:[ee(Vs,{workingLabel:C.chainOfThought.working,label:C.chainOfThought.done}),ee($s,{children:M.map((U,Be)=>{let be=Be===M.length-1;if(U.type==="reasoning")return ee(Ks,{isStreaming:U.state==="streaming",isLast:be,children:U.text},`reasoning-${k.id}-${Be}`);let W=U.title??Nr(U.toolName),ke=Xl(U.toolName);if(m==="titles-only")return ee(Xo,{icon:ke,title:W,state:U.state,isLast:be},U.toolCallId);let ue="output"in U?U.output:void 0;return rt(Xo,{icon:ke,title:W,state:U.state,isLast:be,children:[ee(Br,{input:U.input,debug:p}),ue!==void 0&&ee(Er,{output:ue,errorText:"errorText"in U?U.errorText:void 0,debug:p})]},U.toolCallId)})})]})})(),m!==!1&&!D&&!H&&_.length===1&&(()=>{let T=_[0],O=T.title??Nr(T.toolName);if(m==="titles-only")return ee(El,{title:O,state:T.state});let U="output"in T?T.output:void 0;return rt(Dl,{children:[ee(Bl,{title:O,state:T.state}),rt(_l,{children:[ee(Br,{input:T.input,debug:p}),U!==void 0&&ee(Er,{output:U,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]})})(),_.map(T=>{let O="output"in T?T.output:void 0,U=wa(T.toolName,O,g),Be=Ul(T.toolName,O,g),be=T.toolCallId===d;return U&&n&&O!==void 0?ee("div",{style:be?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:U&&n&&O!==void 0&&ee(mo,{children:ee(Vl,{isFullscreen:be,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},resourceEndpoint:n,chatSessionId:s,isDark:i,autoHeight:Be,toolDefinitions:g,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?W=>c(W,{toolCallId:T.toolCallId,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},autoHeight:Be}):void 0})})},T.toolCallId):null}),!D&&ee("div",{children:rt(Ar,{className:A(k.role==="user"?I?.userBubble:I?.assistantBubble),children:[R.length>0&&ee(Us,{files:R}),v?P.map((T,O)=>{let U=E&&t==="streaming"&&O===P.length-1;return ee(po,{isStreaming:U,children:T.type==="text"?T.text:""},`${k.id}-${O}`)}):null]})})]},k.id)}),y&&ee(jl,{})]})}f();import{jsx as Ql,jsxs as Ug}from"react/jsx-runtime";var Og="https://app.waniwani.ai/assets/waniwani-logo.svg",Ng="https://waniwani.ai";function Jl(){let{t:e}=V();return Ug("a",{href:Ng,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Ql("span",{children:e.poweredBy.label}),Ql("img",{src:Og,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as go}from"react/jsx-runtime";function Yl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:go("div",{className:A("ww:px-4 ww:py-2",o),...r,children:go("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(n=>go("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+n*20}px`}},n)):e.map((n,s)=>go("button",{type:"button",onClick:()=>a(n),className:A("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3.5 ww:py-1.5 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:`${s*50}ms`},children:n},n))})})}f();import{useEffect as Hg,useRef as qg,useState as Wg}from"react";import{jsx as ne,jsxs as ht}from"react/jsx-runtime";var Zl=20;function Gg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ne("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function jg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ne("polyline",{points:"3 4 3 9 8 9"}),ne("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ne("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function zg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("polyline",{points:"3 6 5 6 21 6"}),ne("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ne("path",{d:"M10 11v6"}),ne("path",{d:"M14 11v6"})]})}function eu({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:n,t:s}=V(),[i,l]=Wg(!1),u=qg(null);Hg(()=>{if(!i)return;let p=m=>{let g=u.current;g&&(m.composedPath().includes(g)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Zl),d=Math.max(0,e.length-Zl);return ht("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ne("button",{type:"button",onClick:a,title:s.threadMenu.newChat,"aria-label":s.threadMenu.newChat,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:ne(Gg,{label:s.threadMenu.newChat})}),ne("button",{type:"button",onClick:()=>l(p=>!p),title:s.threadMenu.threadHistory,"aria-label":s.threadMenu.threadHistory,"aria-expanded":i,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:ne(jg,{label:s.threadMenu.threadHistory})}),i&&ht("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:[c.length===0&&ne("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:s.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,g=Date.parse(p.updatedAt);return ht("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ht("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ne("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ne("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(g)?"":qo(g,n)})]}),ne("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:s.threadMenu.deleteThread,"aria-label":s.threadMenu.deleteThread,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:ne(zg,{label:s.threadMenu.deleteThread})})]},p.threadId)}),d>0&&ne("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:s.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as Vg,useRef as $g}from"react";function tu(e){let t=$g(e);return t.current=e,Vg(async a=>{let{api:o,headers:r,onCallTool:n,sessionId:s}=t.current;if(n)return n(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof s=="string"&&s.trim().length>0?s.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...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 fh}from"@ai-sdk/react";import{useCallback as Ce,useEffect as De,useRef as ce,useState as wt}from"react";f();import{createContext as Xg,useContext as Kg}from"react";f();function au(){return{subscribe(){return()=>{}},emit(){}}}var ou=Xg(au());function ru(){return Kg(ou)}var CP=ou.Provider;f();function At(e,t,a){let[o,r=""]=e.split("?"),n=o.replace(/\/$/,""),s=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}f();import{DefaultChatTransport as Qg,uiMessageChunkSchema as Jg}from"ai";function Yg(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(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let s=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(s.length>0)return s}return null}var ho=class extends Qg{processResponseStream(t){let a="",o=Jg(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(n,s){a+=n;let i=a.split(`
82
- `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){s.enqueue(d);continue}let p=await r(d);if(p.success){s.enqueue(p.value);continue}let m=Yg(p.error);if(m?.length){let g={...d};for(let C of m)delete g[C];let I=await r(g);I.success&&s.enqueue(I.value)}}catch{}}}}))}};f();f();var Zg="waniwani-memory";var Fe="threads",wo="by_memoryUserId",eh="by_updatedAt";var su="memoryUserId",nu="waniwani-memory-user-id",Ur=null;function Hr(){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 th(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Fe)){let a=e.createObjectStore(Fe,{keyPath:"threadId"});a.createIndex(wo,"memoryUserId",{unique:!1}),a.createIndex(eh,"updatedAt",{unique:!1})}}async function qr(){return new Promise((e,t)=>{let a=indexedDB.open(Zg,2);a.onupgradeneeded=o=>{th(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function ah(){return qr()}async function oh(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get(su);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function rh(e,t){return new Promise((a,o)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,su);s.onsuccess=()=>a(),s.onerror=()=>o(s.error)})}async function nh(){if(typeof indexedDB>"u")return null;try{let e=await ah();try{let t=await oh(e);if(t)return t;let a=Hr();return await rh(e,a),a}finally{e.close()}}catch{return null}}function sh(){try{let e=localStorage.getItem(nu);if(e)return e;let t=Hr();return localStorage.setItem(nu,t),t}catch{return null}}async function iu(){let e=await nh();if(e)return e;let t=sh();return t||(Ur||(Ur=Hr()),Ur)}var lu=50,uu=1e3;function xo(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 Co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await qr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function Wr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Gr(e){return await Co(async a=>{let n=a.transaction(Fe,"readonly").objectStore(Fe).index(wo),i=(await Wr(n.getAll(e))??[]).filter(xo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Lo(e){return await Co(async a=>{let r=a.transaction(Fe,"readonly").objectStore(Fe),n=await Wr(r.get(e));return xo(n)?n:null})??null}async function jr(e){if(!xo(e))return;let t=e.messages.length>uu?{...e,messages:e.messages.slice(e.messages.length-uu)}:e;await Co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Fe,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Fe).put(t)});let o=a.transaction(Fe,"readwrite"),r=o.objectStore(Fe),n=r.index(wo),i=(await Wr(n.getAll(t.memoryUserId))??[]).filter(xo);if(i.length>lu){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-lu);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function du(e){await Co(async t=>(await new Promise((a,o)=>{let r=t.transaction(Fe,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Fe).delete(e)}),null))}async function zr(e){return(await Gr(e))[0]?.threadId??null}function cu(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 Vr="waniwani-visitor-id";function pu(e,t){return e.match(t)?.[1]??null}function ih(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=pu(e,o);if(r)return{name:a,version:r}}return null}function lh(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=pu(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function uh(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"}function dh(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Io(){try{let t=localStorage.getItem(Vr);if(t)return t}catch{}let e=dh();try{localStorage.setItem(Vr,e)}catch{}return e}function fu(e){let t=typeof e=="string"?e.trim():"";if(!t)return Io();try{localStorage.setItem(Vr,t)}catch{}return t}function ch(e){return e!=null&&typeof e.then=="function"}function mu(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let o;try{o=typeof e=="function"?e():e}catch{return a}return ch(o)?o.then(r=>{t||fu(r??"")},()=>{}):fu(o??""),a}async function $r(){let e=navigator.userAgent,t=Io(),a=await iu();return{userAgent:e,browser:ih(e),os:lh(e),deviceType:uh(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 ph="x-session-id",mh=250,gh=200;function gu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Zt()}function So(){return new Date().toISOString()}function hu(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function hh(e,t){let a=At(e,"/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 n={};for(let s of r.tools)s&&typeof s.name=="string"&&(n[s.name]=s);return n}function wu(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:n,enableThreadHistory:s=!1,activeThreadId:i,onThreadChange:l}=e,u=e.visitorId;De(()=>mu(u),[u]);let c=ru(),d=ce(a),p=ce(o),m=ce(s);De(()=>{m.current=s},[s]);let g=ce(void 0),I=ce(null),[C,S]=wt(void 0),x=ce(C),[L,y]=wt(i),k=ce(L),[P,F]=wt([]),[R,_]=wt(!s),M=ce(void 0),E=ce(void 0),v=ce(void 0),D=ce(void 0),H=ce(0),T=ce(l);De(()=>{T.current=l},[l]);let O=Ce(b=>{k.current=b,y(b),b&&(T.current?.(b),c.emit({name:"thread.changed",sessionId:x.current,properties:{threadId:b}}))},[c]),U=Ce(async()=>{if(!s)return;let b=I.current?.memoryUserId;if(!b)return;let N=await Gr(b);F(N)},[s]),Be=Ce(()=>x.current,[]),be=Ce(b=>{let N=hu(b);if(!N||x.current===N)return;let q=x.current===void 0;x.current=N,S(N),q&&c.emit({name:"session.started",properties:{sessionId:N}})},[c]),W=Ce(()=>{x.current=void 0,S(void 0)},[]);De(()=>{d.current=a},[a]),De(()=>{p.current=o},[o]),De(()=>{let b=!1,N=H.current;return(async()=>{try{let oe=await $r();if(b)return;I.current=oe}catch{}if(!s)return;let q=I.current?.memoryUserId;if(!q){_(!0);return}try{let oe=i??await zr(q);if(b||N!==H.current)return;if(oe){let me=await Lo(oe);if(b||N!==H.current)return;me&&me.memoryUserId===q&&(k.current=me.threadId,y(me.threadId),M.current=me.createdAt,E.current=me.title,me.sessionId&&(x.current=me.sessionId,S(me.sessionId)),z(me.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[]);let ke=ce(new ho({api:t,headers:()=>({...d.current}),body:()=>{let b={...p.current??{}},N=Object.hasOwn(b,"sessionId"),q=hu(b.sessionId);if(q)be(q),b.sessionId=q;else if(N)W(),delete b.sessionId;else{let bo=Be();bo&&(b.sessionId=bo)}Ct(g.current)&&(b.modelContext=g.current);let oe=I.current,me=Io();oe&&(b.visitorContext={timezone:oe.timezone,language:oe.language,languages:oe.languages,deviceType:oe.deviceType,referrer:oe.referrer,visitorId:me});let ie=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},qu=typeof ie.client=="object"&&ie.client!==null?ie.client:{};b.visitor={...ie,id:me,client:{...qu,...oe&&{memoryUserId:oe.memoryUserId}}};let en=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,tn=I.current?.memoryUserId,an=I.current?.language,Sa={};if(tn&&(Sa.memoryUserId=tn),an&&(Sa.locale=an),(Object.keys(Sa).length>0||en)&&(b.extra={...Sa,...en??{}}),m.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(k.current=b.threadId);else{let ya=k.current;ya||(ya=gu(),M.current=So(),E.current=void 0,O(ya)),b.threadId=ya}return b},fetch:(async(b,N)=>{let q=await fetch(b,N);return g.current=void 0,be(q.headers.get(ph)),q})})),ue=ce(null),Ae=ce(null),he=ce({}),[Q,J]=wt(0),Ue=e.skipRemoteConfig===!0,Ie=Ce(async()=>{if(!Ue)try{let b=await hh(t,d.current);he.current=b,J(N=>N+1)}catch(b){console.warn("[Waniwani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,Ue]);De(()=>{Ie()},[Ie]);let{messages:te,sendMessage:fe,setMessages:z,status:G}=fh({messages:e.initialMessages,transport:ke.current,onFinish({message:b,isAbort:N,isDisconnect:q,isError:oe}){n?.(),!N&&!q&&!oe&&c.emit({name:"message.received"}),ue.current&&(Ae.current=b)},onError(b){console.warn("[Waniwani] Chat error:",b.message),c.emit({name:"chat.error",properties:{message:b.message.slice(0,gh)}}),ue.current&&(ue.current.reject(b),ue.current=null)}}),X=ce(te);De(()=>{X.current=te},[te]);let ae=ce(s);De(()=>{if(!s||ae.current||(ae.current=!0,X.current.length>0))return;let b=!1,N=H.current;return _(!1),(async()=>{try{let q=I.current;if(!q)try{q=await $r(),I.current=q}catch{}let oe=q?.memoryUserId;if(!oe||b||N!==H.current){b||_(!0);return}let me=i??await zr(oe);if(b||N!==H.current)return;if(me){let ie=await Lo(me);if(b||N!==H.current)return;ie&&ie.memoryUserId===oe&&(k.current=ie.threadId,y(ie.threadId),M.current=ie.createdAt,E.current=ie.title,ie.sessionId&&(x.current=ie.sessionId,S(ie.sessionId)),z(ie.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[s]),De(()=>{if(G==="ready"&&ue.current&&Ae.current){let b=ue.current,N=Ae.current;ue.current=null,Ae.current=null,b.resolve(N)}},[G]);let[pe,se]=wt(""),[Te,ve]=wt([]),He=G==="submitted"||G==="streaming",xt=Ce(b=>{ve(N=>N.filter(q=>q.id!==b))},[]),Fu=He&&Te.length>0,Du=Ce(b=>{let N=!!b.text?.trim(),q=!!b.files?.length;if(N||q){if(He){if(Te.length>0)return;ve(oe=>[...oe,{id:Zt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),se("");return}g.current=b.modelContext,fe({text:b.text||"",files:b.files}),r?.(b.text||""),c.emit({name:"message.sent"}),se("")}},[fe,r,He,Te.length,c]),Bu=Ce(b=>new Promise((N,q)=>{ue.current={resolve:N,reject:q},fe({text:b}),r?.(b),c.emit({name:"message.sent"})}),[fe,r,c]);De(()=>{if(G!=="ready"||Te.length===0)return;let[b,...N]=Te;ve(N),g.current=b.modelContext,fe({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text),c.emit({name:"message.sent"})},[G,fe,r,Te,c]);let Eu=Ce(()=>{z([]),ve([]),W(),se(""),he.current={},J(b=>b+1),Ie()},[z,W,Ie]),La=Ce(()=>{if(!m.current)return;let b=I.current?.memoryUserId,N=k.current,q=X.current;if(!(!b||!N||q.length===0)){if(M.current||(M.current=So()),!E.current){let oe=q.find(ie=>ie.role==="user"),me=oe?oe.parts.map(ie=>"text"in ie&&typeof ie.text=="string"?ie.text:"").join(" "):"";E.current=cu(me)}return{threadId:N,memoryUserId:b,title:E.current,messages:q,sessionId:x.current,createdAt:M.current,updatedAt:So()}}},[]),Jr=Ce(async()=>{let b=La();b&&(await jr(b),await U())},[La,U]);De(()=>{if(s&&R&&!(G==="submitted"||G==="streaming")&&te.length!==0)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=void 0;let b=Jr().finally(()=>{D.current===b&&(D.current=void 0)});D.current=b},mh),()=>{v.current&&clearTimeout(v.current)}},[s,R,te,G,Jr]);let Ia=Ce(()=>{let b=D.current,N=v.current,q=N?La():void 0;return N&&(clearTimeout(N),v.current=void 0),(async()=>{b&&await b,q&&(await jr(q),await U())})()},[La,U]),_u=Ce(()=>{H.current+=1,Ia(),z([]),ve([]),W(),se("");let b=gu();return M.current=So(),E.current=void 0,O(b),U(),b},[z,W,O,U,Ia]),yo=Ce(async b=>{H.current+=1;let N=H.current;if(await Ia(),N!==H.current)return;let q=await Lo(b);N===H.current&&q&&(q.sessionId?(x.current=q.sessionId,S(q.sessionId)):W(),O(q.threadId),M.current=q.createdAt,E.current=q.title,z(q.messages),ve([]),se(""))},[z,W,O,Ia]),Ou=Ce(async b=>{if(k.current===b){H.current+=1,v.current&&(clearTimeout(v.current),v.current=void 0);let N=D.current;N&&await N}await du(b),await U(),k.current===b&&(z([]),ve([]),W(),se(""),k.current=void 0,y(void 0),M.current=void 0,E.current=void 0)},[z,W,U]);De(()=>{s&&R&&i!==void 0&&i!==k.current&&yo(i)},[i,s,R,yo]);let Nu=Ce(b=>{se(b.target.value)},[]),Yr=te[te.length-1],Zr=te.length>0,Uu=He&&(!Zr||Yr.role==="user"),Hu=he.current;return{messages:te,status:G,text:pe,setText:se,handleSubmit:Du,handleTextChange:Nu,isLoading:He,showLoaderBubble:Uu,lastMessage:Yr,hasMessages:Zr,sendMessage:fe,sendMessageAndWait:Bu,reset:Eu,queuedMessages:Te,queueFull:Fu,removeQueuedMessage:xt,sessionId:C,toolDefinitions:Hu,refreshToolDefinitions:Ie,threads:P,activeThreadId:L,isThreadHistoryReady:R,startNewThread:_u,switchThread:yo,deleteThread:Ou}}f();import{useEffect as xu,useRef as wh,useState as xh}from"react";var Ch={debug:!1,eval:!1};function Cu(e="/api/waniwani",t,a=!1){let[o,r]=xh(Ch),n=wh(t);return xu(()=>{n.current=t},[t]),xu(()=>{a||(async()=>{try{let s=n.current,l=await(await fetch(At(e,"/config"),{headers:s?{...s}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as yh,useEffect as Kr,useRef as bh,useState as Su}from"react";f();var Xr=["channel","page","flow","followup"];f();function Rt(e){return typeof e=="object"&&e!==null}function Lu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Lh(e){if(!Rt(e)||!("toolCallId"in e)||!("output"in e))return null;let t=e.output;if(!Rt(t)||!Rt(t._meta))return null;let a=t._meta[Po];return!Rt(a)||!Lu(a.suggestions)?null:a.suggestions}function Ih(e){let t=null;for(let a of e.parts){let o=Lh(a);o!==null&&(t=o.length>0?o:null)}return t}function Sh(e){for(let t of e.parts){if(!Rt(t)||t.type!=="data-suggestions")continue;let a=t.data;if(Rt(a)&&Lu(a.suggestions)&&a.suggestions.length>0)return a.suggestions}return null}function Iu(e,t={}){let{includeFlow:a=!0}=t,o=a?Ih(e):null;if(o)return{suggestions:o,source:"flow"};let r=Sh(e);return r?{suggestions:r,source:"followup"}:null}function yu(e){return typeof e=="object"&&e!==null}var kh=["channel","page","followup"];function Th(e){if(e===!1)return[];if(e===!0)return[...Xr];if(yu(e)){if(e.origins!==void 0)return e.origins;if(e.dynamic===!0)return[...Xr];if(e.dynamic===!1)return[]}return[...kh]}function bu(e){let{messages:t,status:a,config:o}=e,r=yu(o)&&o.initial?o.initial:void 0,[n,s]=Su(r??[]),[i,l]=Su("channel"),u=bh(a),c=Th(o),d=c.includes("flow"),p=c.includes("followup"),m=yh(()=>{s([])},[]),g=t.length>0;Kr(()=>{g||(s(r??[]),l("channel"))},[r,g]);let I=t[t.length-1];return Kr(()=>{I?.role==="user"&&m()},[I,m]),Kr(()=>{let C=u.current;if(u.current=a,C==="streaming"&&a==="ready"&&(d||p)){let S=[...t].reverse().find(y=>y.role==="assistant");if(!S)return;let x=Iu(S,{includeFlow:d}),L=x&&(x.source==="flow"&&d||x.source==="followup"&&p);s(L?x.suggestions:[]),l(L?x.source:"channel")}},[a,d,p,t]),{suggestions:n,source:i,isLoading:!1,clear:m}}f();import{useEffect as vh,useRef as Ph,useState as Ah}from"react";var Rh=80,Mh=50,Fh=15e3,ku=500;function Tu(e,t=!0){let[a,o]=Ah(""),r=Ph(void 0);return vh(()=>{if(!t){o("");return}let n=0,s=!1,i=!1,l=()=>{i||(s?(n--,o(e.slice(0,n)),n<=0?(s=!1,r.current=setTimeout(l,ku)):r.current=setTimeout(l,Mh)):(n++,o(e.slice(0,n)),n>=e.length?(s=!0,r.current=setTimeout(l,Fh)):r.current=setTimeout(l,Rh)))};return r.current=setTimeout(l,ku),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function vu(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return At(e,"/resource",o?{token:o}:void 0)}f();var Dh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:8,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5",userBubbleTextColor:"#1f2937",assistantBubbleTextColor:"#1f2937",messagePaddingX:16,messagePaddingY:12,messageMaxWidth:"80%",fontSize:16,lineHeight:"1.5"};var Bh={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"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],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"],userBubbleTextColor:["--ww-user-bubble-text"],assistantBubbleTextColor:["--ww-assistant-bubble-text"],messagePaddingX:["--ww-msg-pad-x"],messagePaddingY:["--ww-msg-pad-y"],messageMaxWidth:["--ww-msg-max-width"],fontSize:["--ww-font-size"],lineHeight:["--ww-line-height"]};function Pu(e){return{...Dh,...e}}function Au(e){let t={};for(let[a,o]of Object.entries(Bh)){let r=e[a];if(r===void 0)continue;let n=typeof r=="number"?`${r}px`:String(r);for(let s of o)t[s]=n}return t}import{jsx as Le,jsxs as Ca}from"react/jsx-runtime";var Nh=Eh(function(t,a){let{theme:o,title:r="Assistant",width:n,height:s,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:g,enableThreadHistory:I=!1,showToolCalls:C=!0}=t,S=m??"/api/waniwani",x=vu(S,t.headers),L=Pu(o),y=Au(o??{}),k=L.backgroundColor.replace("#",""),P=parseInt(k.substring(0,2),16),F=parseInt(k.substring(2,4),16),R=parseInt(k.substring(4,6),16),_=(P*299+F*587+R*114)/1e3<128,M=Cu(S,t.headers,t.skipRemoteConfig),E=g??M.debug,v=wu({...t,api:S}),D=tu({...t,api:S,sessionId:v.sessionId}),H=Tu(d,!v.text),[T,O]=Mu(!1),[U,Be]=Mu(null),be=Ru(null),W=Ru(void 0),ke=Qr(()=>{let Q=be.current;if(!Q)return;Q.scrollIntoView({behavior:"smooth",block:"center"});let J=Q.querySelector("textarea");J&&setTimeout(()=>J.focus(),300),O(!0),clearTimeout(W.current),W.current=setTimeout(()=>O(!1),2e3)},[]),ue=bu({messages:v.messages,status:v.status,config:t.suggestions}),Ae=Qr(Q=>{let J=Q.content.map(Ue=>Ue.text??"").join("").trim();J&&v.handleSubmit({text:J,files:[],modelContext:Q.modelContext})},[v.handleSubmit]),he=Qr(Q=>{ue.clear(),v.handleSubmit({text:Q,files:[]})},[ue.clear,v.handleSubmit]);return Oh(a,()=>({sendMessage:Q=>{v.handleSubmit({text:Q,files:[]}),ke()},sendMessageAndWait:Q=>v.sendMessageAndWait(Q),reset:v.reset,focus:ke,get messages(){return v.messages},get sessionId(){return v.sessionId}}),[v.handleSubmit,v.sendMessageAndWait,v.reset,v.messages,v.sessionId,ke]),_h(()=>{if(!p)return;let Q=J=>{let Ue=J.detail,Ie=typeof Ue?.message=="string"?Ue.message:void 0;Ie&&v.handleSubmit({text:Ie,files:[]}),ke()};return window.addEventListener(p,Q),()=>window.removeEventListener(p,Q)},[p,v.handleSubmit,ke]),Ca("div",{ref:be,style:{...y,width:n,height:s},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:A("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",T&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[Ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:L.headerBackgroundColor,color:L.headerTextColor},children:[Le("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),Le(Ns,{messages:v.messages,evalEnabled:M.eval,api:S}),I&&Le(eu,{threads:v.threads,activeThreadId:v.activeThreadId,onNewThread:v.startNewThread,onSelectThread:Q=>{v.switchThread(Q)},onDeleteThread:Q=>{v.deleteThread(Q)}})]}),Ca(gs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[Le(hs,{scrollClassName:U?"ww:!relative ww:!overflow-hidden":void 0,children:Le(Kl,{messages:v.messages,status:v.status,welcomeMessage:u,welcome:c,onSuggestionSelect:he,resourceEndpoint:x,chatSessionId:v.sessionId,isDark:_,onFollowUp:Ae,onCallTool:D,fullscreenToolCallId:U,debug:E,showToolCalls:C,toolDefinitions:v.toolDefinitions,onWidgetDisplayModeChange:(Q,J)=>{Be(Q==="fullscreen"?J.toolCallId:null)}})}),Le(ws,{})]}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Yl,{suggestions:ue.suggestions,isLoading:ue.isLoading,onSelect:he})}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Es,{queuedMessages:v.queuedMessages,onRemove:v.removeQueuedMessage})}),Le("div",{style:U?{display:"none"}:void 0,children:Le("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:Ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[Le(ys,{onSubmit:v.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&Le(Ts,{}),Le(bs,{onChange:v.handleTextChange,value:v.text,placeholder:H,className:"ww:min-h-0 ww:py-1 ww:px-0"}),Le(ks,{status:v.status,disabled:v.queueFull})]})}),Le(Jl,{})]})})})]})});export{Nh as ChatCard,bn as DevModeProvider,Ku as InitializeNextJsInIframe,Rd as LoadingWidget,Fn as WidgetProvider,Cn as createResource,zu as createTool,ko as detectPlatform,Pa as getMockState,Et as initializeMockOpenAI,Gu as isMCPApps,Wu as isOpenAI,Vu as registerTools,uL as toNextJsHandler,Pn as unstable_useSendFollowUpWithGhostGuard,Ot as updateMockDisplayMode,nt as updateMockGlobal,Nt as updateMockTheme,_t as updateMockToolOutput,Dn as useCallTool,Bn as useDisplayMode,En as useFlowAction,_n as useIsChatGptApp,On as useLocale,Nn as useMaxHeight,Un as useOpenExternal,Hn as useRequestDisplayMode,qn as useSafeArea,Wn as useSendFollowUp,Gn as useTheme,Ra as useToolOutput,jn as useToolResponseMetadata,zn as useUpdateModelContext,$ as useWidgetClient,Vn as useWidgetState};
81
+ ${ae}`}]}}E.current({...G,...X?{modelContext:X}:{}})}J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/update-model-context"&&z!=null){Ae=on(Ae,te.params),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="tools/call"&&z!=null){let G=v.current;if(!G){J({jsonrpc:"2.0",id:z,error:{code:-32601,message:"tools/call not supported"}});return}let X=te.params?.name;G({name:X,arguments:te.params?.arguments??{}}).then(ae=>{J({jsonrpc:"2.0",id:z,result:ae});let pe=ae.content?.map(se=>se.text??"").join("").trim();pe&&Rg(X,ae,T.current)&&(he&&clearTimeout(he.timer),he={text:pe,timer:setTimeout(()=>{if(ke)return;let se=Ae;Ae=null,he=null,E.current?.({role:"user",content:[{type:"text",text:pe}],...se?{modelContext:se}:{}})},500)})}).catch(ae=>{let pe=ae instanceof Error?ae.message:"Tool call failed";J({jsonrpc:"2.0",id:z,error:{code:-32e3,message:pe}})});return}if(fe==="ui/request-display-mode"&&z!=null){let G=te.params?.mode,X=G==="fullscreen"||G==="inline"||G==="pip"?G:"inline";k.current=X,J({jsonrpc:"2.0",id:z,result:{mode:X}}),J({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),D.current?.(X);return}if(fe==="ui/resource-teardown"&&z!=null){J({jsonrpc:"2.0",id:z,result:{}});return}fe==="ping"&&z!=null&&J({jsonrpc:"2.0",id:z,result:{}})};return window.addEventListener("message",Ue),()=>{ke=!0,clearTimeout(Q),he&&clearTimeout(he.timer),window.removeEventListener("message",Ue)}},[i,O]),Mg("iframe",{ref:g,src:U,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:A(!p&&"ww:rounded-md ww:border ww:border-border",s),style:{height:p?"100%":P,minWidth:p||!R?void 0:`min(${R}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}f();import{jsx as xa,jsxs as Fg}from"react/jsx-runtime";function $l({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Fg("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&&xa("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}),xa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&xa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&xa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((n,s)=>xa("button",{type:"button",onClick:()=>r?.(n),className:A("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:`${s*50}ms`},children:n},n))})]})}f();import{Component as Dg}from"react";import{jsx as Or,jsxs as Eg}from"react/jsx-runtime";function Bg({onRetry:e}){let{t}=V();return Eg("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:[Or("span",{children:t.widgetErrorBoundary.failedToLoad}),Or("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var mo=class extends Dg{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?Or(Bg,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as _g,jsx as ee,jsxs as rt}from"react/jsx-runtime";function Nr(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Xl(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?$t:it}function Kl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:n,chatSessionId:s,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:g,messageClassNames:I}){let{t:C}=V(),S=e[e.length-1],x=e.length>0,L=d!=null,y=!L&&Gl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return rt(_g,{children:[!L&&(!x&&o?ee($l,{...o,onSuggestionSelect:r}):a&&ee(Pr,{from:"assistant",children:ee(Ar,{children:ee(po,{children:a})})})),e.map(k=>{let P=k.parts.filter(T=>T.type==="text"),F=k.parts.filter(T=>T.type==="reasoning"),R=k.parts.filter(T=>T.type==="file"),_=k.parts.filter(T=>"toolCallId"in T),M=k.parts.filter(T=>T.type==="reasoning"||"toolCallId"in T),E=k===S&&k.role==="assistant",v=P.length>0,D=L?_.some(T=>T.toolCallId===d):!1,H=m!==!1&&!D&&M.length>=2;return L&&!D?ee("div",{style:{display:"none"}},k.id):k.role==="assistant"&&!Wl(k)?ee("div",{style:{display:"none"}},k.id):m===!1&&k.role==="assistant"&&!v&&R.length===0&&_.every(T=>{let O="output"in T?T.output:void 0;return O===void 0||!n||!wa(T.toolName,O,g)})?ee("div",{style:{display:"none"}},k.id):rt(Pr,{from:k.role,className:I?.message,children:[m!==!1&&!D&&!H&&F.map((T,O)=>rt(ta,{isStreaming:T.state==="streaming",children:[ee(aa,{}),ee(oa,{children:T.text})]},`reasoning-${k.id}-${O}`)),H&&(()=>{let T=M[M.length-1],O=T.type==="reasoning"?{icon:Xe,label:C.reasoning.thinking}:{icon:Xl(T.toolName),label:T.title??Nr(T.toolName)};return rt(zs,{isWorking:E&&(t==="streaming"||t==="submitted"),activeStep:O,children:[ee(Vs,{workingLabel:C.chainOfThought.working,label:C.chainOfThought.done}),ee($s,{children:M.map((U,Be)=>{let be=Be===M.length-1;if(U.type==="reasoning")return ee(Ks,{isStreaming:U.state==="streaming",isLast:be,children:U.text},`reasoning-${k.id}-${Be}`);let W=U.title??Nr(U.toolName),ke=Xl(U.toolName);if(m==="titles-only")return ee(Xo,{icon:ke,title:W,state:U.state,isLast:be},U.toolCallId);let ue="output"in U?U.output:void 0;return rt(Xo,{icon:ke,title:W,state:U.state,isLast:be,children:[ee(Br,{input:U.input,debug:p}),ue!==void 0&&ee(Er,{output:ue,errorText:"errorText"in U?U.errorText:void 0,debug:p})]},U.toolCallId)})})]})})(),m!==!1&&!D&&!H&&_.length===1&&(()=>{let T=_[0],O=T.title??Nr(T.toolName);if(m==="titles-only")return ee(El,{title:O,state:T.state});let U="output"in T?T.output:void 0;return rt(Dl,{children:[ee(Bl,{title:O,state:T.state}),rt(_l,{children:[ee(Br,{input:T.input,debug:p}),U!==void 0&&ee(Er,{output:U,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]})})(),_.map(T=>{let O="output"in T?T.output:void 0,U=wa(T.toolName,O,g),Be=Ul(T.toolName,O,g),be=T.toolCallId===d;return U&&n&&O!==void 0?ee("div",{style:be?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:U&&n&&O!==void 0&&ee(mo,{children:ee(Vl,{isFullscreen:be,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},resourceEndpoint:n,chatSessionId:s,isDark:i,autoHeight:Be,toolDefinitions:g,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?W=>c(W,{toolCallId:T.toolCallId,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},autoHeight:Be}):void 0})})},T.toolCallId):null}),!D&&ee("div",{children:rt(Ar,{className:A(k.role==="user"?I?.userBubble:I?.assistantBubble),children:[R.length>0&&ee(Us,{files:R}),v?P.map((T,O)=>{let U=E&&t==="streaming"&&O===P.length-1;return ee(po,{isStreaming:U,children:T.type==="text"?T.text:""},`${k.id}-${O}`)}):null]})})]},k.id)}),y&&ee(jl,{})]})}f();import{jsx as Ql,jsxs as Ug}from"react/jsx-runtime";var Og="https://app.waniwani.ai/assets/waniwani-logo.svg",Ng="https://waniwani.ai";function Jl(){let{t:e}=V();return Ug("a",{href:Ng,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Ql("span",{children:e.poweredBy.label}),Ql("img",{src:Og,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as go}from"react/jsx-runtime";function Yl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:go("div",{className:A("ww:px-4 ww:py-2",o),...r,children:go("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(n=>go("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+n*20}px`}},n)):e.map((n,s)=>go("button",{type:"button",onClick:()=>a(n),className:A("ww:rounded-full ww:border ww:border-border ww:bg-accent ww:px-3.5 ww:py-1.5 ww:text-sm","ww:text-foreground ww:hover:bg-border 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:`${s*50}ms`},children:n},n))})})}f();import{useEffect as Hg,useRef as qg,useState as Wg}from"react";import{jsx as ne,jsxs as ht}from"react/jsx-runtime";var Zl=20;function Gg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ne("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function jg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ne("polyline",{points:"3 4 3 9 8 9"}),ne("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ne("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function zg({label:e}){return ht("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":e,children:[ne("title",{children:e}),ne("polyline",{points:"3 6 5 6 21 6"}),ne("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ne("path",{d:"M10 11v6"}),ne("path",{d:"M14 11v6"})]})}function eu({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:n,t:s}=V(),[i,l]=Wg(!1),u=qg(null);Hg(()=>{if(!i)return;let p=m=>{let g=u.current;g&&(m.composedPath().includes(g)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Zl),d=Math.max(0,e.length-Zl);return ht("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ne("button",{type:"button",onClick:a,title:s.threadMenu.newChat,"aria-label":s.threadMenu.newChat,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:ne(Gg,{label:s.threadMenu.newChat})}),ne("button",{type:"button",onClick:()=>l(p=>!p),title:s.threadMenu.threadHistory,"aria-label":s.threadMenu.threadHistory,"aria-expanded":i,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:ne(jg,{label:s.threadMenu.threadHistory})}),i&&ht("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:[c.length===0&&ne("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:s.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,g=Date.parse(p.updatedAt);return ht("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ht("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ne("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ne("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(g)?"":qo(g,n)})]}),ne("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:s.threadMenu.deleteThread,"aria-label":s.threadMenu.deleteThread,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:ne(zg,{label:s.threadMenu.deleteThread})})]},p.threadId)}),d>0&&ne("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:s.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as Vg,useRef as $g}from"react";function tu(e){let t=$g(e);return t.current=e,Vg(async a=>{let{api:o,headers:r,onCallTool:n,sessionId:s}=t.current;if(n)return n(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof s=="string"&&s.trim().length>0?s.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...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 fh}from"@ai-sdk/react";import{useCallback as Ce,useEffect as De,useRef as ce,useState as wt}from"react";f();import{createContext as Xg,useContext as Kg}from"react";f();function au(){return{subscribe(){return()=>{}},emit(){}}}var ou=Xg(au());function ru(){return Kg(ou)}var CP=ou.Provider;f();function At(e,t,a){let[o,r=""]=e.split("?"),n=o.replace(/\/$/,""),s=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}f();import{DefaultChatTransport as Qg,uiMessageChunkSchema as Jg}from"ai";function Yg(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(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let s=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(s.length>0)return s}return null}var ho=class extends Qg{processResponseStream(t){let a="",o=Jg(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(n,s){a+=n;let i=a.split(`
82
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){s.enqueue(d);continue}let p=await r(d);if(p.success){s.enqueue(p.value);continue}let m=Yg(p.error);if(m?.length){let g={...d};for(let C of m)delete g[C];let I=await r(g);I.success&&s.enqueue(I.value)}}catch{}}}}))}};f();f();var Zg="waniwani-memory";var Fe="threads",wo="by_memoryUserId",eh="by_updatedAt";var su="memoryUserId",nu="waniwani-memory-user-id",Ur=null;function Hr(){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 th(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Fe)){let a=e.createObjectStore(Fe,{keyPath:"threadId"});a.createIndex(wo,"memoryUserId",{unique:!1}),a.createIndex(eh,"updatedAt",{unique:!1})}}async function qr(){return new Promise((e,t)=>{let a=indexedDB.open(Zg,2);a.onupgradeneeded=o=>{th(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function ah(){return qr()}async function oh(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get(su);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function rh(e,t){return new Promise((a,o)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,su);s.onsuccess=()=>a(),s.onerror=()=>o(s.error)})}async function nh(){if(typeof indexedDB>"u")return null;try{let e=await ah();try{let t=await oh(e);if(t)return t;let a=Hr();return await rh(e,a),a}finally{e.close()}}catch{return null}}function sh(){try{let e=localStorage.getItem(nu);if(e)return e;let t=Hr();return localStorage.setItem(nu,t),t}catch{return null}}async function iu(){let e=await nh();if(e)return e;let t=sh();return t||(Ur||(Ur=Hr()),Ur)}var lu=50,uu=1e3;function xo(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 Co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await qr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function Wr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Gr(e){return await Co(async a=>{let n=a.transaction(Fe,"readonly").objectStore(Fe).index(wo),i=(await Wr(n.getAll(e))??[]).filter(xo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Lo(e){return await Co(async a=>{let r=a.transaction(Fe,"readonly").objectStore(Fe),n=await Wr(r.get(e));return xo(n)?n:null})??null}async function jr(e){if(!xo(e))return;let t=e.messages.length>uu?{...e,messages:e.messages.slice(e.messages.length-uu)}:e;await Co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Fe,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Fe).put(t)});let o=a.transaction(Fe,"readwrite"),r=o.objectStore(Fe),n=r.index(wo),i=(await Wr(n.getAll(t.memoryUserId))??[]).filter(xo);if(i.length>lu){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-lu);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function du(e){await Co(async t=>(await new Promise((a,o)=>{let r=t.transaction(Fe,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Fe).delete(e)}),null))}async function zr(e){return(await Gr(e))[0]?.threadId??null}function cu(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 Vr="waniwani-visitor-id";function pu(e,t){return e.match(t)?.[1]??null}function ih(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=pu(e,o);if(r)return{name:a,version:r}}return null}function lh(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=pu(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function uh(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"}function dh(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Io(){try{let t=localStorage.getItem(Vr);if(t)return t}catch{}let e=dh();try{localStorage.setItem(Vr,e)}catch{}return e}function fu(e){let t=typeof e=="string"?e.trim():"";if(!t)return Io();try{localStorage.setItem(Vr,t)}catch{}return t}function ch(e){return e!=null&&typeof e.then=="function"}function mu(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let o;try{o=typeof e=="function"?e():e}catch{return a}return ch(o)?o.then(r=>{t||fu(r??"")},()=>{}):fu(o??""),a}async function $r(){let e=navigator.userAgent,t=Io(),a=await iu();return{userAgent:e,browser:ih(e),os:lh(e),deviceType:uh(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 ph="x-session-id",mh=250,gh=200;function gu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Zt()}function So(){return new Date().toISOString()}function hu(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function hh(e,t){let a=At(e,"/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 n={};for(let s of r.tools)s&&typeof s.name=="string"&&(n[s.name]=s);return n}function wu(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:n,enableThreadHistory:s=!1,activeThreadId:i,onThreadChange:l}=e,u=e.visitorId;De(()=>mu(u),[u]);let c=ru(),d=ce(a),p=ce(o),m=ce(s);De(()=>{m.current=s},[s]);let g=ce(void 0),I=ce(null),[C,S]=wt(void 0),x=ce(C),[L,y]=wt(i),k=ce(L),[P,F]=wt([]),[R,_]=wt(!s),M=ce(void 0),E=ce(void 0),v=ce(void 0),D=ce(void 0),H=ce(0),T=ce(l);De(()=>{T.current=l},[l]);let O=Ce(b=>{k.current=b,y(b),b&&(T.current?.(b),c.emit({name:"thread.changed",sessionId:x.current,properties:{threadId:b}}))},[c]),U=Ce(async()=>{if(!s)return;let b=I.current?.memoryUserId;if(!b)return;let N=await Gr(b);F(N)},[s]),Be=Ce(()=>x.current,[]),be=Ce(b=>{let N=hu(b);if(!N||x.current===N)return;let q=x.current===void 0;x.current=N,S(N),q&&c.emit({name:"session.started",properties:{sessionId:N}})},[c]),W=Ce(()=>{x.current=void 0,S(void 0)},[]);De(()=>{d.current=a},[a]),De(()=>{p.current=o},[o]),De(()=>{let b=!1,N=H.current;return(async()=>{try{let oe=await $r();if(b)return;I.current=oe}catch{}if(!s)return;let q=I.current?.memoryUserId;if(!q){_(!0);return}try{let oe=i??await zr(q);if(b||N!==H.current)return;if(oe){let me=await Lo(oe);if(b||N!==H.current)return;me&&me.memoryUserId===q&&(k.current=me.threadId,y(me.threadId),M.current=me.createdAt,E.current=me.title,me.sessionId&&(x.current=me.sessionId,S(me.sessionId)),z(me.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[]);let ke=ce(new ho({api:t,headers:()=>({...d.current}),body:()=>{let b={...p.current??{}},N=Object.hasOwn(b,"sessionId"),q=hu(b.sessionId);if(q)be(q),b.sessionId=q;else if(N)W(),delete b.sessionId;else{let bo=Be();bo&&(b.sessionId=bo)}Ct(g.current)&&(b.modelContext=g.current);let oe=I.current,me=Io();oe&&(b.visitorContext={timezone:oe.timezone,language:oe.language,languages:oe.languages,deviceType:oe.deviceType,referrer:oe.referrer,visitorId:me});let ie=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},qu=typeof ie.client=="object"&&ie.client!==null?ie.client:{};b.visitor={...ie,id:me,client:{...qu,...oe&&{memoryUserId:oe.memoryUserId}}};let en=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,tn=I.current?.memoryUserId,an=I.current?.language,Sa={};if(tn&&(Sa.memoryUserId=tn),an&&(Sa.locale=an),(Object.keys(Sa).length>0||en)&&(b.extra={...Sa,...en??{}}),m.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(k.current=b.threadId);else{let ya=k.current;ya||(ya=gu(),M.current=So(),E.current=void 0,O(ya)),b.threadId=ya}return b},fetch:(async(b,N)=>{let q=await fetch(b,N);return g.current=void 0,be(q.headers.get(ph)),q})})),ue=ce(null),Ae=ce(null),he=ce({}),[Q,J]=wt(0),Ue=e.skipRemoteConfig===!0,Ie=Ce(async()=>{if(!Ue)try{let b=await hh(t,d.current);he.current=b,J(N=>N+1)}catch(b){console.warn("[Waniwani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,Ue]);De(()=>{Ie()},[Ie]);let{messages:te,sendMessage:fe,setMessages:z,status:G}=fh({messages:e.initialMessages,transport:ke.current,onFinish({message:b,isAbort:N,isDisconnect:q,isError:oe}){n?.(),!N&&!q&&!oe&&c.emit({name:"message.received"}),ue.current&&(Ae.current=b)},onError(b){console.warn("[Waniwani] Chat error:",b.message),c.emit({name:"chat.error",properties:{message:b.message.slice(0,gh)}}),ue.current&&(ue.current.reject(b),ue.current=null)}}),X=ce(te);De(()=>{X.current=te},[te]);let ae=ce(s);De(()=>{if(!s||ae.current||(ae.current=!0,X.current.length>0))return;let b=!1,N=H.current;return _(!1),(async()=>{try{let q=I.current;if(!q)try{q=await $r(),I.current=q}catch{}let oe=q?.memoryUserId;if(!oe||b||N!==H.current){b||_(!0);return}let me=i??await zr(oe);if(b||N!==H.current)return;if(me){let ie=await Lo(me);if(b||N!==H.current)return;ie&&ie.memoryUserId===oe&&(k.current=ie.threadId,y(ie.threadId),M.current=ie.createdAt,E.current=ie.title,ie.sessionId&&(x.current=ie.sessionId,S(ie.sessionId)),z(ie.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[s]),De(()=>{if(G==="ready"&&ue.current&&Ae.current){let b=ue.current,N=Ae.current;ue.current=null,Ae.current=null,b.resolve(N)}},[G]);let[pe,se]=wt(""),[Te,ve]=wt([]),He=G==="submitted"||G==="streaming",xt=Ce(b=>{ve(N=>N.filter(q=>q.id!==b))},[]),Fu=He&&Te.length>0,Du=Ce(b=>{let N=!!b.text?.trim(),q=!!b.files?.length;if(N||q){if(He){if(Te.length>0)return;ve(oe=>[...oe,{id:Zt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),se("");return}g.current=b.modelContext,fe({text:b.text||"",files:b.files}),r?.(b.text||""),c.emit({name:"message.sent"}),se("")}},[fe,r,He,Te.length,c]),Bu=Ce(b=>new Promise((N,q)=>{ue.current={resolve:N,reject:q},fe({text:b}),r?.(b),c.emit({name:"message.sent"})}),[fe,r,c]);De(()=>{if(G!=="ready"||Te.length===0)return;let[b,...N]=Te;ve(N),g.current=b.modelContext,fe({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text),c.emit({name:"message.sent"})},[G,fe,r,Te,c]);let Eu=Ce(()=>{z([]),ve([]),W(),se(""),he.current={},J(b=>b+1),Ie()},[z,W,Ie]),La=Ce(()=>{if(!m.current)return;let b=I.current?.memoryUserId,N=k.current,q=X.current;if(!(!b||!N||q.length===0)){if(M.current||(M.current=So()),!E.current){let oe=q.find(ie=>ie.role==="user"),me=oe?oe.parts.map(ie=>"text"in ie&&typeof ie.text=="string"?ie.text:"").join(" "):"";E.current=cu(me)}return{threadId:N,memoryUserId:b,title:E.current,messages:q,sessionId:x.current,createdAt:M.current,updatedAt:So()}}},[]),Jr=Ce(async()=>{let b=La();b&&(await jr(b),await U())},[La,U]);De(()=>{if(s&&R&&!(G==="submitted"||G==="streaming")&&te.length!==0)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=void 0;let b=Jr().finally(()=>{D.current===b&&(D.current=void 0)});D.current=b},mh),()=>{v.current&&clearTimeout(v.current)}},[s,R,te,G,Jr]);let Ia=Ce(()=>{let b=D.current,N=v.current,q=N?La():void 0;return N&&(clearTimeout(N),v.current=void 0),(async()=>{b&&await b,q&&(await jr(q),await U())})()},[La,U]),_u=Ce(()=>{H.current+=1,Ia(),z([]),ve([]),W(),se("");let b=gu();return M.current=So(),E.current=void 0,O(b),U(),b},[z,W,O,U,Ia]),yo=Ce(async b=>{H.current+=1;let N=H.current;if(await Ia(),N!==H.current)return;let q=await Lo(b);N===H.current&&q&&(q.sessionId?(x.current=q.sessionId,S(q.sessionId)):W(),O(q.threadId),M.current=q.createdAt,E.current=q.title,z(q.messages),ve([]),se(""))},[z,W,O,Ia]),Ou=Ce(async b=>{if(k.current===b){H.current+=1,v.current&&(clearTimeout(v.current),v.current=void 0);let N=D.current;N&&await N}await du(b),await U(),k.current===b&&(z([]),ve([]),W(),se(""),k.current=void 0,y(void 0),M.current=void 0,E.current=void 0)},[z,W,U]);De(()=>{s&&R&&i!==void 0&&i!==k.current&&yo(i)},[i,s,R,yo]);let Nu=Ce(b=>{se(b.target.value)},[]),Yr=te[te.length-1],Zr=te.length>0,Uu=He&&(!Zr||Yr.role==="user"),Hu=he.current;return{messages:te,status:G,text:pe,setText:se,handleSubmit:Du,handleTextChange:Nu,isLoading:He,showLoaderBubble:Uu,lastMessage:Yr,hasMessages:Zr,sendMessage:fe,sendMessageAndWait:Bu,reset:Eu,queuedMessages:Te,queueFull:Fu,removeQueuedMessage:xt,sessionId:C,toolDefinitions:Hu,refreshToolDefinitions:Ie,threads:P,activeThreadId:L,isThreadHistoryReady:R,startNewThread:_u,switchThread:yo,deleteThread:Ou}}f();import{useEffect as xu,useRef as wh,useState as xh}from"react";var Ch={debug:!1,eval:!1};function Cu(e="/api/waniwani",t,a=!1){let[o,r]=xh(Ch),n=wh(t);return xu(()=>{n.current=t},[t]),xu(()=>{a||(async()=>{try{let s=n.current,l=await(await fetch(At(e,"/config"),{headers:s?{...s}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as yh,useEffect as Kr,useRef as bh,useState as Su}from"react";f();var Xr=["channel","page","flow","followup"];f();function Rt(e){return typeof e=="object"&&e!==null}function Lu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Lh(e){if(!Rt(e)||!("toolCallId"in e)||!("output"in e))return null;let t=e.output;if(!Rt(t)||!Rt(t._meta))return null;let a=t._meta[Po];return!Rt(a)||!Lu(a.suggestions)?null:a.suggestions}function Ih(e){let t=null;for(let a of e.parts){let o=Lh(a);o!==null&&(t=o.length>0?o:null)}return t}function Sh(e){for(let t of e.parts){if(!Rt(t)||t.type!=="data-suggestions")continue;let a=t.data;if(Rt(a)&&Lu(a.suggestions)&&a.suggestions.length>0)return a.suggestions}return null}function Iu(e,t={}){let{includeFlow:a=!0}=t,o=a?Ih(e):null;if(o)return{suggestions:o,source:"flow"};let r=Sh(e);return r?{suggestions:r,source:"followup"}:null}function yu(e){return typeof e=="object"&&e!==null}var kh=["channel","page","followup"];function Th(e){if(e===!1)return[];if(e===!0)return[...Xr];if(yu(e)){if(e.origins!==void 0)return e.origins;if(e.dynamic===!0)return[...Xr];if(e.dynamic===!1)return[]}return[...kh]}function bu(e){let{messages:t,status:a,config:o}=e,r=yu(o)&&o.initial?o.initial:void 0,[n,s]=Su(r??[]),[i,l]=Su("channel"),u=bh(a),c=Th(o),d=c.includes("flow"),p=c.includes("followup"),m=yh(()=>{s([])},[]),g=t.length>0;Kr(()=>{g||(s(r??[]),l("channel"))},[r,g]);let I=t[t.length-1];return Kr(()=>{I?.role==="user"&&m()},[I,m]),Kr(()=>{let C=u.current;if(u.current=a,C==="streaming"&&a==="ready"&&(d||p)){let S=[...t].reverse().find(y=>y.role==="assistant");if(!S)return;let x=Iu(S,{includeFlow:d}),L=x&&(x.source==="flow"&&d||x.source==="followup"&&p);s(L?x.suggestions:[]),l(L?x.source:"channel")}},[a,d,p,t]),{suggestions:n,source:i,isLoading:!1,clear:m}}f();import{useEffect as vh,useRef as Ph,useState as Ah}from"react";var Rh=80,Mh=50,Fh=15e3,ku=500;function Tu(e,t=!0){let[a,o]=Ah(""),r=Ph(void 0);return vh(()=>{if(!t){o("");return}let n=0,s=!1,i=!1,l=()=>{i||(s?(n--,o(e.slice(0,n)),n<=0?(s=!1,r.current=setTimeout(l,ku)):r.current=setTimeout(l,Mh)):(n++,o(e.slice(0,n)),n>=e.length?(s=!0,r.current=setTimeout(l,Fh)):r.current=setTimeout(l,Rh)))};return r.current=setTimeout(l,ku),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function vu(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return At(e,"/resource",o?{token:o}:void 0)}f();var Dh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:8,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5",userBubbleTextColor:"#1f2937",assistantBubbleTextColor:"#1f2937",messagePaddingX:16,messagePaddingY:12,messageMaxWidth:"80%",fontSize:16,lineHeight:"1.5",glassTint:"transparent",glassTintStrength:"0"};var Bh={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"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],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"],userBubbleTextColor:["--ww-user-bubble-text"],assistantBubbleTextColor:["--ww-assistant-bubble-text"],messagePaddingX:["--ww-msg-pad-x"],messagePaddingY:["--ww-msg-pad-y"],messageMaxWidth:["--ww-msg-max-width"],fontSize:["--ww-font-size"],lineHeight:["--ww-line-height"],glassTint:["--ww-glass-tint"],glassTintStrength:["--ww-glass-tint-opacity"]};function Pu(e){return{...Dh,...e}}function Au(e){let t={};for(let[a,o]of Object.entries(Bh)){let r=e[a];if(r===void 0)continue;let n=typeof r=="number"?`${r}px`:String(r);for(let s of o)t[s]=n}return t}import{jsx as Le,jsxs as Ca}from"react/jsx-runtime";var Nh=Eh(function(t,a){let{theme:o,title:r="Assistant",width:n,height:s,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:g,enableThreadHistory:I=!1,showToolCalls:C=!0}=t,S=m??"/api/waniwani",x=vu(S,t.headers),L=Pu(o),y=Au(o??{}),k=L.backgroundColor.replace("#",""),P=parseInt(k.substring(0,2),16),F=parseInt(k.substring(2,4),16),R=parseInt(k.substring(4,6),16),_=(P*299+F*587+R*114)/1e3<128,M=Cu(S,t.headers,t.skipRemoteConfig),E=g??M.debug,v=wu({...t,api:S}),D=tu({...t,api:S,sessionId:v.sessionId}),H=Tu(d,!v.text),[T,O]=Mu(!1),[U,Be]=Mu(null),be=Ru(null),W=Ru(void 0),ke=Qr(()=>{let Q=be.current;if(!Q)return;Q.scrollIntoView({behavior:"smooth",block:"center"});let J=Q.querySelector("textarea");J&&setTimeout(()=>J.focus(),300),O(!0),clearTimeout(W.current),W.current=setTimeout(()=>O(!1),2e3)},[]),ue=bu({messages:v.messages,status:v.status,config:t.suggestions}),Ae=Qr(Q=>{let J=Q.content.map(Ue=>Ue.text??"").join("").trim();J&&v.handleSubmit({text:J,files:[],modelContext:Q.modelContext})},[v.handleSubmit]),he=Qr(Q=>{ue.clear(),v.handleSubmit({text:Q,files:[]})},[ue.clear,v.handleSubmit]);return Oh(a,()=>({sendMessage:Q=>{v.handleSubmit({text:Q,files:[]}),ke()},sendMessageAndWait:Q=>v.sendMessageAndWait(Q),reset:v.reset,focus:ke,get messages(){return v.messages},get sessionId(){return v.sessionId}}),[v.handleSubmit,v.sendMessageAndWait,v.reset,v.messages,v.sessionId,ke]),_h(()=>{if(!p)return;let Q=J=>{let Ue=J.detail,Ie=typeof Ue?.message=="string"?Ue.message:void 0;Ie&&v.handleSubmit({text:Ie,files:[]}),ke()};return window.addEventListener(p,Q),()=>window.removeEventListener(p,Q)},[p,v.handleSubmit,ke]),Ca("div",{ref:be,style:{...y,width:n,height:s},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:A("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",T&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[Ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:L.headerBackgroundColor,color:L.headerTextColor},children:[Le("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),Le(Ns,{messages:v.messages,evalEnabled:M.eval,api:S}),I&&Le(eu,{threads:v.threads,activeThreadId:v.activeThreadId,onNewThread:v.startNewThread,onSelectThread:Q=>{v.switchThread(Q)},onDeleteThread:Q=>{v.deleteThread(Q)}})]}),Ca(gs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[Le(hs,{scrollClassName:U?"ww:!relative ww:!overflow-hidden":void 0,children:Le(Kl,{messages:v.messages,status:v.status,welcomeMessage:u,welcome:c,onSuggestionSelect:he,resourceEndpoint:x,chatSessionId:v.sessionId,isDark:_,onFollowUp:Ae,onCallTool:D,fullscreenToolCallId:U,debug:E,showToolCalls:C,toolDefinitions:v.toolDefinitions,onWidgetDisplayModeChange:(Q,J)=>{Be(Q==="fullscreen"?J.toolCallId:null)}})}),Le(ws,{})]}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Yl,{suggestions:ue.suggestions,isLoading:ue.isLoading,onSelect:he})}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Es,{queuedMessages:v.queuedMessages,onRemove:v.removeQueuedMessage})}),Le("div",{style:U?{display:"none"}:void 0,children:Le("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:Ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[Le(ys,{onSubmit:v.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&Le(Ts,{}),Le(bs,{onChange:v.handleTextChange,value:v.text,placeholder:H,className:"ww:min-h-0 ww:py-1 ww:px-0"}),Le(ks,{status:v.status,disabled:v.queueFull})]})}),Le(Jl,{})]})})})]})});export{Nh as ChatCard,bn as DevModeProvider,Ku as InitializeNextJsInIframe,Rd as LoadingWidget,Fn as WidgetProvider,Cn as createResource,zu as createTool,ko as detectPlatform,Pa as getMockState,Et as initializeMockOpenAI,Gu as isMCPApps,Wu as isOpenAI,Vu as registerTools,uL as toNextJsHandler,Pn as unstable_useSendFollowUpWithGhostGuard,Ot as updateMockDisplayMode,nt as updateMockGlobal,Nt as updateMockTheme,_t as updateMockToolOutput,Dn as useCallTool,Bn as useDisplayMode,En as useFlowAction,_n as useIsChatGptApp,On as useLocale,Nn as useMaxHeight,Un as useOpenExternal,Hn as useRequestDisplayMode,qn as useSafeArea,Wn as useSendFollowUp,Gn as useTheme,Ra as useToolOutput,jn as useToolResponseMetadata,zn as useUpdateModelContext,$ as useWidgetClient,Vn as useWidgetState};
83
83
  /*! Bundled license information:
84
84
 
85
85
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js: