@waniwani/sdk 0.12.13 → 0.12.14-beta.1

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 Er,b as _r,c as Nr,d as wt,e as xt,f as ma,g as Ur,h as Or,i as Hr,j as qr,k as ha,l as Wr,m as mo,n as Gr,o as jr,p as Lt,u as Pt}from"../chunk-4WLKD7DL.js";import{a as po,b as nu,c as iu}from"../chunk-R6LESDWJ.js";import{b as Tt,c as gt,d as Dr,e as Br}from"../chunk-PYLRF5BB.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var ga="text/html+skybridge",wa="text/html;profile=mcp-app",zr=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Vr(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function $r(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.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function ho(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 Xr(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:s,widgetDomain:n,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:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=zr(r,s)),p),h=o;async function S(L){let I=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:ga,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":i}},async C=>({contents:[{uri:C.href,mimeType:ga,text:I,_meta:Vr({description:h,prefersBorder:i,widgetDomain:n,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:wa,_meta:{ui:{prefersBorder:i}}},async C=>({contents:[{uri:C.href,mimeType:wa,text:I,_meta:$r({description:h,prefersBorder:i,widgetDomain:n,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:l,register:S}}f();f();var lu="waniwani/client";function Kr(e){if(typeof e=="object"&&e!==null)return e[lu]}function uu(e,t){let{resource:a,description:o,inputSchema:r,annotations:s,autoInjectResultText:n=!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?ho({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:s,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},S=Kr(m),L=await t(d,{extra:{_meta:h},waniwani:S});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...n===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...n===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function du(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as mu,jsx as vt,jsxs as hu}from"react/jsx-runtime";function cu(){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 s=history.pushState.bind(history);history.pushState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);s(null,u,d.pathname+d.search+d.hash)}catch{}};let n=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!==n)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!==n){let l=window.fetch;window.fetch=((p,m)=>{let h=typeof p=="string"&&!/^[a-z][a-z0-9+.-]*:/i.test(p)&&!p.startsWith("//"),S;if(typeof p=="string"||p instanceof URL?S=new URL(p,window.location.href):S=new URL(p.url,window.location.href),S.origin===n)return typeof p=="string"||p instanceof URL?p=S.toString():p=new Request(S.toString(),p),l.call(window,p,{...m,mode:"cors"});if(t.indexOf(S.origin)!==-1)return l.call(window,p,m);if(h&&S.origin===window.location.origin){let L=new URL(e);return L.pathname=S.pathname,L.search=S.search,L.hash=S.hash,S=L,p=S.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=n.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let S=new URL(u);return S.pathname=h.pathname,S.search=h.search,S.hash=h.hash,new c(S.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 fu=`(${cu.toString()})()`;function pu({baseUrl:e,passthroughOrigins:t}){return hu(mu,{children:[vt("base",{href:e}),vt("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),vt("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),vt("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),vt("script",{children:fu})]})}f();f();import{useCallback as qe,useEffect as Ct,useRef as go,useState as Be}from"react";f();var Qr={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},At={...Qr};function Rt(e){typeof window>"u"||window.openai||(At={...Qr,toolOutput:e??null},window.openai={...At,requestDisplayMode:async({mode:t})=>(tt("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=>{tt("widgetState",t)}},window.dispatchEvent(new Tt({globals:At})))}function tt(e,t){typeof window>"u"||!window.openai||(At[e]=t,window.openai[e]=t,window.dispatchEvent(new Tt({globals:{[e]:t}})))}function xa(){return{...At}}function Mt(e){tt("toolOutput",e)}function Ft(e){tt("displayMode",e)}function Dt(e){tt("theme",e)}import{Fragment as wo,jsx as B,jsxs as $}from"react/jsx-runtime";var La=150;function Jr({className:e}){return $("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 gu({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 wu({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 xu({className:e}){return $("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 Lu({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 Cu({className:e}){return $("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 Iu({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 Su({className:e}){return $("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 yu=`
1
+ import{a as Or,b as Hr,c as qr,d as xt,e as Lt,f as ha,g as Wr,h as Gr,i as jr,j as zr,k as ga,l as Vr,m as ho,n as $r,o as Xr,p as Ct,u as vt}from"../chunk-4WLKD7DL.js";import{a as mo,b as uu,c as du}from"../chunk-R6LESDWJ.js";import{b as Pt,c as wt,d as Nr,e as Ur}from"../chunk-PYLRF5BB.js";import{d as f}from"../chunk-LPD7BHH5.js";f();f();f();f();var wa="text/html+skybridge",xa="text/html;profile=mcp-app",Kr=async(e,t)=>{let a=e.endsWith("/")?e.slice(0,-1):e;return await(await fetch(`${a}${t}`)).text()};function Qr(e){return{"openai/widgetDescription":e.description,"openai/widgetPrefersBorder":e.prefersBorder,"openai/widgetDomain":e.widgetDomain,...e.widgetCSP&&{"openai/widgetCSP":e.widgetCSP}}}function Jr(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.widgetDomain&&{domain:e.widgetDomain},...e.prefersBorder!==void 0&&{prefersBorder:e.prefersBorder}}}}function go(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 Zr(e){let{id:t,title:a,description:o,baseUrl:r,htmlPath:s,widgetDomain:n,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:L}=new URL(r);(L==="localhost"||L==="127.0.0.1")&&(u={...u,connect_domains:[...u.connect_domains||[],`ws://${L}:*`,`wss://${L}:*`],resource_domains:[...u.resource_domains||[],`http://${L}:*`]})}catch{}let c=`ui://widgets/apps-sdk/${t}.html`,d=`ui://widgets/ext-apps/${t}.html`,p=null,m=()=>(p||(p=Kr(r,s)),p),h=o;async function I(L){let S=await m();L.registerResource(`${t}-openai-widget`,c,{title:a,description:h,mimeType:wa,_meta:{"openai/widgetDescription":h,"openai/widgetPrefersBorder":i}},async C=>({contents:[{uri:C.href,mimeType:wa,text:S,_meta:Qr({description:h,prefersBorder:i,widgetDomain:n,widgetCSP:u})}]})),L.registerResource(`${t}-mcp-widget`,d,{title:a,description:h,mimeType:xa,_meta:{ui:{prefersBorder:i}}},async C=>({contents:[{uri:C.href,mimeType:xa,text:S,_meta:Jr({description:h,prefersBorder:i,widgetDomain:n,widgetCSP:u})}]}))}return{id:t,title:a,description:o,openaiUri:c,mcpUri:d,autoHeight:l,register:I}}f();f();var cu="waniwani/client";function Yr(e){if(typeof e=="object"&&e!==null)return e[cu]}function fu(e,t){let{resource:a,description:o,inputSchema:r,annotations:s,autoInjectResultText:n=!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?go({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:s,...u&&{_meta:u}},(async(d,p)=>{let m=p,h=m._meta??{},I=Yr(m),L=await t(d,{extra:{_meta:h},waniwani:I});return a&&L.data?{content:[{type:"text",text:L.text}],structuredContent:L.data,_meta:{...u,...h,...n===!1?{"waniwani/autoInjectResultText":!1}:{}}}:{content:[{type:"text",text:L.text}],...L.data?{structuredContent:L.data}:{},...n===!1?{_meta:{"waniwani/autoInjectResultText":!1}}:{}}}))}}}async function pu(e,t){await Promise.all(t.map(a=>a.register(e)))}f();f();import{Fragment as wu,jsx as At,jsxs as xu}from"react/jsx-runtime";function mu(){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 s=history.pushState.bind(history);history.pushState=(l,u,c)=>{try{let d=new URL(String(c??""),window.location.href);s(null,u,d.pathname+d.search+d.hash)}catch{}};let n=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!==n)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!==n){let l=window.fetch;window.fetch=((p,m)=>{let h=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===n)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(h&&I.origin===window.location.origin){let L=new URL(e);return L.pathname=I.pathname,L.search=I.search,L.hash=I.hash,I=L,p=I.toString(),l.call(window,p,{...m,mode:"cors"})}return l.call(window,p,m)});let u=n.replace(/^http/,"ws"),c=window.WebSocket,d=((p,m)=>{let h=new URL(String(p),window.location.href);if(h.origin===window.location.origin||h.origin===window.location.origin.replace(/^http/,"ws")){let I=new URL(u);return I.pathname=h.pathname,I.search=h.search,I.hash=h.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 hu=`(${mu.toString()})()`;function gu({baseUrl:e,passthroughOrigins:t}){return xu(wu,{children:[At("base",{href:e}),At("script",{children:`window.innerBaseUrl = ${JSON.stringify(e)}`}),At("script",{children:`window.__wwPassthroughOrigins = ${JSON.stringify(t??[])}`}),At("script",{children:'window.__isChatGptApp = typeof window.openai !== "undefined";'}),At("script",{children:hu})]})}f();f();import{useCallback as We,useEffect as It,useRef as wo,useState as Ee}from"react";f();var es={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},Rt={...es};function Mt(e){typeof window>"u"||window.openai||(Rt={...es,toolOutput:e??null},window.openai={...Rt,requestDisplayMode:async({mode:t})=>(at("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=>{at("widgetState",t)}},window.dispatchEvent(new Pt({globals:Rt})))}function at(e,t){typeof window>"u"||!window.openai||(Rt[e]=t,window.openai[e]=t,window.dispatchEvent(new Pt({globals:{[e]:t}})))}function La(){return{...Rt}}function Ft(e){at("toolOutput",e)}function Dt(e){at("displayMode",e)}function Bt(e){at("theme",e)}import{Fragment as xo,jsx as E,jsxs as X}from"react/jsx-runtime";var Ca=150;function ts({className:e}){return X("svg",{className:e,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Dev Controls",children:[E("rect",{x:"4",y:"4",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),E("rect",{x:"10",y:"10",width:"10",height:"10",rx:"2",stroke:"currentColor",strokeWidth:"1.5",fill:"currentColor",fillOpacity:"0.15"})]})}function Lu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:E("path",{d:"M18 6L6 18M6 6l12 12"})})}function Cu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("rect",{x:"2",y:"4",width:"12",height:"8",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"})})}function Iu({className:e}){return X("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("rect",{x:"1.5",y:"3",width:"13",height:"10",rx:"1.5",stroke:"currentColor",strokeWidth:"1.25"}),E("rect",{x:"8.5",y:"7",width:"5",height:"4",rx:"0.75",fill:"currentColor"})]})}function Su({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("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 yu({className:e}){return X("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("circle",{cx:"8",cy:"8",r:"2.5",stroke:"currentColor",strokeWidth:"1.25"}),E("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 bu({className:e}){return E("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:E("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 ku({className:e}){return X("svg",{"aria-hidden":"true",className:e,viewBox:"0 0 16 16",fill:"none",children:[E("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"}),E("path",{d:"M12.5 2v3h-3M3.5 14v-3h3",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})]})}var Tu=`
2
2
  @keyframes devPanelSlideIn {
3
3
  0% {
4
4
  opacity: 0;
@@ -46,28 +46,28 @@ import{a as Er,b as _r,c as Nr,d as wt,e as xt,f as ma,g as Ur,h as Or,i as Hr,j
46
46
  .dev-json-editor::-webkit-scrollbar-thumb:hover {
47
47
  background: rgba(255, 255, 255, 0.15);
48
48
  }
49
- `;function Yr({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=Be(!1),[s,n]=Be(!1);return Ct(()=>{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}/`));n(u),u&&Rt(e)}else Rt(e),n(!0);r(!0)},[e,t]),o?s?$(wo,{children:[B(bu,{children:a}),B(ku,{defaultProps:e})]}):B(wo,{children:a}):null}function bu({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 Zr({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return $("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=>$("button",{type:"button",onClick:()=>a(r.value),className:`
49
+ `;function os({defaultProps:e,widgetPaths:t,children:a}){let[o,r]=Ee(!1),[s,n]=Ee(!1);return It(()=>{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}/`));n(u),u&&Mt(e)}else Mt(e),n(!0);r(!0)},[e,t]),o?s?X(xo,{children:[E(Pu,{children:a}),E(vu,{defaultProps:e})]}):E(xo,{children:a}):null}function Pu({children:e}){return E("div",{className:"min-h-screen bg-[#212121] flex items-center justify-center p-8",children:E("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 as({options:e,value:t,onChange:a}){let o=e.findIndex(r=>r.value===t);return X("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:[E("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=>X("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 ku({defaultProps:e}){let[t,a]=Be(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=Be(!1),[s,n]=Be(t),[i,l]=Be("inline"),[u,c]=Be("dark"),[d,p]=Be(!1),[m,h]=Be(()=>JSON.stringify(e??{},null,2)),[S,L]=Be(null),I=go(null),C=go(null),g=go(null);Ct(()=>{let F=xa();l(F.displayMode),c(F.theme)},[]),Ct(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?La:0,left:0,right:0}},window.dispatchEvent(new Tt({globals:{safeArea:window.openai.safeArea}})))},[d]),Ct(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let y=qe(()=>{n(!0),requestAnimationFrame(()=>{a(!0)})},[]),k=qe(()=>{r(!0),a(!1),setTimeout(()=>{n(!1),r(!1)},150)},[]),v=qe(()=>{t?k():y()},[t,y,k]);Ct(()=>{let F=Q=>{(Q.metaKey||Q.ctrlKey)&&Q.shiftKey&&Q.key==="d"&&(Q.preventDefault(),v()),Q.key==="Escape"&&t&&k()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,v,k]),Ct(()=>{if(!t)return;let F=Q=>{g.current&&!g.current.contains(Q.target)&&k()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[t,k]);let A=qe(F=>{l(F),Ft(F)},[]),M=qe(F=>{c(F),Dt(F)},[]),_=qe(F=>{try{let Q=JSON.parse(F);L(null),Mt(Q)}catch{L("Invalid JSON")}},[]),R=qe(F=>{h(F),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{_(F)},500)},[_]),P=qe(()=>{I.current&&clearTimeout(I.current),_(m)},[_,m]),b=qe(()=>{let F=JSON.stringify(e??{},null,2);h(F),L(null),Mt(e??{}),l("inline"),Ft("inline"),c("dark"),Dt("dark")},[e]),E=[{value:"inline",label:"inline",icon:B(wu,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:B(xu,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:B(Lu,{className:"w-3.5 h-3.5"})}],O=[{value:"light",label:"light",icon:B(Cu,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:B(Iu,{className:"w-3.5 h-3.5"})}];return $(wo,{children:[B("style",{dangerouslySetInnerHTML:{__html:yu}}),$("div",{ref:g,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[$("button",{type:"button",onClick:v,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,E("span",{className:"capitalize",children:r.label})]},r.value))]})}function vu({defaultProps:e}){let[t,a]=Ee(()=>typeof window>"u"?!1:localStorage.getItem("dev-controls-open")==="true"),[o,r]=Ee(!1),[s,n]=Ee(t),[i,l]=Ee("inline"),[u,c]=Ee("dark"),[d,p]=Ee(!1),[m,h]=Ee(()=>JSON.stringify(e??{},null,2)),[I,L]=Ee(null),S=wo(null),C=wo(null),g=wo(null);It(()=>{let F=La();l(F.displayMode),c(F.theme)},[]),It(()=>{typeof window>"u"||(window.openai||(window.openai={}),window.openai.safeArea={insets:{top:0,bottom:d?Ca:0,left:0,right:0}},window.dispatchEvent(new Pt({globals:{safeArea:window.openai.safeArea}})))},[d]),It(()=>{localStorage.setItem("dev-controls-open",String(t))},[t]);let y=We(()=>{n(!0),requestAnimationFrame(()=>{a(!0)})},[]),P=We(()=>{r(!0),a(!1),setTimeout(()=>{n(!1),r(!1)},150)},[]),v=We(()=>{t?P():y()},[t,y,P]);It(()=>{let F=J=>{(J.metaKey||J.ctrlKey)&&J.shiftKey&&J.key==="d"&&(J.preventDefault(),v()),J.key==="Escape"&&t&&P()};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,v,P]),It(()=>{if(!t)return;let F=J=>{g.current&&!g.current.contains(J.target)&&P()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[t,P]);let R=We(F=>{l(F),Dt(F)},[]),A=We(F=>{c(F),Bt(F)},[]),_=We(F=>{try{let J=JSON.parse(F);L(null),Ft(J)}catch{L("Invalid JSON")}},[]),M=We(F=>{h(F),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{_(F)},500)},[_]),T=We(()=>{S.current&&clearTimeout(S.current),_(m)},[_,m]),b=We(()=>{let F=JSON.stringify(e??{},null,2);h(F),L(null),Ft(e??{}),l("inline"),Dt("inline"),c("dark"),Bt("dark")},[e]),B=[{value:"inline",label:"inline",icon:E(Cu,{className:"w-3.5 h-3.5"})},{value:"pip",label:"pip",icon:E(Iu,{className:"w-3.5 h-3.5"})},{value:"fullscreen",label:"full",icon:E(Su,{className:"w-3.5 h-3.5"})}],O=[{value:"light",label:"light",icon:E(yu,{className:"w-3.5 h-3.5"})},{value:"dark",label:"dark",icon:E(bu,{className:"w-3.5 h-3.5"})}];return X(xo,{children:[E("style",{dangerouslySetInnerHTML:{__html:Tu}}),X("div",{ref:g,className:"fixed bottom-4 right-4 z-[9999] font-['Inter',_system-ui,_sans-serif]",children:[X("button",{type:"button",onClick:v,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(Jr,{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%)"}})]}),s&&$("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:`
57
+ `},"aria-label":"Toggle Dev Controls","aria-expanded":t,children:[E(ts,{className:`w-5 h-5 transition-all duration-200 ${t?"text-indigo-400 scale-110":"text-gray-300 group-hover:text-white"}`}),E("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%)"}})]}),s&&X("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:[$("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[$("div",{className:"flex items-center gap-2",children:[B(Jr,{className:"w-4 h-4 text-gray-400"}),B("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),$("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(gu,{className:"w-4 h-4"})})]})]}),$("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[$("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(Zr,{options:E,value:i,onChange:A})]}),$("div",{children:[B("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),B(Zr,{options:O,value:u,onChange:M})]}),$("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)"}),$("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&&$("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",La,"px"]})]}),$("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:F=>R(F.target.value),onBlur:P,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:S?"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:F=>{S||(F.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:F=>{S||(F.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),S&&$("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"})}),S]})]}),$("button",{type:"button",onClick:b,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:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.04)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[B(Su,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&$("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${La}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[$("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"})})})]}),$("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",La,"px"]})]})]})}f();f();import{useCallback as Pu,useContext as vu,useLayoutEffect as Au,useMemo as Ru,useRef as es}from"react";f();import{createContext as Tu}from"react";var Bt=Tu(null);import{Fragment as ts,jsx as xo}from"react/jsx-runtime";var Mu="waniwani:send-follow-up:advanced:",Fu=1e4;function as(e){return`${Mu}${e??"default"}`}function Du(e){try{let t=globalThis.localStorage?.getItem(as(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 Bu(e,t){try{globalThis.localStorage?.setItem(as(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function Lo(){return typeof window>"u"?!1:typeof window.openai=="object"}function Eu(){return Lo()?window.openai:null}function _u(){return Au(()=>{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 os(e){let t=vu(Bt),a=es(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=Eu()?.toolResponseMetadata??null,s=o??r,n=s&&typeof s.viewUUID=="string"?s.viewUUID:void 0,i=es("");i.current===""&&(i.current=crypto.randomUUID());let l=Pu((c,d)=>{Lo()&&Bu(n,i.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[n]),u=Ru(()=>{let c=i.current;return function({children:p}){if(!Lo())return xo(ts,{children:p});let m=Du(n);return m&&m.byMountId!==c&&Date.now()-m.at<Fu?xo(_u,{}):xo(ts,{children:p})}},[n]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as Ou}from"react";f();import Et,{useCallback as ss,useContext as Nu,useEffect as ns,useState as Co,useSyncExternalStore as Uu}from"react";f();async function rs(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-XYLENCIC.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-RY3VD4L7.js");return new a}}function is({children:e,loading:t=null,onError:a}){let[o,r]=Co(null),[s,n]=Co(null),[i,l]=Co(!0);return ns(()=>{let u=!0,c=null;async function d(){try{let p=await rs();await p.connect(),u?(c=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),n(p instanceof Error?p:new Error(String(p))),l(!1))}}return d(),()=>{u=!1,c?.close()}},[]),ns(()=>{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]),s&&a?Et.createElement(Et.Fragment,null,a(s)):i||!o?Et.createElement(Et.Fragment,null,t):Et.createElement(Bt.Provider,{value:o},e)}function G(e){let t=Nu(Bt);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=ss(s=>e==="toolOutput"?t.onToolResult(()=>s()):e==="theme"?t.onThemeChange(()=>s()):e==="displayMode"?t.onDisplayModeChange(()=>s()):e==="safeArea"?t.onSafeAreaChange(()=>s()):e==="maxHeight"?t.onMaxHeightChange(()=>s()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>s()):e==="widgetState"?t.onWidgetStateChange(()=>s()):()=>{},[t,e]),o=ss(()=>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=Uu(a,o,o);return e?r:t}function ls(){let e=G();return Ou((t,a)=>e.callTool(t,a),[e])}f();function us(){return G("displayMode")}f();f();function Ca(){return G("toolOutput")}function ds(){return{data:Ca()}}f();import{useSyncExternalStore as Hu}from"react";function cs(){return Hu(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function fs(){return G("locale")}f();function ps(){return G("maxHeight")}f();import{useCallback as qu}from"react";function ms(){let e=G();return qu(t=>e.openExternal(t),[e])}f();import{useCallback as Wu}from"react";function hs(){let e=G();return Wu(t=>e.requestDisplayMode(t),[e])}f();function gs(){return G("safeArea")}f();import{useCallback as Gu}from"react";function ws(){let e=G();return Gu((t,a)=>{(async()=>{gt(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 xs(){return G("theme")}f();function Ls(){return G("toolResponseMetadata")}f();import{useCallback as ju}from"react";function Cs(){let e=G();return ju(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as zu,useEffect as Vu,useState as $u}from"react";function Is(e){let t=G("widgetState"),[a,o]=$u(()=>t??(typeof e=="function"?e():e??null));Vu(()=>{o(t)},[t]);let r=zu(s=>{o(n=>{let i=typeof s=="function"?s(n):s;return po()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as at,jsxs as Ss}from"react/jsx-runtime";var Xu=()=>Ss("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Ss("div",{className:"flex gap-2",children:[at("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),at("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),at("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),at("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..."}),at("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:at("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),at("style",{children:`
61
+ `},children:[X("div",{className:"flex items-center justify-between px-4 py-3",style:{borderBottom:"1px solid rgba(255, 255, 255, 0.06)"},children:[X("div",{className:"flex items-center gap-2",children:[E(ts,{className:"w-4 h-4 text-gray-400"}),E("span",{className:"text-sm font-medium text-white",children:"Dev Controls"})]}),X("div",{className:"flex items-center gap-2",children:[E("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"}),E("button",{type:"button",onClick:P,className:"p-1 rounded-md text-gray-500 hover:text-gray-300 hover:bg-white/5 transition-colors",children:E(Lu,{className:"w-4 h-4"})})]})]}),X("div",{className:"p-4 space-y-5 overflow-y-auto",style:{maxHeight:"calc(100vh - 200px)"},children:[X("div",{children:[E("label",{htmlFor:"display-mode",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Display Mode"}),E(as,{options:B,value:i,onChange:R})]}),X("div",{children:[E("label",{htmlFor:"theme",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Theme"}),E(as,{options:O,value:u,onChange:A})]}),X("div",{children:[E("label",{htmlFor:"safe-area",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Safe Area (Chat Input)"}),X("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:[E("span",{children:"Mock ChatGPT Input Bar"}),E("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&&X("p",{className:"text-[10px] text-gray-500 mt-1.5",children:["bottom: ",Ca,"px"]})]}),X("div",{children:[E("label",{htmlFor:"widget-props",className:"text-[11px] font-medium uppercase tracking-wider text-gray-500 block mb-2",children:"Widget Props"}),E("textarea",{value:m,onChange:F=>M(F.target.value),onBlur:T,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:F=>{I||(F.target.style.borderColor="rgba(99, 102, 241, 0.5)")},onBlurCapture:F=>{I||(F.target.style.borderColor="rgba(255, 255, 255, 0.06)")},spellCheck:!1}),I&&X("p",{className:"text-red-400 text-[11px] mt-1.5 flex items-center gap-1",children:[E("svg",{"aria-hidden":"true","aria-label":"Error",className:"w-3 h-3",viewBox:"0 0 16 16",fill:"currentColor",children:E("path",{d:"M8 1.5a6.5 6.5 0 100 13 6.5 6.5 0 000-13zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"})}),I]})]}),X("button",{type:"button",onClick:b,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:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.08)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.1)"},onMouseLeave:F=>{F.currentTarget.style.background="rgba(255, 255, 255, 0.04)",F.currentTarget.style.borderColor="rgba(255, 255, 255, 0.06)"},children:[E(ku,{className:"w-3.5 h-3.5"}),"Reset to Defaults"]})]})]})]}),d&&X("div",{className:"fixed bottom-0 left-0 right-0 z-[9998] flex items-center justify-center pointer-events-none",style:{height:`${Ca}px`,background:"linear-gradient(to top, #1a1a1a 0%, #1a1a1a 80%, transparent 100%)"},children:[X("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:[E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}),E("div",{className:"flex-1 text-gray-400 text-sm",children:"Ask me anything..."}),E("div",{className:"w-8 h-8 rounded-full bg-[#424242] flex items-center justify-center",children:E("svg",{"aria-hidden":"true",className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:E("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"})})})]}),X("div",{className:"absolute bottom-1 text-[10px] text-gray-600 font-mono",children:["Mock SafeArea: bottom=",Ca,"px"]})]})]})}f();f();import{useCallback as Ru,useContext as Mu,useLayoutEffect as Fu,useMemo as Du,useRef as rs}from"react";f();import{createContext as Au}from"react";var Et=Au(null);import{Fragment as ss,jsx as Lo}from"react/jsx-runtime";var Bu="waniwani:send-follow-up:advanced:",Eu=1e4;function ns(e){return`${Bu}${e??"default"}`}function _u(e){try{let t=globalThis.localStorage?.getItem(ns(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 Nu(e,t){try{globalThis.localStorage?.setItem(ns(e),JSON.stringify({at:Date.now(),byMountId:t}))}catch{}}function Co(){return typeof window>"u"?!1:typeof window.openai=="object"}function Uu(){return Co()?window.openai:null}function Ou(){return Fu(()=>{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 is(e){let t=Mu(Et),a=rs(e);a.current=e;let o=t?.getToolResponseMetadata?.()??null,r=Uu()?.toolResponseMetadata??null,s=o??r,n=s&&typeof s.viewUUID=="string"?s.viewUUID:void 0,i=rs("");i.current===""&&(i.current=crypto.randomUUID());let l=Ru((c,d)=>{Co()&&Nu(n,i.current);try{Promise.resolve(a.current(c)).catch(p=>{console.error("[unstable_useSendFollowUpWithGhostGuard]",p)})}catch(p){console.error("[unstable_useSendFollowUpWithGhostGuard]",p)}},[n]),u=Du(()=>{let c=i.current;return function({children:p}){if(!Co())return Lo(ss,{children:p});let m=_u(n);return m&&m.byMountId!==c&&Date.now()-m.at<Eu?Lo(Ou,{}):Lo(ss,{children:p})}},[n]);return{sendFollowUp:l,Guard:u}}f();import{useCallback as Wu}from"react";f();import _t,{useCallback as us,useContext as Hu,useEffect as ds,useState as Io,useSyncExternalStore as qu}from"react";f();async function ls(){let{detectPlatform:e}=await import("../platform-ZNBJH5XX.js");if(e()==="openai"){let{OpenAIWidgetClient:a}=await import("../openai-client-XYLENCIC.js");return new a}else{let{MCPAppsWidgetClient:a}=await import("../mcp-apps-client-RY3VD4L7.js");return new a}}function cs({children:e,loading:t=null,onError:a}){let[o,r]=Io(null),[s,n]=Io(null),[i,l]=Io(!0);return ds(()=>{let u=!0,c=null;async function d(){try{let p=await ls();await p.connect(),u?(c=p,r(p),l(!1)):p.close()}catch(p){u&&(console.error("error",p),n(p instanceof Error?p:new Error(String(p))),l(!1))}}return d(),()=>{u=!1,c?.close()}},[]),ds(()=>{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]),s&&a?_t.createElement(_t.Fragment,null,a(s)):i||!o?_t.createElement(_t.Fragment,null,t):_t.createElement(Et.Provider,{value:o},e)}function G(e){let t=Hu(Et);if(!t)throw new Error("useWidgetClient must be used within a WidgetProvider");let a=us(s=>e==="toolOutput"?t.onToolResult(()=>s()):e==="theme"?t.onThemeChange(()=>s()):e==="displayMode"?t.onDisplayModeChange(()=>s()):e==="safeArea"?t.onSafeAreaChange(()=>s()):e==="maxHeight"?t.onMaxHeightChange(()=>s()):e==="toolResponseMetadata"?t.onToolResponseMetadataChange(()=>s()):e==="widgetState"?t.onWidgetStateChange(()=>s()):()=>{},[t,e]),o=us(()=>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=qu(a,o,o);return e?r:t}function fs(){let e=G();return Wu((t,a)=>e.callTool(t,a),[e])}f();function ps(){return G("displayMode")}f();f();function Ia(){return G("toolOutput")}function ms(){return{data:Ia()}}f();import{useSyncExternalStore as Gu}from"react";function hs(){return Gu(()=>()=>{},()=>typeof window>"u"?!1:window.__isChatGptApp===!0,()=>!1)}f();function gs(){return G("locale")}f();function ws(){return G("maxHeight")}f();import{useCallback as ju}from"react";function xs(){let e=G();return ju(t=>e.openExternal(t),[e])}f();import{useCallback as zu}from"react";function Ls(){let e=G();return zu(t=>e.requestDisplayMode(t),[e])}f();function Cs(){return G("safeArea")}f();import{useCallback as Vu}from"react";function Is(){let e=G();return Vu((t,a)=>{(async()=>{wt(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 Ss(){return G("theme")}f();function ys(){return G("toolResponseMetadata")}f();import{useCallback as $u}from"react";function bs(){let e=G();return $u(async t=>{await Promise.resolve(e.updateModelContext(t))},[e])}f();import{useCallback as Xu,useEffect as Ku,useState as Qu}from"react";function ks(e){let t=G("widgetState"),[a,o]=Qu(()=>t??(typeof e=="function"?e():e??null));Ku(()=>{o(t)},[t]);let r=Xu(s=>{o(n=>{let i=typeof s=="function"?s(n):s;return mo()==="openai"&&i!=null&&window.openai?.setWidgetState(i),i})},[]);return[a,r]}f();import{jsx as ot,jsxs as Ts}from"react/jsx-runtime";var Ju=()=>Ts("div",{className:"flex flex-col items-center justify-center h-full min-h-[120px] gap-4",children:[Ts("div",{className:"flex gap-2",children:[ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-blue-400 to-cyan-400 animate-bounce [animation-delay:-0.3s]"}),ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-cyan-400 to-teal-400 animate-bounce [animation-delay:-0.15s]"}),ot("div",{className:"w-3 h-3 rounded-full bg-gradient-to-r from-teal-400 to-emerald-400 animate-bounce"})]}),ot("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..."}),ot("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:ot("div",{className:"w-16 h-16 rounded-full border-2 border-blue-400/20 animate-ping"})}),ot("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 Ku={debug:0,warn:1,error:2,none:3};function Qu(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in Ku?e:process.env.WANIWANI_DEBUG?"debug":"none"}function Ee(e,t){return t??Qu()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function ys(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function bs(){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 ks(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Ie=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Ts(e){let t=e.headers,a=t.get("x-vercel-ip-city")??t.get("cf-ipcity")??void 0,o=a?Ju(a):void 0,r=t.get("x-vercel-ip-country")??t.get("cf-ipcountry")??void 0,s=t.get("x-vercel-ip-country-region")??void 0,n=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:s,latitude:n,longitude:i,timezone:l,ip:u}}function Ju(e){try{return decodeURIComponent(e)}catch{return e}}f();function Ps(e,t){if(!gt(t))return e;let a=Br(t);return a?[e,a].filter(Boolean).join(`
66
+ `})]});f();f();f();var Zu={debug:0,warn:1,error:2,none:3};function Yu(){let e=process.env.WANIWANI_LOG_LEVEL;return e&&e in Zu?e:process.env.WANIWANI_DEBUG?"debug":"none"}function _e(e,t){return t??Yu()==="debug"?(...o)=>console.log(`[waniwani:${e}]`,...o):()=>{}}f();function Ps(e){if(e===!0)return{};if(!(e===!1||e===void 0))return e}f();function vs(){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 As(e){return function(a,o){return e(new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"},status:o}))}}f();f();var Se=class extends Error{constructor(a,o){super(a);this.status=o;this.name="WaniWaniError"}};f();function Rs(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,s=t.get("x-vercel-ip-country-region")??void 0,n=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:s,latitude:n,longitude:i,timezone:l,ip:u}}function ed(e){try{return decodeURIComponent(e)}catch{return e}}f();function Ms(e,t){if(!wt(t))return e;let a=Ur(t);return a?[e,a].filter(Boolean).join(`
67
67
 
68
- `):e}function vs(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:c}=e,d=Ee("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),S=h.messages??[],L=h.sessionId,I=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,y=h.visitorContext??null,k=Ts(m),v={geo:k,client:y};if(d("body parsed \u2014 messages:",S.length,"sessionId:",L??"(none)","geo:",JSON.stringify(k)),n){d("running beforeRequest hook");try{let E=await n({messages:S,sessionId:L,modelContext:I,request:m,visitor:v});E&&(E.messages&&(S=E.messages),E.systemPrompt!==void 0&&(C=E.systemPrompt),E.sessionId!==void 0&&(L=E.sessionId),E.modelContext!==void 0&&(I=E.modelContext)),d("beforeRequest hook done \u2014 messages:",S.length,"sessionId:",L??"(none)")}catch(E){console.error("[waniwani:chat] beforeRequest hook error:",E);let O=E instanceof Ie?E.status:400,F=E instanceof Error?E.message:"Request rejected";return d("\u2190 returning",O,"from hook error"),Response.json({error:F},{status:O})}}let A=i??(await l()).mcpServerUrl;d("mcpServerUrl:",A),C=Ps(C,I);let M=`${a}/api/mcp/chat`;d("forwarding to",M);let _=m.headers.get("user-agent"),R=await fetch(M,{method:"POST",headers:{"Content-Type":"application/json","X-WaniWani-Stream-Protocol":"2",...t?{Authorization:`Bearer ${t}`}:{},..._?{"X-Client-User-Agent":_}:{}},body:JSON.stringify({messages:S,mcpServerUrl:A,sessionId:L,source:o,systemPrompt:C,maxSteps:s,visitor:v,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",R.status),!R.ok){let E=await R.text().catch(()=>"");return d("\u2190 returning",R.status,"upstream error:",E),new Response(E,{status:R.status,headers:{"Content-Type":R.headers.get("Content-Type")??"application/json"}})}let P=new Headers({"Content-Type":R.headers.get("Content-Type")??"text/event-stream"}),b=R.headers.get("x-session-id");return b&&P.set("x-session-id",b),d("\u2190 streaming response",R.status,"body null?",R.body===null),new Response(R.body,{status:R.status,headers:P})}catch(h){console.error("[waniwani:chat] handler error:",h);let S=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof Ie?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:S},{status:L})}}}f();function As(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Ee("resource",o);return async function(n){r("\u2192 GET",n.toString());try{let i=n.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 h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{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 Ie?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function Rs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,s=Ee("tool",o);return async function(i){s("\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 s("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});s("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;s("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),s("MCP deps loaded")}catch(I){return console.error("[waniwani:tool] MCP deps import failed:",I),Response.json({error:"MCP tool handler requires @modelcontextprotocol/sdk. Install it to enable tool calls."},{status:501})}s("creating MCP client for",p);let S=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(S);try{s("calling tool:",u);let I={};d&&(I["waniwani/sessionId"]=d),r&&(I["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(I).length>0?{_meta:I}:{}});return s("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),s("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 Ie?l.status:500;return s("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function Ms(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=Ee("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let n=t??(await a()).mcpServerUrl;r("mcpServerUrl:",n);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",n);let u=await i({transport:new l(new URL(n))});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(n){console.error("[waniwani:tools-list] handler error:",n);let i=n instanceof Error?n.message:"Unknown error occurred",l=n instanceof Ie?n.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var Zu=300*1e3;function Fs(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 Ie("WANIWANI_API_KEY is required for createChatHandler",401);let s=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!s.ok){let i=await s.text().catch(()=>"");throw new Ie(`Failed to resolve MCP environment config: ${s.status} ${i}`,s.status)}let n=await s.json();return a={config:n,expiresAt:Date.now()+Zu},n})();try{return await o}finally{o=null}}}var Yu="https://app.waniwani.ai";function Ds(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=Yu,source:o,systemPrompt:r,maxSteps:s=5,beforeRequest:n,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,c=Ee("router",l),d=bs(),p=ks(d),m=Fs(a,t),h=vs({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:ys(u)}),S=As({mcpServerUrl:i,resolveConfig:m,debug:l}),L=Ms({mcpServerUrl:i,resolveConfig:m,debug:l}),I=Rs({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(A){c("\u2192 GET",A.url);try{let M=new URL(A.url),R=M.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",M.pathname,"subRoute:",R),C&&R==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let b=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(b.data??b,200)}catch{return p([],200)}}if(R==="resource"){c("dispatching to resource handler");let P=await S(M);return c("\u2190 resource handler returned",P.status),d(P)}if(R==="config")return c("dispatching to config handler"),p({debug:l,eval:C},200);if(R==="tools"){c("dispatching to tools-list handler");let P=await L();return c("\u2190 tools-list handler returned",P.status),d(P)}return c("\u2190 404 no matching sub-route for",R),p({error:"Not found"},404)}catch(M){console.error("[waniwani:router] GET handler error:",M);let _=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function y(A){c("\u2192 POST",A.url);try{let M=new URL(A.url),R=M.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",M.pathname,"subRoute:",R),C&&R==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let b=await A.json(),E=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(b)}),O=await E.json();return E.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to save scenario"},E.status)}catch(b){let E=b instanceof Error?b.message:"Failed to save scenario";return p({error:E},400)}}if(R==="tool"){c("dispatching to tool handler");let b=await I(A);return c("\u2190 tool handler returned",b.status),d(b)}c("dispatching to chat handler");let P=await h(A);return d(P)}catch(M){console.error("[waniwani:router] POST handler error:",M);let _=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function k(A){c("\u2192 PATCH",A.url);try{let M=new URL(A.url),_=M.pathname.replace(/\/$/,"").split("/").filter(Boolean),R=_.at(-1),P=_.at(-2);if(c("pathname:",M.pathname,"subRoute:",P,"id:",R),C&&P==="scenarios"&&R){c("dispatching to update-scenario handler (proxy to app API)");try{let b=await A.json(),E=await fetch(`${a}/api/mcp/scenarios/${R}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(b)}),O=await E.json();return E.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to update scenario"},E.status)}catch(b){let E=b instanceof Error?b.message:"Failed to update scenario";return p({error:E},400)}}return c("\u2190 404 no matching sub-route for PATCH",P),p({error:"Not found"},404)}catch(M){console.error("[waniwani:router] PATCH handler error:",M);let _=M instanceof Error?M.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}function v(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:S,handleTool:I,routeGet:g,routePost:y,routePatch:k,handleOptions:v}}var Bs=!1;function Jx(e,t){!Bs&&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."),Bs=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",s=Ds({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:s.routePost,GET:s.routeGet,PATCH:s.routePatch,OPTIONS:()=>s.handleOptions()}}f();import{forwardRef as _h,useCallback as Ar,useEffect as Nh,useImperativeHandle as Uh,useRef as Ql,useState as Jl}from"react";f();f();f();import{forwardRef as td,createElement as ad}from"react";f();var Ia=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var Es=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var _s=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var Io=e=>{let t=_s(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as ed,createElement as Os}from"react";f();var Ns={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 Hs=ed(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...i},l)=>Os("svg",{ref:l,...Ns,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:Ia("lucide",r),...!s&&!Us(i)&&{"aria-hidden":"true"},...i},[...n.map(([u,c])=>Os(u,c)),...Array.isArray(s)?s:[s]]));var j=(e,t)=>{let a=td(({className:o,...r},s)=>ad(Hs,{ref:s,iconNode:t,className:Ia(`lucide-${Es(Io(e))}`,`lucide-${e}`,o),...r}));return a.displayName=Io(e),a};f();var od=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],_t=j("arrow-down",od);f();var rd=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Nt=j("arrow-up",rd);f();var sd=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],We=j("braces",sd);f();var nd=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Ut=j("brain",nd);f();var id=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ot=j("check",id);f();var ld=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ot=j("chevron-down",ld);f();var ud=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ht=j("chevron-right",ud);f();var dd=[["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"}]],qt=j("clipboard-copy",dd);f();var cd=[["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"}]],Wt=j("file",cd);f();var fd=[["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"}]],Gt=j("loader",fd);f();var pd=[["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"}]],jt=j("paperclip",pd);f();var md=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],zt=j("square",md);f();var hd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],rt=j("x",hd);f();var gd=[["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"}]],Vt=j("zap",gd);import{useCallback as Dd}from"react";f();import{useCallback as Xe,useMemo as wd,useRef as xd,useState as So}from"react";var Ld={damping:.7,stiffness:.05,mass:1.25},Cd=70,Id=1e3/60,Sd=350,Sa=!1;globalThis.document?.addEventListener("mousedown",()=>{Sa=!0});globalThis.document?.addEventListener("mouseup",()=>{Sa=!1});globalThis.document?.addEventListener("click",()=>{Sa=!1});var Ws=(e={})=>{let[t,a]=So(!1),[o,r]=So(e.initial!==!1),[s,n]=So(!1),i=xd(null);i.current=e;let l=Xe(()=>{if(!Sa)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Xe(C=>{d.isAtBottom=C,r(C)},[]),c=Xe(C=>{d.escapedFromLock=C,a(C)},[]),d=wd(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!I.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!I.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let y=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:I.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:y},requestAnimationFrame(()=>{C=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Cd}}},[]),p=Xe((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),y=bo(i.current,C.animation),{ignoreEscapes:k=!1}=C,v,A=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{v=Date.now()}):v=g+(C.duration??0);let M=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:R}=d,P=performance.now(),b=(P-(d.lastTick??P))/Id;if(d.animation||(d.animation={behavior:y,promise:_,ignoreEscapes:k}),d.animation.behavior===y&&(d.lastTick=P),l()||g>Date.now())return M();if(R<Math.min(A,d.calculatedTargetScrollTop)){if(d.animation?.behavior===y){if(y==="instant")return d.scrollTop=d.calculatedTargetScrollTop,M();d.velocity=(y.damping*d.velocity+y.stiffness*d.scrollDifference)/y.mass,d.accumulated+=d.velocity*b,d.scrollTop+=d.accumulated,d.scrollTop!==R&&(d.accumulated=0)}return M()}return v>Date.now()?(A=d.calculatedTargetScrollTop,M()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:bo(i.current,i.current.resize),ignoreEscapes:k,duration:Math.max(0,v-Date.now())||void 0}):d.isAtBottom)});return _.then(R=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),R))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===y?d.animation.promise:M()},[u,l,d]),m=Xe(()=>{c(!0),u(!1)},[c,u]),h=Xe(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:y}=d,{lastScrollTop:k=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,y&&y>g&&(k=y),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===y)return;if(l()){c(!0),u(!1);return}let v=g>k,A=g<k;if(d.animation?.ignoreEscapes){d.scrollTop=k;return}A&&(c(!0),u(!1)),v&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,l,d]),S=Xe(({target:C,deltaY:g})=>{let y=C;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=qs(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",S),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",S,{passive:!0})},[]),I=qs(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([y])=>{let{height:k}=y.contentRect,v=k-(g??k);if(d.resizeDifference=v,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),v>=0){let A=bo(i.current,g?i.current.resize:i.current.initial);p({animation:A,wait:!0,preserveScrollPosition:!0,duration:A==="instant"?void 0:Sd})}else d.isNearBottom&&(c(!1),u(!0));g=k,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===v&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:I,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function qs(e,t){let a=Xe(o=>(a.current=o,e(o)),t);return a}var yo=new Map;function bo(...e){let t={...Ld},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 yo.has(o)||yo.set(o,Object.freeze(t)),a?"instant":yo.get(o)}f();import*as st from"react";import{createContext as yd,useContext as bd,useEffect as kd,useImperativeHandle as Td,useLayoutEffect as Pd,useMemo as vd,useRef as Ad}from"react";var Gs=yd(null),Rd=typeof window<"u"?Pd:kd;function $t({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:i,contextRef:l,...u}){let c=Ad(null),d=st.useCallback((k,v)=>(y?.targetScrollTop??i)?.(k,v)??k,[i]),p=Ws({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:S,stopScroll:L,isAtBottom:I,escapedFromLock:C,state:g}=e??p,y=vd(()=>({scrollToBottom:S,stopScroll:L,scrollRef:m,isAtBottom:I,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(k){c.current=k}}),[S,I,h,m,L,C,g]);return Td(l,()=>y,[y]),Rd(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),st.createElement(Gs.Provider,{value:y},st.createElement("div",{...u},typeof t=="function"?t(y):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=ko();return st.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},st.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})($t||($t={}));function ko(){let e=bd(Gs);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var Md=_r({prefix:"ww"});function D(...e){return Md(Er(e))}f();import{jsx as Fd}from"react/jsx-runtime";var _e=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>Fd("button",{type:o,className:D("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 ya}from"react/jsx-runtime";var js=({className:e,...t})=>ya($t,{className:D("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),zs=({className:e,...t})=>ya($t.Content,{className:D("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}),Vs=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=ko(),r=Dd(()=>{o()},[o]);return!a&&ya(_e,{className:D("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:ya(_t,{className:"ww:size-4"})})};f();f();import Xs from"crypto";f();var $s="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Bd=128,nt,It,Ed=e=>{!nt||nt.length<e?(nt=Buffer.allocUnsafe(e*Bd),Xs.randomFillSync(nt),It=0):It+e>nt.length&&(Xs.randomFillSync(nt),It=0),It+=e};var Xt=(e=21)=>{Ed(e|=0);let t="";for(let a=It-e;a<It;a++)t+=$s[nt[a]&63];return t};import{createContext as _d,useCallback as Ge,useContext as Nd,useEffect as To,useMemo as Ud,useRef as Po,useState as Ks}from"react";import{jsx as Re,jsxs as an}from"react/jsx-runtime";var Od=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}},Qs=_d(null),Js=()=>{let e=Nd(Qs);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},Zs=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:i,...l})=>{let u=Po(null),c=Po(null),[d,p]=Ks([]),m=Po(d);To(()=>{m.current=d},[d]);let h=Ge(()=>{u.current?.click()},[]),S=Ge(k=>{let v=[...k];if(v.length===0)return;let A=_=>s?_.size<=s:!0,M=v.filter(A);p(_=>{let R=typeof r=="number"?Math.max(0,r-_.length):void 0,P=typeof R=="number"?M.slice(0,R):M;return[..._,...P.map(b=>({filename:b.name,id:Xt(),mediaType:b.type,type:"file",url:URL.createObjectURL(b)}))]})},[r,s]),L=Ge(k=>{p(v=>{let A=v.find(M=>M.id===k);return A?.url&&URL.revokeObjectURL(A.url),v.filter(M=>M.id!==k)})},[]),I=Ge(()=>{p(k=>{for(let v of k)v.url&&URL.revokeObjectURL(v.url);return[]})},[]);To(()=>()=>{for(let k of m.current)k.url&&URL.revokeObjectURL(k.url)},[]);let C=Ge(k=>{k.currentTarget.files&&S(k.currentTarget.files),k.currentTarget.value=""},[S]);To(()=>{if(!o)return;let k=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault()},v=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault(),A.dataTransfer?.files&&A.dataTransfer.files.length>0&&S(A.dataTransfer.files)};return document.addEventListener("dragover",k),document.addEventListener("drop",v),()=>{document.removeEventListener("dragover",k),document.removeEventListener("drop",v)}},[S,o]);let g=Ge(async k=>{k.preventDefault();let v=k.currentTarget,M=new FormData(v).get("message")||"";v.reset();let _=await Promise.all(d.map(async({id:R,...P})=>{if(P.url?.startsWith("blob:")){let b=await Od(P.url);return{...P,url:b??P.url}}return P}));try{let R=n({files:_,text:M},k);R instanceof Promise&&await R,I()}catch{}},[d,n,I]),y=Ud(()=>({add:S,clear:I,files:d,openFileDialog:h,remove:L}),[d,S,L,I,h]);return an(Qs.Provider,{value:y,children:[Re("input",{accept:t,"aria-label":"Upload files",className:"ww:hidden",multiple:a,onChange:C,ref:u,title:"Upload files",type:"file"}),Re("form",{className:D("ww:flex ww:w-full ww:flex-col ww:rounded-lg ww:border ww:border-border ww:bg-background",e),onSubmit:g,ref:c,...l,children:i})]})};var Ys=({onChange:e,onKeyDown:t,className:a,placeholder:o="What would you like to know?",...r})=>{let s=Js(),[n,i]=Ks(!1),l=Ge(c=>{if(t?.(c),!c.defaultPrevented){if(c.key==="Enter"){if(n||c.nativeEvent.isComposing||c.shiftKey)return;c.preventDefault();let{form:d}=c.currentTarget;if(d?.querySelector('button[type="submit"]')?.disabled)return;d?.requestSubmit()}if(c.key==="Backspace"&&c.currentTarget.value===""&&s.files.length>0){c.preventDefault();let d=s.files.at(-1);d&&s.remove(d.id)}}},[t,n,s]),u=Ge(c=>{let d=c.clipboardData?.items;if(!d)return;let p=[];for(let m of d)if(m.kind==="file"){let h=m.getAsFile();h&&p.push(h)}p.length>0&&(c.preventDefault(),s.add(p))},[s]);return Re("textarea",{className:D("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:()=>i(!1),onCompositionStart:()=>i(!0),onKeyDown:l,onPaste:u,placeholder:o,onChange:e,...r})},en=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let n=t==="submitted"||t==="streaming",i=Re(Nt,{className:"ww:size-4"});t==="submitted"?i=Re(Gt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(i=Re(zt,{className:"ww:size-4"}));let l=Ge(u=>{if(n&&a){u.preventDefault(),a();return}o?.(u)},[n,a,o]);return Re(_e,{"aria-label":n?"Stop":"Submit",className:D("ww:bg-foreground ww:text-background ww:hover:bg-foreground ww:rounded-full",e),onClick:l,size:"icon-sm",type:n&&a?"button":"submit",variant:"ghost",...s,children:r??i})},tn=({className:e,children:t,...a})=>{let o=Js();return o.files.length>0?an(_e,{className:D("ww:group ww:relative",e),onClick:()=>o.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":"Remove all attachments",...a,children:[Re("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:o.files.length}),Re(rt,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Re(_e,{className:D(e),onClick:()=>o.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Re(jt,{className:"ww:size-4"})})};f();import{memo as Hd,useCallback as qd}from"react";f();import{jsx as St}from"react/jsx-runtime";var on=({className:e,...t})=>St("div",{className:D("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),rn=({className:e,...t})=>St("li",{className:D("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}),sn=({className:e,...t})=>St("span",{className:D("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),nn=({className:e,...t})=>St("span",{className:D("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),ln=({className:e,...t})=>St("div",{className:D("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),un=({className:e,...t})=>St(_e,{className:D("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 it,jsxs as vo}from"react/jsx-runtime";var dn=Hd(({message:e,onRemove:t})=>{let a=qd(()=>t(e.id),[t,e.id]);return vo(rn,{children:[it(sn,{}),it(nn,{children:e.text||"(attachment)"}),it(ln,{children:it(un,{"aria-label":"Remove from queue",onClick:a,children:it(rt,{className:"ww:size-3"})})})]})});dn.displayName="ChatQueueItem";function cn({queuedMessages:e,onRemove:t,className:a}){return e.length===0?null:vo(on,{className:D("ww:border-t ww:border-border",a),children:[vo("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:[e.length," queued"]}),it("ul",{children:e.map(o=>it(dn,{message:o,onRemove:t},o.id))})]})}f();import{useState as fn}from"react";import{jsx as Wd}from"react/jsx-runtime";function pn({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let[o,r]=fn(!1),[s,n]=fn(null),i=async()=>{let u={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};r(!0),n(null);try{let c=await fetch(`${a}/scenarios`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)});if(!c.ok)throw new Error(`${c.status}`);n("saved")}catch{n("error")}finally{r(!1),setTimeout(()=>n(null),2e3)}};return!t||e.length===0?null:Wd("button",{type:"button",onClick:i,disabled:o,title:"Save scenario to WaniWani",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:o?"saving...":s==="saved"?"saved":s==="error"?"error":"export"})}f();f();import{jsx as Kt,jsxs as jd}from"react/jsx-runtime";var mn=({files:e,className:t,...a})=>e.length===0?null:Kt("div",{className:D("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Kt(Gd,{file:o},r))});function Gd({file:e}){return e.mediaType?.startsWith("image/")&&e.url?Kt("img",{src:e.url,alt:e.filename??"attachment",className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):jd("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:[Kt(Wt,{className:"ww:size-3 ww:shrink-0"}),Kt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??"file"})]})}f();f();f();f();f();f();var de={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 Ne={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 ye={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 hn(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 gn(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function wn(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 xn(e){return hn(e)?"ambiguous":gn(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":wn(e)?"wide":"neutral"}function zd(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ln(e){return zd(e),xn(e)}var Vd=Object.defineProperty,$d=(e,t,a)=>t in e?Vd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,Xd=(e,t,a)=>$d(e,typeof t!="symbol"?t+"":t,a);function Kd(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function Qd(e){if(!e||e<4352)return!1;switch(Ln(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!Kd(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 Jd(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function Zd(e){return e!==null&&e>=65024&&e<=65038}var Yd=Cn(new RegExp("\\p{P}|\\p{S}","u")),ec=Cn(/\s/);function Cn(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var be;(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})(be||(be={}));function Ke(e){if(e===de.eof||Nr(e)||ec(e))return Ne.characterGroupWhitespace;let t=0;if(e>=4352){if(Zd(e))return be.nonEmojiGeneralUseVS;switch(Qd(e)){case null:return be.ivs;case!0:t|=be.cjk;break}}return Yd(e)&&(t|=Ne.characterGroupPunctuation),t}function ba(e,t,a){if(!ac(e))return e;let o=t(),r=Ke(o);return!o||lt(r)?e:Jd(o,a)?be.cjkPunctuation:tc(r)}function tc(e){return e&~be.ivs}function lt(e){return!!(e&Ne.characterGroupWhitespace)}function yt(e){return(e&be.cjkPunctuation)===Ne.characterGroupPunctuation}function Qt(e){return!!(e&be.cjk)}function In(e){return e===be.ivs}function Sn(e){return!!(e&be.cjkOrIvs)}function ac(e){return e===be.nonEmojiGeneralUseVS}function Ao(e){return!!(e&be.spaceOrPunctuation)}function ka(e){return!!(e&&e>=55296&&e<=56319)}function Ta(e){return!!(e&&e>=56320&&e<=57343)}function Pa(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 oc(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,s=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),n=s.charCodeAt(s.length-1);if(Number.isNaN(n))return null;if(s.length<2||n<56320||57343<n)return n;let i=s.codePointAt(0);return i&&i>=65536?i:n}var va=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,Xd(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=oc(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Aa(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var Ro={name:"attention",resolveAll:rc,tokenize:sc};function rc(e,t){let a=-1,o,r,s,n,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};yn(d,-l),yn(p,l),n={type:l>1?ye.strongSequence:ye.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?ye.strongSequence:ye.emphasisSequence,start:{...e[a][1].start},end:p},s={type:l>1?ye.strongText:ye.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?ye.strong:ye.emphasis,start:{...n.start},end:{...i.end}},e[o][1].end={...n.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=xt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=xt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=xt(u,ma(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=xt(u,[["exit",s,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=xt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,wt(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 sc(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=Ta(s)?Pa(s,o(),r):s,i=Ke(n),l=new va(n,o(),r),u=ba(i,l.value.bind(l),n),c;return d;function d(m){return m===de.asterisk||de.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),S=ka(m)?Aa(m,o(),r):m,L=Ke(S);let I=yt(u),C=I||lt(u),g=yt(L),y=g||lt(L),k=Sn(u),v=!y||g&&(C||k)||a.includes(m),A=!C||I&&(y||Qt(L))||a.includes(n);return h._open=!!(c===de.asterisk?v:v&&(Ao(u)||!A)),h._close=!!(c===de.asterisk?A:A&&(Ao(L)||!v)),t(m)}}function yn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function bn(){return{text:{[de.asterisk]:Ro,[de.underscore]:Ro},insideSpan:{null:[Ro]}}}function kn(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(bn())}f();f();function Tn(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:s,resolveAll:r};return a==null&&(a=!0),{text:{[de.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[de.tilde]}};function r(n,i){let l=-1;for(;++l<n.length;)if(n[l][0]==="enter"&&n[l][1].type==="strikethroughSequenceTemporary"&&n[l][1]._close){let u=l;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[l][1].end.offset-n[l][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[l][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[l][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[l][1].start)},p=[["enter",c,i],["enter",n[u][1],i],["exit",n[u][1],i],["enter",d,i]],m=i.parser.constructs.insideSpan.null;m&&wt(p,p.length,0,ma(m,n.slice(u+1,l),i)),wt(p,p.length,0,[["exit",d,i],["enter",n[l][1],i],["exit",n[l][1],i],["exit",c,i]]),wt(n,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<n.length;)n[l][1].type==="strikethroughSequenceTemporary"&&(n[l][1].type=ye.data);return n}function s(n,i,l){let{now:u,sliceSerialize:c,previous:d}=this,p=Ta(d)?Pa(d,u(),c):d,m=Ke(p),h=new va(p,u(),c),S=ba(m,h.value.bind(h),p),L=this.events,I=0;return C;function C(y){return de.tilde,p===de.tilde&&L[L.length-1][1].type!==ye.characterEscape?l(y):(n.enter("strikethroughSequenceTemporary"),g(y))}function g(y){let k=Ke(p);if(y===de.tilde)return I>1?l(y):(n.consume(y),I++,g);if(I<2&&!a)return l(y);let v=n.exit("strikethroughSequenceTemporary"),A=ka(y)?Aa(y,u(),c):y,M=Ke(A),R=yt(S)||lt(S),b=yt(M)||lt(M),E=Qt(S)||In(k);return v._open=!b||M===Ne.attentionSideAfter&&(R||E),v._close=!R||k===Ne.attentionSideAfter&&(b||Qt(M)),i(y)}}}function Pn(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(Tn(e))}var nc=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),ic=/^(https?:\/\/|mailto:|www\.)/i,lc=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},uc=e=>{let t=0;for(let a of e){if(nc.has(a))return t;t+=a.length}return null},dc=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),cc=e=>({type:"text",value:e}),fc=()=>e=>{Ur(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!lc(t)||!ic.test(t.url))return;let r=uc(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),i=dc(s,t),l=cc(n);return o.children.splice(a,1,i,l),a+1})};function pc(){let e=[kn],t=[fc,Pn],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Mo=pc();f();f();f();f();f();var Z=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function mc(e){return qo(e)}function qo(e){return Array.isArray(e)?hc(e):e instanceof RegExp?e:typeof e=="object"?gc(e):e}function hc(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=qo(e[a]);return t}function gc(e){let t={};for(let a in e)t[a]=qo(e[a]);return t}function _n(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Nn(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Nn(e.substring(0,e.length-1)):e.substr(~t+1)}var Fo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ra=class{static hasCaptures(e){return e===null?!1:(Fo.lastIndex=0,Fo.test(e))}static replaceCaptures(e,t,a){return e.replace(Fo,(o,r,s,n)=>{let i=a[parseInt(r||s,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(n){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function Un(e,t){return e<t?-1:e>t?1:0}function On(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 s=Un(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function vn(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 Hn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var qn=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}},Yt=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Lc(e),t)}static createFromParsedTheme(e,t){return Ic(e,t)}_cachedMatchRoot=new qn(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=>wc(e.parent,r.parentScopes));return o?new Wn(o.fontStyle,o.foreground,o.background):null}},Do=class Ma{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Ma(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Ma(a,t[o]);return a}push(t){return new Ma(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 wc(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&&!xc(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function xc(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Wn=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Lc(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,s=t.length;r<s;r++){let n=t[r];if(!n.settings)continue;let i;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(n.scope)?i=n.scope:i=[""];let l=-1;if(typeof n.settings.fontStyle=="string"){l=0;let d=n.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 n.settings.foreground=="string"&&vn(n.settings.foreground)&&(u=n.settings.foreground);let c=null;typeof n.settings.background=="string"&&vn(n.settings.background)&&(c=n.settings.background);for(let d=0,p=i.length;d<p;d++){let h=i[d].trim().split(" "),S=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new Cc(S,L,r,l,u,c)}}return a}var Cc=class{constructor(e,t,a,o,r,s){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=s}},ce=(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))(ce||{});function Ic(e,t){e.sort((l,u)=>{let c=Un(l.scope,u.scope);return c!==0||(c=On(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 s=new Sc(t),n=new Wn(a,s.getId(o),s.getId(r)),i=new bc(new Eo(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,s.getId(c.foreground),s.getId(c.background))}return new Yt(s,n,i)}var Sc=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)}},yc=Object.freeze([]),Eo=class Gn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||yc,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new Gn(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)}},bc=class _o{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 s=a.parentScopes[r].length-t.parentScopes[o].length;if(s!==0)return s;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,s;if(o===-1?(r=t,s=""):(r=t.substring(0,o),s=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(_o._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);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 _o(this._mainRule.clone(),Eo.cloneArr(this._rulesWithParentScopes)),this._children[l]=c),c.insert(t+1,u,o,r,s,n)}_doInsertHere(t,a,o,r,s){if(a===null){this._mainRule.acceptOverwrite(t,o,r,s);return}for(let n=0,i=this._rulesWithParentScopes.length;n<i;n++){let l=this._rulesWithParentScopes[n];if(On(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,s);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Eo(t,a,o,r,s))}},dt=class ve{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=ve.getLanguageId(t),o=ve.getTokenType(t),r=ve.getFontStyle(t),s=ve.getForeground(t),n=ve.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:s,background:n})}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,s,n,i){let l=ve.getLanguageId(t),u=ve.getTokenType(t),c=ve.containsBalancedBrackets(t)?1:0,d=ve.getFontStyle(t),p=ve.getForeground(t),m=ve.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(c=r?1:0),s!==-1&&(d=s),n!==0&&(p=n),i!==0&&(m=i),(l<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function Da(e,t){let a=[],o=kc(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=n();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let l=s();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(An(r)){let l=[];do l.push(r),r=o.next();while(An(r));return u=>t(l,u)}return null}function n(){let l=[],u=s();for(;u;)l.push(u),u=s();return c=>l.every(d=>d(c))}function i(){let l=[],u=n();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return c=>l.some(d=>d(c))}}function An(e){return!!e&&!!e.match(/[\w\.:]+/)}function kc(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 jn(e){typeof e.dispose=="function"&&e.dispose()}var ea=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Tc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Pc=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))}},vc=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ea(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Pc;for(let a of e)Ac(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof ea){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 Ac(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 s=a.lookup(t);e instanceof ea?Fa({baseGrammar:s,selfGrammar:r},o):No(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let i of n)o.add(new ea(i))}function No(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Ba([o],t,a)}}function Fa(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ba(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ba(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ba(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?_n({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&Ba(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=zn(s);switch(n.kind){case 0:Fa({...t,selfGrammar:t.baseGrammar},a);break;case 1:Fa(t,a);break;case 2:No(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};n.kind===4?No(n.ruleName,l,a):Fa(l,a)}else n.kind===4?a.add(new Tc(n.scopeName,n.ruleName)):a.add(new ea(n.scopeName));break}}}var Rc=class{kind=0},Mc=class{kind=1},Fc=class{constructor(e){this.ruleName=e}kind=2},Dc=class{constructor(e){this.scopeName=e}kind=3},Bc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function zn(e){if(e==="$base")return new Rc;if(e==="$self")return new Mc;let t=e.indexOf("#");if(t===-1)return new Dc(e);if(t===0)return new Fc(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Bc(a,o)}}var Ec=/\\(\d+)/,Rn=/\\(\d+)/g;var _c=-1,Vn=-2;var oa=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ra.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ra.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Nn(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:Ra.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ra.replaceCaptures(this._contentName,e,t)}},Nc=class extends oa{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!")}},Uc=class extends oa{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new ta(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 aa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Mn=class extends oa{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 aa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Uo=class extends oa{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,i,l,u){super(e,t,a,o),this._begin=new ta(r,this.id),this.beginCaptures=s,this._end=new ta(n||"\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 aa;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}},Ea=class extends oa{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,i,l){super(e,t,a,o),this._begin=new ta(r,this.id),this.beginCaptures=s,this.whileCaptures=i,this._while=new ta(n,Vn),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 aa;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 aa,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},$n=class he{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new Nc(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new Uc(t.$vscodeTextmateLocation,t.id,t.name,t.match,he._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=_n({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new Mn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,he._compilePatterns(s,a,o))}return t.while?new Ea(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,he._compileCaptures(t.whileCaptures||t.captures,a,o),he._compilePatterns(t.patterns,a,o)):new Uo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,he._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,he._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,he._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let s=0;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10);i>s&&(s=i)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10),l=0;t[n].patterns&&(l=he.getCompiledRuleId(t[n],a,o)),r[i]=he.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let i=t[s],l=-1;if(i.include){let u=zn(i.include);switch(u.kind){case 0:case 1:l=he.getCompiledRuleId(o[i.include],a,o);break;case 2:let c=o[u.ruleName];c&&(l=he.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 h=m.repository[p];h&&(l=he.getCompiledRuleId(h,a,m.repository))}else l=he.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=he.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),c=!1;if((u instanceof Mn||u instanceof Uo||u instanceof Ea)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},ta=class Xn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(s.push(t.substring(r,i)),s.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(n=!0),i++}this.hasAnchor=n,r===0?this.source=t:(s.push(t.substring(r,o)),this.source=s.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=Ec.test(this.source):this.hasBackReferences=!1}clone(){return new Xn(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 Rn.lastIndex=0,this.source.replace(Rn,(r,s)=>Hn(o[parseInt(s,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=[],s,n,i,l;for(s=0,n=this.source.length;s<n;s++)i=this.source.charAt(s),t[s]=i,a[s]=i,o[s]=i,r[s]=i,i==="\\"&&s+1<n&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=l,a[s+1]=l,o[s+1]=l,r[s+1]=l),s++);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}},aa=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 Fn(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 Fn(e,o,this._items.map(r=>r.ruleId))}},Fn=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}},Bo=class{constructor(e,t){this.languageId=e,this.tokenType=t}},Oc=class Oo{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new Bo(t,8),this._embeddedLanguagesMatcher=new Hc(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Oo._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Bo(0,0);_getBasicScopeAttributes=new qn(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new Bo(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Oo.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/},Hc=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])=>Hn(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])}},AS={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Kn=!1,Dn=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Qn(e,t,a,o,r,s,n,i){let l=t.content.length,u=!1,c=-1;if(n){let m=qc(e,t,a,o,r,s);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 Dn(r,!0);p()}return new Dn(r,!1);function p(){let m=Wc(e,t,a,o,r,c);if(!m){s.produce(r,l),u=!0;return}let h=m.captureIndices,S=m.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(S===_c){let I=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),Jt(e,t,a,r,s,I.endCaptures,h),s.produce(r,h[0].end);let C=r;if(r=r.parent,c=C.getAnchorPos(),!L&&C.getEnterPos()===o){r=C,s.produce(r,l),u=!0;return}}else{let I=e.getRule(S);s.produce(r,h[0].start);let C=r,g=I.getName(t.content,h),y=r.contentNameScopesList.pushAttributed(g,e);if(r=r.push(S,o,c,h[0].end===l,null,y,y),I instanceof Uo){let k=I;Jt(e,t,a,r,s,k.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let v=k.getContentName(t.content,h),A=y.pushAttributed(v,e);if(r=r.withContentNameScopesList(A),k.endHasBackReferences&&(r=r.withEndRule(k.getEndWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(I instanceof Ea){let k=I;Jt(e,t,a,r,s,k.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let v=k.getContentName(t.content,h),A=y.pushAttributed(v,e);if(r=r.withContentNameScopesList(A),k.whileHasBackReferences&&(r=r.withEndRule(k.getWhileWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(Jt(e,t,a,r,s,I.captures,h),s.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),s.produce(r,l),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function qc(e,t,a,o,r,s){let n=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof Ea&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:c}=zc(l.rule,e,l.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==Vn){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Jt(e,t,a,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),n=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:n,isFirstLine:a}}function Wc(e,t,a,o,r,s){let n=Gc(e,t,a,o,r,s),i=e.getInjections();if(i.length===0)return n;let l=jc(i,e,t,a,o,r,s);if(!l)return n;if(!n)return l;let u=n.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:n}function Gc(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:i,findOptions:l}=Jn(n,e,r.endRule,a,o===s),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function jc(e,t,a,o,r,s,n){let i=Number.MAX_VALUE,l=null,u,c=0,d=s.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let h=e[p];if(!h.matcher(d))continue;let S=t.getRule(h.ruleId),{ruleScanner:L,findOptions:I}=Jn(S,t,null,o,r===n),C=L.findNextMatchSync(a,r,I);if(!C)continue;let g=C.captureIndices[0].start;if(!(g>=i)&&(i=g,l=C.captureIndices,u=C.ruleId,c=h.priority,i===r))break}return l?{priorityMatch:c===-1,captureIndices:l,matchedRuleId:u}:null}function Jn(e,t,a,o,r){if(Kn){let n=e.compile(t,a),i=Zn(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function zc(e,t,a,o,r){if(Kn){let n=e.compileWhile(t,a),i=Zn(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function Zn(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function Jt(e,t,a,o,r,s,n){if(s.length===0)return;let i=t.content,l=Math.min(s.length,n.length),u=[],c=n[0].end;for(let d=0;d<l;d++){let p=s[d];if(p===null)continue;let m=n[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 S=p.getName(i,n),L=o.contentNameScopesList.pushAttributed(S,e),I=p.getContentName(i,n),C=L.pushAttributed(I,e),g=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,L,C),y=e.createOnigString(i.substring(0,m.end));Qn(e,y,a&&m.start===0,m.start,g,r,!1,0),jn(y);continue}let h=p.getName(i,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new Vc(L,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var Vc=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function $c(e,t,a,o,r,s,n,i){return new Kc(e,t,a,o,r,s,n,i)}function Bn(e,t,a,o,r){let s=Da(t,_a),n=$n.getCompiledRuleId(a,o,r.repository);for(let i of s)e.push({debugSelector:t,matcher:i.matcher,ruleId:n,grammar:r,priority:i.priority})}function _a(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(Xc(t[r],o))return a=r+1,!0;return!1})}function Xc(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 Kc=class{constructor(e,t,a,o,r,s,n,i){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=i,this._basicScopeAttributesProvider=new Oc(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=En(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=Da(l,_a);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 n in r)Bn(t,n,r[n],this,o);let s=this._grammarRepository.injections(a);s&&s.forEach(n=>{let i=this.getExternalGrammar(n);if(i){let l=i.injectionSelector;l&&Bn(t,l,i,this,i)}})}return t.sort((r,s)=>r.priority-s.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]=En(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=$n.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Ho.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=dt.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=Zt.createRootAndLookUpScopeName(p,d,this):m=Zt.createRoot("unknown",d),t=new Ho(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
- `;let s=this.createOnigString(e),n=s.content.length,i=new Jc(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Qn(this,s,r,0,t,i,!0,o);return jn(s),{lineLength:n,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function En(e,t){return e=mc(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 Zt=class Ue{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 s of a)r=Do.push(r,s.scopeNames),o=new Ue(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Ue(null,new Do(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new Do(null,t),n=o.themeProvider.themeMatch(s),i=Ue.mergeAttributes(a,r,n);return new Ue(null,s,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ue.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,s=0,n=0;return o!==null&&(r=o.fontStyle,s=o.foregroundId,n=o.backgroundId),dt.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Ue._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Ue._pushAttributed(r,s,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),s=t.scopePath.push(a),n=o.themeProvider.themeMatch(s),i=Ue.mergeAttributes(t.tokenAttributes,r,n);return new Ue(t,s,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}},Ho=class ut{constructor(t,a,o,r,s,n,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,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 ut(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ut._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Zt.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(){ut._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,i){return new ut(this,t,a,o,r,s,n,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 ut(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=Zt.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ut(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,Zt.fromExtension(o,a.contentNameScopesList))}},Qc=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Da(a,_a).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Da(a,_a).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}},Jc=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 s=e?.getScopeNames()??[];for(let n of this._tokenTypeOverrides)n.matcher(s)&&(o=dt.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=dt.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}},Zc=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 s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,$c(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},Yn=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new Zc(Yt.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Yt.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 Qc(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new vc(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(n=>this._loadSingleGrammar(n.scopeName)),s.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)}},Na=Ho.NULL;f();f();f();f();f();f();var Yc=/["&'<>`]/g,ef=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,tf=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,af=/[|\\{}()[\]^$+*?.]/g,ei=new WeakMap;function ti(e,t){if(e=e.replace(t.subset?of(t.subset):Yc,o),t.subset||t.escapeOnly)return e;return e.replace(ef,a).replace(tf,o);function a(r,s,n){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,n.charCodeAt(s+2),t)}function o(r,s,n){return t.format(r.charCodeAt(0),n.charCodeAt(s+1),t)}}function of(e){let t=ei.get(e);return t||(t=rf(e),ei.set(e,t)),t}function rf(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(af,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var sf=/[\dA-Fa-f]/;function ai(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!sf.test(String.fromCharCode(t))?o:o+";"}f();var nf=/\d/;function oi(e,t,a){let o="&#"+String(e);return a&&t&&!nf.test(String.fromCharCode(t))?o:o+";"}f();f();var ri=["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 Ua={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 si=["cent","copy","divide","gt","lt","not","para","times"];var ni={}.hasOwnProperty,Wo={},Oa;for(Oa in Ua)ni.call(Ua,Oa)&&(Wo[Ua[Oa]]=Oa);var lf=/[^\dA-Za-z]/;function ii(e,t,a,o){let r=String.fromCharCode(e);if(ni.call(Wo,r)){let s=Wo[r],n="&"+s;return a&&ri.includes(s)&&!si.includes(s)&&(!o||t&&t!==61&&lf.test(String.fromCharCode(t)))?n:n+";"}return""}function li(e,t,a){let o=ai(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=ii(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=oi(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function je(e,t){return ti(e,Object.assign({format:li},t))}var uf=/^>|^->|<!--|-->|--!>|<!-$/g,df=[">"],cf=["<",">"];function ui(e,t,a,o){return o.settings.bogusComments?"<?"+je(e.value,Object.assign({},o.settings.characterReferences,{subset:df}))+">":"<!--"+e.value.replace(uf,r)+"-->";function r(s){return je(s,Object.assign({},o.settings.characterReferences,{subset:cf}))}}f();function di(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var ae=ci(1),Go=ci(-1),ff=[];function ci(e){return t;function t(a,o,r){let s=a?a.children:ff,n=(o||0)+e,i=s[n];if(!r)for(;i&&Lt(i);)n+=e,i=s[n];return i}}f();var pf={}.hasOwnProperty;function Ha(e){return t;function t(a,o,r){return pf.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var ra=Ha({body:hf,caption:jo,colgroup:jo,dd:Lf,dt:xf,head:jo,html:mf,li:wf,optgroup:Cf,option:If,p:gf,rp:fi,rt:fi,tbody:yf,td:pi,tfoot:bf,th:pi,thead:Sf,tr:kf});function jo(e,t,a){let o=ae(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&Lt(o.value.charAt(0)))}function mf(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function hf(e,t,a){let o=ae(a,t);return!o||o.type!=="comment"}function gf(e,t,a){let o=ae(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 wf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="li"}function xf(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Lf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function fi(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function Cf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function If(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function Sf(e,t,a){let o=ae(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function yf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function bf(e,t,a){return!ae(a,t)}function kf(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function pi(e,t,a){let o=ae(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var mi=Ha({body:vf,colgroup:Af,head:Pf,html:Tf,tbody:Rf});function Tf(e){let t=ae(e,-1);return!t||t.type!=="comment"}function Pf(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 vf(e){let t=ae(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Lt(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Af(e,t,a){let o=Go(a,t),r=ae(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&ra(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Rf(e,t,a){let o=Go(a,t),r=ae(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&ra(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var qa={name:[[`
68
+ `):e}function Fs(e){let{apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:l,debug:u,webSearch:c}=e,d=_e("chat",u);return async function(m){d("\u2192 POST",m.url);try{let h=await m.json(),I=h.messages??[],L=h.sessionId,S=h.modelContext,C=r,g=typeof h.extra=="object"&&h.extra!==null&&!Array.isArray(h.extra)?h.extra:void 0,y=h.visitorContext??null,P=Rs(m),v={geo:P,client:y};if(d("body parsed \u2014 messages:",I.length,"sessionId:",L??"(none)","geo:",JSON.stringify(P)),n){d("running beforeRequest hook");try{let B=await n({messages:I,sessionId:L,modelContext:S,request:m,visitor:v});B&&(B.messages&&(I=B.messages),B.systemPrompt!==void 0&&(C=B.systemPrompt),B.sessionId!==void 0&&(L=B.sessionId),B.modelContext!==void 0&&(S=B.modelContext)),d("beforeRequest hook done \u2014 messages:",I.length,"sessionId:",L??"(none)")}catch(B){console.error("[waniwani:chat] beforeRequest hook error:",B);let O=B instanceof Se?B.status:400,F=B instanceof Error?B.message:"Request rejected";return d("\u2190 returning",O,"from hook error"),Response.json({error:F},{status:O})}}let R=i??(await l()).mcpServerUrl;d("mcpServerUrl:",R),C=Ms(C,S);let A=`${a}/api/mcp/chat`;d("forwarding to",A);let _=m.headers.get("user-agent"),M=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:R,sessionId:L,source:o,systemPrompt:C,maxSteps:s,visitor:v,webSearch:c,...g&&{extra:g}}),signal:m.signal});if(d("upstream response status:",M.status),!M.ok){let B=await M.text().catch(()=>"");return d("\u2190 returning",M.status,"upstream error:",B),new Response(B,{status:M.status,headers:{"Content-Type":M.headers.get("Content-Type")??"application/json"}})}let T=new Headers({"Content-Type":M.headers.get("Content-Type")??"text/event-stream"}),b=M.headers.get("x-session-id");return b&&T.set("x-session-id",b),d("\u2190 streaming response",M.status,"body null?",M.body===null),new Response(M.body,{status:M.status,headers:T})}catch(h){console.error("[waniwani:chat] handler error:",h);let I=h instanceof Error?h.message:"Unknown error occurred",L=h instanceof Se?h.status:500;return d("\u2190 returning",L,"from caught error"),Response.json({error:I},{status:L})}}}f();function Ds(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=_e("resource",o);return async function(n){r("\u2192 GET",n.toString());try{let i=n.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 h;return"text"in m&&typeof m.text=="string"?h=m.text:"blob"in m&&typeof m.blob=="string"&&(h=atob(m.blob)),h?(r("\u2190 200 HTML length:",h.length),new Response(h,{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 Se?i.status:500;return r("\u2190 returning",u,"from caught error"),Response.json({error:l},{status:u})}}}f();function Bs(e){let{mcpServerUrl:t,resolveConfig:a,debug:o,source:r}=e,s=_e("tool",o);return async function(i){s("\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 s("\u2190 400 missing tool name"),Response.json({error:"Missing tool name"},{status:400});s("tool:",u,"args:",JSON.stringify(c),"sessionId:",d||"(none)");let p=t??(await a()).mcpServerUrl;s("mcpServerUrl:",p);let m,h;try{[{Client:m},{StreamableHTTPClientTransport:h}]=await Promise.all([import("@modelcontextprotocol/sdk/client/index.js"),import("@modelcontextprotocol/sdk/client/streamableHttp.js")]),s("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})}s("creating MCP client for",p);let I=new h(new URL(p)),L=new m({name:"waniwani-tool-caller",version:"1.0.0"});await L.connect(I);try{s("calling tool:",u);let S={};d&&(S["waniwani/sessionId"]=d),r&&(S["waniwani/source"]=r);let C=await L.callTool({name:u,arguments:c??{},...Object.keys(S).length>0?{_meta:S}:{}});return s("tool result received"),Response.json({content:C.content,structuredContent:C.structuredContent,_meta:C._meta,isError:C.isError})}finally{await L.close(),s("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 Se?l.status:500;return s("\u2190 returning",c,"from caught error"),Response.json({error:u},{status:c})}}}f();function Es(e){let{mcpServerUrl:t,resolveConfig:a,debug:o}=e,r=_e("tools-list",o);return async function(){r("\u2192 GET tools/list");try{let n=t??(await a()).mcpServerUrl;r("mcpServerUrl:",n);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",n);let u=await i({transport:new l(new URL(n))});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(n){console.error("[waniwani:tools-list] handler error:",n);let i=n instanceof Error?n.message:"Unknown error occurred",l=n instanceof Se?n.status:500;return r("\u2190 returning",l,"from caught error"),Response.json({error:i},{status:l})}}}f();var td=300*1e3;function _s(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 Se("WANIWANI_API_KEY is required for createChatHandler",401);let s=await fetch(`${e}/api/mcp/environments/config`,{method:"GET",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}});if(!s.ok){let i=await s.text().catch(()=>"");throw new Se(`Failed to resolve MCP environment config: ${s.status} ${i}`,s.status)}let n=await s.json();return a={config:n,expiresAt:Date.now()+td},n})();try{return await o}finally{o=null}}}var ad="https://app.waniwani.ai";function Ns(e={}){let{apiKey:t=process.env.WANIWANI_API_KEY,apiUrl:a=ad,source:o,systemPrompt:r,maxSteps:s=5,beforeRequest:n,mcpServerUrl:i,debug:l=!1,webSearch:u}=e,c=_e("router",l),d=vs(),p=As(d),m=_s(a,t),h=Fs({apiKey:t,apiUrl:a,source:o,systemPrompt:r,maxSteps:s,beforeRequest:n,mcpServerUrl:i,resolveConfig:m,debug:l,webSearch:Ps(u)}),I=Ds({mcpServerUrl:i,resolveConfig:m,debug:l}),L=Es({mcpServerUrl:i,resolveConfig:m,debug:l}),S=Bs({mcpServerUrl:i,resolveConfig:m,debug:l,source:o}),C=process.env.WANIWANI_EVAL==="1";async function g(R){c("\u2192 GET",R.url);try{let A=new URL(R.url),M=A.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",A.pathname,"subRoute:",M),C&&M==="scenarios"){c("dispatching to scenarios handler (proxy to app API)");try{let b=await(await fetch(`${a}/api/mcp/scenarios`,{headers:{...t?{Authorization:`Bearer ${t}`}:{}}})).json();return p(b.data??b,200)}catch{return p([],200)}}if(M==="resource"){c("dispatching to resource handler");let T=await I(A);return c("\u2190 resource handler returned",T.status),d(T)}if(M==="config")return c("dispatching to config handler"),p({debug:l,eval:C},200);if(M==="tools"){c("dispatching to tools-list handler");let T=await L();return c("\u2190 tools-list handler returned",T.status),d(T)}return c("\u2190 404 no matching sub-route for",M),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 c("\u2190 500 from caught error"),p({error:_},500)}}async function y(R){c("\u2192 POST",R.url);try{let A=new URL(R.url),M=A.pathname.replace(/\/$/,"").split("/").filter(Boolean).at(-1);if(c("pathname:",A.pathname,"subRoute:",M),C&&M==="scenarios"){c("dispatching to save-scenario handler (proxy to app API)");try{let b=await R.json(),B=await fetch(`${a}/api/mcp/scenarios`,{method:"POST",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(b)}),O=await B.json();return B.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to save scenario"},B.status)}catch(b){let B=b instanceof Error?b.message:"Failed to save scenario";return p({error:B},400)}}if(M==="tool"){c("dispatching to tool handler");let b=await S(R);return c("\u2190 tool handler returned",b.status),d(b)}c("dispatching to chat handler");let T=await h(R);return d(T)}catch(A){console.error("[waniwani:router] POST handler error:",A);let _=A instanceof Error?A.message:"Unknown error occurred";return c("\u2190 500 from caught error"),p({error:_},500)}}async function P(R){c("\u2192 PATCH",R.url);try{let A=new URL(R.url),_=A.pathname.replace(/\/$/,"").split("/").filter(Boolean),M=_.at(-1),T=_.at(-2);if(c("pathname:",A.pathname,"subRoute:",T,"id:",M),C&&T==="scenarios"&&M){c("dispatching to update-scenario handler (proxy to app API)");try{let b=await R.json(),B=await fetch(`${a}/api/mcp/scenarios/${M}`,{method:"PATCH",headers:{"Content-Type":"application/json",...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify(b)}),O=await B.json();return B.ok?p({ok:!0,scenario:O.data},200):p({error:O.message??"Failed to update scenario"},B.status)}catch(b){let B=b instanceof Error?b.message:"Failed to update scenario";return p({error:B},400)}}return c("\u2190 404 no matching sub-route for PATCH",T),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 c("\u2190 500 from caught error"),p({error:_},500)}}function v(){return d(new Response(null,{status:204}))}return{handleChat:h,handleResource:I,handleTool:S,routeGet:g,routePost:y,routePatch:P,handleOptions:v}}var Us=!1;function sL(e,t){!Us&&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."),Us=!0);let{apiKey:a,apiUrl:o}=e._config,r=t?.debug??process.env.WANIWANI_DEBUG==="1",s=Ns({...t?.chat,apiKey:a,apiUrl:o,source:t?.source,debug:r});return{POST:s.routePost,GET:s.routeGet,PATCH:s.routePatch,OPTIONS:()=>s.handleOptions()}}f();import{forwardRef as jh,useCallback as Dr,useEffect as zh,useImperativeHandle as Vh,useRef as Yl,useState as eu}from"react";f();f();f();import{forwardRef as rd,createElement as sd}from"react";f();var Sa=(...e)=>e.filter((t,a,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===a).join(" ").trim();f();var Os=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();f();f();var Hs=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,a,o)=>o?o.toUpperCase():a.toLowerCase());var So=e=>{let t=Hs(e);return t.charAt(0).toUpperCase()+t.slice(1)};f();import{forwardRef as od,createElement as Gs}from"react";f();var qs={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 Ws=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};var js=od(({color:e="currentColor",size:t=24,strokeWidth:a=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:n,...i},l)=>Gs("svg",{ref:l,...qs,width:t,height:t,stroke:e,strokeWidth:o?Number(a)*24/Number(t):a,className:Sa("lucide",r),...!s&&!Ws(i)&&{"aria-hidden":"true"},...i},[...n.map(([u,c])=>Gs(u,c)),...Array.isArray(s)?s:[s]]));var j=(e,t)=>{let a=rd(({className:o,...r},s)=>sd(js,{ref:s,iconNode:t,className:Sa(`lucide-${Os(So(e))}`,`lucide-${e}`,o),...r}));return a.displayName=So(e),a};f();var nd=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Nt=j("arrow-down",nd);f();var id=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ut=j("arrow-up",id);f();var ld=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],Ge=j("braces",ld);f();var ud=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],Ot=j("brain",ud);f();var dd=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ht=j("check",dd);f();var cd=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rt=j("chevron-down",cd);f();var fd=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],qt=j("chevron-right",fd);f();var pd=[["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"}]],Wt=j("clipboard-copy",pd);f();var md=[["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"}]],Gt=j("file",md);f();var hd=[["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"}]],jt=j("loader",hd);f();var gd=[["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"}]],zt=j("paperclip",gd);f();var wd=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Vt=j("square",wd);f();var xd=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],st=j("x",xd);f();var Ld=[["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"}]],$t=j("zap",Ld);import{useCallback as _d}from"react";f();import{useCallback as Ke,useMemo as Cd,useRef as Id,useState as yo}from"react";var Sd={damping:.7,stiffness:.05,mass:1.25},yd=70,bd=1e3/60,kd=350,ya=!1;globalThis.document?.addEventListener("mousedown",()=>{ya=!0});globalThis.document?.addEventListener("mouseup",()=>{ya=!1});globalThis.document?.addEventListener("click",()=>{ya=!1});var Vs=(e={})=>{let[t,a]=yo(!1),[o,r]=yo(e.initial!==!1),[s,n]=yo(!1),i=Id(null);i.current=e;let l=Ke(()=>{if(!ya)return!1;let C=window.getSelection();if(!C||!C.rangeCount)return!1;let g=C.getRangeAt(0);return g.commonAncestorContainer.contains(L.current)||L.current?.contains(g.commonAncestorContainer)},[]),u=Ke(C=>{d.isAtBottom=C,r(C)},[]),c=Ke(C=>{d.escapedFromLock=C,a(C)},[]),d=Cd(()=>{let C;return{escapedFromLock:t,isAtBottom:o,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return L.current?.scrollTop??0},set scrollTop(g){L.current&&(L.current.scrollTop=g,d.ignoreScrollToTop=L.current.scrollTop)},get targetScrollTop(){return!L.current||!S.current?0:L.current.scrollHeight-1-L.current.clientHeight},get calculatedTargetScrollTop(){if(!L.current||!S.current)return 0;let{targetScrollTop:g}=this;if(!e.targetScrollTop)return g;if(C?.targetScrollTop===g)return C.calculatedScrollTop;let y=Math.max(Math.min(e.targetScrollTop(g,{scrollElement:L.current,contentElement:S.current}),g),0);return C={targetScrollTop:g,calculatedScrollTop:y},requestAnimationFrame(()=>{C=void 0}),y},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=yd}}},[]),p=Ke((C={})=>{typeof C=="string"&&(C={animation:C}),C.preserveScrollPosition||u(!0);let g=Date.now()+(Number(C.wait)||0),y=ko(i.current,C.animation),{ignoreEscapes:P=!1}=C,v,R=d.calculatedTargetScrollTop;C.duration instanceof Promise?C.duration.finally(()=>{v=Date.now()}):v=g+(C.duration??0);let A=async()=>{let _=new Promise(requestAnimationFrame).then(()=>{if(!d.isAtBottom)return d.animation=void 0,!1;let{scrollTop:M}=d,T=performance.now(),b=(T-(d.lastTick??T))/bd;if(d.animation||(d.animation={behavior:y,promise:_,ignoreEscapes:P}),d.animation.behavior===y&&(d.lastTick=T),l()||g>Date.now())return A();if(M<Math.min(R,d.calculatedTargetScrollTop)){if(d.animation?.behavior===y){if(y==="instant")return d.scrollTop=d.calculatedTargetScrollTop,A();d.velocity=(y.damping*d.velocity+y.stiffness*d.scrollDifference)/y.mass,d.accumulated+=d.velocity*b,d.scrollTop+=d.accumulated,d.scrollTop!==M&&(d.accumulated=0)}return A()}return v>Date.now()?(R=d.calculatedTargetScrollTop,A()):(d.animation=void 0,d.scrollTop<d.calculatedTargetScrollTop?p({animation:ko(i.current,i.current.resize),ignoreEscapes:P,duration:Math.max(0,v-Date.now())||void 0}):d.isAtBottom)});return _.then(M=>(requestAnimationFrame(()=>{d.animation||(d.lastTick=void 0,d.velocity=0)}),M))};return C.wait!==!0&&(d.animation=void 0),d.animation?.behavior===y?d.animation.promise:A()},[u,l,d]),m=Ke(()=>{c(!0),u(!1)},[c,u]),h=Ke(({target:C})=>{if(C!==L.current)return;let{scrollTop:g,ignoreScrollToTop:y}=d,{lastScrollTop:P=g}=d;d.lastScrollTop=g,d.ignoreScrollToTop=void 0,y&&y>g&&(P=y),n(d.isNearBottom),setTimeout(()=>{if(d.resizeDifference||g===y)return;if(l()){c(!0),u(!1);return}let v=g>P,R=g<P;if(d.animation?.ignoreEscapes){d.scrollTop=P;return}R&&(c(!0),u(!1)),v&&c(!1),!d.escapedFromLock&&d.isNearBottom&&u(!0)},1)},[c,u,l,d]),I=Ke(({target:C,deltaY:g})=>{let y=C;for(;!["scroll","auto"].includes(getComputedStyle(y).overflow);){if(!y.parentElement)return;y=y.parentElement}y===L.current&&g<0&&L.current.scrollHeight>L.current.clientHeight&&!d.animation?.ignoreEscapes&&(c(!0),u(!1))},[c,u,d]),L=zs(C=>{L.current?.removeEventListener("scroll",h),L.current?.removeEventListener("wheel",I),C?.addEventListener("scroll",h,{passive:!0}),C?.addEventListener("wheel",I,{passive:!0})},[]),S=zs(C=>{if(d.resizeObserver?.disconnect(),!C)return;let g;d.resizeObserver=new ResizeObserver(([y])=>{let{height:P}=y.contentRect,v=P-(g??P);if(d.resizeDifference=v,d.scrollTop>d.targetScrollTop&&(d.scrollTop=d.targetScrollTop),n(d.isNearBottom),v>=0){let R=ko(i.current,g?i.current.resize:i.current.initial);p({animation:R,wait:!0,preserveScrollPosition:!0,duration:R==="instant"?void 0:kd})}else d.isNearBottom&&(c(!1),u(!0));g=P,requestAnimationFrame(()=>{setTimeout(()=>{d.resizeDifference===v&&(d.resizeDifference=0)},1)})}),d.resizeObserver?.observe(C)},[]);return{contentRef:S,scrollRef:L,scrollToBottom:p,stopScroll:m,isAtBottom:o||s,isNearBottom:s,escapedFromLock:t,state:d}};function zs(e,t){let a=Ke(o=>(a.current=o,e(o)),t);return a}var bo=new Map;function ko(...e){let t={...Sd},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 bo.has(o)||bo.set(o,Object.freeze(t)),a?"instant":bo.get(o)}f();import*as nt from"react";import{createContext as Td,useContext as Pd,useEffect as vd,useImperativeHandle as Ad,useLayoutEffect as Rd,useMemo as Md,useRef as Fd}from"react";var $s=Td(null),Dd=typeof window<"u"?Rd:vd;function Xt({instance:e,children:t,resize:a,initial:o,mass:r,damping:s,stiffness:n,targetScrollTop:i,contextRef:l,...u}){let c=Fd(null),d=nt.useCallback((P,v)=>(y?.targetScrollTop??i)?.(P,v)??P,[i]),p=Vs({mass:r,damping:s,stiffness:n,resize:a,initial:o,targetScrollTop:d}),{scrollRef:m,contentRef:h,scrollToBottom:I,stopScroll:L,isAtBottom:S,escapedFromLock:C,state:g}=e??p,y=Md(()=>({scrollToBottom:I,stopScroll:L,scrollRef:m,isAtBottom:S,escapedFromLock:C,contentRef:h,state:g,get targetScrollTop(){return c.current},set targetScrollTop(P){c.current=P}}),[I,S,h,m,L,C,g]);return Ad(l,()=>y,[y]),Dd(()=>{m.current&&getComputedStyle(m.current).overflow==="visible"&&(m.current.style.overflow="auto")},[]),nt.createElement($s.Provider,{value:y},nt.createElement("div",{...u},typeof t=="function"?t(y):t))}(function(e){function t({children:a,scrollClassName:o,...r}){let s=To();return nt.createElement("div",{ref:s.scrollRef,style:{height:"100%",width:"100%",scrollbarGutter:"stable both-edges"},className:o},nt.createElement("div",{...r,ref:s.contentRef},typeof a=="function"?a(s):a))}e.Content=t})(Xt||(Xt={}));function To(){let e=Pd($s);if(!e)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return e}f();var Bd=Hr({prefix:"ww"});function D(...e){return Bd(Or(e))}f();import{jsx as Ed}from"react/jsx-runtime";var Ne=({className:e,variant:t="default",size:a="default",type:o="button",...r})=>Ed("button",{type:o,className:D("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 ba}from"react/jsx-runtime";var Xs=({className:e,...t})=>ba(Xt,{className:D("ww:relative ww:flex-1 ww:overflow-y-hidden",e),initial:"smooth",resize:"smooth",role:"log",...t}),Ks=({className:e,...t})=>ba(Xt.Content,{className:D("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}),Qs=({className:e,...t})=>{let{isAtBottom:a,scrollToBottom:o}=To(),r=_d(()=>{o()},[o]);return!a&&ba(Ne,{className:D("ww:absolute ww:bottom-4 ww:left-[50%] ww:translate-x-[-50%] ww:rounded-full",e),onClick:r,size:"icon",variant:"outline",...t,children:ba(Nt,{className:"ww:size-4"})})};f();f();import Zs from"crypto";f();var Js="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Nd=128,it,St,Ud=e=>{!it||it.length<e?(it=Buffer.allocUnsafe(e*Nd),Zs.randomFillSync(it),St=0):St+e>it.length&&(Zs.randomFillSync(it),St=0),St+=e};var Kt=(e=21)=>{Ud(e|=0);let t="";for(let a=St-e;a<St;a++)t+=Js[it[a]&63];return t};import{createContext as jd,useCallback as je,useContext as zd,useEffect as Ro,useMemo as Vd,useRef as Mo,useState as Ys}from"react";f();f();import{createContext as qd,useContext as Wd,useEffect as DI,useMemo as BI,useState as EI}from"react";f();f();f();f();var vo={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"}`},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"}};f();f();import{jsx as WI}from"react/jsx-runtime";var Gd=qd(null);function z(){let e=Wd(Gd);return e||{locale:"en",t:vo}}f();function Ao(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 Fe,jsxs as nn}from"react/jsx-runtime";var $d=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}},en=jd(null),tn=()=>{let e=zd(en);if(!e)throw new Error("usePromptInputAttachments must be used within a PromptInput");return e},an=({className:e,accept:t,multiple:a,globalDrop:o,maxFiles:r,maxFileSize:s,onSubmit:n,children:i,...l})=>{let{t:u}=z(),c=Mo(null),d=Mo(null),[p,m]=Ys([]),h=Mo(p);Ro(()=>{h.current=p},[p]);let I=je(()=>{c.current?.click()},[]),L=je(v=>{let R=[...v];if(R.length===0)return;let A=M=>s?M.size<=s:!0,_=R.filter(A);m(M=>{let T=typeof r=="number"?Math.max(0,r-M.length):void 0,b=typeof T=="number"?_.slice(0,T):_;return[...M,...b.map(B=>({filename:B.name,id:Kt(),mediaType:B.type,type:"file",url:URL.createObjectURL(B)}))]})},[r,s]),S=je(v=>{m(R=>{let A=R.find(_=>_.id===v);return A?.url&&URL.revokeObjectURL(A.url),R.filter(_=>_.id!==v)})},[]),C=je(()=>{m(v=>{for(let R of v)R.url&&URL.revokeObjectURL(R.url);return[]})},[]);Ro(()=>()=>{for(let v of h.current)v.url&&URL.revokeObjectURL(v.url)},[]);let g=je(v=>{v.currentTarget.files&&L(v.currentTarget.files),v.currentTarget.value=""},[L]);Ro(()=>{if(!o)return;let v=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault()},R=A=>{A.dataTransfer?.types?.includes("Files")&&A.preventDefault(),A.dataTransfer?.files&&A.dataTransfer.files.length>0&&L(A.dataTransfer.files)};return document.addEventListener("dragover",v),document.addEventListener("drop",R),()=>{document.removeEventListener("dragover",v),document.removeEventListener("drop",R)}},[L,o]);let y=je(async v=>{v.preventDefault();let R=v.currentTarget,_=new FormData(R).get("message")||"";R.reset();let M=await Promise.all(p.map(async({id:T,...b})=>{if(b.url?.startsWith("blob:")){let B=await $d(b.url);return{...b,url:B??b.url}}return b}));try{let T=n({files:M,text:_},v);T instanceof Promise&&await T,C()}catch{}},[p,n,C]),P=Vd(()=>({add:L,clear:C,files:p,openFileDialog:I,remove:S}),[p,L,S,C,I]);return nn(en.Provider,{value:P,children:[Fe("input",{accept:t,"aria-label":u.promptInput.uploadFiles,className:"ww:hidden",multiple:a,onChange:g,ref:c,title:u.promptInput.uploadFiles,type:"file"}),Fe("form",{className:D("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 on=({onChange:e,onKeyDown:t,className:a,placeholder:o,...r})=>{let{t:s}=z(),n=tn(),[i,l]=Ys(!1),u=o??s.promptInput.placeholder,c=je(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===""&&n.files.length>0){p.preventDefault();let m=n.files.at(-1);m&&n.remove(m.id)}}},[t,i,n]),d=je(p=>{let m=p.clipboardData?.items;if(!m)return;let h=[];for(let I of m)if(I.kind==="file"){let L=I.getAsFile();L&&h.push(L)}h.length>0&&(p.preventDefault(),n.add(h))},[n]);return Fe("textarea",{className:D("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})},rn=({className:e,status:t,onStop:a,onClick:o,children:r,...s})=>{let{t:n}=z(),i=t==="submitted"||t==="streaming",l=Fe(Ut,{className:"ww:size-4"});t==="submitted"?l=Fe(jt,{className:"ww:size-4 ww:animate-spin"}):t==="streaming"&&(l=Fe(Vt,{className:"ww:size-4"}));let u=je(c=>{if(i&&a){c.preventDefault(),a();return}o?.(c)},[i,a,o]);return Fe(Ne,{"aria-label":i?n.promptInput.stop:n.promptInput.submit,className:D("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",...s,children:r??l})},sn=({className:e,children:t,...a})=>{let{t:o}=z(),r=tn();return r.files.length>0?nn(Ne,{className:D("ww:group ww:relative",e),onClick:()=>r.clear(),size:"icon-sm",type:"button",variant:"ghost","aria-label":o.promptInput.removeAttachments,...a,children:[Fe("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}),Fe(st,{className:"ww:absolute ww:size-4 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100"})]}):Fe(Ne,{className:D(e),onClick:()=>r.openFileDialog(),size:"icon-sm",type:"button",variant:"ghost",...a,children:t??Fe(zt,{className:"ww:size-4"})})};f();import{memo as Xd,useCallback as Kd}from"react";f();import{jsx as yt}from"react/jsx-runtime";var ln=({className:e,...t})=>yt("div",{className:D("ww:flex ww:flex-col ww:gap-1 ww:px-3 ww:py-2",e),...t}),un=({className:e,...t})=>yt("li",{className:D("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}),dn=({className:e,...t})=>yt("span",{className:D("ww:inline-block ww:size-2 ww:shrink-0 ww:rounded-full ww:border ww:border-muted-foreground/50",e),...t}),cn=({className:e,...t})=>yt("span",{className:D("ww:line-clamp-1 ww:grow ww:break-words ww:text-muted-foreground",e),...t}),fn=({className:e,...t})=>yt("div",{className:D("ww:flex ww:shrink-0 ww:gap-1 ww:opacity-0 ww:transition-opacity ww:group-hover:opacity-100",e),...t}),pn=({className:e,...t})=>yt(Ne,{className:D("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 Qe,jsxs as gn}from"react/jsx-runtime";var mn=Xd(({message:e,onRemove:t})=>{let{t:a}=z(),o=Kd(()=>t(e.id),[t,e.id]);return gn(un,{children:[Qe(dn,{}),Qe(cn,{children:e.text||a.chatQueue.attachmentFallback}),Qe(fn,{children:Qe(pn,{"aria-label":a.chatQueue.removeFromQueue,onClick:o,children:Qe(st,{className:"ww:size-3"})})})]})});mn.displayName="ChatQueueItem";function hn({queuedMessages:e,onRemove:t,className:a}){let{t:o}=z();return e.length===0?null:gn(ln,{className:D("ww:border-t ww:border-border",a),children:[Qe("div",{className:"ww:text-[11px] ww:font-medium ww:text-muted-foreground ww:px-2",children:o.chatQueue.queued(e.length)}),Qe("ul",{children:e.map(r=>Qe(mn,{message:r,onRemove:t},r.id))})]})}f();import{useState as wn}from"react";import{jsx as Qd}from"react/jsx-runtime";function xn({messages:e,evalEnabled:t,api:a="/api/waniwani"}){let{t:o}=z(),[r,s]=wn(!1),[n,i]=wn(null),l=async()=>{let c={name:`session-${new Date().toISOString().slice(0,19)}`,type:"functional",messages:e,mode:"manual"};s(!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{s(!1),setTimeout(()=>i(null),2e3)}};if(!t||e.length===0)return null;let u=r?o.exportSession.saving:n==="saved"?o.exportSession.saved:n==="error"?o.exportSession.error:o.exportSession.export;return Qd("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 Qt,jsxs as Zd}from"react/jsx-runtime";var Ln=({files:e,className:t,...a})=>e.length===0?null:Qt("div",{className:D("ww:flex ww:flex-wrap ww:gap-1.5",t),...a,children:e.map((o,r)=>Qt(Jd,{file:o},r))});function Jd({file:e}){let{t}=z();return e.mediaType?.startsWith("image/")&&e.url?Qt("img",{src:e.url,alt:e.filename??t.attachments.attachmentFallback,className:"ww:h-16 ww:max-w-32 ww:rounded ww:object-cover"}):Zd("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:[Qt(Gt,{className:"ww:size-3 ww:shrink-0"}),Qt("span",{className:"ww:max-w-24 ww:truncate",children:e.filename??t.attachments.fileFallback})]})}f();f();f();f();f();f();var ce={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 Ue={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 be={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 Cn(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 In(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function Sn(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 yn(e){return Cn(e)?"ambiguous":In(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":Sn(e)?"wide":"neutral"}function Yd(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function bn(e){return Yd(e),yn(e)}var ec=Object.defineProperty,tc=(e,t,a)=>t in e?ec(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ac=(e,t,a)=>tc(e,typeof t!="symbol"?t+"":t,a);function oc(e){return new RegExp("^\\p{Emoji_Presentation}","u").test(String.fromCodePoint(e))}function rc(e){if(!e||e<4352)return!1;switch(bn(e)){case"fullwidth":case"halfwidth":return!0;case"wide":return!oc(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 sc(e,t){return t!==65025||!e||e<8216?!1:e===8216||e===8217||e===8220||e===8221}function nc(e){return e!==null&&e>=65024&&e<=65038}var ic=kn(new RegExp("\\p{P}|\\p{S}","u")),lc=kn(/\s/);function kn(e){return t;function t(a){return a!==null&&a>-1&&e.test(String.fromCodePoint(a))}}var ke;(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})(ke||(ke={}));function Je(e){if(e===ce.eof||qr(e)||lc(e))return Ue.characterGroupWhitespace;let t=0;if(e>=4352){if(nc(e))return ke.nonEmojiGeneralUseVS;switch(rc(e)){case null:return ke.ivs;case!0:t|=ke.cjk;break}}return ic(e)&&(t|=Ue.characterGroupPunctuation),t}function ka(e,t,a){if(!dc(e))return e;let o=t(),r=Je(o);return!o||lt(r)?e:sc(o,a)?ke.cjkPunctuation:uc(r)}function uc(e){return e&~ke.ivs}function lt(e){return!!(e&Ue.characterGroupWhitespace)}function bt(e){return(e&ke.cjkPunctuation)===Ue.characterGroupPunctuation}function Jt(e){return!!(e&ke.cjk)}function Tn(e){return e===ke.ivs}function Pn(e){return!!(e&ke.cjkOrIvs)}function dc(e){return e===ke.nonEmojiGeneralUseVS}function Fo(e){return!!(e&ke.spaceOrPunctuation)}function Ta(e){return!!(e&&e>=55296&&e<=56319)}function Pa(e){return!!(e&&e>=56320&&e<=57343)}function va(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 cc(e,t,a){let o=e>=65536?2:1;if(t._bufferIndex<1+o)return null;let r=t._bufferIndex-o-2,s=a({start:{...t,_bufferIndex:r>=0?r:0},end:{...t,_bufferIndex:t._bufferIndex-o}}),n=s.charCodeAt(s.length-1);if(Number.isNaN(n))return null;if(s.length<2||n<56320||57343<n)return n;let i=s.codePointAt(0);return i&&i>=65536?i:n}var Aa=class{constructor(e,t,a){this.previousCode=e,this.nowPoint=t,this.sliceSerialize=a,ac(this,"cachedValue")}value(){return this.cachedValue===void 0&&(this.cachedValue=cc(this.previousCode,this.nowPoint,this.sliceSerialize)),this.cachedValue}};function Ra(e,t,a){let o=a({start:t,end:{...t,_bufferIndex:t._bufferIndex+2}}).codePointAt(0);return o&&o>=65536?o:e}var Do={name:"attention",resolveAll:fc,tokenize:pc};function fc(e,t){let a=-1,o,r,s,n,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};vn(d,-l),vn(p,l),n={type:l>1?be.strongSequence:be.emphasisSequence,start:d,end:{...e[o][1].end}},i={type:l>1?be.strongSequence:be.emphasisSequence,start:{...e[a][1].start},end:p},s={type:l>1?be.strongText:be.emphasisText,start:{...e[o][1].end},end:{...e[a][1].start}},r={type:l>1?be.strong:be.emphasis,start:{...n.start},end:{...i.end}},e[o][1].end={...n.start},e[a][1].start={...i.end},u=[],e[o][1].end.offset-e[o][1].start.offset&&(u=Lt(u,[["enter",e[o][1],t],["exit",e[o][1],t]])),u=Lt(u,[["enter",r,t],["enter",n,t],["exit",n,t],["enter",s,t]]),t.parser.constructs.insideSpan.null,u=Lt(u,ha(t.parser.constructs.insideSpan.null,e.slice(o+1,a),t)),u=Lt(u,[["exit",s,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[a][1].end.offset-e[a][1].start.offset?(c=2,u=Lt(u,[["enter",e[a][1],t],["exit",e[a][1],t]])):c=0,xt(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 pc(e,t){let a=this.parser.constructs.attentionMarkers.null,{now:o,sliceSerialize:r,previous:s}=this,n=Pa(s)?va(s,o(),r):s,i=Je(n),l=new Aa(n,o(),r),u=ka(i,l.value.bind(l),n),c;return d;function d(m){return m===ce.asterisk||ce.underscore,c=m,e.enter("attentionSequence"),p(m)}function p(m){if(m===c)return e.consume(m),p;let h=e.exit("attentionSequence"),I=Ta(m)?Ra(m,o(),r):m,L=Je(I);let S=bt(u),C=S||lt(u),g=bt(L),y=g||lt(L),P=Pn(u),v=!y||g&&(C||P)||a.includes(m),R=!C||S&&(y||Jt(L))||a.includes(n);return h._open=!!(c===ce.asterisk?v:v&&(Fo(u)||!R)),h._close=!!(c===ce.asterisk?R:R&&(Fo(L)||!v)),t(m)}}function vn(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}function An(){return{text:{[ce.asterisk]:Do,[ce.underscore]:Do},insideSpan:{null:[Do]}}}function Rn(){let e=this.data();(e.micromarkExtensions||(e.micromarkExtensions=[])).push(An())}f();f();function Mn(e){let a=(e||{}).singleTilde,o={name:"strikethrough",tokenize:s,resolveAll:r};return a==null&&(a=!0),{text:{[ce.tilde]:o},insideSpan:{null:[o]},attentionMarkers:{null:[ce.tilde]}};function r(n,i){let l=-1;for(;++l<n.length;)if(n[l][0]==="enter"&&n[l][1].type==="strikethroughSequenceTemporary"&&n[l][1]._close){let u=l;for(;u--;)if(n[u][0]==="exit"&&n[u][1].type==="strikethroughSequenceTemporary"&&n[u][1]._open&&n[l][1].end.offset-n[l][1].start.offset===n[u][1].end.offset-n[u][1].start.offset){n[l][1].type="strikethroughSequence",n[u][1].type="strikethroughSequence";let c={type:"strikethrough",start:Object.assign({},n[u][1].start),end:Object.assign({},n[l][1].end)},d={type:"strikethroughText",start:Object.assign({},n[u][1].end),end:Object.assign({},n[l][1].start)},p=[["enter",c,i],["enter",n[u][1],i],["exit",n[u][1],i],["enter",d,i]],m=i.parser.constructs.insideSpan.null;m&&xt(p,p.length,0,ha(m,n.slice(u+1,l),i)),xt(p,p.length,0,[["exit",d,i],["enter",n[l][1],i],["exit",n[l][1],i],["exit",c,i]]),xt(n,u-1,l-u+3,p),l=u+p.length-2;break}}for(l=-1;++l<n.length;)n[l][1].type==="strikethroughSequenceTemporary"&&(n[l][1].type=be.data);return n}function s(n,i,l){let{now:u,sliceSerialize:c,previous:d}=this,p=Pa(d)?va(d,u(),c):d,m=Je(p),h=new Aa(p,u(),c),I=ka(m,h.value.bind(h),p),L=this.events,S=0;return C;function C(y){return ce.tilde,p===ce.tilde&&L[L.length-1][1].type!==be.characterEscape?l(y):(n.enter("strikethroughSequenceTemporary"),g(y))}function g(y){let P=Je(p);if(y===ce.tilde)return S>1?l(y):(n.consume(y),S++,g);if(S<2&&!a)return l(y);let v=n.exit("strikethroughSequenceTemporary"),R=Ta(y)?Ra(y,u(),c):y,A=Je(R),M=bt(I)||lt(I),b=bt(A)||lt(A),B=Jt(I)||Tn(P);return v._open=!b||A===Ue.attentionSideAfter&&(M||B),v._close=!M||P===Ue.attentionSideAfter&&(b||Jt(A)),i(y)}}}function Fn(e){let t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(Mn(e))}var mc=new Set(["\u3002","\uFF0E","\uFF0C","\u3001","\uFF1F","\uFF01","\uFF1A","\uFF1B","\uFF08","\uFF09","\u3010","\u3011","\u300C","\u300D","\u300E","\u300F","\u3008","\u3009","\u300A","\u300B"]),hc=/^(https?:\/\/|mailto:|www\.)/i,gc=e=>{if(e.children.length!==1)return!1;let t=e.children[0];return t.type==="text"&&t.value===e.url},wc=e=>{let t=0;for(let a of e){if(mc.has(a))return t;t+=a.length}return null},xc=(e,t)=>({...t,url:e,children:[{type:"text",value:e}]}),Lc=e=>({type:"text",value:e}),Cc=()=>e=>{Wr(e,"link",(t,a,o)=>{if(!o||typeof a!="number"||!gc(t)||!hc.test(t.url))return;let r=wc(t.url);if(r===null||r===0)return;let s=t.url.slice(0,r),n=t.url.slice(r),i=xc(s,t),l=Lc(n);return o.children.splice(a,1,i,l),a+1})};function Ic(){let e=[Rn],t=[Cc,Fn],a=[...e,...t];return{name:"cjk",type:"cjk",remarkPluginsBefore:e,remarkPluginsAfter:t,remarkPlugins:a}}var Bo=Ic();f();f();f();f();f();var Y=class extends Error{constructor(t){super(t),this.name="ShikiError"}};f();function Sc(e){return jo(e)}function jo(e){return Array.isArray(e)?yc(e):e instanceof RegExp?e:typeof e=="object"?bc(e):e}function yc(e){let t=[];for(let a=0,o=e.length;a<o;a++)t[a]=jo(e[a]);return t}function bc(e){let t={};for(let a in e)t[a]=jo(e[a]);return t}function qn(e,...t){return t.forEach(a=>{for(let o in a)e[o]=a[o]}),e}function Wn(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?Wn(e.substring(0,e.length-1)):e.substr(~t+1)}var Eo=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ma=class{static hasCaptures(e){return e===null?!1:(Eo.lastIndex=0,Eo.test(e))}static replaceCaptures(e,t,a){return e.replace(Eo,(o,r,s,n)=>{let i=a[parseInt(r||s,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(n){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return o})}};function Gn(e,t){return e<t?-1:e>t?1:0}function jn(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 s=Gn(e[r],t[r]);if(s!==0)return s}return 0}return a-o}function Dn(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 zn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Vn=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}},ea=class{constructor(e,t,a){this._colorMap=e,this._defaults=t,this._root=a}static createFromRawTheme(e,t){return this.createFromParsedTheme(Pc(e),t)}static createFromParsedTheme(e,t){return Ac(e,t)}_cachedMatchRoot=new Vn(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=>kc(e.parent,r.parentScopes));return o?new $n(o.fontStyle,o.foreground,o.background):null}},_o=class Fa{constructor(t,a){this.parent=t,this.scopeName=a}static push(t,a){for(let o of a)t=new Fa(t,o);return t}static from(...t){let a=null;for(let o=0;o<t.length;o++)a=new Fa(a,t[o]);return a}push(t){return new Fa(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 kc(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&&!Tc(e.scopeName,o);){if(r)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Tc(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var $n=class{constructor(e,t,a){this.fontStyle=e,this.foregroundId=t,this.backgroundId=a}};function Pc(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,a=[],o=0;for(let r=0,s=t.length;r<s;r++){let n=t[r];if(!n.settings)continue;let i;if(typeof n.scope=="string"){let d=n.scope;d=d.replace(/^[,]+/,""),d=d.replace(/[,]+$/,""),i=d.split(",")}else Array.isArray(n.scope)?i=n.scope:i=[""];let l=-1;if(typeof n.settings.fontStyle=="string"){l=0;let d=n.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 n.settings.foreground=="string"&&Dn(n.settings.foreground)&&(u=n.settings.foreground);let c=null;typeof n.settings.background=="string"&&Dn(n.settings.background)&&(c=n.settings.background);for(let d=0,p=i.length;d<p;d++){let h=i[d].trim().split(" "),I=h[h.length-1],L=null;h.length>1&&(L=h.slice(0,h.length-1),L.reverse()),a[o++]=new vc(I,L,r,l,u,c)}}return a}var vc=class{constructor(e,t,a,o,r,s){this.scope=e,this.parentScopes=t,this.index=a,this.fontStyle=o,this.foreground=r,this.background=s}},fe=(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))(fe||{});function Ac(e,t){e.sort((l,u)=>{let c=Gn(l.scope,u.scope);return c!==0||(c=jn(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 s=new Rc(t),n=new $n(a,s.getId(o),s.getId(r)),i=new Fc(new Uo(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,s.getId(c.foreground),s.getId(c.background))}return new ea(s,n,i)}var Rc=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)}},Mc=Object.freeze([]),Uo=class Xn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,a,o,r,s){this.scopeDepth=t,this.parentScopes=a||Mc,this.fontStyle=o,this.foreground=r,this.background=s}clone(){return new Xn(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)}},Fc=class Oo{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 s=a.parentScopes[r].length-t.parentScopes[o].length;if(s!==0)return s;o++,r++}return a.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let o=t.indexOf("."),r,s;if(o===-1?(r=t,s=""):(r=t.substring(0,o),s=t.substring(o+1)),this._children.hasOwnProperty(r))return this._children[r].match(s)}let a=this._rulesWithParentScopes.concat(this._mainRule);return a.sort(Oo._cmpBySpecificity),a}insert(t,a,o,r,s,n){if(a===""){this._doInsertHere(t,o,r,s,n);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 Oo(this._mainRule.clone(),Uo.cloneArr(this._rulesWithParentScopes)),this._children[l]=c),c.insert(t+1,u,o,r,s,n)}_doInsertHere(t,a,o,r,s){if(a===null){this._mainRule.acceptOverwrite(t,o,r,s);return}for(let n=0,i=this._rulesWithParentScopes.length;n<i;n++){let l=this._rulesWithParentScopes[n];if(jn(l.parentScopes,a)===0){l.acceptOverwrite(t,o,r,s);return}}o===-1&&(o=this._mainRule.fontStyle),r===0&&(r=this._mainRule.foreground),s===0&&(s=this._mainRule.background),this._rulesWithParentScopes.push(new Uo(t,a,o,r,s))}},dt=class Ae{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let a=Ae.getLanguageId(t),o=Ae.getTokenType(t),r=Ae.getFontStyle(t),s=Ae.getForeground(t),n=Ae.getBackground(t);console.log({languageId:a,tokenType:o,fontStyle:r,foreground:s,background:n})}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,s,n,i){let l=Ae.getLanguageId(t),u=Ae.getTokenType(t),c=Ae.containsBalancedBrackets(t)?1:0,d=Ae.getFontStyle(t),p=Ae.getForeground(t),m=Ae.getBackground(t);return a!==0&&(l=a),o!==8&&(u=o),r!==null&&(c=r?1:0),s!==-1&&(d=s),n!==0&&(p=n),i!==0&&(m=i),(l<<0|u<<8|c<<10|d<<11|p<<15|m<<24)>>>0}};function Ba(e,t){let a=[],o=Dc(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=n();if(a.push({matcher:u,priority:l}),r!==",")break;r=o.next()}return a;function s(){if(r==="-"){r=o.next();let l=s();return u=>!!l&&!l(u)}if(r==="("){r=o.next();let l=i();return r===")"&&(r=o.next()),l}if(Bn(r)){let l=[];do l.push(r),r=o.next();while(Bn(r));return u=>t(l,u)}return null}function n(){let l=[],u=s();for(;u;)l.push(u),u=s();return c=>l.every(d=>d(c))}function i(){let l=[],u=n();for(;u&&(l.push(u),r==="|"||r===",");){do r=o.next();while(r==="|"||r===",");u=n()}return c=>l.some(d=>d(c))}}function Bn(e){return!!e&&!!e.match(/[\w\.:]+/)}function Dc(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 Kn(e){typeof e.dispose=="function"&&e.dispose()}var ta=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},Bc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ec=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))}},_c=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ta(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new Ec;for(let a of e)Nc(a,this.initialScopeName,this.repo,t);for(let a of t.references)if(a instanceof ta){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 Nc(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 s=a.lookup(t);e instanceof ta?Da({baseGrammar:s,selfGrammar:r},o):Ho(e.ruleName,{baseGrammar:s,selfGrammar:r,repository:r.repository},o);let n=a.injections(e.scopeName);if(n)for(let i of n)o.add(new ta(i))}function Ho(e,t,a){if(t.repository&&t.repository[e]){let o=t.repository[e];Ea([o],t,a)}}function Da(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ea(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ea(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ea(e,t,a){for(let o of e){if(a.visitedRule.has(o))continue;a.visitedRule.add(o);let r=o.repository?qn({},t.repository,o.repository):t.repository;Array.isArray(o.patterns)&&Ea(o.patterns,{...t,repository:r},a);let s=o.include;if(!s)continue;let n=Qn(s);switch(n.kind){case 0:Da({...t,selfGrammar:t.baseGrammar},a);break;case 1:Da(t,a);break;case 2:Ho(n.ruleName,{...t,repository:r},a);break;case 3:case 4:let i=n.scopeName===t.selfGrammar.scopeName?t.selfGrammar:n.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:r};n.kind===4?Ho(n.ruleName,l,a):Da(l,a)}else n.kind===4?a.add(new Bc(n.scopeName,n.ruleName)):a.add(new ta(n.scopeName));break}}}var Uc=class{kind=0},Oc=class{kind=1},Hc=class{constructor(e){this.ruleName=e}kind=2},qc=class{constructor(e){this.scopeName=e}kind=3},Wc=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function Qn(e){if(e==="$base")return new Uc;if(e==="$self")return new Oc;let t=e.indexOf("#");if(t===-1)return new qc(e);if(t===0)return new Hc(e.substring(1));{let a=e.substring(0,t),o=e.substring(t+1);return new Wc(a,o)}}var Gc=/\\(\d+)/,En=/\\(\d+)/g;var jc=-1,Jn=-2;var ra=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,a,o){this.$location=e,this.id=t,this._name=a||null,this._nameIsCapturing=Ma.hasCaptures(this._name),this._contentName=o||null,this._contentNameIsCapturing=Ma.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${Wn(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:Ma.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ma.replaceCaptures(this._contentName,e,t)}},zc=class extends ra{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!")}},Vc=class extends ra{_match;captures;_cachedCompiledPatterns;constructor(e,t,a,o,r){super(e,t,a,null),this._match=new aa(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 oa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},_n=class extends ra{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 oa,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},qo=class extends ra{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,a,o,r,s,n,i,l,u){super(e,t,a,o),this._begin=new aa(r,this.id),this.beginCaptures=s,this._end=new aa(n||"\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 oa;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}},_a=class extends ra{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,a,o,r,s,n,i,l){super(e,t,a,o),this._begin=new aa(r,this.id),this.beginCaptures=s,this.whileCaptures=i,this._while=new aa(n,Jn),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 oa;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 oa,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},Zn=class ge{static createCaptureRule(t,a,o,r,s){return t.registerRule(n=>new zc(a,n,o,r,s))}static getCompiledRuleId(t,a,o){return t.id||a.registerRule(r=>{if(t.id=r,t.match)return new Vc(t.$vscodeTextmateLocation,t.id,t.name,t.match,ge._compileCaptures(t.captures,a,o));if(typeof t.begin>"u"){t.repository&&(o=qn({},o,t.repository));let s=t.patterns;return typeof s>"u"&&t.include&&(s=[{include:t.include}]),new _n(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,ge._compilePatterns(s,a,o))}return t.while?new _a(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,ge._compileCaptures(t.beginCaptures||t.captures,a,o),t.while,ge._compileCaptures(t.whileCaptures||t.captures,a,o),ge._compilePatterns(t.patterns,a,o)):new qo(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,ge._compileCaptures(t.beginCaptures||t.captures,a,o),t.end,ge._compileCaptures(t.endCaptures||t.captures,a,o),t.applyEndPatternLast,ge._compilePatterns(t.patterns,a,o))}),t.id}static _compileCaptures(t,a,o){let r=[];if(t){let s=0;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10);i>s&&(s=i)}for(let n=0;n<=s;n++)r[n]=null;for(let n in t){if(n==="$vscodeTextmateLocation")continue;let i=parseInt(n,10),l=0;t[n].patterns&&(l=ge.getCompiledRuleId(t[n],a,o)),r[i]=ge.createCaptureRule(a,t[n].$vscodeTextmateLocation,t[n].name,t[n].contentName,l)}}return r}static _compilePatterns(t,a,o){let r=[];if(t)for(let s=0,n=t.length;s<n;s++){let i=t[s],l=-1;if(i.include){let u=Qn(i.include);switch(u.kind){case 0:case 1:l=ge.getCompiledRuleId(o[i.include],a,o);break;case 2:let c=o[u.ruleName];c&&(l=ge.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 h=m.repository[p];h&&(l=ge.getCompiledRuleId(h,a,m.repository))}else l=ge.getCompiledRuleId(m.repository.$self,a,m.repository);break}}else l=ge.getCompiledRuleId(i,a,o);if(l!==-1){let u=a.getRule(l),c=!1;if((u instanceof _n||u instanceof qo||u instanceof _a)&&u.hasMissingPatterns&&u.patterns.length===0&&(c=!0),c)continue;r.push(l)}}return{patterns:r,hasMissingPatterns:(t?t.length:0)!==r.length}}},aa=class Yn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,a){if(t&&typeof t=="string"){let o=t.length,r=0,s=[],n=!1;for(let i=0;i<o;i++)if(t.charAt(i)==="\\"&&i+1<o){let u=t.charAt(i+1);u==="z"?(s.push(t.substring(r,i)),s.push("$(?!\\n)(?<!\\n)"),r=i+2):(u==="A"||u==="G")&&(n=!0),i++}this.hasAnchor=n,r===0?this.source=t:(s.push(t.substring(r,o)),this.source=s.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=Gc.test(this.source):this.hasBackReferences=!1}clone(){return new Yn(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 En.lastIndex=0,this.source.replace(En,(r,s)=>zn(o[parseInt(s,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=[],s,n,i,l;for(s=0,n=this.source.length;s<n;s++)i=this.source.charAt(s),t[s]=i,a[s]=i,o[s]=i,r[s]=i,i==="\\"&&s+1<n&&(l=this.source.charAt(s+1),l==="A"?(t[s+1]="\uFFFF",a[s+1]="\uFFFF",o[s+1]="A",r[s+1]="A"):l==="G"?(t[s+1]="\uFFFF",a[s+1]="G",o[s+1]="\uFFFF",r[s+1]="G"):(t[s+1]=l,a[s+1]=l,o[s+1]=l,r[s+1]=l),s++);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}},oa=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 Nn(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 Nn(e,o,this._items.map(r=>r.ruleId))}},Nn=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}},No=class{constructor(e,t){this.languageId=e,this.tokenType=t}},$c=class Wo{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,a){this._defaultAttributes=new No(t,8),this._embeddedLanguagesMatcher=new Xc(Object.entries(a||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Wo._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new No(0,0);_getBasicScopeAttributes=new Vn(t=>{let a=this._scopeToLanguage(t),o=this._toStandardTokenType(t);return new No(a,o)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let a=t.match(Wo.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/},Xc=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])=>zn(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])}},vy={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},ei=!1,Un=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function ti(e,t,a,o,r,s,n,i){let l=t.content.length,u=!1,c=-1;if(n){let m=Kc(e,t,a,o,r,s);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 Un(r,!0);p()}return new Un(r,!1);function p(){let m=Qc(e,t,a,o,r,c);if(!m){s.produce(r,l),u=!0;return}let h=m.captureIndices,I=m.matchedRuleId,L=h&&h.length>0?h[0].end>o:!1;if(I===jc){let S=r.getRule(e);s.produce(r,h[0].start),r=r.withContentNameScopesList(r.nameScopesList),Zt(e,t,a,r,s,S.endCaptures,h),s.produce(r,h[0].end);let C=r;if(r=r.parent,c=C.getAnchorPos(),!L&&C.getEnterPos()===o){r=C,s.produce(r,l),u=!0;return}}else{let S=e.getRule(I);s.produce(r,h[0].start);let C=r,g=S.getName(t.content,h),y=r.contentNameScopesList.pushAttributed(g,e);if(r=r.push(I,o,c,h[0].end===l,null,y,y),S instanceof qo){let P=S;Zt(e,t,a,r,s,P.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let v=P.getContentName(t.content,h),R=y.pushAttributed(v,e);if(r=r.withContentNameScopesList(R),P.endHasBackReferences&&(r=r.withEndRule(P.getEndWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(S instanceof _a){let P=S;Zt(e,t,a,r,s,P.beginCaptures,h),s.produce(r,h[0].end),c=h[0].end;let v=P.getContentName(t.content,h),R=y.pushAttributed(v,e);if(r=r.withContentNameScopesList(R),P.whileHasBackReferences&&(r=r.withEndRule(P.getWhileWithResolvedBackReferences(t.content,h))),!L&&C.hasSameRuleAs(r)){r=r.pop(),s.produce(r,l),u=!0;return}}else if(Zt(e,t,a,r,s,S.captures,h),s.produce(r,h[0].end),r=r.pop(),!L){r=r.safePop(),s.produce(r,l),u=!0;return}}h[0].end>o&&(o=h[0].end,a=!1)}}function Kc(e,t,a,o,r,s){let n=r.beginRuleCapturedEOL?0:-1,i=[];for(let l=r;l;l=l.pop()){let u=l.getRule(e);u instanceof _a&&i.push({rule:u,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:u,findOptions:c}=Yc(l.rule,e,l.stack.endRule,a,o===n),d=u.findNextMatchSync(t,o,c);if(d){if(d.ruleId!==Jn){r=l.stack.pop();break}d.captureIndices&&d.captureIndices.length&&(s.produce(l.stack,d.captureIndices[0].start),Zt(e,t,a,l.stack,s,l.rule.whileCaptures,d.captureIndices),s.produce(l.stack,d.captureIndices[0].end),n=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:n,isFirstLine:a}}function Qc(e,t,a,o,r,s){let n=Jc(e,t,a,o,r,s),i=e.getInjections();if(i.length===0)return n;let l=Zc(i,e,t,a,o,r,s);if(!l)return n;if(!n)return l;let u=n.captureIndices[0].start,c=l.captureIndices[0].start;return c<u||l.priorityMatch&&c===u?l:n}function Jc(e,t,a,o,r,s){let n=r.getRule(e),{ruleScanner:i,findOptions:l}=ai(n,e,r.endRule,a,o===s),u=i.findNextMatchSync(t,o,l);return u?{captureIndices:u.captureIndices,matchedRuleId:u.ruleId}:null}function Zc(e,t,a,o,r,s,n){let i=Number.MAX_VALUE,l=null,u,c=0,d=s.contentNameScopesList.getScopeNames();for(let p=0,m=e.length;p<m;p++){let h=e[p];if(!h.matcher(d))continue;let I=t.getRule(h.ruleId),{ruleScanner:L,findOptions:S}=ai(I,t,null,o,r===n),C=L.findNextMatchSync(a,r,S);if(!C)continue;let g=C.captureIndices[0].start;if(!(g>=i)&&(i=g,l=C.captureIndices,u=C.ruleId,c=h.priority,i===r))break}return l?{priorityMatch:c===-1,captureIndices:l,matchedRuleId:u}:null}function ai(e,t,a,o,r){if(ei){let n=e.compile(t,a),i=oi(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileAG(t,a,o,r),findOptions:0}}function Yc(e,t,a,o,r){if(ei){let n=e.compileWhile(t,a),i=oi(o,r);return{ruleScanner:n,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,a,o,r),findOptions:0}}function oi(e,t){let a=0;return e||(a|=1),t||(a|=4),a}function Zt(e,t,a,o,r,s,n){if(s.length===0)return;let i=t.content,l=Math.min(s.length,n.length),u=[],c=n[0].end;for(let d=0;d<l;d++){let p=s[d];if(p===null)continue;let m=n[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,n),L=o.contentNameScopesList.pushAttributed(I,e),S=p.getContentName(i,n),C=L.pushAttributed(S,e),g=o.push(p.retokenizeCapturedWithRuleId,m.start,-1,!1,null,L,C),y=e.createOnigString(i.substring(0,m.end));ti(e,y,a&&m.start===0,m.start,g,r,!1,0),Kn(y);continue}let h=p.getName(i,n);if(h!==null){let L=(u.length>0?u[u.length-1].scopes:o.contentNameScopesList).pushAttributed(h,e);u.push(new ef(L,m.end))}}for(;u.length>0;)r.produceFromScopes(u[u.length-1].scopes,u[u.length-1].endPos),u.pop()}var ef=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function tf(e,t,a,o,r,s,n,i){return new of(e,t,a,o,r,s,n,i)}function On(e,t,a,o,r){let s=Ba(t,Na),n=Zn.getCompiledRuleId(a,o,r.repository);for(let i of s)e.push({debugSelector:t,matcher:i.matcher,ruleId:n,grammar:r,priority:i.priority})}function Na(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(af(t[r],o))return a=r+1,!0;return!1})}function af(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 of=class{constructor(e,t,a,o,r,s,n,i){if(this._rootScopeName=e,this.balancedBracketSelectors=s,this._onigLib=i,this._basicScopeAttributesProvider=new $c(a,o),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=n,this._grammar=Hn(t,null),this._injections=null,this._tokenTypeMatchers=[],r)for(let l of Object.keys(r)){let u=Ba(l,Na);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 n in r)On(t,n,r[n],this,o);let s=this._grammarRepository.injections(a);s&&s.forEach(n=>{let i=this.getExternalGrammar(n);if(i){let l=i.injectionSelector;l&&On(t,l,i,this,i)}})}return t.sort((r,s)=>r.priority-s.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]=Hn(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=Zn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let r;if(!t||t===Go.NULL){r=!0;let u=this._basicScopeAttributesProvider.getDefaultAttributes(),c=this.themeProvider.getDefaults(),d=dt.set(0,u.languageId,u.tokenType,null,c.fontStyle,c.foregroundId,c.backgroundId),p=this.getRule(this._rootId).getName(null,null),m;p?m=Yt.createRootAndLookUpScopeName(p,d,this):m=Yt.createRoot("unknown",d),t=new Go(null,this._rootId,-1,-1,!1,null,m,m)}else r=!1,t.reset();e=e+`
70
+ `;let s=this.createOnigString(e),n=s.content.length,i=new sf(a,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=ti(this,s,r,0,t,i,!0,o);return Kn(s),{lineLength:n,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function Hn(e,t){return e=Sc(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 Yt=class Oe{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 s of a)r=_o.push(r,s.scopeNames),o=new Oe(o,r,s.encodedTokenAttributes);return o}static createRoot(t,a){return new Oe(null,new _o(null,t),a)}static createRootAndLookUpScopeName(t,a,o){let r=o.getMetadataForScope(t),s=new _o(null,t),n=o.themeProvider.themeMatch(s),i=Oe.mergeAttributes(a,r,n);return new Oe(null,s,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Oe.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,s=0,n=0;return o!==null&&(r=o.fontStyle,s=o.foregroundId,n=o.backgroundId),dt.set(t,a.languageId,a.tokenType,null,r,s,n)}pushAttributed(t,a){if(t===null)return this;if(t.indexOf(" ")===-1)return Oe._pushAttributed(this,t,a);let o=t.split(/ /g),r=this;for(let s of o)r=Oe._pushAttributed(r,s,a);return r}static _pushAttributed(t,a,o){let r=o.getMetadataForScope(a),s=t.scopePath.push(a),n=o.themeProvider.themeMatch(s),i=Oe.mergeAttributes(t.tokenAttributes,r,n);return new Oe(t,s,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}},Go=class ut{constructor(t,a,o,r,s,n,i,l){this.parent=t,this.ruleId=a,this.beginRuleCapturedEOL=s,this.endRule=n,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 ut(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:ut._equals(this,t)}static _equals(t,a){return t===a?!0:this._structuralEquals(t,a)?Yt.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(){ut._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,a,o,r,s,n,i){return new ut(this,t,a,o,r,s,n,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 ut(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=Yt.fromExtension(t?.nameScopesList??null,a.nameScopesList);return new ut(t,a.ruleId,a.enterPos??-1,a.anchorPos??-1,a.beginRuleCapturedEOL,a.endRule,o,Yt.fromExtension(o,a.contentNameScopesList))}},rf=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(a=>a==="*"?(this.allowAny=!0,[]):Ba(a,Na).map(o=>o.matcher)),this.unbalancedBracketScopes=t.flatMap(a=>Ba(a,Na).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}},sf=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 s=e?.getScopeNames()??[];for(let n of this._tokenTypeOverrides)n.matcher(s)&&(o=dt.set(o,0,n.type,null,-1,0,0));this.balancedBracketSelectors&&(r=this.balancedBracketSelectors.match(s))}if(r&&(o=dt.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}},nf=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 s=this._rawGrammars.get(e);if(!s)return null;this._grammars.set(e,tf(e,s,t,a,o,r,this,this._onigLib))}return this._grammars.get(e)}},ri=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new nf(ea.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(ea.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 rf(a.balancedBracketSelectors||[],a.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,a,o,r){let s=new _c(this._syncRegistry,e);for(;s.Q.length>0;)s.Q.map(n=>this._loadSingleGrammar(n.scopeName)),s.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)}},Ua=Go.NULL;f();f();f();f();f();f();var lf=/["&'<>`]/g,uf=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,df=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,cf=/[|\\{}()[\]^$+*?.]/g,si=new WeakMap;function ni(e,t){if(e=e.replace(t.subset?ff(t.subset):lf,o),t.subset||t.escapeOnly)return e;return e.replace(uf,a).replace(df,o);function a(r,s,n){return t.format((r.charCodeAt(0)-55296)*1024+r.charCodeAt(1)-56320+65536,n.charCodeAt(s+2),t)}function o(r,s,n){return t.format(r.charCodeAt(0),n.charCodeAt(s+1),t)}}function ff(e){let t=si.get(e);return t||(t=pf(e),si.set(e,t)),t}function pf(e){let t=[],a=-1;for(;++a<e.length;)t.push(e[a].replace(cf,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}f();f();var mf=/[\dA-Fa-f]/;function ii(e,t,a){let o="&#x"+e.toString(16).toUpperCase();return a&&t&&!mf.test(String.fromCharCode(t))?o:o+";"}f();var hf=/\d/;function li(e,t,a){let o="&#"+String(e);return a&&t&&!hf.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 Oa={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 di=["cent","copy","divide","gt","lt","not","para","times"];var ci={}.hasOwnProperty,zo={},Ha;for(Ha in Oa)ci.call(Oa,Ha)&&(zo[Oa[Ha]]=Ha);var gf=/[^\dA-Za-z]/;function fi(e,t,a,o){let r=String.fromCharCode(e);if(ci.call(zo,r)){let s=zo[r],n="&"+s;return a&&ui.includes(s)&&!di.includes(s)&&(!o||t&&t!==61&&gf.test(String.fromCharCode(t)))?n:n+";"}return""}function pi(e,t,a){let o=ii(e,t,a.omitOptionalSemicolons),r;if((a.useNamedReferences||a.useShortestReferences)&&(r=fi(e,t,a.omitOptionalSemicolons,a.attribute)),(a.useShortestReferences||!r)&&a.useShortestReferences){let s=li(e,t,a.omitOptionalSemicolons);s.length<o.length&&(o=s)}return r&&(!a.useShortestReferences||r.length<o.length)?r:o}function ze(e,t){return ni(e,Object.assign({format:pi},t))}var wf=/^>|^->|<!--|-->|--!>|<!-$/g,xf=[">"],Lf=["<",">"];function mi(e,t,a,o){return o.settings.bogusComments?"<?"+ze(e.value,Object.assign({},o.settings.characterReferences,{subset:xf}))+">":"<!--"+e.value.replace(wf,r)+"-->";function r(s){return ze(s,Object.assign({},o.settings.characterReferences,{subset:Lf}))}}f();function hi(e,t,a,o){return"<!"+(o.settings.upperDoctype?"DOCTYPE":"doctype")+(o.settings.tightDoctype?"":" ")+"html>"}f();f();f();var oe=gi(1),Vo=gi(-1),Cf=[];function gi(e){return t;function t(a,o,r){let s=a?a.children:Cf,n=(o||0)+e,i=s[n];if(!r)for(;i&&Ct(i);)n+=e,i=s[n];return i}}f();var If={}.hasOwnProperty;function qa(e){return t;function t(a,o,r){return If.call(e,a.tagName)&&e[a.tagName](a,o,r)}}var sa=qa({body:yf,caption:$o,colgroup:$o,dd:Pf,dt:Tf,head:$o,html:Sf,li:kf,optgroup:vf,option:Af,p:bf,rp:wi,rt:wi,tbody:Mf,td:xi,tfoot:Ff,th:xi,thead:Rf,tr:Df});function $o(e,t,a){let o=oe(a,t,!0);return!o||o.type!=="comment"&&!(o.type==="text"&&Ct(o.value.charAt(0)))}function Sf(e,t,a){let o=oe(a,t);return!o||o.type!=="comment"}function yf(e,t,a){let o=oe(a,t);return!o||o.type!=="comment"}function bf(e,t,a){let o=oe(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 kf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="li"}function Tf(e,t,a){let o=oe(a,t);return!!(o&&o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd"))}function Pf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="dt"||o.tagName==="dd")}function wi(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="rp"||o.tagName==="rt")}function vf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="optgroup"}function Af(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="option"||o.tagName==="optgroup")}function Rf(e,t,a){let o=oe(a,t);return!!(o&&o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot"))}function Mf(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="tbody"||o.tagName==="tfoot")}function Ff(e,t,a){return!oe(a,t)}function Df(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&o.tagName==="tr"}function xi(e,t,a){let o=oe(a,t);return!o||o.type==="element"&&(o.tagName==="td"||o.tagName==="th")}f();var Li=qa({body:_f,colgroup:Nf,head:Ef,html:Bf,tbody:Uf});function Bf(e){let t=oe(e,-1);return!t||t.type!=="comment"}function Ef(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 _f(e){let t=oe(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&Ct(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Nf(e,t,a){let o=Vo(a,t),r=oe(e,-1,!0);return a&&o&&o.type==="element"&&o.tagName==="colgroup"&&sa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="col")}function Uf(e,t,a){let o=Vo(a,t),r=oe(e,-1);return a&&o&&o.type==="element"&&(o.tagName==="thead"||o.tagName==="tbody")&&sa(o,a.children.indexOf(o),a)?!1:!!(r&&r.type==="element"&&r.tagName==="tr")}var Wa={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 Er,b as _r,c as Nr,d as wt,e as xt,f as ma,g as Ur,h as Or,i as Hr,j
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 hi(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ha);let u=Mf(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!mi(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!n&&(!s||!ra(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function Mf(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=Ff(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function Ff(e,t,a){let o=Hr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=je(o.attribute,Object.assign({},e.settings.characterReferences,{subset:qa.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?Gr:jr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=je(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:qa.unquoted[r][s]}))),i!==a&&(e.settings.quoteSmart&&mo(a,n)>mo(a,e.alternative)&&(n=e.alternative),i=n+je(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?qa.single:qa.double)[r][s],attribute:!0}))+n),l+(i&&"="+i))}f();f();var Df=["<","&"];function Wa(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:je(e.value,Object.assign({},o.settings.characterReferences,{subset:Df}))}function gi(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Wa(e,t,a,o)}f();function wi(e,t,a,o){return o.all(e)}var xi=Wr("type",{invalid:Bf,unknown:Ef,handlers:{comment:ui,doctype:di,element:hi,raw:gi,root:wi,text:Wa}});function Bf(e){throw new Error("Expected node, not `"+e+"`")}function Ef(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var _f={},Nf={},Uf=[];function zo(e,t){let a=t||_f,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:Of,all:Hf,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||Or,characterReferences:a.characterReferences||Nf,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ha:qr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Of(e,t,a){return xi(e,t,a,this)}function Hf(e){let t=[],a=e&&e.children||Uf,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function Ga(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Je(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function qf(e){return Array.isArray(e)?e:[e]}async function ki(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Jo(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Ti(e){return e==="ansi"||Jo(e)}function Zo(e){return e==="none"}function Pi(e){return Zo(e)}function vi(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 Xa(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function Wf(e){let t=Xa(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let i of t){if(s<i.length)break;s-=i.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let i=0;i<r;i++)n+=t[i].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function Ai(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),i=n.includes("/")?n.split("/").pop():n;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var Yo="light-dark()",Gf=["color","background-color"];function jf(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 zf(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,i)=>n-i);return s.length?jf(r,s):r})):e}function Vf(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>ja(e.variants[c])),i=new Set(n.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 n.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&Gf.includes(p))if(o===Yo&&n.length>1){let h=t.findIndex(C=>C==="light"),S=t.findIndex(C=>C==="dark");if(h===-1||S===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",I=n[S][p]||"inherit";l[p]=`light-dark(${L}, ${I})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),s.htmlStyle=l,s}function ja(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&ce.Italic&&(t["font-style"]="italic"),e.fontStyle&ce.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&ce.Underline&&a.push("underline"),e.fontStyle&ce.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Xo(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var Ri=new WeakMap;function Ka(e,t){Ri.set(e,t)}function na(e){return Ri.get(e)}var bt=class e{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,a){return new e(Object.fromEntries(qf(a).map(o=>[o,Na])),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 $f(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function $f(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function Xf(e,t){if(!(e instanceof bt))throw new Z("Invalid grammar state");return e.getInternalStack(t)}function Kf(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new Z(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let i=r.lines[n.line];if(i===void 0)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let l=n.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new Z(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${i.length}`);return{...n,character:l,offset:r.posToIndex(n.line,l)}}},r=Wf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));Qf(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return zf(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 Z(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],S="",L=-1,I=-1;if(d===0&&(L=0),p===0&&(I=0),p===Number.POSITIVE_INFINITY&&(I=h.children.length),L===-1||I===-1)for(let g=0;g<h.children.length;g++)S+=Mi(h.children[g]),L===-1&&S.length===d&&(L=g+1),I===-1&&S.length===p&&(I=g+1);if(L===-1)throw new Z(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(I===-1)throw new Z(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,I);if(!m.alwaysWrap&&C.length===h.children.length)i(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")i(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};i(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},h=d.transform||(S=>S);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&vi(c,d.properties.class),c=h(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)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function Qf(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new Z(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||i||l){if(s&&n||i&&l||i&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new Z(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function Mi(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Mi).join(""):""}var Jf=[Kf()];function za(e){let t=Zf(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Jf]}function Zf(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 ct=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Vo={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Yf(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 Li(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 ep(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)Vo[o]&&t.push({type:"setDecoration",value:Vo[o]});else if(o<=29){let r=Vo[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:ct[o-30]}});else if(o===38){let r=Li(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:ct[o-40]}});else if(o===48){let r=Li(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:ct[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ct[o-100+8]}})}return t}function tp(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=Yf(o,s),i=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let l=ep(n.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var ap={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 op(e=ap){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<ct.length;u++)o.push(t(ct[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 s(i){return r()[i]}function n(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return s(i.index)}}return{value:n}}var rp={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 sp(e,t,a){let o=Ga(e,a),r=Xa(t),s=Object.fromEntries(ct.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||rp[l]]})),n=op(s),i=tp();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=Je(c,o),d=Je(d,o),u.decorations.has("dim")&&(c=np(c));let p=ce.None;return u.decorations.has("bold")&&(p|=ce.Bold),u.decorations.has("italic")&&(p|=ce.Italic),u.decorations.has("underline")&&(p|=ce.Underline),u.decorations.has("strikethrough")&&(p|=ce.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function np(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${l}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function er(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(Jo(r)||Zo(o))return Xa(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return sp(s,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new Z(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(s.name))throw new Z(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return lp(t,i,s,n,a)}function ip(...e){if(e.length===2)return na(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(Jo(r)||Zo(s))throw new Z("Plain language does not have grammar state");if(r==="ansi")throw new Z("ANSI language does not have grammar state");let{theme:n,colorMap:i}=t.setTheme(s),l=t.getLanguage(r);return new bt(tr(a,l,n,i,o).stateStack,l.name,n.name)}function lp(e,t,a,o,r){let s=tr(e,t,a,o,r),n=new bt(s.stateStack,t.name,a.name);return Ka(s.tokens,n),s.tokens}function tr(e,t,a,o,r){let s=Ga(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:i=500}=r,l=Xa(e),u=r.grammarState?Xf(r.grammarState,a.name)??Na:r.grammarContextCode!=null?tr(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Na,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[h,S]=l[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:S,color:"",fontStyle:0}]);continue}let L,I,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,i),I=L.tokens,C=0);let g=t.tokenizeLine2(h,u,i),y=g.tokens.length/2;for(let k=0;k<y;k++){let v=g.tokens[2*k],A=k+1<y?g.tokens[2*k+2]:h.length;if(v===A)continue;let M=g.tokens[2*k+1],_=Je(o[dt.getForeground(M)],s),R=dt.getFontStyle(M),P={content:h.substring(v,A),offset:S+v,color:_,fontStyle:R};if(r.includeExplanation){let b=[];if(r.includeExplanation!=="scopeName")for(let O of a.settings){let F;switch(typeof O.scope){case"string":F=O.scope.split(/,/).map(Q=>Q.trim());break;case"object":F=O.scope;break;default:continue}b.push({settings:O,selectors:F.map(Q=>Q.split(/ /))})}P.explanation=[];let E=0;for(;v+E<A;){let O=I[C],F=h.substring(O.startIndex,O.endIndex);E+=F.length,P.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?up(O.scopes):dp(b,O.scopes)}),C+=1}}c.push(P)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function up(e){return e.map(t=>({scopeName:t}))}function dp(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:fp(e,s,t.slice(0,o))}}return a}function Ci(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function cp(e,t,a){if(!Ci(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)Ci(e[o],a[r])&&(o-=1),r-=1;return o===-1}function fp(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(cp(n,t,a)){o.push(s);break}return o}function Fi(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=er(e,t,{...a,theme:l.theme}),c=na(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),s=pp(...r.map(l=>l.tokens)),n=s[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),s.forEach((m,h)=>{let{content:S,explanation:L,offset:I,...C}=m[u][d];p.variants[o[h].color]=C}),p})),i=r[0].state?new bt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&Ka(n,i),n}function pp(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));let n=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(s[u].push(c),n[u]+=1,i[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function Va(e,t,a){let o,r,s,n,i,l;if("themes"in a){let{defaultColor:u="light",cssVariablePrefix:c="--shiki-",colorsRendering:d="css-vars"}=a,p=Object.entries(a.themes).filter(I=>I[1]).map(I=>({color:I[0],theme:I[1]})).sort((I,C)=>I.color===u?-1:C.color===u?1:0);if(p.length===0)throw new Z("`themes` option must not be empty");let m=Fi(e,t,a);if(l=na(m),u&&Yo!==u&&!p.find(I=>I.color===u))throw new Z(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(I=>e.getTheme(I.theme)),S=p.map(I=>I.color);s=m.map(I=>I.map(C=>Vf(C,S,c,u,d))),l&&Ka(s,l);let L=p.map(I=>Ga(I.theme,a));r=Ii(p,h,L,c,u,"fg",d),o=Ii(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(I=>I.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=Ga(a.theme,a);s=er(e,t,a);let c=e.getTheme(a.theme);o=Je(c.bg,u),r=Je(c.fg,u),n=c.name,l=na(s)}else throw new Z("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:i,grammarState:l}}function Ii(e,t,a,o,r,s,n){return e.map((i,l)=>{let u=Je(t[l][s],a[l])||"inherit",c=`${o+i.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===Yo&&e.length>1){let d=e.findIndex(S=>S.color==="light"),p=e.findIndex(S=>S.color==="dark");if(d===-1||p===-1)throw new Z('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=Je(t[d][s],a[d])||"inherit",h=Je(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(i=>!!i).join(";")}function $a(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>$a(e,r,s),codeToTokens:(r,s)=>Va(e,r,s)}){let r=t;for(let h of za(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:i,themeName:l,rootStyle:u,grammarState:c}=Va(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=hp(s):d==="never"&&(s=gp(s)),p&&(s=wp(s));let m={...o,get source(){return r}};for(let h of za(a))s=h.tokens?.call(m,s)||s;return mp(s,{...a,fg:n,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function mp(e,t,a,o=na(e)){let r=za(t),s=[],n={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[S,L]of Object.entries(t.meta||{}))S.startsWith("_")||(u[S]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:i,addClassToHast:vi,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((S,L)=>{L&&(i==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&s.push({type:"text",value:`
79
- `}));let I={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of S){let y={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},k=Xo(g.htmlStyle||ja(g));k&&(y.properties.style=k);for(let v of r)y=v?.span?.call(m,y,L+1,C,I,g)||y;i==="inline"?n.children.push(y):i==="classic"&&I.children.push(y),C+=g.content.length}if(i==="classic"){for(let g of r)I=g?.line?.call(m,I,L+1)||I;p.push(I),s.push(I)}else i==="inline"&&p.push(I)}),i==="classic"){for(let S of r)d=S?.code?.call(m,d)||d;c.children.push(d);for(let S of r)c=S?.pre?.call(m,c)||c;n.children.push(c)}else if(i==="inline"){let S=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(S.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);S.push(L);let C={type:"element",tagName:"code",properties:{},children:S};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[g];y.type==="element"&&n.children.push(...y.children)}}let h=n;for(let S of r)h=S?.root?.call(m,h)||h;return o&&Ka(h,o),h}function hp(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&ce.Underline||s.fontStyle&ce.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function gp(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function wp(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=Xo(r.htmlStyle||ja(r)),n=Xo(o.htmlStyle||ja(o)),i=r.fontStyle&&(r.fontStyle&ce.Underline||r.fontStyle&ce.Strikethrough),l=o.fontStyle&&(o.fontStyle&ce.Underline||o.fontStyle&ce.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var xp=zo;function Lp(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>$a(e,s,n),codeToTokens:(s,n)=>Va(e,s,n)},r=xp($a(e,t,a,o));for(let s of za(a))r=s.postprocess?.call(o,r,a)||r;return r}var Si={light:"#333333",dark:"#bbbbbb"},yi={light:"#fffffe",dark:"#1e1e1e"},bi="__shiki_resolved";function ar(e){if(e?.[bi])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"?Si.light:Si.dark),a||(a=t.type==="light"?yi.light:yi.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,bi,{enumerable:!1,writable:!1,value:!0}),t}async function Di(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Ti(t)).map(async t=>await ki(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Bi(e){return(await Promise.all(e.map(async a=>Pi(a)?null:ar(await ki(a))))).filter(a=>!!a)}var $o=3,Cp=!1;function Ip(e,t=3){if($o&&!(typeof $o=="number"&&t>$o)){if(Cp)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Qe=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ei(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new Qe(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var Ko=class extends Yn{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=ar(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=Yt.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Ei(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(s=>!o.includes(s));throw new Qe(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},Qo=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},sa=0;function Sp(e){sa+=1,e.warnings!==!1&&sa>=10&&sa%10===0&&console.warn(`[Shiki] ${sa} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Qe("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(ar),r=new Qo(e.engine,a),s=new Ko(r,o,a,e.langAlias),n;function i(g){return Ei(g,e.langAlias)}function l(g){I();let y=s.getGrammar(typeof g=="string"?g:g.name);if(!y)throw new Qe(`Language \`${g}\` not found, you may need to load it first`);return y}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};I();let y=s.getTheme(g);if(!y)throw new Qe(`Theme \`${g}\` not found, you may need to load it first`);return y}function c(g){I();let y=u(g);n!==g&&(s.setTheme(y),n=g);let k=s.getColorMap();return{theme:y,colorMap:k}}function d(){return I(),s.getLoadedThemes()}function p(){return I(),s.getLoadedLanguages()}function m(...g){I(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await Di(g))}function S(...g){I();for(let y of g.flat(1))s.loadTheme(y)}async function L(...g){return I(),S(await Bi(g))}function I(){if(t)throw new Qe("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),sa-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:S,dispose:C,[Symbol.dispose]:C}}async function yp(e){e.engine||Ip("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Bi(e.themes||[]),Di(e.langs||[]),e.engine]);return Sp({...e,themes:t,langs:a,engine:o})}async function bp(e){let t=await yp(e);return{getLastGrammarState:(...a)=>ip(t,...a),codeToTokensBase:(a,o)=>er(t,a,o),codeToTokensWithThemes:(a,o)=>Fi(t,a,o),codeToTokens:(a,o)=>Va(t,a,o),codeToHast:(a,o)=>$a(t,a,o),codeToHtml:(a,o)=>Lp(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function _i(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,Ti(d))return[];let p=t[d];if(!p)throw new Z(`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(Pi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Z(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),c=await bp({engine:s.engine??o(),...s,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function kp(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 Ni(e,t){let a=kp(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var or=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Ui=Object.fromEntries(or.map(e=>[e.id,e.import])),Oi=Object.fromEntries(or.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),ia={...Ui,...Oi};f();var Tp=[{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"))}],Hi=Object.fromEntries(Tp.map(e=>[e.id,e.import]));f();var la=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Pp(){return 2147483648}function vp(){return typeof performance<"u"?performance.now():Date.now()}var Ap=(e,t)=>e+(t-e%t)%t;async function Rp(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,S){o.HEAPU8.copyWithin(m,h,h+S)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let h=o.HEAPU8.length;m=m>>>0;let S=Pp();if(m>S)return!1;for(let L=1;L<=4;L*=2){let I=h*(1+.2/L);I=Math.min(I,m+100663296);let C=Math.min(S,Ap(Math.max(m,I),65536));if(n(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,S=1024){let L=h+S,I=h;for(;m[I]&&!(I>=L);)++I;if(I-h>16&&m.buffer&&l)return l.decode(m.subarray(h,I));let C="";for(;h<I;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let y=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|y);continue}let k=m[h++]&63;if((g&240)===224?g=(g&15)<<12|y<<6|k:g=(g&7)<<18|y<<12|k<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let v=g-65536;C+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:vp,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var Mp=Object.defineProperty,Fp=(e,t,a)=>t in e?Mp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,se=(e,t,a)=>Fp(e,typeof t!="symbol"?t+"":t,a),le=null;function Dp(e){throw new la(e.UTF8ToString(e.getLastOnigError()))}var Ja=class e{constructor(t){se(this,"utf16Length"),se(this,"utf8Length"),se(this,"utf16Value"),se(this,"utf8Value"),se(this,"utf16OffsetToUtf8"),se(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=l,p&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},Za=class Oe{constructor(t){if(se(this,"id",++Oe.LAST_ID),se(this,"_onigBinding"),se(this,"content"),se(this,"utf16Length"),se(this,"utf8Length"),se(this,"utf16OffsetToUtf8"),se(this,"utf8OffsetToUtf16"),se(this,"ptr"),!le)throw new la("Must invoke loadWasm first.");this._onigBinding=le,this.content=t;let a=new Ja(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!Oe._sharedPtrInUse?(Oe._sharedPtr||(Oe._sharedPtr=le.omalloc(1e4)),Oe._sharedPtrInUse=!0,le.HEAPU8.set(a.utf8Value,Oe._sharedPtr),this.ptr=Oe._sharedPtr):this.ptr=a.createString(le)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Oe._sharedPtr?Oe._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};se(Za,"LAST_ID",0);se(Za,"_sharedPtr",0);se(Za,"_sharedPtrInUse",!1);var qi=Za,sr=class{constructor(t){if(se(this,"_onigBinding"),se(this,"_ptr"),!le)throw new la("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Ja(t[i]);a[i]=u.createString(le),o[i]=u.utf8Length}let r=le.omalloc(4*t.length);le.HEAPU32.set(a,r/4);let s=le.omalloc(4*t.length);le.HEAPU32.set(o,s/4);let n=le.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)le.ofree(a[i]);le.ofree(s),le.ofree(r),n===0&&Dp(le),this._onigBinding=le,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new qi(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let i=s.HEAPU32,l=n/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Bp(e){return typeof e.instantiator=="function"}function Ep(e){return typeof e.default=="function"}function _p(e){return typeof e.data<"u"}function Np(e){return typeof Response<"u"&&e instanceof Response}function Up(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 Qa;function Op(e){if(Qa)return Qa;async function t(){le=await Rp(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Bp(o)?o=await o.instantiator(a):Ep(o)?o=await o.default(a):(_p(o)&&(o=o.data),Np(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Hp(o)(a):o=await qp(o)(a):Up(o)?o=await rr(o)(a):o instanceof WebAssembly.Module?o=await rr(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await rr(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return Qa=t(),Qa}function rr(e){return t=>WebAssembly.instantiate(e,t)}function Hp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function qp(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function Wi(e){return e&&await Op(e),{createScanner(t){return new sr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new qi(t)}}}var Ya=_i({langs:ia,themes:Hi,engine:()=>Wi(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Wp,codeToHast:Gp,codeToTokens:jp,codeToTokensBase:zp,codeToTokensWithThemes:Vp,getSingletonHighlighter:$p,getLastGrammarState:Xp}=Ni(Ya,{guessEmbeddedLanguages:Ai});var Gi=new Set(Object.keys(ia)),nr=new Map,ir=new Map,kt=new Map,Kp=(e,t)=>`${e}-${t[0]}-${t[1]}`,Qp=(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}`},Jp=(e,t)=>{let a=Kp(e,t);if(nr.has(a))return nr.get(a);let o=Ya({themes:t,langs:[e]});return nr.set(a,o),o};function Zp(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Gi.has(o)},getSupportedLanguages(){return Array.from(Gi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=Qp(o,r,s);return ir.has(i)?ir.get(i):(n&&(kt.has(i)||kt.set(i,new Set),kt.get(i).add(n)),Jp(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});ir.set(i,c);let d=kt.get(i);if(d){for(let p of d)p(c);kt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),kt.delete(i)}),null)}}}var ji=Zp();import{memo as am}from"react";f();f();import{useEffect as Yp,useRef as eo,useState as em}from"react";var tm=5,zi=400;function Vi(e,t,a={}){let{msPerChar:o=tm}=a,[r,s]=em(t?"":e),n=eo(e),i=eo(t?0:e.length),l=eo(0),u=eo(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),n.current=e,Yp(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,s(e);return}if(n.current.length-i.current>zi&&(i.current=n.current.length-zi),u.current!==null)return;let d=p=>{let m=n.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let h=p-l.current;if(h>=o){let S=Math.min(Math.floor(h/o),m.length-i.current);i.current+=S,s(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as to}from"react/jsx-runtime";var lr=({className:e,from:t,children:a,...o})=>to("div",{className:D("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:to("div",{className:D("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),ur=({children:e,className:t,...a})=>to("div",{className:D("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),om={cjk:Mo,code:ji},rm={cjk:Mo},sm={enabled:!1};function nm({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let n=Vi(typeof o=="string"?o:"",!!a),i=typeof o=="string"?n:o;return to(Pt,{className:D("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??sm,plugins:a?rm:om,...r,children:i})}var ao=am(nm,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);ao.displayName="MessageResponse";f();import{createContext as dm,memo as fr,useCallback as cm,useContext as fm,useEffect as dr,useMemo as pm,useRef as $i,useState as cr}from"react";f();import{memo as im}from"react";import{jsx as um}from"react/jsx-runtime";var lm=({as:e="span",className:t,duration:a=2,style:o,children:r,...s})=>{let n={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...o};return um(e,{"data-waniwani-shimmer":"",className:D("ww:inline-block",t),style:n,...s,children:r})},Ze=im(lm);Ze.displayName="Shimmer";import{Fragment as wm,jsx as Me,jsxs as Qi}from"react/jsx-runtime";var Xi=dm(null);function Ki(){let e=fm(Xi);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var mm=1e3,hm=1e3,pr=fr(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:s,children:n,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=cr(l),m=c?a:d,h=cm(A=>{c||p(A),r?.(A)},[c,r]),[S,L]=cr(void 0),I=s??S,C=$i(t),[g,y]=cr(!1),k=$i(null);dr(()=>{t?(C.current=!0,k.current===null&&(k.current=Date.now())):k.current!==null&&(L(Math.ceil((Date.now()-k.current)/hm)),k.current=null)},[t]),dr(()=>{t&&!m&&!u&&h(!0)},[t,m,u,h]),dr(()=>{if(C.current&&!t&&m&&!g){let A=setTimeout(()=>{h(!1),y(!0)},mm);return()=>clearTimeout(A)}},[t,m,g,h]);let v=pm(()=>({isStreaming:t,isOpen:m,setIsOpen:h,duration:I}),[t,m,h,I]);return Me(Xi.Provider,{value:v,children:Me("div",{className:D("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":m?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:n})})});pr.displayName="Reasoning";var gm=(e,t)=>e||t===0?Me(Ze,{duration:1.6,children:"Thinking\u2026"}):t===void 0?Me("span",{children:"Thought for a few seconds"}):Qi("span",{children:["Thought for ",t," second",t===1?"":"s"]}),mr=fr(({className:e,children:t,getThinkingMessage:a=gm,onClick:o,...r})=>{let{isStreaming:s,isOpen:n,duration:i,setIsOpen:l}=Ki();return Me("button",{type:"button","aria-expanded":n,onClick:u=>{l(!n),o?.(u)},className:D("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...r,children:t??Qi(wm,{children:[Me(Ut,{className:"ww:size-4 ww:shrink-0"}),a(s,i),Me(ot,{className:D("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",n&&"ww:rotate-180")})]})})});mr.displayName="ReasoningTrigger";var hr=fr(({className:e,children:t,...a})=>{let{isOpen:o}=Ki();return Me("div",{className:D("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:Me("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Me("div",{className:D("ww:text-sm ww:text-muted-foreground",e),...a,children:Me(Pt,{children:t})})})})});hr.displayName="ReasoningContent";f();import{createContext as xm,useCallback as Lm,useContext as el,useEffect as Cm,useMemo as wr,useRef as Im,useState as xr}from"react";import{Fragment as Yi,jsx as z,jsxs as Ye}from"react/jsx-runtime";function Sm(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function ym({text:e,className:t}){let[a,o]=xr(!1),r=Im(null);Cm(()=>()=>{r.current&&clearTimeout(r.current)},[]);let s=Lm(async n=>{n.stopPropagation();try{await navigator.clipboard.writeText(e),o(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>o(!1),2e3)}catch{}},[e]);return z(_e,{variant:"ghost",size:"sm",onClick:s,className:D("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:a?Ye(Yi,{children:[z(Ot,{className:"ww:size-3.5"}),z("span",{children:"Copied"})]}):Ye(Yi,{children:[z(qt,{className:"ww:size-3.5"}),z("span",{children:"Copy"})]})})}function tl({data:e,label:t,className:a,...o}){let[r,s]=xr(!1),n=wr(()=>JSON.stringify(e,null,2),[e]),i=Sm(e);return Ye("div",{className:D("ww:rounded-lg ww:bg-tool-card",a),...o,children:[Ye("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[z("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),z(ym,{text:n})]}),Ye("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[z(Ht,{className:D("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?z("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:z("code",{children:n})}):z("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Lr=xm({open:!1,toggle:()=>{}});function al({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=xr(t);return z(Lr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:z("div",{className:D("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 ol({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=el(Lr),n=a==="input-available"||a==="input-streaming",i=t??"";return Ye("button",{type:"button",onClick:s,className:D("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:[z(We,{className:"ww:size-4 ww:shrink-0"}),z("span",{className:"ww:truncate",children:n?z(Ze,{duration:1.6,children:i}):i}),z(ot,{className:D("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function rl({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",s=t??"";return Ye("div",{className:D("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:[z(We,{className:"ww:size-4 ww:shrink-0"}),z("span",{className:"ww:truncate",children:r?z(Ze,{duration:1.6,children:s}):s})]})}function sl({className:e,children:t,...a}){let{open:o}=el(Lr);return z("div",{className:D("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:D("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 nl({className:e,input:t,debug:a,...o}){let r=wr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:s,...n}=t;return n}return t},[t,a]);return z(tl,{data:r,label:"Request",className:e,...o})}function gr(e){if(!(typeof e!="object"||e===null))return e}function il(e){return gr(e?.ui)}function ll(e){return gr(gr(e)?._meta)}function Ji(e){if(!e)return;let t=il(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 Zi(e){return il(e)?.autoHeight===!0}function oo(e,t,a){if(e){let o=Ji(a?.[e]?._meta);if(o)return o}return Ji(ll(t))}function ul(e,t,a){return e&&Zi(a?.[e]?._meta)?!0:Zi(ll(t))}function dl({className:e,output:t,errorText:a,debug:o,...r}){let s=wr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,o]);return t||a?a?Ye("div",{className:D("ww:space-y-2",e),...r,children:[z("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:"Error"}),z("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):z(tl,{data:s,label:"Response",className:e,...r}):null}f();import{jsx as cl,jsxs as km}from"react/jsx-runtime";function bm(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function Cr(e){return e.parts.some(bm)}function fl(e,t){if(t!=="submitted"&&t!=="streaming")return!1;let a=e[e.length-1];return!a||a.role!=="assistant"?!0:!Cr(a)}function pl({className:e,...t}){return km("div",{"aria-live":"polite",className:D("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:[cl(Vt,{className:"ww:size-4 ww:shrink-0"}),cl(Ze,{duration:1.6,children:"On it\u2026"})]})}f();import{useCallback as Tm,useEffect as ml,useMemo as Pm,useRef as xe,useState as hl}from"react";import{jsx as Um}from"react/jsx-runtime";var vm="/api/mcp/resource",Am=500,Rm=0,Mm=16,Fm="2026-01-26",Dm=300,Bm=3e3,Em=3;function _m(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Nm(e,t,a){return oo(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function gl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=vm,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=xe(null),S=xe(t),L=xe(a),I=xe({width:0,height:0}),C=xe(null),g=xe(!1),y=xe(0),k=xe("inline"),[v,A]=hl(Rm),[M,_]=hl(void 0),R=xe(l),P=xe(u),b=xe(c),E=xe(d),O=xe(r),F=xe(m);S.current=t,L.current=a,R.current=l,P.current=u,b.current=c,E.current=d,O.current=r,F.current=m;let Q=Tm(te=>i?Math.max(te+Mm,0):Math.min(Math.max(te,50),Am),[i]),De=Pm(()=>{let te=o.includes("?")?"&":"?";return`${o}${te}uri=${encodeURIComponent(e)}`},[o,e]),Le=xe(s);return Le.current=s,ml(()=>{if(!g.current)return;let te=h.current;te?.contentWindow&&te.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),ml(()=>{let te=h.current;if(!te)return;let me=!1,Se=!1,ge=null,Ce=null,ze=setTimeout(()=>{if(me||Se||y.current>=Em)return;y.current+=1;let Y=new URL(te.src);Y.searchParams.set("_retry",String(y.current)),te.src=Y.toString()},Bm),N=Y=>{te.contentWindow?.postMessage(Y,"*")},ie=Y=>{if(me||Y.source!==te.contentWindow)return;let X=Y.data;if(!X||typeof X!="object"||X.jsonrpc!=="2.0")return;let oe=X.method,W=X.id;if(oe==="ui/initialize"&&W!=null){Se=!0,clearTimeout(ze),N({jsonrpc:"2.0",id:W,result:{protocolVersion:X.params?.protocolVersion??Fm,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Le.current?"dark":"light",displayMode:k.current}}});return}if(oe==="ui/notifications/initialized"){g.current=!0;let V=S.current,K=L.current,q=K._meta&&typeof K._meta=="object"?K._meta:null,J=_m(O.current),re=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,Te=re||J?{...re??{},...J?{sessionId:J}:{}}:void 0,Ve=q||Te?{...q??{},...Te?{waniwani:Te}:{}}:void 0;N({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:V}});let mt=K.content??[{type:"text",text:JSON.stringify(K)}];N({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:mt,structuredContent:K.structuredContent,_meta:Ve,meta:Ve}});return}if(oe==="ui/notifications/size-changed"){let V=X.params,K=typeof V?.height=="number"?V.height:void 0,q=typeof V?.width=="number"?V.width:void 0,J=I.current,re=K!==void 0&&K!==J.height,Te=q!==void 0&&q!==J.width;if(!re&&!Te)return;if(re&&K!==void 0){J.height=K;let Ve=Q(K),mt=te.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),A(Ve),te.animate&&Math.abs(mt-Ve)>2){let ht=te.animate([{height:`${mt}px`},{height:`${Ve}px`}],{duration:Dm,easing:"ease-out",fill:"forwards"});C.current=ht,ht.onfinish=()=>{C.current===ht&&(ht.cancel(),C.current=null)}}}Te&&i&&q!==void 0&&(J.width=q,_(q));return}if(oe==="ui/open-link"&&W!=null){let V=X.params?.url;typeof V=="string"&&(R.current?R.current(V):window.open(V,"_blank","noopener,noreferrer")),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/message"&&W!=null){if(P.current&&X.params){let V=X.params,K=ge;if(ge=null,Ce){clearTimeout(Ce.timer);let q=Ce.text;Ce=null;let J=(V.content??[]).map(re=>re.text??"").join("").trim();V={...V,content:[{type:"text",text:`${J}
78
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Ci(e,t,a,o){let r=o.schema,s=r.space==="svg"?!1:o.settings.omitOptionalTags,n=r.space==="svg"?o.settings.closeEmptyElements:o.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;r.space==="html"&&e.tagName==="svg"&&(o.schema=ga);let u=Of(o,e.properties),c=o.all(r.space==="html"&&e.tagName==="template"?e.content:e);return o.schema=r,c&&(n=!1),(u||!s||!Li(e,t,a))&&(i.push("<",e.tagName,u?" "+u:""),n&&(r.space==="svg"||o.settings.closeSelfClosing)&&(l=u.charAt(u.length-1),(!o.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(c),!n&&(!s||!sa(e,t,a))&&i.push("</"+e.tagName+">"),i.join("")}function Of(e,t){let a=[],o=-1,r;if(t){for(r in t)if(t[r]!==null&&t[r]!==void 0){let s=Hf(e,r,t[r]);s&&a.push(s)}}for(;++o<a.length;){let s=e.settings.tightAttributes?a[o].charAt(a[o].length-1):void 0;o!==a.length-1&&s!=='"'&&s!=="'"&&(a[o]+=" ")}return a.join("")}function Hf(e,t,a){let o=jr(e.schema,t),r=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,s=e.settings.allowDangerousCharacters?0:1,n=e.quote,i;if(o.overloadedBoolean&&(a===o.attribute||a==="")?a=!0:(o.boolean||o.overloadedBoolean)&&(typeof a!="string"||a===o.attribute||a==="")&&(a=!!a),a==null||a===!1||typeof a=="number"&&Number.isNaN(a))return"";let l=ze(o.attribute,Object.assign({},e.settings.characterReferences,{subset:Wa.name[r][s]}));return a===!0||(a=Array.isArray(a)?(o.commaSeparated?$r:Xr)(a,{padLeft:!e.settings.tightCommaSeparatedLists}):String(a),e.settings.collapseEmptyAttributes&&!a)?l:(e.settings.preferUnquoted&&(i=ze(a,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Wa.unquoted[r][s]}))),i!==a&&(e.settings.quoteSmart&&ho(a,n)>ho(a,e.alternative)&&(n=e.alternative),i=n+ze(a,Object.assign({},e.settings.characterReferences,{subset:(n==="'"?Wa.single:Wa.double)[r][s],attribute:!0}))+n),l+(i&&"="+i))}f();f();var qf=["<","&"];function Ga(e,t,a,o){return a&&a.type==="element"&&(a.tagName==="script"||a.tagName==="style")?e.value:ze(e.value,Object.assign({},o.settings.characterReferences,{subset:qf}))}function Ii(e,t,a,o){return o.settings.allowDangerousHtml?e.value:Ga(e,t,a,o)}f();function Si(e,t,a,o){return o.all(e)}var yi=Vr("type",{invalid:Wf,unknown:Gf,handlers:{comment:mi,doctype:hi,element:Ci,raw:Ii,root:Si,text:Ga}});function Wf(e){throw new Error("Expected node, not `"+e+"`")}function Gf(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var jf={},zf={},Vf=[];function Xo(e,t){let a=t||jf,o=a.quote||'"',r=o==='"'?"'":'"';if(o!=='"'&&o!=="'")throw new Error("Invalid quote `"+o+"`, expected `'` or `\"`");return{one:$f,all:Xf,settings:{omitOptionalTags:a.omitOptionalTags||!1,allowParseErrors:a.allowParseErrors||!1,allowDangerousCharacters:a.allowDangerousCharacters||!1,quoteSmart:a.quoteSmart||!1,preferUnquoted:a.preferUnquoted||!1,tightAttributes:a.tightAttributes||!1,upperDoctype:a.upperDoctype||!1,tightDoctype:a.tightDoctype||!1,bogusComments:a.bogusComments||!1,tightCommaSeparatedLists:a.tightCommaSeparatedLists||!1,tightSelfClosing:a.tightSelfClosing||!1,collapseEmptyAttributes:a.collapseEmptyAttributes||!1,allowDangerousHtml:a.allowDangerousHtml||!1,voids:a.voids||Gr,characterReferences:a.characterReferences||zf,closeSelfClosing:a.closeSelfClosing||!1,closeEmptyElements:a.closeEmptyElements||!1},schema:a.space==="svg"?ga:zr,quote:o,alternative:r}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function $f(e,t,a){return yi(e,t,a,this)}function Xf(e){let t=[],a=e&&e.children||Vf,o=-1;for(;++o<a.length;)t[o]=this.one(a[o],o,e);return t.join("")}function ja(e,t){let a=typeof e=="string"?{}:{...e.colorReplacements},o=typeof e=="string"?e:e.name;for(let[r,s]of Object.entries(t?.colorReplacements||{}))typeof s=="string"?a[r]=s:r===o&&Object.assign(a,s);return a}function Ye(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function Kf(e){return Array.isArray(e)?e:[e]}async function Ri(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function er(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Mi(e){return e==="ansi"||er(e)}function tr(e){return e==="none"}function Fi(e){return tr(e)}function Di(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 Ka(e,t=!1){if(e.length===0)return[["",0]];let a=e.split(/(\r?\n)/g),o=0,r=[];for(let s=0;s<a.length;s+=2){let n=t?a[s]+(a[s+1]||""):a[s];r.push([n,o]),o+=a[s].length,o+=a[s+1]?.length||0}return r}function Qf(e){let t=Ka(e,!0).map(([r])=>r);function a(r){if(r===e.length)return{line:t.length-1,character:t[t.length-1].length};let s=r,n=0;for(let i of t){if(s<i.length)break;s-=i.length,n++}return{line:n,character:s}}function o(r,s){let n=0;for(let i=0;i<r;i++)n+=t[i].length;return n+=s,n}return{lines:t,indexToPos:a,posToIndex:o}}function Bi(e,t,a){let o=new Set;for(let s of e.matchAll(/:?lang=["']([^"']+)["']/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/(?:```|~~~)([\w-]+)/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/\\begin\{([\w-]+)\}/g)){let n=s[1].toLowerCase().trim();n&&o.add(n)}for(let s of e.matchAll(/<script\s+(?:type|lang)=["']([^"']+)["']/gi)){let n=s[1].toLowerCase().trim(),i=n.includes("/")?n.split("/").pop():n;i&&o.add(i)}if(!a)return Array.from(o);let r=a.getBundledLanguages();return Array.from(o).filter(s=>s&&r[s])}var ar="light-dark()",Jf=["color","background-color"];function Zf(e,t){let a=0,o=[];for(let r of t)r>a&&o.push({...e,content:e.content.slice(a,r),offset:e.offset+a}),a=r;return a<e.content.length&&o.push({...e,content:e.content.slice(a),offset:e.offset+a}),o}function Yf(e,t){let a=Array.from(t instanceof Set?t:new Set(t)).sort((o,r)=>o-r);return a.length?e.map(o=>o.flatMap(r=>{let s=a.filter(n=>r.offset<n&&n<r.offset+r.content.length).map(n=>n-r.offset).sort((n,i)=>n-i);return s.length?Zf(r,s):r})):e}function ep(e,t,a,o,r="css-vars"){let s={content:e.content,explanation:e.explanation,offset:e.offset},n=t.map(c=>za(e.variants[c])),i=new Set(n.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 n.forEach((c,d)=>{for(let p of i){let m=c[p]||"inherit";if(d===0&&o&&Jf.includes(p))if(o===ar&&n.length>1){let h=t.findIndex(C=>C==="light"),I=t.findIndex(C=>C==="dark");if(h===-1||I===-1)throw new Y('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let L=n[h][p]||"inherit",S=n[I][p]||"inherit";l[p]=`light-dark(${L}, ${S})`,r==="css-vars"&&(l[u(d,p)]=m)}else l[p]=m;else r==="css-vars"&&(l[u(d,p)]=m)}}),s.htmlStyle=l,s}function za(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&fe.Italic&&(t["font-style"]="italic"),e.fontStyle&fe.Bold&&(t["font-weight"]="bold");let a=[];e.fontStyle&fe.Underline&&a.push("underline"),e.fontStyle&fe.Strikethrough&&a.push("line-through"),a.length&&(t["text-decoration"]=a.join(" "))}return t}function Jo(e){return typeof e=="string"?e:Object.entries(e).map(([t,a])=>`${t}:${a}`).join(";")}var Ei=new WeakMap;function Qa(e,t){Ei.set(e,t)}function ia(e){return Ei.get(e)}var kt=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(Kf(a).map(o=>[o,Ua])),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 tp(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function tp(e){let t=[],a=new Set;function o(r){if(a.has(r))return;a.add(r);let s=r?.nameScopesList?.scopeName;s&&t.push(s),r.parent&&o(r.parent)}return o(e),t}function ap(e,t){if(!(e instanceof kt))throw new Y("Invalid grammar state");return e.getInternalStack(t)}function op(){let e=new WeakMap;function t(a){if(!e.has(a.meta)){let o=function(n){if(typeof n=="number"){if(n<0||n>a.source.length)throw new Y(`Invalid decoration offset: ${n}. Code length: ${a.source.length}`);return{...r.indexToPos(n),offset:n}}else{let i=r.lines[n.line];if(i===void 0)throw new Y(`Invalid decoration position ${JSON.stringify(n)}. Lines length: ${r.lines.length}`);let l=n.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new Y(`Invalid decoration position ${JSON.stringify(n)}. Line ${n.line} length: ${i.length}`);return{...n,character:l,offset:r.posToIndex(n.line,l)}}},r=Qf(a.source),s=(a.options.decorations||[]).map(n=>({...n,start:o(n.start),end:o(n.end)}));rp(s),e.set(a.meta,{decorations:s,converter:r,source:a.source})}return e.get(a.meta)}return{name:"shiki:decorations",tokens(a){if(!this.options.decorations?.length)return;let r=t(this).decorations.flatMap(n=>[n.start.offset,n.end.offset]);return Yf(a,r)},code(a){if(!this.options.decorations?.length)return;let o=t(this),r=Array.from(a.children).filter(c=>c.type==="element"&&c.tagName==="span");if(r.length!==o.converter.lines.length)throw new Y(`Number of lines in code element (${r.length}) does not match the number of lines in the source (${o.converter.lines.length}). Failed to apply decorations.`);function s(c,d,p,m){let h=r[c],I="",L=-1,S=-1;if(d===0&&(L=0),p===0&&(S=0),p===Number.POSITIVE_INFINITY&&(S=h.children.length),L===-1||S===-1)for(let g=0;g<h.children.length;g++)I+=_i(h.children[g]),L===-1&&I.length===d&&(L=g+1),S===-1&&I.length===p&&(S=g+1);if(L===-1)throw new Y(`Failed to find start index for decoration ${JSON.stringify(m.start)}`);if(S===-1)throw new Y(`Failed to find end index for decoration ${JSON.stringify(m.end)}`);let C=h.children.slice(L,S);if(!m.alwaysWrap&&C.length===h.children.length)i(h,m,"line");else if(!m.alwaysWrap&&C.length===1&&C[0].type==="element")i(C[0],m,"token");else{let g={type:"element",tagName:"span",properties:{},children:C};i(g,m,"wrapper"),h.children.splice(L,C.length,g)}}function n(c,d){r[c]=i(r[c],d,"line")}function i(c,d,p){let m=d.properties||{},h=d.transform||(I=>I);return c.tagName=d.tagName||"span",c.properties={...c.properties,...m,class:c.properties.class},d.properties?.class&&Di(c,d.properties.class),c=h(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)s(d.line,d.character,p.character,c);else if(d.line<p.line){s(d.line,d.character,Number.POSITIVE_INFINITY,c);for(let m=d.line+1;m<p.line;m++)l.unshift(()=>n(m,c));s(p.line,0,p.character,c)}}l.forEach(c=>c())}}}function rp(e){for(let t=0;t<e.length;t++){let a=e[t];if(a.start.offset>a.end.offset)throw new Y(`Invalid decoration range: ${JSON.stringify(a.start)} - ${JSON.stringify(a.end)}`);for(let o=t+1;o<e.length;o++){let r=e[o],s=a.start.offset<=r.start.offset&&r.start.offset<a.end.offset,n=a.start.offset<r.end.offset&&r.end.offset<=a.end.offset,i=r.start.offset<=a.start.offset&&a.start.offset<r.end.offset,l=r.start.offset<a.end.offset&&a.end.offset<=r.end.offset;if(s||n||i||l){if(s&&n||i&&l||i&&a.start.offset===a.end.offset||n&&r.start.offset===r.end.offset)continue;throw new Y(`Decorations ${JSON.stringify(a.start)} and ${JSON.stringify(r.start)} intersect.`)}}}}function _i(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(_i).join(""):""}var sp=[op()];function Va(e){let t=np(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...sp]}function np(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 ct=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Ko={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function ip(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 bi(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 lp(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)Ko[o]&&t.push({type:"setDecoration",value:Ko[o]});else if(o<=29){let r=Ko[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:ct[o-30]}});else if(o===38){let r=bi(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:ct[o-40]}});else if(o===48){let r=bi(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:ct[o-90+8]}}):o>=100&&o<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ct[o-100+8]}})}return t}function up(){let e=null,t=null,a=new Set;return{parse(o){let r=[],s=0;do{let n=ip(o,s),i=n.sequence?o.substring(s,n.startPosition):o.substring(s);if(i.length>0&&r.push({value:i,foreground:e,background:t,decorations:new Set(a)}),n.sequence){let l=lp(n.sequence);for(let u of l)u.type==="resetAll"?(e=null,t=null,a.clear()):u.type==="resetForegroundColor"?e=null:u.type==="resetBackgroundColor"?t=null:u.type==="resetDecoration"&&a.delete(u.value);for(let u of l)u.type==="setForegroundColor"?e=u.value:u.type==="setBackgroundColor"?t=u.value:u.type==="setDecoration"&&a.add(u.value)}s=n.position}while(s<o.length);return r}}}var dp={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 cp(e=dp){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<ct.length;u++)o.push(t(ct[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 s(i){return r()[i]}function n(i){switch(i.type){case"named":return t(i.name);case"rgb":return a(i.rgb);case"table":return s(i.index)}}return{value:n}}var fp={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 pp(e,t,a){let o=ja(e,a),r=Ka(t),s=Object.fromEntries(ct.map(l=>{let u=`terminal.ansi${l[0].toUpperCase()}${l.substring(1)}`,c=e.colors?.[u];return[l,c||fp[l]]})),n=cp(s),i=up();return r.map(l=>i.parse(l[0]).map(u=>{let c,d;u.decorations.has("reverse")?(c=u.background?n.value(u.background):e.bg,d=u.foreground?n.value(u.foreground):e.fg):(c=u.foreground?n.value(u.foreground):e.fg,d=u.background?n.value(u.background):void 0),c=Ye(c,o),d=Ye(d,o),u.decorations.has("dim")&&(c=mp(c));let p=fe.None;return u.decorations.has("bold")&&(p|=fe.Bold),u.decorations.has("italic")&&(p|=fe.Italic),u.decorations.has("underline")&&(p|=fe.Underline),u.decorations.has("strikethrough")&&(p|=fe.Strikethrough),{content:u.value,offset:l[1],color:c,bgColor:d,fontStyle:p}}))}function mp(e){let t=e.match(/#([0-9a-f]{3,8})/i);if(t){let o=t[1];if(o.length===8){let r=Math.round(Number.parseInt(o.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${o.slice(0,6)}${r}`}else{if(o.length===6)return`#${o}80`;if(o.length===4){let r=o[0],s=o[1],n=o[2],i=o[3],l=Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0");return`#${r}${r}${s}${s}${n}${n}${l}`}else if(o.length===3){let r=o[0],s=o[1],n=o[2];return`#${r}${r}${s}${s}${n}${n}80`}}}let a=e.match(/var\((--[\w-]+-ansi-[\w-]+)\)/);return a?`var(${a[1]}-dim)`:e}function or(e,t,a={}){let{theme:o=e.getLoadedThemes()[0]}=a,r=e.resolveLangAlias(a.lang||"text");if(er(r)||tr(o))return Ka(t).map(l=>[{content:l[0],offset:l[1]}]);let{theme:s,colorMap:n}=e.setTheme(o);if(r==="ansi")return pp(s,t,a);let i=e.getLanguage(a.lang||"text");if(a.grammarState){if(a.grammarState.lang!==i.name)throw new Y(`Grammar state language "${a.grammarState.lang}" does not match highlight language "${i.name}"`);if(!a.grammarState.themes.includes(s.name))throw new Y(`Grammar state themes "${a.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return gp(t,i,s,n,a)}function hp(...e){if(e.length===2)return ia(e[1]);let[t,a,o={}]=e,{lang:r="text",theme:s=t.getLoadedThemes()[0]}=o;if(er(r)||tr(s))throw new Y("Plain language does not have grammar state");if(r==="ansi")throw new Y("ANSI language does not have grammar state");let{theme:n,colorMap:i}=t.setTheme(s),l=t.getLanguage(r);return new kt(rr(a,l,n,i,o).stateStack,l.name,n.name)}function gp(e,t,a,o,r){let s=rr(e,t,a,o,r),n=new kt(s.stateStack,t.name,a.name);return Qa(s.tokens,n),s.tokens}function rr(e,t,a,o,r){let s=ja(a,r),{tokenizeMaxLineLength:n=0,tokenizeTimeLimit:i=500}=r,l=Ka(e),u=r.grammarState?ap(r.grammarState,a.name)??Ua:r.grammarContextCode!=null?rr(r.grammarContextCode,t,a,o,{...r,grammarState:void 0,grammarContextCode:void 0}).stateStack:Ua,c=[],d=[];for(let p=0,m=l.length;p<m;p++){let[h,I]=l[p];if(h===""){c=[],d.push([]);continue}if(n>0&&h.length>=n){c=[],d.push([{content:h,offset:I,color:"",fontStyle:0}]);continue}let L,S,C;r.includeExplanation&&(L=t.tokenizeLine(h,u,i),S=L.tokens,C=0);let g=t.tokenizeLine2(h,u,i),y=g.tokens.length/2;for(let P=0;P<y;P++){let v=g.tokens[2*P],R=P+1<y?g.tokens[2*P+2]:h.length;if(v===R)continue;let A=g.tokens[2*P+1],_=Ye(o[dt.getForeground(A)],s),M=dt.getFontStyle(A),T={content:h.substring(v,R),offset:I+v,color:_,fontStyle:M};if(r.includeExplanation){let b=[];if(r.includeExplanation!=="scopeName")for(let O of a.settings){let F;switch(typeof O.scope){case"string":F=O.scope.split(/,/).map(J=>J.trim());break;case"object":F=O.scope;break;default:continue}b.push({settings:O,selectors:F.map(J=>J.split(/ /))})}T.explanation=[];let B=0;for(;v+B<R;){let O=S[C],F=h.substring(O.startIndex,O.endIndex);B+=F.length,T.explanation.push({content:F,scopes:r.includeExplanation==="scopeName"?wp(O.scopes):xp(b,O.scopes)}),C+=1}}c.push(T)}d.push(c),c=[],u=g.ruleStack}return{tokens:d,stateStack:u}}function wp(e){return e.map(t=>({scopeName:t}))}function xp(e,t){let a=[];for(let o=0,r=t.length;o<r;o++){let s=t[o];a[o]={scopeName:s,themeMatches:Cp(e,s,t.slice(0,o))}}return a}function ki(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Lp(e,t,a){if(!ki(e[e.length-1],t))return!1;let o=e.length-2,r=a.length-1;for(;o>=0&&r>=0;)ki(e[o],a[r])&&(o-=1),r-=1;return o===-1}function Cp(e,t,a){let o=[];for(let{selectors:r,settings:s}of e)for(let n of r)if(Lp(n,t,a)){o.push(s);break}return o}function Ni(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=or(e,t,{...a,theme:l.theme}),c=ia(u),d=typeof l.theme=="string"?l.theme:l.theme.name;return{tokens:u,state:c,theme:d}}),s=Ip(...r.map(l=>l.tokens)),n=s[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),s.forEach((m,h)=>{let{content:I,explanation:L,offset:S,...C}=m[u][d];p.variants[o[h].color]=C}),p})),i=r[0].state?new kt(Object.fromEntries(r.map(l=>[l.theme,l.state?.getInternalStack(l.theme)])),r[0].state.lang):void 0;return i&&Qa(n,i),n}function Ip(...e){let t=e.map(()=>[]),a=e.length;for(let o=0;o<e[0].length;o++){let r=e.map(l=>l[o]),s=t.map(()=>[]);t.forEach((l,u)=>l.push(s[u]));let n=r.map(()=>0),i=r.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(u=>u.content.length));for(let u=0;u<a;u++){let c=i[u];c.content.length===l?(s[u].push(c),n[u]+=1,i[u]=r[u][n[u]]):(s[u].push({...c,content:c.content.slice(0,l)}),i[u]={...c,content:c.content.slice(l),offset:c.offset+l})}}}return t}function $a(e,t,a){let o,r,s,n,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,C)=>S.color===u?-1:C.color===u?1:0);if(p.length===0)throw new Y("`themes` option must not be empty");let m=Ni(e,t,a);if(l=ia(m),u&&ar!==u&&!p.find(S=>S.color===u))throw new Y(`\`themes\` option must contain the defaultColor key \`${u}\``);let h=p.map(S=>e.getTheme(S.theme)),I=p.map(S=>S.color);s=m.map(S=>S.map(C=>ep(C,I,c,u,d))),l&&Qa(s,l);let L=p.map(S=>ja(S.theme,a));r=Ti(p,h,L,c,u,"fg",d),o=Ti(p,h,L,c,u,"bg",d),n=`shiki-themes ${h.map(S=>S.name).join(" ")}`,i=u?void 0:[r,o].join(";")}else if("theme"in a){let u=ja(a.theme,a);s=or(e,t,a);let c=e.getTheme(a.theme);o=Ye(c.bg,u),r=Ye(c.fg,u),n=c.name,l=ia(s)}else throw new Y("Invalid options, either `theme` or `themes` must be provided");return{tokens:s,fg:r,bg:o,themeName:n,rootStyle:i,grammarState:l}}function Ti(e,t,a,o,r,s,n){return e.map((i,l)=>{let u=Ye(t[l][s],a[l])||"inherit",c=`${o+i.color}${s==="bg"?"-bg":""}:${u}`;if(l===0&&r){if(r===ar&&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 Y('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let m=Ye(t[d][s],a[d])||"inherit",h=Ye(t[p][s],a[p])||"inherit";return`light-dark(${m}, ${h});${c}`}return u}return n==="css-vars"?c:null}).filter(i=>!!i).join(";")}function Xa(e,t,a,o={meta:{},options:a,codeToHast:(r,s)=>Xa(e,r,s),codeToTokens:(r,s)=>$a(e,r,s)}){let r=t;for(let h of Va(a))r=h.preprocess?.call(o,r,a)||r;let{tokens:s,fg:n,bg:i,themeName:l,rootStyle:u,grammarState:c}=$a(e,r,a),{mergeWhitespaces:d=!0,mergeSameStyleTokens:p=!1}=a;d===!0?s=yp(s):d==="never"&&(s=bp(s)),p&&(s=kp(s));let m={...o,get source(){return r}};for(let h of Va(a))s=h.tokens?.call(m,s)||s;return Sp(s,{...a,fg:n,bg:i,themeName:l,rootStyle:a.rootStyle===!1?!1:a.rootStyle??u},m,c)}function Sp(e,t,a,o=ia(e)){let r=Va(t),s=[],n={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,u={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?u.style=t.rootStyle:u.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(u.tabindex=l.toString());for(let[I,L]of Object.entries(t.meta||{}))I.startsWith("_")||(u[I]=L);let c={type:"element",tagName:"pre",properties:u,children:[],data:t.data},d={type:"element",tagName:"code",properties:{},children:s},p=[],m={...a,structure:i,addClassToHast:Di,get source(){return a.source},get tokens(){return e},get options(){return t},get root(){return n},get pre(){return c},get code(){return d},get lines(){return p}};if(e.forEach((I,L)=>{L&&(i==="inline"?n.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&s.push({type:"text",value:`
79
+ `}));let S={type:"element",tagName:"span",properties:{class:"line"},children:[]},C=0;for(let g of I){let y={type:"element",tagName:"span",properties:{...g.htmlAttrs},children:[{type:"text",value:g.content}]},P=Jo(g.htmlStyle||za(g));P&&(y.properties.style=P);for(let v of r)y=v?.span?.call(m,y,L+1,C,S,g)||y;i==="inline"?n.children.push(y):i==="classic"&&S.children.push(y),C+=g.content.length}if(i==="classic"){for(let g of r)S=g?.line?.call(m,S,L+1)||S;p.push(S),s.push(S)}else i==="inline"&&p.push(S)}),i==="classic"){for(let I of r)d=I?.code?.call(m,d)||d;c.children.push(d);for(let I of r)c=I?.pre?.call(m,c)||c;n.children.push(c)}else if(i==="inline"){let I=[],L={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let g of n.children)g.type==="element"&&g.tagName==="br"?(I.push(L),L={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(g.type==="element"||g.type==="text")&&L.children.push(g);I.push(L);let C={type:"element",tagName:"code",properties:{},children:I};for(let g of r)C=g?.code?.call(m,C)||C;n.children=[];for(let g=0;g<C.children.length;g++){g>0&&n.children.push({type:"element",tagName:"br",properties:{},children:[]});let y=C.children[g];y.type==="element"&&n.children.push(...y.children)}}let h=n;for(let I of r)h=I?.root?.call(m,h)||h;return o&&Qa(h,o),h}function yp(e){return e.map(t=>{let a=[],o="",r;return t.forEach((s,n)=>{let l=!(s.fontStyle&&(s.fontStyle&fe.Underline||s.fontStyle&fe.Strikethrough));l&&s.content.match(/^\s+$/)&&t[n+1]?(r===void 0&&(r=s.offset),o+=s.content):o?(l?a.push({...s,offset:r,content:o+s.content}):a.push({content:o,offset:r},s),r=void 0,o=""):a.push(s)}),a})}function bp(e){return e.map(t=>t.flatMap(a=>{if(a.content.match(/^\s+$/))return a;let o=a.content.match(/^(\s*)(.*?)(\s*)$/);if(!o)return a;let[,r,s,n]=o;if(!r&&!n)return a;let i=[{...a,offset:a.offset+r.length,content:s}];return r&&i.unshift({content:r,offset:a.offset}),n&&i.push({content:n,offset:a.offset+r.length+s.length}),i}))}function kp(e){return e.map(t=>{let a=[];for(let o of t){if(a.length===0){a.push({...o});continue}let r=a[a.length-1],s=Jo(r.htmlStyle||za(r)),n=Jo(o.htmlStyle||za(o)),i=r.fontStyle&&(r.fontStyle&fe.Underline||r.fontStyle&fe.Strikethrough),l=o.fontStyle&&(o.fontStyle&fe.Underline||o.fontStyle&fe.Strikethrough);!i&&!l&&s===n?r.content+=o.content:a.push({...o})}return a})}var Tp=Xo;function Pp(e,t,a){let o={meta:{},options:a,codeToHast:(s,n)=>Xa(e,s,n),codeToTokens:(s,n)=>$a(e,s,n)},r=Tp(Xa(e,t,a,o));for(let s of Va(a))r=s.postprocess?.call(o,r,a)||r;return r}var Pi={light:"#333333",dark:"#bbbbbb"},vi={light:"#fffffe",dark:"#1e1e1e"},Ai="__shiki_resolved";function sr(e){if(e?.[Ai])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:a,fg:o}=t;if(!a||!o){let i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(o=i.settings.foreground),i?.settings?.background&&(a=i.settings.background),!o&&t?.colors?.["editor.foreground"]&&(o=t.colors["editor.foreground"]),!a&&t?.colors?.["editor.background"]&&(a=t.colors["editor.background"]),o||(o=t.type==="light"?Pi.light:Pi.dark),a||(a=t.type==="light"?vi.light:vi.dark),t.fg=o,t.bg=a}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let r=0,s=new Map;function n(i){if(s.has(i))return s.get(i);r+=1;let l=`#${r.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?n(i):(s.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),u=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!u)return i;let c={...i,settings:{...i.settings}};if(l){let d=n(i.settings.foreground);t.colorReplacements[d]=i.settings.foreground,c.settings.foreground=d}if(u){let d=n(i.settings.background);t.colorReplacements[d]=i.settings.background,c.settings.background=d}return c});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=n(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,Ai,{enumerable:!1,writable:!1,value:!0}),t}async function Ui(e){return Array.from(new Set((await Promise.all(e.filter(t=>!Mi(t)).map(async t=>await Ri(t).then(a=>Array.isArray(a)?a:[a])))).flat()))}async function Oi(e){return(await Promise.all(e.map(async a=>Fi(a)?null:sr(await Ri(a))))).filter(a=>!!a)}var Qo=3,vp=!1;function Ap(e,t=3){if(Qo&&!(typeof Qo=="number"&&t>Qo)){if(vp)throw new Error(`[SHIKI DEPRECATE]: ${e}`);console.trace(`[SHIKI DEPRECATE]: ${e}`)}}var Ze=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Hi(e,t){if(!t)return e;if(t[e]){let a=new Set([e]);for(;t[e];){if(e=t[e],a.has(e))throw new Ze(`Circular alias \`${Array.from(a).join(" -> ")} -> ${e}\``);a.add(e)}}return e}var Zo=class extends ri{constructor(t,a,o,r={}){super(t),this._resolver=t,this._themes=a,this._langs=o,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){let a=sr(t);return a.name&&(this._resolvedThemes.set(a.name,a),this._loadedThemesCache=null),a}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let a=this._textmateThemeCache.get(t);a||(a=ea.createFromRawTheme(t),this._textmateThemeCache.set(t,a)),this._syncRegistry.setTheme(a)}getGrammar(t){return t=Hi(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;let a=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);let o={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);let r=this.loadGrammarWithConfiguration(t.scopeName,1,o);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,a.size)for(let s of a)this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(let r of t)this.resolveEmbeddedLanguages(r);let a=Array.from(this._langGraph.entries()),o=a.filter(([r,s])=>!s);if(o.length){let r=a.filter(([s,n])=>n?(n.embeddedLanguages||n.embeddedLangs)?.some(l=>o.map(([u])=>u).includes(l)):!1).filter(s=>!o.includes(s));throw new Ze(`Missing languages ${o.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of a)this._resolver.addLanguage(s);for(let[r,s]of a)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);let a=t.embeddedLanguages??t.embeddedLangs;if(a)for(let o of a)this._langGraph.set(o,this._langMap.get(o))}},Yo=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,a){this._onigLib={createOnigScanner:o=>t.createScanner(o),createOnigString:o=>t.createString(o)},a.forEach(o=>this.addLanguage(o))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(a=>{this._langs.set(a,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(a=>{this._injections.get(a)||this._injections.set(a,[]),this._injections.get(a).push(t.scopeName)})}getInjections(t){let a=t.split("."),o=[];for(let r=1;r<=a.length;r++){let s=a.slice(0,r).join(".");o=[...o,...this._injections.get(s)||[]]}return o}},na=0;function Rp(e){na+=1,e.warnings!==!1&&na>=10&&na%10===0&&console.warn(`[Shiki] ${na} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new Ze("`engine` option is required for synchronous mode");let a=(e.langs||[]).flat(1),o=(e.themes||[]).flat(1).map(sr),r=new Yo(e.engine,a),s=new Zo(r,o,a,e.langAlias),n;function i(g){return Hi(g,e.langAlias)}function l(g){S();let y=s.getGrammar(typeof g=="string"?g:g.name);if(!y)throw new Ze(`Language \`${g}\` not found, you may need to load it first`);return y}function u(g){if(g==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};S();let y=s.getTheme(g);if(!y)throw new Ze(`Theme \`${g}\` not found, you may need to load it first`);return y}function c(g){S();let y=u(g);n!==g&&(s.setTheme(y),n=g);let P=s.getColorMap();return{theme:y,colorMap:P}}function d(){return S(),s.getLoadedThemes()}function p(){return S(),s.getLoadedLanguages()}function m(...g){S(),s.loadLanguages(g.flat(1))}async function h(...g){return m(await Ui(g))}function I(...g){S();for(let y of g.flat(1))s.loadTheme(y)}async function L(...g){return S(),I(await Oi(g))}function S(){if(t)throw new Ze("Shiki instance has been disposed")}function C(){t||(t=!0,s.dispose(),na-=1)}return{setTheme:c,getTheme:u,getLanguage:l,getLoadedThemes:d,getLoadedLanguages:p,resolveLangAlias:i,loadLanguage:h,loadLanguageSync:m,loadTheme:L,loadThemeSync:I,dispose:C,[Symbol.dispose]:C}}async function Mp(e){e.engine||Ap("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");let[t,a,o]=await Promise.all([Oi(e.themes||[]),Ui(e.langs||[]),e.engine]);return Rp({...e,themes:t,langs:a,engine:o})}async function Fp(e){let t=await Mp(e);return{getLastGrammarState:(...a)=>hp(t,...a),codeToTokensBase:(a,o)=>or(t,a,o),codeToTokensWithThemes:(a,o)=>Ni(t,a,o),codeToTokens:(a,o)=>$a(t,a,o),codeToHast:(a,o)=>Xa(t,a,o),codeToHtml:(a,o)=>Pp(t,a,o),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function qi(e){let t=e.langs,a=e.themes,o=e.engine;async function r(s){function n(d){if(typeof d=="string"){if(d=s.langAlias?.[d]||d,Mi(d))return[];let p=t[d];if(!p)throw new Y(`Language \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}function i(d){if(Fi(d))return"none";if(typeof d=="string"){let p=a[d];if(!p)throw new Y(`Theme \`${d}\` is not included in this bundle. You may want to load it from external source.`);return p}return d}let l=(s.themes??[]).map(d=>i(d)),u=(s.langs??[]).map(d=>n(d)),c=await Fp({engine:s.engine??o(),...s,themes:l,langs:u});return{...c,loadLanguage(...d){return c.loadLanguage(...d.map(n))},loadTheme(...d){return c.loadTheme(...d.map(i))},getBundledLanguages(){return t},getBundledThemes(){return a}}}return r}function Dp(e){let t;async function a(o={}){if(t){let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}else{t=e({...o,themes:[],langs:[]});let r=await t;return await Promise.all([r.loadTheme(...o.themes||[]),r.loadLanguage(...o.langs||[])]),r}}return a}function Wi(e,t){let a=Dp(e);async function o(r,s){let n=await a({langs:[s.lang],themes:"theme"in s?[s.theme]:Object.values(s.themes)}),i=await t?.guessEmbeddedLanguages?.(r,s.lang,n);return i&&await n.loadLanguage(...i),n}return{getSingletonHighlighter(r){return a(r)},async codeToHtml(r,s){return(await o(r,s)).codeToHtml(r,s)},async codeToHast(r,s){return(await o(r,s)).codeToHast(r,s)},async codeToTokens(r,s){return(await o(r,s)).codeToTokens(r,s)},async codeToTokensBase(r,s){return(await o(r,s)).codeToTokensBase(r,s)},async codeToTokensWithThemes(r,s){return(await o(r,s)).codeToTokensWithThemes(r,s)},async getLastGrammarState(r,s){return(await a({langs:[s.lang],themes:[s.theme]})).getLastGrammarState(r,s)}}}f();var nr=[{id:"abap",name:"ABAP",import:(()=>import("../abap-3IAGZ3PS.js"))},{id:"actionscript-3",name:"ActionScript",import:(()=>import("../actionscript-3-C46RIPM4.js"))},{id:"ada",name:"Ada",import:(()=>import("../ada-DNTYS66P.js"))},{id:"angular-html",name:"Angular HTML",import:(()=>import("../angular-html-VZSV3CDH.js"))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>import("../angular-ts-UPMUIYI3.js"))},{id:"apache",name:"Apache Conf",import:(()=>import("../apache-DU26FTNI.js"))},{id:"apex",name:"Apex",import:(()=>import("../apex-OU63AG2P.js"))},{id:"apl",name:"APL",import:(()=>import("../apl-ZTMAKUPW.js"))},{id:"applescript",name:"AppleScript",import:(()=>import("../applescript-TT4XSRXH.js"))},{id:"ara",name:"Ara",import:(()=>import("../ara-Q7AJDKA4.js"))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>import("../asciidoc-WADBFJPS.js"))},{id:"asm",name:"Assembly",import:(()=>import("../asm-D3LJR7GV.js"))},{id:"astro",name:"Astro",import:(()=>import("../astro-ZC25ZSBI.js"))},{id:"awk",name:"AWK",import:(()=>import("../awk-DCAM52A7.js"))},{id:"ballerina",name:"Ballerina",import:(()=>import("../ballerina-44XARFEK.js"))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>import("../bat-WM4RL2AB.js"))},{id:"beancount",name:"Beancount",import:(()=>import("../beancount-5PUWGPVT.js"))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>import("../berry-YAK4XTWX.js"))},{id:"bibtex",name:"BibTeX",import:(()=>import("../bibtex-2ISWNMJJ.js"))},{id:"bicep",name:"Bicep",import:(()=>import("../bicep-EOACOM4G.js"))},{id:"blade",name:"Blade",import:(()=>import("../blade-BVUO2H7O.js"))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>import("../bsl-TNLQPNE3.js"))},{id:"c",name:"C",import:(()=>import("../c-G7V525MX.js"))},{id:"c3",name:"C3",import:(()=>import("../c3-CDQIRWGP.js"))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>import("../cadence-U32GKKTR.js"))},{id:"cairo",name:"Cairo",import:(()=>import("../cairo-26RR6N4F.js"))},{id:"clarity",name:"Clarity",import:(()=>import("../clarity-4JIHRN2V.js"))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>import("../clojure-PKTTXYYS.js"))},{id:"cmake",name:"CMake",import:(()=>import("../cmake-HXKHWGGH.js"))},{id:"cobol",name:"COBOL",import:(()=>import("../cobol-SKJIT3WM.js"))},{id:"codeowners",name:"CODEOWNERS",import:(()=>import("../codeowners-WCXRHQ2R.js"))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>import("../codeql-XZZ2USHF.js"))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>import("../coffee-SGQWHBUL.js"))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>import("../common-lisp-IK3DGBCK.js"))},{id:"coq",name:"Coq",import:(()=>import("../coq-UPTUVPLH.js"))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>import("../cpp-4EW5XLOK.js"))},{id:"crystal",name:"Crystal",import:(()=>import("../crystal-YFCJLEES.js"))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>import("../csharp-6EXQ7B24.js"))},{id:"css",name:"CSS",import:(()=>import("../css-MH4LSMNV.js"))},{id:"csv",name:"CSV",import:(()=>import("../csv-CRTD5FOL.js"))},{id:"cue",name:"CUE",import:(()=>import("../cue-IFMTDLM2.js"))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>import("../cypher-WH7754G7.js"))},{id:"d",name:"D",import:(()=>import("../d-VFMGCSG3.js"))},{id:"dart",name:"Dart",import:(()=>import("../dart-CSERBUPM.js"))},{id:"dax",name:"DAX",import:(()=>import("../dax-Y4DTPR3K.js"))},{id:"desktop",name:"Desktop",import:(()=>import("../desktop-UYAYGPQT.js"))},{id:"diff",name:"Diff",import:(()=>import("../diff-BJDM3N45.js"))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>import("../docker-UOM4Q7PD.js"))},{id:"dotenv",name:"dotEnv",import:(()=>import("../dotenv-LK44WBD3.js"))},{id:"dream-maker",name:"Dream Maker",import:(()=>import("../dream-maker-7RP4JRQH.js"))},{id:"edge",name:"Edge",import:(()=>import("../edge-3LWPZYS7.js"))},{id:"elixir",name:"Elixir",import:(()=>import("../elixir-3H7W7YJZ.js"))},{id:"elm",name:"Elm",import:(()=>import("../elm-THYL2NRS.js"))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>import("../emacs-lisp-YHLQYGNI.js"))},{id:"erb",name:"ERB",import:(()=>import("../erb-AXCKAI43.js"))},{id:"erlang",name:"Erlang",aliases:["erl"],import:(()=>import("../erlang-UNX5MMGA.js"))},{id:"fennel",name:"Fennel",import:(()=>import("../fennel-HYSSBG3N.js"))},{id:"fish",name:"Fish",import:(()=>import("../fish-PTKGQOJI.js"))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>import("../fluent-LEZHPPJV.js"))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>import("../fortran-fixed-form-J5AMEFMB.js"))},{id:"fortran-free-form",name:"Fortran (Free Form)",aliases:["f90","f95","f03","f08","f18"],import:(()=>import("../fortran-free-form-S3BNTBLS.js"))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>import("../fsharp-H4OIW62Z.js"))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>import("../gdresource-A6NTYFLM.js"))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>import("../gdscript-YQUSJRNZ.js"))},{id:"gdshader",name:"GDShader",import:(()=>import("../gdshader-S5432GFE.js"))},{id:"genie",name:"Genie",import:(()=>import("../genie-RNVG5N7L.js"))},{id:"gherkin",name:"Gherkin",import:(()=>import("../gherkin-E5R62T6O.js"))},{id:"git-commit",name:"Git Commit Message",import:(()=>import("../git-commit-QGH6XOBG.js"))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>import("../git-rebase-XTCZTXU4.js"))},{id:"gleam",name:"Gleam",import:(()=>import("../gleam-W5WZ7CST.js"))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>import("../glimmer-js-ZXI6Y36F.js"))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>import("../glimmer-ts-BJKMFBLF.js"))},{id:"glsl",name:"GLSL",import:(()=>import("../glsl-PVW2OPUD.js"))},{id:"gn",name:"GN",import:(()=>import("../gn-FCAO7WI5.js"))},{id:"gnuplot",name:"Gnuplot",import:(()=>import("../gnuplot-Q6SE5CHZ.js"))},{id:"go",name:"Go",import:(()=>import("../go-CPCZAAWX.js"))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>import("../graphql-KHEFECOG.js"))},{id:"groovy",name:"Groovy",import:(()=>import("../groovy-PJAEBBJY.js"))},{id:"hack",name:"Hack",import:(()=>import("../hack-KV5GHBVV.js"))},{id:"haml",name:"Ruby Haml",import:(()=>import("../haml-6R7X7F2Q.js"))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>import("../handlebars-U44VLSEQ.js"))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>import("../haskell-NX6XRMNO.js"))},{id:"haxe",name:"Haxe",import:(()=>import("../haxe-7YNB7FVC.js"))},{id:"hcl",name:"HashiCorp HCL",import:(()=>import("../hcl-ZF75ASCX.js"))},{id:"hjson",name:"Hjson",import:(()=>import("../hjson-65TX6QOC.js"))},{id:"hlsl",name:"HLSL",import:(()=>import("../hlsl-U2O526MI.js"))},{id:"html",name:"HTML",import:(()=>import("../html-MYZBE4UD.js"))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>import("../html-derivative-OWRPAN3G.js"))},{id:"http",name:"HTTP",import:(()=>import("../http-JSPDAWSO.js"))},{id:"hurl",name:"Hurl",import:(()=>import("../hurl-OT2SM4S7.js"))},{id:"hxml",name:"HXML",import:(()=>import("../hxml-IGTXIURH.js"))},{id:"hy",name:"Hy",import:(()=>import("../hy-CLDGXJYP.js"))},{id:"imba",name:"Imba",import:(()=>import("../imba-NWHLCVE5.js"))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>import("../ini-R6WYP7NC.js"))},{id:"java",name:"Java",import:(()=>import("../java-DHBXDMBM.js"))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>import("../javascript-GNUEDNHO.js"))},{id:"jinja",name:"Jinja",import:(()=>import("../jinja-CCI3FGLW.js"))},{id:"jison",name:"Jison",import:(()=>import("../jison-64A6IJCV.js"))},{id:"json",name:"JSON",import:(()=>import("../json-2ELCHKXT.js"))},{id:"json5",name:"JSON5",import:(()=>import("../json5-QRH5UJYD.js"))},{id:"jsonc",name:"JSON with Comments",import:(()=>import("../jsonc-IXPVR4NY.js"))},{id:"jsonl",name:"JSON Lines",import:(()=>import("../jsonl-C57GMUK5.js"))},{id:"jsonnet",name:"Jsonnet",import:(()=>import("../jsonnet-VNADFLKI.js"))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>import("../jssm-CW4ZYDSF.js"))},{id:"jsx",name:"JSX",import:(()=>import("../jsx-YTENXENT.js"))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>import("../julia-BWWONBRS.js"))},{id:"kdl",name:"KDL",import:(()=>import("../kdl-X3AS2HRT.js"))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>import("../kotlin-WGITM75W.js"))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>import("../kusto-LT46F7AO.js"))},{id:"latex",name:"LaTeX",import:(()=>import("../latex-R4PJ7JDY.js"))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>import("../lean-DYWOENAS.js"))},{id:"less",name:"Less",import:(()=>import("../less-ZYJT7MPU.js"))},{id:"liquid",name:"Liquid",import:(()=>import("../liquid-OSRU4KOW.js"))},{id:"llvm",name:"LLVM IR",import:(()=>import("../llvm-WBQ7MHV7.js"))},{id:"log",name:"Log file",import:(()=>import("../log-AXKDFD3L.js"))},{id:"logo",name:"Logo",import:(()=>import("../logo-E23LAFZY.js"))},{id:"lua",name:"Lua",import:(()=>import("../lua-QQ5QEPPO.js"))},{id:"luau",name:"Luau",import:(()=>import("../luau-D432BEB5.js"))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>import("../make-QFMWQJMG.js"))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>import("../markdown-D756RUOP.js"))},{id:"marko",name:"Marko",import:(()=>import("../marko-WVASNOGB.js"))},{id:"matlab",name:"MATLAB",import:(()=>import("../matlab-ZKZ7YBAH.js"))},{id:"mdc",name:"MDC",import:(()=>import("../mdc-PDOFYVVO.js"))},{id:"mdx",name:"MDX",import:(()=>import("../mdx-34BL2O4O.js"))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>import("../mermaid-54Z3SAII.js"))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>import("../mipsasm-NKQWJEL7.js"))},{id:"mojo",name:"Mojo",import:(()=>import("../mojo-KRRNBH7O.js"))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>import("../moonbit-LQ7JL5LZ.js"))},{id:"move",name:"Move",import:(()=>import("../move-4VWCI4YQ.js"))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>import("../narrat-4QSDQDLH.js"))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>import("../nextflow-DPCEWQNZ.js"))},{id:"nginx",name:"Nginx",import:(()=>import("../nginx-DXHAXQRH.js"))},{id:"nim",name:"Nim",import:(()=>import("../nim-WGQAUAVA.js"))},{id:"nix",name:"Nix",import:(()=>import("../nix-WAYR4BYU.js"))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>import("../nushell-26KZW4VL.js"))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>import("../objective-c-246HWLKT.js"))},{id:"objective-cpp",name:"Objective-C++",import:(()=>import("../objective-cpp-RJUXXPYQ.js"))},{id:"ocaml",name:"OCaml",import:(()=>import("../ocaml-P7NGS7PR.js"))},{id:"odin",name:"Odin",import:(()=>import("../odin-UPPZCJGN.js"))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>import("../openscad-JRK6K3FL.js"))},{id:"pascal",name:"Pascal",import:(()=>import("../pascal-RDFLUHHA.js"))},{id:"perl",name:"Perl",import:(()=>import("../perl-Y3ALUOFJ.js"))},{id:"php",name:"PHP",import:(()=>import("../php-QERWOQJG.js"))},{id:"pkl",name:"Pkl",import:(()=>import("../pkl-PAM76VXP.js"))},{id:"plsql",name:"PL/SQL",import:(()=>import("../plsql-3Y6UMFEG.js"))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>import("../po-GNTAKCTE.js"))},{id:"polar",name:"Polar",import:(()=>import("../polar-EVTMRLGV.js"))},{id:"postcss",name:"PostCSS",import:(()=>import("../postcss-42343LW7.js"))},{id:"powerquery",name:"PowerQuery",import:(()=>import("../powerquery-M34PNR4X.js"))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>import("../powershell-IR7ICFQW.js"))},{id:"prisma",name:"Prisma",import:(()=>import("../prisma-RXSIFLZX.js"))},{id:"prolog",name:"Prolog",import:(()=>import("../prolog-YBBQ4UD5.js"))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>import("../proto-U4FF45G6.js"))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>import("../pug-7XNGVJEC.js"))},{id:"puppet",name:"Puppet",import:(()=>import("../puppet-HWOKIYJP.js"))},{id:"purescript",name:"PureScript",import:(()=>import("../purescript-D45AJS5J.js"))},{id:"python",name:"Python",aliases:["py"],import:(()=>import("../python-QWA7UE2I.js"))},{id:"qml",name:"QML",import:(()=>import("../qml-RHCWFR3S.js"))},{id:"qmldir",name:"QML Directory",import:(()=>import("../qmldir-FBDC3XMZ.js"))},{id:"qss",name:"Qt Style Sheets",import:(()=>import("../qss-AD3WZQ45.js"))},{id:"r",name:"R",import:(()=>import("../r-NHIAHDOD.js"))},{id:"racket",name:"Racket",import:(()=>import("../racket-7G65C5N5.js"))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>import("../raku-IWS7BLGD.js"))},{id:"razor",name:"ASP.NET Razor",import:(()=>import("../razor-C2NV2YNT.js"))},{id:"reg",name:"Windows Registry Script",import:(()=>import("../reg-V4XLWESR.js"))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>import("../regexp-XP4MR635.js"))},{id:"rel",name:"Rel",import:(()=>import("../rel-DE6UXATM.js"))},{id:"riscv",name:"RISC-V",import:(()=>import("../riscv-5PDXBPPL.js"))},{id:"ron",name:"RON",import:(()=>import("../ron-WD6BJFDY.js"))},{id:"rosmsg",name:"ROS Interface",import:(()=>import("../rosmsg-7LDUCZRQ.js"))},{id:"rst",name:"reStructuredText",import:(()=>import("../rst-W5S2XFF7.js"))},{id:"ruby",name:"Ruby",aliases:["rb"],import:(()=>import("../ruby-EYYAUQUG.js"))},{id:"rust",name:"Rust",aliases:["rs"],import:(()=>import("../rust-Z2NYMT2Z.js"))},{id:"sas",name:"SAS",import:(()=>import("../sas-A4JCTK6H.js"))},{id:"sass",name:"Sass",import:(()=>import("../sass-75VDP7DE.js"))},{id:"scala",name:"Scala",import:(()=>import("../scala-7TJ4N6KC.js"))},{id:"scheme",name:"Scheme",import:(()=>import("../scheme-5XARZMKT.js"))},{id:"scss",name:"SCSS",import:(()=>import("../scss-4QR2BXFS.js"))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>import("../sdbl-6M55AJVA.js"))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>import("../shaderlab-322XNY5V.js"))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>import("../shellscript-F23VVVTW.js"))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>import("../shellsession-G65XJMCC.js"))},{id:"smalltalk",name:"Smalltalk",import:(()=>import("../smalltalk-LALIO5SC.js"))},{id:"solidity",name:"Solidity",import:(()=>import("../solidity-TQUKTJZZ.js"))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>import("../soy-G2LDZSDN.js"))},{id:"sparql",name:"SPARQL",import:(()=>import("../sparql-ARI3MVK7.js"))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>import("../splunk-QEFG3NPJ.js"))},{id:"sql",name:"SQL",import:(()=>import("../sql-SBP7VV3V.js"))},{id:"ssh-config",name:"SSH Config",import:(()=>import("../ssh-config-SC6RC6IV.js"))},{id:"stata",name:"Stata",import:(()=>import("../stata-MNI5YOQU.js"))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>import("../stylus-YYWEHAK3.js"))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>import("../surrealql-5X7LI3J6.js"))},{id:"svelte",name:"Svelte",import:(()=>import("../svelte-EYZDXUS2.js"))},{id:"swift",name:"Swift",import:(()=>import("../swift-JEBLU4EM.js"))},{id:"system-verilog",name:"SystemVerilog",import:(()=>import("../system-verilog-46QRSGNM.js"))},{id:"systemd",name:"Systemd Units",import:(()=>import("../systemd-3PUVCSI7.js"))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>import("../talonscript-AK4LB3KC.js"))},{id:"tasl",name:"Tasl",import:(()=>import("../tasl-VHTYBUVI.js"))},{id:"tcl",name:"Tcl",import:(()=>import("../tcl-UUMKHRHL.js"))},{id:"templ",name:"Templ",import:(()=>import("../templ-KXQ2KV7D.js"))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>import("../terraform-GCGIT2RL.js"))},{id:"tex",name:"TeX",import:(()=>import("../tex-L55DZDKV.js"))},{id:"toml",name:"TOML",import:(()=>import("../toml-7AH4HFBN.js"))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>import("../ts-tags-TCQ23O6Y.js"))},{id:"tsv",name:"TSV",import:(()=>import("../tsv-EB3LRXYX.js"))},{id:"tsx",name:"TSX",import:(()=>import("../tsx-Y5YXGNIX.js"))},{id:"turtle",name:"Turtle",import:(()=>import("../turtle-KM6UGYIQ.js"))},{id:"twig",name:"Twig",import:(()=>import("../twig-JAL4753Y.js"))},{id:"typescript",name:"TypeScript",aliases:["ts","cts","mts"],import:(()=>import("../typescript-ZF5AMNEZ.js"))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>import("../typespec-6JSRRA42.js"))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>import("../typst-ZOSAUKL5.js"))},{id:"v",name:"V",import:(()=>import("../v-HVLBO3DI.js"))},{id:"vala",name:"Vala",import:(()=>import("../vala-WWRVCJNF.js"))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>import("../vb-XFFF4O73.js"))},{id:"verilog",name:"Verilog",import:(()=>import("../verilog-XTDPJNP7.js"))},{id:"vhdl",name:"VHDL",import:(()=>import("../vhdl-OCZJ2AOZ.js"))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>import("../viml-PVA3ZJ5L.js"))},{id:"vue",name:"Vue",import:(()=>import("../vue-D6SXQNWM.js"))},{id:"vue-html",name:"Vue HTML",import:(()=>import("../vue-html-G4DE7FYD.js"))},{id:"vue-vine",name:"Vue Vine",import:(()=>import("../vue-vine-T6MFB2MU.js"))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>import("../vyper-SBDFKHRI.js"))},{id:"wasm",name:"WebAssembly",import:(()=>import("../wasm-SXNE4SKX.js"))},{id:"wenyan",name:"Wenyan",aliases:["\u6587\u8A00"],import:(()=>import("../wenyan-PMSCJP7P.js"))},{id:"wgsl",name:"WGSL",import:(()=>import("../wgsl-DOXQU7M4.js"))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>import("../wikitext-LGNEKWDX.js"))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>import("../wit-G62U2KBE.js"))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>import("../wolfram-YTZHUYN6.js"))},{id:"xml",name:"XML",import:(()=>import("../xml-WGLM4CWK.js"))},{id:"xsl",name:"XSL",import:(()=>import("../xsl-KAAH2GEK.js"))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>import("../yaml-JGEBDSVI.js"))},{id:"zenscript",name:"ZenScript",import:(()=>import("../zenscript-QQQPZNJ7.js"))},{id:"zig",name:"Zig",import:(()=>import("../zig-6LJUAPBA.js"))}],Gi=Object.fromEntries(nr.map(e=>[e.id,e.import])),ji=Object.fromEntries(nr.flatMap(e=>e.aliases?.map(t=>[t,e.import])||[])),la={...Gi,...ji};f();var Bp=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>import("../andromeeda-XSK3JERF.js"))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>import("../aurora-x-CGSVHL4H.js"))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>import("../ayu-dark-XYI57HMC.js"))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>import("../ayu-light-4PSGMDIC.js"))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>import("../ayu-mirage-DU5SNMZX.js"))},{id:"catppuccin-frappe",displayName:"Catppuccin Frapp\xE9",type:"dark",import:(()=>import("../catppuccin-frappe-UZ4N3Z4I.js"))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>import("../catppuccin-latte-GCOWYLZG.js"))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>import("../catppuccin-macchiato-PJD7W5WJ.js"))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>import("../catppuccin-mocha-RRH4FOBS.js"))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>import("../dark-plus-PSM5XP2I.js"))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>import("../dracula-2VHT5LK5.js"))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>import("../dracula-soft-MSCUO73T.js"))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>import("../everforest-dark-AGVJEQ35.js"))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>import("../everforest-light-62GPFKVJ.js"))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>import("../github-dark-5OJVMBCE.js"))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>import("../github-dark-default-4WERFSZW.js"))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>import("../github-dark-dimmed-7VD3SZKC.js"))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>import("../github-dark-high-contrast-FVMMS656.js"))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>import("../github-light-SE4LEKO7.js"))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>import("../github-light-default-TV7BYQGI.js"))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>import("../github-light-high-contrast-WKO4I3G7.js"))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>import("../gruvbox-dark-hard-LOYZQIGI.js"))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>import("../gruvbox-dark-medium-UIMSJJ6K.js"))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>import("../gruvbox-dark-soft-PU6RNTTO.js"))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>import("../gruvbox-light-hard-ZQJ7XSZF.js"))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>import("../gruvbox-light-medium-CD3ZGYV6.js"))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>import("../gruvbox-light-soft-S74MAGOM.js"))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>import("../horizon-EAAZ4KVN.js"))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>import("../houston-UNRWGR67.js"))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>import("../kanagawa-dragon-BOSCCB42.js"))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>import("../kanagawa-lotus-NXMB2IVI.js"))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>import("../kanagawa-wave-YOHS63UF.js"))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>import("../laserwave-TS4AG4VO.js"))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>import("../light-plus-2HYW3NJ6.js"))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>import("../material-theme-KPDVFAGV.js"))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>import("../material-theme-darker-GVSTMSNT.js"))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>import("../material-theme-lighter-JWZNUXUH.js"))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>import("../material-theme-ocean-MU4N3XNQ.js"))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>import("../material-theme-palenight-VMWD73WM.js"))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>import("../min-dark-ASEVSA24.js"))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>import("../min-light-3H54BB3D.js"))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>import("../monokai-5QWQOFN6.js"))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>import("../night-owl-4QQBS2UX.js"))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>import("../night-owl-light-HR6A2OQO.js"))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>import("../nord-XK3AUNCF.js"))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>import("../one-dark-pro-ZV7CEA5M.js"))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>import("../one-light-FKZJCKM6.js"))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>import("../plastic-SXCQPKYC.js"))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>import("../poimandres-S3UYVG4O.js"))},{id:"red",displayName:"Red",type:"dark",import:(()=>import("../red-A6OC2HVL.js"))},{id:"rose-pine",displayName:"Ros\xE9 Pine",type:"dark",import:(()=>import("../rose-pine-GLWOWPBK.js"))},{id:"rose-pine-dawn",displayName:"Ros\xE9 Pine Dawn",type:"light",import:(()=>import("../rose-pine-dawn-HYE6T7LV.js"))},{id:"rose-pine-moon",displayName:"Ros\xE9 Pine Moon",type:"dark",import:(()=>import("../rose-pine-moon-VHVTDDVO.js"))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>import("../slack-dark-OPW5CYSY.js"))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>import("../slack-ochin-WTVMYBFH.js"))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>import("../snazzy-light-5UQ56PC5.js"))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>import("../solarized-dark-DSMP6D7D.js"))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>import("../solarized-light-3IZTZCIV.js"))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>import("../synthwave-84-JWI6CVJZ.js"))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>import("../tokyo-night-SRK4SADJ.js"))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>import("../vesper-WIZFPFI7.js"))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>import("../vitesse-black-PEGI4HJX.js"))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>import("../vitesse-dark-M2ZAGPXG.js"))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>import("../vitesse-light-RICZI4IG.js"))}],zi=Object.fromEntries(Bp.map(e=>[e.id,e.import]));f();var ua=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function Ep(){return 2147483648}function _p(){return typeof performance<"u"?performance.now():Date.now()}var Np=(e,t)=>e+(t-e%t)%t;async function Up(e){let t,a,o={};function r(m){a=m,o.HEAPU8=new Uint8Array(m),o.HEAPU32=new Uint32Array(m)}function s(m,h,I){o.HEAPU8.copyWithin(m,h,h+I)}function n(m){try{return t.grow(m-a.byteLength+65535>>>16),r(t.buffer),1}catch{}}function i(m){let h=o.HEAPU8.length;m=m>>>0;let I=Ep();if(m>I)return!1;for(let L=1;L<=4;L*=2){let S=h*(1+.2/L);S=Math.min(S,m+100663296);let C=Math.min(I,Np(Math.max(m,S),65536));if(n(C))return!0}return!1}let l=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function u(m,h,I=1024){let L=h+I,S=h;for(;m[S]&&!(S>=L);)++S;if(S-h>16&&m.buffer&&l)return l.decode(m.subarray(h,S));let C="";for(;h<S;){let g=m[h++];if(!(g&128)){C+=String.fromCharCode(g);continue}let y=m[h++]&63;if((g&224)===192){C+=String.fromCharCode((g&31)<<6|y);continue}let P=m[h++]&63;if((g&240)===224?g=(g&15)<<12|y<<6|P:g=(g&7)<<18|y<<12|P<<6|m[h++]&63,g<65536)C+=String.fromCharCode(g);else{let v=g-65536;C+=String.fromCharCode(55296|v>>10,56320|v&1023)}}return C}function c(m,h){return m?u(o.HEAPU8,m,h):""}let d={emscripten_get_now:_p,emscripten_memcpy_big:s,emscripten_resize_heap:i,fd_write:()=>0};async function p(){let h=await e({env:d,wasi_snapshot_preview1:d});t=h.memory,r(t.buffer),Object.assign(o,h),o.UTF8ToString=c}return await p(),o}var Op=Object.defineProperty,Hp=(e,t,a)=>t in e?Op(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,ne=(e,t,a)=>Hp(e,typeof t!="symbol"?t+"":t,a),ue=null;function qp(e){throw new ua(e.UTF8ToString(e.getLastOnigError()))}var Za=class e{constructor(t){ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16Value"),ne(this,"utf8Value"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16");let a=t.length,o=e._utf8ByteLength(t),r=o!==a,s=r?new Uint32Array(a+1):null;r&&(s[a]=o);let n=r?new Uint32Array(o+1):null;r&&(n[o]=a);let i=new Uint8Array(o),l=0;for(let u=0;u<a;u++){let c=t.charCodeAt(u),d=c,p=!1;if(c>=55296&&c<=56319&&u+1<a){let m=t.charCodeAt(u+1);m>=56320&&m<=57343&&(d=(c-55296<<10)+65536|m-56320,p=!0)}r&&(s[u]=l,p&&(s[u+1]=l),d<=127?n[l+0]=u:d<=2047?(n[l+0]=u,n[l+1]=u):d<=65535?(n[l+0]=u,n[l+1]=u,n[l+2]=u):(n[l+0]=u,n[l+1]=u,n[l+2]=u,n[l+3]=u)),d<=127?i[l++]=d:d<=2047?(i[l++]=192|(d&1984)>>>6,i[l++]=128|(d&63)>>>0):d<=65535?(i[l++]=224|(d&61440)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0):(i[l++]=240|(d&1835008)>>>18,i[l++]=128|(d&258048)>>>12,i[l++]=128|(d&4032)>>>6,i[l++]=128|(d&63)>>>0),p&&u++}this.utf16Length=a,this.utf8Length=o,this.utf16Value=t,this.utf8Value=i,this.utf16OffsetToUtf8=s,this.utf8OffsetToUtf16=n}static _utf8ByteLength(t){let a=0;for(let o=0,r=t.length;o<r;o++){let s=t.charCodeAt(o),n=s,i=!1;if(s>=55296&&s<=56319&&o+1<r){let l=t.charCodeAt(o+1);l>=56320&&l<=57343&&(n=(s-55296<<10)+65536|l-56320,i=!0)}n<=127?a+=1:n<=2047?a+=2:n<=65535?a+=3:a+=4,i&&o++}return a}createString(t){let a=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,a),a}},Ya=class He{constructor(t){if(ne(this,"id",++He.LAST_ID),ne(this,"_onigBinding"),ne(this,"content"),ne(this,"utf16Length"),ne(this,"utf8Length"),ne(this,"utf16OffsetToUtf8"),ne(this,"utf8OffsetToUtf16"),ne(this,"ptr"),!ue)throw new ua("Must invoke loadWasm first.");this._onigBinding=ue,this.content=t;let a=new Za(t);this.utf16Length=a.utf16Length,this.utf8Length=a.utf8Length,this.utf16OffsetToUtf8=a.utf16OffsetToUtf8,this.utf8OffsetToUtf16=a.utf8OffsetToUtf16,this.utf8Length<1e4&&!He._sharedPtrInUse?(He._sharedPtr||(He._sharedPtr=ue.omalloc(1e4)),He._sharedPtrInUse=!0,ue.HEAPU8.set(a.utf8Value,He._sharedPtr),this.ptr=He._sharedPtr):this.ptr=a.createString(ue)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===He._sharedPtr?He._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};ne(Ya,"LAST_ID",0);ne(Ya,"_sharedPtr",0);ne(Ya,"_sharedPtrInUse",!1);var Vi=Ya,lr=class{constructor(t){if(ne(this,"_onigBinding"),ne(this,"_ptr"),!ue)throw new ua("Must invoke loadWasm first.");let a=[],o=[];for(let i=0,l=t.length;i<l;i++){let u=new Za(t[i]);a[i]=u.createString(ue),o[i]=u.utf8Length}let r=ue.omalloc(4*t.length);ue.HEAPU32.set(a,r/4);let s=ue.omalloc(4*t.length);ue.HEAPU32.set(o,s/4);let n=ue.createOnigScanner(r,s,t.length);for(let i=0,l=t.length;i<l;i++)ue.ofree(a[i]);ue.ofree(s),ue.ofree(r),n===0&&qp(ue),this._onigBinding=ue,this._ptr=n}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,a,o){let r=0;if(typeof o=="number"&&(r=o),typeof t=="string"){t=new Vi(t);let s=this._findNextMatchSync(t,a,!1,r);return t.dispose(),s}return this._findNextMatchSync(t,a,!1,r)}_findNextMatchSync(t,a,o,r){let s=this._onigBinding,n=s.findNextOnigScannerMatch(this._ptr,t.id,t.ptr,t.utf8Length,t.convertUtf16OffsetToUtf8(a),r);if(n===0)return null;let i=s.HEAPU32,l=n/4,u=i[l++],c=i[l++],d=[];for(let p=0;p<c;p++){let m=t.convertUtf8OffsetToUtf16(i[l++]),h=t.convertUtf8OffsetToUtf16(i[l++]);d[p]={start:m,end:h,length:h-m}}return{index:u,captureIndices:d}}};function Wp(e){return typeof e.instantiator=="function"}function Gp(e){return typeof e.default=="function"}function jp(e){return typeof e.data<"u"}function zp(e){return typeof Response<"u"&&e instanceof Response}function Vp(e){return typeof ArrayBuffer<"u"&&(e instanceof ArrayBuffer||ArrayBuffer.isView(e))||typeof Buffer<"u"&&Buffer.isBuffer?.(e)||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer||typeof Uint32Array<"u"&&e instanceof Uint32Array}var Ja;function $p(e){if(Ja)return Ja;async function t(){ue=await Up(async a=>{let o=e;return o=await o,typeof o=="function"&&(o=await o(a)),typeof o=="function"&&(o=await o(a)),Wp(o)?o=await o.instantiator(a):Gp(o)?o=await o.default(a):(jp(o)&&(o=o.data),zp(o)?typeof WebAssembly.instantiateStreaming=="function"?o=await Xp(o)(a):o=await Kp(o)(a):Vp(o)?o=await ir(o)(a):o instanceof WebAssembly.Module?o=await ir(o)(a):"default"in o&&o.default instanceof WebAssembly.Module&&(o=await ir(o.default)(a))),"instance"in o&&(o=o.instance),"exports"in o&&(o=o.exports),o})}return Ja=t(),Ja}function ir(e){return t=>WebAssembly.instantiate(e,t)}function Xp(e){return t=>WebAssembly.instantiateStreaming(e,t)}function Kp(e){return async t=>{let a=await e.arrayBuffer();return WebAssembly.instantiate(a,t)}}async function $i(e){return e&&await $p(e),{createScanner(t){return new lr(t.map(a=>typeof a=="string"?a:a.source))},createString(t){return new Vi(t)}}}var eo=qi({langs:la,themes:zi,engine:()=>$i(import("../wasm-ISCPKFD2.js"))}),{codeToHtml:Qp,codeToHast:Jp,codeToTokens:Zp,codeToTokensBase:Yp,codeToTokensWithThemes:em,getSingletonHighlighter:tm,getLastGrammarState:am}=Wi(eo,{guessEmbeddedLanguages:Bi});var Xi=new Set(Object.keys(la)),ur=new Map,dr=new Map,Tt=new Map,om=(e,t)=>`${e}-${t[0]}-${t[1]}`,rm=(e,t,a)=>{let o=e.slice(0,100),r=e.length>100?e.slice(-100):"";return`${t}:${a[0]}:${a[1]}:${e.length}:${o}:${r}`},sm=(e,t)=>{let a=om(e,t);if(ur.has(a))return ur.get(a);let o=eo({themes:t,langs:[e]});return ur.set(a,o),o};function nm(e={}){var t;let a=(t=e.themes)!=null?t:["github-light","github-dark"];return{name:"shiki",type:"code-highlighter",supportsLanguage(o){return Xi.has(o)},getSupportedLanguages(){return Array.from(Xi)},getThemes(){return a},highlight({code:o,language:r,themes:s},n){let i=rm(o,r,s);return dr.has(i)?dr.get(i):(n&&(Tt.has(i)||Tt.set(i,new Set),Tt.get(i).add(n)),sm(r,s).then(l=>{let u=l.getLoadedLanguages().includes(r)?r:"text",c=l.codeToTokens(o,{lang:u,themes:{light:s[0],dark:s[1]}});dr.set(i,c);let d=Tt.get(i);if(d){for(let p of d)p(c);Tt.delete(i)}}).catch(l=>{console.error("[Streamdown Code] Failed to highlight code:",l),Tt.delete(i)}),null)}}}var Ki=nm();import{memo as dm}from"react";f();f();import{useEffect as im,useRef as to,useState as lm}from"react";var um=5,Qi=400;function Ji(e,t,a={}){let{msPerChar:o=um}=a,[r,s]=lm(t?"":e),n=to(e),i=to(t?0:e.length),l=to(0),u=to(null);return(e.length<i.current||!e.startsWith(r.slice(0,i.current)))&&(i.current=t?0:e.length),n.current=e,im(()=>{if(!t){u.current!==null&&(cancelAnimationFrame(u.current),u.current=null),i.current=e.length,s(e);return}if(n.current.length-i.current>Qi&&(i.current=n.current.length-Qi),u.current!==null)return;let d=p=>{let m=n.current;if(i.current>=m.length){u.current=null;return}l.current===0&&(l.current=p);let h=p-l.current;if(h>=o){let I=Math.min(Math.floor(h/o),m.length-i.current);i.current+=I,s(m.slice(0,i.current)),l.current=p}u.current=requestAnimationFrame(d)};return u.current=requestAnimationFrame(d),()=>{u.current!==null&&(cancelAnimationFrame(u.current),u.current=null)}},[e,t,o]),r}import{jsx as ao}from"react/jsx-runtime";var cr=({className:e,from:t,children:a,...o})=>ao("div",{className:D("ww:group ww:flex ww:w-full",t==="user"?"is-user ww:ml-auto ww:max-w-[80%] ww:flex-col ww:items-end":"is-assistant ww:flex-col",e),...o,children:ao("div",{className:D("ww:flex ww:min-w-0 ww:flex-col ww:gap-2","ww:w-full"),children:a})}),fr=({children:e,className:t,...a})=>ao("div",{className:D("ww:flex ww:w-fit ww:min-w-0 ww:max-w-full ww:flex-col ww:gap-2 ww:overflow-hidden ww:text-base","ww:group-[.is-user]:ml-auto ww:group-[.is-user]:rounded-lg ww:group-[.is-user]:bg-user-bubble ww:group-[.is-user]:px-4 ww:group-[.is-user]:py-3 ww:group-[.is-user]:text-primary-foreground","ww:group-[.is-assistant]:text-foreground",t),...a,children:e}),cm={cjk:Bo,code:Ki},fm={cjk:Bo},pm={enabled:!1};function mm({className:e,linkSafety:t,isStreaming:a,children:o,...r}){let n=Ji(typeof o=="string"?o:"",!!a),i=typeof o=="string"?n:o;return ao(vt,{className:D("ww:size-full ww:[&>*:first-child]:mt-0 ww:[&>*:last-child]:mb-0",e),linkSafety:t??pm,plugins:a?fm:cm,...r,children:i})}var oo=dm(mm,(e,t)=>e.children===t.children&&e.isStreaming===t.isStreaming);oo.displayName="MessageResponse";f();import{createContext as xm,memo as hr,useCallback as Lm,useContext as Cm,useEffect as pr,useMemo as Im,useRef as Zi,useState as mr}from"react";f();import{memo as hm}from"react";import{jsx as wm}from"react/jsx-runtime";var gm=({as:e="span",className:t,duration:a=2,style:o,children:r,...s})=>{let n={backgroundImage:"linear-gradient(90deg, var(--ww-color-muted-foreground) 0%, var(--ww-color-muted-foreground) 40%, var(--ww-color-foreground) 50%, var(--ww-color-muted-foreground) 60%, var(--ww-color-muted-foreground) 100%)",backgroundSize:"250% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:`ww-shimmer ${a}s linear infinite`,...o};return wm(e,{"data-waniwani-shimmer":"",className:D("ww:inline-block",t),style:n,...s,children:r})},et=hm(gm);et.displayName="Shimmer";import{Fragment as bm,jsx as Re,jsxs as km}from"react/jsx-runtime";var Yi=xm(null);function el(){let e=Cm(Yi);if(!e)throw new Error("Reasoning components must be used within <Reasoning>");return e}var Sm=1e3,ym=1e3,gr=hr(({className:e,isStreaming:t=!1,open:a,defaultOpen:o,onOpenChange:r,duration:s,children:n,...i})=>{let l=o??t,u=o===!1,c=a!==void 0,[d,p]=mr(l),m=c?a:d,h=Lm(R=>{c||p(R),r?.(R)},[c,r]),[I,L]=mr(void 0),S=s??I,C=Zi(t),[g,y]=mr(!1),P=Zi(null);pr(()=>{t?(C.current=!0,P.current===null&&(P.current=Date.now())):P.current!==null&&(L(Math.ceil((Date.now()-P.current)/ym)),P.current=null)},[t]),pr(()=>{t&&!m&&!u&&h(!0)},[t,m,u,h]),pr(()=>{if(C.current&&!t&&m&&!g){let R=setTimeout(()=>{h(!1),y(!0)},Sm);return()=>clearTimeout(R)}},[t,m,g,h]);let v=Im(()=>({isStreaming:t,isOpen:m,setIsOpen:h,duration:S}),[t,m,h,S]);return Re(Yi.Provider,{value:v,children:Re("div",{className:D("ww:mb-4 ww:flex ww:flex-col ww:gap-2",e),"data-state":m?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...i,children:n})})});gr.displayName="Reasoning";var wr=hr(({className:e,children:t,getThinkingMessage:a,onClick:o,...r})=>{let{t:s}=z(),{isStreaming:n,isOpen:i,duration:l,setIsOpen:u}=el(),d=a??((p,m)=>p||m===0?Re(et,{duration:1.6,children:s.reasoning.thinking}):m===void 0?Re("span",{children:s.reasoning.thoughtBrief}):Re("span",{children:s.reasoning.thoughtForSeconds(m)}));return Re("button",{type:"button","aria-expanded":i,onClick:p=>{u(!i),o?.(p)},className:D("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),...r,children:t??km(bm,{children:[Re(Ot,{className:"ww:size-4 ww:shrink-0"}),d(n,l),Re(rt,{className:D("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",i&&"ww:rotate-180")})]})})});wr.displayName="ReasoningTrigger";var xr=hr(({className:e,children:t,...a})=>{let{isOpen:o}=el();return Re("div",{className:D("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:Re("div",{className:"ww:min-h-0 ww:overflow-hidden",children:Re("div",{className:D("ww:text-sm ww:text-muted-foreground",e),...a,children:Re(vt,{children:t})})})})});xr.displayName="ReasoningContent";f();import{createContext as Tm,useCallback as Pm,useContext as rl,useEffect as vm,useMemo as Cr,useRef as Am,useState as Ir}from"react";import{Fragment as ol,jsx as V,jsxs as tt}from"react/jsx-runtime";function Rm(e,t=80){if(e==null)return String(e);if(typeof e!="object")return String(e).slice(0,t);if(Array.isArray(e))return`Array(${e.length})`;let a=JSON.stringify(e);if(a.length<=t)return a;let o=Object.entries(e),r=[],s=t-2;for(let[n,i]of o){if(s<=8)break;let l=n.length>4?`${n.slice(0,4)}\u2026`:n,u;typeof i=="string"?u=i.length>2?`'${i.slice(0,1)}\u2026`:`'${i}'`:Array.isArray(i)?u=`Array(${i.length})`:typeof i=="object"&&i!==null?u="{\u2026}":u=String(i);let c=`${l}\u2009${u}`;r.push(c),s-=c.length+3}return`{${r.join(", ")}}`}function Mm({text:e,className:t}){let{t:a}=z(),[o,r]=Ir(!1),s=Am(null);vm(()=>()=>{s.current&&clearTimeout(s.current)},[]);let n=Pm(async i=>{i.stopPropagation();try{await navigator.clipboard.writeText(e),r(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r(!1),2e3)}catch{}},[e]);return V(Ne,{variant:"ghost",size:"sm",onClick:n,className:D("ww:h-auto ww:gap-1 ww:px-1.5 ww:py-0.5 ww:text-xs ww:text-muted-foreground ww:hover:text-foreground",t),children:o?tt(ol,{children:[V(Ht,{className:"ww:size-3.5"}),V("span",{children:a.tool.copied})]}):tt(ol,{children:[V(Wt,{className:"ww:size-3.5"}),V("span",{children:a.tool.copy})]})})}function sl({data:e,label:t,className:a,...o}){let[r,s]=Ir(!1),n=Cr(()=>JSON.stringify(e,null,2),[e]),i=Rm(e);return tt("div",{className:D("ww:rounded-lg ww:bg-tool-card",a),...o,children:[tt("div",{className:"ww:flex ww:items-center ww:justify-between ww:px-3 ww:pt-2.5 ww:pb-1.5",children:[V("span",{className:"ww:text-xs ww:font-medium ww:text-muted-foreground",children:t}),V(Mm,{text:n})]}),tt("button",{type:"button",onClick:()=>s(l=>!l),className:"ww:flex ww:w-full ww:items-start ww:gap-2 ww:px-3 ww:pb-3 ww:text-left",children:[V(qt,{className:D("ww:mt-0.5 ww:size-3.5 ww:shrink-0 ww:text-muted-foreground ww:transition-transform ww:duration-150",r&&"ww:rotate-90")}),r?V("pre",{className:"ww:overflow-x-auto ww:text-xs ww:font-mono ww:text-foreground ww:whitespace-pre-wrap ww:break-all",children:V("code",{children:n})}):V("span",{className:"ww:truncate ww:text-xs ww:font-mono ww:text-foreground/80",children:i})]})]})}var Sr=Tm({open:!1,toggle:()=>{}});function nl({className:e,defaultOpen:t=!1,children:a,...o}){let[r,s]=Ir(t);return V(Sr.Provider,{value:{open:r,toggle:()=>s(n=>!n)},children:V("div",{className:D("ww:mb-4 ww:w-full",e),"data-state":r?"open":"closed",style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:a})})}function il({className:e,title:t,state:a,...o}){let{open:r,toggle:s}=rl(Sr),n=a==="input-available"||a==="input-streaming",i=t??"";return tt("button",{type:"button",onClick:s,className:D("ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground ww:transition-colors ww:hover:text-foreground",e),"aria-expanded":r,...o,children:[V(Ge,{className:"ww:size-4 ww:shrink-0"}),V("span",{className:"ww:truncate",children:n?V(et,{duration:1.6,children:i}):i}),V(rt,{className:D("ww:size-4 ww:shrink-0 ww:transition-transform ww:duration-200",r&&"ww:rotate-180")})]})}function ll({className:e,title:t,state:a,...o}){let r=a==="input-available"||a==="input-streaming",s=t??"";return tt("div",{className:D("ww:mb-4 ww:flex ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...o,children:[V(Ge,{className:"ww:size-4 ww:shrink-0"}),V("span",{className:"ww:truncate",children:r?V(et,{duration:1.6,children:s}):s})]})}function ul({className:e,children:t,...a}){let{open:o}=rl(Sr);return V("div",{className:D("ww:grid ww:transition-[grid-template-rows,opacity] ww:duration-200 ww:ease-out",o?"ww:grid-rows-[1fr] ww:opacity-100":"ww:grid-rows-[0fr] ww:opacity-0"),children:V("div",{className:"ww:min-h-0 ww:overflow-hidden",children:V("div",{className:D("ww:mt-2 ww:space-y-3 ww:rounded-lg ww:border ww:border-border ww:bg-background ww:p-3",e),...a,children:t})})})}function dl({className:e,input:t,debug:a,...o}){let{t:r}=z(),s=Cr(()=>{if(!a&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:n,...i}=t;return i}return t},[t,a]);return V(sl,{data:s,label:r.tool.request,className:e,...o})}function Lr(e){if(!(typeof e!="object"||e===null))return e}function cl(e){return Lr(e?.ui)}function fl(e){return Lr(Lr(e)?._meta)}function tl(e){if(!e)return;let t=cl(e)?.resourceUri;if(typeof t=="string"&&t.length>0)return t;let a=e["ui/resourceUri"];if(typeof a=="string"&&a.length>0)return a;let o=e["openai/outputTemplate"];if(typeof o=="string"&&o.length>0)return o}function al(e){return cl(e)?.autoHeight===!0}function ro(e,t,a){if(e){let o=tl(a?.[e]?._meta);if(o)return o}return tl(fl(t))}function pl(e,t,a){return e&&al(a?.[e]?._meta)?!0:al(fl(t))}function ml({className:e,output:t,errorText:a,debug:o,...r}){let{t:s}=z(),n=Cr(()=>{if(!o&&typeof t=="object"&&t!==null&&!Array.isArray(t)){let{_meta:i,...l}=t;return l}return t},[t,o]);return t||a?a?tt("div",{className:D("ww:space-y-2",e),...r,children:[V("h4",{className:"ww:text-xs ww:font-medium ww:uppercase ww:tracking-wide ww:text-muted-foreground",children:s.tool.error}),V("div",{className:"ww:rounded-lg ww:bg-destructive/10 ww:p-3 ww:text-xs ww:text-destructive",children:a})]}):V(sl,{data:n,label:s.tool.response,className:e,...r}):null}f();import{jsx as hl,jsxs as Dm}from"react/jsx-runtime";function Fm(e){return e.type==="text"||e.type==="reasoning"||e.type==="file"||"toolCallId"in e}function yr(e){return e.parts.some(Fm)}function gl(e,t){if(t!=="submitted"&&t!=="streaming")return!1;let a=e[e.length-1];return!a||a.role!=="assistant"?!0:!yr(a)}function wl({className:e,...t}){let{t:a}=z();return Dm("div",{"aria-live":"polite",className:D("ww:mb-4 ww:flex ww:w-full ww:items-center ww:gap-2 ww:text-sm ww:text-muted-foreground",e),style:{animation:"ww-fade-in 0.2s ease-out"},...t,children:[hl($t,{className:"ww:size-4 ww:shrink-0"}),hl(et,{duration:1.6,children:a.workingIndicator.default})]})}f();import{useCallback as Bm,useEffect as xl,useMemo as Em,useRef as Le,useState as Ll}from"react";import{jsx as Vm}from"react/jsx-runtime";var _m="/api/mcp/resource",Nm=500,Um=0,Om=16,Hm="2026-01-26",qm=300,Wm=3e3,Gm=3;function jm(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function zm(e,t,a){return ro(e,t,a)?!1:t._meta?.["waniwani/autoInjectResultText"]!==!1}function Cl({resourceUri:e,toolInput:t,toolResult:a,resourceEndpoint:o=_m,chatSessionId:r,isDark:s=!1,className:n,autoHeight:i=!1,onOpenLink:l,onFollowUp:u,onCallTool:c,onDisplayModeChange:d,isFullscreen:p=!1,toolDefinitions:m}){let h=Le(null),I=Le(t),L=Le(a),S=Le({width:0,height:0}),C=Le(null),g=Le(!1),y=Le(0),P=Le("inline"),[v,R]=Ll(Um),[A,_]=Ll(void 0),M=Le(l),T=Le(u),b=Le(c),B=Le(d),O=Le(r),F=Le(m);I.current=t,L.current=a,M.current=l,T.current=u,b.current=c,B.current=d,O.current=r,F.current=m;let J=Bm(ae=>i?Math.max(ae+Om,0):Math.min(Math.max(ae,50),Nm),[i]),Be=Em(()=>{let ae=o.includes("?")?"&":"?";return`${o}${ae}uri=${encodeURIComponent(e)}`},[o,e]),Ce=Le(s);return Ce.current=s,xl(()=>{if(!g.current)return;let ae=h.current;ae?.contentWindow&&ae.contentWindow.postMessage({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{theme:s?"dark":"light"}},"*")},[s]),xl(()=>{let ae=h.current;if(!ae)return;let he=!1,ye=!1,we=null,Ie=null,Ve=setTimeout(()=>{if(he||ye||y.current>=Gm)return;y.current+=1;let te=new URL(ae.src);te.searchParams.set("_retry",String(y.current)),ae.src=te.toString()},Wm),N=te=>{ae.contentWindow?.postMessage(te,"*")},le=te=>{if(he||te.source!==ae.contentWindow)return;let K=te.data;if(!K||typeof K!="object"||K.jsonrpc!=="2.0")return;let re=K.method,W=K.id;if(re==="ui/initialize"&&W!=null){ye=!0,clearTimeout(Ve),N({jsonrpc:"2.0",id:W,result:{protocolVersion:K.params?.protocolVersion??Hm,hostInfo:{name:"WaniWani Chat",version:"1.0.0"},hostCapabilities:{openLinks:{},message:{text:{}},tools:{},updateModelContext:{text:{},structuredContent:{}}},hostContext:{theme:Ce.current?"dark":"light",displayMode:P.current}}});return}if(re==="ui/notifications/initialized"){g.current=!0;let $=I.current,Q=L.current,q=Q._meta&&typeof Q._meta=="object"?Q._meta:null,Z=jm(O.current),se=q&&typeof q.waniwani=="object"&&q.waniwani!==null?q.waniwani:null,Pe=se||Z?{...se??{},...Z?{sessionId:Z}:{}}:void 0,$e=q||Pe?{...q??{},...Pe?{waniwani:Pe}:{}}:void 0;N({jsonrpc:"2.0",method:"ui/notifications/tool-input",params:{arguments:$}});let ht=Q.content??[{type:"text",text:JSON.stringify(Q)}];N({jsonrpc:"2.0",method:"ui/notifications/tool-result",params:{content:ht,structuredContent:Q.structuredContent,_meta:$e,meta:$e}});return}if(re==="ui/notifications/size-changed"){let $=K.params,Q=typeof $?.height=="number"?$.height:void 0,q=typeof $?.width=="number"?$.width:void 0,Z=S.current,se=Q!==void 0&&Q!==Z.height,Pe=q!==void 0&&q!==Z.width;if(!se&&!Pe)return;if(se&&Q!==void 0){Z.height=Q;let $e=J(Q),ht=ae.getBoundingClientRect().height;if(C.current&&(C.current.cancel(),C.current=null),R($e),ae.animate&&Math.abs(ht-$e)>2){let gt=ae.animate([{height:`${ht}px`},{height:`${$e}px`}],{duration:qm,easing:"ease-out",fill:"forwards"});C.current=gt,gt.onfinish=()=>{C.current===gt&&(gt.cancel(),C.current=null)}}}Pe&&i&&q!==void 0&&(Z.width=q,_(q));return}if(re==="ui/open-link"&&W!=null){let $=K.params?.url;typeof $=="string"&&(M.current?M.current($):window.open($,"_blank","noopener,noreferrer")),N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="ui/message"&&W!=null){if(T.current&&K.params){let $=K.params,Q=we;if(we=null,Ie){clearTimeout(Ie.timer);let q=Ie.text;Ie=null;let Z=($.content??[]).map(se=>se.text??"").join("").trim();$={...$,content:[{type:"text",text:`${Z}
80
80
 
81
- ${q}`}]}}P.current({...V,...K?{modelContext:K}:{}})}N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="ui/update-model-context"&&W!=null){ge=Dr(ge,X.params),N({jsonrpc:"2.0",id:W,result:{}});return}if(oe==="tools/call"&&W!=null){let V=b.current;if(!V){N({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let K=X.params?.name;V({name:K,arguments:X.params?.arguments??{}}).then(q=>{N({jsonrpc:"2.0",id:W,result:q});let J=q.content?.map(re=>re.text??"").join("").trim();J&&Nm(K,q,F.current)&&(Ce&&clearTimeout(Ce.timer),Ce={text:J,timer:setTimeout(()=>{if(me)return;let re=ge;ge=null,Ce=null,P.current?.({role:"user",content:[{type:"text",text:J}],...re?{modelContext:re}:{}})},500)})}).catch(q=>{let J=q instanceof Error?q.message:"Tool call failed";N({jsonrpc:"2.0",id:W,error:{code:-32e3,message:J}})});return}if(oe==="ui/request-display-mode"&&W!=null){let V=X.params?.mode,K=V==="fullscreen"||V==="inline"||V==="pip"?V:"inline";k.current=K,N({jsonrpc:"2.0",id:W,result:{mode:K}}),N({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:K}}),E.current?.(K);return}if(oe==="ui/resource-teardown"&&W!=null){N({jsonrpc:"2.0",id:W,result:{}});return}oe==="ping"&&W!=null&&N({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",ie),()=>{me=!0,clearTimeout(ze),Ce&&clearTimeout(Ce.timer),window.removeEventListener("message",ie)}},[i,Q]),Um("iframe",{ref:h,src:De,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:D(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":v,minWidth:p||!M?void 0:`min(${M}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as ua,jsxs as Om}from"react/jsx-runtime";function wl({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return Om("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&&ua("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}),ua("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&ua("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&ua("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>ua("button",{type:"button",onClick:()=>r?.(s),className:D("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as Hm}from"react";import{jsx as xl,jsxs as qm}from"react/jsx-runtime";var ro=class extends Hm{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?qm("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[xl("span",{children:"Widget failed to load"}),xl("button",{type:"button",onClick:()=>this.setState({hasError:!1}),className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:"Retry"})]}):this.props.children}};import{Fragment as Wm,jsx as ne,jsxs as ft}from"react/jsx-runtime";function Ll(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function Cl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let S=e[e.length-1],L=e.length>0,I=d!=null,C=!I&&fl(e,t);return ft(Wm,{children:[!I&&(!L&&o?ne(wl,{...o,onSuggestionSelect:r}):a&&ne(lr,{from:"assistant",children:ne(ur,{children:ne(ao,{children:a})})})),e.map(g=>{let y=g.parts.filter(P=>P.type==="text"),k=g.parts.filter(P=>P.type==="reasoning"),v=g.parts.filter(P=>P.type==="file"),A=g.parts.filter(P=>"toolCallId"in P),M=g===S&&g.role==="assistant",_=y.length>0,R=I?A.some(P=>P.toolCallId===d):!1;return I&&!R?ne("div",{style:{display:"none"}},g.id):g.role==="assistant"&&!Cr(g)?ne("div",{style:{display:"none"}},g.id):ft(lr,{from:g.role,children:[!R&&k.map((P,b)=>ft(pr,{isStreaming:P.state==="streaming",children:[ne(mr,{}),ne(hr,{children:P.text})]},`reasoning-${g.id}-${b}`)),A.map(P=>{let b="output"in P?P.output:void 0,E=oo(P.toolName,b,h),O=ul(P.toolName,b,h),F=P.toolCallId===d;return ft("div",{style:F?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[ne("div",{style:F?{display:"none"}:void 0,children:m?ft(al,{children:[ne(ol,{title:P.title??Ll(P.toolName),state:P.state}),ft(sl,{children:[ne(nl,{input:P.input,debug:p}),b!==void 0&&ne(dl,{output:b,errorText:"errorText"in P?P.errorText:void 0,debug:p})]})]}):ne(rl,{title:P.title??Ll(P.toolName),state:P.state})}),E&&s&&b!==void 0&&ne(ro,{children:ne(gl,{isFullscreen:F,resourceUri:E,toolInput:P.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:O,toolDefinitions:h,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?Q=>c(Q,{toolCallId:P.toolCallId,resourceUri:E,toolInput:P.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},autoHeight:O}):void 0})})]},P.toolCallId)}),!R&&ne("div",{children:ft(ur,{children:[v.length>0&&ne(mn,{files:v}),_?y.map((P,b)=>{let E=M&&t==="streaming"&&b===y.length-1;return ne(ao,{isStreaming:E,children:P.type==="text"?P.text:""},`${g.id}-${b}`)}):null]})})]},g.id)}),C&&ne(pl,{})]})}f();import{jsx as Il,jsxs as zm}from"react/jsx-runtime";var Gm="https://app.waniwani.ai/assets/waniwani-logo.svg",jm="https://waniwani.ai";function Sl(){return zm("a",{href:jm,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[Il("span",{children:"AI agent powered by"}),Il("img",{src:Gm,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as so}from"react/jsx-runtime";function yl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:so("div",{className:D("ww:px-4 ww:py-2",o),...r,children:so("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>so("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>so("button",{type:"button",onClick:()=>a(s),className:D("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as Vm,useRef as $m,useState as Xm}from"react";import{jsx as ee,jsxs as et}from"react/jsx-runtime";var bl=20;function Km(e){let t=Date.parse(e);if(Number.isNaN(t))return"";let a=Date.now()-t;return a<6e4?"just now":a<60*6e4?`${Math.floor(a/6e4)}m ago`:a<1440*6e4?`${Math.floor(a/(60*6e4))}h ago`:`${Math.floor(a/(1440*6e4))}d ago`}function Qm(){return et("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"New chat",children:[ee("title",{children:"New chat"}),ee("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ee("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Jm(){return et("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Thread history",children:[ee("title",{children:"Thread history"}),ee("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ee("polyline",{points:"3 4 3 9 8 9"}),ee("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ee("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function Zm(){return et("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":"Delete thread",children:[ee("title",{children:"Delete thread"}),ee("polyline",{points:"3 6 5 6 21 6"}),ee("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ee("path",{d:"M10 11v6"}),ee("path",{d:"M14 11v6"})]})}function kl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let[s,n]=Xm(!1),i=$m(null);Vm(()=>{if(!s)return;let c=d=>{let p=i.current;p&&(d.composedPath().includes(p)||n(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);let l=e.slice(0,bl),u=Math.max(0,e.length-bl);return et("div",{ref:i,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ee("button",{type:"button",onClick:a,title:"New chat","aria-label":"New chat",className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ee(Qm,{})}),ee("button",{type:"button",onClick:()=>n(c=>!c),title:"Thread history","aria-label":"Thread history","aria-expanded":s,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ee(Jm,{})}),s&&et("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:[l.length===0&&ee("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:"No previous chats yet."}),l.map(c=>{let d=c.threadId===t;return et("div",{className:`ww:flex ww:items-center ww:gap-2 ww:px-3 ww:py-2 ww:text-xs hover:ww:bg-foreground/5 ${d?"ww:bg-foreground/5":""}`,children:[et("button",{type:"button",onClick:()=>{o(c.threadId),n(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ee("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:c.title}),ee("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Km(c.updatedAt)})]}),ee("button",{type:"button",onClick:p=>{p.stopPropagation(),r(c.threadId)},title:"Delete thread","aria-label":"Delete thread",className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:ee(Zm,{})})]},c.threadId)}),u>0&&et("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:[u," older thread",u===1?"":"s"," hidden"]})]})]})}f();import{useCallback as Ym,useRef as eh}from"react";function Tl(e){let t=eh(e);return t.current=e,Ym(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as wh}from"@ai-sdk/react";import{useCallback as fe,useEffect as Fe,useRef as ue,useState as pt}from"react";f();import{DefaultChatTransport as th,uiMessageChunkSchema as ah}from"ai";function oh(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var no=class extends th{processResponseStream(t){let a="",o=ah(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
82
- `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=oh(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let S=await r(h);S.success&&n.enqueue(S.value)}}catch{}}}}))}};f();f();var rh="waniwani-memory";var ke="threads",io="by_memoryUserId",sh="by_updatedAt";var vl="memoryUserId",Pl="waniwani-memory-user-id",Ir=null;function Sr(){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 nh(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(ke)){let a=e.createObjectStore(ke,{keyPath:"threadId"});a.createIndex(io,"memoryUserId",{unique:!1}),a.createIndex(sh,"updatedAt",{unique:!1})}}async function yr(){return new Promise((e,t)=>{let a=indexedDB.open(rh,2);a.onupgradeneeded=o=>{nh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function ih(){return yr()}async function lh(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(vl);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function uh(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,vl);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function dh(){if(typeof indexedDB>"u")return null;try{let e=await ih();try{let t=await lh(e);if(t)return t;let a=Sr();return await uh(e,a),a}finally{e.close()}}catch{return null}}function ch(){try{let e=localStorage.getItem(Pl);if(e)return e;let t=Sr();return localStorage.setItem(Pl,t),t}catch{return null}}async function Al(){let e=await dh();if(e)return e;let t=ch();return t||(Ir||(Ir=Sr()),Ir)}var Rl=50,Ml=1e3;function lo(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 uo(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await yr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function br(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function kr(e){return await uo(async a=>{let s=a.transaction(ke,"readonly").objectStore(ke).index(io),i=(await br(s.getAll(e))??[]).filter(lo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Tr(e){return await uo(async a=>{let r=a.transaction(ke,"readonly").objectStore(ke),s=await br(r.get(e));return lo(s)?s:null})??null}async function Pr(e){if(!lo(e))return;let t=e.messages.length>Ml?{...e,messages:e.messages.slice(e.messages.length-Ml)}:e;await uo(async a=>{await new Promise((l,u)=>{let c=a.transaction(ke,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(ke).put(t)});let o=a.transaction(ke,"readwrite"),r=o.objectStore(ke),s=r.index(io),i=(await br(s.getAll(t.memoryUserId))??[]).filter(lo);if(i.length>Rl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Rl);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 Fl(e){await uo(async t=>(await new Promise((a,o)=>{let r=t.transaction(ke,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(ke).delete(e)}),null))}async function Dl(e){return(await kr(e))[0]?.threadId??null}function Bl(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 El="waniwani-visitor-id";function _l(e,t){return e.match(t)?.[1]??null}function fh(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=_l(e,o);if(r)return{name:a,version:r}}return null}function ph(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=_l(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function mh(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function hh(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function gh(){try{let a=localStorage.getItem(El);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await hh(e);try{localStorage.setItem(El,t)}catch{}return t}async function Nl(){let e=navigator.userAgent,[t,a]=await Promise.all([gh(),Al()]);return{userAgent:e,browser:fh(e),os:ph(e),deviceType:mh(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 xh="x-session-id",Lh=250;function Ul(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Xt()}function co(){return new Date().toISOString()}function Ol(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function Ch(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Hl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=ue(a),c=ue(o),d=ue(n);Fe(()=>{d.current=n},[n]);let p=ue(void 0),m=ue(null),[h,S]=pt(void 0),L=ue(h),[I,C]=pt(i),g=ue(I),[y,k]=pt([]),[v,A]=pt(!n),M=ue(void 0),_=ue(void 0),R=ue(void 0),P=ue(void 0),b=ue(0),E=ue(l);Fe(()=>{E.current=l},[l]);let O=fe(T=>{g.current=T,C(T),T&&E.current?.(T)},[]),F=fe(async()=>{if(!n)return;let T=m.current?.memoryUserId;if(!T)return;let U=await kr(T);k(U)},[n]),Q=fe(()=>L.current,[]),De=fe(T=>{let U=Ol(T);U&&L.current!==U&&(L.current=U,S(U))},[]),Le=fe(()=>{L.current=void 0,S(void 0)},[]);Fe(()=>{u.current=a},[a]),Fe(()=>{c.current=o},[o]),Fe(()=>{let T=!1,U=b.current;return(async()=>{try{let Pe=await Nl();if(T)return;m.current=Pe}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){A(!0);return}try{let Pe=i??await Dl(H);if(T||U!==b.current)return;if(Pe){let we=await Tr(Pe);if(T||U!==b.current)return;we&&we.memoryUserId===H&&(g.current=we.threadId,C(we.threadId),M.current=we.createdAt,_.current=we.title,we.sessionId&&(L.current=we.sessionId,S(we.sessionId)),oe(we.messages))}await F()}finally{T||A(!0)}})(),()=>{T=!0}},[]);let te=ue(new no({api:t,headers:()=>({...u.current}),body:()=>{let T={...c.current??{}},U=Object.hasOwn(T,"sessionId"),H=Ol(T.sessionId);if(H)De(H),T.sessionId=H;else if(U)Le(),delete T.sessionId;else{let Ae=Q();Ae&&(T.sessionId=Ae)}if(gt(p.current)&&(T.modelContext=p.current),m.current){let Ae=m.current;T.visitorContext={timezone:Ae.timezone,language:Ae.language,languages:Ae.languages,deviceType:Ae.deviceType,referrer:Ae.referrer,visitorId:Ae.visitorId};let He=typeof T.visitor=="object"&&T.visitor!==null?T.visitor:{},su=typeof He.client=="object"&&He.client!==null?He.client:{};T.visitor={...He,client:{...su,memoryUserId:Ae.memoryUserId}}}let Pe=typeof T.extra=="object"&&T.extra!==null&&!Array.isArray(T.extra)?T.extra:void 0,we=m.current?.memoryUserId,$e=m.current?.language,pa={};if(we&&(pa.memoryUserId=we),$e&&(pa.locale=$e),(Object.keys(pa).length>0||Pe)&&(T.extra={...pa,...Pe??{}}),d.current)if(Object.hasOwn(T,"threadId"))typeof T.threadId=="string"&&(g.current=T.threadId);else{let He=g.current;He||(He=Ul(),M.current=co(),_.current=void 0,O(He)),T.threadId=He}return T},fetch:(async(T,U)=>{let H=await fetch(T,U);return p.current=void 0,De(H.headers.get(xh)),H})})),me=ue(null),Se=ue(null),ge=ue({}),[Ce,ze]=pt(0),N=e.skipRemoteConfig===!0,ie=fe(async()=>{if(!N)try{let T=await Ch(t,u.current);ge.current=T,ze(U=>U+1)}catch(T){console.warn("[WaniWani] Failed to fetch tool definitions:",T instanceof Error?T.message:T)}},[t,N]);Fe(()=>{ie()},[ie]);let{messages:Y,sendMessage:X,setMessages:oe,status:W}=wh({messages:e.initialMessages,transport:te.current,onFinish({message:T}){s?.(),me.current&&(Se.current=T)},onError(T){console.warn("[WaniWani] Chat error:",T.message),me.current&&(me.current.reject(T),me.current=null)}}),V=ue(Y);Fe(()=>{V.current=Y},[Y]),Fe(()=>{if(W==="ready"&&me.current&&Se.current){let T=me.current,U=Se.current;me.current=null,Se.current=null,T.resolve(U)}},[W]);let[K,q]=pt(""),[J,re]=pt([]),Te=W==="submitted"||W==="streaming",Ve=fe(T=>{re(U=>U.filter(H=>H.id!==T))},[]),mt=Te&&J.length>0,ht=fe(T=>{let U=!!T.text?.trim(),H=!!T.files?.length;if(U||H){if(Te){if(J.length>0)return;re(Pe=>[...Pe,{id:Xt(),text:T.text||"",files:T.files??[],modelContext:T.modelContext}]),q("");return}p.current=T.modelContext,X({text:T.text||"",files:T.files}),r?.(T.text||""),q("")}},[X,r,Te,J.length]),Zl=fe(T=>new Promise((U,H)=>{me.current={resolve:U,reject:H},X({text:T}),r?.(T)}),[X,r]);Fe(()=>{if(W!=="ready"||J.length===0)return;let[T,...U]=J;re(U),p.current=T.modelContext,X({text:T.text,files:T.files.length>0?T.files:void 0}),r?.(T.text)},[W,X,r,J]);let Yl=fe(()=>{oe([]),re([]),Le(),q(""),ge.current={},ze(T=>T+1),ie()},[oe,Le,ie]),ca=fe(()=>{if(!d.current)return;let T=m.current?.memoryUserId,U=g.current,H=V.current;if(!(!T||!U||H.length===0)){if(M.current||(M.current=co()),!_.current){let Pe=H.find($e=>$e.role==="user"),we=Pe?Pe.parts.map($e=>"text"in $e&&typeof $e.text=="string"?$e.text:"").join(" "):"";_.current=Bl(we)}return{threadId:U,memoryUserId:T,title:_.current,messages:H,sessionId:L.current,createdAt:M.current,updatedAt:co()}}},[]),Rr=fe(async()=>{let T=ca();T&&(await Pr(T),await F())},[ca,F]);Fe(()=>{if(n&&v&&!(W==="submitted"||W==="streaming")&&Y.length!==0)return R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{R.current=void 0;let T=Rr().finally(()=>{P.current===T&&(P.current=void 0)});P.current=T},Lh),()=>{R.current&&clearTimeout(R.current)}},[n,v,Y,W,Rr]);let fa=fe(()=>{let T=P.current,U=R.current,H=U?ca():void 0;return U&&(clearTimeout(U),R.current=void 0),(async()=>{T&&await T,H&&(await Pr(H),await F())})()},[ca,F]),eu=fe(()=>{b.current+=1,fa(),oe([]),re([]),Le(),q("");let T=Ul();return M.current=co(),_.current=void 0,O(T),F(),T},[oe,Le,O,F,fa]),fo=fe(async T=>{b.current+=1;let U=b.current;if(await fa(),U!==b.current)return;let H=await Tr(T);U===b.current&&H&&(O(H.threadId),M.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,S(H.sessionId)):Le(),oe(H.messages),re([]),q(""))},[oe,Le,O,fa]),tu=fe(async T=>{if(g.current===T){b.current+=1,R.current&&(clearTimeout(R.current),R.current=void 0);let U=P.current;U&&await U}await Fl(T),await F(),g.current===T&&(oe([]),re([]),Le(),q(""),g.current=void 0,C(void 0),M.current=void 0,_.current=void 0)},[oe,Le,F]);Fe(()=>{n&&v&&i!==void 0&&i!==g.current&&fo(i)},[i,n,v,fo]);let au=fe(T=>{q(T.target.value)},[]),Mr=Y[Y.length-1],Fr=Y.length>0,ou=Te&&(!Fr||Mr.role==="user"),ru=ge.current;return{messages:Y,status:W,text:K,setText:q,handleSubmit:ht,handleTextChange:au,isLoading:Te,showLoaderBubble:ou,lastMessage:Mr,hasMessages:Fr,sendMessage:X,sendMessageAndWait:Zl,reset:Yl,queuedMessages:J,queueFull:mt,removeQueuedMessage:Ve,sessionId:h,toolDefinitions:ru,refreshToolDefinitions:ie,threads:y,activeThreadId:I,isThreadHistoryReady:v,startNewThread:eu,switchThread:fo,deleteThread:tu}}f();import{useEffect as ql,useRef as Ih,useState as Sh}from"react";var yh={debug:!1,eval:!1};function Wl(e="/api/waniwani",t,a=!1){let[o,r]=Sh(yh),s=Ih(t);return ql(()=>{s.current=t},[t]),ql(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as bh,useEffect as vr,useRef as kh,useState as Th}from"react";function Ph(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Gl(e){return typeof e=="object"&&e!==null&&"initial"in e}function jl(e){let{messages:t,status:a,config:o}=e,r=Gl(o)&&o.initial?o.initial:void 0,[s,n]=Th(r??[]),i=kh(a),l=o===!0||Gl(o)&&o.dynamic!==!1,u=bh(()=>{n([])},[]),c=t.length>0;vr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return vr(()=>{d?.role==="user"&&u()},[d,u]),vr(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(S=>S.role==="assistant");if(!m)return;let h=Ph(m);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as vh,useRef as Ah,useState as Rh}from"react";var Mh=50,Fh=30,Dh=2e3,zl=500;function Vl(e,t=!0){let[a,o]=Rh(""),r=Ah(void 0);return vh(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,zl)):r.current=setTimeout(l,Fh)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,Dh)):r.current=setTimeout(l,Mh)))};return r.current=setTimeout(l,zl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function $l(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Bh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var Eh={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function Xl(e){return{...Bh,...e}}function Kl(e){let t={};for(let[a,o]of Object.entries(Eh)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as pe,jsxs as da}from"react/jsx-runtime";var Oh=_h(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:S=!1,showToolCalls:L=!0}=t,I=m??"/api/waniwani",C=$l(I,t.headers),g=Xl(o),y=Kl(g),k=g.backgroundColor.replace("#",""),v=parseInt(k.substring(0,2),16),A=parseInt(k.substring(2,4),16),M=parseInt(k.substring(4,6),16),_=(v*299+A*587+M*114)/1e3<128,R=Wl(I,t.headers,t.skipRemoteConfig),P=h??R.debug,b=Hl({...t,api:I}),E=Tl({...t,api:I,sessionId:b.sessionId}),O=Vl(d,!b.text),[F,Q]=Jl(!1),[De,Le]=Jl(null),te=Ql(null),me=Ql(void 0),Se=Ar(()=>{let N=te.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let ie=N.querySelector("textarea");ie&&setTimeout(()=>ie.focus(),300),Q(!0),clearTimeout(me.current),me.current=setTimeout(()=>Q(!1),2e3)},[]),ge=jl({messages:b.messages,status:b.status,config:t.suggestions}),Ce=Ar(N=>{let ie=N.content.map(Y=>Y.text??"").join("").trim();ie&&b.handleSubmit({text:ie,files:[],modelContext:N.modelContext})},[b.handleSubmit]),ze=Ar(N=>{ge.clear(),b.handleSubmit({text:N,files:[]})},[ge.clear,b.handleSubmit]);return Uh(a,()=>({sendMessage:N=>{b.handleSubmit({text:N,files:[]}),Se()},sendMessageAndWait:N=>b.sendMessageAndWait(N),reset:b.reset,focus:Se,get messages(){return b.messages}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,Se]),Nh(()=>{if(!p)return;let N=ie=>{let Y=ie.detail,X=typeof Y?.message=="string"?Y.message:void 0;X&&b.handleSubmit({text:X,files:[]}),Se()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,b.handleSubmit,Se]),da("div",{ref:te,style:{...y,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:D("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[da("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[pe("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),pe(pn,{messages:b.messages,evalEnabled:R.eval,api:I}),S&&pe(kl,{threads:b.threads,activeThreadId:b.activeThreadId,onNewThread:b.startNewThread,onSelectThread:N=>{b.switchThread(N)},onDeleteThread:N=>{b.deleteThread(N)}})]}),da(js,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[pe(zs,{scrollClassName:De?"ww:!relative ww:!overflow-hidden":void 0,children:pe(Cl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:ze,resourceEndpoint:C,chatSessionId:b.sessionId,isDark:_,onFollowUp:Ce,onCallTool:E,fullscreenToolCallId:De,debug:P,showToolCalls:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(N,ie)=>{Le(N==="fullscreen"?ie.toolCallId:null)}})}),pe(Vs,{})]}),pe("div",{style:De?{display:"none"}:void 0,children:pe(yl,{suggestions:ge.suggestions,isLoading:ge.isLoading,onSelect:ze})}),pe("div",{style:De?{display:"none"}:void 0,children:pe(cn,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),pe("div",{style:De?{display:"none"}:void 0,children:pe("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:da("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[pe(Zs,{onSubmit:b.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:da("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&pe(tn,{}),pe(Ys,{onChange:b.handleTextChange,value:b.text,placeholder:O,className:"ww:min-h-0 ww:py-1 ww:px-0"}),pe(en,{status:b.status,disabled:b.queueFull})]})}),pe(Sl,{})]})})})]})});export{Oh as ChatCard,Yr as DevModeProvider,pu as InitializeNextJsInIframe,Xu as LoadingWidget,is as WidgetProvider,Xr as createResource,uu as createTool,po as detectPlatform,xa as getMockState,Rt as initializeMockOpenAI,iu as isMCPApps,nu as isOpenAI,du as registerTools,Jx as toNextJsHandler,os as unstable_useSendFollowUpWithGhostGuard,Ft as updateMockDisplayMode,tt as updateMockGlobal,Dt as updateMockTheme,Mt as updateMockToolOutput,ls as useCallTool,us as useDisplayMode,ds as useFlowAction,cs as useIsChatGptApp,fs as useLocale,ps as useMaxHeight,ms as useOpenExternal,hs as useRequestDisplayMode,gs as useSafeArea,ws as useSendFollowUp,xs as useTheme,Ca as useToolOutput,Ls as useToolResponseMetadata,Cs as useUpdateModelContext,G as useWidgetClient,Is as useWidgetState};
81
+ ${q}`}]}}T.current({...$,...Q?{modelContext:Q}:{}})}N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="ui/update-model-context"&&W!=null){we=Nr(we,K.params),N({jsonrpc:"2.0",id:W,result:{}});return}if(re==="tools/call"&&W!=null){let $=b.current;if(!$){N({jsonrpc:"2.0",id:W,error:{code:-32601,message:"tools/call not supported"}});return}let Q=K.params?.name;$({name:Q,arguments:K.params?.arguments??{}}).then(q=>{N({jsonrpc:"2.0",id:W,result:q});let Z=q.content?.map(se=>se.text??"").join("").trim();Z&&zm(Q,q,F.current)&&(Ie&&clearTimeout(Ie.timer),Ie={text:Z,timer:setTimeout(()=>{if(he)return;let se=we;we=null,Ie=null,T.current?.({role:"user",content:[{type:"text",text:Z}],...se?{modelContext:se}:{}})},500)})}).catch(q=>{let Z=q instanceof Error?q.message:"Tool call failed";N({jsonrpc:"2.0",id:W,error:{code:-32e3,message:Z}})});return}if(re==="ui/request-display-mode"&&W!=null){let $=K.params?.mode,Q=$==="fullscreen"||$==="inline"||$==="pip"?$:"inline";P.current=Q,N({jsonrpc:"2.0",id:W,result:{mode:Q}}),N({jsonrpc:"2.0",method:"ui/notifications/host-context-changed",params:{displayMode:Q}}),B.current?.(Q);return}if(re==="ui/resource-teardown"&&W!=null){N({jsonrpc:"2.0",id:W,result:{}});return}re==="ping"&&W!=null&&N({jsonrpc:"2.0",id:W,result:{}})};return window.addEventListener("message",le),()=>{he=!0,clearTimeout(Ve),Ie&&clearTimeout(Ie.timer),window.removeEventListener("message",le)}},[i,J]),Vm("iframe",{ref:h,src:Be,sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox",className:D(!p&&"ww:rounded-md ww:border ww:border-border",n),style:{height:p?"100%":v,minWidth:p||!A?void 0:`min(${A}px, 100%)`,width:"100%",border:"none",colorScheme:s?"dark":"auto"},title:"MCP App"})}f();import{jsx as da,jsxs as $m}from"react/jsx-runtime";function Il({icon:e,title:t,description:a,suggestions:o,onSuggestionSelect:r}){return $m("div",{className:"ww:flex ww:flex-col ww:items-center ww:justify-center ww:py-12 ww:px-6 ww:text-center ww:min-h-full",children:[e&&da("div",{className:"ww:mb-4 ww:flex ww:items-center ww:justify-center ww:size-12 ww:rounded-xl ww:bg-foreground ww:text-background",children:e}),da("h2",{className:"ww:text-lg ww:font-semibold ww:text-foreground",children:t}),a&&da("p",{className:"ww:mt-1 ww:text-sm ww:text-muted-foreground ww:max-w-sm",children:a}),o&&o.length>0&&da("div",{className:"ww:mt-6 ww:w-full ww:max-w-md ww:flex ww:flex-col ww:gap-2",children:o.map((s,n)=>da("button",{type:"button",onClick:()=>r?.(s),className:D("ww:w-full ww:text-left ww:rounded-xl ww:border ww:border-border ww:bg-background ww:px-4 ww:py-3 ww:text-sm","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})]})}f();import{Component as Xm}from"react";import{jsx as br,jsxs as Qm}from"react/jsx-runtime";function Km({onRetry:e}){let{t}=z();return Qm("div",{className:"ww:flex ww:items-center ww:justify-between ww:rounded-md ww:border ww:border-border ww:bg-muted/50 ww:px-4 ww:py-3 ww:text-sm ww:text-muted-foreground",children:[br("span",{children:t.widgetErrorBoundary.failedToLoad}),br("button",{type:"button",onClick:e,className:"ww:text-xs ww:font-medium ww:text-primary ww:hover:underline",children:t.widgetErrorBoundary.retry})]})}var so=class extends Xm{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){console.warn("[WaniWani] Widget failed to render:",t.message)}render(){return this.state.hasError?br(Km,{onRetry:()=>this.setState({hasError:!1})}):this.props.children}};import{Fragment as Jm,jsx as ie,jsxs as ft}from"react/jsx-runtime";function Sl(e){return e?e.replace(/[-_]/g," ").replace(/^\w/,t=>t.toUpperCase()):"Tool"}function yl({messages:e,status:t,welcomeMessage:a,welcome:o,onSuggestionSelect:r,resourceEndpoint:s,chatSessionId:n,isDark:i,onFollowUp:l,onCallTool:u,onWidgetDisplayModeChange:c,fullscreenToolCallId:d,debug:p,showToolCalls:m=!0,toolDefinitions:h}){let I=e[e.length-1],L=e.length>0,S=d!=null,C=!S&&gl(e,t);return ft(Jm,{children:[!S&&(!L&&o?ie(Il,{...o,onSuggestionSelect:r}):a&&ie(cr,{from:"assistant",children:ie(fr,{children:ie(oo,{children:a})})})),e.map(g=>{let y=g.parts.filter(T=>T.type==="text"),P=g.parts.filter(T=>T.type==="reasoning"),v=g.parts.filter(T=>T.type==="file"),R=g.parts.filter(T=>"toolCallId"in T),A=g===I&&g.role==="assistant",_=y.length>0,M=S?R.some(T=>T.toolCallId===d):!1;return S&&!M?ie("div",{style:{display:"none"}},g.id):g.role==="assistant"&&!yr(g)?ie("div",{style:{display:"none"}},g.id):ft(cr,{from:g.role,children:[!M&&P.map((T,b)=>ft(gr,{isStreaming:T.state==="streaming",children:[ie(wr,{}),ie(xr,{children:T.text})]},`reasoning-${g.id}-${b}`)),R.map(T=>{let b="output"in T?T.output:void 0,B=ro(T.toolName,b,h),O=pl(T.toolName,b,h),F=T.toolCallId===d;return ft("div",{style:F?{position:"absolute",inset:0,zIndex:10,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--ww-color-background)"}:void 0,children:[ie("div",{style:F?{display:"none"}:void 0,children:m?ft(nl,{children:[ie(il,{title:T.title??Sl(T.toolName),state:T.state}),ft(ul,{children:[ie(dl,{input:T.input,debug:p}),b!==void 0&&ie(ml,{output:b,errorText:"errorText"in T?T.errorText:void 0,debug:p})]})]}):ie(ll,{title:T.title??Sl(T.toolName),state:T.state})}),B&&s&&b!==void 0&&ie(so,{children:ie(Cl,{isFullscreen:F,resourceUri:B,toolInput:T.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},resourceEndpoint:s,chatSessionId:n,isDark:i,autoHeight:O,toolDefinitions:h,onFollowUp:l,onCallTool:u,onDisplayModeChange:c?J=>c(J,{toolCallId:T.toolCallId,resourceUri:B,toolInput:T.input??{},toolResult:{content:b.content,structuredContent:b.structuredContent,_meta:b._meta},autoHeight:O}):void 0})})]},T.toolCallId)}),!M&&ie("div",{children:ft(fr,{children:[v.length>0&&ie(Ln,{files:v}),_?y.map((T,b)=>{let B=A&&t==="streaming"&&b===y.length-1;return ie(oo,{isStreaming:B,children:T.type==="text"?T.text:""},`${g.id}-${b}`)}):null]})})]},g.id)}),C&&ie(wl,{})]})}f();import{jsx as bl,jsxs as eh}from"react/jsx-runtime";var Zm="https://app.waniwani.ai/assets/waniwani-logo.svg",Ym="https://waniwani.ai";function kl(){let{t:e}=z();return eh("a",{href:Ym,target:"_blank",rel:"noopener noreferrer",className:"ww:flex ww:items-center ww:gap-1.5 ww:text-[11px] ww:text-muted-foreground ww:opacity-70 hover:ww:opacity-100 ww:transition-opacity",children:[bl("span",{children:e.poweredBy.label}),bl("img",{src:Zm,alt:"WaniWani",width:72,height:10,"data-waniwani-logo":"",className:"ww:h-2.5 ww:w-auto"})]})}f();import{jsx as no}from"react/jsx-runtime";function Tl({suggestions:e,isLoading:t,onSelect:a,className:o,...r}){return e.length===0&&!t?null:no("div",{className:D("ww:px-4 ww:py-2",o),...r,children:no("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl ww:flex ww:flex-wrap ww:gap-2",children:t?[0,1,2].map(s=>no("div",{className:"ww:h-7 ww:rounded-full ww:bg-accent ww:animate-pulse",style:{width:`${60+s*20}px`}},s)):e.map((s,n)=>no("button",{type:"button",onClick:()=>a(s),className:D("ww:rounded-full ww:border ww:border-border ww:bg-background ww:px-3 ww:py-1 ww:text-xs","ww:text-foreground ww:hover:bg-accent ww:hover:border-primary/30","ww:transition-all ww:duration-200 ww:ease-out ww:cursor-pointer","ww:animate-[ww-fade-in_0.2s_ease-out_both]"),style:{animationDelay:`${n*50}ms`},children:s},s))})})}f();import{useEffect as th,useRef as ah,useState as oh}from"react";import{jsx as ee,jsxs as pt}from"react/jsx-runtime";var Pl=20;function rh({label:e}){return pt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ee("title",{children:e}),ee("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),ee("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function sh({label:e}){return pt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ee("title",{children:e}),ee("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),ee("polyline",{points:"3 4 3 9 8 9"}),ee("line",{x1:"12",y1:"7",x2:"12",y2:"12"}),ee("line",{x1:"12",y1:"12",x2:"15",y2:"14"})]})}function nh({label:e}){return pt("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",role:"img","aria-label":e,children:[ee("title",{children:e}),ee("polyline",{points:"3 6 5 6 21 6"}),ee("path",{d:"M19 6l-2 14a2 2 0 0 1-2 2H9a2 2 0 0 1-2-2L5 6"}),ee("path",{d:"M10 11v6"}),ee("path",{d:"M14 11v6"})]})}function vl({threads:e,activeThreadId:t,onNewThread:a,onSelectThread:o,onDeleteThread:r}){let{locale:s,t:n}=z(),[i,l]=oh(!1),u=ah(null);th(()=>{if(!i)return;let p=m=>{let h=u.current;h&&(m.composedPath().includes(h)||l(!1))};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]);let c=e.slice(0,Pl),d=Math.max(0,e.length-Pl);return pt("div",{ref:u,className:"ww:relative ww:flex ww:items-center ww:gap-1",children:[ee("button",{type:"button",onClick:a,title:n.threadMenu.newChat,"aria-label":n.threadMenu.newChat,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ee(rh,{label:n.threadMenu.newChat})}),ee("button",{type:"button",onClick:()=>l(p=>!p),title:n.threadMenu.threadHistory,"aria-label":n.threadMenu.threadHistory,"aria-expanded":i,className:"ww:p-1.5 ww:rounded-md ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/5 ww:transition-colors ww:cursor-pointer",children:ee(sh,{label:n.threadMenu.threadHistory})}),i&&pt("div",{role:"menu",className:"ww:absolute ww:right-0 ww:top-full ww:mt-1 ww:w-72 ww:max-h-80 ww:overflow-y-auto ww:rounded-lg ww:border ww:border-border ww:bg-background ww:shadow-lg ww:z-50",children:[c.length===0&&ee("div",{className:"ww:px-3 ww:py-3 ww:text-xs ww:text-muted-foreground",children:n.threadMenu.noPreviousChats}),c.map(p=>{let m=p.threadId===t,h=Date.parse(p.updatedAt);return pt("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:[pt("button",{type:"button",onClick:()=>{o(p.threadId),l(!1)},className:"ww:flex-1 ww:min-w-0 ww:text-left ww:cursor-pointer",children:[ee("div",{className:"ww:truncate ww:text-foreground ww:font-medium",children:p.title}),ee("div",{className:"ww:text-[10px] ww:text-muted-foreground",children:Number.isNaN(h)?"":Ao(h,s)})]}),ee("button",{type:"button",onClick:I=>{I.stopPropagation(),r(p.threadId)},title:n.threadMenu.deleteThread,"aria-label":n.threadMenu.deleteThread,className:"ww:p-1 ww:rounded ww:text-muted-foreground hover:ww:text-foreground hover:ww:bg-foreground/10 ww:transition-colors ww:cursor-pointer",children:ee(nh,{label:n.threadMenu.deleteThread})})]},p.threadId)}),d>0&&ee("div",{className:"ww:px-3 ww:py-2 ww:text-[10px] ww:text-muted-foreground ww:border-t ww:border-border",children:n.threadMenu.hiddenThreads(d)})]})]})}f();import{useCallback as ih,useRef as lh}from"react";function Al(e){let t=lh(e);return t.current=e,ih(async a=>{let{api:o,headers:r,onCallTool:s,sessionId:n}=t.current;if(s)return s(a);let i=`${o??"/api/waniwani"}/tool`,l=typeof n=="string"&&n.trim().length>0?n.trim():void 0,u=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",...l?{"X-Session-Id":l}:{},...r},body:JSON.stringify(a)});if(!u.ok)throw new Error(`Tool call failed: ${u.status} ${u.statusText}`);return u.json()},[])}f();import{useChat as kh}from"@ai-sdk/react";import{useCallback as pe,useEffect as De,useRef as de,useState as mt}from"react";f();import{DefaultChatTransport as uh,uiMessageChunkSchema as dh}from"ai";function ch(e){let t=e?.cause,a=t?.issues??t?.errors;if(!Array.isArray(a))return null;let o=a.find(r=>r.code==="invalid_union");if(!o?.errors)return null;for(let r of o.errors){if(!Array.isArray(r)||r.some(i=>(i.code==="invalid_value"||i.code==="invalid_literal")&&i.path?.[0]==="type"))continue;let n=r.filter(i=>i.code==="unrecognized_keys").flatMap(i=>i.keys??[]);if(n.length>0)return n}return null}var io=class extends uh{processResponseStream(t){let a="",o=dh(),r=o.validate?.bind(o);return t.pipeThrough(new TextDecoderStream).pipeThrough(new TransformStream({async transform(s,n){a+=s;let i=a.split(`
82
+ `);a=i.pop()??"";for(let l of i){let u=l.trim();if(!u.startsWith("data:"))continue;let c=u.slice(5).trim();if(c!=="[DONE]")try{let d=JSON.parse(c);if(!r){n.enqueue(d);continue}let p=await r(d);if(p.success){n.enqueue(p.value);continue}let m=ch(p.error);if(m?.length){let h={...d};for(let L of m)delete h[L];let I=await r(h);I.success&&n.enqueue(I.value)}}catch{}}}}))}};f();f();var fh="waniwani-memory";var Te="threads",lo="by_memoryUserId",ph="by_updatedAt";var Ml="memoryUserId",Rl="waniwani-memory-user-id",kr=null;function Tr(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function mh(e,t){if(t<1&&(e.objectStoreNames.contains("ids")||e.createObjectStore("ids")),t<2&&!e.objectStoreNames.contains(Te)){let a=e.createObjectStore(Te,{keyPath:"threadId"});a.createIndex(lo,"memoryUserId",{unique:!1}),a.createIndex(ph,"updatedAt",{unique:!1})}}async function Pr(){return new Promise((e,t)=>{let a=indexedDB.open(fh,2);a.onupgradeneeded=o=>{mh(a.result,o.oldVersion)},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error)})}async function hh(){return Pr()}async function gh(e){return new Promise((t,a)=>{let s=e.transaction("ids","readonly").objectStore("ids").get(Ml);s.onsuccess=()=>t(typeof s.result=="string"?s.result:null),s.onerror=()=>a(s.error)})}async function wh(e,t){return new Promise((a,o)=>{let n=e.transaction("ids","readwrite").objectStore("ids").put(t,Ml);n.onsuccess=()=>a(),n.onerror=()=>o(n.error)})}async function xh(){if(typeof indexedDB>"u")return null;try{let e=await hh();try{let t=await gh(e);if(t)return t;let a=Tr();return await wh(e,a),a}finally{e.close()}}catch{return null}}function Lh(){try{let e=localStorage.getItem(Rl);if(e)return e;let t=Tr();return localStorage.setItem(Rl,t),t}catch{return null}}async function Fl(){let e=await xh();if(e)return e;let t=Lh();return t||(kr||(kr=Tr()),kr)}var Dl=50,Bl=1e3;function uo(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.threadId=="string"&&typeof t.memoryUserId=="string"&&typeof t.title=="string"&&Array.isArray(t.messages)&&typeof t.createdAt=="string"&&typeof t.updatedAt=="string"}async function co(e){if(typeof indexedDB>"u")return null;let t=null;try{return t=await Pr(),await e(t)}catch{return null}finally{try{t?.close()}catch{}}}function vr(e){return new Promise((t,a)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>a(e.error)})}async function Ar(e){return await co(async a=>{let s=a.transaction(Te,"readonly").objectStore(Te).index(lo),i=(await vr(s.getAll(e))??[]).filter(uo);return i.sort((l,u)=>l.updatedAt<u.updatedAt?1:-1),i})??[]}async function Rr(e){return await co(async a=>{let r=a.transaction(Te,"readonly").objectStore(Te),s=await vr(r.get(e));return uo(s)?s:null})??null}async function Mr(e){if(!uo(e))return;let t=e.messages.length>Bl?{...e,messages:e.messages.slice(e.messages.length-Bl)}:e;await co(async a=>{await new Promise((l,u)=>{let c=a.transaction(Te,"readwrite");c.oncomplete=()=>l(),c.onerror=()=>u(c.error),c.onabort=()=>u(c.error),c.objectStore(Te).put(t)});let o=a.transaction(Te,"readwrite"),r=o.objectStore(Te),s=r.index(lo),i=(await vr(s.getAll(t.memoryUserId))??[]).filter(uo);if(i.length>Dl){i.sort((u,c)=>u.updatedAt<c.updatedAt?-1:1);let l=i.slice(0,i.length-Dl);for(let u of l)r.delete(u.threadId)}return await new Promise((l,u)=>{o.oncomplete=()=>l(),o.onerror=()=>u(o.error),o.onabort=()=>u(o.error)}),null})}async function El(e){await co(async t=>(await new Promise((a,o)=>{let r=t.transaction(Te,"readwrite");r.oncomplete=()=>a(),r.onerror=()=>o(r.error),r.onabort=()=>o(r.error),r.objectStore(Te).delete(e)}),null))}async function _l(e){return(await Ar(e))[0]?.threadId??null}function Nl(e){let t=e.trim();if(!t)return`Conversation on ${new Date().toISOString().slice(0,10)}`;let a=t.split(/\r?\n/,1)[0]??t;return a.length<=60?a:`${a.slice(0,60).trimEnd()}\u2026`}f();var Ul="waniwani-visitor-id";function Ol(e,t){return e.match(t)?.[1]??null}function Ch(e){let t=[["Edge",/Edg(?:e|A|iOS)?\/(\S+)/],["Opera",/(?:OPR|Opera)\/(\S+)/],["Samsung Internet",/SamsungBrowser\/(\S+)/],["Firefox",/Firefox\/(\S+)/],["Chrome",/Chrome\/(\S+)/],["Safari",/Version\/(\S+).*Safari/]];for(let[a,o]of t){let r=Ol(e,o);if(r)return{name:a,version:r}}return null}function Ih(e){let t=[["iOS",/(?:iPhone|iPad|iPod).+?OS (\d+[_.\d]*)/],["Android",/Android (\d+[.\d]*)/],["macOS",/Mac OS X (\d+[_.\d]*)/],["Windows",/Windows NT (\d+[.\d]*)/],["ChromeOS",/CrOS \S+ (\d+[.\d]*)/],["Linux",/Linux/]];for(let[a,o]of t){let r=Ol(e,o);if(r)return{name:a,version:r.replace(/_/g,".")};if(a==="Linux"&&o.test(e))return{name:a,version:""}}return null}function Sh(e){return typeof navigator<"u"&&"userAgentData"in navigator&&navigator.userAgentData?.mobile?"mobile":/iPad|tablet|PlayBook/i.test(e)?"tablet":/Mobi|Android.*Mobile|iPhone|iPod/i.test(e)?"mobile":"desktop"}async function yh(e){let t=new TextEncoder().encode(e),a=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(a)).map(o=>o.toString(16).padStart(2,"0")).join("")}async function bh(){try{let a=localStorage.getItem(Ul);if(a)return a}catch{}let e=[navigator.userAgent,screen.width,screen.height,screen.colorDepth,Intl.DateTimeFormat().resolvedOptions().timeZone,navigator.language,navigator.hardwareConcurrency??"",navigator.platform??""].join("|"),t=await yh(e);try{localStorage.setItem(Ul,t)}catch{}return t}async function Hl(){let e=navigator.userAgent,[t,a]=await Promise.all([bh(),Fl()]);return{userAgent:e,browser:Ch(e),os:Ih(e),deviceType:Sh(e),language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,colorDepth:screen.colorDepth,devicePixelRatio:window.devicePixelRatio??1,touchSupport:"ontouchstart"in window||navigator.maxTouchPoints>0,connectionType:navigator.connection?.effectiveType??"unknown",referrer:document.referrer,visitorId:t,memoryUserId:a}}var Th="x-session-id",Ph=250;function ql(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Kt()}function fo(){return new Date().toISOString()}function Wl(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}async function vh(e,t){let a=`${e.replace(/\/$/,"")}/tools`,o=await fetch(a,{method:"GET",headers:t?{...t}:void 0});if(!o.ok)throw new Error(`[WaniWani] Failed to fetch /tools: ${o.status} ${o.statusText}`);let r=await o.json();if(!r||!Array.isArray(r.tools))return{};let s={};for(let n of r.tools)n&&typeof n.name=="string"&&(s[n.name]=n);return s}function Gl(e){let{api:t="/api/waniwani",headers:a,body:o,onMessageSent:r,onResponseReceived:s,enableThreadHistory:n=!1,activeThreadId:i,onThreadChange:l}=e,u=de(a),c=de(o),d=de(n);De(()=>{d.current=n},[n]);let p=de(void 0),m=de(null),[h,I]=mt(void 0),L=de(h),[S,C]=mt(i),g=de(S),[y,P]=mt([]),[v,R]=mt(!n),A=de(void 0),_=de(void 0),M=de(void 0),T=de(void 0),b=de(0),B=de(l);De(()=>{B.current=l},[l]);let O=pe(k=>{g.current=k,C(k),k&&B.current?.(k)},[]),F=pe(async()=>{if(!n)return;let k=m.current?.memoryUserId;if(!k)return;let U=await Ar(k);P(U)},[n]),J=pe(()=>L.current,[]),Be=pe(k=>{let U=Wl(k);U&&L.current!==U&&(L.current=U,I(U))},[]),Ce=pe(()=>{L.current=void 0,I(void 0)},[]);De(()=>{u.current=a},[a]),De(()=>{c.current=o},[o]),De(()=>{let k=!1,U=b.current;return(async()=>{try{let ve=await Hl();if(k)return;m.current=ve}catch{}if(!n)return;let H=m.current?.memoryUserId;if(!H){R(!0);return}try{let ve=i??await _l(H);if(k||U!==b.current)return;if(ve){let xe=await Rr(ve);if(k||U!==b.current)return;xe&&xe.memoryUserId===H&&(g.current=xe.threadId,C(xe.threadId),A.current=xe.createdAt,_.current=xe.title,xe.sessionId&&(L.current=xe.sessionId,I(xe.sessionId)),re(xe.messages))}await F()}finally{k||R(!0)}})(),()=>{k=!0}},[]);let ae=de(new io({api:t,headers:()=>({...u.current}),body:()=>{let k={...c.current??{}},U=Object.hasOwn(k,"sessionId"),H=Wl(k.sessionId);if(H)Be(H),k.sessionId=H;else if(U)Ce(),delete k.sessionId;else{let Me=J();Me&&(k.sessionId=Me)}if(wt(p.current)&&(k.modelContext=p.current),m.current){let Me=m.current;k.visitorContext={timezone:Me.timezone,language:Me.language,languages:Me.languages,deviceType:Me.deviceType,referrer:Me.referrer,visitorId:Me.visitorId};let qe=typeof k.visitor=="object"&&k.visitor!==null?k.visitor:{},lu=typeof qe.client=="object"&&qe.client!==null?qe.client:{};k.visitor={...qe,client:{...lu,memoryUserId:Me.memoryUserId}}}let ve=typeof k.extra=="object"&&k.extra!==null&&!Array.isArray(k.extra)?k.extra:void 0,xe=m.current?.memoryUserId,Xe=m.current?.language,ma={};if(xe&&(ma.memoryUserId=xe),Xe&&(ma.locale=Xe),(Object.keys(ma).length>0||ve)&&(k.extra={...ma,...ve??{}}),d.current)if(Object.hasOwn(k,"threadId"))typeof k.threadId=="string"&&(g.current=k.threadId);else{let qe=g.current;qe||(qe=ql(),A.current=fo(),_.current=void 0,O(qe)),k.threadId=qe}return k},fetch:(async(k,U)=>{let H=await fetch(k,U);return p.current=void 0,Be(H.headers.get(Th)),H})})),he=de(null),ye=de(null),we=de({}),[Ie,Ve]=mt(0),N=e.skipRemoteConfig===!0,le=pe(async()=>{if(!N)try{let k=await vh(t,u.current);we.current=k,Ve(U=>U+1)}catch(k){console.warn("[WaniWani] Failed to fetch tool definitions:",k instanceof Error?k.message:k)}},[t,N]);De(()=>{le()},[le]);let{messages:te,sendMessage:K,setMessages:re,status:W}=kh({messages:e.initialMessages,transport:ae.current,onFinish({message:k}){s?.(),he.current&&(ye.current=k)},onError(k){console.warn("[WaniWani] Chat error:",k.message),he.current&&(he.current.reject(k),he.current=null)}}),$=de(te);De(()=>{$.current=te},[te]),De(()=>{if(W==="ready"&&he.current&&ye.current){let k=he.current,U=ye.current;he.current=null,ye.current=null,k.resolve(U)}},[W]);let[Q,q]=mt(""),[Z,se]=mt([]),Pe=W==="submitted"||W==="streaming",$e=pe(k=>{se(U=>U.filter(H=>H.id!==k))},[]),ht=Pe&&Z.length>0,gt=pe(k=>{let U=!!k.text?.trim(),H=!!k.files?.length;if(U||H){if(Pe){if(Z.length>0)return;se(ve=>[...ve,{id:Kt(),text:k.text||"",files:k.files??[],modelContext:k.modelContext}]),q("");return}p.current=k.modelContext,K({text:k.text||"",files:k.files}),r?.(k.text||""),q("")}},[K,r,Pe,Z.length]),tu=pe(k=>new Promise((U,H)=>{he.current={resolve:U,reject:H},K({text:k}),r?.(k)}),[K,r]);De(()=>{if(W!=="ready"||Z.length===0)return;let[k,...U]=Z;se(U),p.current=k.modelContext,K({text:k.text,files:k.files.length>0?k.files:void 0}),r?.(k.text)},[W,K,r,Z]);let au=pe(()=>{re([]),se([]),Ce(),q(""),we.current={},Ve(k=>k+1),le()},[re,Ce,le]),fa=pe(()=>{if(!d.current)return;let k=m.current?.memoryUserId,U=g.current,H=$.current;if(!(!k||!U||H.length===0)){if(A.current||(A.current=fo()),!_.current){let ve=H.find(Xe=>Xe.role==="user"),xe=ve?ve.parts.map(Xe=>"text"in Xe&&typeof Xe.text=="string"?Xe.text:"").join(" "):"";_.current=Nl(xe)}return{threadId:U,memoryUserId:k,title:_.current,messages:H,sessionId:L.current,createdAt:A.current,updatedAt:fo()}}},[]),Br=pe(async()=>{let k=fa();k&&(await Mr(k),await F())},[fa,F]);De(()=>{if(n&&v&&!(W==="submitted"||W==="streaming")&&te.length!==0)return M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=void 0;let k=Br().finally(()=>{T.current===k&&(T.current=void 0)});T.current=k},Ph),()=>{M.current&&clearTimeout(M.current)}},[n,v,te,W,Br]);let pa=pe(()=>{let k=T.current,U=M.current,H=U?fa():void 0;return U&&(clearTimeout(U),M.current=void 0),(async()=>{k&&await k,H&&(await Mr(H),await F())})()},[fa,F]),ou=pe(()=>{b.current+=1,pa(),re([]),se([]),Ce(),q("");let k=ql();return A.current=fo(),_.current=void 0,O(k),F(),k},[re,Ce,O,F,pa]),po=pe(async k=>{b.current+=1;let U=b.current;if(await pa(),U!==b.current)return;let H=await Rr(k);U===b.current&&H&&(O(H.threadId),A.current=H.createdAt,_.current=H.title,H.sessionId?(L.current=H.sessionId,I(H.sessionId)):Ce(),re(H.messages),se([]),q(""))},[re,Ce,O,pa]),ru=pe(async k=>{if(g.current===k){b.current+=1,M.current&&(clearTimeout(M.current),M.current=void 0);let U=T.current;U&&await U}await El(k),await F(),g.current===k&&(re([]),se([]),Ce(),q(""),g.current=void 0,C(void 0),A.current=void 0,_.current=void 0)},[re,Ce,F]);De(()=>{n&&v&&i!==void 0&&i!==g.current&&po(i)},[i,n,v,po]);let su=pe(k=>{q(k.target.value)},[]),Er=te[te.length-1],_r=te.length>0,nu=Pe&&(!_r||Er.role==="user"),iu=we.current;return{messages:te,status:W,text:Q,setText:q,handleSubmit:gt,handleTextChange:su,isLoading:Pe,showLoaderBubble:nu,lastMessage:Er,hasMessages:_r,sendMessage:K,sendMessageAndWait:tu,reset:au,queuedMessages:Z,queueFull:ht,removeQueuedMessage:$e,sessionId:h,toolDefinitions:iu,refreshToolDefinitions:le,threads:y,activeThreadId:S,isThreadHistoryReady:v,startNewThread:ou,switchThread:po,deleteThread:ru}}f();import{useEffect as jl,useRef as Ah,useState as Rh}from"react";var Mh={debug:!1,eval:!1};function zl(e="/api/waniwani",t,a=!1){let[o,r]=Rh(Mh),s=Ah(t);return jl(()=>{s.current=t},[t]),jl(()=>{a||(async()=>{try{let n=s.current,l=await(await fetch(`${e}/config`,{headers:n?{...n}:void 0})).json();r({debug:l.debug===!0,eval:l.eval===!0})}catch{}})()},[e,a]),o}f();import{useCallback as Fh,useEffect as Fr,useRef as Dh,useState as Bh}from"react";function Eh(e){for(let t of e.parts){let a=t;if(a.type==="data"||a.type==="data-suggestions"){let o=a.data;if(o&&Array.isArray(o.suggestions))return o.suggestions}}return null}function Vl(e){return typeof e=="object"&&e!==null&&"initial"in e}function $l(e){let{messages:t,status:a,config:o}=e,r=Vl(o)&&o.initial?o.initial:void 0,[s,n]=Bh(r??[]),i=Dh(a),l=o===!0||Vl(o)&&o.dynamic!==!1,u=Fh(()=>{n([])},[]),c=t.length>0;Fr(()=>{!c&&r&&r.length>0&&n(r)},[r,c]);let d=t[t.length-1];return Fr(()=>{d?.role==="user"&&u()},[d,u]),Fr(()=>{let p=i.current;if(i.current=a,p==="streaming"&&a==="ready"&&l){let m=[...t].reverse().find(I=>I.role==="assistant");if(!m)return;let h=Eh(m);h&&n(h)}},[a,l,t]),{suggestions:s,isLoading:!1,clear:u}}f();import{useEffect as _h,useRef as Nh,useState as Uh}from"react";var Oh=50,Hh=30,qh=2e3,Xl=500;function Kl(e,t=!0){let[a,o]=Uh(""),r=Nh(void 0);return _h(()=>{if(!t){o("");return}let s=0,n=!1,i=!1,l=()=>{i||(n?(s--,o(e.slice(0,s)),s<=0?(n=!1,r.current=setTimeout(l,Xl)):r.current=setTimeout(l,Hh)):(s++,o(e.slice(0,s)),s>=e.length?(n=!0,r.current=setTimeout(l,qh)):r.current=setTimeout(l,Oh)))};return r.current=setTimeout(l,Xl),()=>{i=!0,clearTimeout(r.current)}},[e,t]),a}f();function Ql(e,t){let a=t?.Authorization,o=typeof a=="string"&&a.startsWith("Bearer ")?a.slice(7):null;return o?`${e}/resource?token=${encodeURIComponent(o)}`:`${e}/resource`}f();var Wh={primaryColor:"#6366f1",primaryForeground:"#1f2937",backgroundColor:"#ffffff",textColor:"#1f2937",mutedColor:"#6b7280",borderColor:"#e5e7eb",borderWidth:0,boxShadow:"none",assistantBubbleColor:"#f3f4f6",userBubbleColor:"#f4f4f4",inputBackgroundColor:"#f9fafb",borderRadius:16,messageBorderRadius:12,fontFamily:"system-ui, -apple-system, 'Segoe UI', sans-serif",headerBackgroundColor:"#ffffff",headerTextColor:"#1f2937",statusColor:"#22c55e",toolCardColor:"#f4f4f5"};var Gh={primaryColor:["--ww-primary","--ww-color-primary"],primaryForeground:["--ww-primary-fg","--ww-color-primary-foreground"],backgroundColor:["--ww-bg","--ww-color-background"],textColor:["--ww-text","--ww-color-foreground","--ww-color-accent-foreground"],mutedColor:["--ww-muted","--ww-color-muted-foreground"],borderColor:["--ww-border","--ww-color-border"],borderWidth:["--ww-border-width"],boxShadow:["--ww-shadow"],assistantBubbleColor:["--ww-assistant-bubble","--ww-color-accent"],userBubbleColor:["--ww-user-bubble"],inputBackgroundColor:["--ww-input-bg","--ww-color-input"],borderRadius:["--ww-radius"],messageBorderRadius:["--ww-msg-radius"],fontFamily:["--ww-font"],headerBackgroundColor:["--ww-header-bg"],headerTextColor:["--ww-header-text"],statusColor:["--ww-status"],toolCardColor:["--ww-tool-card","--ww-color-tool-card"]};function Jl(e){return{...Wh,...e}}function Zl(e){let t={};for(let[a,o]of Object.entries(Gh)){let r=e[a];if(r===void 0)continue;let s=typeof r=="number"?`${r}px`:String(r);for(let n of o)t[n]=s}return t}import{jsx as me,jsxs as ca}from"react/jsx-runtime";var $h=jh(function(t,a){let{theme:o,title:r="Assistant",width:s,height:n,className:i,allowAttachments:l=!1,welcomeMessage:u,welcome:c,placeholder:d="Ask me anything...",triggerEvent:p="triggerDemoRequest",api:m,debug:h,enableThreadHistory:I=!1,showToolCalls:L=!0}=t,S=m??"/api/waniwani",C=Ql(S,t.headers),g=Jl(o),y=Zl(g),P=g.backgroundColor.replace("#",""),v=parseInt(P.substring(0,2),16),R=parseInt(P.substring(2,4),16),A=parseInt(P.substring(4,6),16),_=(v*299+R*587+A*114)/1e3<128,M=zl(S,t.headers,t.skipRemoteConfig),T=h??M.debug,b=Gl({...t,api:S}),B=Al({...t,api:S,sessionId:b.sessionId}),O=Kl(d,!b.text),[F,J]=eu(!1),[Be,Ce]=eu(null),ae=Yl(null),he=Yl(void 0),ye=Dr(()=>{let N=ae.current;if(!N)return;N.scrollIntoView({behavior:"smooth",block:"center"});let le=N.querySelector("textarea");le&&setTimeout(()=>le.focus(),300),J(!0),clearTimeout(he.current),he.current=setTimeout(()=>J(!1),2e3)},[]),we=$l({messages:b.messages,status:b.status,config:t.suggestions}),Ie=Dr(N=>{let le=N.content.map(te=>te.text??"").join("").trim();le&&b.handleSubmit({text:le,files:[],modelContext:N.modelContext})},[b.handleSubmit]),Ve=Dr(N=>{we.clear(),b.handleSubmit({text:N,files:[]})},[we.clear,b.handleSubmit]);return Vh(a,()=>({sendMessage:N=>{b.handleSubmit({text:N,files:[]}),ye()},sendMessageAndWait:N=>b.sendMessageAndWait(N),reset:b.reset,focus:ye,get messages(){return b.messages}}),[b.handleSubmit,b.sendMessageAndWait,b.reset,b.messages,ye]),zh(()=>{if(!p)return;let N=le=>{let te=le.detail,K=typeof te?.message=="string"?te.message:void 0;K&&b.handleSubmit({text:K,files:[]}),ye()};return window.addEventListener(p,N),()=>window.removeEventListener(p,N)},[p,b.handleSubmit,ye]),ca("div",{ref:ae,style:{...y,width:s,height:n},"data-waniwani-chat":"","data-waniwani-layout":"card",..._?{"data-waniwani-dark":""}:{},className:D("ww:flex ww:flex-col ww:font-[family-name:var(--ww-font)] ww:text-foreground ww:bg-background ww:rounded-[var(--ww-radius)] ww:overflow-hidden",F&&"ww:ring-2 ww:ring-blue-400/70 ww:ring-offset-2 ww:ring-offset-background",i),children:[ca("div",{className:"ww:shrink-0 ww:flex ww:items-center ww:gap-2 ww:px-6 ww:py-3",style:{backgroundColor:g.headerBackgroundColor,color:g.headerTextColor},children:[me("div",{className:"ww:text-sm ww:font-semibold ww:truncate ww:flex-1 ww:min-w-0",children:r}),me(xn,{messages:b.messages,evalEnabled:M.eval,api:S}),I&&me(vl,{threads:b.threads,activeThreadId:b.activeThreadId,onNewThread:b.startNewThread,onSelectThread:N=>{b.switchThread(N)},onDeleteThread:N=>{b.deleteThread(N)}})]}),ca(Xs,{className:"ww:flex-1 ww:min-h-0 ww:bg-background",children:[me(Ks,{scrollClassName:Be?"ww:!relative ww:!overflow-hidden":void 0,children:me(yl,{messages:b.messages,status:b.status,welcomeMessage:u,welcome:c,onSuggestionSelect:Ve,resourceEndpoint:C,chatSessionId:b.sessionId,isDark:_,onFollowUp:Ie,onCallTool:B,fullscreenToolCallId:Be,debug:T,showToolCalls:L,toolDefinitions:b.toolDefinitions,onWidgetDisplayModeChange:(N,le)=>{Ce(N==="fullscreen"?le.toolCallId:null)}})}),me(Qs,{})]}),me("div",{style:Be?{display:"none"}:void 0,children:me(Tl,{suggestions:we.suggestions,isLoading:we.isLoading,onSelect:Ve})}),me("div",{style:Be?{display:"none"}:void 0,children:me(hn,{queuedMessages:b.queuedMessages,onRemove:b.removeQueuedMessage})}),me("div",{style:Be?{display:"none"}:void 0,children:me("div",{className:"ww:shrink-0 ww:px-4 ww:pb-8 ww:pt-2 ww:bg-background",children:ca("div",{className:"ww:mx-auto ww:w-full ww:max-w-3xl",children:[me(an,{onSubmit:b.handleSubmit,globalDrop:l,multiple:l,className:"ww:rounded-2xl ww:border-border ww:bg-input",children:ca("div",{className:"ww:flex ww:items-center ww:gap-1 ww:pl-4 ww:pr-3 ww:py-2.5",children:[l&&me(sn,{}),me(on,{onChange:b.handleTextChange,value:b.text,placeholder:O,className:"ww:min-h-0 ww:py-1 ww:px-0"}),me(rn,{status:b.status,disabled:b.queueFull})]})}),me(kl,{})]})})})]})});export{$h as ChatCard,os as DevModeProvider,gu as InitializeNextJsInIframe,Ju as LoadingWidget,cs as WidgetProvider,Zr as createResource,fu as createTool,mo as detectPlatform,La as getMockState,Mt as initializeMockOpenAI,du as isMCPApps,uu as isOpenAI,pu as registerTools,sL as toNextJsHandler,is as unstable_useSendFollowUpWithGhostGuard,Dt as updateMockDisplayMode,at as updateMockGlobal,Bt as updateMockTheme,Ft as updateMockToolOutput,fs as useCallTool,ps as useDisplayMode,ms as useFlowAction,hs as useIsChatGptApp,gs as useLocale,ws as useMaxHeight,xs as useOpenExternal,Ls as useRequestDisplayMode,Cs as useSafeArea,Is as useSendFollowUp,Ss as useTheme,Ia as useToolOutput,ys as useToolResponseMetadata,bs as useUpdateModelContext,G as useWidgetClient,ks as useWidgetState};
83
83
  /*! Bundled license information:
84
84
 
85
85
  lucide-react/dist/esm/shared/src/utils/mergeClasses.js: