larkup 0.1.28 → 0.1.29

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 (214) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +5 -5
  3. package/.next/diagnostics/route-bundle-stats.json +25 -25
  4. package/.next/fallback-build-manifest.json +3 -3
  5. package/.next/next-minimal-server.js.nft.json +1 -1
  6. package/.next/next-server.js.nft.json +1 -1
  7. package/.next/prerender-manifest.json +3 -3
  8. package/.next/required-server-files.js +4 -4
  9. package/.next/required-server-files.json +4 -4
  10. package/.next/server/app/_global-error/page/build-manifest.json +2 -2
  11. package/.next/server/app/_global-error/page.js.nft.json +1 -1
  12. package/.next/server/app/_global-error.html +1 -1
  13. package/.next/server/app/_global-error.rsc +1 -1
  14. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  15. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  17. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  18. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  19. package/.next/server/app/_not-found/page/build-manifest.json +2 -2
  20. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  21. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  22. package/.next/server/app/_not-found.html +1 -1
  23. package/.next/server/app/_not-found.rsc +16 -16
  24. package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
  25. package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  26. package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
  27. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  28. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  29. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  30. package/.next/server/app/analytics/page/build-manifest.json +2 -2
  31. package/.next/server/app/analytics/page.js.nft.json +1 -1
  32. package/.next/server/app/analytics/page_client-reference-manifest.js +1 -1
  33. package/.next/server/app/analytics.html +1 -1
  34. package/.next/server/app/analytics.rsc +17 -17
  35. package/.next/server/app/analytics.segments/_full.segment.rsc +17 -17
  36. package/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
  37. package/.next/server/app/analytics.segments/_index.segment.rsc +11 -11
  38. package/.next/server/app/analytics.segments/_tree.segment.rsc +1 -1
  39. package/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +3 -3
  40. package/.next/server/app/analytics.segments/analytics.segment.rsc +3 -3
  41. package/.next/server/app/api/analytics/route.js.nft.json +1 -1
  42. package/.next/server/app/api/chat/route.js +8 -9
  43. package/.next/server/app/api/chat/route.js.nft.json +1 -1
  44. package/.next/server/app/api/chat/status/route.js.nft.json +1 -1
  45. package/.next/server/app/api/chat/suggestions/route.js.nft.json +1 -1
  46. package/.next/server/app/api/config/route.js.nft.json +1 -1
  47. package/.next/server/app/api/config/test/route.js.nft.json +1 -1
  48. package/.next/server/app/api/config/test-embedding/route.js.nft.json +1 -1
  49. package/.next/server/app/api/config/test-llm/route.js.nft.json +1 -1
  50. package/.next/server/app/api/config/test-provider/route.js.nft.json +1 -1
  51. package/.next/server/app/api/config/verify/route.js.nft.json +1 -1
  52. package/.next/server/app/api/connections/route.js.nft.json +1 -1
  53. package/.next/server/app/api/connections/webhook/route.js.nft.json +1 -1
  54. package/.next/server/app/api/demo/route.js.nft.json +1 -1
  55. package/.next/server/app/api/deploy/cloud-project/route.js.nft.json +1 -1
  56. package/.next/server/app/api/deploy/ssh/route.js.nft.json +1 -1
  57. package/.next/server/app/api/deployment/blob-setup/route.js.nft.json +1 -1
  58. package/.next/server/app/api/deployment/config/route.js.nft.json +1 -1
  59. package/.next/server/app/api/describe-image/route.js.nft.json +1 -1
  60. package/.next/server/app/api/doc-editor/edit/route.js.nft.json +1 -1
  61. package/.next/server/app/api/doc-editor/export/route.js.nft.json +1 -1
  62. package/.next/server/app/api/doc-editor/extract-text/route.js.nft.json +1 -1
  63. package/.next/server/app/api/doc-editor/parse/route.js.nft.json +1 -1
  64. package/.next/server/app/api/doc-editor/restore/route.js.nft.json +1 -1
  65. package/.next/server/app/api/document/sign/route.js.nft.json +1 -1
  66. package/.next/server/app/api/documents/route.js.nft.json +1 -1
  67. package/.next/server/app/api/firecrawl/local/route.js.nft.json +1 -1
  68. package/.next/server/app/api/index/route.js.nft.json +1 -1
  69. package/.next/server/app/api/integrations/notion/callback/route.js.nft.json +1 -1
  70. package/.next/server/app/api/integrations/notion/route.js.nft.json +1 -1
  71. package/.next/server/app/api/jobs/[id]/route.js.nft.json +1 -1
  72. package/.next/server/app/api/jobs/route.js.nft.json +1 -1
  73. package/.next/server/app/api/marketplace/[toolId]/route.js +1 -1
  74. package/.next/server/app/api/marketplace/[toolId]/route.js.nft.json +1 -1
  75. package/.next/server/app/api/marketplace/route.js +1 -1
  76. package/.next/server/app/api/marketplace/route.js.nft.json +1 -1
  77. package/.next/server/app/api/media/[id]/route.js.nft.json +1 -1
  78. package/.next/server/app/api/media/process/route.js +2 -2
  79. package/.next/server/app/api/media/process/route.js.nft.json +1 -1
  80. package/.next/server/app/api/media/route.js +1 -1
  81. package/.next/server/app/api/media/route.js.nft.json +1 -1
  82. package/.next/server/app/api/media/stream/route.js.nft.json +1 -1
  83. package/.next/server/app/api/models/route.js.nft.json +1 -1
  84. package/.next/server/app/api/parse-file/route.js.nft.json +1 -1
  85. package/.next/server/app/api/proxy/verify/route.js.nft.json +1 -1
  86. package/.next/server/app/api/sandbox/route.js.nft.json +1 -1
  87. package/.next/server/app/api/search/bing/route.js.nft.json +1 -1
  88. package/.next/server/app/api/search/brave/route.js.nft.json +1 -1
  89. package/.next/server/app/api/search/exa/route.js.nft.json +1 -1
  90. package/.next/server/app/api/search/google/route.js.nft.json +1 -1
  91. package/.next/server/app/api/search/route.js.nft.json +1 -1
  92. package/.next/server/app/api/search/tavily/route.js.nft.json +1 -1
  93. package/.next/server/app/api/search/verify/route.js.nft.json +1 -1
  94. package/.next/server/app/api/server/agent/route.js.nft.json +1 -1
  95. package/.next/server/app/api/server/download/route.js.nft.json +1 -1
  96. package/.next/server/app/api/server/generate/route.js.nft.json +1 -1
  97. package/.next/server/app/api/server/local/route.js.nft.json +1 -1
  98. package/.next/server/app/api/servers/route.js.nft.json +1 -1
  99. package/.next/server/app/api/tabular/query/route.js.nft.json +1 -1
  100. package/.next/server/app/api/tabular/route.js.nft.json +1 -1
  101. package/.next/server/app/api/upload-file/route.js.nft.json +1 -1
  102. package/.next/server/app/api/uploads/[...slug]/route.js.nft.json +1 -1
  103. package/.next/server/app/api/vector-stores/install/route.js.nft.json +1 -1
  104. package/.next/server/app/api/vector-stores/status/route.js.nft.json +1 -1
  105. package/.next/server/app/chat/page/build-manifest.json +2 -2
  106. package/.next/server/app/chat/page.js.nft.json +1 -1
  107. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  108. package/.next/server/app/chat.html +1 -1
  109. package/.next/server/app/chat.rsc +17 -17
  110. package/.next/server/app/chat.segments/_full.segment.rsc +17 -17
  111. package/.next/server/app/chat.segments/_head.segment.rsc +4 -4
  112. package/.next/server/app/chat.segments/_index.segment.rsc +11 -11
  113. package/.next/server/app/chat.segments/_tree.segment.rsc +1 -1
  114. package/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +3 -3
  115. package/.next/server/app/chat.segments/chat.segment.rsc +3 -3
  116. package/.next/server/app/data/page/build-manifest.json +2 -2
  117. package/.next/server/app/data/page.js.nft.json +1 -1
  118. package/.next/server/app/data/page_client-reference-manifest.js +1 -1
  119. package/.next/server/app/data.html +1 -1
  120. package/.next/server/app/data.rsc +17 -17
  121. package/.next/server/app/data.segments/_full.segment.rsc +17 -17
  122. package/.next/server/app/data.segments/_head.segment.rsc +4 -4
  123. package/.next/server/app/data.segments/_index.segment.rsc +11 -11
  124. package/.next/server/app/data.segments/_tree.segment.rsc +1 -1
  125. package/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
  126. package/.next/server/app/data.segments/data.segment.rsc +3 -3
  127. package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  128. package/.next/server/app/index.html +1 -1
  129. package/.next/server/app/index.rsc +16 -16
  130. package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  131. package/.next/server/app/index.segments/_full.segment.rsc +16 -16
  132. package/.next/server/app/index.segments/_head.segment.rsc +4 -4
  133. package/.next/server/app/index.segments/_index.segment.rsc +11 -11
  134. package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  135. package/.next/server/app/page/build-manifest.json +2 -2
  136. package/.next/server/app/page.js.nft.json +1 -1
  137. package/.next/server/app/page_client-reference-manifest.js +1 -1
  138. package/.next/server/app/settings/page/build-manifest.json +2 -2
  139. package/.next/server/app/settings/page/server-reference-manifest.json +3 -3
  140. package/.next/server/app/settings/page.js.nft.json +1 -1
  141. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  142. package/.next/server/app/settings.html +1 -1
  143. package/.next/server/app/settings.rsc +18 -18
  144. package/.next/server/app/settings.segments/_full.segment.rsc +18 -18
  145. package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
  146. package/.next/server/app/settings.segments/_index.segment.rsc +11 -11
  147. package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  148. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
  149. package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
  150. package/.next/server/chunks/[root-of-the-server]__0c80bj0._.js +3 -0
  151. package/.next/server/chunks/{[root-of-the-server]__1m7m2x7._.js → [root-of-the-server]__0drkoru._.js} +2 -2
  152. package/.next/server/chunks/{[root-of-the-server]__0vnm6_8._.js → [root-of-the-server]__0kmh740._.js} +6 -6
  153. package/.next/server/chunks/{[root-of-the-server]__0ou70-v._.js → [root-of-the-server]__0nfenje._.js} +1 -1
  154. package/.next/server/chunks/[root-of-the-server]__0omd-x0._.js +3 -0
  155. package/.next/server/chunks/{[root-of-the-server]__1s1zui-._.js → [root-of-the-server]__10v5qsi._.js} +1 -1
  156. package/.next/server/chunks/[root-of-the-server]__1idgvjh._.js +172 -0
  157. package/.next/server/chunks/[root-of-the-server]__1ip05r1._.js +1 -1
  158. package/.next/server/chunks/[root-of-the-server]__1jc54o2._.js +3 -0
  159. package/.next/server/chunks/{[root-of-the-server]__0748x7h._.js → [root-of-the-server]__1lhls88._.js} +1 -1
  160. package/.next/server/chunks/{[root-of-the-server]__0g_q-44._.js → [root-of-the-server]__1wy6wes._.js} +2 -2
  161. package/.next/server/chunks/{packages_1f4dx4h._.js → packages_1ggqion._.js} +2 -2
  162. package/.next/server/chunks/packages_marketplace_src_125_g2p._.js +1 -1
  163. package/.next/server/chunks/{packages_vector-stores_src_064-9ay._.js → packages_vector-stores_src_1fib7u-._.js} +2 -2
  164. package/.next/server/chunks/ssr/_169pdlf._.js +2 -2
  165. package/.next/server/chunks/ssr/_1hetwwu._.js +2 -2
  166. package/.next/server/chunks/ssr/_1iff9ia._.js +1 -1
  167. package/.next/server/chunks/ssr/_1yqlx1m._.js +1 -1
  168. package/.next/server/chunks/ssr/apps_web_lib_pdf-images_ts_13-l5wa._.js +1 -1
  169. package/.next/server/middleware-build-manifest.js +5 -5
  170. package/.next/server/pages/404.html +1 -1
  171. package/.next/server/pages/500.html +1 -1
  172. package/.next/server/server-reference-manifest.js +1 -1
  173. package/.next/server/server-reference-manifest.json +4 -4
  174. package/.next/static/chunks/{13hmtkhrbm4t3.js → 01qmngac69n9j.js} +1 -1
  175. package/.next/static/chunks/{3bpr59xr-_rv7.js → 0ge3nirnmx_np.js} +1 -1
  176. package/.next/static/chunks/{0k405nomf6s4e.js → 102b8vinedggz.js} +6 -6
  177. package/.next/static/chunks/{2jqjx4-rh414_.js → 13kyiy7q3of41.js} +1 -1
  178. package/.next/static/chunks/{1fz_0-qb5r5wd.js → 1dykihoo_1ae5.js} +1 -1
  179. package/.next/static/chunks/{0rgt7-bqxonef.js → 1sh7d5tt49x8b.js} +2 -2
  180. package/.next/static/chunks/{1-afr-snks55m.js → 1z4nte07k3dt6.js} +1 -1
  181. package/.next/static/chunks/2ib3e0xrrdait.js +1 -0
  182. package/.next/static/chunks/{turbopack-2gu-fmc6o5wkn.js → turbopack-2qt7vn_ocj4ao.js} +1 -1
  183. package/CHANGELOG.md +10 -0
  184. package/app/api/describe-image/route.ts +12 -4
  185. package/components/data/media-panel.tsx +34 -2
  186. package/components/data/upload-panel.tsx +2 -1
  187. package/components/settings/marketplace-section.tsx +14 -2
  188. package/lib/pdf-images.ts +20 -5
  189. package/package.json +5 -5
  190. package/.next/server/chunks/[root-of-the-server]__00r1kgp._.js +0 -143
  191. package/.next/server/chunks/[root-of-the-server]__064gb96._.js +0 -3
  192. package/.next/server/chunks/_0ce9vcg._.js +0 -32
  193. package/.next/static/chunks/00z1f-adeq1lg.js +0 -1
  194. package/archive/redesign-v2/app/configure/page.tsx +0 -53
  195. package/archive/redesign-v2/app/demo/page.tsx +0 -15
  196. package/archive/redesign-v2/app/server/page.tsx +0 -22
  197. package/archive/redesign-v2/app/simple/chat/page.tsx +0 -17
  198. package/archive/redesign-v2/app/simple/docs/page.tsx +0 -21
  199. package/archive/redesign-v2/app/simple/settings/page.tsx +0 -1104
  200. package/archive/redesign-v2/app-routes/configure/page.tsx +0 -53
  201. package/archive/redesign-v2/app-routes/demo/page.tsx +0 -15
  202. package/archive/redesign-v2/app-routes/server/page.tsx +0 -22
  203. package/archive/redesign-v2/app-routes/simple/chat/page.tsx +0 -17
  204. package/archive/redesign-v2/app-routes/simple/docs/page.tsx +0 -21
  205. package/archive/redesign-v2/app-routes/simple/layout.tsx +0 -9
  206. package/archive/redesign-v2/app-routes/simple/settings/page.tsx +0 -1104
  207. package/archive/redesign-v2/components/app-sidebar.tsx +0 -188
  208. package/archive/redesign-v2/components/app-topnav.tsx +0 -195
  209. package/archive/redesign-v2/components/global-settings.tsx +0 -288
  210. package/archive/redesign-v2/components/simple/simple-sidebar.tsx +0 -171
  211. package/archive/redesign-v2/components/simple/simple-topnav.tsx +0 -175
  212. /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → W6QdudzTPo_OVPpNt29f7}/_buildManifest.js +0 -0
  213. /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → W6QdudzTPo_OVPpNt29f7}/_clientMiddlewareManifest.js +0 -0
  214. /package/.next/static/{bDwMIFYSTVBKUJkJJx77o → W6QdudzTPo_OVPpNt29f7}/_ssgManifest.js +0 -0
@@ -56,7 +56,7 @@ const { text } = await generateText({
56
56
  prompt: 'What is this about?',
57
57
  });
58
58
 
