@waniwani/sdk 0.14.13 → 0.14.14
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.
- package/dist/chat/embed.js +2 -2
- package/dist/chat/embed.js.map +1 -1
- package/dist/chat/index.js +1 -1
- package/dist/chat/index.js.map +1 -1
- package/dist/chat/styles.css +1 -1
- package/dist/legacy/index.js +1 -1
- package/dist/legacy/index.js.map +1 -1
- package/package.json +1 -1
package/dist/chat/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import{a as $r,b as Xr,c as Qr,d as Kr,e as Jr,f as ua,g as Zr,h as Yr,i as es,j
|
|
|
12
12
|
\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Qn(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ua);let u=Uf(o,e.properties),f=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,f&&(n=!1),(u||!s||!Xn(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),n&&(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(f),!n&&(!s||!Qt(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function Uf(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=Hf(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function Hf(e,t,a){let o=Kr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=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:Oa.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Zr:Yr)(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:Oa.unquoted[r][s]}))),i!==a&&(e.settings.quoteSmart&&Co(a,n)>Co(a,e.alternative)&&(n=e.alternative),i=n+qe(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Oa.single:Oa.double)[r][s],attribute:!0}))+n),l+(i&&"="+i))}var qf=["<","&"];function Ua(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:qf}))}function Kn(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ua(e,t,a,o)}function Jn(e,t,a,o){return o.all(e)}var Zn=es("type",{invalid:Gf,unknown:Wf,handlers:{comment:Wn,doctype:Vn,element:Qn,raw:Kn,root:Jn,text:Ua}});function Gf(e){throw new Error("Expected node, not `"+e+"`")}function Wf(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Vf={},zf={},jf=[];function Yo(e,t){let a=t||Vf,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:$f,all:Xf,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||ts,characterReferences:a.characterReferences||zf,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ua:Jr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function $f(e,t,a){return Zn(e,t,a,this)}function Xf(e){let t=[],a=e&&e.children||jf,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Ha(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Xe(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Qf(e){return Array.isArray(e)?e:[e]}async function si(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function sr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function ni(e){return e==="ansi"||sr(e)}function nr(e){return e==="none"}function ii(e){return nr(e)}function li(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 za(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function Kf(e){let t=za(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let i of t){if(s<i.length)break;s-=i.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let i=0;i<r;i++)n+=t[i].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function ui(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),i=n.includes("/")?n.split("/").pop():n;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var ir="light-dark()",Jf=["color","background-color"];function Zf(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 Yf(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,i)=>n-i);return s.length?Zf(r,s):r})):e}function ec(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(f=>qa(e.variants[f])),i=new Set(n.flatMap(f=>Object.keys(f))),l={},u=(f,d)=>{let c=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[f]+(d==="color"?"":c)};return n.forEach((f,d)=>{for(let c of i){let p=f[c]||"inherit";if(d===0&&o&&Jf.includes(c))if(o===ir&&n.length>1){let m=t.findIndex(g=>g==="light"),C=t.findIndex(g=>g==="dark");if(m===-1||C===-1)throw new ee('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let w=n[m][c]||"inherit",x=n[C][c]||"inherit";l[c]=`light-dark(${w}, ${x})`,r==="css-vars"&&(l[u(d,c)]=p)}else l[c]=p;else r==="css-vars"&&(l[u(d,c)]=p)}}),s.htmlStyle=l,s}function qa(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ge.Italic&&(t["font-style"]="italic"),e.fontStyle&ge.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&ge.Underline&&a.push("underline"),e.fontStyle&ge.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function ar(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var di=new WeakMap;function ja(e,t){di.set(e,t)}function Jt(e){return di.get(e)}var Ct=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(Qf(a).map(o=>[o,Da])),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 tc(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function tc(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function ac(e,t){if(!(e instanceof Ct))throw new ee("Invalid grammar state");return e.getInternalStack(t)}function oc(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new ee(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let i=r.lines[n.line];if(i===void 0)throw new ee(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let l=n.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new ee(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${i.length}`);return{...n,character:l,offset:r.posToIndex(n.line,l)}}},r=Kf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));rc(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return Yf(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(f=>f.type==="element"&&f.tagName==="span");if(r.length!==o.converter.lines.length)throw new ee(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(f,d,c,p){let m=r[f],C="",w=-1,x=-1;if(d===0&&(w=0),c===0&&(x=0),c===Number.POSITIVE_INFINITY&&(x=m.children.length),w===-1||x===-1)for(let h=0;h<m.children.length;h++)C+=fi(m.children[h]),w===-1&&C.length===d&&(w=h+1),x===-1&&C.length===c&&(x=h+1);if(w===-1)throw new ee(`Failed to find start index for decoration ${JSON.stringify(p.start)}`);if(x===-1)throw new ee(`Failed to find end index for decoration ${JSON.stringify(p.end)}`);let g=m.children.slice(w,x);if(!p.alwaysWrap&&g.length===m.children.length)i(m,p,"line");else if(!p.alwaysWrap&&g.length===1&&g[0].type==="element")i(g[0],p,"token");else{let h={type:"element",tagName:"span",properties:{},children:g};i(h,p,"wrapper"),m.children.splice(w,g.length,h)}}function n(f,d){r[f]=i(r[f],d,"line")}function i(f,d,c){let p=d.properties||{},m=d.transform||(C=>C);return f.tagName=d.tagName||"span",f.properties={...f.properties,...p,class:f.properties.class},d.properties?.class&&li(f,d.properties.class),f=m(f,c)||f,f}let l=[],u=o.decorations.sort((f,d)=>d.start.offset-f.start.offset||f.end.offset-d.end.offset);for(let f of u){let{start:d,end:c}=f;if(d.line===c.line)s(d.line,d.character,c.character,f);else if(d.line<c.line){s(d.line,d.character,Number.POSITIVE_INFINITY,f);for(let p=d.line+1;p<c.line;p++)l.unshift(()=>n(p,f));s(c.line,0,c.character,f)}}l.forEach(f=>f())}}}function rc(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new ee(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,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(s||n||i||l){if(s&&n||i&&l||i&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new ee(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function fi(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(fi).join(""):""}var sc=[oc()];function Ga(e){let t=nc(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...sc]}function nc(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var lt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],er={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ic(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 Yn(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 lc(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)er[o]&&t.push({type:"setDecoration",value:er[o]});else if(o<=29){let r=er[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-30]}});else if(o===38){let r=Yn(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-40]}});else if(o===48){let r=Yn(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:lt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:lt[o-100+8]}})}return t}function uc(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=ic(o,s),i=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let l=lc(n.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)}s=n.position}while(s<o.length);return r}}}var dc={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 fc(e=dc){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<lt.length;u++)o.push(t(lt[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let f=0;f<6;f++)for(let d=0;d<6;d++)o.push(a([i[u],i[f],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function s(i){return r()[i]}function n(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return s(i.index)}}return{value:n}}var cc={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 pc(e,t,a){let o=Ha(e,a),r=za(t),s=Object.fromEntries(lt.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,f=e.colors?.[u];return[l,f||cc[l]]})),n=fc(s),i=uc();return r.map(l=>i.parse(l[0]).map(u=>{let f,d;u.decorations.has("reverse")?(f=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(f=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),f=Xe(f,o),d=Xe(d,o),u.decorations.has("dim")&&(f=mc(f));let c=ge.None;return u.decorations.has("bold")&&(c|=ge.Bold),u.decorations.has("italic")&&(c|=ge.Italic),u.decorations.has("underline")&&(c|=ge.Underline),u.decorations.has("strikethrough")&&(c|=ge.Strikethrough),{content:u.value,offset:l[1],color:f,bgColor:d,fontStyle:c}}))}function mc(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${l}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function lr(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(sr(r)||nr(o))return za(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return pc(s,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new ee(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(s.name))throw new ee(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return gc(t,i,s,n,a)}function hc(...e){if(e.length===2)return Jt(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(sr(r)||nr(s))throw new ee("Plain language does not have grammar state");if(r==="ansi")throw new ee("ANSI language does not have grammar state");let{theme:n,colorMap:i}=t.setTheme(s),l=t.getLanguage(r);return new Ct(ur(a,l,n,i,o).stateStack,l.name,n.name)}function gc(e,t,a,o,r){let s=ur(e,t,a,o,r),n=new Ct(s.stateStack,t.name,a.name);return ja(s.tokens,n),s.tokens}function ur(e,t,a,o,r){let s=Ha(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:i=500}=r,l=za(e),u=r.grammarState?ac(r.grammarState,a.name)??Da:r.grammarContextCode!=null?ur(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Da,f=[],d=[];for(let c=0,p=l.length;c<p;c++){let[m,C]=l[c];if(m===""){f=[],d.push([]);continue}if(n>0&&m.length>=n){f=[],d.push([{content:m,offset:C,color:"",fontStyle:0}]);continue}let w,x,g;r.includeExplanation&&(w=t.tokenizeLine(m,u,i),x=w.tokens,g=0);let h=t.tokenizeLine2(m,u,i),L=h.tokens.length/2;for(let S=0;S<L;S++){let k=h.tokens[2*S],A=S+1<L?h.tokens[2*S+2]:m.length;if(k===A)continue;let P=h.tokens[2*S+1],E=Xe(o[it.getForeground(P)],s),B=it.getFontStyle(P),O={content:m.substring(k,A),offset:C+k,color:E,fontStyle:B};if(r.includeExplanation){let b=[];if(r.includeExplanation!=="scopeName")for(let y of a.settings){let M;switch(typeof y.scope){case"string":M=y.scope.split(/,/).map(X=>X.trim());break;case"object":M=y.scope;break;default:continue}b.push({settings:y,selectors:M.map(X=>X.split(/ /))})}O.explanation=[];let v=0;for(;k+v<A;){let y=x[g],M=m.substring(y.startIndex,y.endIndex);v+=M.length,O.explanation.push({content:M,scopes:r.includeExplanation==="scopeName"?wc(y.scopes):xc(b,y.scopes)}),g+=1}}f.push(O)}d.push(f),f=[],u=h.ruleStack}return{tokens:d,stateStack:u}}function wc(e){return e.map(t=>({scopeName:t}))}function xc(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Cc(e,s,t.slice(0,o))}}return a}function ei(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Lc(e,t,a){if(!ei(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)ei(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Cc(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Lc(n,t,a)){o.push(s);break}return o}function ci(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}),f=Jt(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:f,theme:d}}),s=Ic(...r.map(l=>l.tokens)),n=s[0].map((l,u)=>l.map((f,d)=>{let c={content:f.content,variants:{},offset:f.offset};return"includeExplanation"in a&&a.includeExplanation&&(c.explanation=f.explanation),s.forEach((p,m)=>{let{content:C,explanation:w,offset:x,...g}=p[u][d];c.variants[o[m].color]=g}),c})),i=r[0].state?new Ct(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&ja(n,i),n}function Ic(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));let n=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 f=i[u];f.content.length===l?(s[u].push(f),n[u]+=1,i[u]=r[u][n[u]]):(s[u].push({...f,content:f.content.slice(0,l)}),i[u]={...f,content:f.content.slice(l),offset:f.offset+l})}}}return t}function Wa(e,t,a){let o,r,s,n,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:f="--shiki-",colorsRendering:d="css-vars"}=a,c=Object.entries(a.themes).filter(x=>x[1]).map(x=>({color:x[0],theme:x[1]})).sort((x,g)=>x.color===u?-1:g.color===u?1:0);if(c.length===0)throw new ee("`themes` option must not be empty");let p=ci(e,t,a);if(l=Jt(p),u&&ir!==u&&!c.find(x=>x.color===u))throw new ee(`\`themes\` option must contain the defaultColor key \`${u}\``);let m=c.map(x=>e.getTheme(x.theme)),C=c.map(x=>x.color);s=p.map(x=>x.map(g=>ec(g,C,f,u,d))),l&&ja(s,l);let w=c.map(x=>Ha(x.theme,a));r=ti(c,m,w,f,u,"fg",d),o=ti(c,m,w,f,u,"bg",d),n=`shiki-themes ${m.map(x=>x.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Ha(a.theme,a);s=lr(e,t,a);let f=e.getTheme(a.theme);o=Xe(f.bg,u),r=Xe(f.fg,u),n=f.name,l=Jt(s)}else throw new ee("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:i,grammarState:l}}function ti(e,t,a,o,r,s,n){return e.map((i,l)=>{let u=Xe(t[l][s],a[l])||"inherit",f=`${o+i.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===ir&&e.length>1){let d=e.findIndex(C=>C.color==="light"),c=e.findIndex(C=>C.color==="dark");if(d===-1||c===-1)throw new ee('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let p=Xe(t[d][s],a[d])||"inherit",m=Xe(t[c][s],a[c])||"inherit";return`light-dark(${p}, ${m});${f}`}return u}return n==="css-vars"?f:null}).filter(i=>!!i).join(";")}function Va(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>Va(e,r,s),codeToTokens:(r,s)=>Wa(e,r,s)}){let r=t;for(let m of Ga(a))r=m.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:i,themeName:l,rootStyle:u,grammarState:f}=Wa(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:c=!1}=a;d===!0?s=yc(s):d==="never"&&(s=bc(s)),c&&(s=kc(s));let p={...o,get source(){return r}};for(let m of Ga(a))s=m.tokens?.call(p,s)||s;return Sc(s,{...a,fg:n,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},p,f)}function Sc(e,t,a,o=Jt(e)){let r=Ga(t),s=[],n={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[C,w]of Object.entries(t.meta||{}))C.startsWith("_")||(u[C]=w);let f={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},c=[],p={...a,structure:i,addClassToHast:li,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return f},get code(){return d},get lines(){return c}};if(e.forEach((C,w)=>{w&&(i==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&s.push({type:"text",value:`
|
|
13
13
|
`}));let x={type:"element",tagName:"span",properties:{class:"line"},children:[]},g=0;for(let h of C){let L={type:"element",tagName:"span",properties:{...h.htmlAttrs},children:[{type:"text",value:h.content}]},S=ar(h.htmlStyle||qa(h));S&&(L.properties.style=S);for(let k of r)L=k?.span?.call(p,L,w+1,g,x,h)||L;i==="inline"?n.children.push(L):i==="classic"&&x.children.push(L),g+=h.content.length}if(i==="classic"){for(let h of r)x=h?.line?.call(p,x,w+1)||x;c.push(x),s.push(x)}else i==="inline"&&c.push(x)}),i==="classic"){for(let C of r)d=C?.code?.call(p,d)||d;f.children.push(d);for(let C of r)f=C?.pre?.call(p,f)||f;n.children.push(f)}else if(i==="inline"){let C=[],w={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let h of n.children)h.type==="element"&&h.tagName==="br"?(C.push(w),w={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(h.type==="element"||h.type==="text")&&w.children.push(h);C.push(w);let g={type:"element",tagName:"code",properties:{},children:C};for(let h of r)g=h?.code?.call(p,g)||g;n.children=[];for(let h=0;h<g.children.length;h++){h>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let L=g.children[h];L.type==="element"&&n.children.push(...L.children)}}let m=n;for(let C of r)m=C?.root?.call(p,m)||m;return o&&ja(m,o),m}function yc(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&ge.Underline||s.fontStyle&ge.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function bc(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function kc(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=ar(r.htmlStyle||qa(r)),n=ar(o.htmlStyle||qa(o)),i=r.fontStyle&&(r.fontStyle&ge.Underline||r.fontStyle&ge.Strikethrough),l=o.fontStyle&&(o.fontStyle&ge.Underline||o.fontStyle&ge.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var Tc=Yo;function Pc(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Va(e,s,n),codeToTokens:(s,n)=>Wa(e,s,n)},r=Tc(Va(e,t,a,o));for(let s of Ga(a))r=s.postprocess?.call(o,r,a)||r;return r}var ai={light:"#333333",dark:"#bbbbbb"},oi={light:"#fffffe",dark:"#1e1e1e"},ri="__shiki_resolved";function dr(e){if(e?.[ri])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"?ai.light:ai.dark),a||(a=t.type==="light"?oi.light:oi.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.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 f={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,f.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,f.settings.background=d}return f});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=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,ri,{enumerable:!1,writable:!1,value:!0}),t}async function pi(e){return Array.from(new Set((await Promise.all(e.filter(t=>!ni(t)).map(async t=>await si(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function mi(e){return(await Promise.all(e.map(async a=>ii(a)?null:dr(await si(a))))).filter(a=>!!a)}var tr=3,Ac=!1;function vc(e,t=3){if(tr&&!(typeof tr=="number"&&t>tr)){if(Ac)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var $e=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function hi(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 $e(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var or=class extends Bn{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=dr(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=Vt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=hi(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(s=>!o.includes(s));throw new $e(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},rr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},Kt=0;function Rc(e){Kt+=1,e.warnings!==!1&&Kt>=10&&Kt%10===0&&console.warn(`[Shiki] ${Kt} 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 $e("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(dr),r=new rr(e.engine,a),s=new or(r,o,a,e.langAlias),n;function i(h){return hi(h,e.langAlias)}function l(h){x();let L=s.getGrammar(typeof h=="string"?h:h.name);if(!L)throw new $e(`Language \`${h}\` not found, you may need to load it first`);return L}function u(h){if(h==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};x();let L=s.getTheme(h);if(!L)throw new $e(`Theme \`${h}\` not found, you may need to load it first`);return L}function f(h){x();let L=u(h);n!==h&&(s.setTheme(L),n=h);let S=s.getColorMap();return{theme:L,colorMap:S}}function d(){return x(),s.getLoadedThemes()}function c(){return x(),s.getLoadedLanguages()}function p(...h){x(),s.loadLanguages(h.flat(1))}async function m(...h){return p(await pi(h))}function C(...h){x();for(let L of h.flat(1))s.loadTheme(L)}async function w(...h){return x(),C(await mi(h))}function x(){if(t)throw new $e("Shiki instance has been disposed")}function g(){t||(t=!0,s.dispose(),Kt-=1)}return{setTheme:f,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:c,resolveLangAlias:i,loadLanguage:m,loadLanguageSync:p,loadTheme:w,loadThemeSync:C,dispose:g,[Symbol.dispose]:g}}async function Mc(e){e.engine||vc("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([mi(e.themes||[]),pi(e.langs||[]),e.engine]);return Rc({...e,themes:t,langs:a,engine:o})}async function Fc(e){let t=await Mc(e);return{getLastGrammarState:(...a)=>hc(t,...a),codeToTokensBase:(a,o)=>lr(t,a,o),codeToTokensWithThemes:(a,o)=>ci(t,a,o),codeToTokens:(a,o)=>Wa(t,a,o),codeToHast:(a,o)=>Va(t,a,o),codeToHtml:(a,o)=>Pc(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function gi(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,ni(d))return[];let c=t[d];if(!c)throw new ee(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}function i(d){if(ii(d))return"none";if(typeof d=="string"){let c=a[d];if(!c)throw new ee(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return c}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),f=await Fc({engine:s.engine??o(),...s,themes:l,langs:u});return{...f,loadLanguage(...d){return f.loadLanguage(...d.map(n))},loadTheme(...d){return f.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Bc(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 wi(e,t){let a=Bc(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}var fr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-KGVIZMDC.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-2UHK5QYP.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-JKTWR5BV.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-EOIKHM3D.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-DFS2FCNO.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-MPGFGQFB.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-BOAZL66Z.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-FBR445XW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-C4CJ3STL.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-FSFFBRSD.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-QQK2LANG.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-X43A2VYW.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-BMSTTQT4.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-4Z3PRTF7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-JCXSJ2QD.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-XFWR7RMZ.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-7BBDB4BH.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-PQ2BEJIZ.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-J2PAB23I.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-TNKT6R3W.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-OHP5YUT7.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-PQW6E45S.js"))},{id:"c",name:"C",import:(()=>import("../c-PZBJFNXE.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-GP7XYHE6.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-NABGDHKY.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-WQSC2GLN.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-NXNSINKX.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-Y57BKRMA.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-LVMEA3JZ.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-LJNKRWP5.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-JYHOTXQS.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-IWWSYR3L.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-NNDQ5QXC.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-JKXCDYH3.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-BEHPNP64.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-IALOHSZA.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-ZDP3FIUI.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-ODFBXRGA.js"))},{id:"css",name:"CSS",import:(()=>import("../css-CJGL5AVH.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-LIK4TU3Z.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-UAAEAKHI.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-SZPVUQZJ.js"))},{id:"d",name:"D",import:(()=>import("../d-VSCA3XHG.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-A4PE6FIS.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-TILIKSFB.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-75KK3D55.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-HOT6P45M.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-FF35TY6T.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-FVPPHJI3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-SYE3ZPSJ.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-CCLQ2CKA.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-F6DQGRKA.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-5QRQXDZ6.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-NJ4S4OHV.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-KUYJX32Q.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-APEONNZ6.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-7OCMFVPS.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-BC46ME2N.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-MXZS6EX3.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-35BC2KX6.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-AXRAI2HH.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-JKNSQXHD.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-ZMKZGPZV.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-HNCVXEYB.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-XAJ4QRYP.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-HEFVQZAP.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-OFBRDPXX.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-ZE2M3Q5H.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-3N3INGLU.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-NFFQFQLP.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-RSUW6JYN.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-EZGWLX5T.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-VJLRYEVJ.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-UH2XQWLG.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-K6IV6NNR.js"))},{id:"go",name:"Go",import:(()=>import("../go-BDV7RR5G.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-NLMAEKLI.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-SX7K3XGL.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-3TGPQNR2.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-335RVEQR.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-73IS6B2J.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-P5PTJARU.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-RCPSSA3N.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-AKKZAVC2.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-REXV6F6N.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-AJ7VWOVL.js"))},{id:"html",name:"HTML",import:(()=>import("../html-654LNGWF.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-CMQ7BFDQ.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-7ZVVH3VM.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-B6WXEN45.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-5BXJCAAU.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-SB4TMFE7.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-Y64MHYWP.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-J2OP4CNW.js"))},{id:"java",name:"Java",import:(()=>import("../java-MJKJ5GPP.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-IYAGHPR6.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-WPD26JJ6.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-UYDZQBN5.js"))},{id:"json",name:"JSON",import:(()=>import("../json-5V4JESJO.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-7SHUZD3R.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-X3Z34FN3.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-6I3D2HM6.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-PZEQIBYV.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-GJJ25IKR.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-NI2J427C.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-CPV3A4MM.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-IA7HA2TL.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-CCRMGYMI.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-7DW25GYH.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-F2CTDTFG.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-MGJJWBTR.js"))},{id:"less",name:"Less",import:(()=>import("../less-WFSIMX5G.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-7CFNUD3V.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-CFQSEDXB.js"))},{id:"log",name:"Log file",import:(()=>import("../log-YQNML6LA.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-2PPKBL2M.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-RPAMRKNG.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-GR2DOH6N.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-DQQEEPI4.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-OC5ILZSY.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-XSB3CTWQ.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-YQY6FS4U.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-XWCHWP6B.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-ZIH2JLVR.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-WPX56SBB.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-IDXQRZ2B.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-MH7EQVOK.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-5JDFTWKE.js"))},{id:"move",name:"Move",import:(()=>import("../move-RWSXKYDY.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-QJUEXMVV.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-2EICNZA3.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-RIWAEC5Z.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-U57UBFBS.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-XCKQVWCN.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-QGW7HANA.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-V7KYXFHL.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-NKUEWVGU.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-QT2CZJZN.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-MVMIXBHP.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-BJDUXUUZ.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-HGWEFD6L.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-IZHDGBO6.js"))},{id:"php",name:"PHP",import:(()=>import("../php-MNP62HWP.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-VA5ZK5DW.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-J7A7YWFH.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-5RDI65JX.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-VUJL2E7F.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-ESTB5G7N.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-ODTEKQCW.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-ZOYRAWBJ.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-QHG2W5GE.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-CSAPG5PH.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-WDNJBTSW.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-P7LS6DER.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-LHFWHTY3.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-DUFJP4FY.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-5ZNZSNQ2.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-LTAXB6W5.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-7Z2ODQLM.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-FDFD3HQD.js"))},{id:"r",name:"R",import:(()=>import("../r-6ZOS53WN.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7AYZPEUI.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-A4F6VHVG.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-4QOCK4UD.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-FAPHGG66.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-5BYLYA2R.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-7DJ7HHU4.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-YIYJATFG.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-HYYMCHTX.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-FDNH6QF7.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-6KQSGP2V.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-OWE2HOOR.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-V3GMJA2K.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-D3G4GB3X.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-JTO65AGR.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-4XQGFSVM.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-CB7AC7IL.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-6SKV4OGI.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-LKGZFJ46.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-K536DHEB.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-LRNUKUSZ.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-IBQK7VWQ.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-DQOSWAW7.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-V2FMZEG4.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-VW3CKXWF.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-L2VKP7YP.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-KDKHP7GC.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-UF27CALT.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-JC2DQ6ED.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-7PXCUY24.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-2L7N3EZD.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-ZY3E6XEL.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-Q45XIK2A.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-XBH5HZSC.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-VRAUSZY3.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-JOTSGJD4.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-NNZRZKOU.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-MBFZ4QNC.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-4GEDCBVE.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-3XM7DLQ3.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-XTHOS4UK.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-UXMN2CV7.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-J6K55ZSV.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-XNK5N5RZ.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-DOUJHQDQ.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-G5BMVRHK.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-JHJ7W6U5.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-OEIJ72KK.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-LMKEAHFC.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-5CLTIJYY.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-4W4Z436Z.js"))},{id:"v",name:"V",import:(()=>import("../v-Y4SBDBN7.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-UMKT2MFA.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-DQ7A5WJU.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-N6ZF7GQD.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-BNYDT37G.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-37RMDCBC.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-FIH2DYBE.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-ZLTZN573.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-6JKAZ54I.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-GVXF46KD.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-NTB4O7GL.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-W7WB3BC7.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-7GTDVXHG.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-ASAFPAIL.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-ZBCR6544.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-SZRZOETJ.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-EBTJCOTU.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-IBYEXWDX.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-GMVQNECR.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-O2TZFP4A.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-ZLGM7IMN.js"))}],xi=Object.fromEntries(fr.map(e=>[e.id,e.import])),Li=Object.fromEntries(fr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),Zt={...xi,...Li};var Dc=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-HAPOYWX3.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-R6WAWEBC.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-KMD4YO7F.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-2ATPDILG.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-LJ7PG5AM.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-Z4Y2POK6.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-4TQUIKX4.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-B7YYPERT.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-KX33VXKA.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-LNHXUR7U.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-T2CMBBQ5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-SMFRNKX2.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-DBZHIUAO.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-TDAGYJUK.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-3E25TTAN.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-KCBFVSS5.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-WRCBXEVS.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-ET7SAHAV.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-6FNTZH5H.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-GGTAKNM7.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-LHYKPR5E.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-IQWZCHF7.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-ARPWF4FS.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-ODS6FPID.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-KFA5YFDW.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-MMET4L3Y.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-DBZDERMK.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-FSOMPXNP.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-FAQBCORN.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-JNDVF5RJ.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-S7JK6TQ6.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-QJJIMVEV.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-YFP3EJVX.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-NGDHCPUZ.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-H2BHKUKX.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-VENCGWTB.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-SDMLS22W.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-UHDBRLVF.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-3TB2BEET.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-CQ5WKNT7.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-LZRD4NPR.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-WHRY6275.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-7PNEW2JB.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-GJUYOOJR.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-EVGUMUX2.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-PMTR3SA7.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-O7WH4N5X.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-FBVUW6NJ.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-WBB7GZAD.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-7KAMONOP.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-F2G5IHZD.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-ALZ7XGH2.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-D3K4SWUL.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-YFPJODWS.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-H67AWZOI.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-OUVS63VK.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-2RCAVEXJ.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-XFSENHTC.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-5XXB3K6S.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-CHJCCBJH.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-Y5GIEAN4.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-7TI33KHX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-FOB25MRB.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-4WCNCTCO.js"))}],Ci=Object.fromEntries(Dc.map(e=>[e.id,e.import]));var Yt=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ec(){return 2147483648}function _c(){return typeof performance<"u"?performance.now():Date.now()}var Nc=(e,t)=>e+(t-e%t)%t;async function Oc(e){let t,a,o={};function r(p){a=p,o.HEAPU8=new Uint8Array(p),o.HEAPU32=new Uint32Array(p)}function s(p,m,C){o.HEAPU8.copyWithin(p,m,m+C)}function n(p){try{return t.grow(p-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(p){let m=o.HEAPU8.length;p=p>>>0;let C=Ec();if(p>C)return!1;for(let w=1;w<=4;w*=2){let x=m*(1+.2/w);x=Math.min(x,p+100663296);let g=Math.min(C,Nc(Math.max(p,x),65536));if(n(g))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(p,m,C=1024){let w=m+C,x=m;for(;p[x]&&!(x>=w);)++x;if(x-m>16&&p.buffer&&l)return l.decode(p.subarray(m,x));let g="";for(;m<x;){let h=p[m++];if(!(h&128)){g+=String.fromCharCode(h);continue}let L=p[m++]&63;if((h&224)===192){g+=String.fromCharCode((h&31)<<6|L);continue}let S=p[m++]&63;if((h&240)===224?h=(h&15)<<12|L<<6|S:h=(h&7)<<18|L<<12|S<<6|p[m++]&63,h<65536)g+=String.fromCharCode(h);else{let k=h-65536;g+=String.fromCharCode(55296|k>>10,56320|k&1023)}}return g}function f(p,m){return p?u(o.HEAPU8,p,m):""}let d={emscripten_get_now:_c,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function c(){let m=await e({env:d,wasi_snapshot_preview1:d});t=m.memory,r(t.buffer),Object.assign(o,m),o.UTF8ToString=f}return await c(),o}var Uc=Object.defineProperty,Hc=(e,t,a)=>t in e?Uc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,le=(e,t,a)=>Hc(e,typeof t!="symbol"?t+"":t,a),me=null;function qc(e){throw new Yt(e.UTF8ToString(e.getLastOnigError()))}var Xa=class e{constructor(t){le(this,"utf16Length"),le(this,"utf8Length"),le(this,"utf16Value"),le(this,"utf8Value"),le(this,"utf16OffsetToUtf8"),le(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let f=t.charCodeAt(u),d=f,c=!1;if(f>=55296&&f<=56319&&u+1<a){let p=t.charCodeAt(u+1);p>=56320&&p<=57343&&(d=(f-55296<<10)+65536|p-56320,c=!0)}r&&(s[u]=l,c&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[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),c&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=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}},Qa=class Oe{constructor(t){if(le(this,"id",++Oe.LAST_ID),le(this,"_onigBinding"),le(this,"content"),le(this,"utf16Length"),le(this,"utf8Length"),le(this,"utf16OffsetToUtf8"),le(this,"utf8OffsetToUtf16"),le(this,"ptr"),!me)throw new Yt("Must invoke loadWasm first.");this._onigBinding=me,this.content=t;let a=new Xa(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Oe._sharedPtrInUse?(Oe._sharedPtr||(Oe._sharedPtr=me.omalloc(1e4)),Oe._sharedPtrInUse=!0,me.HEAPU8.set(a.utf8Value,Oe._sharedPtr),this.ptr=Oe._sharedPtr):this.ptr=a.createString(me)}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===Oe._sharedPtr?Oe._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};le(Qa,"LAST_ID",0);le(Qa,"_sharedPtr",0);le(Qa,"_sharedPtrInUse",!1);var Ii=Qa,pr=class{constructor(t){if(le(this,"_onigBinding"),le(this,"_ptr"),!me)throw new Yt("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Xa(t[i]);a[i]=u.createString(me),o[i]=u.utf8Length}let r=me.omalloc(4*t.length);me.HEAPU32.set(a,r/4);let s=me.omalloc(4*t.length);me.HEAPU32.set(o,s/4);let n=me.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)me.ofree(a[i]);me.ofree(s),me.ofree(r),n===0&&qc(me),this._onigBinding=me,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Ii(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let i=s.HEAPU32,l=n/4,u=i[l++],f=i[l++],d=[];for(let c=0;c<f;c++){let p=t.convertUtf8OffsetToUtf16(i[l++]),m=t.convertUtf8OffsetToUtf16(i[l++]);d[c]={start:p,end:m,length:m-p}}return{index:u,captureIndices:d}}};function Gc(e){return typeof e.instantiator=="function"}function Wc(e){return typeof e.default=="function"}function Vc(e){return typeof e.data<"u"}function zc(e){return typeof Response<"u"&&e instanceof Response}function jc(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 $a;function $c(e){if($a)return $a;async function t(){me=await Oc(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Gc(o)?o=await o.instantiator(a):Wc(o)?o=await o.default(a):(Vc(o)&&(o=o.data),zc(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Xc(o)(a):o=await Qc(o)(a):jc(o)?o=await cr(o)(a):o instanceof WebAssembly.Module?o=await cr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await cr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return $a=t(),$a}function cr(e){return t=>WebAssembly.instantiate(e,t)}function Xc(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Qc(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Si(e){return e&&await $c(e),{createScanner(t){return new pr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Ii(t)}}}var Ka=gi({langs:Zt,themes:Ci,engine:()=>Si(import("../wasm-EOPKAILK.js"))}),{codeToHtml:Kc,codeToHast:Jc,codeToTokens:Zc,codeToTokensBase:Yc,codeToTokensWithThemes:ep,getSingletonHighlighter:tp,getLastGrammarState:ap}=wi(Ka,{guessEmbeddedLanguages:ui});var yi=new Set(Object.keys(Zt)),mr=new Map,hr=new Map,It=new Map,op=(e,t)=>`${e}-${t[0]}-${t[1]}`,rp=(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}`},sp=(e,t)=>{let a=op(e,t);if(mr.has(a))return mr.get(a);let o=Ka({themes:t,langs:[e]});return mr.set(a,o),o};function np(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return yi.has(o)},getSupportedLanguages(){return Array.from(yi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=rp(o,r,s);return hr.has(i)?hr.get(i):(n&&(It.has(i)||It.set(i,new Set),It.get(i).add(n)),sp(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",f=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});hr.set(i,f);let d=It.get(i);if(d){for(let c of d)c(f);It.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),It.delete(i)}),null)}}}var bi=np();import{memo as dp}from"react";import{useEffect as ip,useRef as Ja,useState as lp}from"react";var up=5,ki=400;function Ti(e,t,a={}){let{msPerChar:o=up}=a,[r,s]=lp(t?"":e),n=Ja(e),i=Ja(t?0:e.length),l=Ja(0),u=Ja(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),n.current=e,ip(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,s(e);return}if(n.current.length-i.current>ki&&(i.current=n.current.length-ki),u.current!==null)return;let d=c=>{let p=n.current;if(i.current>=p.length){u.current=null;return}l.current===0&&(l.current=c);let m=c-l.current;if(m>=o){let C=Math.min(Math.floor(m/o),p.length-i.current);i.current+=C,s(p.slice(0,i.current)),l.current=c}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 Za}from"react/jsx-runtime";var gr=({className:e,from:t,children:a,...o})=>Za("div",{className:T("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:Za("div",{className:T("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),wr=({children:e,className:t,...a})=>Za("div",{className:T("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),fp={cjk:Uo,code:bi},cp={cjk:Uo},pp={enabled:!1};function mp({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let n=Ti(typeof o=="string"?o:"",!!a),i=typeof o=="string"?n:o;return Za(bt,{className:T("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??pp,plugins:a?cp:fp,...r,children:i})}var Ya=dp(mp,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);Ya.displayName="MessageResponse";import{createContext as hp,useCallback as gp,useContext as Ri,useEffect as wp,useMemo as Lr,useRef as xp,useState as Cr}from"react";import{Fragment as vi,jsx as Q,jsxs as ut}from"react/jsx-runtime";function Lp(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,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 f=`${l}\u2009${u}`;r.push(f),s-=f.length+3}return`{${r.join(", ")}}`}function Cp({text:e,className:t}){let{t:a}=U(),[o,r]=Cr(!1),s=xp(null);wp(()=>()=>{s.current&&clearTimeout(s.current)},[]);let n=gp(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return Q(Ae,{variant:"ghost",size:"sm",onClick:n,className:T("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?ut(vi,{children:[Q(Tt,{className:"ww:size-3.5"}),Q("span",{children:a.tool.copied})]}):ut(vi,{children:[Q(At,{className:"ww:size-3.5"}),Q("span",{children:a.tool.copy})]})})}function Mi({data:e,label:t,className:a,...o}){let[r,s]=Cr(!1),n=Lr(()=>JSON.stringify(e,null,2),[e]),i=Lp(e);return ut("div",{className:T("ww:rounded-lg ww:bg-tool-card",a),...o,children:[ut("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[Q("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),Q(Cp,{text:n})]}),ut("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[Q(Pt,{className:T("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?Q("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:Q("code",{children:n})}):Q("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Ir=hp({open:!1,toggle:()=>{}});function Fi({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=Cr(t);return Q(Ir.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:Q("div",{className:T("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 Bi({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=Ri(Ir),n=a==="input-available"||a==="input-streaming",i=t??"";return ut("button",{type:"button",onClick:s,className:T("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:[Q(et,{className:"ww:size-4 ww:shrink-0"}),Q("span",{className:"ww:truncate",children:n?Q(Be,{duration:1.6,children:i}):i}),Q(We,{className:T("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Di({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",s=t??"";return Q("div",{className:T("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:Q("span",{className:"ww:truncate",children:r?Q(Be,{duration:1.6,children:s}):s})})}function Ei({className:e,children:t,...a}){let{open:o}=Ri(Ir);return Q("div",{className:T("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:Q("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Q("div",{className:T("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 Sr({className:e,input:t,debug:a,...o}){let{t:r}=U(),s=Lr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,a]);return Q(Mi,{data:s,label:r.tool.request,className:e,...o})}function xr(e){if(!(typeof e!="object"||e===null))return e}function _i(e){return xr(e?.ui)}function Ni(e){return xr(xr(e)?._meta)}function Pi(e){if(!e)return;let t=_i(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 Ai(e){return _i(e)?.autoHeight===!0}function ea(e,t,a){if(e){let o=Pi(a?.[e]?._meta);if(o)return o}return Pi(Ni(t))}function Oi(e,t,a){return e&&Ai(a?.[e]?._meta)?!0:Ai(Ni(t))}function yr({className:e,output:t,errorText:a,debug:o,...r}){let{t:s}=U(),n=Lr(()=>{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?ut("div",{className:T("ww:space-y-2",e),...r,children:[Q("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:s.tool.error}),Q("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):Q(Mi,{data:n,label:s.tool.response,className:e,...r}):null}import{jsx as Ui,jsxs as Ip}from"react/jsx-runtime";function Hi(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function qi(e){return e.parts.some(Hi)}function Gi(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(s=>!(!Hi(s)||a?.ignoreToolParts&&"toolCallId"in s||a?.ignoreReasoningParts&&s.type==="reasoning"))}function Wi({className:e,...t}){let{t:a}=U();return Ip("div",{"aria-live":"polite",className:T("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:[Ui(Dt,{className:"ww:size-4 ww:shrink-0"}),Ui(Be,{duration:1.6,children:a.workingIndicator.default})]})}import{useCallback as Sp,useEffect as zi,useMemo as yp,useRef as ye,useState as ji}from"react";function St(e){if(!e)return!1;let t=Array.isArray(e.content)&&e.content.length>0,a=typeof e.structuredContent=="object"&&e.structuredContent!==null&&Object.keys(e.structuredContent).length>0;return t||a}function Vi(e,t){return!St(e)&&!St(t)?null:St(e)?St(t)?{...e.content||t.content?{content:[...e.content??[],...t.content??[]]}:{},...e.structuredContent||t.structuredContent?{structuredContent:{...e.structuredContent??{},...t.structuredContent??{}}}:{}}:{...e.content?{content:[...e.content]}:{},...e.structuredContent?{structuredContent:{...e.structuredContent}}:{}}:{...t?.content?{content:[...t.content]}:{},...t?.structuredContent?{structuredContent:{...t.structuredContent}}:{}}}import{jsx as Dp}from"react/jsx-runtime";var bp="/api/mcp/resource",kp=500,Tp=0,Pp=16,Ap="2026-01-26",vp=300,Rp=3e3,Mp=3;function Fp(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Bp(e,t,a){return ea(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function br({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=bp,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:f,onDisplayModeChange:d,isFullscreen:c=!1,toolDefinitions:p}){let m=ye(null),C=ye(t),w=ye(a),x=ye({width:0,height:0}),g=ye(null),h=ye(!1),L=ye(0),S=ye("inline"),[k,A]=ji(Tp),[P,E]=ji(void 0),B=ye(l),O=ye(u),b=ye(f),v=ye(d),y=ye(r),M=ye(p);C.current=t,w.current=a,B.current=l,O.current=u,b.current=f,v.current=d,y.current=r,M.current=p;let X=Sp(V=>i?Math.max(V+Pp,0):Math.min(Math.max(V,50),kp),[i]),ae=yp(()=>{let V=o.includes("?")?"&":"?";return`${o}${V}uri=${encodeURIComponent(e)}`},[o,e]),oe=ye(s);return oe.current=s,zi(()=>{if(!h.current)return;let V=m.current;V?.contentWindow&&V.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),zi(()=>{let V=m.current;if(!V)return;let re=!1,Le=!1,fe=null,ce=null,Ee=setTimeout(()=>{if(re||Le||L.current>=Mp)return;L.current+=1;let z=new URL(V.src);z.searchParams.set("_retry",String(L.current)),V.src=z.toString()},Rp),_=z=>{V.contentWindow?.postMessage(z,"*")},J=z=>{if(re||z.source!==V.contentWindow)return;let G=z.data;if(!G||typeof G!="object"||G.jsonrpc!=="2.0")return;let Z=G.method,H=G.id;if(Z==="ui/initialize"&&H!=null){Le=!0,clearTimeout(Ee),_({jsonrpc:"2.0",id:H,result:{protocolVersion:G.params?.protocolVersion??Ap,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:oe.current?"dark":"light",displayMode:S.current}}});return}if(Z==="ui/notifications/initialized"){h.current=!0;let j=C.current,$=w.current,R=$._meta&&typeof $._meta=="object"?$._meta:null,F=Fp(y.current),q=R&&typeof R.waniwani=="object"&&R.waniwani!==null?R.waniwani:null,se=q||F?{...q??{},...F?{sessionId:F}:{}}:void 0,Ce=R||se?{...R??{},...se?{waniwani:se}:{}}:void 0;_({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:j}});let Me=$.content??[{type:"text",text:JSON.stringify($)}];_({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:Me,structuredContent:$.structuredContent,_meta:Ce,meta:Ce}});return}if(Z==="ui/notifications/size-changed"){let j=G.params,$=typeof j?.height=="number"?j.height:void 0,R=typeof j?.width=="number"?j.width:void 0,F=x.current,q=$!==void 0&&$!==F.height,se=R!==void 0&&R!==F.width;if(!q&&!se)return;if(q&&$!==void 0){F.height=$;let Ce=X($),Me=V.getBoundingClientRect().height;if(g.current&&(g.current.cancel(),g.current=null),A(Ce),V.animate&&Math.abs(Me-Ce)>2){let Ge=V.animate([{height:`${Me}px`},{height:`${Ce}px`}],{duration:vp,easing:"ease-out",fill:"forwards"});g.current=Ge,Ge.onfinish=()=>{g.current===Ge&&(Ge.cancel(),g.current=null)}}}se&&i&&R!==void 0&&(F.width=R,E(R));return}if(Z==="ui/open-link"&&H!=null){let j=G.params?.url;typeof j=="string"&&(B.current?B.current(j):window.open(j,"_blank","noopener,noreferrer")),_({jsonrpc:"2.0",id:H,result:{}});return}if(Z==="ui/message"&&H!=null){if(O.current&&G.params){let j=G.params,$=fe;if(fe=null,ce){clearTimeout(ce.timer);let R=ce.text;ce=null;let F=(j.content??[]).map(q=>q.text??"").join("").trim();j={...j,content:[{type:"text",text:`${F}
|
|
14
14
|
|
|
15
|
-
${R}`}]}}O.current({...j,...$?{modelContext:$}:{}})}_({jsonrpc:"2.0",id:H,result:{}});return}if(Z==="ui/update-model-context"&&H!=null){fe=Vi(fe,G.params),_({jsonrpc:"2.0",id:H,result:{}});return}if(Z==="tools/call"&&H!=null){let j=b.current;if(!j){_({jsonrpc:"2.0",id:H,error:{code:-32601,message:"tools/call not supported"}});return}let $=G.params?.name;j({name:$,arguments:G.params?.arguments??{}}).then(R=>{_({jsonrpc:"2.0",id:H,result:R});let F=R.content?.map(q=>q.text??"").join("").trim();F&&Bp($,R,M.current)&&(ce&&clearTimeout(ce.timer),ce={text:F,timer:setTimeout(()=>{if(re)return;let q=fe;fe=null,ce=null,O.current?.({role:"user",content:[{type:"text",text:F}],...q?{modelContext:q}:{}})},500)})}).catch(R=>{let F=R instanceof Error?R.message:"Tool call failed";_({jsonrpc:"2.0",id:H,error:{code:-32e3,message:F}})});return}if(Z==="ui/request-display-mode"&&H!=null){let j=G.params?.mode,$=j==="fullscreen"||j==="inline"||j==="pip"?j:"inline";S.current=$,_({jsonrpc:"2.0",id:H,result:{mode:$}}),_({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:$}}),v.current?.($);return}if(Z==="ui/resource-teardown"&&H!=null){_({jsonrpc:"2.0",id:H,result:{}});return}Z==="ping"&&H!=null&&_({jsonrpc:"2.0",id:H,result:{}})};return window.addEventListener("message",J),()=>{re=!0,clearTimeout(Ee),ce&&clearTimeout(ce.timer),window.removeEventListener("message",J)}},[i,X]),Dp("iframe",{ref:m,src:ae,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:T(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":k,minWidth:c||!P?void 0:`min(${P}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as ta,jsxs as Ep}from"react/jsx-runtime";function $i({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Ep("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&&ta("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}),ta("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&ta("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&ta("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>ta("button",{type:"button",onClick:()=>r?.(s),className:T("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}import{Component as _p}from"react";import{jsx as kr,jsxs as Op}from"react/jsx-runtime";function Np({onRetry:e}){let{t}=U();return Op("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:[kr("span",{children:t.widgetErrorBoundary.failedToLoad}),kr("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var eo=class extends _p{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?kr(Np,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Hp,jsx as K,jsxs as Qe}from"react/jsx-runtime";function Xi(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Up(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?Rt:et}function to({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,showToolCalls:p=!0,toolDefinitions:m}){let{t:C}=U(),w=e[e.length-1],x=e.length>0,g=d!=null,h=!g&&Gi(e,t,{ignoreToolParts:p===!1,ignoreReasoningParts:p===!1});return Qe(Hp,{children:[!g&&(!x&&o?K($i,{...o,onSuggestionSelect:r}):a&&K(gr,{from:"assistant",children:K(wr,{children:K(Ya,{children:a})})})),e.map(L=>{let S=L.parts.filter(y=>y.type==="text"),k=L.parts.filter(y=>y.type==="reasoning"),A=L.parts.filter(y=>y.type==="file"),P=L.parts.filter(y=>"toolCallId"in y),E=L.parts.filter(y=>y.type==="reasoning"||"toolCallId"in y),B=L===w&&L.role==="assistant",O=S.length>0,b=g?P.some(y=>y.toolCallId===d):!1,v=p!==!1&&!b&&E.length>=2;return g&&!b?K("div",{style:{display:"none"}},L.id):L.role==="assistant"&&!qi(L)?K("div",{style:{display:"none"}},L.id):p===!1&&L.role==="assistant"&&!O&&A.length===0&&P.every(y=>{let M="output"in y?y.output:void 0;return M===void 0||!s||!ea(y.toolName,M,m)})?K("div",{style:{display:"none"}},L.id):Qe(gr,{from:L.role,children:[p!==!1&&!b&&!v&&k.map((y,M)=>Qe(Ot,{isStreaming:y.state==="streaming",children:[K(Ut,{}),K(Ht,{children:y.text})]},`reasoning-${L.id}-${M}`)),v&&Qe(Ws,{isWorking:B&&(t==="streaming"||t==="submitted"),children:[K(Vs,{workingLabel:C.chainOfThought.working,label:C.chainOfThought.done}),K(zs,{children:E.map((y,M)=>{let X=M===E.length-1;if(y.type==="reasoning")return K($s,{isStreaming:y.state==="streaming",isLast:X,children:y.text},`reasoning-${L.id}-${M}`);let ae=y.title??Xi(y.toolName),oe=Up(y.toolName);if(p==="titles-only")return K(_o,{icon:oe,title:ae,state:y.state,isLast:X},y.toolCallId);let V="output"in y?y.output:void 0;return Qe(_o,{icon:oe,title:ae,state:y.state,isLast:X,children:[K(Sr,{input:y.input,debug:c}),V!==void 0&&K(yr,{output:V,errorText:"errorText"in y?y.errorText:void 0,debug:c})]},y.toolCallId)})})]}),p!==!1&&!b&&!v&&P.length===1&&(()=>{let y=P[0],M=y.title??Xi(y.toolName);if(p==="titles-only")return K(Di,{title:M,state:y.state});let X="output"in y?y.output:void 0;return Qe(Fi,{children:[K(Bi,{title:M,state:y.state}),Qe(Ei,{children:[K(Sr,{input:y.input,debug:c}),X!==void 0&&K(yr,{output:X,errorText:"errorText"in y?y.errorText:void 0,debug:c})]})]})})(),P.map(y=>{let M="output"in y?y.output:void 0,X=ea(y.toolName,M,m),ae=Oi(y.toolName,M,m),oe=y.toolCallId===d;return X&&s&&M!==void 0?K("div",{style:oe?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:X&&s&&M!==void 0&&K(eo,{children:K(br,{isFullscreen:oe,resourceUri:X,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:ae,toolDefinitions:m,onFollowUp:l,onCallTool:u,onDisplayModeChange:f?V=>f(V,{toolCallId:y.toolCallId,resourceUri:X,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:ae}):void 0})})},y.toolCallId):null}),!b&&K("div",{children:Qe(wr,{children:[A.length>0&&K(_s,{files:A}),O?S.map((y,M)=>{let X=B&&t==="streaming"&&M===S.length-1;return K(Ya,{isStreaming:X,children:y.type==="text"?y.text:""},`${L.id}-${M}`)}):null]})})]},L.id)}),h&&K(Wi,{})]})}import{jsx as Qi,jsxs as Wp}from"react/jsx-runtime";var qp="https://app.waniwani.ai/assets/waniwani-logo.svg",Gp="https://waniwani.ai";function ao(){let{t:e}=U();return Wp("a",{href:Gp,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:[Qi("span",{children:e.poweredBy.label}),Qi("img",{src:qp,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}import{jsx as oo}from"react/jsx-runtime";function ro({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:oo("div",{className:T("ww:px-4 ww:py-2",o),...r,children:oo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>oo("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>oo("button",{type:"button",onClick:()=>a(s),className:T("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}import{useEffect as Vp,useRef as zp,useState as jp}from"react";import{jsx as te,jsxs as dt}from"react/jsx-runtime";var Ki=20;function $p({label:e}){return dt("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:[te("title",{children:e}),te("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),te("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Xp({label:e}){return dt("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:[te("title",{children:e}),te("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),te("polyline",{points:"3 4 3 9 8 9"}),te("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),te("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Qp({label:e}){return dt("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:[te("title",{children:e}),te("polyline",{points:"3 6 5 6 21 6"}),te("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),te("path",{d:"M10 11v6"}),te("path",{d:"M14 11v6"})]})}function so({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:s,t:n}=U(),[i,l]=jp(!1),u=zp(null);Vp(()=>{if(!i)return;let c=p=>{let m=u.current;m&&(p.composedPath().includes(m)||l(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);let f=e.slice(0,Ki),d=Math.max(0,e.length-Ki);return dt("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[te("button",{type:"button",onClick:a,title:n.threadMenu.newChat,"aria-label":n.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:te($p,{label:n.threadMenu.newChat})}),te("button",{type:"button",onClick:()=>l(c=>!c),title:n.threadMenu.threadHistory,"aria-label":n.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:te(Xp,{label:n.threadMenu.threadHistory})}),i&&dt("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:[f.length===0&&te("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:n.threadMenu.noPreviousChats}),f.map(c=>{let p=c.threadId===t,m=Date.parse(c.updatedAt);return dt("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${p?"ww:bg-foreground/5":""}`,children:[dt("button",{type:"button",onClick:()=>{o(c.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[te("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),te("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(m)?"":vo(m,s)})]}),te("button",{type:"button",onClick:C=>{C.stopPropagation(),r(c.threadId)},title:n.threadMenu.deleteThread,"aria-label":n.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:te(Qp,{label:n.threadMenu.deleteThread})})]},c.threadId)}),d>0&&te("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:n.threadMenu.hiddenThreads(d)})]})]})}import{useCallback as Kp,useRef as Jp}from"react";function no(e){let t=Jp(e);return t.current=e,Kp(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.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()},[])}import{useChat as mm}from"@ai-sdk/react";import{useCallback as we,useEffect as Re,useRef as ue,useState as ft}from"react";function Ke(e,t,a){let[o,r=""]=e.split("?"),s=o.replace(/\/$/,""),n=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))n.set(l,u);let i=n.toString();return`${s}${t}${i?`?${i}`:""}`}import{DefaultChatTransport as Zp,uiMessageChunkSchema as Yp}from"ai";function em(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 n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var io=class extends Zp{processResponseStream(t){let a="",o=Yp(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
|
|
15
|
+
${R}`}]}}O.current({...j,...$?{modelContext:$}:{}})}_({jsonrpc:"2.0",id:H,result:{}});return}if(Z==="ui/update-model-context"&&H!=null){fe=Vi(fe,G.params),_({jsonrpc:"2.0",id:H,result:{}});return}if(Z==="tools/call"&&H!=null){let j=b.current;if(!j){_({jsonrpc:"2.0",id:H,error:{code:-32601,message:"tools/call not supported"}});return}let $=G.params?.name;j({name:$,arguments:G.params?.arguments??{}}).then(R=>{_({jsonrpc:"2.0",id:H,result:R});let F=R.content?.map(q=>q.text??"").join("").trim();F&&Bp($,R,M.current)&&(ce&&clearTimeout(ce.timer),ce={text:F,timer:setTimeout(()=>{if(re)return;let q=fe;fe=null,ce=null,O.current?.({role:"user",content:[{type:"text",text:F}],...q?{modelContext:q}:{}})},500)})}).catch(R=>{let F=R instanceof Error?R.message:"Tool call failed";_({jsonrpc:"2.0",id:H,error:{code:-32e3,message:F}})});return}if(Z==="ui/request-display-mode"&&H!=null){let j=G.params?.mode,$=j==="fullscreen"||j==="inline"||j==="pip"?j:"inline";S.current=$,_({jsonrpc:"2.0",id:H,result:{mode:$}}),_({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:$}}),v.current?.($);return}if(Z==="ui/resource-teardown"&&H!=null){_({jsonrpc:"2.0",id:H,result:{}});return}Z==="ping"&&H!=null&&_({jsonrpc:"2.0",id:H,result:{}})};return window.addEventListener("message",J),()=>{re=!0,clearTimeout(Ee),ce&&clearTimeout(ce.timer),window.removeEventListener("message",J)}},[i,X]),Dp("iframe",{ref:m,src:ae,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:T(!c&&"ww:rounded-md ww:border ww:border-border",n),style:{height:c?"100%":k,minWidth:c||!P?void 0:`min(${P}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}import{jsx as ta,jsxs as Ep}from"react/jsx-runtime";function $i({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Ep("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&&ta("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}),ta("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&ta("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&ta("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>ta("button",{type:"button",onClick:()=>r?.(s),className:T("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}import{Component as _p}from"react";import{jsx as kr,jsxs as Op}from"react/jsx-runtime";function Np({onRetry:e}){let{t}=U();return Op("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:[kr("span",{children:t.widgetErrorBoundary.failedToLoad}),kr("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var eo=class extends _p{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?kr(Np,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Hp,jsx as K,jsxs as Qe}from"react/jsx-runtime";function Xi(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Up(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?Rt:et}function to({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:f,fullscreenToolCallId:d,debug:c,showToolCalls:p=!0,toolDefinitions:m}){let{t:C}=U(),w=e[e.length-1],x=e.length>0,g=d!=null,h=!g&&Gi(e,t,{ignoreToolParts:p===!1,ignoreReasoningParts:p===!1});return Qe(Hp,{children:[!g&&(!x&&o?K($i,{...o,onSuggestionSelect:r}):a&&K(gr,{from:"assistant",children:K(wr,{children:K(Ya,{children:a})})})),e.map(L=>{let S=L.parts.filter(y=>y.type==="text"),k=L.parts.filter(y=>y.type==="reasoning"),A=L.parts.filter(y=>y.type==="file"),P=L.parts.filter(y=>"toolCallId"in y),E=L.parts.filter(y=>y.type==="reasoning"||"toolCallId"in y),B=L===w&&L.role==="assistant",O=S.length>0,b=g?P.some(y=>y.toolCallId===d):!1,v=p!==!1&&!b&&E.length>=2;return g&&!b?K("div",{style:{display:"none"}},L.id):L.role==="assistant"&&!qi(L)?K("div",{style:{display:"none"}},L.id):p===!1&&L.role==="assistant"&&!O&&A.length===0&&P.every(y=>{let M="output"in y?y.output:void 0;return M===void 0||!s||!ea(y.toolName,M,m)})?K("div",{style:{display:"none"}},L.id):Qe(gr,{from:L.role,children:[p!==!1&&!b&&!v&&k.map((y,M)=>Qe(Ot,{isStreaming:y.state==="streaming",children:[K(Ut,{}),K(Ht,{children:y.text})]},`reasoning-${L.id}-${M}`)),v&&Qe(Ws,{isWorking:B&&(t==="streaming"||t==="submitted"),children:[K(Vs,{workingLabel:C.chainOfThought.working,label:C.chainOfThought.done}),K(zs,{children:E.map((y,M)=>{let X=M===E.length-1;if(y.type==="reasoning")return K($s,{isStreaming:y.state==="streaming",isLast:X,children:y.text},`reasoning-${L.id}-${M}`);let ae=y.title??Xi(y.toolName),oe=Up(y.toolName);if(p==="titles-only")return K(_o,{icon:oe,title:ae,state:y.state,isLast:X},y.toolCallId);let V="output"in y?y.output:void 0;return Qe(_o,{icon:oe,title:ae,state:y.state,isLast:X,children:[K(Sr,{input:y.input,debug:c}),V!==void 0&&K(yr,{output:V,errorText:"errorText"in y?y.errorText:void 0,debug:c})]},y.toolCallId)})})]}),p!==!1&&!b&&!v&&P.length===1&&(()=>{let y=P[0],M=y.title??Xi(y.toolName);if(p==="titles-only")return K(Di,{title:M,state:y.state});let X="output"in y?y.output:void 0;return Qe(Fi,{children:[K(Bi,{title:M,state:y.state}),Qe(Ei,{children:[K(Sr,{input:y.input,debug:c}),X!==void 0&&K(yr,{output:X,errorText:"errorText"in y?y.errorText:void 0,debug:c})]})]})})(),P.map(y=>{let M="output"in y?y.output:void 0,X=ea(y.toolName,M,m),ae=Oi(y.toolName,M,m),oe=y.toolCallId===d;return X&&s&&M!==void 0?K("div",{style:oe?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:X&&s&&M!==void 0&&K(eo,{children:K(br,{isFullscreen:oe,resourceUri:X,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:ae,toolDefinitions:m,onFollowUp:l,onCallTool:u,onDisplayModeChange:f?V=>f(V,{toolCallId:y.toolCallId,resourceUri:X,toolInput:y.input??{},toolResult:{content:M.content,structuredContent:M.structuredContent,_meta:M._meta},autoHeight:ae}):void 0})})},y.toolCallId):null}),!b&&K("div",{children:Qe(wr,{children:[A.length>0&&K(_s,{files:A}),O?S.map((y,M)=>{let X=B&&t==="streaming"&&M===S.length-1;return K(Ya,{isStreaming:X,children:y.type==="text"?y.text:""},`${L.id}-${M}`)}):null]})})]},L.id)}),h&&K(Wi,{})]})}import{jsx as Qi,jsxs as Wp}from"react/jsx-runtime";var qp="https://app.waniwani.ai/assets/waniwani-logo.svg",Gp="https://waniwani.ai";function ao(){let{t:e}=U();return Wp("a",{href:Gp,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:[Qi("span",{children:e.poweredBy.label}),Qi("img",{src:qp,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}import{jsx as oo}from"react/jsx-runtime";function ro({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:oo("div",{className:T("ww:px-4 ww:py-2",o),...r,children:oo("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>oo("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>oo("button",{type:"button",onClick:()=>a(s),className:T("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:`${n*50}ms`},children:s},s))})})}import{useEffect as Vp,useRef as zp,useState as jp}from"react";import{jsx as te,jsxs as dt}from"react/jsx-runtime";var Ki=20;function $p({label:e}){return dt("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:[te("title",{children:e}),te("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),te("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Xp({label:e}){return dt("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:[te("title",{children:e}),te("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),te("polyline",{points:"3 4 3 9 8 9"}),te("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),te("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Qp({label:e}){return dt("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:[te("title",{children:e}),te("polyline",{points:"3 6 5 6 21 6"}),te("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),te("path",{d:"M10 11v6"}),te("path",{d:"M14 11v6"})]})}function so({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:s,t:n}=U(),[i,l]=jp(!1),u=zp(null);Vp(()=>{if(!i)return;let c=p=>{let m=u.current;m&&(p.composedPath().includes(m)||l(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);let f=e.slice(0,Ki),d=Math.max(0,e.length-Ki);return dt("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[te("button",{type:"button",onClick:a,title:n.threadMenu.newChat,"aria-label":n.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:te($p,{label:n.threadMenu.newChat})}),te("button",{type:"button",onClick:()=>l(c=>!c),title:n.threadMenu.threadHistory,"aria-label":n.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:te(Xp,{label:n.threadMenu.threadHistory})}),i&&dt("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:[f.length===0&&te("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:n.threadMenu.noPreviousChats}),f.map(c=>{let p=c.threadId===t,m=Date.parse(c.updatedAt);return dt("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${p?"ww:bg-foreground/5":""}`,children:[dt("button",{type:"button",onClick:()=>{o(c.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[te("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),te("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(m)?"":vo(m,s)})]}),te("button",{type:"button",onClick:C=>{C.stopPropagation(),r(c.threadId)},title:n.threadMenu.deleteThread,"aria-label":n.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:te(Qp,{label:n.threadMenu.deleteThread})})]},c.threadId)}),d>0&&te("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:n.threadMenu.hiddenThreads(d)})]})]})}import{useCallback as Kp,useRef as Jp}from"react";function no(e){let t=Jp(e);return t.current=e,Kp(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.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()},[])}import{useChat as mm}from"@ai-sdk/react";import{useCallback as we,useEffect as Re,useRef as ue,useState as ft}from"react";function Ke(e,t,a){let[o,r=""]=e.split("?"),s=o.replace(/\/$/,""),n=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))n.set(l,u);let i=n.toString();return`${s}${t}${i?`?${i}`:""}`}import{DefaultChatTransport as Zp,uiMessageChunkSchema as Yp}from"ai";function em(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 n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var io=class extends Zp{processResponseStream(t){let a="",o=Yp(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
|
|
16
16
|
`);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let f=u.slice(5).trim();if(f!=="[DONE]")try{let d=JSON.parse(f);if(!r){n.enqueue(d);continue}let c=await r(d);if(c.success){n.enqueue(c.value);continue}let p=em(c.error);if(p?.length){let m={...d};for(let w of p)delete m[w];let C=await r(m);C.success&&n.enqueue(C.value)}}catch{}}}}))}};var tm="waniwani-memory";var Te="threads",lo="by_memoryUserId",am="by_updatedAt";var Zi="memoryUserId",Ji="waniwani-memory-user-id",Tr=null;function Pr(){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 om(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Te)){let a=e.createObjectStore(Te,{keyPath:"threadId"});a.createIndex(lo,"memoryUserId",{unique:!1}),a.createIndex(am,"updatedAt",{unique:!1})}}async function Ar(){return new Promise((e,t)=>{let a=indexedDB.open(tm,2);a.onupgradeneeded=o=>{om(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function rm(){return Ar()}async function sm(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Zi);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function nm(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Zi);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function im(){if(typeof indexedDB>"u")return null;try{let e=await rm();try{let t=await sm(e);if(t)return t;let a=Pr();return await nm(e,a),a}finally{e.close()}}catch{return null}}function lm(){try{let e=localStorage.getItem(Ji);if(e)return e;let t=Pr();return localStorage.setItem(Ji,t),t}catch{return null}}async function Yi(){let e=await im();if(e)return e;let t=lm();return t||(Tr||(Tr=Pr()),Tr)}var el=50,tl=1e3;function uo(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 fo(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Ar(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function vr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Rr(e){return await fo(async a=>{let s=a.transaction(Te,"readonly").objectStore(Te).index(lo),i=(await vr(s.getAll(e))??[]).filter(uo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function co(e){return await fo(async a=>{let r=a.transaction(Te,"readonly").objectStore(Te),s=await vr(r.get(e));return uo(s)?s:null})??null}async function Mr(e){if(!uo(e))return;let t=e.messages.length>tl?{...e,messages:e.messages.slice(e.messages.length-tl)}:e;await fo(async a=>{await new Promise((l,u)=>{let f=a.transaction(Te,"readwrite");f.oncomplete=()=>l(),f.onerror=()=>u(f.error),f.onabort=()=>u(f.error),f.objectStore(Te).put(t)});let o=a.transaction(Te,"readwrite"),r=o.objectStore(Te),s=r.index(lo),i=(await vr(s.getAll(t.memoryUserId))??[]).filter(uo);if(i.length>el){i.sort((u,f)=>u.updatedAt<f.updatedAt?-1:1);let l=i.slice(0,i.length-el);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 al(e){await fo(async t=>(await new Promise((a,o)=>{let r=t.transaction(Te,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Te).delete(e)}),null))}async function Fr(e){return(await Rr(e))[0]?.threadId??null}function ol(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`}var rl="waniwani-visitor-id";function sl(e,t){return e.match(t)?.[1]??null}function um(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=sl(e,o);if(r)return{name:a,version:r}}return null}function dm(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=sl(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function fm(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function cm(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function pm(){try{let a=localStorage.getItem(rl);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await cm(e);try{localStorage.setItem(rl,t)}catch{}return t}async function aa(){let e=navigator.userAgent,[t,a]=await Promise.all([pm(),Yi()]);return{userAgent:e,browser:um(e),os:dm(e),deviceType:fm(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 hm="x-session-id",gm=250;function nl(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():_t()}function po(){return new Date().toISOString()}function il(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function wm(e,t){let a=Ke(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 s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function mo(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=ue(a),f=ue(o),d=ue(n);Re(()=>{d.current=n},[n]);let c=ue(void 0),p=ue(null),[m,C]=ft(void 0),w=ue(m),[x,g]=ft(i),h=ue(x),[L,S]=ft([]),[k,A]=ft(!n),P=ue(void 0),E=ue(void 0),B=ue(void 0),O=ue(void 0),b=ue(0),v=ue(l);Re(()=>{v.current=l},[l]);let y=we(I=>{h.current=I,g(I),I&&v.current?.(I)},[]),M=we(async()=>{if(!n)return;let I=p.current?.memoryUserId;if(!I)return;let D=await Rr(I);S(D)},[n]),X=we(()=>w.current,[]),ae=we(I=>{let D=il(I);D&&w.current!==D&&(w.current=D,C(D))},[]),oe=we(()=>{w.current=void 0,C(void 0)},[]);Re(()=>{u.current=a},[a]),Re(()=>{f.current=o},[o]),Re(()=>{let I=!1,D=b.current;return(async()=>{try{let Ie=await aa();if(I)return;p.current=Ie}catch{}if(!n)return;let N=p.current?.memoryUserId;if(!N){A(!0);return}try{let Ie=i??await Fr(N);if(I||D!==b.current)return;if(Ie){let pe=await co(Ie);if(I||D!==b.current)return;pe&&pe.memoryUserId===N&&(h.current=pe.threadId,g(pe.threadId),P.current=pe.createdAt,E.current=pe.title,pe.sessionId&&(w.current=pe.sessionId,C(pe.sessionId)),Z(pe.messages))}await M()}finally{I||A(!0)}})(),()=>{I=!0}},[]);let V=ue(new io({api:t,headers:()=>({...u.current}),body:()=>{let I={...f.current??{}},D=Object.hasOwn(I,"sessionId"),N=il(I.sessionId);if(N)ae(N),I.sessionId=N;else if(D)oe(),delete I.sessionId;else{let Pe=X();Pe&&(I.sessionId=Pe)}if(St(c.current)&&(I.modelContext=c.current),p.current){let Pe=p.current;I.visitorContext={timezone:Pe.timezone,language:Pe.language,languages:Pe.languages,deviceType:Pe.deviceType,referrer:Pe.referrer,visitorId:Pe.visitorId};let Ue=typeof I.visitor=="object"&&I.visitor!==null?I.visitor:{},_l=typeof Ue.client=="object"&&Ue.client!==null?Ue.client:{};I.visitor={...Ue,id:Pe.visitorId,client:{..._l,memoryUserId:Pe.memoryUserId}}}let Ie=typeof I.extra=="object"&&I.extra!==null&&!Array.isArray(I.extra)?I.extra:void 0,pe=p.current?.memoryUserId,ie=p.current?.language,la={};if(pe&&(la.memoryUserId=pe),ie&&(la.locale=ie),(Object.keys(la).length>0||Ie)&&(I.extra={...la,...Ie??{}}),d.current)if(Object.hasOwn(I,"threadId"))typeof I.threadId=="string"&&(h.current=I.threadId);else{let Ue=h.current;Ue||(Ue=nl(),P.current=po(),E.current=void 0,y(Ue)),I.threadId=Ue}return I},fetch:(async(I,D)=>{let N=await fetch(I,D);return c.current=void 0,ae(N.headers.get(hm)),N})})),re=ue(null),Le=ue(null),fe=ue({}),[ce,Ee]=ft(0),_=e.skipRemoteConfig===!0,J=we(async()=>{if(!_)try{let I=await wm(t,u.current);fe.current=I,Ee(D=>D+1)}catch(I){console.warn("[Waniwani] Failed to fetch tool definitions:",I instanceof Error?I.message:I)}},[t,_]);Re(()=>{J()},[J]);let{messages:z,sendMessage:G,setMessages:Z,status:H}=mm({messages:e.initialMessages,transport:V.current,onFinish({message:I}){s?.(),re.current&&(Le.current=I)},onError(I){console.warn("[Waniwani] Chat error:",I.message),re.current&&(re.current.reject(I),re.current=null)}}),j=ue(z);Re(()=>{j.current=z},[z]);let $=ue(n);Re(()=>{if(!n||$.current||($.current=!0,j.current.length>0))return;let I=!1,D=b.current;return A(!1),(async()=>{try{let N=p.current;if(!N)try{N=await aa(),p.current=N}catch{}let Ie=N?.memoryUserId;if(!Ie||I||D!==b.current){I||A(!0);return}let pe=i??await Fr(Ie);if(I||D!==b.current)return;if(pe){let ie=await co(pe);if(I||D!==b.current)return;ie&&ie.memoryUserId===Ie&&(h.current=ie.threadId,g(ie.threadId),P.current=ie.createdAt,E.current=ie.title,ie.sessionId&&(w.current=ie.sessionId,C(ie.sessionId)),Z(ie.messages))}await M()}finally{I||A(!0)}})(),()=>{I=!0}},[n]),Re(()=>{if(H==="ready"&&re.current&&Le.current){let I=re.current,D=Le.current;re.current=null,Le.current=null,I.resolve(D)}},[H]);let[R,F]=ft(""),[q,se]=ft([]),Ce=H==="submitted"||H==="streaming",Me=we(I=>{se(D=>D.filter(N=>N.id!==I))},[]),Ge=Ce&&q.length>0,Al=we(I=>{let D=!!I.text?.trim(),N=!!I.files?.length;if(D||N){if(Ce){if(q.length>0)return;se(Ie=>[...Ie,{id:_t(),text:I.text||"",files:I.files??[],modelContext:I.modelContext}]),F("");return}c.current=I.modelContext,G({text:I.text||"",files:I.files}),r?.(I.text||""),F("")}},[G,r,Ce,q.length]),vl=we(I=>new Promise((D,N)=>{re.current={resolve:D,reject:N},G({text:I}),r?.(I)}),[G,r]);Re(()=>{if(H!=="ready"||q.length===0)return;let[I,...D]=q;se(D),c.current=I.modelContext,G({text:I.text,files:I.files.length>0?I.files:void 0}),r?.(I.text)},[H,G,r,q]);let Rl=we(()=>{Z([]),se([]),oe(),F(""),fe.current={},Ee(I=>I+1),J()},[Z,oe,J]),na=we(()=>{if(!d.current)return;let I=p.current?.memoryUserId,D=h.current,N=j.current;if(!(!I||!D||N.length===0)){if(P.current||(P.current=po()),!E.current){let Ie=N.find(ie=>ie.role==="user"),pe=Ie?Ie.parts.map(ie=>"text"in ie&&typeof ie.text=="string"?ie.text:"").join(" "):"";E.current=ol(pe)}return{threadId:D,memoryUserId:I,title:E.current,messages:N,sessionId:w.current,createdAt:P.current,updatedAt:po()}}},[]),Vr=we(async()=>{let I=na();I&&(await Mr(I),await M())},[na,M]);Re(()=>{if(n&&k&&!(H==="submitted"||H==="streaming")&&z.length!==0)return B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{B.current=void 0;let I=Vr().finally(()=>{O.current===I&&(O.current=void 0)});O.current=I},gm),()=>{B.current&&clearTimeout(B.current)}},[n,k,z,H,Vr]);let ia=we(()=>{let I=O.current,D=B.current,N=D?na():void 0;return D&&(clearTimeout(D),B.current=void 0),(async()=>{I&&await I,N&&(await Mr(N),await M())})()},[na,M]),Ml=we(()=>{b.current+=1,ia(),Z([]),se([]),oe(),F("");let I=nl();return P.current=po(),E.current=void 0,y(I),M(),I},[Z,oe,y,M,ia]),Lo=we(async I=>{b.current+=1;let D=b.current;if(await ia(),D!==b.current)return;let N=await co(I);D===b.current&&N&&(y(N.threadId),P.current=N.createdAt,E.current=N.title,N.sessionId?(w.current=N.sessionId,C(N.sessionId)):oe(),Z(N.messages),se([]),F(""))},[Z,oe,y,ia]),Fl=we(async I=>{if(h.current===I){b.current+=1,B.current&&(clearTimeout(B.current),B.current=void 0);let D=O.current;D&&await D}await al(I),await M(),h.current===I&&(Z([]),se([]),oe(),F(""),h.current=void 0,g(void 0),P.current=void 0,E.current=void 0)},[Z,oe,M]);Re(()=>{n&&k&&i!==void 0&&i!==h.current&&Lo(i)},[i,n,k,Lo]);let Bl=we(I=>{F(I.target.value)},[]),zr=z[z.length-1],jr=z.length>0,Dl=Ce&&(!jr||zr.role==="user"),El=fe.current;return{messages:z,status:H,text:R,setText:F,handleSubmit:Al,handleTextChange:Bl,isLoading:Ce,showLoaderBubble:Dl,lastMessage:zr,hasMessages:jr,sendMessage:G,sendMessageAndWait:vl,reset:Rl,queuedMessages:q,queueFull:Ge,removeQueuedMessage:Me,sessionId:m,toolDefinitions:El,refreshToolDefinitions:J,threads:L,activeThreadId:x,isThreadHistoryReady:k,startNewThread:Ml,switchThread:Lo,deleteThread:Fl}}import{useEffect as ll,useRef as xm,useState as Lm}from"react";var Cm={debug:!1,eval:!1};function ul(e="/api/waniwani",t,a=!1){let[o,r]=Lm(Cm),s=xm(t);return ll(()=>{s.current=t},[t]),ll(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(Ke(e,"/config"),{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}import{useCallback as Im,useEffect as Br,useRef as Sm,useState as ym}from"react";function bm(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function dl(e){return typeof e=="object"&&e!==null&&"initial"in e}function ho(e){let{messages:t,status:a,config:o}=e,r=dl(o)&&o.initial?o.initial:void 0,[s,n]=ym(r??[]),i=Sm(a),l=o===!0||dl(o)&&o.dynamic!==!1,u=Im(()=>{n([])},[]),f=t.length>0;Br(()=>{!f&&r&&r.length>0&&n(r)},[r,f]);let d=t[t.length-1];return Br(()=>{d?.role==="user"&&u()},[d,u]),Br(()=>{let c=i.current;if(i.current=a,c==="streaming"&&a==="ready"&&l){let p=[...t].reverse().find(C=>C.role==="assistant");if(!p)return;let m=bm(p);m&&n(m)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}import{useEffect as km,useRef as Tm,useState as Pm}from"react";var Am=80,vm=50,Rm=15e3,fl=500;function go(e,t=!0){let[a,o]=Pm(""),r=Tm(void 0);return km(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,fl)):r.current=setTimeout(l,vm)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Rm)):r.current=setTimeout(l,Am)))};return r.current=setTimeout(l,fl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}function wo(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return Ke(e,"/resource",o?{token:o}:void 0)}var cl={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:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"},Mm={backgroundColor:"#212121",headerBackgroundColor:"#1e1e1e",headerTextColor:"#ececec",textColor:"#ececec",primaryForeground:"#ffffff",mutedColor:"#8e8ea0",borderColor:"#444444",assistantBubbleColor:"#2f2f2f",userBubbleColor:"#303030",inputBackgroundColor:"#2f2f2f",primaryColor:"#6366f1",statusColor:"#22c55e",toolCardColor:"#262626"},Fm={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"]};function Dr(e){return{...cl,...e}}function oa(e){let t={};for(let[a,o]of Object.entries(Fm)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as xe,jsxs as ra}from"react/jsx-runtime";var _m=Bm(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:f,placeholder:d="Ask me anything...",triggerEvent:c="triggerDemoRequest",api:p,debug:m,enableThreadHistory:C=!1,showToolCalls:w=!0}=t,x=p??"/api/waniwani",g=wo(x,t.headers),h=Dr(o),L=oa(h),S=h.backgroundColor.replace("#",""),k=parseInt(S.substring(0,2),16),A=parseInt(S.substring(2,4),16),P=parseInt(S.substring(4,6),16),E=(k*299+A*587+P*114)/1e3<128,B=ul(x,t.headers,t.skipRemoteConfig),O=m??B.debug,b=mo({...t,api:x}),v=no({...t,api:x,sessionId:b.sessionId}),y=go(d,!b.text),[M,X]=ml(!1),[ae,oe]=ml(null),V=pl(null),re=pl(void 0),Le=Er(()=>{let _=V.current;if(!_)return;_.scrollIntoView({behavior:"smooth",block:"center"});let J=_.querySelector("textarea");J&&setTimeout(()=>J.focus(),300),X(!0),clearTimeout(re.current),re.current=setTimeout(()=>X(!1),2e3)},[]),fe=ho({messages:b.messages,status:b.status,config:t.suggestions}),ce=Er(_=>{let J=_.content.map(z=>z.text??"").join("").trim();J&&b.handleSubmit({text:J,files:[],modelContext:_.modelContext})},[b.handleSubmit]),Ee=Er(_=>{fe.clear(),b.handleSubmit({text:_,files:[]})},[fe.clear,b.handleSubmit]);return Em(a,()=>({sendMessage:_=>{b.handleSubmit({text:_,files:[]}),Le()},sendMessageAndWait:_=>b.sendMessageAndWait(_),reset:b.reset,focus:Le,get messages(){return b.messages},get sessionId(){return b.sessionId}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,b.sessionId,Le]),Dm(()=>{if(!c)return;let _=J=>{let z=J.detail,G=typeof z?.message=="string"?z.message:void 0;G&&b.handleSubmit({text:G,files:[]}),Le()};return window.addEventListener(c,_),()=>window.removeEventListener(c,_)},[c,b.handleSubmit,Le]),ra("div",{ref:V,style:{...L,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",...E?{"data-waniwani-dark":""}:{},className:T("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",M&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[ra("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:h.headerBackgroundColor,color:h.headerTextColor},children:[xe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),xe(Es,{messages:b.messages,evalEnabled:B.eval,api:x}),C&&xe(so,{threads:b.threads,activeThreadId:b.activeThreadId,onNewThread:b.startNewThread,onSelectThread:_=>{b.switchThread(_)},onDeleteThread:_=>{b.deleteThread(_)}})]}),ra(cs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[xe(ps,{scrollClassName:ae?"ww:!relative ww:!overflow-hidden":void 0,children:xe(to,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:f,onSuggestionSelect:Ee,resourceEndpoint:g,chatSessionId:b.sessionId,isDark:E,onFollowUp:ce,onCallTool:v,fullscreenToolCallId:ae,debug:O,showToolCalls:w,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(_,J)=>{oe(_==="fullscreen"?J.toolCallId:null)}})}),xe(ms,{})]}),xe("div",{style:ae?{display:"none"}:void 0,children:xe(ro,{suggestions:fe.suggestions,isLoading:fe.isLoading,onSelect:Ee})}),xe("div",{style:ae?{display:"none"}:void 0,children:xe(La,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),xe("div",{style:ae?{display:"none"}:void 0,children:xe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ra("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[xe(ha,{onSubmit:b.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ra("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&xe(xa,{}),xe(ga,{onChange:b.handleTextChange,value:b.text,placeholder:y,className:"ww:min-h-0 ww:py-1 ww:px-0"}),xe(wa,{status:b.status,disabled:b.queueFull})]})}),xe(ao,{})]})})})]})});import{forwardRef as gl,useCallback as xo,useEffect as yt,useImperativeHandle as Om,useRef as sa,useState as _r}from"react";import{jsx as Nm}from"react/jsx-runtime";function hl({text:e}){let{t}=U();return e===!1?null:Nm("span",{className:"ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70",children:e||t.aiDisclaimer.default})}import{jsx as de,jsxs as Je}from"react/jsx-runtime";var Nr=gl(function(t,a){let{locale:o,messages:r}=t;return de(Ao,{locale:o,messages:r,children:de(Um,{...t,ref:a})})}),Um=gl(function(t,a){let{t:o,ready:r}=U(),{appearance:s,className:n,allowAttachments:i=!1,welcomeMessage:l,welcome:u,placeholder:f=o.promptInput.placeholder,triggerEvent:d="triggerDemoRequest",api:c,mcp:p,debug:m=!1,readOnly:C=!1,title:w,headerActions:x,hideHeader:g=!1,enableThreadHistory:h=!1,showToolCalls:L=!0,initializing:S=!1,disclaimer:k}=t,A=s?.theme,P=s?.variables,E=P?oa(P):{},[B,O]=_r(!1);yt(()=>{if(A!=="auto"||typeof window>"u")return;let R=window.matchMedia("(prefers-color-scheme: dark)");O(R.matches);let F=()=>O(R.matches);return R.addEventListener("change",F),()=>R.removeEventListener("change",F)},[A]);let b=A==="dark"||A==="auto"&&B,v=mo({...t,api:c}),y=no({...t,api:c,sessionId:v.sessionId,onCallTool:p?.onCallTool}),M=p?.resourceEndpoint??wo(c,t.headers),X=go(f,!v.text),[ae,oe]=_r(null),V=sa(null),re=sa(null),Le=sa(null),fe=sa(null),[ce,Ee]=_r(!0),_=sa(ce);_.current=ce;let J=xo(()=>{let R=V.current;if(!R)return;let F=R.querySelector("textarea");F&&F.focus()},[]),z=xo((R="smooth")=>{let F=re.current;F&&F.scrollTo({top:F.scrollHeight,behavior:R})},[]);yt(()=>{let R=fe.current,F=re.current;if(!R||!F)return;let q=new IntersectionObserver(([se])=>Ee(se.isIntersecting),{root:F,rootMargin:"0px 0px 200px 0px",threshold:0});return q.observe(R),()=>q.disconnect()},[]),yt(()=>{(v.messages[v.messages.length-1]?.role==="user"||_.current)&&z("smooth")},[v.messages.length,v.messages[v.messages.length-1]]),yt(()=>{z("auto")},[z]),yt(()=>{if(typeof ResizeObserver>"u")return;let R=re.current,F=Le.current;if(!R&&!F)return;let q=R?.scrollHeight??0,se=R?.clientHeight??0,Ce=new ResizeObserver(()=>{let Me=re.current;if(!Me)return;let Ge=Me.scrollTop+se>=q-5;q=Me.scrollHeight,se=Me.clientHeight,Ge&&z("auto")});return R&&Ce.observe(R),F&&Ce.observe(F),()=>Ce.disconnect()},[z]);let G=ho({messages:v.messages,status:v.status,config:t.suggestions}),Z=xo(R=>{let F=R.content.map(q=>q.text??"").join("").trim();F&&v.handleSubmit({text:F,files:[],modelContext:R.modelContext})},[v.handleSubmit]),H=xo(R=>{G.clear(),v.handleSubmit({text:R,files:[]})},[G.clear,v.handleSubmit]);Om(a,()=>({sendMessage:R=>{v.handleSubmit({text:R,files:[]}),J()},sendMessageAndWait:R=>v.sendMessageAndWait(R),reset:v.reset,focus:J,get messages(){return v.messages},get sessionId(){return v.sessionId}}),[v.handleSubmit,v.sendMessageAndWait,v.reset,v.messages,v.sessionId,J]),yt(()=>{if(!d)return;let R=F=>{let q=F.detail,se=typeof q?.message=="string"?q.message:void 0;se&&v.handleSubmit({text:se,files:[]}),J()};return window.addEventListener(d,R),()=>window.removeEventListener(d,R)},[d,v.handleSubmit,J]);let j=!g&&!!(w||h||x),$=S||!r;return Je("div",{ref:V,style:{...E,maxHeight:"inherit",opacity:$?0:1,transition:"opacity 220ms ease-out"},"data-waniwani-chat":"","data-waniwani-layout":"embed","data-color-scheme":A==="auto"?"auto":void 0,...$?{"data-waniwani-initializing":""}:{},...b?{"data-waniwani-dark":""}:{},className:T("ww:relative ww:w-full ww:h-full ww:flex ww:flex-col ww:bg-background ww:text-foreground ww:font-[family-name:var(--ww-font)] ww:overflow-hidden",A==="dark"&&"dark",n),children:[j&&Je("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:pl-4 ww:pr-3 ww:py-3 ww:border-b ww:border-border",style:{backgroundColor:"var(--ww-color-card-header)",color:"var(--ww-color-card-header-foreground)"},children:[w&&de("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:w}),!w&&de("div",{className:"ww:flex-1"}),h&&de(so,{threads:v.threads,activeThreadId:v.activeThreadId,onNewThread:v.startNewThread,onSelectThread:R=>{v.switchThread(R)},onDeleteThread:R=>{v.deleteThread(R)}}),x]}),Je("div",{ref:re,className:T("ww:relative ww:flex-1 ww:min-h-0",ae?"ww:overflow-hidden":"ww:overflow-y-auto"),children:[Je("div",{ref:Le,className:T("ww:mx-auto ww:w-full ww:max-w-3xl ww:px-4 ww:py-6 ww:flex ww:flex-col ww:gap-6",ae&&"ww:!py-0"),children:[de(to,{messages:v.messages,status:v.status,welcomeMessage:l,welcome:u,onSuggestionSelect:H,resourceEndpoint:M,chatSessionId:v.sessionId,isDark:b,onFollowUp:Z,onCallTool:y,fullscreenToolCallId:ae,debug:m,showToolCalls:L,toolDefinitions:v.toolDefinitions,onWidgetDisplayModeChange:(R,F)=>{oe(R==="fullscreen"?F.toolCallId:null)}}),de("div",{ref:fe,"aria-hidden":!0,style:{height:1}})]}),!ce&&!ae&&de("div",{className:"ww:sticky ww:bottom-2 ww:flex ww:justify-center ww:pointer-events-none",children:de(Ae,{type:"button",onClick:()=>z("smooth"),size:"icon",variant:"outline",className:"ww:rounded-full ww:shadow ww:pointer-events-auto","aria-label":"Scroll to latest",children:de(Ze,{className:"ww:size-4"})})})]}),!C&&Je("div",{className:"ww:shrink-0 ww:bg-background",style:ae?{display:"none"}:void 0,children:[de(ro,{suggestions:G.suggestions,isLoading:G.isLoading,onSelect:H}),de(La,{queuedMessages:v.queuedMessages,onRemove:v.removeQueuedMessage}),de("div",{className:"ww:px-4 ww:pb-2 ww:pt-2",children:Je("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[de(ha,{onSubmit:v.handleSubmit,globalDrop:i,multiple:i,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Je("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[i&&de(xa,{}),de(ga,{onChange:v.handleTextChange,value:v.text,placeholder:X,className:"ww:min-h-0 ww:py-1 ww:px-0"}),de(wa,{status:v.status,disabled:v.queueFull})]})}),Je("div",{className:"ww:pt-2 ww:pb-1 ww:flex ww:flex-nowrap ww:justify-center ww:items-center ww:gap-1.5",children:[de(ao,{}),de(hl,{text:k})]})]})})]})]})});import{forwardRef as nh,useEffect as ih,useMemo as kl,useState as Tl}from"react";var Hm="https://app.waniwani.ai/api/mcp/chat",qm={api:Hm};function Gm(){if(typeof document>"u")return null;if(document.currentScript instanceof HTMLScriptElement)return document.currentScript;let e=document.querySelector("script[src][data-token]");if(e instanceof HTMLScriptElement)return e;let t=document.querySelectorAll("script[src]");for(let a of t)if(a instanceof HTMLScriptElement&&/embed/i.test(a.src))return a;return null}function Wm(){let e=Gm();if(!e)return{};let t=P=>e.getAttribute(P)??void 0,a=P=>{let E=e.getAttribute(P);if(E==null)return;let B=E.trim().toLowerCase();if(B==="true"||B==="1"||B==="")return!0;if(B==="false"||B==="0")return!1},o={},r=t("data-api");r&&(o.api=r);let s=t("data-token");s&&(o.token=s);let n=t("data-title");n&&(o.title=n);let i=t("data-welcome-message");i&&(o.welcomeMessage=i);let l=t("data-placeholder");l&&(o.placeholder=l);let u=t("data-mcp-server-url");u&&(o.mcpServerUrl=u);let f=t("data-channel-id");if(f&&(o.channelId=f),t("data-show-tool-calls")?.trim().toLowerCase()==="titles-only")o.showToolCalls="titles-only";else{let P=a("data-show-tool-calls");P!==void 0&&(o.showToolCalls=P)}let c=t("data-css");c&&(o.css=c);let p=t("data-suggestions");p&&(o.suggestions=p.split(",").map(P=>P.trim()).filter(Boolean));let m=a("data-enable-thread-history");m!==void 0&&(o.enableThreadHistory=m);let C=a("data-disable-page-view");C!==void 0&&(o.disablePageView=C);let w=a("data-hide-header");w!==void 0&&(o.hideHeader=w);let x=t("data-theme");(x==="light"||x==="dark"||x==="auto")&&(o.appearance={theme:x});let g=t("data-locale");(g==="en"||g==="fr"||g==="es")&&(o.locale=g);let h=t("data-mode");(h==="inline"||h==="floating")&&(o.mode=h);let L=t("data-height");L&&(o.height=L);let S=t("data-launcher-text");S&&(o.launcherText=S);let k=t("data-appear-delay");if(k!==void 0){let P=Number.parseInt(k.trim(),10);Number.isFinite(P)&&P>=0&&(o.appearDelay=P)}let A=t("data-disclaimer");if(A!==void 0){let P=A.trim(),E=P.toLowerCase();E==="false"||E==="0"?o.disclaimer=!1:P&&(o.disclaimer=P)}return o}function Or(e){if(!e)return{};let t={};for(let a in e)e[a]!==void 0&&(t[a]=e[a]);return t}function Ur(e,t,a){let o=a??Wm(),r=Vm(t,o,e),s={token:"",...qm,...Or(t),...Or(o),...Or(e),...r?{appearance:r}:{}};if(!s.token)throw new Error("[Waniwani] Missing required config: `token`. Set data-token on the script tag or pass it to Waniwani.chat.init().");return s}function Vm(e,t,a){let o=a?.appearance?.theme??t.appearance?.theme??e?.appearance?.theme,r={...e?.appearance?.variables??{},...t.appearance?.variables??{},...a?.appearance?.variables??{}},s=Object.keys(r).length>0;if(!o&&!s)return;let n={};return o&&(n.theme=o),s&&(n.variables=r),n}import{useEffect as vy,useState as Ry}from"react";function zm(){if(typeof window>"u")return!1;try{return window.WANIWANI_DEBUG?!0:!!window.localStorage?.getItem("WANIWANI_DEBUG")}catch{return!1}}function Hr(...e){zm()&&console.log("[Waniwani]",...e)}var qr=new Set;function jm(e,t,a){return`${e}|${t}|${a??""}`}function $m(e){try{return`${new URL(e).origin}/api/mcp/events/v2/batch`}catch{return e.replace(/\/$/,"").replace(/\/chat$/,"/events/v2/batch")}}async function Gr(e){let{api:t,token:a,channelId:o,mode:r,source:s}=e;if(typeof window>"u"||!t||!a||!s)return;let n=jm(t,a,o);if(!qr.has(n)){qr.add(n);try{let i=await aa(),l=new Date().toISOString(),u=JSON.stringify({sentAt:l,source:{sdk:"@waniwani/sdk",version:"0.1.0"},events:[{id:crypto.randomUUID(),type:"mcp.event",name:"page.viewed",source:s,timestamp:l,correlation:{visitorId:i.visitorId},properties:{channelId:o,mode:r,url:window.location.href,referrer:i.referrer,deviceType:i.deviceType,language:i.language,timezone:i.timezone},metadata:{}}]});await fetch($m(t),{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:u,keepalive:!0})}catch{qr.delete(n)}}}var Xm="waniwani:config:";function wl(e,t,a){return`${Xm}${e}|${t}|${a??""}`}function xl(e,t,a){if(typeof window>"u")return null;try{let o=window.sessionStorage.getItem(wl(e,t,a));if(!o)return null;let r=JSON.parse(o);return r&&typeof r=="object"?r:null}catch{return null}}function Ll(e,t,a,o){if(!(typeof window>"u"))try{window.sessionStorage.setItem(wl(e,t,a),JSON.stringify(o))}catch{}}async function Cl(e,t,a,o){try{let r=Ke(e,"/config",o?{channel:o}:void 0),s=await fetch(r,{method:"GET",headers:{Authorization:`Bearer ${t}`},signal:a});if(!s.ok)return{};let n=await s.json(),i=n&&typeof n=="object"&&"data"in n&&n.data?n.data:n;return i?Qm(i):{}}catch{return{}}}function Qm(e){let t={};return e.source!=null&&(t.source=e.source),e.title!=null&&(t.title=e.title),e.welcomeMessage!=null&&(t.welcomeMessage=e.welcomeMessage),e.placeholder!=null&&(t.placeholder=e.placeholder),e.suggestions!=null&&e.suggestions.length>0&&(t.suggestions=e.suggestions),typeof e.enableThreadHistory=="boolean"&&(t.enableThreadHistory=e.enableThreadHistory),e.toolCallDisplay==="full"?t.showToolCalls=!0:e.toolCallDisplay==="titles-only"?t.showToolCalls="titles-only":e.toolCallDisplay==="hidden"&&(t.showToolCalls=!1),e.visibility&&(t.visibility=e.visibility),t}import{useEffect as Ym,useSyncExternalStore as eh}from"react";function Km(e){return e?.patterns??e?.rules??[]}var Il="\0\0";function Jm(e){let a=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\*\\\*/g,Il).replace(/\\\*/g,"[^/]*").split(Il).join(".*");return new RegExp(`^${a}$`)}function Zm(e,t){try{return Jm(e).test(t)}catch{return!1}}function Sl(e,t){if(!e)return!0;let a=!1;for(let o of Km(e))if(Zm(o.glob,t)){if(o.action==="hide")return!1;a=!0}return a?!0:(e.default??"show")!=="hide"}var Wr="waniwani:locationchange",yl=!1;function th(){if(!(yl||typeof history>"u")){yl=!0;for(let e of["pushState","replaceState"]){let t=history[e];history[e]=function(...o){let r=t.apply(this,o);return window.dispatchEvent(new Event(Wr)),r}}}}function ah(e){return th(),window.addEventListener(Wr,e),window.addEventListener("popstate",e),()=>{window.removeEventListener(Wr,e),window.removeEventListener("popstate",e)}}function oh(){return window.location.pathname}function rh(){return"/"}function sh(){return eh(ah,oh,rh)}function bl(e,t){let a=sh(),o=t&&Sl(e,a);return Ym(()=>{Hr("visibility gate",{pathname:a,ready:t,visible:o,rules:e})},[a,t,o]),o}import{jsx as dh}from"react/jsx-runtime";var lh=600,Pl="https://app.waniwani.ai/api/mcp/chat",uh=nh(function(t,a){let{token:o,channelId:r,className:s,overrides:n}=t,i=kl(()=>({token:o,channelId:r,api:n?.api,mcpServerUrl:n?.mcpServerUrl,title:n?.title,hideHeader:n?.hideHeader,welcomeMessage:n?.welcomeMessage,placeholder:n?.placeholder,suggestions:n?.suggestions,enableThreadHistory:n?.enableThreadHistory,showToolCalls:n?.showToolCalls,appearance:n?.appearance,disclaimer:n?.disclaimer,locale:n?.locale}),[o,r,n?.api,n?.mcpServerUrl,n?.title,n?.hideHeader,n?.welcomeMessage,n?.placeholder,n?.suggestions,n?.enableThreadHistory,n?.showToolCalls,n?.appearance,n?.disclaimer,n?.locale]),l=n?.api??Pl,[u,f]=Tl({}),[d,c]=Tl(!1),p=n?.disablePageView;ih(()=>{if(!o){c(!0);return}let x=S=>{p||Gr({api:l,token:o,channelId:r,mode:"inline",source:S})},g=xl(l,o,r);g&&(f(g),c(!0),x(g.source));let h=new AbortController,L=setTimeout(()=>c(!0),lh);return Cl(l,o,h.signal,r).then(S=>{h.signal.aborted||(Object.keys(S).length>0&&(Ll(l,o,r,S),f(S)),c(!0),x(S.source))}).catch(S=>{console.error("[Waniwani] Remote config fetch failed:",S),c(!0)}).finally(()=>clearTimeout(L)),()=>{h.abort(),clearTimeout(L)}},[l,o,r,p]);let m=kl(()=>Ur(i,u,void 0),[i,u]),C=bl(m.visibility,d),w={};return m.mcpServerUrl&&(w.mcpServerUrl=m.mcpServerUrl),m.channelId&&(w.channelId=m.channelId),C?dh(Nr,{ref:a,api:m.api??Pl,headers:{Authorization:`Bearer ${m.token}`},skipRemoteConfig:!0,body:Object.keys(w).length>0?w:void 0,appearance:m.appearance,title:m.title,hideHeader:m.hideHeader,welcomeMessage:m.welcomeMessage,welcome:n?.welcome,placeholder:m.placeholder,suggestions:m.suggestions?{initial:m.suggestions}:void 0,enableThreadHistory:m.enableThreadHistory,showToolCalls:m.showToolCalls,disclaimer:m.disclaimer,allowAttachments:n?.allowAttachments,locale:m.locale,messages:n?.messages,className:s,initializing:!d}):null});export{_m as ChatCard,Nr as ChatEmbed,Mm as DARK_THEME,cl as DEFAULT_THEME,br as McpAppFrame,uh as WaniwaniChat,Dr as mergeTheme,oa as themeToCSSProperties};
|
|
17
17
|
/*! Bundled license information:
|
|
18
18
|
|