@mcp-use/inspector 20.0.0-beta.0 → 20.0.0-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.
Files changed (63) hide show
  1. package/dist/cdn/{ChatTab-5ya_YTFV.js → ChatTab-D8uwCHAf.js} +2 -2
  2. package/dist/cdn/{ConnectionSettingsForm-iwNW86ZU.js → ConnectionSettingsForm-BNS6bOMD.js} +1 -1
  3. package/dist/cdn/{ConnectionSettingsTab-CeK83dxn.js → ConnectionSettingsTab-B97gPPJW.js} +1 -1
  4. package/dist/cdn/{OAuthCallback-BxuOVgdb.js → OAuthCallback-k3oeLtIC.js} +1 -1
  5. package/dist/cdn/{ResourcesTab-BczUMFil.js → ResourcesTab-KfamsM6-.js} +3 -3
  6. package/dist/cdn/{SamplingTab-6u5s845G.js → SamplingTab-vcufuK24.js} +1 -1
  7. package/dist/cdn/{ToolsTab-CUhwP4rZ.js → ToolsTab-DRjcZnpu.js} +3 -3
  8. package/dist/cdn/{ViewPreview-CxJc1Kht.js → ViewPreview-B_onhcUB.js} +2 -2
  9. package/dist/cdn/{WidgetWrapper-BJJtLqMb.js → WidgetWrapper-D29YDxIu.js} +1 -1
  10. package/dist/cdn/inspector.js +116 -109
  11. package/dist/cdn/{react-yUi9mVK4.js → react-BxO-uEDZ.js} +32 -26
  12. package/dist/cdn/{useViewHostProps-C7vjco2m.js → useViewHostProps-Dr6W2ooF.js} +1 -1
  13. package/dist/cli.js +116 -14
  14. package/dist/server/asset-urls.d.ts +14 -0
  15. package/dist/server/asset-urls.d.ts.map +1 -0
  16. package/dist/server/asset-urls.js +13 -0
  17. package/dist/server/cdn-shell.d.ts +3 -3
  18. package/dist/server/cdn-shell.d.ts.map +1 -1
  19. package/dist/server/cdn-shell.js +5 -3
  20. package/dist/server/{chunk-J67FVPHF.js → chunk-IXYK6ZOY.js} +1 -1
  21. package/dist/server/{chunk-ESODOPDD.js → chunk-J4FNYLBF.js} +4 -0
  22. package/dist/server/chunk-KBVKS4J5.js +53 -0
  23. package/dist/server/chunk-M5TZA42I.js +54 -0
  24. package/dist/server/{chunk-TPHRVELX.js → chunk-VDUV6LR6.js} +16 -9
  25. package/dist/server/{chunk-THQ67TSE.js → chunk-Y2GBQOQW.js} +1 -1
  26. package/dist/server/cli.js +6 -4
  27. package/dist/server/favicon-static.d.ts.map +1 -1
  28. package/dist/server/favicon-static.js +1 -1
  29. package/dist/server/index.js +7 -5
  30. package/dist/server/middleware.js +7 -5
  31. package/dist/server/static-assets.d.ts +5 -0
  32. package/dist/server/static-assets.d.ts.map +1 -0
  33. package/dist/server/static-assets.js +9 -0
  34. package/dist/server/version.js +1 -1
  35. package/dist/web/assets/{ChatTab-CiAqtqhj.js → ChatTab-Cy8eyFYI.js} +3 -3
  36. package/dist/web/assets/{ConnectionSettingsTab-CTh6MFKE.js → ConnectionSettingsTab-sDZGaUJn.js} +1 -1
  37. package/dist/web/assets/{ElicitationTab-B3Eg0_Jm.js → ElicitationTab-wDKgU1qL.js} +1 -1
  38. package/dist/web/assets/{ManufactOAuthCallback-B-tdkUA2.js → ManufactOAuthCallback-DCLbW-mz.js} +1 -1
  39. package/dist/web/assets/{NotificationsTab-BgLjxuos.js → NotificationsTab-JevzvJTg.js} +1 -1
  40. package/dist/web/assets/{OAuthCallback-Bp-jLoQs.js → OAuthCallback-BjcRxLh5.js} +1 -1
  41. package/dist/web/assets/{PromptsTab-CA-SZs43.js → PromptsTab-DsQVOjKH.js} +1 -1
  42. package/dist/web/assets/{ResourcesTab-DdMIW_af.js → ResourcesTab-Bw8_p6M1.js} +1 -1
  43. package/dist/web/assets/{SamplingTab-DjyDG01W.js → SamplingTab-BrcF1zJF.js} +1 -1
  44. package/dist/web/assets/{ServerMetadataTab-Q4PlqP_B.js → ServerMetadataTab-Bydeh1Po.js} +1 -1
  45. package/dist/web/assets/{ToolsTab-BHk8GCmd.js → ToolsTab-DJWF7Q_x.js} +1 -1
  46. package/dist/web/assets/{ViewPreview-DWtmwzCb.js → ViewPreview-jgeU7bY9.js} +1 -1
  47. package/dist/web/assets/{WidgetWrapper-B43lqbld.js → WidgetWrapper-B_vJU9uF.js} +1 -1
  48. package/dist/web/assets/{checkbox-_GzEPQic.js → checkbox-BA-XURSj.js} +1 -1
  49. package/dist/web/assets/{chunk-BO2N2NFS-BdIeB5Lr.js → chunk-BO2N2NFS-CGbd3eLY.js} +4 -4
  50. package/dist/web/assets/{dist-DQjEDTKs.js → dist-BcAQZluc.js} +3 -3
  51. package/dist/web/assets/{highlighted-body-OFNGDK62-Dp3e1QHL.js → highlighted-body-OFNGDK62-BBJFbIMp.js} +1 -1
  52. package/dist/web/assets/{index-Bbn-6QR2.js → index-D2UxaT9v.js} +3 -3
  53. package/dist/web/assets/mermaid-GHXKKRXX-B4MKVODA.js +1 -0
  54. package/dist/web/assets/{pdf-C3cfS_Ha.js → pdf-CuwKm9zO.js} +1 -1
  55. package/dist/web/assets/{shared-Dfwy7nyg.js → shared-DQE60Op-.js} +1 -1
  56. package/dist/web/assets/{sheet-CRPrEqAa.js → sheet-7TIkLdpr.js} +1 -1
  57. package/dist/web/assets/{tabs-subtle-Dxgism9f.js → tabs-subtle-AkJZvdxS.js} +1 -1
  58. package/dist/web/assets/{useConfig-b1f_iVFH.js → useConfig-Qglo4xs1.js} +1 -1
  59. package/dist/web/assets/{useMCPPrompts-CPskz9af.js → useMCPPrompts-USLYc1I4.js} +1 -1
  60. package/dist/web/assets/{useViewHostProps-BgsQ2yYl.js → useViewHostProps-DXAD1g7g.js} +1 -1
  61. package/dist/web/index.html +1 -1
  62. package/package.json +5 -5
  63. package/dist/web/assets/mermaid-GHXKKRXX-yq1lkD3x.js +0 -1
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  mountInspector
3
- } from "./chunk-J67FVPHF.js";
4
- import "./chunk-TPHRVELX.js";
5
- import "./chunk-THQ67TSE.js";
6
- import "./chunk-ESODOPDD.js";
7
- import "./chunk-WFT4JHYI.js";
3
+ } from "./chunk-IXYK6ZOY.js";
4
+ import "./chunk-VDUV6LR6.js";
5
+ import "./chunk-M5TZA42I.js";
6
+ import "./chunk-Y2GBQOQW.js";
7
+ import "./chunk-KBVKS4J5.js";
8
8
  import "./chunk-5B3SXGZP.js";
9
9
  import "./chunk-IKTZUWSX.js";
10
10
  import "./chunk-6XWDZEFF.js";
11
11
  import "./chunk-K2F2AJOI.js";
12
+ import "./chunk-J4FNYLBF.js";
13
+ import "./chunk-WFT4JHYI.js";
12
14
  import "./chunk-PKBMQBKP.js";
13
15
  export {
14
16
  mountInspector
@@ -0,0 +1,5 @@
1
+ import type { Hono } from "hono";
2
+ export declare function resolveDistCdnDir(): string;
3
+ /** Serve dist/cdn/ at ${basePath}/dist/cdn/* (standalone / npx). */
4
+ export declare function registerInspectorStaticAssets(app: Hono, basePath?: string): void;
5
+ //# sourceMappingURL=static-assets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static-assets.d.ts","sourceRoot":"","sources":["../../src/server/static-assets.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAWjC,wBAAgB,iBAAiB,IAAI,MAAM,CAa1C;AAED,oEAAoE;AACpE,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,IAAI,EACT,QAAQ,GAAE,MAAW,QAsBtB"}
@@ -0,0 +1,9 @@
1
+ import {
2
+ registerInspectorStaticAssets,
3
+ resolveDistCdnDir
4
+ } from "./chunk-M5TZA42I.js";
5
+ import "./chunk-PKBMQBKP.js";
6
+ export {
7
+ registerInspectorStaticAssets,
8
+ resolveDistCdnDir
9
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  VERSION,
3
3
  getInspectorVersion
4
- } from "./chunk-THQ67TSE.js";
4
+ } from "./chunk-Y2GBQOQW.js";
5
5
  import "./chunk-PKBMQBKP.js";
6
6
  export {
7
7
  VERSION,
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-C3cfS_Ha.js","assets/index-Bbn-6QR2.js","assets/react-CU_d2d5K.js","assets/input-CjmxOFr6.js","assets/bundle-mjs-8puS6ou7.js","assets/createLucideIcon-B3b8EU0b.js","assets/jsx-runtime-Cjj9sGSy.js","assets/FormContext-Cqc_A12u.js","assets/select-C0xlfLAa.js","assets/AnimatePresence-CthXziG2.js","assets/label-B5Q_Zr8M.js","assets/index-BjH-Qp85.css"])))=>i.map(i=>d[i]);
2
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Cr as r,Dr as i,En as a,G as o,Ir as s,Lr as c,Mn as l,Nn as u,Nr as d,Sr as f,Tn as p,Yn as m,_r as h,a as g,an as _,br as v,c as y,d as b,dr as x,f as S,fr as C,gr as w,in as T,kn as E,mn as D,mr as O,n as k,on as A,or as j,pn as M,pr as N,r as P,s as F,sr as I,t as ee,u as L,wr as te,xr as ne}from"./input-CjmxOFr6.js";import{n as re,t as R}from"./label-B5Q_Zr8M.js";import{m as z,t as ie}from"./AnimatePresence-CthXziG2.js";import{a as B,c as ae,i as V,n as H,o as oe,p as se,r as U,s as W,t as G}from"./select-C0xlfLAa.js";import{a as K,c as q,i as ce,l as le,n as ue,o as de,r as fe,s as J,t as pe}from"./FormContext-Cqc_A12u.js";import{t as me}from"./createLucideIcon-B3b8EU0b.js";import{t as he}from"./refresh-cw-C9wQl8_d.js";import{$t as ge,A as _e,At as ve,Bt as ye,C as be,E as xe,F as Se,Ft as Ce,It as we,K as Te,Kt as Ee,M as De,Mt as Oe,N as ke,Nt as Ae,O as je,Q as Me,T as Ne,Xt as Pe,Yt as Fe,_ as Ie,_t as Le,a as Re,an as ze,b as Be,bt as Ve,c as He,cn as Ue,ct as We,d as Ge,dt as Ke,en as qe,f as Je,g as Ye,h as Xe,j as Ze,jt as Y,kt as Qe,l as $e,ln as et,lt as tt,m as nt,mt as rt,n as it,nn as at,on as X,ot,qt as st,rn as ct,s as lt,tn as ut,u as dt,v as ft,w as pt,wt as mt,y as ht}from"./index-Bbn-6QR2.js";import{a as gt,c as _t,d as vt,f as yt,h as bt,l as xt,m as St,p as Ct,r as wt,s as Tt,u as Et}from"./chunk-BO2N2NFS-BdIeB5Lr.js";import{a as Dt,i as Ot,n as kt,o as At,r as jt,t as Mt}from"./sheet-CRPrEqAa.js";import{a as Nt,c as Pt,i as Ft,n as It,o as Lt,r as Rt,s as zt}from"./dist-DQjEDTKs.js";import{t as Bt}from"./useMCPPrompts-CPskz9af.js";import{a as Vt,i as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt}from"./useConfig-b1f_iVFH.js";import{a as Jt,i as Yt,n as Xt,t as Zt}from"./tabs-subtle-Dxgism9f.js";import{t as Qt}from"./textarea-Ci09-en6.js";import{t as $t}from"./checkbox-_GzEPQic.js";import{n as en,t as tn}from"./schemaHelpers-DLNTQr_6.js";import{t as nn}from"./useViewHostProps-BgsQ2yYl.js";var rn=me(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),an=me(`arrow-left-from-line`,[[`path`,{d:`m9 6-6 6 6 6`,key:`7v63n9`}],[`path`,{d:`M3 12h14`,key:`13k4hi`}],[`path`,{d:`M21 19V5`,key:`b4bplr`}]]),on=me(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),sn=me(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),cn=me(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),ln=me(`paperclip`,[[`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`}]]),un=me(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),dn=me(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Z=e(t(),1),Q=n(),fn=Z.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsx)(`div`,{ref:r,"data-slot":`scroll-area`,className:c(`relative overflow-hidden`,e),...n,children:(0,Q.jsx)(`div`,{"data-slot":`scroll-area-viewport`,className:`h-full w-full overflow-y-auto overflow-x-hidden`,children:t})}));fn.displayName=`ScrollArea`;function pn({count:e}){return(0,Q.jsx)(`div`,{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${L}`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full`,children:[(0,Q.jsx)(`h2`,{className:b,children:`Chat History`}),(0,Q.jsx)(d,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:e})]})})}function mn({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:c(`animate-pulse rounded-md bg-muted`,e),...t})}var hn=`New Chat`,gn=`Chat`;function _n(e){return e===`New Chat`||e===`Chat`}var vn=`Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question — not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.`,yn=[`greeting`,`initiation`,`conversation start`,`introduction to`,`chat session`,`starting a chat`,`beginning of`];function bn(e){return typeof e.content==`string`?e.content.trim():String(e.content??``).trim()}function xn(e){for(let t of e){if(t.role!==`user`)continue;let e=bn(t);if(e)return e}return null}function Sn(e){let t=e.toLowerCase();for(let e of yn)if(t.includes(e))return!0;return!1}function Cn(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g,` `).toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function wn(e){return e.length>60?`${e.substring(0,57)}...`:e}function Tn(e){return e?.model?.trim()?e.provider===`ollama`?!0:!!e.apiKey?.trim():!1}async function En(e,t,n){let r=t.trim();if(!r||!Tn(e))return null;if(Cn(r))return wn(r);try{let t=(await Nt({config:Pt(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),messages:[{role:`system`,content:vn},{role:`user`,content:r}],signal:n})).trim();if(!t)return null;let i=wn(t);return i===`Chat`||Sn(i)?wn(r):i}catch{return null}}var Dn=28,On=3,kn=.72;function An({chatId:e,title:t,className:n,onRevealComplete:r}){let[i,a]=(0,Z.useState)(t),[o,s]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(1),d=(0,Z.useRef)(t),f=(0,Z.useRef)(null),p=(0,Z.useRef)(e);return(0,Z.useEffect)(()=>{if(p.current!==e){p.current=e,d.current=t,f.current=null,a(t),s(0),u(1);return}},[e,t]),(0,Z.useEffect)(()=>{let n=`${e}:${t}`;if(f.current===n){a(t),s(0),u(1);return}let i=d.current,o=_n(i)&&!_n(t)&&t!==i;if(d.current=t,!o){a(t),s(0),u(1);return}f.current=n;let c=0,l=t.length;a(``),s(On),u(kn);let p,m=()=>{c+=1;let e=l>0?c/l:1;a(t.slice(0,c)),s(On*(1-e)),u(kn+(1-kn)*e),c<l?p=setTimeout(m,Dn):r?.()};return p=setTimeout(m,Dn),()=>{p&&clearTimeout(p)}},[e,t,r]),(0,Q.jsx)(`span`,{className:c(`block truncate transition-[filter,opacity] duration-75`,n),style:{filter:o>0?`blur(${o}px)`:void 0,opacity:l},children:i})}function jn({compact:e,hideAgentName:t}){return(0,Q.jsxs)(`div`,{className:c(`flex items-center justify-between py-3 gap-2`,e?`px-4`:`px-3 rounded-lg`),children:[(0,Q.jsxs)(`div`,{className:c(`flex-1 min-w-0 flex flex-col gap-1`,t?`gap-1.5`:`gap-1`),children:[(0,Q.jsx)(mn,{className:`h-4 w-3/4`}),!t&&(0,Q.jsx)(mn,{className:`h-3 w-1/2`})]}),(0,Q.jsx)(mn,{className:`h-3 w-14 shrink-0`})]})}function Mn({chats:e,onDelete:t,onSelect:n,compact:r,hideAgentName:i,isLoading:a,currentChatId:s}){let[l,u]=Z.useState(``),d=e.filter(e=>e.type!==`agent_execution`),f=d.filter(e=>(e.title??``).toLowerCase().includes(l.toLowerCase())),p=e=>{let t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});let r=new Date(n);if(r.setDate(r.getDate()-1),t.toDateString()===r.toDateString())return`Yesterday`;let i=n.getTime()-t.getTime(),a=Math.floor(i/(1e3*60*60*24));return a<7?`${a} days ago`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},m=e=>(0,Q.jsxs)(`div`,{className:c(`flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer`,r?`px-4`:`px-3 rounded-lg`,s===e.id&&`bg-muted/50`),children:[(0,Q.jsxs)(`div`,{className:c(`flex-1 min-w-0 flex overflow-hidden`,i?`flex-col`:`flex-col gap-1`),children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium truncate w-full`,children:(0,Q.jsx)(An,{chatId:e.id,title:e.title},`${e.id}:${e.title}`)}),!i&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground truncate w-full`,children:e.agent_name})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:p(e.updated_at)})})]});return(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,Q.jsx)(`div`,{className:`mb-4 px-3 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(o,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(ee,{placeholder:`Search chats...`,value:l,onChange:e=>u(e.target.value),className:`pl-9 h-8 border-gray-300 dark:border-zinc-600`})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:a&&d.length===0?(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(jn,{compact:r,hideAgentName:i}),(0,Q.jsx)(jn,{compact:r,hideAgentName:i}),(0,Q.jsx)(jn,{compact:r,hideAgentName:i})]}):d.length===0?(0,Q.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]`,children:(0,Q.jsx)(Qe,{vertical:!0,noBorder:!0,message:`No chats`,className:`mt-0`})}):f.length===0?null:(0,Q.jsx)(`div`,{className:`space-y-1`,children:f.map(e=>n?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`block w-full text-left group cursor-pointer`,children:m(e)},e.id):(0,Q.jsx)(`div`,{className:`block group cursor-pointer`,children:m(e)},e.id))})})]})}var Nn=20;function Pn({provider:e,enabled:t=!0,agentId:n,refetchKey:r,refetchInterval:i=!1}){let[a,o]=(0,Z.useState)(1),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(void 0),g=(0,Z.useCallback)(async()=>{if(t){f(!0),m(null);try{let t=await e.listChats({...n?{agentId:n}:{},take:Nn*a,skip:0});c(t.items),u(t.total)}catch(e){m(e instanceof Error?e:Error(String(e)))}finally{f(!1)}}},[e,t,n,a]);(0,Z.useEffect)(()=>{t&&o(1)},[t]),(0,Z.useEffect)(()=>{g()},[g]),(0,Z.useEffect)(()=>{r!==void 0&&r!==h.current&&(h.current=r,t&&g())},[r,t,g]),(0,Z.useEffect)(()=>{if(!t||!i)return;let e=setInterval(()=>void g(),i);return()=>clearInterval(e)},[t,i,g]);let _=l>s.length;return{chats:s,total:l,isLoading:d,error:p,hasNextPage:_,loadMore:(0,Z.useCallback)(()=>{_&&!d&&o(e=>e+1)},[_,d]),refetch:(0,Z.useCallback)(()=>{g()},[g]),deleteChat:(0,Z.useCallback)(async t=>{await e.deleteChat(t),await g()},[e,g])}}function Fn({provider:e,open:t,onOpenChange:n,currentChatId:r,container:i,agentId:a,agentDisplayNameFallback:o,onSelectChat:s,variant:l=`drawer`,containerClassName:u,refetchKey:d,refetchInterval:f=!1,onCurrentChatDeleted:p,onDeleteSuccess:m,onDeleteError:h}){let g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),{chats:v,isLoading:y,hasNextPage:b,loadMore:x,deleteChat:S}=Pn({provider:e,enabled:t,agentId:a,refetchKey:d,refetchInterval:o?f||3e3:f});(0,Z.useEffect)(()=>{if(!t||!_.current)return;let e=new IntersectionObserver(e=>{e[0]?.isIntersecting&&x()},{threshold:.5});return e.observe(_.current),()=>{e.disconnect()}},[t,b,y,x]);let C=async e=>{try{await S(e),m?.(),e===r&&p?.()}catch(e){console.error(`Failed to delete chat:`,e),h?.(e)}},w=v.map(e=>({...e,title:e.title||`New Chat`,agent_name:e.agent_name??o??`Unknown Agent`})),T=w.filter(e=>e.type!==`agent_execution`).length,E=(0,Q.jsx)(Mn,{chats:w,onDelete:C,compact:l===`inline`,hideAgentName:!!o,isLoading:y&&v.length===0,currentChatId:r,onSelect:s?e=>{s(e),n(!1)}:void 0}),D=(0,Q.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[(0,Q.jsx)(pn,{count:T}),(0,Q.jsxs)(fn,{ref:g,className:c(`min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!`,l===`inline`?`p-0`:`px-3 sm:px-5`),children:[E,b&&(0,Q.jsx)(`div`,{ref:_,className:`py-4 flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(st,{className:`h-4 w-4 animate-spin`}),`Loading more...`]})})]})]});return l===`inline`?(0,Q.jsx)(`div`,{className:c(`flex h-full min-h-0 flex-col`,u),children:D}):(0,Q.jsx)(Mt,{open:t,onOpenChange:n,children:(0,Q.jsx)(kt,{side:`left`,className:`w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700`,container:i,children:D})})}function In({onCollapse:e}){return(0,Q.jsxs)(k,{children:[(0,Q.jsx)(g,{render:(0,Q.jsxs)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":`Collapse`,onClick:e,className:`border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background`,children:[(0,Q.jsx)(an,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Collapse`})]}),nativeButton:!0}),(0,Q.jsx)(P,{side:`right`,children:`Collapse`})]})}var Ln=`mcp-inspector-chats`,Rn=`New Chat`,zn=40;function Bn(){try{let e=localStorage.getItem(Ln);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages==`object`?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function Vn(e){localStorage.setItem(Ln,JSON.stringify(e))}function Hn(){return new Date().toISOString()}function Un(e){let t=e.find(e=>e.role===`user`);if(!t)return;let n=typeof t.content==`string`?t.content.trim():String(t.content??``).trim();if(n)return n.length>zn?`${n.slice(0,zn)}…`:n}var Wn=class{saveTimers=new Map;async listChats(e){let{sessions:t}=Bn(),n=t;e.agentId&&(n=t.filter(t=>t.agent_id===e.agentId)),n=[...n].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime());let r=n.length,i=e.skip??0,a=e.take??r;return{items:n.slice(i,i+a),total:r}}async getMessages(e){let{messages:t}=Bn();return t[e]??[]}async createChat(e){let t=Bn(),n=Hn(),r={id:crypto.randomUUID(),title:e.title??Rn,agent_id:e.agentId,agent_name:e.agentName??`MCP Server`,created_at:n,updated_at:n};return t.sessions.push(r),t.messages[r.id]=[],Vn(t),r}async updateChat(e,t){let n=Bn(),r=n.sessions.findIndex(t=>t.id===e);if(r===-1)throw Error(`Chat not found: ${e}`);let i=n.sessions[r];return t.title!==void 0&&(i.title=t.title),i.updated_at=Hn(),n.sessions[r]=i,Vn(n),i}async deleteChat(e){let t=Bn();t.sessions=t.sessions.filter(t=>t.id!==e),delete t.messages[e],Vn(t)}async saveMessages(e,t){let n=this.saveTimers.get(e);n&&clearTimeout(n),await new Promise(n=>{let r=setTimeout(()=>{this.saveTimers.delete(e);let r=Bn();r.messages[e]=t;let i=r.sessions.findIndex(t=>t.id===e);if(i!==-1){let e=r.sessions[i];if(e.updated_at=Hn(),e.title===Rn){let n=Un(t);n&&(e.title=n)}r.sessions[i]=e}Vn(r),n()},500);this.saveTimers.set(e,r)})}};function Gn({activeChatId:e,storage:t,messages:n,isLoading:r,effectiveClientSide:i,llmConfig:a,activeChatTitle:o,titleGenerationReady:s=!0,onTitleGenerated:c,onHistoryRefetch:l}){let u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{u.current=null},[e]),(0,Z.useEffect)(()=>{if(!e||!t||r||!s||o&&!_n(o))return;let d=xn(n);if(!d)return;let f=`${e}:${d}`;if(u.current===f)return;u.current=f;let p=!1;return(async()=>{let n=null;if(t.generateTitle?n=await t.generateTitle(e):i&&a&&(n=await En(a,d),n&&await t.updateChat(e,{title:n})),!p){if(!n||n===`New Chat`){u.current=null;return}l?.(),c?.(e,n)}})().catch(()=>{p||(u.current=null)}),()=>{p=!0}},[e,t,n,r,i,a,o,s,c,l])}var Kn=`#version 300 es
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-CuwKm9zO.js","assets/index-D2UxaT9v.js","assets/react-CU_d2d5K.js","assets/input-CjmxOFr6.js","assets/bundle-mjs-8puS6ou7.js","assets/createLucideIcon-B3b8EU0b.js","assets/jsx-runtime-Cjj9sGSy.js","assets/FormContext-Cqc_A12u.js","assets/select-C0xlfLAa.js","assets/AnimatePresence-CthXziG2.js","assets/label-B5Q_Zr8M.js","assets/index-BjH-Qp85.css"])))=>i.map(i=>d[i]);
2
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Cr as r,Dr as i,En as a,G as o,Ir as s,Lr as c,Mn as l,Nn as u,Nr as d,Sr as f,Tn as p,Yn as m,_r as h,a as g,an as _,br as v,c as y,d as b,dr as x,f as S,fr as C,gr as w,in as T,kn as E,mn as D,mr as O,n as k,on as A,or as j,pn as M,pr as N,r as P,s as F,sr as I,t as ee,u as L,wr as te,xr as ne}from"./input-CjmxOFr6.js";import{n as re,t as R}from"./label-B5Q_Zr8M.js";import{m as z,t as ie}from"./AnimatePresence-CthXziG2.js";import{a as B,c as ae,i as V,n as H,o as oe,p as se,r as U,s as W,t as G}from"./select-C0xlfLAa.js";import{a as K,c as q,i as ce,l as le,n as ue,o as de,r as fe,s as J,t as pe}from"./FormContext-Cqc_A12u.js";import{t as me}from"./createLucideIcon-B3b8EU0b.js";import{t as he}from"./refresh-cw-C9wQl8_d.js";import{$t as ge,A as _e,At as ve,Bt as ye,C as be,E as xe,F as Se,Ft as Ce,It as we,K as Te,Kt as Ee,M as De,Mt as Oe,N as ke,Nt as Ae,O as je,Q as Me,T as Ne,Xt as Pe,Yt as Fe,_ as Ie,_t as Le,a as Re,an as ze,b as Be,bt as Ve,c as He,cn as Ue,ct as We,d as Ge,dt as Ke,en as qe,f as Je,g as Ye,h as Xe,j as Ze,jt as Y,kt as Qe,l as $e,ln as et,lt as tt,m as nt,mt as rt,n as it,nn as at,on as X,ot,qt as st,rn as ct,s as lt,tn as ut,u as dt,v as ft,w as pt,wt as mt,y as ht}from"./index-D2UxaT9v.js";import{a as gt,c as _t,d as vt,f as yt,h as bt,l as xt,m as St,p as Ct,r as wt,s as Tt,u as Et}from"./chunk-BO2N2NFS-CGbd3eLY.js";import{a as Dt,i as Ot,n as kt,o as At,r as jt,t as Mt}from"./sheet-7TIkLdpr.js";import{a as Nt,c as Pt,i as Ft,n as It,o as Lt,r as Rt,s as zt}from"./dist-BcAQZluc.js";import{t as Bt}from"./useMCPPrompts-USLYc1I4.js";import{a as Vt,i as Ht,n as Ut,o as Wt,r as Gt,s as Kt,t as qt}from"./useConfig-Qglo4xs1.js";import{a as Jt,i as Yt,n as Xt,t as Zt}from"./tabs-subtle-AkJZvdxS.js";import{t as Qt}from"./textarea-Ci09-en6.js";import{t as $t}from"./checkbox-BA-XURSj.js";import{n as en,t as tn}from"./schemaHelpers-DLNTQr_6.js";import{t as nn}from"./useViewHostProps-DXAD1g7g.js";var rn=me(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),an=me(`arrow-left-from-line`,[[`path`,{d:`m9 6-6 6 6 6`,key:`7v63n9`}],[`path`,{d:`M3 12h14`,key:`13k4hi`}],[`path`,{d:`M21 19V5`,key:`b4bplr`}]]),on=me(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),sn=me(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),cn=me(`key`,[[`path`,{d:`m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4`,key:`g0fldk`}],[`path`,{d:`m21 2-9.6 9.6`,key:`1j0ho8`}],[`circle`,{cx:`7.5`,cy:`15.5`,r:`5.5`,key:`yqb3hr`}]]),ln=me(`paperclip`,[[`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`}]]),un=me(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),dn=me(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),Z=e(t(),1),Q=n(),fn=Z.forwardRef(({className:e,children:t,...n},r)=>(0,Q.jsx)(`div`,{ref:r,"data-slot":`scroll-area`,className:c(`relative overflow-hidden`,e),...n,children:(0,Q.jsx)(`div`,{"data-slot":`scroll-area-viewport`,className:`h-full w-full overflow-y-auto overflow-x-hidden`,children:t})}));fn.displayName=`ScrollArea`;function pn({count:e}){return(0,Q.jsx)(`div`,{className:`flex flex-row absolute top-0 right-0 z-10 w-full items-center justify-between gap-2 ${L}`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-full`,children:[(0,Q.jsx)(`h2`,{className:b,children:`Chat History`}),(0,Q.jsx)(d,{className:`bg-zinc-500/20 text-zinc-600 dark:text-zinc-400 border-transparent`,variant:`outline`,children:e})]})})}function mn({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:c(`animate-pulse rounded-md bg-muted`,e),...t})}var hn=`New Chat`,gn=`Chat`;function _n(e){return e===`New Chat`||e===`Chat`}var vn=`Generate a concise title (maximum 60 characters) for this chat based on the user's first message. Name the subject matter, task, or question — not the act of chatting. Never output meta phrases (e.g. do not use: greeting, introduction, initiation, conversation start, chat session). If there is no specific topic yet, reply with exactly: Chat. Return only the title, no quotes or extra text.`,yn=[`greeting`,`initiation`,`conversation start`,`introduction to`,`chat session`,`starting a chat`,`beginning of`];function bn(e){return typeof e.content==`string`?e.content.trim():String(e.content??``).trim()}function xn(e){for(let t of e){if(t.role!==`user`)continue;let e=bn(t);if(e)return e}return null}function Sn(e){let t=e.toLowerCase();for(let e of yn)if(t.includes(e))return!0;return!1}function Cn(e){let t=e.trim().split(/\r?\n/)[0].trim();if(!t)return!0;if(t.length>48)return!1;let n=t.replace(/\s+/g,` `).toLowerCase();return/^(hi|hello|hey|greetings?)[!.]?$/i.test(n)||/^(good morning|good afternoon|good evening)[!.]?$/i.test(n)||/^(hi|hello|hey)\s+(there|all|team|everyone)[!.]?$/i.test(n)}function wn(e){return e.length>60?`${e.substring(0,57)}...`:e}function Tn(e){return e?.model?.trim()?e.provider===`ollama`?!0:!!e.apiKey?.trim():!1}async function En(e,t,n){let r=t.trim();if(!r||!Tn(e))return null;if(Cn(r))return wn(r);try{let t=(await Nt({config:Pt(e.provider,e.model,{apiKey:e.apiKey,temperature:e.temperature,baseUrl:e.baseUrl,maxTokens:128}),messages:[{role:`system`,content:vn},{role:`user`,content:r}],signal:n})).trim();if(!t)return null;let i=wn(t);return i===`Chat`||Sn(i)?wn(r):i}catch{return null}}var Dn=28,On=3,kn=.72;function An({chatId:e,title:t,className:n,onRevealComplete:r}){let[i,a]=(0,Z.useState)(t),[o,s]=(0,Z.useState)(0),[l,u]=(0,Z.useState)(1),d=(0,Z.useRef)(t),f=(0,Z.useRef)(null),p=(0,Z.useRef)(e);return(0,Z.useEffect)(()=>{if(p.current!==e){p.current=e,d.current=t,f.current=null,a(t),s(0),u(1);return}},[e,t]),(0,Z.useEffect)(()=>{let n=`${e}:${t}`;if(f.current===n){a(t),s(0),u(1);return}let i=d.current,o=_n(i)&&!_n(t)&&t!==i;if(d.current=t,!o){a(t),s(0),u(1);return}f.current=n;let c=0,l=t.length;a(``),s(On),u(kn);let p,m=()=>{c+=1;let e=l>0?c/l:1;a(t.slice(0,c)),s(On*(1-e)),u(kn+(1-kn)*e),c<l?p=setTimeout(m,Dn):r?.()};return p=setTimeout(m,Dn),()=>{p&&clearTimeout(p)}},[e,t,r]),(0,Q.jsx)(`span`,{className:c(`block truncate transition-[filter,opacity] duration-75`,n),style:{filter:o>0?`blur(${o}px)`:void 0,opacity:l},children:i})}function jn({compact:e,hideAgentName:t}){return(0,Q.jsxs)(`div`,{className:c(`flex items-center justify-between py-3 gap-2`,e?`px-4`:`px-3 rounded-lg`),children:[(0,Q.jsxs)(`div`,{className:c(`flex-1 min-w-0 flex flex-col gap-1`,t?`gap-1.5`:`gap-1`),children:[(0,Q.jsx)(mn,{className:`h-4 w-3/4`}),!t&&(0,Q.jsx)(mn,{className:`h-3 w-1/2`})]}),(0,Q.jsx)(mn,{className:`h-3 w-14 shrink-0`})]})}function Mn({chats:e,onDelete:t,onSelect:n,compact:r,hideAgentName:i,isLoading:a,currentChatId:s}){let[l,u]=Z.useState(``),d=e.filter(e=>e.type!==`agent_execution`),f=d.filter(e=>(e.title??``).toLowerCase().includes(l.toLowerCase())),p=e=>{let t=new Date(e),n=new Date;if(t.toDateString()===n.toDateString())return t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});let r=new Date(n);if(r.setDate(r.getDate()-1),t.toDateString()===r.toDateString())return`Yesterday`;let i=n.getTime()-t.getTime(),a=Math.floor(i/(1e3*60*60*24));return a<7?`${a} days ago`:t.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})},m=e=>(0,Q.jsxs)(`div`,{className:c(`flex items-center justify-between py-3 hover:bg-muted/50 transition-colors gap-2 cursor-pointer`,r?`px-4`:`px-3 rounded-lg`,s===e.id&&`bg-muted/50`),children:[(0,Q.jsxs)(`div`,{className:c(`flex-1 min-w-0 flex overflow-hidden`,i?`flex-col`:`flex-col gap-1`),children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium truncate w-full`,children:(0,Q.jsx)(An,{chatId:e.id,title:e.title},`${e.id}:${e.title}`)}),!i&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground truncate w-full`,children:e.agent_name})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:p(e.updated_at)})})]});return(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col`,children:[(0,Q.jsx)(`div`,{className:`mb-4 px-3 sm:px-5`,children:(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(o,{className:`absolute left-3 top-2.5 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(ee,{placeholder:`Search chats...`,value:l,onChange:e=>u(e.target.value),className:`pl-9 h-8 border-gray-300 dark:border-zinc-600`})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1`,children:a&&d.length===0?(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(jn,{compact:r,hideAgentName:i}),(0,Q.jsx)(jn,{compact:r,hideAgentName:i}),(0,Q.jsx)(jn,{compact:r,hideAgentName:i})]}):d.length===0?(0,Q.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center min-h-[12rem]`,children:(0,Q.jsx)(Qe,{vertical:!0,noBorder:!0,message:`No chats`,className:`mt-0`})}):f.length===0?null:(0,Q.jsx)(`div`,{className:`space-y-1`,children:f.map(e=>n?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),className:`block w-full text-left group cursor-pointer`,children:m(e)},e.id):(0,Q.jsx)(`div`,{className:`block group cursor-pointer`,children:m(e)},e.id))})})]})}var Nn=20;function Pn({provider:e,enabled:t=!0,agentId:n,refetchKey:r,refetchInterval:i=!1}){let[a,o]=(0,Z.useState)(1),[s,c]=(0,Z.useState)([]),[l,u]=(0,Z.useState)(0),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),h=(0,Z.useRef)(void 0),g=(0,Z.useCallback)(async()=>{if(t){f(!0),m(null);try{let t=await e.listChats({...n?{agentId:n}:{},take:Nn*a,skip:0});c(t.items),u(t.total)}catch(e){m(e instanceof Error?e:Error(String(e)))}finally{f(!1)}}},[e,t,n,a]);(0,Z.useEffect)(()=>{t&&o(1)},[t]),(0,Z.useEffect)(()=>{g()},[g]),(0,Z.useEffect)(()=>{r!==void 0&&r!==h.current&&(h.current=r,t&&g())},[r,t,g]),(0,Z.useEffect)(()=>{if(!t||!i)return;let e=setInterval(()=>void g(),i);return()=>clearInterval(e)},[t,i,g]);let _=l>s.length;return{chats:s,total:l,isLoading:d,error:p,hasNextPage:_,loadMore:(0,Z.useCallback)(()=>{_&&!d&&o(e=>e+1)},[_,d]),refetch:(0,Z.useCallback)(()=>{g()},[g]),deleteChat:(0,Z.useCallback)(async t=>{await e.deleteChat(t),await g()},[e,g])}}function Fn({provider:e,open:t,onOpenChange:n,currentChatId:r,container:i,agentId:a,agentDisplayNameFallback:o,onSelectChat:s,variant:l=`drawer`,containerClassName:u,refetchKey:d,refetchInterval:f=!1,onCurrentChatDeleted:p,onDeleteSuccess:m,onDeleteError:h}){let g=(0,Z.useRef)(null),_=(0,Z.useRef)(null),{chats:v,isLoading:y,hasNextPage:b,loadMore:x,deleteChat:S}=Pn({provider:e,enabled:t,agentId:a,refetchKey:d,refetchInterval:o?f||3e3:f});(0,Z.useEffect)(()=>{if(!t||!_.current)return;let e=new IntersectionObserver(e=>{e[0]?.isIntersecting&&x()},{threshold:.5});return e.observe(_.current),()=>{e.disconnect()}},[t,b,y,x]);let C=async e=>{try{await S(e),m?.(),e===r&&p?.()}catch(e){console.error(`Failed to delete chat:`,e),h?.(e)}},w=v.map(e=>({...e,title:e.title||`New Chat`,agent_name:e.agent_name??o??`Unknown Agent`})),T=w.filter(e=>e.type!==`agent_execution`).length,E=(0,Q.jsx)(Mn,{chats:w,onDelete:C,compact:l===`inline`,hideAgentName:!!o,isLoading:y&&v.length===0,currentChatId:r,onSelect:s?e=>{s(e),n(!1)}:void 0}),D=(0,Q.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[(0,Q.jsx)(pn,{count:T}),(0,Q.jsxs)(fn,{ref:g,className:c(`min-h-0 flex-1 w-full pt-14 sm:pt-16 [&_[data-slot=scroll-area-viewport]]:block!`,l===`inline`?`p-0`:`px-3 sm:px-5`),children:[E,b&&(0,Q.jsx)(`div`,{ref:_,className:`py-4 flex items-center justify-center`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(st,{className:`h-4 w-4 animate-spin`}),`Loading more...`]})})]})]});return l===`inline`?(0,Q.jsx)(`div`,{className:c(`flex h-full min-h-0 flex-col`,u),children:D}):(0,Q.jsx)(Mt,{open:t,onOpenChange:n,children:(0,Q.jsx)(kt,{side:`left`,className:`w-[400px] sm:w-[400px] border-zinc-200 p-0 dark:border-zinc-700`,container:i,children:D})})}function In({onCollapse:e}){return(0,Q.jsxs)(k,{children:[(0,Q.jsx)(g,{render:(0,Q.jsxs)(I,{type:`button`,variant:`ghost`,size:`icon-sm`,tabIndex:-1,"aria-label":`Collapse`,onClick:e,className:`border-border absolute top-1/2 right-0 z-30 size-7 min-h-7 min-w-7 -translate-y-1/2 translate-x-1/2 rounded-full border bg-background`,children:[(0,Q.jsx)(an,{className:`size-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:`Collapse`})]}),nativeButton:!0}),(0,Q.jsx)(P,{side:`right`,children:`Collapse`})]})}var Ln=`mcp-inspector-chats`,Rn=`New Chat`,zn=40;function Bn(){try{let e=localStorage.getItem(Ln);if(!e)return{sessions:[],messages:{}};let t=JSON.parse(e);return{sessions:Array.isArray(t.sessions)?t.sessions:[],messages:t.messages&&typeof t.messages==`object`?t.messages:{}}}catch{return{sessions:[],messages:{}}}}function Vn(e){localStorage.setItem(Ln,JSON.stringify(e))}function Hn(){return new Date().toISOString()}function Un(e){let t=e.find(e=>e.role===`user`);if(!t)return;let n=typeof t.content==`string`?t.content.trim():String(t.content??``).trim();if(n)return n.length>zn?`${n.slice(0,zn)}…`:n}var Wn=class{saveTimers=new Map;async listChats(e){let{sessions:t}=Bn(),n=t;e.agentId&&(n=t.filter(t=>t.agent_id===e.agentId)),n=[...n].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime());let r=n.length,i=e.skip??0,a=e.take??r;return{items:n.slice(i,i+a),total:r}}async getMessages(e){let{messages:t}=Bn();return t[e]??[]}async createChat(e){let t=Bn(),n=Hn(),r={id:crypto.randomUUID(),title:e.title??Rn,agent_id:e.agentId,agent_name:e.agentName??`MCP Server`,created_at:n,updated_at:n};return t.sessions.push(r),t.messages[r.id]=[],Vn(t),r}async updateChat(e,t){let n=Bn(),r=n.sessions.findIndex(t=>t.id===e);if(r===-1)throw Error(`Chat not found: ${e}`);let i=n.sessions[r];return t.title!==void 0&&(i.title=t.title),i.updated_at=Hn(),n.sessions[r]=i,Vn(n),i}async deleteChat(e){let t=Bn();t.sessions=t.sessions.filter(t=>t.id!==e),delete t.messages[e],Vn(t)}async saveMessages(e,t){let n=this.saveTimers.get(e);n&&clearTimeout(n),await new Promise(n=>{let r=setTimeout(()=>{this.saveTimers.delete(e);let r=Bn();r.messages[e]=t;let i=r.sessions.findIndex(t=>t.id===e);if(i!==-1){let e=r.sessions[i];if(e.updated_at=Hn(),e.title===Rn){let n=Un(t);n&&(e.title=n)}r.sessions[i]=e}Vn(r),n()},500);this.saveTimers.set(e,r)})}};function Gn({activeChatId:e,storage:t,messages:n,isLoading:r,effectiveClientSide:i,llmConfig:a,activeChatTitle:o,titleGenerationReady:s=!0,onTitleGenerated:c,onHistoryRefetch:l}){let u=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{u.current=null},[e]),(0,Z.useEffect)(()=>{if(!e||!t||r||!s||o&&!_n(o))return;let d=xn(n);if(!d)return;let f=`${e}:${d}`;if(u.current===f)return;u.current=f;let p=!1;return(async()=>{let n=null;if(t.generateTitle?n=await t.generateTitle(e):i&&a&&(n=await En(a,d),n&&await t.updateChat(e,{title:n})),!p){if(!n||n===`New Chat`){u.current=null;return}l?.(),c?.(e,n)}})().catch(()=>{p||(u.current=null)}),()=>{p=!0}},[e,t,n,r,i,a,o,s,c,l])}var Kn=`#version 300 es
3
3
  precision mediump float;
4
4
 
5
5
  layout(location = 0) in vec4 a_position;
@@ -441,7 +441,7 @@ XID_Continue XIDC
441
441
  XID_Start XIDS`.split(/\s/).map(e=>[Cd(e),e])),_f=new Map([[`s`,tf(383)],[tf(383),`s`]]),vf=new Map([[tf(223),tf(7838)],[tf(107),tf(8490)],[tf(229),tf(8491)],[tf(969),tf(8486)]]),yf=new Map([Sf(453),Sf(456),Sf(459),Sf(498),...Cf(8072,8079),...Cf(8088,8095),...Cf(8104,8111),Sf(8124),Sf(8140),Sf(8188)]),bf=new Map([[`alnum`,$`[\p{Alpha}\p{Nd}]`],[`alpha`,$`\p{Alpha}`],[`ascii`,$`\p{ASCII}`],[`blank`,$`[\p{Zs}\t]`],[`cntrl`,$`\p{Cc}`],[`digit`,$`\p{Nd}`],[`graph`,$`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],[`lower`,$`\p{Lower}`],[`print`,$`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],[`punct`,$`[\p{P}\p{S}]`],[`space`,$`\p{space}`],[`upper`,$`\p{Upper}`],[`word`,$`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],[`xdigit`,$`\p{AHex}`]]);function xf(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Sf(e){let t=tf(e);return[t.toLowerCase(),t]}function Cf(e,t){return xf(e,t).map(e=>Sf(e))}var wf=new Set([`Lower`,`Lowercase`,`Upper`,`Uppercase`,`Ll`,`Lowercase_Letter`,`Lt`,`Titlecase_Letter`,`Lu`,`Uppercase_Letter`]);function Tf(e,t){let n={accuracy:`default`,asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:`ES2025`,...t};kf(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:sf(n.bestEffortTarget,`ES2024`),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};Ed(e,Ef,r);let i={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},a={currentFlags:i,prevFlags:null,globalFlags:i,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};return Ed(e,Df,a),Ed(e,Of,{groupsByName:a.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:a.reffedNodesByReferencer}),e._originMap=a.groupOriginByCopy,e._strategy=r.strategy,e}var Ef={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:i}=e;if(i===`repeater`){let e=cd();e.body[0].body.push(ld({negate:!0,body:r}),hd(`Any`));let i=cd();i.body[0].body.push(fd(`greedy`,0,1/0,e)),n(Jf(i,t),{traverse:!0})}else throw Error(`Unsupported absence function "(?~|"`)},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let i=e.body.filter(e=>e.kind===`flags`);for(let e=n+1;e<t.body.length;e++){let n=t.body[e];of(r,n,[]).push(...i)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=If(t.get(e));if(n){let t=cd({flags:n});t.body[0].body=e.body,e.body=[Jf(t,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:i,remove:a,replaceWith:o},s){let{kind:c,negate:l}=e,{asciiWordBoundaries:u,avoidSubclass:d,supportedGNodes:f,wordIsAscii:p}=s;if(c===`text_segment_boundary`)throw Error(`Unsupported text segment boundary "\\${l?`Y`:`y`}"`);if(c===`line_end`)o(Jf(ld({body:[Qu({body:[$u(`string_end`)]}),Qu({body:[nd(10)]})]}),t));else if(c===`line_start`)o(Jf(Gf($`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(c===`search_start`)if(f.has(e))i.flags.sticky=!0,a();else{let e=r[n-1];if(e&&Hf(e))o(Jf(ld({negate:!0}),t));else if(d)throw Error($`Uses "\G" in a way that requires a subclass`);else o(qf($u(`string_start`),t)),s.strategy=`clip_search`}else if(!(c===`string_end`||c===`string_start`))if(c===`string_end_newline`)o(Jf(Gf($`(?=\n?\z)`),t));else if(c===`word_boundary`){if(!p&&!u){let e=`(?:(?<=${mf})(?!${mf})|(?<!${mf})(?=${mf}))`,n=`(?:(?<=${mf})(?=${mf})|(?<!${mf})(?!${mf}))`;o(Jf(Gf(l?n:e),t))}}else throw Error(`Unexpected assertion kind "${c}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Wf(n)&&(n=Ff(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Wf(r)&&(r=Ff(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){t.kind===`intersection`&&n(Jf(rd({body:[e]}),t),{traverse:!0})},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:i,digitIsAscii:a,spaceIsAscii:o,wordIsAscii:s}){let{kind:c,negate:l,value:u}=e;if(a&&(c===`digit`||u===`digit`)){n(qf(ad(`digit`,{negate:l}),t));return}if(o&&(c===`space`||u===`space`)){n(Jf(Kf(Gf(ff),l),t));return}if(s&&(c===`word`||u===`word`)){n(qf(ad(`word`,{negate:l}),t));return}if(c===`any`)n(qf(hd(`Any`),t));else if(c===`digit`)n(qf(hd(`Nd`,{negate:l}),t));else if(c!==`dot`)if(c===`text_segment`){if(r===`strict`)throw Error($`Use of "\X" requires non-strict accuracy`);let e=`\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?`,a=$`\p{RI}{2}|${e}(?:\u200D${e})*`;n(Jf(Gf($`(?>\r\n|${i?$`\p{RGI_Emoji}`:a}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(c===`hex`)n(qf(hd(`AHex`,{negate:l}),t));else if(c===`newline`)n(Jf(Gf(l?`[^
442
442
  ]`:`(?>\r
443
443
  ?|[
444
- \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${tf(e.codePointAt(0)-1)}${tf(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Jf(Gf(`[${e}]`),t))}else n(Jf(Kf(Gf(bf.get(u)),l),t));else if(c===`property`)gf.has(Cd(u))||(e.key=`sc`);else if(c===`space`)n(qf(hd(`space`,{negate:l}),t));else if(c===`word`)n(Jf(Kf(Gf(mf),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=cd({flags:c});e.body[0].body=o(),i(Jf(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&zu(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error($`Uses "\K" in a way that's unsupported`);let o=ld({behind:!0});o.body[0].body=a(),i(Jf(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Jf(ld({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=cd();t.body[0].body.push(e.body),e.body=Jf(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=zf(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error($`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Wf(n)&&(n=Ff(n,t),e.ref=n)}},Df={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=qf(Nf(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&of(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=of(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=af(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Nf(0):Mf(o,r.groupOriginByCopy,null),l=c;if(!s){let e=If(Pf(o,e=>e.type===`Group`&&!!e.flags)),t=e?af(r.globalFlags,e):r.globalFlags;Af(t,r.currentFlags)||(l=cd({flags:Lf(t)}),l.body[0].body.push(c))}n(Jf(l,t),{traverse:!s})}},Of={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>jf(t,e));i.length?i.length>1?n(Jf(cd({atomic:!0,body:i.reverse().map(e=>Qu({body:[ed(e.number)]}))}),t)):e.ref=i[0].number:n(Jf(ld({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=td();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function kf(e){Ed(e,{"*"({node:e,parent:t}){e.parent=t}})}function Af(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function jf(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Rf(n.parent);for(let r of t){if(r===n)break;if(r===e||Bf(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Mf(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Mf(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Nf(e){let t=md(e);return t.isRecursive=!0,t}function Pf(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Ff(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function If(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Lf({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Rf(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function zf(e){let t=e.find(e=>e.kind===`search_start`||Uf(e,{negate:!1})||!Vf(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=zf(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Bf(e,t){let n=Rf(e)??[];for(let e of n)if(e===t||Bf(e,t))return!0;return!1}function Vf({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Hf(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Uf(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&zu(e.body[0],{type:`Assertion`,kind:`search_start`})}function Wf(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Gf(e,t){let n=Hu(e,{...t,unicodePropertyMap:gf}).body;return n.length>1||n[0].body.length>1?cd({body:n}):n[0].body[0]}function Kf(e,t){return e.negate=t,e}function qf(e,t){return e.parent=t,e}function Jf(e,t){return kf(e),e.parent=t,e}function Yf(e,t){let n=df(t),r=sf(n.target,`ES2024`),i=sf(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];Ed(e,Xf,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,cf(Zf[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&of(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Xf={"*":{enter({node:e},t){if(lp(e)){let n=t.getCurrentModI();t.pushModI(e.flags?af({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){lp(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){rp(tf(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),ip(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&wf.has(e.value)&&t.setHasCasedChar()}},Zf={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?$`\B`:$`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=tf(e),r=ap(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&rp(n)){let e=hf(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);nf.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(dp)&&(o=[nd(45),...o.filter(e=>!dp(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||nf.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=cd(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Qu({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(nf.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=ap(n,i),o=ap(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&op(ip(e)).forEach(e=>{s.add(Array.isArray(e)?`${ap(e[0],i)}-${ap(e[1],i)}`:ap(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:$`[^\n]`;if(e===`digit`)return t?$`\D`:$`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&wf.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?$`\P`:$`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?$`\W`:$`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=af(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${sp(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+cp(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:$`\g<${t}&R=${r}>`}},Qf=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),$f=new Set([`-`,`\\`,`]`,`^`,`[`]),ep=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),tp=new Map([[9,$`\t`],[10,$`\n`],[11,$`\v`],[12,$`\f`],[13,$`\r`],[8232,$`\u2028`],[8233,$`\u2029`],[65279,$`\uFEFF`]]),np=/^\p{Cased}$/u;function rp(e){return np.test(e)}function ip(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=tf(e);if(!rp(t))continue;let o=hf(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function ap(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(tp.has(e))return tp.get(e);if(e<32||e>126&&e<160||e>262143||t&&up(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?ep:$f:Qf,a=tf(e);return(i.has(a)?`\\`:``)+a}function op(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function sp(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function cp({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function lp({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function up(e){return e>47&&e<58}function dp({type:e,value:t}){return e===`Character`&&t===45}var fp=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=mp(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(pp(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=hp(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function pp(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function mp(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)of(n,t,{}).transferTo=e;return n}function hp(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function gp(e,t){let n=_p(e,t);return n.options?new fp(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function _p(e,t){let n=df(t),r=Tf(Hu(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:gf}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Yf(r,n),a=Yd(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=zd(Hd(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}var vp=4294967295,yp=class{constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:vp,end:vp,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function bp(e,t){return gp(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function xp(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>bp(e,{target:t.target}),{createScanner(e){return new yp(e,t)},createString(e){return{content:e}}}}var Sp=[`javascript`,`js`,`typescript`,`ts`,`python`,`py`,`bash`,`sh`,`shell`,`json`],Cp=new Set(Sp),wp={javascript:`javascript`,js:`javascript`,typescript:`typescript`,ts:`typescript`,python:`python`,py:`python`,bash:`bash`,sh:`bash`,shell:`bash`,json:`json`};function Tp(e){let t=e.trim().toLowerCase();return Cp.has(t)?wp[t]??null:null}function Ep(e){return typeof e==`string`?e:e.name??`custom`}var Dp=null;function Op(){return Dp||=Jl({themes:[xa,ba],langs:[ga,ya,va,ha,_a],engine:xp({forgiving:!0})}),Dp}var kp=new Map,Ap=new Map;function jp(e,t,n){let r=e.slice(0,100),i=e.length>100?e.slice(-100):``;return`${t}:${n[0]}:${n[1]}:${e.length}:${r}:${i}`}var Mp={name:`shiki`,type:`code-highlighter`,getSupportedLanguages:()=>[...Sp],getThemes:()=>[`github-light`,`github-dark`],supportsLanguage:e=>Tp(String(e))!=null,highlight({code:e,language:t,themes:n},r){let i=Tp(String(t));if(!i)return null;let a=Ep(n[0]),o=Ep(n[1]),s=jp(e,i,[a,o]);return kp.get(s)||(r&&(Ap.has(s)||Ap.set(s,new Set),Ap.get(s).add(r)),Op().then(t=>{let n=t.codeToTokens(e,{lang:i,themes:{light:a,dark:o}});kp.set(s,n);let r=Ap.get(s);if(r){for(let e of r)e(n);Ap.delete(s)}}).catch(e=>{console.error(`[Streamdown Code] Failed to highlight code:`,e),Ap.delete(s)}),null)}};function Np(e){return gt(e).map((e,t)=>`${t}:${e.length}:${e.charCodeAt(0)??0}`).join(`|`)}var Pp={code:Mp},Fp={animation:`fadeIn`,duration:200,easing:`ease-out`,sep:`word`,stagger:0},Ip=(0,Z.memo)(function({content:e,isStreaming:t=!1}){let n=(0,Z.useMemo)(()=>t?Np(e):`static`,[e,t]);return(0,Q.jsx)(wt,{className:c(`text-[14px] leading-relaxed text-foreground`,`[&_p]:mb-2 [&_p:last-child]:mb-0`,`[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2`),plugins:Pp,animated:Fp,isAnimating:t,parseIncompleteMarkdown:t,lineNumbers:!1,mode:t?`streaming`:`static`,children:e},n)});function Lp(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=new AbortController,{signal:n}=e,r=()=>{let e=`ontouchstart`in window||navigator.maxTouchPoints>0,n=window.matchMedia(`(pointer: coarse)`).matches;t(e&&n)};return window.matchMedia(`(pointer: coarse)`).addEventListener(`change`,r,{signal:n}),window.addEventListener(`pointerdown`,r,{signal:n}),r(),()=>e.abort()},[]),e}var Rp=null;async function zp(){return Rp||=Ve(()=>import(`./pdf-C3cfS_Ha.js`).then(e=>(e.GlobalWorkerOptions.workerSrc||(e.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${e.version}/build/pdf.worker.min.mjs`),e)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),Rp}async function Bp(e,t){let n=await zp(),r=await e.arrayBuffer(),i=await(await n.getDocument({data:r}).promise).getPage(1),a=i.getViewport({scale:1}),o=t*2/a.width,s=i.getViewport({scale:o}),c=document.createElement(`canvas`);return c.width=s.width,c.height=s.height,await i.render({canvas:c,viewport:s}).promise,c.toDataURL(`image/png`)}function Vp({file:e,size:t,className:n}){let r=s(),i=e.type.startsWith(`image/`),a=e.type===`application/pdf`,[o,l]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!i){l(null);return}let t=URL.createObjectURL(e);return l(t),()=>URL.revokeObjectURL(t)},[i,e]);let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(p(!1),!a){d(null);return}let n=!1;return Bp(e,t).then(e=>{n||d(e)}).catch(()=>{n||p(!0)}),()=>{n=!0}},[e,a,t]);let m=o??u,h=i&&!o||a&&!u&&!f;return(0,Q.jsx)(`div`,{className:c(`relative shrink-0 overflow-hidden bg-accent border border-border`,r.bg,n),style:{width:t,height:t},children:m?(0,Q.jsx)(`img`,{src:m,alt:e.name,className:`absolute inset-0 w-full h-full object-cover`}):h?(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin`,"aria-label":`Loading preview`,role:`status`})}):(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground`,role:`img`,"aria-label":e.name,children:(0,Q.jsxs)(`svg`,{width:Math.max(16,t*.35),height:Math.max(16,t*.35),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,Q.jsx)(`path`,{d:`M14 3v5h5`})]})})})}var Hp=(0,Z.forwardRef)(({from:e,files:t,thumbnailSize:n=64,time:r,actions:i,children:a,className:o,...l},u)=>{let d=s(),f=e===`user`,p=Lp(),m=f&&r!=null;return(0,Q.jsxs)(S.div,{ref:u,layout:`position`,initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:F.moderate,style:{transformOrigin:f?`bottom right`:`bottom left`},className:c(`group flex max-w-[80%] flex-col gap-1.5`,f?`items-end self-end`:`items-start self-start`,o),...l,children:[t&&t.length>0&&(0,Q.jsx)(`div`,{className:c(`flex flex-wrap gap-1.5`,f?`justify-end`:`justify-start`),children:t.map((e,t)=>(0,Q.jsx)(Vp,{file:e,size:n},`${e.name}-${e.size}-${e.lastModified}-${t}`))}),a!=null&&a!==``&&(0,Q.jsx)(`div`,{className:c(`py-2 text-[14px] whitespace-pre-wrap break-words`,f?c(d.bg,`px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground`):`text-foreground`),children:a}),(m||i!=null)&&(0,Q.jsxs)(`div`,{className:c(`flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none`,!p&&[`opacity-0 pointer-events-none transition-opacity duration-150`,`group-hover:opacity-100 group-hover:pointer-events-auto`,`group-focus-within:opacity-100 group-focus-within:pointer-events-auto`]),children:[m&&(0,Q.jsx)(`span`,{className:`tabular-nums`,children:r}),i!=null&&(0,Q.jsx)(`span`,{className:`flex items-center gap-0.5`,children:i})]})]})});Hp.displayName=`ChatMessage`;function Up({text:e}){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground flex items-center rounded p-0.5`,onClick:async()=>{await tt(e),n(!0),setTimeout(()=>n(!1),2e3)},title:`Copy message content`,"data-testid":`copy-button`,children:t?(0,Q.jsx)(X,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(ct,{className:`h-3.5 w-3.5`})})}function Wp(e,t){let n=e===1?`token`:`tokens`;return`${e.toLocaleString()} ${n} ${t}`}function Gp({variant:e,copyText:t,inputTokens:n,outputTokens:r}){let i=!!t,a=e===`user`&&n!=null?Wp(n,`in`):e===`assistant`&&r!=null?Wp(r,`out`):null;if(!i&&!a)return null;let o=i?(0,Q.jsx)(Up,{text:t}):null,s=a?(0,Q.jsx)(`span`,{className:`tabular-nums`,title:e===`user`?`Input tokens`:`Output tokens`,"data-testid":e===`user`?`message-input-tokens`:`message-output-tokens`,children:a}):null;return e===`user`?(0,Q.jsxs)(Q.Fragment,{children:[s,o]}):(0,Q.jsxs)(Q.Fragment,{children:[o,s]})}function Kp({content:e,timestamp:t,_isStreaming:n,outputTokens:r}){return!e||e.length===0?null:(0,Q.jsxs)(`div`,{"data-testid":`chat-message-assistant`,children:[(0,Q.jsx)(Hp,{from:`assistant`,actions:(0,Q.jsx)(Gp,{variant:`assistant`,copyText:e,outputTokens:r}),"data-testid":`chat-message-content`,children:(0,Q.jsx)(Ip,{content:e,isStreaming:n})}),t!=null&&(0,Q.jsx)(`span`,{className:`sr-only`,children:new Date(t).toLocaleTimeString()})]})}function qp({toolName:e,args:t,result:n,state:r=`result`,partialArgs:i}){let a=r===`call`&&i?i:t,o=()=>{switch(r){case`call`:return(0,Q.jsx)(st,{className:`h-4 w-4 animate-spin text-blue-500 dark:text-blue-400`});case`result`:return(0,Q.jsx)(X,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`});case`error`:return(0,Q.jsx)(Ce,{className:`h-4 w-4 text-red-500 dark:text-red-400`});default:return(0,Q.jsx)(X,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`})}},s=()=>{switch(r){case`call`:return` bg-blue-500/20 dark:bg-blue-500/20`;case`result`:return` bg-emerald-500/20 dark:bg-emerald-500/20`;case`error`:return` bg-red-500/20 dark:bg-red-500/20`;default:return` bg-emerald-500/20 dark:bg-emerald-500/20`}},l=e=>typeof e==`object`?dt(e).preview:String(e);return(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(At,{render:(0,Q.jsxs)(`div`,{className:`flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4`,"data-testid":`chat-tool-call-${e}`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0`,children:(0,Q.jsx)(we,{className:`size-4 text-muted-foreground`})}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[e,`(`,Object.keys(a).length>0?(0,Q.jsxs)(`span`,{className:`bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs`,children:[Object.keys(a).length,` args`]}):``,`)`]})})}),(0,Q.jsx)(`div`,{className:c(`w-8 h-8 rounded-full flex items-center justify-center`,s()),"data-testid":`chat-tool-call-status-${r}`,children:o()})]}),nativeButton:!1}),(0,Q.jsxs)(kt,{side:`right`,className:`w-[400px] sm:w-[540px] p-4 overflow-y-auto`,"data-testid":`chat-tool-drawer`,children:[(0,Q.jsxs)(Ot,{children:[(0,Q.jsxs)(Dt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(we,{className:`h-5 w-5`}),`Tool Call Details`]}),(0,Q.jsxs)(jt,{className:`flex items-center gap-2`,children:[e,` — `,r,r===`call`&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-blue-500 dark:text-blue-400`,children:[(0,Q.jsx)(st,{className:`h-3 w-3 animate-spin`}),`streaming…`]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Arguments`}),(0,Q.jsxs)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-args`,children:[(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words`,children:l(a)}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(l(a)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy arguments`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]})]}),n&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Result`}),(0,Q.jsx)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-result`,children:typeof n==`string`?(0,Q.jsxs)(`div`,{className:c(`p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[n.startsWith(`Error`)?(0,Q.jsxs)(`div`,{className:`font-mono`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-destructive mb-1`,children:`Error:`}),(0,Q.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:n.replace(/^Error:\s*/,``)})]}):(0,Q.jsx)(`div`,{className:`whitespace-pre-wrap font-mono break-words`,children:n}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(n),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]}):(0,Q.jsxs)(`div`,{className:c(`p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[(0,Q.jsx)($e,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(JSON.stringify(n,null,2)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]})})]})]})]})]})}function Jp({widgetId:e}){let{getWidget:t}=it(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,Q.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,Q.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function Yp({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,partialToolArgs:s,cancelled:c}){let l=(0,Z.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),u=(0,Z.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch{return n}return n},[n]),d=rt(a),f=d?a?.ui?.resourceUri??null:null,p=(0,Z.useMemo)(()=>t,[e,u]),m=(0,Z.useMemo)(()=>u,[e,u]),h=nn({serverId:r??``,viewId:l,resourceUri:f??``,toolName:e,toolInput:p,toolOutput:m,toolMetadata:a,readResource:i??(async()=>({}))});return d&&f&&r&&i&&h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ke,{viewId:l,toolName:e,toolInput:p,toolOutput:m,partialToolInput:s,cancelled:c,className:`my-4`,onMessage:e=>{e.length>0&&o&&o(e)},...h}),(0,Q.jsx)(Jp,{widgetId:l})]}):d&&!f?(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,Q.jsx)(Ne,{className:`size-5`})}):d&&(!r||!i)?(0,Q.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})}):null}function Xp(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new File([n],e.name||`attachment`,{type:e.mimeType})}function Zp({content:e,timestamp:t,attachments:n,inputTokens:r}){let i=(0,Z.useMemo)(()=>n?.map(Xp),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:(0,Q.jsx)(`div`,{"data-testid":`chat-message-user`,className:`flex flex-col items-end`,children:(0,Q.jsx)(Hp,{from:`user`,files:i,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||r!=null?(0,Q.jsx)(Gp,{variant:`user`,copyText:e||void 0,inputTokens:r}):void 0,"data-testid":`chat-message-content`,children:e&&e.length>0?e:void 0})})}var Qp={events:[],spans:[]};function $p(e){if(!e||typeof e!=`object`)return;let t=e,n=(...e)=>{for(let n of e)if(typeof t[n]==`number`)return t[n]},r=n(`inputTokens`,`input_tokens`,`promptTokens`),i=n(`outputTokens`,`output_tokens`,`completionTokens`),a=n(`totalTokens`,`total_tokens`)??(r!==void 0&&i!==void 0?r+i:void 0);if(!(r===void 0&&i===void 0&&a===void 0))return{inputTokens:r,outputTokens:i,totalTokens:a}}var em=new Set([`apikey`,`authorization`,`accesstoken`,`refreshtoken`,`password`,`cookie`,`secret`]);function tm(e){return Array.isArray(e)?e.map(tm):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,em.has(e.toLowerCase().replace(/[_-]/g,``))?`[REDACTED]`:tm(t)]))}function nm(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}…`:n}function rm(e){switch(e.type){case`request`:return`LLM request`;case`text-delta`:return e.delta.trim()||`Text delta`;case`tool-call-start`:return e.toolName;case`tool-call-args`:return nm(e.args);case`tool-result`:return nm(e.result);case`usage`:return`${e.usage.totalTokens??`?`} tokens`;case`error`:return e.message;case`done`:return`Completed`;default:return e}}function im(e,t){let n=(e,t)=>e===void 0&&t===void 0?void 0:(e??0)+(t??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function am(e,t){let n=e.spans.map(e=>({...e})),r=e.usage,i=[...n].reverse().find(e=>e.kind===`llm`&&e.status===`running`);if(t.type===`request`)n.push({id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if((t.type===`text-delta`||t.type===`tool-call-start`)&&!i)i={id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:t.type===`text-delta`?rm(t):`LLM response`},n.push(i),t.type===`tool-call-start`&&n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if(t.type===`tool-call-start`)n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if(t.type===`tool-call-args`){let e=n.find(e=>e.id===t.toolCallId);e&&(e.preview=rm(t))}else if(t.type===`tool-result`){let e=t.toolCallId?n.find(e=>e.id===t.toolCallId):[...n].reverse().find(e=>e.kind===`tool`&&e.name===t.toolName&&e.status===`running`);e&&(e.status=t.isError?`error`:`success`,e.endedAt=t.timestamp,e.preview=rm(t))}else t.type===`usage`?(r=im(r,t.usage),i&&(i.usage=im(i.usage,t.usage))):(t.type===`error`||t.type===`done`)&&i&&(i.status=t.type===`error`?`error`:`success`,i.endedAt=t.timestamp,i.preview=rm(t));return{events:[...e.events,t],spans:n,usage:r}}function om(e,t){let n=[],r=null;for(let t of e)t.type===`request`?(r&&n.push(r),r={request:t,response:[]}):r&&r.response.push(t);return r&&n.push(r),{turns:n,tokenUsage:t??null}}function sm(e){let t;for(let n of e)n.type===`usage`&&(t=im(t,n.usage));return t}function cm(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!==`user`){n++;continue}let r=e[n].id;n++;let i=null;for(;n<e.length&&e[n]?.role===`assistant`;)i=e[n].id,n++;t.push({userId:r,assistantId:i})}return t}function lm(e,t){let{turns:n}=om(t),r=cm(e),i=new Map,a=Math.min(n.length,r.length);for(let e=0;e<a;e++){let t=sm(n[e].response);if(!t)continue;let{userId:a,assistantId:o}=r[e];t.inputTokens!=null&&i.set(a,{...i.get(a),inputTokens:t.inputTokens}),o!=null&&t.outputTokens!=null&&i.set(o,{...i.get(o),outputTokens:t.outputTokens})}return i}var um=(0,Z.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,messagesEndRef:o,traceEvents:s=[]})=>{let c=(0,Z.useMemo)(()=>lm(e,s),[e,s]),l=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},u=e=>rt(l(e)),d=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
444
+ \v\f…\u2028\u2029])`),t));else if(c===`posix`)if(!i&&(u===`graph`||u===`print`)){if(r===`strict`)throw Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let e={graph:`!-~`,print:` -~`}[u];l&&(e=`\0-${tf(e.codePointAt(0)-1)}${tf(e.codePointAt(2)+1)}-\u{10FFFF}`),n(Jf(Gf(`[${e}]`),t))}else n(Jf(Kf(Gf(bf.get(u)),l),t));else if(c===`property`)gf.has(Cd(u))||(e.key=`sc`);else if(c===`space`)n(qf(hd(`space`,{negate:l}),t));else if(c===`word`)n(Jf(Kf(Gf(mf),l),t));else throw Error(`Unexpected character set kind "${c}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:i,removeAllPrevSiblings:a,removeAllNextSiblings:o}){let{kind:s,flags:c}=e;if(s===`flags`)if(!c.enable&&!c.disable)r();else{let e=cd({flags:c});e.body[0].body=o(),i(Jf(e,t),{traverse:!0})}else if(s===`keep`){let e=n.body[0],r=n.body.length===1&&zu(e,{type:`Group`})&&e.body[0].body.length===1?e.body[0]:n;if(t.parent!==r||r.body.length>1)throw Error($`Uses "\K" in a way that's unsupported`);let o=ld({behind:!0});o.body[0].body=a(),i(Jf(o,t))}else throw Error(`Unexpected directive kind "${s}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw Error(`Unsupported flag "P"`);if(e.textSegmentMode===`word`)throw Error(`Unsupported flag "y{w}"`);[`digitIsAscii`,`extended`,`posixIsAscii`,`spaceIsAscii`,`wordIsAscii`,`textSegmentMode`].forEach(t=>delete e[t]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n===`lookbehind`&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r===`fail`)n(Jf(ld({negate:!0}),t));else throw Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type===`Quantifier`){let t=cd();t.body[0].body.push(e.body),e.body=Jf(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,i=!1;for(let t of e.body)if(t.body.length===1&&t.body[0].kind===`search_start`)t.body.pop();else{let e=zf(t.body);e?(r=!0,Array.isArray(e)?n.push(...e):n.push(e)):i=!0}r&&!i&&n.forEach(e=>t.add(e))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t===`strict`&&n&&r)throw Error($`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n==`string`&&!Wf(n)&&(n=Ff(n,t),e.ref=n)}},Df={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:i}=e;r||n.set(e,[...t.get(i).map(({node:e})=>e)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:i,groupsByName:a,multiplexCapturesToLeftByRef:o,openRefs:s,reffedNodesByReferencer:c}){let l=i.get(e);if(l&&s.has(e.number)){let r=qf(Nf(e.number),t);c.set(r,s.get(e.number)),n(r);return}s.set(e.number,e),o.set(e.number,[]),e.name&&of(o,e.name,[]);let u=o.get(e.name??e.number);for(let t=0;t<u.length;t++){let n=u[t];if(l===n.node||l&&l===n.origin||e===n.origin){u.splice(t,1);break}}if(o.get(e.number).push({node:e,origin:l}),e.name&&o.get(e.name).push({node:e,origin:l}),e.name){let t=of(a,e.name,new Map),n=!1;if(l)n=!0;else for(let e of t.values())if(!e.hasDuplicateNameToRemove){n=!0;break}a.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:n})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=af(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:i,ref:a}=e;if(i){let n=t;for(;(n=n.parent)&&!(n.type===`CapturingGroup`&&(n.name===a||n.number===a)););r.reffedNodesByReferencer.set(e,n);return}let o=r.subroutineRefMap.get(a),s=a===0,c=s?Nf(0):Mf(o,r.groupOriginByCopy,null),l=c;if(!s){let e=If(Pf(o,e=>e.type===`Group`&&!!e.flags)),t=e?af(r.globalFlags,e):r.globalFlags;Af(t,r.currentFlags)||(l=cd({flags:Lf(t)}),l.body[0].body.push(c))}n(Jf(l,t),{traverse:!s})}},Of={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let i=r.reffedNodesByReferencer.get(e).filter(t=>jf(t,e));i.length?i.length>1?n(Jf(cd({atomic:!0,body:i.reverse().map(e=>Qu({body:[ed(e.number)]}))}),t)):e.ref=i[0].number:n(Jf(ld({negate:!0}),t))},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let t=0;t<n;t++){let t=td();e.body.at(-1).body.push(t)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function kf(e){Ed(e,{"*"({node:e,parent:t}){e.parent=t}})}function Af(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function jf(e,t){let n=t;do{if(n.type===`Regex`)return!1;if(n.type===`Alternative`)continue;if(n===e)return!1;let t=Rf(n.parent);for(let r of t){if(r===n)break;if(r===e||Bf(r,e))return!0}}while(n=n.parent);throw Error(`Unexpected path`)}function Mf(e,t,n,r){let i=Array.isArray(e)?[]:{};for(let[a,o]of Object.entries(e))a===`parent`?i.parent=Array.isArray(n)?r:n:o&&typeof o==`object`?i[a]=Mf(o,t,i,n):(a===`type`&&o===`CapturingGroup`&&t.set(i,t.get(e)??e),i[a]=o);return i}function Nf(e){let t=md(e);return t.isRecursive=!0,t}function Pf(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Ff(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/gu,`_`)}`;return t.set(e,n),n}function If(e){let t=[`dotAll`,`ignoreCase`],n={enable:{},disable:{}};return e.forEach(({flags:e})=>{t.forEach(t=>{e.enable?.[t]&&(delete n.disable[t],n.enable[t]=!0),e.disable?.[t]&&(n.disable[t]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Lf({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Rf(e){if(!e)throw Error(`Node expected`);let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function zf(e){let t=e.find(e=>e.kind===`search_start`||Uf(e,{negate:!1})||!Vf(e));if(!t)return null;if(t.kind===`search_start`)return t;if(t.type===`LookaroundAssertion`)return t.body[0].body[0];if(t.type===`CapturingGroup`||t.type===`Group`){let e=[];for(let n of t.body){let t=zf(n.body);if(!t)return null;Array.isArray(t)?e.push(...t):e.push(t)}return e}return null}function Bf(e,t){let n=Rf(e)??[];for(let e of n)if(e===t||Bf(e,t))return!0;return!1}function Vf({type:e}){return e===`Assertion`||e===`Directive`||e===`LookaroundAssertion`}function Hf(e){let t=[`Character`,`CharacterClass`,`CharacterSet`];return t.includes(e.type)||e.type===`Quantifier`&&e.min&&t.includes(e.body.type)}function Uf(e,t){let n={negate:null,...t};return e.type===`LookaroundAssertion`&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&zu(e.body[0],{type:`Assertion`,kind:`search_start`})}function Wf(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Gf(e,t){let n=Hu(e,{...t,unicodePropertyMap:gf}).body;return n.length>1||n[0].body.length>1?cd({body:n}):n[0].body[0]}function Kf(e,t){return e.negate=t,e}function qf(e,t){return e.parent=t,e}function Jf(e,t){return kf(e),e.parent=t,e}function Yf(e,t){let n=df(t),r=sf(n.target,`ES2024`),i=sf(n.target,`ES2025`),a=n.rules.recursionLimit;if(!Number.isInteger(a)||a<2||a>20)throw Error(`Invalid recursionLimit; use 2-20`);let o=null,s=null;if(!i){let t=[e.flags.ignoreCase];Ed(e,Xf,{getCurrentModI:()=>t.at(-1),popModI(){t.pop()},pushModI(e){t.push(e)},setHasCasedChar(){t.at(-1)?o=!0:s=!0}})}let c={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||o)&&!s)},l=e,u={accuracy:n.accuracy,appliedGlobalFlags:c,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:l,originMap:e._originMap,recursionLimit:a,useAppliedIgnoreCase:!!(!i&&o&&s),useFlagMods:i,useFlagV:r,verbose:n.verbose};function d(e){return u.lastNode=l,l=e,cf(Zf[e.type],`Unexpected node type "${e.type}"`)(e,u,d)}let f={pattern:e.body.map(d).join(`|`),flags:d(e.flags),options:{...e.options}};return r||(delete f.options.force.v,f.options.disable.v=!0,f.options.unicodeSetsPlugin=null),f._captureTransfers=new Map,f._hiddenCaptures=[],u.captureMap.forEach((e,t)=>{e.hidden&&f._hiddenCaptures.push(t),e.transferTo&&of(f._captureTransfers,e.transferTo,[]).push(t)}),f}var Xf={"*":{enter({node:e},t){if(lp(e)){let n=t.getCurrentModI();t.pushModI(e.flags?af({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){lp(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){rp(tf(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),ip(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind===`property`&&wf.has(e.value)&&t.setHasCasedChar()}},Zf={Alternative({body:e},t,n){return e.map(n).join(``)},Assertion({kind:e,negate:t}){if(e===`string_end`)return`$`;if(e===`string_start`)return`^`;if(e===`word_boundary`)return t?$`\B`:$`\b`;throw Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!=`number`)throw Error(`Unexpected named backref in transformed AST`);if(!t.useFlagMods&&t.accuracy===`strict`&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw Error(`Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy`);return`\\`+e},CapturingGroup(e,t,n){let{body:r,name:i,number:a}=e,o={ignoreCase:t.currentFlags.ignoreCase},s=t.originMap.get(e);return s&&(o.hidden=!0,a>s.number&&(o.transferTo=s.number)),t.captureMap.set(a,o),`(${i?`?<${i}>`:``}${r.map(n).join(`|`)})`},Character({value:e},t){let n=tf(e),r=ap(e,{escDigit:t.lastNode.type===`Backreference`,inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&rp(n)){let e=hf(n);return t.inCharClass?e.join(``):e.length>1?`[${e.join(``)}]`:e[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:i,parent:a}=e,{body:o}=e;if(r===`intersection`&&!t.useFlagV)throw Error(`Use of character class intersection requires min target ES2024`);nf.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&o.some(dp)&&(o=[nd(45),...o.filter(e=>!dp(e))]);let s=()=>`[${i?`^`:``}${o.map(n).join(r===`intersection`?`&&`:``)}]`;if(!t.inCharClass){if((!t.useFlagV||nf.bugNestedClassIgnoresNegation)&&!i){let t=o.filter(e=>e.type===`CharacterClass`&&e.kind===`union`&&e.negate);if(t.length){let r=cd(),i=r.body[0];return r.parent=a,i.parent=r,o=o.filter(e=>!t.includes(e)),e.body=o,o.length?(e.parent=i,i.body.push(e)):r.body.pop(),t.forEach(e=>{let t=Qu({body:[e]});e.parent=t,t.parent=r,r.body.push(t)}),n(r)}}t.inCharClass=!0;let r=s();return t.inCharClass=!1,r}let c=o[0];if(r===`union`&&!i&&c&&((!t.useFlagV||!t.verbose)&&a.kind===`union`&&!(nf.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&a.kind===`intersection`&&o.length===1&&c.type!==`CharacterClassRange`))return o.map(n).join(``);if(!t.useFlagV&&a.type===`CharacterClass`)throw Error(`Uses nested character class in a way that requires min target ES2024`);return s()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,i={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},a=ap(n,i),o=ap(r,i),s=new Set;return t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&op(ip(e)).forEach(e=>{s.add(Array.isArray(e)?`${ap(e[0],i)}-${ap(e[1],i)}`:ap(e,i))}),`${a}-${o}${[...s].join(``)}`},CharacterSet({kind:e,negate:t,value:n,key:r},i){if(e===`dot`)return i.currentFlags.dotAll?i.appliedGlobalFlags.dotAll||i.useFlagMods?`.`:`[^]`:$`[^\n]`;if(e===`digit`)return t?$`\D`:$`\d`;if(e===`property`){if(i.useAppliedIgnoreCase&&i.currentFlags.ignoreCase&&wf.has(n))throw Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?$`\P`:$`\p`}{${r?`${r}=`:``}${n}}`}if(e===`word`)return t?$`\W`:$`\w`;throw Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?`i`:``)+(e.dotAll?`s`:``)+(e.sticky?`y`:``)},Group({atomic:e,body:t,flags:n,parent:r},i,a){let o=i.currentFlags;n&&(i.currentFlags=af(o,n));let s=t.map(a).join(`|`),c=!i.verbose&&t.length===1&&r.type!==`Quantifier`&&!e&&(!i.useFlagMods||!n)?s:`(?${sp(e,n,i.useFlagMods)}${s})`;return i.currentFlags=o,c},LookaroundAssertion({body:e,kind:t,negate:n},r,i){return`(?${`${t===`lookahead`?``:`<`}${n?`!`:`=`}`}${e.map(i).join(`|`)})`},Quantifier(e,t,n){return n(e.body)+cp(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw Error(`Unexpected non-recursive subroutine in transformed AST`);let r=n.recursionLimit;return t===0?`(?R=${r})`:$`\g<${t}&R=${r}>`}},Qf=new Set([`$`,`(`,`)`,`*`,`+`,`.`,`?`,`[`,`\\`,`]`,`^`,`{`,`|`,`}`]),$f=new Set([`-`,`\\`,`]`,`^`,`[`]),ep=new Set("()-/[\\]^{|}!#$%&*+,.:;<=>?@`~".split(``)),tp=new Map([[9,$`\t`],[10,$`\n`],[11,$`\v`],[12,$`\f`],[13,$`\r`],[8232,$`\u2028`],[8233,$`\u2029`],[65279,$`\uFEFF`]]),np=/^\p{Cased}$/u;function rp(e){return np.test(e)}function ip(e,t){let n=!!t?.firstOnly,r=e.min.value,i=e.max.value,a=[];if(r<65&&(i===65535||i>=131071)||r===65536&&i>=131071)return a;for(let e=r;e<=i;e++){let t=tf(e);if(!rp(t))continue;let o=hf(t).filter(e=>{let t=e.codePointAt(0);return t<r||t>i});if(o.length&&(a.push(...o),n))break}return a}function ap(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(tp.has(e))return tp.get(e);if(e<32||e>126&&e<160||e>262143||t&&up(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,`0`)}`;let i=n?r?ep:$f:Qf,a=tf(e);return(i.has(a)?`\\`:``)+a}function op(e){let t=e.map(e=>e.codePointAt(0)).sort((e,t)=>e-t),n=[],r=null;for(let e=0;e<t.length;e++)t[e+1]===t[e]+1?r??=t[e]:r===null?n.push(t[e]):(n.push([r,t[e]]),r=null);return n}function sp(e,t,n){if(e)return`>`;let r=``;if(t&&n){let{enable:e,disable:n}=t;r=(e?.ignoreCase?`i`:``)+(e?.dotAll?`s`:``)+(n?`-`:``)+(n?.ignoreCase?`i`:``)+(n?.dotAll?`s`:``)}return`${r}:`}function cp({kind:e,max:t,min:n}){let r;return r=!n&&t===1?`?`:!n&&t===1/0?`*`:n===1&&t===1/0?`+`:n===t?`{${n}}`:`{${n},${t===1/0?``:t}}`,r+{greedy:``,lazy:`?`,possessive:`+`}[e]}function lp({type:e}){return e===`CapturingGroup`||e===`Group`||e===`LookaroundAssertion`}function up(e){return e>47&&e<58}function dp({type:e,value:t}){return e===`Character`&&t===45}var fp=class e extends RegExp{#e=new Map;#t=null;#n;#r=null;#i=null;rawOptions={};get source(){return this.#n||`(?:)`}constructor(t,n,r){let i=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw Error(`Cannot provide options when copying a regexp`);let i=t;super(i,n),this.#n=i.source,i instanceof e&&(this.#e=i.#e,this.#r=i.#r,this.#i=i.#i,this.rawOptions=i.rawOptions)}else{let e={hiddenCaptures:[],strategy:null,transfers:[],...r};super(i?``:t,n),this.#n=t,this.#e=mp(e.hiddenCaptures,e.transfers),this.#i=e.strategy,this.rawOptions=r??{}}i||(this.#t=this)}exec(t){if(!this.#t){let{lazyCompile:t,...n}=this.rawOptions;this.#t=new e(this.#n,this.flags,n)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#i===`clip_search`&&n&&r){this.lastIndex=0;let e=this.#a(t.slice(r));return e&&(pp(e,r,t,this.hasIndices),this.lastIndex+=r),e}return this.#a(t)}#a(e){this.#t.lastIndex=this.lastIndex;let t=super.exec.call(this.#t,e);if(this.lastIndex=this.#t.lastIndex,!t||!this.#e.size)return t;let n=[...t];t.length=1;let r;this.hasIndices&&(r=[...t.indices],t.indices.length=1);let i=[0];for(let e=1;e<n.length;e++){let{hidden:a,transferTo:o}=this.#e.get(e)??{};if(a?i.push(null):(i.push(t.length),t.push(n[e]),this.hasIndices&&t.indices.push(r[e])),o&&n[e]!==void 0){let a=i[o];if(!a)throw Error(`Invalid capture transfer to "${a}"`);if(t[a]=n[e],this.hasIndices&&(t.indices[a]=r[e]),t.groups){this.#r||=hp(this.source);let i=this.#r.get(o);i&&(t.groups[i]=n[e],this.hasIndices&&(t.indices.groups[i]=r[e]))}}}return t}};function pp(e,t,n,r){if(e.index+=t,e.input=n,r){let n=e.indices;for(let e=0;e<n.length;e++){let r=n[e];r&&(n[e]=[r[0]+t,r[1]+t])}let r=n.groups;r&&Object.keys(r).forEach(e=>{let n=r[e];n&&(r[e]=[n[0]+t,n[1]+t])})}}function mp(e,t){let n=new Map;for(let t of e)n.set(t,{hidden:!0});for(let[e,r]of t)for(let t of r)of(n,t,{}).transferTo=e;return n}function hp(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,i=0,a;for(;a=t.exec(e);){let{0:e,groups:{capture:t,name:o}}=a;e===`[`?r++:r?e===`]`&&r--:t&&(i++,o&&n.set(i,o))}return n}function gp(e,t){let n=_p(e,t);return n.options?new fp(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function _p(e,t){let n=df(t),r=Tf(Hu(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:gf}),{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),i=Yf(r,n),a=Yd(i.pattern,{captureTransfers:i._captureTransfers,hiddenCaptures:i._hiddenCaptures,mode:`external`}),o=zd(Hd(a.pattern).pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),s={pattern:o.pattern,flags:`${n.hasIndices?`d`:``}${n.global?`g`:``}${i.flags}${i.options.disable.v?`u`:`v`}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw Error(`Lazy compilation requires subclass`)}else{let e=o.hiddenCaptures.sort((e,t)=>e-t),t=Array.from(o.captureTransfers),i=r._strategy,a=s.pattern.length>=n.lazyCompileLength;(e.length||t.length||i||a)&&(s.options={...e.length&&{hiddenCaptures:e},...t.length&&{transfers:t},...i&&{strategy:i},...a&&{lazyCompile:a}})}return s}var vp=4294967295,yp=class{constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:i}=t;if(!i)throw Error("Option `regexConstructor` is not provided");this.regexps=e.map(e=>{if(typeof e!=`string`)return e;let t=r?.get(e);if(t){if(t instanceof RegExp)return t;if(n)return null;throw t}try{let t=i(e);return r?.set(e,t),t}catch(t){if(r?.set(e,t),n)return null;throw t}})}regexps;findNextMatchSync(e,t,n){let r=typeof e==`string`?e:e.content,i=[];function a(e,t,n=0){return{index:e,captureIndices:t.indices.map(e=>e==null?{start:vp,end:vp,length:0}:{start:e[0]+n,end:e[1]+n,length:e[1]-e[0]})}}for(let e=0;e<this.regexps.length;e++){let n=this.regexps[e];if(n)try{n.lastIndex=t;let o=n.exec(r);if(!o)continue;if(o.index===t)return a(e,o,0);i.push([e,o,0])}catch(e){if(this.options.forgiving)continue;throw e}}if(i.length){let e=Math.min(...i.map(e=>e[1].index));for(let[t,n,r]of i)if(n.index===e)return a(t,n,r)}return null}};function bp(e,t){return gp(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function xp(e={}){let t=Object.assign({target:`auto`,cache:new Map},e);return t.regexConstructor||=e=>bp(e,{target:t.target}),{createScanner(e){return new yp(e,t)},createString(e){return{content:e}}}}var Sp=[`javascript`,`js`,`typescript`,`ts`,`python`,`py`,`bash`,`sh`,`shell`,`json`],Cp=new Set(Sp),wp={javascript:`javascript`,js:`javascript`,typescript:`typescript`,ts:`typescript`,python:`python`,py:`python`,bash:`bash`,sh:`bash`,shell:`bash`,json:`json`};function Tp(e){let t=e.trim().toLowerCase();return Cp.has(t)?wp[t]??null:null}function Ep(e){return typeof e==`string`?e:e.name??`custom`}var Dp=null;function Op(){return Dp||=Jl({themes:[xa,ba],langs:[ga,ya,va,ha,_a],engine:xp({forgiving:!0})}),Dp}var kp=new Map,Ap=new Map;function jp(e,t,n){let r=e.slice(0,100),i=e.length>100?e.slice(-100):``;return`${t}:${n[0]}:${n[1]}:${e.length}:${r}:${i}`}var Mp={name:`shiki`,type:`code-highlighter`,getSupportedLanguages:()=>[...Sp],getThemes:()=>[`github-light`,`github-dark`],supportsLanguage:e=>Tp(String(e))!=null,highlight({code:e,language:t,themes:n},r){let i=Tp(String(t));if(!i)return null;let a=Ep(n[0]),o=Ep(n[1]),s=jp(e,i,[a,o]);return kp.get(s)||(r&&(Ap.has(s)||Ap.set(s,new Set),Ap.get(s).add(r)),Op().then(t=>{let n=t.codeToTokens(e,{lang:i,themes:{light:a,dark:o}});kp.set(s,n);let r=Ap.get(s);if(r){for(let e of r)e(n);Ap.delete(s)}}).catch(e=>{console.error(`[Streamdown Code] Failed to highlight code:`,e),Ap.delete(s)}),null)}};function Np(e){return gt(e).map((e,t)=>`${t}:${e.length}:${e.charCodeAt(0)??0}`).join(`|`)}var Pp={code:Mp},Fp={animation:`fadeIn`,duration:200,easing:`ease-out`,sep:`word`,stagger:0},Ip=(0,Z.memo)(function({content:e,isStreaming:t=!1}){let n=(0,Z.useMemo)(()=>t?Np(e):`static`,[e,t]);return(0,Q.jsx)(wt,{className:c(`text-[14px] leading-relaxed text-foreground`,`[&_p]:mb-2 [&_p:last-child]:mb-0`,`[&_pre]:my-3 [&_ul]:mb-2 [&_ol]:mb-2`),plugins:Pp,animated:Fp,isAnimating:t,parseIncompleteMarkdown:t,lineNumbers:!1,mode:t?`streaming`:`static`,children:e},n)});function Lp(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=new AbortController,{signal:n}=e,r=()=>{let e=`ontouchstart`in window||navigator.maxTouchPoints>0,n=window.matchMedia(`(pointer: coarse)`).matches;t(e&&n)};return window.matchMedia(`(pointer: coarse)`).addEventListener(`change`,r,{signal:n}),window.addEventListener(`pointerdown`,r,{signal:n}),r(),()=>e.abort()},[]),e}var Rp=null;async function zp(){return Rp||=Ve(()=>import(`./pdf-CuwKm9zO.js`).then(e=>(e.GlobalWorkerOptions.workerSrc||(e.GlobalWorkerOptions.workerSrc=`https://cdn.jsdelivr.net/npm/pdfjs-dist@${e.version}/build/pdf.worker.min.mjs`),e)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11])),Rp}async function Bp(e,t){let n=await zp(),r=await e.arrayBuffer(),i=await(await n.getDocument({data:r}).promise).getPage(1),a=i.getViewport({scale:1}),o=t*2/a.width,s=i.getViewport({scale:o}),c=document.createElement(`canvas`);return c.width=s.width,c.height=s.height,await i.render({canvas:c,viewport:s}).promise,c.toDataURL(`image/png`)}function Vp({file:e,size:t,className:n}){let r=s(),i=e.type.startsWith(`image/`),a=e.type===`application/pdf`,[o,l]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{if(!i){l(null);return}let t=URL.createObjectURL(e);return l(t),()=>URL.revokeObjectURL(t)},[i,e]);let[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{if(p(!1),!a){d(null);return}let n=!1;return Bp(e,t).then(e=>{n||d(e)}).catch(()=>{n||p(!0)}),()=>{n=!0}},[e,a,t]);let m=o??u,h=i&&!o||a&&!u&&!f;return(0,Q.jsx)(`div`,{className:c(`relative shrink-0 overflow-hidden bg-accent border border-border`,r.bg,n),style:{width:t,height:t},children:m?(0,Q.jsx)(`img`,{src:m,alt:e.name,className:`absolute inset-0 w-full h-full object-cover`}):h?(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,Q.jsx)(`div`,{className:`w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin`,"aria-label":`Loading preview`,role:`status`})}):(0,Q.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-muted-foreground`,role:`img`,"aria-label":e.name,children:(0,Q.jsxs)(`svg`,{width:Math.max(16,t*.35),height:Math.max(16,t*.35),viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z`}),(0,Q.jsx)(`path`,{d:`M14 3v5h5`})]})})})}var Hp=(0,Z.forwardRef)(({from:e,files:t,thumbnailSize:n=64,time:r,actions:i,children:a,className:o,...l},u)=>{let d=s(),f=e===`user`,p=Lp(),m=f&&r!=null;return(0,Q.jsxs)(S.div,{ref:u,layout:`position`,initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},transition:F.moderate,style:{transformOrigin:f?`bottom right`:`bottom left`},className:c(`group flex max-w-[80%] flex-col gap-1.5`,f?`items-end self-end`:`items-start self-start`,o),...l,children:[t&&t.length>0&&(0,Q.jsx)(`div`,{className:c(`flex flex-wrap gap-1.5`,f?`justify-end`:`justify-start`),children:t.map((e,t)=>(0,Q.jsx)(Vp,{file:e,size:n},`${e.name}-${e.size}-${e.lastModified}-${t}`))}),a!=null&&a!==``&&(0,Q.jsx)(`div`,{className:c(`py-2 text-[14px] whitespace-pre-wrap break-words`,f?c(d.bg,`px-3.5 text-pretty bg-[color-mix(in_oklab,var(--accent),var(--background)_45%)] text-accent-foreground`):`text-foreground`),children:a}),(m||i!=null)&&(0,Q.jsxs)(`div`,{className:c(`flex items-center gap-2 px-1 text-[12px] leading-none text-muted-foreground select-none`,!p&&[`opacity-0 pointer-events-none transition-opacity duration-150`,`group-hover:opacity-100 group-hover:pointer-events-auto`,`group-focus-within:opacity-100 group-focus-within:pointer-events-auto`]),children:[m&&(0,Q.jsx)(`span`,{className:`tabular-nums`,children:r}),i!=null&&(0,Q.jsx)(`span`,{className:`flex items-center gap-0.5`,children:i})]})]})});Hp.displayName=`ChatMessage`;function Up({text:e}){let[t,n]=(0,Z.useState)(!1);return(0,Q.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground flex items-center rounded p-0.5`,onClick:async()=>{await tt(e),n(!0),setTimeout(()=>n(!1),2e3)},title:`Copy message content`,"data-testid":`copy-button`,children:t?(0,Q.jsx)(X,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(ct,{className:`h-3.5 w-3.5`})})}function Wp(e,t){let n=e===1?`token`:`tokens`;return`${e.toLocaleString()} ${n} ${t}`}function Gp({variant:e,copyText:t,inputTokens:n,outputTokens:r}){let i=!!t,a=e===`user`&&n!=null?Wp(n,`in`):e===`assistant`&&r!=null?Wp(r,`out`):null;if(!i&&!a)return null;let o=i?(0,Q.jsx)(Up,{text:t}):null,s=a?(0,Q.jsx)(`span`,{className:`tabular-nums`,title:e===`user`?`Input tokens`:`Output tokens`,"data-testid":e===`user`?`message-input-tokens`:`message-output-tokens`,children:a}):null;return e===`user`?(0,Q.jsxs)(Q.Fragment,{children:[s,o]}):(0,Q.jsxs)(Q.Fragment,{children:[o,s]})}function Kp({content:e,timestamp:t,_isStreaming:n,outputTokens:r}){return!e||e.length===0?null:(0,Q.jsxs)(`div`,{"data-testid":`chat-message-assistant`,children:[(0,Q.jsx)(Hp,{from:`assistant`,actions:(0,Q.jsx)(Gp,{variant:`assistant`,copyText:e,outputTokens:r}),"data-testid":`chat-message-content`,children:(0,Q.jsx)(Ip,{content:e,isStreaming:n})}),t!=null&&(0,Q.jsx)(`span`,{className:`sr-only`,children:new Date(t).toLocaleTimeString()})]})}function qp({toolName:e,args:t,result:n,state:r=`result`,partialArgs:i}){let a=r===`call`&&i?i:t,o=()=>{switch(r){case`call`:return(0,Q.jsx)(st,{className:`h-4 w-4 animate-spin text-blue-500 dark:text-blue-400`});case`result`:return(0,Q.jsx)(X,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`});case`error`:return(0,Q.jsx)(Ce,{className:`h-4 w-4 text-red-500 dark:text-red-400`});default:return(0,Q.jsx)(X,{className:`h-4 w-4 text-emerald-800 dark:text-emerald-400`})}},s=()=>{switch(r){case`call`:return` bg-blue-500/20 dark:bg-blue-500/20`;case`result`:return` bg-emerald-500/20 dark:bg-emerald-500/20`;case`error`:return` bg-red-500/20 dark:bg-red-500/20`;default:return` bg-emerald-500/20 dark:bg-emerald-500/20`}},l=e=>typeof e==`object`?dt(e).preview:String(e);return(0,Q.jsxs)(Mt,{children:[(0,Q.jsx)(At,{render:(0,Q.jsxs)(`div`,{className:`flex max-w-min items-center gap-3 p-1 rounded-full border bg-card hover:bg-accent/50 transition-colors cursor-pointer my-4`,"data-testid":`chat-tool-call-${e}`,children:[(0,Q.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-zinc-100 dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 flex items-center justify-center shrink-0`,children:(0,Q.jsx)(we,{className:`size-4 text-muted-foreground`})}),(0,Q.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`text-sm font-medium truncate`,children:[e,`(`,Object.keys(a).length>0?(0,Q.jsxs)(`span`,{className:`bg-muted-foreground/20 rounded-full px-1.5 mx-1 py-0.5 text-xs`,children:[Object.keys(a).length,` args`]}):``,`)`]})})}),(0,Q.jsx)(`div`,{className:c(`w-8 h-8 rounded-full flex items-center justify-center`,s()),"data-testid":`chat-tool-call-status-${r}`,children:o()})]}),nativeButton:!1}),(0,Q.jsxs)(kt,{side:`right`,className:`w-[400px] sm:w-[540px] p-4 overflow-y-auto`,"data-testid":`chat-tool-drawer`,children:[(0,Q.jsxs)(Ot,{children:[(0,Q.jsxs)(Dt,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(we,{className:`h-5 w-5`}),`Tool Call Details`]}),(0,Q.jsxs)(jt,{className:`flex items-center gap-2`,children:[e,` — `,r,r===`call`&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 text-blue-500 dark:text-blue-400`,children:[(0,Q.jsx)(st,{className:`h-3 w-3 animate-spin`}),`streaming…`]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6 py-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Arguments`}),(0,Q.jsxs)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-args`,children:[(0,Q.jsx)(`pre`,{className:`text-xs bg-muted/50 rounded-lg p-3 overflow-x-auto border font-mono leading-relaxed max-h-48 whitespace-pre-wrap break-words`,children:l(a)}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(l(a)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy arguments`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]})]}),n&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium mb-2`,children:`Result`}),(0,Q.jsx)(`div`,{className:`relative`,"data-testid":`chat-tool-drawer-result`,children:typeof n==`string`?(0,Q.jsxs)(`div`,{className:c(`p-3 rounded-lg border text-sm leading-relaxed max-h-48 overflow-x-auto whitespace-pre-wrap break-words max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[n.startsWith(`Error`)?(0,Q.jsxs)(`div`,{className:`font-mono`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-destructive mb-1`,children:`Error:`}),(0,Q.jsx)(`div`,{className:`whitespace-pre-wrap break-words`,children:n.replace(/^Error:\s*/,``)})]}):(0,Q.jsx)(`div`,{className:`whitespace-pre-wrap font-mono break-words`,children:n}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(n),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]}):(0,Q.jsxs)(`div`,{className:c(`p-3 rounded-lg border text-sm leading-relaxed max-h-96 overflow-y-auto max-w-full`,r===`error`?`bg-destructive/10 border-destructive/20 text-destructive-foreground`:`bg-muted/30 border-border`),children:[(0,Q.jsx)($e,{data:n,filename:`tool-call-${e}-result-${Date.now()}.json`}),(0,Q.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>tt(JSON.stringify(n,null,2)),className:`absolute top-2 right-2 h-6 w-6 p-0 opacity-70 hover:opacity-100`,title:`Copy result`,children:(0,Q.jsx)(ct,{className:`h-3 w-3`})})]})})]})]})]})]})}function Jp({widgetId:e}){let{getWidget:t}=it(),n=t(e)?.modelContext;if(!n?.content?.length&&!n?.structuredContent)return null;let r=n.content?.map(e=>e.text).join(` `)??JSON.stringify(n.structuredContent).slice(0,80);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] text-muted-foreground bg-muted/30 border border-border/40 rounded-md mt-1`,children:[(0,Q.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-blue-400 shrink-0`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:`State synced to model`}),(0,Q.jsx)(`span`,{className:`truncate opacity-60 max-w-[300px]`,children:r})]})}function Yp({toolName:e,toolArgs:t,result:n,serverId:r,readResource:i,toolMeta:a,onSendFollowUp:o,partialToolArgs:s,cancelled:c}){let l=(0,Z.useMemo)(()=>`chat-tool-${e}-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,[e]),u=(0,Z.useMemo)(()=>{if(!n)return null;if(typeof n==`string`)try{return JSON.parse(n)}catch{return n}return n},[n]),d=rt(a),f=d?a?.ui?.resourceUri??null:null,p=(0,Z.useMemo)(()=>t,[e,u]),m=(0,Z.useMemo)(()=>u,[e,u]),h=nn({serverId:r??``,viewId:l,resourceUri:f??``,toolName:e,toolInput:p,toolOutput:m,toolMetadata:a,readResource:i??(async()=>({}))});return d&&f&&r&&i&&h?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ke,{viewId:l,toolName:e,toolInput:p,toolOutput:m,partialToolInput:s,cancelled:c,className:`my-4`,onMessage:e=>{e.length>0&&o&&o(e)},...h}),(0,Q.jsx)(Jp,{widgetId:l})]}):d&&!f?(0,Q.jsx)(`div`,{className:`flex items-center justify-center w-full h-[200px] rounded border`,children:(0,Q.jsx)(Ne,{className:`size-5`})}):d&&(!r||!i)?(0,Q.jsx)(`div`,{className:`my-4 p-4 bg-red-50/30 dark:bg-red-950/20 border border-red-200/50 dark:border-red-800/50 rounded-lg`,children:(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:`Cannot render widget: Missing required props (serverId or readResource)`})}):null}function Xp(e){let t=atob(e.data),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return new File([n],e.name||`attachment`,{type:e.mimeType})}function Zp({content:e,timestamp:t,attachments:n,inputTokens:r}){let i=(0,Z.useMemo)(()=>n?.map(Xp),[n]);return(!e||e.length===0)&&(!n||n.length===0)?null:(0,Q.jsx)(`div`,{"data-testid":`chat-message-user`,className:`flex flex-col items-end`,children:(0,Q.jsx)(Hp,{from:`user`,files:i,time:t?new Date(t).toLocaleTimeString():void 0,actions:e||r!=null?(0,Q.jsx)(Gp,{variant:`user`,copyText:e||void 0,inputTokens:r}):void 0,"data-testid":`chat-message-content`,children:e&&e.length>0?e:void 0})})}var Qp={events:[],spans:[]};function $p(e){if(!e||typeof e!=`object`)return;let t=e,n=(...e)=>{for(let n of e)if(typeof t[n]==`number`)return t[n]},r=n(`inputTokens`,`input_tokens`,`promptTokens`),i=n(`outputTokens`,`output_tokens`,`completionTokens`),a=n(`totalTokens`,`total_tokens`)??(r!==void 0&&i!==void 0?r+i:void 0);if(!(r===void 0&&i===void 0&&a===void 0))return{inputTokens:r,outputTokens:i,totalTokens:a}}var em=new Set([`apikey`,`authorization`,`accesstoken`,`refreshtoken`,`password`,`cookie`,`secret`]);function tm(e){return Array.isArray(e)?e.map(tm):!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,em.has(e.toLowerCase().replace(/[_-]/g,``))?`[REDACTED]`:tm(t)]))}function nm(e,t=120){let n;try{n=JSON.stringify(e)}catch{n=String(e)}return n.length>t?`${n.slice(0,t)}…`:n}function rm(e){switch(e.type){case`request`:return`LLM request`;case`text-delta`:return e.delta.trim()||`Text delta`;case`tool-call-start`:return e.toolName;case`tool-call-args`:return nm(e.args);case`tool-result`:return nm(e.result);case`usage`:return`${e.usage.totalTokens??`?`} tokens`;case`error`:return e.message;case`done`:return`Completed`;default:return e}}function im(e,t){let n=(e,t)=>e===void 0&&t===void 0?void 0:(e??0)+(t??0);return{inputTokens:n(e?.inputTokens,t.inputTokens),outputTokens:n(e?.outputTokens,t.outputTokens),totalTokens:n(e?.totalTokens,t.totalTokens),cachedInputTokens:n(e?.cachedInputTokens,t.cachedInputTokens),reasoningTokens:n(e?.reasoningTokens,t.reasoningTokens)}}function am(e,t){let n=e.spans.map(e=>({...e})),r=e.usage,i=[...n].reverse().find(e=>e.kind===`llm`&&e.status===`running`);if(t.type===`request`)n.push({id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if((t.type===`text-delta`||t.type===`tool-call-start`)&&!i)i={id:`llm-${t.id}`,kind:`llm`,name:`LLM`,status:`running`,startedAt:t.timestamp,preview:t.type===`text-delta`?rm(t):`LLM response`},n.push(i),t.type===`tool-call-start`&&n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if(t.type===`tool-call-start`)n.push({id:t.toolCallId,kind:`tool`,name:t.toolName,status:`running`,startedAt:t.timestamp,preview:rm(t)});else if(t.type===`tool-call-args`){let e=n.find(e=>e.id===t.toolCallId);e&&(e.preview=rm(t))}else if(t.type===`tool-result`){let e=t.toolCallId?n.find(e=>e.id===t.toolCallId):[...n].reverse().find(e=>e.kind===`tool`&&e.name===t.toolName&&e.status===`running`);e&&(e.status=t.isError?`error`:`success`,e.endedAt=t.timestamp,e.preview=rm(t))}else t.type===`usage`?(r=im(r,t.usage),i&&(i.usage=im(i.usage,t.usage))):(t.type===`error`||t.type===`done`)&&i&&(i.status=t.type===`error`?`error`:`success`,i.endedAt=t.timestamp,i.preview=rm(t));return{events:[...e.events,t],spans:n,usage:r}}function om(e,t){let n=[],r=null;for(let t of e)t.type===`request`?(r&&n.push(r),r={request:t,response:[]}):r&&r.response.push(t);return r&&n.push(r),{turns:n,tokenUsage:t??null}}function sm(e){let t;for(let n of e)n.type===`usage`&&(t=im(t,n.usage));return t}function cm(e){let t=[],n=0;for(;n<e.length;){if(e[n]?.role!==`user`){n++;continue}let r=e[n].id;n++;let i=null;for(;n<e.length&&e[n]?.role===`assistant`;)i=e[n].id,n++;t.push({userId:r,assistantId:i})}return t}function lm(e,t){let{turns:n}=om(t),r=cm(e),i=new Map,a=Math.min(n.length,r.length);for(let e=0;e<a;e++){let t=sm(n[e].response);if(!t)continue;let{userId:a,assistantId:o}=r[e];t.inputTokens!=null&&i.set(a,{...i.get(a),inputTokens:t.inputTokens}),o!=null&&t.outputTokens!=null&&i.set(o,{...i.get(o),outputTokens:t.outputTokens})}return i}var um=(0,Z.memo)(({messages:e,isLoading:t,serverId:n,readResource:r,tools:i,sendMessage:a,messagesEndRef:o,traceEvents:s=[]})=>{let c=(0,Z.useMemo)(()=>lm(e,s),[e,s]),l=e=>{let t=e=>e.replace(/-/g,`_`),n=t(e);return i?.find(e=>t(e.name)===n)?._meta},u=e=>rt(l(e)),d=(0,Z.useCallback)(e=>{let t=e.filter(e=>e.type===`text`&&`text`in e).map(e=>e.text).join(`
445
445
  `),n=e.filter(e=>e.type===`image`&&`data`in e&&`mimeType`in e).map(e=>({type:`image`,data:e.data,mimeType:e.mimeType}));a?.(t,n.length>0?n:void 0)},[a]),f=t&&(()=>{if(e.length===0)return!0;let t=e[e.length-1];if(t.role===`user`)return!0;if(t.role===`assistant`){if(t.parts&&t.parts.length>0)return!1;let e=typeof t.content==`string`?t.content:Array.isArray(t.content)?t.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(t.content);return!(e&&e.trim().length>0)}return!1})(),p=e[e.length-1],m=t&&p?.role===`assistant`,h=e=>{for(let t=e.length-1;t>=0;t--)if(e[t]?.type===`text`)return t;return-1},g=(e,t,n)=>m&&e.id===p?.id&&t===h(n),_=e=>m&&e.id===p?.id;return(0,Q.jsxs)(`div`,{className:`space-y-6 max-w-3xl mx-auto px-2`,children:[e.map(e=>{let t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e.text||JSON.stringify(e)).join(``):JSON.stringify(e.content);if(e.role===`user`)return(0,Q.jsx)(Zp,{content:t,timestamp:e.timestamp,attachments:e.attachments,inputTokens:c.get(e.id)?.inputTokens},e.id);if(e.role===`assistant`){let i=c.get(e.id)?.outputTokens,a=e.parts&&e.parts.length>0?h(e.parts):-1;return(0,Q.jsx)(`div`,{className:`space-y-4`,children:e.parts&&e.parts.length>0?e.parts.map((t,o)=>{let s=t.type===`text`?`${e.id}-text-${o}`:`${e.id}-tool-${t.toolInvocation?.toolName}-${o}`;return t.type===`text`?(0,Q.jsx)(Kp,{content:t.text||``,timestamp:o===e.parts.length-1?e.timestamp:void 0,_isStreaming:g(e,o,e.parts),outputTokens:o===a?i:void 0},s):t.type===`tool-invocation`&&t.toolInvocation?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(qp,{toolName:t.toolInvocation.toolName,args:t.toolInvocation.args,result:t.toolInvocation.result,state:t.toolInvocation.state===`error`?`error`:t.toolInvocation.state===`streaming`||t.toolInvocation.state===`pending`?`call`:`result`,partialArgs:t.toolInvocation.partialArgs}),(t.toolInvocation.result||t.toolInvocation.state===`streaming`||u(t.toolInvocation.toolName))&&(0,Q.jsx)(`div`,{"data-tool-call-id":`${e.id}-${t.toolInvocation.toolName}-${o}`,children:(0,Q.jsx)(Yp,{toolName:t.toolInvocation.toolName,toolArgs:t.toolInvocation.args,result:t.toolInvocation.result||null,serverId:n,readResource:r,toolMeta:l(t.toolInvocation.toolName),onSendFollowUp:d,partialToolArgs:t.toolInvocation.partialArgs,cancelled:t.toolInvocation.state===`error`&&t.toolInvocation.result===`Cancelled by user`})})]},s):null}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Kp,{content:t,timestamp:e.timestamp,_isStreaming:_(e),outputTokens:i}),e.toolCalls&&e.toolCalls.length>0&&(0,Q.jsx)(`div`,{className:`space-y-2`,children:e.toolCalls.map(t=>{let i=`${e.id}-${t.toolName}-${JSON.stringify(t.args).slice(0,50)}`;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(qp,{toolName:t.toolName,args:t.args,result:t.result,state:t.result?`result`:`call`}),(t.result||u(t.toolName))&&(0,Q.jsx)(`div`,{"data-tool-call-id":i,children:(0,Q.jsx)(Yp,{toolName:t.toolName,toolArgs:t.args,result:t.result||null,serverId:n,readResource:r,toolMeta:l(t.toolName),onSendFollowUp:d})})]},i)})})]})},e.id)}return null}),f&&(0,Q.jsx)(`div`,{className:`flex items-start gap-3`,children:(0,Q.jsx)(`div`,{className:`flex-1`,children:(0,Q.jsx)(`div`,{className:`rounded-lg p-4 max-w-fit`,children:(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`span`,{className:`text-sm`,children:(0,Q.jsx)(ma,{duration:2,spread:1,children:`Thinking...`})})})})})}),(0,Q.jsx)(`div`,{ref:o})]})});function dm({visible:e,onClick:t}){return(0,Q.jsx)(`div`,{className:`pointer-events-none absolute bottom-2 left-0 right-0 z-30 flex justify-center`,children:(0,Q.jsx)(ie,{children:e&&(0,Q.jsx)(S.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.18,ease:`easeOut`},children:(0,Q.jsx)(I,{type:`button`,variant:`secondary`,className:`pointer-events-auto size-9 rounded-full border bg-background/95 p-0 shadow-lg backdrop-blur supports-[backdrop-filter]:bg-background/80`,onClick:t,"aria-label":`Scroll to bottom`,title:`Scroll to bottom`,"data-testid":`chat-scroll-to-bottom`,children:(0,Q.jsx)(rn,{className:`size-4`})})})})})}function fm(e,{messageCount:t,isLoading:n,enabled:r=!0}){let i=(0,Z.useRef)(null),[a,o]=(0,Z.useState)(!0),s=(0,Z.useRef)(!0),c=(0,Z.useRef)({length:0,loading:!1}),l=t>0,u=r&&l&&!a,d=(0,Z.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.scrollHeight-(t.scrollTop+t.clientHeight)<=64;s.current=n,o(n)},[e]),f=(0,Z.useCallback)(t=>{let n=e.current;n&&(n.scrollTo({top:n.scrollHeight,behavior:t}),s.current=!0,o(!0))},[e]);return(0,Z.useEffect)(()=>{if(!r)return;let t=e.current;if(!t)return;d();let n=()=>d();t.addEventListener(`scroll`,n,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>d()):null;return i?.observe(t),()=>{t.removeEventListener(`scroll`,n),i?.disconnect()}},[r,d,t,e]),(0,Z.useEffect)(()=>{if(!r||!l||!s.current)return;let e=c.current,i=t!==e.length,a=n!==e.loading;c.current={length:t,loading:n},!(!i&&!a)&&f(n?`auto`:`smooth`)},[r,l,n,t,f]),{messagesEndRef:i,showScrollToBottom:u,scrollToBottom:f}}function pm(e){return Lt(e)}var mm=e=>{let t=[];for(let n of e){if(n.error||n.result?.isError){let e={id:`prompt-error-${n.promptName}-${n.timestamp}`,role:`assistant`,content:n.error||`Prompt execution failed`,timestamp:n.timestamp};t.push(e);continue}let e=n.result;if(e&&`messages`in e&&Array.isArray(e.messages))for(let r of e.messages){let e=``,i=[];if(typeof r.content==`string`)e=r.content;else if(Array.isArray(r.content)){let t=[];for(let e of r.content)e.type===`text`&&e.text?t.push(e.text):e.type===`image`&&e.data?i.push({type:`image`,data:e.data,mimeType:e.mimeType||`image/png`}):e.type===`resource`&&t.push(`[Resource: ${e.resource?.uri||`embedded`}]`);e=t.join(`
446
446
  `)}else r.content&&typeof r.content==`object`&&(r.content.type===`text`&&r.content.text?e=r.content.text:r.content.type===`image`&&r.content.data?i.push({type:`image`,data:r.content.data,mimeType:r.content.mimeType||`image/png`}):e=JSON.stringify(r.content));!e&&i.length===0&&(e=`[no content]`);let a={id:`prompt-${n.promptName}-${n.timestamp}-${t.length}`,role:r.role,content:e||``,timestamp:n.timestamp,attachments:i.length>0?i:void 0};t.push(a)}}return t};function hm({mcpServerUrl:e,llmConfig:t,authConfig:n,isConnected:r,chatApiUrl:i,waitForChatApiUrl:a,widgetModelContexts:o,initialMessages:s,disabledTools:c,streamProtocol:l=`sse`,credentials:u,extraHeaders:d,body:f}){let[p,m]=(0,Z.useState)(s??[]),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(Qp),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=(0,Z.useRef)(null),E=(0,Z.useRef)(0),D=(0,Z.useCallback)(e=>{let t={...e,id:`trace-${++E.current}`,timestamp:Date.now()};b(e=>am(e,t))},[]),O=(0,Z.useCallback)(async(s,h,y)=>{let b=[..._,...y??[]];if(!(s.trim()||h.length>0||b.length>0)||!t||!r)return;let x=[...mm(h)];if(s.trim()||b.length>0){let e={id:`user-${Date.now()}`,role:`user`,content:s.trim(),timestamp:Date.now(),attachments:b.length>0?b:void 0};x.push(e)}m(e=>[...e,...x]),g(!0),v([]),T.current=new AbortController;try{let r=n;if(n?.type===`oauth`)try{let t=`mcp:auth_${Gt(e)}_tokens`,i=localStorage.getItem(t);if(i){let e=JSON.parse(i);r={...n,oauthTokens:e}}else console.warn(`No OAuth tokens found in localStorage for key:`,t)}catch(e){console.warn(`Failed to retrieve OAuth tokens:`,e)}let s=[];if(o&&o.size>0){let e=[];for(let[,t]of o)t&&(t.content?.length?e.push(t.content.map(e=>e.text).join(`
447
447
  `)):t.structuredContent&&e.push(JSON.stringify(t.structuredContent)));e.length>0&&s.push({id:`widget-context-${Date.now()}`,role:`user`,content:`[Current Widget State]\n${e.join(`
@@ -1 +1 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{d as r,l as i,sr as a,u as o}from"./input-CjmxOFr6.js";import{Bt as s,D as c,Q as l,it as u,nt as d,rt as f,tt as p}from"./index-Bbn-6QR2.js";import{t as m}from"./inspector-settings-layout-yjKRJDai.js";import{n as h}from"./ListTabHeader-G-nQX18m.js";var g=e(t(),1);function _(e,t){let[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`auto`),[c,m]=(0,g.useState)([]),[h,_]=(0,g.useState)(`10000`),[v,y]=(0,g.useState)(`True`),[b,x]=(0,g.useState)(`60000`),[S,C]=(0,g.useState)(d()),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(``);return(0,g.useEffect)(()=>{if(!e||!t)return;let n=u(e,f(e.id));a(n.url),r(n.name||n.url);let i=n.proxyConfig?.proxyAddress||(typeof n.autoProxyFallback==`object`?n.autoProxyFallback.proxyAddress:void 0);s(n.connectionMode||`auto`),C(i||d());let o=n.headers||{};m(Object.entries(o).map(([e,t],n)=>({id:`header-${n}`,name:e,value:String(t)}))),T(n.oauth?.clientId||``),D(n.oauth?.clientSecret||``),k(n.oauth?.scope||``),n.requestTimeout!==void 0&&_(String(n.requestTimeout)),n.resetTimeoutOnProgress!==void 0&&y(n.resetTimeoutOnProgress?`True`:`False`),n.maxTotalTimeout!==void 0&&x(String(n.maxTotalTimeout))},[e,t]),{alias:n,setAlias:r,url:i,setUrl:a,connectionMode:o,setConnectionMode:s,customHeaders:c,setCustomHeaders:m,requestTimeout:h,setRequestTimeout:_,resetTimeoutOnProgress:v,setResetTimeoutOnProgress:y,maxTotalTimeout:b,setMaxTotalTimeout:x,proxyAddress:S,setProxyAddress:C,clientId:w,setClientId:T,clientSecret:E,setClientSecret:D,scope:O,setScope:k,buildConfig:()=>{if(!i.trim())return null;let e=i.trim();try{let t=new URL(e);if(!(t.protocol===`http:`||t.protocol===`https:`))return l.error(`Invalid URL protocol. Please use http:// or https://`),null}catch{try{let t=`https://${e}`,n=new URL(t);if(!(n.protocol===`http:`||n.protocol===`https:`))return l.error(`Invalid URL protocol. Please use http:// or https://`),null;e=t}catch{return l.error(`Invalid URL format. Please enter a valid URL.`),null}}let t=c.reduce((e,t)=>(t.name&&t.value&&(e[t.name]=t.value),e),{}),r=o===`proxy`&&S.trim()?{proxyAddress:S.trim(),headers:t}:void 0,a=o===`auto`&&S.trim()?{enabled:!0,proxyAddress:S.trim()}:!1,s=p(w,E,O),u=Number.parseInt(h,10),d=Number.parseInt(b,10);return{url:e,name:n.trim()||e,transportType:`http`,connectionMode:o,proxyConfig:r,headers:Object.keys(t).length>0?t:void 0,autoProxyFallback:a,...s?{oauth:s}:{},...Number.isFinite(u)?{requestTimeout:u}:{},resetTimeoutOnProgress:v===`True`,...Number.isFinite(d)?{maxTotalTimeout:d}:{}}}}}var v=n();function y({connection:e,onSave:t}){let n=_(e,!0),[l,u]=(0,g.useState)(!1);return(0,v.jsxs)(`div`,{className:`h-full overflow-y-auto overscroll-none`,onScroll:e=>u(e.currentTarget.scrollTop>0),children:[(0,v.jsxs)(`div`,{className:`${i(l)} flex flex-row items-center justify-between gap-2 ${o}`,children:[(0,v.jsxs)(`h2`,{className:`${r} flex items-center gap-1.5`,children:[(0,v.jsx)(s,{className:h,"aria-hidden":!0}),`Connection Settings`]}),(0,v.jsx)(a,{"data-testid":`connection-form-save-button`,size:`sm`,onClick:()=>{let e=n.buildConfig();e&&t(e)},children:`Save`})]}),(0,v.jsx)(`div`,{className:m,children:(0,v.jsx)(c,{alias:n.alias,setAlias:n.setAlias,url:n.url,setUrl:n.setUrl,connectionMode:n.connectionMode,setConnectionMode:n.setConnectionMode,customHeaders:n.customHeaders,setCustomHeaders:n.setCustomHeaders,requestTimeout:n.requestTimeout,setRequestTimeout:n.setRequestTimeout,resetTimeoutOnProgress:n.resetTimeoutOnProgress,setResetTimeoutOnProgress:n.setResetTimeoutOnProgress,maxTotalTimeout:n.maxTotalTimeout,setMaxTotalTimeout:n.setMaxTotalTimeout,proxyAddress:n.proxyAddress,setProxyAddress:n.setProxyAddress,clientId:n.clientId,setClientId:n.setClientId,clientSecret:n.clientSecret,setClientSecret:n.setClientSecret,scope:n.scope,setScope:n.setScope,showConnectButton:!1,showExportButton:!1,inlineSections:!0,cardSections:!0})})]})}export{y as ConnectionSettingsTab};
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{d as r,l as i,sr as a,u as o}from"./input-CjmxOFr6.js";import{Bt as s,D as c,Q as l,it as u,nt as d,rt as f,tt as p}from"./index-D2UxaT9v.js";import{t as m}from"./inspector-settings-layout-yjKRJDai.js";import{n as h}from"./ListTabHeader-G-nQX18m.js";var g=e(t(),1);function _(e,t){let[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(`auto`),[c,m]=(0,g.useState)([]),[h,_]=(0,g.useState)(`10000`),[v,y]=(0,g.useState)(`True`),[b,x]=(0,g.useState)(`60000`),[S,C]=(0,g.useState)(d()),[w,T]=(0,g.useState)(``),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)(``);return(0,g.useEffect)(()=>{if(!e||!t)return;let n=u(e,f(e.id));a(n.url),r(n.name||n.url);let i=n.proxyConfig?.proxyAddress||(typeof n.autoProxyFallback==`object`?n.autoProxyFallback.proxyAddress:void 0);s(n.connectionMode||`auto`),C(i||d());let o=n.headers||{};m(Object.entries(o).map(([e,t],n)=>({id:`header-${n}`,name:e,value:String(t)}))),T(n.oauth?.clientId||``),D(n.oauth?.clientSecret||``),k(n.oauth?.scope||``),n.requestTimeout!==void 0&&_(String(n.requestTimeout)),n.resetTimeoutOnProgress!==void 0&&y(n.resetTimeoutOnProgress?`True`:`False`),n.maxTotalTimeout!==void 0&&x(String(n.maxTotalTimeout))},[e,t]),{alias:n,setAlias:r,url:i,setUrl:a,connectionMode:o,setConnectionMode:s,customHeaders:c,setCustomHeaders:m,requestTimeout:h,setRequestTimeout:_,resetTimeoutOnProgress:v,setResetTimeoutOnProgress:y,maxTotalTimeout:b,setMaxTotalTimeout:x,proxyAddress:S,setProxyAddress:C,clientId:w,setClientId:T,clientSecret:E,setClientSecret:D,scope:O,setScope:k,buildConfig:()=>{if(!i.trim())return null;let e=i.trim();try{let t=new URL(e);if(!(t.protocol===`http:`||t.protocol===`https:`))return l.error(`Invalid URL protocol. Please use http:// or https://`),null}catch{try{let t=`https://${e}`,n=new URL(t);if(!(n.protocol===`http:`||n.protocol===`https:`))return l.error(`Invalid URL protocol. Please use http:// or https://`),null;e=t}catch{return l.error(`Invalid URL format. Please enter a valid URL.`),null}}let t=c.reduce((e,t)=>(t.name&&t.value&&(e[t.name]=t.value),e),{}),r=o===`proxy`&&S.trim()?{proxyAddress:S.trim(),headers:t}:void 0,a=o===`auto`&&S.trim()?{enabled:!0,proxyAddress:S.trim()}:!1,s=p(w,E,O),u=Number.parseInt(h,10),d=Number.parseInt(b,10);return{url:e,name:n.trim()||e,transportType:`http`,connectionMode:o,proxyConfig:r,headers:Object.keys(t).length>0?t:void 0,autoProxyFallback:a,...s?{oauth:s}:{},...Number.isFinite(u)?{requestTimeout:u}:{},resetTimeoutOnProgress:v===`True`,...Number.isFinite(d)?{maxTotalTimeout:d}:{}}}}}var v=n();function y({connection:e,onSave:t}){let n=_(e,!0),[l,u]=(0,g.useState)(!1);return(0,v.jsxs)(`div`,{className:`h-full overflow-y-auto overscroll-none`,onScroll:e=>u(e.currentTarget.scrollTop>0),children:[(0,v.jsxs)(`div`,{className:`${i(l)} flex flex-row items-center justify-between gap-2 ${o}`,children:[(0,v.jsxs)(`h2`,{className:`${r} flex items-center gap-1.5`,children:[(0,v.jsx)(s,{className:h,"aria-hidden":!0}),`Connection Settings`]}),(0,v.jsx)(a,{"data-testid":`connection-form-save-button`,size:`sm`,onClick:()=>{let e=n.buildConfig();e&&t(e)},children:`Save`})]}),(0,v.jsx)(`div`,{className:m,children:(0,v.jsx)(c,{alias:n.alias,setAlias:n.setAlias,url:n.url,setUrl:n.setUrl,connectionMode:n.connectionMode,setConnectionMode:n.setConnectionMode,customHeaders:n.customHeaders,setCustomHeaders:n.setCustomHeaders,requestTimeout:n.requestTimeout,setRequestTimeout:n.setRequestTimeout,resetTimeoutOnProgress:n.resetTimeoutOnProgress,setResetTimeoutOnProgress:n.setResetTimeoutOnProgress,maxTotalTimeout:n.maxTotalTimeout,setMaxTotalTimeout:n.setMaxTotalTimeout,proxyAddress:n.proxyAddress,setProxyAddress:n.setProxyAddress,clientId:n.clientId,setClientId:n.setClientId,clientSecret:n.clientSecret,setClientSecret:n.setClientSecret,scope:n.scope,setScope:n.setScope,showConnectButton:!1,showExportButton:!1,inlineSections:!0,cardSections:!0})})]})}export{y as ConnectionSettingsTab};
@@ -1 +1 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Nr as r,a as i,n as a,r as o,sr as s,t as c}from"./input-CjmxOFr6.js";import{t as l}from"./label-B5Q_Zr8M.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./shared-Dfwy7nyg.js";import{t as g}from"./maximize-2-BTT9QQU9.js";import{Ft as _,Q as v,bt as y,kt as b,l as x,lt as S,nn as C,on as w,rn as T,tn as E,ut as D,w as O,zt as k}from"./index-Bbn-6QR2.js";import{t as A}from"./textarea-Ci09-en6.js";import{t as j}from"./checkbox-_GzEPQic.js";import{n as M,t as N}from"./schemaHelpers-DLNTQr_6.js";var P=e(t(),1),F=n();function I({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:i,formatRelativeTime:a}){return e.length===0?(0,F.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,F.jsx)(b,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,F.jsx)(`div`,{children:e.map((e,o)=>{let s=e.request.mode||`form`,c=s===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,F.jsx)(m,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${o}`,isSelected:t?.id===e.id,isFocused:i===o,title:(0,F.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,F.jsx)(r,{variant:`outline`,className:s===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:s})]}),description:(()=>{let t=a(e.timestamp),n=[];return c&&n.push(`with schema`),s===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function L({request:e,formData:t,onFieldChange:n,idPrefix:r,testIdPrefix:i,fieldContainerClassName:a=`space-y-2`,textareaRows:o=4,showOuterLabelForBoolean:s=!0,emptyFallback:u}){return(0,F.jsx)(F.Fragment,{children:(0,P.useMemo)(()=>{if(!(`requestedSchema`in e.request))return null;let d=e.request.requestedSchema;if(!d||d.type!==`object`||!d.properties)return u??(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema available`});let f=d.properties,p=d.required||[];return(0,F.jsx)(`div`,{className:`space-y-4`,children:Object.entries(f).map(([e,u])=>{let d=u,f=p.includes(e),m=d.type||`string`,h=d.title||e,g=d.description,_=M(d),v=_.length>0,y=Array.isArray(d.enum),b=m===`array`&&Array.isArray(d.items?.enum),x=N(d),S=m===`array`&&x.length>0,C=Array.isArray(t[e])?t[e]:[],w=`${r}-${e}`,T=`${i}-${e}`;return(0,F.jsxs)(`div`,{className:a,children:[(m!==`boolean`||s)&&(0,F.jsxs)(l,{htmlFor:w,children:[h,f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),g&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g}),m===`boolean`?(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:w,"data-testid":T,checked:t[e]||!1,onCheckedChange:t=>n(e,t)}),(0,F.jsxs)(l,{htmlFor:w,className:`text-sm font-normal cursor-pointer`,children:[h,!s&&f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]})]}):m===`number`||m===`integer`?(0,F.jsx)(c,{id:w,"data-testid":T,type:`number`,value:t[e]??``,onChange:t=>{let r=m===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value);n(e,isNaN(r)?``:r)},placeholder:d.default?.toString()||``}):v?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),_.map(e=>(0,F.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):y?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),d.enum.map((e,t)=>(0,F.jsx)(`option`,{value:e,children:d.enumNames?.[t]||e},e))]}):b?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:d.items.enum.map(t=>{let r=`${w}-${t}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t),onCheckedChange:r=>{n(e,r?[...C,t]:C.filter(e=>e!==t))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):S?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:x.map(t=>{let r=`${w}-${t.const}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t.const),onCheckedChange:r=>{n(e,r?[...C,t.const]:C.filter(e=>e!==t.const))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):m===`string`&&(d.format===`textarea`||d.maxLength>100)?(0,F.jsx)(A,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``,rows:o}):(0,F.jsx)(c,{id:w,"data-testid":T,type:`text`,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``})]},e)})})},[e,t,n,r,i,a,o,s,u])})}function R(e){let[t,n]=(0,P.useState)({}),[r,i]=(0,P.useState)(!1),a=e?.request.mode||`form`,o=a===`form`,s=a===`url`;return(0,P.useEffect)(()=>{if(e&&o&&`requestedSchema`in e.request){let t=e.request.requestedSchema,r={};if(t?.type===`object`&&t.properties)for(let[e,n]of Object.entries(t.properties)){let t=n;t.default===void 0?t.type===`array`?r[e]=[]:t.type===`boolean`?r[e]=!1:t.type===`number`||t.type===`integer`?r[e]=0:r[e]=``:r[e]=t.default}n(r)}i(!1)},[e?.id,o]),{formData:t,setFieldValue:(0,P.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),getMissingRequiredFields:(0,P.useCallback)(()=>!e||!o||!(`requestedSchema`in e.request)?[]:(e.request.requestedSchema?.required??[]).filter(e=>t[e]===void 0||t[e]===``||t[e]===null),[e,t,o]),urlCompleted:r,setUrlCompleted:i,mode:a,isFormMode:o,isUrlMode:s}}function z({request:t,onApprove:n,onReject:c,onClose:u,previewMode:d,onTogglePreview:f,isCopied:p,onCopy:m,onDownload:h,onFullscreen:b}){let{formData:S,setFieldValue:D,getMissingRequiredFields:O,urlCompleted:k,setUrlCompleted:A,mode:M,isFormMode:N,isUrlMode:P}=R(t);return t?(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:t.serverName}),(0,F.jsx)(r,{variant:`outline`,className:P?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:M}),(0,F.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(t.timestamp).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:m,className:`h-8 w-8 p-0`,children:p?(0,F.jsx)(w,{className:`h-4 w-4 text-green-600`}):(0,F.jsx)(T,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Copy request`})]}),(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:h,className:`h-8 w-8 p-0`,children:(0,F.jsx)(C,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Download request`})]}),(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:b,className:`h-8 w-8 p-0`,children:(0,F.jsx)(g,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Fullscreen`})]}),(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,F.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,F.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:t.request.message})]}),P&&`url`in t.request&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,F.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,F.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:t.request.url}),(0,F.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>{t&&P&&`url`in t.request&&(window.open(t.request.url,`_blank`),A(!0))},className:`flex items-center gap-2`,children:[(0,F.jsx)(E,{className:`h-4 w-4`}),`Open URL`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,F.jsx)(j,{id:`url-completed`,checked:k,onCheckedChange:e=>A(!!e)}),(0,F.jsx)(l,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),N&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),(0,F.jsx)(L,{request:t,formData:S,onFieldChange:D,idPrefix:`field`,testIdPrefix:`elicitation-field`,emptyFallback:(0,F.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`})})]}),N&&`requestedSchema`in t.request&&t.request.requestedSchema&&(0,F.jsxs)(`details`,{className:`space-y-2`,children:[(0,F.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,F.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,F.jsx)(x,{data:t.request.requestedSchema})})]})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,F.jsx)(s,{onClick:()=>{if(t){if(N){let e=O();if(e.length>0){v.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}n(t.id,{action:`accept`,content:S})}else P&&n(t.id,{action:`accept`});u(),y(()=>import(`./react-CU_d2d5K.js`).then(t=>e(t.t(),1)).then(e=>{let t=v(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),v.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},className:`flex-1`,disabled:P&&!k,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,F.jsx)(s,{onClick:()=>{t&&(n(t.id,{action:`decline`}),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,F.jsx)(s,{onClick:()=>{t&&(c(t.id,`User cancelled elicitation request`),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,F.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function B({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=O(),[s,c]=(0,P.useState)(null),[l,m]=(0,P.useState)(``),[g,v]=(0,P.useState)(-1),[y,b]=(0,P.useState)(!0),[x,C]=(0,P.useState)(!1),[w,T]=(0,P.useState)(!0),[E,A]=(0,P.useState)(!1),j=(0,P.useRef)(null),M=(0,P.useRef)(null),N=(0,P.useRef)(null),L=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,P.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,P.useEffect)(()=>{y&&e.length>0&&j.current&&!L.current&&(j.current.scrollTop=0)},[e.length,y]),(0,P.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{e.scrollTop>0&&(L.current=!0,b(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,P.useEffect)(()=>{e.length===0&&(L.current=!1,b(!0))},[e.length]),(0,P.useEffect)(()=>{x&&N.current&&N.current.focus()},[x]);let R=(0,P.useCallback)(()=>{l.trim()||C(!1)},[l]),B=(0,P.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,P.useEffect)(()=>{v(-1)},[l]),(0,P.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=B;if(e.key===`ArrowDown`)e.preventDefault(),v(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),v(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&g>=0){e.preventDefault();let t=B[g];t&&V(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g,B]),(0,P.useEffect)(()=>{if(g>=0){let e=`elicitation-request-${B[g]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[g,B]);let V=(0,P.useCallback)(e=>{c(e)},[]),H=(0,P.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),U=(0,P.useCallback)(async()=>{if(s)try{await S(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),W=(0,P.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),G=(0,P.useCallback)(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,F.jsxs)(p,{orientation:`horizontal`,className:`h-full`,children:[(0,F.jsx)(u,{defaultSize:40,minSize:30,children:(0,F.jsx)(p,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,F.jsx)(u,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,F.jsx)(f,{scrollRef:j,children:t=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{isScrolled:t,title:`Elicitation`,icon:k,titleTestId:`elicitation-tab-header`,count:B.length,isSearchExpanded:x,searchQuery:l,searchPlaceholder:`Search requests...`,onSearchExpand:()=>C(!0),onSearchChange:m,onSearchBlur:R,bulkAction:{icon:_,label:`Cancel all`,onClick:H,disabled:e.length===0},searchInputRef:N}),(0,F.jsx)(I,{requests:B,selectedRequest:s,onRequestSelect:V,focusedIndex:g,formatRelativeTime:D})]})})})})}),(0,F.jsx)(d,{}),(0,F.jsx)(u,{defaultSize:60,minSize:40,children:(0,F.jsx)(`div`,{ref:M,className:`h-full bg-white dark:bg-zinc-900`,children:(0,F.jsx)(z,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:w,onTogglePreview:()=>T(!w),isCopied:E,onCopy:U,onDownload:W,onFullscreen:G})})})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,F.jsx)(k,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{B as ElicitationTab};
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Nr as r,a as i,n as a,r as o,sr as s,t as c}from"./input-CjmxOFr6.js";import{t as l}from"./label-B5Q_Zr8M.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./shared-DQE60Op-.js";import{t as g}from"./maximize-2-BTT9QQU9.js";import{Ft as _,Q as v,bt as y,kt as b,l as x,lt as S,nn as C,on as w,rn as T,tn as E,ut as D,w as O,zt as k}from"./index-D2UxaT9v.js";import{t as A}from"./textarea-Ci09-en6.js";import{t as j}from"./checkbox-BA-XURSj.js";import{n as M,t as N}from"./schemaHelpers-DLNTQr_6.js";var P=e(t(),1),F=n();function I({requests:e,selectedRequest:t,onRequestSelect:n,focusedIndex:i,formatRelativeTime:a}){return e.length===0?(0,F.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,F.jsx)(b,{vertical:!0,noBorder:!0,message:`No elicitation requests`})}):(0,F.jsx)(`div`,{children:e.map((e,o)=>{let s=e.request.mode||`form`,c=s===`form`&&`requestedSchema`in e.request&&e.request.requestedSchema;return(0,F.jsx)(m,{id:`elicitation-request-${e.id}`,"data-testid":`elicitation-request-item-${o}`,isSelected:t?.id===e.id,isFocused:i===o,title:(0,F.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.serverName,(0,F.jsx)(r,{variant:`outline`,className:s===`url`?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:s})]}),description:(()=>{let t=a(e.timestamp),n=[];return c&&n.push(`with schema`),s===`url`&&n.push(`external action`),t+(n.length>0?` | ${n.join(`, `)}`:``)})(),onClick:()=>n(e)},e.id)})})}function L({request:e,formData:t,onFieldChange:n,idPrefix:r,testIdPrefix:i,fieldContainerClassName:a=`space-y-2`,textareaRows:o=4,showOuterLabelForBoolean:s=!0,emptyFallback:u}){return(0,F.jsx)(F.Fragment,{children:(0,P.useMemo)(()=>{if(!(`requestedSchema`in e.request))return null;let d=e.request.requestedSchema;if(!d||d.type!==`object`||!d.properties)return u??(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No form schema available`});let f=d.properties,p=d.required||[];return(0,F.jsx)(`div`,{className:`space-y-4`,children:Object.entries(f).map(([e,u])=>{let d=u,f=p.includes(e),m=d.type||`string`,h=d.title||e,g=d.description,_=M(d),v=_.length>0,y=Array.isArray(d.enum),b=m===`array`&&Array.isArray(d.items?.enum),x=N(d),S=m===`array`&&x.length>0,C=Array.isArray(t[e])?t[e]:[],w=`${r}-${e}`,T=`${i}-${e}`;return(0,F.jsxs)(`div`,{className:a,children:[(m!==`boolean`||s)&&(0,F.jsxs)(l,{htmlFor:w,children:[h,f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),g&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g}),m===`boolean`?(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:w,"data-testid":T,checked:t[e]||!1,onCheckedChange:t=>n(e,t)}),(0,F.jsxs)(l,{htmlFor:w,className:`text-sm font-normal cursor-pointer`,children:[h,!s&&f&&(0,F.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]})]}):m===`number`||m===`integer`?(0,F.jsx)(c,{id:w,"data-testid":T,type:`number`,value:t[e]??``,onChange:t=>{let r=m===`integer`?parseInt(t.target.value,10):parseFloat(t.target.value);n(e,isNaN(r)?``:r)},placeholder:d.default?.toString()||``}):v?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),_.map(e=>(0,F.jsx)(`option`,{value:e.const,children:e.title||e.const},e.const))]}):y?(0,F.jsxs)(`select`,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:[(0,F.jsx)(`option`,{value:``,children:`Select...`}),d.enum.map((e,t)=>(0,F.jsx)(`option`,{value:e,children:d.enumNames?.[t]||e},e))]}):b?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:d.items.enum.map(t=>{let r=`${w}-${t}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t),onCheckedChange:r=>{n(e,r?[...C,t]:C.filter(e=>e!==t))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t})]},t)})}):S?(0,F.jsx)(`div`,{className:`space-y-2`,"data-testid":T,children:x.map(t=>{let r=`${w}-${t.const}`;return(0,F.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,F.jsx)(j,{id:r,checked:C.includes(t.const),onCheckedChange:r=>{n(e,r?[...C,t.const]:C.filter(e=>e!==t.const))}}),(0,F.jsx)(l,{htmlFor:r,className:`text-sm font-normal cursor-pointer`,children:t.title||t.const})]},t.const)})}):m===`string`&&(d.format===`textarea`||d.maxLength>100)?(0,F.jsx)(A,{id:w,"data-testid":T,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``,rows:o}):(0,F.jsx)(c,{id:w,"data-testid":T,type:`text`,value:t[e]||``,onChange:t=>n(e,t.target.value),placeholder:d.default||``})]},e)})})},[e,t,n,r,i,a,o,s,u])})}function R(e){let[t,n]=(0,P.useState)({}),[r,i]=(0,P.useState)(!1),a=e?.request.mode||`form`,o=a===`form`,s=a===`url`;return(0,P.useEffect)(()=>{if(e&&o&&`requestedSchema`in e.request){let t=e.request.requestedSchema,r={};if(t?.type===`object`&&t.properties)for(let[e,n]of Object.entries(t.properties)){let t=n;t.default===void 0?t.type===`array`?r[e]=[]:t.type===`boolean`?r[e]=!1:t.type===`number`||t.type===`integer`?r[e]=0:r[e]=``:r[e]=t.default}n(r)}i(!1)},[e?.id,o]),{formData:t,setFieldValue:(0,P.useCallback)((e,t)=>{n(n=>({...n,[e]:t}))},[]),getMissingRequiredFields:(0,P.useCallback)(()=>!e||!o||!(`requestedSchema`in e.request)?[]:(e.request.requestedSchema?.required??[]).filter(e=>t[e]===void 0||t[e]===``||t[e]===null),[e,t,o]),urlCompleted:r,setUrlCompleted:i,mode:a,isFormMode:o,isUrlMode:s}}function z({request:t,onApprove:n,onReject:c,onClose:u,previewMode:d,onTogglePreview:f,isCopied:p,onCopy:m,onDownload:h,onFullscreen:b}){let{formData:S,setFieldValue:D,getMissingRequiredFields:O,urlCompleted:k,setUrlCompleted:A,mode:M,isFormMode:N,isUrlMode:P}=R(t);return t?(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b dark:border-zinc-700`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:t.serverName}),(0,F.jsx)(r,{variant:`outline`,className:P?`bg-blue-500/20 text-blue-600 dark:text-blue-400 border-blue-500/50`:`bg-green-500/20 text-green-600 dark:text-green-400 border-green-500/50`,children:M}),(0,F.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:new Date(t.timestamp).toLocaleString()})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:m,className:`h-8 w-8 p-0`,children:p?(0,F.jsx)(w,{className:`h-4 w-4 text-green-600`}):(0,F.jsx)(T,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Copy request`})]}),(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:h,className:`h-8 w-8 p-0`,children:(0,F.jsx)(C,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Download request`})]}),(0,F.jsxs)(a,{children:[(0,F.jsx)(i,{render:(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:b,className:`h-8 w-8 p-0`,children:(0,F.jsx)(g,{className:`h-4 w-4`})}),nativeButton:!0}),(0,F.jsx)(o,{children:`Fullscreen`})]}),(0,F.jsx)(s,{variant:`ghost`,size:`sm`,onClick:u,className:`h-8 w-8 p-0`,children:(0,F.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-6`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Message`}),(0,F.jsx)(`p`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:t.request.message})]}),P&&`url`in t.request&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`External Action Required`}),(0,F.jsxs)(`div`,{className:`bg-muted rounded-lg p-4 space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This request requires you to complete an action at an external URL:`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-background rounded border`,children:[(0,F.jsx)(`code`,{className:`flex-1 text-xs font-mono break-all`,children:t.request.url}),(0,F.jsxs)(s,{size:`sm`,variant:`outline`,onClick:()=>{t&&P&&`url`in t.request&&(window.open(t.request.url,`_blank`),A(!0))},className:`flex items-center gap-2`,children:[(0,F.jsx)(E,{className:`h-4 w-4`}),`Open URL`]})]}),(0,F.jsxs)(`div`,{className:`flex items-center space-x-2 pt-2`,children:[(0,F.jsx)(j,{id:`url-completed`,checked:k,onCheckedChange:e=>A(!!e)}),(0,F.jsx)(l,{htmlFor:`url-completed`,className:`text-sm font-normal cursor-pointer`,children:`I have completed the required action`})]})]})]}),N&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:`Form Data`}),(0,F.jsx)(L,{request:t,formData:S,onFieldChange:D,idPrefix:`field`,testIdPrefix:`elicitation-field`,emptyFallback:(0,F.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:`No form schema available`})})]}),N&&`requestedSchema`in t.request&&t.request.requestedSchema&&(0,F.jsxs)(`details`,{className:`space-y-2`,children:[(0,F.jsx)(`summary`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100 cursor-pointer`,children:`Schema (for reference)`}),(0,F.jsx)(`div`,{className:`bg-muted rounded-lg p-3 max-h-64 overflow-auto`,children:(0,F.jsx)(x,{data:t.request.requestedSchema})})]})]}),(0,F.jsxs)(`div`,{className:`flex gap-2 p-4 border-t dark:border-zinc-700`,children:[(0,F.jsx)(s,{onClick:()=>{if(t){if(N){let e=O();if(e.length>0){v.error(`Missing required fields`,{description:`Please fill in: ${e.join(`, `)}`});return}n(t.id,{action:`accept`,content:S})}else P&&n(t.id,{action:`accept`});u(),y(()=>import(`./react-CU_d2d5K.js`).then(t=>e(t.t(),1)).then(e=>{let t=v(e.createElement(`div`,{className:`space-y-3`},e.createElement(`div`,null,e.createElement(`strong`,null,`Elicitation Response Sent`),e.createElement(`p`,{className:`text-sm text-muted-foreground mt-1`},`The tool will continue executing.`)),e.createElement(`div`,{className:`flex gap-2`},e.createElement(`button`,{"data-testid":`elicitation-view-tool-result`,className:`px-3 py-1.5 text-xs font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,onClick:()=>{let e=new globalThis.CustomEvent(`navigate-to-tool-result`,{detail:{toolName:null}});window.dispatchEvent(e),v.dismiss(t)}},`View Tool Result`))),{duration:5e3})}),[])}},className:`flex-1`,disabled:P&&!k,"data-testid":`elicitation-accept-button`,children:`Accept`}),(0,F.jsx)(s,{onClick:()=>{t&&(n(t.id,{action:`decline`}),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-decline-button`,children:`Decline`}),(0,F.jsx)(s,{onClick:()=>{t&&(c(t.id,`User cancelled elicitation request`),u())},variant:`outline`,className:`flex-1`,"data-testid":`elicitation-cancel-button`,children:`Cancel`})]})]}):(0,F.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select an elicitation request to view details`})})}function B({pendingRequests:e=[],onApprove:t,onReject:n,serverId:r,isConnected:i}){let{selectedElicitationRequestId:a,setSelectedElicitationRequestId:o}=O(),[s,c]=(0,P.useState)(null),[l,m]=(0,P.useState)(``),[g,v]=(0,P.useState)(-1),[y,b]=(0,P.useState)(!0),[x,C]=(0,P.useState)(!1),[w,T]=(0,P.useState)(!0),[E,A]=(0,P.useState)(!1),j=(0,P.useRef)(null),M=(0,P.useRef)(null),N=(0,P.useRef)(null),L=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(console.log(`[ElicitationTab] Auto-selection check:`,{selectedElicitationRequestId:a,pendingRequestsCount:e.length,currentSelectedId:s?.id}),a&&e.length>0){let t=e.find(e=>e.id===a);console.log(`[ElicitationTab] Found request for auto-selection:`,!!t,t?.id),t&&(console.log(`[ElicitationTab] Auto-selecting request:`,t.id),o(null),c(t),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${t.id}`);console.log(`[ElicitationTab] Scrolling to element:`,!!e),e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},100))}},[a,e,o]),(0,P.useEffect)(()=>{let t=t=>{let n=t.detail.requestId;console.log(`[ElicitationTab] Custom navigate event received:`,n);let r=e.find(e=>e.id===n);r&&(console.log(`[ElicitationTab] Selecting request from event:`,n),c(r),setTimeout(()=>{let e=document.getElementById(`elicitation-request-${n}`);e&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},200))};return window.addEventListener(`navigate-to-elicitation`,t),()=>window.removeEventListener(`navigate-to-elicitation`,t)},[e]),(0,P.useEffect)(()=>{y&&e.length>0&&j.current&&!L.current&&(j.current.scrollTop=0)},[e.length,y]),(0,P.useEffect)(()=>{let e=j.current;if(!e)return;let t=()=>{e.scrollTop>0&&(L.current=!0,b(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,P.useEffect)(()=>{e.length===0&&(L.current=!1,b(!0))},[e.length]),(0,P.useEffect)(()=>{x&&N.current&&N.current.focus()},[x]);let R=(0,P.useCallback)(()=>{l.trim()||C(!1)},[l]),B=(0,P.useMemo)(()=>{if(!l.trim())return e;let t=l.toLowerCase();return e.filter(e=>e.serverName.toLowerCase().includes(t)||e.request.message.toLowerCase().includes(t)||JSON.stringify(e.request||{}).toLowerCase().includes(t))},[e,l]);(0,P.useEffect)(()=>{v(-1)},[l]),(0,P.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=B;if(e.key===`ArrowDown`)e.preventDefault(),v(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),v(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&g>=0){e.preventDefault();let t=B[g];t&&V(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[g,B]),(0,P.useEffect)(()=>{if(g>=0){let e=`elicitation-request-${B[g]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[g,B]);let V=(0,P.useCallback)(e=>{c(e)},[]),H=(0,P.useCallback)(()=>{window.confirm(`Are you sure you want to cancel all elicitation requests? This cannot be undone.`)&&(e.forEach(e=>{n(e.id,`User cancelled all requests`)}),c(null))},[e,n]),U=(0,P.useCallback)(async()=>{if(s)try{await S(JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)),A(!0),setTimeout(()=>A(!1),2e3)}catch(e){console.error(`[ElicitationTab] Failed to copy request:`,e)}},[s]),W=(0,P.useCallback)(()=>{if(s)try{let e=new globalThis.Blob([JSON.stringify({id:s.id,serverName:s.serverName,timestamp:s.timestamp,request:s.request},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`elicitation-request-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[ElicitationTab] Failed to download request:`,e)}},[s]),G=(0,P.useCallback)(async()=>{if(M.current)try{document.fullscreenElement?await document.exitFullscreen():await M.current.requestFullscreen()}catch(e){console.error(`[ElicitationTab] Failed to toggle fullscreen:`,e)}},[]);return i?(0,F.jsxs)(p,{orientation:`horizontal`,className:`h-full`,children:[(0,F.jsx)(u,{defaultSize:40,minSize:30,children:(0,F.jsx)(p,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,F.jsx)(u,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,F.jsx)(f,{scrollRef:j,children:t=>(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(h,{isScrolled:t,title:`Elicitation`,icon:k,titleTestId:`elicitation-tab-header`,count:B.length,isSearchExpanded:x,searchQuery:l,searchPlaceholder:`Search requests...`,onSearchExpand:()=>C(!0),onSearchChange:m,onSearchBlur:R,bulkAction:{icon:_,label:`Cancel all`,onClick:H,disabled:e.length===0},searchInputRef:N}),(0,F.jsx)(I,{requests:B,selectedRequest:s,onRequestSelect:V,focusedIndex:g,formatRelativeTime:D})]})})})})}),(0,F.jsx)(d,{}),(0,F.jsx)(u,{defaultSize:60,minSize:40,children:(0,F.jsx)(`div`,{ref:M,className:`h-full bg-white dark:bg-zinc-900`,children:(0,F.jsx)(z,{request:s,onApprove:t,onReject:n,onClose:()=>c(null),previewMode:w,onTogglePreview:()=>T(!w),isCopied:E,onCopy:U,onDownload:W,onFullscreen:G})})})]}):(0,F.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,F.jsx)(k,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,F.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{B as ElicitationTab};
@@ -1 +1 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{qt as r,x as i}from"./index-Bbn-6QR2.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{i().then(()=>window.close()).catch(e=>{t(e instanceof Error?e.message:String(e))})},[]),(0,o.jsx)(`div`,{className:`flex h-screen w-full items-center justify-center bg-background`,children:(0,o.jsx)(`div`,{className:`flex max-w-md flex-col items-center gap-4 p-6 text-center`,children:e?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`text-lg font-semibold text-destructive`,children:`Authorization failed`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r,{className:`size-8 animate-spin text-muted-foreground`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Completing Manufact authorization…`})]})})})}export{s as ManufactOAuthCallback};
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{qt as r,x as i}from"./index-D2UxaT9v.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(null);return(0,a.useEffect)(()=>{i().then(()=>window.close()).catch(e=>{t(e instanceof Error?e.message:String(e))})},[]),(0,o.jsx)(`div`,{className:`flex h-screen w-full items-center justify-center bg-background`,children:(0,o.jsx)(`div`,{className:`flex max-w-md flex-col items-center gap-4 p-6 text-center`,children:e?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`h1`,{className:`text-lg font-semibold text-destructive`,children:`Authorization failed`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r,{className:`size-8 animate-spin text-muted-foreground`}),(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Completing Manufact authorization…`})]})})})}export{s as ManufactOAuthCallback};
@@ -1 +1 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{sr as r}from"./input-CjmxOFr6.js";import{t as i}from"./brush--0LobUi4.js";import{t as a}from"./code-tME-5H6D.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./shared-Dfwy7nyg.js";import{t as f}from"./maximize-_O55kFcr.js";import{Ft as p,Lt as m,in as h,kt as g,l as _,lt as v,nn as y,on as b,rn as x,sn as S,ut as C}from"./index-Bbn-6QR2.js";var w=e(t(),1),T=n();function E({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i}){return e.length===0?(0,T.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,T.jsx)(g,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,T.jsx)(`div`,{children:e.map((e,a)=>(0,T.jsx)(u,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,T.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,T.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function D({notification:e,previewMode:t,onTogglePreview:n,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,onClose:u}){return e?(0,T.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,T.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(h,{className:`h-3 w-3 text-gray-400`}),(0,T.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,T.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,T.jsx)(a,{className:`h-4 w-4 mr-1`}):(0,T.jsx)(i,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,T.jsx)(b,{className:`h-4 w-4`}):(0,T.jsx)(x,{className:`h-4 w-4`})}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:s,children:(0,T.jsx)(y,{className:`h-4 w-4`})}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:c,children:(0,T.jsx)(f,{className:`h-4 w-4`})}),u&&(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:u,children:(0,T.jsx)(p,{className:`h-4 w-4`})})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,T.jsx)(`div`,{className:`px-4 pt-4`,children:(0,T.jsx)(_,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,T.jsx)(S,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,T.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function O({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:u}){let[f,p]=(0,w.useState)(null),[h,g]=(0,w.useState)(``),[_,y]=(0,w.useState)(-1),[b,x]=(0,w.useState)(!0),[O,k]=(0,w.useState)(!1),[A,j]=(0,w.useState)(!0),[M,N]=(0,w.useState)(!1),P=(0,w.useRef)(null),F=(0,w.useRef)(null),I=(0,w.useRef)(null),L=(0,w.useRef)(!1);(0,w.useEffect)(()=>{b&&e.length>0&&P.current&&!L.current&&(P.current.scrollTop=0)},[e.length,b]),(0,w.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>{e.scrollTop>0&&(L.current=!0,x(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,w.useEffect)(()=>{e.length===0&&(L.current=!1,x(!0))},[e.length]),(0,w.useEffect)(()=>{f&&!f.read&&n(f.id)},[f,n]),(0,w.useEffect)(()=>{O&&I.current&&I.current.focus()},[O]);let R=(0,w.useCallback)(()=>{h.trim()||k(!1)},[h]),z=(0,w.useMemo)(()=>{if(!h.trim())return e;let t=h.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,h]);(0,w.useEffect)(()=>{y(-1)},[h]),(0,w.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=z;if(e.key===`ArrowDown`)e.preventDefault(),y(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),y(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&_>=0){e.preventDefault();let t=z[_];t&&B(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,z]),(0,w.useEffect)(()=>{if(_>=0){let e=`notification-${z[_]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[_,z]);let B=(0,w.useCallback)(e=>{p(e)},[]),V=(0,w.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),p(null))},[i]),H=(0,w.useCallback)(async()=>{if(f)try{await v(JSON.stringify({method:f.method,timestamp:f.timestamp,read:f.read,params:f.params},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[f]),U=(0,w.useCallback)(()=>{if(f)try{let e=new globalThis.Blob([JSON.stringify({method:f.method,timestamp:f.timestamp,read:f.read,params:f.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[f]),W=(0,w.useCallback)(async()=>{if(F.current)try{document.fullscreenElement?await document.exitFullscreen():await F.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),G=f?{method:f.method,params:f.params,timestamp:f.timestamp,read:f.read,formatRelativeTime:C}:null;return u?(0,T.jsxs)(l,{orientation:`horizontal`,className:`h-full`,children:[(0,T.jsx)(o,{defaultSize:40,minSize:30,children:(0,T.jsx)(l,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,T.jsx)(o,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,T.jsx)(c,{scrollRef:P,children:t=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(d,{isScrolled:t,title:`Notifications`,icon:S,count:z.length,isSearchExpanded:O,searchQuery:h,searchPlaceholder:`Search notifications...`,onSearchExpand:()=>k(!0),onSearchChange:g,onSearchBlur:R,bulkAction:{icon:m,label:`Clear all`,onClick:V,disabled:e.length===0},searchInputRef:I}),(0,T.jsx)(E,{notifications:z,selectedNotification:f,onNotificationSelect:B,focusedIndex:_,formatRelativeTime:C})]})})})})}),(0,T.jsx)(s,{}),(0,T.jsx)(o,{defaultSize:60,minSize:40,children:(0,T.jsx)(`div`,{ref:F,className:`h-full bg-white dark:bg-zinc-900`,children:(0,T.jsx)(D,{notification:G,previewMode:A,onTogglePreview:()=>j(!A),onCopy:H,onDownload:U,onFullscreen:W,onClose:()=>p(null),isCopied:M})})})]}):(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,T.jsx)(S,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,T.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{O as NotificationsTab};
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{sr as r}from"./input-CjmxOFr6.js";import{t as i}from"./brush--0LobUi4.js";import{t as a}from"./code-tME-5H6D.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./shared-DQE60Op-.js";import{t as f}from"./maximize-_O55kFcr.js";import{Ft as p,Lt as m,in as h,kt as g,l as _,lt as v,nn as y,on as b,rn as x,sn as S,ut as C}from"./index-D2UxaT9v.js";var w=e(t(),1),T=n();function E({notifications:e,selectedNotification:t,onNotificationSelect:n,focusedIndex:r,formatRelativeTime:i}){return e.length===0?(0,T.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-4 text-center`,children:(0,T.jsx)(g,{vertical:!0,noBorder:!0,message:`No notifications yet`})}):(0,T.jsx)(`div`,{children:e.map((e,a)=>(0,T.jsx)(u,{id:`notification-${e.id}`,isSelected:t?.id===e.id,isFocused:r===a,title:(0,T.jsxs)(`span`,{className:`flex items-center gap-3`,children:[e.method,!e.read&&(0,T.jsx)(`span`,{className:`size-1.5 block rounded-full bg-orange-500`})]}),description:(()=>{let t=i(e.timestamp),n=e.params&&Object.keys(e.params).length>0?Object.keys(e.params).length:0;return t+(n>0?` | ${n} param${n>1?`s`:``}`:``)})(),onClick:()=>n(e)},e.id))})}function D({notification:e,previewMode:t,onTogglePreview:n,onCopy:o,onDownload:s,onFullscreen:c,isCopied:l=!1,onClose:u}){return e?(0,T.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,T.jsxs)(`div`,{className:`flex-shrink-0 px-4 py-3 border-b border-gray-200 dark:border-zinc-700 flex items-center justify-between`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(h,{className:`h-3 w-3 text-gray-400`}),(0,T.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleTimeString()})]}),(0,T.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.formatRelativeTime(e.timestamp)})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:n,className:t?``:`text-purple-600 dark:text-purple-400`,children:[t?(0,T.jsx)(a,{className:`h-4 w-4 mr-1`}):(0,T.jsx)(i,{className:`h-4 w-4 mr-1`}),t?`JSON`:`Formatted`]}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:o,children:l?(0,T.jsx)(b,{className:`h-4 w-4`}):(0,T.jsx)(x,{className:`h-4 w-4`})}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:s,children:(0,T.jsx)(y,{className:`h-4 w-4`})}),(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:c,children:(0,T.jsx)(f,{className:`h-4 w-4`})}),u&&(0,T.jsx)(r,{variant:`ghost`,size:`sm`,onClick:u,children:(0,T.jsx)(p,{className:`h-4 w-4`})})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,T.jsx)(`div`,{className:`px-4 pt-4`,children:(0,T.jsx)(_,{data:{method:e.method,timestamp:e.timestamp,read:e.read,params:e.params},filename:`notification-${e.method.replace(/[^a-zA-Z0-9]/g,`-`)}-${Date.now()}.json`})})})]}):(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,T.jsx)(S,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,T.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Select a notification to view details`})]})}function O({notifications:e,unreadCount:t,markNotificationRead:n,markAllNotificationsRead:r,clearNotifications:i,serverId:a,isConnected:u}){let[f,p]=(0,w.useState)(null),[h,g]=(0,w.useState)(``),[_,y]=(0,w.useState)(-1),[b,x]=(0,w.useState)(!0),[O,k]=(0,w.useState)(!1),[A,j]=(0,w.useState)(!0),[M,N]=(0,w.useState)(!1),P=(0,w.useRef)(null),F=(0,w.useRef)(null),I=(0,w.useRef)(null),L=(0,w.useRef)(!1);(0,w.useEffect)(()=>{b&&e.length>0&&P.current&&!L.current&&(P.current.scrollTop=0)},[e.length,b]),(0,w.useEffect)(()=>{let e=P.current;if(!e)return;let t=()=>{e.scrollTop>0&&(L.current=!0,x(!1))};return e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)},[]),(0,w.useEffect)(()=>{e.length===0&&(L.current=!1,x(!0))},[e.length]),(0,w.useEffect)(()=>{f&&!f.read&&n(f.id)},[f,n]),(0,w.useEffect)(()=>{O&&I.current&&I.current.focus()},[O]);let R=(0,w.useCallback)(()=>{h.trim()||k(!1)},[h]),z=(0,w.useMemo)(()=>{if(!h.trim())return e;let t=h.toLowerCase();return e.filter(e=>e.method.toLowerCase().includes(t)||JSON.stringify(e.params||{}).toLowerCase().includes(t))},[e,h]);(0,w.useEffect)(()=>{y(-1)},[h]),(0,w.useEffect)(()=>{let e=e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.contentEditable===`true`||e.metaKey||e.ctrlKey||e.altKey)return;let n=z;if(e.key===`ArrowDown`)e.preventDefault(),y(e=>{let t=e+1;return t>=n.length?0:t});else if(e.key===`ArrowUp`)e.preventDefault(),y(e=>{let t=e-1;return t<0?n.length-1:t});else if(e.key===`Enter`&&_>=0){e.preventDefault();let t=z[_];t&&B(t)}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[_,z]),(0,w.useEffect)(()=>{if(_>=0){let e=`notification-${z[_]?.id}`,t=document.getElementById(e);t&&t.scrollIntoView({behavior:`smooth`,block:`nearest`})}},[_,z]);let B=(0,w.useCallback)(e=>{p(e)},[]),V=(0,w.useCallback)(()=>{window.confirm(`Are you sure you want to clear all notifications? This cannot be undone.`)&&(i(),p(null))},[i]),H=(0,w.useCallback)(async()=>{if(f)try{await v(JSON.stringify({method:f.method,timestamp:f.timestamp,read:f.read,params:f.params},null,2)),N(!0),setTimeout(()=>N(!1),2e3)}catch(e){console.error(`[NotificationsTab] Failed to copy notification:`,e)}},[f]),U=(0,w.useCallback)(()=>{if(f)try{let e=new globalThis.Blob([JSON.stringify({method:f.method,timestamp:f.timestamp,read:f.read,params:f.params},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`notification-${Date.now()}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}catch(e){console.error(`[NotificationsTab] Failed to download notification:`,e)}},[f]),W=(0,w.useCallback)(async()=>{if(F.current)try{document.fullscreenElement?await document.exitFullscreen():await F.current.requestFullscreen()}catch(e){console.error(`[NotificationsTab] Failed to toggle fullscreen:`,e)}},[]),G=f?{method:f.method,params:f.params,timestamp:f.timestamp,read:f.read,formatRelativeTime:C}:null;return u?(0,T.jsxs)(l,{orientation:`horizontal`,className:`h-full`,children:[(0,T.jsx)(o,{defaultSize:40,minSize:30,children:(0,T.jsx)(l,{orientation:`vertical`,className:`h-full border-r dark:border-zinc-700`,children:(0,T.jsx)(o,{defaultSize:75,minSize:30,className:`h-full overflow-hidden`,children:(0,T.jsx)(c,{scrollRef:P,children:t=>(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(d,{isScrolled:t,title:`Notifications`,icon:S,count:z.length,isSearchExpanded:O,searchQuery:h,searchPlaceholder:`Search notifications...`,onSearchExpand:()=>k(!0),onSearchChange:g,onSearchBlur:R,bulkAction:{icon:m,label:`Clear all`,onClick:V,disabled:e.length===0},searchInputRef:I}),(0,T.jsx)(E,{notifications:z,selectedNotification:f,onNotificationSelect:B,focusedIndex:_,formatRelativeTime:C})]})})})})}),(0,T.jsx)(s,{}),(0,T.jsx)(o,{defaultSize:60,minSize:40,children:(0,T.jsx)(`div`,{ref:F,className:`h-full bg-white dark:bg-zinc-900`,children:(0,T.jsx)(D,{notification:G,previewMode:A,onTogglePreview:()=>j(!A),onCopy:H,onDownload:U,onFullscreen:W,onClose:()=>p(null),isCopied:M})})})]}):(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,T.jsx)(S,{className:`h-12 w-12 text-gray-400 dark:text-gray-600 mb-3`}),(0,T.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`Not connected to server`})]})}export{O as NotificationsTab};
@@ -1 +1 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{ht as r,qt as i}from"./index-Bbn-6QR2.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(`processing`),[n,s]=(0,a.useState)(``);return(0,a.useEffect)(()=>{console.log(`[OAuthCallback] Component mounted, handling authorization...`),console.log(`[OAuthCallback] Current URL:`,window.location.href),r().then(()=>{console.log(`[OAuthCallback] Authorization successful`),t(`success`)}).catch(e=>{console.error(`[OAuthCallback] Authorization failed:`,e),t(`error`),s(e instanceof Error?e.message:String(e))})},[]),e===`processing`?(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,o.jsx)(i,{className:`h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Completing authentication...`})]})}):e===`error`?(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,o.jsx)(`h1`,{className:`text-xl font-semibold text-red-600 dark:text-red-400 mb-2`,children:`Authentication Error`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400 mb-4`,children:n}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-500`,children:`You can close this window and try again.`})]})}):(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,o.jsx)(`h1`,{className:`text-xl font-semibold text-green-600 dark:text-green-400 mb-2`,children:`Authentication Successful!`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Redirecting you back...`})]})})}export{s as OAuthCallback};
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{ht as r,qt as i}from"./index-D2UxaT9v.js";var a=e(t(),1),o=n();function s(){let[e,t]=(0,a.useState)(`processing`),[n,s]=(0,a.useState)(``);return(0,a.useEffect)(()=>{console.log(`[OAuthCallback] Component mounted, handling authorization...`),console.log(`[OAuthCallback] Current URL:`,window.location.href),r().then(()=>{console.log(`[OAuthCallback] Authorization successful`),t(`success`)}).catch(e=>{console.error(`[OAuthCallback] Authorization failed:`,e),t(`error`),s(e instanceof Error?e.message:String(e))})},[]),e===`processing`?(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,o.jsx)(i,{className:`h-8 w-8 animate-spin text-zinc-600 dark:text-zinc-400`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Completing authentication...`})]})}):e===`error`?(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,o.jsx)(`h1`,{className:`text-xl font-semibold text-red-600 dark:text-red-400 mb-2`,children:`Authentication Error`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400 mb-4`,children:n}),(0,o.jsx)(`p`,{className:`text-xs text-zinc-500 dark:text-zinc-500`,children:`You can close this window and try again.`})]})}):(0,o.jsx)(`div`,{className:`h-screen w-full flex items-center justify-center bg-white dark:bg-zinc-900`,children:(0,o.jsxs)(`div`,{className:`max-w-md p-6`,children:[(0,o.jsx)(`h1`,{className:`text-xl font-semibold text-green-600 dark:text-green-400 mb-2`,children:`Authentication Successful!`}),(0,o.jsx)(`p`,{className:`text-sm text-zinc-600 dark:text-zinc-400`,children:`Redirecting you back...`})]})})}export{s as OAuthCallback};
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Lr as r,Nr as i,cr as a,f as o,lr as s,sr as c,t as l,ur as u}from"./input-CjmxOFr6.js";import{t as d}from"./label-B5Q_Zr8M.js";import{t as f}from"./AnimatePresence-CthXziG2.js";import{a as p,i as m,n as h,r as g,t as _}from"./select-C0xlfLAa.js";import{n as v,t as y}from"./zap-Du2Uc5pa.js";import{a as b,i as x,n as S,o as C,r as w,s as T}from"./shared-Dfwy7nyg.js";import{t as ee}from"./maximize-_O55kFcr.js";import{n as E,t as te}from"./save-B-MsgxX9.js";import{Ht as ne,Kt as re,Lt as ie,T as D,Xt as ae,in as oe,kt as se,l as ce,lt as O,on as k,rn as le,w as A}from"./index-Bbn-6QR2.js";import{t as ue}from"./useMCPPrompts-CPskz9af.js";import{t as de}from"./textarea-Ci09-en6.js";import{t as fe}from"./checkbox-_GzEPQic.js";import{t as j}from"./ListTabHeader-G-nQX18m.js";var M=e(t(),1),N=n();function pe({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,N.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`})]},r):e.type===`number`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(l,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:`Enter ${r}`})]},r):e.type===`array`||e.type===`object`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(de,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`})]},r):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(l,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:`Enter ${r}`})]},r)};return(0,N.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function me({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:i,onArgChange:o,onExecute:l,onSave:d}){return(0,M.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&i&&(t.preventDefault(),l())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,i,l]),e?(0,N.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,N.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,N.jsx)(c,{onClick:l,disabled:n||!i,size:`sm`,className:a,"data-testid":`prompt-execute-button`,children:n?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ne,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,N.jsx)(`span`,{className:s,children:`⌘↵`})]})}),(0,N.jsxs)(c,{variant:`outline`,onClick:d,disabled:n,size:`sm`,className:r(u,`gap-2`),children:[(0,N.jsx)(te,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,N.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,N.jsx)(pe,{selectedPrompt:e,promptArgs:t,onArgChange:o})})]}):(0,N.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,N.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,N.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}var he;function ge(e){if(!he)if(typeof document<`u`)he=document.createElement(`textarea`);else return;var t=`&`+e+`;`;he.innerHTML=t;var n=he.value;return n===t?void 0:n}var P=32,F=9,_e=13,I=10,L=96,ve=126,ye=91,be=94,R=62,xe=35,Se=36,Ce=37,z=45,we=61,B=92,Te=42,Ee=95,V=60,De=64,Oe=93,H=33,ke=38,Ae=58,je=70,Me=102,Ne=104,Pe=119,Fe=116,Ie=112,Le=115,Re=160,ze=12,Be=44,Ve=59,He=63,Ue=46,U=47,We=39,Ge=34,Ke=43,qe=124,Je=123,Ye=125,Xe=40,Ze=41,Qe=30,$e=31,W=48,G=57,K=65,q=90,et=97,tt=122,nt=128,rt=32,J={blockQuote:0,breakLine:1,breakThematic:2,codeBlock:3,codeInline:4,footnote:5,footnoteReference:6,frontmatter:7,gfmTask:8,heading:9,htmlBlock:10,htmlComment:11,htmlSelfClosing:12,image:13,link:14,orderedList:15,paragraph:16,ref:17,refCollection:18,table:19,text:20,textFormatted:21,unorderedList:22};function it(e){if(!_t(e,`---`))return null;let t=3;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;if(t<e.length&&e[t]===`\r`&&t++,t>=e.length||e[t]!==`
1
+ import{s as e,t}from"./react-CU_d2d5K.js";import{t as n}from"./jsx-runtime-Cjj9sGSy.js";import{Lr as r,Nr as i,cr as a,f as o,lr as s,sr as c,t as l,ur as u}from"./input-CjmxOFr6.js";import{t as d}from"./label-B5Q_Zr8M.js";import{t as f}from"./AnimatePresence-CthXziG2.js";import{a as p,i as m,n as h,r as g,t as _}from"./select-C0xlfLAa.js";import{n as v,t as y}from"./zap-Du2Uc5pa.js";import{a as b,i as x,n as S,o as C,r as w,s as T}from"./shared-DQE60Op-.js";import{t as ee}from"./maximize-_O55kFcr.js";import{n as E,t as te}from"./save-B-MsgxX9.js";import{Ht as ne,Kt as re,Lt as ie,T as D,Xt as ae,in as oe,kt as se,l as ce,lt as O,on as k,rn as le,w as A}from"./index-D2UxaT9v.js";import{t as ue}from"./useMCPPrompts-USLYc1I4.js";import{t as de}from"./textarea-Ci09-en6.js";import{t as fe}from"./checkbox-BA-XURSj.js";import{t as j}from"./ListTabHeader-G-nQX18m.js";var M=e(t(),1),N=n();function pe({selectedPrompt:e,promptArgs:t,onArgChange:n}){let r=e?.arguments||[];if(!(r.length>0))return(0,N.jsx)(`div`,{className:`flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm`,children:`No arguments required`});let i=e=>{let r=e.name,i=t[r],a=typeof i==`string`?i:JSON.stringify(i);return e.type===`boolean`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(`input`,{id:r,type:`checkbox`,checked:!!i,onChange:e=>n(r,e.target.checked),className:`rounded`,"aria-label":`Toggle ${r}`})]},r):e.type===`number`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(l,{id:r,type:`number`,value:Number(i)||0,onChange:e=>n(r,Number(e.target.value)),placeholder:`Enter ${r}`})]},r):e.type===`array`||e.type===`object`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(de,{id:r,value:a,onChange:e=>{try{n(r,JSON.parse(e.target.value))}catch{n(r,e.target.value)}},placeholder:`Enter ${r} as JSON`,className:`font-mono text-sm min-h-[100px]`})]},r):(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(d,{htmlFor:r,className:`text-sm font-medium`,children:[r,e.required&&(0,N.jsx)(`span`,{className:`text-red-500 ml-1`,children:`*`})]}),e.description&&(0,N.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e.description})]}),(0,N.jsx)(l,{id:r,"data-testid":`prompt-param-${r}`,value:a,onChange:e=>n(r,e.target.value),placeholder:`Enter ${r}`})]},r)};return(0,N.jsx)(`div`,{className:`space-y-4`,children:r.map(e=>i(e))})}function me({selectedPrompt:e,promptArgs:t,isExecuting:n,isConnected:i,onArgChange:o,onExecute:l,onSave:d}){return(0,M.useEffect)(()=>{let t=t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&e&&!n&&i&&(t.preventDefault(),l())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,i,l]),e?(0,N.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,N.jsx)(`div`,{className:`flex-shrink-0 p-3 sm:p-6 pt-3 pb-4 pr-3`,children:(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`flex flex-row items-center justify-between mb-0 gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-base sm:text-lg font-semibold`,children:e.name}),(0,N.jsxs)(`div`,{className:`flex gap-2 flex-shrink-0`,children:[(0,N.jsx)(c,{onClick:l,disabled:n||!i,size:`sm`,className:a,"data-testid":`prompt-execute-button`,children:n?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Executing...`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ne,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Execute`}),(0,N.jsx)(`span`,{className:s,children:`⌘↵`})]})}),(0,N.jsxs)(c,{variant:`outline`,onClick:d,disabled:n,size:`sm`,className:r(u,`gap-2`),children:[(0,N.jsx)(te,{}),(0,N.jsx)(`span`,{className:`hidden sm:inline`,children:`Save`})]})]})]}),e.description&&(0,N.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 leading-relaxed mt-2`,children:e.description})]})}),(0,N.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 sm:px-6 pb-4 pr-3`,children:(0,N.jsx)(pe,{selectedPrompt:e,promptArgs:t,onArgChange:o})})]}):(0,N.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-4 text-center`,children:[(0,N.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400 mb-2`,children:`Select a prompt to get started`}),(0,N.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:`Choose a prompt from the list to view its details and execute it`})]})}var he;function ge(e){if(!he)if(typeof document<`u`)he=document.createElement(`textarea`);else return;var t=`&`+e+`;`;he.innerHTML=t;var n=he.value;return n===t?void 0:n}var P=32,F=9,_e=13,I=10,L=96,ve=126,ye=91,be=94,R=62,xe=35,Se=36,Ce=37,z=45,we=61,B=92,Te=42,Ee=95,V=60,De=64,Oe=93,H=33,ke=38,Ae=58,je=70,Me=102,Ne=104,Pe=119,Fe=116,Ie=112,Le=115,Re=160,ze=12,Be=44,Ve=59,He=63,Ue=46,U=47,We=39,Ge=34,Ke=43,qe=124,Je=123,Ye=125,Xe=40,Ze=41,Qe=30,$e=31,W=48,G=57,K=65,q=90,et=97,tt=122,nt=128,rt=32,J={blockQuote:0,breakLine:1,breakThematic:2,codeBlock:3,codeInline:4,footnote:5,footnoteReference:6,frontmatter:7,gfmTask:8,heading:9,htmlBlock:10,htmlComment:11,htmlSelfClosing:12,image:13,link:14,orderedList:15,paragraph:16,ref:17,refCollection:18,table:19,text:20,textFormatted:21,unorderedList:22};function it(e){if(!_t(e,`---`))return null;let t=3;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;if(t<e.length&&e[t]===`\r`&&t++,t>=e.length||e[t]!==`
2
2
  `)return null;t++;let n=!1;for(;t<e.length;){let r=t;for(;t<e.length&&e[t]!==`
3
3
  `&&e[t]!==`\r`;)t++;if(t>=e.length)break;let i=t;if(e[t]===`\r`&&t++,t<e.length&&e[t]===`
4
4
  `&&t++,_t(e,`---`,r))return{endPos:t,hasValidYaml:n};let a=e.indexOf(`:`,r);a!==-1&&a<i&&(n=!0)}return null}var at=/&([a-zA-Z0-9]+|#[0-9]{1,7}|#x[0-9a-fA-F]{1,6});/gi,ot={class:`className`,for:`htmlFor`,allowfullscreen:`allowFullScreen`,allowtransparency:`allowTransparency`,autocomplete:`autoComplete`,autofocus:`autoFocus`,autoplay:`autoPlay`,cellpadding:`cellPadding`,cellspacing:`cellSpacing`,charset:`charSet`,classid:`classId`,colspan:`colSpan`,contenteditable:`contentEditable`,contextmenu:`contextMenu`,crossorigin:`crossOrigin`,enctype:`encType`,formaction:`formAction`,formenctype:`formEncType`,formmethod:`formMethod`,formnovalidate:`formNoValidate`,formtarget:`formTarget`,frameborder:`frameBorder`,hreflang:`hrefLang`,inputmode:`inputMode`,keyparams:`keyParams`,keytype:`keyType`,marginheight:`marginHeight`,marginwidth:`marginWidth`,maxlength:`maxLength`,mediagroup:`mediaGroup`,minlength:`minLength`,novalidate:`noValidate`,radiogroup:`radioGroup`,readonly:`readOnly`,rowspan:`rowSpan`,spellcheck:`spellCheck`,srcdoc:`srcDoc`,srclang:`srcLang`,srcset:`srcSet`,tabindex:`tabIndex`,usemap:`useMap`,viewbox:`viewBox`};function st(e){var t={};for(var n in e){var r=ot[n.toLowerCase()];if(r)t[r]=e[n];else{var i=n.indexOf(`:`);i===-1?t[n]=e[n]:t[n.slice(0,i)+n[i+1].toUpperCase()+n.slice(i+2)]=e[n]}}return t}var ct=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s|^<(div|p|h[1-6]|ul|ol|li|blockquote|pre|table|thead|tbody|tr|td|th|dl|dt|dd|hr|address|article|aside|details|dialog|figure|figcaption|footer|form|header|main|menu|nav|section|summary|textarea|fieldset|legend|center|dir|hgroup|marquee|search|output|template)\b)/i;function lt(e){return e.indexOf(`&`)===-1?e:e.replace(at,(e,t)=>{var n=ge(t);if(n)return n;if(t[0]===`#`){var r=t[1]===`x`||t[1]===`X`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return r===0||r>=55296&&r<=57343||r>1114111?`�`:r<=65535?String.fromCharCode(r):String.fromCharCode(55296+(r-65536>>10),56320+(r-65536&1023))}return e})}var ut=/(javascript|vbscript|data(?!:image)):/i;function dt(e){if(ut.test(e))return null;if(e.indexOf(`%`)===-1)return e;try{let t=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,``);if(ut.test(t))return null}catch{return null}return e}var ft={},pt,mt;for(pt=[192,193,194,195,196,197,224,225,226,227,228,229,230,198],mt=0;mt<pt.length;mt++)ft[pt[mt]]=`a`;for(ft[231]=ft[199]=`c`,ft[240]=ft[208]=`d`,pt=[200,201,202,203,233,232,234,235],mt=0;mt<pt.length;mt++)ft[pt[mt]]=`e`;for(pt=[207,239,206,238,205,237,204,236],mt=0;mt<pt.length;mt++)ft[pt[mt]]=`i`;for(ft[209]=ft[241]=`n`,pt=[248,216,339,338,213,245,212,244,211,243,210,242],mt=0;mt<pt.length;mt++)ft[pt[mt]]=`o`;for(pt=[220,252,219,251,218,250,217,249],mt=0;mt<pt.length;mt++)ft[pt[mt]]=`u`;ft[376]=ft[255]=ft[221]=ft[253]=`y`;function ht(e){return e<nt&&(jt[e]&(St|Ct))!==0}function gt(e){for(var t=``,n=-1,r=0;r<e.length;r++){var i=e.charCodeAt(r);if(ht(i))i>=K&&i<=q?(n>=0&&(t+=e.slice(n,r),n=-1),t+=String.fromCharCode(i+rt)):n<0&&(n=r);else if(i===P||i===z)n>=0&&(t+=e.slice(n,r),n=-1),t+=`-`;else{n>=0&&(t+=e.slice(n,r),n=-1);var a=ft[i];a&&(t+=a)}}return n>=0&&(t+=e.slice(n)),t}function _t(e,t,n){return e.startsWith(t,n)}var vt=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`,`circle`,`ellipse`,`line`,`path`,`polygon`,`polyline`,`rect`,`use`,`stop`,`animate`,`set`]);function yt(e){let t=e.toLowerCase();if(vt.has(t))return!0;let n=t.indexOf(`:`);return n===-1?!1:(t=t.slice(n+1),vt.has(t))}var bt=1,xt=2,St=4,Ct=8,wt=16,Tt=32,Et=64,Dt=1,Ot=2,kt=3,At=4,jt=(function(){let e=new Uint8Array(128),t;for(e[F]=bt|Tt,e[I]=bt|wt,e[ze]=bt,e[_e]=bt|wt,e[P]=bt|Tt,t=H;t<=U;t++)e[t]=xt;for(t=Ae;t<=De;t++)e[t]=xt;for(t=ye;t<=L;t++)e[t]=xt;for(t=Je;t<=ve;t++)e[t]=xt;for(t=W;t<=G;t++)e[t]=Ct;for(t=K;t<=q;t++)e[t]=St|Et;for(t=et;t<=tt;t++)e[t]=St;return e})();(function(){let e=new Uint8Array(128);return e[B]=Ot,e[ye]=At,e[Te]=e[Ee]=e[ve]=e[we]=kt,e[L]=e[V]=e[De]=e[Oe]=e[I]=e[P]=e[H]=Dt,e[Me]=e[Ne]=e[Pe]=Dt,e})();var Mt=[];function Nt(e){var t=e.indexOf(`\r`),n=e.indexOf(`\0`);if(t===-1&&n===-1)return e;var r=e.length;Mt.length=0;var i=0,a=0;for(a=t===-1?n:n===-1||t<n?t:n;a<r;a++){var o=e.charCodeAt(a);o===_e?(i<a&&Mt.push(e.slice(i,a)),a+1<r&&e.charCodeAt(a+1)===I&&a++,Mt.push(`