59
- console.log(text);`})[d];async function i(){await navigator.clipboard.writeText(h),g(!0),setTimeout(()=>g(!1),2e3)}return(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsx)(aG.DialogTrigger,{render:(0,z.jsxs)(U.Button,{size:"sm",variant:"outline",className:"gap-2 h-8",disabled:b,children:[(0,z.jsx)(aI,{className:"size-4"}),"Connect to Server SDK"]})}),(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-2xl",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsxs)(aG.DialogTitle,{className:"flex items-center gap-2",children:[(0,z.jsx)(aI,{className:"size-5 text-primary"}),"Connect to your RAG Server"]}),(0,z.jsx)(aG.DialogDescription,{children:"Use one of these SDKs to programmatically interact with your RAG server."})]}),(0,z.jsx)("div",{className:"flex gap-1 rounded-lg border bg-muted/40 p-1",children:td.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>e(a.id),className:(0,M.cn)("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-all",d===a.id?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:a.label},a.id))}),(0,z.jsxs)("div",{className:"relative rounded-lg border bg-slate-50 overflow-hidden",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between border-b border-slate-200 px-4 py-2 bg-slate-100/50",children:[(0,z.jsx)("span",{className:"text-xs text-slate-500 font-mono",children:"python"===d?"main.py":"typescript"===d?"index.ts":"connect.ts"}),(0,z.jsx)("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-slate-500 transition hover:bg-slate-200 hover:text-slate-900",children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aJ.Check,{className:"size-3.5"}),"Copied!"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(at.Copy,{className:"size-3.5"}),"Copy"]})})]}),(0,z.jsx)(tc,{value:h,language:"python"===d?"python":"javascript",height:"auto"})]}),(0,z.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,z.jsxs)("span",{className:"text-muted-foreground",children:["Server URL:"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono",children:a||"Not running"})]}),(0,z.jsxs)("a",{href:"https://www.larkup.de/sdk/overview",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline",children:["Full docs",(0,z.jsx)(ar.ExternalLink,{className:"size-3.5"})]})]})]})]})}var tf=a.i(842586);let tg=(0,G.default)("dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]),th=(0,G.default)("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),ti=(0,G.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);var tj=a.i(745975),tk=a.i(959183),tl=a.i(299574),tm=a.i(655208),tn=a.i(96607);function to({store:a,values:b,errors:c,onChange:d,indexType:e}){let f=(0,tn.visibleFields)(a,b,e),[g,h]=(0,A.useState)({});return(0,z.jsx)("div",{className:"grid gap-5 sm:grid-cols-2",children:f.map(a=>{let e=b[a.key]??a.defaultValue??"",f=c[a.key],i=`store-${a.key}`;return(0,z.jsxs)("div",{className:(0,M.cn)("space-y-1.5","select"===a.type&&"sm:col-span-1"),children:[(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsx)(W.Label,{htmlFor:i,children:a.label}),a.required&&(0,z.jsx)("span",{className:"text-destructive","aria-hidden":!0,children:"*"}),a.secret&&(0,z.jsxs)(tl.Badge,{variant:"outline",className:"h-4 gap-1 px-1 text-[9px] font-mono uppercase text-muted-foreground",children:[(0,z.jsx)(ay,{className:"size-2.5"}),"secret"]})]}),"select"===a.type?(0,z.jsxs)(X.Select,{value:e,onValueChange:b=>d(a.key,b??""),children:[(0,z.jsx)(X.SelectTrigger,{id:i,className:(0,M.cn)("w-full",f&&"border-destructive"),children:(0,z.jsx)(X.SelectValue,{placeholder:`Select ${a.label}`})}),(0,z.jsx)(X.SelectContent,{children:a.options?.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:a.label},a.value))})]}):"password"===a.type?(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(V.Input,{id:i,type:g[a.key]?"text":"password",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("font-mono text-sm pr-9",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>{var b;return b=a.key,void h(a=>({...a,[b]:!a[b]}))},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:g[a.key]?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})})]}):(0,z.jsx)(V.Input,{id:i,type:"text",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("path"===a.type&&"font-mono text-sm",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),f?(0,z.jsx)("p",{className:"text-xs text-destructive",children:f}):a.help?(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:a.help}):null]},a.key)})})}var tp=a.i(576991);let tq=(0,tp.createServerReference)("788d2a54def528afab85cd875b9df9131f22ff7825",tp.callServer,void 0,tp.findSourceMapURL,"deployToVercel"),tr=(0,tp.createServerReference)("406854aa983e37f94e9402716a996c9c31b64b8fce",tp.callServer,void 0,tp.findSourceMapURL,"getServerEnvRequirements");function ts(a){return`larkup_deployments_${a}`}function tt(a){return a.url.replace(/\/$/,"")}function tu(a){return`larkup_api_key_version_${a}`}function tv(a){return Number.parseInt(localStorage.getItem(tu(a))||"0",10)||0}function tw(a){let b=tv(a)+1;return localStorage.setItem(tu(a),String(b)),b}function tx(a){try{let b=localStorage.getItem(ts(a));if(b)return JSON.parse(b)}catch{}let b=function(a){let b=localStorage.getItem(`vercel_deployed_url_${a}`);if(!b)return[];let c=localStorage.getItem(`vercel_deployed_provider_${a}`)||"vercel";return[{id:`${c}:${b}`,provider:c,project:localStorage.getItem(`vercel_project_${a}`)||b,url:b,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]}(a);return b.length&&localStorage.setItem(ts(a),JSON.stringify(b)),b}function ty(a,b){localStorage.setItem(ts(a),JSON.stringify(b)),window.dispatchEvent(new CustomEvent("larkup-deployments-change",{detail:a}))}function tz(a,b){let c=tx(a),d=c.findIndex(a=>a.provider===b.provider&&a.project===b.project),e=new Date().toISOString(),f={...b,apiKeyVersion:b.apiKeyVersion??tv(a),id:d>=0?c[d].id:`${b.provider}:${b.project}`,createdAt:d>=0?c[d].createdAt:e,updatedAt:e};return d>=0?c[d]=f:c.unshift(f),ty(a,c),c}function tA(a,b,c){let d=tx(a).map(a=>a.id===b?{...a,...c,updatedAt:new Date().toISOString()}:a);return ty(a,d),d}let tB="vercel_token";function tC(a){return`vercel_project_${a}`}function tD(a){return`vercel_deployed_url_${a}`}function tE(a){return`vercel_deployed_provider_${a}`}function tF(a){return`rag_server_env_vars_${a}`}function tG(a,b){b!==(localStorage.getItem("rag_server_api_key")||"")&&tw(a),b?localStorage.setItem("rag_server_api_key",b):localStorage.removeItem("rag_server_api_key")}let tH=a=>fetch(a).then(a=>a.json()),tI={lancedb:{iconSrc:"/icons/lancedb2.png",pillBg:"bg-yellow-50 dark:bg-yellow-950/40"},pinecone:{iconSrc:"/icons/pinecone.png",pillBg:"bg-green-50 dark:bg-green-950/40"}};function tJ(a){return(0,tn.getVectorStore)(a).fields.reduce((a,b)=>(b.defaultValue&&(a[b.key]=b.defaultValue),a),{})}function tK({open:a,onOpenChange:b,target:c,serverId:d}){let{refresh:e,activateServer:f}=(0,$.useWorkspace)(),[g,h]=(0,A.useState)("general"),[i,j]=(0,A.useState)(null),k=`/api/config?serverId=${encodeURIComponent(d)}`,{data:l}=(0,P.default)(a?k:null,tH),[m,n]=(0,A.useState)("lancedb"),[o,p]=(0,A.useState)({}),[q,r]=(0,A.useState)({}),[s,t]=(0,A.useState)(!0),[u,v]=(0,A.useState)(!1),[w,x]=(0,A.useState)(!1),[y,B]=(0,A.useState)(""),[D,E]=(0,A.useState)(!1),[F,G]=(0,A.useState)(null),[H,I]=(0,A.useState)(!0),[J,K]=(0,A.useState)(null),[L,M]=(0,A.useState)(!1),N=(0,A.useRef)(void 0),[O,R]=(0,A.useState)([]),[T,Z]=(0,A.useState)({}),[_,ab]=(0,A.useState)(""),[ac,ad]=(0,A.useState)(!1),[ae,af]=(0,A.useState)({}),[ag,ai]=(0,A.useState)(!1),[aj,al]=(0,A.useState)(!1),[am,an]=(0,A.useState)(""),[ao,ap]=(0,A.useState)(""),[aq,ar]=(0,A.useState)(!1),[as,at]=(0,A.useState)(!1),[au,av]=(0,A.useState)(""),[aw,ax]=(0,A.useState)("root"),[ay,az]=(0,A.useState)("password"),[aA,aB]=(0,A.useState)(""),[aC,aD]=(0,A.useState)(!1),[aE,aF]=(0,A.useState)([]),[aG,aH]=(0,A.useState)(!1),[aI,aJ]=(0,A.useState)(""),[aK,aL]=(0,A.useState)(""),[aM,aN]=(0,A.useState)(!1),[aO,aP]=(0,A.useState)(!1),[aQ,aR]=(0,A.useState)(!1),aS=(0,A.useRef)(null),aT=F??d,{data:aU}=(0,P.default)(F?`/api/index?serverId=${encodeURIComponent(F)}`:null,tH,{refreshInterval:a=>a?.run&&!["completed","failed"].includes(a.run.status)?1200:0}),aV=aU?.run;aV&&["completed","failed"].includes(aV.status);let aW=(0,A.useMemo)(()=>aV?.totalChunks?Math.round(aV.processedChunks/aV.totalChunks*100):5,[aV]);(0,A.useEffect)(()=>{a?"env"===c?h("general"):h("provider"):(ai(!1),al(!1),G(null),M(!1),aR(!1),j(null),"env"===c&&h("general"))},[a,c]),(0,A.useEffect)(()=>{aV?.warning&&aV.warning!==N.current&&Y.toast.warning(aV.warning,{id:"cloud-index-rate-limit",duration:7e4,position:"bottom-left"}),N.current=aV?.warning},[aV?.warning]),(0,A.useEffect)(()=>{if(!l?.config||F||ag)return;let a=l.config,b="lancedb"===a.vectorStore?"lancedb":a.vectorStore;n(b),p(a.vectorStore===b?a.storeConfig:tJ(b)),B(a.embeddingModelId),tr(d).then(a=>{R(a);let b=localStorage.getItem(tF(d)),c=b?JSON.parse(b):{},e={};for(let b of a)e[b.key]=c[b.key]||b.defaultValue||"";Z(e);let f=localStorage.getItem(tB),g=localStorage.getItem(tC(d)),h=localStorage.getItem("rag_server_api_key");h&&ab(h),f&&(an(f),at(!0)),g&&ap(g),ai(!0),al(!0)})},[l,F,ag,d]);let aX=(0,A.useMemo)(()=>{if(!l?.config)return[];let a=l.config.embeddingProvider,b=[...ak.EMBEDDING_MODELS.filter(b=>"vercel_ai_gateway"===a||b.provider===a),...(l.config.customEmbeddings??[]).map(a=>({id:`custom:${a.modelName}`,label:a.modelName}))];return b.some(a=>a.id===l.config.embeddingModelId)?b:[{id:l.config.embeddingModelId,label:l.config.embeddingModelId},...b]},[l?.config]),aY=aX.find(a=>a.id===y)??aX[0],aZ=(0,tn.getVectorStore)(m),a$="lancedb"===m&&(o.mode??"local")==="local";async function a_(){if(!l?.config)return!1;let a=(0,tn.validateStoreConfig)(aZ,o,l.config.indexType);if(Object.keys(a).length>0)return r(a),I(!0),h("general"),Y.toast.error("Complete the required storage fields before verifying.",{position:"bottom-left"}),!1;v(!0),K(null);try{let a=await fetch("/api/config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l.config,vectorStore:m,storeConfig:o,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw b.fieldErrors&&(r(b.fieldErrors),I(!0)),Error(b.error??"Connection failed");return x(!0),Y.toast.success("Storage credentials verified.",{position:"bottom-left"}),!0}catch(b){x(!1);let a=b instanceof Error?b.message:"Connection failed";return K(a),Y.toast.error(a,{position:"bottom-left"}),!1}finally{v(!1)}}async function a0(){if(!l?.config||a$)return Y.toast.error("Choose cloud storage before continuing.",{position:"bottom-left"}),null;if(!w&&!await a_())return null;E(!0);try{let a=await fetch("/api/deploy/cloud-project",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceServerId:d,vectorStore:m,storeConfig:o,indexType:l.config.indexType,copyKnowledgeBase:s,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw r(b.fieldErrors??{}),Error(b.error??"Could not create cloud project.");return G(b.server.id),await e(),Y.toast.success(b.copiedDocuments?"Knowledge base indexing started...":"Cloud project created.",{position:"bottom-left"}),b.server.id}catch(a){return Y.toast.error(a instanceof Error?a.message:"Could not create cloud project.",{position:"bottom-left"}),null}finally{E(!1)}}async function a1(){if("env"===c){tG(d,_),localStorage.setItem(tF(d),JSON.stringify(T)),b(!1),Y.toast.success("Environment configuration saved.",{position:"bottom-left"});return}if(j(null),"vercel"===c){if(!am||!ao){h("provider"),j("provider"),Y.toast.error("Please enter both a Vercel Token and a Project name.",{position:"bottom-left"});return}}else if(!au||!aw||!aA){h("provider"),j("provider"),Y.toast.error("Please fill in all SSH connection details.",{position:"bottom-left"});return}for(let a of O)if(a.required&&!T[a.key]){h("general"),j("general"),Y.toast.error(`Please provide a value for ${a.key}.`,{position:"bottom-left"});return}if(a$){h("general"),j("general"),Y.toast.error("You must configure a cloud vector store (e.g. Pinecone) to deploy.",{position:"bottom-left"});return}if(!w&&!await a_()){h("general"),j("general");return}if(!F&&l?.config.vectorStore==="lancedb"&&"lancedb"!==m){await a0()&&M(!0);return}"vercel"===c?a2(F??d):a3(F??d,void 0)}async function a2(a){aR(!0),Y.toast.info("Triggering deployment started !!",{position:"bottom-left"});try{let c={...T};_&&(c.SERVER_API_KEY=_,tG(a,_));let e=await tq(am,ao,a,c);if(e.success){localStorage.setItem(tB,am),localStorage.setItem(tC(a),ao),localStorage.setItem(tD(a),e.url),localStorage.setItem(tE(a),"vercel"),tz(a,{provider:"vercel",project:e.projectName??ao,url:e.url,status:e.status}),a!==d&&await f(a);let c=e.projectCreated?"Project created and will be available in a few seconds":"Server has been deployed successfully!";Y.toast.success((0,z.jsx)("div",{className:"flex flex-col gap-1",children:(0,z.jsx)("span",{children:c})}),{position:"bottom-left"}),b(!1)}else Y.toast.error(e.error||"Failed to deploy files to Vercel.",{position:"bottom-left"})}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}async function a3(a,c){let d;aR(!0),Y.toast.info("Connecting to server and deploying via SSH...",{duration:1e4,position:"bottom-left"});let e=aS.current?.host||au,f=aS.current?.username||aw,g=aS.current?.auth||{type:ay,value:aA},h=aS.current?.envVars||(d={...T},_&&(d.SERVER_API_KEY=_,tG(a,_)),d);try{let d={serverId:a,host:e,username:f,privateKeyOrPassword:g,envVars:h};c&&(d.newPassword=c);let i=await fetch("/api/deploy/ssh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!i.body)throw Error("No response from server.");let j=i.body.getReader(),k=new TextDecoder,l=!1,m="";for(;!l;){let{value:c,done:d}=await j.read();if(l=d,c){let d=(m+=k.decode(c,{stream:!0})).split("\n\n");for(let c of(m=d.pop()||"",d))if(c.startsWith("data: "))try{let d=JSON.parse(c.slice(6));if("log"===d.type)aF(a=>[...a,d.message]);else if("password_change_required"===d.type){aS.current={host:e,username:f,auth:g,envVars:h},aR(!1),aJ(""),aL(""),aH(!0);return}else"password_changed"===d.type?(navigator.clipboard.writeText(d.newPassword),Y.toast.warning("Server password updated.",{duration:6e4,position:"bottom-left"})):"done"===d.type?d.success?(localStorage.setItem(tD(a),d.url),localStorage.setItem(tE(a),"hetzner"),tz(a,{provider:"hetzner",project:e,url:d.url,status:"ready"}),Y.toast.success("Server deployed via SSH successfully!",{position:"bottom-left"}),aS.current=null,b(!1)):Y.toast.error(d.error||"Failed to deploy via SSH.",{position:"bottom-left"}):"error"===d.type&&Y.toast.error(d.error||"Failed to deploy.",{position:"bottom-left"})}catch(a){}}}}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}(0,A.useEffect)(()=>{L&&aV?.status==="completed"&&F&&(M(!1),"vercel"===c?a2(F):"env"!==c&&a3(F))},[aV?.status,L,F,c]);let a4=async()=>{aI?aI!==aK?Y.toast.error("Passwords do not match.",{position:"bottom-left"}):aI.length<8?Y.toast.error("Password must be at least 8 characters.",{position:"bottom-left"}):(aH(!1),aF(a=>[...a,"","--- Retrying with new password ---"]),await a3(aT,aI)):Y.toast.error("Enter a new password.",{position:"bottom-left"})},a5="general"===g;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(tk.Sheet,{open:a&&!aG,onOpenChange:a=>{aQ||b(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full max-w-[90%]! w-187.5! overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"env"===c?"Environment Settings":`Deploy to ${"vercel"===c?"Vercel":"Server"}`}),(0,z.jsx)(tk.SheetDescription,{children:"env"===c?"Configure environment variables and storage.":"Configure your deployment settings before launching."})]})}),(0,z.jsxs)("div",{className:"flex-1 px-6 overflow-y-auto",children:["env"!==c&&(0,z.jsx)(aa.Tabs,{value:g,onValueChange:a=>h(a),children:(0,z.jsxs)(aa.TabsList,{className:" rounded-md border bg-muted/20 w-fit ",children:[(0,z.jsxs)(aa.TabsTrigger,{value:"general",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"general"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(C.Settings2,{className:"size-3.5 mr-1.5"}),"General"]}),(0,z.jsxs)(aa.TabsTrigger,{value:"provider",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"provider"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(tj.Cloud,{className:"size-3.5 mr-1.5"}),"Provider"]})]})}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${!a5?"hidden":"block"}`,children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Vector Storage"}),(0,z.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer bg-muted/20 px-2.5 py-1 rounded-md border",children:[(0,z.jsx)("input",{type:"checkbox",className:"shrink-0",checked:s,onChange:a=>t(a.target.checked)}),"Include Knowledge Base"]})]}),(0,z.jsxs)("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)(X.Select,{value:m,onValueChange:a=>{n(a),p(tJ(a)),r({}),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-50 bg-background",children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[tI[m]&&(0,z.jsx)(ah.ProviderIcon,{src:tI[m].iconSrc,alt:aZ.label,pillBg:tI[m].pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:aZ.label})]})}),(0,z.jsx)(X.SelectContent,{children:tn.VECTOR_STORE_LIST.map(a=>{let b=tI[a.id],c="coming-soon"===a.installStatus;return(0,z.jsx)(X.SelectItem,{value:a.id,disabled:c,children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[b&&(0,z.jsx)(ah.ProviderIcon,{src:b.iconSrc,alt:a.label,pillBg:b.pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),c&&(0,z.jsx)("span",{className:"ml-2 text-[9px] text-muted-foreground border rounded-full px-1.5",children:"Soon"})]})},a.id)})})]}),(0,z.jsxs)(U.Button,{variant:w?"secondary":"outline",size:"sm",onClick:a_,disabled:u||a$,children:[u?(0,z.jsx)(Q.Loader2,{className:"size-3.5 mr-2 animate-spin"}):w?(0,z.jsx)(th,{className:"size-3.5 mr-2 text-emerald-500"}):(0,z.jsx)(ti,{className:"size-3.5 mr-2"}),w?"Verified":"Verify"]})]}),a$&&(0,z.jsx)("p",{className:"text-xs text-destructive",children:"You must select a cloud storage provider before deploying."}),(0,z.jsx)(to,{store:aZ,values:o,errors:q,indexType:l?.config.indexType,onChange:(a,b)=>{p(c=>({...c,[a]:b})),r(b=>({...b,[a]:""})),x(!1)}}),(0,z.jsxs)("div",{className:"pt-2 border-t mt-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Embedding Model"}),(0,z.jsxs)(X.Select,{value:y,onValueChange:a=>{B(a||""),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full bg-white",children:(0,z.jsx)("span",{className:"font-medium text-sm",children:aY?.label??"Default"})}),(0,z.jsx)(X.SelectContent,{children:aX.map(a=>(0,z.jsx)(X.SelectItem,{value:a.id,children:(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label})},a.id))})]})]})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Environment Variables"}),(0,z.jsxs)("div",{className:"grid gap-4 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SERVER_API_KEY"," ",(0,z.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"(Optional)"})]}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ac?"text":"password",value:_,onChange:a=>ab(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ad(!ac),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",onClick:()=>{ab("larkup-"+Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15))},children:(0,z.jsx)(tg,{className:"size-4"})})]})]}),O.map(a=>(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:[a.key,a.required&&(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})," ",T[a.key]&&(0,z.jsx)("span",{className:"text-emerald-500 text-[10px] ml-2",children:"Pre-filled"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ae[a.key]?"text":"password",value:T[a.key]||"",onChange:b=>Z({...T,[a.key]:b.target.value})}),(0,z.jsx)("button",{type:"button",onClick:()=>af(b=>({...b,[a.key]:!b[a.key]})),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),a.help&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:a.help})]},a.key))]})]})]}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${a5?"hidden":"block"}`,children:["vercel"===c?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{className:"flex justify-between w-full items-center",children:[(0,z.jsxs)("span",{children:["Vercel Token ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noreferrer",className:"text-[10px] font-medium text-muted-foreground underline hover:text-foreground",children:"Get token"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aq?"text":"password",value:am,onChange:a=>an(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ar(!aq),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Project Name ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:ao,onChange:a=>ap(a.target.value)})]})]}):(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Server IP / Hostname ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:au,onChange:a=>av(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SSH Username ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:aw,onChange:a=>ax(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)("div",{className:"flex gap-2 mb-2",children:[(0,z.jsx)(tl.Badge,{variant:"key"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("key"),children:"Private Key"}),(0,z.jsx)(tl.Badge,{variant:"password"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("password"),children:"Password"})]}),"key"===ay?(0,z.jsx)("textarea",{className:"min-h-30 rounded-md border bg-transparent px-3 py-2 text-sm font-mono",value:aA,onChange:a=>aB(a.target.value)}):(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aC?"text":"password",value:aA,onChange:a=>aB(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>aD(!aC),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]})]}),aQ&&aE.length>0&&(0,z.jsx)("div",{className:"bg-black text-[#00ff00] font-mono text-[10px] p-3 rounded-md h-50 overflow-y-auto break-all whitespace-pre-wrap flex flex-col-reverse",children:(0,z.jsx)("div",{children:aE.map((a,b)=>(0,z.jsx)("div",{children:a},b))})})]}),L&&(0,z.jsxs)("div",{className:"mt-8 space-y-3 rounded-lg border p-5 bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex justify-between text-sm font-medium",children:[(0,z.jsx)("span",{children:aV?.status==="completed"?"Knowledge base uploaded":"Uploading knowledge base"}),(0,z.jsxs)("span",{className:"tabular-nums",children:[aW,"%"]})]}),(0,z.jsx)(tm.Progress,{value:aW,className:"h-2"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground pt-1",children:aV?.warning||`${aV?.processedChunks??0} / ${aV?.totalChunks??0} chunks`})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 z-10 border-t bg-background px-6 py-4 flex items-center justify-between mt-auto",children:[(0,z.jsx)(U.Button,{variant:"outline",className:"px-5",onClick:()=>b(!1),disabled:aQ||L,children:"Cancel"}),(0,z.jsxs)(U.Button,{className:"px-7",onClick:a1,disabled:aQ||L,children:[(aQ||L)&&(0,z.jsx)(Q.Loader2,{className:"mr-2 size-4 animate-spin"}),"env"===c?"Save Settings":"Deploy"]})]})]})}),(0,z.jsx)(tk.Sheet,{open:aG,onOpenChange:a=>{a||(aS.current=null),aH(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full sm:max-w-md w-full overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"Password Change Required"}),(0,z.jsx)(tk.SheetDescription,{children:"Your server requires a password change on first login."})]})}),(0,z.jsxs)("div",{className:"flex-1 p-6 overflow-y-auto grid gap-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"New Password"}),(0,z.jsx)(V.Input,{type:"password",value:aI,onChange:a=>aJ(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"Confirm Password"}),(0,z.jsx)(V.Input,{type:"password",value:aK,onChange:a=>aL(a.target.value)})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 border-t bg-background px-6 py-4 flex justify-between",children:[(0,z.jsx)(U.Button,{variant:"outline",onClick:()=>aH(!1),children:"Cancel"}),(0,z.jsx)(U.Button,{onClick:a4,children:"Change & Deploy"})]})]})})]})}function tL({serverId:a="default",showUtilities:b=!0,compact:c=!1,openTarget:d,openSignal:e}){let[f,g]=(0,A.useState)(!1),[h,i]=(0,A.useState)(null),j=(0,A.useRef)(0),k=a=>{i(a),g(!0)},l=a=>{Y.toast.success(`Downloading deployment package for ${a}...`),window.open(`/api/server/download?provider=${a}`)};return(0,A.useEffect)(()=>{d&&e&&e!==j.current&&(j.current=e,k(d))},[e,d]),(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,z.jsx)(ac.TooltipProvider,{children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{delay:0,render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:`${c?"h-8 w-8":"h-9 w-9"} shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>k("env"),children:(0,z.jsx)(C.Settings2,{className:"size-4"})})}),(0,z.jsx)(ac.TooltipContent,{children:(0,z.jsx)("p",{children:"Environment Variables"})})]})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"default",size:"default",className:`${c?"h-8":"h-9"} w-32.5 justify-start gap-1 rounded-md`}),children:(0,z.jsxs)("div",{className:"w-full flex items-center h-8 justify-between rounded-lg",children:[(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 mr-2"}),"Deploy"]}),(0,z.jsx)(tf.ChevronDown,{})]})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-50",children:[(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("vercel"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/vercel.svg",className:"size-4 mr-2",alt:"Vercel"}),"Vercel"]})}),(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("hetzner"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/hetzner.svg",className:"size-4 mr-2",alt:"Hetzner"}),"Hetzner"]})}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/azure.svg",className:"size-4 mr-2",alt:"Azure"}),"Azure"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-app-service"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Service"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-container-apps"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Container Apps"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("azure"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Virtual Machines"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/aws.svg",className:"size-4 mr-2",alt:"AWS"}),"AWS"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-elastic-beanstalk"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Elastic Beanstalk"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-app-runner"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Runner / Fargate"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("aws"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"EC2"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/gcp.svg",className:"size-4 mr-2",alt:"GCP"}),"GCP"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-app-engine"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-cloud-run"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Cloud Run"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("gcp"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Compute Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/digital-ocean.webp",className:"size-4 mr-2",alt:"DigitalOcean"}),"DigitalOcean"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("digitalocean-app-platform"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Platform"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("digitalocean"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Droplets"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]})]})]}),(0,z.jsx)(tK,{open:f,onOpenChange:g,target:h,serverId:a})]})}let tM=(0,tp.createServerReference)("60ea4ad1fe472ddb6bec9ab5b1a25f7b1c6808aab8",tp.callServer,void 0,tp.findSourceMapURL,"getVercelDeploymentStatus"),tN=a=>fetch(a).then(a=>a.json());function tO(a){return a.replace(/\/$/,"")}function tP(a){return`${tO(a)}/reference`}function tQ({url:a,project:b,compact:c=!1}){return(0,z.jsxs)("a",{href:tP(a),target:"_blank",rel:"noreferrer","aria-label":`Open API reference for ${b}`,className:(0,M.cn)((0,U.buttonVariants)({variant:c?"ghost":"outline",size:c?"icon":"sm"}),c?"size-8 sm:hidden":"hidden h-8 gap-1.5 px-2 text-xs sm:inline-flex"),children:[(0,z.jsx)(ar.ExternalLink,{className:c?"size-4":"size-3"}),!c&&"API reference"]})}function tR(){let{activeServer:a,refresh:b}=(0,$.useWorkspace)(),c=a?.id||"default",[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)(!1),[j,k]=(0,A.useState)(null),[l,m]=(0,A.useState)(!1),[n,o]=(0,A.useState)(0),[p,q]=(0,A.useState)(!1),[r,s]=(0,A.useState)([]),[t,u]=(0,A.useState)(null),[v,w]=(0,A.useState)(""),[x,y]=(0,A.useState)(null),[B,C]=(0,A.useState)(!1),[D,E]=(0,A.useState)(0),F=(0,A.useRef)(new Set);(0,A.useEffect)(()=>{let a=localStorage.getItem("rag_server_api_key");a&&g(a),o(tv(c)),s(tx(c)),F.current.clear()},[c]),(0,A.useEffect)(()=>{let a=localStorage.getItem("vercel_token"),b=r.filter(a=>"vercel"===a.provider);if(!a||0===b.length)return;let d=b.filter(a=>"queued"===a.status||"building"===a.status||"ready"===a.status&&!F.current.has(a.id));if(0===d.length)return;let e=!1,f=async()=>{let b=await Promise.all(d.map(async b=>({deployment:b,result:await tM(a,b.project)})));if(!e)for(let{deployment:a,result:d}of b){"ready"===d.status&&F.current.add(a.id);let b=d.hasProductionAlias?d.url:void 0;"unknown"!==d.status&&(a.status!==d.status||b&&a.url!==b)&&s(tA(c,a.id,{status:d.status,url:b}))}};f();let g=d.some(a=>"queued"===a.status||"building"===a.status)?window.setInterval(()=>void f(),8e3):void 0;return()=>{e=!0,g&&window.clearInterval(g)}},[r,c]),(0,A.useEffect)(()=>{let a=a=>{a.detail===c&&(s(tx(c)),o(tv(c)))};return window.addEventListener("larkup-deployments-change",a),()=>window.removeEventListener("larkup-deployments-change",a)},[c]);let{data:G,mutate:H}=(0,P.default)("/api/server/local",tN,{refreshInterval:a=>5e3*!!a?.state.running}),I=G?.state;async function J(a){e(a);let d="start"===a;H({state:{...I,running:d}},!1),(0,ao.mutate)("/api/servers",a=>a?{...a,servers:a.servers.map(a=>a.id===c?{...a,running:d}:a)}:a,!1);try{let c=localStorage.getItem("rag_server_api_key")||"",d=await fetch("/api/server/local",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a,serverApiKey:c})}),e=await d.json();"start"===a?e.state?.running?Y.toast.success("Server is running."):(Y.toast.error(e.state?.lastError??"Server did not start."),(0,ao.mutate)("/api/servers")):Y.toast.success("Server stopped."),H(),b()}catch{Y.toast.error("Could not reach the server controller."),(0,ao.mutate)("/api/servers"),H()}finally{e(null)}}function K(a){let b=localStorage.getItem("rag_server_api_key")||"";g(a),localStorage.setItem("rag_server_api_key",a),a!==b&&o(tw(c))}function L(a){return r.length>0&&a!==(localStorage.getItem("rag_server_api_key")||"")?(y(a),C(!0),!1):(K(a),!0)}function N(a){if(null!==x&&K(x),y(null),C(!1),a){E(a=>a+1),Y.toast.info("New API key saved. Configure the Vercel redeploy to sync it remotely.");return}Y.toast.info("API key updated locally. Redeploy cloud servers when you are ready to sync it.")}async function O(){await navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),1500)}async function R(a){f?(await navigator.clipboard.writeText(f),k(a),setTimeout(()=>k(null),1500),Y.toast.success("Cloud API key copied")):Y.toast.error("Generate or enter an API key before copying it.")}async function W(){I?.endpoint&&(await navigator.clipboard.writeText(I.endpoint),m(!0),setTimeout(()=>m(!1),1500))}return(0,z.jsxs)("main",{className:"mx-auto w-full max-w-5xl px-6 ",children:[(0,z.jsxs)("header",{className:"mb-12",children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Server"}),(0,z.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Test locally, then deploy one retrieval and chat server anywhere."})]}),(0,z.jsxs)("section",{className:"mb-14",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(as,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Local server"})]}),(0,z.jsxs)("span",{className:"flex items-center gap-2 text-xs",children:[I?.running?(0,z.jsxs)("span",{className:"relative flex size-2",children:[(0,z.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}):(0,z.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/40"}),(0,z.jsx)("span",{className:I?.running?"font-medium text-emerald-600 dark:text-emerald-400":"text-muted-foreground",children:I?.running?`running on :${I.port}`:"stopped"})]})]}),(0,z.jsx)("p",{className:"mt-2 max-w-xl text-sm text-muted-foreground",children:"Start the server locally to test your AI endpoints. Your configuration and API keys are applied automatically."}),I?.lastError&&!I.running&&(0,z.jsxs)(aF.Alert,{variant:"destructive",children:[(0,z.jsx)(aF.AlertTitle,{children:"Launch failed"}),(0,z.jsx)(aF.AlertDescription,{className:"wrap-break-word",children:I.lastError})]}),I?.running?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border border-border",children:[(0,z.jsxs)("button",{type:"button",onClick:W,className:"flex w-full items-center justify-between gap-3 border-b border-border bg-muted/30 px-4 py-3 text-left",children:[(0,z.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5 font-mono text-sm",children:[(0,z.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:(0,z.jsx)(at.Copy,{className:"size-3.5"})}),(0,z.jsx)("span",{className:"truncate",children:I.endpoint})]}),(0,z.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:l?"Copied":"Click to copy"})]}),(0,z.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[(0,z.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,z.jsx)(te,{serverUrl:I.endpoint}),(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsxs)(aG.DialogTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8 text-xs px-2 gap-1.5"}),children:[(0,z.jsx)(as,{className:"size-3"}),"Try it (cURL)"]}),(0,z.jsxs)(aG.DialogContent,{className:"max-w-2xl!",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsx)(aG.DialogTitle,{children:"cURL Example"}),(0,z.jsx)(aG.DialogDescription,{children:"You can use this command to test your RAG server endpoint."})]}),(0,z.jsxs)("div",{className:"relative rounded-md bg-muted p-4 mt-2 border border-border/50",children:[(0,z.jsx)("pre",{className:"font-mono text-xs overflow-x-auto text-foreground pb-4 pr-6",children:(0,z.jsx)("code",{children:`curl -X POST ${I.endpoint}/query \\
59
+ console.log(text);`})[d];async function i(){await navigator.clipboard.writeText(h),g(!0),setTimeout(()=>g(!1),2e3)}return(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsx)(aG.DialogTrigger,{render:(0,z.jsxs)(U.Button,{size:"sm",variant:"outline",className:"gap-2 h-8",disabled:b,children:[(0,z.jsx)(aI,{className:"size-4"}),"Connect to Server SDK"]})}),(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-2xl",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsxs)(aG.DialogTitle,{className:"flex items-center gap-2",children:[(0,z.jsx)(aI,{className:"size-5 text-primary"}),"Connect to your RAG Server"]}),(0,z.jsx)(aG.DialogDescription,{children:"Use one of these SDKs to programmatically interact with your RAG server."})]}),(0,z.jsx)("div",{className:"flex gap-1 rounded-lg border bg-muted/40 p-1",children:td.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>e(a.id),className:(0,M.cn)("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-all",d===a.id?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:a.label},a.id))}),(0,z.jsxs)("div",{className:"relative rounded-lg border bg-slate-50 overflow-hidden",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between border-b border-slate-200 px-4 py-2 bg-slate-100/50",children:[(0,z.jsx)("span",{className:"text-xs text-slate-500 font-mono",children:"python"===d?"main.py":"typescript"===d?"index.ts":"connect.ts"}),(0,z.jsx)("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-slate-500 transition hover:bg-slate-200 hover:text-slate-900",children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aJ.Check,{className:"size-3.5"}),"Copied!"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(at.Copy,{className:"size-3.5"}),"Copy"]})})]}),(0,z.jsx)(tc,{value:h,language:"python"===d?"python":"javascript",height:"auto"})]}),(0,z.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,z.jsxs)("span",{className:"text-muted-foreground",children:["Server URL:"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono",children:a||"Not running"})]}),(0,z.jsxs)("a",{href:"https://www.larkup.de/sdk/overview",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline",children:["Full docs",(0,z.jsx)(ar.ExternalLink,{className:"size-3.5"})]})]})]})]})}var tf=a.i(842586);let tg=(0,G.default)("dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]),th=(0,G.default)("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),ti=(0,G.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);var tj=a.i(745975),tk=a.i(959183),tl=a.i(299574),tm=a.i(655208),tn=a.i(96607);function to({store:a,values:b,errors:c,onChange:d,indexType:e}){let f=(0,tn.visibleFields)(a,b,e),[g,h]=(0,A.useState)({});return(0,z.jsx)("div",{className:"grid gap-5 sm:grid-cols-2",children:f.map(a=>{let e=b[a.key]??a.defaultValue??"",f=c[a.key],i=`store-${a.key}`;return(0,z.jsxs)("div",{className:(0,M.cn)("space-y-1.5","select"===a.type&&"sm:col-span-1"),children:[(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsx)(W.Label,{htmlFor:i,children:a.label}),a.required&&(0,z.jsx)("span",{className:"text-destructive","aria-hidden":!0,children:"*"}),a.secret&&(0,z.jsxs)(tl.Badge,{variant:"outline",className:"h-4 gap-1 px-1 text-[9px] font-mono uppercase text-muted-foreground",children:[(0,z.jsx)(ay,{className:"size-2.5"}),"secret"]})]}),"select"===a.type?(0,z.jsxs)(X.Select,{value:e,onValueChange:b=>d(a.key,b??""),children:[(0,z.jsx)(X.SelectTrigger,{id:i,className:(0,M.cn)("w-full",f&&"border-destructive"),children:(0,z.jsx)(X.SelectValue,{placeholder:`Select ${a.label}`})}),(0,z.jsx)(X.SelectContent,{children:a.options?.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:a.label},a.value))})]}):"password"===a.type?(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(V.Input,{id:i,type:g[a.key]?"text":"password",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("font-mono text-sm pr-9",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>{var b;return b=a.key,void h(a=>({...a,[b]:!a[b]}))},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:g[a.key]?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})})]}):(0,z.jsx)(V.Input,{id:i,type:"text",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("path"===a.type&&"font-mono text-sm",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),f?(0,z.jsx)("p",{className:"text-xs text-destructive",children:f}):a.help?(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:a.help}):null]},a.key)})})}var tp=a.i(576991);let tq=(0,tp.createServerReference)("780515026f56e4b23ff2db4f54ee68bba38658617e",tp.callServer,void 0,tp.findSourceMapURL,"deployToVercel"),tr=(0,tp.createServerReference)("406a39d072c7c90c2773e7de0f7b3f60b03d19efed",tp.callServer,void 0,tp.findSourceMapURL,"getServerEnvRequirements");function ts(a){return`larkup_deployments_${a}`}function tt(a){return a.url.replace(/\/$/,"")}function tu(a){return`larkup_api_key_version_${a}`}function tv(a){return Number.parseInt(localStorage.getItem(tu(a))||"0",10)||0}function tw(a){let b=tv(a)+1;return localStorage.setItem(tu(a),String(b)),b}function tx(a){try{let b=localStorage.getItem(ts(a));if(b)return JSON.parse(b)}catch{}let b=function(a){let b=localStorage.getItem(`vercel_deployed_url_${a}`);if(!b)return[];let c=localStorage.getItem(`vercel_deployed_provider_${a}`)||"vercel";return[{id:`${c}:${b}`,provider:c,project:localStorage.getItem(`vercel_project_${a}`)||b,url:b,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]}(a);return b.length&&localStorage.setItem(ts(a),JSON.stringify(b)),b}function ty(a,b){localStorage.setItem(ts(a),JSON.stringify(b)),window.dispatchEvent(new CustomEvent("larkup-deployments-change",{detail:a}))}function tz(a,b){let c=tx(a),d=c.findIndex(a=>a.provider===b.provider&&a.project===b.project),e=new Date().toISOString(),f={...b,apiKeyVersion:b.apiKeyVersion??tv(a),id:d>=0?c[d].id:`${b.provider}:${b.project}`,createdAt:d>=0?c[d].createdAt:e,updatedAt:e};return d>=0?c[d]=f:c.unshift(f),ty(a,c),c}function tA(a,b,c){let d=tx(a).map(a=>a.id===b?{...a,...c,updatedAt:new Date().toISOString()}:a);return ty(a,d),d}let tB="vercel_token";function tC(a){return`vercel_project_${a}`}function tD(a){return`vercel_deployed_url_${a}`}function tE(a){return`vercel_deployed_provider_${a}`}function tF(a){return`rag_server_env_vars_${a}`}function tG(a,b){b!==(localStorage.getItem("rag_server_api_key")||"")&&tw(a),b?localStorage.setItem("rag_server_api_key",b):localStorage.removeItem("rag_server_api_key")}let tH=a=>fetch(a).then(a=>a.json()),tI={lancedb:{iconSrc:"/icons/lancedb2.png",pillBg:"bg-yellow-50 dark:bg-yellow-950/40"},pinecone:{iconSrc:"/icons/pinecone.png",pillBg:"bg-green-50 dark:bg-green-950/40"}};function tJ(a){return(0,tn.getVectorStore)(a).fields.reduce((a,b)=>(b.defaultValue&&(a[b.key]=b.defaultValue),a),{})}function tK({open:a,onOpenChange:b,target:c,serverId:d}){let{refresh:e,activateServer:f}=(0,$.useWorkspace)(),[g,h]=(0,A.useState)("general"),[i,j]=(0,A.useState)(null),k=`/api/config?serverId=${encodeURIComponent(d)}`,{data:l}=(0,P.default)(a?k:null,tH),[m,n]=(0,A.useState)("lancedb"),[o,p]=(0,A.useState)({}),[q,r]=(0,A.useState)({}),[s,t]=(0,A.useState)(!0),[u,v]=(0,A.useState)(!1),[w,x]=(0,A.useState)(!1),[y,B]=(0,A.useState)(""),[D,E]=(0,A.useState)(!1),[F,G]=(0,A.useState)(null),[H,I]=(0,A.useState)(!0),[J,K]=(0,A.useState)(null),[L,M]=(0,A.useState)(!1),N=(0,A.useRef)(void 0),[O,R]=(0,A.useState)([]),[T,Z]=(0,A.useState)({}),[_,ab]=(0,A.useState)(""),[ac,ad]=(0,A.useState)(!1),[ae,af]=(0,A.useState)({}),[ag,ai]=(0,A.useState)(!1),[aj,al]=(0,A.useState)(!1),[am,an]=(0,A.useState)(""),[ao,ap]=(0,A.useState)(""),[aq,ar]=(0,A.useState)(!1),[as,at]=(0,A.useState)(!1),[au,av]=(0,A.useState)(""),[aw,ax]=(0,A.useState)("root"),[ay,az]=(0,A.useState)("password"),[aA,aB]=(0,A.useState)(""),[aC,aD]=(0,A.useState)(!1),[aE,aF]=(0,A.useState)([]),[aG,aH]=(0,A.useState)(!1),[aI,aJ]=(0,A.useState)(""),[aK,aL]=(0,A.useState)(""),[aM,aN]=(0,A.useState)(!1),[aO,aP]=(0,A.useState)(!1),[aQ,aR]=(0,A.useState)(!1),aS=(0,A.useRef)(null),aT=F??d,{data:aU}=(0,P.default)(F?`/api/index?serverId=${encodeURIComponent(F)}`:null,tH,{refreshInterval:a=>a?.run&&!["completed","failed"].includes(a.run.status)?1200:0}),aV=aU?.run;aV&&["completed","failed"].includes(aV.status);let aW=(0,A.useMemo)(()=>aV?.totalChunks?Math.round(aV.processedChunks/aV.totalChunks*100):5,[aV]);(0,A.useEffect)(()=>{a?"env"===c?h("general"):h("provider"):(ai(!1),al(!1),G(null),M(!1),aR(!1),j(null),"env"===c&&h("general"))},[a,c]),(0,A.useEffect)(()=>{aV?.warning&&aV.warning!==N.current&&Y.toast.warning(aV.warning,{id:"cloud-index-rate-limit",duration:7e4,position:"bottom-left"}),N.current=aV?.warning},[aV?.warning]),(0,A.useEffect)(()=>{if(!l?.config||F||ag)return;let a=l.config,b="lancedb"===a.vectorStore?"lancedb":a.vectorStore;n(b),p(a.vectorStore===b?a.storeConfig:tJ(b)),B(a.embeddingModelId),tr(d).then(a=>{R(a);let b=localStorage.getItem(tF(d)),c=b?JSON.parse(b):{},e={};for(let b of a)e[b.key]=c[b.key]||b.defaultValue||"";Z(e);let f=localStorage.getItem(tB),g=localStorage.getItem(tC(d)),h=localStorage.getItem("rag_server_api_key");h&&ab(h),f&&(an(f),at(!0)),g&&ap(g),ai(!0),al(!0)})},[l,F,ag,d]);let aX=(0,A.useMemo)(()=>{if(!l?.config)return[];let a=l.config.embeddingProvider,b=[...ak.EMBEDDING_MODELS.filter(b=>"vercel_ai_gateway"===a||b.provider===a),...(l.config.customEmbeddings??[]).map(a=>({id:`custom:${a.modelName}`,label:a.modelName}))];return b.some(a=>a.id===l.config.embeddingModelId)?b:[{id:l.config.embeddingModelId,label:l.config.embeddingModelId},...b]},[l?.config]),aY=aX.find(a=>a.id===y)??aX[0],aZ=(0,tn.getVectorStore)(m),a$="lancedb"===m&&(o.mode??"local")==="local";async function a_(){if(!l?.config)return!1;let a=(0,tn.validateStoreConfig)(aZ,o,l.config.indexType);if(Object.keys(a).length>0)return r(a),I(!0),h("general"),Y.toast.error("Complete the required storage fields before verifying.",{position:"bottom-left"}),!1;v(!0),K(null);try{let a=await fetch("/api/config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l.config,vectorStore:m,storeConfig:o,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw b.fieldErrors&&(r(b.fieldErrors),I(!0)),Error(b.error??"Connection failed");return x(!0),Y.toast.success("Storage credentials verified.",{position:"bottom-left"}),!0}catch(b){x(!1);let a=b instanceof Error?b.message:"Connection failed";return K(a),Y.toast.error(a,{position:"bottom-left"}),!1}finally{v(!1)}}async function a0(){if(!l?.config||a$)return Y.toast.error("Choose cloud storage before continuing.",{position:"bottom-left"}),null;if(!w&&!await a_())return null;E(!0);try{let a=await fetch("/api/deploy/cloud-project",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceServerId:d,vectorStore:m,storeConfig:o,indexType:l.config.indexType,copyKnowledgeBase:s,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw r(b.fieldErrors??{}),Error(b.error??"Could not create cloud project.");return G(b.server.id),await e(),Y.toast.success(b.copiedDocuments?"Knowledge base indexing started...":"Cloud project created.",{position:"bottom-left"}),b.server.id}catch(a){return Y.toast.error(a instanceof Error?a.message:"Could not create cloud project.",{position:"bottom-left"}),null}finally{E(!1)}}async function a1(){if("env"===c){tG(d,_),localStorage.setItem(tF(d),JSON.stringify(T)),b(!1),Y.toast.success("Environment configuration saved.",{position:"bottom-left"});return}if(j(null),"vercel"===c){if(!am||!ao){h("provider"),j("provider"),Y.toast.error("Please enter both a Vercel Token and a Project name.",{position:"bottom-left"});return}}else if(!au||!aw||!aA){h("provider"),j("provider"),Y.toast.error("Please fill in all SSH connection details.",{position:"bottom-left"});return}for(let a of O)if(a.required&&!T[a.key]){h("general"),j("general"),Y.toast.error(`Please provide a value for ${a.key}.`,{position:"bottom-left"});return}if(a$){h("general"),j("general"),Y.toast.error("You must configure a cloud vector store (e.g. Pinecone) to deploy.",{position:"bottom-left"});return}if(!w&&!await a_()){h("general"),j("general");return}if(!F&&l?.config.vectorStore==="lancedb"&&"lancedb"!==m){await a0()&&M(!0);return}"vercel"===c?a2(F??d):a3(F??d,void 0)}async function a2(a){aR(!0),Y.toast.info("Triggering deployment started !!",{position:"bottom-left"});try{let c={...T};_&&(c.SERVER_API_KEY=_,tG(a,_));let e=await tq(am,ao,a,c);if(e.success){localStorage.setItem(tB,am),localStorage.setItem(tC(a),ao),localStorage.setItem(tD(a),e.url),localStorage.setItem(tE(a),"vercel"),tz(a,{provider:"vercel",project:e.projectName??ao,url:e.url,status:e.status}),a!==d&&await f(a);let c=e.projectCreated?"Project created and will be available in a few seconds":"Server has been deployed successfully!";Y.toast.success((0,z.jsx)("div",{className:"flex flex-col gap-1",children:(0,z.jsx)("span",{children:c})}),{position:"bottom-left"}),b(!1)}else Y.toast.error(e.error||"Failed to deploy files to Vercel.",{position:"bottom-left"})}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}async function a3(a,c){let d;aR(!0),Y.toast.info("Connecting to server and deploying via SSH...",{duration:1e4,position:"bottom-left"});let e=aS.current?.host||au,f=aS.current?.username||aw,g=aS.current?.auth||{type:ay,value:aA},h=aS.current?.envVars||(d={...T},_&&(d.SERVER_API_KEY=_,tG(a,_)),d);try{let d={serverId:a,host:e,username:f,privateKeyOrPassword:g,envVars:h};c&&(d.newPassword=c);let i=await fetch("/api/deploy/ssh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!i.body)throw Error("No response from server.");let j=i.body.getReader(),k=new TextDecoder,l=!1,m="";for(;!l;){let{value:c,done:d}=await j.read();if(l=d,c){let d=(m+=k.decode(c,{stream:!0})).split("\n\n");for(let c of(m=d.pop()||"",d))if(c.startsWith("data: "))try{let d=JSON.parse(c.slice(6));if("log"===d.type)aF(a=>[...a,d.message]);else if("password_change_required"===d.type){aS.current={host:e,username:f,auth:g,envVars:h},aR(!1),aJ(""),aL(""),aH(!0);return}else"password_changed"===d.type?(navigator.clipboard.writeText(d.newPassword),Y.toast.warning("Server password updated.",{duration:6e4,position:"bottom-left"})):"done"===d.type?d.success?(localStorage.setItem(tD(a),d.url),localStorage.setItem(tE(a),"hetzner"),tz(a,{provider:"hetzner",project:e,url:d.url,status:"ready"}),Y.toast.success("Server deployed via SSH successfully!",{position:"bottom-left"}),aS.current=null,b(!1)):Y.toast.error(d.error||"Failed to deploy via SSH.",{position:"bottom-left"}):"error"===d.type&&Y.toast.error(d.error||"Failed to deploy.",{position:"bottom-left"})}catch(a){}}}}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}(0,A.useEffect)(()=>{L&&aV?.status==="completed"&&F&&(M(!1),"vercel"===c?a2(F):"env"!==c&&a3(F))},[aV?.status,L,F,c]);let a4=async()=>{aI?aI!==aK?Y.toast.error("Passwords do not match.",{position:"bottom-left"}):aI.length<8?Y.toast.error("Password must be at least 8 characters.",{position:"bottom-left"}):(aH(!1),aF(a=>[...a,"","--- Retrying with new password ---"]),await a3(aT,aI)):Y.toast.error("Enter a new password.",{position:"bottom-left"})},a5="general"===g;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(tk.Sheet,{open:a&&!aG,onOpenChange:a=>{aQ||b(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full max-w-[90%]! w-187.5! overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"env"===c?"Environment Settings":`Deploy to ${"vercel"===c?"Vercel":"Server"}`}),(0,z.jsx)(tk.SheetDescription,{children:"env"===c?"Configure environment variables and storage.":"Configure your deployment settings before launching."})]})}),(0,z.jsxs)("div",{className:"flex-1 px-6 overflow-y-auto",children:["env"!==c&&(0,z.jsx)(aa.Tabs,{value:g,onValueChange:a=>h(a),children:(0,z.jsxs)(aa.TabsList,{className:" rounded-md border bg-muted/20 w-fit ",children:[(0,z.jsxs)(aa.TabsTrigger,{value:"general",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"general"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(C.Settings2,{className:"size-3.5 mr-1.5"}),"General"]}),(0,z.jsxs)(aa.TabsTrigger,{value:"provider",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"provider"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(tj.Cloud,{className:"size-3.5 mr-1.5"}),"Provider"]})]})}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${!a5?"hidden":"block"}`,children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Vector Storage"}),(0,z.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer bg-muted/20 px-2.5 py-1 rounded-md border",children:[(0,z.jsx)("input",{type:"checkbox",className:"shrink-0",checked:s,onChange:a=>t(a.target.checked)}),"Include Knowledge Base"]})]}),(0,z.jsxs)("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)(X.Select,{value:m,onValueChange:a=>{n(a),p(tJ(a)),r({}),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-50 bg-background",children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[tI[m]&&(0,z.jsx)(ah.ProviderIcon,{src:tI[m].iconSrc,alt:aZ.label,pillBg:tI[m].pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:aZ.label})]})}),(0,z.jsx)(X.SelectContent,{children:tn.VECTOR_STORE_LIST.map(a=>{let b=tI[a.id],c="coming-soon"===a.installStatus;return(0,z.jsx)(X.SelectItem,{value:a.id,disabled:c,children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[b&&(0,z.jsx)(ah.ProviderIcon,{src:b.iconSrc,alt:a.label,pillBg:b.pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),c&&(0,z.jsx)("span",{className:"ml-2 text-[9px] text-muted-foreground border rounded-full px-1.5",children:"Soon"})]})},a.id)})})]}),(0,z.jsxs)(U.Button,{variant:w?"secondary":"outline",size:"sm",onClick:a_,disabled:u||a$,children:[u?(0,z.jsx)(Q.Loader2,{className:"size-3.5 mr-2 animate-spin"}):w?(0,z.jsx)(th,{className:"size-3.5 mr-2 text-emerald-500"}):(0,z.jsx)(ti,{className:"size-3.5 mr-2"}),w?"Verified":"Verify"]})]}),a$&&(0,z.jsx)("p",{className:"text-xs text-destructive",children:"You must select a cloud storage provider before deploying."}),(0,z.jsx)(to,{store:aZ,values:o,errors:q,indexType:l?.config.indexType,onChange:(a,b)=>{p(c=>({...c,[a]:b})),r(b=>({...b,[a]:""})),x(!1)}}),(0,z.jsxs)("div",{className:"pt-2 border-t mt-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Embedding Model"}),(0,z.jsxs)(X.Select,{value:y,onValueChange:a=>{B(a||""),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full bg-white",children:(0,z.jsx)("span",{className:"font-medium text-sm",children:aY?.label??"Default"})}),(0,z.jsx)(X.SelectContent,{children:aX.map(a=>(0,z.jsx)(X.SelectItem,{value:a.id,children:(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label})},a.id))})]})]})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Environment Variables"}),(0,z.jsxs)("div",{className:"grid gap-4 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SERVER_API_KEY"," ",(0,z.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"(Optional)"})]}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ac?"text":"password",value:_,onChange:a=>ab(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ad(!ac),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",onClick:()=>{ab("larkup-"+Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15))},children:(0,z.jsx)(tg,{className:"size-4"})})]})]}),O.map(a=>(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:[a.key,a.required&&(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})," ",T[a.key]&&(0,z.jsx)("span",{className:"text-emerald-500 text-[10px] ml-2",children:"Pre-filled"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ae[a.key]?"text":"password",value:T[a.key]||"",onChange:b=>Z({...T,[a.key]:b.target.value})}),(0,z.jsx)("button",{type:"button",onClick:()=>af(b=>({...b,[a.key]:!b[a.key]})),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),a.help&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:a.help})]},a.key))]})]})]}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${a5?"hidden":"block"}`,children:["vercel"===c?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{className:"flex justify-between w-full items-center",children:[(0,z.jsxs)("span",{children:["Vercel Token ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noreferrer",className:"text-[10px] font-medium text-muted-foreground underline hover:text-foreground",children:"Get token"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aq?"text":"password",value:am,onChange:a=>an(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ar(!aq),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Project Name ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:ao,onChange:a=>ap(a.target.value)})]})]}):(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Server IP / Hostname ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:au,onChange:a=>av(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SSH Username ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:aw,onChange:a=>ax(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)("div",{className:"flex gap-2 mb-2",children:[(0,z.jsx)(tl.Badge,{variant:"key"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("key"),children:"Private Key"}),(0,z.jsx)(tl.Badge,{variant:"password"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("password"),children:"Password"})]}),"key"===ay?(0,z.jsx)("textarea",{className:"min-h-30 rounded-md border bg-transparent px-3 py-2 text-sm font-mono",value:aA,onChange:a=>aB(a.target.value)}):(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aC?"text":"password",value:aA,onChange:a=>aB(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>aD(!aC),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]})]}),aQ&&aE.length>0&&(0,z.jsx)("div",{className:"bg-black text-[#00ff00] font-mono text-[10px] p-3 rounded-md h-50 overflow-y-auto break-all whitespace-pre-wrap flex flex-col-reverse",children:(0,z.jsx)("div",{children:aE.map((a,b)=>(0,z.jsx)("div",{children:a},b))})})]}),L&&(0,z.jsxs)("div",{className:"mt-8 space-y-3 rounded-lg border p-5 bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex justify-between text-sm font-medium",children:[(0,z.jsx)("span",{children:aV?.status==="completed"?"Knowledge base uploaded":"Uploading knowledge base"}),(0,z.jsxs)("span",{className:"tabular-nums",children:[aW,"%"]})]}),(0,z.jsx)(tm.Progress,{value:aW,className:"h-2"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground pt-1",children:aV?.warning||`${aV?.processedChunks??0} / ${aV?.totalChunks??0} chunks`})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 z-10 border-t bg-background px-6 py-4 flex items-center justify-between mt-auto",children:[(0,z.jsx)(U.Button,{variant:"outline",className:"px-5",onClick:()=>b(!1),disabled:aQ||L,children:"Cancel"}),(0,z.jsxs)(U.Button,{className:"px-7",onClick:a1,disabled:aQ||L,children:[(aQ||L)&&(0,z.jsx)(Q.Loader2,{className:"mr-2 size-4 animate-spin"}),"env"===c?"Save Settings":"Deploy"]})]})]})}),(0,z.jsx)(tk.Sheet,{open:aG,onOpenChange:a=>{a||(aS.current=null),aH(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full sm:max-w-md w-full overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"Password Change Required"}),(0,z.jsx)(tk.SheetDescription,{children:"Your server requires a password change on first login."})]})}),(0,z.jsxs)("div",{className:"flex-1 p-6 overflow-y-auto grid gap-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"New Password"}),(0,z.jsx)(V.Input,{type:"password",value:aI,onChange:a=>aJ(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"Confirm Password"}),(0,z.jsx)(V.Input,{type:"password",value:aK,onChange:a=>aL(a.target.value)})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 border-t bg-background px-6 py-4 flex justify-between",children:[(0,z.jsx)(U.Button,{variant:"outline",onClick:()=>aH(!1),children:"Cancel"}),(0,z.jsx)(U.Button,{onClick:a4,children:"Change & Deploy"})]})]})})]})}function tL({serverId:a="default",showUtilities:b=!0,compact:c=!1,openTarget:d,openSignal:e}){let[f,g]=(0,A.useState)(!1),[h,i]=(0,A.useState)(null),j=(0,A.useRef)(0),k=a=>{i(a),g(!0)},l=a=>{Y.toast.success(`Downloading deployment package for ${a}...`),window.open(`/api/server/download?provider=${a}`)};return(0,A.useEffect)(()=>{d&&e&&e!==j.current&&(j.current=e,k(d))},[e,d]),(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,z.jsx)(ac.TooltipProvider,{children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{delay:0,render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:`${c?"h-8 w-8":"h-9 w-9"} shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>k("env"),children:(0,z.jsx)(C.Settings2,{className:"size-4"})})}),(0,z.jsx)(ac.TooltipContent,{children:(0,z.jsx)("p",{children:"Environment Variables"})})]})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"default",size:"default",className:`${c?"h-8":"h-9"} w-32.5 justify-start gap-1 rounded-md`}),children:(0,z.jsxs)("div",{className:"w-full flex items-center h-8 justify-between rounded-lg",children:[(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 mr-2"}),"Deploy"]}),(0,z.jsx)(tf.ChevronDown,{})]})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-50",children:[(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("vercel"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/vercel.svg",className:"size-4 mr-2",alt:"Vercel"}),"Vercel"]})}),(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("hetzner"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/hetzner.svg",className:"size-4 mr-2",alt:"Hetzner"}),"Hetzner"]})}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/azure.svg",className:"size-4 mr-2",alt:"Azure"}),"Azure"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-app-service"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Service"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-container-apps"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Container Apps"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("azure"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Virtual Machines"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/aws.svg",className:"size-4 mr-2",alt:"AWS"}),"AWS"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-elastic-beanstalk"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Elastic Beanstalk"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-app-runner"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Runner / Fargate"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("aws"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"EC2"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/gcp.svg",className:"size-4 mr-2",alt:"GCP"}),"GCP"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-app-engine"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-cloud-run"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Cloud Run"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("gcp"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Compute Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/digital-ocean.webp",className:"size-4 mr-2",alt:"DigitalOcean"}),"DigitalOcean"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("digitalocean-app-platform"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Platform"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("digitalocean"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Droplets"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]})]})]}),(0,z.jsx)(tK,{open:f,onOpenChange:g,target:h,serverId:a})]})}let tM=(0,tp.createServerReference)("60b38ac8b6a6260cf147e193083e400ab9e0863ac7",tp.callServer,void 0,tp.findSourceMapURL,"getVercelDeploymentStatus"),tN=a=>fetch(a).then(a=>a.json());function tO(a){return a.replace(/\/$/,"")}function tP(a){return`${tO(a)}/reference`}function tQ({url:a,project:b,compact:c=!1}){return(0,z.jsxs)("a",{href:tP(a),target:"_blank",rel:"noreferrer","aria-label":`Open API reference for ${b}`,className:(0,M.cn)((0,U.buttonVariants)({variant:c?"ghost":"outline",size:c?"icon":"sm"}),c?"size-8 sm:hidden":"hidden h-8 gap-1.5 px-2 text-xs sm:inline-flex"),children:[(0,z.jsx)(ar.ExternalLink,{className:c?"size-4":"size-3"}),!c&&"API reference"]})}function tR(){let{activeServer:a,refresh:b}=(0,$.useWorkspace)(),c=a?.id||"default",[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)(!1),[j,k]=(0,A.useState)(null),[l,m]=(0,A.useState)(!1),[n,o]=(0,A.useState)(0),[p,q]=(0,A.useState)(!1),[r,s]=(0,A.useState)([]),[t,u]=(0,A.useState)(null),[v,w]=(0,A.useState)(""),[x,y]=(0,A.useState)(null),[B,C]=(0,A.useState)(!1),[D,E]=(0,A.useState)(0),F=(0,A.useRef)(new Set);(0,A.useEffect)(()=>{let a=localStorage.getItem("rag_server_api_key");a&&g(a),o(tv(c)),s(tx(c)),F.current.clear()},[c]),(0,A.useEffect)(()=>{let a=localStorage.getItem("vercel_token"),b=r.filter(a=>"vercel"===a.provider);if(!a||0===b.length)return;let d=b.filter(a=>"queued"===a.status||"building"===a.status||"ready"===a.status&&!F.current.has(a.id));if(0===d.length)return;let e=!1,f=async()=>{let b=await Promise.all(d.map(async b=>({deployment:b,result:await tM(a,b.project)})));if(!e)for(let{deployment:a,result:d}of b){"ready"===d.status&&F.current.add(a.id);let b=d.hasProductionAlias?d.url:void 0;"unknown"!==d.status&&(a.status!==d.status||b&&a.url!==b)&&s(tA(c,a.id,{status:d.status,url:b}))}};f();let g=d.some(a=>"queued"===a.status||"building"===a.status)?window.setInterval(()=>void f(),8e3):void 0;return()=>{e=!0,g&&window.clearInterval(g)}},[r,c]),(0,A.useEffect)(()=>{let a=a=>{a.detail===c&&(s(tx(c)),o(tv(c)))};return window.addEventListener("larkup-deployments-change",a),()=>window.removeEventListener("larkup-deployments-change",a)},[c]);let{data:G,mutate:H}=(0,P.default)("/api/server/local",tN,{refreshInterval:a=>5e3*!!a?.state.running}),I=G?.state;async function J(a){e(a);let d="start"===a;H({state:{...I,running:d}},!1),(0,ao.mutate)("/api/servers",a=>a?{...a,servers:a.servers.map(a=>a.id===c?{...a,running:d}:a)}:a,!1);try{let c=localStorage.getItem("rag_server_api_key")||"",d=await fetch("/api/server/local",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a,serverApiKey:c})}),e=await d.json();"start"===a?e.state?.running?Y.toast.success("Server is running."):(Y.toast.error(e.state?.lastError??"Server did not start."),(0,ao.mutate)("/api/servers")):Y.toast.success("Server stopped."),H(),b()}catch{Y.toast.error("Could not reach the server controller."),(0,ao.mutate)("/api/servers"),H()}finally{e(null)}}function K(a){let b=localStorage.getItem("rag_server_api_key")||"";g(a),localStorage.setItem("rag_server_api_key",a),a!==b&&o(tw(c))}function L(a){return r.length>0&&a!==(localStorage.getItem("rag_server_api_key")||"")?(y(a),C(!0),!1):(K(a),!0)}function N(a){if(null!==x&&K(x),y(null),C(!1),a){E(a=>a+1),Y.toast.info("New API key saved. Configure the Vercel redeploy to sync it remotely.");return}Y.toast.info("API key updated locally. Redeploy cloud servers when you are ready to sync it.")}async function O(){await navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),1500)}async function R(a){f?(await navigator.clipboard.writeText(f),k(a),setTimeout(()=>k(null),1500),Y.toast.success("Cloud API key copied")):Y.toast.error("Generate or enter an API key before copying it.")}async function W(){I?.endpoint&&(await navigator.clipboard.writeText(I.endpoint),m(!0),setTimeout(()=>m(!1),1500))}return(0,z.jsxs)("main",{className:"mx-auto w-full max-w-5xl px-6 ",children:[(0,z.jsxs)("header",{className:"mb-12",children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Server"}),(0,z.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Test locally, then deploy one retrieval and chat server anywhere."})]}),(0,z.jsxs)("section",{className:"mb-14",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(as,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Local server"})]}),(0,z.jsxs)("span",{className:"flex items-center gap-2 text-xs",children:[I?.running?(0,z.jsxs)("span",{className:"relative flex size-2",children:[(0,z.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}):(0,z.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/40"}),(0,z.jsx)("span",{className:I?.running?"font-medium text-emerald-600 dark:text-emerald-400":"text-muted-foreground",children:I?.running?`running on :${I.port}`:"stopped"})]})]}),(0,z.jsx)("p",{className:"mt-2 max-w-xl text-sm text-muted-foreground",children:"Start the server locally to test your AI endpoints. Your configuration and API keys are applied automatically."}),I?.lastError&&!I.running&&(0,z.jsxs)(aF.Alert,{variant:"destructive",children:[(0,z.jsx)(aF.AlertTitle,{children:"Launch failed"}),(0,z.jsx)(aF.AlertDescription,{className:"wrap-break-word",children:I.lastError})]}),I?.running?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border border-border",children:[(0,z.jsxs)("button",{type:"button",onClick:W,className:"flex w-full items-center justify-between gap-3 border-b border-border bg-muted/30 px-4 py-3 text-left",children:[(0,z.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5 font-mono text-sm",children:[(0,z.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:(0,z.jsx)(at.Copy,{className:"size-3.5"})}),(0,z.jsx)("span",{className:"truncate",children:I.endpoint})]}),(0,z.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:l?"Copied":"Click to copy"})]}),(0,z.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[(0,z.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,z.jsx)(te,{serverUrl:I.endpoint}),(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsxs)(aG.DialogTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8 text-xs px-2 gap-1.5"}),children:[(0,z.jsx)(as,{className:"size-3"}),"Try it (cURL)"]}),(0,z.jsxs)(aG.DialogContent,{className:"max-w-2xl!",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsx)(aG.DialogTitle,{children:"cURL Example"}),(0,z.jsx)(aG.DialogDescription,{children:"You can use this command to test your RAG server endpoint."})]}),(0,z.jsxs)("div",{className:"relative rounded-md bg-muted p-4 mt-2 border border-border/50",children:[(0,z.jsx)("pre",{className:"font-mono text-xs overflow-x-auto text-foreground pb-4 pr-6",children:(0,z.jsx)("code",{children:`curl -X POST ${I.endpoint}/query \\
60
60
  -H "Content-Type: application/json" \\${f?`
61
61
  -H "Authorization: Bearer ${f}" \\`:""}
62
62
  -d '{"query":"hello"}'`})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>{navigator.clipboard.writeText(`curl -X POST ${I.endpoint}/query -H "Content-Type: application/json"${f?` -H "Authorization: Bearer ${f}"`:""} -d '{"query":"hello"}'`),Y.toast.success("Command copied")},children:(0,z.jsx)(at.Copy,{className:"size-3"})})]})]})]}),(0,z.jsxs)(U.Button,{variant:"outline",size:"sm",disabled:"start"===d||!I.running,render:(0,z.jsx)("a",{href:tP(I.endpoint),target:"_blank",rel:"noreferrer"}),className:"h-8 gap-1.5 text-xs",children:[(0,z.jsx)(ar.ExternalLink,{className:"size-3"}),"API reference"]})]}),(0,z.jsxs)(U.Button,{size:"sm",variant:"destructive",onClick:()=>J("stop"),disabled:null!==d,children:["stop"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(aq.Square,{className:"size-4"}),"Stop server"]})]})]}):(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsxs)(U.Button,{size:"sm",onClick:()=>J("start"),disabled:null!==d,children:["start"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(ap.Play,{className:"size-4"}),"start"===d?"Starting…":"Launch server"]}),(0,z.jsx)(te,{serverUrl:I?.endpoint||"http://localhost:8080",disabled:!0})]})]}),(0,z.jsxs)("div",{className:"grid gap-14 border-t border-border pt-12 md:grid-cols-2 md:gap-10",children:[(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Deploy to cloud"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Deploy your AI server to Vercel for production use."}),(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsx)(tL,{serverId:c,showUtilities:!0,compact:!0,openTarget:"vercel",openSignal:D}),(0,z.jsxs)(U.Button,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:O,children:[h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"}),"Copy API key"]})]})]}),(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ay,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Server API key"})]}),(0,z.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["Clients must send this key in the"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"Authorization"})," ","header."]}),(0,z.jsxs)("div",{className:"mt-5 flex items-center gap-2",children:[(0,z.jsx)(V.Input,{type:p?"text":"password",value:f,onChange:a=>g(a.target.value),onBlur:()=>L(f),placeholder:"sk-...",className:"h-8 flex-1 font-mono text-xs"}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>q(a=>!a),children:p?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:O,disabled:!f,children:h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:function(){L("sk-"+Array.from(crypto.getRandomValues(new Uint8Array(24))).map(a=>a.toString(16).padStart(2,"0")).join(""))&&Y.toast.success("API key generated")},"aria-label":"Generate a new API key"}),children:(0,z.jsx)(av.RefreshCw,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:"Generate a new API key"})]})})]}),(0,z.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Stored locally in your browser. Generate a new key or paste your own."})]})]}),(0,z.jsxs)("section",{className:"mt-14 border-t border-border pt-10",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aB.Globe,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Cloud deployments"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Each deployment exposes its API endpoint and interactive API reference."}),r.length>0?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border",children:[(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b bg-muted/30 px-4 py-2 text-xs text-muted-foreground sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsx)("span",{className:"hidden sm:block",children:"Provider"}),(0,z.jsx)("span",{children:"API endpoint"}),(0,z.jsx)("span",{className:"hidden sm:block",children:"Reference"}),(0,z.jsx)("span",{children:"Actions"})]}),r.map(a=>(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b bg-background px-4 py-3 last:border-b-0 sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsxs)("span",{className:"hidden items-center gap-2 text-sm font-medium sm:flex",children:["vercel"===a.provider?(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-3.5"}):(0,z.jsx)(aB.Globe,{className:"size-3.5"}),a.provider,a.status&&(0,z.jsx)("span",{className:(0,M.cn)("rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium capitalize","ready"===a.status&&"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400","error"===a.status&&"bg-background text-foreground",("building"===a.status||"queued"===a.status)&&"border-orange-500/20 bg-orange-500/10 text-orange-700 dark:text-orange-400"),children:a.status}),(a.apiKeyVersion??0)!==n&&(0,z.jsx)("span",{className:"rounded-sm border border-orange-500/20 bg-orange-500/10 px-1.5 py-0.5 text-[10px] font-medium text-orange-700 dark:text-orange-400",children:"Key redeploy required"})]}),t===a.id?(0,z.jsx)(V.Input,{value:v,onChange:a=>w(a.target.value),className:"h-8 font-mono text-xs","aria-label":"Deployment URL"}):(0,z.jsx)("a",{href:tt(a),target:"_blank",rel:"noreferrer",className:"truncate font-mono text-xs hover:underline",children:tO(tt(a)).replace(/^https?:\/\//,"")}),(0,z.jsx)(tQ,{url:tt(a),project:a.project}),(0,z.jsx)("div",{className:"flex items-center gap-1",children:t===a.id?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{try{var b;let d=new URL(v).toString();s((b=a.id,tA(c,b,{url:d}))),u(null)}catch{Y.toast.error("Enter a valid deployment URL.")}},"aria-label":"Save deployment URL",children:(0,z.jsx)(au.CheckCircle2,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>u(null),"aria-label":"Cancel editing deployment URL",children:(0,z.jsx)(aA.X,{className:"size-4"})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>R(a.id),disabled:!f,"aria-label":"Copy cloud API key"}),children:j===a.id?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:j===a.id?"Cloud API key copied":(a.apiKeyVersion??0)===n?"Copy cloud API key":"Copy local key — redeploy to apply it"})]})}),(0,z.jsx)(tQ,{url:tt(a),project:a.project,compact:!0}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{u(a.id),w(tt(a))},"aria-label":"Edit deployment URL",children:(0,z.jsx)(az.Pencil,{className:"size-4"})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",children:(0,z.jsx)(aD,{className:"size-4"})})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-37.5",children:["vercel"===a.provider&&(0,z.jsxs)(aE.DropdownMenuItem,{onClick:()=>{let b=a.url.replace(/^https?:\/\//,"");window.open(`https://${b}/_logs`,"_blank")},children:[(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-4 mr-2 dark:invert"}),"View in Vercel"]}),(0,z.jsxs)(aE.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>{var b;let d;return s((b=a.id,d=tx(c).filter(a=>a.id!==b),ty(c,d),d))},children:[(0,z.jsx)(aw.Trash2,{className:"size-4 mr-2"}),"Delete"]})]})]})]})})]},a.id))]}):(0,z.jsxs)("div",{className:"flex flex-col border border-border rounded-md items-center px-4 py-6 justify-center gap-2 mt-5",children:[(0,z.jsx)("div",{className:"bg-white p-1 border border-border rounded-md",children:(0,z.jsx)(aC.default,{className:"size-5"})}),(0,z.jsx)("p",{className:" rounded-lg text-sm text-muted-foreground text-center mx-auto",children:"No cloud deployments yet. Deploy to a provider above to add one here."})]})]}),(0,z.jsx)(aH.AlertDialog,{open:B,onOpenChange:C,children:(0,z.jsxs)(aH.AlertDialogContent,{className:"max-w-xl! w-full!",children:[(0,z.jsxs)(aH.AlertDialogHeader,{children:[(0,z.jsx)(aH.AlertDialogTitle,{children:"Deploy this new API key?"}),(0,z.jsx)(aH.AlertDialogDescription,{children:"Existing cloud deployments keep their current key until you redeploy them. Choose whether to update locally only, or open a Vercel redeploy with this new key so your local and remote API keys stay in sync."})]}),(0,z.jsxs)(aH.AlertDialogFooter,{className:"mt-3",children:[(0,z.jsx)(aH.AlertDialogCancel,{className:"mr-auto",size:"sm",onClick:()=>{g(localStorage.getItem("rag_server_api_key")||""),y(null)},children:"Cancel"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Update locally only"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",onClick:()=>N(!0),children:"Update & deploy to Vercel"})]})]})})]})}let tS=(0,G.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);var tT=a.i(733105);new Date(0).toISOString();let tU=`You are a powerful data analysis assistant with access to a knowledge base, corpus introspection tools, tabular data tools, and a code sandbox.
@@ -117,6 +117,6 @@ RESPONSE FORMATTING (Analytics Style):
117
117
  - Structure complex responses logically (e.g., Summary -> Key Metrics -> Breakdown).
118
118
  - If your findings contain a small table of data, format it cleanly using Markdown tables.
119
119
  - DO NOT hallucinate facts; rely strictly on the provided query results.
120
- - End with a one-sentence synthesis if appropriate, avoiding filler words.`,tV=(0,G.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),tW=(0,G.default)("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);var tX=a.i(918788);let tY=(0,G.default)("scan-eye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),tZ=(0,G.default)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),t$=(0,G.default)("chart-no-axes-column-increasing",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]]),t_=(0,G.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),t0=(0,G.default)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]);var t1=a.i(609509),t2=a.i(66651),t3=a.i(964598);let t4=a=>fetch(a).then(a=>a.json());function t5(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id,c=b?`/api/config?serverId=${encodeURIComponent(b)}`:"/api/config",{data:d,isLoading:e,mutate:f}=(0,P.default)(c,t4),[g,h]=(0,A.useState)({}),[i,j]=(0,A.useState)(!1);(0,A.useEffect)(()=>{d?.config&&h({...d.config,systemPrompt:d.config.systemPrompt||tU})},[d]);let k=(g.systemPrompt||"")!==(d?.config?.systemPrompt||"")||JSON.stringify(g.enabledTools||[])!==JSON.stringify(d?.config?.enabledTools||[]);async function l(){j(!0);try{let a={...d?.config,...g},b=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await b.json();if(!b.ok)throw Error(e.error??"Failed to save");await f(e,{revalidate:!1}),Y.toast.success("Prompt saved")}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to save")}finally{j(!1)}}return e?(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Agent Customization"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Customize the instructions and tools given to your AI assistant."})]}),(0,z.jsxs)(U.Button,{size:"sm",disabled:i||!k,onClick:l,className:"gap-1.5",children:[i?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})]}),(0,z.jsxs)(Z.Card,{className:"bg-white/60",children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"System Prompt"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Override the default instructions given to the AI. Leave blank for the default behavior."})]}),(0,z.jsx)(Z.CardContent,{children:(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(t3.Textarea,{value:g.systemPrompt||"",onChange:a=>h({...g,systemPrompt:a.target.value}),placeholder:"You are a helpful research assistant...",className:"w-full rounded-lg border border-border/70 bg-card px-3 py-2 text-sm text-foreground outline-none transition focus:border-border resize-none max-h-50 pb-10 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/40 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent"}),(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsx)(aG.DialogTrigger,{render:(0,z.jsx)("button",{type:"button",className:"absolute bottom-2 right-2 p-1.5 text-muted-foreground/60 hover:text-foreground transition-colors rounded-md cursor-pointer",children:(0,z.jsx)(tS,{className:"size-4",strokeWidth:1.75})})}),(0,z.jsxs)(aG.DialogContent,{className:"max-w-[90vw] sm:max-w-[90vw] w-[90vw] h-[90vh] flex flex-col ",children:[(0,z.jsxs)(aG.DialogHeader,{className:"shrink-0 space-y-0 p-3 pb-0",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aG.DialogTitle,{className:"text-lg font-semibold",children:"Edit text content."}),(0,z.jsx)(tT.FileText,{className:"size-4 text-muted-foreground"})]}),(0,z.jsx)(aG.DialogDescription,{children:"Edit text content."})]}),(0,z.jsx)("div",{className:"flex-1 min-h-0 mt-2 relative ",children:(0,z.jsx)(t3.Textarea,{value:g.systemPrompt||"",onChange:a=>h({...g,systemPrompt:a.target.value}),placeholder:"You are a helpful research assistant...",className:"h-full w-full rounded-lg border border-border/40 bg-background px-4 py-3 text-sm text-foreground outline-none transition focus:border-border resize-none [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/40 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent"})}),(0,z.jsxs)(aG.DialogFooter,{className:"mt-6 justify-end flex items-center gap-2 shrink-0",children:[(0,z.jsx)(aG.DialogClose,{render:(0,z.jsx)(U.Button,{variant:"outline",className:"px-3"}),children:"Cancel"}),(0,z.jsx)(aG.DialogClose,{render:(0,z.jsx)(U.Button,{}),children:"Save"})]})]})]})]})})]}),(0,z.jsx)(t8,{form:g,setForm:h})]})}let t6=[{id:"searchKnowledgeBase",name:"Semantic Search",desc:"Search the RAG knowledge base for text.",icon:F.Search},{id:"queryTabularData",name:"Tabular Data Query",desc:"Filter, group, and aggregate tabular data.",icon:tZ},{id:"generateVisualization",name:"Generate Charts",desc:"Create interactive Recharts visualizations.",icon:t$},{id:"executeAnalysis",name:"Python Sandbox",desc:"Execute Python code for complex analysis.",icon:t_},{id:"getIndexedData",name:"Indexed Data",desc:"List and filter source documents.",icon:t0},{id:"analyzeCorpusWithCode",name:"Corpus Analysis",desc:"Python sandbox with full corpus access.",icon:t_},{id:"fillDocumentForm",name:"Form Filler",desc:"Fill forms in the active document.",icon:t1.FileEdit},{id:"editDocument",name:"Document Editor",desc:"Edit text in the active document.",icon:t2.PenTool}],t7={Film:tX.Film,ScanEye:tY};function t8({form:a,setForm:b}){let[c,d]=(0,A.useState)("tools"),{data:e}=(0,P.default)("/api/marketplace",a=>fetch(a).then(a=>a.json())),f=(e?.tools||[]).filter(a=>"installed"===a.status),g=[...t6,...f.map(a=>({id:a.id,name:a.name,desc:a.description,isMarketplace:!0,...a}))],h=new Set(a.enabledTools||[]),i="tools"===c?t6:f.map(a=>({id:a.id,name:a.name,desc:a.description,isMarketplace:!0,...a}));return(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-4",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Agent Tools"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Select which tools the AI assistant is allowed to use."}),(0,z.jsx)("div",{className:"mt-4 flex flex-wrap items-center gap-4",children:(0,z.jsxs)("div",{className:"flex items-center gap-1 border border-border/90 rounded-lg bg-muted/60 p-1",children:[(0,z.jsxs)("button",{type:"button",onClick:()=>d("tools"),className:(0,M.cn)("relative flex items-center gap-1.5 px-3 py-1.5 text-[13px] font-medium transition-all duration-200 rounded-md","tools"===c?"bg-background text-foreground ring-1 ring-border":"text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:[(0,z.jsx)(tV,{className:"size-3.5",strokeWidth:"tools"===c?2:1.75}),"Tools",(0,z.jsx)("span",{className:"ml-1 flex h-4 items-center justify-center rounded-full bg-secondary px-1.5 text-[10px] font-medium text-muted-foreground",children:t6.length})]}),(0,z.jsxs)("button",{type:"button",onClick:()=>d("plugins"),className:(0,M.cn)("relative flex items-center gap-1.5 px-3 py-1.5 text-[13px] font-medium transition-all duration-200 rounded-md","plugins"===c?"bg-background text-foreground ring-1 ring-border":"text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:[(0,z.jsx)(tW,{className:"size-3.5",strokeWidth:"plugins"===c?2:1.75}),"Plugins",(0,z.jsx)("span",{className:"ml-1 flex h-4 items-center justify-center rounded-full bg-secondary px-1.5 text-[10px] font-medium text-muted-foreground",children:f.length})]})]})})]}),(0,z.jsx)(Z.CardContent,{children:0===i.length?(0,z.jsx)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No plugins installed. Go to the Marketplace to install plugins."}):(0,z.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:i.map(c=>{var d;let e,f=(d=c.id,!a.enabledTools||0===a.enabledTools.length||h.has(d));return(0,z.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/70 bg-background px-4 py-3.5 transition-colors hover:border-border",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(e=c.isMarketplace?c.icon&&t7[c.icon]||tW:c.icon||tV,(0,z.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border",children:c.emoji?(0,z.jsx)("span",{className:"text-xl leading-none",children:c.emoji}):(0,z.jsx)(e,{className:"size-5 text-foreground",strokeWidth:1.75})})),(0,z.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,z.jsxs)("span",{className:"text-[13px] font-medium text-foreground truncate",children:[c.name,c.isMarketplace&&(0,z.jsx)("span",{className:"ml-2 rounded-md bg-secondary px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"Plugin"})]}),(0,z.jsx)("p",{className:"mt-0.5 text-[12px] text-muted-foreground leading-relaxed line-clamp-1",children:c.desc})]})]}),(0,z.jsx)(ab.Switch,{checked:f,onCheckedChange:()=>{var d;let e;return d=c.id,e=new Set(h),void(a.enabledTools&&0!==a.enabledTools.length?e.has(d)?e.delete(d):e.add(d):g.forEach(a=>{a.id!==d&&e.add(a.id)}),b({...a,enabledTools:Array.from(e)}))},"aria-label":`Toggle ${c.name}`})]},c.id)})})})]})}var t9=a.i(113413);let ua=(0,G.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]);var ub=a.i(95507);let uc=a=>fetch(a).then(a=>a.json()),ud=[1,3,5,8,10],ue=["What is this corpus about?","Summarize the key concepts.","How does retrieval work?"];function uf(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id??null,c=b?`/api/demo?serverId=${encodeURIComponent(b)}`:"/api/demo",{data:d,isLoading:e}=(0,P.default)(c,uc,{refreshInterval:5e3}),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)(5),[j,k]=(0,A.useState)(!1),[l,m]=(0,A.useState)(null),[n,o]=(0,A.useState)(null);if((0,A.useEffect)(()=>{o(null),m(null)},[b]),e||!d)return(0,z.jsx)("div",{className:"px-6 py-6 md:px-8",children:(0,z.jsx)(ub.Skeleton,{className:"h-40 w-full"})});let{ready:p,blockers:q,server:r,config:s}=d;async function t(a){let c=a.trim();if(c){k(!0),m(null);try{let a=await fetch("/api/demo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:c,topK:h,serverId:b})}),d=await a.json();if(!a.ok){m(d.error??"Query failed."),o(null);return}o(d)}catch{m("Could not reach the retrieval endpoint."),o(null)}finally{k(!1)}}}return(0,z.jsxs)("div",{className:"space-y-6 w-full",children:[!p&&(0,z.jsxs)(aF.Alert,{variant:"default",className:"text-orange-500",children:[(0,z.jsx)(t9.AlertTriangle,{className:"size-4"}),(0,z.jsx)(aF.AlertTitle,{children:"Nothing to query yet"}),(0,z.jsx)(aF.AlertDescription,{children:(0,z.jsx)("ul",{className:"list-disc pl-4",children:q.map(a=>(0,z.jsx)("li",{children:a},a))})})]}),(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"space-y-4 pt-6",children:[(0,z.jsx)("div",{className:"relative",children:(0,z.jsx)(t3.Textarea,{value:f,onChange:a=>g(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),t(f))},placeholder:"Ask a question to retrieve the most relevant chunks…",disabled:!p||j,rows:3,className:"resize-none pr-3 text-sm leading-relaxed"})}),(0,z.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Top-k"}),(0,z.jsx)("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-muted/40 p-0.5",children:ud.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>i(a),className:(0,M.cn)("min-w-8 rounded-md px-2.5 py-1 text-xs font-medium tabular-nums transition-colors",h===a?"bg-white border text-foreground ":"text-muted-foreground hover:text-foreground"),children:a},a))})]}),(0,z.jsxs)(U.Button,{onClick:()=>t(f),disabled:!p||j||!f.trim(),children:[j?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(F.Search,{className:"size-4"}),j?"Searching…":"Search",!j&&(0,z.jsx)("kbd",{className:"ml-1 hidden items-center gap-0.5 rounded border border-primary-foreground/30 px-1 text-[10px] opacity-80 sm:inline-flex",children:(0,z.jsx)(ua,{className:"size-2.5"})})]})]}),p&&!n&&!j&&(0,z.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Try:"}),ue.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>{g(a),t(a)},className:"rounded-full border border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:a},a))]})]})}),l&&(0,z.jsxs)(aF.Alert,{variant:"destructive",children:[(0,z.jsx)(t9.AlertTriangle,{className:"size-4"}),(0,z.jsx)(aF.AlertTitle,{children:"Query failed"}),(0,z.jsx)(aF.AlertDescription,{children:l})]}),j&&(0,z.jsx)(ui,{count:h}),!j&&n&&(0,z.jsx)(ug,{result:n})]})}function ug({result:a}){return 0===a.hits.length?(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"flex flex-col items-center justify-center gap-1 py-12 text-center",children:[(0,z.jsx)(F.Search,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,z.jsx)("p",{className:"text-sm font-medium",children:"No matches found"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Nothing in the index scored against that query. Try rephrasing or indexing more content."})]})}):(0,z.jsxs)("div",{className:"space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("h2",{className:"text-sm font-medium",children:[a.hits.length," result",1===a.hits.length?"":"s"]}),(0,z.jsxs)("span",{className:"font-mono text-xs text-muted-foreground tabular-nums",children:["server"===a.source?"via server":"via direct"," ·"," ",a.tookMs.toLocaleString(),"ms"]})]}),a.hits.map((a,b)=>(0,z.jsx)(uh,{hit:a,rank:b+1},a.id||b))]})}function uh({hit:a,rank:b}){let c=Math.round(100*Math.min(Math.max(a.score,0),1));return(0,z.jsx)(Z.Card,{className:"overflow-hidden",children:(0,z.jsxs)(Z.CardContent,{className:"flex gap-4 py-4",children:[(0,z.jsx)("div",{className:"flex flex-col items-center gap-1 pt-0.5",children:(0,z.jsx)("span",{className:"flex size-7 items-center justify-center rounded-md bg-muted text-xs font-semibold tabular-nums text-muted-foreground",children:b})}),(0,z.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,z.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,z.jsx)(tT.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,z.jsx)("h3",{className:"truncate text-sm font-medium",children:a.title||"Untitled"})]}),(0,z.jsxs)(tl.Badge,{variant:"secondary",className:"shrink-0 font-mono text-[11px] tabular-nums",children:[c,"%"]})]}),(0,z.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:a.text.length>360?`${a.text.slice(0,360).trim()}…`:a.text}),a.url&&(0,z.jsxs)("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,z.jsx)(ar.ExternalLink,{className:"size-3"}),(0,z.jsx)("span",{className:"truncate",children:a.url})]})]})]})})}function ui({count:a}){return(0,z.jsx)("div",{className:"space-y-3",children:Array.from({length:Math.min(a,4)}).map((a,b)=>(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"flex gap-4 py-4",children:[(0,z.jsx)(ub.Skeleton,{className:"size-7 rounded-md"}),(0,z.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,z.jsx)(ub.Skeleton,{className:"h-4 w-1/3"}),(0,z.jsx)(ub.Skeleton,{className:"h-3 w-full"}),(0,z.jsx)(ub.Skeleton,{className:"h-3 w-4/5"})]})]})},b))})}function uj(){return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Playground"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Test your search and retrieval to see what your AI returns."})]}),(0,z.jsx)(uf,{})]})}var uk=a.i(295805);let ul=[{id:"default",name:"Caffee",color:"#f2efe4"},{id:"theme-gaia",name:"Emerald Green",color:"#2b935f"},{id:"theme-docker",name:"Ocean Blue",color:"#1d63ed"},{id:"theme-pinecone",name:"Deep Indigo",color:"#6e56cf"},{id:"theme-vercel",name:"Minimal Black",color:"#000000"},{id:"theme-elevenlabs",name:"Soft Cream",color:"#f8f7f5"},{id:"theme-espresso",name:"Espresso",color:"#6B3F2A"},{id:"theme-sienna",name:"Warm Sienna",color:"#A0522D"},{id:"theme-caramel",name:"Caramel",color:"#C47C3E"}],um=[{id:"bg-default",name:"White",color:"#FFFFFF"},{id:"bg-pure",name:"Pure White",color:"#FFFFFF"},{id:"bg-fafafa",name:"Near White",color:"#F4F4F4"},{id:"bg-silver",name:"Silver",color:"#F8F8F8"},{id:"bg-soft",name:"Soft",color:"#FBFAF8"},{id:"bg-stone",name:"Stone",color:"#F5F5F2"},{id:"bg-sage",name:"Sage",color:"#EDEDE8"},{id:"bg-warm",name:"Warm Cream",color:"#F7F1EA"}],un=[{id:"panel-default",name:"Theme Default",color:"#FAFAFA"},{id:"panel-white",name:"White",color:"#FFFFFF"},{id:"panel-fafafa",name:"Near White",color:"#F4F4F4"},{id:"panel-silver",name:"Silver",color:"#F8F8F8"},{id:"panel-soft",name:"Soft",color:"#FBFAF8"},{id:"panel-stone",name:"Stone",color:"#F5F5F2"},{id:"panel-warm",name:"Warm Cream",color:"#F7F1EA"}],uo=[{id:"radius-0",name:"Sharp",value:"0"},{id:"radius-sm",name:"Small",value:"0.3rem"},{id:"radius-default",name:"Default",value:"0.625rem"},{id:"radius-lg",name:"Large",value:"1rem"}],up=[{id:"card",name:"Card Wrapper"},{id:"fused",name:"Fused (Edge to edge)"}],uq=[{id:"sidebar",name:"Sidebar Navigation"},{id:"topnav",name:"Top Navigation"}];function ur(){let{theme:a,setTheme:b,background:c,setBackground:d,panelBg:e,setPanelBg:f,navBg:g,setNavBg:h,radius:i,setRadius:j,pageStyle:k,setPageStyle:l,layout:m,setLayout:n,isMounted:o}=(0,uk.useThemeCustomizer)();return o?(0,z.jsxs)("div",{className:"space-y-10 max-w-2xl",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-xl font-semibold tracking-tight",children:"Appearance"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Customize the look and feel of your workspace."})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Theme & Colors"}),(0,z.jsx)("div",{className:"space-y-6",children:(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Primary Accent Color"}),(0,z.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 gap-2",children:ul.map(c=>(0,z.jsxs)("button",{onClick:()=>b(c.id),className:(0,M.cn)("relative flex flex-col items-center justify-center gap-2 rounded-lg border p-2 text-xs transition-all hover:bg-muted/50",a===c.id?"border-border bg-white":"border-muted/20"),children:[(0,z.jsx)("div",{className:"h-6 w-6 rounded-full ring-1 ring-border/20",style:{background:c.color}}),a===c.id&&(0,z.jsx)(aJ.Check,{className:"absolute top-1 right-1 size-3 text-primary"}),(0,z.jsx)("span",{className:"truncate w-full text-center text-[10px] text-muted-foreground",children:c.name})]},c.id))})]})})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Layout Preferences"}),(0,z.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Navigation Style"}),(0,z.jsx)("div",{className:"flex flex-col gap-2",children:uq.map(a=>(0,z.jsx)("button",{onClick:()=>n(a.id),className:(0,M.cn)("rounded-lg border p-2.5 text-xs font-medium transition-all text-left",m===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),children:a.name},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"App Wrapper"}),(0,z.jsx)("div",{className:"flex flex-col gap-2",children:up.map(a=>(0,z.jsx)("button",{onClick:()=>l(a.id),className:(0,M.cn)("rounded-lg border p-2.5 text-xs font-medium transition-all text-left",k===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),children:a.name},a.id))})]})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Backgrounds & Shapes"}),(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6",children:[(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Page Base"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:um.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>d(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",c===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","bg-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Content Panel"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:un.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>f(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",e===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","panel-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Sidebar Nav"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:un.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>h(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",g===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","panel-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},`nav-${a.id}`))})]})]})}),(0,z.jsxs)("div",{className:"space-y-2.5 pt-4",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Corners Radius"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:uo.map(a=>(0,z.jsx)("button",{onClick:()=>j(a.id),className:(0,M.cn)("rounded-md border px-3 py-1.5 text-xs font-medium transition-all",i===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),style:{borderRadius:a.value},children:a.name},a.id))})]})]})]}):null}var us=a.i(886215),ut=a.i(671008);let uu=[{value:"hybrid",label:"Hybrid",description:"Combines semantic understanding with keyword matching for best results."},{value:"semantic",label:"Semantic",description:"Uses embeddings to find conceptually similar content."},{value:"lexical",label:"Lexical",description:"Traditional keyword-based search using BM25 scoring."}],uv=a=>fetch(a).then(a=>a.json()),uw={lancedb:{iconSrc:"/icons/lancedb2.png",pillBg:"bg-yellow-50 dark:bg-yellow-950/40"},pinecone:{iconSrc:"/icons/pinecone.png",pillBg:"bg-green-50 dark:bg-green-950/40"}};function ux(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id,c=b?`/api/config?serverId=${encodeURIComponent(b)}`:"/api/config",{data:d,isLoading:e,mutate:f}=(0,P.default)(c,uv),[g,h]=(0,A.useState)({}),[i,j]=(0,A.useState)(!1),[k,l]=(0,A.useState)({}),[m,n]=(0,A.useState)(null),[o,p]=(0,A.useState)(!1),[q,r]=(0,A.useState)(!1),{data:s}=(0,P.default)("/api/index",a=>fetch(a).then(a=>a.json())),t=s?.run?.status==="completed"?s.run:null;(0,A.useEffect)(()=>{d?.config&&h(d.config)},[d]);let u=JSON.stringify(g)!==JSON.stringify(d?.config??{});async function v(){if(m){if(q)try{if(!(await fetch("/api/documents",{method:"DELETE"})).ok)throw Error("Could not clear the knowledge base.");Y.toast.success("Knowledge base cleared.")}catch(a){Y.toast.error(a instanceof Error?a.message:"Could not clear the knowledge base.");return}h(a=>({...a,vectorStore:m,storeConfig:{}})),p(!1),n(null)}}async function w(){if(!d?.config)return;let a=!1,b={};if(g.vectorStore){let c=(0,tn.getVectorStore)(g.vectorStore);if(c){let d=(0,tn.validateStoreConfig)(c,g.storeConfig||{},g.indexType||"hybrid");Object.keys(d).length>0&&(Object.assign(b,d),a=!0)}}if(l(b),a)return void Y.toast.error("Please fill in all required fields",{duration:1/0});j(!0);try{let a={...d.config,...g},b=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await b.json();if(!b.ok)throw Error(e.error??"Failed to save");await f(e,{revalidate:!1}),Y.toast.success("Storage settings saved",{duration:1/0})}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to save",{duration:1/0})}finally{j(!1)}}return e?(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Storage"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Where your processed data is stored and indexed."})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-2 text-sm",children:[(0,z.jsx)(ut.Layers,{className:"size-3.5 text-primary"}),"Indexing Strategy"]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"How your documents are indexed for retrieval."})]}),(0,z.jsx)(Z.CardContent,{className:"space-y-4",children:(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{className:"text-xs",children:"Strategy"}),(0,z.jsxs)(X.Select,{value:g.indexType||"hybrid",onValueChange:a=>{t&&d?.config&&a!==d.config.indexType?(0,Y.toast)("Cannot modify configuration",{description:"This project already has indexed data. You must create a new project to change this setting.",duration:1/0}):h(b=>({...b,indexType:a}))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full",children:(0,z.jsx)("span",{className:"font-medium text-sm",children:uu.find(a=>a.value===(g.indexType||"hybrid"))?.label??"Select strategy…"})}),(0,z.jsx)(X.SelectContent,{children:uu.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:(0,z.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:a.description})]})},a.value))})]})]})})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-2 text-sm",children:[(0,z.jsx)(I.Database,{className:"size-3.5 text-primary"}),"Storage Engine"]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Configure your vector database connection."})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-5",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{className:"text-xs",children:"Storage Engine"}),(0,z.jsxs)(X.Select,{value:g.vectorStore||"",onValueChange:a=>{d?.config&&a!==g.vectorStore&&(n(a),r(!1),p(!0))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full",children:g.vectorStore?(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[(0,z.jsx)(ah.ProviderIcon,{src:uw[g.vectorStore]?.iconSrc??"",alt:(0,tn.getVectorStore)(g.vectorStore)?.label??g.vectorStore,pillBg:uw[g.vectorStore]?.pillBg??void 0,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:(0,tn.getVectorStore)(g.vectorStore)?.label??g.vectorStore})]}):(0,z.jsx)("span",{className:"text-muted-foreground",children:"Select storage engine…"})}),(0,z.jsx)(X.SelectContent,{children:tn.VECTOR_STORE_LIST.map(a=>{let b=uw[a.id],c="coming-soon"===a.installStatus;return(0,z.jsx)(X.SelectItem,{value:a.id,disabled:c,className:c?"opacity-50":"",children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5 w-full",children:[b&&(0,z.jsx)(ah.ProviderIcon,{src:b.iconSrc,alt:a.label,pillBg:b.pillBg??void 0,size:16}),(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),c&&(0,z.jsxs)("span",{className:"h-3.5 px-1 text-[9px] font-medium shrink-0 text-muted-foreground border rounded-full flex items-center bg-transparent",children:[(0,z.jsx)(us.Clock,{className:"size-2.5 mr-0.5"}),"Coming Soon"]})]})]})},a.id)})})]})]}),g.vectorStore&&(0,z.jsx)("div",{className:"border-t pt-4",children:(0,z.jsx)(to,{store:(0,tn.getVectorStore)(g.vectorStore),values:g.storeConfig||{},errors:k,onChange:(a,b)=>{h(c=>({...c,storeConfig:{...c.storeConfig,[a]:b}})),k[a]&&l(b=>{let c={...b};return delete c[a],c})},indexType:g.indexType||"hybrid"})})]}),(0,z.jsx)(Z.CardFooter,{className:"flex justify-end pt-4 border-t",children:(0,z.jsxs)(U.Button,{size:"sm",disabled:i||!u,onClick:w,className:"gap-1.5",children:[i?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})})]}),(0,z.jsx)(aH.AlertDialog,{open:o,onOpenChange:p,children:(0,z.jsxs)(aH.AlertDialogContent,{children:[(0,z.jsxs)(aH.AlertDialogHeader,{children:[(0,z.jsx)(aH.AlertDialogTitle,{children:"Change vector storage?"}),(0,z.jsx)(aH.AlertDialogDescription,{children:"Your existing indexed vectors stay in the current storage engine and will not be available after this change. Keep the knowledge base to re-index it in the new store, or clear it intentionally below."})]}),(0,z.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border p-3 text-sm",children:[(0,z.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:q,onChange:a=>r(a.target.checked)}),(0,z.jsxs)("span",{children:[(0,z.jsx)("span",{className:"font-medium",children:"Clear knowledge base"}),(0,z.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Permanently remove documents and the current vector index before changing storage."})]})]}),(0,z.jsxs)(aH.AlertDialogFooter,{children:[(0,z.jsx)(aH.AlertDialogCancel,{onClick:()=>n(null),children:"Cancel"}),(0,z.jsx)(aH.AlertDialogAction,{onClick:v,children:q?"Clear and change storage":"Keep documents and continue"})]})]})})]})}let uy=(0,G.default)("blocks",[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]]),uz=[{id:"webhook",name:"Webhook",description:"Custom webhook integration",iconPath:"/icons/webhook.png",fields:[{id:"url",label:"Webhook URL",type:"url",placeholder:"https://your-domain.com/webhook"}]},{id:"slack",name:"Slack",description:"Connect to a Slack workspace",iconPath:"/icons/slack.png",fields:[{id:"token",label:"Bot User OAuth Token",type:"password",placeholder:"xoxb-..."}]},{id:"discord",name:"Discord",description:"Add a Discord bot",iconPath:"/icons/discord.png",fields:[{id:"token",label:"Bot Token",type:"password",placeholder:"Paste your Discord bot token"}]},{id:"telegram",name:"Telegram",description:"Create a Telegram bot",iconPath:"/icons/telegram.png",fields:[{id:"token",label:"Bot Token",type:"password",placeholder:"Paste your Telegram bot token from BotFather"}]},{id:"whatsapp",name:"WhatsApp",description:"WhatsApp Business API",iconPath:"/icons/whatsapp.png",fields:[{id:"phoneNumberId",label:"Phone Number ID",type:"text",placeholder:"e.g. 10123456789"},{id:"token",label:"Access Token",type:"password",placeholder:"Permanent or temporary access token"}]},{id:"widget",name:"Website Widget",description:"Inject a chat UI in your website",IconComponent:aI,fields:[{id:"domain",label:"Allowed Domain",type:"text",placeholder:"https://your-website.com"}]}];function uA(){let[a,b]=(0,A.useState)({});(0,A.useEffect)(()=>{fetch("/api/connections").then(a=>a.json()).then(a=>{a.error||b(a)})},[]);let c=async a=>{b(a),await fetch("/api/connections",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})},[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(null),[h,i]=(0,A.useState)(!1),[j,k]=(0,A.useState)(""),[l,m]=(0,A.useState)(""),[n,o]=(0,A.useState)(""),[p,q]=(0,A.useState)(""),[r,s]=(0,A.useState)(!1),[t,u]=(0,A.useState)(!1),v=async a=>{if(a.preventDefault(),n){s(!0);try{if(!(await fetch(process.env.NEXT_PUBLIC_CONNECT_API_URL||"https://www.larkup.de/api/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,company:l,email:n,message:p})})).ok)throw Error("Failed to send request");u(!0),Y.toast.success("Request sent successfully!"),setTimeout(()=>{i(!1),u(!1),k(""),m(""),o(""),q("")},2e3)}catch(a){Y.toast.error("Failed to send request. Please try again later.")}finally{s(!1)}}},w=uz.find(a=>a.id===d);return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Connections"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Connect different channels to your AI server to chat from anywhere."})]}),(0,z.jsxs)(U.Button,{variant:"default",size:"sm",className:"h-8 gap-2 ",onClick:()=>i(!0),children:[(0,z.jsx)(uy,{className:"size-3.5"}),"Ask for connection"]})]}),(0,z.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-1 gap-5",children:uz.map(b=>{let c=a[b.id];return(0,z.jsxs)("div",{className:"group flex items-center justify-between gap-3.5 rounded-xl border border-border bg-card px-4 py-3.5 transition-all ",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3.5 min-w-0",children:[(0,z.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border border-border/30",children:b.iconPath?(0,z.jsx)("img",{src:b.iconPath,alt:b.name,className:"size-6 object-contain"}):b.IconComponent?(0,z.jsx)(b.IconComponent,{className:"size-5 text-foreground"}):null}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsx)("div",{className:"text-sm font-medium text-foreground",children:b.name}),(0,z.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:b.description})]})]}),(0,z.jsx)("div",{className:"shrink-0",children:c?(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8 hover:bg-muted/80 ",onClick:()=>{e(b.id),g("configure")},children:"Configure"}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8",disabled:!0,children:"Coming soon"})})})]},b.id)})}),(0,z.jsx)(aG.Dialog,{open:!!d,onOpenChange:a=>!a&&e(null),children:(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-md",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsx)(aG.DialogTitle,{children:"connect"===f?`Connect ${w?.name}`:`Configure ${w?.name}`}),(0,z.jsx)(aG.DialogDescription,{children:"connect"===f?`Enter the required details to connect your ${w?.name} integration.`:`Manage your ${w?.name} integration settings.`})]}),"connect"===f&&w&&(0,z.jsxs)("div",{className:"space-y-4 py-4",children:[w.fields.map(a=>(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:a.id,children:a.label}),(0,z.jsx)(V.Input,{id:a.id,type:a.type,placeholder:a.placeholder})]},a.id)),"widget"===w.id&&(0,z.jsxs)("div",{className:"mt-4 p-4 bg-muted rounded-md border border-border",children:[(0,z.jsx)(W.Label,{className:"mb-2 block",children:"Widget Code"}),(0,z.jsx)("code",{className:"text-xs text-muted-foreground break-all",children:'<script src="https://larkup.com/widget.js" data-token="YOUR_TOKEN"></script>'})]})]}),"configure"===f&&w&&(0,z.jsx)("div",{className:"space-y-4 py-4",children:(0,z.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,z.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-background border border-border",children:w.iconPath?(0,z.jsx)("img",{src:w.iconPath,alt:w.name,className:"size-6 object-contain"}):w.IconComponent?(0,z.jsx)(w.IconComponent,{className:"size-5 text-foreground"}):null}),(0,z.jsxs)("div",{children:[(0,z.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Status: Connected"}),(0,z.jsxs)("div",{className:"text-xs text-green-600 flex items-center gap-1 mt-0.5",children:[(0,z.jsxs)("span",{className:"relative flex size-2",children:[(0,z.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]}),"Active and receiving messages"]})]})]})}),(0,z.jsx)(aG.DialogFooter,{className:"gap-2 sm:gap-0",children:"configure"===f?(0,z.jsxs)("div",{className:"flex w-full justify-between items-center",children:[(0,z.jsx)(U.Button,{variant:"destructive",onClick:()=>{d&&(c({...a,[d]:!1}),e(null))},children:"Disconnect"}),(0,z.jsx)(U.Button,{variant:"outline",onClick:()=>e(null),children:"Close"})]}):(0,z.jsx)("div",{className:"flex w-full justify-end",children:(0,z.jsx)(U.Button,{onClick:()=>{d&&(c({...a,[d]:!0}),e(null))},children:"Save Connection"})})})]})}),(0,z.jsx)(aG.Dialog,{open:h,onOpenChange:i,children:(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-3xl",children:[(0,z.jsx)(aG.DialogHeader,{children:(0,z.jsx)(aG.DialogTitle,{children:"Ask for Connection"})}),t?(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center space-y-4",children:[(0,z.jsx)("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:(0,z.jsx)(D.Sparkles,{className:"h-6 w-6"})}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Thank you! We've received your request and will get back to you soon."})]}):(0,z.jsxs)("form",{onSubmit:v,className:"space-y-4 mt-4",children:[(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"name",children:"Name"}),(0,z.jsx)(V.Input,{id:"name",type:"text",placeholder:"John Doe",value:j,onChange:a=>k(a.target.value)})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"company",children:"Company"}),(0,z.jsx)(V.Input,{id:"company",type:"text",placeholder:"Acme Inc.",value:l,onChange:a=>m(a.target.value)})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)(W.Label,{htmlFor:"email",children:["Your Email ",(0,z.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,z.jsx)(V.Input,{id:"email",type:"email",required:!0,placeholder:"name@company.com",value:n,onChange:a=>o(a.target.value)})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"message",children:"Which connection do you need?"}),(0,z.jsx)(t3.Textarea,{id:"message",placeholder:"Tell us which platform you want to connect to your AI server...",className:"resize-none min-h-30 max-h-67.5!",rows:5,value:p,onChange:a=>q(a.target.value)})]}),(0,z.jsxs)(aG.DialogFooter,{className:"bg-muted/50 border-border/70 mt-6",children:[(0,z.jsx)(U.Button,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),(0,z.jsxs)(U.Button,{type:"submit",disabled:r,children:[r&&(0,z.jsx)(Q.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Request"]})]})]})]})})]})}function uB(){let[a,b]=(0,A.useState)(null),[c,d]=(0,A.useState)(null),[e,f]=(0,A.useState)(!0),[g,h]=(0,A.useState)(!1),[i,j]=(0,A.useState)(""),[k,l]=(0,A.useState)(!1);async function m(){try{let a=await fetch("/api/deployment/config"),c=await a.json();c.error||b(c)}finally{f(!1)}}async function n(){let a=await fetch("/api/server/agent");a.ok&&d(await a.json())}async function o(){let a=await fetch("/api/deployment/blob-setup");if(a.ok){let{connected:b}=await a.json();l(b)}}async function p(c){if(!a)return;let d={...a,...c};b(d),await fetch("/api/deployment/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),Y.toast.success("Deployment settings saved")}async function q(){(await fetch("/api/deployment/blob-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})})).ok?(Y.toast.success("Vercel Blob connected"),l(!0),j("")):Y.toast.error("Failed to connect Vercel Blob")}async function r(){if(c?.running){h(!0);let a=await fetch("/api/server/agent",{method:"DELETE"});a.ok&&d(await a.json()),h(!1)}else{h(!0);let a=await fetch("/api/server/agent",{method:"POST"});a.ok&&d(await a.json()),h(!1)}}return((0,A.useEffect)(()=>{m(),n(),o()},[]),e||!a)?(0,z.jsx)("div",{className:"p-8 text-center text-muted-foreground",children:"Loading deployment config..."}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsx)("div",{className:"flex items-center justify-between",children:(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Deploy & Share Agent"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure how your agent is deployed, shared, and embedded in external websites."})]})}),(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Agent Type"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Choose the type of deployment"})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Deployment Type"}),(0,z.jsxs)(X.Select,{value:a.type||"",onValueChange:a=>p({type:a}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"rag-only",children:"RAG Only (API Backend)"}),(0,z.jsx)(X.SelectItem,{value:"full-agent",children:"Full Agent (Chat UI & Widget)"})]})]})]}),"full-agent"===a.type&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"system-prompt",children:"System Prompt"}),(0,z.jsx)(t3.Textarea,{id:"system-prompt",placeholder:"You are a helpful AI...",value:a.systemPrompt||"",onChange:a=>p({systemPrompt:a.target.value}),rows:3,className:"resize-none"})]})]})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Authentication"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Control who can access your agent"})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Auth Mode"}),(0,z.jsxs)(X.Select,{value:a.authMode||"",onValueChange:a=>p({authMode:a}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"none",children:"Public (No Auth)"}),(0,z.jsx)(X.SelectItem,{value:"api-key",children:"API Key (Server to Server)"}),(0,z.jsx)(X.SelectItem,{value:"join-code",children:"Join Code (For Users)"})]})]})]}),"join-code"===a.authMode&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"join-code",children:"Join Code"}),(0,z.jsx)(V.Input,{id:"join-code",placeholder:"e.g. secret-beta-code",value:a.joinCode||"",onChange:a=>p({joinCode:a.target.value})})]})]})]}),"full-agent"===a.type&&(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Widget Customization"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Customize the appearance of the embeddable chat widget"})]}),(0,z.jsxs)(Z.CardContent,{className:"grid gap-6 md:grid-cols-2",children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"primary-color",children:"Primary Color"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(V.Input,{type:"color",value:a.widgetStyle.primaryColor,onChange:b=>p({widgetStyle:{...a.widgetStyle,primaryColor:b.target.value}}),className:"w-12 h-10 p-1 cursor-pointer"}),(0,z.jsx)(V.Input,{id:"primary-color",value:a.widgetStyle.primaryColor,onChange:b=>p({widgetStyle:{...a.widgetStyle,primaryColor:b.target.value}}),className:"font-mono flex-1"})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Position"}),(0,z.jsxs)(X.Select,{value:a.widgetStyle.position||"",onValueChange:b=>p({widgetStyle:{...a.widgetStyle,position:b}}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"bottom-right",children:"Bottom Right"}),(0,z.jsx)(X.SelectItem,{value:"bottom-left",children:"Bottom Left"})]})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Widget Title"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.title,onChange:b=>p({widgetStyle:{...a.widgetStyle,title:b.target.value}})})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Welcome Message"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.welcomeMessage,onChange:b=>p({widgetStyle:{...a.widgetStyle,welcomeMessage:b.target.value}})})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Input Placeholder"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.placeholder,onChange:b=>p({widgetStyle:{...a.widgetStyle,placeholder:b.target.value}})})]}),(0,z.jsxs)("div",{className:"flex items-center justify-between pt-4",children:[(0,z.jsxs)(W.Label,{className:"flex flex-col gap-1",children:[(0,z.jsx)("span",{children:"Dark Mode"}),(0,z.jsx)("span",{className:"font-normal text-sm text-muted-foreground",children:"Force dark mode for the widget"})]}),(0,z.jsx)(ab.Switch,{checked:a.widgetStyle.darkMode,onCheckedChange:b=>p({widgetStyle:{...a.widgetStyle,darkMode:b}})})]})]})]})]})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Cloud Storage Setup"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Use Vercel Blob for original files and media. Configure a cloud vector store separately for retrieval."})]}),(0,z.jsx)(Z.CardContent,{children:k?(0,z.jsxs)("div",{className:"flex items-center gap-2 text-emerald-600 dark:text-emerald-400 font-medium bg-emerald-50 dark:bg-emerald-950/30 p-3 rounded-md",children:[(0,z.jsx)(aJ.Check,{className:"w-5 h-5"})," Vercel Blob is connected for media and file storage."]}):(0,z.jsxs)("div",{className:"space-y-3 max-w-lg",children:[(0,z.jsx)("a",{href:"https://vercel.com/integrations/vercel-blob",target:"_blank",rel:"noreferrer",className:"inline-flex text-sm font-medium underline underline-offset-4",children:"Install Vercel Blob in your Vercel account"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"After installation, paste the Blob read/write token to connect this workspace."}),(0,z.jsxs)("div",{className:"flex items-end gap-3",children:[(0,z.jsxs)("div",{className:"space-y-2 flex-1",children:[(0,z.jsx)(W.Label,{children:"Vercel Blob Read/Write Token"}),(0,z.jsx)(V.Input,{type:"password",placeholder:"vercel_blob_rw_...",value:i,onChange:a=>j(a.target.value)})]}),(0,z.jsx)(U.Button,{onClick:q,disabled:!i,children:"Connect"})]})]})})]}),(0,z.jsxs)("div",{className:"mt-8 pt-8 border-t border-border/50 flex flex-col md:flex-row items-start md:items-center justify-between gap-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h3",{className:"text-lg font-medium mb-1",children:"Local Test Server"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Start the agent server locally to test your chat UI and widget configuration."}),(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)(U.Button,{onClick:r,disabled:g,variant:c?.running?"destructive":"default",className:"w-32",children:g?"Working...":c?.running?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aq.Square,{className:"w-4 h-4 mr-2"})," Stop Agent"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ap.Play,{className:"w-4 h-4 mr-2"})," Start Agent"]})}),c?.running&&(0,z.jsxs)("span",{className:"text-sm font-medium text-emerald-600 flex items-center gap-2",children:[(0,z.jsxs)("span",{className:"relative flex h-3 w-3",children:[(0,z.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-emerald-500"})]}),"Agent Running on port 8081"]})]})]}),c?.running&&"full-agent"===a.type&&(0,z.jsxs)("div",{className:"flex flex-col gap-3 min-w-[280px]",children:[(0,z.jsxs)(U.Button,{variant:"outline",className:"justify-between",onClick:()=>{navigator.clipboard.writeText("http://localhost:8081/chat-ui"),Y.toast.success("Share link copied to clipboard")},children:[(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)(ar.ExternalLink,{className:"w-4 h-4"})," Share Link"]}),(0,z.jsx)(at.Copy,{className:"w-4 h-4 text-muted-foreground"})]}),(0,z.jsxs)(U.Button,{variant:"outline",className:"justify-between bg-primary/5 hover:bg-primary/10 border-primary/20",onClick:()=>{navigator.clipboard.writeText('<script src="http://localhost:8081/widget.js"></script>'),Y.toast.success("Widget code copied to clipboard")},children:[(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)(t_,{className:"w-4 h-4 text-primary"})," Copy Embed Code"]}),(0,z.jsx)(at.Copy,{className:"w-4 h-4 text-primary/70"})]})]})]})]})}var uC=a.i(898871);let uD=(0,G.default)("megaphone",[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]]),uE={Film:tX.Film,ScanEye:tY},uF={all:"All",media:"Media",search:"Search",analytics:"Analytics",integration:"Integration",embedding:"Embedding",ai:"AI",automation:"Automation",utility:"Utility"},uG=a=>fetch(a).then(a=>a.json());function uH(){let{data:a,isLoading:b,mutate:c}=(0,P.default)("/api/marketplace",uG),[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)("all"),j=(0,A.useCallback)(async a=>{e(a);try{let b=await fetch(`/api/marketplace/${a}`,{method:"POST"});if(!b.ok){let a=await b.json();throw Error(a.error||"Install failed")}Y.toast.success("Tool installed successfully"),c()}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to install tool")}finally{e(null)}},[c]),k=(0,A.useCallback)(async a=>{try{if(!(await fetch(`/api/marketplace/${a}`,{method:"DELETE"})).ok)throw Error("Uninstall failed");Y.toast.success("Tool removed"),c()}catch{Y.toast.error("Failed to remove tool")}},[c]),l=a?.tools??[],m=(0,A.useMemo)(()=>["all",...Array.from(new Set(l.map(a=>a.category))).sort()],[l]),n=(0,A.useMemo)(()=>{let a=l;if("all"!==h&&(a=a.filter(a=>a.category===h)),f.trim()){let b=f.toLowerCase();a=a.filter(a=>a.name.toLowerCase().includes(b)||a.description.toLowerCase().includes(b)||a.tags?.some(a=>a.toLowerCase().includes(b))||a.author.toLowerCase().includes(b))}return a},[l,h,f]);return(0,z.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Marketplace"}),(0,z.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Extend Larkup with optional tools and capabilities."})]}),(0,z.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(F.Search,{className:"absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,z.jsx)(V.Input,{type:"text",placeholder:"Search tools…",value:f,onChange:a=>g(a.target.value),className:(0,M.cn)("w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2","text-[13px] text-foreground placeholder:text-muted-foreground/50","outline-none transition-colors","focus:border-foreground/20")})]}),m.length>2&&(0,z.jsx)("div",{className:"flex items-center gap-1.5 overflow-x-auto",children:m.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>i(a),className:(0,M.cn)("shrink-0 rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors",h===a?"bg-foreground text-background":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:uF[a]??a},a))})]}),b?(0,z.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):0===n.length?(0,z.jsx)("div",{className:"py-16 text-center text-sm text-muted-foreground",children:f||"all"!==h?"No tools match your search.":"No tools available yet."}):(0,z.jsx)("div",{className:"flex flex-col gap-2",children:n.map(a=>(0,z.jsx)(uI,{tool:a,installing:d===a.id,onInstall:j,onUninstall:k},a.id))})]})}function uI({tool:a,installing:b,onInstall:c,onUninstall:d}){var e;let f=uE[a.icon]??tX.Film,g="installed"===a.status,h=a.comingSoon;return(0,z.jsxs)("div",{className:(0,M.cn)("group flex items-center gap-4 rounded-xl border border-border bg-card px-4 py-3.5","transition-colors hover:border-border/80"),children:[(0,z.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border",children:a.emoji?(0,z.jsx)("span",{className:"text-xl leading-none",children:a.emoji}):(0,z.jsx)(f,{className:"size-5 text-foreground",strokeWidth:1.75})}),(0,z.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("h3",{className:"text-[13px] font-medium text-foreground truncate",children:a.name}),(0,z.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:["v",a.version]}),(0,z.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/40",children:"·"}),(0,z.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:a.author})]}),(0,z.jsx)("p",{className:"mt-0.5 text-[12px] text-muted-foreground leading-relaxed line-clamp-1",children:a.description}),a.tags&&a.tags.length>0&&(0,z.jsxs)("div",{className:"mt-1.5 flex items-center gap-1 overflow-hidden",children:[a.tags.slice(0,4).map(a=>(0,z.jsx)("span",{className:"rounded-md bg-secondary px-1.5 py-0.5 text-[10px] text-muted-foreground",children:a},a)),a.tags.length>4&&(0,z.jsxs)("span",{className:"text-[10px] text-muted-foreground/50",children:["+",a.tags.length-4]})]})]}),(0,z.jsxs)("div",{className:"hidden sm:flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground/60",children:[(0,z.jsx)("span",{className:"tabular-nums",children:a.installSize}),a.downloads>0&&(0,z.jsxs)("span",{className:"tabular-nums",children:["↓ ",(e=a.downloads)>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)]})]}),(0,z.jsx)("div",{className:"shrink-0",children:(0,z.jsx)("span",{className:(0,M.cn)("rounded-md px-2 py-0.5 text-[10px] font-medium","free"===a.pricing?"bg-secondary text-muted-foreground":"pro"===a.pricing?"bg-blue-50 text-blue-600":"bg-purple-50 text-purple-600"),children:"free"===a.pricing?"Free":"pro"===a.pricing?"Pro":"Enterprise"})}),(0,z.jsxs)("div",{className:"shrink-0 flex items-center gap-1.5",children:[a.repositoryUrl&&(0,z.jsx)("a",{href:a.repositoryUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-muted-foreground transition-colors",children:(0,z.jsx)(ar.ExternalLink,{className:"size-3.5"})}),h?(0,z.jsxs)(U.Button,{size:"sm",className:"h-7 text-[11px]",variant:"default",disabled:!0,children:[(0,z.jsx)(uD,{className:"size-3"}),"Soon"]}):g?(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsxs)("span",{className:"flex items-center gap-1 text-[11px] font-medium text-emerald-600",children:[(0,z.jsx)(aJ.Check,{className:"size-3"}),"Installed"]}),(0,z.jsx)(U.Button,{variant:"ghost",size:"sm",className:"size-7 p-0 text-muted-foreground/40 hover:text-destructive",onClick:()=>d(a.id),children:(0,z.jsx)(aw.Trash2,{className:"size-3"})})]}):(0,z.jsxs)(U.Button,{variant:"default",size:"sm",className:"h-7 gap-1.5 text-[11px] px-3",disabled:b,onClick:()=>c(a.id),children:[b?(0,z.jsx)(Q.Loader2,{className:"size-3 animate-spin"}):(0,z.jsx)(uC.Download,{className:"size-3"}),b?"Installing…":"Install"]})]})]})}var uJ=a.i(318467),uJ=uJ;let uK=a=>fetch(a).then(a=>a.json());function uL(){let{data:a,isLoading:b,error:c}=(0,P.default)("/api/marketplace",uK),{data:d,mutate:e,isLoading:f,error:g}=(0,P.default)("/api/config",uK),[h,i]=(0,A.useState)({toolConfigs:{}}),[j,k]=(0,A.useState)(null),[l,m]=(0,A.useState)(null),[n,o]=(0,A.useState)({}),[p,q]=(0,A.useState)({});if((0,A.useEffect)(()=>{d?.config?.toolConfigs&&i({toolConfigs:d.config.toolConfigs})},[d]),c||g)return(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[(0,z.jsx)(uJ.default,{className:"h-6 w-6 text-destructive mb-4"}),(0,z.jsx)("h3",{className:"text-lg font-medium text-destructive",children:"Failed to load configuration"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Please try refreshing the page."})]});if(b||f||!a||!d)return(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 text-muted-foreground animate-spin"})});let r=a?.tools?.filter(a=>"installed"===a.status&&a.configSchema?.length>0)||[];if(0===r.length)return(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[(0,z.jsx)("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:(0,z.jsx)(K.Store,{className:"h-6 w-6 text-primary"})}),(0,z.jsx)("h3",{className:"mb-2 text-lg font-semibold",children:"No Tools Installed"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:"You haven't installed any Marketplace tools that require configuration yet."})]});async function s(a){k(a);try{let a={...d?.config||{},toolConfigs:h.toolConfigs};if(!(await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok)throw Error("Failed to save configuration");await e(),Y.toast.success("Tool configuration saved successfully")}catch(a){Y.toast.error(a.message||"An error occurred while saving")}finally{k(null)}}async function t(a){m(a),o(b=>({...b,[a]:{status:null}}));try{if("video-audio"===a){let a=h.toolConfigs["video-audio"]?.audioProvider,b=h.toolConfigs["video-audio"]?.audioApiKey||"";if(!a)throw Error("Choose an Audio Provider before verifying this tool.");let c=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({audioProvider:a,audioApiKey:b})});if(!c.ok){let a=await c.json();throw Error(a.error||"Verification failed")}}else await new Promise(a=>setTimeout(a,1e3));o(b=>({...b,[a]:{status:"success"}})),Y.toast.success("Configuration verified successfully")}catch(b){o(c=>({...c,[a]:{status:"error",message:b.message}})),Y.toast.error(b.message||"Verification failed")}finally{m(null)}}let u=a=>{switch(a){case"openai":return"/icons/openai.svg";case"google":return"/icons/gemini.svg";case"deepgram":return"/icons/deepgram.png";case"elevenlabs":return"/icons/elevenlabs.png";case"groq":return"/icons/grok.png";default:return"/icons/audio.png"}};return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-xl font-medium tracking-tight",children:"Marketplace Tools"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure API keys and settings for your installed tools."})]}),(0,z.jsx)("div",{className:"grid gap-6",children:r.map(a=>{let b=JSON.stringify(h.toolConfigs?.[a.id]||{})!==JSON.stringify(d?.config?.toolConfigs?.[a.id]||{}),c=n[a.id];return(0,z.jsxs)(Z.Card,{className:"overflow-hidden transition-all border border-border bg-white",children:[(0,z.jsxs)(Z.CardHeader,{className:" pb-4 gap-0 ",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-3 text-base",children:[(0,z.jsx)("div",{className:"flex h-8 w-8 mt-1 items-center justify-center rounded-md bg-background border border-border/50",children:(0,z.jsx)("img",{src:`/icons/${"video-audio"===a.id?"video":"webhook"}.png`,alt:a.name,className:"h-5 w-5 object-contain",onError:a=>{a.currentTarget.src="/icons/audio.png"}})}),a.name]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs pt-0 ml-11",children:a.description})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-5 ",children:[c?.status==="error"&&(0,z.jsxs)("div",{className:"rounded-md bg-destructive/10 p-3 flex gap-2 items-start border border-destructive/20 text-destructive text-sm",children:[(0,z.jsx)(uJ.default,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,z.jsx)("span",{children:c.message})]}),c?.status==="success"&&(0,z.jsxs)("div",{className:"rounded-md bg-emerald-500/10 p-3 flex gap-2 items-start border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 text-sm",children:[(0,z.jsx)(au.CheckCircle2,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,z.jsx)("span",{children:"Connection verified successfully."})]}),a.configSchema.map(b=>{let d=h.toolConfigs?.[a.id]?.[b.key];void 0===d&&"audioProvider"===b.key&&"video-audio"===a.id?d="":void 0===d&&(d=b.defaultValue??"");let e=p[`${a.id}_${b.key}`],f=b.label;if("audioApiKey"===b.key&&"video-audio"===a.id){let c=h.toolConfigs?.[a.id]?.audioProvider||"";if("local"===c)return null;let d=a.configSchema.find(a=>"audioProvider"===a.key)?.options?.find(a=>a.value===c);f=d?`${d.label} API Key`:b.label}return(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)(W.Label,{className:"text-[13px] font-medium",children:f}),"audioApiKey"===b.key&&c?.status==="success"&&(0,z.jsx)("span",{className:"text-[10px] text-emerald-500 font-medium",children:"✓ Verified"}),"audioApiKey"===b.key&&c?.status==="error"&&(0,z.jsx)("span",{className:"text-[10px] text-destructive font-medium truncate max-w-[150px]",children:c.message})]}),"select"===b.type?(0,z.jsxs)(X.Select,{value:d||"",onValueChange:c=>{"local"===c?(0,Y.toast)("Coming Soon",{description:"Local Whisper support is currently in development."}):(i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c}}}),o(b=>({...b,[a.id]:{status:null}})))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full h-9",children:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:["audioProvider"===b.key&&(0,z.jsx)("img",{src:u(d),className:"w-4 h-4 object-contain opacity-80",alt:""}),(0,z.jsx)("span",{children:b.options?.find(a=>a.value===d)?.label||d||"Choose a provider"})]})}),(0,z.jsx)(X.SelectContent,{children:b.options?.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:["audioProvider"===b.key&&(0,z.jsx)("img",{src:u(a.value),className:"w-4 h-4 object-contain",alt:""}),(0,z.jsxs)("span",{className:"local"===a.value?"text-muted-foreground":"",children:[a.label,"local"===a.value&&" (Coming soon)"]})]})},a.value))})]}):"password"===b.type?(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:e?"text":"password",value:d,onChange:c=>{i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c.target.value}}}),o(b=>({...b,[a.id]:{status:null}}))},placeholder:b.placeholder||"sk-...",className:"pr-10 h-9 font-mono text-sm"}),(0,z.jsx)("button",{type:"button",onClick:()=>q({...p,[`${a.id}_${b.key}`]:!e}),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted-foreground hover:text-foreground",children:e?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})})]}),"audioApiKey"===b.key&&"video-audio"===a.id&&(0,z.jsx)(U.Button,{className:"rounded-md h-9",variant:"outline",size:"default",onClick:()=>t(a.id),disabled:l===a.id||!d,children:l===a.id?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):"Verify"})]}):(0,z.jsx)(V.Input,{type:"text",value:d,onChange:c=>{i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c.target.value}}}),o(b=>({...b,[a.id]:{status:null}}))},placeholder:b.placeholder,className:"h-9"}),b.help&&(0,z.jsx)("p",{className:"text-[11px] text-muted-foreground",children:b.help})]},b.key)})]}),(0,z.jsx)(Z.CardFooter,{className:"flex justify-end gap-2 pt-4 pb-4 border-t bg-muted/10",children:(0,z.jsxs)(U.Button,{size:"sm",disabled:j===a.id||!b,onClick:()=>s(a.id),className:"gap-1.5 min-w-[80px]",children:[j===a.id?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})})]},a.id)})})]})}function uM(){let a=(0,B.useSearchParams)(),b=(0,B.useRouter)(),c=(0,B.usePathname)(),[d,e]=(0,A.useState)((()=>{if(a.has("ai-models"))return"models";let b=a.get("section");return b||"general"})());return(0,A.useEffect)(()=>{let f=a.get("section");if(a.has("ai-models")){let f=new URLSearchParams(a.toString());f.delete("ai-models"),f.set("section","models"),b.replace(`${c}?${f.toString()}`),"models"!==d&&e("models")}else f&&f!==d&&e(f)},[a,d,c,b]),(0,z.jsxs)(O,{activeSection:d,onSectionChange:d=>{e(d);let f=new URLSearchParams(a.toString());f.delete("ai-models"),f.set("section",d),b.replace(`${c}?${f.toString()}`)},children:["general"===d&&(0,z.jsx)(ae,{}),"models"===d&&(0,z.jsx)(an,{}),"storage"===d&&(0,z.jsx)(ux,{}),"server"===d&&(0,z.jsx)(tR,{}),"connections"===d&&(0,z.jsx)(uA,{}),"deployment"===d&&(0,z.jsx)(uB,{}),"marketplace"===d&&(0,z.jsx)(uH,{}),"tool-settings"===d&&(0,z.jsx)(uL,{}),"prompts"===d&&(0,z.jsx)(t5,{}),"playground"===d&&(0,z.jsx)(uj,{}),"appearance"===d&&(0,z.jsx)(ur,{})]})}a.s(["default",0,function(){return(0,z.jsx)(A.Suspense,{children:(0,z.jsx)(uM,{})})}],98350)}];
120
+ - End with a one-sentence synthesis if appropriate, avoiding filler words.`,tV=(0,G.default)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]),tW=(0,G.default)("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);var tX=a.i(918788);let tY=(0,G.default)("scan-eye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),tZ=(0,G.default)("table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]),t$=(0,G.default)("chart-no-axes-column-increasing",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]]),t_=(0,G.default)("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),t0=(0,G.default)("files",[["path",{d:"M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8",key:"14sh0y"}],["path",{d:"M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z",key:"1970lx"}],["path",{d:"M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1",key:"l4dndm"}]]);var t1=a.i(609509),t2=a.i(66651),t3=a.i(964598);let t4=a=>fetch(a).then(a=>a.json());function t5(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id,c=b?`/api/config?serverId=${encodeURIComponent(b)}`:"/api/config",{data:d,isLoading:e,mutate:f}=(0,P.default)(c,t4),[g,h]=(0,A.useState)({}),[i,j]=(0,A.useState)(!1);(0,A.useEffect)(()=>{d?.config&&h({...d.config,systemPrompt:d.config.systemPrompt||tU})},[d]);let k=(g.systemPrompt||"")!==(d?.config?.systemPrompt||"")||JSON.stringify(g.enabledTools||[])!==JSON.stringify(d?.config?.enabledTools||[]);async function l(){j(!0);try{let a={...d?.config,...g},b=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await b.json();if(!b.ok)throw Error(e.error??"Failed to save");await f(e,{revalidate:!1}),Y.toast.success("Prompt saved")}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to save")}finally{j(!1)}}return e?(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Agent Customization"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Customize the instructions and tools given to your AI assistant."})]}),(0,z.jsxs)(U.Button,{size:"sm",disabled:i||!k,onClick:l,className:"gap-1.5",children:[i?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})]}),(0,z.jsxs)(Z.Card,{className:"bg-white/60",children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"System Prompt"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Override the default instructions given to the AI. Leave blank for the default behavior."})]}),(0,z.jsx)(Z.CardContent,{children:(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(t3.Textarea,{value:g.systemPrompt||"",onChange:a=>h({...g,systemPrompt:a.target.value}),placeholder:"You are a helpful research assistant...",className:"w-full rounded-lg border border-border/70 bg-card px-3 py-2 text-sm text-foreground outline-none transition focus:border-border resize-none max-h-50 pb-10 [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/40 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent"}),(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsx)(aG.DialogTrigger,{render:(0,z.jsx)("button",{type:"button",className:"absolute bottom-2 right-2 p-1.5 text-muted-foreground/60 hover:text-foreground transition-colors rounded-md cursor-pointer",children:(0,z.jsx)(tS,{className:"size-4",strokeWidth:1.75})})}),(0,z.jsxs)(aG.DialogContent,{className:"max-w-[90vw] sm:max-w-[90vw] w-[90vw] h-[90vh] flex flex-col ",children:[(0,z.jsxs)(aG.DialogHeader,{className:"shrink-0 space-y-0 p-3 pb-0",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aG.DialogTitle,{className:"text-lg font-semibold",children:"Edit text content."}),(0,z.jsx)(tT.FileText,{className:"size-4 text-muted-foreground"})]}),(0,z.jsx)(aG.DialogDescription,{children:"Edit text content."})]}),(0,z.jsx)("div",{className:"flex-1 min-h-0 mt-2 relative ",children:(0,z.jsx)(t3.Textarea,{value:g.systemPrompt||"",onChange:a=>h({...g,systemPrompt:a.target.value}),placeholder:"You are a helpful research assistant...",className:"h-full w-full rounded-lg border border-border/40 bg-background px-4 py-3 text-sm text-foreground outline-none transition focus:border-border resize-none [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/40 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-transparent"})}),(0,z.jsxs)(aG.DialogFooter,{className:"mt-6 justify-end flex items-center gap-2 shrink-0",children:[(0,z.jsx)(aG.DialogClose,{render:(0,z.jsx)(U.Button,{variant:"outline",className:"px-3"}),children:"Cancel"}),(0,z.jsx)(aG.DialogClose,{render:(0,z.jsx)(U.Button,{}),children:"Save"})]})]})]})]})})]}),(0,z.jsx)(t8,{form:g,setForm:h})]})}let t6=[{id:"searchKnowledgeBase",name:"Semantic Search",desc:"Search the RAG knowledge base for text.",icon:F.Search},{id:"queryTabularData",name:"Tabular Data Query",desc:"Filter, group, and aggregate tabular data.",icon:tZ},{id:"generateVisualization",name:"Generate Charts",desc:"Create interactive Recharts visualizations.",icon:t$},{id:"executeAnalysis",name:"Python Sandbox",desc:"Execute Python code for complex analysis.",icon:t_},{id:"getIndexedData",name:"Indexed Data",desc:"List and filter source documents.",icon:t0},{id:"analyzeCorpusWithCode",name:"Corpus Analysis",desc:"Python sandbox with full corpus access.",icon:t_},{id:"fillDocumentForm",name:"Form Filler",desc:"Fill forms in the active document.",icon:t1.FileEdit},{id:"editDocument",name:"Document Editor",desc:"Edit text in the active document.",icon:t2.PenTool}],t7={Film:tX.Film,ScanEye:tY};function t8({form:a,setForm:b}){let[c,d]=(0,A.useState)("tools"),{data:e}=(0,P.default)("/api/marketplace",a=>fetch(a).then(a=>a.json())),f=(e?.tools||[]).filter(a=>"installed"===a.status),g=[...t6,...f.map(a=>({id:a.id,name:a.name,desc:a.description,isMarketplace:!0,...a}))],h=new Set(a.enabledTools||[]),i="tools"===c?t6:f.map(a=>({id:a.id,name:a.name,desc:a.description,isMarketplace:!0,...a}));return(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-4",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Agent Tools"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Select which tools the AI assistant is allowed to use."}),(0,z.jsx)("div",{className:"mt-4 flex flex-wrap items-center gap-4",children:(0,z.jsxs)("div",{className:"flex items-center gap-1 border border-border/90 rounded-lg bg-muted/60 p-1",children:[(0,z.jsxs)("button",{type:"button",onClick:()=>d("tools"),className:(0,M.cn)("relative flex items-center gap-1.5 px-3 py-1.5 text-[13px] font-medium transition-all duration-200 rounded-md","tools"===c?"bg-background text-foreground ring-1 ring-border":"text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:[(0,z.jsx)(tV,{className:"size-3.5",strokeWidth:"tools"===c?2:1.75}),"Tools",(0,z.jsx)("span",{className:"ml-1 flex h-4 items-center justify-center rounded-full bg-secondary px-1.5 text-[10px] font-medium text-muted-foreground",children:t6.length})]}),(0,z.jsxs)("button",{type:"button",onClick:()=>d("plugins"),className:(0,M.cn)("relative flex items-center gap-1.5 px-3 py-1.5 text-[13px] font-medium transition-all duration-200 rounded-md","plugins"===c?"bg-background text-foreground ring-1 ring-border":"text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:[(0,z.jsx)(tW,{className:"size-3.5",strokeWidth:"plugins"===c?2:1.75}),"Plugins",(0,z.jsx)("span",{className:"ml-1 flex h-4 items-center justify-center rounded-full bg-secondary px-1.5 text-[10px] font-medium text-muted-foreground",children:f.length})]})]})})]}),(0,z.jsx)(Z.CardContent,{children:0===i.length?(0,z.jsx)("div",{className:"py-8 text-center text-sm text-muted-foreground",children:"No plugins installed. Go to the Marketplace to install plugins."}):(0,z.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:i.map(c=>{var d;let e,f=(d=c.id,!a.enabledTools||0===a.enabledTools.length||h.has(d));return(0,z.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-xl border border-border/70 bg-background px-4 py-3.5 transition-colors hover:border-border",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[(e=c.isMarketplace?c.icon&&t7[c.icon]||tW:c.icon||tV,(0,z.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border",children:c.emoji?(0,z.jsx)("span",{className:"text-xl leading-none",children:c.emoji}):(0,z.jsx)(e,{className:"size-5 text-foreground",strokeWidth:1.75})})),(0,z.jsxs)("div",{className:"flex flex-col min-w-0",children:[(0,z.jsxs)("span",{className:"text-[13px] font-medium text-foreground truncate",children:[c.name,c.isMarketplace&&(0,z.jsx)("span",{className:"ml-2 rounded-md bg-secondary px-1.5 py-0.5 text-[10px] text-muted-foreground",children:"Plugin"})]}),(0,z.jsx)("p",{className:"mt-0.5 text-[12px] text-muted-foreground leading-relaxed line-clamp-1",children:c.desc})]})]}),(0,z.jsx)(ab.Switch,{checked:f,onCheckedChange:()=>{var d;let e;return d=c.id,e=new Set(h),void(a.enabledTools&&0!==a.enabledTools.length?e.has(d)?e.delete(d):e.add(d):g.forEach(a=>{a.id!==d&&e.add(a.id)}),b({...a,enabledTools:Array.from(e)}))},"aria-label":`Toggle ${c.name}`})]},c.id)})})})]})}var t9=a.i(113413);let ua=(0,G.default)("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]);var ub=a.i(95507);let uc=a=>fetch(a).then(a=>a.json()),ud=[1,3,5,8,10],ue=["What is this corpus about?","Summarize the key concepts.","How does retrieval work?"];function uf(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id??null,c=b?`/api/demo?serverId=${encodeURIComponent(b)}`:"/api/demo",{data:d,isLoading:e}=(0,P.default)(c,uc,{refreshInterval:5e3}),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)(5),[j,k]=(0,A.useState)(!1),[l,m]=(0,A.useState)(null),[n,o]=(0,A.useState)(null);if((0,A.useEffect)(()=>{o(null),m(null)},[b]),e||!d)return(0,z.jsx)("div",{className:"px-6 py-6 md:px-8",children:(0,z.jsx)(ub.Skeleton,{className:"h-40 w-full"})});let{ready:p,blockers:q,server:r,config:s}=d;async function t(a){let c=a.trim();if(c){k(!0),m(null);try{let a=await fetch("/api/demo",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:c,topK:h,serverId:b})}),d=await a.json();if(!a.ok){m(d.error??"Query failed."),o(null);return}o(d)}catch{m("Could not reach the retrieval endpoint."),o(null)}finally{k(!1)}}}return(0,z.jsxs)("div",{className:"space-y-6 w-full",children:[!p&&(0,z.jsxs)(aF.Alert,{variant:"default",className:"text-orange-500",children:[(0,z.jsx)(t9.AlertTriangle,{className:"size-4"}),(0,z.jsx)(aF.AlertTitle,{children:"Nothing to query yet"}),(0,z.jsx)(aF.AlertDescription,{children:(0,z.jsx)("ul",{className:"list-disc pl-4",children:q.map(a=>(0,z.jsx)("li",{children:a},a))})})]}),(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"space-y-4 pt-6",children:[(0,z.jsx)("div",{className:"relative",children:(0,z.jsx)(t3.Textarea,{value:f,onChange:a=>g(a.target.value),onKeyDown:a=>{"Enter"===a.key&&(a.metaKey||a.ctrlKey)&&(a.preventDefault(),t(f))},placeholder:"Ask a question to retrieve the most relevant chunks…",disabled:!p||j,rows:3,className:"resize-none pr-3 text-sm leading-relaxed"})}),(0,z.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Top-k"}),(0,z.jsx)("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-muted/40 p-0.5",children:ud.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>i(a),className:(0,M.cn)("min-w-8 rounded-md px-2.5 py-1 text-xs font-medium tabular-nums transition-colors",h===a?"bg-white border text-foreground ":"text-muted-foreground hover:text-foreground"),children:a},a))})]}),(0,z.jsxs)(U.Button,{onClick:()=>t(f),disabled:!p||j||!f.trim(),children:[j?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(F.Search,{className:"size-4"}),j?"Searching…":"Search",!j&&(0,z.jsx)("kbd",{className:"ml-1 hidden items-center gap-0.5 rounded border border-primary-foreground/30 px-1 text-[10px] opacity-80 sm:inline-flex",children:(0,z.jsx)(ua,{className:"size-2.5"})})]})]}),p&&!n&&!j&&(0,z.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-t border-border pt-3",children:[(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:"Try:"}),ue.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>{g(a),t(a)},className:"rounded-full border border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:a},a))]})]})}),l&&(0,z.jsxs)(aF.Alert,{variant:"destructive",children:[(0,z.jsx)(t9.AlertTriangle,{className:"size-4"}),(0,z.jsx)(aF.AlertTitle,{children:"Query failed"}),(0,z.jsx)(aF.AlertDescription,{children:l})]}),j&&(0,z.jsx)(ui,{count:h}),!j&&n&&(0,z.jsx)(ug,{result:n})]})}function ug({result:a}){return 0===a.hits.length?(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"flex flex-col items-center justify-center gap-1 py-12 text-center",children:[(0,z.jsx)(F.Search,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,z.jsx)("p",{className:"text-sm font-medium",children:"No matches found"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Nothing in the index scored against that query. Try rephrasing or indexing more content."})]})}):(0,z.jsxs)("div",{className:"space-y-3",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("h2",{className:"text-sm font-medium",children:[a.hits.length," result",1===a.hits.length?"":"s"]}),(0,z.jsxs)("span",{className:"font-mono text-xs text-muted-foreground tabular-nums",children:["server"===a.source?"via server":"via direct"," ·"," ",a.tookMs.toLocaleString(),"ms"]})]}),a.hits.map((a,b)=>(0,z.jsx)(uh,{hit:a,rank:b+1},a.id||b))]})}function uh({hit:a,rank:b}){let c=Math.round(100*Math.min(Math.max(a.score,0),1));return(0,z.jsx)(Z.Card,{className:"overflow-hidden",children:(0,z.jsxs)(Z.CardContent,{className:"flex gap-4 py-4",children:[(0,z.jsx)("div",{className:"flex flex-col items-center gap-1 pt-0.5",children:(0,z.jsx)("span",{className:"flex size-7 items-center justify-center rounded-md bg-muted text-xs font-semibold tabular-nums text-muted-foreground",children:b})}),(0,z.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,z.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,z.jsx)(tT.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,z.jsx)("h3",{className:"truncate text-sm font-medium",children:a.title||"Untitled"})]}),(0,z.jsxs)(tl.Badge,{variant:"secondary",className:"shrink-0 font-mono text-[11px] tabular-nums",children:[c,"%"]})]}),(0,z.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:a.text.length>360?`${a.text.slice(0,360).trim()}…`:a.text}),a.url&&(0,z.jsxs)("a",{href:a.url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline",children:[(0,z.jsx)(ar.ExternalLink,{className:"size-3"}),(0,z.jsx)("span",{className:"truncate",children:a.url})]})]})]})})}function ui({count:a}){return(0,z.jsx)("div",{className:"space-y-3",children:Array.from({length:Math.min(a,4)}).map((a,b)=>(0,z.jsx)(Z.Card,{children:(0,z.jsxs)(Z.CardContent,{className:"flex gap-4 py-4",children:[(0,z.jsx)(ub.Skeleton,{className:"size-7 rounded-md"}),(0,z.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,z.jsx)(ub.Skeleton,{className:"h-4 w-1/3"}),(0,z.jsx)(ub.Skeleton,{className:"h-3 w-full"}),(0,z.jsx)(ub.Skeleton,{className:"h-3 w-4/5"})]})]})},b))})}function uj(){return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Playground"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Test your search and retrieval to see what your AI returns."})]}),(0,z.jsx)(uf,{})]})}var uk=a.i(295805);let ul=[{id:"default",name:"Caffee",color:"#f2efe4"},{id:"theme-gaia",name:"Emerald Green",color:"#2b935f"},{id:"theme-docker",name:"Ocean Blue",color:"#1d63ed"},{id:"theme-pinecone",name:"Deep Indigo",color:"#6e56cf"},{id:"theme-vercel",name:"Minimal Black",color:"#000000"},{id:"theme-elevenlabs",name:"Soft Cream",color:"#f8f7f5"},{id:"theme-espresso",name:"Espresso",color:"#6B3F2A"},{id:"theme-sienna",name:"Warm Sienna",color:"#A0522D"},{id:"theme-caramel",name:"Caramel",color:"#C47C3E"}],um=[{id:"bg-default",name:"White",color:"#FFFFFF"},{id:"bg-pure",name:"Pure White",color:"#FFFFFF"},{id:"bg-fafafa",name:"Near White",color:"#F4F4F4"},{id:"bg-silver",name:"Silver",color:"#F8F8F8"},{id:"bg-soft",name:"Soft",color:"#FBFAF8"},{id:"bg-stone",name:"Stone",color:"#F5F5F2"},{id:"bg-sage",name:"Sage",color:"#EDEDE8"},{id:"bg-warm",name:"Warm Cream",color:"#F7F1EA"}],un=[{id:"panel-default",name:"Theme Default",color:"#FAFAFA"},{id:"panel-white",name:"White",color:"#FFFFFF"},{id:"panel-fafafa",name:"Near White",color:"#F4F4F4"},{id:"panel-silver",name:"Silver",color:"#F8F8F8"},{id:"panel-soft",name:"Soft",color:"#FBFAF8"},{id:"panel-stone",name:"Stone",color:"#F5F5F2"},{id:"panel-warm",name:"Warm Cream",color:"#F7F1EA"}],uo=[{id:"radius-0",name:"Sharp",value:"0"},{id:"radius-sm",name:"Small",value:"0.3rem"},{id:"radius-default",name:"Default",value:"0.625rem"},{id:"radius-lg",name:"Large",value:"1rem"}],up=[{id:"card",name:"Card Wrapper"},{id:"fused",name:"Fused (Edge to edge)"}],uq=[{id:"sidebar",name:"Sidebar Navigation"},{id:"topnav",name:"Top Navigation"}];function ur(){let{theme:a,setTheme:b,background:c,setBackground:d,panelBg:e,setPanelBg:f,navBg:g,setNavBg:h,radius:i,setRadius:j,pageStyle:k,setPageStyle:l,layout:m,setLayout:n,isMounted:o}=(0,uk.useThemeCustomizer)();return o?(0,z.jsxs)("div",{className:"space-y-10 max-w-2xl",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-xl font-semibold tracking-tight",children:"Appearance"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Customize the look and feel of your workspace."})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Theme & Colors"}),(0,z.jsx)("div",{className:"space-y-6",children:(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Primary Accent Color"}),(0,z.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 gap-2",children:ul.map(c=>(0,z.jsxs)("button",{onClick:()=>b(c.id),className:(0,M.cn)("relative flex flex-col items-center justify-center gap-2 rounded-lg border p-2 text-xs transition-all hover:bg-muted/50",a===c.id?"border-border bg-white":"border-muted/20"),children:[(0,z.jsx)("div",{className:"h-6 w-6 rounded-full ring-1 ring-border/20",style:{background:c.color}}),a===c.id&&(0,z.jsx)(aJ.Check,{className:"absolute top-1 right-1 size-3 text-primary"}),(0,z.jsx)("span",{className:"truncate w-full text-center text-[10px] text-muted-foreground",children:c.name})]},c.id))})]})})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Layout Preferences"}),(0,z.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Navigation Style"}),(0,z.jsx)("div",{className:"flex flex-col gap-2",children:uq.map(a=>(0,z.jsx)("button",{onClick:()=>n(a.id),className:(0,M.cn)("rounded-lg border p-2.5 text-xs font-medium transition-all text-left",m===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),children:a.name},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"App Wrapper"}),(0,z.jsx)("div",{className:"flex flex-col gap-2",children:up.map(a=>(0,z.jsx)("button",{onClick:()=>l(a.id),className:(0,M.cn)("rounded-lg border p-2.5 text-xs font-medium transition-all text-left",k===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),children:a.name},a.id))})]})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold border-b pb-2",children:"Backgrounds & Shapes"}),(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6",children:[(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Page Base"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:um.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>d(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",c===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","bg-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Content Panel"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:un.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>f(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",e===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","panel-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},a.id))})]}),(0,z.jsxs)("div",{className:"space-y-2.5",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Sidebar Nav"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:un.map(a=>(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)("button",{onClick:()=>h(a.id),className:(0,M.cn)("flex items-center justify-center rounded-full border p-0.5 transition-all hover:scale-110",g===a.id?"border-primary":"border-transparent")}),children:(0,z.jsx)("div",{className:(0,M.cn)("h-5 w-5 rounded-full ring-1 ring-border/20 shrink-0","panel-default"===a.id&&"border-dashed border-2"),style:{background:a.color}})}),(0,z.jsx)(ac.TooltipContent,{side:"bottom",className:"text-[10px]",children:a.name})]},`nav-${a.id}`))})]})]})}),(0,z.jsxs)("div",{className:"space-y-2.5 pt-4",children:[(0,z.jsx)("label",{className:"text-xs font-medium text-muted-foreground",children:"Corners Radius"}),(0,z.jsx)("div",{className:"flex flex-wrap gap-2",children:uo.map(a=>(0,z.jsx)("button",{onClick:()=>j(a.id),className:(0,M.cn)("rounded-md border px-3 py-1.5 text-xs font-medium transition-all",i===a.id?"border-border bg-white text-foreground":"border-muted/20 text-foreground hover:bg-muted/30"),style:{borderRadius:a.value},children:a.name},a.id))})]})]})]}):null}var us=a.i(886215),ut=a.i(671008);let uu=[{value:"hybrid",label:"Hybrid",description:"Combines semantic understanding with keyword matching for best results."},{value:"semantic",label:"Semantic",description:"Uses embeddings to find conceptually similar content."},{value:"lexical",label:"Lexical",description:"Traditional keyword-based search using BM25 scoring."}],uv=a=>fetch(a).then(a=>a.json()),uw={lancedb:{iconSrc:"/icons/lancedb2.png",pillBg:"bg-yellow-50 dark:bg-yellow-950/40"},pinecone:{iconSrc:"/icons/pinecone.png",pillBg:"bg-green-50 dark:bg-green-950/40"}};function ux(){let{activeServer:a}=(0,$.useWorkspace)(),b=a?.id,c=b?`/api/config?serverId=${encodeURIComponent(b)}`:"/api/config",{data:d,isLoading:e,mutate:f}=(0,P.default)(c,uv),[g,h]=(0,A.useState)({}),[i,j]=(0,A.useState)(!1),[k,l]=(0,A.useState)({}),[m,n]=(0,A.useState)(null),[o,p]=(0,A.useState)(!1),[q,r]=(0,A.useState)(!1),{data:s}=(0,P.default)("/api/index",a=>fetch(a).then(a=>a.json())),t=s?.run?.status==="completed"?s.run:null;(0,A.useEffect)(()=>{d?.config&&h(d.config)},[d]);let u=JSON.stringify(g)!==JSON.stringify(d?.config??{});async function v(){if(m){if(q)try{if(!(await fetch("/api/documents",{method:"DELETE"})).ok)throw Error("Could not clear the knowledge base.");Y.toast.success("Knowledge base cleared.")}catch(a){Y.toast.error(a instanceof Error?a.message:"Could not clear the knowledge base.");return}h(a=>({...a,vectorStore:m,storeConfig:{}})),p(!1),n(null)}}async function w(){if(!d?.config)return;let a=!1,b={};if(g.vectorStore){let c=(0,tn.getVectorStore)(g.vectorStore);if(c){let d=(0,tn.validateStoreConfig)(c,g.storeConfig||{},g.indexType||"hybrid");Object.keys(d).length>0&&(Object.assign(b,d),a=!0)}}if(l(b),a)return void Y.toast.error("Please fill in all required fields",{duration:1/0});j(!0);try{let a={...d.config,...g},b=await fetch(c,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),e=await b.json();if(!b.ok)throw Error(e.error??"Failed to save");await f(e,{revalidate:!1}),Y.toast.success("Storage settings saved",{duration:1/0})}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to save",{duration:1/0})}finally{j(!1)}}return e?(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Storage"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Where your processed data is stored and indexed."})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-2 text-sm",children:[(0,z.jsx)(ut.Layers,{className:"size-3.5 text-primary"}),"Indexing Strategy"]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"How your documents are indexed for retrieval."})]}),(0,z.jsx)(Z.CardContent,{className:"space-y-4",children:(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{className:"text-xs",children:"Strategy"}),(0,z.jsxs)(X.Select,{value:g.indexType||"hybrid",onValueChange:a=>{t&&d?.config&&a!==d.config.indexType?(0,Y.toast)("Cannot modify configuration",{description:"This project already has indexed data. You must create a new project to change this setting.",duration:1/0}):h(b=>({...b,indexType:a}))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full",children:(0,z.jsx)("span",{className:"font-medium text-sm",children:uu.find(a=>a.value===(g.indexType||"hybrid"))?.label??"Select strategy…"})}),(0,z.jsx)(X.SelectContent,{children:uu.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:(0,z.jsxs)("span",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),(0,z.jsx)("span",{className:"text-xs text-muted-foreground",children:a.description})]})},a.value))})]})]})})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-2 text-sm",children:[(0,z.jsx)(I.Database,{className:"size-3.5 text-primary"}),"Storage Engine"]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Configure your vector database connection."})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-5",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{className:"text-xs",children:"Storage Engine"}),(0,z.jsxs)(X.Select,{value:g.vectorStore||"",onValueChange:a=>{d?.config&&a!==g.vectorStore&&(n(a),r(!1),p(!0))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full",children:g.vectorStore?(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[(0,z.jsx)(ah.ProviderIcon,{src:uw[g.vectorStore]?.iconSrc??"",alt:(0,tn.getVectorStore)(g.vectorStore)?.label??g.vectorStore,pillBg:uw[g.vectorStore]?.pillBg??void 0,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:(0,tn.getVectorStore)(g.vectorStore)?.label??g.vectorStore})]}):(0,z.jsx)("span",{className:"text-muted-foreground",children:"Select storage engine…"})}),(0,z.jsx)(X.SelectContent,{children:tn.VECTOR_STORE_LIST.map(a=>{let b=uw[a.id],c="coming-soon"===a.installStatus;return(0,z.jsx)(X.SelectItem,{value:a.id,disabled:c,className:c?"opacity-50":"",children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5 w-full",children:[b&&(0,z.jsx)(ah.ProviderIcon,{src:b.iconSrc,alt:a.label,pillBg:b.pillBg??void 0,size:16}),(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),c&&(0,z.jsxs)("span",{className:"h-3.5 px-1 text-[9px] font-medium shrink-0 text-muted-foreground border rounded-full flex items-center bg-transparent",children:[(0,z.jsx)(us.Clock,{className:"size-2.5 mr-0.5"}),"Coming Soon"]})]})]})},a.id)})})]})]}),g.vectorStore&&(0,z.jsx)("div",{className:"border-t pt-4",children:(0,z.jsx)(to,{store:(0,tn.getVectorStore)(g.vectorStore),values:g.storeConfig||{},errors:k,onChange:(a,b)=>{h(c=>({...c,storeConfig:{...c.storeConfig,[a]:b}})),k[a]&&l(b=>{let c={...b};return delete c[a],c})},indexType:g.indexType||"hybrid"})})]}),(0,z.jsx)(Z.CardFooter,{className:"flex justify-end pt-4 border-t",children:(0,z.jsxs)(U.Button,{size:"sm",disabled:i||!u,onClick:w,className:"gap-1.5",children:[i?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})})]}),(0,z.jsx)(aH.AlertDialog,{open:o,onOpenChange:p,children:(0,z.jsxs)(aH.AlertDialogContent,{children:[(0,z.jsxs)(aH.AlertDialogHeader,{children:[(0,z.jsx)(aH.AlertDialogTitle,{children:"Change vector storage?"}),(0,z.jsx)(aH.AlertDialogDescription,{children:"Your existing indexed vectors stay in the current storage engine and will not be available after this change. Keep the knowledge base to re-index it in the new store, or clear it intentionally below."})]}),(0,z.jsxs)("label",{className:"flex cursor-pointer items-start gap-3 rounded-md border p-3 text-sm",children:[(0,z.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:q,onChange:a=>r(a.target.checked)}),(0,z.jsxs)("span",{children:[(0,z.jsx)("span",{className:"font-medium",children:"Clear knowledge base"}),(0,z.jsx)("span",{className:"block text-xs text-muted-foreground",children:"Permanently remove documents and the current vector index before changing storage."})]})]}),(0,z.jsxs)(aH.AlertDialogFooter,{children:[(0,z.jsx)(aH.AlertDialogCancel,{onClick:()=>n(null),children:"Cancel"}),(0,z.jsx)(aH.AlertDialogAction,{onClick:v,children:q?"Clear and change storage":"Keep documents and continue"})]})]})})]})}let uy=(0,G.default)("blocks",[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2",key:"1ah6g2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1",key:"88lufb"}]]),uz=[{id:"webhook",name:"Webhook",description:"Custom webhook integration",iconPath:"/icons/webhook.png",fields:[{id:"url",label:"Webhook URL",type:"url",placeholder:"https://your-domain.com/webhook"}]},{id:"slack",name:"Slack",description:"Connect to a Slack workspace",iconPath:"/icons/slack.png",fields:[{id:"token",label:"Bot User OAuth Token",type:"password",placeholder:"xoxb-..."}]},{id:"discord",name:"Discord",description:"Add a Discord bot",iconPath:"/icons/discord.png",fields:[{id:"token",label:"Bot Token",type:"password",placeholder:"Paste your Discord bot token"}]},{id:"telegram",name:"Telegram",description:"Create a Telegram bot",iconPath:"/icons/telegram.png",fields:[{id:"token",label:"Bot Token",type:"password",placeholder:"Paste your Telegram bot token from BotFather"}]},{id:"whatsapp",name:"WhatsApp",description:"WhatsApp Business API",iconPath:"/icons/whatsapp.png",fields:[{id:"phoneNumberId",label:"Phone Number ID",type:"text",placeholder:"e.g. 10123456789"},{id:"token",label:"Access Token",type:"password",placeholder:"Permanent or temporary access token"}]},{id:"widget",name:"Website Widget",description:"Inject a chat UI in your website",IconComponent:aI,fields:[{id:"domain",label:"Allowed Domain",type:"text",placeholder:"https://your-website.com"}]}];function uA(){let[a,b]=(0,A.useState)({});(0,A.useEffect)(()=>{fetch("/api/connections").then(a=>a.json()).then(a=>{a.error||b(a)})},[]);let c=async a=>{b(a),await fetch("/api/connections",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})},[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(null),[h,i]=(0,A.useState)(!1),[j,k]=(0,A.useState)(""),[l,m]=(0,A.useState)(""),[n,o]=(0,A.useState)(""),[p,q]=(0,A.useState)(""),[r,s]=(0,A.useState)(!1),[t,u]=(0,A.useState)(!1),v=async a=>{if(a.preventDefault(),n){s(!0);try{if(!(await fetch(process.env.NEXT_PUBLIC_CONNECT_API_URL||"https://www.larkup.de/api/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j,company:l,email:n,message:p})})).ok)throw Error("Failed to send request");u(!0),Y.toast.success("Request sent successfully!"),setTimeout(()=>{i(!1),u(!1),k(""),m(""),o(""),q("")},2e3)}catch(a){Y.toast.error("Failed to send request. Please try again later.")}finally{s(!1)}}},w=uz.find(a=>a.id===d);return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Connections"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Connect different channels to your AI server to chat from anywhere."})]}),(0,z.jsxs)(U.Button,{variant:"default",size:"sm",className:"h-8 gap-2 ",onClick:()=>i(!0),children:[(0,z.jsx)(uy,{className:"size-3.5"}),"Ask for connection"]})]}),(0,z.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-1 gap-5",children:uz.map(b=>{let c=a[b.id];return(0,z.jsxs)("div",{className:"group flex items-center justify-between gap-3.5 rounded-xl border border-border bg-card px-4 py-3.5 transition-all ",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3.5 min-w-0",children:[(0,z.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border border-border/30",children:b.iconPath?(0,z.jsx)("img",{src:b.iconPath,alt:b.name,className:"size-6 object-contain"}):b.IconComponent?(0,z.jsx)(b.IconComponent,{className:"size-5 text-foreground"}):null}),(0,z.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,z.jsx)("div",{className:"text-sm font-medium text-foreground",children:b.name}),(0,z.jsx)("div",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:b.description})]})]}),(0,z.jsx)("div",{className:"shrink-0",children:c?(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8 hover:bg-muted/80 ",onClick:()=>{e(b.id),g("configure")},children:"Configure"}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8",disabled:!0,children:"Coming soon"})})})]},b.id)})}),(0,z.jsx)(aG.Dialog,{open:!!d,onOpenChange:a=>!a&&e(null),children:(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-md",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsx)(aG.DialogTitle,{children:"connect"===f?`Connect ${w?.name}`:`Configure ${w?.name}`}),(0,z.jsx)(aG.DialogDescription,{children:"connect"===f?`Enter the required details to connect your ${w?.name} integration.`:`Manage your ${w?.name} integration settings.`})]}),"connect"===f&&w&&(0,z.jsxs)("div",{className:"space-y-4 py-4",children:[w.fields.map(a=>(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:a.id,children:a.label}),(0,z.jsx)(V.Input,{id:a.id,type:a.type,placeholder:a.placeholder})]},a.id)),"widget"===w.id&&(0,z.jsxs)("div",{className:"mt-4 p-4 bg-muted rounded-md border border-border",children:[(0,z.jsx)(W.Label,{className:"mb-2 block",children:"Widget Code"}),(0,z.jsx)("code",{className:"text-xs text-muted-foreground break-all",children:'<script src="https://larkup.com/widget.js" data-token="YOUR_TOKEN"></script>'})]})]}),"configure"===f&&w&&(0,z.jsx)("div",{className:"space-y-4 py-4",children:(0,z.jsxs)("div",{className:"flex items-center gap-3 p-4 bg-muted/50 rounded-lg border border-border/50",children:[(0,z.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-background border border-border",children:w.iconPath?(0,z.jsx)("img",{src:w.iconPath,alt:w.name,className:"size-6 object-contain"}):w.IconComponent?(0,z.jsx)(w.IconComponent,{className:"size-5 text-foreground"}):null}),(0,z.jsxs)("div",{children:[(0,z.jsx)("div",{className:"text-sm font-medium text-foreground",children:"Status: Connected"}),(0,z.jsxs)("div",{className:"text-xs text-green-600 flex items-center gap-1 mt-0.5",children:[(0,z.jsxs)("span",{className:"relative flex size-2",children:[(0,z.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]}),"Active and receiving messages"]})]})]})}),(0,z.jsx)(aG.DialogFooter,{className:"gap-2 sm:gap-0",children:"configure"===f?(0,z.jsxs)("div",{className:"flex w-full justify-between items-center",children:[(0,z.jsx)(U.Button,{variant:"destructive",onClick:()=>{d&&(c({...a,[d]:!1}),e(null))},children:"Disconnect"}),(0,z.jsx)(U.Button,{variant:"outline",onClick:()=>e(null),children:"Close"})]}):(0,z.jsx)("div",{className:"flex w-full justify-end",children:(0,z.jsx)(U.Button,{onClick:()=>{d&&(c({...a,[d]:!0}),e(null))},children:"Save Connection"})})})]})}),(0,z.jsx)(aG.Dialog,{open:h,onOpenChange:i,children:(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-3xl",children:[(0,z.jsx)(aG.DialogHeader,{children:(0,z.jsx)(aG.DialogTitle,{children:"Ask for Connection"})}),t?(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-8 text-center space-y-4",children:[(0,z.jsx)("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center text-primary",children:(0,z.jsx)(D.Sparkles,{className:"h-6 w-6"})}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Thank you! We've received your request and will get back to you soon."})]}):(0,z.jsxs)("form",{onSubmit:v,className:"space-y-4 mt-4",children:[(0,z.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"name",children:"Name"}),(0,z.jsx)(V.Input,{id:"name",type:"text",placeholder:"John Doe",value:j,onChange:a=>k(a.target.value)})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"company",children:"Company"}),(0,z.jsx)(V.Input,{id:"company",type:"text",placeholder:"Acme Inc.",value:l,onChange:a=>m(a.target.value)})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)(W.Label,{htmlFor:"email",children:["Your Email ",(0,z.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,z.jsx)(V.Input,{id:"email",type:"email",required:!0,placeholder:"name@company.com",value:n,onChange:a=>o(a.target.value)})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"message",children:"Which connection do you need?"}),(0,z.jsx)(t3.Textarea,{id:"message",placeholder:"Tell us which platform you want to connect to your AI server...",className:"resize-none min-h-30 max-h-67.5!",rows:5,value:p,onChange:a=>q(a.target.value)})]}),(0,z.jsxs)(aG.DialogFooter,{className:"bg-muted/50 border-border/70 mt-6",children:[(0,z.jsx)(U.Button,{type:"button",variant:"outline",onClick:()=>i(!1),children:"Cancel"}),(0,z.jsxs)(U.Button,{type:"submit",disabled:r,children:[r&&(0,z.jsx)(Q.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Submit Request"]})]})]})]})})]})}function uB(){let[a,b]=(0,A.useState)(null),[c,d]=(0,A.useState)(null),[e,f]=(0,A.useState)(!0),[g,h]=(0,A.useState)(!1),[i,j]=(0,A.useState)(""),[k,l]=(0,A.useState)(!1);async function m(){try{let a=await fetch("/api/deployment/config"),c=await a.json();c.error||b(c)}finally{f(!1)}}async function n(){let a=await fetch("/api/server/agent");a.ok&&d(await a.json())}async function o(){let a=await fetch("/api/deployment/blob-setup");if(a.ok){let{connected:b}=await a.json();l(b)}}async function p(c){if(!a)return;let d={...a,...c};b(d),await fetch("/api/deployment/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)}),Y.toast.success("Deployment settings saved")}async function q(){(await fetch("/api/deployment/blob-setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})})).ok?(Y.toast.success("Vercel Blob connected"),l(!0),j("")):Y.toast.error("Failed to connect Vercel Blob")}async function r(){if(c?.running){h(!0);let a=await fetch("/api/server/agent",{method:"DELETE"});a.ok&&d(await a.json()),h(!1)}else{h(!0);let a=await fetch("/api/server/agent",{method:"POST"});a.ok&&d(await a.json()),h(!1)}}return((0,A.useEffect)(()=>{m(),n(),o()},[]),e||!a)?(0,z.jsx)("div",{className:"p-8 text-center text-muted-foreground",children:"Loading deployment config..."}):(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsx)("div",{className:"flex items-center justify-between",children:(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Deploy & Share Agent"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground",children:"Configure how your agent is deployed, shared, and embedded in external websites."})]})}),(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Agent Type"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Choose the type of deployment"})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Deployment Type"}),(0,z.jsxs)(X.Select,{value:a.type||"",onValueChange:a=>p({type:a}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"rag-only",children:"RAG Only (API Backend)"}),(0,z.jsx)(X.SelectItem,{value:"full-agent",children:"Full Agent (Chat UI & Widget)"})]})]})]}),"full-agent"===a.type&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"system-prompt",children:"System Prompt"}),(0,z.jsx)(t3.Textarea,{id:"system-prompt",placeholder:"You are a helpful AI...",value:a.systemPrompt||"",onChange:a=>p({systemPrompt:a.target.value}),rows:3,className:"resize-none"})]})]})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Authentication"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Control who can access your agent"})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Auth Mode"}),(0,z.jsxs)(X.Select,{value:a.authMode||"",onValueChange:a=>p({authMode:a}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"none",children:"Public (No Auth)"}),(0,z.jsx)(X.SelectItem,{value:"api-key",children:"API Key (Server to Server)"}),(0,z.jsx)(X.SelectItem,{value:"join-code",children:"Join Code (For Users)"})]})]})]}),"join-code"===a.authMode&&(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"join-code",children:"Join Code"}),(0,z.jsx)(V.Input,{id:"join-code",placeholder:"e.g. secret-beta-code",value:a.joinCode||"",onChange:a=>p({joinCode:a.target.value})})]})]})]}),"full-agent"===a.type&&(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Widget Customization"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Customize the appearance of the embeddable chat widget"})]}),(0,z.jsxs)(Z.CardContent,{className:"grid gap-6 md:grid-cols-2",children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{htmlFor:"primary-color",children:"Primary Color"}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsx)(V.Input,{type:"color",value:a.widgetStyle.primaryColor,onChange:b=>p({widgetStyle:{...a.widgetStyle,primaryColor:b.target.value}}),className:"w-12 h-10 p-1 cursor-pointer"}),(0,z.jsx)(V.Input,{id:"primary-color",value:a.widgetStyle.primaryColor,onChange:b=>p({widgetStyle:{...a.widgetStyle,primaryColor:b.target.value}}),className:"font-mono flex-1"})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Position"}),(0,z.jsxs)(X.Select,{value:a.widgetStyle.position||"",onValueChange:b=>p({widgetStyle:{...a.widgetStyle,position:b}}),children:[(0,z.jsx)(X.SelectTrigger,{children:(0,z.jsx)(X.SelectValue,{})}),(0,z.jsxs)(X.SelectContent,{children:[(0,z.jsx)(X.SelectItem,{value:"bottom-right",children:"Bottom Right"}),(0,z.jsx)(X.SelectItem,{value:"bottom-left",children:"Bottom Left"})]})]})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Widget Title"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.title,onChange:b=>p({widgetStyle:{...a.widgetStyle,title:b.target.value}})})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Welcome Message"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.welcomeMessage,onChange:b=>p({widgetStyle:{...a.widgetStyle,welcomeMessage:b.target.value}})})]}),(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsx)(W.Label,{children:"Input Placeholder"}),(0,z.jsx)(V.Input,{value:a.widgetStyle.placeholder,onChange:b=>p({widgetStyle:{...a.widgetStyle,placeholder:b.target.value}})})]}),(0,z.jsxs)("div",{className:"flex items-center justify-between pt-4",children:[(0,z.jsxs)(W.Label,{className:"flex flex-col gap-1",children:[(0,z.jsx)("span",{children:"Dark Mode"}),(0,z.jsx)("span",{className:"font-normal text-sm text-muted-foreground",children:"Force dark mode for the widget"})]}),(0,z.jsx)(ab.Switch,{checked:a.widgetStyle.darkMode,onCheckedChange:b=>p({widgetStyle:{...a.widgetStyle,darkMode:b}})})]})]})]})]})]}),(0,z.jsxs)(Z.Card,{children:[(0,z.jsxs)(Z.CardHeader,{className:"pb-3",children:[(0,z.jsx)(Z.CardTitle,{className:"text-sm",children:"Cloud Storage Setup"}),(0,z.jsx)(Z.CardDescription,{className:"text-xs",children:"Use Vercel Blob for original files and media. Configure a cloud vector store separately for retrieval."})]}),(0,z.jsx)(Z.CardContent,{children:k?(0,z.jsxs)("div",{className:"flex items-center gap-2 text-emerald-600 dark:text-emerald-400 font-medium bg-emerald-50 dark:bg-emerald-950/30 p-3 rounded-md",children:[(0,z.jsx)(aJ.Check,{className:"w-5 h-5"})," Vercel Blob is connected for media and file storage."]}):(0,z.jsxs)("div",{className:"space-y-3 max-w-lg",children:[(0,z.jsx)("a",{href:"https://vercel.com/integrations/vercel-blob",target:"_blank",rel:"noreferrer",className:"inline-flex text-sm font-medium underline underline-offset-4",children:"Install Vercel Blob in your Vercel account"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:"After installation, paste the Blob read/write token to connect this workspace."}),(0,z.jsxs)("div",{className:"flex items-end gap-3",children:[(0,z.jsxs)("div",{className:"space-y-2 flex-1",children:[(0,z.jsx)(W.Label,{children:"Vercel Blob Read/Write Token"}),(0,z.jsx)(V.Input,{type:"password",placeholder:"vercel_blob_rw_...",value:i,onChange:a=>j(a.target.value)})]}),(0,z.jsx)(U.Button,{onClick:q,disabled:!i,children:"Connect"})]})]})})]}),(0,z.jsxs)("div",{className:"mt-8 pt-8 border-t border-border/50 flex flex-col md:flex-row items-start md:items-center justify-between gap-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h3",{className:"text-lg font-medium mb-1",children:"Local Test Server"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mb-4",children:"Start the agent server locally to test your chat UI and widget configuration."}),(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)(U.Button,{onClick:r,disabled:g,variant:c?.running?"destructive":"default",className:"w-32",children:g?"Working...":c?.running?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aq.Square,{className:"w-4 h-4 mr-2"})," Stop Agent"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ap.Play,{className:"w-4 h-4 mr-2"})," Start Agent"]})}),c?.running&&(0,z.jsxs)("span",{className:"text-sm font-medium text-emerald-600 flex items-center gap-2",children:[(0,z.jsxs)("span",{className:"relative flex h-3 w-3",children:[(0,z.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-emerald-500"})]}),"Agent Running on port 8081"]})]})]}),c?.running&&"full-agent"===a.type&&(0,z.jsxs)("div",{className:"flex flex-col gap-3 min-w-[280px]",children:[(0,z.jsxs)(U.Button,{variant:"outline",className:"justify-between",onClick:()=>{navigator.clipboard.writeText("http://localhost:8081/chat-ui"),Y.toast.success("Share link copied to clipboard")},children:[(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)(ar.ExternalLink,{className:"w-4 h-4"})," Share Link"]}),(0,z.jsx)(at.Copy,{className:"w-4 h-4 text-muted-foreground"})]}),(0,z.jsxs)(U.Button,{variant:"outline",className:"justify-between bg-primary/5 hover:bg-primary/10 border-primary/20",onClick:()=>{navigator.clipboard.writeText('<script src="http://localhost:8081/widget.js"></script>'),Y.toast.success("Widget code copied to clipboard")},children:[(0,z.jsxs)("span",{className:"flex items-center gap-2",children:[(0,z.jsx)(t_,{className:"w-4 h-4 text-primary"})," Copy Embed Code"]}),(0,z.jsx)(at.Copy,{className:"w-4 h-4 text-primary/70"})]})]})]})]})}var uC=a.i(898871);let uD=(0,G.default)("megaphone",[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]]),uE={Film:tX.Film,ScanEye:tY},uF={all:"All",media:"Media",search:"Search",analytics:"Analytics",integration:"Integration",embedding:"Embedding",ai:"AI",automation:"Automation",utility:"Utility"},uG=a=>fetch(a).then(a=>a.json());function uH(){let a=(0,B.useRouter)(),{data:b,isLoading:c,mutate:d}=(0,P.default)("/api/marketplace",uG),[e,f]=(0,A.useState)(null),[g,h]=(0,A.useState)(""),[i,j]=(0,A.useState)("all"),k=(0,A.useCallback)(async b=>{f(b);try{let c=await fetch(`/api/marketplace/${b}`,{method:"POST"});if(!c.ok){let a=await c.json();throw Error(a.error||"Install failed")}"video-audio"===b?Y.toast.success("Video & Audio installed",{description:"Choose an audio provider before you index media.",action:{label:"Set up audio",onClick:()=>a.push("/settings?section=tool-settings")}}):Y.toast.success("Tool installed successfully"),d()}catch(a){Y.toast.error(a instanceof Error?a.message:"Failed to install tool")}finally{f(null)}},[d,a]),l=(0,A.useCallback)(async a=>{try{if(!(await fetch(`/api/marketplace/${a}`,{method:"DELETE"})).ok)throw Error("Uninstall failed");Y.toast.success("Tool removed"),d()}catch{Y.toast.error("Failed to remove tool")}},[d]),m=b?.tools??[],n=(0,A.useMemo)(()=>["all",...Array.from(new Set(m.map(a=>a.category))).sort()],[m]),o=(0,A.useMemo)(()=>{let a=m;if("all"!==i&&(a=a.filter(a=>a.category===i)),g.trim()){let b=g.toLowerCase();a=a.filter(a=>a.name.toLowerCase().includes(b)||a.description.toLowerCase().includes(b)||a.tags?.some(a=>a.toLowerCase().includes(b))||a.author.toLowerCase().includes(b))}return a},[m,i,g]);return(0,z.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-lg font-semibold text-foreground",children:"Marketplace"}),(0,z.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Extend Larkup with optional tools and capabilities."})]}),(0,z.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(F.Search,{className:"absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,z.jsx)(V.Input,{type:"text",placeholder:"Search tools…",value:g,onChange:a=>h(a.target.value),className:(0,M.cn)("w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2","text-[13px] text-foreground placeholder:text-muted-foreground/50","outline-none transition-colors","focus:border-foreground/20")})]}),n.length>2&&(0,z.jsx)("div",{className:"flex items-center gap-1.5 overflow-x-auto",children:n.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>j(a),className:(0,M.cn)("shrink-0 rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors",i===a?"bg-foreground text-background":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:uF[a]??a},a))})]}),c?(0,z.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,z.jsx)(Q.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):0===o.length?(0,z.jsx)("div",{className:"py-16 text-center text-sm text-muted-foreground",children:g||"all"!==i?"No tools match your search.":"No tools available yet."}):(0,z.jsx)("div",{className:"flex flex-col gap-2",children:o.map(a=>(0,z.jsx)(uI,{tool:a,installing:e===a.id,onInstall:k,onUninstall:l},a.id))})]})}function uI({tool:a,installing:b,onInstall:c,onUninstall:d}){var e;let f=uE[a.icon]??tX.Film,g="installed"===a.status,h=a.comingSoon;return(0,z.jsxs)("div",{className:(0,M.cn)("group flex items-center gap-4 rounded-xl border border-border bg-card px-4 py-3.5","transition-colors hover:border-border/80"),children:[(0,z.jsx)("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-lg bg-muted/50 border",children:a.emoji?(0,z.jsx)("span",{className:"text-xl leading-none",children:a.emoji}):(0,z.jsx)(f,{className:"size-5 text-foreground",strokeWidth:1.75})}),(0,z.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)("h3",{className:"text-[13px] font-medium text-foreground truncate",children:a.name}),(0,z.jsxs)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:["v",a.version]}),(0,z.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/40",children:"·"}),(0,z.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground/60",children:a.author})]}),(0,z.jsx)("p",{className:"mt-0.5 text-[12px] text-muted-foreground leading-relaxed line-clamp-1",children:a.description}),a.tags&&a.tags.length>0&&(0,z.jsxs)("div",{className:"mt-1.5 flex items-center gap-1 overflow-hidden",children:[a.tags.slice(0,4).map(a=>(0,z.jsx)("span",{className:"rounded-md bg-secondary px-1.5 py-0.5 text-[10px] text-muted-foreground",children:a},a)),a.tags.length>4&&(0,z.jsxs)("span",{className:"text-[10px] text-muted-foreground/50",children:["+",a.tags.length-4]})]})]}),(0,z.jsxs)("div",{className:"hidden sm:flex shrink-0 items-center gap-2 text-[11px] text-muted-foreground/60",children:[(0,z.jsx)("span",{className:"tabular-nums",children:a.installSize}),a.downloads>0&&(0,z.jsxs)("span",{className:"tabular-nums",children:["↓ ",(e=a.downloads)>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)]})]}),(0,z.jsx)("div",{className:"shrink-0",children:(0,z.jsx)("span",{className:(0,M.cn)("rounded-md px-2 py-0.5 text-[10px] font-medium","free"===a.pricing?"bg-secondary text-muted-foreground":"pro"===a.pricing?"bg-blue-50 text-blue-600":"bg-purple-50 text-purple-600"),children:"free"===a.pricing?"Free":"pro"===a.pricing?"Pro":"Enterprise"})}),(0,z.jsxs)("div",{className:"shrink-0 flex items-center gap-1.5",children:[a.repositoryUrl&&(0,z.jsx)("a",{href:a.repositoryUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1.5 rounded-md text-muted-foreground/40 hover:text-muted-foreground transition-colors",children:(0,z.jsx)(ar.ExternalLink,{className:"size-3.5"})}),h?(0,z.jsxs)(U.Button,{size:"sm",className:"h-7 text-[11px]",variant:"default",disabled:!0,children:[(0,z.jsx)(uD,{className:"size-3"}),"Soon"]}):g?(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsxs)("span",{className:"flex items-center gap-1 text-[11px] font-medium text-emerald-600",children:[(0,z.jsx)(aJ.Check,{className:"size-3"}),"Installed"]}),(0,z.jsx)(U.Button,{variant:"ghost",size:"sm",className:"size-7 p-0 text-muted-foreground/40 hover:text-destructive",onClick:()=>d(a.id),children:(0,z.jsx)(aw.Trash2,{className:"size-3"})})]}):(0,z.jsxs)(U.Button,{variant:"default",size:"sm",className:"h-7 gap-1.5 text-[11px] px-3",disabled:b,onClick:()=>c(a.id),children:[b?(0,z.jsx)(Q.Loader2,{className:"size-3 animate-spin"}):(0,z.jsx)(uC.Download,{className:"size-3"}),b?"Installing…":"Install"]})]})]})}var uJ=a.i(318467),uJ=uJ;let uK=a=>fetch(a).then(a=>a.json());function uL(){let{data:a,isLoading:b,error:c}=(0,P.default)("/api/marketplace",uK),{data:d,mutate:e,isLoading:f,error:g}=(0,P.default)("/api/config",uK),[h,i]=(0,A.useState)({toolConfigs:{}}),[j,k]=(0,A.useState)(null),[l,m]=(0,A.useState)(null),[n,o]=(0,A.useState)({}),[p,q]=(0,A.useState)({});if((0,A.useEffect)(()=>{d?.config?.toolConfigs&&i({toolConfigs:d.config.toolConfigs})},[d]),c||g)return(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[(0,z.jsx)(uJ.default,{className:"h-6 w-6 text-destructive mb-4"}),(0,z.jsx)("h3",{className:"text-lg font-medium text-destructive",children:"Failed to load configuration"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Please try refreshing the page."})]});if(b||f||!a||!d)return(0,z.jsx)("div",{className:"flex h-40 items-center justify-center",children:(0,z.jsx)(Q.Loader2,{className:"size-5 text-muted-foreground animate-spin"})});let r=a?.tools?.filter(a=>"installed"===a.status&&a.configSchema?.length>0)||[];if(0===r.length)return(0,z.jsxs)("div",{className:"flex flex-col items-center justify-center py-24 text-center",children:[(0,z.jsx)("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-primary/10",children:(0,z.jsx)(K.Store,{className:"h-6 w-6 text-primary"})}),(0,z.jsx)("h3",{className:"mb-2 text-lg font-semibold",children:"No Tools Installed"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground max-w-sm",children:"You haven't installed any Marketplace tools that require configuration yet."})]});async function s(a){k(a);try{let a={...d?.config||{},toolConfigs:h.toolConfigs};if(!(await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok)throw Error("Failed to save configuration");await e(),Y.toast.success("Tool configuration saved successfully")}catch(a){Y.toast.error(a.message||"An error occurred while saving")}finally{k(null)}}async function t(a){m(a),o(b=>({...b,[a]:{status:null}}));try{if("video-audio"===a){let a=h.toolConfigs["video-audio"]?.audioProvider,b=h.toolConfigs["video-audio"]?.audioApiKey||"";if(!a)throw Error("Choose an Audio Provider before verifying this tool.");let c=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({audioProvider:a,audioApiKey:b})});if(!c.ok){let a=await c.json();throw Error(a.error||"Verification failed")}}else await new Promise(a=>setTimeout(a,1e3));o(b=>({...b,[a]:{status:"success"}})),Y.toast.success("Configuration verified successfully")}catch(b){o(c=>({...c,[a]:{status:"error",message:b.message}})),Y.toast.error(b.message||"Verification failed")}finally{m(null)}}let u=a=>{switch(a){case"openai":return"/icons/openai.svg";case"google":return"/icons/gemini.svg";case"deepgram":return"/icons/deepgram.png";case"elevenlabs":return"/icons/elevenlabs.png";case"groq":return"/icons/grok.png";default:return"/icons/audio.png"}};return(0,z.jsxs)("div",{className:"space-y-6",children:[(0,z.jsxs)("div",{children:[(0,z.jsx)("h2",{className:"text-xl font-medium tracking-tight",children:"Marketplace Tools"}),(0,z.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure API keys and settings for your installed tools."})]}),(0,z.jsx)("div",{className:"grid gap-6",children:r.map(a=>{let b=JSON.stringify(h.toolConfigs?.[a.id]||{})!==JSON.stringify(d?.config?.toolConfigs?.[a.id]||{}),c=n[a.id];return(0,z.jsxs)(Z.Card,{className:"overflow-hidden transition-all border border-border bg-white",children:[(0,z.jsxs)(Z.CardHeader,{className:" pb-4 gap-0 ",children:[(0,z.jsxs)(Z.CardTitle,{className:"flex items-center gap-3 text-base",children:[(0,z.jsx)("div",{className:"flex h-8 w-8 mt-1 items-center justify-center rounded-md bg-background border border-border/50",children:(0,z.jsx)("img",{src:`/icons/${"video-audio"===a.id?"video":"webhook"}.png`,alt:a.name,className:"h-5 w-5 object-contain",onError:a=>{a.currentTarget.src="/icons/audio.png"}})}),a.name]}),(0,z.jsx)(Z.CardDescription,{className:"text-xs pt-0 ml-11",children:a.description})]}),(0,z.jsxs)(Z.CardContent,{className:"space-y-5 ",children:[c?.status==="error"&&(0,z.jsxs)("div",{className:"rounded-md bg-destructive/10 p-3 flex gap-2 items-start border border-destructive/20 text-destructive text-sm",children:[(0,z.jsx)(uJ.default,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,z.jsx)("span",{children:c.message})]}),c?.status==="success"&&(0,z.jsxs)("div",{className:"rounded-md bg-emerald-500/10 p-3 flex gap-2 items-start border border-emerald-500/20 text-emerald-600 dark:text-emerald-400 text-sm",children:[(0,z.jsx)(au.CheckCircle2,{className:"h-4 w-4 mt-0.5 shrink-0"}),(0,z.jsx)("span",{children:"Connection verified successfully."})]}),a.configSchema.map(b=>{let d=h.toolConfigs?.[a.id]?.[b.key];void 0===d&&"audioProvider"===b.key&&"video-audio"===a.id?d="":void 0===d&&(d=b.defaultValue??"");let e=p[`${a.id}_${b.key}`],f=b.label;if("audioApiKey"===b.key&&"video-audio"===a.id){let c=h.toolConfigs?.[a.id]?.audioProvider||"";if("local"===c)return null;let d=a.configSchema.find(a=>"audioProvider"===a.key)?.options?.find(a=>a.value===c);f=d?`${d.label} API Key`:b.label}return(0,z.jsxs)("div",{className:"space-y-2",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)(W.Label,{className:"text-[13px] font-medium",children:f}),"audioApiKey"===b.key&&c?.status==="success"&&(0,z.jsx)("span",{className:"text-[10px] text-emerald-500 font-medium",children:"✓ Verified"}),"audioApiKey"===b.key&&c?.status==="error"&&(0,z.jsx)("span",{className:"text-[10px] text-destructive font-medium truncate max-w-[150px]",children:c.message})]}),"select"===b.type?(0,z.jsxs)(X.Select,{value:d||"",onValueChange:c=>{"local"===c?(0,Y.toast)("Coming Soon",{description:"Local Whisper support is currently in development."}):(i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c}}}),o(b=>({...b,[a.id]:{status:null}})))},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full h-9",children:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:["audioProvider"===b.key&&(0,z.jsx)("img",{src:u(d),className:"w-4 h-4 object-contain opacity-80",alt:""}),(0,z.jsx)("span",{children:b.options?.find(a=>a.value===d)?.label||d||"Choose a provider"})]})}),(0,z.jsx)(X.SelectContent,{children:b.options?.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:(0,z.jsxs)("div",{className:"flex items-center gap-2",children:["audioProvider"===b.key&&(0,z.jsx)("img",{src:u(a.value),className:"w-4 h-4 object-contain",alt:""}),(0,z.jsxs)("span",{className:"local"===a.value?"text-muted-foreground":"",children:[a.label,"local"===a.value&&" (Coming soon)"]})]})},a.value))})]}):"password"===b.type?(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:e?"text":"password",value:d,onChange:c=>{i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c.target.value}}}),o(b=>({...b,[a.id]:{status:null}}))},placeholder:b.placeholder||"sk-...",className:"pr-10 h-9 font-mono text-sm"}),(0,z.jsx)("button",{type:"button",onClick:()=>q({...p,[`${a.id}_${b.key}`]:!e}),className:"absolute inset-y-0 right-0 flex items-center pr-3 text-muted-foreground hover:text-foreground",children:e?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})})]}),"audioApiKey"===b.key&&"video-audio"===a.id&&(0,z.jsx)(U.Button,{className:"rounded-md h-9",variant:"outline",size:"default",onClick:()=>t(a.id),disabled:l===a.id||!d,children:l===a.id?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):"Verify"})]}):(0,z.jsx)(V.Input,{type:"text",value:d,onChange:c=>{i({...h,toolConfigs:{...h.toolConfigs,[a.id]:{...h.toolConfigs?.[a.id]||{},[b.key]:c.target.value}}}),o(b=>({...b,[a.id]:{status:null}}))},placeholder:b.placeholder,className:"h-9"}),b.help&&(0,z.jsx)("p",{className:"text-[11px] text-muted-foreground",children:b.help})]},b.key)})]}),(0,z.jsx)(Z.CardFooter,{className:"flex justify-end gap-2 pt-4 pb-4 border-t bg-muted/10",children:(0,z.jsxs)(U.Button,{size:"sm",disabled:j===a.id||!b,onClick:()=>s(a.id),className:"gap-1.5 min-w-[80px]",children:[j===a.id?(0,z.jsx)(Q.Loader2,{className:"size-3.5 animate-spin"}):(0,z.jsx)(R.Save,{className:"size-3.5"}),"Save"]})})]},a.id)})})]})}function uM(){let a=(0,B.useSearchParams)(),b=(0,B.useRouter)(),c=(0,B.usePathname)(),[d,e]=(0,A.useState)((()=>{if(a.has("ai-models"))return"models";let b=a.get("section");return b||"general"})());return(0,A.useEffect)(()=>{let f=a.get("section");if(a.has("ai-models")){let f=new URLSearchParams(a.toString());f.delete("ai-models"),f.set("section","models"),b.replace(`${c}?${f.toString()}`),"models"!==d&&e("models")}else f&&f!==d&&e(f)},[a,d,c,b]),(0,z.jsxs)(O,{activeSection:d,onSectionChange:d=>{e(d);let f=new URLSearchParams(a.toString());f.delete("ai-models"),f.set("section",d),b.replace(`${c}?${f.toString()}`)},children:["general"===d&&(0,z.jsx)(ae,{}),"models"===d&&(0,z.jsx)(an,{}),"storage"===d&&(0,z.jsx)(ux,{}),"server"===d&&(0,z.jsx)(tR,{}),"connections"===d&&(0,z.jsx)(uA,{}),"deployment"===d&&(0,z.jsx)(uB,{}),"marketplace"===d&&(0,z.jsx)(uH,{}),"tool-settings"===d&&(0,z.jsx)(uL,{}),"prompts"===d&&(0,z.jsx)(t5,{}),"playground"===d&&(0,z.jsx)(uj,{}),"appearance"===d&&(0,z.jsx)(ur,{})]})}a.s(["default",0,function(){return(0,z.jsx)(A.Suspense,{children:(0,z.jsx)(uM,{})})}],98350)}];
121
121
 
122
122
  //# sourceMappingURL=_1hetwwu._.js.map