@waniwani/sdk 0.12.15 → 0.12.16

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.
@@ -1478,6 +1478,8 @@ interface ChatHandle {
1478
1478
  focus: () => void;
1479
1479
  /** Current chat messages */
1480
1480
  messages: ai.UIMessage[];
1481
+ /** Session ID used for event correlation. Available after the first message. */
1482
+ sessionId: string | undefined;
1481
1483
  }
1482
1484
 
1483
1485
  /** @deprecated Use `WaniwaniChat` (hosted, React) or the `<script>` embed for new code. `ChatCard` is preserved for back-compat only and lives under `@waniwani/sdk/legacy`. */
@@ -79,7 +79,7 @@ import{a as Or,b as Hr,c as qr,d as wt,e as xt,f as ha,g as Wr,h as Gr,i as jr,j
79
79
  `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let y={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},P=Jo(g.htmlStyle||za(g));P&&(y.properties.style=P);for(let v of r)y=v?.span?.call(m,y,L+1,C,S,g)||y;i==="inline"?n.children.push(y):i==="classic"&&S.children.push(y),C+=g.content.length}if(i==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(i==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[g];y.type==="element"&&n.children.push(...y.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&Qa(h,o),h}function yp(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&fe.Underline||s.fontStyle&fe.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 bp(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 kp(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=Jo(r.htmlStyle||za(r)),n=Jo(o.htmlStyle||za(o)),i=r.fontStyle&&(r.fontStyle&fe.Underline||r.fontStyle&fe.Strikethrough),l=o.fontStyle&&(o.fontStyle&fe.Underline||o.fontStyle&fe.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var Tp=Xo;function Pp(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Xa(e,s,n),codeToTokens:(s,n)=>$a(e,s,n)},r=Tp(Xa(e,t,a,o));for(let s of Va(a))r=s.postprocess?.call(o,r,a)||r;return r}var Pi={light:"#333333",dark:"#bbbbbb"},vi={light:"#fffffe",dark:"#1e1e1e"},Ai="__shiki_resolved";function sr(e){if(e?.[Ai])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"?Pi.light:Pi.dark),a||(a=t.type==="light"?vi.light:vi.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 c={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,Ai,{enumerable:!1,writable:!1,value:!0}),t}async function Ui(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Mi(t)).map(async t=>await Ri(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Oi(e){return(await Promise.all(e.map(async a=>Fi(a)?null:sr(await Ri(a))))).filter(a=>!!a)}var Qo=3,vp=!1;function Ap(e,t=3){if(Qo&&!(typeof Qo=="number"&&t>Qo)){if(vp)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Ze=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 Ze(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var Zo=class extends ri{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=sr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=ea.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 Ze(`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))}},Yo=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}},na=0;function Rp(e){na+=1,e.warnings!==!1&&na>=10&&na%10===0&&console.warn(`[Shiki] ${na} 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 Ze("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(sr),r=new Yo(e.engine,a),s=new Zo(r,o,a,e.langAlias),n;function i(g){return Hi(g,e.langAlias)}function l(g){S();let y=s.getGrammar(typeof g=="string"?g:g.name);if(!y)throw new Ze(`Language \`${g}\` not found, you may need to load it first`);return y}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=s.getTheme(g);if(!y)throw new Ze(`Theme \`${g}\` not found, you may need to load it first`);return y}function c(g){S();let y=u(g);n!==g&&(s.setTheme(y),n=g);let P=s.getColorMap();return{theme:y,colorMap:P}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await Ui(g))}function I(...g){S();for(let y of g.flat(1))s.loadTheme(y)}async function L(...g){return S(),I(await Oi(g))}function S(){if(t)throw new Ze("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),na-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function Mp(e){e.engine||Ap("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Oi(e.themes||[]),Ui(e.langs||[]),e.engine]);return Rp({...e,themes:t,langs:a,engine:o})}async function Fp(e){let t=await Mp(e);return{getLastGrammarState:(...a)=>hp(t,...a),codeToTokensBase:(a,o)=>or(t,a,o),codeToTokensWithThemes:(a,o)=>Ni(t,a,o),codeToTokens:(a,o)=>$a(t,a,o),codeToHast:(a,o)=>Xa(t,a,o),codeToHtml:(a,o)=>Pp(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function qi(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,Mi(d))return[];let p=t[d];if(!p)throw new Y(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(Fi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Y(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),c=await Fp({engine:s.engine??o(),...s,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Dp(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=Dp(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)}}}f();var nr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Gi=Object.fromEntries(nr.map(e=>[e.id,e.import])),ji=Object.fromEntries(nr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),la={...Gi,...ji};f();var Bp=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],zi=Object.fromEntries(Bp.map(e=>[e.id,e.import]));f();var ua=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ep(){return 2147483648}function _p(){return typeof performance<"u"?performance.now():Date.now()}var Np=(e,t)=>e+(t-e%t)%t;async function Up(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let h=o.HEAPU8.length;m=m>>>0;let I=Ep();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,Np(Math.max(m,S),65536));if(n(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&l)return l.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let y=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|y);continue}let P=m[h++]&63;if((g&240)===224?g=(g&15)<<12|y<<6|P:g=(g&7)<<18|y<<12|P<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let v=g-65536;C+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:_p,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var Op=Object.defineProperty,Hp=(e,t,a)=>t in e?Op(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ne=(e,t,a)=>Hp(e,typeof t!="symbol"?t+"":t,a),ue=null;function qp(e){throw new ua(e.UTF8ToString(e.getLastOnigError()))}var Za=class e{constructor(t){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=l,p&&(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),p&&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}},Ya=class He{constructor(t){if(ne(this,"id",++He.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!ue)throw new ua("Must invoke loadWasm first.");this._onigBinding=ue,this.content=t;let a=new Za(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!He._sharedPtrInUse?(He._sharedPtr||(He._sharedPtr=ue.omalloc(1e4)),He._sharedPtrInUse=!0,ue.HEAPU8.set(a.utf8Value,He._sharedPtr),this.ptr=He._sharedPtr):this.ptr=a.createString(ue)}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===He._sharedPtr?He._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne(Ya,"LAST_ID",0);ne(Ya,"_sharedPtr",0);ne(Ya,"_sharedPtrInUse",!1);var Vi=Ya,lr=class{constructor(t){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!ue)throw new ua("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Za(t[i]);a[i]=u.createString(ue),o[i]=u.utf8Length}let r=ue.omalloc(4*t.length);ue.HEAPU32.set(a,r/4);let s=ue.omalloc(4*t.length);ue.HEAPU32.set(o,s/4);let n=ue.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)ue.ofree(a[i]);ue.ofree(s),ue.ofree(r),n===0&&qp(ue),this._onigBinding=ue,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 Vi(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++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Wp(e){return typeof e.instantiator=="function"}function Gp(e){return typeof e.default=="function"}function jp(e){return typeof e.data<"u"}function zp(e){return typeof Response<"u"&&e instanceof Response}function Vp(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var Ja;function $p(e){if(Ja)return Ja;async function t(){ue=await Up(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Wp(o)?o=await o.instantiator(a):Gp(o)?o=await o.default(a):(jp(o)&&(o=o.data),zp(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Xp(o)(a):o=await Kp(o)(a):Vp(o)?o=await ir(o)(a):o instanceof WebAssembly.Module?o=await ir(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await ir(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return Ja=t(),Ja}function ir(e){return t=>WebAssembly.instantiate(e,t)}function Xp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Kp(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function $i(e){return e&&await $p(e),{createScanner(t){return new lr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Vi(t)}}}var eo=qi({langs:la,themes:zi,engine:()=>$i(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Qp,codeToHast:Jp,codeToTokens:Zp,codeToTokensBase:Yp,codeToTokensWithThemes:em,getSingletonHighlighter:tm,getLastGrammarState:am}=Wi(eo,{guessEmbeddedLanguages:Bi});var Xi=new Set(Object.keys(la)),ur=new Map,dr=new Map,kt=new Map,om=(e,t)=>`${e}-${t[0]}-${t[1]}`,rm=(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}`},sm=(e,t)=>{let a=om(e,t);if(ur.has(a))return ur.get(a);let o=eo({themes:t,langs:[e]});return ur.set(a,o),o};function nm(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Xi.has(o)},getSupportedLanguages(){return Array.from(Xi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=rm(o,r,s);return dr.has(i)?dr.get(i):(n&&(kt.has(i)||kt.set(i,new Set),kt.get(i).add(n)),sm(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});dr.set(i,c);let d=kt.get(i);if(d){for(let p of d)p(c);kt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),kt.delete(i)}),null)}}}var Ki=nm();import{memo as dm}from"react";f();f();import{useEffect as im,useRef as to,useState as lm}from"react";var um=5,Qi=400;function Ji(e,t,a={}){let{msPerChar:o=um}=a,[r,s]=lm(t?"":e),n=to(e),i=to(t?0:e.length),l=to(0),u=to(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),n.current=e,im(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,s(e);return}if(n.current.length-i.current>Qi&&(i.current=n.current.length-Qi),u.current!==null)return;let d=p=>{let m=n.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let h=p-l.current;if(h>=o){let I=Math.min(Math.floor(h/o),m.length-i.current);i.current+=I,s(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as ao}from"react/jsx-runtime";var cr=({className:e,from:t,children:a,...o})=>ao("div",{className:B("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:ao("div",{className:B("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),fr=({children:e,className:t,...a})=>ao("div",{className:B("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),cm={cjk:Bo,code:Ki},fm={cjk:Bo},pm={enabled:!1};function mm({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let n=Ji(typeof o=="string"?o:"",!!a),i=typeof o=="string"?n:o;return ao(Pt,{className:B("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??pm,plugins:a?fm:cm,...r,children:i})}var oo=dm(mm,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);oo.displayName="MessageResponse";f();import{createContext as xm,memo as hr,useCallback as Lm,useContext as Cm,useEffect as pr,useMemo as Im,useRef as Zi,useState as mr}from"react";f();import{memo as hm}from"react";import{jsx as wm}from"react/jsx-runtime";var gm=({as:e="span",className:t,duration:a=2,style:o,children:r,...s})=>{let n={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...o};return wm(e,{"data-waniwani-shimmer":"",className:B("ww:inline-block",t),style:n,...s,children:r})},et=hm(gm);et.displayName="Shimmer";import{Fragment as bm,jsx as Fe,jsxs as km}from"react/jsx-runtime";var Yi=xm(null);function el(){let e=Cm(Yi);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Sm=1e3,ym=1e3,gr=hr(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:s,children:n,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=mr(l),m=c?a:d,h=Lm(R=>{c||p(R),r?.(R)},[c,r]),[I,L]=mr(void 0),S=s??I,C=Zi(t),[g,y]=mr(!1),P=Zi(null);pr(()=>{t?(C.current=!0,P.current===null&&(P.current=Date.now())):P.current!==null&&(L(Math.ceil((Date.now()-P.current)/ym)),P.current=null)},[t]),pr(()=>{t&&!m&&!u&&h(!0)},[t,m,u,h]),pr(()=>{if(C.current&&!t&&m&&!g){let R=setTimeout(()=>{h(!1),y(!0)},Sm);return()=>clearTimeout(R)}},[t,m,g,h]);let v=Im(()=>({isStreaming:t,isOpen:m,setIsOpen:h,duration:S}),[t,m,h,S]);return Fe(Yi.Provider,{value:v,children:Fe("div",{className:B("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":m?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:n})})});gr.displayName="Reasoning";var wr=hr(({className:e,children:t,getThinkingMessage:a,onClick:o,...r})=>{let{t:s}=z(),{isStreaming:n,isOpen:i,duration:l,setIsOpen:u}=el(),d=a??((p,m)=>p||m===0?Fe(et,{duration:1.6,children:s.reasoning.thinking}):m===void 0?Fe("span",{children:s.reasoning.thoughtBrief}):Fe("span",{children:s.reasoning.thoughtForSeconds(m)}));return Fe("button",{type:"button","aria-expanded":i,onClick:p=>{u(!i),o?.(p)},className:B("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),...r,children:t??km(bm,{children:[Fe(Ut,{className:"ww:size-4 ww:shrink-0"}),d(n,l)]})})});wr.displayName="ReasoningTrigger";var xr=hr(({className:e,children:t,...a})=>{let{isOpen:o}=el();return Fe("div",{className:B("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Fe("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Fe("div",{className:B("ww:text-sm ww:text-muted-foreground",e),...a,children:Fe(Pt,{children:t})})})})});xr.displayName="ReasoningContent";f();import{createContext as Tm,useCallback as Pm,useContext as rl,useEffect as vm,useMemo as Cr,useRef as Am,useState as Ir}from"react";import{Fragment as ol,jsx as V,jsxs as tt}from"react/jsx-runtime";function Rm(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 c=`${l}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Mm({text:e,className:t}){let{t:a}=z(),[o,r]=Ir(!1),s=Am(null);vm(()=>()=>{s.current&&clearTimeout(s.current)},[]);let n=Pm(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 V(Ne,{variant:"ghost",size:"sm",onClick:n,className:B("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?tt(ol,{children:[V(Ot,{className:"ww:size-3.5"}),V("span",{children:a.tool.copied})]}):tt(ol,{children:[V(Wt,{className:"ww:size-3.5"}),V("span",{children:a.tool.copy})]})})}function sl({data:e,label:t,className:a,...o}){let[r,s]=Ir(!1),n=Cr(()=>JSON.stringify(e,null,2),[e]),i=Rm(e);return tt("div",{className:B("ww:rounded-lg ww:bg-tool-card",a),...o,children:[tt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[V("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),V(Mm,{text:n})]}),tt("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:[V(qt,{className:B("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?V("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:V("code",{children:n})}):V("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Sr=Tm({open:!1,toggle:()=>{}});function nl({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=Ir(t);return V(Sr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:V("div",{className:B("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 il({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=rl(Sr),n=a==="input-available"||a==="input-streaming",i=t??"";return tt("button",{type:"button",onClick:s,className:B("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:[V(Ge,{className:"ww:size-4 ww:shrink-0"}),V("span",{className:"ww:truncate",children:n?V(et,{duration:1.6,children:i}):i}),V(Ht,{className:B("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function ll({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",s=t??"";return tt("div",{className:B("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:[V(Ge,{className:"ww:size-4 ww:shrink-0"}),V("span",{className:"ww:truncate",children:r?V(et,{duration:1.6,children:s}):s})]})}function ul({className:e,children:t,...a}){let{open:o}=rl(Sr);return V("div",{className:B("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:V("div",{className:"ww:min-h-0 ww:overflow-hidden",children:V("div",{className:B("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function dl({className:e,input:t,debug:a,...o}){let{t:r}=z(),s=Cr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,a]);return V(sl,{data:s,label:r.tool.request,className:e,...o})}function Lr(e){if(!(typeof e!="object"||e===null))return e}function cl(e){return Lr(e?.ui)}function fl(e){return Lr(Lr(e)?._meta)}function tl(e){if(!e)return;let t=cl(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function al(e){return cl(e)?.autoHeight===!0}function ro(e,t,a){if(e){let o=tl(a?.[e]?._meta);if(o)return o}return tl(fl(t))}function pl(e,t,a){return e&&al(a?.[e]?._meta)?!0:al(fl(t))}function ml({className:e,output:t,errorText:a,debug:o,...r}){let{t:s}=z(),n=Cr(()=>{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?tt("div",{className:B("ww:space-y-2",e),...r,children:[V("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:s.tool.error}),V("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):V(sl,{data:n,label:s.tool.response,className:e,...r}):null}f();import{jsx as hl,jsxs as Dm}from"react/jsx-runtime";function Fm(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function yr(e){return e.parts.some(Fm)}function gl(e,t){if(t!=="submitted"&&t!=="streaming")return!1;let a=e[e.length-1];return!a||a.role!=="assistant"?!0:!yr(a)}function wl({className:e,...t}){let{t:a}=z();return Dm("div",{"aria-live":"polite",className:B("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[hl($t,{className:"ww:size-4 ww:shrink-0"}),hl(et,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as Bm,useEffect as xl,useMemo as Em,useRef as Le,useState as Ll}from"react";import{jsx as Vm}from"react/jsx-runtime";var _m="/api/mcp/resource",Nm=500,Um=0,Om=16,Hm="2026-01-26",qm=300,Wm=3e3,Gm=3;function jm(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function zm(e,t,a){return ro(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Cl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=_m,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=Le(null),I=Le(t),L=Le(a),S=Le({width:0,height:0}),C=Le(null),g=Le(!1),y=Le(0),P=Le("inline"),[v,R]=Ll(Um),[A,_]=Ll(void 0),M=Le(l),T=Le(u),b=Le(c),D=Le(d),O=Le(r),F=Le(m);I.current=t,L.current=a,M.current=l,T.current=u,b.current=c,D.current=d,O.current=r,F.current=m;let J=Bm(ae=>i?Math.max(ae+Om,0):Math.min(Math.max(ae,50),Nm),[i]),Be=Em(()=>{let ae=o.includes("?")?"&":"?";return`${o}${ae}uri=${encodeURIComponent(e)}`},[o,e]),Ce=Le(s);return Ce.current=s,xl(()=>{if(!g.current)return;let ae=h.current;ae?.contentWindow&&ae.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),xl(()=>{let ae=h.current;if(!ae)return;let he=!1,ye=!1,we=null,Ie=null,Ve=setTimeout(()=>{if(he||ye||y.current>=Gm)return;y.current+=1;let te=new URL(ae.src);te.searchParams.set("_retry",String(y.current)),ae.src=te.toString()},Wm),N=te=>{ae.contentWindow?.postMessage(te,"*")},le=te=>{if(he||te.source!==ae.contentWindow)return;let K=te.data;if(!K||typeof K!="object"||K.jsonrpc!=="2.0")return;let re=K.method,W=K.id;if(re==="ui/initialize"&&W!=null){ye=!0,clearTimeout(Ve),N({jsonrpc:"2.0",id:W,result:{protocolVersion:K.params?.protocolVersion??Hm,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Ce.current?"dark":"light",displayMode:P.current}}});return}if(re==="ui/notifications/initialized"){g.current=!0;let $=I.current,Q=L.current,q=Q._meta&&typeof Q._meta=="object"?Q._meta:null,Z=jm(O.current),se=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,Pe=se||Z?{...se??{},...Z?{sessionId:Z}:{}}:void 0,$e=q||Pe?{...q??{},...Pe?{waniwani:Pe}:{}}:void 0;N({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:$}});let mt=Q.content??[{type:"text",text:JSON.stringify(Q)}];N({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:mt,structuredContent:Q.structuredContent,_meta:$e,meta:$e}});return}if(re==="ui/notifications/size-changed"){let $=K.params,Q=typeof $?.height=="number"?$.height:void 0,q=typeof $?.width=="number"?$.width:void 0,Z=S.current,se=Q!==void 0&&Q!==Z.height,Pe=q!==void 0&&q!==Z.width;if(!se&&!Pe)return;if(se&&Q!==void 0){Z.height=Q;let $e=J(Q),mt=ae.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),R($e),ae.animate&&Math.abs(mt-$e)>2){let ht=ae.animate([{height:`${mt}px`},{height:`${$e}px`}],{duration:qm,easing:"ease-out",fill:"forwards"});C.current=ht,ht.onfinish=()=>{C.current===ht&&(ht.cancel(),C.current=null)}}}Pe&&i&&q!==void 0&&(Z.width=q,_(q));return}if(re==="ui/open-link"&&W!=null){let $=K.params?.url;typeof $=="string"&&(M.current?M.current($):window.open($,"_blank","noopener,noreferrer")),N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="ui/message"&&W!=null){if(T.current&&K.params){let $=K.params,Q=we;if(we=null,Ie){clearTimeout(Ie.timer);let q=Ie.text;Ie=null;let Z=($.content??[]).map(se=>se.text??"").join("").trim();$={...$,content:[{type:"text",text:`${Z}
80
80
 
81
81
  ${q}`}]}}T.current({...$,...Q?{modelContext:Q}:{}})}N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="ui/update-model-context"&&W!=null){we=Nr(we,K.params),N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="tools/call"&&W!=null){let $=b.current;if(!$){N({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let Q=K.params?.name;$({name:Q,arguments:K.params?.arguments??{}}).then(q=>{N({jsonrpc:"2.0",id:W,result:q});let Z=q.content?.map(se=>se.text??"").join("").trim();Z&&zm(Q,q,F.current)&&(Ie&&clearTimeout(Ie.timer),Ie={text:Z,timer:setTimeout(()=>{if(he)return;let se=we;we=null,Ie=null,T.current?.({role:"user",content:[{type:"text",text:Z}],...se?{modelContext:se}:{}})},500)})}).catch(q=>{let Z=q instanceof Error?q.message:"Tool call failed";N({jsonrpc:"2.0",id:W,error:{code:-32e3,message:Z}})});return}if(re==="ui/request-display-mode"&&W!=null){let $=K.params?.mode,Q=$==="fullscreen"||$==="inline"||$==="pip"?$:"inline";P.current=Q,N({jsonrpc:"2.0",id:W,result:{mode:Q}}),N({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:Q}}),D.current?.(Q);return}if(re==="ui/resource-teardown"&&W!=null){N({jsonrpc:"2.0",id:W,result:{}});return}re==="ping"&&W!=null&&N({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",le),()=>{he=!0,clearTimeout(Ve),Ie&&clearTimeout(Ie.timer),window.removeEventListener("message",le)}},[i,J]),Vm("iframe",{ref:h,src:Be,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:B(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":v,minWidth:p||!A?void 0:`min(${A}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as da,jsxs as $m}from"react/jsx-runtime";function Il({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return $m("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&&da("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}),da("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&da("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&da("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)=>da("button",{type:"button",onClick:()=>r?.(s),className:B("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as Xm}from"react";import{jsx as br,jsxs as Qm}from"react/jsx-runtime";function Km({onRetry:e}){let{t}=z();return Qm("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:[br("span",{children:t.widgetErrorBoundary.failedToLoad}),br("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var so=class extends Xm{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?br(Km,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Jm,jsx as ie,jsxs as ct}from"react/jsx-runtime";function Sl(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function yl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=e[e.length-1],L=e.length>0,S=d!=null,C=!S&&gl(e,t);return ct(Jm,{children:[!S&&(!L&&o?ie(Il,{...o,onSuggestionSelect:r}):a&&ie(cr,{from:"assistant",children:ie(fr,{children:ie(oo,{children:a})})})),e.map(g=>{let y=g.parts.filter(T=>T.type==="text"),P=g.parts.filter(T=>T.type==="reasoning"),v=g.parts.filter(T=>T.type==="file"),R=g.parts.filter(T=>"toolCallId"in T),A=g===I&&g.role==="assistant",_=y.length>0,M=S?R.some(T=>T.toolCallId===d):!1;return S&&!M?ie("div",{style:{display:"none"}},g.id):g.role==="assistant"&&!yr(g)?ie("div",{style:{display:"none"}},g.id):ct(cr,{from:g.role,children:[!M&&P.map((T,b)=>ct(gr,{isStreaming:T.state==="streaming",children:[ie(wr,{}),ie(xr,{children:T.text})]},`reasoning-${g.id}-${b}`)),R.map(T=>{let b="output"in T?T.output:void 0,D=ro(T.toolName,b,h),O=pl(T.toolName,b,h),F=T.toolCallId===d;return ct("div",{style:F?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[ie("div",{style:F?{display:"none"}:void 0,children:m?ct(nl,{children:[ie(il,{title:T.title??Sl(T.toolName),state:T.state}),ct(ul,{children:[ie(dl,{input:T.input,debug:p}),b!==void 0&&ie(ml,{output:b,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]}):ie(ll,{title:T.title??Sl(T.toolName),state:T.state})}),D&&s&&b!==void 0&&ie(so,{children:ie(Cl,{isFullscreen:F,resourceUri:D,toolInput:T.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:O,toolDefinitions:h,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?J=>c(J,{toolCallId:T.toolCallId,resourceUri:D,toolInput:T.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},autoHeight:O}):void 0})})]},T.toolCallId)}),!M&&ie("div",{children:ct(fr,{children:[v.length>0&&ie(Ln,{files:v}),_?y.map((T,b)=>{let D=A&&t==="streaming"&&b===y.length-1;return ie(oo,{isStreaming:D,children:T.type==="text"?T.text:""},`${g.id}-${b}`)}):null]})})]},g.id)}),C&&ie(wl,{})]})}f();import{jsx as bl,jsxs as eh}from"react/jsx-runtime";var Zm="https://app.waniwani.ai/assets/waniwani-logo.svg",Ym="https://waniwani.ai";function kl(){let{t:e}=z();return eh("a",{href:Ym,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[bl("span",{children:e.poweredBy.label}),bl("img",{src:Zm,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as no}from"react/jsx-runtime";function Tl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:no("div",{className:B("ww:px-4 ww:py-2",o),...r,children:no("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=>no("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)=>no("button",{type:"button",onClick:()=>a(s),className:B("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as th,useRef as ah,useState as oh}from"react";import{jsx as ee,jsxs as ft}from"react/jsx-runtime";var Pl=20;function rh({label:e}){return ft("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:[ee("title",{children:e}),ee("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ee("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function sh({label:e}){return ft("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:[ee("title",{children:e}),ee("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ee("polyline",{points:"3 4 3 9 8 9"}),ee("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ee("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function nh({label:e}){return ft("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:[ee("title",{children:e}),ee("polyline",{points:"3 6 5 6 21 6"}),ee("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ee("path",{d:"M10 11v6"}),ee("path",{d:"M14 11v6"})]})}function vl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:s,t:n}=z(),[i,l]=oh(!1),u=ah(null);th(()=>{if(!i)return;let p=m=>{let h=u.current;h&&(m.composedPath().includes(h)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Pl),d=Math.max(0,e.length-Pl);return ft("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ee("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:ee(rh,{label:n.threadMenu.newChat})}),ee("button",{type:"button",onClick:()=>l(p=>!p),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:ee(sh,{label:n.threadMenu.threadHistory})}),i&&ft("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&ee("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:n.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,h=Date.parse(p.updatedAt);return ft("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ft("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ee("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ee("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(h)?"":Ao(h,s)})]}),ee("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.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:ee(nh,{label:n.threadMenu.deleteThread})})]},p.threadId)}),d>0&&ee("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)})]})]})}f();import{useCallback as ih,useRef as lh}from"react";function Al(e){let t=lh(e);return t.current=e,ih(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()},[])}f();import{useChat as kh}from"@ai-sdk/react";import{useCallback as pe,useEffect as De,useRef as de,useState as pt}from"react";f();import{DefaultChatTransport as uh,uiMessageChunkSchema as dh}from"ai";function ch(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 uh{processResponseStream(t){let a="",o=dh(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
82
- `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=ch(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var fh="waniwani-memory";var Te="threads",lo="by_memoryUserId",ph="by_updatedAt";var Ml="memoryUserId",Rl="waniwani-memory-user-id",kr=null;function Tr(){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 mh(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(ph,"updatedAt",{unique:!1})}}async function Pr(){return new Promise((e,t)=>{let a=indexedDB.open(fh,2);a.onupgradeneeded=o=>{mh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function hh(){return Pr()}async function gh(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Ml);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function wh(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Ml);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function xh(){if(typeof indexedDB>"u")return null;try{let e=await hh();try{let t=await gh(e);if(t)return t;let a=Tr();return await wh(e,a),a}finally{e.close()}}catch{return null}}function Lh(){try{let e=localStorage.getItem(Rl);if(e)return e;let t=Tr();return localStorage.setItem(Rl,t),t}catch{return null}}async function Fl(){let e=await xh();if(e)return e;let t=Lh();return t||(kr||(kr=Tr()),kr)}var Dl=50,Bl=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 co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Pr(),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 Ar(e){return await co(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 Rr(e){return await co(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>Bl?{...e,messages:e.messages.slice(e.messages.length-Bl)}:e;await co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Te,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.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>Dl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Dl);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 El(e){await co(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 _l(e){return(await Ar(e))[0]?.threadId??null}function Nl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var Ul="waniwani-visitor-id";function Ol(e,t){return e.match(t)?.[1]??null}function Ch(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=Ol(e,o);if(r)return{name:a,version:r}}return null}function Ih(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=Ol(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Sh(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 yh(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 bh(){try{let a=localStorage.getItem(Ul);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 yh(e);try{localStorage.setItem(Ul,t)}catch{}return t}async function Hl(){let e=navigator.userAgent,[t,a]=await Promise.all([bh(),Fl()]);return{userAgent:e,browser:Ch(e),os:Ih(e),deviceType:Sh(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 Th="x-session-id",Ph=250;function ql(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Kt()}function fo(){return new Date().toISOString()}function Wl(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function vh(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Gl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=de(a),c=de(o),d=de(n);De(()=>{d.current=n},[n]);let p=de(void 0),m=de(null),[h,I]=pt(void 0),L=de(h),[S,C]=pt(i),g=de(S),[y,P]=pt([]),[v,R]=pt(!n),A=de(void 0),_=de(void 0),M=de(void 0),T=de(void 0),b=de(0),D=de(l);De(()=>{D.current=l},[l]);let O=pe(k=>{g.current=k,C(k),k&&D.current?.(k)},[]),F=pe(async()=>{if(!n)return;let k=m.current?.memoryUserId;if(!k)return;let U=await Ar(k);P(U)},[n]),J=pe(()=>L.current,[]),Be=pe(k=>{let U=Wl(k);U&&L.current!==U&&(L.current=U,I(U))},[]),Ce=pe(()=>{L.current=void 0,I(void 0)},[]);De(()=>{u.current=a},[a]),De(()=>{c.current=o},[o]),De(()=>{let k=!1,U=b.current;return(async()=>{try{let ve=await Hl();if(k)return;m.current=ve}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){R(!0);return}try{let ve=i??await _l(H);if(k||U!==b.current)return;if(ve){let xe=await Rr(ve);if(k||U!==b.current)return;xe&&xe.memoryUserId===H&&(g.current=xe.threadId,C(xe.threadId),A.current=xe.createdAt,_.current=xe.title,xe.sessionId&&(L.current=xe.sessionId,I(xe.sessionId)),re(xe.messages))}await F()}finally{k||R(!0)}})(),()=>{k=!0}},[]);let ae=de(new io({api:t,headers:()=>({...u.current}),body:()=>{let k={...c.current??{}},U=Object.hasOwn(k,"sessionId"),H=Wl(k.sessionId);if(H)Be(H),k.sessionId=H;else if(U)Ce(),delete k.sessionId;else{let Re=J();Re&&(k.sessionId=Re)}if(gt(p.current)&&(k.modelContext=p.current),m.current){let Re=m.current;k.visitorContext={timezone:Re.timezone,language:Re.language,languages:Re.languages,deviceType:Re.deviceType,referrer:Re.referrer,visitorId:Re.visitorId};let qe=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},lu=typeof qe.client=="object"&&qe.client!==null?qe.client:{};k.visitor={...qe,client:{...lu,memoryUserId:Re.memoryUserId}}}let ve=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,xe=m.current?.memoryUserId,Xe=m.current?.language,ma={};if(xe&&(ma.memoryUserId=xe),Xe&&(ma.locale=Xe),(Object.keys(ma).length>0||ve)&&(k.extra={...ma,...ve??{}}),d.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(g.current=k.threadId);else{let qe=g.current;qe||(qe=ql(),A.current=fo(),_.current=void 0,O(qe)),k.threadId=qe}return k},fetch:(async(k,U)=>{let H=await fetch(k,U);return p.current=void 0,Be(H.headers.get(Th)),H})})),he=de(null),ye=de(null),we=de({}),[Ie,Ve]=pt(0),N=e.skipRemoteConfig===!0,le=pe(async()=>{if(!N)try{let k=await vh(t,u.current);we.current=k,Ve(U=>U+1)}catch(k){console.warn("[WaniWani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,N]);De(()=>{le()},[le]);let{messages:te,sendMessage:K,setMessages:re,status:W}=kh({messages:e.initialMessages,transport:ae.current,onFinish({message:k}){s?.(),he.current&&(ye.current=k)},onError(k){console.warn("[WaniWani] Chat error:",k.message),he.current&&(he.current.reject(k),he.current=null)}}),$=de(te);De(()=>{$.current=te},[te]),De(()=>{if(W==="ready"&&he.current&&ye.current){let k=he.current,U=ye.current;he.current=null,ye.current=null,k.resolve(U)}},[W]);let[Q,q]=pt(""),[Z,se]=pt([]),Pe=W==="submitted"||W==="streaming",$e=pe(k=>{se(U=>U.filter(H=>H.id!==k))},[]),mt=Pe&&Z.length>0,ht=pe(k=>{let U=!!k.text?.trim(),H=!!k.files?.length;if(U||H){if(Pe){if(Z.length>0)return;se(ve=>[...ve,{id:Kt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),q("");return}p.current=k.modelContext,K({text:k.text||"",files:k.files}),r?.(k.text||""),q("")}},[K,r,Pe,Z.length]),tu=pe(k=>new Promise((U,H)=>{he.current={resolve:U,reject:H},K({text:k}),r?.(k)}),[K,r]);De(()=>{if(W!=="ready"||Z.length===0)return;let[k,...U]=Z;se(U),p.current=k.modelContext,K({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text)},[W,K,r,Z]);let au=pe(()=>{re([]),se([]),Ce(),q(""),we.current={},Ve(k=>k+1),le()},[re,Ce,le]),fa=pe(()=>{if(!d.current)return;let k=m.current?.memoryUserId,U=g.current,H=$.current;if(!(!k||!U||H.length===0)){if(A.current||(A.current=fo()),!_.current){let ve=H.find(Xe=>Xe.role==="user"),xe=ve?ve.parts.map(Xe=>"text"in Xe&&typeof Xe.text=="string"?Xe.text:"").join(" "):"";_.current=Nl(xe)}return{threadId:U,memoryUserId:k,title:_.current,messages:H,sessionId:L.current,createdAt:A.current,updatedAt:fo()}}},[]),Br=pe(async()=>{let k=fa();k&&(await Mr(k),await F())},[fa,F]);De(()=>{if(n&&v&&!(W==="submitted"||W==="streaming")&&te.length!==0)return M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=void 0;let k=Br().finally(()=>{T.current===k&&(T.current=void 0)});T.current=k},Ph),()=>{M.current&&clearTimeout(M.current)}},[n,v,te,W,Br]);let pa=pe(()=>{let k=T.current,U=M.current,H=U?fa():void 0;return U&&(clearTimeout(U),M.current=void 0),(async()=>{k&&await k,H&&(await Mr(H),await F())})()},[fa,F]),ou=pe(()=>{b.current+=1,pa(),re([]),se([]),Ce(),q("");let k=ql();return A.current=fo(),_.current=void 0,O(k),F(),k},[re,Ce,O,F,pa]),po=pe(async k=>{b.current+=1;let U=b.current;if(await pa(),U!==b.current)return;let H=await Rr(k);U===b.current&&H&&(O(H.threadId),A.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):Ce(),re(H.messages),se([]),q(""))},[re,Ce,O,pa]),ru=pe(async k=>{if(g.current===k){b.current+=1,M.current&&(clearTimeout(M.current),M.current=void 0);let U=T.current;U&&await U}await El(k),await F(),g.current===k&&(re([]),se([]),Ce(),q(""),g.current=void 0,C(void 0),A.current=void 0,_.current=void 0)},[re,Ce,F]);De(()=>{n&&v&&i!==void 0&&i!==g.current&&po(i)},[i,n,v,po]);let su=pe(k=>{q(k.target.value)},[]),Er=te[te.length-1],_r=te.length>0,nu=Pe&&(!_r||Er.role==="user"),iu=we.current;return{messages:te,status:W,text:Q,setText:q,handleSubmit:ht,handleTextChange:su,isLoading:Pe,showLoaderBubble:nu,lastMessage:Er,hasMessages:_r,sendMessage:K,sendMessageAndWait:tu,reset:au,queuedMessages:Z,queueFull:mt,removeQueuedMessage:$e,sessionId:h,toolDefinitions:iu,refreshToolDefinitions:le,threads:y,activeThreadId:S,isThreadHistoryReady:v,startNewThread:ou,switchThread:po,deleteThread:ru}}f();import{useEffect as jl,useRef as Ah,useState as Rh}from"react";var Mh={debug:!1,eval:!1};function zl(e="/api/waniwani",t,a=!1){let[o,r]=Rh(Mh),s=Ah(t);return jl(()=>{s.current=t},[t]),jl(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as Fh,useEffect as Fr,useRef as Dh,useState as Bh}from"react";function Eh(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 Vl(e){return typeof e=="object"&&e!==null&&"initial"in e}function $l(e){let{messages:t,status:a,config:o}=e,r=Vl(o)&&o.initial?o.initial:void 0,[s,n]=Bh(r??[]),i=Dh(a),l=o===!0||Vl(o)&&o.dynamic!==!1,u=Fh(()=>{n([])},[]),c=t.length>0;Fr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return Fr(()=>{d?.role==="user"&&u()},[d,u]),Fr(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=Eh(m);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as _h,useRef as Nh,useState as Uh}from"react";var Oh=50,Hh=30,qh=2e3,Xl=500;function Kl(e,t=!0){let[a,o]=Uh(""),r=Nh(void 0);return _h(()=>{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,Xl)):r.current=setTimeout(l,Hh)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,qh)):r.current=setTimeout(l,Oh)))};return r.current=setTimeout(l,Xl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function Ql(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Wh={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"};var Gh={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 Jl(e){return{...Wh,...e}}function Zl(e){let t={};for(let[a,o]of Object.entries(Gh)){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 me,jsxs as ca}from"react/jsx-runtime";var $h=jh(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=Ql(S,t.headers),g=Jl(o),y=Zl(g),P=g.backgroundColor.replace("#",""),v=parseInt(P.substring(0,2),16),R=parseInt(P.substring(2,4),16),A=parseInt(P.substring(4,6),16),_=(v*299+R*587+A*114)/1e3<128,M=zl(S,t.headers,t.skipRemoteConfig),T=h??M.debug,b=Gl({...t,api:S}),D=Al({...t,api:S,sessionId:b.sessionId}),O=Kl(d,!b.text),[F,J]=eu(!1),[Be,Ce]=eu(null),ae=Yl(null),he=Yl(void 0),ye=Dr(()=>{let N=ae.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let le=N.querySelector("textarea");le&&setTimeout(()=>le.focus(),300),J(!0),clearTimeout(he.current),he.current=setTimeout(()=>J(!1),2e3)},[]),we=$l({messages:b.messages,status:b.status,config:t.suggestions}),Ie=Dr(N=>{let le=N.content.map(te=>te.text??"").join("").trim();le&&b.handleSubmit({text:le,files:[],modelContext:N.modelContext})},[b.handleSubmit]),Ve=Dr(N=>{we.clear(),b.handleSubmit({text:N,files:[]})},[we.clear,b.handleSubmit]);return Vh(a,()=>({sendMessage:N=>{b.handleSubmit({text:N,files:[]}),ye()},sendMessageAndWait:N=>b.sendMessageAndWait(N),reset:b.reset,focus:ye,get messages(){return b.messages}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,ye]),zh(()=>{if(!p)return;let N=le=>{let te=le.detail,K=typeof te?.message=="string"?te.message:void 0;K&&b.handleSubmit({text:K,files:[]}),ye()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,b.handleSubmit,ye]),ca("div",{ref:ae,style:{...y,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:B("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[me("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),me(xn,{messages:b.messages,evalEnabled:M.eval,api:S}),I&&me(vl,{threads:b.threads,activeThreadId:b.activeThreadId,onNewThread:b.startNewThread,onSelectThread:N=>{b.switchThread(N)},onDeleteThread:N=>{b.deleteThread(N)}})]}),ca(Xs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[me(Ks,{scrollClassName:Be?"ww:!relative ww:!overflow-hidden":void 0,children:me(yl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:Ve,resourceEndpoint:C,chatSessionId:b.sessionId,isDark:_,onFollowUp:Ie,onCallTool:D,fullscreenToolCallId:Be,debug:T,showToolCalls:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(N,le)=>{Ce(N==="fullscreen"?le.toolCallId:null)}})}),me(Qs,{})]}),me("div",{style:Be?{display:"none"}:void 0,children:me(Tl,{suggestions:we.suggestions,isLoading:we.isLoading,onSelect:Ve})}),me("div",{style:Be?{display:"none"}:void 0,children:me(hn,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),me("div",{style:Be?{display:"none"}:void 0,children:me("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[me(an,{onSubmit:b.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&me(sn,{}),me(on,{onChange:b.handleTextChange,value:b.text,placeholder:O,className:"ww:min-h-0 ww:py-1 ww:px-0"}),me(rn,{status:b.status,disabled:b.queueFull})]})}),me(kl,{})]})})})]})});export{$h as ChatCard,os as DevModeProvider,gu as InitializeNextJsInIframe,Ju as LoadingWidget,cs as WidgetProvider,Zr as createResource,fu as createTool,mo as detectPlatform,La as getMockState,Rt as initializeMockOpenAI,du as isMCPApps,uu as isOpenAI,pu as registerTools,sL as toNextJsHandler,is as unstable_useSendFollowUpWithGhostGuard,Ft as updateMockDisplayMode,at as updateMockGlobal,Dt as updateMockTheme,Mt as updateMockToolOutput,fs as useCallTool,ps as useDisplayMode,ms as useFlowAction,hs as useIsChatGptApp,gs as useLocale,ws as useMaxHeight,xs as useOpenExternal,Ls as useRequestDisplayMode,Cs as useSafeArea,Is as useSendFollowUp,Ss as useTheme,Ia as useToolOutput,ys as useToolResponseMetadata,bs as useUpdateModelContext,G as useWidgetClient,ks as useWidgetState};
82
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=ch(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var fh="waniwani-memory";var Te="threads",lo="by_memoryUserId",ph="by_updatedAt";var Ml="memoryUserId",Rl="waniwani-memory-user-id",kr=null;function Tr(){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 mh(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(ph,"updatedAt",{unique:!1})}}async function Pr(){return new Promise((e,t)=>{let a=indexedDB.open(fh,2);a.onupgradeneeded=o=>{mh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function hh(){return Pr()}async function gh(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Ml);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function wh(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Ml);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function xh(){if(typeof indexedDB>"u")return null;try{let e=await hh();try{let t=await gh(e);if(t)return t;let a=Tr();return await wh(e,a),a}finally{e.close()}}catch{return null}}function Lh(){try{let e=localStorage.getItem(Rl);if(e)return e;let t=Tr();return localStorage.setItem(Rl,t),t}catch{return null}}async function Fl(){let e=await xh();if(e)return e;let t=Lh();return t||(kr||(kr=Tr()),kr)}var Dl=50,Bl=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 co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Pr(),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 Ar(e){return await co(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 Rr(e){return await co(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>Bl?{...e,messages:e.messages.slice(e.messages.length-Bl)}:e;await co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Te,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.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>Dl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Dl);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 El(e){await co(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 _l(e){return(await Ar(e))[0]?.threadId??null}function Nl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var Ul="waniwani-visitor-id";function Ol(e,t){return e.match(t)?.[1]??null}function Ch(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=Ol(e,o);if(r)return{name:a,version:r}}return null}function Ih(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=Ol(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Sh(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 yh(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 bh(){try{let a=localStorage.getItem(Ul);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 yh(e);try{localStorage.setItem(Ul,t)}catch{}return t}async function Hl(){let e=navigator.userAgent,[t,a]=await Promise.all([bh(),Fl()]);return{userAgent:e,browser:Ch(e),os:Ih(e),deviceType:Sh(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 Th="x-session-id",Ph=250;function ql(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Kt()}function fo(){return new Date().toISOString()}function Wl(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function vh(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Gl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=de(a),c=de(o),d=de(n);De(()=>{d.current=n},[n]);let p=de(void 0),m=de(null),[h,I]=pt(void 0),L=de(h),[S,C]=pt(i),g=de(S),[y,P]=pt([]),[v,R]=pt(!n),A=de(void 0),_=de(void 0),M=de(void 0),T=de(void 0),b=de(0),D=de(l);De(()=>{D.current=l},[l]);let O=pe(k=>{g.current=k,C(k),k&&D.current?.(k)},[]),F=pe(async()=>{if(!n)return;let k=m.current?.memoryUserId;if(!k)return;let U=await Ar(k);P(U)},[n]),J=pe(()=>L.current,[]),Be=pe(k=>{let U=Wl(k);U&&L.current!==U&&(L.current=U,I(U))},[]),Ce=pe(()=>{L.current=void 0,I(void 0)},[]);De(()=>{u.current=a},[a]),De(()=>{c.current=o},[o]),De(()=>{let k=!1,U=b.current;return(async()=>{try{let ve=await Hl();if(k)return;m.current=ve}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){R(!0);return}try{let ve=i??await _l(H);if(k||U!==b.current)return;if(ve){let xe=await Rr(ve);if(k||U!==b.current)return;xe&&xe.memoryUserId===H&&(g.current=xe.threadId,C(xe.threadId),A.current=xe.createdAt,_.current=xe.title,xe.sessionId&&(L.current=xe.sessionId,I(xe.sessionId)),re(xe.messages))}await F()}finally{k||R(!0)}})(),()=>{k=!0}},[]);let ae=de(new io({api:t,headers:()=>({...u.current}),body:()=>{let k={...c.current??{}},U=Object.hasOwn(k,"sessionId"),H=Wl(k.sessionId);if(H)Be(H),k.sessionId=H;else if(U)Ce(),delete k.sessionId;else{let Re=J();Re&&(k.sessionId=Re)}if(gt(p.current)&&(k.modelContext=p.current),m.current){let Re=m.current;k.visitorContext={timezone:Re.timezone,language:Re.language,languages:Re.languages,deviceType:Re.deviceType,referrer:Re.referrer,visitorId:Re.visitorId};let qe=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},lu=typeof qe.client=="object"&&qe.client!==null?qe.client:{};k.visitor={...qe,client:{...lu,memoryUserId:Re.memoryUserId}}}let ve=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,xe=m.current?.memoryUserId,Xe=m.current?.language,ma={};if(xe&&(ma.memoryUserId=xe),Xe&&(ma.locale=Xe),(Object.keys(ma).length>0||ve)&&(k.extra={...ma,...ve??{}}),d.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(g.current=k.threadId);else{let qe=g.current;qe||(qe=ql(),A.current=fo(),_.current=void 0,O(qe)),k.threadId=qe}return k},fetch:(async(k,U)=>{let H=await fetch(k,U);return p.current=void 0,Be(H.headers.get(Th)),H})})),he=de(null),ye=de(null),we=de({}),[Ie,Ve]=pt(0),N=e.skipRemoteConfig===!0,le=pe(async()=>{if(!N)try{let k=await vh(t,u.current);we.current=k,Ve(U=>U+1)}catch(k){console.warn("[WaniWani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,N]);De(()=>{le()},[le]);let{messages:te,sendMessage:K,setMessages:re,status:W}=kh({messages:e.initialMessages,transport:ae.current,onFinish({message:k}){s?.(),he.current&&(ye.current=k)},onError(k){console.warn("[WaniWani] Chat error:",k.message),he.current&&(he.current.reject(k),he.current=null)}}),$=de(te);De(()=>{$.current=te},[te]),De(()=>{if(W==="ready"&&he.current&&ye.current){let k=he.current,U=ye.current;he.current=null,ye.current=null,k.resolve(U)}},[W]);let[Q,q]=pt(""),[Z,se]=pt([]),Pe=W==="submitted"||W==="streaming",$e=pe(k=>{se(U=>U.filter(H=>H.id!==k))},[]),mt=Pe&&Z.length>0,ht=pe(k=>{let U=!!k.text?.trim(),H=!!k.files?.length;if(U||H){if(Pe){if(Z.length>0)return;se(ve=>[...ve,{id:Kt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),q("");return}p.current=k.modelContext,K({text:k.text||"",files:k.files}),r?.(k.text||""),q("")}},[K,r,Pe,Z.length]),tu=pe(k=>new Promise((U,H)=>{he.current={resolve:U,reject:H},K({text:k}),r?.(k)}),[K,r]);De(()=>{if(W!=="ready"||Z.length===0)return;let[k,...U]=Z;se(U),p.current=k.modelContext,K({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text)},[W,K,r,Z]);let au=pe(()=>{re([]),se([]),Ce(),q(""),we.current={},Ve(k=>k+1),le()},[re,Ce,le]),fa=pe(()=>{if(!d.current)return;let k=m.current?.memoryUserId,U=g.current,H=$.current;if(!(!k||!U||H.length===0)){if(A.current||(A.current=fo()),!_.current){let ve=H.find(Xe=>Xe.role==="user"),xe=ve?ve.parts.map(Xe=>"text"in Xe&&typeof Xe.text=="string"?Xe.text:"").join(" "):"";_.current=Nl(xe)}return{threadId:U,memoryUserId:k,title:_.current,messages:H,sessionId:L.current,createdAt:A.current,updatedAt:fo()}}},[]),Br=pe(async()=>{let k=fa();k&&(await Mr(k),await F())},[fa,F]);De(()=>{if(n&&v&&!(W==="submitted"||W==="streaming")&&te.length!==0)return M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=void 0;let k=Br().finally(()=>{T.current===k&&(T.current=void 0)});T.current=k},Ph),()=>{M.current&&clearTimeout(M.current)}},[n,v,te,W,Br]);let pa=pe(()=>{let k=T.current,U=M.current,H=U?fa():void 0;return U&&(clearTimeout(U),M.current=void 0),(async()=>{k&&await k,H&&(await Mr(H),await F())})()},[fa,F]),ou=pe(()=>{b.current+=1,pa(),re([]),se([]),Ce(),q("");let k=ql();return A.current=fo(),_.current=void 0,O(k),F(),k},[re,Ce,O,F,pa]),po=pe(async k=>{b.current+=1;let U=b.current;if(await pa(),U!==b.current)return;let H=await Rr(k);U===b.current&&H&&(O(H.threadId),A.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):Ce(),re(H.messages),se([]),q(""))},[re,Ce,O,pa]),ru=pe(async k=>{if(g.current===k){b.current+=1,M.current&&(clearTimeout(M.current),M.current=void 0);let U=T.current;U&&await U}await El(k),await F(),g.current===k&&(re([]),se([]),Ce(),q(""),g.current=void 0,C(void 0),A.current=void 0,_.current=void 0)},[re,Ce,F]);De(()=>{n&&v&&i!==void 0&&i!==g.current&&po(i)},[i,n,v,po]);let su=pe(k=>{q(k.target.value)},[]),Er=te[te.length-1],_r=te.length>0,nu=Pe&&(!_r||Er.role==="user"),iu=we.current;return{messages:te,status:W,text:Q,setText:q,handleSubmit:ht,handleTextChange:su,isLoading:Pe,showLoaderBubble:nu,lastMessage:Er,hasMessages:_r,sendMessage:K,sendMessageAndWait:tu,reset:au,queuedMessages:Z,queueFull:mt,removeQueuedMessage:$e,sessionId:h,toolDefinitions:iu,refreshToolDefinitions:le,threads:y,activeThreadId:S,isThreadHistoryReady:v,startNewThread:ou,switchThread:po,deleteThread:ru}}f();import{useEffect as jl,useRef as Ah,useState as Rh}from"react";var Mh={debug:!1,eval:!1};function zl(e="/api/waniwani",t,a=!1){let[o,r]=Rh(Mh),s=Ah(t);return jl(()=>{s.current=t},[t]),jl(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as Fh,useEffect as Fr,useRef as Dh,useState as Bh}from"react";function Eh(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 Vl(e){return typeof e=="object"&&e!==null&&"initial"in e}function $l(e){let{messages:t,status:a,config:o}=e,r=Vl(o)&&o.initial?o.initial:void 0,[s,n]=Bh(r??[]),i=Dh(a),l=o===!0||Vl(o)&&o.dynamic!==!1,u=Fh(()=>{n([])},[]),c=t.length>0;Fr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return Fr(()=>{d?.role==="user"&&u()},[d,u]),Fr(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=Eh(m);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as _h,useRef as Nh,useState as Uh}from"react";var Oh=50,Hh=30,qh=2e3,Xl=500;function Kl(e,t=!0){let[a,o]=Uh(""),r=Nh(void 0);return _h(()=>{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,Xl)):r.current=setTimeout(l,Hh)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,qh)):r.current=setTimeout(l,Oh)))};return r.current=setTimeout(l,Xl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function Ql(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Wh={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"};var Gh={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 Jl(e){return{...Wh,...e}}function Zl(e){let t={};for(let[a,o]of Object.entries(Gh)){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 me,jsxs as ca}from"react/jsx-runtime";var $h=jh(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=Ql(S,t.headers),g=Jl(o),y=Zl(g),P=g.backgroundColor.replace("#",""),v=parseInt(P.substring(0,2),16),R=parseInt(P.substring(2,4),16),A=parseInt(P.substring(4,6),16),_=(v*299+R*587+A*114)/1e3<128,M=zl(S,t.headers,t.skipRemoteConfig),T=h??M.debug,b=Gl({...t,api:S}),D=Al({...t,api:S,sessionId:b.sessionId}),O=Kl(d,!b.text),[F,J]=eu(!1),[Be,Ce]=eu(null),ae=Yl(null),he=Yl(void 0),ye=Dr(()=>{let N=ae.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let le=N.querySelector("textarea");le&&setTimeout(()=>le.focus(),300),J(!0),clearTimeout(he.current),he.current=setTimeout(()=>J(!1),2e3)},[]),we=$l({messages:b.messages,status:b.status,config:t.suggestions}),Ie=Dr(N=>{let le=N.content.map(te=>te.text??"").join("").trim();le&&b.handleSubmit({text:le,files:[],modelContext:N.modelContext})},[b.handleSubmit]),Ve=Dr(N=>{we.clear(),b.handleSubmit({text:N,files:[]})},[we.clear,b.handleSubmit]);return Vh(a,()=>({sendMessage:N=>{b.handleSubmit({text:N,files:[]}),ye()},sendMessageAndWait:N=>b.sendMessageAndWait(N),reset:b.reset,focus:ye,get messages(){return b.messages},get sessionId(){return b.sessionId}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,b.sessionId,ye]),zh(()=>{if(!p)return;let N=le=>{let te=le.detail,K=typeof te?.message=="string"?te.message:void 0;K&&b.handleSubmit({text:K,files:[]}),ye()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,b.handleSubmit,ye]),ca("div",{ref:ae,style:{...y,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:B("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[me("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),me(xn,{messages:b.messages,evalEnabled:M.eval,api:S}),I&&me(vl,{threads:b.threads,activeThreadId:b.activeThreadId,onNewThread:b.startNewThread,onSelectThread:N=>{b.switchThread(N)},onDeleteThread:N=>{b.deleteThread(N)}})]}),ca(Xs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[me(Ks,{scrollClassName:Be?"ww:!relative ww:!overflow-hidden":void 0,children:me(yl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:Ve,resourceEndpoint:C,chatSessionId:b.sessionId,isDark:_,onFollowUp:Ie,onCallTool:D,fullscreenToolCallId:Be,debug:T,showToolCalls:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(N,le)=>{Ce(N==="fullscreen"?le.toolCallId:null)}})}),me(Qs,{})]}),me("div",{style:Be?{display:"none"}:void 0,children:me(Tl,{suggestions:we.suggestions,isLoading:we.isLoading,onSelect:Ve})}),me("div",{style:Be?{display:"none"}:void 0,children:me(hn,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),me("div",{style:Be?{display:"none"}:void 0,children:me("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[me(an,{onSubmit:b.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&me(sn,{}),me(on,{onChange:b.handleTextChange,value:b.text,placeholder:O,className:"ww:min-h-0 ww:py-1 ww:px-0"}),me(rn,{status:b.status,disabled:b.queueFull})]})}),me(kl,{})]})})})]})});export{$h as ChatCard,os as DevModeProvider,gu as InitializeNextJsInIframe,Ju as LoadingWidget,cs as WidgetProvider,Zr as createResource,fu as createTool,mo as detectPlatform,La as getMockState,Rt as initializeMockOpenAI,du as isMCPApps,uu as isOpenAI,pu as registerTools,sL as toNextJsHandler,is as unstable_useSendFollowUpWithGhostGuard,Ft as updateMockDisplayMode,at as updateMockGlobal,Dt as updateMockTheme,Mt as updateMockToolOutput,fs as useCallTool,ps as useDisplayMode,ms as useFlowAction,hs as useIsChatGptApp,gs as useLocale,ws as useMaxHeight,xs as useOpenExternal,Ls as useRequestDisplayMode,Cs as useSafeArea,Is as useSendFollowUp,Ss as useTheme,Ia as useToolOutput,ys as useToolResponseMetadata,bs as useUpdateModelContext,G as useWidgetClient,ks as useWidgetState};
83
83
  /*! Bundled license information:
84
84
 
85
85
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js: