larkup 0.1.37 → 0.1.39
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.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- package/.next/diagnostics/route-bundle-stats.json +12 -12
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/required-server-files.js +1 -1
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +18 -18
- package/.next/server/app/_not-found.segments/_full.segment.rsc +18 -18
- package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_index.segment.rsc +12 -12
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/analytics/page_client-reference-manifest.js +1 -1
- package/.next/server/app/analytics.html +1 -1
- package/.next/server/app/analytics.rsc +19 -19
- package/.next/server/app/analytics.segments/_full.segment.rsc +19 -19
- package/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
- package/.next/server/app/analytics.segments/_index.segment.rsc +12 -12
- package/.next/server/app/analytics.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/analytics.segments/analytics.segment.rsc +3 -3
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/chat.html +1 -1
- package/.next/server/app/chat.rsc +19 -19
- package/.next/server/app/chat.segments/_full.segment.rsc +19 -19
- package/.next/server/app/chat.segments/_head.segment.rsc +4 -4
- package/.next/server/app/chat.segments/_index.segment.rsc +12 -12
- package/.next/server/app/chat.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/chat.segments/chat.segment.rsc +3 -3
- package/.next/server/app/data/page_client-reference-manifest.js +1 -1
- package/.next/server/app/data.html +1 -1
- package/.next/server/app/data.rsc +19 -19
- package/.next/server/app/data.segments/_full.segment.rsc +19 -19
- package/.next/server/app/data.segments/_head.segment.rsc +4 -4
- package/.next/server/app/data.segments/_index.segment.rsc +12 -12
- package/.next/server/app/data.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/data.segments/data.segment.rsc +3 -3
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +17 -17
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +17 -17
- package/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/server/app/index.segments/_index.segment.rsc +12 -12
- package/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +19 -19
- package/.next/server/app/settings.segments/_full.segment.rsc +19 -19
- package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
- package/.next/server/app/settings.segments/_index.segment.rsc +12 -12
- package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
- package/.next/server/app/settings.segments/settings.segment.rsc +3 -3
- package/.next/server/chunks/0598_next_dist_esm_build_templates_app-route_0kbcuk-.js +24 -28
- package/.next/server/chunks/[root-of-the-server]__1jc54o2._.js +1 -1
- package/.next/server/chunks/_1twj5f0._.js +3 -3
- package/.next/server/chunks/ssr/_169pdlf._.js +1 -1
- package/.next/server/chunks/ssr/_18jagqc._.js +1 -1
- package/.next/server/chunks/ssr/_1hetwwu._.js +1 -1
- package/.next/server/chunks/ssr/_1yqlx1m._.js +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/standalone/apps/web/.next/BUILD_ID +1 -1
- package/.next/standalone/apps/web/.next/build-manifest.json +3 -3
- package/.next/standalone/apps/web/.next/required-server-files.json +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/_not-found.rsc +18 -18
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_full.segment.rsc +18 -18
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/analytics/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/analytics.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/analytics.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/_full.segment.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/analytics.segments/analytics.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/chat.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/chat.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/chat.segments/_full.segment.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/chat.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/chat.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/chat.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/chat.segments/chat.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/data/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/data.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/data.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/data.segments/_full.segment.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/data.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/data.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/data.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/data.segments/data/__PAGE__.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/data.segments/data.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/app/index.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/index.rsc +17 -17
- package/.next/standalone/apps/web/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/index.segments/_full.segment.rsc +17 -17
- package/.next/standalone/apps/web/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/index.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/standalone/apps/web/.next/server/app/settings.html +1 -1
- package/.next/standalone/apps/web/.next/server/app/settings.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/settings.segments/_full.segment.rsc +19 -19
- package/.next/standalone/apps/web/.next/server/app/settings.segments/_head.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/settings.segments/_index.segment.rsc +12 -12
- package/.next/standalone/apps/web/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/apps/web/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +4 -4
- package/.next/standalone/apps/web/.next/server/app/settings.segments/settings.segment.rsc +3 -3
- package/.next/standalone/apps/web/.next/server/chunks/0598_next_dist_esm_build_templates_app-route_0kbcuk-.js +24 -28
- package/.next/standalone/apps/web/.next/server/chunks/[root-of-the-server]__1jc54o2._.js +1 -1
- package/.next/standalone/apps/web/.next/server/chunks/_1twj5f0._.js +3 -3
- package/.next/standalone/apps/web/.next/server/chunks/ssr/_169pdlf._.js +1 -1
- package/.next/standalone/apps/web/.next/server/chunks/ssr/_18jagqc._.js +1 -1
- package/.next/standalone/apps/web/.next/server/chunks/ssr/_1hetwwu._.js +1 -1
- package/.next/standalone/apps/web/.next/server/chunks/ssr/_1yqlx1m._.js +1 -1
- package/.next/standalone/apps/web/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/apps/web/.next/server/pages/404.html +1 -1
- package/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
- package/.next/{static/chunks/40jjwg-270y6t.js → standalone/apps/web/.next/static/chunks/03ju_837pa9ul.js} +3 -3
- package/.next/standalone/apps/web/.next/static/chunks/{3y2ki5tkccfxh.js → 19krxv-ou9c8c.js} +1 -1
- package/.next/standalone/apps/web/.next/static/chunks/1_nk3imchwn8a.css +1 -0
- package/.next/standalone/apps/web/.next/static/chunks/{0xvo_v5tiy4hc.js → 1ov69q-i9ybqi.js} +1 -1
- package/.next/{static/chunks/195c9wbq4gya9.js → standalone/apps/web/.next/static/chunks/2ljwki2xxnblc.js} +1 -1
- package/.next/standalone/apps/web/CHANGELOG.md +12 -0
- package/.next/standalone/apps/web/app/api/chat/route.ts +45 -34
- package/.next/standalone/apps/web/app/api/media/route.ts +3 -2
- package/.next/standalone/apps/web/app/api/media/stream/route.ts +19 -3
- package/.next/standalone/apps/web/app/settings/page.tsx +8 -16
- package/.next/standalone/apps/web/components/chat/message-item.tsx +18 -6
- package/.next/standalone/apps/web/components/chat/tools/knowledge-base-result.tsx +3 -4
- package/.next/standalone/apps/web/components/data/data-workspace.tsx +14 -10
- package/.next/standalone/apps/web/components/data/media-panel.tsx +112 -86
- package/.next/standalone/apps/web/components/settings/marketplace-section.tsx +5 -0
- package/.next/standalone/apps/web/package.json +1 -1
- package/.next/standalone/apps/web/server.js +1 -1
- package/.next/{standalone/apps/web/.next/static/chunks/40jjwg-270y6t.js → static/chunks/03ju_837pa9ul.js} +3 -3
- package/.next/static/chunks/{3y2ki5tkccfxh.js → 19krxv-ou9c8c.js} +1 -1
- package/.next/static/chunks/1_nk3imchwn8a.css +1 -0
- package/.next/static/chunks/{0xvo_v5tiy4hc.js → 1ov69q-i9ybqi.js} +1 -1
- package/.next/{standalone/apps/web/.next/static/chunks/195c9wbq4gya9.js → static/chunks/2ljwki2xxnblc.js} +1 -1
- package/CHANGELOG.md +12 -0
- package/app/api/chat/route.ts +45 -34
- package/app/api/media/route.ts +3 -2
- package/app/api/media/stream/route.ts +19 -3
- package/app/settings/page.tsx +8 -16
- package/components/chat/message-item.tsx +18 -6
- package/components/chat/tools/knowledge-base-result.tsx +3 -4
- package/components/data/data-workspace.tsx +14 -10
- package/components/data/media-panel.tsx +112 -86
- package/components/settings/marketplace-section.tsx +5 -0
- package/package.json +4 -4
- package/.next/standalone/apps/web/.next/static/chunks/427kg1r2nc6x0.css +0 -1
- package/.next/static/chunks/427kg1r2nc6x0.css +0 -1
- /package/.next/standalone/apps/web/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_buildManifest.js +0 -0
- /package/.next/standalone/apps/web/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/apps/web/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_ssgManifest.js +0 -0
- /package/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_buildManifest.js +0 -0
- /package/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{j-tshQTNg-SioxN4TXZNS → iCALZzxFfElF4z3wYZwsC}/_ssgManifest.js +0 -0
|
@@ -118,6 +118,6 @@ RESPONSE FORMATTING (Analytics Style):
|
|
|
118
118
|
- Structure complex responses logically (e.g., Summary -> Key Metrics -> Breakdown).
|
|
119
119
|
- If your findings contain a small table of data, format it cleanly using Markdown tables.
|
|
120
120
|
- DO NOT hallucinate facts; rely strictly on the provided query results.
|
|
121
|
-
- 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&&d.config.systemPrompt!==tU?d.config.systemPrompt:""})},[d]);let k=(g.systemPrompt||"")!==(d?.config?.systemPrompt===tU?"":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:"Add your own instructions. Larkup keeps its generated tool and retrieval instructions separate and combines them automatically."})]}),(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,c,b,d]),(0,z.jsxs)(O,{activeSection:d,onSectionChange:a=>{e(a),b.replace(`${c}?section=${a}`,{scroll:!1})},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
|
+
- 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&&d.config.systemPrompt!==tU?d.config.systemPrompt:""})},[d]);let k=(g.systemPrompt||"")!==(d?.config?.systemPrompt===tU?"":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:"Add your own instructions. Larkup keeps its generated tool and retrieval instructions separate and combines them automatically."})]}),(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);let c=Y.toast.loading("Downloading and installing tool…",{description:"This may take a moment on first install."});try{let e=await fetch(`/api/marketplace/${b}`,{method:"POST"});if(!e.ok){let a=await e.json();throw Error(a.error||"Install failed")}Y.toast.dismiss(c),"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.dismiss(c),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=(()=>{if(a.has("ai-models"))return"models";let b=a.get("section");return b||"general"})();return(0,A.useEffect)(()=>{if(a.has("ai-models")){let d=new URLSearchParams(a.toString());d.delete("ai-models"),d.set("section","models"),b.replace(`${c}?${d.toString()}`)}},[a,c,b]),(0,z.jsxs)(O,{activeSection:d,onSectionChange:a=>{b.replace(`${c}?section=${a}`,{scroll:!1})},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)}];
|
|
122
122
|
|
|
123
123
|
//# sourceMappingURL=_1hetwwu._.js.map
|