@waniwani/sdk 0.19.2 → 0.19.4

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.
@@ -1,4 +1,4 @@
1
- import{a as ko,b as Wu,c as Gu}from"../chunk-R6LESDWJ.js";import{b as Mt,c as Ct,d as on,e as rn}from"../chunk-PYLRF5BB.js";import{a as nn,b as sn,c as ln,d as un,e as dn,f as ba,g as cn,h as fn,i as pn,j as mn,k as To,l as gn,m as Lt,n as It,o as ka,p as St,u as Ft}from"../chunk-YP6YTC7R.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var Ta="text/html+skybridge",va="text/html;profile=mcp-app",hn=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function wn(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function xn(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function vo(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function Cn(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:n,widgetDomain:s,prefersBorder:i=!0,autoHeight:l=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:C}=new URL(r);(C==="localhost"||C==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${C}:*`,`wss://${C}:*`],resource_domains:[...u.resource_domains||[],`http://${C}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=hn(r,n)),p),g=o;async function I(C){let S=await m();C.registerResource(`${t}-openai-widget`,c,{title:a,description:g,mimeType:Ta,_meta:{"openai/widgetDescription":g,"openai/widgetPrefersBorder":i}},async x=>({contents:[{uri:x.href,mimeType:Ta,text:S,_meta:wn({description:g,prefersBorder:i,widgetDomain:s,widgetCSP:u})}]})),C.registerResource(`${t}-mcp-widget`,d,{title:a,description:g,mimeType:va,_meta:{ui:{prefersBorder:i}}},async x=>({contents:[{uri:x.href,mimeType:va,text:S,_meta:xn({description:g,prefersBorder:i,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:l,register:I}}f();f();f();f();f();var Po="waniwani/suggestions";var ju="waniwani/client";function Ln(e){if(typeof e=="object"&&e!==null)return e[ju]}function zu(e,t){let{resource:a,description:o,inputSchema:r,annotations:n,autoInjectResultText:s=!0}=e,i=e.id??a?.id,l=e.title??a?.title;if(!i)throw new Error("createTool: `id` is required when no resource is provided");if(!l)throw new Error("createTool: `title` is required when no resource is provided");let u=a?vo({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:i,title:l,description:o,async register(c){c.registerTool(i,{title:l,description:o,inputSchema:r,annotations:n,...u&&{_meta:u}},(async(d,p)=>{let m=p,g=m._meta??{},I=Ln(m),C=await t(d,{extra:{_meta:g},waniwani:I});return a&&C.data?{content:[{type:"text",text:C.text}],structuredContent:C.data,_meta:{...u,...g,...s===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:C.text}],...C.data?{structuredContent:C.data}:{},...s===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Vu(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as Qu,jsx as Dt,jsxs as Ju}from"react/jsx-runtime";function $u(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(l=>{l.forEach(u=>{if(u.type==="attributes"&&u.target===a){let c=u.attributeName;c&&c!=="suppresshydrationwarning"&&c!=="lang"&&c!=="class"&&c!=="style"&&a.removeAttribute(c)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);r(null,u,d.pathname+d.search+d.hash)}catch{}};let n=history.pushState.bind(history);history.pushState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);n(null,u,d.pathname+d.search+d.hash)}catch{}};let s=new URL(e).origin,i=window.self!==window.top;if(window.addEventListener("click",l=>{let u=l?.target?.closest("a");if(!u||!u.href)return;let c=new URL(u.href,window.location.href);if(c.origin!==window.location.origin&&c.origin!==s)try{window.openai&&(window.openai?.openExternal({href:u.href}),l.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),i&&window.location.origin!==s){let l=window.fetch;window.fetch=((p,m)=>{let g=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===s)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),l.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return l.call(window,p,m);if(g&&I.origin===window.location.origin){let C=new URL(e);return C.pathname=I.pathname,C.search=I.search,C.hash=I.hash,I=C,p=I.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=s.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let g=new URL(String(p),window.location.href);if(g.origin===window.location.origin||g.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=g.pathname,I.search=g.search,I.hash=g.hash,new c(I.toString(),m)}return new c(p,m)});d.prototype=c.prototype,Object.assign(d,{CONNECTING:c.CONNECTING,OPEN:c.OPEN,CLOSING:c.CLOSING,CLOSED:c.CLOSED}),window.WebSocket=d}}var Xu=`(${$u.toString()})()`;function Ku({baseUrl:e,passthroughOrigins:t}){return Ju(Qu,{children:[Dt("base",{href:e}),Dt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),Dt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),Dt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),Dt("script",{children:Xu})]})}f();f();import{useCallback as $e,useEffect as yt,useRef as Ao,useState as qe}from"react";f();var In={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},Bt={...In};function Et(e){typeof window>"u"||window.openai||(Bt={...In,toolOutput:e??null},window.openai={...Bt,requestDisplayMode:async({mode:t})=>(nt("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{nt("widgetState",t)}},window.dispatchEvent(new Mt({globals:Bt})))}function nt(e,t){typeof window>"u"||!window.openai||(Bt[e]=t,window.openai[e]=t,window.dispatchEvent(new Mt({globals:{[e]:t}})))}function Pa(){return{...Bt}}function _t(e){nt("toolOutput",e)}function Ot(e){nt("displayMode",e)}function Nt(e){nt("theme",e)}import{Fragment as Ro,jsx as B,jsxs as Y}from"react/jsx-runtime";var Aa=150;function Sn({className:e}){return Y("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[B("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),B("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Yu({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B("path",{d:"M18 6L6 18M6 6l12 12"})})}function Zu({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function ed({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),B("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function td({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function ad({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),B("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function od({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function rd({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),B("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var nd=`
1
+ import{a as To,b as ju,c as zu}from"../chunk-R6LESDWJ.js";import{b as Mt,c as Ct,d as nn,e as sn}from"../chunk-PYLRF5BB.js";import{a as ln,b as un,c as dn,d as cn,e as fn,f as ba,g as pn,h as mn,i as gn,j as hn,k as vo,l as wn,m as Lt,n as It,o as ka,p as St,u as Ft}from"../chunk-YP6YTC7R.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var Ta="text/html+skybridge",va="text/html;profile=mcp-app",xn=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Cn(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function Ln(e){let t=e.widgetCSP?{connectDomains:e.widgetCSP.connect_domains,resourceDomains:e.widgetCSP.resource_domains,frameDomains:e.widgetCSP.frame_domains,redirectDomains:e.widgetCSP.redirect_domains}:void 0;return{ui:{...t&&{csp:t},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function Po(e){return{...e.openaiTemplateUri&&{"openai/outputTemplate":e.openaiTemplateUri},"openai/toolInvocation/invoking":e.invoking,"openai/toolInvocation/invoked":e.invoked,"openai/widgetAccessible":!0,"openai/resultCanProduceWidget":!0,...e.mcpTemplateUri&&{ui:{resourceUri:e.mcpTemplateUri,...e.autoHeight&&{autoHeight:!0}}},...e.mcpTemplateUri&&{"ui/resourceUri":e.mcpTemplateUri}}}function In(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:n,widgetDomain:s,prefersBorder:i=!0,autoHeight:l=!0}=e,u=e.widgetCSP??{connect_domains:[r],resource_domains:[r]};if(process.env.NODE_ENV==="development")try{let{hostname:x}=new URL(r);(x==="localhost"||x==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${x}:*`,`wss://${x}:*`],resource_domains:[...u.resource_domains||[],`http://${x}:*`]})}catch{}let d=`ui://widgets/apps-sdk/${t}.html`,c=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=xn(r,n)),p),g=o;async function I(x){let S=await m();x.registerResource(`${t}-openai-widget`,d,{title:a,description:g,mimeType:Ta,_meta:{"openai/widgetDescription":g,"openai/widgetPrefersBorder":i}},async C=>({contents:[{uri:C.href,mimeType:Ta,text:S,_meta:Cn({description:g,prefersBorder:i,widgetDomain:s,widgetCSP:u})}]})),x.registerResource(`${t}-mcp-widget`,c,{title:a,description:g,mimeType:va,_meta:{ui:{prefersBorder:i}}},async C=>({contents:[{uri:C.href,mimeType:va,text:S,_meta:Ln({description:g,prefersBorder:i,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:d,mcpUri:c,autoHeight:l,register:I}}f();f();f();f();f();var Ao="waniwani/suggestions";var Vu="waniwani/client";function Sn(e){if(typeof e=="object"&&e!==null)return e[Vu]}function $u(e,t){let{resource:a,description:o,inputSchema:r,annotations:n,autoInjectResultText:s=!0}=e,i=e.id??a?.id,l=e.title??a?.title;if(!i)throw new Error("createTool: `id` is required when no resource is provided");if(!l)throw new Error("createTool: `title` is required when no resource is provided");let u=a?Po({openaiTemplateUri:a.openaiUri,mcpTemplateUri:a.mcpUri,invoking:e.invoking??"Loading...",invoked:e.invoked??"Loaded",autoHeight:a.autoHeight}):void 0;return{id:i,title:l,description:o,async register(d){d.registerTool(i,{title:l,description:o,inputSchema:r,annotations:n,...u&&{_meta:u}},(async(c,p)=>{let m=p,g=m._meta??{},I=Sn(m),x=await t(c,{extra:{_meta:g},waniwani:I});return a&&x.data?{content:[{type:"text",text:x.text}],structuredContent:x.data,_meta:{...u,...g,...s===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:x.text}],...x.data?{structuredContent:x.data}:{},...s===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function Xu(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as Yu,jsx as Dt,jsxs as Zu}from"react/jsx-runtime";function Ku(){let e=window.innerBaseUrl,t=window.__wwPassthroughOrigins??[],a=document.documentElement;new MutationObserver(l=>{l.forEach(u=>{if(u.type==="attributes"&&u.target===a){let d=u.attributeName;d&&d!=="suppresshydrationwarning"&&d!=="lang"&&d!=="class"&&d!=="style"&&a.removeAttribute(d)}})}).observe(a,{attributes:!0,attributeOldValue:!0});let r=history.replaceState.bind(history);history.replaceState=(l,u,d)=>{try{let c=new URL(String(d??""),window.location.href);r(null,u,c.pathname+c.search+c.hash)}catch{}};let n=history.pushState.bind(history);history.pushState=(l,u,d)=>{try{let c=new URL(String(d??""),window.location.href);n(null,u,c.pathname+c.search+c.hash)}catch{}};let s=new URL(e).origin,i=window.self!==window.top;if(window.addEventListener("click",l=>{let u=l?.target?.closest("a");if(!u||!u.href)return;let d=new URL(u.href,window.location.href);if(d.origin!==window.location.origin&&d.origin!==s)try{window.openai&&(window.openai?.openExternal({href:u.href}),l.preventDefault())}catch{console.warn("openExternal failed, likely not in OpenAI client")}},!0),i&&window.location.origin!==s){let l=window.fetch;window.fetch=((p,m)=>{let g=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),I;if(typeof p=="string"||p instanceof URL?I=new URL(p,window.location.href):I=new URL(p.url,window.location.href),I.origin===s)return typeof p=="string"||p instanceof URL?p=I.toString():p=new Request(I.toString(),p),l.call(window,p,{...m,mode:"cors"});if(t.indexOf(I.origin)!==-1)return l.call(window,p,m);if(g&&I.origin===window.location.origin){let x=new URL(e);return x.pathname=I.pathname,x.search=I.search,x.hash=I.hash,I=x,p=I.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=s.replace(/^http/,"ws"),d=window.WebSocket,c=((p,m)=>{let g=new URL(String(p),window.location.href);if(g.origin===window.location.origin||g.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=g.pathname,I.search=g.search,I.hash=g.hash,new d(I.toString(),m)}return new d(p,m)});c.prototype=d.prototype,Object.assign(c,{CONNECTING:d.CONNECTING,OPEN:d.OPEN,CLOSING:d.CLOSING,CLOSED:d.CLOSED}),window.WebSocket=c}}var Qu=`(${Ku.toString()})()`;function Ju({baseUrl:e,passthroughOrigins:t}){return Zu(Yu,{children:[Dt("base",{href:e}),Dt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),Dt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),Dt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),Dt("script",{children:Qu})]})}f();f();import{useCallback as $e,useEffect as yt,useRef as Ro,useState as qe}from"react";f();var yn={theme:"dark",userAgent:{device:{type:"desktop"},capabilities:{hover:!0,touch:!1}},locale:"en",maxHeight:800,displayMode:"inline",safeArea:{insets:{top:0,bottom:0,left:0,right:0}},toolInput:{},toolOutput:null,toolResponseMetadata:null,widgetState:null},Bt={...yn};function Et(e){typeof window>"u"||window.openai||(Bt={...yn,toolOutput:e??null},window.openai={...Bt,requestDisplayMode:async({mode:t})=>(nt("displayMode",t),{mode:t}),callTool:async(t,a)=>(console.log(`[DevMode] callTool: ${t}`,a),{result:JSON.stringify({mock:!0,tool:t,args:a})}),sendFollowUpMessage:async({prompt:t})=>{console.log(`[DevMode] sendFollowUpMessage: ${t}`)},openExternal:({href:t})=>{console.log(`[DevMode] openExternal: ${t}`),window.open(t,"_blank")},setWidgetState:async t=>{nt("widgetState",t)}},window.dispatchEvent(new Mt({globals:Bt})))}function nt(e,t){typeof window>"u"||!window.openai||(Bt[e]=t,window.openai[e]=t,window.dispatchEvent(new Mt({globals:{[e]:t}})))}function Pa(){return{...Bt}}function _t(e){nt("toolOutput",e)}function Ot(e){nt("displayMode",e)}function Nt(e){nt("theme",e)}import{Fragment as Mo,jsx as B,jsxs as Y}from"react/jsx-runtime";var Aa=150;function bn({className:e}){return Y("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[B("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),B("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function ed({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B("path",{d:"M18 6L6 18M6 6l12 12"})})}function td({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function ad({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),B("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function od({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("path",{d:"M2 5.5V3.5C2 2.95 2.45 2.5 3 2.5H5.5M10.5 2.5H13C13.55 2.5 14 2.95 14 3.5V5.5M14 10.5V12.5C14 13.05 13.55 13.5 13 13.5H10.5M5.5 13.5H3C2.45 13.5 2 13.05 2 12.5V10.5",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function rd({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),B("path",{d:"M8 2v1.5M8 12.5V14M2 8h1.5M12.5 8H14M4.11 4.11l1.06 1.06M10.83 10.83l1.06 1.06M4.11 11.89l1.06-1.06M10.83 5.17l1.06-1.06",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})]})}function nd({className:e}){return B("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:B("path",{d:"M13.5 9.5a5.5 5.5 0 01-7-7 5.5 5.5 0 107 7z",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})}function sd({className:e}){return Y("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[B("path",{d:"M2.5 8a5.5 5.5 0 019.37-3.9M13.5 8a5.5 5.5 0 01-9.37 3.9",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"}),B("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var id=`
2
2
  @keyframes devPanelSlideIn {
3
3
  0% {
4
4
  opacity: 0;
@@ -46,28 +46,28 @@ import{a as ko,b as Wu,c as Gu}from"../chunk-R6LESDWJ.js";import{b as Mt,c as Ct
46
46
  .dev-json-editor::-webkit-scrollbar-thumb:hover {
47
47
  background: rgba(255, 255, 255, 0.15);
48
48
  }
49
- `;function bn({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=qe(!1),[n,s]=qe(!1);return yt(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){r(!0);return}if(t&&t.length>0){let l=window.location.pathname,u=t.some(c=>l===c||l.startsWith(`${c}/`));s(u),u&&Et(e)}else Et(e),s(!0);r(!0)},[e,t]),o?n?Y(Ro,{children:[B(sd,{children:a}),B(id,{defaultProps:e})]}):B(Ro,{children:a}):null}function sd({children:e}){return B("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:B("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function yn({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return Y("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[B("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${o*100}% + ${o*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(r=>Y("button",{type:"button",onClick:()=>a(r.value),className:`
49
+ `;function Tn({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=qe(!1),[n,s]=qe(!1);return yt(()=>{if(new URLSearchParams(window.location.search).get("platform")==="mcp-apps"){r(!0);return}if(t&&t.length>0){let l=window.location.pathname,u=t.some(d=>l===d||l.startsWith(`${d}/`));s(u),u&&Et(e)}else Et(e),s(!0);r(!0)},[e,t]),o?n?Y(Mo,{children:[B(ld,{children:a}),B(ud,{defaultProps:e})]}):B(Mo,{children:a}):null}function ld({children:e}){return B("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:B("div",{className:"relative w-full max-w-md overflow-hidden rounded-2xl sm:rounded-3xl border border-[#414141]",style:{boxShadow:"0px 0px 0px 1px #414141, 0px 4px 14px rgba(0,0,0,0.24)"},children:e})})}function kn({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return Y("div",{className:"relative flex p-0.5 rounded-lg",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:[B("div",{className:"absolute top-0.5 bottom-0.5 rounded-md transition-transform duration-150 ease-out",style:{width:`calc(${100/e.length}% - 2px)`,left:"2px",transform:`translateX(calc(${o*100}% + ${o*2}px))`,background:"rgba(255, 255, 255, 0.1)"}}),e.map(r=>Y("button",{type:"button",onClick:()=>a(r.value),className:`
50
50
  relative z-10 flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5
51
51
  text-xs font-medium rounded-md transition-colors duration-150
52
52
  ${t===r.value?"text-white":"text-gray-400 hover:text-gray-300"}
53
- `,children:[r.icon,B("span",{className:"capitalize",children:r.label})]},r.value))]})}function id({defaultProps:e}){let[t,a]=qe(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=qe(!1),[n,s]=qe(t),[i,l]=qe("inline"),[u,c]=qe("dark"),[d,p]=qe(!1),[m,g]=qe(()=>JSON.stringify(e??{},null,2)),[I,C]=qe(null),S=Ao(null),x=Ao(null),L=Ao(null);yt(()=>{let T=Pa();l(T.displayMode),c(T.theme)},[]),yt(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?Aa:0,left:0,right:0}},window.dispatchEvent(new Mt({globals:{safeArea:window.openai.safeArea}})))},[d]),yt(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let y=$e(()=>{s(!0),requestAnimationFrame(()=>{a(!0)})},[]),k=$e(()=>{r(!0),a(!1),setTimeout(()=>{s(!1),r(!1)},150)},[]),P=$e(()=>{t?k():y()},[t,y,k]);yt(()=>{let T=O=>{(O.metaKey||O.ctrlKey)&&O.shiftKey&&O.key==="d"&&(O.preventDefault(),P()),O.key==="Escape"&&t&&k()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,P,k]),yt(()=>{if(!t)return;let T=O=>{L.current&&!L.current.contains(O.target)&&k()};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t,k]);let F=$e(T=>{l(T),Ot(T)},[]),R=$e(T=>{c(T),Nt(T)},[]),_=$e(T=>{try{let O=JSON.parse(T);C(null),_t(O)}catch{C("Invalid JSON")}},[]),M=$e(T=>{g(T),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{_(T)},500)},[_]),E=$e(()=>{S.current&&clearTimeout(S.current),_(m)},[_,m]),v=$e(()=>{let T=JSON.stringify(e??{},null,2);g(T),C(null),_t(e??{}),l("inline"),Ot("inline"),c("dark"),Nt("dark")},[e]),D=[{value:"inline",label:"inline",icon:B(Zu,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:B(ed,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:B(td,{className:"w-3.5 h-3.5"})}],H=[{value:"light",label:"light",icon:B(ad,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:B(od,{className:"w-3.5 h-3.5"})}];return Y(Ro,{children:[B("style",{dangerouslySetInnerHTML:{__html:nd}}),Y("div",{ref:L,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[Y("button",{type:"button",onClick:P,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
53
+ `,children:[r.icon,B("span",{className:"capitalize",children:r.label})]},r.value))]})}function ud({defaultProps:e}){let[t,a]=qe(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=qe(!1),[n,s]=qe(t),[i,l]=qe("inline"),[u,d]=qe("dark"),[c,p]=qe(!1),[m,g]=qe(()=>JSON.stringify(e??{},null,2)),[I,x]=qe(null),S=Ro(null),C=Ro(null),L=Ro(null);yt(()=>{let T=Pa();l(T.displayMode),d(T.theme)},[]),yt(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:c?Aa:0,left:0,right:0}},window.dispatchEvent(new Mt({globals:{safeArea:window.openai.safeArea}})))},[c]),yt(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let y=$e(()=>{s(!0),requestAnimationFrame(()=>{a(!0)})},[]),b=$e(()=>{r(!0),a(!1),setTimeout(()=>{s(!1),r(!1)},150)},[]),P=$e(()=>{t?b():y()},[t,y,b]);yt(()=>{let T=O=>{(O.metaKey||O.ctrlKey)&&O.shiftKey&&O.key==="d"&&(O.preventDefault(),P()),O.key==="Escape"&&t&&b()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[t,P,b]),yt(()=>{if(!t)return;let T=O=>{L.current&&!L.current.contains(O.target)&&b()};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[t,b]);let M=$e(T=>{l(T),Ot(T)},[]),A=$e(T=>{d(T),Nt(T)},[]),_=$e(T=>{try{let O=JSON.parse(T);x(null),_t(O)}catch{x("Invalid JSON")}},[]),F=$e(T=>{g(T),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{_(T)},500)},[_]),E=$e(()=>{S.current&&clearTimeout(S.current),_(m)},[_,m]),v=$e(()=>{let T=JSON.stringify(e??{},null,2);g(T),x(null),_t(e??{}),l("inline"),Ot("inline"),d("dark"),Nt("dark")},[e]),D=[{value:"inline",label:"inline",icon:B(td,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:B(ad,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:B(od,{className:"w-3.5 h-3.5"})}],H=[{value:"light",label:"light",icon:B(rd,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:B(nd,{className:"w-3.5 h-3.5"})}];return Y(Mo,{children:[B("style",{dangerouslySetInnerHTML:{__html:id}}),Y("div",{ref:L,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[Y("button",{type:"button",onClick:P,className:"group relative flex items-center justify-center w-11 h-11 rounded-xl transition-all duration-200 ease-out hover:scale-105 active:scale-95",style:{background:"rgba(14, 14, 16, 0.95)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:`
54
54
  0 4px 12px rgba(0, 0, 0, 0.4),
55
55
  0 0 0 1px rgba(255, 255, 255, 0.05),
56
56
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
57
- `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[B(Sn,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),B("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),n&&Y("div",{ref:x,className:`absolute bottom-14 right-0 w-80 ${t&&!o?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
57
+ `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[B(bn,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),B("div",{className:"absolute inset-0 rounded-xl opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none",style:{background:"radial-gradient(circle at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%)"}})]}),n&&Y("div",{ref:C,className:`absolute bottom-14 right-0 w-80 ${t&&!o?"dev-panel-enter":"dev-panel-exit"}`,style:{maxHeight:"calc(100vh - 120px)",background:"rgba(14, 14, 16, 0.92)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"16px",boxShadow:`
58
58
  0 25px 50px -12px rgba(0, 0, 0, 0.6),
59
59
  0 0 0 1px rgba(255, 255, 255, 0.05),
60
60
  inset 0 1px 0 rgba(255, 255, 255, 0.04)
61
- `},children:[Y("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[Y("div",{className:"flex items-center gap-2",children:[B(Sn,{className:"w-4 h-4 text-gray-400"}),B("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),Y("div",{className:"flex items-center gap-2",children:[B("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),B("button",{type:"button",onClick:k,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:B(Yu,{className:"w-4 h-4"})})]})]}),Y("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[Y("div",{children:[B("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),B(yn,{options:D,value:i,onChange:F})]}),Y("div",{children:[B("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),B(yn,{options:H,value:u,onChange:R})]}),Y("div",{children:[B("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),Y("button",{type:"button",onClick:()=>p(!d),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${d?"text-emerald-400":"text-gray-400"}`,style:{background:d?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:d?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[B("span",{children:"Mock ChatGPT Input Bar"}),B("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${d?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:d?"ON":"OFF"})]}),d&&Y("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",Aa,"px"]})]}),Y("div",{children:[B("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),B("textarea",{value:m,onChange:T=>M(T.target.value),onBlur:E,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:T=>{I||(T.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:T=>{I||(T.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&Y("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[B("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:B("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),Y("button",{type:"button",onClick:v,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:T=>{T.currentTarget.style.background="rgba(255, 255, 255, 0.08)",T.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:T=>{T.currentTarget.style.background="rgba(255, 255, 255, 0.04)",T.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[B(rd,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&Y("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${Aa}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[Y("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[B("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:B("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:B("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),B("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),B("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:B("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:B("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),Y("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",Aa,"px"]})]})]})}f();f();import{useCallback as ud,useContext as dd,useLayoutEffect as cd,useMemo as fd,useRef as kn}from"react";f();import{createContext as ld}from"react";var Ut=ld(null);import{Fragment as Tn,jsx as Mo}from"react/jsx-runtime";var pd="waniwani:send-follow-up:advanced:",md=1e4;function vn(e){return`${pd}${e??"default"}`}function gd(e){try{let t=globalThis.localStorage?.getItem(vn(e));if(!t)return null;let a=JSON.parse(t);return typeof a?.at!="number"||typeof a?.byMountId!="string"?null:a}catch{return null}}function hd(e,t){try{globalThis.localStorage?.setItem(vn(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function Fo(){return typeof window>"u"?!1:typeof window.openai=="object"}function wd(){return Fo()?window.openai:null}function xd(){return cd(()=>{let e=document.documentElement,t=document.body,a=e.getAttribute("style"),o=t.getAttribute("style"),r="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",r),t.setAttribute("style",r),()=>{a===null?e.removeAttribute("style"):e.setAttribute("style",a),o===null?t.removeAttribute("style"):t.setAttribute("style",o)}},[]),null}function Pn(e){let t=dd(Ut),a=kn(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=wd()?.toolResponseMetadata??null,n=o??r,s=n&&typeof n.viewUUID=="string"?n.viewUUID:void 0,i=kn("");i.current===""&&(i.current=crypto.randomUUID());let l=ud((c,d)=>{Fo()&&hd(s,i.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[s]),u=fd(()=>{let c=i.current;return function({children:p}){if(!Fo())return Mo(Tn,{children:p});let m=gd(s);return m&&m.byMountId!==c&&Date.now()-m.at<md?Mo(xd,{}):Mo(Tn,{children:p})}},[s]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as Id}from"react";f();import Ht,{useCallback as Rn,useContext as Cd,useEffect as Mn,useState as Do,useSyncExternalStore as Ld}from"react";f();async function An(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-VRJPAPFR.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-Z5ICFYSR.js");return new a}}function Fn({children:e,loading:t=null,onError:a}){let[o,r]=Do(null),[n,s]=Do(null),[i,l]=Do(!0);return Mn(()=>{let u=!0,c=null;async function d(){try{let p=await An();await p.connect(),u?(c=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),s(p instanceof Error?p:new Error(String(p))),l(!1))}}return d(),()=>{u=!1,c?.close()}},[]),Mn(()=>{if(!o)return;let u=c=>{document.documentElement.classList.toggle("dark",c==="dark"),document.documentElement.style.colorScheme=c==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),n&&a?Ht.createElement(Ht.Fragment,null,a(n)):i||!o?Ht.createElement(Ht.Fragment,null,t):Ht.createElement(Ut.Provider,{value:o},e)}function $(e){let t=Cd(Ut);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=Rn(n=>e==="toolOutput"?t.onToolResult(()=>n()):e==="theme"?t.onThemeChange(()=>n()):e==="displayMode"?t.onDisplayModeChange(()=>n()):e==="safeArea"?t.onSafeAreaChange(()=>n()):e==="maxHeight"?t.onMaxHeightChange(()=>n()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>n()):e==="widgetState"?t.onWidgetStateChange(()=>n()):()=>{},[t,e]),o=Rn(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=Ld(a,o,o);return e?r:t}function Dn(){let e=$();return Id((t,a)=>e.callTool(t,a),[e])}f();function Bn(){return $("displayMode")}f();f();function Ra(){return $("toolOutput")}function En(){return{data:Ra()}}f();import{useSyncExternalStore as Sd}from"react";function _n(){return Sd(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function On(){return $("locale")}f();function Nn(){return $("maxHeight")}f();import{useCallback as yd}from"react";function Un(){let e=$();return yd(t=>e.openExternal(t),[e])}f();import{useCallback as bd}from"react";function Hn(){let e=$();return bd(t=>e.requestDisplayMode(t),[e])}f();function qn(){return $("safeArea")}f();import{useCallback as kd}from"react";function Wn(){let e=$();return kd((t,a)=>{(async()=>{Ct(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function Gn(){return $("theme")}f();function jn(){return $("toolResponseMetadata")}f();import{useCallback as Td}from"react";function zn(){let e=$();return Td(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as vd,useEffect as Pd,useState as Ad}from"react";function Vn(e){let t=$("widgetState"),[a,o]=Ad(()=>t??(typeof e=="function"?e():e??null));Pd(()=>{o(t)},[t]);let r=vd(n=>{o(s=>{let i=typeof n=="function"?n(s):n;return ko()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as st,jsxs as $n}from"react/jsx-runtime";var Rd=()=>$n("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[$n("div",{className:"flex gap-2",children:[st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),st("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),st("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:st("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),st("style",{children:`
61
+ `},children:[Y("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[Y("div",{className:"flex items-center gap-2",children:[B(bn,{className:"w-4 h-4 text-gray-400"}),B("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),Y("div",{className:"flex items-center gap-2",children:[B("span",{className:"text-[10px] font-medium text-gray-500 px-1.5 py-0.5 rounded",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},children:typeof navigator<"u"&&navigator.platform?.includes("Mac")?"\u2318\u21E7D":"Ctrl+Shift+D"}),B("button",{type:"button",onClick:b,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:B(ed,{className:"w-4 h-4"})})]})]}),Y("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[Y("div",{children:[B("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),B(kn,{options:D,value:i,onChange:M})]}),Y("div",{children:[B("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),B(kn,{options:H,value:u,onChange:A})]}),Y("div",{children:[B("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),Y("button",{type:"button",onClick:()=>p(!c),className:`w-full flex items-center justify-between px-3 py-2.5 rounded-lg text-xs font-medium transition-all duration-150 ${c?"text-emerald-400":"text-gray-400"}`,style:{background:c?"rgba(34, 197, 94, 0.1)":"rgba(255, 255, 255, 0.04)",border:c?"1px solid rgba(34, 197, 94, 0.3)":"1px solid rgba(255, 255, 255, 0.06)"},children:[B("span",{children:"Mock ChatGPT Input Bar"}),B("span",{className:`px-2 py-0.5 rounded text-[10px] font-semibold ${c?"bg-emerald-500/20 text-emerald-400":"bg-gray-500/20 text-gray-500"}`,children:c?"ON":"OFF"})]}),c&&Y("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",Aa,"px"]})]}),Y("div",{children:[B("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),B("textarea",{value:m,onChange:T=>F(T.target.value),onBlur:E,className:"dev-json-editor w-full min-h-[160px] text-xs text-gray-200 p-3 rounded-lg resize-none focus:outline-none transition-colors",style:{background:"rgba(0, 0, 0, 0.3)",border:I?"1px solid rgba(239, 68, 68, 0.5)":"1px solid rgba(255, 255, 255, 0.06)",fontFamily:"'JetBrains Mono', 'SF Mono', 'Fira Code', monospace",lineHeight:1.6},onFocus:T=>{I||(T.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:T=>{I||(T.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&Y("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[B("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:B("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),Y("button",{type:"button",onClick:v,className:"w-full flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium text-gray-400 transition-all duration-150 hover:text-gray-200",style:{background:"rgba(255, 255, 255, 0.04)",border:"1px solid rgba(255, 255, 255, 0.06)"},onMouseEnter:T=>{T.currentTarget.style.background="rgba(255, 255, 255, 0.08)",T.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:T=>{T.currentTarget.style.background="rgba(255, 255, 255, 0.04)",T.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[B(sd,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),c&&Y("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${Aa}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[Y("div",{className:"w-full max-w-2xl mx-4 px-4 py-3 rounded-2xl bg-[#2f2f2f] border border-[#424242] flex items-center gap-3",children:[B("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:B("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:B("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),B("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),B("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:B("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:B("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11a7 7 0 01-7 7m0 0a7 7 0 01-7-7m7 7v4m0 0H8m4 0h4m-4-8a3 3 0 01-3-3V5a3 3 0 116 0v6a3 3 0 01-3 3z"})})})]}),Y("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",Aa,"px"]})]})]})}f();f();import{useCallback as cd,useContext as fd,useLayoutEffect as pd,useMemo as md,useRef as vn}from"react";f();import{createContext as dd}from"react";var Ut=dd(null);import{Fragment as Pn,jsx as Fo}from"react/jsx-runtime";var gd="waniwani:send-follow-up:advanced:",hd=1e4;function An(e){return`${gd}${e??"default"}`}function wd(e){try{let t=globalThis.localStorage?.getItem(An(e));if(!t)return null;let a=JSON.parse(t);return typeof a?.at!="number"||typeof a?.byMountId!="string"?null:a}catch{return null}}function xd(e,t){try{globalThis.localStorage?.setItem(An(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function Do(){return typeof window>"u"?!1:typeof window.openai=="object"}function Cd(){return Do()?window.openai:null}function Ld(){return pd(()=>{let e=document.documentElement,t=document.body,a=e.getAttribute("style"),o=t.getAttribute("style"),r="margin:0!important;padding:0!important;border:0!important;background:transparent!important;background-color:transparent!important;height:0!important;min-height:0!important;max-height:0!important;overflow:hidden!important;";return e.setAttribute("style",r),t.setAttribute("style",r),()=>{a===null?e.removeAttribute("style"):e.setAttribute("style",a),o===null?t.removeAttribute("style"):t.setAttribute("style",o)}},[]),null}function Rn(e){let t=fd(Ut),a=vn(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=Cd()?.toolResponseMetadata??null,n=o??r,s=n&&typeof n.viewUUID=="string"?n.viewUUID:void 0,i=vn("");i.current===""&&(i.current=crypto.randomUUID());let l=cd((d,c)=>{Do()&&xd(s,i.current);try{Promise.resolve(a.current(d)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[s]),u=md(()=>{let d=i.current;return function({children:p}){if(!Do())return Fo(Pn,{children:p});let m=wd(s);return m&&m.byMountId!==d&&Date.now()-m.at<hd?Fo(Ld,{}):Fo(Pn,{children:p})}},[s]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as yd}from"react";f();import Ht,{useCallback as Fn,useContext as Id,useEffect as Dn,useState as Bo,useSyncExternalStore as Sd}from"react";f();async function Mn(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-VRJPAPFR.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-Z5ICFYSR.js");return new a}}function Bn({children:e,loading:t=null,onError:a}){let[o,r]=Bo(null),[n,s]=Bo(null),[i,l]=Bo(!0);return Dn(()=>{let u=!0,d=null;async function c(){try{let p=await Mn();await p.connect(),u?(d=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),s(p instanceof Error?p:new Error(String(p))),l(!1))}}return c(),()=>{u=!1,d?.close()}},[]),Dn(()=>{if(!o)return;let u=d=>{document.documentElement.classList.toggle("dark",d==="dark"),document.documentElement.style.colorScheme=d==="dark"?"dark":"auto"};return u(o.getTheme()),o.onThemeChange(u)},[o]),n&&a?Ht.createElement(Ht.Fragment,null,a(n)):i||!o?Ht.createElement(Ht.Fragment,null,t):Ht.createElement(Ut.Provider,{value:o},e)}function $(e){let t=Id(Ut);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=Fn(n=>e==="toolOutput"?t.onToolResult(()=>n()):e==="theme"?t.onThemeChange(()=>n()):e==="displayMode"?t.onDisplayModeChange(()=>n()):e==="safeArea"?t.onSafeAreaChange(()=>n()):e==="maxHeight"?t.onMaxHeightChange(()=>n()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>n()):e==="widgetState"?t.onWidgetStateChange(()=>n()):()=>{},[t,e]),o=Fn(()=>e==="toolOutput"?t.getToolOutput():e==="theme"?t.getTheme():e==="displayMode"?t.getDisplayMode():e==="locale"?t.getLocale():e==="safeArea"?t.getSafeArea():e==="maxHeight"?t.getMaxHeight():e==="toolResponseMetadata"?t.getToolResponseMetadata():e==="widgetState"?t.getWidgetState():null,[t,e]),r=Sd(a,o,o);return e?r:t}function En(){let e=$();return yd((t,a)=>e.callTool(t,a),[e])}f();function _n(){return $("displayMode")}f();f();function Ra(){return $("toolOutput")}function On(){return{data:Ra()}}f();import{useSyncExternalStore as bd}from"react";function Nn(){return bd(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function Un(){return $("locale")}f();function Hn(){return $("maxHeight")}f();import{useCallback as kd}from"react";function qn(){let e=$();return kd(t=>e.openExternal(t),[e])}f();import{useCallback as Td}from"react";function Wn(){let e=$();return Td(t=>e.requestDisplayMode(t),[e])}f();function Gn(){return $("safeArea")}f();import{useCallback as vd}from"react";function jn(){let e=$();return vd((t,a)=>{(async()=>{Ct(a?.modelContext)&&await Promise.resolve(e.updateModelContext(a.modelContext)),await Promise.resolve(e.sendFollowUp(t))})().catch(o=>{console.error("Failed to send follow-up message:",o)})},[e])}f();function zn(){return $("theme")}f();function Vn(){return $("toolResponseMetadata")}f();import{useCallback as Pd}from"react";function $n(){let e=$();return Pd(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as Ad,useEffect as Rd,useState as Md}from"react";function Xn(e){let t=$("widgetState"),[a,o]=Md(()=>t??(typeof e=="function"?e():e??null));Rd(()=>{o(t)},[t]);let r=Ad(n=>{o(s=>{let i=typeof n=="function"?n(s):n;return To()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as st,jsxs as Kn}from"react/jsx-runtime";var Fd=()=>Kn("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Kn("div",{className:"flex gap-2",children:[st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),st("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),st("p",{className:"text-sm font-medium text-transparent bg-clip-text bg-gradient-to-r from-slate-400 via-slate-200 to-slate-400 bg-[length:200%_100%] animate-[shimmer_1.5s_ease-in-out_infinite]",children:"Loading widget..."}),st("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:st("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),st("style",{children:`
62
62
  @keyframes shimmer {
63
63
  0% { background-position: 200% 0; }
64
64
  100% { background-position: -200% 0; }
65
65
  }
66
- `})]});f();f();f();var Md={debug:0,warn:1,error:2,none:3};function Fd(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in Md?e:process.env.WANIWANI_DEBUG?"debug":"none"}function We(e,t){return t??Fd()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function Xn(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function Kn(){return function(t){return t.headers.set("Access-Control-Allow-Origin","*"),t.headers.set("Access-Control-Allow-Methods","GET, POST, PATCH, OPTIONS"),t.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization, X-Session-Id, X-Client-User-Agent"),t.headers.set("Access-Control-Expose-Headers","X-Session-Id"),t}}function Qn(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Pe=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Jn(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?Dd(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,n=t.get("x-vercel-ip-country-region")??void 0,s=t.get("x-vercel-ip-latitude")??t.get("cf-iplatitude")??void 0,i=t.get("x-vercel-ip-longitude")??t.get("cf-iplongitude")??void 0,l=t.get("x-vercel-ip-timezone")??t.get("cf-iptimezone")??void 0,u=t.get("x-real-ip")??t.get("x-forwarded-for")?.split(",")[0]?.trim()??t.get("cf-connecting-ip")??void 0;return{city:o,country:r,countryRegion:n,latitude:s,longitude:i,timezone:l,ip:u}}function Dd(e){try{return decodeURIComponent(e)}catch{return e}}f();function Yn(e,t){if(!Ct(t))return e;let a=rn(t);return a?[e,a].filter(Boolean).join(`
66
+ `})]});f();f();f();var Dd={debug:0,warn:1,error:2,none:3};function Bd(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in Dd?e:process.env.WANIWANI_DEBUG?"debug":"none"}function We(e,t){return t??Bd()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function Qn(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function Jn(){return function(t){return t.headers.set("Access-Control-Allow-Origin","*"),t.headers.set("Access-Control-Allow-Methods","GET, POST, PATCH, OPTIONS"),t.headers.set("Access-Control-Allow-Headers","Content-Type, Authorization, X-Session-Id, X-Client-User-Agent"),t.headers.set("Access-Control-Expose-Headers","X-Session-Id"),t}}function Yn(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Pe=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Zn(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?Ed(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,n=t.get("x-vercel-ip-country-region")??void 0,s=t.get("x-vercel-ip-latitude")??t.get("cf-iplatitude")??void 0,i=t.get("x-vercel-ip-longitude")??t.get("cf-iplongitude")??void 0,l=t.get("x-vercel-ip-timezone")??t.get("cf-iptimezone")??void 0,u=t.get("x-real-ip")??t.get("x-forwarded-for")?.split(",")[0]?.trim()??t.get("cf-connecting-ip")??void 0;return{city:o,country:r,countryRegion:n,latitude:s,longitude:i,timezone:l,ip:u}}function Ed(e){try{return decodeURIComponent(e)}catch{return e}}f();function es(e,t){if(!Ct(t))return e;let a=sn(t);return a?[e,a].filter(Boolean).join(`
67
67
 
68
- `):e}function Zn(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:c}=e,d=We("chat",u);return async function(m){d("\u2192 POST",m.url);try{let g=await m.json(),I=g.messages??[],C=g.sessionId,S=g.modelContext,x=r,L=typeof g.extra=="object"&&g.extra!==null&&!Array.isArray(g.extra)?g.extra:void 0,y=g.visitorContext??null,k=Jn(m),P={geo:k,client:y};if(d("body parsed \u2014 messages:",I.length,"sessionId:",C??"(none)","geo:",JSON.stringify(k)),s){d("running beforeRequest hook");try{let D=await s({messages:I,sessionId:C,modelContext:S,request:m,visitor:P});D&&(D.messages&&(I=D.messages),D.systemPrompt!==void 0&&(x=D.systemPrompt),D.sessionId!==void 0&&(C=D.sessionId),D.modelContext!==void 0&&(S=D.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",C??"(none)")}catch(D){console.error("[waniwani:chat] beforeRequest hook error:",D);let H=D instanceof Pe?D.status:400,T=D instanceof Error?D.message:"Request rejected";return d("\u2190 returning",H,"from hook error"),Response.json({error:T},{status:H})}}let F=i??(await l()).mcpServerUrl;d("mcpServerUrl:",F),x=Yn(x,S);let R=`${a}/api/mcp/chat`;d("forwarding to",R);let _=m.headers.get("user-agent"),M=await fetch(R,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:I,mcpServerUrl:F,sessionId:C,source:o,systemPrompt:x,maxSteps:n,visitor:P,webSearch:c,...L&&{extra:L}}),signal:m.signal});if(d("upstream response status:",M.status),!M.ok){let D=await M.text().catch(()=>"");return d("\u2190 returning",M.status,"upstream error:",D),new Response(D,{status:M.status,headers:{"Content-Type":M.headers.get("Content-Type")??"application/json"}})}let E=new Headers({"Content-Type":M.headers.get("Content-Type")??"text/event-stream"}),v=M.headers.get("x-session-id");return v&&E.set("x-session-id",v),d("\u2190 streaming response",M.status,"body null?",M.body===null),new Response(M.body,{status:M.status,headers:E})}catch(g){console.error("[waniwani:chat] handler error:",g);let I=g instanceof Error?g.message:"Unknown error occurred",C=g instanceof Pe?g.status:500;return d("\u2190 returning",C,"from caught error"),Response.json({error:I},{status:C})}}}f();function es(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=We("resource",o);return async function(s){r("\u2192 GET",s.toString());try{let i=s.searchParams.get("uri");if(r("uri:",i??"(missing)"),!i)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let l=t??(await a()).mcpServerUrl;r("mcpServerUrl:",l);let u,c;try{[{createMCPClient:u},{StreamableHTTPClientTransport:c}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",l);let d=await u({transport:new c(new URL(l))});try{r("reading resource:",i);let p=await d.readResource({uri:i});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let g;return"text"in m&&typeof m.text=="string"?g=m.text:"blob"in m&&typeof m.blob=="string"&&(g=atob(m.blob)),g?(r("\u2190 200 HTML length:",g.length),new Response(g,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await d.close(),r("MCP client closed")}}catch(i){console.error("[waniwani:resource] handler error:",i);let l=i instanceof Error?i.message:"Unknown error occurred",u=i instanceof Pe?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function ts(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,n=We("tool",o);return async function(i){n("\u2192 POST",i.url);try{let l=await i.json(),{name:u,arguments:c}=l,d=i.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return n("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});n("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;n("mcpServerUrl:",p);let m,g;try{[{Client:m},{StreamableHTTPClientTransport:g}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),n("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}n("creating MCP client for",p);let I=new g(new URL(p)),C=new m({name:"waniwani-tool-caller",version:"1.0.0"});await C.connect(I);try{n("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let x=await C.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return n("tool result received"),Response.json({content:x.content,structuredContent:x.structuredContent,_meta:x._meta,isError:x.isError})}finally{await C.close(),n("MCP client closed")}}catch(l){console.error("[waniwani:tool] handler error:",l);let u=l instanceof Error?l.message:"Unknown error occurred",c=l instanceof Pe?l.status:500;return n("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function as(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=We("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let s=t??(await a()).mcpServerUrl;r("mcpServerUrl:",s);let i,l;try{[{createMCPClient:i},{StreamableHTTPClientTransport:l}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(c){return console.error("[waniwani:tools-list] MCP deps import failed:",c),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",s);let u=await i({transport:new l(new URL(s))});try{r("listing tools");let c=await u.listTools();r("tools count:",c.tools.length);let d={tools:c.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...c.nextCursor!==void 0&&{nextCursor:c.nextCursor}};return r("\u2190 200"),Response.json(d,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(s){console.error("[waniwani:tools-list] handler error:",s);let i=s instanceof Error?s.message:"Unknown error occurred",l=s instanceof Pe?s.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var Bd=300*1e3;function os(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new Pe("WANIWANI_API_KEY is required for createChatHandler",401);let n=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok){let i=await n.text().catch(()=>"");throw new Pe(`Failed to resolve MCP environment config: ${n.status} ${i}`,n.status)}let s=await n.json();return a={config:s,expiresAt:Date.now()+Bd},s})();try{return await o}finally{o=null}}}var Ed="https://app.waniwani.ai";function rs(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=Ed,source:o,systemPrompt:r,maxSteps:n=5,beforeRequest:s,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,c=We("router",l),d=Kn(),p=Qn(d),m=os(a,t),g=Zn({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:Xn(u)}),I=es({mcpServerUrl:i,resolveConfig:m,debug:l}),C=as({mcpServerUrl:i,resolveConfig:m,debug:l}),S=ts({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),x=process.env.WANIWANI_EVAL==="1";async function L(F){c("\u2192 GET",F.url);try{let R=new URL(F.url),M=R.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",R.pathname,"subRoute:",M),x&&M==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let v=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(v.data??v,200)}catch{return p([],200)}}if(M==="resource"){c("dispatching to resource handler");let E=await I(R);return c("\u2190 resource handler returned",E.status),d(E)}if(M==="config")return c("dispatching to config handler"),p({debug:l,eval:x},200);if(M==="tools"){c("dispatching to tools-list handler");let E=await C();return c("\u2190 tools-list handler returned",E.status),d(E)}return c("\u2190 404 no matching sub-route for",M),p({error:"Not found"},404)}catch(R){console.error("[waniwani:router] GET handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function y(F){c("\u2192 POST",F.url);try{let R=new URL(F.url),M=R.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",R.pathname,"subRoute:",M),x&&M==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let v=await F.json(),D=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(v)}),H=await D.json();return D.ok?p({ok:!0,scenario:H.data},200):p({error:H.message??"Failed to save scenario"},D.status)}catch(v){let D=v instanceof Error?v.message:"Failed to save scenario";return p({error:D},400)}}if(M==="tool"){c("dispatching to tool handler");let v=await S(F);return c("\u2190 tool handler returned",v.status),d(v)}c("dispatching to chat handler");let E=await g(F);return d(E)}catch(R){console.error("[waniwani:router] POST handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function k(F){c("\u2192 PATCH",F.url);try{let R=new URL(F.url),_=R.pathname.replace(/\/$/,"").split("/").filter(Boolean),M=_.at(-1),E=_.at(-2);if(c("pathname:",R.pathname,"subRoute:",E,"id:",M),x&&E==="scenarios"&&M){c("dispatching to update-scenario handler (proxy to app API)");try{let v=await F.json(),D=await fetch(`${a}/api/mcp/scenarios/${M}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(v)}),H=await D.json();return D.ok?p({ok:!0,scenario:H.data},200):p({error:H.message??"Failed to update scenario"},D.status)}catch(v){let D=v instanceof Error?v.message:"Failed to update scenario";return p({error:D},400)}}return c("\u2190 404 no matching sub-route for PATCH",E),p({error:"Not found"},404)}catch(R){console.error("[waniwani:router] PATCH handler error:",R);let _=R instanceof Error?R.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}function P(){return d(new Response(null,{status:204}))}return{handleChat:g,handleResource:I,handleTool:S,routeGet:L,routePost:y,routePatch:k,handleOptions:P}}var ns=!1;function uL(e,t){!ns&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),ns=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",n=rs({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:n.routePost,GET:n.routeGet,PATCH:n.routePatch,OPTIONS:()=>n.handleOptions()}}f();import{forwardRef as Eh,useCallback as Qr,useEffect as _h,useImperativeHandle as Oh,useRef as Ru,useState as Mu}from"react";f();f();f();import{forwardRef as Od,createElement as Nd}from"react";f();var Ma=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var ss=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var is=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var Bo=e=>{let t=is(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as _d,createElement as ds}from"react";f();var ls={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};f();var us=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var cs=_d(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:n,iconNode:s,...i},l)=>ds("svg",{ref:l,...ls,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:Ma("lucide",r),...!n&&!us(i)&&{"aria-hidden":"true"},...i},[...s.map(([u,c])=>ds(u,c)),...Array.isArray(n)?n:[n]]));var j=(e,t)=>{let a=Od(({className:o,...r},n)=>Nd(cs,{ref:n,iconNode:t,className:Ma(`lucide-${ss(Bo(e))}`,`lucide-${e}`,o),...r}));return a.displayName=Bo(e),a};f();var Ud=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],qt=j("arrow-down",Ud);f();var Hd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wt=j("arrow-up",Hd);f();var qd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Gt=j("check",qd);f();var Wd=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Je=j("chevron-down",Wd);f();var Gd=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jt=j("chevron-right",Gd);f();var jd=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],zt=j("clipboard-copy",jd);f();var zd=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xe=j("clock",zd);f();var Vd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Vt=j("file",Vd);f();var $d=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],$t=j("globe",$d);f();var Xd=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Xt=j("loader",Xd);f();var Kd=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Kt=j("paperclip",Kd);f();var Qd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Qt=j("square",Qd);f();var Jd=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],it=j("wrench",Jd);f();var Yd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=j("x",Yd);f();var Zd=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Jt=j("zap",Zd);import{useCallback as hc}from"react";f();import{useCallback as Ye,useMemo as ec,useRef as tc,useState as Eo}from"react";var ac={damping:.7,stiffness:.05,mass:1.25},oc=70,rc=1e3/60,nc=350,Fa=!1;globalThis.document?.addEventListener("mousedown",()=>{Fa=!0});globalThis.document?.addEventListener("mouseup",()=>{Fa=!1});globalThis.document?.addEventListener("click",()=>{Fa=!1});var ps=(e={})=>{let[t,a]=Eo(!1),[o,r]=Eo(e.initial!==!1),[n,s]=Eo(!1),i=tc(null);i.current=e;let l=Ye(()=>{if(!Fa)return!1;let x=window.getSelection();if(!x||!x.rangeCount)return!1;let L=x.getRangeAt(0);return L.commonAncestorContainer.contains(C.current)||C.current?.contains(L.commonAncestorContainer)},[]),u=Ye(x=>{d.isAtBottom=x,r(x)},[]),c=Ye(x=>{d.escapedFromLock=x,a(x)},[]),d=ec(()=>{let x;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return C.current?.scrollTop??0},set scrollTop(L){C.current&&(C.current.scrollTop=L,d.ignoreScrollToTop=C.current.scrollTop)},get targetScrollTop(){return!C.current||!S.current?0:C.current.scrollHeight-1-C.current.clientHeight},get calculatedTargetScrollTop(){if(!C.current||!S.current)return 0;let{targetScrollTop:L}=this;if(!e.targetScrollTop)return L;if(x?.targetScrollTop===L)return x.calculatedScrollTop;let y=Math.max(Math.min(e.targetScrollTop(L,{scrollElement:C.current,contentElement:S.current}),L),0);return x={targetScrollTop:L,calculatedScrollTop:y},requestAnimationFrame(()=>{x=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=oc}}},[]),p=Ye((x={})=>{typeof x=="string"&&(x={animation:x}),x.preserveScrollPosition||u(!0);let L=Date.now()+(Number(x.wait)||0),y=Oo(i.current,x.animation),{ignoreEscapes:k=!1}=x,P,F=d.calculatedTargetScrollTop;x.duration instanceof Promise?x.duration.finally(()=>{P=Date.now()}):P=L+(x.duration??0);let R=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:M}=d,E=performance.now(),v=(E-(d.lastTick??E))/rc;if(d.animation||(d.animation={behavior:y,promise:_,ignoreEscapes:k}),d.animation.behavior===y&&(d.lastTick=E),l()||L>Date.now())return R();if(M<Math.min(F,d.calculatedTargetScrollTop)){if(d.animation?.behavior===y){if(y==="instant")return d.scrollTop=d.calculatedTargetScrollTop,R();d.velocity=(y.damping*d.velocity+y.stiffness*d.scrollDifference)/y.mass,d.accumulated+=d.velocity*v,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return R()}return P>Date.now()?(F=d.calculatedTargetScrollTop,R()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:Oo(i.current,i.current.resize),ignoreEscapes:k,duration:Math.max(0,P-Date.now())||void 0}):d.isAtBottom)});return _.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return x.wait!==!0&&(d.animation=void 0),d.animation?.behavior===y?d.animation.promise:R()},[u,l,d]),m=Ye(()=>{c(!0),u(!1)},[c,u]),g=Ye(({target:x})=>{if(x!==C.current)return;let{scrollTop:L,ignoreScrollToTop:y}=d,{lastScrollTop:k=L}=d;d.lastScrollTop=L,d.ignoreScrollToTop=void 0,y&&y>L&&(k=y),s(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||L===y)return;if(l()){c(!0),u(!1);return}let P=L>k,F=L<k;if(d.animation?.ignoreEscapes){d.scrollTop=k;return}F&&(c(!0),u(!1)),P&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,l,d]),I=Ye(({target:x,deltaY:L})=>{let y=x;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===C.current&&L<0&&C.current.scrollHeight>C.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),C=fs(x=>{C.current?.removeEventListener("scroll",g),C.current?.removeEventListener("wheel",I),x?.addEventListener("scroll",g,{passive:!0}),x?.addEventListener("wheel",I,{passive:!0})},[]),S=fs(x=>{if(d.resizeObserver?.disconnect(),!x)return;let L;d.resizeObserver=new ResizeObserver(([y])=>{let{height:k}=y.contentRect,P=k-(L??k);if(d.resizeDifference=P,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),s(d.isNearBottom),P>=0){let F=Oo(i.current,L?i.current.resize:i.current.initial);p({animation:F,wait:!0,preserveScrollPosition:!0,duration:F==="instant"?void 0:nc})}else d.isNearBottom&&(c(!1),u(!0));L=k,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===P&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(x)},[]);return{contentRef:S,scrollRef:C,scrollToBottom:p,stopScroll:m,isAtBottom:o||n,isNearBottom:n,escapedFromLock:t,state:d}};function fs(e,t){let a=Ye(o=>(a.current=o,e(o)),t);return a}var _o=new Map;function Oo(...e){let t={...ac},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return _o.has(o)||_o.set(o,Object.freeze(t)),a?"instant":_o.get(o)}f();import*as ut from"react";import{createContext as sc,useContext as ic,useEffect as lc,useImperativeHandle as uc,useLayoutEffect as dc,useMemo as cc,useRef as fc}from"react";var ms=sc(null),pc=typeof window<"u"?dc:lc;function Yt({instance:e,children:t,resize:a,initial:o,mass:r,damping:n,stiffness:s,targetScrollTop:i,contextRef:l,...u}){let c=fc(null),d=ut.useCallback((k,P)=>(y?.targetScrollTop??i)?.(k,P)??k,[i]),p=ps({mass:r,damping:n,stiffness:s,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:g,scrollToBottom:I,stopScroll:C,isAtBottom:S,escapedFromLock:x,state:L}=e??p,y=cc(()=>({scrollToBottom:I,stopScroll:C,scrollRef:m,isAtBottom:S,escapedFromLock:x,contentRef:g,state:L,get targetScrollTop(){return c.current},set targetScrollTop(k){c.current=k}}),[I,S,g,m,C,x,L]);return uc(l,()=>y,[y]),pc(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),ut.createElement(ms.Provider,{value:y},ut.createElement("div",{...u},typeof t=="function"?t(y):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let n=No();return ut.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},ut.createElement("div",{...r,ref:n.contentRef},typeof a=="function"?a(n):a))}e.Content=t})(Yt||(Yt={}));function No(){let e=ic(ms);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var mc=sn({prefix:"ww"});function A(...e){return mc(nn(e))}f();import{jsx as gc}from"react/jsx-runtime";var Ge=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>gc("button",{type:o,className:A("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});import{jsx as Da}from"react/jsx-runtime";var gs=({className:e,...t})=>Da(Yt,{className:A("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),hs=({className:e,...t})=>Da(Yt.Content,{className:A("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),ws=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=No(),r=hc(()=>{o()},[o]);return!a&&Da(Ge,{className:A("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:Da(qt,{className:"ww:size-4"})})};f();f();import Cs from"crypto";f();var xs="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var wc=128,dt,bt,xc=e=>{!dt||dt.length<e?(dt=Buffer.allocUnsafe(e*wc),Cs.randomFillSync(dt),bt=0):bt+e>dt.length&&(Cs.randomFillSync(dt),bt=0),bt+=e};var Zt=(e=21)=>{xc(e|=0);let t="";for(let a=bt-e;a<bt;a++)t+=xs[dt[a]&63];return t};import{createContext as bc,useCallback as Ke,useContext as kc,useEffect as Wo,useMemo as Tc,useRef as Go,useState as Ls}from"react";f();f();import{createContext as Ic,useContext as Sc,useEffect as qS,useMemo as WS,useState as GS}from"react";f();f();f();f();var Ho={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments"},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};f();f();import{jsx as QS}from"react/jsx-runtime";var yc=Ic(null);function V(){let e=Sc(yc);return e||{locale:"en",t:Ho,ready:!0}}f();function qo(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let o,r;a<60*6e4?(o=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(o=-Math.floor(a/(60*6e4)),r="hour"):(o=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(o,r)}catch{return`${Math.abs(o)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}import{jsx as _e,jsxs as vs}from"react/jsx-runtime";var vc=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},Is=bc(null),Ss=()=>{let e=kc(Is);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},ys=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:n,onSubmit:s,children:i,...l})=>{let{t:u}=V(),c=Go(null),d=Go(null),[p,m]=Ls([]),g=Go(p);Wo(()=>{g.current=p},[p]);let I=Ke(()=>{c.current?.click()},[]),C=Ke(P=>{let F=[...P];if(F.length===0)return;let R=M=>n?M.size<=n:!0,_=F.filter(R);m(M=>{let E=typeof r=="number"?Math.max(0,r-M.length):void 0,v=typeof E=="number"?_.slice(0,E):_;return[...M,...v.map(D=>({filename:D.name,id:Zt(),mediaType:D.type,type:"file",url:URL.createObjectURL(D)}))]})},[r,n]),S=Ke(P=>{m(F=>{let R=F.find(_=>_.id===P);return R?.url&&URL.revokeObjectURL(R.url),F.filter(_=>_.id!==P)})},[]),x=Ke(()=>{m(P=>{for(let F of P)F.url&&URL.revokeObjectURL(F.url);return[]})},[]);Wo(()=>()=>{for(let P of g.current)P.url&&URL.revokeObjectURL(P.url)},[]);let L=Ke(P=>{P.currentTarget.files&&C(P.currentTarget.files),P.currentTarget.value=""},[C]);Wo(()=>{if(!o)return;let P=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault()},F=R=>{R.dataTransfer?.types?.includes("Files")&&R.preventDefault(),R.dataTransfer?.files&&R.dataTransfer.files.length>0&&C(R.dataTransfer.files)};return document.addEventListener("dragover",P),document.addEventListener("drop",F),()=>{document.removeEventListener("dragover",P),document.removeEventListener("drop",F)}},[C,o]);let y=Ke(async P=>{P.preventDefault();let F=P.currentTarget,_=new FormData(F).get("message")||"";F.reset();let M=await Promise.all(p.map(async({id:E,...v})=>{if(v.url?.startsWith("blob:")){let D=await vc(v.url);return{...v,url:D??v.url}}return v}));try{let E=s({files:M,text:_},P);E instanceof Promise&&await E,x()}catch{}},[p,s,x]),k=Tc(()=>({add:C,clear:x,files:p,openFileDialog:I,remove:S}),[p,C,S,x,I]);return vs(Is.Provider,{value:k,children:[_e("input",{accept:t,"aria-label":u.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:L,ref:c,title:u.promptInput.uploadFiles,type:"file"}),_e("form",{className:A("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:y,ref:d,...l,children:i})]})};var bs=({onChange:e,onKeyDown:t,className:a,placeholder:o,...r})=>{let{t:n}=V(),s=Ss(),[i,l]=Ls(!1),u=o??n.promptInput.placeholder,c=Ke(p=>{if(t?.(p),!p.defaultPrevented){if(p.key==="Enter"){if(i||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();let{form:m}=p.currentTarget;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&s.files.length>0){p.preventDefault();let m=s.files.at(-1);m&&s.remove(m.id)}}},[t,i,s]),d=Ke(p=>{let m=p.clipboardData?.items;if(!m)return;let g=[];for(let I of m)if(I.kind==="file"){let C=I.getAsFile();C&&g.push(C)}g.length>0&&(p.preventDefault(),s.add(g))},[s]);return _e("textarea",{className:A("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:c,onPaste:d,placeholder:u,onChange:e,...r})},ks=({className:e,status:t,onStop:a,onClick:o,children:r,...n})=>{let{t:s}=V(),i=t==="submitted"||t==="streaming",l=_e(Wt,{className:"ww:size-4"});t==="submitted"?l=_e(Xt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=_e(Qt,{className:"ww:size-4"}));let u=Ke(c=>{if(i&&a){c.preventDefault(),a();return}o?.(c)},[i,a,o]);return _e(Ge,{"aria-label":i?s.promptInput.stop:s.promptInput.submit,className:A("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:u,size:"icon-sm",type:i&&a?"button":"submit",variant:"ghost",...n,children:r??l})},Ts=({className:e,children:t,...a})=>{let{t:o}=V(),r=Ss();return r.files.length>0?vs(Ge,{className:A("ww:group ww:relative",e),onClick:()=>r.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":o.promptInput.removeAttachments,...a,children:[_e("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:r.files.length}),_e(lt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):_e(Ge,{className:A(e),onClick:()=>r.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??_e(Kt,{className:"ww:size-4"})})};f();import{memo as Pc,useCallback as Ac}from"react";f();import{jsx as kt}from"react/jsx-runtime";var Ps=({className:e,...t})=>kt("div",{className:A("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),As=({className:e,...t})=>kt("li",{className:A("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Rs=({className:e,...t})=>kt("span",{className:A("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Ms=({className:e,...t})=>kt("span",{className:A("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Fs=({className:e,...t})=>kt("div",{className:A("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Ds=({className:e,...t})=>kt(Ge,{className:A("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});import{jsx as Ze,jsxs as _s}from"react/jsx-runtime";var Bs=Pc(({message:e,onRemove:t})=>{let{t:a}=V(),o=Ac(()=>t(e.id),[t,e.id]);return _s(As,{children:[Ze(Rs,{}),Ze(Ms,{children:e.text||a.chatQueue.attachmentFallback}),Ze(Fs,{children:Ze(Ds,{"aria-label":a.chatQueue.removeFromQueue,onClick:o,children:Ze(lt,{className:"ww:size-3"})})})]})});Bs.displayName="ChatQueueItem";function Es({queuedMessages:e,onRemove:t,className:a}){let{t:o}=V();return e.length===0?null:_s(Ps,{className:A("ww:border-t ww:border-border",a),children:[Ze("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:o.chatQueue.queued(e.length)}),Ze("ul",{children:e.map(r=>Ze(Bs,{message:r,onRemove:t},r.id))})]})}f();import{useState as Os}from"react";import{jsx as Rc}from"react/jsx-runtime";function Ns({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let{t:o}=V(),[r,n]=Os(!1),[s,i]=Os(null),l=async()=>{let c={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};n(!0),i(null);try{let d=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!d.ok)throw new Error(`${d.status}`);i("saved")}catch{i("error")}finally{n(!1),setTimeout(()=>i(null),2e3)}};if(!t||e.length===0)return null;let u=r?o.exportSession.saving:s==="saved"?o.exportSession.saved:s==="error"?o.exportSession.error:o.exportSession.export;return Rc("button",{type:"button",onClick:l,disabled:r,title:o.exportSession.tooltip,className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:u})}f();f();import{jsx as ea,jsxs as Fc}from"react/jsx-runtime";var Us=({files:e,className:t,...a})=>e.length===0?null:ea("div",{className:A("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>ea(Mc,{file:o},r))});function Mc({file:e}){let{t}=V();return e.mediaType?.startsWith("image/")&&e.url?ea("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):Fc("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[ea(Vt,{className:"ww:size-3 ww:shrink-0"}),ea("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}f();import{createContext as jc,useCallback as zc,useContext as Vc,useEffect as $c,useMemo as Xc,useState as $o}from"react";f();import{createContext as _c,memo as Vo,useCallback as Oc,useContext as Nc,useEffect as jo,useMemo as Uc,useRef as Hs,useState as zo}from"react";f();f();import{memo as Dc}from"react";import{jsx as Ec}from"react/jsx-runtime";var Bc=({as:e="span",className:t,duration:a=2,style:o,children:r,...n})=>{let s={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 Ec(e,{"data-waniwani-shimmer":"",className:A("ww:inline-block",t),style:s,...n,children:r})},Oe=Dc(Bc);Oe.displayName="Shimmer";import{Fragment as Wc,jsx as Ne,jsxs as Gc}from"react/jsx-runtime";var qs=_c(null);function Ws(){let e=Nc(qs);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Hc=1e3,qc=1e3,ta=Vo(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:n,children:s,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=zo(l),m=c?a:d,g=Oc(F=>{c||p(F),r?.(F)},[c,r]),[I,C]=zo(void 0),S=n??I,x=Hs(t),[L,y]=zo(!1),k=Hs(null);jo(()=>{t?(x.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(C(Math.ceil((Date.now()-k.current)/qc)),k.current=null)},[t]),jo(()=>{t&&!m&&!u&&g(!0)},[t,m,u,g]),jo(()=>{if(x.current&&!t&&m&&!L){let F=setTimeout(()=>{g(!1),y(!0)},Hc);return()=>clearTimeout(F)}},[t,m,L,g]);let P=Uc(()=>({isStreaming:t,isOpen:m,setIsOpen:g,duration:S}),[t,m,g,S]);return Ne(qs.Provider,{value:P,children:Ne("div",{className:A("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:s})})});ta.displayName="Reasoning";var aa=Vo(({className:e,children:t,getThinkingMessage:a,hideIcon:o=!1,onClick:r,...n})=>{let{t:s}=V(),{isStreaming:i,isOpen:l,duration:u,setIsOpen:c}=Ws(),p=a??((m,g)=>m||g===0?Ne(Oe,{duration:1.6,children:s.reasoning.thinking}):g===void 0?Ne("span",{children:s.reasoning.thoughtBrief}):Ne("span",{children:s.reasoning.thoughtForSeconds(g)}));return Ne("button",{type:"button","aria-expanded":l,onClick:m=>{c(!l),r?.(m)},className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...n,children:t??Gc(Wc,{children:[!o&&Ne(Xe,{className:"ww:size-4 ww:shrink-0"}),p(i,u)]})})});aa.displayName="ReasoningTrigger";var oa=Vo(({className:e,children:t,...a})=>{let{isOpen:o}=Ws();return Ne("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Ne("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Ne("div",{className:A("ww:text-sm ww:text-muted-foreground",e),...a,children:Ne(Ft,{children:t})})})})});oa.displayName="ReasoningContent";import{jsx as Z,jsxs as et}from"react/jsx-runtime";var Kc=500,Gs=jc(null);function js(){let e=Vc(Gs);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function zs({className:e,isWorking:t=!1,activeStep:a,open:o,defaultOpen:r=!1,onOpenChange:n,children:s,...i}){let l=o!==void 0,[u,c]=$o(r),d=l?o:u,p=zc(C=>{l||c(C),n?.(C)},[l,n]),[m,g]=$o(!t);$c(()=>{if(t){g(!1);return}let C=setTimeout(()=>g(!0),Kc);return()=>clearTimeout(C)},[t]);let I=Xc(()=>({open:d,setOpen:p,isWorking:t,settled:m,activeStep:a}),[d,p,t,m,a]);return Z(Gs.Provider,{value:I,children:Z("div",{className:A("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":d?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:s})})}function Vs({className:e,label:t,workingLabel:a,children:o,...r}){let{open:n,setOpen:s,isWorking:i,settled:l,activeStep:u}=js();if(!l){let c=u?.icon,d=u?.label??a??t??"";return Z("div",{className:A("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground",e),children:et("span",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-1.5",style:{animation:"ww-fade-in 0.25s ease-out"},children:[c&&Z(c,{className:A("ww:size-4 ww:shrink-0",i&&"ww:animate-pulse")}),Z("span",{className:"ww:truncate",children:i?Z(Oe,{duration:2.6,children:d}):d})]},d)})}return et("button",{type:"button",onClick:()=>s(!n),"aria-expanded":n,className:A("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),style:{animation:"ww-fade-in 0.25s ease-out"},...r,children:[Z("span",{className:"ww:truncate",children:o??t}),Z(Je,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",n&&"ww:rotate-180")})]})}function $s({className:e,children:t,...a}){let{open:o}=js();return Z("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Z("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Z("div",{className:A("ww:flex ww:flex-col",e),...a,children:t})})})}function Xs({icon:e,isLast:t,running:a,error:o}){return et("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[Z("span",{className:"ww:flex ww:h-5 ww:items-center",children:Z(e,{className:A("ww:size-4 ww:shrink-0",o?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&Z("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function Xo({className:e,icon:t,title:a,state:o,isLast:r=!1,children:n,...s}){let i=o==="input-available"||o==="input-streaming",l=o==="output-error",u=n!=null,[c,d]=$o(!1),p=a??"",m=i?Z(Oe,{duration:1.6,children:p}):Z("span",{className:"ww:truncate",children:p});return et("div",{className:A("ww:flex ww:gap-2",e),...s,children:[Z(Xs,{icon:t,isLast:r,running:i,error:l}),et("div",{className:A("ww:min-w-0 ww:flex-1",!r&&"ww:pb-3"),children:[u?et("button",{type:"button",onClick:()=>d(g=>!g),"aria-expanded":c,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[m,Z(Je,{className:A("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",c&&"ww:rotate-180")})]}):Z("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:m}),u&&Z("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",c?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Z("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Z("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:n})})})]})]})}function Ks({isStreaming:e=!1,isLast:t=!1,children:a}){return et("div",{className:"ww:flex ww:gap-2",children:[Z(Xs,{icon:Xe,isLast:t,running:e}),Z("div",{className:A("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:et(ta,{isStreaming:e,className:"ww:mb-0",children:[Z(aa,{hideIcon:!0}),Z(oa,{children:a})]})})]})}f();f();f();f();f();f();var we={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533};f();var je={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};f();var Re={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};f();f();f();function Qs(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Js(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Ys(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Zs(e){return Qs(e)?"ambiguous":Js(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":Ys(e)?"wide":"neutral"}function Qc(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ei(e){return Qc(e),Zs(e)}var Jc=Object.defineProperty,Yc=(e,t,a)=>t in e?Jc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Zc=(e,t,a)=>Yc(e,typeof t!="symbol"?t+"":t,a);function ef(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function tf(e){if(!e||e<4352)return!1;switch(ei(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!ef(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function af(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function of(e){return e!==null&&e>=65024&&e<=65038}var rf=ti(new RegExp("\\p{P}|\\p{S}","u")),nf=ti(/\s/);function ti(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Me;(e=>{e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Me||(Me={}));function tt(e){if(e===we.eof||gn(e)||nf(e))return je.characterGroupWhitespace;let t=0;if(e>=4352){if(of(e))return Me.nonEmojiGeneralUseVS;switch(tf(e)){case null:return Me.ivs;case!0:t|=Me.cjk;break}}return rf(e)&&(t|=je.characterGroupPunctuation),t}function Ba(e,t,a){if(!lf(e))return e;let o=t(),r=tt(o);return!o||ct(r)?e:af(o,a)?Me.cjkPunctuation:sf(r)}function sf(e){return e&~Me.ivs}function ct(e){return!!(e&je.characterGroupWhitespace)}function Tt(e){return(e&Me.cjkPunctuation)===je.characterGroupPunctuation}function ra(e){return!!(e&Me.cjk)}function ai(e){return e===Me.ivs}function oi(e){return!!(e&Me.cjkOrIvs)}function lf(e){return e===Me.nonEmojiGeneralUseVS}function Ko(e){return!!(e&Me.spaceOrPunctuation)}function Ea(e){return!!(e&&e>=55296&&e<=56319)}function _a(e){return!!(e&&e>=56320&&e<=57343)}function Oa(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function uf(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,n=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),s=n.charCodeAt(n.length-1);if(Number.isNaN(s))return null;if(n.length<2||s<56320||57343<s)return s;let i=n.codePointAt(0);return i&&i>=65536?i:s}var Na=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,Zc(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=uf(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Ua(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var Qo={name:"attention",resolveAll:df,tokenize:cf};function df(e,t){let a=-1,o,r,n,s,i,l,u,c;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;l=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let d={...e[o][1].end},p={...e[a][1].start};ri(d,-l),ri(p,l),s={type:l>1?Re.strongSequence:Re.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?Re.strongSequence:Re.emphasisSequence,start:{...e[a][1].start},end:p},n={type:l>1?Re.strongText:Re.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?Re.strong:Re.emphasis,start:{...s.start},end:{...i.end}},e[o][1].end={...s.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=It(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=It(u,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",n,t]]),t.parser.constructs.insideSpan.null,u=It(u,ka(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=It(u,[["exit",n,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=It(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,Lt(e,o-1,a-o+3,u),a=o+u.length-c-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function cf(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:n}=this,s=_a(n)?Oa(n,o(),r):n,i=tt(s),l=new Na(s,o(),r),u=Ba(i,l.value.bind(l),s),c;return d;function d(m){return m===we.asterisk||we.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let g=e.exit("attentionSequence"),I=Ea(m)?Ua(m,o(),r):m,C=tt(I);let S=Tt(u),x=S||ct(u),L=Tt(C),y=L||ct(C),k=oi(u),P=!y||L&&(x||k)||a.includes(m),F=!x||S&&(y||ra(C))||a.includes(s);return g._open=!!(c===we.asterisk?P:P&&(Ko(u)||!F)),g._close=!!(c===we.asterisk?F:F&&(Ko(C)||!P)),t(m)}}function ri(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function ni(){return{text:{[we.asterisk]:Qo,[we.underscore]:Qo},insideSpan:{null:[Qo]}}}function si(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(ni())}f();f();function ii(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:n,resolveAll:r};return a==null&&(a=!0),{text:{[we.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[we.tilde]}};function r(s,i){let l=-1;for(;++l<s.length;)if(s[l][0]==="enter"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._close){let u=l;for(;u--;)if(s[u][0]==="exit"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._open&&s[l][1].end.offset-s[l][1].start.offset===s[u][1].end.offset-s[u][1].start.offset){s[l][1].type="strikethroughSequence",s[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},d={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},p=[["enter",c,i],["enter",s[u][1],i],["exit",s[u][1],i],["enter",d,i]],m=i.parser.constructs.insideSpan.null;m&&Lt(p,p.length,0,ka(m,s.slice(u+1,l),i)),Lt(p,p.length,0,[["exit",d,i],["enter",s[l][1],i],["exit",s[l][1],i],["exit",c,i]]),Lt(s,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<s.length;)s[l][1].type==="strikethroughSequenceTemporary"&&(s[l][1].type=Re.data);return s}function n(s,i,l){let{now:u,sliceSerialize:c,previous:d}=this,p=_a(d)?Oa(d,u(),c):d,m=tt(p),g=new Na(p,u(),c),I=Ba(m,g.value.bind(g),p),C=this.events,S=0;return x;function x(y){return we.tilde,p===we.tilde&&C[C.length-1][1].type!==Re.characterEscape?l(y):(s.enter("strikethroughSequenceTemporary"),L(y))}function L(y){let k=tt(p);if(y===we.tilde)return S>1?l(y):(s.consume(y),S++,L);if(S<2&&!a)return l(y);let P=s.exit("strikethroughSequenceTemporary"),F=Ea(y)?Ua(y,u(),c):y,R=tt(F),M=Tt(I)||ct(I),v=Tt(R)||ct(R),D=ra(I)||ai(k);return P._open=!v||R===je.attentionSideAfter&&(M||D),P._close=!M||k===je.attentionSideAfter&&(v||ra(R)),i(y)}}}function li(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(ii(e))}var ff=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),pf=/^(https?:\/\/|mailto:|www\.)/i,mf=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},gf=e=>{let t=0;for(let a of e){if(ff.has(a))return t;t+=a.length}return null},hf=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),wf=e=>({type:"text",value:e}),xf=()=>e=>{ln(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!mf(t)||!pf.test(t.url))return;let r=gf(t.url);if(r===null||r===0)return;let n=t.url.slice(0,r),s=t.url.slice(r),i=hf(n,t),l=wf(s);return o.children.splice(a,1,i,l),a+1})};function Cf(){let e=[si],t=[xf,li],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Jo=Cf();f();f();f();f();f();var re=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Lf(e){return ir(e)}function ir(e){return Array.isArray(e)?If(e):e instanceof RegExp?e:typeof e=="object"?Sf(e):e}function If(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=ir(e[a]);return t}function Sf(e){let t={};for(let a in e)t[a]=ir(e[a]);return t}function wi(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function xi(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?xi(e.substring(0,e.length-1)):e.substr(~t+1)}var Yo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ha=class{static hasCaptures(e){return e===null?!1:(Yo.lastIndex=0,Yo.test(e))}static replaceCaptures(e,t,a){return e.replace(Yo,(o,r,n,s)=>{let i=a[parseInt(r||n,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(s){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function Ci(e,t){return e<t?-1:e>t?1:0}function Li(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let n=Ci(e[r],t[r]);if(n!==0)return n}return 0}return a-o}function ui(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Ii(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Si=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},ia=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(kf(e),t)}static createFromParsedTheme(e,t){return vf(e,t)}_cachedMatchRoot=new Si(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,o=this._cachedMatchRoot.get(t).find(r=>yf(e.parent,r.parentScopes));return o?new yi(o.fontStyle,o.foreground,o.background):null}},Zo=class qa{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new qa(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new qa(a,t[o]);return a}push(t){return new qa(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function yf(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!bf(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function bf(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var yi=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function kf(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,n=t.length;r<n;r++){let s=t[r];if(!s.settings)continue;let i;if(typeof s.scope=="string"){let d=s.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(s.scope)?i=s.scope:i=[""];let l=-1;if(typeof s.settings.fontStyle=="string"){l=0;let d=s.settings.fontStyle.split(" ");for(let p=0,m=d.length;p<m;p++)switch(d[p]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof s.settings.foreground=="string"&&ui(s.settings.foreground)&&(u=s.settings.foreground);let c=null;typeof s.settings.background=="string"&&ui(s.settings.background)&&(c=s.settings.background);for(let d=0,p=i.length;d<p;d++){let g=i[d].trim().split(" "),I=g[g.length-1],C=null;g.length>1&&(C=g.slice(0,g.length-1),C.reverse()),a[o++]=new Tf(I,C,r,l,u,c)}}return a}var Tf=class{constructor(e,t,a,o,r,n){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=n}},xe=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(xe||{});function vf(e,t){e.sort((l,u)=>{let c=Ci(l.scope,u.scope);return c!==0||(c=Li(l.parentScopes,u.parentScopes),c!==0)?c:l.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(o=l.foreground),l.background!==null&&(r=l.background)}let n=new Pf(t),s=new yi(a,n.getId(o),n.getId(r)),i=new Rf(new tr(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let c=e[l];i.insert(0,c.scope,c.parentScopes,c.fontStyle,n.getId(c.foreground),n.getId(c.background))}return new ia(n,s,i)}var Pf=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Af=Object.freeze([]),tr=class bi{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,n){this.scopeDepth=t,this.parentScopes=a||Af,this.fontStyle=o,this.foreground=r,this.background=n}clone(){return new bi(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},Rf=class ar{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let n=a.parentScopes[r].length-t.parentScopes[o].length;if(n!==0)return n;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,n;if(o===-1?(r=t,n=""):(r=t.substring(0,o),n=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(n)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(ar._cmpBySpecificity),a}insert(t,a,o,r,n,s){if(a===""){this._doInsertHere(t,o,r,n,s);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let c;this._children.hasOwnProperty(l)?c=this._children[l]:(c=new ar(this._mainRule.clone(),tr.cloneArr(this._rulesWithParentScopes)),this._children[l]=c),c.insert(t+1,u,o,r,n,s)}_doInsertHere(t,a,o,r,n){if(a===null){this._mainRule.acceptOverwrite(t,o,r,n);return}for(let s=0,i=this._rulesWithParentScopes.length;s<i;s++){let l=this._rulesWithParentScopes[s];if(Li(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,n);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),n===0&&(n=this._mainRule.background),this._rulesWithParentScopes.push(new tr(t,a,o,r,n))}},pt=class Ee{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ee.getLanguageId(t),o=Ee.getTokenType(t),r=Ee.getFontStyle(t),n=Ee.getForeground(t),s=Ee.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:n,background:s})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,o,r,n,s,i){let l=Ee.getLanguageId(t),u=Ee.getTokenType(t),c=Ee.containsBalancedBrackets(t)?1:0,d=Ee.getFontStyle(t),p=Ee.getForeground(t),m=Ee.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(c=r?1:0),n!==-1&&(d=n),s!==0&&(p=s),i!==0&&(m=i),(l<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function Ga(e,t){let a=[],o=Mf(e),r=o.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=s();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function n(){if(r==="-"){r=o.next();let l=n();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(di(r)){let l=[];do l.push(r),r=o.next();while(di(r));return u=>t(l,u)}return null}function s(){let l=[],u=n();for(;u;)l.push(u),u=n();return c=>l.every(d=>d(c))}function i(){let l=[],u=s();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=s()}return c=>l.some(d=>d(c))}}function di(e){return!!e&&!!e.match(/[\w\.:]+/)}function Mf(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function ki(e){typeof e.dispose=="function"&&e.dispose()}var la=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Ff=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Df=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},Bf=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new la(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Df;for(let a of e)Ef(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof la){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Ef(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let n=a.lookup(t);e instanceof la?Wa({baseGrammar:n,selfGrammar:r},o):or(e.ruleName,{baseGrammar:n,selfGrammar:r,repository:r.repository},o);let s=a.injections(e.scopeName);if(s)for(let i of s)o.add(new la(i))}function or(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];ja([o],t,a)}}function Wa(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ja(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ja(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ja(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?wi({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&ja(o.patterns,{...t,repository:r},a);let n=o.include;if(!n)continue;let s=Ti(n);switch(s.kind){case 0:Wa({...t,selfGrammar:t.baseGrammar},a);break;case 1:Wa(t,a);break;case 2:or(s.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=s.scopeName===t.selfGrammar.scopeName?t.selfGrammar:s.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};s.kind===4?or(s.ruleName,l,a):Wa(l,a)}else s.kind===4?a.add(new Ff(s.scopeName,s.ruleName)):a.add(new la(s.scopeName));break}}}var _f=class{kind=0},Of=class{kind=1},Nf=class{constructor(e){this.ruleName=e}kind=2},Uf=class{constructor(e){this.scopeName=e}kind=3},Hf=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Ti(e){if(e==="$base")return new _f;if(e==="$self")return new Of;let t=e.indexOf("#");if(t===-1)return new Uf(e);if(t===0)return new Nf(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Hf(a,o)}}var qf=/\\(\d+)/,ci=/\\(\d+)/g;var Wf=-1,vi=-2;var ca=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ha.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ha.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${xi(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Ha.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ha.replaceCaptures(this._contentName,e,t)}},Gf=class extends ca{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},jf=class extends ca{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new ua(o,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new da,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},fi=class extends ca{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new da,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},rr=class extends ca{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,n,s,i,l,u){super(e,t,a,o),this._begin=new ua(r,this.id),this.beginCaptures=n,this._end=new ua(s||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new da;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},za=class extends ca{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,n,s,i,l){super(e,t,a,o),this._begin=new ua(r,this.id),this.beginCaptures=n,this.whileCaptures=i,this._while=new ua(s,vi),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new da;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new da,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Pi=class Se{static createCaptureRule(t,a,o,r,n){return t.registerRule(s=>new Gf(a,s,o,r,n))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new jf(t.$vscodeTextmateLocation,t.id,t.name,t.match,Se._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=wi({},o,t.repository));let n=t.patterns;return typeof n>"u"&&t.include&&(n=[{include:t.include}]),new fi(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Se._compilePatterns(n,a,o))}return t.while?new za(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,Se._compileCaptures(t.whileCaptures||t.captures,a,o),Se._compilePatterns(t.patterns,a,o)):new rr(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,Se._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,Se._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let n=0;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10);i>n&&(n=i)}for(let s=0;s<=n;s++)r[s]=null;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10),l=0;t[s].patterns&&(l=Se.getCompiledRuleId(t[s],a,o)),r[i]=Se.createCaptureRule(a,t[s].$vscodeTextmateLocation,t[s].name,t[s].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let n=0,s=t.length;n<s;n++){let i=t[n],l=-1;if(i.include){let u=Ti(i.include);switch(u.kind){case 0:case 1:l=Se.getCompiledRuleId(o[i.include],a,o);break;case 2:let c=o[u.ruleName];c&&(l=Se.getCompiledRuleId(c,a,o));break;case 3:case 4:let d=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(d,o);if(m)if(p){let g=m.repository[p];g&&(l=Se.getCompiledRuleId(g,a,m.repository))}else l=Se.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=Se.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),c=!1;if((u instanceof fi||u instanceof rr||u instanceof za)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},ua=class Ai{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,n=[],s=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(n.push(t.substring(r,i)),n.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(s=!0),i++}this.hasAnchor=s,r===0?this.source=t:(n.push(t.substring(r,o)),this.source=n.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=qf.test(this.source):this.hasBackReferences=!1}clone(){return new Ai(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let o=a.map(r=>t.substring(r.start,r.end));return ci.lastIndex=0,this.source.replace(ci,(r,n)=>Ii(o[parseInt(n,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],o=[],r=[],n,s,i,l;for(n=0,s=this.source.length;n<s;n++)i=this.source.charAt(n),t[n]=i,a[n]=i,o[n]=i,r[n]=i,i==="\\"&&n+1<s&&(l=this.source.charAt(n+1),l==="A"?(t[n+1]="\uFFFF",a[n+1]="\uFFFF",o[n+1]="A",r[n+1]="A"):l==="G"?(t[n+1]="\uFFFF",a[n+1]="G",o[n+1]="\uFFFF",r[n+1]="G"):(t[n+1]=l,a[n+1]=l,o[n+1]=l,r[n+1]=l),n++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},da=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new pi(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let o=this._items.map(r=>r.resolveAnchors(t,a));return new pi(e,o,this._items.map(r=>r.ruleId))}},pi=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
69
- `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},er=class{constructor(e,t){this.languageId=e,this.tokenType=t}},zf=class nr{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new er(t,8),this._embeddedLanguagesMatcher=new Vf(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?nr._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new er(0,0);_getBasicScopeAttributes=new Si(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new er(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(nr.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Vf=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,o])=>Ii(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},f0={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Ri=!1,mi=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Mi(e,t,a,o,r,n,s,i){let l=t.content.length,u=!1,c=-1;if(s){let m=$f(e,t,a,o,r,n);r=m.stack,o=m.linePos,a=m.isFirstLine,c=m.anchorPosition}let d=Date.now();for(;!u;){if(i!==0&&Date.now()-d>i)return new mi(r,!0);p()}return new mi(r,!1);function p(){let m=Xf(e,t,a,o,r,c);if(!m){n.produce(r,l),u=!0;return}let g=m.captureIndices,I=m.matchedRuleId,C=g&&g.length>0?g[0].end>o:!1;if(I===Wf){let S=r.getRule(e);n.produce(r,g[0].start),r=r.withContentNameScopesList(r.nameScopesList),na(e,t,a,r,n,S.endCaptures,g),n.produce(r,g[0].end);let x=r;if(r=r.parent,c=x.getAnchorPos(),!C&&x.getEnterPos()===o){r=x,n.produce(r,l),u=!0;return}}else{let S=e.getRule(I);n.produce(r,g[0].start);let x=r,L=S.getName(t.content,g),y=r.contentNameScopesList.pushAttributed(L,e);if(r=r.push(I,o,c,g[0].end===l,null,y,y),S instanceof rr){let k=S;na(e,t,a,r,n,k.beginCaptures,g),n.produce(r,g[0].end),c=g[0].end;let P=k.getContentName(t.content,g),F=y.pushAttributed(P,e);if(r=r.withContentNameScopesList(F),k.endHasBackReferences&&(r=r.withEndRule(k.getEndWithResolvedBackReferences(t.content,g))),!C&&x.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(S instanceof za){let k=S;na(e,t,a,r,n,k.beginCaptures,g),n.produce(r,g[0].end),c=g[0].end;let P=k.getContentName(t.content,g),F=y.pushAttributed(P,e);if(r=r.withContentNameScopesList(F),k.whileHasBackReferences&&(r=r.withEndRule(k.getWhileWithResolvedBackReferences(t.content,g))),!C&&x.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(na(e,t,a,r,n,S.captures,g),n.produce(r,g[0].end),r=r.pop(),!C){r=r.safePop(),n.produce(r,l),u=!0;return}}g[0].end>o&&(o=g[0].end,a=!1)}}function $f(e,t,a,o,r,n){let s=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof za&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:c}=Jf(l.rule,e,l.stack.endRule,a,o===s),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==vi){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(n.produce(l.stack,d.captureIndices[0].start),na(e,t,a,l.stack,n,l.rule.whileCaptures,d.captureIndices),n.produce(l.stack,d.captureIndices[0].end),s=d.captureIndices[0].end,d.captureIndices[0].end>o&&(o=d.captureIndices[0].end,a=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:s,isFirstLine:a}}function Xf(e,t,a,o,r,n){let s=Kf(e,t,a,o,r,n),i=e.getInjections();if(i.length===0)return s;let l=Qf(i,e,t,a,o,r,n);if(!l)return s;if(!s)return l;let u=s.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:s}function Kf(e,t,a,o,r,n){let s=r.getRule(e),{ruleScanner:i,findOptions:l}=Fi(s,e,r.endRule,a,o===n),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function Qf(e,t,a,o,r,n,s){let i=Number.MAX_VALUE,l=null,u,c=0,d=n.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let g=e[p];if(!g.matcher(d))continue;let I=t.getRule(g.ruleId),{ruleScanner:C,findOptions:S}=Fi(I,t,null,o,r===s),x=C.findNextMatchSync(a,r,S);if(!x)continue;let L=x.captureIndices[0].start;if(!(L>=i)&&(i=L,l=x.captureIndices,u=x.ruleId,c=g.priority,i===r))break}return l?{priorityMatch:c===-1,captureIndices:l,matchedRuleId:u}:null}function Fi(e,t,a,o,r){if(Ri){let s=e.compile(t,a),i=Di(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function Jf(e,t,a,o,r){if(Ri){let s=e.compileWhile(t,a),i=Di(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function Di(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function na(e,t,a,o,r,n,s){if(n.length===0)return;let i=t.content,l=Math.min(n.length,s.length),u=[],c=s[0].end;for(let d=0;d<l;d++){let p=n[d];if(p===null)continue;let m=s[d];if(m.length===0)continue;if(m.start>c)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,m.start):r.produce(o,m.start),p.retokenizeCapturedWithRuleId){let I=p.getName(i,s),C=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(i,s),x=C.pushAttributed(S,e),L=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,C,x),y=e.createOnigString(i.substring(0,m.end));Mi(e,y,a&&m.start===0,m.start,L,r,!1,0),ki(y);continue}let g=p.getName(i,s);if(g!==null){let C=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(g,e);u.push(new Yf(C,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Yf=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Zf(e,t,a,o,r,n,s,i){return new tp(e,t,a,o,r,n,s,i)}function gi(e,t,a,o,r){let n=Ga(t,Va),s=Pi.getCompiledRuleId(a,o,r.repository);for(let i of n)e.push({debugSelector:t,matcher:i.matcher,ruleId:s,grammar:r,priority:i.priority})}function Va(e,t){if(t.length<e.length)return!1;let a=0;return e.every(o=>{for(let r=a;r<t.length;r++)if(ep(t[r],o))return a=r+1,!0;return!1})}function ep(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var tp=class{constructor(e,t,a,o,r,n,s,i){if(this._rootScopeName=e,this.balancedBracketSelectors=n,this._onigLib=i,this._basicScopeAttributesProvider=new zf(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=hi(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=Ga(l,Va);for(let c of u)this._tokenTypeMatchers.push({matcher:c.matcher,type:r[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],a=this._rootScopeName,o=e.lookup(a);if(o){let r=o.injections;if(r)for(let s in r)gi(t,s,r[s],this,o);let n=this._grammarRepository.injections(a);n&&n.forEach(s=>{let i=this.getExternalGrammar(s);if(i){let l=i.injectionSelector;l&&gi(t,l,i,this,i)}})}return t.sort((r,n)=>r.priority-n.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=hi(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let o=this._tokenize(e,t,!1,a);return{tokens:o.lineTokens.getResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}tokenizeLine2(e,t,a=0){let o=this._tokenize(e,t,!0,a);return{tokens:o.lineTokens.getBinaryResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}_tokenize(e,t,a,o){this._rootId===-1&&(this._rootId=Pi.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===sr.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=pt.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=sa.createRootAndLookUpScopeName(p,d,this):m=sa.createRoot("unknown",d),t=new sr(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
- `;let n=this.createOnigString(e),s=n.content.length,i=new op(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Mi(this,n,r,0,t,i,!0,o);return ki(n),{lineLength:s,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function hi(e,t){return e=Lf(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var sa=class ze{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let n of a)r=Zo.push(r,n.scopeNames),o=new ze(o,r,n.encodedTokenAttributes);return o}static createRoot(t,a){return new ze(null,new Zo(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),n=new Zo(null,t),s=o.themeProvider.themeMatch(n),i=ze.mergeAttributes(a,r,s);return new ze(null,n,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return ze.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,n=0,s=0;return o!==null&&(r=o.fontStyle,n=o.foregroundId,s=o.backgroundId),pt.set(t,a.languageId,a.tokenType,null,r,n,s)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return ze._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let n of o)r=ze._pushAttributed(r,n,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),n=t.scopePath.push(a),s=o.themeProvider.themeMatch(n),i=ze.mergeAttributes(t.tokenAttributes,r,s);return new ze(t,n,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},sr=class ft{constructor(t,a,o,r,n,s,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=n,this.endRule=s,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new ft(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ft._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?sa.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){ft._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,n,s,i){return new ft(this,t,a,o,r,n,s,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ft(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=sa.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ft(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,sa.fromExtension(o,a.contentNameScopesList))}},ap=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Ga(a,Va).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Ga(a,Va).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},op=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let n=e?.getScopeNames()??[];for(let s of this._tokenTypeOverrides)s.matcher(n)&&(o=pt.set(o,0,s.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(n))}if(r&&(o=pt.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},rp=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let n=this._rawGrammars.get(e);if(!n)return null;this._grammars.set(e,Zf(e,n,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Bi=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new rp(ia.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ia.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new ap(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let n=new Bf(this._syncRegistry,e);for(;n.Q.length>0;)n.Q.map(s=>this._loadSingleGrammar(s.scopeName)),n.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},$a=sr.NULL;f();f();f();f();f();f();var np=/["&'<>`]/g,sp=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,ip=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,lp=/[|\\{}()[\]^$+*?.]/g,Ei=new WeakMap;function _i(e,t){if(e=e.replace(t.subset?up(t.subset):np,o),t.subset||t.escapeOnly)return e;return e.replace(sp,a).replace(ip,o);function a(r,n,s){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,s.charCodeAt(n+2),t)}function o(r,n,s){return t.format(r.charCodeAt(0),s.charCodeAt(n+1),t)}}function up(e){let t=Ei.get(e);return t||(t=dp(e),Ei.set(e,t)),t}function dp(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(lp,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var cp=/[\dA-Fa-f]/;function Oi(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!cp.test(String.fromCharCode(t))?o:o+";"}f();var fp=/\d/;function Ni(e,t,a){let o="&#"+String(e);return a&&t&&!fp.test(String.fromCharCode(t))?o:o+";"}f();f();var Ui=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Xa={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Hi=["cent","copy","divide","gt","lt","not","para","times"];var qi={}.hasOwnProperty,lr={},Ka;for(Ka in Xa)qi.call(Xa,Ka)&&(lr[Xa[Ka]]=Ka);var pp=/[^\dA-Za-z]/;function Wi(e,t,a,o){let r=String.fromCharCode(e);if(qi.call(lr,r)){let n=lr[r],s="&"+n;return a&&Ui.includes(n)&&!Hi.includes(n)&&(!o||t&&t!==61&&pp.test(String.fromCharCode(t)))?s:s+";"}return""}function Gi(e,t,a){let o=Oi(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=Wi(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let n=Ni(e,t,a.omitOptionalSemicolons);n.length<o.length&&(o=n)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function Qe(e,t){return _i(e,Object.assign({format:Gi},t))}var mp=/^>|^->|<!--|-->|--!>|<!-$/g,gp=[">"],hp=["<",">"];function ji(e,t,a,o){return o.settings.bogusComments?"<?"+Qe(e.value,Object.assign({},o.settings.characterReferences,{subset:gp}))+">":"<!--"+e.value.replace(mp,r)+"-->";function r(n){return Qe(n,Object.assign({},o.settings.characterReferences,{subset:hp}))}}f();function zi(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var le=Vi(1),ur=Vi(-1),wp=[];function Vi(e){return t;function t(a,o,r){let n=a?a.children:wp,s=(o||0)+e,i=n[s];if(!r)for(;i&&St(i);)s+=e,i=n[s];return i}}f();var xp={}.hasOwnProperty;function Qa(e){return t;function t(a,o,r){return xp.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var fa=Qa({body:Lp,caption:dr,colgroup:dr,dd:bp,dt:yp,head:dr,html:Cp,li:Sp,optgroup:kp,option:Tp,p:Ip,rp:$i,rt:$i,tbody:Pp,td:Xi,tfoot:Ap,th:Xi,thead:vp,tr:Rp});function dr(e,t,a){let o=le(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&St(o.value.charAt(0)))}function Cp(e,t,a){let o=le(a,t);return!o||o.type!=="comment"}function Lp(e,t,a){let o=le(a,t);return!o||o.type!=="comment"}function Ip(e,t,a){let o=le(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function Sp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="li"}function yp(e,t,a){let o=le(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function bp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function $i(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function kp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function Tp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function vp(e,t,a){let o=le(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Pp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function Ap(e,t,a){return!le(a,t)}function Rp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function Xi(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Ki=Qa({body:Dp,colgroup:Bp,head:Fp,html:Mp,tbody:Ep});function Mp(e){let t=le(e,-1);return!t||t.type!=="comment"}function Fp(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function Dp(e){let t=le(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&St(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Bp(e,t,a){let o=ur(a,t),r=le(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&fa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Ep(e,t,a){let o=ur(a,t),r=le(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&fa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Ja={name:[[`
68
+ `):e}function ts(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:d}=e,c=We("chat",u);return async function(m){c("\u2192 POST",m.url);try{let g=await m.json(),I=g.messages??[],x=g.sessionId,S=g.modelContext,C=r,L=typeof g.extra=="object"&&g.extra!==null&&!Array.isArray(g.extra)?g.extra:void 0,y=g.visitorContext??null,b=Zn(m),P={geo:b,client:y};if(c("body parsed \u2014 messages:",I.length,"sessionId:",x??"(none)","geo:",JSON.stringify(b)),s){c("running beforeRequest hook");try{let D=await s({messages:I,sessionId:x,modelContext:S,request:m,visitor:P});D&&(D.messages&&(I=D.messages),D.systemPrompt!==void 0&&(C=D.systemPrompt),D.sessionId!==void 0&&(x=D.sessionId),D.modelContext!==void 0&&(S=D.modelContext)),c("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",x??"(none)")}catch(D){console.error("[waniwani:chat] beforeRequest hook error:",D);let H=D instanceof Pe?D.status:400,T=D instanceof Error?D.message:"Request rejected";return c("\u2190 returning",H,"from hook error"),Response.json({error:T},{status:H})}}let M=i??(await l()).mcpServerUrl;c("mcpServerUrl:",M),C=es(C,S);let A=`${a}/api/mcp/chat`;c("forwarding to",A);let _=m.headers.get("user-agent"),F=await fetch(A,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:I,mcpServerUrl:M,sessionId:x,source:o,systemPrompt:C,maxSteps:n,visitor:P,webSearch:d,...L&&{extra:L}}),signal:m.signal});if(c("upstream response status:",F.status),!F.ok){let D=await F.text().catch(()=>"");return c("\u2190 returning",F.status,"upstream error:",D),new Response(D,{status:F.status,headers:{"Content-Type":F.headers.get("Content-Type")??"application/json"}})}let E=new Headers({"Content-Type":F.headers.get("Content-Type")??"text/event-stream"}),v=F.headers.get("x-session-id");return v&&E.set("x-session-id",v),c("\u2190 streaming response",F.status,"body null?",F.body===null),new Response(F.body,{status:F.status,headers:E})}catch(g){console.error("[waniwani:chat] handler error:",g);let I=g instanceof Error?g.message:"Unknown error occurred",x=g instanceof Pe?g.status:500;return c("\u2190 returning",x,"from caught error"),Response.json({error:I},{status:x})}}}f();function as(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=We("resource",o);return async function(s){r("\u2192 GET",s.toString());try{let i=s.searchParams.get("uri");if(r("uri:",i??"(missing)"),!i)return r("\u2190 400 missing uri"),Response.json({error:"Missing uri query parameter"},{status:400});let l=t??(await a()).mcpServerUrl;r("mcpServerUrl:",l);let u,d;try{[{createMCPClient:u},{StreamableHTTPClientTransport:d}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(p){return console.error("[waniwani:resource] MCP deps import failed:",p),Response.json({error:"MCP resource handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable resource serving."},{status:501})}r("creating MCP client for",l);let c=await u({transport:new d(new URL(l))});try{r("reading resource:",i);let p=await c.readResource({uri:i});r("resource contents count:",p.contents.length);let m=p.contents[0];if(!m)return r("\u2190 404 resource not found"),Response.json({error:"Resource not found"},{status:404});let g;return"text"in m&&typeof m.text=="string"?g=m.text:"blob"in m&&typeof m.blob=="string"&&(g=atob(m.blob)),g?(r("\u2190 200 HTML length:",g.length),new Response(g,{headers:{"Content-Type":"text/html","Cache-Control":"private, max-age=300"}})):(r("\u2190 404 resource has no content, keys:",Object.keys(m)),Response.json({error:"Resource has no content"},{status:404}))}finally{await c.close(),r("MCP client closed")}}catch(i){console.error("[waniwani:resource] handler error:",i);let l=i instanceof Error?i.message:"Unknown error occurred",u=i instanceof Pe?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function os(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,n=We("tool",o);return async function(i){n("\u2192 POST",i.url);try{let l=await i.json(),{name:u,arguments:d}=l,c=i.headers.get("x-session-id")?.trim();if(!u||typeof u!="string")return n("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});n("tool:",u,"args:",JSON.stringify(d),"sessionId:",c||"(none)");let p=t??(await a()).mcpServerUrl;n("mcpServerUrl:",p);let m,g;try{[{Client:m},{StreamableHTTPClientTransport:g}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),n("MCP deps loaded")}catch(S){return console.error("[waniwani:tool] MCP deps import failed:",S),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}n("creating MCP client for",p);let I=new g(new URL(p)),x=new m({name:"waniwani-tool-caller",version:"1.0.0"});await x.connect(I);try{n("calling tool:",u);let S={};c&&(S["waniwani/sessionId"]=c),r&&(S["waniwani/source"]=r);let C=await x.callTool({name:u,arguments:d??{},...Object.keys(S).length>0?{_meta:S}:{}});return n("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await x.close(),n("MCP client closed")}}catch(l){console.error("[waniwani:tool] handler error:",l);let u=l instanceof Error?l.message:"Unknown error occurred",d=l instanceof Pe?l.status:500;return n("\u2190 returning",d,"from caught error"),Response.json({error:u},{status:d})}}}f();function rs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=We("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let s=t??(await a()).mcpServerUrl;r("mcpServerUrl:",s);let i,l;try{[{createMCPClient:i},{StreamableHTTPClientTransport:l}]=await Promise.all([import("@ai-sdk/mcp"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),r("MCP deps loaded")}catch(d){return console.error("[waniwani:tools-list] MCP deps import failed:",d),Response.json({error:"MCP tools list handler requires @ai-sdk/mcp and @modelcontextprotocol/sdk. Install them to enable tool discovery."},{status:501})}r("creating MCP client for",s);let u=await i({transport:new l(new URL(s))});try{r("listing tools");let d=await u.listTools();r("tools count:",d.tools.length);let c={tools:d.tools.map(p=>({name:p.name,...p.title!==void 0&&{title:p.title},...p.description!==void 0&&{description:p.description},...p.inputSchema!==void 0&&{inputSchema:p.inputSchema},...p.outputSchema!==void 0&&{outputSchema:p.outputSchema},...p.annotations!==void 0&&{annotations:p.annotations},...p._meta!==void 0&&{_meta:p._meta}})),...d.nextCursor!==void 0&&{nextCursor:d.nextCursor}};return r("\u2190 200"),Response.json(c,{headers:{"Cache-Control":"private, max-age=60"}})}finally{await u.close(),r("MCP client closed")}}catch(s){console.error("[waniwani:tools-list] handler error:",s);let i=s instanceof Error?s.message:"Unknown error occurred",l=s instanceof Pe?s.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var _d=300*1e3;function ns(e,t){let a=null,o=null;return async function(){if(a&&Date.now()<a.expiresAt)return a.config;if(o)return o;o=(async()=>{if(!t)throw new Pe("WANIWANI_API_KEY is required for createChatHandler",401);let n=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!n.ok){let i=await n.text().catch(()=>"");throw new Pe(`Failed to resolve MCP environment config: ${n.status} ${i}`,n.status)}let s=await n.json();return a={config:s,expiresAt:Date.now()+_d},s})();try{return await o}finally{o=null}}}var Od="https://app.waniwani.ai";function ss(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=Od,source:o,systemPrompt:r,maxSteps:n=5,beforeRequest:s,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,d=We("router",l),c=Jn(),p=Yn(c),m=ns(a,t),g=ts({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:n,beforeRequest:s,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:Qn(u)}),I=as({mcpServerUrl:i,resolveConfig:m,debug:l}),x=rs({mcpServerUrl:i,resolveConfig:m,debug:l}),S=os({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),C=process.env.WANIWANI_EVAL==="1";async function L(M){d("\u2192 GET",M.url);try{let A=new URL(M.url),F=A.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(d("pathname:",A.pathname,"subRoute:",F),C&&F==="scenarios"){d("dispatching to scenarios handler (proxy to app API)");try{let v=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(v.data??v,200)}catch{return p([],200)}}if(F==="resource"){d("dispatching to resource handler");let E=await I(A);return d("\u2190 resource handler returned",E.status),c(E)}if(F==="config")return d("dispatching to config handler"),p({debug:l,eval:C},200);if(F==="tools"){d("dispatching to tools-list handler");let E=await x();return d("\u2190 tools-list handler returned",E.status),c(E)}return d("\u2190 404 no matching sub-route for",F),p({error:"Not found"},404)}catch(A){console.error("[waniwani:router] GET handler error:",A);let _=A instanceof Error?A.message:"Unknown error occurred";return d("\u2190 500 from caught error"),p({error:_},500)}}async function y(M){d("\u2192 POST",M.url);try{let A=new URL(M.url),F=A.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(d("pathname:",A.pathname,"subRoute:",F),C&&F==="scenarios"){d("dispatching to save-scenario handler (proxy to app API)");try{let v=await M.json(),D=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(v)}),H=await D.json();return D.ok?p({ok:!0,scenario:H.data},200):p({error:H.message??"Failed to save scenario"},D.status)}catch(v){let D=v instanceof Error?v.message:"Failed to save scenario";return p({error:D},400)}}if(F==="tool"){d("dispatching to tool handler");let v=await S(M);return d("\u2190 tool handler returned",v.status),c(v)}d("dispatching to chat handler");let E=await g(M);return c(E)}catch(A){console.error("[waniwani:router] POST handler error:",A);let _=A instanceof Error?A.message:"Unknown error occurred";return d("\u2190 500 from caught error"),p({error:_},500)}}async function b(M){d("\u2192 PATCH",M.url);try{let A=new URL(M.url),_=A.pathname.replace(/\/$/,"").split("/").filter(Boolean),F=_.at(-1),E=_.at(-2);if(d("pathname:",A.pathname,"subRoute:",E,"id:",F),C&&E==="scenarios"&&F){d("dispatching to update-scenario handler (proxy to app API)");try{let v=await M.json(),D=await fetch(`${a}/api/mcp/scenarios/${F}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(v)}),H=await D.json();return D.ok?p({ok:!0,scenario:H.data},200):p({error:H.message??"Failed to update scenario"},D.status)}catch(v){let D=v instanceof Error?v.message:"Failed to update scenario";return p({error:D},400)}}return d("\u2190 404 no matching sub-route for PATCH",E),p({error:"Not found"},404)}catch(A){console.error("[waniwani:router] PATCH handler error:",A);let _=A instanceof Error?A.message:"Unknown error occurred";return d("\u2190 500 from caught error"),p({error:_},500)}}function P(){return c(new Response(null,{status:204}))}return{handleChat:g,handleResource:I,handleTool:S,routeGet:L,routePost:y,routePatch:b,handleOptions:P}}var is=!1;function uL(e,t){!is&&process.env.NODE_ENV!=="test"&&(console.warn("[waniwani-sdk] toNextJsHandler is deprecated; switch to toExpressJsHandler from @waniwani/sdk/express-js. It will be removed in a follow-up release."),is=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",n=ss({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:n.routePost,GET:n.routeGet,PATCH:n.routePatch,OPTIONS:()=>n.handleOptions()}}f();import{forwardRef as Eh,useCallback as Yr,useEffect as _h,useImperativeHandle as Oh,useRef as Fu,useState as Du}from"react";f();f();f();import{forwardRef as Ud,createElement as Hd}from"react";f();var Ma=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var ls=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var us=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var Eo=e=>{let t=us(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as Nd,createElement as fs}from"react";f();var ds={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};f();var cs=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var ps=Nd(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:n,iconNode:s,...i},l)=>fs("svg",{ref:l,...ds,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:Ma("lucide",r),...!n&&!cs(i)&&{"aria-hidden":"true"},...i},[...s.map(([u,d])=>fs(u,d)),...Array.isArray(n)?n:[n]]));var j=(e,t)=>{let a=Ud(({className:o,...r},n)=>Hd(ps,{ref:n,iconNode:t,className:Ma(`lucide-${ls(Eo(e))}`,`lucide-${e}`,o),...r}));return a.displayName=Eo(e),a};f();var qd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],qt=j("arrow-down",qd);f();var Wd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Wt=j("arrow-up",Wd);f();var Gd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Gt=j("check",Gd);f();var jd=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Je=j("chevron-down",jd);f();var zd=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],jt=j("chevron-right",zd);f();var Vd=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],zt=j("clipboard-copy",Vd);f();var $d=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Xe=j("clock",$d);f();var Xd=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Vt=j("file",Xd);f();var Kd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],$t=j("globe",Kd);f();var Qd=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Xt=j("loader",Qd);f();var Jd=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Kt=j("paperclip",Jd);f();var Yd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Qt=j("square",Yd);f();var Zd=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],it=j("wrench",Zd);f();var ec=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lt=j("x",ec);f();var tc=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],Jt=j("zap",tc);import{useCallback as xc}from"react";f();import{useCallback as Ye,useMemo as ac,useRef as oc,useState as _o}from"react";var rc={damping:.7,stiffness:.05,mass:1.25},nc=70,sc=1e3/60,ic=350,Fa=!1;globalThis.document?.addEventListener("mousedown",()=>{Fa=!0});globalThis.document?.addEventListener("mouseup",()=>{Fa=!1});globalThis.document?.addEventListener("click",()=>{Fa=!1});var gs=(e={})=>{let[t,a]=_o(!1),[o,r]=_o(e.initial!==!1),[n,s]=_o(!1),i=oc(null);i.current=e;let l=Ye(()=>{if(!Fa)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let L=C.getRangeAt(0);return L.commonAncestorContainer.contains(x.current)||x.current?.contains(L.commonAncestorContainer)},[]),u=Ye(C=>{c.isAtBottom=C,r(C)},[]),d=Ye(C=>{c.escapedFromLock=C,a(C)},[]),c=ac(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return x.current?.scrollTop??0},set scrollTop(L){x.current&&(x.current.scrollTop=L,c.ignoreScrollToTop=x.current.scrollTop)},get targetScrollTop(){return!x.current||!S.current?0:x.current.scrollHeight-1-x.current.clientHeight},get calculatedTargetScrollTop(){if(!x.current||!S.current)return 0;let{targetScrollTop:L}=this;if(!e.targetScrollTop)return L;if(C?.targetScrollTop===L)return C.calculatedScrollTop;let y=Math.max(Math.min(e.targetScrollTop(L,{scrollElement:x.current,contentElement:S.current}),L),0);return C={targetScrollTop:L,calculatedScrollTop:y},requestAnimationFrame(()=>{C=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=nc}}},[]),p=Ye((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let L=Date.now()+(Number(C.wait)||0),y=No(i.current,C.animation),{ignoreEscapes:b=!1}=C,P,M=c.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{P=Date.now()}):P=L+(C.duration??0);let A=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!c.isAtBottom)return c.animation=void 0,!1;let{scrollTop:F}=c,E=performance.now(),v=(E-(c.lastTick??E))/sc;if(c.animation||(c.animation={behavior:y,promise:_,ignoreEscapes:b}),c.animation.behavior===y&&(c.lastTick=E),l()||L>Date.now())return A();if(F<Math.min(M,c.calculatedTargetScrollTop)){if(c.animation?.behavior===y){if(y==="instant")return c.scrollTop=c.calculatedTargetScrollTop,A();c.velocity=(y.damping*c.velocity+y.stiffness*c.scrollDifference)/y.mass,c.accumulated+=c.velocity*v,c.scrollTop+=c.accumulated,c.scrollTop!==F&&(c.accumulated=0)}return A()}return P>Date.now()?(M=c.calculatedTargetScrollTop,A()):(c.animation=void 0,c.scrollTop<c.calculatedTargetScrollTop?p({animation:No(i.current,i.current.resize),ignoreEscapes:b,duration:Math.max(0,P-Date.now())||void 0}):c.isAtBottom)});return _.then(F=>(requestAnimationFrame(()=>{c.animation||(c.lastTick=void 0,c.velocity=0)}),F))};return C.wait!==!0&&(c.animation=void 0),c.animation?.behavior===y?c.animation.promise:A()},[u,l,c]),m=Ye(()=>{d(!0),u(!1)},[d,u]),g=Ye(({target:C})=>{if(C!==x.current)return;let{scrollTop:L,ignoreScrollToTop:y}=c,{lastScrollTop:b=L}=c;c.lastScrollTop=L,c.ignoreScrollToTop=void 0,y&&y>L&&(b=y),s(c.isNearBottom),setTimeout(()=>{if(c.resizeDifference||L===y)return;if(l()){d(!0),u(!1);return}let P=L>b,M=L<b;if(c.animation?.ignoreEscapes){c.scrollTop=b;return}M&&(d(!0),u(!1)),P&&d(!1),!c.escapedFromLock&&c.isNearBottom&&u(!0)},1)},[d,u,l,c]),I=Ye(({target:C,deltaY:L})=>{let y=C;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===x.current&&L<0&&x.current.scrollHeight>x.current.clientHeight&&!c.animation?.ignoreEscapes&&(d(!0),u(!1))},[d,u,c]),x=ms(C=>{x.current?.removeEventListener("scroll",g),x.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",g,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=ms(C=>{if(c.resizeObserver?.disconnect(),!C)return;let L;c.resizeObserver=new ResizeObserver(([y])=>{let{height:b}=y.contentRect,P=b-(L??b);if(c.resizeDifference=P,c.scrollTop>c.targetScrollTop&&(c.scrollTop=c.targetScrollTop),s(c.isNearBottom),P>=0){let M=No(i.current,L?i.current.resize:i.current.initial);p({animation:M,wait:!0,preserveScrollPosition:!0,duration:M==="instant"?void 0:ic})}else c.isNearBottom&&(d(!1),u(!0));L=b,requestAnimationFrame(()=>{setTimeout(()=>{c.resizeDifference===P&&(c.resizeDifference=0)},1)})}),c.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:x,scrollToBottom:p,stopScroll:m,isAtBottom:o||n,isNearBottom:n,escapedFromLock:t,state:c}};function ms(e,t){let a=Ye(o=>(a.current=o,e(o)),t);return a}var Oo=new Map;function No(...e){let t={...rc},a=!1;for(let r of e){if(r==="instant"){a=!0;continue}typeof r=="object"&&(a=!1,t.damping=r.damping??t.damping,t.stiffness=r.stiffness??t.stiffness,t.mass=r.mass??t.mass)}let o=JSON.stringify(t);return Oo.has(o)||Oo.set(o,Object.freeze(t)),a?"instant":Oo.get(o)}f();import*as ut from"react";import{createContext as lc,useContext as uc,useEffect as dc,useImperativeHandle as cc,useLayoutEffect as fc,useMemo as pc,useRef as mc}from"react";var hs=lc(null),gc=typeof window<"u"?fc:dc;function Yt({instance:e,children:t,resize:a,initial:o,mass:r,damping:n,stiffness:s,targetScrollTop:i,contextRef:l,...u}){let d=mc(null),c=ut.useCallback((b,P)=>(y?.targetScrollTop??i)?.(b,P)??b,[i]),p=gs({mass:r,damping:n,stiffness:s,resize:a,initial:o,targetScrollTop:c}),{scrollRef:m,contentRef:g,scrollToBottom:I,stopScroll:x,isAtBottom:S,escapedFromLock:C,state:L}=e??p,y=pc(()=>({scrollToBottom:I,stopScroll:x,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:g,state:L,get targetScrollTop(){return d.current},set targetScrollTop(b){d.current=b}}),[I,S,g,m,x,C,L]);return cc(l,()=>y,[y]),gc(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),ut.createElement(hs.Provider,{value:y},ut.createElement("div",{...u},typeof t=="function"?t(y):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let n=Uo();return ut.createElement("div",{ref:n.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},ut.createElement("div",{...r,ref:n.contentRef},typeof a=="function"?a(n):a))}e.Content=t})(Yt||(Yt={}));function Uo(){let e=uc(hs);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var hc=un({prefix:"ww"});function R(...e){return hc(ln(e))}f();import{jsx as wc}from"react/jsx-runtime";var Ge=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>wc("button",{type:o,className:R("ww:inline-flex ww:cursor-pointer ww:items-center ww:justify-center ww:rounded-md ww:font-medium ww:transition-colors ww:disabled:pointer-events-none ww:disabled:opacity-50",t==="default"&&"ww:bg-primary ww:text-primary-foreground ww:hover:bg-primary/90",t==="outline"&&"ww:border ww:border-border ww:bg-background ww:hover:bg-accent ww:hover:text-accent-foreground",t==="ghost"&&"ww:hover:bg-accent ww:hover:text-accent-foreground",a==="default"&&"ww:h-9 ww:px-4 ww:py-2 ww:text-sm",a==="sm"&&"ww:h-8 ww:px-3 ww:text-xs",a==="icon"&&"ww:size-9 ww:!rounded-full",a==="icon-sm"&&"ww:size-7 ww:!rounded-full",e),...r});import{jsx as Da}from"react/jsx-runtime";var ws=({className:e,...t})=>Da(Yt,{className:R("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),xs=({className:e,...t})=>Da(Yt.Content,{className:R("ww:flex ww:flex-col ww:gap-6 ww:px-4 ww:py-6 ww:mx-auto ww:w-full ww:max-w-3xl",e),...t}),Cs=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=Uo(),r=xc(()=>{o()},[o]);return!a&&Da(Ge,{className:R("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:Da(qt,{className:"ww:size-4"})})};f();f();import Is from"crypto";f();var Ls="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Cc=128,dt,bt,Lc=e=>{!dt||dt.length<e?(dt=Buffer.allocUnsafe(e*Cc),Is.randomFillSync(dt),bt=0):bt+e>dt.length&&(Is.randomFillSync(dt),bt=0),bt+=e};var Zt=(e=21)=>{Lc(e|=0);let t="";for(let a=bt-e;a<bt;a++)t+=Ls[dt[a]&63];return t};import{createContext as Tc,useCallback as Ke,useContext as vc,useEffect as Go,useMemo as Pc,useRef as jo,useState as Ss}from"react";f();f();import{createContext as yc,useContext as bc,useEffect as qS,useMemo as WS,useState as GS}from"react";f();f();f();f();var qo={promptInput:{placeholder:"What would you like to know?",uploadFiles:"Upload files",stop:"Stop",submit:"Submit",removeAttachments:"Remove all attachments"},workingIndicator:{default:"On it\u2026"},reasoning:{thinking:"Thinking\u2026",thoughtBrief:"Thought for a few seconds",thoughtForSeconds:e=>`Thought for ${e} second${e===1?"":"s"}`},chainOfThought:{working:"Working on it\u2026",done:"Thought process"},tool:{copy:"Copy",copied:"Copied",request:"Request",response:"Response",error:"Error"},attachments:{attachmentFallback:"attachment",fileFallback:"file"},threadMenu:{newChat:"New chat",threadHistory:"Thread history",deleteThread:"Delete thread",noPreviousChats:"No previous chats yet.",hiddenThreads:e=>`${e} older thread${e===1?"":"s"} hidden`},chatQueue:{attachmentFallback:"(attachment)",removeFromQueue:"Remove from queue",queued:e=>`${e} queued`},poweredBy:{label:"AI agent powered by"},aiDisclaimer:{default:"can make mistakes"},exportSession:{saving:"saving...",saved:"saved",error:"error",export:"export",tooltip:"Save scenario to Waniwani"},widgetErrorBoundary:{failedToLoad:"Widget failed to load",retry:"Retry"},launcher:{prompt:"Ask anything\u2026",open:"Open chat",close:"Close chat",minimize:"Minimize"}};f();f();import{jsx as QS}from"react/jsx-runtime";var kc=yc(null);function V(){let e=bc(kc);return e||{locale:"en",t:qo,ready:!0}}f();function Wo(e,t){let a=Date.now()-e;if(a<6e4)try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"narrow"}).format(0,"second")}catch{return"just now"}let o,r;a<60*6e4?(o=-Math.floor(a/6e4),r="minute"):a<1440*6e4?(o=-Math.floor(a/(60*6e4)),r="hour"):(o=-Math.floor(a/(1440*6e4)),r="day");try{return new Intl.RelativeTimeFormat(t,{numeric:"auto",style:"short"}).format(o,r)}catch{return`${Math.abs(o)}${r==="minute"?"m":r==="hour"?"h":"d"} ago`}}import{jsx as _e,jsxs as As}from"react/jsx-runtime";var Ac=async e=>{try{let a=await(await fetch(e)).blob();return new Promise(o=>{let r=new FileReader;r.onloadend=()=>o(r.result),r.onerror=()=>o(null),r.readAsDataURL(a)})}catch{return null}},ys=Tc(null),bs=()=>{let e=vc(ys);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},ks=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:n,onSubmit:s,children:i,...l})=>{let{t:u}=V(),d=jo(null),c=jo(null),[p,m]=Ss([]),g=jo(p);Go(()=>{g.current=p},[p]);let I=Ke(()=>{d.current?.click()},[]),x=Ke(P=>{let M=[...P];if(M.length===0)return;let A=F=>n?F.size<=n:!0,_=M.filter(A);m(F=>{let E=typeof r=="number"?Math.max(0,r-F.length):void 0,v=typeof E=="number"?_.slice(0,E):_;return[...F,...v.map(D=>({filename:D.name,id:Zt(),mediaType:D.type,type:"file",url:URL.createObjectURL(D)}))]})},[r,n]),S=Ke(P=>{m(M=>{let A=M.find(_=>_.id===P);return A?.url&&URL.revokeObjectURL(A.url),M.filter(_=>_.id!==P)})},[]),C=Ke(()=>{m(P=>{for(let M of P)M.url&&URL.revokeObjectURL(M.url);return[]})},[]);Go(()=>()=>{for(let P of g.current)P.url&&URL.revokeObjectURL(P.url)},[]);let L=Ke(P=>{P.currentTarget.files&&x(P.currentTarget.files),P.currentTarget.value=""},[x]);Go(()=>{if(!o)return;let P=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault()},M=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault(),A.dataTransfer?.files&&A.dataTransfer.files.length>0&&x(A.dataTransfer.files)};return document.addEventListener("dragover",P),document.addEventListener("drop",M),()=>{document.removeEventListener("dragover",P),document.removeEventListener("drop",M)}},[x,o]);let y=Ke(async P=>{P.preventDefault();let M=P.currentTarget,_=new FormData(M).get("message")||"";M.reset();let F=await Promise.all(p.map(async({id:E,...v})=>{if(v.url?.startsWith("blob:")){let D=await Ac(v.url);return{...v,url:D??v.url}}return v}));try{let E=s({files:F,text:_},P);E instanceof Promise&&await E,C()}catch{}},[p,s,C]),b=Pc(()=>({add:x,clear:C,files:p,openFileDialog:I,remove:S}),[p,x,S,C,I]);return As(ys.Provider,{value:b,children:[_e("input",{accept:t,"aria-label":u.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:L,ref:d,title:u.promptInput.uploadFiles,type:"file"}),_e("form",{className:R("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:y,ref:c,...l,children:i})]})};var Ts=({onChange:e,onKeyDown:t,className:a,placeholder:o,...r})=>{let{t:n}=V(),s=bs(),[i,l]=Ss(!1),u=o??n.promptInput.placeholder,d=Ke(p=>{if(t?.(p),!p.defaultPrevented){if(p.key==="Enter"){if(i||p.nativeEvent.isComposing||p.shiftKey)return;p.preventDefault();let{form:m}=p.currentTarget;if(m?.querySelector('button[type="submit"]')?.disabled)return;m?.requestSubmit()}if(p.key==="Backspace"&&p.currentTarget.value===""&&s.files.length>0){p.preventDefault();let m=s.files.at(-1);m&&s.remove(m.id)}}},[t,i,s]),c=Ke(p=>{let m=p.clipboardData?.items;if(!m)return;let g=[];for(let I of m)if(I.kind==="file"){let x=I.getAsFile();x&&g.push(x)}g.length>0&&(p.preventDefault(),s.add(g))},[s]);return _e("textarea",{className:R("ww:field-sizing-content ww:max-h-48 ww:min-h-0 ww:w-full ww:resize-none ww:border-0 ww:bg-transparent ww:px-3 ww:py-2 ww:text-base ww:sm:text-sm ww:outline-none ww:placeholder:text-muted-foreground",a),name:"message",onCompositionEnd:()=>l(!1),onCompositionStart:()=>l(!0),onKeyDown:d,onPaste:c,placeholder:u,onChange:e,...r})},vs=({className:e,status:t,onStop:a,onClick:o,children:r,...n})=>{let{t:s}=V(),i=t==="submitted"||t==="streaming",l=_e(Wt,{className:"ww:size-4"});t==="submitted"?l=_e(Xt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=_e(Qt,{className:"ww:size-4"}));let u=Ke(d=>{if(i&&a){d.preventDefault(),a();return}o?.(d)},[i,a,o]);return _e(Ge,{"aria-label":i?s.promptInput.stop:s.promptInput.submit,className:R("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:u,size:"icon-sm",type:i&&a?"button":"submit",variant:"ghost",...n,children:r??l})},Ps=({className:e,children:t,...a})=>{let{t:o}=V(),r=bs();return r.files.length>0?As(Ge,{className:R("ww:group ww:relative",e),onClick:()=>r.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":o.promptInput.removeAttachments,...a,children:[_e("span",{className:"ww:flex ww:size-5 ww:items-center ww:justify-center ww:rounded-full ww:bg-primary ww:text-[10px] ww:font-medium ww:text-primary-foreground ww:transition-opacity ww:group-hover:opacity-0",children:r.files.length}),_e(lt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):_e(Ge,{className:R(e),onClick:()=>r.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??_e(Kt,{className:"ww:size-4"})})};f();import{memo as Rc,useCallback as Mc}from"react";f();import{jsx as kt}from"react/jsx-runtime";var Rs=({className:e,...t})=>kt("div",{className:R("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),Ms=({className:e,...t})=>kt("li",{className:R("ww:group ww:flex ww:items-center ww:gap-2 ww:rounded-md ww:px-2 ww:py-1 ww:text-sm ww:transition-colors ww:hover:bg-muted",e),...t}),Fs=({className:e,...t})=>kt("span",{className:R("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),Ds=({className:e,...t})=>kt("span",{className:R("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),Bs=({className:e,...t})=>kt("div",{className:R("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),Es=({className:e,...t})=>kt(Ge,{className:R("ww:size-auto ww:rounded ww:p-1 ww:text-muted-foreground ww:hover:bg-muted-foreground/10 ww:hover:text-foreground",e),size:"icon",type:"button",variant:"ghost",...t});import{jsx as Ze,jsxs as Ns}from"react/jsx-runtime";var _s=Rc(({message:e,onRemove:t})=>{let{t:a}=V(),o=Mc(()=>t(e.id),[t,e.id]);return Ns(Ms,{children:[Ze(Fs,{}),Ze(Ds,{children:e.text||a.chatQueue.attachmentFallback}),Ze(Bs,{children:Ze(Es,{"aria-label":a.chatQueue.removeFromQueue,onClick:o,children:Ze(lt,{className:"ww:size-3"})})})]})});_s.displayName="ChatQueueItem";function Os({queuedMessages:e,onRemove:t,className:a}){let{t:o}=V();return e.length===0?null:Ns(Rs,{className:R("ww:border-t ww:border-border",a),children:[Ze("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:o.chatQueue.queued(e.length)}),Ze("ul",{children:e.map(r=>Ze(_s,{message:r,onRemove:t},r.id))})]})}f();import{useState as Us}from"react";import{jsx as Fc}from"react/jsx-runtime";function Hs({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let{t:o}=V(),[r,n]=Us(!1),[s,i]=Us(null),l=async()=>{let d={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};n(!0),i(null);try{let c=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!c.ok)throw new Error(`${c.status}`);i("saved")}catch{i("error")}finally{n(!1),setTimeout(()=>i(null),2e3)}};if(!t||e.length===0)return null;let u=r?o.exportSession.saving:s==="saved"?o.exportSession.saved:s==="error"?o.exportSession.error:o.exportSession.export;return Fc("button",{type:"button",onClick:l,disabled:r,title:o.exportSession.tooltip,className:"ww:ml-auto ww:text-[10px] ww:font-mono ww:uppercase ww:tracking-wider ww:text-muted-foreground hover:ww:text-foreground ww:cursor-pointer ww:transition-colors ww:disabled:opacity-40",children:u})}f();f();import{jsx as ea,jsxs as Bc}from"react/jsx-runtime";var qs=({files:e,className:t,...a})=>e.length===0?null:ea("div",{className:R("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>ea(Dc,{file:o},r))});function Dc({file:e}){let{t}=V();return e.mediaType?.startsWith("image/")&&e.url?ea("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):Bc("span",{className:"ww:inline-flex ww:items-center ww:gap-1.5 ww:rounded ww:bg-background/20 ww:px-2 ww:py-1 ww:text-xs",children:[ea(Vt,{className:"ww:size-3 ww:shrink-0"}),ea("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}f();import{createContext as Vc,useCallback as $c,useContext as Xc,useEffect as Kc,useMemo as Qc,useState as Xo}from"react";f();import{createContext as Nc,memo as $o,useCallback as Uc,useContext as Hc,useEffect as zo,useMemo as qc,useRef as Ws,useState as Vo}from"react";f();f();import{memo as Ec}from"react";import{jsx as Oc}from"react/jsx-runtime";var _c=({as:e="span",className:t,duration:a=2,style:o,children:r,...n})=>{let s={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 Oc(e,{"data-waniwani-shimmer":"",className:R("ww:inline-block",t),style:s,...n,children:r})},Oe=Ec(_c);Oe.displayName="Shimmer";import{Fragment as jc,jsx as Ne,jsxs as zc}from"react/jsx-runtime";var Gs=Nc(null);function js(){let e=Hc(Gs);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Wc=1e3,Gc=1e3,ta=$o(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:n,children:s,...i})=>{let l=o??t,u=o===!1,d=a!==void 0,[c,p]=Vo(l),m=d?a:c,g=Uc(M=>{d||p(M),r?.(M)},[d,r]),[I,x]=Vo(void 0),S=n??I,C=Ws(t),[L,y]=Vo(!1),b=Ws(null);zo(()=>{t?(C.current=!0,b.current===null&&(b.current=Date.now())):b.current!==null&&(x(Math.ceil((Date.now()-b.current)/Gc)),b.current=null)},[t]),zo(()=>{t&&!m&&!u&&g(!0)},[t,m,u,g]),zo(()=>{if(C.current&&!t&&m&&!L){let M=setTimeout(()=>{g(!1),y(!0)},Wc);return()=>clearTimeout(M)}},[t,m,L,g]);let P=qc(()=>({isStreaming:t,isOpen:m,setIsOpen:g,duration:S}),[t,m,g,S]);return Ne(Gs.Provider,{value:P,children:Ne("div",{className:R("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:s})})});ta.displayName="Reasoning";var aa=$o(({className:e,children:t,getThinkingMessage:a,hideIcon:o=!1,onClick:r,...n})=>{let{t:s}=V(),{isStreaming:i,isOpen:l,duration:u,setIsOpen:d}=js(),p=a??((m,g)=>m||g===0?Ne(Oe,{duration:1.6,children:s.reasoning.thinking}):g===void 0?Ne("span",{children:s.reasoning.thoughtBrief}):Ne("span",{children:s.reasoning.thoughtForSeconds(g)}));return Ne("button",{type:"button","aria-expanded":l,onClick:m=>{d(!l),r?.(m)},className:R("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),...n,children:t??zc(jc,{children:[!o&&Ne(Xe,{className:"ww:size-4 ww:shrink-0"}),p(i,u)]})})});aa.displayName="ReasoningTrigger";var oa=$o(({className:e,children:t,...a})=>{let{isOpen:o}=js();return Ne("div",{className:R("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:Ne("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Ne("div",{className:R("ww:text-sm ww:text-muted-foreground",e),...a,children:Ne(Ft,{children:t})})})})});oa.displayName="ReasoningContent";import{jsx as Z,jsxs as et}from"react/jsx-runtime";var Jc=500,zs=Vc(null);function Vs(){let e=Xc(zs);if(!e)throw new Error("ChainOfThought components must be used within <ChainOfThought>");return e}function $s({className:e,isWorking:t=!1,activeStep:a,open:o,defaultOpen:r=!1,onOpenChange:n,children:s,...i}){let l=o!==void 0,[u,d]=Xo(r),c=l?o:u,p=$c(x=>{l||d(x),n?.(x)},[l,n]),[m,g]=Xo(!t);Kc(()=>{if(t){g(!1);return}let x=setTimeout(()=>g(!0),Jc);return()=>clearTimeout(x)},[t]);let I=Qc(()=>({open:c,setOpen:p,isWorking:t,settled:m,activeStep:a}),[c,p,t,m,a]);return Z(zs.Provider,{value:I,children:Z("div",{className:R("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":c?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:s})})}function Xs({className:e,label:t,workingLabel:a,children:o,...r}){let{open:n,setOpen:s,isWorking:i,settled:l,activeStep:u}=Vs();if(!l){let d=u?.icon,c=u?.label??a??t??"";return Z("div",{className:R("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground",e),children:et("span",{className:"ww:flex ww:min-w-0 ww:items-center ww:gap-1.5",style:{animation:"ww-fade-in 0.25s ease-out"},children:[d&&Z(d,{className:R("ww:size-4 ww:shrink-0",i&&"ww:animate-pulse")}),Z("span",{className:"ww:truncate",children:i?Z(Oe,{duration:2.6,children:c}):c})]},c)})}return et("button",{type:"button",onClick:()=>s(!n),"aria-expanded":n,className:R("ww:flex ww:min-h-5 ww:w-full ww:items-center ww:gap-1.5 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),style:{animation:"ww-fade-in 0.25s ease-out"},...r,children:[Z("span",{className:"ww:truncate",children:o??t}),Z(Je,{className:R("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",n&&"ww:rotate-180")})]})}function Ks({className:e,children:t,...a}){let{open:o}=Vs();return Z("div",{className:R("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:Z("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Z("div",{className:R("ww:flex ww:flex-col",e),...a,children:t})})})}function Qs({icon:e,isLast:t,running:a,error:o}){return et("div",{className:"ww:flex ww:flex-col ww:items-center ww:self-stretch",children:[Z("span",{className:"ww:flex ww:h-5 ww:items-center",children:Z(e,{className:R("ww:size-4 ww:shrink-0",o?"ww:text-destructive":a?"ww:animate-pulse ww:text-foreground":"ww:text-muted-foreground")})}),!t&&Z("span",{className:"ww:w-px ww:flex-1 ww:bg-border"})]})}function Ko({className:e,icon:t,title:a,state:o,isLast:r=!1,children:n,...s}){let i=o==="input-available"||o==="input-streaming",l=o==="output-error",u=n!=null,[d,c]=Xo(!1),p=a??"",m=i?Z(Oe,{duration:1.6,children:p}):Z("span",{className:"ww:truncate",children:p});return et("div",{className:R("ww:flex ww:gap-2",e),...s,children:[Z(Qs,{icon:t,isLast:r,running:i,error:l}),et("div",{className:R("ww:min-w-0 ww:flex-1",!r&&"ww:pb-3"),children:[u?et("button",{type:"button",onClick:()=>c(g=>!g),"aria-expanded":d,className:"ww:flex ww:w-full ww:items-center ww:gap-1.5 ww:text-left ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",children:[m,Z(Je,{className:R("ww:size-3.5 ww:shrink-0 ww:transition-transform ww:duration-200",d&&"ww:rotate-180")})]}):Z("div",{className:"ww:flex ww:items-center ww:text-sm ww:text-muted-foreground",children:m}),u&&Z("div",{className:R("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",d?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:Z("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Z("div",{className:"ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",children:n})})})]})]})}function Js({isStreaming:e=!1,isLast:t=!1,children:a}){return et("div",{className:"ww:flex ww:gap-2",children:[Z(Qs,{icon:Xe,isLast:t,running:e}),Z("div",{className:R("ww:min-w-0 ww:flex-1",!t&&"ww:pb-3"),children:et(ta,{isStreaming:e,className:"ww:mb-0",children:[Z(aa,{hideIcon:!0}),Z(oa,{children:a})]})})]})}f();f();f();f();f();f();var we={carriageReturn:-5,lineFeed:-4,carriageReturnLineFeed:-3,horizontalTab:-2,virtualSpace:-1,eof:null,nul:0,soh:1,stx:2,etx:3,eot:4,enq:5,ack:6,bel:7,bs:8,ht:9,lf:10,vt:11,ff:12,cr:13,so:14,si:15,dle:16,dc1:17,dc2:18,dc3:19,dc4:20,nak:21,syn:22,etb:23,can:24,em:25,sub:26,esc:27,fs:28,gs:29,rs:30,us:31,space:32,exclamationMark:33,quotationMark:34,numberSign:35,dollarSign:36,percentSign:37,ampersand:38,apostrophe:39,leftParenthesis:40,rightParenthesis:41,asterisk:42,plusSign:43,comma:44,dash:45,dot:46,slash:47,digit0:48,digit1:49,digit2:50,digit3:51,digit4:52,digit5:53,digit6:54,digit7:55,digit8:56,digit9:57,colon:58,semicolon:59,lessThan:60,equalsTo:61,greaterThan:62,questionMark:63,atSign:64,uppercaseA:65,uppercaseB:66,uppercaseC:67,uppercaseD:68,uppercaseE:69,uppercaseF:70,uppercaseG:71,uppercaseH:72,uppercaseI:73,uppercaseJ:74,uppercaseK:75,uppercaseL:76,uppercaseM:77,uppercaseN:78,uppercaseO:79,uppercaseP:80,uppercaseQ:81,uppercaseR:82,uppercaseS:83,uppercaseT:84,uppercaseU:85,uppercaseV:86,uppercaseW:87,uppercaseX:88,uppercaseY:89,uppercaseZ:90,leftSquareBracket:91,backslash:92,rightSquareBracket:93,caret:94,underscore:95,graveAccent:96,lowercaseA:97,lowercaseB:98,lowercaseC:99,lowercaseD:100,lowercaseE:101,lowercaseF:102,lowercaseG:103,lowercaseH:104,lowercaseI:105,lowercaseJ:106,lowercaseK:107,lowercaseL:108,lowercaseM:109,lowercaseN:110,lowercaseO:111,lowercaseP:112,lowercaseQ:113,lowercaseR:114,lowercaseS:115,lowercaseT:116,lowercaseU:117,lowercaseV:118,lowercaseW:119,lowercaseX:120,lowercaseY:121,lowercaseZ:122,leftCurlyBrace:123,verticalBar:124,rightCurlyBrace:125,tilde:126,del:127,byteOrderMarker:65279,replacementCharacter:65533};f();var je={attentionSideAfter:2,attentionSideBefore:1,atxHeadingOpeningFenceSizeMax:6,autolinkDomainSizeMax:63,autolinkSchemeSizeMax:32,cdataOpeningString:"CDATA[",characterGroupPunctuation:2,characterGroupWhitespace:1,characterReferenceDecimalSizeMax:7,characterReferenceHexadecimalSizeMax:6,characterReferenceNamedSizeMax:31,codeFencedSequenceSizeMin:3,contentTypeContent:"content",contentTypeDocument:"document",contentTypeFlow:"flow",contentTypeString:"string",contentTypeText:"text",hardBreakPrefixSizeMin:2,htmlBasic:6,htmlCdata:5,htmlComment:2,htmlComplete:7,htmlDeclaration:4,htmlInstruction:3,htmlRawSizeMax:8,htmlRaw:1,linkResourceDestinationBalanceMax:32,linkReferenceSizeMax:999,listItemValueSizeMax:10,numericBaseDecimal:10,numericBaseHexadecimal:16,tabSize:4,thematicBreakMarkerCountMin:3,v8MaxSafeChunkSize:1e4};f();var Re={data:"data",whitespace:"whitespace",lineEnding:"lineEnding",lineEndingBlank:"lineEndingBlank",linePrefix:"linePrefix",lineSuffix:"lineSuffix",atxHeading:"atxHeading",atxHeadingSequence:"atxHeadingSequence",atxHeadingText:"atxHeadingText",autolink:"autolink",autolinkEmail:"autolinkEmail",autolinkMarker:"autolinkMarker",autolinkProtocol:"autolinkProtocol",characterEscape:"characterEscape",characterEscapeValue:"characterEscapeValue",characterReference:"characterReference",characterReferenceMarker:"characterReferenceMarker",characterReferenceMarkerNumeric:"characterReferenceMarkerNumeric",characterReferenceMarkerHexadecimal:"characterReferenceMarkerHexadecimal",characterReferenceValue:"characterReferenceValue",codeFenced:"codeFenced",codeFencedFence:"codeFencedFence",codeFencedFenceSequence:"codeFencedFenceSequence",codeFencedFenceInfo:"codeFencedFenceInfo",codeFencedFenceMeta:"codeFencedFenceMeta",codeFlowValue:"codeFlowValue",codeIndented:"codeIndented",codeText:"codeText",codeTextData:"codeTextData",codeTextPadding:"codeTextPadding",codeTextSequence:"codeTextSequence",content:"content",definition:"definition",definitionDestination:"definitionDestination",definitionDestinationLiteral:"definitionDestinationLiteral",definitionDestinationLiteralMarker:"definitionDestinationLiteralMarker",definitionDestinationRaw:"definitionDestinationRaw",definitionDestinationString:"definitionDestinationString",definitionLabel:"definitionLabel",definitionLabelMarker:"definitionLabelMarker",definitionLabelString:"definitionLabelString",definitionMarker:"definitionMarker",definitionTitle:"definitionTitle",definitionTitleMarker:"definitionTitleMarker",definitionTitleString:"definitionTitleString",emphasis:"emphasis",emphasisSequence:"emphasisSequence",emphasisText:"emphasisText",escapeMarker:"escapeMarker",hardBreakEscape:"hardBreakEscape",hardBreakTrailing:"hardBreakTrailing",htmlFlow:"htmlFlow",htmlFlowData:"htmlFlowData",htmlText:"htmlText",htmlTextData:"htmlTextData",image:"image",label:"label",labelText:"labelText",labelLink:"labelLink",labelImage:"labelImage",labelMarker:"labelMarker",labelImageMarker:"labelImageMarker",labelEnd:"labelEnd",link:"link",paragraph:"paragraph",reference:"reference",referenceMarker:"referenceMarker",referenceString:"referenceString",resource:"resource",resourceDestination:"resourceDestination",resourceDestinationLiteral:"resourceDestinationLiteral",resourceDestinationLiteralMarker:"resourceDestinationLiteralMarker",resourceDestinationRaw:"resourceDestinationRaw",resourceDestinationString:"resourceDestinationString",resourceMarker:"resourceMarker",resourceTitle:"resourceTitle",resourceTitleMarker:"resourceTitleMarker",resourceTitleString:"resourceTitleString",setextHeading:"setextHeading",setextHeadingText:"setextHeadingText",setextHeadingLine:"setextHeadingLine",setextHeadingLineSequence:"setextHeadingLineSequence",strong:"strong",strongSequence:"strongSequence",strongText:"strongText",thematicBreak:"thematicBreak",thematicBreakSequence:"thematicBreakSequence",blockQuote:"blockQuote",blockQuotePrefix:"blockQuotePrefix",blockQuoteMarker:"blockQuoteMarker",blockQuotePrefixWhitespace:"blockQuotePrefixWhitespace",listOrdered:"listOrdered",listUnordered:"listUnordered",listItemIndent:"listItemIndent",listItemMarker:"listItemMarker",listItemPrefix:"listItemPrefix",listItemPrefixWhitespace:"listItemPrefixWhitespace",listItemValue:"listItemValue",chunkDocument:"chunkDocument",chunkContent:"chunkContent",chunkFlow:"chunkFlow",chunkText:"chunkText",chunkString:"chunkString"};f();f();f();function Ys(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Zs(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function ei(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function ti(e){return Ys(e)?"ambiguous":Zs(e)?"fullwidth":e===8361||e>=65377&&e<=65470||e>=65474&&e<=65479||e>=65482&&e<=65487||e>=65490&&e<=65495||e>=65498&&e<=65500||e>=65512&&e<=65518?"halfwidth":e>=32&&e<=126||e===162||e===163||e===165||e===166||e===172||e===175||e>=10214&&e<=10221||e===10629||e===10630?"narrow":ei(e)?"wide":"neutral"}function Yc(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ai(e){return Yc(e),ti(e)}var Zc=Object.defineProperty,ef=(e,t,a)=>t in e?Zc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,tf=(e,t,a)=>ef(e,typeof t!="symbol"?t+"":t,a);function af(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function of(e){if(!e||e<4352)return!1;switch(ai(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!af(e);case"narrow":return!1;case"ambiguous":return 917760<=e&&e<=917999?null:!1;case"neutral":return new RegExp("^\\p{sc=Hangul}","u").test(String.fromCodePoint(e))}}function rf(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function nf(e){return e!==null&&e>=65024&&e<=65038}var sf=oi(new RegExp("\\p{P}|\\p{S}","u")),lf=oi(/\s/);function oi(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var Me;(e=>{e.spaceOrPunctuation=3,e.cjk=4096,e.cjkPunctuation=4098,e.ivs=8192,e.cjkOrIvs=12288,e.nonEmojiGeneralUseVS=16384,e.variationSelector=24576,e.ivsToCjkRightShift=1})(Me||(Me={}));function tt(e){if(e===we.eof||wn(e)||lf(e))return je.characterGroupWhitespace;let t=0;if(e>=4352){if(nf(e))return Me.nonEmojiGeneralUseVS;switch(of(e)){case null:return Me.ivs;case!0:t|=Me.cjk;break}}return sf(e)&&(t|=je.characterGroupPunctuation),t}function Ba(e,t,a){if(!df(e))return e;let o=t(),r=tt(o);return!o||ct(r)?e:rf(o,a)?Me.cjkPunctuation:uf(r)}function uf(e){return e&~Me.ivs}function ct(e){return!!(e&je.characterGroupWhitespace)}function Tt(e){return(e&Me.cjkPunctuation)===je.characterGroupPunctuation}function ra(e){return!!(e&Me.cjk)}function ri(e){return e===Me.ivs}function ni(e){return!!(e&Me.cjkOrIvs)}function df(e){return e===Me.nonEmojiGeneralUseVS}function Qo(e){return!!(e&Me.spaceOrPunctuation)}function Ea(e){return!!(e&&e>=55296&&e<=56319)}function _a(e){return!!(e&&e>=56320&&e<=57343)}function Oa(e,t,a){if(t._bufferIndex<2)return e;let r=a({start:{...t,_bufferIndex:t._bufferIndex-2},end:t}).codePointAt(0);return r&&r>=65536?r:e}function cf(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,n=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),s=n.charCodeAt(n.length-1);if(Number.isNaN(s))return null;if(n.length<2||s<56320||57343<s)return s;let i=n.codePointAt(0);return i&&i>=65536?i:s}var Na=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,tf(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=cf(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Ua(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var Jo={name:"attention",resolveAll:ff,tokenize:pf};function ff(e,t){let a=-1,o,r,n,s,i,l,u,d;for(;++a<e.length;)if(e[a][0]==="enter"&&e[a][1].type==="attentionSequence"&&e[a][1]._close){for(o=a;o--;)if(e[o][0]==="exit"&&e[o][1].type==="attentionSequence"&&e[o][1]._open&&t.sliceSerialize(e[o][1]).charCodeAt(0)===t.sliceSerialize(e[a][1]).charCodeAt(0)){if((e[o][1]._close||e[a][1]._open)&&(e[a][1].end.offset-e[a][1].start.offset)%3&&!((e[o][1].end.offset-e[o][1].start.offset+e[a][1].end.offset-e[a][1].start.offset)%3))continue;l=e[o][1].end.offset-e[o][1].start.offset>1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;let c={...e[o][1].end},p={...e[a][1].start};si(c,-l),si(p,l),s={type:l>1?Re.strongSequence:Re.emphasisSequence,start:c,end:{...e[o][1].end}},i={type:l>1?Re.strongSequence:Re.emphasisSequence,start:{...e[a][1].start},end:p},n={type:l>1?Re.strongText:Re.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?Re.strong:Re.emphasis,start:{...s.start},end:{...i.end}},e[o][1].end={...s.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=It(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=It(u,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",n,t]]),t.parser.constructs.insideSpan.null,u=It(u,ka(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=It(u,[["exit",n,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(d=2,u=It(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):d=0,Lt(e,o-1,a-o+3,u),a=o+u.length-d-2;break}}for(a=-1;++a<e.length;)e[a][1].type==="attentionSequence"&&(e[a][1].type="data");return e}function pf(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:n}=this,s=_a(n)?Oa(n,o(),r):n,i=tt(s),l=new Na(s,o(),r),u=Ba(i,l.value.bind(l),s),d;return c;function c(m){return m===we.asterisk||we.underscore,d=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===d)return e.consume(m),p;let g=e.exit("attentionSequence"),I=Ea(m)?Ua(m,o(),r):m,x=tt(I);let S=Tt(u),C=S||ct(u),L=Tt(x),y=L||ct(x),b=ni(u),P=!y||L&&(C||b)||a.includes(m),M=!C||S&&(y||ra(x))||a.includes(s);return g._open=!!(d===we.asterisk?P:P&&(Qo(u)||!M)),g._close=!!(d===we.asterisk?M:M&&(Qo(x)||!P)),t(m)}}function si(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function ii(){return{text:{[we.asterisk]:Jo,[we.underscore]:Jo},insideSpan:{null:[Jo]}}}function li(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(ii())}f();f();function ui(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:n,resolveAll:r};return a==null&&(a=!0),{text:{[we.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[we.tilde]}};function r(s,i){let l=-1;for(;++l<s.length;)if(s[l][0]==="enter"&&s[l][1].type==="strikethroughSequenceTemporary"&&s[l][1]._close){let u=l;for(;u--;)if(s[u][0]==="exit"&&s[u][1].type==="strikethroughSequenceTemporary"&&s[u][1]._open&&s[l][1].end.offset-s[l][1].start.offset===s[u][1].end.offset-s[u][1].start.offset){s[l][1].type="strikethroughSequence",s[u][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},s[u][1].start),end:Object.assign({},s[l][1].end)},c={type:"strikethroughText",start:Object.assign({},s[u][1].end),end:Object.assign({},s[l][1].start)},p=[["enter",d,i],["enter",s[u][1],i],["exit",s[u][1],i],["enter",c,i]],m=i.parser.constructs.insideSpan.null;m&&Lt(p,p.length,0,ka(m,s.slice(u+1,l),i)),Lt(p,p.length,0,[["exit",c,i],["enter",s[l][1],i],["exit",s[l][1],i],["exit",d,i]]),Lt(s,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<s.length;)s[l][1].type==="strikethroughSequenceTemporary"&&(s[l][1].type=Re.data);return s}function n(s,i,l){let{now:u,sliceSerialize:d,previous:c}=this,p=_a(c)?Oa(c,u(),d):c,m=tt(p),g=new Na(p,u(),d),I=Ba(m,g.value.bind(g),p),x=this.events,S=0;return C;function C(y){return we.tilde,p===we.tilde&&x[x.length-1][1].type!==Re.characterEscape?l(y):(s.enter("strikethroughSequenceTemporary"),L(y))}function L(y){let b=tt(p);if(y===we.tilde)return S>1?l(y):(s.consume(y),S++,L);if(S<2&&!a)return l(y);let P=s.exit("strikethroughSequenceTemporary"),M=Ea(y)?Ua(y,u(),d):y,A=tt(M),F=Tt(I)||ct(I),v=Tt(A)||ct(A),D=ra(I)||ri(b);return P._open=!v||A===je.attentionSideAfter&&(F||D),P._close=!F||b===je.attentionSideAfter&&(v||ra(A)),i(y)}}}function di(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(ui(e))}var mf=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),gf=/^(https?:\/\/|mailto:|www\.)/i,hf=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},wf=e=>{let t=0;for(let a of e){if(mf.has(a))return t;t+=a.length}return null},xf=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Cf=e=>({type:"text",value:e}),Lf=()=>e=>{dn(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!hf(t)||!gf.test(t.url))return;let r=wf(t.url);if(r===null||r===0)return;let n=t.url.slice(0,r),s=t.url.slice(r),i=xf(n,t),l=Cf(s);return o.children.splice(a,1,i,l),a+1})};function If(){let e=[li],t=[Lf,di],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Yo=If();f();f();f();f();f();var re=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Sf(e){return lr(e)}function lr(e){return Array.isArray(e)?yf(e):e instanceof RegExp?e:typeof e=="object"?bf(e):e}function yf(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=lr(e[a]);return t}function bf(e){let t={};for(let a in e)t[a]=lr(e[a]);return t}function Ci(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Li(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Li(e.substring(0,e.length-1)):e.substr(~t+1)}var Zo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ha=class{static hasCaptures(e){return e===null?!1:(Zo.lastIndex=0,Zo.test(e))}static replaceCaptures(e,t,a){return e.replace(Zo,(o,r,n,s)=>{let i=a[parseInt(r||n,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(s){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function Ii(e,t){return e<t?-1:e>t?1:0}function Si(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let a=e.length,o=t.length;if(a===o){for(let r=0;r<a;r++){let n=Ii(e[r],t[r]);if(n!==0)return n}return 0}return a-o}function ci(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function yi(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var bi=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},ia=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(vf(e),t)}static createFromParsedTheme(e,t){return Af(e,t)}_cachedMatchRoot=new bi(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,o=this._cachedMatchRoot.get(t).find(r=>kf(e.parent,r.parentScopes));return o?new ki(o.fontStyle,o.foreground,o.background):null}},er=class qa{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new qa(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new qa(a,t[o]);return a}push(t){return new qa(this,t)}getSegments(){let t=this,a=[];for(;t;)a.push(t.scopeName),t=t.parent;return a.reverse(),a}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push(o.scopeName),o=o.parent;return o===t?a.reverse():void 0}};function kf(e,t){if(t.length===0)return!0;for(let a=0;a<t.length;a++){let o=t[a],r=!1;if(o===">"){if(a===t.length-1)return!1;o=t[++a],r=!0}for(;e&&!Tf(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Tf(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var ki=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function vf(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,n=t.length;r<n;r++){let s=t[r];if(!s.settings)continue;let i;if(typeof s.scope=="string"){let c=s.scope;c=c.replace(/^[,]+/,""),c=c.replace(/[,]+$/,""),i=c.split(",")}else Array.isArray(s.scope)?i=s.scope:i=[""];let l=-1;if(typeof s.settings.fontStyle=="string"){l=0;let c=s.settings.fontStyle.split(" ");for(let p=0,m=c.length;p<m;p++)switch(c[p]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let u=null;typeof s.settings.foreground=="string"&&ci(s.settings.foreground)&&(u=s.settings.foreground);let d=null;typeof s.settings.background=="string"&&ci(s.settings.background)&&(d=s.settings.background);for(let c=0,p=i.length;c<p;c++){let g=i[c].trim().split(" "),I=g[g.length-1],x=null;g.length>1&&(x=g.slice(0,g.length-1),x.reverse()),a[o++]=new Pf(I,x,r,l,u,d)}}return a}var Pf=class{constructor(e,t,a,o,r,n){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=n}},xe=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))(xe||{});function Af(e,t){e.sort((l,u)=>{let d=Ii(l.scope,u.scope);return d!==0||(d=Si(l.parentScopes,u.parentScopes),d!==0)?d:l.index-u.index});let a=0,o="#000000",r="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(a=l.fontStyle),l.foreground!==null&&(o=l.foreground),l.background!==null&&(r=l.background)}let n=new Rf(t),s=new ki(a,n.getId(o),n.getId(r)),i=new Ff(new ar(0,null,-1,0,0),[]);for(let l=0,u=e.length;l<u;l++){let d=e[l];i.insert(0,d.scope,d.parentScopes,d.fontStyle,n.getId(d.foreground),n.getId(d.background))}return new ia(n,s,i)}var Rf=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,a=e.length;t<a;t++)this._color2id[e[t]]=t,this._id2color[t]=e[t]}else this._isFrozen=!1}getId(e){if(e===null)return 0;e=e.toUpperCase();let t=this._color2id[e];if(t)return t;if(this._isFrozen)throw new Error(`Missing color in color map - ${e}`);return t=++this._lastColorId,this._color2id[e]=t,this._id2color[t]=e,t}getColorMap(){return this._id2color.slice(0)}},Mf=Object.freeze([]),ar=class Ti{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,n){this.scopeDepth=t,this.parentScopes=a||Mf,this.fontStyle=o,this.foreground=r,this.background=n}clone(){return new Ti(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let a=[];for(let o=0,r=t.length;o<r;o++)a[o]=t[o].clone();return a}acceptOverwrite(t,a,o,r){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,a!==-1&&(this.fontStyle=a),o!==0&&(this.foreground=o),r!==0&&(this.background=r)}},Ff=class or{constructor(t,a=[],o={}){this._mainRule=t,this._children=o,this._rulesWithParentScopes=a}_rulesWithParentScopes;static _cmpBySpecificity(t,a){if(t.scopeDepth!==a.scopeDepth)return a.scopeDepth-t.scopeDepth;let o=0,r=0;for(;t.parentScopes[o]===">"&&o++,a.parentScopes[r]===">"&&r++,!(o>=t.parentScopes.length||r>=a.parentScopes.length);){let n=a.parentScopes[r].length-t.parentScopes[o].length;if(n!==0)return n;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,n;if(o===-1?(r=t,n=""):(r=t.substring(0,o),n=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(n)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(or._cmpBySpecificity),a}insert(t,a,o,r,n,s){if(a===""){this._doInsertHere(t,o,r,n,s);return}let i=a.indexOf("."),l,u;i===-1?(l=a,u=""):(l=a.substring(0,i),u=a.substring(i+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new or(this._mainRule.clone(),ar.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(t+1,u,o,r,n,s)}_doInsertHere(t,a,o,r,n){if(a===null){this._mainRule.acceptOverwrite(t,o,r,n);return}for(let s=0,i=this._rulesWithParentScopes.length;s<i;s++){let l=this._rulesWithParentScopes[s];if(Si(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,n);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),n===0&&(n=this._mainRule.background),this._rulesWithParentScopes.push(new ar(t,a,o,r,n))}},pt=class Ee{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ee.getLanguageId(t),o=Ee.getTokenType(t),r=Ee.getFontStyle(t),n=Ee.getForeground(t),s=Ee.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:n,background:s})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,a,o,r,n,s,i){let l=Ee.getLanguageId(t),u=Ee.getTokenType(t),d=Ee.containsBalancedBrackets(t)?1:0,c=Ee.getFontStyle(t),p=Ee.getForeground(t),m=Ee.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(d=r?1:0),n!==-1&&(c=n),s!==0&&(p=s),i!==0&&(m=i),(l<<0|u<<8|d<<10|c<<11|p<<15|m<<24)>>>0}};function Ga(e,t){let a=[],o=Df(e),r=o.next();for(;r!==null;){let l=0;if(r.length===2&&r.charAt(1)===":"){switch(r.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${r} in scope selector`)}r=o.next()}let u=s();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function n(){if(r==="-"){r=o.next();let l=n();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(fi(r)){let l=[];do l.push(r),r=o.next();while(fi(r));return u=>t(l,u)}return null}function s(){let l=[],u=n();for(;u;)l.push(u),u=n();return d=>l.every(c=>c(d))}function i(){let l=[],u=s();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=s()}return d=>l.some(c=>c(d))}}function fi(e){return!!e&&!!e.match(/[\w\.:]+/)}function Df(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,a=t.exec(e);return{next:()=>{if(!a)return null;let o=a[0];return a=t.exec(e),o}}}function vi(e){typeof e.dispose=="function"&&e.dispose()}var la=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Bf=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ef=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},_f=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new la(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ef;for(let a of e)Of(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof la){if(this.seenFullScopeRequests.has(a.scopeName))continue;this.seenFullScopeRequests.add(a.scopeName),this.Q.push(a)}else{if(this.seenFullScopeRequests.has(a.scopeName)||this.seenPartialScopeRequests.has(a.toKey()))continue;this.seenPartialScopeRequests.add(a.toKey()),this.Q.push(a)}}};function Of(e,t,a,o){let r=a.lookup(e.scopeName);if(!r){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let n=a.lookup(t);e instanceof la?Wa({baseGrammar:n,selfGrammar:r},o):rr(e.ruleName,{baseGrammar:n,selfGrammar:r,repository:r.repository},o);let s=a.injections(e.scopeName);if(s)for(let i of s)o.add(new la(i))}function rr(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];ja([o],t,a)}}function Wa(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&ja(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&ja(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function ja(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?Ci({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&ja(o.patterns,{...t,repository:r},a);let n=o.include;if(!n)continue;let s=Pi(n);switch(s.kind){case 0:Wa({...t,selfGrammar:t.baseGrammar},a);break;case 1:Wa(t,a);break;case 2:rr(s.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=s.scopeName===t.selfGrammar.scopeName?t.selfGrammar:s.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};s.kind===4?rr(s.ruleName,l,a):Wa(l,a)}else s.kind===4?a.add(new Bf(s.scopeName,s.ruleName)):a.add(new la(s.scopeName));break}}}var Nf=class{kind=0},Uf=class{kind=1},Hf=class{constructor(e){this.ruleName=e}kind=2},qf=class{constructor(e){this.scopeName=e}kind=3},Wf=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Pi(e){if(e==="$base")return new Nf;if(e==="$self")return new Uf;let t=e.indexOf("#");if(t===-1)return new qf(e);if(t===0)return new Hf(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Wf(a,o)}}var Gf=/\\(\d+)/,pi=/\\(\d+)/g;var jf=-1,Ai=-2;var ca=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ha.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ha.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Li(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${e}`}getName(e,t){return!this._nameIsCapturing||this._name===null||e===null||t===null?this._name:Ha.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ha.replaceCaptures(this._contentName,e,t)}},zf=class extends ca{retokenizeCapturedWithRuleId;constructor(e,t,a,o,r){super(e,t,a,o),this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,a,o){throw new Error("Not supported!")}},Vf=class extends ca{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new ua(o,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new da,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},mi=class extends ca{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,o),this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let a of this.patterns)e.getRule(a).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new da,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},nr=class extends ca{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,n,s,i,l,u){super(e,t,a,o),this._begin=new ua(r,this.id),this.beginCaptures=n,this._end=new ua(s||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=u.patterns,this.hasMissingPatterns=u.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e,t).compileAG(e,a,o)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new da;for(let a of this.patterns)e.getRule(a).collectPatterns(e,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},za=class extends ca{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,n,s,i,l){super(e,t,a,o),this._begin=new ua(r,this.id),this.beginCaptures=n,this.whileCaptures=i,this._while=new ua(s,Ai),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,a,o){return this._getCachedCompiledPatterns(e).compileAG(e,a,o)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new da;for(let t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,a,o){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,a,o)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new da,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Ri=class Se{static createCaptureRule(t,a,o,r,n){return t.registerRule(s=>new zf(a,s,o,r,n))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new Vf(t.$vscodeTextmateLocation,t.id,t.name,t.match,Se._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=Ci({},o,t.repository));let n=t.patterns;return typeof n>"u"&&t.include&&(n=[{include:t.include}]),new mi(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Se._compilePatterns(n,a,o))}return t.while?new za(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,Se._compileCaptures(t.whileCaptures||t.captures,a,o),Se._compilePatterns(t.patterns,a,o)):new nr(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Se._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,Se._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,Se._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let n=0;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10);i>n&&(n=i)}for(let s=0;s<=n;s++)r[s]=null;for(let s in t){if(s==="$vscodeTextmateLocation")continue;let i=parseInt(s,10),l=0;t[s].patterns&&(l=Se.getCompiledRuleId(t[s],a,o)),r[i]=Se.createCaptureRule(a,t[s].$vscodeTextmateLocation,t[s].name,t[s].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let n=0,s=t.length;n<s;n++){let i=t[n],l=-1;if(i.include){let u=Pi(i.include);switch(u.kind){case 0:case 1:l=Se.getCompiledRuleId(o[i.include],a,o);break;case 2:let d=o[u.ruleName];d&&(l=Se.getCompiledRuleId(d,a,o));break;case 3:case 4:let c=u.scopeName,p=u.kind===4?u.ruleName:null,m=a.getExternalGrammar(c,o);if(m)if(p){let g=m.repository[p];g&&(l=Se.getCompiledRuleId(g,a,m.repository))}else l=Se.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=Se.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),d=!1;if((u instanceof mi||u instanceof nr||u instanceof za)&&u.hasMissingPatterns&&u.patterns.length===0&&(d=!0),d)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},ua=class Mi{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,n=[],s=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(n.push(t.substring(r,i)),n.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(s=!0),i++}this.hasAnchor=s,r===0?this.source=t:(n.push(t.substring(r,o)),this.source=n.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=a,typeof this.source=="string"?this.hasBackReferences=Gf.test(this.source):this.hasBackReferences=!1}clone(){return new Mi(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,a){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let o=a.map(r=>t.substring(r.start,r.end));return pi.lastIndex=0,this.source.replace(pi,(r,n)=>yi(o[parseInt(n,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],a=[],o=[],r=[],n,s,i,l;for(n=0,s=this.source.length;n<s;n++)i=this.source.charAt(n),t[n]=i,a[n]=i,o[n]=i,r[n]=i,i==="\\"&&n+1<s&&(l=this.source.charAt(n+1),l==="A"?(t[n+1]="\uFFFF",a[n+1]="\uFFFF",o[n+1]="A",r[n+1]="A"):l==="G"?(t[n+1]="\uFFFF",a[n+1]="G",o[n+1]="\uFFFF",r[n+1]="G"):(t[n+1]=l,a[n+1]=l,o[n+1]=l,r[n+1]=l),n++);return{A0_G0:t.join(""),A0_G1:a.join(""),A1_G0:o.join(""),A1_G1:r.join("")}}resolveAnchors(t,a){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?a?this._anchorCache.A1_G1:this._anchorCache.A1_G0:a?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},da=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(a=>a.source);this._cached=new gi(e,t,this._items.map(a=>a.ruleId))}return this._cached}compileAG(e,t,a){return this._hasAnchors?t?a?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A1_G0):a?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,a)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,a){let o=this._items.map(r=>r.resolveAnchors(t,a));return new gi(e,o,this._items.map(r=>r.ruleId))}},gi=class{constructor(e,t,a){this.regExps=t,this.rules=a,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,a=this.rules.length;t<a;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
69
+ `)}findNextMatchSync(e,t,a){let o=this.scanner.findNextMatchSync(e,t,a);return o?{ruleId:this.rules[o.index],captureIndices:o.captureIndices}:null}},tr=class{constructor(e,t){this.languageId=e,this.tokenType=t}},$f=class sr{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new tr(t,8),this._embeddedLanguagesMatcher=new Xf(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?sr._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new tr(0,0);_getBasicScopeAttributes=new bi(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new tr(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(sr.STANDARD_TOKEN_TYPE_REGEXP);if(!a)return 8;switch(a[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},Xf=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([a,o])=>yi(a));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},f0={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Fi=!1,hi=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Di(e,t,a,o,r,n,s,i){let l=t.content.length,u=!1,d=-1;if(s){let m=Kf(e,t,a,o,r,n);r=m.stack,o=m.linePos,a=m.isFirstLine,d=m.anchorPosition}let c=Date.now();for(;!u;){if(i!==0&&Date.now()-c>i)return new hi(r,!0);p()}return new hi(r,!1);function p(){let m=Qf(e,t,a,o,r,d);if(!m){n.produce(r,l),u=!0;return}let g=m.captureIndices,I=m.matchedRuleId,x=g&&g.length>0?g[0].end>o:!1;if(I===jf){let S=r.getRule(e);n.produce(r,g[0].start),r=r.withContentNameScopesList(r.nameScopesList),na(e,t,a,r,n,S.endCaptures,g),n.produce(r,g[0].end);let C=r;if(r=r.parent,d=C.getAnchorPos(),!x&&C.getEnterPos()===o){r=C,n.produce(r,l),u=!0;return}}else{let S=e.getRule(I);n.produce(r,g[0].start);let C=r,L=S.getName(t.content,g),y=r.contentNameScopesList.pushAttributed(L,e);if(r=r.push(I,o,d,g[0].end===l,null,y,y),S instanceof nr){let b=S;na(e,t,a,r,n,b.beginCaptures,g),n.produce(r,g[0].end),d=g[0].end;let P=b.getContentName(t.content,g),M=y.pushAttributed(P,e);if(r=r.withContentNameScopesList(M),b.endHasBackReferences&&(r=r.withEndRule(b.getEndWithResolvedBackReferences(t.content,g))),!x&&C.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(S instanceof za){let b=S;na(e,t,a,r,n,b.beginCaptures,g),n.produce(r,g[0].end),d=g[0].end;let P=b.getContentName(t.content,g),M=y.pushAttributed(P,e);if(r=r.withContentNameScopesList(M),b.whileHasBackReferences&&(r=r.withEndRule(b.getWhileWithResolvedBackReferences(t.content,g))),!x&&C.hasSameRuleAs(r)){r=r.pop(),n.produce(r,l),u=!0;return}}else if(na(e,t,a,r,n,S.captures,g),n.produce(r,g[0].end),r=r.pop(),!x){r=r.safePop(),n.produce(r,l),u=!0;return}}g[0].end>o&&(o=g[0].end,a=!1)}}function Kf(e,t,a,o,r,n){let s=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof za&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:d}=Zf(l.rule,e,l.stack.endRule,a,o===s),c=u.findNextMatchSync(t,o,d);if(c){if(c.ruleId!==Ai){r=l.stack.pop();break}c.captureIndices&&c.captureIndices.length&&(n.produce(l.stack,c.captureIndices[0].start),na(e,t,a,l.stack,n,l.rule.whileCaptures,c.captureIndices),n.produce(l.stack,c.captureIndices[0].end),s=c.captureIndices[0].end,c.captureIndices[0].end>o&&(o=c.captureIndices[0].end,a=!1))}else{r=l.stack.pop();break}}return{stack:r,linePos:o,anchorPosition:s,isFirstLine:a}}function Qf(e,t,a,o,r,n){let s=Jf(e,t,a,o,r,n),i=e.getInjections();if(i.length===0)return s;let l=Yf(i,e,t,a,o,r,n);if(!l)return s;if(!s)return l;let u=s.captureIndices[0].start,d=l.captureIndices[0].start;return d<u||l.priorityMatch&&d===u?l:s}function Jf(e,t,a,o,r,n){let s=r.getRule(e),{ruleScanner:i,findOptions:l}=Bi(s,e,r.endRule,a,o===n),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function Yf(e,t,a,o,r,n,s){let i=Number.MAX_VALUE,l=null,u,d=0,c=n.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let g=e[p];if(!g.matcher(c))continue;let I=t.getRule(g.ruleId),{ruleScanner:x,findOptions:S}=Bi(I,t,null,o,r===s),C=x.findNextMatchSync(a,r,S);if(!C)continue;let L=C.captureIndices[0].start;if(!(L>=i)&&(i=L,l=C.captureIndices,u=C.ruleId,d=g.priority,i===r))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:u}:null}function Bi(e,t,a,o,r){if(Fi){let s=e.compile(t,a),i=Ei(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function Zf(e,t,a,o,r){if(Fi){let s=e.compileWhile(t,a),i=Ei(o,r);return{ruleScanner:s,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function Ei(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function na(e,t,a,o,r,n,s){if(n.length===0)return;let i=t.content,l=Math.min(n.length,s.length),u=[],d=s[0].end;for(let c=0;c<l;c++){let p=n[c];if(p===null)continue;let m=s[c];if(m.length===0)continue;if(m.start>d)break;for(;u.length>0&&u[u.length-1].endPos<=m.start;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop();if(u.length>0?r.produceFromScopes(u[u.length-1].scopes,m.start):r.produce(o,m.start),p.retokenizeCapturedWithRuleId){let I=p.getName(i,s),x=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(i,s),C=x.pushAttributed(S,e),L=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,x,C),y=e.createOnigString(i.substring(0,m.end));Di(e,y,a&&m.start===0,m.start,L,r,!1,0),vi(y);continue}let g=p.getName(i,s);if(g!==null){let x=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(g,e);u.push(new ep(x,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var ep=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function tp(e,t,a,o,r,n,s,i){return new op(e,t,a,o,r,n,s,i)}function wi(e,t,a,o,r){let n=Ga(t,Va),s=Ri.getCompiledRuleId(a,o,r.repository);for(let i of n)e.push({debugSelector:t,matcher:i.matcher,ruleId:s,grammar:r,priority:i.priority})}function Va(e,t){if(t.length<e.length)return!1;let a=0;return e.every(o=>{for(let r=a;r<t.length;r++)if(ap(t[r],o))return a=r+1,!0;return!1})}function ap(e,t){if(!e)return!1;if(e===t)return!0;let a=t.length;return e.length>a&&e.substr(0,a)===t&&e[a]==="."}var op=class{constructor(e,t,a,o,r,n,s,i){if(this._rootScopeName=e,this.balancedBracketSelectors=n,this._onigLib=i,this._basicScopeAttributesProvider=new $f(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=s,this._grammar=xi(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=Ga(l,Va);for(let d of u)this._tokenTypeMatchers.push({matcher:d.matcher,type:r[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:r=>r===this._rootScopeName?this._grammar:this.getExternalGrammar(r),injections:r=>this._grammarRepository.injections(r)},t=[],a=this._rootScopeName,o=e.lookup(a);if(o){let r=o.injections;if(r)for(let s in r)wi(t,s,r[s],this,o);let n=this._grammarRepository.injections(a);n&&n.forEach(s=>{let i=this.getExternalGrammar(s);if(i){let l=i.injectionSelector;l&&wi(t,l,i,this,i)}})}return t.sort((r,n)=>r.priority-n.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,a=e(t);return this._ruleId2desc[t]=a,a}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let a=this._grammarRepository.lookup(e);if(a)return this._includedGrammars[e]=xi(a,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,a=0){let o=this._tokenize(e,t,!1,a);return{tokens:o.lineTokens.getResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}tokenizeLine2(e,t,a=0){let o=this._tokenize(e,t,!0,a);return{tokens:o.lineTokens.getBinaryResult(o.ruleStack,o.lineLength),ruleStack:o.ruleStack,stoppedEarly:o.stoppedEarly}}_tokenize(e,t,a,o){this._rootId===-1&&(this._rootId=Ri.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===ir.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),c=pt.set(0,u.languageId,u.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=sa.createRootAndLookUpScopeName(p,c,this):m=sa.createRoot("unknown",c),t=new ir(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
+ `;let n=this.createOnigString(e),s=n.content.length,i=new np(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Di(this,n,r,0,t,i,!0,o);return vi(n),{lineLength:s,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function xi(e,t){return e=Sf(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var sa=class ze{constructor(t,a,o){this.parent=t,this.scopePath=a,this.tokenAttributes=o}static fromExtension(t,a){let o=t,r=t?.scopePath??null;for(let n of a)r=er.push(r,n.scopeNames),o=new ze(o,r,n.encodedTokenAttributes);return o}static createRoot(t,a){return new ze(null,new er(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),n=new er(null,t),s=o.themeProvider.themeMatch(n),i=ze.mergeAttributes(a,r,s);return new ze(null,n,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return ze.equals(this,t)}static equals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.scopeName!==a.scopeName||t.tokenAttributes!==a.tokenAttributes)return!1;t=t.parent,a=a.parent}while(!0)}static mergeAttributes(t,a,o){let r=-1,n=0,s=0;return o!==null&&(r=o.fontStyle,n=o.foregroundId,s=o.backgroundId),pt.set(t,a.languageId,a.tokenType,null,r,n,s)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return ze._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let n of o)r=ze._pushAttributed(r,n,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),n=t.scopePath.push(a),s=o.themeProvider.themeMatch(n),i=ze.mergeAttributes(t.tokenAttributes,r,s);return new ze(t,n,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let a=[],o=this;for(;o&&o!==t;)a.push({encodedTokenAttributes:o.tokenAttributes,scopeNames:o.scopePath.getExtensionIfDefined(o.parent?.scopePath??null)}),o=o.parent;return o===t?a.reverse():void 0}},ir=class ft{constructor(t,a,o,r,n,s,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=n,this.endRule=s,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=o,this._anchorPos=r}_stackElementBrand=void 0;static NULL=new ft(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ft._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?sa.equals(t.contentNameScopesList,a.contentNameScopesList):!1}static _structuralEquals(t,a){do{if(t===a||!t&&!a)return!0;if(!t||!a||t.depth!==a.depth||t.ruleId!==a.ruleId||t.endRule!==a.endRule)return!1;t=t.parent,a=a.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){ft._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,n,s,i){return new ft(this,t,a,o,r,n,s,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,a){return this.parent&&(a=this.parent._writeString(t,a)),t[a++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,a}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new ft(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let a=this;for(;a&&a._enterPos===t._enterPos;){if(a.ruleId===t.ruleId)return!0;a=a.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,a){let o=sa.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ft(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,sa.fromExtension(o,a.contentNameScopesList))}},rp=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Ga(a,Va).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Ga(a,Va).map(o=>o.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},np=class{constructor(e,t,a,o){this.balancedBracketSelectors=o,this._emitBinaryTokens=e,this._tokenTypeOverrides=a,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let o=e?.tokenAttributes??0,r=!1;if(this.balancedBracketSelectors?.matchesAlways&&(r=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let n=e?.getScopeNames()??[];for(let s of this._tokenTypeOverrides)s.matcher(n)&&(o=pt.set(o,0,s.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(n))}if(r&&(o=pt.set(o,0,8,r,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===o){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(o),this._lastTokenEndIndex=t;return}let a=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:a}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let a=new Uint32Array(this._binaryTokens.length);for(let o=0,r=this._binaryTokens.length;o<r;o++)a[o]=this._binaryTokens[o];return a}},sp=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,a,o,r){if(!this._grammars.has(e)){let n=this._rawGrammars.get(e);if(!n)return null;this._grammars.set(e,tp(e,n,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},_i=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new sp(ia.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ia.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,a){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:a})}loadGrammarWithConfiguration(e,t,a){return this._loadGrammar(e,t,a.embeddedLanguages,a.tokenTypes,new rp(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let n=new _f(this._syncRegistry,e);for(;n.Q.length>0;)n.Q.map(s=>this._loadSingleGrammar(s.scopeName)),n.processQueue();return this._grammarForScopeName(e,t,a,o,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let a=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,a)}}addGrammar(e,t=[],a=0,o=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,a,o)}_grammarForScopeName(e,t=0,a=null,o=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,a,o,r)}},$a=ir.NULL;f();f();f();f();f();f();var ip=/["&'<>`]/g,lp=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,up=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,dp=/[|\\{}()[\]^$+*?.]/g,Oi=new WeakMap;function Ni(e,t){if(e=e.replace(t.subset?cp(t.subset):ip,o),t.subset||t.escapeOnly)return e;return e.replace(lp,a).replace(up,o);function a(r,n,s){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,s.charCodeAt(n+2),t)}function o(r,n,s){return t.format(r.charCodeAt(0),s.charCodeAt(n+1),t)}}function cp(e){let t=Oi.get(e);return t||(t=fp(e),Oi.set(e,t)),t}function fp(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(dp,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var pp=/[\dA-Fa-f]/;function Ui(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!pp.test(String.fromCharCode(t))?o:o+";"}f();var mp=/\d/;function Hi(e,t,a){let o="&#"+String(e);return a&&t&&!mp.test(String.fromCharCode(t))?o:o+";"}f();f();var qi=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];f();var Xa={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};f();var Wi=["cent","copy","divide","gt","lt","not","para","times"];var Gi={}.hasOwnProperty,ur={},Ka;for(Ka in Xa)Gi.call(Xa,Ka)&&(ur[Xa[Ka]]=Ka);var gp=/[^\dA-Za-z]/;function ji(e,t,a,o){let r=String.fromCharCode(e);if(Gi.call(ur,r)){let n=ur[r],s="&"+n;return a&&qi.includes(n)&&!Wi.includes(n)&&(!o||t&&t!==61&&gp.test(String.fromCharCode(t)))?s:s+";"}return""}function zi(e,t,a){let o=Ui(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=ji(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let n=Hi(e,t,a.omitOptionalSemicolons);n.length<o.length&&(o=n)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function Qe(e,t){return Ni(e,Object.assign({format:zi},t))}var hp=/^>|^->|<!--|-->|--!>|<!-$/g,wp=[">"],xp=["<",">"];function Vi(e,t,a,o){return o.settings.bogusComments?"<?"+Qe(e.value,Object.assign({},o.settings.characterReferences,{subset:wp}))+">":"<!--"+e.value.replace(hp,r)+"-->";function r(n){return Qe(n,Object.assign({},o.settings.characterReferences,{subset:xp}))}}f();function $i(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var le=Xi(1),dr=Xi(-1),Cp=[];function Xi(e){return t;function t(a,o,r){let n=a?a.children:Cp,s=(o||0)+e,i=n[s];if(!r)for(;i&&St(i);)s+=e,i=n[s];return i}}f();var Lp={}.hasOwnProperty;function Qa(e){return t;function t(a,o,r){return Lp.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var fa=Qa({body:Sp,caption:cr,colgroup:cr,dd:Tp,dt:kp,head:cr,html:Ip,li:bp,optgroup:vp,option:Pp,p:yp,rp:Ki,rt:Ki,tbody:Rp,td:Qi,tfoot:Mp,th:Qi,thead:Ap,tr:Fp});function cr(e,t,a){let o=le(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&St(o.value.charAt(0)))}function Ip(e,t,a){let o=le(a,t);return!o||o.type!=="comment"}function Sp(e,t,a){let o=le(a,t);return!o||o.type!=="comment"}function yp(e,t,a){let o=le(a,t);return o?o.type==="element"&&(o.tagName==="address"||o.tagName==="article"||o.tagName==="aside"||o.tagName==="blockquote"||o.tagName==="details"||o.tagName==="div"||o.tagName==="dl"||o.tagName==="fieldset"||o.tagName==="figcaption"||o.tagName==="figure"||o.tagName==="footer"||o.tagName==="form"||o.tagName==="h1"||o.tagName==="h2"||o.tagName==="h3"||o.tagName==="h4"||o.tagName==="h5"||o.tagName==="h6"||o.tagName==="header"||o.tagName==="hgroup"||o.tagName==="hr"||o.tagName==="main"||o.tagName==="menu"||o.tagName==="nav"||o.tagName==="ol"||o.tagName==="p"||o.tagName==="pre"||o.tagName==="section"||o.tagName==="table"||o.tagName==="ul"):!a||!(a.type==="element"&&(a.tagName==="a"||a.tagName==="audio"||a.tagName==="del"||a.tagName==="ins"||a.tagName==="map"||a.tagName==="noscript"||a.tagName==="video"))}function bp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="li"}function kp(e,t,a){let o=le(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Tp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function Ki(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function vp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function Pp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function Ap(e,t,a){let o=le(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Rp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function Mp(e,t,a){return!le(a,t)}function Fp(e,t,a){let o=le(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function Qi(e,t,a){let o=le(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Ji=Qa({body:Ep,colgroup:_p,head:Bp,html:Dp,tbody:Op});function Dp(e){let t=le(e,-1);return!t||t.type!=="comment"}function Bp(e){let t=new Set;for(let o of e.children)if(o.type==="element"&&(o.tagName==="base"||o.tagName==="title")){if(t.has(o.tagName))return!1;t.add(o.tagName)}let a=e.children[0];return!a||a.type==="element"}function Ep(e){let t=le(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&St(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function _p(e,t,a){let o=dr(a,t),r=le(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&fa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Op(e,t,a){let o=dr(a,t),r=le(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&fa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Ja={name:[[`
71
71
  \f\r &/=>`.split(""),`
72
72
  \f\r "&'/=>\``.split("")],[`\0
73
73
  \f\r "&'/<=>`.split(""),`\0
@@ -75,11 +75,11 @@ import{a as ko,b as Wu,c as Gu}from"../chunk-R6LESDWJ.js";import{b as Mt,c as Ct
75
75
  \f\r &>`.split(""),`\0
76
76
  \f\r "&'<=>\``.split("")],[`\0
77
77
  \f\r "&'<=>\``.split(""),`\0
78
- \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Qi(e,t,a,o){let r=o.schema,n=r.space==="svg"?!1:o.settings.omitOptionalTags,s=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ba);let u=_p(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(s=!1),(u||!n||!Ki(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),s&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!s&&(!n||!fa(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function _p(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let n=Op(e,r,t[r]);n&&a.push(n)}}for(;++o<a.length;){let n=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&n!=='"'&&n!=="'"&&(a[o]+=" ")}return a.join("")}function Op(e,t,a){let o=un(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,n=e.settings.allowDangerousCharacters?0:1,s=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=Qe(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ja.name[r][n]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?cn:fn)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=Qe(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ja.unquoted[r][n]}))),i!==a&&(e.settings.quoteSmart&&To(a,s)>To(a,e.alternative)&&(s=e.alternative),i=s+Qe(a,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Ja.single:Ja.double)[r][n],attribute:!0}))+s),l+(i&&"="+i))}f();f();var Np=["<","&"];function Ya(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:Qe(e.value,Object.assign({},o.settings.characterReferences,{subset:Np}))}function Ji(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ya(e,t,a,o)}f();function Yi(e,t,a,o){return o.all(e)}var Zi=pn("type",{invalid:Up,unknown:Hp,handlers:{comment:ji,doctype:zi,element:Qi,raw:Ji,root:Yi,text:Ya}});function Up(e){throw new Error("Expected node, not `"+e+"`")}function Hp(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var qp={},Wp={},Gp=[];function cr(e,t){let a=t||qp,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:jp,all:zp,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||mn,characterReferences:a.characterReferences||Wp,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ba:dn,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function jp(e,t,a){return Zi(e,t,a,this)}function zp(e){let t=[],a=e&&e.children||Gp,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Za(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,n]of Object.entries(t?.colorReplacements||{}))typeof n=="string"?a[r]=n:r===o&&Object.assign(a,n);return a}function ot(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Vp(e){return Array.isArray(e)?e:[e]}async function sl(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function wr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function il(e){return e==="ansi"||wr(e)}function xr(e){return e==="none"}function ll(e){return xr(e)}function ul(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function ro(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let n=0;n<a.length;n+=2){let s=t?a[n]+(a[n+1]||""):a[n];r.push([s,o]),o+=a[n].length,o+=a[n+1]?.length||0}return r}function $p(e){let t=ro(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let n=r,s=0;for(let i of t){if(n<i.length)break;n-=i.length,s++}return{line:s,character:n}}function o(r,n){let s=0;for(let i=0;i<r;i++)s+=t[i].length;return s+=n,s}return{lines:t,indexToPos:a,posToIndex:o}}function dl(e,t,a){let o=new Set;for(let n of e.matchAll(/:?lang=["']([^"']+)["']/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/\\begin\{([\w-]+)\}/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let s=n[1].toLowerCase().trim(),i=s.includes("/")?s.split("/").pop():s;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(n=>n&&r[n])}var Cr="light-dark()",Xp=["color","background-color"];function Kp(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function Qp(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let n=a.filter(s=>r.offset<s&&s<r.offset+r.content.length).map(s=>s-r.offset).sort((s,i)=>s-i);return n.length?Kp(r,n):r})):e}function Jp(e,t,a,o,r="css-vars"){let n={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(c=>eo(e.variants[c])),i=new Set(s.flatMap(c=>Object.keys(c))),l={},u=(c,d)=>{let p=d==="color"?"":d==="background-color"?"-bg":`-${d}`;return a+t[c]+(d==="color"?"":p)};return s.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&Xp.includes(p))if(o===Cr&&s.length>1){let g=t.findIndex(x=>x==="light"),I=t.findIndex(x=>x==="dark");if(g===-1||I===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let C=s[g][p]||"inherit",S=s[I][p]||"inherit";l[p]=`light-dark(${C}, ${S})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),n.htmlStyle=l,n}function eo(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&xe.Italic&&(t["font-style"]="italic"),e.fontStyle&xe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&xe.Underline&&a.push("underline"),e.fontStyle&xe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function mr(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var cl=new WeakMap;function no(e,t){cl.set(e,t)}function ma(e){return cl.get(e)}var vt=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(Vp(a).map(o=>[o,$a])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Yp(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Yp(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let n=r?.nameScopesList?.scopeName;n&&t.push(n),r.parent&&o(r.parent)}return o(e),t}function Zp(e,t){if(!(e instanceof vt))throw new re("Invalid grammar state");return e.getInternalStack(t)}function em(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(s){if(typeof s=="number"){if(s<0||s>a.source.length)throw new re(`Invalid decoration offset: ${s}. Code length: ${a.source.length}`);return{...r.indexToPos(s),offset:s}}else{let i=r.lines[s.line];if(i===void 0)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${i.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=$p(a.source),n=(a.options.decorations||[]).map(s=>({...s,start:o(s.start),end:o(s.end)}));tm(n),e.set(a.meta,{decorations:n,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(s=>[s.start.offset,s.end.offset]);return Qp(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new re(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function n(c,d,p,m){let g=r[c],I="",C=-1,S=-1;if(d===0&&(C=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=g.children.length),C===-1||S===-1)for(let L=0;L<g.children.length;L++)I+=fl(g.children[L]),C===-1&&I.length===d&&(C=L+1),S===-1&&I.length===p&&(S=L+1);if(C===-1)throw new re(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new re(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let x=g.children.slice(C,S);if(!m.alwaysWrap&&x.length===g.children.length)i(g,m,"line");else if(!m.alwaysWrap&&x.length===1&&x[0].type==="element")i(x[0],m,"token");else{let L={type:"element",tagName:"span",properties:{},children:x};i(L,m,"wrapper"),g.children.splice(C,x.length,L)}}function s(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},g=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&ul(c,d.properties.class),c=g(c,p)||c,c}let l=[],u=o.decorations.sort((c,d)=>d.start.offset-c.start.offset||c.end.offset-d.end.offset);for(let c of u){let{start:d,end:p}=c;if(d.line===p.line)n(d.line,d.character,p.character,c);else if(d.line<p.line){n(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>s(m,c));n(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function tm(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new re(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],n=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,s=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(n||s||i||l){if(n&&s||i&&l||i&&a.start.offset===a.end.offset||s&&r.start.offset===r.end.offset)continue;throw new re(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function fl(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(fl).join(""):""}var am=[em()];function to(e){let t=om(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...am]}function om(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var mt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],fr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function rm(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function el(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function nm(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)fr[o]&&t.push({type:"setDecoration",value:fr[o]});else if(o<=29){let r=fr[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-30]}});else if(o===38){let r=el(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-40]}});else if(o===48){let r=el(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-100+8]}})}return t}function sm(){let e=null,t=null,a=new Set;return{parse(o){let r=[],n=0;do{let s=rm(o,n),i=s.sequence?o.substring(n,s.startPosition):o.substring(n);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),s.sequence){let l=nm(s.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}n=s.position}while(n<o.length);return r}}}var im={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function lm(e=im){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<mt.length;u++)o.push(t(mt[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let c=0;c<6;c++)for(let d=0;d<6;d++)o.push(a([i[u],i[c],i[d]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function n(i){return r()[i]}function s(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return n(i.index)}}return{value:s}}var um={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function dm(e,t,a){let o=Za(e,a),r=ro(t),n=Object.fromEntries(mt.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||um[l]]})),s=lm(n),i=sm();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?s.value(u.background):e.bg,d=u.foreground?s.value(u.foreground):e.fg):(c=u.foreground?s.value(u.foreground):e.fg,d=u.background?s.value(u.background):void 0),c=ot(c,o),d=ot(d,o),u.decorations.has("dim")&&(c=cm(c));let p=xe.None;return u.decorations.has("bold")&&(p|=xe.Bold),u.decorations.has("italic")&&(p|=xe.Italic),u.decorations.has("underline")&&(p|=xe.Underline),u.decorations.has("strikethrough")&&(p|=xe.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function cm(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],n=o[1],s=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${n}${n}${s}${s}${l}`}else if(o.length===3){let r=o[0],n=o[1],s=o[2];return`#${r}${r}${n}${n}${s}${s}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Lr(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(wr(r)||xr(o))return ro(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:n,colorMap:s}=e.setTheme(o);if(r==="ansi")return dm(n,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new re(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new re(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return pm(t,i,n,s,a)}function fm(...e){if(e.length===2)return ma(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:n=t.getLoadedThemes()[0]}=o;if(wr(r)||xr(n))throw new re("Plain language does not have grammar state");if(r==="ansi")throw new re("ANSI language does not have grammar state");let{theme:s,colorMap:i}=t.setTheme(n),l=t.getLanguage(r);return new vt(Ir(a,l,s,i,o).stateStack,l.name,s.name)}function pm(e,t,a,o,r){let n=Ir(e,t,a,o,r),s=new vt(n.stateStack,t.name,a.name);return no(n.tokens,s),n.tokens}function Ir(e,t,a,o,r){let n=Za(a,r),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:i=500}=r,l=ro(e),u=r.grammarState?Zp(r.grammarState,a.name)??$a:r.grammarContextCode!=null?Ir(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:$a,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[g,I]=l[p];if(g===""){c=[],d.push([]);continue}if(s>0&&g.length>=s){c=[],d.push([{content:g,offset:I,color:"",fontStyle:0}]);continue}let C,S,x;r.includeExplanation&&(C=t.tokenizeLine(g,u,i),S=C.tokens,x=0);let L=t.tokenizeLine2(g,u,i),y=L.tokens.length/2;for(let k=0;k<y;k++){let P=L.tokens[2*k],F=k+1<y?L.tokens[2*k+2]:g.length;if(P===F)continue;let R=L.tokens[2*k+1],_=ot(o[pt.getForeground(R)],n),M=pt.getFontStyle(R),E={content:g.substring(P,F),offset:I+P,color:_,fontStyle:M};if(r.includeExplanation){let v=[];if(r.includeExplanation!=="scopeName")for(let H of a.settings){let T;switch(typeof H.scope){case"string":T=H.scope.split(/,/).map(O=>O.trim());break;case"object":T=H.scope;break;default:continue}v.push({settings:H,selectors:T.map(O=>O.split(/ /))})}E.explanation=[];let D=0;for(;P+D<F;){let H=S[x],T=g.substring(H.startIndex,H.endIndex);D+=T.length,E.explanation.push({content:T,scopes:r.includeExplanation==="scopeName"?mm(H.scopes):gm(v,H.scopes)}),x+=1}}c.push(E)}d.push(c),c=[],u=L.ruleStack}return{tokens:d,stateStack:u}}function mm(e){return e.map(t=>({scopeName:t}))}function gm(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let n=t[o];a[o]={scopeName:n,themeMatches:wm(e,n,t.slice(0,o))}}return a}function tl(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function hm(e,t,a){if(!tl(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)tl(e[o],a[r])&&(o-=1),r-=1;return o===-1}function wm(e,t,a){let o=[];for(let{selectors:r,settings:n}of e)for(let s of r)if(hm(s,t,a)){o.push(n);break}return o}function pl(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=Lr(e,t,{...a,theme:l.theme}),c=ma(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),n=xm(...r.map(l=>l.tokens)),s=n[0].map((l,u)=>l.map((c,d)=>{let p={content:c.content,variants:{},offset:c.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=c.explanation),n.forEach((m,g)=>{let{content:I,explanation:C,offset:S,...x}=m[u][d];p.variants[o[g].color]=x}),p})),i=r[0].state?new vt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&no(s,i),s}function xm(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),n=t.map(()=>[]);t.forEach((l,u)=>l.push(n[u]));let s=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(n[u].push(c),s[u]+=1,i[u]=r[u][s[u]]):(n[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function ao(e,t,a){let o,r,n,s,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,x)=>S.color===u?-1:x.color===u?1:0);if(p.length===0)throw new re("`themes` option must not be empty");let m=pl(e,t,a);if(l=ma(m),u&&Cr!==u&&!p.find(S=>S.color===u))throw new re(`\`themes\` option must contain the defaultColor key \`${u}\``);let g=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);n=m.map(S=>S.map(x=>Jp(x,I,c,u,d))),l&&no(n,l);let C=p.map(S=>Za(S.theme,a));r=al(p,g,C,c,u,"fg",d),o=al(p,g,C,c,u,"bg",d),s=`shiki-themes ${g.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Za(a.theme,a);n=Lr(e,t,a);let c=e.getTheme(a.theme);o=ot(c.bg,u),r=ot(c.fg,u),s=c.name,l=ma(n)}else throw new re("Invalid options, either `theme` or `themes` must be provided");return{tokens:n,fg:r,bg:o,themeName:s,rootStyle:i,grammarState:l}}function al(e,t,a,o,r,n,s){return e.map((i,l)=>{let u=ot(t[l][n],a[l])||"inherit",c=`${o+i.color}${n==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===Cr&&e.length>1){let d=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(d===-1||p===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=ot(t[d][n],a[d])||"inherit",g=ot(t[p][n],a[p])||"inherit";return`light-dark(${m}, ${g});${c}`}return u}return s==="css-vars"?c:null}).filter(i=>!!i).join(";")}function oo(e,t,a,o={meta:{},options:a,codeToHast:(r,n)=>oo(e,r,n),codeToTokens:(r,n)=>ao(e,r,n)}){let r=t;for(let g of to(a))r=g.preprocess?.call(o,r,a)||r;let{tokens:n,fg:s,bg:i,themeName:l,rootStyle:u,grammarState:c}=ao(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?n=Lm(n):d==="never"&&(n=Im(n)),p&&(n=Sm(n));let m={...o,get source(){return r}};for(let g of to(a))n=g.tokens?.call(m,n)||n;return Cm(n,{...a,fg:s,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Cm(e,t,a,o=ma(e)){let r=to(t),n=[],s={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,C]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=C);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:n},p=[],m={...a,structure:i,addClassToHast:ul,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,C)=>{C&&(i==="inline"?s.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&n.push({type:"text",value:`
79
- `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},x=0;for(let L of I){let y={type:"element",tagName:"span",properties:{...L.htmlAttrs},children:[{type:"text",value:L.content}]},k=mr(L.htmlStyle||eo(L));k&&(y.properties.style=k);for(let P of r)y=P?.span?.call(m,y,C+1,x,S,L)||y;i==="inline"?s.children.push(y):i==="classic"&&S.children.push(y),x+=L.content.length}if(i==="classic"){for(let L of r)S=L?.line?.call(m,S,C+1)||S;p.push(S),n.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;s.children.push(c)}else if(i==="inline"){let I=[],C={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let L of s.children)L.type==="element"&&L.tagName==="br"?(I.push(C),C={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(L.type==="element"||L.type==="text")&&C.children.push(L);I.push(C);let x={type:"element",tagName:"code",properties:{},children:I};for(let L of r)x=L?.code?.call(m,x)||x;s.children=[];for(let L=0;L<x.children.length;L++){L>0&&s.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=x.children[L];y.type==="element"&&s.children.push(...y.children)}}let g=s;for(let I of r)g=I?.root?.call(m,g)||g;return o&&no(g,o),g}function Lm(e){return e.map(t=>{let a=[],o="",r;return t.forEach((n,s)=>{let l=!(n.fontStyle&&(n.fontStyle&xe.Underline||n.fontStyle&xe.Strikethrough));l&&n.content.match(/^\s+$/)&&t[s+1]?(r===void 0&&(r=n.offset),o+=n.content):o?(l?a.push({...n,offset:r,content:o+n.content}):a.push({content:o,offset:r},n),r=void 0,o=""):a.push(n)}),a})}function Im(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,n,s]=o;if(!r&&!s)return a;let i=[{...a,offset:a.offset+r.length,content:n}];return r&&i.unshift({content:r,offset:a.offset}),s&&i.push({content:s,offset:a.offset+r.length+n.length}),i}))}function Sm(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],n=mr(r.htmlStyle||eo(r)),s=mr(o.htmlStyle||eo(o)),i=r.fontStyle&&(r.fontStyle&xe.Underline||r.fontStyle&xe.Strikethrough),l=o.fontStyle&&(o.fontStyle&xe.Underline||o.fontStyle&xe.Strikethrough);!i&&!l&&n===s?r.content+=o.content:a.push({...o})}return a})}var ym=cr;function bm(e,t,a){let o={meta:{},options:a,codeToHast:(n,s)=>oo(e,n,s),codeToTokens:(n,s)=>ao(e,n,s)},r=ym(oo(e,t,a,o));for(let n of to(a))r=n.postprocess?.call(o,r,a)||r;return r}var ol={light:"#333333",dark:"#bbbbbb"},rl={light:"#fffffe",dark:"#1e1e1e"},nl="__shiki_resolved";function Sr(e){if(e?.[nl])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?ol.light:ol.dark),a||(a=t.type==="light"?rl.light:rl.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,n=new Map;function s(i){if(n.has(i))return n.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?s(i):(n.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=s(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=s(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=s(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,nl,{enumerable:!1,writable:!1,value:!0}),t}async function ml(e){return Array.from(new Set((await Promise.all(e.filter(t=>!il(t)).map(async t=>await sl(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function gl(e){return(await Promise.all(e.map(async a=>ll(a)?null:Sr(await sl(a))))).filter(a=>!!a)}var pr=3,km=!1;function Tm(e,t=3){if(pr&&!(typeof pr=="number"&&t>pr)){if(km)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var at=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function hl(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new at(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var gr=class extends Bi{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(n=>this.loadTheme(n)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=Sr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=ia.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=hl(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(n=>n.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(n=>{this._alias[n]=t.name}),this._loadedLanguagesCache=null,a.size)for(let n of a)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,n])=>!n);if(o.length){let r=a.filter(([n,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(n=>!o.includes(n));throw new at(`Missing languages ${o.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of a)this._resolver.addLanguage(n);for(let[r,n]of a)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},hr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let n=a.slice(0,r).join(".");o=[...o,...this._injections.get(n)||[]]}return o}},pa=0;function vm(e){pa+=1,e.warnings!==!1&&pa>=10&&pa%10===0&&console.warn(`[Shiki] ${pa} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new at("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(Sr),r=new hr(e.engine,a),n=new gr(r,o,a,e.langAlias),s;function i(L){return hl(L,e.langAlias)}function l(L){S();let y=n.getGrammar(typeof L=="string"?L:L.name);if(!y)throw new at(`Language \`${L}\` not found, you may need to load it first`);return y}function u(L){if(L==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=n.getTheme(L);if(!y)throw new at(`Theme \`${L}\` not found, you may need to load it first`);return y}function c(L){S();let y=u(L);s!==L&&(n.setTheme(y),s=L);let k=n.getColorMap();return{theme:y,colorMap:k}}function d(){return S(),n.getLoadedThemes()}function p(){return S(),n.getLoadedLanguages()}function m(...L){S(),n.loadLanguages(L.flat(1))}async function g(...L){return m(await ml(L))}function I(...L){S();for(let y of L.flat(1))n.loadTheme(y)}async function C(...L){return S(),I(await gl(L))}function S(){if(t)throw new at("Shiki instance has been disposed")}function x(){t||(t=!0,n.dispose(),pa-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:g,loadLanguageSync:m,loadTheme:C,loadThemeSync:I,dispose:x,[Symbol.dispose]:x}}async function Pm(e){e.engine||Tm("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([gl(e.themes||[]),ml(e.langs||[]),e.engine]);return vm({...e,themes:t,langs:a,engine:o})}async function Am(e){let t=await Pm(e);return{getLastGrammarState:(...a)=>fm(t,...a),codeToTokensBase:(a,o)=>Lr(t,a,o),codeToTokensWithThemes:(a,o)=>pl(t,a,o),codeToTokens:(a,o)=>ao(t,a,o),codeToHast:(a,o)=>oo(t,a,o),codeToHtml:(a,o)=>bm(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function wl(e){let t=e.langs,a=e.themes,o=e.engine;async function r(n){function s(d){if(typeof d=="string"){if(d=n.langAlias?.[d]||d,il(d))return[];let p=t[d];if(!p)throw new re(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(ll(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new re(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(n.themes??[]).map(d=>i(d)),u=(n.langs??[]).map(d=>s(d)),c=await Am({engine:n.engine??o(),...n,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(s))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Rm(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function xl(e,t){let a=Rm(e);async function o(r,n){let s=await a({langs:[n.lang],themes:"theme"in n?[n.theme]:Object.values(n.themes)}),i=await t?.guessEmbeddedLanguages?.(r,n.lang,s);return i&&await s.loadLanguage(...i),s}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,n){return(await o(r,n)).codeToHtml(r,n)},async codeToHast(r,n){return(await o(r,n)).codeToHast(r,n)},async codeToTokens(r,n){return(await o(r,n)).codeToTokens(r,n)},async codeToTokensBase(r,n){return(await o(r,n)).codeToTokensBase(r,n)},async codeToTokensWithThemes(r,n){return(await o(r,n)).codeToTokensWithThemes(r,n)},async getLastGrammarState(r,n){return(await a({langs:[n.lang],themes:[n.theme]})).getLastGrammarState(r,n)}}}f();var yr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-GK625GFM.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-BBPQXDS2.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-JGB4KP74.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-K7JGTCPV.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-RWJJQSLU.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-ZFZ6ZP6X.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-HLYUQ6RF.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-UPNOBGN4.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-XE5XFLFP.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-EXRA4QJX.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-LRUOJBTB.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-JA25I4AE.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-CKELYRRF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-QIUJFE3G.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-JQIESO7E.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-UBV5AWUH.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-AWDHWPK7.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-QY3ZIV7G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-AEVQQKWS.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-75QR2XDN.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-S4LVU77Y.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-NDTDGSIG.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-Z6EEJ7SX.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-5IQEFQG3.js"))},{id:"php",name:"PHP",import:(()=>import("../php-UQGWKJAF.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-XHTBJJNO.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-UMC4HKIF.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-HCGHBPBZ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-ML25RVXY.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-ALTWCQTO.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-6TT7H4YP.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-WN3SJLUV.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-NAJDOQCO.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-GIY7NVAA.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-V6GLJNYA.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-KB45C76H.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Cl=Object.fromEntries(yr.map(e=>[e.id,e.import])),Ll=Object.fromEntries(yr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ga={...Cl,...Ll};f();var Mm=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],Il=Object.fromEntries(Mm.map(e=>[e.id,e.import]));f();var ha=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Fm(){return 2147483648}function Dm(){return typeof performance<"u"?performance.now():Date.now()}var Bm=(e,t)=>e+(t-e%t)%t;async function Em(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function n(m,g,I){o.HEAPU8.copyWithin(m,g,g+I)}function s(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let g=o.HEAPU8.length;m=m>>>0;let I=Fm();if(m>I)return!1;for(let C=1;C<=4;C*=2){let S=g*(1+.2/C);S=Math.min(S,m+100663296);let x=Math.min(I,Bm(Math.max(m,S),65536));if(s(x))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,g,I=1024){let C=g+I,S=g;for(;m[S]&&!(S>=C);)++S;if(S-g>16&&m.buffer&&l)return l.decode(m.subarray(g,S));let x="";for(;g<S;){let L=m[g++];if(!(L&128)){x+=String.fromCharCode(L);continue}let y=m[g++]&63;if((L&224)===192){x+=String.fromCharCode((L&31)<<6|y);continue}let k=m[g++]&63;if((L&240)===224?L=(L&15)<<12|y<<6|k:L=(L&7)<<18|y<<12|k<<6|m[g++]&63,L<65536)x+=String.fromCharCode(L);else{let P=L-65536;x+=String.fromCharCode(55296|P>>10,56320|P&1023)}}return x}function c(m,g){return m?u(o.HEAPU8,m,g):""}let d={emscripten_get_now:Dm,emscripten_memcpy_big:n,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let g=await e({env:d,wasi_snapshot_preview1:d});t=g.memory,r(t.buffer),Object.assign(o,g),o.UTF8ToString=c}return await p(),o}var _m=Object.defineProperty,Om=(e,t,a)=>t in e?_m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,de=(e,t,a)=>Om(e,typeof t!="symbol"?t+"":t,a),ge=null;function Nm(e){throw new ha(e.UTF8ToString(e.getLastOnigError()))}var io=class e{constructor(t){de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16Value"),de(this,"utf8Value"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,n=r?new Uint32Array(a+1):null;r&&(n[a]=o);let s=r?new Uint32Array(o+1):null;r&&(s[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(n[u]=l,p&&(n[u+1]=l),d<=127?s[l+0]=u:d<=2047?(s[l+0]=u,s[l+1]=u):d<=65535?(s[l+0]=u,s[l+1]=u,s[l+2]=u):(s[l+0]=u,s[l+1]=u,s[l+2]=u,s[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=n,this.utf8OffsetToUtf16=s}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let n=t.charCodeAt(o),s=n,i=!1;if(n>=55296&&n<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(s=(n-55296<<10)+65536|l-56320,i=!0)}s<=127?a+=1:s<=2047?a+=2:s<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},lo=class Ve{constructor(t){if(de(this,"id",++Ve.LAST_ID),de(this,"_onigBinding"),de(this,"content"),de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16"),de(this,"ptr"),!ge)throw new ha("Must invoke loadWasm first.");this._onigBinding=ge,this.content=t;let a=new io(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ve._sharedPtrInUse?(Ve._sharedPtr||(Ve._sharedPtr=ge.omalloc(1e4)),Ve._sharedPtrInUse=!0,ge.HEAPU8.set(a.utf8Value,Ve._sharedPtr),this.ptr=Ve._sharedPtr):this.ptr=a.createString(ge)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ve._sharedPtr?Ve._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};de(lo,"LAST_ID",0);de(lo,"_sharedPtr",0);de(lo,"_sharedPtrInUse",!1);var Sl=lo,kr=class{constructor(t){if(de(this,"_onigBinding"),de(this,"_ptr"),!ge)throw new ha("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new io(t[i]);a[i]=u.createString(ge),o[i]=u.utf8Length}let r=ge.omalloc(4*t.length);ge.HEAPU32.set(a,r/4);let n=ge.omalloc(4*t.length);ge.HEAPU32.set(o,n/4);let s=ge.createOnigScanner(r,n,t.length);for(let i=0,l=t.length;i<l;i++)ge.ofree(a[i]);ge.ofree(n),ge.ofree(r),s===0&&Nm(ge),this._onigBinding=ge,this._ptr=s}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Sl(t);let n=this._findNextMatchSync(t,a,!1,r);return t.dispose(),n}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let n=this._onigBinding,s=n.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(s===0)return null;let i=n.HEAPU32,l=s/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),g=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:g,length:g-m}}return{index:u,captureIndices:d}}};function Um(e){return typeof e.instantiator=="function"}function Hm(e){return typeof e.default=="function"}function qm(e){return typeof e.data<"u"}function Wm(e){return typeof Response<"u"&&e instanceof Response}function Gm(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var so;function jm(e){if(so)return so;async function t(){ge=await Em(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Um(o)?o=await o.instantiator(a):Hm(o)?o=await o.default(a):(qm(o)&&(o=o.data),Wm(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await zm(o)(a):o=await Vm(o)(a):Gm(o)?o=await br(o)(a):o instanceof WebAssembly.Module?o=await br(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await br(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return so=t(),so}function br(e){return t=>WebAssembly.instantiate(e,t)}function zm(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Vm(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function yl(e){return e&&await jm(e),{createScanner(t){return new kr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Sl(t)}}}var uo=wl({langs:ga,themes:Il,engine:()=>yl(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:$m,codeToHast:Xm,codeToTokens:Km,codeToTokensBase:Qm,codeToTokensWithThemes:Jm,getSingletonHighlighter:Ym,getLastGrammarState:Zm}=xl(uo,{guessEmbeddedLanguages:dl});var bl=new Set(Object.keys(ga)),Tr=new Map,vr=new Map,Pt=new Map,eg=(e,t)=>`${e}-${t[0]}-${t[1]}`,tg=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},ag=(e,t)=>{let a=eg(e,t);if(Tr.has(a))return Tr.get(a);let o=uo({themes:t,langs:[e]});return Tr.set(a,o),o};function og(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return bl.has(o)},getSupportedLanguages(){return Array.from(bl)},getThemes(){return a},highlight({code:o,language:r,themes:n},s){let i=tg(o,r,n);return vr.has(i)?vr.get(i):(s&&(Pt.has(i)||Pt.set(i,new Set),Pt.get(i).add(s)),ag(r,n).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:n[0],dark:n[1]}});vr.set(i,c);let d=Pt.get(i);if(d){for(let p of d)p(c);Pt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),Pt.delete(i)}),null)}}}var kl=og();import{memo as ig}from"react";f();import{useEffect as rg,useRef as co,useState as ng}from"react";var sg=5,Tl=400;function vl(e,t,a={}){let{msPerChar:o=sg}=a,[r,n]=ng(t?"":e),s=co(e),i=co(t?0:e.length),l=co(0),u=co(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),s.current=e,rg(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,n(e);return}if(s.current.length-i.current>Tl&&(i.current=s.current.length-Tl),u.current!==null)return;let d=p=>{let m=s.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let g=p-l.current;if(g>=o){let I=Math.min(Math.floor(g/o),m.length-i.current);i.current+=I,n(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as fo}from"react/jsx-runtime";var Pr=({className:e,from:t,children:a,...o})=>fo("div",{className:A("ww-message ww:group ww:flex ww:w-full",t==="user"?"ww-message-user is-user ww:ml-auto ww:flex-col ww:items-end ww:[max-width:var(--ww-msg-max-width,80%)]":"ww-message-assistant is-assistant ww:flex-col",e),...o,children:fo("div",{className:A("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Ar=({children:e,className:t,...a})=>fo("div",{className:A("ww-bubble ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden","ww:[font-size:var(--ww-font-size,1rem)] ww:[line-height:var(--ww-line-height,1.5)]","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:[color:var(--ww-color-user-bubble-text)] ww:group-[.is-user]:[border-radius:var(--ww-msg-radius,8px)] ww:group-[.is-user]:[padding:var(--ww-msg-pad-y,12px)_var(--ww-msg-pad-x,16px)]","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),lg={cjk:Jo,code:kl},ug={cjk:Jo},dg={enabled:!1};function cg({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let s=vl(typeof o=="string"?o:"",!!a),i=typeof o=="string"?s:o;return fo(Ft,{className:A("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??dg,plugins:a?ug:lg,...r,children:i})}var po=ig(cg,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);po.displayName="MessageResponse";f();import{createContext as fg,useCallback as pg,useContext as Ml,useEffect as mg,useMemo as Mr,useRef as gg,useState as Fr}from"react";import{Fragment as Rl,jsx as K,jsxs as gt}from"react/jsx-runtime";function hg(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],n=t-2;for(let[s,i]of o){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),n-=c.length+3}return`{${r.join(", ")}}`}function wg({text:e,className:t}){let{t:a}=V(),[o,r]=Fr(!1),n=gg(null);mg(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=pg(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return K(Ge,{variant:"ghost",size:"sm",onClick:s,className:A("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?gt(Rl,{children:[K(Gt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copied})]}):gt(Rl,{children:[K(zt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copy})]})})}function Fl({data:e,label:t,className:a,...o}){let[r,n]=Fr(!1),s=Mr(()=>JSON.stringify(e,null,2),[e]),i=hg(e);return gt("div",{className:A("ww:rounded-lg ww:bg-tool-card",a),...o,children:[gt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[K("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),K(wg,{text:s})]}),gt("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[K(jt,{className:A("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?K("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:K("code",{children:s})}):K("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Dr=fg({open:!1,toggle:()=>{}});function Dl({className:e,defaultOpen:t=!1,children:a,...o}){let[r,n]=Fr(t);return K(Dr.Provider,{value:{open:r,toggle:()=>n(s=>!s)},children:K("div",{className:A("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:a})})}function Bl({className:e,title:t,state:a,...o}){let{open:r,toggle:n}=Ml(Dr),s=a==="input-available"||a==="input-streaming",i=t??"";return gt("button",{type:"button",onClick:n,className:A("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...o,children:[K(it,{className:"ww:size-4 ww:shrink-0"}),K("span",{className:"ww:truncate",children:s?K(Oe,{duration:1.6,children:i}):i}),K(Je,{className:A("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function El({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",n=t??"";return K("div",{className:A("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:K("span",{className:"ww:truncate",children:r?K(Oe,{duration:1.6,children:n}):n})})}function _l({className:e,children:t,...a}){let{open:o}=Ml(Dr);return K("div",{className:A("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:K("div",{className:"ww:min-h-0 ww:overflow-hidden",children:K("div",{className:A("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function Br({className:e,input:t,debug:a,...o}){let{t:r}=V(),n=Mr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return K(Fl,{data:n,label:r.tool.request,className:e,...o})}function Rr(e){if(!(typeof e!="object"||e===null))return e}function Ol(e){return Rr(e?.ui)}function Nl(e){return Rr(Rr(e)?._meta)}function Pl(e){if(!e)return;let t=Ol(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function Al(e){return Ol(e)?.autoHeight===!0}function wa(e,t,a){if(e){let o=Pl(a?.[e]?._meta);if(o)return o}return Pl(Nl(t))}function Ul(e,t,a){return e&&Al(a?.[e]?._meta)?!0:Al(Nl(t))}function Er({className:e,output:t,errorText:a,debug:o,...r}){let{t:n}=V(),s=Mr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?gt("div",{className:A("ww:space-y-2",e),...r,children:[K("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),K("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):K(Fl,{data:s,label:n.tool.response,className:e,...r}):null}f();import{jsx as Hl,jsxs as xg}from"react/jsx-runtime";function ql(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function Wl(e){return e.parts.some(ql)}function Gl(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let o=e[e.length-1];return!o||o.role!=="assistant"?!0:!o.parts.some(n=>!(!ql(n)||a?.ignoreToolParts&&"toolCallId"in n||a?.ignoreReasoningParts&&n.type==="reasoning"))}function jl({className:e,...t}){let{t:a}=V();return xg("div",{"aria-live":"polite",className:A("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[Hl(Jt,{className:"ww:size-4 ww:shrink-0"}),Hl(Oe,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as Cg,useEffect as _r,useMemo as Lg,useRef as ye,useState as zl}from"react";import{jsx as Mg}from"react/jsx-runtime";var Ig="/api/mcp/resource",Sg=500,yg=0,bg=16,kg="2026-01-26",Tg=300,vg=3e3,Pg=3;function Ag(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Rg(e,t,a){return wa(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Vl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=Ig,chatSessionId:r,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let g=ye(null),I=ye(t),C=ye(a),S=ye({width:0,height:0}),x=ye(null),L=ye(!1),y=ye(0),k=ye("inline"),[P,F]=zl(yg),[R,_]=zl(void 0),M=ye(l),E=ye(u),v=ye(c),D=ye(d),H=ye(r),T=ye(m);I.current=t,C.current=a,M.current=l,E.current=u,v.current=c,D.current=d,H.current=r,T.current=m;let O=Cg(W=>i?Math.max(W+bg,0):Math.min(Math.max(W,50),Sg),[i]),U=Lg(()=>{let W=o.includes("?")?"&":"?";return`${o}${W}uri=${encodeURIComponent(e)}`},[o,e]),Be=ye(n);Be.current=n;let be=ye(p);return _r(()=>{be.current=p,S.current.height=-1,x.current&&(x.current.cancel(),x.current=null)},[p]),_r(()=>{if(!L.current)return;let W=g.current;W?.contentWindow&&W.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),_r(()=>{let W=g.current;if(!W)return;let ke=!1,ue=!1,Ae=null,he=null,Q=setTimeout(()=>{if(ke||ue||y.current>=Pg)return;y.current+=1;let Ie=new URL(W.src);Ie.searchParams.set("_retry",String(y.current)),W.src=Ie.toString()},vg),J=Ie=>{W.contentWindow?.postMessage(Ie,"*")},Ue=Ie=>{if(ke||Ie.source!==W.contentWindow)return;let te=Ie.data;if(!te||typeof te!="object"||te.jsonrpc!=="2.0")return;let fe=te.method,z=te.id;if(fe==="ui/initialize"&&z!=null){ue=!0,clearTimeout(Q),J({jsonrpc:"2.0",id:z,result:{protocolVersion:te.params?.protocolVersion??kg,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Be.current?"dark":"light",displayMode:k.current}}});return}if(fe==="ui/notifications/initialized"){L.current=!0;let G=I.current,X=C.current,ae=X._meta&&typeof X._meta=="object"?X._meta:null,pe=Ag(H.current),se=ae&&typeof ae.waniwani=="object"&&ae.waniwani!==null?ae.waniwani:null,Te=se||pe?{...se??{},...pe?{sessionId:pe}:{}}:void 0,ve=ae||Te?{...ae??{},...Te?{waniwani:Te}:{}}:void 0;J({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:G}});let He=X.content??[{type:"text",text:JSON.stringify(X)}];J({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:He,structuredContent:X.structuredContent,_meta:ve,meta:ve}});return}if(fe==="ui/notifications/size-changed"){let G=te.params,X=typeof G?.height=="number"?G.height:void 0,ae=typeof G?.width=="number"?G.width:void 0,pe=S.current,se=X!==void 0&&X!==pe.height,Te=ae!==void 0&&ae!==pe.width;if(!se&&!Te)return;if(se&&X!==void 0){if(pe.height=X,be.current)return;let ve=O(X),He=W.getBoundingClientRect().height;if(x.current&&(x.current.cancel(),x.current=null),F(ve),W.animate&&Math.abs(He-ve)>2){let xt=W.animate([{height:`${He}px`},{height:`${ve}px`}],{duration:Tg,easing:"ease-out",fill:"forwards"});x.current=xt,xt.onfinish=()=>{x.current===xt&&(xt.cancel(),x.current=null)}}}Te&&i&&ae!==void 0&&(pe.width=ae,_(ae));return}if(fe==="ui/open-link"&&z!=null){let G=te.params?.url;typeof G=="string"&&(M.current?M.current(G):window.open(G,"_blank","noopener,noreferrer")),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/message"&&z!=null){if(E.current&&te.params){let G=te.params,X=Ae;if(Ae=null,he){clearTimeout(he.timer);let ae=he.text;he=null;let pe=(G.content??[]).map(se=>se.text??"").join("").trim();G={...G,content:[{type:"text",text:`${pe}
78
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Yi(e,t,a,o){let r=o.schema,n=r.space==="svg"?!1:o.settings.omitOptionalTags,s=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ba);let u=Np(o,e.properties),d=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,d&&(s=!1),(u||!n||!Ji(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),s&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(d),!s&&(!n||!fa(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function Np(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let n=Up(e,r,t[r]);n&&a.push(n)}}for(;++o<a.length;){let n=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&n!=='"'&&n!=="'"&&(a[o]+=" ")}return a.join("")}function Up(e,t,a){let o=cn(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,n=e.settings.allowDangerousCharacters?0:1,s=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=Qe(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Ja.name[r][n]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?pn:mn)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=Qe(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Ja.unquoted[r][n]}))),i!==a&&(e.settings.quoteSmart&&vo(a,s)>vo(a,e.alternative)&&(s=e.alternative),i=s+Qe(a,Object.assign({},e.settings.characterReferences,{subset:(s==="'"?Ja.single:Ja.double)[r][n],attribute:!0}))+s),l+(i&&"="+i))}f();f();var Hp=["<","&"];function Ya(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:Qe(e.value,Object.assign({},o.settings.characterReferences,{subset:Hp}))}function Zi(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ya(e,t,a,o)}f();function el(e,t,a,o){return o.all(e)}var tl=gn("type",{invalid:qp,unknown:Wp,handlers:{comment:Vi,doctype:$i,element:Yi,raw:Zi,root:el,text:Ya}});function qp(e){throw new Error("Expected node, not `"+e+"`")}function Wp(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var Gp={},jp={},zp=[];function fr(e,t){let a=t||Gp,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:Vp,all:$p,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||hn,characterReferences:a.characterReferences||jp,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ba:fn,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Vp(e,t,a){return tl(e,t,a,this)}function $p(e){let t=[],a=e&&e.children||zp,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Za(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,n]of Object.entries(t?.colorReplacements||{}))typeof n=="string"?a[r]=n:r===o&&Object.assign(a,n);return a}function ot(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Xp(e){return Array.isArray(e)?e:[e]}async function ll(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function xr(e){return!e||["plaintext","txt","text","plain"].includes(e)}function ul(e){return e==="ansi"||xr(e)}function Cr(e){return e==="none"}function dl(e){return Cr(e)}function cl(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(/\s+/g)),Array.isArray(e.properties.class)||(e.properties.class=[]);let a=Array.isArray(t)?t:t.split(/\s+/g);for(let o of a)o&&!e.properties.class.includes(o)&&e.properties.class.push(o);return e}function ro(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let n=0;n<a.length;n+=2){let s=t?a[n]+(a[n+1]||""):a[n];r.push([s,o]),o+=a[n].length,o+=a[n+1]?.length||0}return r}function Kp(e){let t=ro(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let n=r,s=0;for(let i of t){if(n<i.length)break;n-=i.length,s++}return{line:s,character:n}}function o(r,n){let s=0;for(let i=0;i<r;i++)s+=t[i].length;return s+=n,s}return{lines:t,indexToPos:a,posToIndex:o}}function fl(e,t,a){let o=new Set;for(let n of e.matchAll(/:?lang=["']([^"']+)["']/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/\\begin\{([\w-]+)\}/g)){let s=n[1].toLowerCase().trim();s&&o.add(s)}for(let n of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let s=n[1].toLowerCase().trim(),i=s.includes("/")?s.split("/").pop():s;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(n=>n&&r[n])}var Lr="light-dark()",Qp=["color","background-color"];function Jp(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function Yp(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let n=a.filter(s=>r.offset<s&&s<r.offset+r.content.length).map(s=>s-r.offset).sort((s,i)=>s-i);return n.length?Jp(r,n):r})):e}function Zp(e,t,a,o,r="css-vars"){let n={content:e.content,explanation:e.explanation,offset:e.offset},s=t.map(d=>eo(e.variants[d])),i=new Set(s.flatMap(d=>Object.keys(d))),l={},u=(d,c)=>{let p=c==="color"?"":c==="background-color"?"-bg":`-${c}`;return a+t[d]+(c==="color"?"":p)};return s.forEach((d,c)=>{for(let p of i){let m=d[p]||"inherit";if(c===0&&o&&Qp.includes(p))if(o===Lr&&s.length>1){let g=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(g===-1||I===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let x=s[g][p]||"inherit",S=s[I][p]||"inherit";l[p]=`light-dark(${x}, ${S})`,r==="css-vars"&&(l[u(c,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(c,p)]=m)}}),n.htmlStyle=l,n}function eo(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&xe.Italic&&(t["font-style"]="italic"),e.fontStyle&xe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&xe.Underline&&a.push("underline"),e.fontStyle&xe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function gr(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var pl=new WeakMap;function no(e,t){pl.set(e,t)}function ma(e){return pl.get(e)}var vt=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(Xp(a).map(o=>[o,$a])),t)}constructor(...t){if(t.length===2){let[a,o]=t;this.lang=o,this._stacks=a}else{let[a,o,r]=t;this.lang=o,this._stacks={[r]:a}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return em(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function em(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let n=r?.nameScopesList?.scopeName;n&&t.push(n),r.parent&&o(r.parent)}return o(e),t}function tm(e,t){if(!(e instanceof vt))throw new re("Invalid grammar state");return e.getInternalStack(t)}function am(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(s){if(typeof s=="number"){if(s<0||s>a.source.length)throw new re(`Invalid decoration offset: ${s}. Code length: ${a.source.length}`);return{...r.indexToPos(s),offset:s}}else{let i=r.lines[s.line];if(i===void 0)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Lines length: ${r.lines.length}`);let l=s.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new re(`Invalid decoration position ${JSON.stringify(s)}. Line ${s.line} length: ${i.length}`);return{...s,character:l,offset:r.posToIndex(s.line,l)}}},r=Kp(a.source),n=(a.options.decorations||[]).map(s=>({...s,start:o(s.start),end:o(s.end)}));om(n),e.set(a.meta,{decorations:n,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(s=>[s.start.offset,s.end.offset]);return Yp(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(d=>d.type==="element"&&d.tagName==="span");if(r.length!==o.converter.lines.length)throw new re(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function n(d,c,p,m){let g=r[d],I="",x=-1,S=-1;if(c===0&&(x=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=g.children.length),x===-1||S===-1)for(let L=0;L<g.children.length;L++)I+=ml(g.children[L]),x===-1&&I.length===c&&(x=L+1),S===-1&&I.length===p&&(S=L+1);if(x===-1)throw new re(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new re(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=g.children.slice(x,S);if(!m.alwaysWrap&&C.length===g.children.length)i(g,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")i(C[0],m,"token");else{let L={type:"element",tagName:"span",properties:{},children:C};i(L,m,"wrapper"),g.children.splice(x,C.length,L)}}function s(d,c){r[d]=i(r[d],c,"line")}function i(d,c,p){let m=c.properties||{},g=c.transform||(I=>I);return d.tagName=c.tagName||"span",d.properties={...d.properties,...m,class:d.properties.class},c.properties?.class&&cl(d,c.properties.class),d=g(d,p)||d,d}let l=[],u=o.decorations.sort((d,c)=>c.start.offset-d.start.offset||d.end.offset-c.end.offset);for(let d of u){let{start:c,end:p}=d;if(c.line===p.line)n(c.line,c.character,p.character,d);else if(c.line<p.line){n(c.line,c.character,Number.POSITIVE_INFINITY,d);for(let m=c.line+1;m<p.line;m++)l.unshift(()=>s(m,d));n(p.line,0,p.character,d)}}l.forEach(d=>d())}}}function om(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new re(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],n=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,s=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(n||s||i||l){if(n&&s||i&&l||i&&a.start.offset===a.end.offset||s&&r.start.offset===r.end.offset)continue;throw new re(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function ml(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(ml).join(""):""}var rm=[am()];function to(e){let t=nm(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...rm]}function nm(e){let t=[],a=[],o=[];for(let r of e)switch(r.enforce){case"pre":t.push(r);break;case"post":a.push(r);break;default:o.push(r)}return{pre:t,post:a,normal:o}}var mt=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],pr={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function sm(e,t){let a=e.indexOf("\x1B",t);if(a!==-1&&e[a+1]==="["){let o=e.indexOf("m",a);if(o!==-1)return{sequence:e.substring(a+2,o).split(";"),startPosition:a,position:o+1}}return{position:e.length}}function al(e){let t=e.shift();if(t==="2"){let a=e.splice(0,3).map(o=>Number.parseInt(o));return a.length!==3||a.some(o=>Number.isNaN(o))?void 0:{type:"rgb",rgb:a}}else if(t==="5"){let a=e.shift();if(a)return{type:"table",index:Number(a)}}}function im(e){let t=[];for(;e.length>0;){let a=e.shift();if(!a)continue;let o=Number.parseInt(a);if(!Number.isNaN(o))if(o===0)t.push({type:"resetAll"});else if(o<=9)pr[o]&&t.push({type:"setDecoration",value:pr[o]});else if(o<=29){let r=pr[o-20];r&&(t.push({type:"resetDecoration",value:r}),r==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(o<=37)t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-30]}});else if(o===38){let r=al(e);r&&t.push({type:"setForegroundColor",value:r})}else if(o===39)t.push({type:"resetForegroundColor"});else if(o<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-40]}});else if(o===48){let r=al(e);r&&t.push({type:"setBackgroundColor",value:r})}else o===49?t.push({type:"resetBackgroundColor"}):o===53?t.push({type:"setDecoration",value:"overline"}):o===55?t.push({type:"resetDecoration",value:"overline"}):o>=90&&o<=97?t.push({type:"setForegroundColor",value:{type:"named",name:mt[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:mt[o-100+8]}})}return t}function lm(){let e=null,t=null,a=new Set;return{parse(o){let r=[],n=0;do{let s=sm(o,n),i=s.sequence?o.substring(n,s.startPosition):o.substring(n);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),s.sequence){let l=im(s.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}n=s.position}while(n<o.length);return r}}}var um={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function dm(e=um){function t(i){return e[i]}function a(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let o;function r(){if(o)return o;o=[];for(let u=0;u<mt.length;u++)o.push(t(mt[u]));let i=[0,95,135,175,215,255];for(let u=0;u<6;u++)for(let d=0;d<6;d++)for(let c=0;c<6;c++)o.push(a([i[u],i[d],i[c]]));let l=8;for(let u=0;u<24;u++,l+=10)o.push(a([l,l,l]));return o}function n(i){return r()[i]}function s(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return n(i.index)}}return{value:s}}var cm={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function fm(e,t,a){let o=Za(e,a),r=ro(t),n=Object.fromEntries(mt.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,d=e.colors?.[u];return[l,d||cm[l]]})),s=dm(n),i=lm();return r.map(l=>i.parse(l[0]).map(u=>{let d,c;u.decorations.has("reverse")?(d=u.background?s.value(u.background):e.bg,c=u.foreground?s.value(u.foreground):e.fg):(d=u.foreground?s.value(u.foreground):e.fg,c=u.background?s.value(u.background):void 0),d=ot(d,o),c=ot(c,o),u.decorations.has("dim")&&(d=pm(d));let p=xe.None;return u.decorations.has("bold")&&(p|=xe.Bold),u.decorations.has("italic")&&(p|=xe.Italic),u.decorations.has("underline")&&(p|=xe.Underline),u.decorations.has("strikethrough")&&(p|=xe.Strikethrough),{content:u.value,offset:l[1],color:d,bgColor:c,fontStyle:p}}))}function pm(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],n=o[1],s=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${n}${n}${s}${s}${l}`}else if(o.length===3){let r=o[0],n=o[1],s=o[2];return`#${r}${r}${n}${n}${s}${s}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function Ir(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(xr(r)||Cr(o))return ro(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:n,colorMap:s}=e.setTheme(o);if(r==="ansi")return fm(n,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new re(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(n.name))throw new re(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${n.name}"`)}return gm(t,i,n,s,a)}function mm(...e){if(e.length===2)return ma(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:n=t.getLoadedThemes()[0]}=o;if(xr(r)||Cr(n))throw new re("Plain language does not have grammar state");if(r==="ansi")throw new re("ANSI language does not have grammar state");let{theme:s,colorMap:i}=t.setTheme(n),l=t.getLanguage(r);return new vt(Sr(a,l,s,i,o).stateStack,l.name,s.name)}function gm(e,t,a,o,r){let n=Sr(e,t,a,o,r),s=new vt(n.stateStack,t.name,a.name);return no(n.tokens,s),n.tokens}function Sr(e,t,a,o,r){let n=Za(a,r),{tokenizeMaxLineLength:s=0,tokenizeTimeLimit:i=500}=r,l=ro(e),u=r.grammarState?tm(r.grammarState,a.name)??$a:r.grammarContextCode!=null?Sr(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:$a,d=[],c=[];for(let p=0,m=l.length;p<m;p++){let[g,I]=l[p];if(g===""){d=[],c.push([]);continue}if(s>0&&g.length>=s){d=[],c.push([{content:g,offset:I,color:"",fontStyle:0}]);continue}let x,S,C;r.includeExplanation&&(x=t.tokenizeLine(g,u,i),S=x.tokens,C=0);let L=t.tokenizeLine2(g,u,i),y=L.tokens.length/2;for(let b=0;b<y;b++){let P=L.tokens[2*b],M=b+1<y?L.tokens[2*b+2]:g.length;if(P===M)continue;let A=L.tokens[2*b+1],_=ot(o[pt.getForeground(A)],n),F=pt.getFontStyle(A),E={content:g.substring(P,M),offset:I+P,color:_,fontStyle:F};if(r.includeExplanation){let v=[];if(r.includeExplanation!=="scopeName")for(let H of a.settings){let T;switch(typeof H.scope){case"string":T=H.scope.split(/,/).map(O=>O.trim());break;case"object":T=H.scope;break;default:continue}v.push({settings:H,selectors:T.map(O=>O.split(/ /))})}E.explanation=[];let D=0;for(;P+D<M;){let H=S[C],T=g.substring(H.startIndex,H.endIndex);D+=T.length,E.explanation.push({content:T,scopes:r.includeExplanation==="scopeName"?hm(H.scopes):wm(v,H.scopes)}),C+=1}}d.push(E)}c.push(d),d=[],u=L.ruleStack}return{tokens:c,stateStack:u}}function hm(e){return e.map(t=>({scopeName:t}))}function wm(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let n=t[o];a[o]={scopeName:n,themeMatches:Cm(e,n,t.slice(0,o))}}return a}function ol(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function xm(e,t,a){if(!ol(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)ol(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Cm(e,t,a){let o=[];for(let{selectors:r,settings:n}of e)for(let s of r)if(xm(s,t,a)){o.push(n);break}return o}function gl(e,t,a){let o=Object.entries(a.themes).filter(l=>l[1]).map(l=>({color:l[0],theme:l[1]})),r=o.map(l=>{let u=Ir(e,t,{...a,theme:l.theme}),d=ma(u),c=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:d,theme:c}}),n=Lm(...r.map(l=>l.tokens)),s=n[0].map((l,u)=>l.map((d,c)=>{let p={content:d.content,variants:{},offset:d.offset};return"includeExplanation"in a&&a.includeExplanation&&(p.explanation=d.explanation),n.forEach((m,g)=>{let{content:I,explanation:x,offset:S,...C}=m[u][c];p.variants[o[g].color]=C}),p})),i=r[0].state?new vt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&no(s,i),s}function Lm(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),n=t.map(()=>[]);t.forEach((l,u)=>l.push(n[u]));let s=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let d=i[u];d.content.length===l?(n[u].push(d),s[u]+=1,i[u]=r[u][s[u]]):(n[u].push({...d,content:d.content.slice(0,l)}),i[u]={...d,content:d.content.slice(l),offset:d.offset+l})}}}return t}function ao(e,t,a){let o,r,n,s,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:d="--shiki-",colorsRendering:c="css-vars"}=a,p=Object.entries(a.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new re("`themes` option must not be empty");let m=gl(e,t,a);if(l=ma(m),u&&Lr!==u&&!p.find(S=>S.color===u))throw new re(`\`themes\` option must contain the defaultColor key \`${u}\``);let g=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);n=m.map(S=>S.map(C=>Zp(C,I,d,u,c))),l&&no(n,l);let x=p.map(S=>Za(S.theme,a));r=rl(p,g,x,d,u,"fg",c),o=rl(p,g,x,d,u,"bg",c),s=`shiki-themes ${g.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Za(a.theme,a);n=Ir(e,t,a);let d=e.getTheme(a.theme);o=ot(d.bg,u),r=ot(d.fg,u),s=d.name,l=ma(n)}else throw new re("Invalid options, either `theme` or `themes` must be provided");return{tokens:n,fg:r,bg:o,themeName:s,rootStyle:i,grammarState:l}}function rl(e,t,a,o,r,n,s){return e.map((i,l)=>{let u=ot(t[l][n],a[l])||"inherit",d=`${o+i.color}${n==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===Lr&&e.length>1){let c=e.findIndex(I=>I.color==="light"),p=e.findIndex(I=>I.color==="dark");if(c===-1||p===-1)throw new re('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=ot(t[c][n],a[c])||"inherit",g=ot(t[p][n],a[p])||"inherit";return`light-dark(${m}, ${g});${d}`}return u}return s==="css-vars"?d:null}).filter(i=>!!i).join(";")}function oo(e,t,a,o={meta:{},options:a,codeToHast:(r,n)=>oo(e,r,n),codeToTokens:(r,n)=>ao(e,r,n)}){let r=t;for(let g of to(a))r=g.preprocess?.call(o,r,a)||r;let{tokens:n,fg:s,bg:i,themeName:l,rootStyle:u,grammarState:d}=ao(e,r,a),{mergeWhitespaces:c=!0,mergeSameStyleTokens:p=!1}=a;c===!0?n=Sm(n):c==="never"&&(n=ym(n)),p&&(n=bm(n));let m={...o,get source(){return r}};for(let g of to(a))n=g.tokens?.call(m,n)||n;return Im(n,{...a,fg:s,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,d)}function Im(e,t,a,o=ma(e)){let r=to(t),n=[],s={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,x]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=x);let d={type:"element",tagName:"pre",properties:u,children:[],data:t.data},c={type:"element",tagName:"code",properties:{},children:n},p=[],m={...a,structure:i,addClassToHast:cl,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return s},get pre(){return d},get code(){return c},get lines(){return p}};if(e.forEach((I,x)=>{x&&(i==="inline"?s.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&n.push({type:"text",value:`
79
+ `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let L of I){let y={type:"element",tagName:"span",properties:{...L.htmlAttrs},children:[{type:"text",value:L.content}]},b=gr(L.htmlStyle||eo(L));b&&(y.properties.style=b);for(let P of r)y=P?.span?.call(m,y,x+1,C,S,L)||y;i==="inline"?s.children.push(y):i==="classic"&&S.children.push(y),C+=L.content.length}if(i==="classic"){for(let L of r)S=L?.line?.call(m,S,x+1)||S;p.push(S),n.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)c=I?.code?.call(m,c)||c;d.children.push(c);for(let I of r)d=I?.pre?.call(m,d)||d;s.children.push(d)}else if(i==="inline"){let I=[],x={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let L of s.children)L.type==="element"&&L.tagName==="br"?(I.push(x),x={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(L.type==="element"||L.type==="text")&&x.children.push(L);I.push(x);let C={type:"element",tagName:"code",properties:{},children:I};for(let L of r)C=L?.code?.call(m,C)||C;s.children=[];for(let L=0;L<C.children.length;L++){L>0&&s.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[L];y.type==="element"&&s.children.push(...y.children)}}let g=s;for(let I of r)g=I?.root?.call(m,g)||g;return o&&no(g,o),g}function Sm(e){return e.map(t=>{let a=[],o="",r;return t.forEach((n,s)=>{let l=!(n.fontStyle&&(n.fontStyle&xe.Underline||n.fontStyle&xe.Strikethrough));l&&n.content.match(/^\s+$/)&&t[s+1]?(r===void 0&&(r=n.offset),o+=n.content):o?(l?a.push({...n,offset:r,content:o+n.content}):a.push({content:o,offset:r},n),r=void 0,o=""):a.push(n)}),a})}function ym(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,n,s]=o;if(!r&&!s)return a;let i=[{...a,offset:a.offset+r.length,content:n}];return r&&i.unshift({content:r,offset:a.offset}),s&&i.push({content:s,offset:a.offset+r.length+n.length}),i}))}function bm(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],n=gr(r.htmlStyle||eo(r)),s=gr(o.htmlStyle||eo(o)),i=r.fontStyle&&(r.fontStyle&xe.Underline||r.fontStyle&xe.Strikethrough),l=o.fontStyle&&(o.fontStyle&xe.Underline||o.fontStyle&xe.Strikethrough);!i&&!l&&n===s?r.content+=o.content:a.push({...o})}return a})}var km=fr;function Tm(e,t,a){let o={meta:{},options:a,codeToHast:(n,s)=>oo(e,n,s),codeToTokens:(n,s)=>ao(e,n,s)},r=km(oo(e,t,a,o));for(let n of to(a))r=n.postprocess?.call(o,r,a)||r;return r}var nl={light:"#333333",dark:"#bbbbbb"},sl={light:"#fffffe",dark:"#1e1e1e"},il="__shiki_resolved";function yr(e){if(e?.[il])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"?nl.light:nl.dark),a||(a=t.type==="light"?sl.light:sl.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,n=new Map;function s(i){if(n.has(i))return n.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?s(i):(n.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let d={...i,settings:{...i.settings}};if(l){let c=s(i.settings.foreground);t.colorReplacements[c]=i.settings.foreground,d.settings.foreground=c}if(u){let c=s(i.settings.background);t.colorReplacements[c]=i.settings.background,d.settings.background=c}return d});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=s(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,il,{enumerable:!1,writable:!1,value:!0}),t}async function hl(e){return Array.from(new Set((await Promise.all(e.filter(t=>!ul(t)).map(async t=>await ll(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function wl(e){return(await Promise.all(e.map(async a=>dl(a)?null:yr(await ll(a))))).filter(a=>!!a)}var mr=3,vm=!1;function Pm(e,t=3){if(mr&&!(typeof mr=="number"&&t>mr)){if(vm)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var at=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function xl(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new at(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var hr=class extends _i{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(n=>this.loadTheme(n)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=yr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=ia.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=xl(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(n=>n.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(n=>{this._alias[n]=t.name}),this._loadedLanguagesCache=null,a.size)for(let n of a)this._resolvedGrammars.delete(n.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(n.scopeName),this._syncRegistry?._grammars?.delete(n.scopeName),this.loadLanguage(this._langMap.get(n.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,n])=>!n);if(o.length){let r=a.filter(([n,s])=>s?(s.embeddedLanguages||s.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(n=>!o.includes(n));throw new at(`Missing languages ${o.map(([n])=>`\`${n}\``).join(", ")}, required by ${r.map(([n])=>`\`${n}\``).join(", ")}`)}for(let[r,n]of a)this._resolver.addLanguage(n);for(let[r,n]of a)this.loadLanguage(n)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},wr=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let n=a.slice(0,r).join(".");o=[...o,...this._injections.get(n)||[]]}return o}},pa=0;function Am(e){pa+=1,e.warnings!==!1&&pa>=10&&pa%10===0&&console.warn(`[Shiki] ${pa} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new at("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(yr),r=new wr(e.engine,a),n=new hr(r,o,a,e.langAlias),s;function i(L){return xl(L,e.langAlias)}function l(L){S();let y=n.getGrammar(typeof L=="string"?L:L.name);if(!y)throw new at(`Language \`${L}\` not found, you may need to load it first`);return y}function u(L){if(L==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=n.getTheme(L);if(!y)throw new at(`Theme \`${L}\` not found, you may need to load it first`);return y}function d(L){S();let y=u(L);s!==L&&(n.setTheme(y),s=L);let b=n.getColorMap();return{theme:y,colorMap:b}}function c(){return S(),n.getLoadedThemes()}function p(){return S(),n.getLoadedLanguages()}function m(...L){S(),n.loadLanguages(L.flat(1))}async function g(...L){return m(await hl(L))}function I(...L){S();for(let y of L.flat(1))n.loadTheme(y)}async function x(...L){return S(),I(await wl(L))}function S(){if(t)throw new at("Shiki instance has been disposed")}function C(){t||(t=!0,n.dispose(),pa-=1)}return{setTheme:d,getTheme:u,getLanguage:l,getLoadedThemes:c,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:g,loadLanguageSync:m,loadTheme:x,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function Rm(e){e.engine||Pm("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([wl(e.themes||[]),hl(e.langs||[]),e.engine]);return Am({...e,themes:t,langs:a,engine:o})}async function Mm(e){let t=await Rm(e);return{getLastGrammarState:(...a)=>mm(t,...a),codeToTokensBase:(a,o)=>Ir(t,a,o),codeToTokensWithThemes:(a,o)=>gl(t,a,o),codeToTokens:(a,o)=>ao(t,a,o),codeToHast:(a,o)=>oo(t,a,o),codeToHtml:(a,o)=>Tm(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function Cl(e){let t=e.langs,a=e.themes,o=e.engine;async function r(n){function s(c){if(typeof c=="string"){if(c=n.langAlias?.[c]||c,ul(c))return[];let p=t[c];if(!p)throw new re(`Language \`${c}\` is not included in this bundle. You may want to load it from external source.`);return p}return c}function i(c){if(dl(c))return"none";if(typeof c=="string"){let p=a[c];if(!p)throw new re(`Theme \`${c}\` is not included in this bundle. You may want to load it from external source.`);return p}return c}let l=(n.themes??[]).map(c=>i(c)),u=(n.langs??[]).map(c=>s(c)),d=await Mm({engine:n.engine??o(),...n,themes:l,langs:u});return{...d,loadLanguage(...c){return d.loadLanguage(...c.map(s))},loadTheme(...c){return d.loadTheme(...c.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Fm(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 Ll(e,t){let a=Fm(e);async function o(r,n){let s=await a({langs:[n.lang],themes:"theme"in n?[n.theme]:Object.values(n.themes)}),i=await t?.guessEmbeddedLanguages?.(r,n.lang,s);return i&&await s.loadLanguage(...i),s}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,n){return(await o(r,n)).codeToHtml(r,n)},async codeToHast(r,n){return(await o(r,n)).codeToHast(r,n)},async codeToTokens(r,n){return(await o(r,n)).codeToTokens(r,n)},async codeToTokensBase(r,n){return(await o(r,n)).codeToTokensBase(r,n)},async codeToTokensWithThemes(r,n){return(await o(r,n)).codeToTokensWithThemes(r,n)},async getLastGrammarState(r,n){return(await a({langs:[n.lang],themes:[n.theme]})).getLastGrammarState(r,n)}}}f();var br=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-GK625GFM.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-BBPQXDS2.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-JGB4KP74.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-K7JGTCPV.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-RWJJQSLU.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-ZFZ6ZP6X.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-HLYUQ6RF.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-UPNOBGN4.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-XE5XFLFP.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-EXRA4QJX.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-LRUOJBTB.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-JA25I4AE.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-CKELYRRF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-UN5O7U5U.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-QIUJFE3G.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-JQIESO7E.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-UBV5AWUH.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-AWDHWPK7.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-QY3ZIV7G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-KIGXJYY6.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-BZB5LDD5.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-AEVQQKWS.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-75QR2XDN.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-S4LVU77Y.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-NDTDGSIG.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-Z6EEJ7SX.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-5IQEFQG3.js"))},{id:"php",name:"PHP",import:(()=>import("../php-UQGWKJAF.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-XHTBJJNO.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-UMC4HKIF.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-HCGHBPBZ.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-ML25RVXY.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-ALTWCQTO.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-6TT7H4YP.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-WN3SJLUV.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-NAJDOQCO.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-GIY7NVAA.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-V6GLJNYA.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-KB45C76H.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Il=Object.fromEntries(br.map(e=>[e.id,e.import])),Sl=Object.fromEntries(br.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ga={...Il,...Sl};f();var Dm=[{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"))}],yl=Object.fromEntries(Dm.map(e=>[e.id,e.import]));f();var ha=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Bm(){return 2147483648}function Em(){return typeof performance<"u"?performance.now():Date.now()}var _m=(e,t)=>e+(t-e%t)%t;async function Om(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function n(m,g,I){o.HEAPU8.copyWithin(m,g,g+I)}function s(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let g=o.HEAPU8.length;m=m>>>0;let I=Bm();if(m>I)return!1;for(let x=1;x<=4;x*=2){let S=g*(1+.2/x);S=Math.min(S,m+100663296);let C=Math.min(I,_m(Math.max(m,S),65536));if(s(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,g,I=1024){let x=g+I,S=g;for(;m[S]&&!(S>=x);)++S;if(S-g>16&&m.buffer&&l)return l.decode(m.subarray(g,S));let C="";for(;g<S;){let L=m[g++];if(!(L&128)){C+=String.fromCharCode(L);continue}let y=m[g++]&63;if((L&224)===192){C+=String.fromCharCode((L&31)<<6|y);continue}let b=m[g++]&63;if((L&240)===224?L=(L&15)<<12|y<<6|b:L=(L&7)<<18|y<<12|b<<6|m[g++]&63,L<65536)C+=String.fromCharCode(L);else{let P=L-65536;C+=String.fromCharCode(55296|P>>10,56320|P&1023)}}return C}function d(m,g){return m?u(o.HEAPU8,m,g):""}let c={emscripten_get_now:Em,emscripten_memcpy_big:n,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let g=await e({env:c,wasi_snapshot_preview1:c});t=g.memory,r(t.buffer),Object.assign(o,g),o.UTF8ToString=d}return await p(),o}var Nm=Object.defineProperty,Um=(e,t,a)=>t in e?Nm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,de=(e,t,a)=>Um(e,typeof t!="symbol"?t+"":t,a),ge=null;function Hm(e){throw new ha(e.UTF8ToString(e.getLastOnigError()))}var io=class e{constructor(t){de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16Value"),de(this,"utf8Value"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,n=r?new Uint32Array(a+1):null;r&&(n[a]=o);let s=r?new Uint32Array(o+1):null;r&&(s[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let d=t.charCodeAt(u),c=d,p=!1;if(d>=55296&&d<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(c=(d-55296<<10)+65536|m-56320,p=!0)}r&&(n[u]=l,p&&(n[u+1]=l),c<=127?s[l+0]=u:c<=2047?(s[l+0]=u,s[l+1]=u):c<=65535?(s[l+0]=u,s[l+1]=u,s[l+2]=u):(s[l+0]=u,s[l+1]=u,s[l+2]=u,s[l+3]=u)),c<=127?i[l++]=c:c<=2047?(i[l++]=192|(c&1984)>>>6,i[l++]=128|(c&63)>>>0):c<=65535?(i[l++]=224|(c&61440)>>>12,i[l++]=128|(c&4032)>>>6,i[l++]=128|(c&63)>>>0):(i[l++]=240|(c&1835008)>>>18,i[l++]=128|(c&258048)>>>12,i[l++]=128|(c&4032)>>>6,i[l++]=128|(c&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=n,this.utf8OffsetToUtf16=s}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let n=t.charCodeAt(o),s=n,i=!1;if(n>=55296&&n<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(s=(n-55296<<10)+65536|l-56320,i=!0)}s<=127?a+=1:s<=2047?a+=2:s<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},lo=class Ve{constructor(t){if(de(this,"id",++Ve.LAST_ID),de(this,"_onigBinding"),de(this,"content"),de(this,"utf16Length"),de(this,"utf8Length"),de(this,"utf16OffsetToUtf8"),de(this,"utf8OffsetToUtf16"),de(this,"ptr"),!ge)throw new ha("Must invoke loadWasm first.");this._onigBinding=ge,this.content=t;let a=new io(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ve._sharedPtrInUse?(Ve._sharedPtr||(Ve._sharedPtr=ge.omalloc(1e4)),Ve._sharedPtrInUse=!0,ge.HEAPU8.set(a.utf8Value,Ve._sharedPtr),this.ptr=Ve._sharedPtr):this.ptr=a.createString(ge)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ve._sharedPtr?Ve._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};de(lo,"LAST_ID",0);de(lo,"_sharedPtr",0);de(lo,"_sharedPtrInUse",!1);var bl=lo,Tr=class{constructor(t){if(de(this,"_onigBinding"),de(this,"_ptr"),!ge)throw new ha("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new io(t[i]);a[i]=u.createString(ge),o[i]=u.utf8Length}let r=ge.omalloc(4*t.length);ge.HEAPU32.set(a,r/4);let n=ge.omalloc(4*t.length);ge.HEAPU32.set(o,n/4);let s=ge.createOnigScanner(r,n,t.length);for(let i=0,l=t.length;i<l;i++)ge.ofree(a[i]);ge.ofree(n),ge.ofree(r),s===0&&Hm(ge),this._onigBinding=ge,this._ptr=s}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new bl(t);let n=this._findNextMatchSync(t,a,!1,r);return t.dispose(),n}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let n=this._onigBinding,s=n.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(s===0)return null;let i=n.HEAPU32,l=s/4,u=i[l++],d=i[l++],c=[];for(let p=0;p<d;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),g=t.convertUtf8OffsetToUtf16(i[l++]);c[p]={start:m,end:g,length:g-m}}return{index:u,captureIndices:c}}};function qm(e){return typeof e.instantiator=="function"}function Wm(e){return typeof e.default=="function"}function Gm(e){return typeof e.data<"u"}function jm(e){return typeof Response<"u"&&e instanceof Response}function zm(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var so;function Vm(e){if(so)return so;async function t(){ge=await Om(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),qm(o)?o=await o.instantiator(a):Wm(o)?o=await o.default(a):(Gm(o)&&(o=o.data),jm(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await $m(o)(a):o=await Xm(o)(a):zm(o)?o=await kr(o)(a):o instanceof WebAssembly.Module?o=await kr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await kr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return so=t(),so}function kr(e){return t=>WebAssembly.instantiate(e,t)}function $m(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Xm(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function kl(e){return e&&await Vm(e),{createScanner(t){return new Tr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new bl(t)}}}var uo=Cl({langs:ga,themes:yl,engine:()=>kl(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Km,codeToHast:Qm,codeToTokens:Jm,codeToTokensBase:Ym,codeToTokensWithThemes:Zm,getSingletonHighlighter:eg,getLastGrammarState:tg}=Ll(uo,{guessEmbeddedLanguages:fl});var Tl=new Set(Object.keys(ga)),vr=new Map,Pr=new Map,Pt=new Map,ag=(e,t)=>`${e}-${t[0]}-${t[1]}`,og=(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}`},rg=(e,t)=>{let a=ag(e,t);if(vr.has(a))return vr.get(a);let o=uo({themes:t,langs:[e]});return vr.set(a,o),o};function ng(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Tl.has(o)},getSupportedLanguages(){return Array.from(Tl)},getThemes(){return a},highlight({code:o,language:r,themes:n},s){let i=og(o,r,n);return Pr.has(i)?Pr.get(i):(s&&(Pt.has(i)||Pt.set(i,new Set),Pt.get(i).add(s)),rg(r,n).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",d=l.codeToTokens(o,{lang:u,themes:{light:n[0],dark:n[1]}});Pr.set(i,d);let c=Pt.get(i);if(c){for(let p of c)p(d);Pt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),Pt.delete(i)}),null)}}}var vl=ng();import{memo as ug}from"react";f();import{useEffect as sg,useRef as co,useState as ig}from"react";var lg=5,Pl=400;function Al(e,t,a={}){let{msPerChar:o=lg}=a,[r,n]=ig(t?"":e),s=co(e),i=co(t?0:e.length),l=co(0),u=co(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),s.current=e,sg(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,n(e);return}if(s.current.length-i.current>Pl&&(i.current=s.current.length-Pl),u.current!==null)return;let c=p=>{let m=s.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let g=p-l.current;if(g>=o){let I=Math.min(Math.floor(g/o),m.length-i.current);i.current+=I,n(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(c)};return u.current=requestAnimationFrame(c),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as fo}from"react/jsx-runtime";var Ar=({className:e,from:t,children:a,...o})=>fo("div",{className:R("ww-message ww:group ww:flex ww:w-full",t==="user"?"ww-message-user is-user ww:ml-auto ww:flex-col ww:items-end ww:[max-width:var(--ww-msg-max-width,80%)]":"ww-message-assistant is-assistant ww:flex-col",e),...o,children:fo("div",{className:R("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),Rr=({children:e,className:t,...a})=>fo("div",{className:R("ww-bubble ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden","ww:[font-size:var(--ww-font-size,1rem)] ww:[line-height:var(--ww-line-height,1.5)]","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:[color:var(--ww-color-user-bubble-text)] ww:group-[.is-user]:[border-radius:var(--ww-msg-radius,8px)] ww:group-[.is-user]:[padding:var(--ww-msg-pad-y,12px)_var(--ww-msg-pad-x,16px)]","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),dg={cjk:Yo,code:vl},cg={cjk:Yo},fg={enabled:!1};function pg({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let s=Al(typeof o=="string"?o:"",!!a),i=typeof o=="string"?s:o;return fo(Ft,{className:R("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??fg,plugins:a?cg:dg,...r,children:i})}var po=ug(pg,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);po.displayName="MessageResponse";f();import{createContext as mg,useCallback as gg,useContext as Dl,useEffect as hg,useMemo as Fr,useRef as wg,useState as Dr}from"react";import{Fragment as Fl,jsx as K,jsxs as gt}from"react/jsx-runtime";function xg(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],n=t-2;for(let[s,i]of o){if(n<=8)break;let l=s.length>4?`${s.slice(0,4)}\u2026`:s,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let d=`${l}\u2009${u}`;r.push(d),n-=d.length+3}return`{${r.join(", ")}}`}function Cg({text:e,className:t}){let{t:a}=V(),[o,r]=Dr(!1),n=wg(null);hg(()=>()=>{n.current&&clearTimeout(n.current)},[]);let s=gg(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return K(Ge,{variant:"ghost",size:"sm",onClick:s,className:R("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?gt(Fl,{children:[K(Gt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copied})]}):gt(Fl,{children:[K(zt,{className:"ww:size-3.5"}),K("span",{children:a.tool.copy})]})})}function Bl({data:e,label:t,className:a,...o}){let[r,n]=Dr(!1),s=Fr(()=>JSON.stringify(e,null,2),[e]),i=xg(e);return gt("div",{className:R("ww:rounded-lg ww:bg-tool-card",a),...o,children:[gt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[K("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),K(Cg,{text:s})]}),gt("button",{type:"button",onClick:()=>n(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[K(jt,{className:R("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?K("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:K("code",{children:s})}):K("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Br=mg({open:!1,toggle:()=>{}});function El({className:e,defaultOpen:t=!1,children:a,...o}){let[r,n]=Dr(t);return K(Br.Provider,{value:{open:r,toggle:()=>n(s=>!s)},children:K("div",{className:R("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 _l({className:e,title:t,state:a,...o}){let{open:r,toggle:n}=Dl(Br),s=a==="input-available"||a==="input-streaming",i=t??"";return gt("button",{type:"button",onClick:n,className:R("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...o,children:[K(it,{className:"ww:size-4 ww:shrink-0"}),K("span",{className:"ww:truncate",children:s?K(Oe,{duration:1.6,children:i}):i}),K(Je,{className:R("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function Ol({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",n=t??"";return K("div",{className:R("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:K("span",{className:"ww:truncate",children:r?K(Oe,{duration:1.6,children:n}):n})})}function Nl({className:e,children:t,...a}){let{open:o}=Dl(Br);return K("div",{className:R("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:K("div",{className:"ww:min-h-0 ww:overflow-hidden",children:K("div",{className:R("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 Er({className:e,input:t,debug:a,...o}){let{t:r}=V(),n=Fr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...i}=t;return i}return t},[t,a]);return K(Bl,{data:n,label:r.tool.request,className:e,...o})}function Mr(e){if(!(typeof e!="object"||e===null))return e}function Ul(e){return Mr(e?.ui)}function Hl(e){return Mr(Mr(e)?._meta)}function Rl(e){if(!e)return;let t=Ul(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 Ml(e){return Ul(e)?.autoHeight===!0}function wa(e,t,a){if(e){let o=Rl(a?.[e]?._meta);if(o)return o}return Rl(Hl(t))}function ql(e,t,a){return e&&Ml(a?.[e]?._meta)?!0:Ml(Hl(t))}function _r({className:e,output:t,errorText:a,debug:o,...r}){let{t:n}=V(),s=Fr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?gt("div",{className:R("ww:space-y-2",e),...r,children:[K("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:n.tool.error}),K("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):K(Bl,{data:s,label:n.tool.response,className:e,...r}):null}f();import{jsx as Wl,jsxs as Lg}from"react/jsx-runtime";function Gl(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function jl(e){return e.parts.some(Gl)}function zl(e,t,a){if(t!=="submitted"&&t!=="streaming")return!1;let o=e[e.length-1];return!o||o.role!=="assistant"?!0:!o.parts.some(n=>!(!Gl(n)||a?.ignoreToolParts&&"toolCallId"in n||a?.ignoreReasoningParts&&n.type==="reasoning"))}function Vl({className:e,...t}){let{t:a}=V();return Lg("div",{"aria-live":"polite",className:R("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:[Wl(Jt,{className:"ww:size-4 ww:shrink-0"}),Wl(Oe,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as Ig,useEffect as Or,useMemo as Sg,useRef as ye,useState as $l}from"react";import{jsx as Dg}from"react/jsx-runtime";var yg="/api/mcp/resource",bg=500,kg=0,Tg=16,vg="2026-01-26",Pg=300,Ag=3e3,Rg=3;function Mg(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Fg(e,t,a){return wa(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Xl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=yg,chatSessionId:r,isDark:n=!1,className:s,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:d,onDisplayModeChange:c,isFullscreen:p=!1,toolDefinitions:m}){let g=ye(null),I=ye(t),x=ye(a),S=ye({width:0,height:0}),C=ye(null),L=ye(!1),y=ye(0),b=ye("inline"),[P,M]=$l(kg),[A,_]=$l(void 0),F=ye(l),E=ye(u),v=ye(d),D=ye(c),H=ye(r),T=ye(m);I.current=t,x.current=a,F.current=l,E.current=u,v.current=d,D.current=c,H.current=r,T.current=m;let O=Ig(W=>i?Math.max(W+Tg,0):Math.min(Math.max(W,50),bg),[i]),U=Sg(()=>{let W=o.includes("?")?"&":"?";return`${o}${W}uri=${encodeURIComponent(e)}`},[o,e]),Be=ye(n);Be.current=n;let be=ye(p);return Or(()=>{be.current=p,S.current.height=-1,C.current&&(C.current.cancel(),C.current=null)},[p]),Or(()=>{if(!L.current)return;let W=g.current;W?.contentWindow&&W.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:n?"dark":"light"}},"*")},[n]),Or(()=>{let W=g.current;if(!W)return;let ke=!1,ue=!1,Ae=null,he=null,Q=setTimeout(()=>{if(ke||ue||y.current>=Rg)return;y.current+=1;let Ie=new URL(W.src);Ie.searchParams.set("_retry",String(y.current)),W.src=Ie.toString()},Ag),J=Ie=>{W.contentWindow?.postMessage(Ie,"*")},Ue=Ie=>{if(ke||Ie.source!==W.contentWindow)return;let te=Ie.data;if(!te||typeof te!="object"||te.jsonrpc!=="2.0")return;let fe=te.method,z=te.id;if(fe==="ui/initialize"&&z!=null){ue=!0,clearTimeout(Q),J({jsonrpc:"2.0",id:z,result:{protocolVersion:te.params?.protocolVersion??vg,hostInfo:{name:"Waniwani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Be.current?"dark":"light",displayMode:b.current}}});return}if(fe==="ui/notifications/initialized"){L.current=!0;let G=I.current,X=x.current,ae=X._meta&&typeof X._meta=="object"?X._meta:null,pe=Mg(H.current),se=ae&&typeof ae.waniwani=="object"&&ae.waniwani!==null?ae.waniwani:null,Te=se||pe?{...se??{},...pe?{sessionId:pe}:{}}:void 0,ve=ae||Te?{...ae??{},...Te?{waniwani:Te}:{}}:void 0;J({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:G}});let He=X.content??[{type:"text",text:JSON.stringify(X)}];J({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:He,structuredContent:X.structuredContent,_meta:ve,meta:ve}});return}if(fe==="ui/notifications/size-changed"){let G=te.params,X=typeof G?.height=="number"?G.height:void 0,ae=typeof G?.width=="number"?G.width:void 0,pe=S.current,se=X!==void 0&&X!==pe.height,Te=ae!==void 0&&ae!==pe.width;if(!se&&!Te)return;if(se&&X!==void 0){if(pe.height=X,be.current)return;let ve=O(X),He=W.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),M(ve),W.animate&&Math.abs(He-ve)>2){let xt=W.animate([{height:`${He}px`},{height:`${ve}px`}],{duration:Pg,easing:"ease-out",fill:"forwards"});C.current=xt,xt.onfinish=()=>{C.current===xt&&(xt.cancel(),C.current=null)}}}Te&&i&&ae!==void 0&&(pe.width=ae,_(ae));return}if(fe==="ui/open-link"&&z!=null){let G=te.params?.url;typeof G=="string"&&(F.current?F.current(G):window.open(G,"_blank","noopener,noreferrer")),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/message"&&z!=null){if(E.current&&te.params){let G=te.params,X=Ae;if(Ae=null,he){clearTimeout(he.timer);let ae=he.text;he=null;let pe=(G.content??[]).map(se=>se.text??"").join("").trim();G={...G,content:[{type:"text",text:`${pe}
80
80
 
81
- ${ae}`}]}}E.current({...G,...X?{modelContext:X}:{}})}J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/update-model-context"&&z!=null){Ae=on(Ae,te.params),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="tools/call"&&z!=null){let G=v.current;if(!G){J({jsonrpc:"2.0",id:z,error:{code:-32601,message:"tools/call not supported"}});return}let X=te.params?.name;G({name:X,arguments:te.params?.arguments??{}}).then(ae=>{J({jsonrpc:"2.0",id:z,result:ae});let pe=ae.content?.map(se=>se.text??"").join("").trim();pe&&Rg(X,ae,T.current)&&(he&&clearTimeout(he.timer),he={text:pe,timer:setTimeout(()=>{if(ke)return;let se=Ae;Ae=null,he=null,E.current?.({role:"user",content:[{type:"text",text:pe}],...se?{modelContext:se}:{}})},500)})}).catch(ae=>{let pe=ae instanceof Error?ae.message:"Tool call failed";J({jsonrpc:"2.0",id:z,error:{code:-32e3,message:pe}})});return}if(fe==="ui/request-display-mode"&&z!=null){let G=te.params?.mode,X=G==="fullscreen"||G==="inline"||G==="pip"?G:"inline";k.current=X,J({jsonrpc:"2.0",id:z,result:{mode:X}}),J({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),D.current?.(X);return}if(fe==="ui/resource-teardown"&&z!=null){J({jsonrpc:"2.0",id:z,result:{}});return}fe==="ping"&&z!=null&&J({jsonrpc:"2.0",id:z,result:{}})};return window.addEventListener("message",Ue),()=>{ke=!0,clearTimeout(Q),he&&clearTimeout(he.timer),window.removeEventListener("message",Ue)}},[i,O]),Mg("iframe",{ref:g,src:U,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:A(!p&&"ww:rounded-md ww:border ww:border-border",s),style:{height:p?"100%":P,minWidth:p||!R?void 0:`min(${R}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}f();import{jsx as xa,jsxs as Fg}from"react/jsx-runtime";function $l({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Fg("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&xa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),xa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&xa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&xa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((n,s)=>xa("button",{type:"button",onClick:()=>r?.(n),className:A("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})]})}f();import{Component as Dg}from"react";import{jsx as Or,jsxs as Eg}from"react/jsx-runtime";function Bg({onRetry:e}){let{t}=V();return Eg("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[Or("span",{children:t.widgetErrorBoundary.failedToLoad}),Or("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var mo=class extends Dg{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?Or(Bg,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as _g,jsx as ee,jsxs as rt}from"react/jsx-runtime";function Nr(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Xl(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?$t:it}function Kl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:n,chatSessionId:s,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:g,messageClassNames:I}){let{t:C}=V(),S=e[e.length-1],x=e.length>0,L=d!=null,y=!L&&Gl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return rt(_g,{children:[!L&&(!x&&o?ee($l,{...o,onSuggestionSelect:r}):a&&ee(Pr,{from:"assistant",children:ee(Ar,{children:ee(po,{children:a})})})),e.map(k=>{let P=k.parts.filter(T=>T.type==="text"),F=k.parts.filter(T=>T.type==="reasoning"),R=k.parts.filter(T=>T.type==="file"),_=k.parts.filter(T=>"toolCallId"in T),M=k.parts.filter(T=>T.type==="reasoning"||"toolCallId"in T),E=k===S&&k.role==="assistant",v=P.length>0,D=L?_.some(T=>T.toolCallId===d):!1,H=m!==!1&&!D&&M.length>=2;return L&&!D?ee("div",{style:{display:"none"}},k.id):k.role==="assistant"&&!Wl(k)?ee("div",{style:{display:"none"}},k.id):m===!1&&k.role==="assistant"&&!v&&R.length===0&&_.every(T=>{let O="output"in T?T.output:void 0;return O===void 0||!n||!wa(T.toolName,O,g)})?ee("div",{style:{display:"none"}},k.id):rt(Pr,{from:k.role,className:I?.message,children:[m!==!1&&!D&&!H&&F.map((T,O)=>rt(ta,{isStreaming:T.state==="streaming",children:[ee(aa,{}),ee(oa,{children:T.text})]},`reasoning-${k.id}-${O}`)),H&&(()=>{let T=M[M.length-1],O=T.type==="reasoning"?{icon:Xe,label:C.reasoning.thinking}:{icon:Xl(T.toolName),label:T.title??Nr(T.toolName)};return rt(zs,{isWorking:E&&(t==="streaming"||t==="submitted"),activeStep:O,children:[ee(Vs,{workingLabel:C.chainOfThought.working,label:C.chainOfThought.done}),ee($s,{children:M.map((U,Be)=>{let be=Be===M.length-1;if(U.type==="reasoning")return ee(Ks,{isStreaming:U.state==="streaming",isLast:be,children:U.text},`reasoning-${k.id}-${Be}`);let W=U.title??Nr(U.toolName),ke=Xl(U.toolName);if(m==="titles-only")return ee(Xo,{icon:ke,title:W,state:U.state,isLast:be},U.toolCallId);let ue="output"in U?U.output:void 0;return rt(Xo,{icon:ke,title:W,state:U.state,isLast:be,children:[ee(Br,{input:U.input,debug:p}),ue!==void 0&&ee(Er,{output:ue,errorText:"errorText"in U?U.errorText:void 0,debug:p})]},U.toolCallId)})})]})})(),m!==!1&&!D&&!H&&_.length===1&&(()=>{let T=_[0],O=T.title??Nr(T.toolName);if(m==="titles-only")return ee(El,{title:O,state:T.state});let U="output"in T?T.output:void 0;return rt(Dl,{children:[ee(Bl,{title:O,state:T.state}),rt(_l,{children:[ee(Br,{input:T.input,debug:p}),U!==void 0&&ee(Er,{output:U,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]})})(),_.map(T=>{let O="output"in T?T.output:void 0,U=wa(T.toolName,O,g),Be=Ul(T.toolName,O,g),be=T.toolCallId===d;return U&&n&&O!==void 0?ee("div",{style:be?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:U&&n&&O!==void 0&&ee(mo,{children:ee(Vl,{isFullscreen:be,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},resourceEndpoint:n,chatSessionId:s,isDark:i,autoHeight:Be,toolDefinitions:g,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?W=>c(W,{toolCallId:T.toolCallId,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},autoHeight:Be}):void 0})})},T.toolCallId):null}),!D&&ee("div",{children:rt(Ar,{className:A(k.role==="user"?I?.userBubble:I?.assistantBubble),children:[R.length>0&&ee(Us,{files:R}),v?P.map((T,O)=>{let U=E&&t==="streaming"&&O===P.length-1;return ee(po,{isStreaming:U,children:T.type==="text"?T.text:""},`${k.id}-${O}`)}):null]})})]},k.id)}),y&&ee(jl,{})]})}f();import{jsx as Ql,jsxs as Ug}from"react/jsx-runtime";var Og="https://app.waniwani.ai/assets/waniwani-logo.svg",Ng="https://waniwani.ai";function Jl(){let{t:e}=V();return Ug("a",{href:Ng,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Ql("span",{children:e.poweredBy.label}),Ql("img",{src:Og,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as go}from"react/jsx-runtime";function Yl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:go("div",{className:A("ww:px-4 ww:py-2",o),...r,children:go("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(n=>go("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+n*20}px`}},n)):e.map((n,s)=>go("button",{type:"button",onClick:()=>a(n),className:A("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3.5 ww:py-1.5 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})})}f();import{useEffect as Hg,useRef as qg,useState as Wg}from"react";import{jsx as ne,jsxs as ht}from"react/jsx-runtime";var Zl=20;function Gg({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ne("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function jg({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ne("polyline",{points:"3 4 3 9 8 9"}),ne("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ne("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function zg({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("polyline",{points:"3 6 5 6 21 6"}),ne("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ne("path",{d:"M10 11v6"}),ne("path",{d:"M14 11v6"})]})}function eu({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:n,t:s}=V(),[i,l]=Wg(!1),u=qg(null);Hg(()=>{if(!i)return;let p=m=>{let g=u.current;g&&(m.composedPath().includes(g)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Zl),d=Math.max(0,e.length-Zl);return ht("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ne("button",{type:"button",onClick:a,title:s.threadMenu.newChat,"aria-label":s.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ne(Gg,{label:s.threadMenu.newChat})}),ne("button",{type:"button",onClick:()=>l(p=>!p),title:s.threadMenu.threadHistory,"aria-label":s.threadMenu.threadHistory,"aria-expanded":i,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ne(jg,{label:s.threadMenu.threadHistory})}),i&&ht("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&ne("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:s.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,g=Date.parse(p.updatedAt);return ht("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ht("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ne("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ne("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(g)?"":qo(g,n)})]}),ne("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:s.threadMenu.deleteThread,"aria-label":s.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:ne(zg,{label:s.threadMenu.deleteThread})})]},p.threadId)}),d>0&&ne("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:s.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as Vg,useRef as $g}from"react";function tu(e){let t=$g(e);return t.current=e,Vg(async a=>{let{api:o,headers:r,onCallTool:n,sessionId:s}=t.current;if(n)return n(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof s=="string"&&s.trim().length>0?s.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as fh}from"@ai-sdk/react";import{useCallback as Ce,useEffect as De,useRef as ce,useState as wt}from"react";f();import{createContext as Xg,useContext as Kg}from"react";f();function au(){return{subscribe(){return()=>{}},emit(){}}}var ou=Xg(au());function ru(){return Kg(ou)}var CP=ou.Provider;f();function At(e,t,a){let[o,r=""]=e.split("?"),n=o.replace(/\/$/,""),s=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}f();import{DefaultChatTransport as Qg,uiMessageChunkSchema as Jg}from"ai";function Yg(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let s=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(s.length>0)return s}return null}var ho=class extends Qg{processResponseStream(t){let a="",o=Jg(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(n,s){a+=n;let i=a.split(`
82
- `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){s.enqueue(d);continue}let p=await r(d);if(p.success){s.enqueue(p.value);continue}let m=Yg(p.error);if(m?.length){let g={...d};for(let C of m)delete g[C];let I=await r(g);I.success&&s.enqueue(I.value)}}catch{}}}}))}};f();f();var Zg="waniwani-memory";var Fe="threads",wo="by_memoryUserId",eh="by_updatedAt";var su="memoryUserId",nu="waniwani-memory-user-id",Ur=null;function Hr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function th(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Fe)){let a=e.createObjectStore(Fe,{keyPath:"threadId"});a.createIndex(wo,"memoryUserId",{unique:!1}),a.createIndex(eh,"updatedAt",{unique:!1})}}async function qr(){return new Promise((e,t)=>{let a=indexedDB.open(Zg,2);a.onupgradeneeded=o=>{th(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function ah(){return qr()}async function oh(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get(su);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function rh(e,t){return new Promise((a,o)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,su);s.onsuccess=()=>a(),s.onerror=()=>o(s.error)})}async function nh(){if(typeof indexedDB>"u")return null;try{let e=await ah();try{let t=await oh(e);if(t)return t;let a=Hr();return await rh(e,a),a}finally{e.close()}}catch{return null}}function sh(){try{let e=localStorage.getItem(nu);if(e)return e;let t=Hr();return localStorage.setItem(nu,t),t}catch{return null}}async function iu(){let e=await nh();if(e)return e;let t=sh();return t||(Ur||(Ur=Hr()),Ur)}var lu=50,uu=1e3;function xo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function Co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await qr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function Wr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Gr(e){return await Co(async a=>{let n=a.transaction(Fe,"readonly").objectStore(Fe).index(wo),i=(await Wr(n.getAll(e))??[]).filter(xo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Lo(e){return await Co(async a=>{let r=a.transaction(Fe,"readonly").objectStore(Fe),n=await Wr(r.get(e));return xo(n)?n:null})??null}async function jr(e){if(!xo(e))return;let t=e.messages.length>uu?{...e,messages:e.messages.slice(e.messages.length-uu)}:e;await Co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Fe,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Fe).put(t)});let o=a.transaction(Fe,"readwrite"),r=o.objectStore(Fe),n=r.index(wo),i=(await Wr(n.getAll(t.memoryUserId))??[]).filter(xo);if(i.length>lu){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-lu);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function du(e){await Co(async t=>(await new Promise((a,o)=>{let r=t.transaction(Fe,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Fe).delete(e)}),null))}async function zr(e){return(await Gr(e))[0]?.threadId??null}function cu(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var Vr="waniwani-visitor-id";function pu(e,t){return e.match(t)?.[1]??null}function ih(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=pu(e,o);if(r)return{name:a,version:r}}return null}function lh(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=pu(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function uh(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}function dh(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Io(){try{let t=localStorage.getItem(Vr);if(t)return t}catch{}let e=dh();try{localStorage.setItem(Vr,e)}catch{}return e}function fu(e){let t=typeof e=="string"?e.trim():"";if(!t)return Io();try{localStorage.setItem(Vr,t)}catch{}return t}function ch(e){return e!=null&&typeof e.then=="function"}function mu(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let o;try{o=typeof e=="function"?e():e}catch{return a}return ch(o)?o.then(r=>{t||fu(r??"")},()=>{}):fu(o??""),a}async function $r(){let e=navigator.userAgent,t=Io(),a=await iu();return{userAgent:e,browser:ih(e),os:lh(e),deviceType:uh(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var ph="x-session-id",mh=250,gh=200;function gu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Zt()}function So(){return new Date().toISOString()}function hu(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function hh(e,t){let a=At(e,"/tools"),o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[Waniwani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let n={};for(let s of r.tools)s&&typeof s.name=="string"&&(n[s.name]=s);return n}function wu(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:n,enableThreadHistory:s=!1,activeThreadId:i,onThreadChange:l}=e,u=e.visitorId;De(()=>mu(u),[u]);let c=ru(),d=ce(a),p=ce(o),m=ce(s);De(()=>{m.current=s},[s]);let g=ce(void 0),I=ce(null),[C,S]=wt(void 0),x=ce(C),[L,y]=wt(i),k=ce(L),[P,F]=wt([]),[R,_]=wt(!s),M=ce(void 0),E=ce(void 0),v=ce(void 0),D=ce(void 0),H=ce(0),T=ce(l);De(()=>{T.current=l},[l]);let O=Ce(b=>{k.current=b,y(b),b&&(T.current?.(b),c.emit({name:"thread.changed",sessionId:x.current,properties:{threadId:b}}))},[c]),U=Ce(async()=>{if(!s)return;let b=I.current?.memoryUserId;if(!b)return;let N=await Gr(b);F(N)},[s]),Be=Ce(()=>x.current,[]),be=Ce(b=>{let N=hu(b);if(!N||x.current===N)return;let q=x.current===void 0;x.current=N,S(N),q&&c.emit({name:"session.started",properties:{sessionId:N}})},[c]),W=Ce(()=>{x.current=void 0,S(void 0)},[]);De(()=>{d.current=a},[a]),De(()=>{p.current=o},[o]),De(()=>{let b=!1,N=H.current;return(async()=>{try{let oe=await $r();if(b)return;I.current=oe}catch{}if(!s)return;let q=I.current?.memoryUserId;if(!q){_(!0);return}try{let oe=i??await zr(q);if(b||N!==H.current)return;if(oe){let me=await Lo(oe);if(b||N!==H.current)return;me&&me.memoryUserId===q&&(k.current=me.threadId,y(me.threadId),M.current=me.createdAt,E.current=me.title,me.sessionId&&(x.current=me.sessionId,S(me.sessionId)),z(me.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[]);let ke=ce(new ho({api:t,headers:()=>({...d.current}),body:()=>{let b={...p.current??{}},N=Object.hasOwn(b,"sessionId"),q=hu(b.sessionId);if(q)be(q),b.sessionId=q;else if(N)W(),delete b.sessionId;else{let bo=Be();bo&&(b.sessionId=bo)}Ct(g.current)&&(b.modelContext=g.current);let oe=I.current,me=Io();oe&&(b.visitorContext={timezone:oe.timezone,language:oe.language,languages:oe.languages,deviceType:oe.deviceType,referrer:oe.referrer,visitorId:me});let ie=typeof b.visitor=="object"&&b.visitor!==null?b.visitor:{},qu=typeof ie.client=="object"&&ie.client!==null?ie.client:{};b.visitor={...ie,id:me,client:{...qu,...oe&&{memoryUserId:oe.memoryUserId}}};let en=typeof b.extra=="object"&&b.extra!==null&&!Array.isArray(b.extra)?b.extra:void 0,tn=I.current?.memoryUserId,an=I.current?.language,Sa={};if(tn&&(Sa.memoryUserId=tn),an&&(Sa.locale=an),(Object.keys(Sa).length>0||en)&&(b.extra={...Sa,...en??{}}),m.current)if(Object.hasOwn(b,"threadId"))typeof b.threadId=="string"&&(k.current=b.threadId);else{let ya=k.current;ya||(ya=gu(),M.current=So(),E.current=void 0,O(ya)),b.threadId=ya}return b},fetch:(async(b,N)=>{let q=await fetch(b,N);return g.current=void 0,be(q.headers.get(ph)),q})})),ue=ce(null),Ae=ce(null),he=ce({}),[Q,J]=wt(0),Ue=e.skipRemoteConfig===!0,Ie=Ce(async()=>{if(!Ue)try{let b=await hh(t,d.current);he.current=b,J(N=>N+1)}catch(b){console.warn("[Waniwani] Failed to fetch tool definitions:",b instanceof Error?b.message:b)}},[t,Ue]);De(()=>{Ie()},[Ie]);let{messages:te,sendMessage:fe,setMessages:z,status:G}=fh({messages:e.initialMessages,transport:ke.current,onFinish({message:b,isAbort:N,isDisconnect:q,isError:oe}){n?.(),!N&&!q&&!oe&&c.emit({name:"message.received"}),ue.current&&(Ae.current=b)},onError(b){console.warn("[Waniwani] Chat error:",b.message),c.emit({name:"chat.error",properties:{message:b.message.slice(0,gh)}}),ue.current&&(ue.current.reject(b),ue.current=null)}}),X=ce(te);De(()=>{X.current=te},[te]);let ae=ce(s);De(()=>{if(!s||ae.current||(ae.current=!0,X.current.length>0))return;let b=!1,N=H.current;return _(!1),(async()=>{try{let q=I.current;if(!q)try{q=await $r(),I.current=q}catch{}let oe=q?.memoryUserId;if(!oe||b||N!==H.current){b||_(!0);return}let me=i??await zr(oe);if(b||N!==H.current)return;if(me){let ie=await Lo(me);if(b||N!==H.current)return;ie&&ie.memoryUserId===oe&&(k.current=ie.threadId,y(ie.threadId),M.current=ie.createdAt,E.current=ie.title,ie.sessionId&&(x.current=ie.sessionId,S(ie.sessionId)),z(ie.messages))}await U()}finally{b||_(!0)}})(),()=>{b=!0}},[s]),De(()=>{if(G==="ready"&&ue.current&&Ae.current){let b=ue.current,N=Ae.current;ue.current=null,Ae.current=null,b.resolve(N)}},[G]);let[pe,se]=wt(""),[Te,ve]=wt([]),He=G==="submitted"||G==="streaming",xt=Ce(b=>{ve(N=>N.filter(q=>q.id!==b))},[]),Fu=He&&Te.length>0,Du=Ce(b=>{let N=!!b.text?.trim(),q=!!b.files?.length;if(N||q){if(He){if(Te.length>0)return;ve(oe=>[...oe,{id:Zt(),text:b.text||"",files:b.files??[],modelContext:b.modelContext}]),se("");return}g.current=b.modelContext,fe({text:b.text||"",files:b.files}),r?.(b.text||""),c.emit({name:"message.sent"}),se("")}},[fe,r,He,Te.length,c]),Bu=Ce(b=>new Promise((N,q)=>{ue.current={resolve:N,reject:q},fe({text:b}),r?.(b),c.emit({name:"message.sent"})}),[fe,r,c]);De(()=>{if(G!=="ready"||Te.length===0)return;let[b,...N]=Te;ve(N),g.current=b.modelContext,fe({text:b.text,files:b.files.length>0?b.files:void 0}),r?.(b.text),c.emit({name:"message.sent"})},[G,fe,r,Te,c]);let Eu=Ce(()=>{z([]),ve([]),W(),se(""),he.current={},J(b=>b+1),Ie()},[z,W,Ie]),La=Ce(()=>{if(!m.current)return;let b=I.current?.memoryUserId,N=k.current,q=X.current;if(!(!b||!N||q.length===0)){if(M.current||(M.current=So()),!E.current){let oe=q.find(ie=>ie.role==="user"),me=oe?oe.parts.map(ie=>"text"in ie&&typeof ie.text=="string"?ie.text:"").join(" "):"";E.current=cu(me)}return{threadId:N,memoryUserId:b,title:E.current,messages:q,sessionId:x.current,createdAt:M.current,updatedAt:So()}}},[]),Jr=Ce(async()=>{let b=La();b&&(await jr(b),await U())},[La,U]);De(()=>{if(s&&R&&!(G==="submitted"||G==="streaming")&&te.length!==0)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=void 0;let b=Jr().finally(()=>{D.current===b&&(D.current=void 0)});D.current=b},mh),()=>{v.current&&clearTimeout(v.current)}},[s,R,te,G,Jr]);let Ia=Ce(()=>{let b=D.current,N=v.current,q=N?La():void 0;return N&&(clearTimeout(N),v.current=void 0),(async()=>{b&&await b,q&&(await jr(q),await U())})()},[La,U]),_u=Ce(()=>{H.current+=1,Ia(),z([]),ve([]),W(),se("");let b=gu();return M.current=So(),E.current=void 0,O(b),U(),b},[z,W,O,U,Ia]),yo=Ce(async b=>{H.current+=1;let N=H.current;if(await Ia(),N!==H.current)return;let q=await Lo(b);N===H.current&&q&&(q.sessionId?(x.current=q.sessionId,S(q.sessionId)):W(),O(q.threadId),M.current=q.createdAt,E.current=q.title,z(q.messages),ve([]),se(""))},[z,W,O,Ia]),Ou=Ce(async b=>{if(k.current===b){H.current+=1,v.current&&(clearTimeout(v.current),v.current=void 0);let N=D.current;N&&await N}await du(b),await U(),k.current===b&&(z([]),ve([]),W(),se(""),k.current=void 0,y(void 0),M.current=void 0,E.current=void 0)},[z,W,U]);De(()=>{s&&R&&i!==void 0&&i!==k.current&&yo(i)},[i,s,R,yo]);let Nu=Ce(b=>{se(b.target.value)},[]),Yr=te[te.length-1],Zr=te.length>0,Uu=He&&(!Zr||Yr.role==="user"),Hu=he.current;return{messages:te,status:G,text:pe,setText:se,handleSubmit:Du,handleTextChange:Nu,isLoading:He,showLoaderBubble:Uu,lastMessage:Yr,hasMessages:Zr,sendMessage:fe,sendMessageAndWait:Bu,reset:Eu,queuedMessages:Te,queueFull:Fu,removeQueuedMessage:xt,sessionId:C,toolDefinitions:Hu,refreshToolDefinitions:Ie,threads:P,activeThreadId:L,isThreadHistoryReady:R,startNewThread:_u,switchThread:yo,deleteThread:Ou}}f();import{useEffect as xu,useRef as wh,useState as xh}from"react";var Ch={debug:!1,eval:!1};function Cu(e="/api/waniwani",t,a=!1){let[o,r]=xh(Ch),n=wh(t);return xu(()=>{n.current=t},[t]),xu(()=>{a||(async()=>{try{let s=n.current,l=await(await fetch(At(e,"/config"),{headers:s?{...s}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as yh,useEffect as Kr,useRef as bh,useState as Su}from"react";f();var Xr=["channel","page","flow","followup"];f();function Rt(e){return typeof e=="object"&&e!==null}function Lu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Lh(e){if(!Rt(e)||!("toolCallId"in e)||!("output"in e))return null;let t=e.output;if(!Rt(t)||!Rt(t._meta))return null;let a=t._meta[Po];return!Rt(a)||!Lu(a.suggestions)?null:a.suggestions}function Ih(e){let t=null;for(let a of e.parts){let o=Lh(a);o!==null&&(t=o.length>0?o:null)}return t}function Sh(e){for(let t of e.parts){if(!Rt(t)||t.type!=="data-suggestions")continue;let a=t.data;if(Rt(a)&&Lu(a.suggestions)&&a.suggestions.length>0)return a.suggestions}return null}function Iu(e,t={}){let{includeFlow:a=!0}=t,o=a?Ih(e):null;if(o)return{suggestions:o,source:"flow"};let r=Sh(e);return r?{suggestions:r,source:"followup"}:null}function yu(e){return typeof e=="object"&&e!==null}var kh=["channel","page","followup"];function Th(e){if(e===!1)return[];if(e===!0)return[...Xr];if(yu(e)){if(e.origins!==void 0)return e.origins;if(e.dynamic===!0)return[...Xr];if(e.dynamic===!1)return[]}return[...kh]}function bu(e){let{messages:t,status:a,config:o}=e,r=yu(o)&&o.initial?o.initial:void 0,[n,s]=Su(r??[]),[i,l]=Su("channel"),u=bh(a),c=Th(o),d=c.includes("flow"),p=c.includes("followup"),m=yh(()=>{s([])},[]),g=t.length>0;Kr(()=>{g||(s(r??[]),l("channel"))},[r,g]);let I=t[t.length-1];return Kr(()=>{I?.role==="user"&&m()},[I,m]),Kr(()=>{let C=u.current;if(u.current=a,C==="streaming"&&a==="ready"&&(d||p)){let S=[...t].reverse().find(y=>y.role==="assistant");if(!S)return;let x=Iu(S,{includeFlow:d}),L=x&&(x.source==="flow"&&d||x.source==="followup"&&p);s(L?x.suggestions:[]),l(L?x.source:"channel")}},[a,d,p,t]),{suggestions:n,source:i,isLoading:!1,clear:m}}f();import{useEffect as vh,useRef as Ph,useState as Ah}from"react";var Rh=80,Mh=50,Fh=15e3,ku=500;function Tu(e,t=!0){let[a,o]=Ah(""),r=Ph(void 0);return vh(()=>{if(!t){o("");return}let n=0,s=!1,i=!1,l=()=>{i||(s?(n--,o(e.slice(0,n)),n<=0?(s=!1,r.current=setTimeout(l,ku)):r.current=setTimeout(l,Mh)):(n++,o(e.slice(0,n)),n>=e.length?(s=!0,r.current=setTimeout(l,Fh)):r.current=setTimeout(l,Rh)))};return r.current=setTimeout(l,ku),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function vu(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return At(e,"/resource",o?{token:o}:void 0)}f();var Dh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:8,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5",userBubbleTextColor:"#1f2937",assistantBubbleTextColor:"#1f2937",messagePaddingX:16,messagePaddingY:12,messageMaxWidth:"80%",fontSize:16,lineHeight:"1.5"};var Bh={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"],userBubbleTextColor:["--ww-user-bubble-text"],assistantBubbleTextColor:["--ww-assistant-bubble-text"],messagePaddingX:["--ww-msg-pad-x"],messagePaddingY:["--ww-msg-pad-y"],messageMaxWidth:["--ww-msg-max-width"],fontSize:["--ww-font-size"],lineHeight:["--ww-line-height"]};function Pu(e){return{...Dh,...e}}function Au(e){let t={};for(let[a,o]of Object.entries(Bh)){let r=e[a];if(r===void 0)continue;let n=typeof r=="number"?`${r}px`:String(r);for(let s of o)t[s]=n}return t}import{jsx as Le,jsxs as Ca}from"react/jsx-runtime";var Nh=Eh(function(t,a){let{theme:o,title:r="Assistant",width:n,height:s,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:g,enableThreadHistory:I=!1,showToolCalls:C=!0}=t,S=m??"/api/waniwani",x=vu(S,t.headers),L=Pu(o),y=Au(o??{}),k=L.backgroundColor.replace("#",""),P=parseInt(k.substring(0,2),16),F=parseInt(k.substring(2,4),16),R=parseInt(k.substring(4,6),16),_=(P*299+F*587+R*114)/1e3<128,M=Cu(S,t.headers,t.skipRemoteConfig),E=g??M.debug,v=wu({...t,api:S}),D=tu({...t,api:S,sessionId:v.sessionId}),H=Tu(d,!v.text),[T,O]=Mu(!1),[U,Be]=Mu(null),be=Ru(null),W=Ru(void 0),ke=Qr(()=>{let Q=be.current;if(!Q)return;Q.scrollIntoView({behavior:"smooth",block:"center"});let J=Q.querySelector("textarea");J&&setTimeout(()=>J.focus(),300),O(!0),clearTimeout(W.current),W.current=setTimeout(()=>O(!1),2e3)},[]),ue=bu({messages:v.messages,status:v.status,config:t.suggestions}),Ae=Qr(Q=>{let J=Q.content.map(Ue=>Ue.text??"").join("").trim();J&&v.handleSubmit({text:J,files:[],modelContext:Q.modelContext})},[v.handleSubmit]),he=Qr(Q=>{ue.clear(),v.handleSubmit({text:Q,files:[]})},[ue.clear,v.handleSubmit]);return Oh(a,()=>({sendMessage:Q=>{v.handleSubmit({text:Q,files:[]}),ke()},sendMessageAndWait:Q=>v.sendMessageAndWait(Q),reset:v.reset,focus:ke,get messages(){return v.messages},get sessionId(){return v.sessionId}}),[v.handleSubmit,v.sendMessageAndWait,v.reset,v.messages,v.sessionId,ke]),_h(()=>{if(!p)return;let Q=J=>{let Ue=J.detail,Ie=typeof Ue?.message=="string"?Ue.message:void 0;Ie&&v.handleSubmit({text:Ie,files:[]}),ke()};return window.addEventListener(p,Q),()=>window.removeEventListener(p,Q)},[p,v.handleSubmit,ke]),Ca("div",{ref:be,style:{...y,width:n,height:s},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:A("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",T&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[Ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:L.headerBackgroundColor,color:L.headerTextColor},children:[Le("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),Le(Ns,{messages:v.messages,evalEnabled:M.eval,api:S}),I&&Le(eu,{threads:v.threads,activeThreadId:v.activeThreadId,onNewThread:v.startNewThread,onSelectThread:Q=>{v.switchThread(Q)},onDeleteThread:Q=>{v.deleteThread(Q)}})]}),Ca(gs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[Le(hs,{scrollClassName:U?"ww:!relative ww:!overflow-hidden":void 0,children:Le(Kl,{messages:v.messages,status:v.status,welcomeMessage:u,welcome:c,onSuggestionSelect:he,resourceEndpoint:x,chatSessionId:v.sessionId,isDark:_,onFollowUp:Ae,onCallTool:D,fullscreenToolCallId:U,debug:E,showToolCalls:C,toolDefinitions:v.toolDefinitions,onWidgetDisplayModeChange:(Q,J)=>{Be(Q==="fullscreen"?J.toolCallId:null)}})}),Le(ws,{})]}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Yl,{suggestions:ue.suggestions,isLoading:ue.isLoading,onSelect:he})}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Es,{queuedMessages:v.queuedMessages,onRemove:v.removeQueuedMessage})}),Le("div",{style:U?{display:"none"}:void 0,children:Le("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:Ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[Le(ys,{onSubmit:v.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&Le(Ts,{}),Le(bs,{onChange:v.handleTextChange,value:v.text,placeholder:H,className:"ww:min-h-0 ww:py-1 ww:px-0"}),Le(ks,{status:v.status,disabled:v.queueFull})]})}),Le(Jl,{})]})})})]})});export{Nh as ChatCard,bn as DevModeProvider,Ku as InitializeNextJsInIframe,Rd as LoadingWidget,Fn as WidgetProvider,Cn as createResource,zu as createTool,ko as detectPlatform,Pa as getMockState,Et as initializeMockOpenAI,Gu as isMCPApps,Wu as isOpenAI,Vu as registerTools,uL as toNextJsHandler,Pn as unstable_useSendFollowUpWithGhostGuard,Ot as updateMockDisplayMode,nt as updateMockGlobal,Nt as updateMockTheme,_t as updateMockToolOutput,Dn as useCallTool,Bn as useDisplayMode,En as useFlowAction,_n as useIsChatGptApp,On as useLocale,Nn as useMaxHeight,Un as useOpenExternal,Hn as useRequestDisplayMode,qn as useSafeArea,Wn as useSendFollowUp,Gn as useTheme,Ra as useToolOutput,jn as useToolResponseMetadata,zn as useUpdateModelContext,$ as useWidgetClient,Vn as useWidgetState};
81
+ ${ae}`}]}}E.current({...G,...X?{modelContext:X}:{}})}J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="ui/update-model-context"&&z!=null){Ae=nn(Ae,te.params),J({jsonrpc:"2.0",id:z,result:{}});return}if(fe==="tools/call"&&z!=null){let G=v.current;if(!G){J({jsonrpc:"2.0",id:z,error:{code:-32601,message:"tools/call not supported"}});return}let X=te.params?.name;G({name:X,arguments:te.params?.arguments??{}}).then(ae=>{J({jsonrpc:"2.0",id:z,result:ae});let pe=ae.content?.map(se=>se.text??"").join("").trim();pe&&Fg(X,ae,T.current)&&(he&&clearTimeout(he.timer),he={text:pe,timer:setTimeout(()=>{if(ke)return;let se=Ae;Ae=null,he=null,E.current?.({role:"user",content:[{type:"text",text:pe}],...se?{modelContext:se}:{}})},500)})}).catch(ae=>{let pe=ae instanceof Error?ae.message:"Tool call failed";J({jsonrpc:"2.0",id:z,error:{code:-32e3,message:pe}})});return}if(fe==="ui/request-display-mode"&&z!=null){let G=te.params?.mode,X=G==="fullscreen"||G==="inline"||G==="pip"?G:"inline";b.current=X,J({jsonrpc:"2.0",id:z,result:{mode:X}}),J({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:X}}),D.current?.(X);return}if(fe==="ui/resource-teardown"&&z!=null){J({jsonrpc:"2.0",id:z,result:{}});return}fe==="ping"&&z!=null&&J({jsonrpc:"2.0",id:z,result:{}})};return window.addEventListener("message",Ue),()=>{ke=!0,clearTimeout(Q),he&&clearTimeout(he.timer),window.removeEventListener("message",Ue)}},[i,O]),Dg("iframe",{ref:g,src:U,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:R(!p&&"ww:rounded-md ww:border ww:border-border",s),style:{height:p?"100%":P,minWidth:p||!A?void 0:`min(${A}px, 100%)`,width:"100%",border:"none",colorScheme:n?"dark":"auto"},title:"MCP App"})}f();import{jsx as xa,jsxs as Bg}from"react/jsx-runtime";function Kl({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Bg("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&xa("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),xa("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&xa("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&xa("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((n,s)=>xa("button",{type:"button",onClick:()=>r?.(n),className:R("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})]})}f();import{Component as Eg}from"react";import{jsx as Nr,jsxs as Og}from"react/jsx-runtime";function _g({onRetry:e}){let{t}=V();return Og("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:[Nr("span",{children:t.widgetErrorBoundary.failedToLoad}),Nr("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var mo=class extends Eg{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[Waniwani] Widget failed to render:",t.message)}render(){return this.state.hasError?Nr(_g,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Ng,jsx as ee,jsxs as rt}from"react/jsx-runtime";function Ur(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Ql(e){return e&&/search|find|lookup|query|web|browse|google/i.test(e)?$t:it}function Jl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:n,chatSessionId:s,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:d,fullscreenToolCallId:c,debug:p,showToolCalls:m=!0,toolDefinitions:g,messageClassNames:I}){let{t:x}=V(),S=e[e.length-1],C=e.length>0,L=c!=null,y=!L&&zl(e,t,{ignoreToolParts:m===!1,ignoreReasoningParts:m===!1});return rt(Ng,{children:[!L&&(!C&&o?ee(Kl,{...o,onSuggestionSelect:r}):a&&ee(Ar,{from:"assistant",children:ee(Rr,{children:ee(po,{children:a})})})),e.map(b=>{let P=b.parts.filter(T=>T.type==="text"),M=b.parts.filter(T=>T.type==="reasoning"),A=b.parts.filter(T=>T.type==="file"),_=b.parts.filter(T=>"toolCallId"in T),F=b.parts.filter(T=>T.type==="reasoning"||"toolCallId"in T),E=b===S&&b.role==="assistant",v=P.length>0,D=L?_.some(T=>T.toolCallId===c):!1,H=m!==!1&&!D&&F.length>=2;return L&&!D?ee("div",{style:{display:"none"}},b.id):b.role==="assistant"&&!jl(b)?ee("div",{style:{display:"none"}},b.id):m===!1&&b.role==="assistant"&&!v&&A.length===0&&_.every(T=>{let O="output"in T?T.output:void 0;return O===void 0||!n||!wa(T.toolName,O,g)})?ee("div",{style:{display:"none"}},b.id):rt(Ar,{from:b.role,className:I?.message,children:[m!==!1&&!D&&!H&&M.map((T,O)=>rt(ta,{isStreaming:T.state==="streaming",children:[ee(aa,{}),ee(oa,{children:T.text})]},`reasoning-${b.id}-${O}`)),H&&(()=>{let T=F[F.length-1],O=T.type==="reasoning"?{icon:Xe,label:x.reasoning.thinking}:{icon:Ql(T.toolName),label:T.title??Ur(T.toolName)};return rt($s,{isWorking:E&&(t==="streaming"||t==="submitted"),activeStep:O,children:[ee(Xs,{workingLabel:x.chainOfThought.working,label:x.chainOfThought.done}),ee(Ks,{children:F.map((U,Be)=>{let be=Be===F.length-1;if(U.type==="reasoning")return ee(Js,{isStreaming:U.state==="streaming",isLast:be,children:U.text},`reasoning-${b.id}-${Be}`);let W=U.title??Ur(U.toolName),ke=Ql(U.toolName);if(m==="titles-only")return ee(Ko,{icon:ke,title:W,state:U.state,isLast:be},U.toolCallId);let ue="output"in U?U.output:void 0;return rt(Ko,{icon:ke,title:W,state:U.state,isLast:be,children:[ee(Er,{input:U.input,debug:p}),ue!==void 0&&ee(_r,{output:ue,errorText:"errorText"in U?U.errorText:void 0,debug:p})]},U.toolCallId)})})]})})(),m!==!1&&!D&&!H&&_.length===1&&(()=>{let T=_[0],O=T.title??Ur(T.toolName);if(m==="titles-only")return ee(Ol,{title:O,state:T.state});let U="output"in T?T.output:void 0;return rt(El,{children:[ee(_l,{title:O,state:T.state}),rt(Nl,{children:[ee(Er,{input:T.input,debug:p}),U!==void 0&&ee(_r,{output:U,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]})})(),_.map(T=>{let O="output"in T?T.output:void 0,U=wa(T.toolName,O,g),Be=ql(T.toolName,O,g),be=T.toolCallId===c;return U&&n&&O!==void 0?ee("div",{style:be?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:U&&n&&O!==void 0&&ee(mo,{children:ee(Xl,{isFullscreen:be,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},resourceEndpoint:n,chatSessionId:s,isDark:i,autoHeight:Be,toolDefinitions:g,onFollowUp:l,onCallTool:u,onDisplayModeChange:d?W=>d(W,{toolCallId:T.toolCallId,resourceUri:U,toolInput:T.input??{},toolResult:{content:O.content,structuredContent:O.structuredContent,_meta:O._meta},autoHeight:Be}):void 0})})},T.toolCallId):null}),!D&&ee("div",{children:rt(Rr,{className:R(b.role==="user"?I?.userBubble:I?.assistantBubble),children:[A.length>0&&ee(qs,{files:A}),v?P.map((T,O)=>{let U=E&&t==="streaming"&&O===P.length-1;return ee(po,{isStreaming:U,children:T.type==="text"?T.text:""},`${b.id}-${O}`)}):null]})})]},b.id)}),y&&ee(Vl,{})]})}f();import{jsx as Yl,jsxs as qg}from"react/jsx-runtime";var Ug="https://app.waniwani.ai/assets/waniwani-logo.svg",Hg="https://waniwani.ai";function Zl(){let{t:e}=V();return qg("a",{href:Hg,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:whitespace-nowrap ww:text-[10px] ww:sm:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Yl("span",{children:e.poweredBy.label}),Yl("img",{src:Ug,alt:"Waniwani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as go}from"react/jsx-runtime";function eu({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:go("div",{className:R("ww:px-4 ww:py-2",o),...r,children:go("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(n=>go("div",{className:"ww:h-8 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+n*20}px`}},n)):e.map((n,s)=>go("button",{type:"button",onClick:()=>a(n),className:R("ww:rounded-full ww:border ww:border-border ww:bg-accent ww:px-3.5 ww:py-1.5 ww:text-sm","ww:text-foreground ww:hover:bg-border ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${s*50}ms`},children:n},n))})})}f();import{useEffect as Wg,useRef as Gg,useState as jg}from"react";import{jsx as ne,jsxs as ht}from"react/jsx-runtime";var tu=20;function zg({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ne("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Vg({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ne("polyline",{points:"3 4 3 9 8 9"}),ne("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ne("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function $g({label:e}){return ht("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ne("title",{children:e}),ne("polyline",{points:"3 6 5 6 21 6"}),ne("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ne("path",{d:"M10 11v6"}),ne("path",{d:"M14 11v6"})]})}function au({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:n,t:s}=V(),[i,l]=jg(!1),u=Gg(null);Wg(()=>{if(!i)return;let p=m=>{let g=u.current;g&&(m.composedPath().includes(g)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let d=e.slice(0,tu),c=Math.max(0,e.length-tu);return ht("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ne("button",{type:"button",onClick:a,title:s.threadMenu.newChat,"aria-label":s.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ne(zg,{label:s.threadMenu.newChat})}),ne("button",{type:"button",onClick:()=>l(p=>!p),title:s.threadMenu.threadHistory,"aria-label":s.threadMenu.threadHistory,"aria-expanded":i,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ne(Vg,{label:s.threadMenu.threadHistory})}),i&&ht("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[d.length===0&&ne("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:s.threadMenu.noPreviousChats}),d.map(p=>{let m=p.threadId===t,g=Date.parse(p.updatedAt);return ht("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${m?"ww:bg-foreground/5":""}`,children:[ht("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ne("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ne("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(g)?"":Wo(g,n)})]}),ne("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:s.threadMenu.deleteThread,"aria-label":s.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:ne($g,{label:s.threadMenu.deleteThread})})]},p.threadId)}),c>0&&ne("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:s.threadMenu.hiddenThreads(c)})]})]})}f();import{useCallback as Xg,useRef as Kg}from"react";function ou(e){let t=Kg(e);return t.current=e,Xg(async a=>{let{api:o,headers:r,onCallTool:n,sessionId:s}=t.current;if(n)return n(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof s=="string"&&s.trim().length>0?s.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as mh}from"@ai-sdk/react";import{useCallback as Ce,useEffect as De,useRef as ce,useState as wt}from"react";f();import{createContext as Qg,useContext as Jg}from"react";f();function ru(){return{subscribe(){return()=>{}},emit(){}}}var nu=Qg(ru());function su(){return Jg(nu)}var CP=nu.Provider;f();function At(e,t,a){let[o,r=""]=e.split("?"),n=o.replace(/\/$/,""),s=new URLSearchParams(r);if(a)for(let[l,u]of Object.entries(a))s.set(l,u);let i=s.toString();return`${n}${t}${i?`?${i}`:""}`}f();import{DefaultChatTransport as Yg,uiMessageChunkSchema as Zg}from"ai";function eh(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let s=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(s.length>0)return s}return null}var ho=class extends Yg{processResponseStream(t){let a="",o=Zg(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(n,s){a+=n;let i=a.split(`
82
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let d=u.slice(5).trim();if(d!=="[DONE]")try{let c=JSON.parse(d);if(!r){s.enqueue(c);continue}let p=await r(c);if(p.success){s.enqueue(p.value);continue}let m=eh(p.error);if(m?.length){let g={...c};for(let x of m)delete g[x];let I=await r(g);I.success&&s.enqueue(I.value)}}catch{}}}}))}};f();f();var th="waniwani-memory";var Fe="threads",wo="by_memoryUserId",ah="by_updatedAt";var lu="memoryUserId",iu="waniwani-memory-user-id",Hr=null;function qr(){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 oh(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Fe)){let a=e.createObjectStore(Fe,{keyPath:"threadId"});a.createIndex(wo,"memoryUserId",{unique:!1}),a.createIndex(ah,"updatedAt",{unique:!1})}}async function Wr(){return new Promise((e,t)=>{let a=indexedDB.open(th,2);a.onupgradeneeded=o=>{oh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function rh(){return Wr()}async function nh(e){return new Promise((t,a)=>{let n=e.transaction("ids","readonly").objectStore("ids").get(lu);n.onsuccess=()=>t(typeof n.result=="string"?n.result:null),n.onerror=()=>a(n.error)})}async function sh(e,t){return new Promise((a,o)=>{let s=e.transaction("ids","readwrite").objectStore("ids").put(t,lu);s.onsuccess=()=>a(),s.onerror=()=>o(s.error)})}async function ih(){if(typeof indexedDB>"u")return null;try{let e=await rh();try{let t=await nh(e);if(t)return t;let a=qr();return await sh(e,a),a}finally{e.close()}}catch{return null}}function lh(){try{let e=localStorage.getItem(iu);if(e)return e;let t=qr();return localStorage.setItem(iu,t),t}catch{return null}}async function uu(){let e=await ih();if(e)return e;let t=lh();return t||(Hr||(Hr=qr()),Hr)}var du=50,cu=1e3;function xo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function Co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Wr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function Gr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function jr(e){return await Co(async a=>{let n=a.transaction(Fe,"readonly").objectStore(Fe).index(wo),i=(await Gr(n.getAll(e))??[]).filter(xo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Lo(e){return await Co(async a=>{let r=a.transaction(Fe,"readonly").objectStore(Fe),n=await Gr(r.get(e));return xo(n)?n:null})??null}async function zr(e){if(!xo(e))return;let t=e.messages.length>cu?{...e,messages:e.messages.slice(e.messages.length-cu)}:e;await Co(async a=>{await new Promise((l,u)=>{let d=a.transaction(Fe,"readwrite");d.oncomplete=()=>l(),d.onerror=()=>u(d.error),d.onabort=()=>u(d.error),d.objectStore(Fe).put(t)});let o=a.transaction(Fe,"readwrite"),r=o.objectStore(Fe),n=r.index(wo),i=(await Gr(n.getAll(t.memoryUserId))??[]).filter(xo);if(i.length>du){i.sort((u,d)=>u.updatedAt<d.updatedAt?-1:1);let l=i.slice(0,i.length-du);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 fu(e){await Co(async t=>(await new Promise((a,o)=>{let r=t.transaction(Fe,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Fe).delete(e)}),null))}async function Vr(e){return(await jr(e))[0]?.threadId??null}function pu(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 $r="waniwani-visitor-id";function gu(e,t){return e.match(t)?.[1]??null}function uh(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=gu(e,o);if(r)return{name:a,version:r}}return null}function dh(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=gu(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function ch(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}function fh(){try{if(typeof crypto<"u"){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();if(typeof crypto.getRandomValues=="function"){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,a=>a.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}}catch{}return`v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function Io(){try{let t=localStorage.getItem($r);if(t)return t}catch{}let e=fh();try{localStorage.setItem($r,e)}catch{}return e}function mu(e){let t=typeof e=="string"?e.trim():"";if(!t)return Io();try{localStorage.setItem($r,t)}catch{}return t}function ph(e){return e!=null&&typeof e.then=="function"}function hu(e){let t=!1,a=()=>{t=!0};if(e==null)return a;let o;try{o=typeof e=="function"?e():e}catch{return a}return ph(o)?o.then(r=>{t||mu(r??"")},()=>{}):mu(o??""),a}async function Xr(){let e=navigator.userAgent,t=Io(),a=await uu();return{userAgent:e,browser:uh(e),os:dh(e),deviceType:ch(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 gh="x-session-id",hh=250,wh=200;function wu(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Zt()}function So(){return new Date().toISOString()}function xu(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function xh(e,t){let a=At(e,"/tools"),o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[Waniwani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let n={};for(let s of r.tools)s&&typeof s.name=="string"&&(n[s.name]=s);return n}function Cu(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:n,enableThreadHistory:s=!1,activeThreadId:i,onThreadChange:l}=e,u=e.visitorId;De(()=>hu(u),[u]);let d=su(),c=ce(a),p=ce(o),m=ce(s);De(()=>{m.current=s},[s]);let g=ce(void 0),I=ce(null),[x,S]=wt(void 0),C=ce(x),[L,y]=wt(i),b=ce(L),[P,M]=wt([]),[A,_]=wt(!s),F=ce(void 0),E=ce(void 0),v=ce(void 0),D=ce(void 0),H=ce(0),T=ce(l);De(()=>{T.current=l},[l]);let O=Ce(k=>{b.current=k,y(k),k&&(T.current?.(k),d.emit({name:"thread.changed",sessionId:C.current,properties:{threadId:k}}))},[d]),U=Ce(async()=>{if(!s)return;let k=I.current?.memoryUserId;if(!k)return;let N=await jr(k);M(N)},[s]),Be=Ce(()=>C.current,[]),be=Ce(k=>{let N=xu(k);if(!N||C.current===N)return;let q=C.current===void 0;C.current=N,S(N),q&&d.emit({name:"session.started",properties:{sessionId:N}})},[d]),W=Ce(()=>{C.current=void 0,S(void 0)},[]);De(()=>{c.current=a},[a]),De(()=>{p.current=o},[o]),De(()=>{let k=!1,N=H.current;return(async()=>{try{let oe=await Xr();if(k)return;I.current=oe}catch{}if(!s)return;let q=I.current?.memoryUserId;if(!q){_(!0);return}try{let oe=i??await Vr(q);if(k||N!==H.current)return;if(oe){let me=await Lo(oe);if(k||N!==H.current)return;me&&me.memoryUserId===q&&(b.current=me.threadId,y(me.threadId),F.current=me.createdAt,E.current=me.title,me.sessionId&&(C.current=me.sessionId,S(me.sessionId)),z(me.messages))}await U()}finally{k||_(!0)}})(),()=>{k=!0}},[]);let ke=ce(new ho({api:t,headers:()=>({...c.current}),body:()=>{let k={...p.current??{}},N=Object.hasOwn(k,"sessionId"),q=xu(k.sessionId);if(q)be(q),k.sessionId=q;else if(N)W(),delete k.sessionId;else{let ko=Be();ko&&(k.sessionId=ko)}Ct(g.current)&&(k.modelContext=g.current);let oe=I.current,me=Io();oe&&(k.visitorContext={timezone:oe.timezone,language:oe.language,languages:oe.languages,deviceType:oe.deviceType,referrer:oe.referrer,visitorId:me});let ie=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},Gu=typeof ie.client=="object"&&ie.client!==null?ie.client:{};k.visitor={...ie,id:me,client:{...Gu,...oe&&{memoryUserId:oe.memoryUserId}}};let an=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,on=I.current?.memoryUserId,rn=I.current?.language,Sa={};if(on&&(Sa.memoryUserId=on),rn&&(Sa.locale=rn),(Object.keys(Sa).length>0||an)&&(k.extra={...Sa,...an??{}}),m.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(b.current=k.threadId);else{let ya=b.current;ya||(ya=wu(),F.current=So(),E.current=void 0,O(ya)),k.threadId=ya}return k},fetch:(async(k,N)=>{let q=await fetch(k,N);return g.current=void 0,be(q.headers.get(gh)),q})})),ue=ce(null),Ae=ce(null),he=ce({}),[Q,J]=wt(0),Ue=e.skipRemoteConfig===!0,Ie=Ce(async()=>{if(!Ue)try{let k=await xh(t,c.current);he.current=k,J(N=>N+1)}catch(k){console.warn("[Waniwani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,Ue]);De(()=>{Ie()},[Ie]);let{messages:te,sendMessage:fe,setMessages:z,status:G}=mh({messages:e.initialMessages,transport:ke.current,onFinish({message:k,isAbort:N,isDisconnect:q,isError:oe}){n?.(),!N&&!q&&!oe&&d.emit({name:"message.received"}),ue.current&&(Ae.current=k)},onError(k){console.warn("[Waniwani] Chat error:",k.message),d.emit({name:"chat.error",properties:{message:k.message.slice(0,wh)}}),ue.current&&(ue.current.reject(k),ue.current=null)}}),X=ce(te);De(()=>{X.current=te},[te]);let ae=ce(s);De(()=>{if(!s||ae.current||(ae.current=!0,X.current.length>0))return;let k=!1,N=H.current;return _(!1),(async()=>{try{let q=I.current;if(!q)try{q=await Xr(),I.current=q}catch{}let oe=q?.memoryUserId;if(!oe||k||N!==H.current){k||_(!0);return}let me=i??await Vr(oe);if(k||N!==H.current)return;if(me){let ie=await Lo(me);if(k||N!==H.current)return;ie&&ie.memoryUserId===oe&&(b.current=ie.threadId,y(ie.threadId),F.current=ie.createdAt,E.current=ie.title,ie.sessionId&&(C.current=ie.sessionId,S(ie.sessionId)),z(ie.messages))}await U()}finally{k||_(!0)}})(),()=>{k=!0}},[s]),De(()=>{if(G==="ready"&&ue.current&&Ae.current){let k=ue.current,N=Ae.current;ue.current=null,Ae.current=null,k.resolve(N)}},[G]);let[pe,se]=wt(""),[Te,ve]=wt([]),He=G==="submitted"||G==="streaming",xt=Ce(k=>{ve(N=>N.filter(q=>q.id!==k))},[]),Bu=He&&Te.length>0,Eu=Ce(k=>{let N=!!k.text?.trim(),q=!!k.files?.length;if(N||q){if(He){if(Te.length>0)return;ve(oe=>[...oe,{id:Zt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),se("");return}g.current=k.modelContext,fe({text:k.text||"",files:k.files}),r?.(k.text||""),d.emit({name:"message.sent"}),se("")}},[fe,r,He,Te.length,d]),_u=Ce(k=>new Promise((N,q)=>{ue.current={resolve:N,reject:q},fe({text:k}),r?.(k),d.emit({name:"message.sent"})}),[fe,r,d]);De(()=>{if(G!=="ready"||Te.length===0)return;let[k,...N]=Te;ve(N),g.current=k.modelContext,fe({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text),d.emit({name:"message.sent"})},[G,fe,r,Te,d]);let Ou=Ce(()=>{z([]),ve([]),W(),se(""),he.current={},J(k=>k+1),Ie()},[z,W,Ie]),La=Ce(()=>{if(!m.current)return;let k=I.current?.memoryUserId,N=b.current,q=X.current;if(!(!k||!N||q.length===0)){if(F.current||(F.current=So()),!E.current){let oe=q.find(ie=>ie.role==="user"),me=oe?oe.parts.map(ie=>"text"in ie&&typeof ie.text=="string"?ie.text:"").join(" "):"";E.current=pu(me)}return{threadId:N,memoryUserId:k,title:E.current,messages:q,sessionId:C.current,createdAt:F.current,updatedAt:So()}}},[]),Zr=Ce(async()=>{let k=La();k&&(await zr(k),await U())},[La,U]);De(()=>{if(s&&A&&!(G==="submitted"||G==="streaming")&&te.length!==0)return v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=void 0;let k=Zr().finally(()=>{D.current===k&&(D.current=void 0)});D.current=k},hh),()=>{v.current&&clearTimeout(v.current)}},[s,A,te,G,Zr]);let Ia=Ce(()=>{let k=D.current,N=v.current,q=N?La():void 0;return N&&(clearTimeout(N),v.current=void 0),(async()=>{k&&await k,q&&(await zr(q),await U())})()},[La,U]),Nu=Ce(()=>{H.current+=1,Ia(),z([]),ve([]),W(),se("");let k=wu();return F.current=So(),E.current=void 0,O(k),U(),k},[z,W,O,U,Ia]),bo=Ce(async k=>{H.current+=1;let N=H.current;if(await Ia(),N!==H.current)return;let q=await Lo(k);N===H.current&&q&&(q.sessionId?(C.current=q.sessionId,S(q.sessionId)):W(),O(q.threadId),F.current=q.createdAt,E.current=q.title,z(q.messages),ve([]),se(""))},[z,W,O,Ia]),Uu=Ce(async k=>{if(b.current===k){H.current+=1,v.current&&(clearTimeout(v.current),v.current=void 0);let N=D.current;N&&await N}await fu(k),await U(),b.current===k&&(z([]),ve([]),W(),se(""),b.current=void 0,y(void 0),F.current=void 0,E.current=void 0)},[z,W,U]);De(()=>{s&&A&&i!==void 0&&i!==b.current&&bo(i)},[i,s,A,bo]);let Hu=Ce(k=>{se(k.target.value)},[]),en=te[te.length-1],tn=te.length>0,qu=He&&(!tn||en.role==="user"),Wu=he.current;return{messages:te,status:G,text:pe,setText:se,handleSubmit:Eu,handleTextChange:Hu,isLoading:He,showLoaderBubble:qu,lastMessage:en,hasMessages:tn,sendMessage:fe,sendMessageAndWait:_u,reset:Ou,queuedMessages:Te,queueFull:Bu,removeQueuedMessage:xt,sessionId:x,toolDefinitions:Wu,refreshToolDefinitions:Ie,threads:P,activeThreadId:L,isThreadHistoryReady:A,startNewThread:Nu,switchThread:bo,deleteThread:Uu}}f();import{useEffect as Lu,useRef as Ch,useState as Lh}from"react";var Ih={debug:!1,eval:!1};function Iu(e="/api/waniwani",t,a=!1){let[o,r]=Lh(Ih),n=Ch(t);return Lu(()=>{n.current=t},[t]),Lu(()=>{a||(async()=>{try{let s=n.current,l=await(await fetch(At(e,"/config"),{headers:s?{...s}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as yh,useEffect as Qr,useMemo as Jr,useRef as bh,useState as ku}from"react";f();function yo(e){return e.map(t=>({id:null,text:t}))}function Kr(e){let{flow:t,followup:a,page:o,channel:r}=e;return t!==null?{origin:"flow",suggestions:t}:a?.length?{origin:"followup",suggestions:a}:o?.length?{origin:"page",suggestions:o}:r?.length?{origin:"channel",suggestions:r}:null}f();function Rt(e){return typeof e=="object"&&e!==null}function Su(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Sh(e){if(!Rt(e)||!("toolCallId"in e)||!("output"in e))return null;let t=e.output;if(!Rt(t)||!Rt(t._meta))return null;let a=t._meta[Ao];return!Rt(a)||!Su(a.suggestions)?null:a.suggestions}function yu(e){let t=null;for(let a of e.parts){let o=Sh(a);o!==null&&(t=o)}return t}function bu(e){for(let t of e.parts){if(!Rt(t)||t.type!=="data-suggestions")continue;let a=t.data;if(Rt(a)&&Su(a.suggestions)&&a.suggestions.length>0)return a.suggestions}return null}function kh(e){return"page"in e||"channel"in e}function Th(e){return typeof e!="object"||e===null?{}:kh(e)?{rungs:e}:{initial:e.initial}}function Tu(e){let{messages:t,status:a,suggestions:o}=e,r=o!==!1,{rungs:n,initial:s}=Th(o),i=Jr(()=>({page:null,channel:yo(s??[])}),[s]),l=n??i,u=Jr(()=>r?Kr({flow:null,followup:null,...l}):null,[r,l]),d=Jr(()=>u?.suggestions.map(L=>L.text)??[],[u]),[c,p]=ku(d),[m,g]=ku(u?.origin??"channel"),I=bh(a),x=yh(()=>{p([])},[]),S=t.length>0;Qr(()=>{S||(p(d),g(u?.origin??"channel"))},[d,u,S]);let C=t[t.length-1];return Qr(()=>{C?.role==="user"&&x()},[C,x]),Qr(()=>{let L=I.current;if(I.current=a,L!=="streaming"||a!=="ready"||!r)return;let y=[...t].reverse().find(A=>A.role==="assistant");if(!y)return;let b=yu(y),P=bu(y),M=Kr({flow:b===null?null:yo(b),followup:P===null?null:yo(P),page:null,channel:null});p(M?M.suggestions.map(A=>A.text):[]),g(M?.origin??"channel")},[a,r,t]),{suggestions:c,source:m,isLoading:!1,clear:x}}f();import{useEffect as vh,useRef as Ph,useState as Ah}from"react";var Rh=80,Mh=50,Fh=15e3,vu=500;function Pu(e,t=!0){let[a,o]=Ah(""),r=Ph(void 0);return vh(()=>{if(!t){o("");return}let n=0,s=!1,i=!1,l=()=>{i||(s?(n--,o(e.slice(0,n)),n<=0?(s=!1,r.current=setTimeout(l,vu)):r.current=setTimeout(l,Mh)):(n++,o(e.slice(0,n)),n>=e.length?(s=!0,r.current=setTimeout(l,Fh)):r.current=setTimeout(l,Rh)))};return r.current=setTimeout(l,vu),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function Au(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return At(e,"/resource",o?{token:o}:void 0)}f();var Dh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:8,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5",userBubbleTextColor:"#1f2937",assistantBubbleTextColor:"#1f2937",messagePaddingX:16,messagePaddingY:12,messageMaxWidth:"80%",fontSize:16,lineHeight:"1.5",glassTint:"transparent",glassTintStrength:"0"};var Bh={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"],userBubbleTextColor:["--ww-user-bubble-text"],assistantBubbleTextColor:["--ww-assistant-bubble-text"],messagePaddingX:["--ww-msg-pad-x"],messagePaddingY:["--ww-msg-pad-y"],messageMaxWidth:["--ww-msg-max-width"],fontSize:["--ww-font-size"],lineHeight:["--ww-line-height"],glassTint:["--ww-glass-tint"],glassTintStrength:["--ww-glass-tint-opacity"]};function Ru(e){return{...Dh,...e}}function Mu(e){let t={};for(let[a,o]of Object.entries(Bh)){let r=e[a];if(r===void 0)continue;let n=typeof r=="number"?`${r}px`:String(r);for(let s of o)t[s]=n}return t}import{jsx as Le,jsxs as Ca}from"react/jsx-runtime";var Nh=Eh(function(t,a){let{theme:o,title:r="Assistant",width:n,height:s,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:d,placeholder:c="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:g,enableThreadHistory:I=!1,showToolCalls:x=!0}=t,S=m??"/api/waniwani",C=Au(S,t.headers),L=Ru(o),y=Mu(o??{}),b=L.backgroundColor.replace("#",""),P=parseInt(b.substring(0,2),16),M=parseInt(b.substring(2,4),16),A=parseInt(b.substring(4,6),16),_=(P*299+M*587+A*114)/1e3<128,F=Iu(S,t.headers,t.skipRemoteConfig),E=g??F.debug,v=Cu({...t,api:S}),D=ou({...t,api:S,sessionId:v.sessionId}),H=Pu(c,!v.text),[T,O]=Du(!1),[U,Be]=Du(null),be=Fu(null),W=Fu(void 0),ke=Yr(()=>{let Q=be.current;if(!Q)return;Q.scrollIntoView({behavior:"smooth",block:"center"});let J=Q.querySelector("textarea");J&&setTimeout(()=>J.focus(),300),O(!0),clearTimeout(W.current),W.current=setTimeout(()=>O(!1),2e3)},[]),ue=Tu({messages:v.messages,status:v.status,suggestions:t.suggestions}),Ae=Yr(Q=>{let J=Q.content.map(Ue=>Ue.text??"").join("").trim();J&&v.handleSubmit({text:J,files:[],modelContext:Q.modelContext})},[v.handleSubmit]),he=Yr(Q=>{ue.clear(),v.handleSubmit({text:Q,files:[]})},[ue.clear,v.handleSubmit]);return Oh(a,()=>({sendMessage:Q=>{v.handleSubmit({text:Q,files:[]}),ke()},sendMessageAndWait:Q=>v.sendMessageAndWait(Q),reset:v.reset,focus:ke,get messages(){return v.messages},get sessionId(){return v.sessionId}}),[v.handleSubmit,v.sendMessageAndWait,v.reset,v.messages,v.sessionId,ke]),_h(()=>{if(!p)return;let Q=J=>{let Ue=J.detail,Ie=typeof Ue?.message=="string"?Ue.message:void 0;Ie&&v.handleSubmit({text:Ie,files:[]}),ke()};return window.addEventListener(p,Q),()=>window.removeEventListener(p,Q)},[p,v.handleSubmit,ke]),Ca("div",{ref:be,style:{...y,width:n,height:s},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:R("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",T&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[Ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:L.headerBackgroundColor,color:L.headerTextColor},children:[Le("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),Le(Hs,{messages:v.messages,evalEnabled:F.eval,api:S}),I&&Le(au,{threads:v.threads,activeThreadId:v.activeThreadId,onNewThread:v.startNewThread,onSelectThread:Q=>{v.switchThread(Q)},onDeleteThread:Q=>{v.deleteThread(Q)}})]}),Ca(ws,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[Le(xs,{scrollClassName:U?"ww:!relative ww:!overflow-hidden":void 0,children:Le(Jl,{messages:v.messages,status:v.status,welcomeMessage:u,welcome:d,onSuggestionSelect:he,resourceEndpoint:C,chatSessionId:v.sessionId,isDark:_,onFollowUp:Ae,onCallTool:D,fullscreenToolCallId:U,debug:E,showToolCalls:x,toolDefinitions:v.toolDefinitions,onWidgetDisplayModeChange:(Q,J)=>{Be(Q==="fullscreen"?J.toolCallId:null)}})}),Le(Cs,{})]}),Le("div",{style:U?{display:"none"}:void 0,children:Le(eu,{suggestions:ue.suggestions,isLoading:ue.isLoading,onSelect:he})}),Le("div",{style:U?{display:"none"}:void 0,children:Le(Os,{queuedMessages:v.queuedMessages,onRemove:v.removeQueuedMessage})}),Le("div",{style:U?{display:"none"}:void 0,children:Le("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:Ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[Le(ks,{onSubmit:v.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:Ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&Le(Ps,{}),Le(Ts,{onChange:v.handleTextChange,value:v.text,placeholder:H,className:"ww:min-h-0 ww:py-1 ww:px-0"}),Le(vs,{status:v.status,disabled:v.queueFull})]})}),Le(Zl,{})]})})})]})});export{Nh as ChatCard,Tn as DevModeProvider,Ju as InitializeNextJsInIframe,Fd as LoadingWidget,Bn as WidgetProvider,In as createResource,$u as createTool,To as detectPlatform,Pa as getMockState,Et as initializeMockOpenAI,zu as isMCPApps,ju as isOpenAI,Xu as registerTools,uL as toNextJsHandler,Rn as unstable_useSendFollowUpWithGhostGuard,Ot as updateMockDisplayMode,nt as updateMockGlobal,Nt as updateMockTheme,_t as updateMockToolOutput,En as useCallTool,_n as useDisplayMode,On as useFlowAction,Nn as useIsChatGptApp,Un as useLocale,Hn as useMaxHeight,qn as useOpenExternal,Wn as useRequestDisplayMode,Gn as useSafeArea,jn as useSendFollowUp,zn as useTheme,Ra as useToolOutput,Vn as useToolResponseMetadata,$n as useUpdateModelContext,$ as useWidgetClient,Xn as useWidgetState};
83
83
  /*! Bundled license information:
84
84
 
85
85
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js: