dexto 1.0.2 → 1.1.0

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 (165) hide show
  1. package/README.md +1 -1
  2. package/agents/agent-registry.json +53 -0
  3. package/agents/database-agent/README.md +35 -0
  4. package/agents/database-agent/data/example.db +0 -0
  5. package/agents/database-agent/database-agent-example.sql +98 -0
  6. package/agents/database-agent/database-agent.yml +116 -0
  7. package/agents/database-agent/setup-database.sh +64 -0
  8. package/agents/{agent.yml → default-agent.yml} +1 -1
  9. package/agents/image-editor-agent/Lenna.webp +0 -0
  10. package/agents/image-editor-agent/README.md +435 -0
  11. package/agents/image-editor-agent/image-editor-agent.yml +45 -0
  12. package/agents/music-agent/README.md +294 -0
  13. package/agents/music-agent/music-agent.yml +43 -0
  14. package/agents/product-name-researcher/README.md +98 -0
  15. package/agents/product-name-researcher/product-name-researcher.yml +161 -0
  16. package/agents/talk2pdf-agent/README.md +166 -0
  17. package/agents/talk2pdf-agent/talk2pdf-agent.yml +42 -0
  18. package/agents/triage-demo/README.md +337 -0
  19. package/agents/triage-demo/billing-agent.yml +76 -0
  20. package/agents/triage-demo/docs/billing-policies.md +246 -0
  21. package/agents/triage-demo/docs/company-overview.md +94 -0
  22. package/agents/triage-demo/docs/escalation-policies.md +301 -0
  23. package/agents/triage-demo/docs/product-features.md +253 -0
  24. package/agents/triage-demo/docs/technical-documentation.md +226 -0
  25. package/agents/triage-demo/escalation-agent.yml +82 -0
  26. package/agents/triage-demo/product-info-agent.yml +86 -0
  27. package/agents/triage-demo/technical-support-agent.yml +71 -0
  28. package/agents/triage-demo/test-scenarios.md +209 -0
  29. package/agents/triage-demo/triage-agent.yml +172 -0
  30. package/dist/src/app/chunk-CLDYRNV6.js +10139 -0
  31. package/dist/src/app/chunk-DYNVXGAH.js +137 -0
  32. package/dist/src/app/chunk-PW2PHCHR.js +83 -0
  33. package/dist/src/app/chunk-R4Q522DR.js +205 -0
  34. package/dist/src/app/chunk-UXCBS3TR.js +281 -0
  35. package/dist/src/app/chunk-X6LEX724.js +108 -0
  36. package/dist/src/app/chunk-Y33BS5SA.js +39 -0
  37. package/dist/src/app/{cli-confirmation-handler-EZF6AMUS.js → cli-confirmation-handler-GJHPLGOL.js} +4 -1
  38. package/dist/src/app/errors-5MNETGOV.js +8 -0
  39. package/dist/src/app/index.js +1604 -8978
  40. package/dist/src/app/loader-EFMKWNNQ.js +20 -0
  41. package/dist/src/app/path-7FT4SZMO.js +23 -0
  42. package/dist/src/app/{postgres-backend-7HVVW3RL.js → postgres-backend-U5MIIMUY.js} +12 -1
  43. package/dist/src/app/{redis-backend-2YBZSSSV.js → redis-backend-NGI67ILT.js} +38 -9
  44. package/dist/src/app/registry-RALMVM3P.js +14 -0
  45. package/dist/src/app/sqlite-backend-752UUBD4.js +245 -0
  46. package/dist/src/app/webui/.next/standalone/.next/BUILD_ID +1 -1
  47. package/dist/src/app/webui/.next/standalone/.next/app-build-manifest.json +20 -21
  48. package/dist/src/app/webui/.next/standalone/.next/app-path-routes-manifest.json +0 -1
  49. package/dist/src/app/webui/.next/standalone/.next/build-manifest.json +4 -4
  50. package/dist/src/app/webui/.next/standalone/.next/prerender-manifest.json +4 -82
  51. package/dist/src/app/webui/.next/standalone/.next/required-server-files.json +2 -3
  52. package/dist/src/app/webui/.next/standalone/.next/routes-manifest.json +0 -6
  53. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js +1 -1
  54. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  55. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  56. package/dist/src/app/webui/.next/standalone/.next/server/app/page.js +7 -3
  57. package/dist/src/app/webui/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  58. package/dist/src/app/webui/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js +8 -8
  60. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js.nft.json +1 -1
  61. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page_client-reference-manifest.js +1 -1
  62. package/dist/src/app/webui/.next/standalone/.next/server/app-paths-manifest.json +0 -1
  63. package/dist/src/app/webui/.next/standalone/.next/server/chunks/176.js +1 -0
  64. package/dist/src/app/webui/.next/standalone/.next/server/chunks/195.js +24 -0
  65. package/dist/src/app/webui/.next/standalone/.next/server/chunks/620.js +1 -0
  66. package/dist/src/app/webui/.next/standalone/.next/server/chunks/80.js +5 -0
  67. package/dist/src/app/webui/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
  68. package/dist/src/app/webui/.next/standalone/.next/server/pages/500.html +1 -1
  69. package/dist/src/app/webui/.next/standalone/.next/server/pages-manifest.json +1 -2
  70. package/dist/src/app/webui/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  71. package/dist/src/app/webui/.next/standalone/.next/server/webpack-runtime.js +1 -1
  72. package/dist/src/app/webui/.next/standalone/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
  73. package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
  74. package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
  75. package/dist/src/app/webui/.next/standalone/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
  76. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
  77. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
  78. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
  79. package/dist/src/app/webui/.next/standalone/.next/static/css/af71306827be150e.css +3 -0
  80. package/dist/src/app/webui/.next/standalone/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
  81. package/dist/src/app/webui/.next/standalone/package.json +4 -3
  82. package/dist/src/app/webui/.next/standalone/public/favicon2.ico +0 -0
  83. package/dist/src/app/webui/.next/standalone/public/logo.svg +1 -0
  84. package/dist/src/app/webui/.next/standalone/public/logo_no_text.png +0 -0
  85. package/dist/src/app/webui/.next/standalone/server.js +1 -1
  86. package/dist/src/app/webui/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
  87. package/dist/src/app/webui/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
  88. package/dist/src/app/webui/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
  89. package/dist/src/app/webui/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
  90. package/dist/src/app/webui/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
  91. package/dist/src/app/webui/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
  92. package/dist/src/app/webui/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
  93. package/dist/src/app/webui/.next/static/css/af71306827be150e.css +3 -0
  94. package/dist/src/app/webui/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
  95. package/dist/src/app/webui/package.json +4 -3
  96. package/dist/src/app/webui/public/favicon2.ico +0 -0
  97. package/dist/src/app/webui/public/logo.svg +1 -0
  98. package/dist/src/app/webui/public/logo_no_text.png +0 -0
  99. package/dist/src/core/chunk-7A6NQKQ3.js +193 -0
  100. package/dist/src/core/chunk-CZIXQNMZ.js +12191 -0
  101. package/dist/src/core/index.cjs +10605 -8030
  102. package/dist/src/core/index.d.cts +4339 -3927
  103. package/dist/src/core/index.d.ts +4339 -3927
  104. package/dist/src/core/index.js +113 -8381
  105. package/dist/src/core/{postgres-backend-ERZ6DP76.js → postgres-backend-LOLKTD2T.js} +9 -2
  106. package/dist/src/core/{redis-backend-46O7Y44C.js → redis-backend-APZ576PJ.js} +35 -10
  107. package/dist/src/core/sqlite-backend-KQ75DPR7.js +245 -0
  108. package/package.json +18 -11
  109. package/dist/src/app/chunk-W7G44EAE.js +0 -463
  110. package/dist/src/app/sqlite-backend-VRXGIKHQ.js +0 -180
  111. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.html +0 -1
  112. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.meta +0 -8
  113. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.rsc +0 -21
  114. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js +0 -1
  115. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js.nft.json +0 -1
  116. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.body +0 -0
  117. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.meta +0 -1
  118. package/dist/src/app/webui/.next/standalone/.next/server/app/index.html +0 -1
  119. package/dist/src/app/webui/.next/standalone/.next/server/app/index.meta +0 -7
  120. package/dist/src/app/webui/.next/standalone/.next/server/app/index.rsc +0 -22
  121. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.html +0 -1
  122. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.meta +0 -7
  123. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.rsc +0 -25
  124. package/dist/src/app/webui/.next/standalone/.next/server/chunks/447.js +0 -20
  125. package/dist/src/app/webui/.next/standalone/.next/server/chunks/504.js +0 -1
  126. package/dist/src/app/webui/.next/standalone/.next/server/chunks/54.js +0 -5
  127. package/dist/src/app/webui/.next/standalone/.next/server/chunks/624.js +0 -1
  128. package/dist/src/app/webui/.next/standalone/.next/server/chunks/985.js +0 -5
  129. package/dist/src/app/webui/.next/standalone/.next/server/pages/404.html +0 -1
  130. package/dist/src/app/webui/.next/standalone/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
  131. package/dist/src/app/webui/.next/standalone/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
  132. package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
  133. package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
  134. package/dist/src/app/webui/.next/standalone/.next/static/chunks/687-3e614f30982093f6.js +0 -1
  135. package/dist/src/app/webui/.next/standalone/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
  136. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
  137. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
  138. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
  139. package/dist/src/app/webui/.next/standalone/.next/static/css/d44f09bc2605dc76.css +0 -3
  140. package/dist/src/app/webui/.next/standalone/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js +0 -19
  141. package/dist/src/app/webui/.next/standalone/public/favicon.svg +0 -26
  142. package/dist/src/app/webui/.next/standalone/public/logo.png +0 -0
  143. package/dist/src/app/webui/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
  144. package/dist/src/app/webui/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
  145. package/dist/src/app/webui/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
  146. package/dist/src/app/webui/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
  147. package/dist/src/app/webui/.next/static/chunks/687-3e614f30982093f6.js +0 -1
  148. package/dist/src/app/webui/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
  149. package/dist/src/app/webui/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
  150. package/dist/src/app/webui/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
  151. package/dist/src/app/webui/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
  152. package/dist/src/app/webui/.next/static/css/d44f09bc2605dc76.css +0 -3
  153. package/dist/src/app/webui/public/favicon.svg +0 -26
  154. package/dist/src/app/webui/public/logo.png +0 -0
  155. package/dist/src/core/chunk-6VYPSHEV.js +0 -2153
  156. package/dist/src/core/chunk-BYHW25EA.js +0 -41
  157. package/dist/src/core/sqlite-backend-M2ZPSSIZ.js +0 -184
  158. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
  159. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
  160. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
  161. /package/dist/src/app/webui/.next/standalone/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
  162. /package/dist/src/app/webui/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
  163. /package/dist/src/app/webui/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
  164. /package/dist/src/app/webui/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
  165. /package/dist/src/app/webui/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[177],{3140:(e,n,t)=>{"use strict";t.d(n,{SpeechReset:()=>s});var i=t(2115);function s(){return(0,i.useEffect)(()=>{let e=()=>{try{"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch(e){}};e();let n=()=>{"hidden"===document.visibilityState&&e()};return window.addEventListener("pagehide",e),window.addEventListener("beforeunload",e),document.addEventListener("visibilitychange",n),()=>{window.removeEventListener("pagehide",e),window.removeEventListener("beforeunload",e),document.removeEventListener("visibilitychange",n)}},[]),null}},5688:e=>{e.exports={style:{fontFamily:"'Geist', 'Geist Fallback'",fontStyle:"normal"},className:"__className_5cfdac",variable:"__variable_5cfdac"}},9324:()=>{},9432:e=>{e.exports={style:{fontFamily:"'Geist Mono', 'Geist Mono Fallback'",fontStyle:"normal"},className:"__className_9a8899",variable:"__variable_9a8899"}},9546:(e,n,t)=>{Promise.resolve().then(t.bind(t,6487)),Promise.resolve().then(t.bind(t,3140)),Promise.resolve().then(t.t.bind(t,5688,23)),Promise.resolve().then(t.t.bind(t,9432,23)),Promise.resolve().then(t.t.bind(t,9324,23))}},e=>{var n=n=>e(e.s=n);e.O(0,[261,487,441,684,358],()=>n(9546)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{7067:(e,t,s)=>{"use strict";s.d(t,{default:()=>ts});var r,a=s(5155),n=s(2115),l=s(6487),i=s(3999),o=s(5604),c=s(1243),d=s(7863),m=s(6474),u=s(4416),x=s(5196),h=s(4357),p=s(7833);function f(e){let{delayDuration:t=0,...s}=e;return(0,a.jsx)(p.Kq,{"data-slot":"tooltip-provider",delayDuration:t,...s})}function g(e){let{...t}=e;return(0,a.jsx)(f,{children:(0,a.jsx)(p.bL,{"data-slot":"tooltip",...t})})}function v(e){let{...t}=e;return(0,a.jsx)(p.l9,{"data-slot":"tooltip-trigger",...t})}function j(e){let{className:t,sideOffset:s=0,children:r,...n}=e;return(0,a.jsx)(p.ZL,{children:(0,a.jsxs)(p.UC,{"data-slot":"tooltip-content",sideOffset:s,className:(0,i.cn)("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t),...n,children:[r,(0,a.jsx)(p.i3,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}var b=s(7168);let y=(0,n.forwardRef)((e,t)=>{let{children:s,tooltip:r,side:n="bottom",className:l,...o}=e;return(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsxs)(b.$,{variant:"ghost",size:"icon",...o,className:(0,i.cn)("size-6 p-1",l),ref:t,children:[s,(0,a.jsx)("span",{className:"sr-only",children:r})]})}),(0,a.jsx)(j,{side:n,children:r})]})});function w(e){let{value:t,tooltip:s="Copy",copiedTooltip:r="Copied!",className:l,size:i=12}=e,[o,c]=(0,n.useState)(!1);return(0,a.jsx)(y,{tooltip:o?r:s,onClick:()=>{navigator.clipboard.writeText(t).then(()=>{c(!0),setTimeout(()=>c(!1),2e3)}).catch(()=>{})},className:l,children:o?(0,a.jsx)(x.A,{size:i}):(0,a.jsx)(h.A,{size:i})})}y.displayName="TooltipIconButton";var N=s(8979),k=s(5273);class C{get supported(){return"speechSynthesis"in window&&"SpeechSynthesisUtterance"in window}isSpeaking(){return this._speaking}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}subscribeVoices(e){return this.voiceSubscribers.add(e),()=>{this.voiceSubscribers.delete(e)}}notify(){for(let e of this.subscribers)try{e()}catch(e){}}stop(){if(this.supported){try{window.speechSynthesis.cancel()}catch(e){}this.utterance=null,this._speaking&&(this._speaking=!1,this.notify())}}speak(e,t){if(!this.supported||!e||!e.trim())return;this.stop();let s=new window.SpeechSynthesisUtterance(e);(null==t?void 0:t.rate)!=null&&(s.rate=t.rate),(null==t?void 0:t.pitch)!=null&&(s.pitch=t.pitch);let r=this.resolveVoice();if(r)try{s.voice=r,(null==t?void 0:t.lang)?s.lang=t.lang:r.lang&&(s.lang=r.lang)}catch(e){}else(null==t?void 0:t.lang)&&(s.lang=t.lang);s.onstart=()=>{this.utterance===s&&(this._speaking=!0,this.notify())};let a=()=>{this.utterance===s&&(this._speaking=!1,this.utterance=null,this.notify())};s.onend=a,s.onerror=a;try{this.utterance=s,window.speechSynthesis.speak(s),this._speaking||(this._speaking=!0,this.notify())}catch(e){a()}}getVoices(){return this.voices}setPreferredVoice(e){this.preferredVoiceName=e&&e.length?e:null;try{this.preferredVoiceName?window.localStorage.setItem("ttsVoiceName",this.preferredVoiceName):window.localStorage.removeItem("ttsVoiceName")}catch(e){}this.voiceSubscribers.forEach(e=>e())}getPreferredVoiceName(){return this.preferredVoiceName}resolveVoice(){if(!this.voices.length)return null;let e=this.preferredVoiceName?this.voices.find(e=>e.name===this.preferredVoiceName):null;if(e)return e;let t=this.voices.find(e=>{var t;return"google uk english female"===e.name.toLowerCase()||e.name.toLowerCase().includes("google uk english female")&&(null==(t=e.lang)?void 0:t.toLowerCase().startsWith("en-gb"))});if(t)return t;let s=e=>{var t;let s=e.name.toLowerCase(),r=(null!=(t=e.lang)?t:"").toLowerCase(),a=0;return("en"===r||r.startsWith("en-"))&&(a+=3),s.includes("google")&&(a+=5),(s.includes("microsoft")||s.includes("azure"))&&(a+=4),(s.includes("natural")||s.includes("neural")||s.includes("premium"))&&(a+=4),s.includes("siri")&&(a+=3),s.includes("female")&&(a+=1),a};return[...this.voices].sort((e,t)=>s(t)-s(e))[0]||this.voices[0]||null}constructor(){if(this._speaking=!1,this.subscribers=new Set,this.utterance=null,this.voices=[],this.voiceSubscribers=new Set,this.preferredVoiceName=null,this.supported){try{let e=window.localStorage.getItem("ttsVoiceName");this.preferredVoiceName=e&&e.length?e:null}catch(e){}let e=()=>{try{let e=window.speechSynthesis.getVoices()||[];(e.length!==this.voices.length||e.some((e,t)=>{var s;return e.name!==(null==(s=this.voices[t])?void 0:s.name)}))&&(this.voices=e,this.voiceSubscribers.forEach(e=>e()))}catch(e){}};e();try{window.speechSynthesis.addEventListener("voiceschanged",e)}catch(e){}}}}let S=globalThis,A=null!=(r=S.__speechController)?r:S.__speechController=new C;function E(e){let{value:t,tooltip:s="Speak",stopTooltip:r="Stop",className:l,rate:i=1,pitch:o=1,lang:c}=e,[d,m]=(0,n.useState)(!1),u=A.supported,x=(null!=t?t:"").trim().length>0;return(0,n.useEffect)(()=>(m(A.isSpeaking()),A.subscribe(()=>m(A.isSpeaking()))),[]),(0,a.jsx)(y,{tooltip:d?r:s,onClick:()=>{if(u&&x){if(d)return A.stop();A.speak(t,{rate:i,pitch:o,lang:c})}},className:l,disabled:!u||!x,children:d?(0,a.jsx)(N.A,{size:12}):(0,a.jsx)(k.A,{size:12})})}function T(e){var t;let{error:s,onDismiss:r}=e,[l,i]=(0,n.useState)(!1),o=null==(t=s.detailedIssues)?void 0:t[0],x=(null==o?void 0:o.context)&&"object"==typeof o.context&&"detailedIssues"in o.context?o.context.detailedIssues:[],h=x.length>0?"".concat(s.message,"\n\nDetails:\n").concat(x.map(e=>{let t=e.message;if(e.context){let s="string"==typeof e.context?e.context:JSON.stringify(e.context,null,2);t+="\nContext: ".concat(s)}return t}).join("\n\n")):s.message;return(0,a.jsx)("div",{className:"w-full rounded-lg p-4 mb-4 border shadow-sm bg-destructive/10 border-destructive/40",children:(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)(c.A,{className:"h-5 w-5 text-destructive mt-0.5 flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-destructive",children:"Error"}),s.context&&(0,a.jsx)("span",{className:"text-xs bg-destructive/15 text-destructive px-2 py-0.5 rounded-full",children:s.context})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[x.length>0&&(0,a.jsx)("button",{onClick:()=>i(!l),className:"p-1 hover:bg-destructive/15 rounded text-destructive",title:l?"Collapse":"Expand",children:l?(0,a.jsx)(d.A,{className:"h-4 w-4"}):(0,a.jsx)(m.A,{className:"h-4 w-4"})}),(0,a.jsx)(w,{value:h,tooltip:"Copy error",className:"p-1 hover:bg-destructive/15 rounded text-destructive",size:16}),(0,a.jsx)(E,{value:h,tooltip:"Read error",className:"p-1 hover:bg-destructive/15 rounded text-destructive"}),(0,a.jsx)("button",{onClick:r,className:"p-1 hover:bg-destructive/15 rounded text-destructive",title:"Dismiss",children:(0,a.jsx)(u.A,{className:"h-4 w-4"})})]})]}),(0,a.jsx)("div",{className:"mt-2 text-sm text-destructive",children:s.message}),l&&x.length>0&&(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)("div",{className:"text-xs text-destructive bg-destructive/10 p-3 rounded border border-destructive/30 overflow-auto max-h-60",children:x.map((e,t)=>(0,a.jsxs)("div",{className:"mb-2 last:mb-0",children:[(0,a.jsx)("div",{className:"font-medium",children:e.message}),null!=e.context&&(0,a.jsx)("div",{className:"text-destructive/70 mt-1",children:"string"==typeof e.context?e.context:JSON.stringify(e.context,null,2)})]},t))})})]})]})})}var D=s(1007),R=s(5657),I=s(8313),O=s(9376),L=s(3052),F=s(646),P=s(1154),z=s(5517),q=s(9890),U=s(7213),J=s(4481),_=s(8240),K=s(4823);let $=(0,n.memo)(e=>{let{children:t}=e;return(0,a.jsx)("div",{className:"prose max-w-none dark:prose-invert [&>p]:my-5 [&>p]:leading-7 [&>p]:first:mt-0 [&>p]:last:mb-0 [&>h1]:mb-8 [&>h1]:text-4xl [&>h1]:font-extrabold [&>h1]:tracking-tight [&>h1]:last:mb-0 [&>h2]:mb-4 [&>h2]:mt-8 [&>h2]:text-3xl [&>h2]:font-semibold [&>h2]:tracking-tight [&>h2]:first:mt-0 [&>h2]:last:mb-0 [&>h3]:mb-4 [&>h3]:mt-6 [&>h3]:text-2xl [&>h3]:font-semibold [&>h3]:tracking-tight [&>h3]:first:mt-0 [&>h3]:last:mb-0 [&>h4]:mb-4 [&>h4]:mt-6 [&>h4]:text-xl [&>h4]:font-semibold [&>h4]:tracking-tight [&>h4]:first:mt-0 [&>h4]:last:mb-0 [&>ul]:my-5 [&>ul]:ml-6 [&>ul]:list-disc [&>ul>li]:mt-2 [&>ol]:my-5 [&>ol]:ml-6 [&>ol]:list-decimal [&>ol>li]:mt-2 [&_ul]:my-5 [&_ul]:ml-6 [&_ul]:list-disc [&_ul>li]:mt-2 [&_ol]:my-5 [&_ol]:ml-6 [&_ol]:list-decimal [&_ol>li]:mt-2 [&>blockquote]:border-l-2 [&>blockquote]:pl-6 [&>blockquote]:italic [&>hr]:my-5 [&>hr]:border-b",children:(0,a.jsx)(_.oz,{remarkPlugins:[K.A],skipHtml:!0,components:{table:e=>{let{className:t,children:s,...r}=e;return(0,a.jsx)("div",{className:"my-4 overflow-x-auto -mx-1 px-1",children:(0,a.jsx)("table",{className:["w-full border-separate border-spacing-0",t].filter(Boolean).join(" "),...r,children:s})})},thead:e=>{let{className:t,...s}=e;return(0,a.jsx)("thead",{className:t,...s})},tr:e=>{let{className:t,...s}=e;return(0,a.jsx)("tr",{className:["m-0 border-b first:border-t","[&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",t].filter(Boolean).join(" "),...s})},th:e=>{let{className:t,...s}=e;return(0,a.jsx)("th",{className:["bg-muted text-left font-bold align-top","px-4 py-2 first:rounded-tl-lg last:rounded-tr-lg","[&[align=center]]:text-center [&[align=right]]:text-right",t].filter(Boolean).join(" "),...s})},td:e=>{let{className:t,...s}=e;return(0,a.jsx)("td",{className:["border-b border-l last:border-r text-left align-top","px-4 py-2 whitespace-normal break-words","[&[align=center]]:text-center [&[align=right]]:text-right",t].filter(Boolean).join(" "),...s})},code:e=>{let{className:t,children:s,...r}=e,[l,i]=(0,n.useState)(!1),o=String(null!=s?s:"").replace(/\n$/,"");return t?(0,a.jsxs)("div",{className:"relative group my-4",children:[(0,a.jsx)(y,{tooltip:l?"Copied!":"Copy code",onClick:()=>{navigator.clipboard.writeText(o).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},className:"absolute right-2 top-2 z-10 opacity-70 hover:opacity-100 transition-opacity bg-background/80 hover:bg-background",children:l?(0,a.jsx)(x.A,{size:14}):(0,a.jsx)(h.A,{size:14})}),(0,a.jsx)("pre",{className:"overflow-auto bg-muted p-3 rounded-lg text-sm",children:(0,a.jsx)("code",{className:t,children:o})})]}):(0,a.jsx)("code",{className:"text-xs px-1.5 py-0.5 bg-muted rounded font-mono",...r,children:s})}},children:t})})}),M=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function V(e){return/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/i.test(e)}function B(e){try{let t=new URL(e);return("https:"===t.protocol||"http:"===t.protocol)&&"localhost"!==t.hostname}catch(e){return!1}}function G(e){var t,s;if(e.base64&&e.mimeType)return"data:".concat(e.mimeType,";base64,").concat(e.base64);if("string"==typeof e.base64)return e.base64;let r=null!=(s=null!=(t=e.url)?t:e.image)?s:e.audio;return"string"==typeof r?r:""}function H(e){let{messages:t,activeError:s,onDismissError:r,outerRef:l}=e,x=(0,n.useRef)(null),[h,p]=(0,n.useState)({}),[f,b]=(0,n.useState)({}),[y,N]=(0,n.useState)(null);(0,n.useRef)(null);let[C,S]=(0,n.useState)({isOpen:!1,src:"",alt:""});(0,n.useEffect)(()=>{let e=document.createElement("style");return e.textContent="\n .audio-controls-container audio {\n max-width: 100% !important;\n width: 100% !important;\n height: auto !important;\n min-height: 32px;\n }\n .audio-controls-container audio::-webkit-media-controls-panel {\n max-width: 100% !important;\n }\n .audio-controls-container audio::-webkit-media-controls-timeline {\n max-width: 100% !important;\n }\n ",document.head.appendChild(e),()=>{document.head.removeChild(e)}},[]);let A=(e,t)=>{S({isOpen:!0,src:e,alt:t})};if(!t||0===t.length)return null;let _=e=>"string"==typeof e.content?e.content:Array.isArray(e.content)?e.content.map(e=>(0,o.PI)(e)?e.text:"").filter(Boolean).join("\n"):e.content&&"object"==typeof e.content?JSON.stringify(e.content,null,2):"",K=e=>e?(0,o.KU)(e)?"object"==typeof e.error?JSON.stringify(e.error,null,2):String(e.error):(0,o.P2)(e)?e.content.map(e=>(0,o.PI)(e)?e.text:"object"==typeof e?"":String(e)).filter(Boolean).join("\n"):"object"==typeof e?JSON.stringify(e,null,2):String(e):"";return(0,a.jsxs)("div",{id:"message-list-container",ref:l,className:"flex flex-col space-y-3 px-4 py-2",children:[t.map((e,n)=>{var l,u,x,y;let N=null!=(u=e.id)?u:"msg-".concat(n),C="user"===e.role,S="assistant"===e.role,H="system"===e.role,W=n===t.length-1,Q=!!(e.toolName&&e.toolArgs),Y=!!(e.toolName&&e.toolResult),Z=Q||Y,X=Z&&W||!!h[N],ee=[],et=[];Y&&e.toolResult&&(0,o.P2)(e.toolResult)&&e.toolResult.content.forEach((e,t)=>{if((0,o.j0)(e)){let s=G(e);s&&(s.startsWith("data:")&&V(s)||s.startsWith("blob:")||B(s))&&ee.push({src:s,alt:"Tool result image ".concat(t+1),index:t})}else if((0,o.kz)(e)){let s=G(e);s&&(s.startsWith("data:audio/")||s.startsWith("blob:")||B(s))&&et.push({src:s,filename:e.filename,index:t})}});let es=C?D.A:R.A,er=(0,i.cn)(C?"grid w-full grid-cols-[1fr_auto] gap-x-2 items-start":"grid w-full grid-cols-[auto_1fr] gap-x-2 items-start"),ea=(0,i.cn)("tool"===e.role?"w-full text-muted-foreground/70 bg-secondary border border-muted/30 rounded-md text-base":C?"p-3 rounded-xl shadow-sm w-fit max-w-[75%] bg-primary text-primary-foreground rounded-br-none text-base break-normal hyphens-none":S?"p-3 rounded-xl shadow-sm w-fit max-w-[90%] bg-card text-card-foreground border border-border rounded-bl-none text-base break-normal hyphens-none":H?"p-3 shadow-none w-full bg-transparent text-xs text-muted-foreground italic text-center border-none":""),en=M(e.createdAt),el=!!(s&&s.anchorMessageId===e.id);return(0,a.jsxs)("div",{className:"w-full","data-role":e.role,id:e.id?"message-".concat(e.id):void 0,children:[(0,a.jsxs)("div",{className:er,children:[S&&(0,a.jsx)(es,{className:"h-7 w-7 mt-1 text-muted-foreground col-start-1"}),"tool"===e.role&&(0,a.jsx)(I.A,{className:"h-7 w-7 p-1 mt-1 rounded-full border border-border text-muted-foreground col-start-1"}),(0,a.jsxs)("div",{className:(0,i.cn)("flex flex-col group w-full",H?"col-span-2 items-center":C?"col-start-1 justify-self-end items-end":"col-start-2 justify-self-start items-start"),children:[(0,a.jsx)("div",{className:ea,children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[S&&"string"==typeof e.reasoning&&e.reasoning.trim().length>0&&(0,a.jsxs)("div",{className:"mb-3 border border-orange-200/50 dark:border-orange-400/20 rounded-lg bg-gradient-to-br from-orange-50/30 to-amber-50/20 dark:from-orange-900/20 dark:to-amber-900/10",children:[(0,a.jsxs)("div",{className:"px-3 py-2 border-b border-orange-200/30 dark:border-orange-400/20 bg-orange-100/50 dark:bg-orange-900/30 rounded-t-lg flex items-center justify-between",children:[(0,a.jsxs)("button",{type:"button",className:"flex items-center gap-2 text-xs font-medium text-orange-700 dark:text-orange-300 hover:text-orange-800 dark:hover:text-orange-200 transition-colors group",onClick:()=>b(t=>({...t,[e.id]:!t[e.id]})),children:[(0,a.jsx)(O.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{children:"AI Reasoning"}),null==(x=f[e.id])||x?(0,a.jsx)(d.A,{className:"h-3 w-3 group-hover:scale-110 transition-transform"}):(0,a.jsx)(m.A,{className:"h-3 w-3 group-hover:scale-110 transition-transform"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(w,{value:e.reasoning,tooltip:"Copy reasoning",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,a.jsx)(E,{value:e.reasoning,tooltip:"Speak reasoning",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]}),(null==(y=f[e.id])||y)&&(0,a.jsx)("div",{className:"px-3 py-2",children:(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words text-xs text-orange-800/80 dark:text-orange-200/70 leading-relaxed font-mono",children:e.reasoning})})]}),e.toolName?(0,a.jsxs)("div",{className:"p-2 rounded border border-border bg-muted/30 hover:bg-muted/60 cursor-pointer w-full",onClick:()=>{Z&&p(e=>({...e,[N]:!e[N]}))},children:[(0,a.jsxs)("div",{className:"flex items-center justify-between text-xs font-medium",children:[(0,a.jsxs)("span",{className:"flex items-center",children:[X?(0,a.jsx)(d.A,{className:"h-4 w-4 mr-2 text-primary"}):(0,a.jsx)(L.A,{className:"h-4 w-4 mr-2 text-primary"}),"Tool: ",e.toolName]}),e.toolResult?(0,o.KU)(e.toolResult)?(0,a.jsx)(c.A,{className:"mx-2 h-4 w-4 text-red-500"}):(0,a.jsx)(F.A,{className:"mx-2 h-4 w-4 text-green-500"}):(0,a.jsx)(P.A,{className:"mx-2 h-4 w-4 animate-spin text-muted-foreground"})]}),X&&(0,a.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs font-medium",children:"Arguments:"}),(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(e.toolArgs,null,2)})]}),e.toolResult&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"text-xs font-medium flex items-center justify-between",onClick:e=>e.stopPropagation(),children:[(0,a.jsx)("span",{children:"Result:"}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(w,{value:K(e.toolResult),tooltip:"Copy result",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,a.jsx)(E,{value:K(e.toolResult),tooltip:"Speak result",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]}),(0,o.KU)(e.toolResult)?(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-red-100 text-red-700 p-2 rounded text-xs",children:"object"==typeof e.toolResult.error?JSON.stringify(e.toolResult.error,null,2):String(e.toolResult.error)}):(0,o.P2)(e.toolResult)?e.toolResult.content.map((e,t)=>(0,o.j0)(e)||(0,o.kz)(e)?null:(0,o.PI)(e)?(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:e.text},t):(0,o.EQ)(e)?(0,a.jsxs)("div",{className:"my-1 flex items-center gap-2 p-2 rounded border border-border bg-muted/50",children:[(0,a.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.filename||"File attachment"," (",e.mimeType,")"]})]},t):(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground my-1",children:"object"==typeof e?JSON.stringify(e,null,2):String(e)},t)):(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:"string"==typeof e.toolResult&&e.toolResult.startsWith("data:image")?V(e.toolResult)?(0,a.jsx)("img",{src:e.toolResult,alt:"Tool result image",className:"my-1 max-h-48 w-auto rounded border border-border"}):"Invalid image data":"object"==typeof e.toolResult?JSON.stringify(e.toolResult,null,2):String(e.toolResult)})]})]})]}):(0,a.jsxs)(a.Fragment,{children:["string"==typeof e.content&&""!==e.content.trim()&&(0,a.jsx)("div",{className:"relative",children:C?(0,a.jsx)("p",{className:"text-base whitespace-pre-line break-normal",children:e.content}):(0,a.jsx)($,{children:e.content})}),e.content&&"object"==typeof e.content&&!Array.isArray(e.content)&&(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words overflow-auto bg-background/50 p-2 rounded text-xs text-muted-foreground",children:JSON.stringify(e.content,null,2)}),Array.isArray(e.content)&&e.content.map((e,t)=>{let s="".concat(N,"-part-").concat(t);if("text"===e.type)return(0,a.jsx)("div",{className:"relative",children:C?(0,a.jsx)("p",{className:"text-base whitespace-pre-line break-normal",children:e.text}):(0,a.jsx)($,{children:e.text})},s);if((0,o.EQ)(e)){if(!e.mimeType.startsWith("audio/"))return(0,a.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,a.jsx)(q.A,{className:"h-5 w-5 text-muted-foreground"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:e.filename||"".concat(e.mimeType," file")}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.mimeType})]},s);{let t="data:".concat(e.mimeType,";base64,").concat(e.data);return(0,a.jsxs)("div",{className:"my-2 flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,a.jsx)(z.A,{className:"h-5 w-5 text-muted-foreground"}),(0,a.jsx)("audio",{controls:!0,src:t,className:"flex-1 h-8"}),e.filename&&(0,a.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:e.filename})]},s)}}return null}),H&&!e.content&&(0,a.jsx)("p",{className:"italic",children:"System message"})]}),e.imageData&&!Array.isArray(e.content)&&(()=>{let t="data:".concat(e.imageData.mimeType,";base64,").concat(e.imageData.base64);return V(t)?(0,a.jsx)("img",{src:t,alt:"attachment",className:"mt-2 max-h-60 w-full rounded-lg border border-border object-contain"}):null})(),e.fileData&&!Array.isArray(e.content)&&(0,a.jsx)("div",{className:"mt-2",children:e.fileData.mimeType.startsWith("audio/")?(0,a.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,a.jsx)(z.A,{className:"h-5 w-5 text-muted-foreground"}),(0,a.jsx)("audio",{controls:!0,src:"data:".concat(e.fileData.mimeType,";base64,").concat(e.fileData.base64),className:"flex-1 h-8"}),e.fileData.filename&&(0,a.jsx)("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:e.fileData.filename})]}):(0,a.jsxs)("div",{className:"flex items-center gap-2 p-3 rounded-lg border border-border bg-muted/50",children:[(0,a.jsx)(q.A,{className:"h-5 w-5 text-muted-foreground"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:e.fileData.filename||"".concat(e.fileData.mimeType," file")}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.fileData.mimeType})]})})]})}),!H&&!Z&&(0,a.jsxs)("div",{className:"text-xs text-muted-foreground mt-1 px-1 flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{children:en}),S&&(null==(l=e.tokenUsage)?void 0:l.totalTokens)!==void 0&&(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/50 text-xs cursor-default",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-green-500"}),e.tokenUsage.totalTokens," tokens"]})}),(0,a.jsx)(j,{children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[void 0!==e.tokenUsage.inputTokens&&(0,a.jsxs)("div",{children:["Input: ",e.tokenUsage.inputTokens]}),void 0!==e.tokenUsage.outputTokens&&(0,a.jsxs)("div",{children:["Output: ",e.tokenUsage.outputTokens]}),void 0!==e.tokenUsage.reasoningTokens&&(0,a.jsxs)("div",{children:["Reasoning: ",e.tokenUsage.reasoningTokens]}),(0,a.jsxs)("div",{className:"font-medium mt-0.5",children:["Total: ",e.tokenUsage.totalTokens]})]})})]}),S&&e.model&&(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{children:(0,a.jsx)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/30 text-xs cursor-default",children:e.model})}),(0,a.jsx)(j,{children:(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("div",{className:"font-medium",children:["Model: ",e.model]}),e.router&&(0,a.jsxs)("div",{className:"text-muted-foreground",children:["Router: ",e.router]})]})})]})]}),(S||C)&&(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(w,{value:_(e),tooltip:"Copy message",copiedTooltip:"Copied!",className:"opacity-70 hover:opacity-100 transition-opacity"}),(0,a.jsx)(E,{value:_(e),tooltip:"Speak",stopTooltip:"Stop",className:"opacity-70 hover:opacity-100 transition-opacity"})]})]})]}),C&&(0,a.jsx)(es,{className:"h-7 w-7 mt-1 text-muted-foreground col-start-2"})]}),ee.map((e,t)=>(0,a.jsx)("div",{className:"w-full mt-2",children:(0,a.jsxs)("div",{className:"flex items-end w-full justify-start",children:[(0,a.jsx)(U.A,{className:"h-7 w-7 mr-2 mb-1 text-muted-foreground self-start flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex flex-col items-start",children:[(0,a.jsx)("div",{className:"p-3 rounded-xl shadow-sm max-w-[75%] bg-card text-card-foreground border border-border rounded-bl-none text-sm",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(U.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:"Tool Result Image"})]}),(0,a.jsxs)("div",{className:"relative group cursor-pointer",onClick:()=>A(e.src,e.alt),children:[(0,a.jsx)("img",{src:e.src,alt:e.alt,className:"max-h-80 w-auto rounded border border-border object-contain transition-transform group-hover:scale-[1.02]"}),(0,a.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors rounded border border-border flex items-center justify-center",children:(0,a.jsx)(J.A,{className:"h-8 w-8 text-white opacity-0 group-hover:opacity-100 transition-opacity drop-shadow-lg"})})]})]})}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground mt-1 px-1",children:(0,a.jsx)("span",{children:en})})]})]})},"".concat(N,"-image-").concat(t))),et.map((e,t)=>(0,a.jsx)("div",{className:"w-full mt-2",children:(0,a.jsxs)("div",{className:"flex items-end w-full justify-start",children:[(0,a.jsx)(k.A,{className:"h-7 w-7 mr-2 mb-1 text-muted-foreground self-start flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex flex-col items-start",children:[(0,a.jsx)("div",{className:"p-3 rounded-xl shadow-sm max-w-[75%] bg-card text-card-foreground border border-border rounded-bl-none text-sm overflow-hidden",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)(k.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:"Tool Result Audio"})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-2 p-2 rounded border border-border bg-muted/30 min-w-0 audio-controls-container",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)(z.A,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),(0,a.jsx)("audio",{controls:!0,src:e.src,className:"flex-1 min-w-0"})]}),e.filename&&(0,a.jsx)("div",{className:"flex items-center gap-2 min-w-0",children:(0,a.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:e.filename})})]})]})}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground mt-1 px-1",children:(0,a.jsx)("span",{children:en})})]})]})},"".concat(N,"-audio-").concat(t))),el&&(0,a.jsx)("div",{className:"mt-2 ml-12 mr-4",children:(0,a.jsx)(T,{error:s,onDismiss:r||(()=>{})})})]},N)}),(0,a.jsx)("div",{ref:x,className:"h-px"},"end-anchor"),C.isOpen&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,a.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh] bg-background rounded-lg shadow-2xl border border-border",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Tool Result Image"}),(0,a.jsx)("button",{onClick:()=>{S({isOpen:!1,src:"",alt:""})},className:"p-2 hover:bg-muted rounded-md transition-colors","aria-label":"Close modal",children:(0,a.jsx)(u.A,{className:"h-5 w-5"})})]}),(0,a.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,a.jsx)("img",{src:C.src,alt:C.alt,className:"max-w-full max-h-[70vh] object-contain rounded"})}),(0,a.jsx)("div",{className:"p-4 border-t border-border text-sm text-muted-foreground",children:(0,a.jsx)("p",{children:C.alt})})]})})]})}var W=s(5958);function Q(e){let{children:t,className:s}=e;return(0,a.jsx)("div",{className:(0,i.cn)("relative","w-full","flex flex-col overflow-hidden","max-h-[max(35svh,5rem)]","border-2 border-border/50","bg-background","rounded-3xl shadow-sm","transition-all duration-200",s),children:t})}function Y(e){let{leftButtons:t,rightButtons:s,className:r}=e;return(0,a.jsxs)("div",{className:(0,i.cn)("flex items-center justify-between","h-12 px-2",r),children:[(0,a.jsx)("div",{className:"flex items-center gap-2",children:t}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:s})]})}var Z=s(1539),X=s(6225);let ee=n.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(X.bL,{className:(0,i.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s),...r,ref:t,children:(0,a.jsx)(X.zi,{className:(0,i.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})})});function et(e){let{isStreaming:t,onStreamingChange:s,className:r}=e;return(0,a.jsx)(f,{children:(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsxs)("div",{className:"flex items-center gap-1.5 cursor-pointer ".concat(r||""),children:[(0,a.jsx)(Z.A,{className:"h-3 w-3 ".concat(t?"text-blue-500":"text-muted-foreground")}),(0,a.jsx)(ee,{checked:t,onCheckedChange:s,className:"scale-75","aria-label":"Toggle streaming"})]})}),(0,a.jsxs)(j,{side:"top",children:[(0,a.jsx)("p",{children:t?"Streaming enabled":"Streaming disabled"}),(0,a.jsx)("p",{className:"text-xs opacity-75",children:t?"Responses will stream in real-time":"Responses will arrive all at once"})]})]})})}ee.displayName=X.bL.displayName;var es=s(791);function er(e){let{...t}=e;return(0,a.jsx)(es.bL,{"data-slot":"popover",...t})}function ea(e){let{className:t,align:s="center",sideOffset:r=4,...n}=e;return(0,a.jsx)(es.ZL,{children:(0,a.jsx)(es.UC,{"data-slot":"popover-content",align:s,sideOffset:r,className:(0,i.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...n})})}let en=e=>{let{children:t,...s}=e;return(0,a.jsx)(er,{...s,children:t})},el=function(e){let{...t}=e;return(0,a.jsx)(es.l9,{"data-slot":"popover-trigger",...t})},ei=n.forwardRef((e,t)=>{let{className:s,align:r="end",sideOffset:n=4,...l}=e;return(0,a.jsx)(ea,{ref:t,align:r,sideOffset:n,className:(0,i.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...l})});ei.displayName="DropdownMenuContent";let eo=n.forwardRef((e,t)=>{let{className:s,disabled:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r&&"pointer-events-none opacity-50",!r&&"hover:bg-accent hover:text-accent-foreground cursor-pointer",s),...n})});eo.displayName="DropdownMenuItem";let ec=n.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("-mx-1 my-1 h-px bg-muted",s),...r})});function ed(e){var t;let{currentModel:s,isLoading:r,models:n,onModelChange:l,className:o}=e;return(0,a.jsxs)(en,{children:[(0,a.jsx)(el,{asChild:!0,children:(0,a.jsxs)(b.$,{variant:"ghost",size:"sm",className:(0,i.cn)("h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full",o),disabled:r,children:[(0,a.jsx)(R.A,{className:"h-3 w-3 mr-1.5"}),(0,a.jsx)("span",{className:"hidden sm:inline",children:r?"...":null!=(t=null==s?void 0:s.name)?t:"Select model"}),(0,a.jsx)(m.A,{className:"h-3 w-3 ml-1"})]})}),(0,a.jsx)(ei,{align:"end",children:n.map(e=>(0,a.jsxs)(eo,{onClick:()=>l(e),children:[(0,a.jsx)(R.A,{className:"h-4 w-4 mr-2"}),e.name]},e.model))})]})}ec.displayName="DropdownMenuSeparator";var em=s(492);function eu(e){let{onImageAttach:t,onPdfAttach:s,onAudioAttach:r,className:n}=e;return(0,a.jsxs)(en,{children:[(0,a.jsx)(el,{asChild:!0,children:(0,a.jsxs)(b.$,{variant:"ghost",size:"sm",className:"h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full ".concat(n||""),"aria-label":"Attach File",children:[(0,a.jsx)(em.A,{className:"h-3 w-3 mr-1.5"}),"Attach"]})}),(0,a.jsxs)(ei,{side:"top",align:"start",children:[(0,a.jsxs)(eo,{onClick:t,children:[(0,a.jsx)(em.A,{className:"h-4 w-4 mr-2"})," Image"]}),(0,a.jsxs)(eo,{onClick:s,children:[(0,a.jsx)(q.A,{className:"h-4 w-4 mr-2"})," PDF"]}),(0,a.jsxs)(eo,{onClick:r,children:[(0,a.jsx)(z.A,{className:"h-4 w-4 mr-2"})," Audio file"]})]})]})}var ex=s(2431),eh=s(9588);function ep(e){let{isRecording:t,onToggleRecording:s,className:r}=e;return(0,a.jsxs)(b.$,{variant:"ghost",size:"sm",onClick:s,className:"h-8 px-3 text-sm text-muted-foreground hover:text-foreground rounded-full ".concat(r||""),"aria-label":t?"Stop recording":"Record audio",children:[t?(0,a.jsx)(ex.A,{className:"h-3 w-3 mr-1.5 text-red-500"}):(0,a.jsx)(eh.A,{className:"h-3 w-3 mr-1.5"}),t?"Stop":"Record"]})}var ef=s(5339),eg=s(429),ev=s(9026);function ej(e){let{onSend:t,isSending:s,variant:r="chat"}=e,[i,o]=(0,n.useState)(""),c=(0,n.useRef)(null),[d,m]=(0,n.useState)(null),[x,h]=(0,n.useState)(null),p=(0,n.useRef)(null),f=(0,n.useRef)(null),g=(0,n.useRef)(null),v=function(){let[e,t]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if("undefined"==typeof document)return;let e=document;if(!e.fonts||!e.fonts.ready)return void t(!0);let s=!1;return e.fonts.ready.then(()=>{s||t(!0)}),()=>{s=!0}},[]),e}(),[j,y]=(0,n.useState)(!1),w=(0,n.useRef)(null),{currentSessionId:N,isStreaming:k,setStreaming:C}=(0,l.v)(),[S,A]=(0,n.useState)(null),[E,T]=(0,n.useState)(!1),[D,R]=(0,n.useState)(null),[I,O]=(0,n.useState)(null),L=[{name:"Claude 4 Sonnet",provider:"anthropic",model:"claude-4-sonnet-20250514"},{name:"GPT-4o",provider:"openai",model:"gpt-4o"},{name:"GPT-4.1 Mini",provider:"openai",model:"gpt-4.1-mini"},{name:"Gemini 2.5 Pro",provider:"google",model:"gemini-2.5-pro"}],F=e=>{O(e),setTimeout(()=>O(null),5e3)};(0,n.useEffect)(()=>{(async()=>{try{let e=N?"/api/llm/current?sessionId=".concat(N):"/api/llm/current",t=await fetch(e);if(t.ok){let e=await t.json(),s=L.find(t=>t.model===e.config.model);s?A(s):A({name:"".concat(e.config.provider,"/").concat(e.config.model),provider:e.config.provider,model:e.config.model})}}catch(e){console.error("Failed to fetch current model:",e),A(null)}})()},[N]);let U=()=>{let e=i.trim();(e||d||x)&&(t(e,null!=d?d:void 0,null!=x?x:void 0),o(""),m(null),h(null))},J=e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),U())},_=e=>{try{return btoa(unescape(encodeURIComponent(e)))}catch(t){return btoa(e)}},K=e=>{let t=e.clipboardData.getData("text/plain");if(t&&!(t.length<=2e4))if(e.preventDefault(),window.confirm("Large text detected. Attach as a file instead of inflating the input?\n(OK = attach as file, Cancel = paste truncated preview)"))h({base64:_(t),mimeType:"text/plain",filename:"pasted.txt"});else{let e=t.slice(0,2e4);o(t=>t+e)}},$=async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e);w.current=t;let s=[];t.ondataavailable=e=>{e.data.size>0&&s.push(e.data)},t.onstop=()=>{let r=new Blob(s,{type:t.mimeType}),a=new FileReader;a.onloadend=()=>{try{let e=a.result,s=e.indexOf(","),r=e.substring(s+1),n=t.mimeType||"audio/webm",l={"audio/mp3":"mp3","audio/mpeg":"mp3","audio/wav":"wav","audio/x-wav":"wav","audio/wave":"wav","audio/webm":"webm","audio/ogg":"ogg","audio/m4a":"m4a","audio/aac":"aac"}[n]||n.split("/")[1]||"webm";h({base64:r,mimeType:n,filename:"recording.".concat(l)})}catch(e){F("Failed to process audio recording. Please try again."),h(null)}},a.readAsDataURL(r),e.getTracks().forEach(e=>e.stop())},t.start(),y(!0)}catch(e){F("Failed to start audio recording. Please check microphone permissions.")}},M=async e=>{T(!0),R(null);try{let t={provider:e.provider,model:e.model};N&&(t.sessionId=N);let s=await fetch("/api/llm/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),r=await s.json();if(s.ok)A(e),R(null);else{let e="Failed to switch model";if(r.issues&&r.issues.length>0){let t=r.issues.filter(e=>"error"===e.severity);t.length>0&&(e=t[0].message)}else r.error&&(e=r.error);console.error("Failed to switch model:",e),R(e),setTimeout(()=>R(null),1e4)}}catch(e){console.error("Network error while switching model:",e),R("Network error while switching model"),setTimeout(()=>R(null),1e4)}finally{T(!1)}};return(0,n.useEffect)(()=>{i&&D&&R(null),i&&I&&O(null)},[i,D]),i.length,(0,a.jsxs)("div",{id:"input-area",className:"flex flex-col gap-2 w-full",children:[D&&(0,a.jsxs)(ev.Fc,{variant:"destructive",className:"mb-2",children:[(0,a.jsx)(ef.A,{className:"h-4 w-4"}),(0,a.jsxs)(ev.TN,{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:D}),(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>R(null),className:"h-auto p-1 ml-2",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]})]}),I&&(0,a.jsxs)(ev.Fc,{variant:"destructive",className:"mb-2",children:[(0,a.jsx)(ef.A,{className:"h-4 w-4"}),(0,a.jsxs)(ev.TN,{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{children:I}),(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>O(null),className:"h-auto p-1 ml-2",children:(0,a.jsx)(u.A,{className:"h-3 w-3"})})]})]}),(0,a.jsxs)("div",{className:"w-full",children:[(0,a.jsx)("form",{onSubmit:e=>{e.preventDefault(),U()},children:(0,a.jsxs)(Q,{children:[(d||x)&&(0,a.jsx)("div",{className:"px-4 pt-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,a.jsxs)("div",{className:"relative w-fit border border-border rounded-lg p-1 bg-muted/50 group",children:[(0,a.jsx)("img",{src:"data:".concat(d.mimeType,";base64,").concat(d.base64),alt:"preview",className:"h-12 w-auto rounded-md"}),(0,a.jsx)(b.$,{variant:"destructive",size:"icon",onClick:()=>m(null),className:"absolute -top-1 -right-1 h-4 w-4 rounded-full bg-destructive text-destructive-foreground opacity-100 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove image",children:(0,a.jsx)(u.A,{className:"h-2 w-2"})})]}),x&&(0,a.jsxs)("div",{className:"relative w-fit border border-border rounded-lg p-2 bg-muted/50 flex items-center gap-2 group",children:[x.mimeType.startsWith("audio")?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(z.A,{className:"h-4 w-4"}),(0,a.jsx)("audio",{controls:!0,src:"data:".concat(x.mimeType,";base64,").concat(x.base64),className:"h-8"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-xs font-medium max-w-[160px] truncate",children:x.filename||"attachment"})]}),(0,a.jsx)(b.$,{variant:"destructive",size:"icon",onClick:()=>h(null),className:"absolute -top-1 -right-1 h-4 w-4 rounded-full bg-destructive text-destructive-foreground opacity-100 group-hover:opacity-100 transition-opacity duration-150 shadow-md","aria-label":"Remove attachment",children:(0,a.jsx)(u.A,{className:"h-2 w-2"})})]})]})}),(0,a.jsx)("div",{className:"flex-auto overflow-y-auto",children:v?(0,a.jsx)(W.A,{ref:c,value:i,onChange:e=>o(e.target.value),onKeyDown:J,onPaste:K,placeholder:"Ask Dexto anything...",minRows:1,maxRows:8,className:"w-full px-4 pt-4 pb-1 text-lg leading-7 placeholder:text-lg bg-transparent border-none resize-none outline-none ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none max-h-full"}):(0,a.jsx)("textarea",{ref:c,rows:1,value:i,onChange:e=>o(e.target.value),onKeyDown:J,onPaste:K,placeholder:"Ask Dexto anything...",className:"w-full px-4 pt-4 pb-1 text-lg leading-7 placeholder:text-lg bg-transparent border-none resize-none outline-none ring-0 ring-offset-0 focus:ring-0 focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none"})}),(0,a.jsx)(Y,{leftButtons:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eu,{onImageAttach:()=>{var e;return null==(e=p.current)?void 0:e.click()},onPdfAttach:()=>{var e;return null==(e=f.current)?void 0:e.click()},onAudioAttach:()=>{var e;return null==(e=g.current)?void 0:e.click()}}),(0,a.jsx)(ep,{isRecording:j,onToggleRecording:j?()=>{var e;null==(e=w.current)||e.stop(),y(!1)}:$})]}),rightButtons:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(et,{isStreaming:k,onStreamingChange:C}),(0,a.jsx)(ed,{currentModel:S,isLoading:E,models:L,onModelChange:M}),(0,a.jsx)(b.$,{type:"submit",disabled:!i.trim()&&!d&&!x||s,className:"h-10 w-10 p-0 rounded-full shadow-sm hover:shadow-md transition-shadow","aria-label":"Send message",children:s?(0,a.jsx)(P.A,{className:"h-4 w-4 animate-spin"}):(0,a.jsx)(eg.A,{className:"h-4 w-4"})})]})})]})}),(0,a.jsx)("input",{ref:p,type:"file",id:"image-upload",accept:"image/*",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(!s)return;if(s.size>0x4000000){F("Image file too large. Maximum size is 64MB."),e.target.value="";return}if(!s.type.startsWith("image/")){F("Please select a valid image file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,t=e.indexOf(",");if(-1===t)throw Error("Invalid Data URL format");let a=e.substring(0,t),n=e.substring(t+1),l=a.match(/data:(.*);base64/),i=l?l[1]:s.type;if(!i)throw Error("Could not determine MIME type");m({base64:n,mimeType:i}),O(null)}catch(e){F("Failed to process image file. Please try again."),m(null)}},r.onerror=e=>{F("Failed to read image file. Please try again."),m(null)},r.readAsDataURL(s),e.target.value=""}}),(0,a.jsx)("input",{ref:f,type:"file",id:"pdf-upload",accept:"application/pdf",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(!s)return;if(s.size>0x4000000){F("PDF file too large. Maximum size is 64MB."),e.target.value="";return}if("application/pdf"!==s.type){F("Please select a valid PDF file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,t=e.indexOf(","),a=e.substring(t+1);h({base64:a,mimeType:"application/pdf",filename:s.name}),O(null)}catch(e){F("Failed to process PDF file. Please try again."),h(null)}},r.onerror=e=>{F("Failed to read PDF file. Please try again."),h(null)},r.readAsDataURL(s),e.target.value=""}}),(0,a.jsx)("input",{ref:g,type:"file",id:"audio-upload",accept:"audio/*",className:"hidden",onChange:e=>{var t;let s=null==(t=e.target.files)?void 0:t[0];if(!s)return;if(s.size>0x4000000){F("Audio file too large. Maximum size is 64MB."),e.target.value="";return}if(!s.type.startsWith("audio/")){F("Please select a valid audio file."),e.target.value="";return}let r=new FileReader;r.onloadend=()=>{try{let e=r.result,t=e.indexOf(","),a=e.substring(t+1);h({base64:a,mimeType:s.type,filename:s.name}),O(null)}catch(e){F("Failed to process audio file. Please try again."),h(null)}},r.onerror=e=>{F("Failed to read audio file. Please try again."),h(null)},r.readAsDataURL(s),e.target.value=""}})]})]})}var eb=s(8861);class ey{static getInstance(){return ey.instance||(ey.instance=new ey),ey.instance}async initialize(){this.isInitialized||(this.registryEntries=this.getBuiltinEntries(),await this.loadCustomEntries(),this.isInitialized=!0)}async getEntries(e){var t;await this.initialize();let s=[...this.registryEntries];if((null==e?void 0:e.category)&&(s=s.filter(t=>t.category===e.category)),(null==e||null==(t=e.tags)?void 0:t.length)&&(s=s.filter(t=>e.tags.some(e=>t.tags.includes(e)))),null==e?void 0:e.search){let t=e.search.toLowerCase();s=s.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.tags.some(e=>e.toLowerCase().includes(t)))}return(null==e?void 0:e.installed)!==void 0&&(s=s.filter(t=>t.isInstalled===e.installed)),(null==e?void 0:e.official)!==void 0&&(s=s.filter(t=>t.isOfficial===e.official)),s.sort((e,t)=>e.isInstalled!==t.isInstalled?e.isInstalled?-1:1:e.isOfficial!==t.isOfficial?e.isOfficial?-1:1:e.popularity!==t.popularity?(t.popularity||0)-(e.popularity||0):e.name.localeCompare(t.name))}async addCustomEntry(e){let t={...e,id:"custom-".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),isOfficial:!1,lastUpdated:new Date};return this.registryEntries.push(t),await this.saveCustomEntries(),t}async updateEntry(e,t){let s=this.registryEntries.findIndex(t=>t.id===e);return -1!==s&&(this.registryEntries[s]={...this.registryEntries[s],...t,lastUpdated:new Date},await this.saveCustomEntries(),!0)}async setInstalled(e,t){return this.updateEntry(e,{isInstalled:t})}async getServerConfig(e){return await this.initialize(),this.registryEntries.find(t=>t.id===e)||null}getBuiltinEntries(){return[{id:"filesystem",name:"File System",description:"Secure file operations with configurable access controls for reading and writing files",category:"productivity",icon:"\uD83D\uDCC1",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-filesystem","/path/to/allowed/directory"],timeout:3e4},tags:["file","directory","filesystem","io"],isOfficial:!0,isInstalled:!1,popularity:95,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"github",name:"GitHub",description:"Repository management, file operations, search repositories, manage issues and pull requests",category:"development",icon:"\uD83D\uDC19",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-github"],env:{GITHUB_PERSONAL_ACCESS_TOKEN:""},timeout:3e4},tags:["git","repository","version-control","issues","pr"],isOfficial:!0,isInstalled:!1,popularity:92,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"GitHub",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"brave-search",name:"Brave Search",description:"Web and local search using Brave's Search API for real-time information retrieval",category:"research",icon:"\uD83D\uDD0D",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-brave-search"],env:{BRAVE_SEARCH_API_KEY:""},timeout:3e4},tags:["search","web","research","information"],isOfficial:!0,isInstalled:!1,popularity:88,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"sqlite",name:"SQLite",description:"Database interaction and business intelligence capabilities for SQLite databases",category:"data",icon:"\uD83D\uDDC4️",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-sqlite","/path/to/database.db"],timeout:3e4},tags:["database","sql","sqlite","query"],isOfficial:!0,isInstalled:!1,popularity:85,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"puppeteer",name:"Puppeteer",description:"Browser automation and web scraping with Puppeteer for automated testing and data extraction",category:"research",icon:"\uD83C\uDFAD",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-puppeteer"],timeout:3e4},tags:["browser","automation","scraping","web","testing"],isOfficial:!0,isInstalled:!1,popularity:80,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"postgresql",name:"PostgreSQL",description:"Read-only database access with schema inspection for PostgreSQL databases",category:"data",icon:"\uD83D\uDC18",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-postgres","postgresql://localhost/mydb"],timeout:3e4},tags:["database","sql","postgresql","postgres","query"],isOfficial:!0,isInstalled:!1,popularity:83,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"slack",name:"Slack",description:"Channel management and messaging capabilities for Slack workspaces",category:"communication",icon:"\uD83D\uDCAC",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-slack"],env:{SLACK_BOT_TOKEN:""},timeout:3e4},tags:["slack","messaging","team","communication","channels"],isOfficial:!0,isInstalled:!1,popularity:75,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"fetch",name:"Fetch",description:"Web content fetching and conversion for efficient LLM usage",category:"research",icon:"\uD83C\uDF10",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-fetch"],timeout:3e4},tags:["web","fetch","content","http","download"],isOfficial:!0,isInstalled:!1,popularity:78,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"http-example",name:"HTTP MCP Server",description:"Example HTTP-based MCP server for API integrations",category:"development",icon:"\uD83C\uDF10",config:{type:"http",baseUrl:"http://localhost:8080",headers:{Authorization:"Bearer your-api-key","Content-Type":"application/json"},timeout:3e4},tags:["http","api","integration","web"],isOfficial:!1,isInstalled:!1,popularity:70,lastUpdated:new Date,requirements:{platform:"all"},author:"Community",version:"1.0.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"memory",name:"Memory",description:"Knowledge graph-based persistent memory system for storing and retrieving information",category:"productivity",icon:"\uD83E\uDDE0",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-memory"],timeout:3e4},tags:["memory","knowledge","graph","persistence","storage"],isOfficial:!0,isInstalled:!1,popularity:87,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"google-drive",name:"Google Drive",description:"File access and search capabilities for Google Drive integration",category:"productivity",icon:"\uD83D\uDCCB",config:{type:"stdio",command:"npx",args:["-y","@modelcontextprotocol/server-gdrive"],env:{GOOGLE_APPLICATION_CREDENTIALS:""},timeout:3e4},tags:["google","drive","files","cloud","storage"],isOfficial:!0,isInstalled:!1,popularity:82,lastUpdated:new Date,requirements:{platform:"all",node:">=18.0.0"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"},{id:"git",name:"Git",description:"Tools to read, search, and manipulate Git repositories",category:"development",icon:"\uD83C\uDF3F",config:{type:"stdio",command:"uvx",args:["mcp-server-git","--repository","/path/to/git/repo"],timeout:3e4},tags:["git","version-control","repository","commits","diff"],isOfficial:!0,isInstalled:!1,popularity:90,lastUpdated:new Date,requirements:{platform:"all",python:">=3.8"},author:"Anthropic",version:"0.6.0",homepage:"https://github.com/modelcontextprotocol/servers"}]}async saveCustomEntries(){let e=this.registryEntries.filter(e=>!e.isOfficial);localStorage.setItem("mcp-custom-servers",JSON.stringify(e))}async loadCustomEntries(){{let e=localStorage.getItem("mcp-custom-servers");if(e)try{let t=JSON.parse(e);this.registryEntries.push(...t)}catch(e){console.warn("Failed to load custom server entries:",e)}}}constructor(){this.registryEntries=[],this.isInitialized=!1}}let ew=ey.getInstance();var eN=s(9840),ek=s(9852),eC=s(2714),eS=s(9474),eA=s(5784),eE=s(4616),eT=s(4229),eD=s(7617);function eR(e){let{isOpen:t,onClose:s,onAddServer:r}=e,[l,i]=(0,n.useState)({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),[o,c]=(0,n.useState)(""),[d,m]=(0,n.useState)(""),[u,x]=(0,n.useState)(""),[h,p]=(0,n.useState)([]),[f,g]=(0,n.useState)(""),[v,j]=(0,n.useState)(null),[y,w]=(0,n.useState)(!1),N=async e=>{e.preventDefault(),j(null),w(!0);try{let e=o.split(",").map(e=>e.trim()).filter(Boolean),t=d.split(",").map(e=>e.trim()).filter(Boolean),a=f.split(",").map(e=>e.trim()).filter(Boolean),n={};if(u.trim())for(let e of u.split("\n")){let t=e.trim();if(!t)continue;let s=t.indexOf("=");if(s>0){let e=t.substring(0,s).trim(),r=t.substring(s+1).trim();e&&(n[e]=r)}}let v={};if(h.forEach(e=>{e.key.trim()&&e.value.trim()&&(v[e.key.trim()]=e.value.trim())}),!l.name.trim())throw Error("Server name is required");if(!l.description.trim())throw Error("Description is required");if("stdio"===l.config.type&&!l.config.command.trim())throw Error("Command is required for stdio servers");if("sse"===l.config.type&&!l.config.url.trim())throw Error("URL is required for SSE servers");if("http"===l.config.type&&!l.config.url.trim())throw Error("URL is required for HTTP servers");let j={...l,config:{...l.config,args:e,env:n,headers:v},tags:t,requirements:{...l.requirements,dependencies:a}};await r(j),s(),i({name:"",description:"",category:"custom",icon:"",version:"",author:"",homepage:"",config:{type:"stdio",command:"",args:[],url:"",env:{},headers:{},timeout:3e4},tags:[],isInstalled:!1,requirements:{platform:"all",node:"",python:"",dependencies:[]}}),c(""),m(""),x(""),p([]),g("")}catch(e){j(e.message||"Failed to add custom server")}finally{w(!1)}},k=e=>{let{name:t,value:s}=e.target;i(e=>({...e,config:{...e.config,[t]:s}}))};return(0,a.jsx)(eN.lG,{open:t,onOpenChange:s,children:(0,a.jsxs)(eN.Cf,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsxs)(eN.c7,{children:[(0,a.jsxs)(eN.L3,{className:"flex items-center gap-2",children:[(0,a.jsx)(eE.A,{className:"h-5 w-5"}),"Add Custom Server to Registry"]}),(0,a.jsx)(eN.rr,{children:"Add your own custom MCP server configuration to the registry for easy reuse."})]}),(0,a.jsxs)("form",{onSubmit:N,className:"space-y-4",children:[v&&(0,a.jsx)(ev.Fc,{variant:"destructive",children:(0,a.jsx)(ev.TN,{children:v})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"name",children:"Server Name *"}),(0,a.jsx)(ek.p,{id:"name",value:l.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:"My Custom Server",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"category",children:"Category"}),(0,a.jsxs)(eA.l6,{value:l.category,onValueChange:e=>i(t=>({...t,category:e})),children:[(0,a.jsx)(eA.bq,{id:"category",children:(0,a.jsx)(eA.yv,{})}),(0,a.jsx)(eA.gC,{children:[{value:"productivity",label:"Productivity"},{value:"development",label:"Development"},{value:"research",label:"Research"},{value:"creative",label:"Creative"},{value:"data",label:"Data"},{value:"communication",label:"Communication"},{value:"custom",label:"Custom"}].map(e=>(0,a.jsx)(eA.eb,{value:e.value,children:e.label},e.value))})]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"description",children:"Description *"}),(0,a.jsx)(eS.T,{id:"description",value:l.description,onChange:e=>i(t=>({...t,description:e.target.value})),placeholder:"Describe what this server does...",required:!0})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Server Configuration"}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"serverType",children:"Server Type"}),(0,a.jsxs)(eA.l6,{value:l.config.type,onValueChange:e=>i(t=>({...t,config:{...t.config,type:e}})),children:[(0,a.jsx)(eA.bq,{id:"serverType",children:(0,a.jsx)(eA.yv,{})}),(0,a.jsxs)(eA.gC,{children:[(0,a.jsx)(eA.eb,{value:"stdio",children:"stdio"}),(0,a.jsx)(eA.eb,{value:"sse",children:"sse"}),(0,a.jsx)(eA.eb,{value:"http",children:"http"})]})]})]}),"stdio"===l.config.type?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"command",children:"Command *"}),(0,a.jsx)(ek.p,{id:"command",value:l.config.command,onChange:e=>i(t=>({...t,config:{...t.config,command:e.target.value}})),placeholder:"npx or python",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"args",children:"Arguments"}),(0,a.jsx)(ek.p,{id:"args",value:o,onChange:e=>c(e.target.value),placeholder:"Comma-separated: -m,script.py,--port,8080"})]})]}):"sse"===l.config.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{htmlFor:"url",children:"URL *"}),(0,a.jsx)(ek.p,{id:"url",name:"url",value:l.config.url,onChange:k,placeholder:"http://localhost:8080/sse",required:!0})]}):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{htmlFor:"url",children:"URL *"}),(0,a.jsx)(ek.p,{id:"url",name:"url",value:l.config.url,onChange:k,placeholder:"https://example.com",required:!0})]}),"stdio"===l.config.type&&(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"env",children:"Environment Variables"}),(0,a.jsx)(eS.T,{id:"env",value:u,onChange:e=>x(e.target.value),placeholder:"KEY1=value1\nKEY2=value2",rows:3})]}),("sse"===l.config.type||"http"===l.config.type)&&(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsx)(eD.w,{label:"Headers",pairs:h,onChange:p,placeholder:{key:"Authorization",value:"Bearer your-token"},keyLabel:"Header",valueLabel:"Value"})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"tags",children:"Tags"}),(0,a.jsx)(ek.p,{id:"tags",value:d,onChange:e=>m(e.target.value),placeholder:"Comma-separated: file, database, api"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"icon",children:"Icon (Emoji)"}),(0,a.jsx)(ek.p,{id:"icon",value:l.icon,onChange:e=>i(t=>({...t,icon:e.target.value})),placeholder:"⚡",maxLength:2})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"version",children:"Version"}),(0,a.jsx)(ek.p,{id:"version",value:l.version,onChange:e=>i(t=>({...t,version:e.target.value})),placeholder:"1.0.0"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"author",children:"Author"}),(0,a.jsx)(ek.p,{id:"author",value:l.author,onChange:e=>i(t=>({...t,author:e.target.value})),placeholder:"Your Name"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"homepage",children:"Homepage URL"}),(0,a.jsx)(ek.p,{id:"homepage",value:l.homepage,onChange:e=>i(t=>({...t,homepage:e.target.value})),placeholder:"https://github.com/youruser/yourserver"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Requirements"}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"platform",children:"Platform"}),(0,a.jsxs)(eA.l6,{value:l.requirements.platform,onValueChange:e=>i(t=>({...t,requirements:{...t.requirements,platform:e}})),children:[(0,a.jsx)(eA.bq,{id:"platform",children:(0,a.jsx)(eA.yv,{})}),(0,a.jsx)(eA.gC,{children:[{value:"all",label:"All Platforms"},{value:"win32",label:"Windows"},{value:"darwin",label:"macOS"},{value:"linux",label:"Linux"}].map(e=>(0,a.jsx)(eA.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"dependencies",children:"Dependencies"}),(0,a.jsx)(ek.p,{id:"dependencies",value:f,onChange:e=>g(e.target.value),placeholder:"Comma-separated: package1, package2"})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"nodeVersion",children:"Node.js Version"}),(0,a.jsx)(ek.p,{id:"nodeVersion",value:l.requirements.node,onChange:e=>i(t=>({...t,requirements:{...t.requirements,node:e.target.value}})),placeholder:">=16.0.0"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(eC.J,{htmlFor:"pythonVersion",children:"Python Version"}),(0,a.jsx)(ek.p,{id:"pythonVersion",value:l.requirements.python,onChange:e=>i(t=>({...t,requirements:{...t.requirements,python:e.target.value}})),placeholder:">=3.8"})]})]})]}),(0,a.jsxs)(eN.Es,{className:"flex gap-2",children:[(0,a.jsx)(b.$,{type:"button",variant:"outline",onClick:s,children:"Cancel"}),(0,a.jsx)(b.$,{type:"submit",disabled:y,children:y?"Adding...":(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eT.A,{className:"h-4 w-4 mr-2"}),"Add to Registry"]})})]})]})]})})}var eI=s(8145),eO=s(5487),eL=s(5543);function eF(e){let{isOpen:t,onClose:s,onInstallServer:r}=e,[l,o]=(0,n.useState)([]),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x,h]=(0,n.useState)(null),[p,f]=(0,n.useState)(null),[g,v]=(0,n.useState)(!1),[j,y]=(0,n.useState)({}),[w,N]=(0,n.useState)(""),k=(0,n.useRef)(null),C=(0,n.useRef)(!0),S=(0,n.useRef)(null);(0,n.useEffect)(()=>(C.current=!0,()=>{C.current=!1,k.current&&clearTimeout(k.current),S.current&&S.current.abort()}),[]),(0,n.useEffect)(()=>{t&&(async()=>{S.current&&S.current.abort();let e=new AbortController;if(S.current=e,C.current){u(!0),h(null);try{let t=await ew.getEntries();C.current&&!e.signal.aborted&&(o(t),d(t))}catch(t){C.current&&!e.signal.aborted&&h(t instanceof Error?t.message:"Failed to load server registry")}finally{C.current&&!e.signal.aborted&&u(!1)}}})()},[t]);let A=(0,n.useCallback)(async(e,t)=>{if(C.current)try{let s=await ew.getEntries({...e,search:t||void 0});C.current&&d(s)}catch(e){C.current&&h(e instanceof Error?e.message:"Failed to filter entries")}},[]);(0,n.useEffect)(()=>(k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{A(j,w)},300),()=>{k.current&&clearTimeout(k.current)}),[j,w,l,A]);let E=async e=>{if(C.current){f(e.id);try{await r(e),await ew.setInstalled(e.id,!0),C.current&&o(t=>t.map(t=>t.id===e.id?{...t,isInstalled:!0}:t))}catch(e){C.current&&h(e instanceof Error?e.message:"Failed to install server")}finally{C.current&&f(null)}}},T=async e=>{if(C.current)try{let t=await ew.addCustomEntry(e);C.current&&(o(e=>[t,...e]),v(!1))}catch(e){C.current&&h(e instanceof Error?e.message:"Failed to add custom server")}};return(0,a.jsxs)(eN.lG,{open:t,onOpenChange:s,children:[(0,a.jsxs)(eN.Cf,{className:"max-w-2xl max-h-[70vh] overflow-hidden flex flex-col border-0 shadow-2xl",children:[(0,a.jsxs)(eN.c7,{className:"pb-6",children:[(0,a.jsxs)(eN.L3,{className:"flex items-center gap-3 text-lg",children:[(0,a.jsx)("div",{className:"p-2 rounded-lg bg-primary/10",children:(0,a.jsx)(eO.A,{className:"h-5 w-5 text-primary"})}),"Browse Tools"]}),(0,a.jsx)(eN.rr,{className:"text-muted-foreground",children:"Discover and add new capabilities to your AI assistant"})]}),(0,a.jsxs)("div",{className:"relative mb-6",children:[(0,a.jsx)(eL.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,a.jsx)(ek.p,{placeholder:"Search for tools and integrations...",value:w,onChange:e=>N(e.target.value),className:"pl-10 h-11 border-border/50 focus:border-primary/50 bg-background/50"})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto -mx-1 px-1",children:[x&&(0,a.jsx)(ev.Fc,{variant:"destructive",className:"mb-4",children:(0,a.jsx)(ev.TN,{children:x})}),m?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,a.jsx)("div",{className:"h-8 w-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin"}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground",children:"Discovering tools..."})]})}):0===c.length?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(0,a.jsx)("div",{className:"p-3 rounded-full bg-muted/50 mb-4",children:(0,a.jsx)(eO.A,{className:"h-8 w-8 text-muted-foreground"})}),(0,a.jsx)("div",{className:"text-muted-foreground",children:0===l.length?"No tools available in the registry":"No tools match your search"}),w&&(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>N(""),className:"mt-2",children:"Clear search"})]}):(0,a.jsx)("div",{className:"space-y-3",children:c.map((e,t)=>(0,a.jsxs)("div",{className:"group relative flex items-center justify-between p-4 border border-border/50 rounded-xl hover:border-border hover:shadow-sm bg-card/50 hover:bg-card transition-all duration-200",style:{animationDelay:"".concat(Math.min(50*t,500),"ms")},children:[(0,a.jsxs)("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"flex-shrink-0 text-2xl p-2 rounded-lg bg-primary/5 border border-primary/10",children:e.icon||"⚡"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)("h3",{className:"font-semibold text-sm text-foreground group-hover:text-primary transition-colors",children:e.name}),e.isOfficial&&(0,a.jsx)(eI.E,{variant:"secondary",className:"text-xs font-medium px-2",children:"Official"}),e.isInstalled&&(0,a.jsx)(eI.E,{className:"text-xs font-medium px-2 bg-green-100 text-green-800 border-green-200",children:"Added"})]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-1 leading-relaxed",children:e.description})]})]}),(0,a.jsx)(b.$,{onClick:()=>E(e),disabled:e.isInstalled||p===e.id,size:"sm",variant:e.isInstalled?"outline":"default",className:(0,i.cn)("flex-shrink-0 ml-3 min-w-[80px] transition-all",!e.isInstalled&&"hover:shadow-sm",p===e.id&&"opacity-70"),children:p===e.id?(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-3 w-3 border border-current border-t-transparent rounded-full animate-spin"}),(0,a.jsx)("span",{children:"Adding..."})]}):e.isInstalled?"Added":"Add"})]},e.id))})]})]}),(0,a.jsx)(eR,{isOpen:g,onClose:()=>v(!1),onAddServer:T})]})}var eP=s(3904),ez=s(9103),eq=s(7108),eU=s(2525),eJ=s(142);let e_="/api";function eK(e){let{isOpen:t,onClose:s,onOpenConnectModal:r,variant:l="overlay",refreshTrigger:o}=e,[d,x]=(0,n.useState)([]),[h,p]=(0,n.useState)(null),[f,g]=(0,n.useState)([]),[v,j]=(0,n.useState)(!1),[y,w]=(0,n.useState)(!1),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(null),[A,E]=(0,n.useState)(!1),[T,D]=(0,n.useState)(null),[R,I]=(0,n.useState)(!1),O=(e,t)=>{console.error("ServersPanel Error (".concat(t,"):"),e),"servers"===t&&k(e),"tools"===t&&S(e)},L=(0,n.useCallback)(async e=>{j(!0),k(null),x([]),p(null),g([]),S(null);try{let t=await fetch("".concat(e_,"/mcp/servers"),e?{signal:e}:{});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to fetch servers"}));throw Error(e.message||e.error||"Server List: ".concat(t.statusText))}let s=(await t.json()).servers||[];if(x(s),s.length>0){let e=s.find(e=>"connected"===e.status);e?p(e.id):s.length>0&&p(s[0].id)}else console.log("No MCP servers found or returned from API.")}catch(e){"AbortError"!==e.name&&O(e.message,"servers")}finally{(null==e?void 0:e.aborted)||j(!1)}},[]),F=async e=>{I(!1);let t={type:e.config.type,command:e.config.command,args:e.config.args||[],url:e.config.url,env:e.config.env||{},headers:e.config.headers||{},timeout:e.config.timeout||3e4};try{let s=await fetch("/api/connect-server",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,config:t})}),r=await s.json();if(!s.ok)throw Error(r.error||"Server returned status ".concat(s.status));await L()}catch(e){throw Error(e.message||"Failed to install server")}},P=async e=>{let t=d.find(t=>t.id===e);if(t&&window.confirm('Are you sure you want to remove server "'.concat(t.name,'"?'))){D(e),k(null);try{let t=await fetch("".concat(e_,"/mcp/servers/").concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed to remove server"}));throw Error(e.message||e.error||"Server Removal: ".concat(t.statusText))}h===e&&(p(null),g([])),await L()}catch(e){O(e.message,"servers")}finally{D(null)}}};(0,n.useEffect)(()=>{if(!t)return;let e=new AbortController;return L(e.signal),D(null),()=>{e.abort()}},[t,L]),(0,n.useEffect)(()=>{if(o&&t){let e=new AbortController;return L(e.signal),()=>{e.abort()}}},[o,t,L]);let z=(0,n.useCallback)(async(e,t)=>{let s=d.find(t=>t.id===e);if(g([]),S(null),!s||"connected"!==s.status)return void console.warn('Server "'.concat((null==s?void 0:s.name)||e,'" is not connected or not found. Cannot fetch tools.'));w(!0);try{let r=await fetch("".concat(e_,"/mcp/servers/").concat(e,"/tools"),t?{signal:t}:{});if(!r.ok){let e=await r.json().catch(()=>({error:"Failed to fetch tools for ".concat(s.name)}));throw Error(e.message||e.error||"Tool List (".concat(s.name,"): ").concat(r.statusText))}let a=await r.json();(null==t?void 0:t.aborted)||g(a.tools||[]),a.tools&&0!==a.tools.length||console.log('No tools found for server "'.concat(s.name,'".'))}catch(e){"AbortError"!==e.name&&O(e.message,"tools")}finally{(null==t?void 0:t.aborted)||w(!1)}},[d]);(0,n.useEffect)(()=>{if(!h)return;let e=new AbortController;return z(h,e.signal),()=>{e.abort()}},[h,z]);let q=d.find(e=>e.id===h);if("overlay"===l&&!t)return null;let U=(0,i.cn)("fixed top-0 right-0 z-40 h-screen w-80 bg-card border-l border-border shadow-xl transition-transform transform flex flex-col",t?"translate-x-0":"translate-x-full"),J=(0,i.cn)("h-full w-full flex flex-col bg-card");return(0,a.jsxs)("aside",{className:"overlay"===l?U:J,children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border/50 bg-card/50 backdrop-blur-sm",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Tools & Servers"}),(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>L(),disabled:v,className:"h-8 w-8 p-0",children:(0,a.jsx)(eP.A,{className:(0,i.cn)("h-3.5 w-3.5",v&&"animate-spin")})}),"overlay"===l&&(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:s,className:"h-8 w-8 p-0",children:(0,a.jsx)(u.A,{className:"h-3.5 w-3.5"})})]})]}),(0,a.jsxs)("div",{className:"px-4 py-3 space-y-2 border-b border-border/30",children:[(0,a.jsxs)(b.$,{onClick:r,className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,a.jsx)(ez.A,{className:"mr-2 h-4 w-4"}),"Connect Server"]}),(0,a.jsxs)(b.$,{onClick:()=>I(!0),variant:"outline",className:"w-full h-9 text-sm font-medium",size:"sm",children:[(0,a.jsx)(eq.A,{className:"mr-2 h-4 w-4"}),"Browse Registry"]})]}),(0,a.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"p-4 border-b border-border/30",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-3",children:(0,a.jsxs)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:["Connected Servers (",d.length,")"]})}),v&&(0,a.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,a.jsx)(eP.A,{className:"h-5 w-5 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading servers..."})]})}),N&&(0,a.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,a.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,a.jsx)(c.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Connection Error"}),(0,a.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:N})]})]})}),!v&&0===d.length&&!N&&(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)(eO.A,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-2"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"No servers connected"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Connect or browse the registry"})]}),d.map(e=>(0,a.jsx)("div",{onClick:()=>p(e.id),className:(0,i.cn)("p-3 rounded-lg border cursor-pointer transition-all duration-200 mb-2 last:mb-0",h===e.id?"bg-primary/5 border-primary/20 shadow-sm":"bg-background hover:bg-muted/50 border-border/50 hover:border-border"),children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("div",{className:(0,i.cn)("w-2 h-2 rounded-full flex-shrink-0","connected"===e.status?"bg-green-500":"error"===e.status?"bg-red-500":"bg-yellow-500")}),(0,a.jsx)("h4",{className:"text-sm font-medium truncate",children:e.name})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1 capitalize",children:e.status})]}),T===e.id?(0,a.jsx)(eP.A,{className:"h-4 w-4 animate-spin text-muted-foreground"}):(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),P(e.id)},className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",children:(0,a.jsx)(eU.A,{className:"h-3.5 w-3.5"})})]})},e.id))]}),q&&(0,a.jsxs)("div",{className:"flex-1 overflow-hidden flex flex-col",children:[(0,a.jsx)("div",{className:"px-4 py-3 border-b border-border/30",children:(0,a.jsxs)("button",{onClick:()=>E(!A),className:"flex items-center justify-between w-full text-left",children:[(0,a.jsx)("h3",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wide",children:"Available Tools"}),(0,a.jsx)(m.A,{className:(0,i.cn)("h-3.5 w-3.5 transition-transform text-muted-foreground",A&&"rotate-180")})]})}),A&&(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:[y&&(0,a.jsx)("div",{className:"flex items-center justify-center py-6",children:(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-2",children:[(0,a.jsx)(eP.A,{className:"h-4 w-4 animate-spin text-muted-foreground"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"Loading tools..."})]})}),C&&(0,a.jsx)("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 mb-3",children:(0,a.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,a.jsx)(c.A,{className:"h-4 w-4 text-destructive flex-shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-destructive",children:"Tools Error"}),(0,a.jsx)("p",{className:"text-xs text-destructive/80 mt-1",children:C})]})]})}),!y&&0===f.length&&!C&&"connected"===q.status&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)(eJ.A,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"No tools available"})]}),"connected"!==q.status&&(0,a.jsxs)("div",{className:"text-center py-6",children:[(0,a.jsx)(c.A,{className:"h-6 w-6 text-muted-foreground/50 mx-auto mb-2"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Server not connected"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Tools unavailable"})]}),f.map(e=>{var t;return(0,a.jsxs)("div",{className:"p-3 rounded-lg border border-border/50 bg-background hover:bg-muted/30 transition-colors mb-2 last:mb-0",children:[(0,a.jsx)("h4",{className:"text-sm font-medium mb-1",children:e.name}),e.description&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2 mb-2",children:e.description}),(null==(t=e.inputSchema)?void 0:t.properties)&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-1 mt-2",children:[Object.keys(e.inputSchema.properties).slice(0,3).map(e=>(0,a.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md bg-muted text-xs font-medium",children:e},e)),Object.keys(e.inputSchema.properties).length>3&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",Object.keys(e.inputSchema.properties).length-3," more"]})]})]},e.name)})]})]})]}),(0,a.jsx)(eF,{isOpen:R,onClose:()=>I(!1),onInstallServer:F})]})}let e$=n.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("relative overflow-auto",s),...n,children:r})});e$.displayName="ScrollArea";var eM=s(9676),eV=s(5448),eB=s(4186),eG=s(9074);function eH(e){let{isOpen:t,onClose:s,currentSessionId:r,onSessionChange:l,returnToWelcome:o,variant:d="modal",onSearchOpen:m}=e,[u,x]=(0,n.useState)([]),[h,p]=(0,n.useState)(!1),[f,g]=(0,n.useState)(null),[v,j]=(0,n.useState)(!1),[y,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(null),[C,S]=(0,n.useState)(!1),[A,E]=(0,n.useState)(null),[T,D]=(0,n.useState)(!1),R=(0,n.useCallback)(async()=>{p(!0),g(null);try{let e=await fetch("/api/sessions");if(!e.ok)throw Error("Failed to fetch sessions");let t=await e.json();x(t.sessions||[])}catch(e){console.error("Error fetching sessions:",e),g(e instanceof Error?e.message:"Failed to fetch sessions")}finally{p(!1)}},[]);(0,n.useEffect)(()=>{t&&R()},[t,R]),(0,n.useEffect)(()=>{let e=()=>{t&&R()},s=()=>{t&&R()};return window.addEventListener("dexto:message",e),window.addEventListener("dexto:response",s),()=>{window.removeEventListener("dexto:message",e),window.removeEventListener("dexto:response",s)}},[t,R]);let I=async()=>{try{let e=await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:y.trim()||void 0})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create session")}let t=await e.json();x(e=>[...e,t.session]),w(""),j(!1),l(t.session.id)}catch(e){console.error("Error creating session:",e),g(e instanceof Error?e.message:"Failed to create session")}},O=async e=>{k(e);try{let t=await fetch("/api/sessions/".concat(e),{method:"DELETE"});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete session")}x(t=>t.filter(t=>t.id!==e)),r===e&&o()}catch(e){console.error("Error deleting session:",e),g(e instanceof Error?e.message:"Failed to delete session")}finally{k(null)}},L=async()=>{if(A){D(!0);try{if(!(await fetch("/api/sessions/".concat(A),{method:"DELETE",headers:{"Content-Type":"application/json"}})).ok)throw Error("Failed to delete conversation");x(e=>e.filter(e=>e.id!==A)),r===A&&o(),S(!1),E(null)}catch(e){console.error("Error deleting conversation:",e),g(e instanceof Error?e.message:"Failed to delete conversation")}finally{D(!1)}}},F=e=>{if(!e)return"Unknown";let t=new Date(e);return t.toLocaleDateString()+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},P=e=>{if(!e)return"Unknown";let t=new Date(e),s=new Date().getTime()-t.getTime(),r=Math.floor(s/6e4),a=Math.floor(s/36e5),n=Math.floor(s/864e5);return r<1?"Just now":r<60?"".concat(r,"m ago"):a<24?"".concat(a,"h ago"):"".concat(n,"d ago")},z=(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 border-b border-border/50",children:[(0,a.jsx)("div",{className:"flex items-center space-x-2",children:(0,a.jsx)("h2",{className:"text-base font-semibold",children:"Chat History"})}),(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[m&&(0,a.jsx)(b.$,{variant:"outline",size:"sm",onClick:m,className:"h-7 w-7 p-0",title:"Search Conversations (⌘⇧S)",children:(0,a.jsx)(eL.A,{className:"h-3.5 w-3.5"})}),(0,a.jsxs)(b.$,{variant:"outline",size:"sm",onClick:()=>j(!0),className:"h-7 px-2",children:[(0,a.jsx)(eE.A,{className:"h-3.5 w-3.5 mr-1"}),(0,a.jsx)("span",{className:"text-xs",children:"New"})]})]})]}),f&&(0,a.jsx)("div",{className:"p-4",children:(0,a.jsxs)(ev.Fc,{variant:"destructive",children:[(0,a.jsx)(c.A,{className:"h-4 w-4"}),(0,a.jsx)(ev.TN,{children:f})]})}),(0,a.jsx)(e$,{className:"flex-1 p-4",children:(0,a.jsx)("div",{className:"space-y-2",children:h?(0,a.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,a.jsx)(eP.A,{className:"h-6 w-6 animate-spin"})}):0===u.length?(0,a.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,a.jsx)(eM.A,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,a.jsx)("p",{children:"No chat history"}),(0,a.jsx)("p",{className:"text-sm",children:"Start a conversation to see it here"})]}):u.map(e=>(0,a.jsx)("div",{className:(0,i.cn)("group p-3 rounded-lg border border-border/50 bg-card hover:bg-muted/50 transition-all cursor-pointer",r===e.id&&"ring-2 ring-primary bg-primary/5"),onClick:()=>l(e.id),children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,a.jsx)("h3",{className:"font-medium text-sm truncate",children:e.id}),r===e.id&&(0,a.jsx)(eI.E,{variant:"secondary",className:"text-xs",children:"Active"})]}),(0,a.jsxs)("div",{className:"space-y-1 text-xs text-muted-foreground",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,a.jsx)(eV.A,{className:"h-3 w-3"}),(0,a.jsxs)("span",{children:[e.messageCount," messages"]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,a.jsx)(eB.A,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:P(e.lastActivity)})]})]}),e.createdAt&&(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,a.jsx)(eG.A,{className:"h-3 w-3"}),(0,a.jsxs)("span",{children:["Created ",F(e.createdAt)]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[e.messageCount>0&&(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),E(e.id),S(!0)},className:"h-8 w-8 p-0",title:"Delete Conversation",children:(0,a.jsx)(eU.A,{className:"h-4 w-4 text-destructive"})})}),0===e.messageCount&&(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:t=>{t.stopPropagation(),O(e.id)},disabled:N===e.id,className:"h-8 w-8 p-0",title:"Delete Session",children:(0,a.jsx)(eU.A,{className:"h-4 w-4 text-destructive"})})]})]})},e.id))})}),(0,a.jsx)(eN.lG,{open:v,onOpenChange:j,children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-md",children:[(0,a.jsx)(eN.c7,{children:(0,a.jsx)(eN.L3,{children:"Start New Chat"})}),(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{htmlFor:"sessionId",children:"Chat ID"}),(0,a.jsx)(ek.p,{id:"sessionId",value:y,onChange:e=>w(e.target.value),placeholder:"e.g., user-123, project-alpha",className:"font-mono"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Leave empty to auto-generate a unique ID"})]})}),(0,a.jsxs)(eN.Es,{children:[(0,a.jsx)(b.$,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),(0,a.jsx)(b.$,{onClick:I,children:"Start Chat"})]})]})}),(0,a.jsx)(eN.lG,{open:C,onOpenChange:S,children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(eN.c7,{children:[(0,a.jsxs)(eN.L3,{className:"flex items-center space-x-2",children:[(0,a.jsx)(eU.A,{className:"h-5 w-5 text-destructive"}),(0,a.jsx)("span",{children:"Delete Conversation"})]}),(0,a.jsxs)(eN.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",A&&(0,a.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,a.jsx)("span",{className:"font-mono",children:A})]})]})]}),(0,a.jsxs)(eN.Es,{children:[(0,a.jsx)(b.$,{variant:"outline",onClick:()=>S(!1),children:"Cancel"}),(0,a.jsxs)(b.$,{variant:"destructive",onClick:L,disabled:T,className:"flex items-center space-x-2",children:[(0,a.jsx)(eU.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:T?"Deleting...":"Delete Conversation"})]})]})]})})]});return"inline"===d?(0,a.jsx)("div",{className:"h-full",children:z}):(0,a.jsx)(eN.lG,{open:t,onOpenChange:s,children:(0,a.jsx)(eN.Cf,{className:"sm:max-w-lg h-[600px] flex flex-col p-0",children:z})})}var eW=s(5139);function eQ(e){let{websocket:t}=e,[s,r]=(0,n.useState)(null),[l,i]=(0,n.useState)(!1),[o,d]=(0,n.useState)(!1),m=n.useRef([]);(0,n.useEffect)(()=>{if(!t)return;let e=e=>{try{let t=JSON.parse(e.data);if("toolConfirmationRequest"===t.event){let e={...t.data,timestamp:new Date(t.data.timestamp)};console.debug("[WebUI] Received toolConfirmationRequest",e),o?m.current.push(e):(r(e),d(!0),i(!1))}}catch(e){console.error("Error parsing WebSocket message:",e)}};return t.addEventListener("message",e),()=>{t.removeEventListener("message",e)}},[t,o]);let u=(0,n.useCallback)(e=>{if(!s||!t)return;let a={type:"toolConfirmationResponse",data:{executionId:s.executionId,approved:e,rememberChoice:l,sessionId:s.sessionId}};if(console.debug("[WebUI] Sending toolConfirmationResponse",a),t.send(JSON.stringify(a)),d(!1),r(null),i(!1),m.current.length>0){let e=m.current.shift();setTimeout(()=>{r(e),d(!0)},0)}},[s,l,t]);return((0,n.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>{u(!1)},12e4);return()=>clearTimeout(e)},[o,u]),s)?(0,a.jsx)(eN.lG,{open:o,onOpenChange:e=>{e||u(!1)},children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-[800px] max-w-[95vw] max-h-[90vh] overflow-hidden flex flex-col",children:[(0,a.jsx)(eN.c7,{children:(0,a.jsxs)(eN.L3,{className:"flex items-center gap-2",children:[(0,a.jsx)(c.A,{className:"h-5 w-5 text-yellow-500"}),"Tool Execution Confirmation"]})}),(0,a.jsxs)("div",{className:"space-y-4 overflow-y-auto flex-1 min-h-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(I.A,{className:"h-4 w-4 text-blue-500"}),(0,a.jsx)("span",{className:"font-medium",children:"Tool:"}),(0,a.jsx)(eI.E,{variant:"outline",children:s.toolName})]}),s.description&&(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"font-medium",children:"Description:"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:s.description})]}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-medium mb-2",children:"Arguments:"}),(0,a.jsx)("div",{className:"bg-background/50 p-3 rounded-md text-xs overflow-auto max-h-80 min-h-16 text-muted-foreground border",children:(0,a.jsx)("pre",{className:"whitespace-pre-wrap break-words font-mono",children:(e=>{if(!e)return"No arguments";try{return JSON.stringify(e,null,2)}catch(t){return String(e)}})(s.args)})})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-gray-500",children:[(0,a.jsx)(eB.A,{className:"h-4 w-4"}),(0,a.jsxs)("span",{children:["Requested at: ",s.timestamp.toLocaleString()]})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(eW.S,{id:"remember",checked:l,onCheckedChange:e=>i(!0===e)}),(0,a.jsx)("label",{htmlFor:"remember",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"Approve future executions of this tool for this session"})]}),(0,a.jsx)("div",{className:"bg-yellow-50 p-3 rounded-md",children:(0,a.jsxs)("p",{className:"text-sm text-yellow-800",children:[(0,a.jsx)("strong",{children:"Security Notice:"})," Only approve tools you trust. Tools can access your system and data according to their permissions."]})})]}),(0,a.jsxs)(eN.Es,{className:"gap-2 flex-shrink-0 mt-4 pt-4 border-t",children:[(0,a.jsx)(b.$,{variant:"outline",onClick:()=>u(!1),className:"bg-red-50 hover:bg-red-100 text-red-700 border-red-200",children:"Deny"}),(0,a.jsx)(b.$,{onClick:()=>u(!0),className:"bg-green-600 hover:bg-green-700",children:"Approve"})]})]})}):null}var eY=s(381),eZ=s(1497);function eX(e){let{isOpen:t,onClose:s,onNavigateToSession:r}=e,[l,o]=(0,n.useState)(""),[c,d]=(0,n.useState)([]),[m,u]=(0,n.useState)(!1),[x,h]=(0,n.useState)(null),[p,f]=(0,n.useState)(0),g=(0,n.useCallback)(async e=>{if(!e.trim()){d([]),h(null);return}u(!0),h(null);try{let t=new URLSearchParams({q:e,limit:"10",offset:"0"}),s=await fetch("/api/search/messages?".concat(t));if(!s.ok){let e=await s.text();throw Error("Search failed: ".concat(s.status," ").concat(e))}let r=await s.json();d(r.results),f(0)}catch(e){console.error("Search error:",e),d([]),h(e instanceof Error?e.message:"Search failed")}finally{u(!1)}},[]);(0,n.useEffect)(()=>{let e=setTimeout(()=>{g(l)},300);return()=>clearTimeout(e)},[l,g]),(0,n.useEffect)(()=>{t&&(o(""),d([]),h(null),f(0))},[t]),(0,n.useEffect)(()=>{if(!t)return;let e=e=>{if(t&&(!e.ctrlKey&&!e.metaKey||!e.shiftKey||"S"!==e.key))switch(e.key){case"ArrowDown":e.preventDefault(),e.stopPropagation(),f(e=>Math.min(e+1,c.length-1));break;case"ArrowUp":e.preventDefault(),e.stopPropagation(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),e.stopPropagation(),c[p]&&v(c[p]);break;case"Escape":e.preventDefault(),e.stopPropagation(),s()}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t,c,p,s]);let v=e=>{r(e.sessionId,e.messageIndex),s()},j=e=>{switch(e){case"user":return(0,a.jsx)(D.A,{className:"w-4 h-4"});case"assistant":return(0,a.jsx)(R.A,{className:"w-4 h-4"});case"system":return(0,a.jsx)(eY.A,{className:"w-4 h-4"});default:return(0,a.jsx)(eZ.A,{className:"w-4 h-4"})}},b=e=>{switch(e){case"user":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"assistant":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"system":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}},y=(e,t)=>{if(!t)return e;let s=t.replace(/[.*+?^${}()|\[\]\\]/g,"\\$&"),r=RegExp("(".concat(s,")"),"gi");return e.split(r).map((e,t)=>r.test(e)?(0,a.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-800 font-medium rounded px-1",children:e},t):e)};return(0,a.jsx)(eN.lG,{open:t,onOpenChange:s,children:(0,a.jsx)(eN.Cf,{className:"max-w-2xl p-0 top-[20%] transform translate-y-0",children:(0,a.jsxs)("div",{className:"flex flex-col max-h-[70vh]",children:[(0,a.jsx)("div",{className:"p-6 pb-4",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(eL.A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-5 h-5 text-muted-foreground"}),(0,a.jsx)(ek.p,{placeholder:"Search conversations...",value:l,onChange:e=>o(e.target.value),className:"pl-12 text-lg border-0 shadow-none focus-visible:ring-0 bg-transparent",autoFocus:!0})]})}),(0,a.jsx)("div",{className:"flex-1 overflow-hidden border-t",children:m?(0,a.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,a.jsx)(eP.A,{className:"h-6 w-6 animate-spin mr-3"}),(0,a.jsx)("span",{className:"text-muted-foreground",children:"Searching..."})]}):x?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(eL.A,{className:"w-12 h-12 mx-auto mb-4 text-destructive opacity-50"}),(0,a.jsx)("p",{className:"text-destructive font-medium",children:"Search Error"}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:x}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Try again or check your connection."})]})}):(0,a.jsx)(e$,{className:"h-full",children:(0,a.jsx)("div",{className:"p-2",children:c.length>0?(0,a.jsx)("div",{className:"space-y-1",children:c.map((e,t)=>(0,a.jsxs)("div",{className:(0,i.cn)("flex items-start gap-3 p-3 rounded-lg cursor-pointer transition-colors",t===p?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onClick:()=>v(e),children:[(0,a.jsx)("div",{className:"flex-shrink-0 mt-1",children:(0,a.jsx)(eI.E,{className:(0,i.cn)("text-xs",b(e.message.role)),children:j(e.message.role)})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:e.sessionId.length>20?"".concat(e.sessionId.slice(0,20),"..."):e.sessionId}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e.message.role})]}),(0,a.jsx)("div",{className:"text-sm text-muted-foreground line-clamp-2",children:y(e.context,l)})]}),(0,a.jsx)(L.A,{className:"w-4 h-4 text-muted-foreground flex-shrink-0 mt-1"})]},t))}):l?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)(eL.A,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"No messages found matching your search."}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground mt-2",children:"Try different keywords."})]}):(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)(eL.A,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),(0,a.jsx)("p",{className:"text-muted-foreground",children:"Start typing to search your conversations."}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-4 mt-4 text-xs text-muted-foreground",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↑"}),(0,a.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"↓"}),(0,a.jsx)("span",{children:"to navigate"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Enter"}),(0,a.jsx)("span",{children:"to select"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("kbd",{className:"px-2 py-1 bg-muted rounded text-xs",children:"Esc"}),(0,a.jsx)("span",{children:"to close"})]})]})]})})})})]})})})}var e0=s(2432),e1=s(2111),e2=s(5623),e4=s(1788),e5=s(5133),e3=s(6874),e8=s.n(e3),e6=s(3509),e7=s(2098);function e9(){let{theme:e,toggleTheme:t}=function(){let[e,t]=(0,n.useState)(()=>"undefined"!=typeof document?document.documentElement.classList.contains("dark")?"dark":"light":"dark");return(0,n.useEffect)(()=>{if("undefined"!=typeof document){document.documentElement.classList.toggle("dark","dark"===e);try{var t;localStorage.setItem("theme",e);let s=(null==(t=window.location)?void 0:t.protocol)==="https:";document.cookie="theme=".concat(encodeURIComponent(e),"; path=/; max-age=31536000; SameSite=Lax").concat(s?"; Secure":"")}catch(e){}}},[e]),{theme:e,toggleTheme:e=>{t(e?"dark":"light")},hasMounted:!0}}(),s="dark"===e;return(0,a.jsx)(X.bL,{checked:s,onCheckedChange:t,className:"w-12 h-6 bg-gray-300 dark:bg-gray-700 rounded-full relative transition-colors flex items-center px-0.5","aria-label":"Toggle dark mode",children:(0,a.jsx)(X.zi,{className:"\n w-5 h-5 rounded-full shadow flex items-center justify-center\n transition-transform transform\n translate-x-0.5 data-[state=checked]:translate-x-[1.375rem]\n bg-white dark:bg-gray-100\n ",children:s?(0,a.jsx)(e6.A,{className:"w-3.5 h-3.5 text-gray-700"}):(0,a.jsx)(e7.A,{className:"w-3.5 h-3.5 text-yellow-500"})})})}function te(e){let{active:t=!1}=e,{voices:s,selected:r,setSelected:l}=function(){let[e,t]=(0,n.useState)(A.getVoices()),[s,r]=(0,n.useState)(A.getPreferredVoiceName());return(0,n.useEffect)(()=>{let e=A.subscribeVoices(()=>{t(A.getVoices()),r(A.getPreferredVoiceName())});return()=>e()},[]),{voices:e,selected:s,setSelected:e=>{A.setPreferredVoice(e),r(A.getPreferredVoiceName())}}}(),[i,o]=(0,n.useState)(!1);return((0,n.useEffect)(()=>{if(!t)return void o(!1);let e=window.requestIdleCallback?window.requestIdleCallback(()=>o(!0)):setTimeout(()=>o(!0),0);return()=>{window.cancelIdleCallback&&"number"==typeof e?window.cancelIdleCallback(e):clearTimeout(e)}},[t]),t)?(0,a.jsxs)(eA.l6,{value:null!=r?r:"auto",onValueChange:e=>{l("auto"===e?null:e)},children:[(0,a.jsx)(eA.bq,{className:"h-8 w-[12rem] text-xs",children:(0,a.jsx)(eA.yv,{placeholder:"Voice"})}),(0,a.jsxs)(eA.gC,{children:[(0,a.jsx)(eA.eb,{value:"auto",children:"Auto (best available)"}),i&&s.map(e=>(0,a.jsxs)(eA.eb,{value:e.name,children:[e.name," (",e.lang,")"]},"".concat(e.name,"-").concat(e.lang)))]})]}):null}function tt(e){let{isOpen:t,onClose:s}=e;return(0,a.jsx)(eN.lG,{open:t,onOpenChange:e=>!e&&s(),children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-lg",children:[(0,a.jsxs)(eN.c7,{children:[(0,a.jsx)(eN.L3,{children:"Settings"}),(0,a.jsx)(eN.rr,{children:"Configure preferences for speech and more."})]}),(0,a.jsx)("div",{className:"space-y-6 py-2",children:(0,a.jsxs)("section",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{className:"text-xs uppercase text-muted-foreground",children:"Voice"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Choose a preferred text-to-speech voice. “Auto” selects the best available voice on your device."}),(0,a.jsx)(te,{active:t})]})})]})})}function ts(){let{messages:e,sendMessage:t,currentSessionId:s,switchSession:r,isWelcomeState:o,returnToWelcome:d,websocket:u,activeError:x,clearError:h}=(0,l.v)(),[p,f]=(0,n.useState)(!1),[y,w]=(0,n.useState)(!1),[N,k]=(0,n.useState)(!1),[C,S]=(0,n.useState)(!1),[A,E]=(0,n.useState)(!1),[T,D]=(0,n.useState)(!1),[R,O]=(0,n.useState)(!1),[L,F]=(0,n.useState)("dexto-config"),[P,z]=(0,n.useState)(null),[q,U]=(0,n.useState)(""),[J,_]=(0,n.useState)(!1),[K,$]=(0,n.useState)(!1),[M,V]=(0,n.useState)(!1),[B,G]=(0,n.useState)(null),[W,Q]=(0,n.useState)(!1),[Y,Z]=(0,n.useState)(!1),[X,ee]=(0,n.useState)(""),et=n.useRef(null),es=n.useRef(null),[er,ea]=(0,n.useState)(!0),[ed,em]=(0,n.useState)(!1),[eu,ex]=(0,n.useState)(!1),eh=n.useRef(0),[ep,ef]=(0,n.useState)(!1),eg=n.useRef(null),[ey,ew]=(0,n.useState)(0),eA=(0,n.useCallback)(()=>{let e=et.current;e&&ea(e.scrollHeight-e.scrollTop<=e.clientHeight+1)},[]),eT=(0,n.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"auto",t=et.current;t&&(em(!0),t.scrollTo({top:t.scrollHeight,behavior:e}),requestAnimationFrame(()=>em(!1)))},[]);(0,n.useEffect)(()=>{let e=et.current;if(!e)return;let t=()=>{let t=eh.current,s=e.scrollTop;!ed&&eu&&s<t&&ex(!1),eh.current=s,eA(),e.scrollHeight-e.scrollTop<=e.clientHeight+1?(ef(!1),eg.current&&(window.clearTimeout(eg.current),eg.current=null)):(ef(!1),eg.current&&window.clearTimeout(eg.current),eg.current=window.setTimeout(()=>{ef(!0)},180))};return e.addEventListener("scroll",t),eA(),()=>e.removeEventListener("scroll",t)},[eA,eu,ed,o]),(0,n.useEffect)(()=>{let e=es.current;if(!e)return;let t=new ResizeObserver(()=>{!ed&&(eu||er)&&eT("auto")});return t.observe(e),()=>t.disconnect()},[er,ed,eu,eT,o]),(0,n.useEffect)(()=>{eu&&eT("auto")},[eu,e,eT]);let eD=(0,n.useCallback)(()=>{let e=et.current;if(!e)return;let t=e.querySelectorAll('[data-role="user"]'),s=t[t.length-1];if(!s)return void eT("auto");let r=e.getBoundingClientRect(),a=Math.max(s.getBoundingClientRect().top-r.top+e.scrollTop-16,0);em(!0),e.scrollTo({top:a,behavior:"auto"}),requestAnimationFrame(()=>em(!1))},[eT]);(0,n.useEffect)(()=>{T?fetch(s?"/api/config.yaml?sessionId=".concat(s):"/api/config.yaml").then(e=>{if(!e.ok)throw Error("Failed to fetch configuration");return e.text()}).then(e=>{U(e),z(null)}).catch(e=>{console.error("Preview fetch failed:",e),z(e instanceof Error?e.message:"Preview fetch failed")}):(U(""),z(null),_(!1))},[T,s]);let eR=(0,n.useCallback)(async()=>{try{let e=s?"/api/config.yaml?sessionId=".concat(s):"/api/config.yaml",t=await fetch(e);if(!t.ok)throw Error("Failed to fetch configuration");let r=await t.text(),a=new Blob([r],{type:"application/x-yaml"}),n=URL.createObjectURL(a),l=document.createElement("a");l.href=n,l.download=s?"".concat(L,"-").concat(s,".yml"):"".concat(L,".yml"),document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(n)}catch(e){console.error("Download failed:",e),z(e instanceof Error?e.message:"Download failed")}},[L,s]),eL=(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(q),_(!0),setTimeout(()=>_(!1),2e3)}catch(e){console.error("Copy failed:",e),z("Failed to copy to clipboard")}},[q]),eP=(0,n.useCallback)(async(e,s,r)=>{$(!0),G(null);try{await t(e,s,r),setTimeout(()=>{eD(),ex(!0)},0)}catch(e){console.error("Failed to send message:",e),G(e instanceof Error?e.message:"Failed to send message"),setTimeout(()=>G(null),5e3)}finally{$(!1)}},[t,eD]);(0,n.useEffect)(()=>{let e=()=>ex(!0),t=()=>ex(!1);return window.addEventListener("dexto:message",e),window.addEventListener("dexto:response",t),()=>{window.removeEventListener("dexto:message",e),window.removeEventListener("dexto:response",t)}},[]);let ez=(0,n.useCallback)(e=>{r(e),S(!1)},[r]),eq=(0,n.useCallback)(async e=>{try{if(!(await fetch("/api/mcp/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({serverId:e.id})})).ok)throw Error("Failed to install server");w(!1),ew(e=>e+1)}catch(e){console.error("Failed to install server:",e),G(e instanceof Error?e.message:"Failed to install server"),setTimeout(()=>G(null),5e3)}},[N]),eJ=(0,n.useCallback)(async()=>{if(s){Z(!0);try{if(!(await fetch("/api/sessions/".concat(s),{method:"DELETE"})).ok)throw Error("Failed to delete conversation");Q(!1),d()}catch(e){console.error("Failed to delete conversation:",e),G(e instanceof Error?e.message:"Failed to delete conversation"),setTimeout(()=>G(null),5e3)}finally{Z(!1)}}},[s,d]);(0,n.useCallback)(e=>{e.preventDefault(),X.trim()&&(eP(X.trim()),ee(""))},[X,eP]);let e_=(0,n.useCallback)(async()=>{try{let e=await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!e.ok){let t="HTTP ".concat(e.status,": ").concat(e.statusText);try{let s=await e.json();t=s.message||s.error||t}catch(e){}throw Error(t)}let t=await e.json();ez(t.session.id)}catch(e){console.error("Error creating new session:",e),G("Failed to create new session. Please try again."),setTimeout(()=>G(null),5e3)}},[ez]),e$=[{title:"Help me get started",description:"Show me what you can do",action:()=>eP("I'm new to Dexto. Can you show me your capabilities and help me understand how to work with you effectively?"),icon:"\uD83D\uDE80"},{title:"Create Snake Game",description:"Build a game and open it",action:()=>eP("Create a snake game in a new directory with HTML, CSS, and JavaScript, then open it in the browser for me to play."),icon:"\uD83D\uDC0D"},{title:"Connect new tools",description:"Browse and add MCP servers",action:()=>k(!0),icon:"\uD83D\uDD27"},{title:"Demonstrate tools",description:"Show me your capabilities",action:()=>eP("Pick one of your most interesting tools and demonstrate it with a practical example. Show me what it can do."),icon:"⚡"}];return(0,n.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&!e.shiftKey&&"h"===e.key&&(e.preventDefault(),S(e=>!e)),(e.ctrlKey||e.metaKey)&&!e.shiftKey&&"k"===e.key&&(e.preventDefault(),e_()),(e.ctrlKey||e.metaKey)&&!e.shiftKey&&"j"===e.key&&(e.preventDefault(),k(e=>!e)),(e.ctrlKey||e.metaKey)&&e.shiftKey&&"s"===e.key&&(e.preventDefault(),e.stopPropagation(),E(!0)),(e.ctrlKey||e.metaKey)&&!e.shiftKey&&"l"===e.key&&(e.preventDefault(),window.open("/playground","_blank")),(e.ctrlKey||e.metaKey)&&e.shiftKey&&"e"===e.key&&(e.preventDefault(),D(!0)),(e.ctrlKey||e.metaKey)&&!e.shiftKey&&"/"===e.key&&(e.preventDefault(),V(!0)),"Escape"===e.key&&(N?k(!1):C?S(!1):y?w(!1):T?D(!1):M?V(!1):W?Q(!1):B&&G(null))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[N,C,A,y,T,M,W,B,E]),(0,a.jsxs)("div",{className:"flex h-screen bg-background",children:[(0,a.jsx)("div",{className:(0,i.cn)("shrink-0 transition-all duration-300 ease-in-out border-r border-border/50 bg-card/50 backdrop-blur-sm",C?"w-80":"w-0 overflow-hidden"),children:C&&(0,a.jsx)(eH,{isOpen:C,onClose:()=>S(!1),currentSessionId:s,onSessionChange:ez,returnToWelcome:d,variant:"inline",onSearchOpen:()=>E(!0)})}),(0,a.jsxs)("main",{className:"flex-1 flex flex-col relative",style:{"--thread-max-width":"54rem"},children:[null,(0,a.jsx)("header",{className:"shrink-0 border-b border-border/50 bg-background/95 backdrop-blur-xl shadow-sm",children:(0,a.jsxs)("div",{className:"flex justify-between items-center px-4 py-3",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>S(!C),className:(0,i.cn)("h-8 w-8 p-0 transition-colors",C&&"bg-muted"),children:(0,a.jsx)(e0.A,{className:"h-4 w-4"})})}),(0,a.jsx)(j,{children:"Chat History (⌘H)"})]}),!C&&(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"outline",size:"sm",onClick:e_,className:"h-8 w-8 p-0",children:(0,a.jsx)(eE.A,{className:"h-4 w-4"})})}),(0,a.jsx)(j,{children:"New Chat (⌘K)"})]}),(0,a.jsxs)("a",{href:"https://dexto.ai",target:"_blank",rel:"noopener noreferrer",className:"flex items-center space-x-3 hover:opacity-80 transition-opacity",children:[(0,a.jsx)("img",{src:"/logo.svg",alt:"Dexto",className:"h-8 w-auto"}),(0,a.jsx)("span",{className:"sr-only",children:"Dexto"})]}),s&&!o&&(0,a.jsx)("div",{className:"flex items-center space-x-2",children:(0,a.jsx)(eI.E,{variant:"secondary",className:"text-xs bg-muted/50 border-border/30",children:s})})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,a.jsx)(e9,{}),(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"ghost",size:"sm",onClick:()=>O(!0),className:"h-8 w-8 p-0","aria-label":"Open settings",children:(0,a.jsx)(eY.A,{className:"h-3.5 w-3.5"})})}),(0,a.jsx)(j,{children:"Settings"})]}),(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsxs)(b.$,{variant:"ghost",size:"sm",onClick:()=>k(!N),className:(0,i.cn)("h-8 px-2 text-sm transition-colors",N&&"bg-muted"),children:[(0,a.jsx)(I.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Tools"})]})}),(0,a.jsx)(j,{children:"Toggle tools panel (⌘J)"})]}),(0,a.jsxs)(g,{children:[(0,a.jsx)(v,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"ghost",size:"sm",asChild:!0,className:"h-8 px-2 text-sm",children:(0,a.jsxs)(e8(),{href:"/playground",target:"_blank",rel:"noopener noreferrer",children:[(0,a.jsx)(e1.A,{className:"h-3.5 w-3.5"}),(0,a.jsx)("span",{className:"hidden sm:inline ml-1.5",children:"Playground"})]})})}),(0,a.jsx)(j,{children:"Open MCP playground (⌘L)"})]}),(0,a.jsxs)(en,{children:[(0,a.jsx)(el,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:(0,a.jsx)(e2.A,{className:"h-3.5 w-3.5"})})}),(0,a.jsxs)(ei,{align:"end",children:[(0,a.jsxs)(eo,{onClick:()=>w(!0),children:[(0,a.jsx)(eO.A,{className:"h-4 w-4 mr-2"}),"Browse MCP Registry"]}),(0,a.jsxs)(eo,{onClick:()=>D(!0),children:[(0,a.jsx)(e4.A,{className:"h-4 w-4 mr-2"}),"Export Config"]}),(0,a.jsxs)(eo,{onClick:()=>V(!0),children:[(0,a.jsx)(e5.A,{className:"h-4 w-4 mr-2"}),"Shortcuts"]}),s&&!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec,{}),(0,a.jsxs)(eo,{onClick:()=>Q(!0),className:"text-destructive focus:text-destructive",children:[(0,a.jsx)(eU.A,{className:"h-4 w-4 mr-2"}),"Delete Conversation"]})]})]})]})]})]})}),(0,a.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[B&&(0,a.jsx)("div",{className:"absolute top-4 right-4 z-50 bg-destructive text-destructive-foreground px-4 py-2 rounded-md shadow-lg",children:B}),(0,a.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:o||0===e.length?(0,a.jsx)("div",{className:"flex-1 flex items-center justify-center p-6 -mt-20",children:(0,a.jsxs)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto space-y-6",children:[(0,a.jsxs)("div",{className:"text-center space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3",children:[(0,a.jsx)("img",{src:"/logo_no_text.png",alt:"Dexto",className:"h-8 w-auto"}),(0,a.jsx)("h2",{className:"text-2xl font-bold font-mono tracking-tight bg-gradient-to-r from-primary to-primary/70 bg-clip-text text-transparent",children:"Welcome to Dexto"})]}),(0,a.jsx)("p",{className:"text-base text-muted-foreground max-w-xl mx-auto leading-relaxed",children:"Your AI assistant with powerful tools. Ask anything or connect new capabilities."})]}),(0,a.jsx)("div",{className:"flex flex-wrap justify-center gap-2 max-w-[var(--thread-max-width)] mx-auto",children:e$.map((e,t)=>(0,a.jsx)("button",{onClick:e.action,className:"group px-3 py-2 text-left rounded-full bg-primary/5 hover:bg-primary/10 transition-all duration-200 hover:shadow-sm hover:scale-105",children:(0,a.jsxs)("div",{className:"flex items-center space-x-1.5",children:[(0,a.jsx)("span",{className:"text-sm",children:e.icon}),(0,a.jsx)("span",{className:"font-medium text-sm text-primary group-hover:text-primary/80 transition-colors",children:e.title})]})},t))}),(0,a.jsx)("div",{className:"max-w-[var(--thread-max-width)] mx-auto",children:(0,a.jsx)(ej,{onSend:eP,isSending:K,variant:"welcome"})}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground space-y-1 text-center",children:(0,a.jsxs)("p",{children:["\uD83D\uDCA1 Try ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘K"})," for new chat, ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘J"})," for tools, ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘L"})," for playground, ",(0,a.jsx)("kbd",{className:"px-1 py-0.5 bg-muted rounded text-xs",children:"⌘/"})," for shortcuts"]})})]})}):(0,a.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden",children:(0,a.jsx)("div",{ref:et,className:"h-full overflow-y-auto overscroll-contain relative",children:(0,a.jsxs)("div",{className:"min-h-full grid grid-rows-[1fr_auto]",children:[(0,a.jsx)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto",children:(0,a.jsx)(H,{messages:e,activeError:x,onDismissError:h,outerRef:es})}),(0,a.jsxs)("div",{className:"sticky bottom-0 z-10 px-4 pt-2 pb-[calc(env(safe-area-inset-bottom)+16px)] bg-background relative",children:[ep&&(0,a.jsx)("div",{className:"absolute left-1/2 -translate-x-1/2 -top-3 z-20 pointer-events-none",children:(0,a.jsxs)("button",{onClick:()=>{ef(!1),eT("smooth")},className:"pointer-events-auto px-3 py-1.5 rounded-full shadow-sm bg-background/95 border border-border/60 backdrop-blur supports-[backdrop-filter]:bg-background/80 text-sm text-muted-foreground hover:text-foreground transition-colors inline-flex items-center gap-1.5",children:[(0,a.jsx)("span",{children:"Scroll to bottom"}),(0,a.jsx)(m.A,{className:"h-3.5 w-3.5"})]})}),(0,a.jsx)("div",{className:"w-full max-w-[var(--thread-max-width)] mx-auto pointer-events-auto",children:(0,a.jsx)(ej,{onSend:eP,isSending:K,variant:"chat"})})]})]})})})}),(0,a.jsx)("div",{className:(0,i.cn)("shrink-0 transition-all duration-300 ease-in-out border-l border-border/50 bg-card/50 backdrop-blur-sm",N?"w-80":"w-0 overflow-hidden"),children:N&&(0,a.jsx)(eK,{isOpen:N,onClose:()=>k(!1),onOpenConnectModal:()=>f(!0),variant:"inline",refreshTrigger:ey})})]}),(0,a.jsx)(eb.A,{isOpen:p,onClose:()=>f(!1),onServerConnected:()=>{ew(e=>e+1)}}),(0,a.jsx)(eF,{isOpen:y,onClose:()=>w(!1),onInstallServer:eq}),(0,a.jsx)(eN.lG,{open:T,onOpenChange:D,children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-2xl",children:[(0,a.jsxs)(eN.c7,{children:[(0,a.jsxs)(eN.L3,{className:"flex items-center space-x-2",children:[(0,a.jsx)(e4.A,{className:"h-5 w-5"}),(0,a.jsx)("span",{children:"Export Configuration"})]}),(0,a.jsxs)(eN.rr,{children:["Download your tool configuration for Claude Desktop or other MCP clients",s&&(0,a.jsxs)("span",{className:"block mt-1 text-sm text-muted-foreground",children:["Including session-specific settings for: ",(0,a.jsx)("span",{className:"font-mono",children:s})]})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{htmlFor:"filename",children:"File name"}),(0,a.jsx)(ek.p,{id:"filename",value:L,onChange:e=>F(e.target.value),placeholder:"dexto-config",className:"font-mono"})]}),P&&(0,a.jsxs)(ev.Fc,{variant:"destructive",children:[(0,a.jsx)(c.A,{className:"h-4 w-4"}),(0,a.jsx)(ev.XL,{children:"Export Error"}),(0,a.jsx)(ev.TN,{children:P})]}),q&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(eC.J,{children:"Configuration Preview"}),(0,a.jsx)(eS.T,{value:q,readOnly:!0,className:"h-32 font-mono text-xs bg-muted/30"})]})]}),(0,a.jsxs)(eN.Es,{children:[(0,a.jsx)(b.$,{variant:"outline",onClick:eL,className:"flex items-center space-x-2",children:(0,a.jsx)("span",{children:J?"Copied!":"Copy"})}),(0,a.jsxs)(b.$,{onClick:eR,className:"flex items-center space-x-2",children:[(0,a.jsx)(e4.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:"Download"})]})]})]})}),(0,a.jsx)(tt,{isOpen:R,onClose:()=>O(!1)}),(0,a.jsx)(eN.lG,{open:W,onOpenChange:Q,children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(eN.c7,{children:[(0,a.jsxs)(eN.L3,{className:"flex items-center space-x-2",children:[(0,a.jsx)(eU.A,{className:"h-5 w-5 text-destructive"}),(0,a.jsx)("span",{children:"Delete Conversation"})]}),(0,a.jsxs)(eN.rr,{children:["This will permanently delete this conversation and all its messages. This action cannot be undone.",s&&(0,a.jsxs)("span",{className:"block mt-2 font-medium",children:["Session: ",(0,a.jsx)("span",{className:"font-mono",children:s})]})]})]}),(0,a.jsxs)(eN.Es,{children:[(0,a.jsx)(b.$,{variant:"outline",onClick:()=>Q(!1),children:"Cancel"}),(0,a.jsxs)(b.$,{variant:"destructive",onClick:eJ,disabled:Y,className:"flex items-center space-x-2",children:[(0,a.jsx)(eU.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:Y?"Deleting...":"Delete Conversation"})]})]})]})}),(0,a.jsx)(eN.lG,{open:M,onOpenChange:V,children:(0,a.jsxs)(eN.Cf,{className:"sm:max-w-md",children:[(0,a.jsx)(eN.c7,{children:(0,a.jsxs)(eN.L3,{className:"flex items-center space-x-2",children:[(0,a.jsx)(e5.A,{className:"h-5 w-5"}),(0,a.jsx)("span",{children:"Keyboard Shortcuts"})]})}),(0,a.jsx)("div",{className:"space-y-3",children:[{key:"⌘H",desc:"Toggle chat history panel"},{key:"⌘K",desc:"Create new chat"},{key:"⌘J",desc:"Toggle tools panel"},{key:"⌘⇧S",desc:"Search conversations"},{key:"⌘L",desc:"Open MCP playground"},{key:"⌘⇧E",desc:"Export config"},{key:"⌘/",desc:"Show shortcuts"},{key:"Esc",desc:"Close panels"}].map((e,t)=>(0,a.jsxs)("div",{className:"flex justify-between items-center py-1",children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:e.desc}),(0,a.jsx)(eI.E,{variant:"outline",className:"font-mono text-xs",children:e.key})]},t))}),(0,a.jsx)(eN.Es,{children:(0,a.jsx)(eN.HM,{asChild:!0,children:(0,a.jsx)(b.$,{variant:"outline",children:"Close"})})})]})})]}),(0,a.jsx)(eX,{isOpen:A,onClose:()=>E(!1),onNavigateToSession:(e,t)=>{r(e),E(!1)}}),(0,a.jsx)(eQ,{websocket:u})]})}},8958:(e,t,s)=>{Promise.resolve().then(s.bind(s,7067))}},e=>{var t=t=>e(e.s=t);e.O(0,[62,190,588,487,441,684,358],()=>t(8958)),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[882],{704:(e,t,r)=>{Promise.resolve().then(r.bind(r,7959))},7959:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>T});var s=r(5155),a=r(2115),n=r(6874),l=r.n(n),o=r(9946);let i=(0,o.A)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);var c=r(4186),d=r(646);let m=(0,o.A)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var u=r(1243),p=r(4357);let x=(0,o.A)("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);var h=r(8861),f=r(8240),g=r(4823),b=r(9852),y=r(5139),v=r(5784),j=r(9474),N=r(2714),w=r(7168),S=r(8145),k=r(9026);function C(){var e,t,r,n,o,C,T;let[O,A]=(0,a.useState)([]),[E,J]=(0,a.useState)(null),[z,q]=(0,a.useState)([]),[D,_]=(0,a.useState)(null),[F,P]=(0,a.useState)({}),[R,I]=(0,a.useState)(null),[$,M]=(0,a.useState)(!1),[W,L]=(0,a.useState)(null),[Z,Q]=(0,a.useState)({}),[U,B]=(0,a.useState)(!1),[H,V]=(0,a.useState)(null),[G,K]=(0,a.useState)([]),[X]=(0,a.useState)(Date.now()),[Y]=(0,a.useState)([{name:"Quick Test",description:"Fill with test values",apply:e=>{var t;let r={};return(null==(t=e.inputSchema)?void 0:t.properties)&&Object.entries(e.inputSchema.properties).forEach(e=>{let[t,s]=e;"string"===s.type?r[t]="test-".concat(t):"number"===s.type?r[t]=42:"boolean"===s.type?r[t]=!0:"object"===s.type?r[t]='{"example": "value"}':"array"===s.type&&(r[t]='["example"]')}),r}},{name:"Empty Form",description:"Clear all fields",apply:()=>({})},{name:"Required Only",description:"Fill only required fields",apply:e=>{var t,r;let s={};return(null==(t=e.inputSchema)?void 0:t.properties)&&(null==(r=e.inputSchema)?void 0:r.required)&&e.inputSchema.required.forEach(t=>{let r=e.inputSchema.properties[t];"string"===r.type||"number"===r.type?s[t]="":"boolean"===r.type?s[t]=!1:"object"===r.type?s[t]="{}":"array"===r.type&&(s[t]="[]")}),s}}]),ee="/api",et=(0,a.useRef)(null),er=(0,a.useRef)(null);(0,a.useEffect)(()=>()=>{var e;null==(e=et.current)||e.abort()},[]);let es=(e,t)=>{console.error("Playground Error (".concat(t||"general","):"),e),"input"!==t&&L(e)},ea=(0,a.useCallback)(async()=>{M(!0),L(null);try{let e=await fetch("".concat(ee,"/mcp/servers"));if(!e.ok){let t=await e.json().catch(()=>({error:"Failed to fetch servers"}));throw Error(t.error||"Server List: ".concat(e.statusText))}let t=await e.json();A(t.servers||[]),t.servers&&0!==t.servers.length||console.log("No MCP servers found or returned from API.")}catch(e){es(e.message,"servers"),A([])}finally{M(!1)}},[]);(0,a.useEffect)(()=>{ea()},[ea]);let en=(0,a.useCallback)(async e=>{var t;null==(t=et.current)||t.abort();let r=new AbortController;if(et.current=r,J(e),_(null),I(null),q([]),L(null),Q({}),"connected"!==e.status)return void console.warn('Server "'.concat(e.name,'" is ').concat(e.status,". Cannot fetch tools."));M(!0);try{let t=await fetch("".concat(ee,"/mcp/servers/").concat(e.id,"/tools"),{signal:r.signal});if(!t.ok){let r=await t.json().catch(()=>({error:"Failed to fetch tools for ".concat(e.name)}));throw Error(r.error||"Tool List (".concat(e.name,"): ").concat(t.statusText))}let s=await t.json();if(r.signal.aborted)return;q(s.tools||[]),s.tools&&0!==s.tools.length||console.log('No tools found for server "'.concat(e.name,'".'))}catch(e){"AbortError"!==e.name&&(es(e.message,"tools"),q([]))}finally{r.signal.aborted||M(!1)}},[]),el=(0,a.useCallback)(e=>{_(e),I(null),L(null),Q({});let t={};if(e.inputSchema&&e.inputSchema.properties)for(let r in e.inputSchema.properties){let s=e.inputSchema.properties[r];void 0!==s.default?t[r]=s.default:"boolean"===s.type?t[r]=!1:("number"===s.type||"integer"===s.type||"object"===s.type||s.type,t[r]="")}P(t)},[]),eo=(0,a.useCallback)((e,t,r)=>{if((P(r=>({...r,[e]:t})),Z[e]&&Q(t=>({...t,[e]:""})),"object"===r||"array"===r)&&""!==t)try{JSON.parse(t)}catch(t){Q(t=>({...t,[e]:"Invalid JSON format"}));return}},[Z]),ei=()=>{if(!D||!D.inputSchema||!D.inputSchema.properties)return!0;let e={},t=!0;for(let s in D.inputSchema.properties){var r;let a=D.inputSchema.properties[s],n=F[s];if((null==(r=D.inputSchema.required)?void 0:r.includes(s))&&(void 0===n||""===n||"boolean"===a.type&&"boolean"!=typeof n)){e[s]="This field is required.",t=!1;continue}if(("number"===a.type||"integer"===a.type)&&""!==n&&isNaN(Number(n))&&(e[s]="Must be a valid number.",t=!1),("object"===a.type||"array"===a.type)&&""!==n)try{JSON.parse(n)}catch(r){e[s]="Invalid JSON format.",t=!1}}return Q(e),t},ec=(0,a.useCallback)(async()=>{var e;if(!E||!D)return void es("No server or tool selected for execution.","execution");null==(e=er.current)||e.abort();let t=new AbortController;if(er.current=t,L(null),I(null),!ei())return void es("Please correct the input errors.","input");let r=Date.now(),s="exec_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9));M(!0);try{let e={};if(D.inputSchema&&D.inputSchema.properties)for(let t in D.inputSchema.properties){let r=D.inputSchema.properties[t],s=F[t];if("number"===r.type)s=""===s?void 0:Number(s);else if("integer"===r.type)if(""===s)s=void 0;else{let e=Number(s);if(!Number.isInteger(e)){Q(e=>({...e,[t]:"Must be a valid integer."})),M(!1);return}s=e}else if("boolean"===r.type)s="string"==typeof s?"true"===s:!!s;else if(("object"===r.type||"array"===r.type)&&"string"==typeof s&&""!==s.trim())try{s=JSON.parse(s)}catch(e){Q(e=>({...e,[t]:"Invalid JSON before sending."})),M(!1);return}else("object"===r.type||"array"===r.type)&&(void 0===s||""===s)&&(s=void 0);void 0!==s&&(e[t]=s)}let a=await fetch("".concat(ee,"/mcp/servers/").concat(E.id,"/tools/").concat(D.id,"/execute"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:t.signal}),n=await a.json();if(!a.ok)throw Error(n.error||"Tool Execution (".concat(D.name,"): ").concat(a.statusText));let l=Date.now()-r;I(n),K(e=>[{id:s,toolName:D.name,timestamp:new Date,success:!0,duration:l},...e.slice(0,9)])}catch(e){if("AbortError"!==e.name){let t=Date.now()-r;es(e.message,"execution"),e.message&&(!R||R.success||R.error!==e.message)&&I({success:!1,error:e.message}),K(e=>[{id:s,toolName:(null==D?void 0:D.name)||"Unknown",timestamp:new Date,success:!1,duration:t},...e.slice(0,9)])}}finally{t.signal.aborted||M(!1)}},[E,D,F,ei,R]),ed=async(e,t)=>{try{await navigator.clipboard.writeText(e),V({message:t||"Copied to clipboard",type:"success"}),setTimeout(()=>V(null),3e3)}catch(e){V({message:"Failed to copy to clipboard. Please check browser permissions.",type:"error"}),setTimeout(()=>V(null),5e3),console.error("Failed to copy to clipboard:",e)}};return(0,s.jsxs)("div",{className:"flex h-screen bg-muted/40 text-foreground antialiased",children:[(0,s.jsxs)("aside",{className:"w-72 flex-shrink-0 border-r border-border bg-background p-4 flex flex-col rounded-r-lg shadow-md",children:[(0,s.jsx)("div",{className:"flex items-center justify-between pb-3 mb-3 border-b border-border",children:(0,s.jsx)(l(),{href:"/",children:(0,s.jsx)(w.$,{variant:"outline",size:"sm",className:"pl-2 pr-3",asChild:!0,children:(0,s.jsxs)("span",{children:[(0,s.jsx)(i,{className:"h-4 w-4 mr-1.5"}),"Back to Chat"]})})})}),(0,s.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground px-1",children:"MCP Servers"}),$&&0===O.length&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading..."})]}),W&&0===O.length&&!$&&(0,s.jsxs)("p",{className:"text-destructive text-sm p-2 bg-destructive/10 rounded-md",children:["Error: ",W]}),0===O.length&&!$&&!W&&(0,s.jsx)("p",{className:"text-muted-foreground text-sm px-1",children:"No servers available."}),(0,s.jsx)("div",{className:"flex-grow overflow-y-auto space-y-1 pr-1 -mr-1",children:O.length>0&&(0,s.jsx)("ul",{className:"space-y-1",children:O.map(e=>(0,s.jsx)("li",{className:"p-2.5 rounded-md cursor-pointer hover:bg-muted transition-colors group \n ".concat((null==E?void 0:E.id)===e.id?"bg-primary text-primary-foreground hover:bg-primary/90":"text-foreground hover:text-primary","\n ").concat("connected"!==e.status?"opacity-60 cursor-not-allowed":""),onClick:()=>"connected"===e.status&&en(e),title:"connected"!==e.status?"".concat(e.name," is ").concat(e.status):e.name,children:(0,s.jsxs)("div",{className:"flex justify-between items-center",children:[(0,s.jsx)("span",{className:"font-medium truncate group-hover:text-primary-foreground_conditional",children:e.name}),(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full \n ".concat("connected"===e.status?"bg-green-100 text-green-700 dark:bg-green-700/20 dark:text-green-400":"disconnected"===e.status?"bg-slate-100 text-slate-600 dark:bg-slate-700/20 dark:text-slate-400":"bg-yellow-100 text-yellow-700 dark:bg-yellow-700/20 dark:text-yellow-400"),children:e.status})]})},e.id))})}),(0,s.jsx)(w.$,{onClick:()=>B(!0),variant:"outline",className:"mt-auto w-full sticky bottom-0 left-0 right-0 bg-background hover:bg-muted py-3",children:"Connect New Server"})]}),(0,s.jsxs)("section",{className:"w-80 flex-shrink-0 border-r border-border bg-background p-4 flex flex-col rounded-l-none shadow-md",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center pb-3 mb-3 border-b border-border",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground px-1",children:"Tools"}),E&&"connected"===E.status&&$&&0===z.length&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Loading..."})]}),(0,s.jsxs)("div",{className:"flex-grow overflow-y-auto space-y-1 pr-1 -mr-1",children:[!E&&(0,s.jsx)("p",{className:"text-muted-foreground text-sm px-1",children:"Select a connected server to view tools."}),E&&"connected"!==E.status&&(0,s.jsxs)("p",{className:"text-muted-foreground text-sm px-1",children:['Server "',E.name,'" is ',E.status,". Tools unavailable."]}),E&&"connected"===E.status&&!$&&0===z.length&&!W&&(0,s.jsxs)("p",{className:"text-muted-foreground text-sm px-1",children:["No tools found for ",E.name,"."]}),W&&(null==E?void 0:E.status)==="connected"&&0===z.length&&!$&&(0,s.jsxs)("p",{className:"text-destructive text-sm p-2 bg-destructive/10 rounded-md",children:["Error loading tools: ",W]}),z.length>0&&(0,s.jsx)("ul",{className:"space-y-1",children:z.map(e=>(0,s.jsxs)("li",{className:"p-3 rounded-md cursor-pointer hover:bg-muted transition-colors group\n ".concat((null==D?void 0:D.id)===e.id?"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90":"text-foreground hover:text-primary"),onClick:()=>el(e),children:[(0,s.jsx)("h3",{className:"font-medium truncate group-hover:text-primary-foreground_conditional",children:e.name}),e.description&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-0.5 group-hover:text-primary-foreground_conditional/80",children:e.description})]},e.id))})]})]}),(0,s.jsxs)("main",{className:"flex-1 p-6 flex flex-col bg-zinc-50 dark:bg-zinc-900 overflow-y-auto",children:[(0,s.jsx)("div",{className:"pb-3 mb-4 border-b border-border",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Tool Runner"}),G.length>0&&(0,s.jsxs)("div",{className:"flex items-center space-x-4 mt-2 text-sm text-muted-foreground",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,s.jsx)(c.A,{className:"h-3 w-3"}),(0,s.jsxs)("span",{children:[G.length," executions this session"]})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,s.jsx)(d.A,{className:"h-3 w-3 text-green-500"}),(0,s.jsx)("span",{children:G.filter(e=>e.success).length})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,s.jsx)(m,{className:"h-3 w-3 text-red-500"}),(0,s.jsx)("span",{children:G.filter(e=>!e.success).length})]})]})]})]}),G.length>0&&(0,s.jsxs)("div",{className:"hidden lg:block",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground mb-2",children:"Recent executions"}),(0,s.jsx)("div",{className:"flex space-x-1",children:G.slice(0,5).map(e=>(0,s.jsxs)(S.E,{variant:e.success?"secondary":"destructive",className:"text-xs px-2 py-1 truncate max-w-24",title:"".concat(e.toolName," - ").concat(e.success?"Success":"Failed"," (").concat(e.duration,"ms)"),children:[e.toolName.slice(0,8),e.toolName.length>8&&"..."]},e.id))})]})]})}),W&&D&&(!R||!R.success)&&(0,s.jsxs)("div",{className:"mb-4 p-3 border border-destructive/50 bg-destructive/10 rounded-md text-destructive text-sm",children:[(0,s.jsx)("p",{className:"font-medium",children:"Error:"}),(0,s.jsx)("p",{children:W})]}),H&&(0,s.jsxs)(k.Fc,{variant:"error"===H.type?"destructive":"default",className:"mb-4 ".concat("success"===H.type?"border-green-200 bg-green-50 text-green-800 dark:border-green-800 dark:bg-green-950 dark:text-green-400":""),children:["error"===H.type&&(0,s.jsx)(u.A,{className:"h-4 w-4"}),"success"===H.type&&(0,s.jsx)(d.A,{className:"h-4 w-4"}),(0,s.jsx)(k.TN,{children:H.message})]}),!D&&(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsxs)("div",{className:"text-center max-w-md",children:[(0,s.jsx)("div",{className:"mb-4",children:(0,s.jsx)(i,{className:"h-12 w-12 mx-auto text-muted-foreground opacity-50"})}),(0,s.jsx)("h3",{className:"text-lg font-semibold mb-2",children:"Select a Tool"}),(0,s.jsx)("p",{className:"text-muted-foreground",children:"Choose a tool from the left panel to start testing and experimenting with MCP capabilities."})]})}),D&&(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsx)("div",{className:"p-4 border border-border rounded-lg bg-card shadow-sm",children:(0,s.jsxs)("div",{className:"flex justify-between items-start",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-base font-semibold text-primary mb-1",children:D.name}),D.description&&(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:D.description})]}),(0,s.jsxs)("div",{className:"text-right text-xs text-muted-foreground",children:[(0,s.jsxs)("p",{children:["Server: ",null==E?void 0:E.name]}),G.filter(e=>e.toolName===D.name).length>0&&(0,s.jsxs)("p",{children:["Runs: ",G.filter(e=>e.toolName===D.name).length]})]})]})}),(0,s.jsxs)("form",{onSubmit:e=>{e.preventDefault(),ei()&&ec()},className:"space-y-5 p-4 border border-border rounded-lg bg-card shadow-sm",children:[D&&(null==(e=D.inputSchema)?void 0:e.properties)&&Object.keys(D.inputSchema.properties).length>0&&(0,s.jsxs)("div",{className:"border-b border-border pb-4",children:[(0,s.jsx)("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Quick Fill Templates"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:Y.map((e,t)=>(0,s.jsx)(w.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{P(e.apply(D)),Q({})},className:"text-xs",title:e.description,children:e.name},t))})]}),D&&D.inputSchema&&D.inputSchema.properties?Object.entries(D.inputSchema.properties).map(e=>{var t,r;let a,[n,l]=e,o=null==(r=D.inputSchema)||null==(t=r.required)?void 0:t.includes(n),i=Z[n],c="w-full ".concat(i?"border-destructive focus-visible:ring-destructive":"border-input");if(l.enum&&Array.isArray(l.enum)){let e=l.enum.every(e=>"boolean"==typeof e),t=l.enum.every(e=>"number"==typeof e);a=(0,s.jsxs)(v.l6,{value:void 0===F[n]&&void 0!==l.default?String(l.default):String(F[n]||""),onValueChange:r=>{let s=r;e?s="true"===r:t&&(s=Number(r)),eo(n,s,l.type)},disabled:$,children:[(0,s.jsx)(v.bq,{id:n,className:c,children:(0,s.jsx)(v.yv,{placeholder:"Select ".concat(l.description||n).concat(o?"":" (optional)","...")})}),(0,s.jsx)(v.gC,{children:l.enum.map(e=>(0,s.jsx)(v.eb,{value:String(e),children:String(e)},String(e)))})]})}else if("boolean"===l.type)a=(0,s.jsx)(y.S,{id:n,checked:void 0===F[n]&&void 0!==l.default?!!l.default:!!F[n],onCheckedChange:e=>eo(n,e,l.type),disabled:$,className:"".concat(i?"border-destructive ring-destructive":"")});else if("object"===l.type||"array"===l.type)a=(0,s.jsx)(j.T,{id:n,value:void 0===F[n]&&void 0!==l.default?JSON.stringify(l.default,null,2):F[n]||"",onChange:e=>eo(n,e.target.value,l.type),rows:5,className:"".concat(c," font-mono text-sm min-h-[100px] resize-y"),placeholder:"Enter JSON for ".concat(l.description||n),disabled:$});else{let e="text";("number"===l.type||"integer"===l.type)&&(e="number"),"date-time"===l.format&&(e="datetime-local"),"date"===l.format&&(e="date"),"email"===l.format&&(e="email"),"uri"===l.format&&(e="url"),"password"===l.format&&(e="password"),a=(0,s.jsx)(b.p,{type:e,id:n,value:void 0===F[n]&&void 0!==l.default?String(l.default):String(F[n]||""),onChange:e=>eo(n,e.target.value,l.type),className:c,placeholder:l.description||"Enter ".concat(n),disabled:$,step:"number"===l.type||"integer"===l.type?"any":void 0})}return(0,s.jsxs)("div",{className:"grid gap-1.5",children:[(0,s.jsxs)("div",{className:"flex ".concat("boolean"===l.type?"flex-row items-center space-x-3":"flex-col"),children:[(0,s.jsxs)(N.J,{htmlFor:n,className:"".concat("boolean"===l.type?"leading-none cursor-pointer peer-disabled:cursor-not-allowed peer-disabled:opacity-70":"capitalize font-medium"),children:[l.description||n.replace(/([A-Z]+(?=[A-Z][a-z]))|([A-Z][a-z])/g," $&").trim().replace(/_/g," "),o&&(0,s.jsx)("span",{className:"text-destructive text-lg ml-0.5",children:"*"})]}),"boolean"===l.type?a:(0,s.jsx)("div",{className:"w-full",children:a})]}),i&&(0,s.jsx)("p",{className:"text-xs text-destructive",children:i})]},n)}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"This tool does not require any inputs, or its input schema is not defined."}),D&&(0,s.jsx)(w.$,{type:"submit",disabled:$||E&&"connected"!==E.status||Object.keys(Z).some(e=>""!==Z[e]),className:"w-full sm:w-auto mt-3 py-2.5 px-6",children:$?"Executing...":"Run Tool"}),D&&Object.keys(F).length>0&&(0,s.jsxs)("div",{className:"flex gap-2 mt-4 pt-4 border-t border-border",children:[(0,s.jsxs)(w.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{D&&E&&ed(JSON.stringify({server:E.name,tool:D.name,inputs:F,timestamp:new Date().toISOString()},null,2),"Tool configuration copied!")},className:"flex items-center gap-2",children:[(0,s.jsx)(p.A,{className:"h-3 w-3"}),"Copy Config"]}),(0,s.jsxs)(w.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(!D||!E)return;E.name,D.name;let e="Check out this Dexto tool configuration:\n\nServer: ".concat(E.name,"\nTool: ").concat(D.name,"\nInputs: ").concat(JSON.stringify(F,null,2));navigator.share?navigator.share({title:"Dexto Tool: ".concat(D.name),text:e}):ed(e,"Tool configuration copied for sharing!")},className:"flex items-center gap-2",children:[(0,s.jsx)(x,{className:"h-3 w-3"}),"Share"]})]})]}),R&&(0,s.jsxs)("div",{className:"mt-6 p-4 border border-border rounded-lg bg-muted/30",children:[(0,s.jsxs)("div",{className:"flex justify-between items-center mb-3",children:[(0,s.jsxs)("h3",{className:"text-lg font-semibold text-foreground",children:["Tool Result for ",(0,s.jsx)("span",{className:"font-bold text-primary",children:null==D?void 0:D.name})]}),(0,s.jsxs)(w.$,{variant:"outline",size:"sm",onClick:()=>{R&&ed("object"==typeof R.data?JSON.stringify(R.data,null,2):String(R.data),"Tool result copied!")},className:"flex items-center gap-2",children:[(0,s.jsx)(p.A,{className:"h-3 w-3"}),"Copy Result"]})]}),R.success?(0,s.jsx)("div",{className:"space-y-3 text-sm",children:((null==(r=R.metadata)||null==(t=r.mimeType)?void 0:t.startsWith("image/"))||(null==(o=R.metadata)||null==(n=o.type)?void 0:n.startsWith("image"))||R.data&&"object"==typeof R.data&&Array.isArray(R.data.content))&&R.data?(()=>{var e;let t="",r=null,a=null==(e=R.metadata)?void 0:e.mimeType,n=[];if(Array.isArray(R.data))(r=R.data.find(e=>e&&"image"===e.type))&&"string"==typeof r.data&&r.mimeType&&(t="data:".concat(r.mimeType,";base64,").concat(r.data));else if(R.data&&"object"==typeof R.data&&Array.isArray(R.data.content)){let e=R.data.content;if((r=e.find(e=>e&&"image"===e.type))&&"string"==typeof r.data){let e=r.mimeType||a;e&&(t="data:".concat(e,";base64,").concat(r.data))}n=e.filter(e=>e&&"image"!==e.type)}else"string"==typeof R.data&&(R.data.startsWith("data:image")?t=R.data:a?t="data:".concat(a,";base64,").concat(R.data):(R.data.startsWith("http://")||R.data.startsWith("https://"))&&(t=R.data));return t?(0,s.jsx)("img",{src:t,alt:"Tool result image",className:"my-2 max-h-96 w-auto rounded border border-input shadow-sm"}):n.length>0?(0,s.jsx)("div",{className:"space-y-3",children:n.map((e,t)=>(0,s.jsx)("pre",{className:"whitespace-pre-wrap text-sm bg-background p-3 rounded-md border border-input font-mono overflow-x-auto max-h-64",children:"object"==typeof e?JSON.stringify(e,null,2):String(e)},t))}):(0,s.jsxs)("p",{className:"text-xs text-destructive",children:["Image data is not in a recognized format. Data: ",JSON.stringify(R.data)]})})():(null==(C=R.metadata)?void 0:C.type)==="markdown"&&R.data?(0,s.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none p-3 bg-background rounded border border-input leading-relaxed",children:(0,s.jsx)(f.oz,{remarkPlugins:[g.A],children:"string"==typeof R.data?R.data:JSON.stringify(R.data,null,2)})}):(null==(T=R.metadata)?void 0:T.type)==="json"&&R.data?(0,s.jsx)("pre",{className:"whitespace-pre-wrap text-sm bg-background p-3 rounded-md border border-input font-mono",children:"string"==typeof R.data?R.data:JSON.stringify(R.data,null,2)}):(0,s.jsx)("pre",{className:"whitespace-pre-wrap text-sm bg-background p-3 rounded-md border border-input",children:"object"==typeof R.data?JSON.stringify(R.data,null,2):String(R.data)})}):(0,s.jsxs)("div",{className:"p-3 bg-destructive/10 rounded-md",children:[(0,s.jsx)("p",{className:"text-sm text-destructive font-semibold",children:"Error executing tool:"}),(0,s.jsx)("pre",{className:"mt-1 text-xs text-destructive whitespace-pre-wrap break-all",children:R.error||"Unknown error"})]})]})]})]}),(0,s.jsx)(h.A,{isOpen:U,onClose:()=>{B(!1),ea()}})]})}function T(){return(0,s.jsx)(C,{})}}},e=>{var t=t=>e(e.s=t);e.O(0,[62,588,441,684,358],()=>t(704)),_N_E=e.O()}]);