larkup 0.1.26 → 0.1.28
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 +11 -11
- 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 +16 -16
- package/.next/server/app/_not-found.segments/_full.segment.rsc +16 -16
- package/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_index.segment.rsc +11 -11
- 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 +1 -1
- 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 +17 -17
- package/.next/server/app/analytics.segments/_full.segment.rsc +17 -17
- package/.next/server/app/analytics.segments/_head.segment.rsc +4 -4
- package/.next/server/app/analytics.segments/_index.segment.rsc +11 -11
- package/.next/server/app/analytics.segments/_tree.segment.rsc +1 -1
- 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/api/chat/route.js +4 -4
- package/.next/server/app/api/media/process/route.js +2 -2
- 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 +17 -17
- package/.next/server/app/chat.segments/_full.segment.rsc +17 -17
- package/.next/server/app/chat.segments/_head.segment.rsc +4 -4
- package/.next/server/app/chat.segments/_index.segment.rsc +11 -11
- package/.next/server/app/chat.segments/_tree.segment.rsc +1 -1
- 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 +17 -17
- package/.next/server/app/data.segments/_full.segment.rsc +17 -17
- package/.next/server/app/data.segments/_head.segment.rsc +4 -4
- package/.next/server/app/data.segments/_index.segment.rsc +11 -11
- package/.next/server/app/data.segments/_tree.segment.rsc +1 -1
- 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 +16 -16
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/index.segments/_full.segment.rsc +16 -16
- package/.next/server/app/index.segments/_head.segment.rsc +4 -4
- package/.next/server/app/index.segments/_index.segment.rsc +11 -11
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- 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 +18 -18
- package/.next/server/app/settings.segments/_full.segment.rsc +18 -18
- package/.next/server/app/settings.segments/_head.segment.rsc +4 -4
- package/.next/server/app/settings.segments/_index.segment.rsc +11 -11
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- 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/[root-of-the-server]__1o3rcbz._.js +5 -3
- package/.next/server/chunks/[root-of-the-server]__1s9is1o._.js +5 -3
- package/.next/server/chunks/[root-of-the-server]__1zptg4z._.js +5 -3
- package/.next/server/chunks/packages_marketplace_src_125_g2p._.js +1 -1
- package/.next/server/chunks/ssr/_18jagqc._.js +1 -1
- package/.next/server/chunks/ssr/_1hetwwu._.js +4 -2
- package/.next/server/chunks/ssr/_1yqlx1m._.js +1 -1
- package/.next/server/chunks/ssr/apps_web_components_analytics_analytics-dashboard_tsx_1056-z3._.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/static/chunks/{35vy87bzy7bpe.js → 0k405nomf6s4e.js} +9 -7
- package/.next/static/chunks/{1j-0l9rslamm-.js → 0qyuw19snetjl.js} +1 -1
- package/.next/static/chunks/{0yczikyqgop_l.js → 13hmtkhrbm4t3.js} +1 -1
- package/.next/static/chunks/{1w2jeq6n8-qz9.js → 3g_wl1fri6jb-.js} +1 -1
- package/CHANGELOG.md +22 -0
- package/components/analytics/analytics-dashboard.tsx +7 -7
- package/components/chat/message-item.tsx +7 -3
- package/components/settings/server-section.tsx +9 -9
- package/package.json +6 -6
- /package/.next/static/{xTwOrztPHLuoZTFujcRUv → bDwMIFYSTVBKUJkJJx77o}/_buildManifest.js +0 -0
- /package/.next/static/{xTwOrztPHLuoZTFujcRUv → bDwMIFYSTVBKUJkJJx77o}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{xTwOrztPHLuoZTFujcRUv → bDwMIFYSTVBKUJkJJx77o}/_ssgManifest.js +0 -0
|
@@ -59,7 +59,7 @@ const { text } = await generateText({
|
|
|
59
59
|
console.log(text);`})[d];async function i(){await navigator.clipboard.writeText(h),g(!0),setTimeout(()=>g(!1),2e3)}return(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsx)(aG.DialogTrigger,{render:(0,z.jsxs)(U.Button,{size:"sm",variant:"outline",className:"gap-2 h-8",disabled:b,children:[(0,z.jsx)(aI,{className:"size-4"}),"Connect to Server SDK"]})}),(0,z.jsxs)(aG.DialogContent,{className:"sm:max-w-2xl",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsxs)(aG.DialogTitle,{className:"flex items-center gap-2",children:[(0,z.jsx)(aI,{className:"size-5 text-primary"}),"Connect to your RAG Server"]}),(0,z.jsx)(aG.DialogDescription,{children:"Use one of these SDKs to programmatically interact with your RAG server."})]}),(0,z.jsx)("div",{className:"flex gap-1 rounded-lg border bg-muted/40 p-1",children:td.map(a=>(0,z.jsx)("button",{type:"button",onClick:()=>e(a.id),className:(0,M.cn)("flex-1 rounded-md px-3 py-1.5 text-sm font-medium transition-all",d===a.id?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:a.label},a.id))}),(0,z.jsxs)("div",{className:"relative rounded-lg border bg-slate-50 overflow-hidden",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between border-b border-slate-200 px-4 py-2 bg-slate-100/50",children:[(0,z.jsx)("span",{className:"text-xs text-slate-500 font-mono",children:"python"===d?"main.py":"typescript"===d?"index.ts":"connect.ts"}),(0,z.jsx)("button",{type:"button",onClick:i,className:"flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-slate-500 transition hover:bg-slate-200 hover:text-slate-900",children:f?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(aJ.Check,{className:"size-3.5"}),"Copied!"]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(at.Copy,{className:"size-3.5"}),"Copy"]})})]}),(0,z.jsx)(tc,{value:h,language:"python"===d?"python":"javascript",height:"auto"})]}),(0,z.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,z.jsxs)("span",{className:"text-muted-foreground",children:["Server URL:"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono",children:a||"Not running"})]}),(0,z.jsxs)("a",{href:"https://www.larkup.de/sdk/overview",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline",children:["Full docs",(0,z.jsx)(ar.ExternalLink,{className:"size-3.5"})]})]})]})]})}var tf=a.i(842586);let tg=(0,G.default)("dices",[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]]),th=(0,G.default)("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),ti=(0,G.default)("plug-zap",[["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m18 3-4 4h6l-4 4",key:"16psg9"}]]);var tj=a.i(745975),tk=a.i(959183),tl=a.i(299574),tm=a.i(655208),tn=a.i(96607);function to({store:a,values:b,errors:c,onChange:d,indexType:e}){let f=(0,tn.visibleFields)(a,b,e),[g,h]=(0,A.useState)({});return(0,z.jsx)("div",{className:"grid gap-5 sm:grid-cols-2",children:f.map(a=>{let e=b[a.key]??a.defaultValue??"",f=c[a.key],i=`store-${a.key}`;return(0,z.jsxs)("div",{className:(0,M.cn)("space-y-1.5","select"===a.type&&"sm:col-span-1"),children:[(0,z.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,z.jsx)(W.Label,{htmlFor:i,children:a.label}),a.required&&(0,z.jsx)("span",{className:"text-destructive","aria-hidden":!0,children:"*"}),a.secret&&(0,z.jsxs)(tl.Badge,{variant:"outline",className:"h-4 gap-1 px-1 text-[9px] font-mono uppercase text-muted-foreground",children:[(0,z.jsx)(ay,{className:"size-2.5"}),"secret"]})]}),"select"===a.type?(0,z.jsxs)(X.Select,{value:e,onValueChange:b=>d(a.key,b??""),children:[(0,z.jsx)(X.SelectTrigger,{id:i,className:(0,M.cn)("w-full",f&&"border-destructive"),children:(0,z.jsx)(X.SelectValue,{placeholder:`Select ${a.label}`})}),(0,z.jsx)(X.SelectContent,{children:a.options?.map(a=>(0,z.jsx)(X.SelectItem,{value:a.value,children:a.label},a.value))})]}):"password"===a.type?(0,z.jsxs)("div",{className:"relative",children:[(0,z.jsx)(V.Input,{id:i,type:g[a.key]?"text":"password",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("font-mono text-sm pr-9",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>{var b;return b=a.key,void h(a=>({...a,[b]:!a[b]}))},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors",tabIndex:-1,children:g[a.key]?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})})]}):(0,z.jsx)(V.Input,{id:i,type:"text",placeholder:a.placeholder,value:e,spellCheck:!1,autoComplete:"off",className:(0,M.cn)("path"===a.type&&"font-mono text-sm",f&&"border-destructive"),onChange:b=>d(a.key,b.target.value)}),f?(0,z.jsx)("p",{className:"text-xs text-destructive",children:f}):a.help?(0,z.jsx)("p",{className:"text-xs text-muted-foreground leading-relaxed",children:a.help}):null]},a.key)})})}var tp=a.i(576991);let tq=(0,tp.createServerReference)("788d2a54def528afab85cd875b9df9131f22ff7825",tp.callServer,void 0,tp.findSourceMapURL,"deployToVercel"),tr=(0,tp.createServerReference)("406854aa983e37f94e9402716a996c9c31b64b8fce",tp.callServer,void 0,tp.findSourceMapURL,"getServerEnvRequirements");function ts(a){return`larkup_deployments_${a}`}function tt(a){return a.url.replace(/\/$/,"")}function tu(a){return`larkup_api_key_version_${a}`}function tv(a){return Number.parseInt(localStorage.getItem(tu(a))||"0",10)||0}function tw(a){let b=tv(a)+1;return localStorage.setItem(tu(a),String(b)),b}function tx(a){try{let b=localStorage.getItem(ts(a));if(b)return JSON.parse(b)}catch{}let b=function(a){let b=localStorage.getItem(`vercel_deployed_url_${a}`);if(!b)return[];let c=localStorage.getItem(`vercel_deployed_provider_${a}`)||"vercel";return[{id:`${c}:${b}`,provider:c,project:localStorage.getItem(`vercel_project_${a}`)||b,url:b,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}]}(a);return b.length&&localStorage.setItem(ts(a),JSON.stringify(b)),b}function ty(a,b){localStorage.setItem(ts(a),JSON.stringify(b)),window.dispatchEvent(new CustomEvent("larkup-deployments-change",{detail:a}))}function tz(a,b){let c=tx(a),d=c.findIndex(a=>a.provider===b.provider&&a.project===b.project),e=new Date().toISOString(),f={...b,apiKeyVersion:b.apiKeyVersion??tv(a),id:d>=0?c[d].id:`${b.provider}:${b.project}`,createdAt:d>=0?c[d].createdAt:e,updatedAt:e};return d>=0?c[d]=f:c.unshift(f),ty(a,c),c}function tA(a,b,c){let d=tx(a).map(a=>a.id===b?{...a,...c,updatedAt:new Date().toISOString()}:a);return ty(a,d),d}let tB="vercel_token";function tC(a){return`vercel_project_${a}`}function tD(a){return`vercel_deployed_url_${a}`}function tE(a){return`vercel_deployed_provider_${a}`}function tF(a){return`rag_server_env_vars_${a}`}function tG(a,b){b!==(localStorage.getItem("rag_server_api_key")||"")&&tw(a),b?localStorage.setItem("rag_server_api_key",b):localStorage.removeItem("rag_server_api_key")}let tH=a=>fetch(a).then(a=>a.json()),tI={lancedb:{iconSrc:"/icons/lancedb2.png",pillBg:"bg-yellow-50 dark:bg-yellow-950/40"},pinecone:{iconSrc:"/icons/pinecone.png",pillBg:"bg-green-50 dark:bg-green-950/40"}};function tJ(a){return(0,tn.getVectorStore)(a).fields.reduce((a,b)=>(b.defaultValue&&(a[b.key]=b.defaultValue),a),{})}function tK({open:a,onOpenChange:b,target:c,serverId:d}){let{refresh:e,activateServer:f}=(0,$.useWorkspace)(),[g,h]=(0,A.useState)("general"),[i,j]=(0,A.useState)(null),k=`/api/config?serverId=${encodeURIComponent(d)}`,{data:l}=(0,P.default)(a?k:null,tH),[m,n]=(0,A.useState)("lancedb"),[o,p]=(0,A.useState)({}),[q,r]=(0,A.useState)({}),[s,t]=(0,A.useState)(!0),[u,v]=(0,A.useState)(!1),[w,x]=(0,A.useState)(!1),[y,B]=(0,A.useState)(""),[D,E]=(0,A.useState)(!1),[F,G]=(0,A.useState)(null),[H,I]=(0,A.useState)(!0),[J,K]=(0,A.useState)(null),[L,M]=(0,A.useState)(!1),N=(0,A.useRef)(void 0),[O,R]=(0,A.useState)([]),[T,Z]=(0,A.useState)({}),[_,ab]=(0,A.useState)(""),[ac,ad]=(0,A.useState)(!1),[ae,af]=(0,A.useState)({}),[ag,ai]=(0,A.useState)(!1),[aj,al]=(0,A.useState)(!1),[am,an]=(0,A.useState)(""),[ao,ap]=(0,A.useState)(""),[aq,ar]=(0,A.useState)(!1),[as,at]=(0,A.useState)(!1),[au,av]=(0,A.useState)(""),[aw,ax]=(0,A.useState)("root"),[ay,az]=(0,A.useState)("password"),[aA,aB]=(0,A.useState)(""),[aC,aD]=(0,A.useState)(!1),[aE,aF]=(0,A.useState)([]),[aG,aH]=(0,A.useState)(!1),[aI,aJ]=(0,A.useState)(""),[aK,aL]=(0,A.useState)(""),[aM,aN]=(0,A.useState)(!1),[aO,aP]=(0,A.useState)(!1),[aQ,aR]=(0,A.useState)(!1),aS=(0,A.useRef)(null),aT=F??d,{data:aU}=(0,P.default)(F?`/api/index?serverId=${encodeURIComponent(F)}`:null,tH,{refreshInterval:a=>a?.run&&!["completed","failed"].includes(a.run.status)?1200:0}),aV=aU?.run;aV&&["completed","failed"].includes(aV.status);let aW=(0,A.useMemo)(()=>aV?.totalChunks?Math.round(aV.processedChunks/aV.totalChunks*100):5,[aV]);(0,A.useEffect)(()=>{a?"env"===c?h("general"):h("provider"):(ai(!1),al(!1),G(null),M(!1),aR(!1),j(null),"env"===c&&h("general"))},[a,c]),(0,A.useEffect)(()=>{aV?.warning&&aV.warning!==N.current&&Y.toast.warning(aV.warning,{id:"cloud-index-rate-limit",duration:7e4,position:"bottom-left"}),N.current=aV?.warning},[aV?.warning]),(0,A.useEffect)(()=>{if(!l?.config||F||ag)return;let a=l.config,b="lancedb"===a.vectorStore?"lancedb":a.vectorStore;n(b),p(a.vectorStore===b?a.storeConfig:tJ(b)),B(a.embeddingModelId),tr(d).then(a=>{R(a);let b=localStorage.getItem(tF(d)),c=b?JSON.parse(b):{},e={};for(let b of a)e[b.key]=c[b.key]||b.defaultValue||"";Z(e);let f=localStorage.getItem(tB),g=localStorage.getItem(tC(d)),h=localStorage.getItem("rag_server_api_key");h&&ab(h),f&&(an(f),at(!0)),g&&ap(g),ai(!0),al(!0)})},[l,F,ag,d]);let aX=(0,A.useMemo)(()=>{if(!l?.config)return[];let a=l.config.embeddingProvider,b=[...ak.EMBEDDING_MODELS.filter(b=>"vercel_ai_gateway"===a||b.provider===a),...(l.config.customEmbeddings??[]).map(a=>({id:`custom:${a.modelName}`,label:a.modelName}))];return b.some(a=>a.id===l.config.embeddingModelId)?b:[{id:l.config.embeddingModelId,label:l.config.embeddingModelId},...b]},[l?.config]),aY=aX.find(a=>a.id===y)??aX[0],aZ=(0,tn.getVectorStore)(m),a$="lancedb"===m&&(o.mode??"local")==="local";async function a_(){if(!l?.config)return!1;let a=(0,tn.validateStoreConfig)(aZ,o,l.config.indexType);if(Object.keys(a).length>0)return r(a),I(!0),h("general"),Y.toast.error("Complete the required storage fields before verifying.",{position:"bottom-left"}),!1;v(!0),K(null);try{let a=await fetch("/api/config/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l.config,vectorStore:m,storeConfig:o,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw b.fieldErrors&&(r(b.fieldErrors),I(!0)),Error(b.error??"Connection failed");return x(!0),Y.toast.success("Storage credentials verified.",{position:"bottom-left"}),!0}catch(b){x(!1);let a=b instanceof Error?b.message:"Connection failed";return K(a),Y.toast.error(a,{position:"bottom-left"}),!1}finally{v(!1)}}async function a0(){if(!l?.config||a$)return Y.toast.error("Choose cloud storage before continuing.",{position:"bottom-left"}),null;if(!w&&!await a_())return null;E(!0);try{let a=await fetch("/api/deploy/cloud-project",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceServerId:d,vectorStore:m,storeConfig:o,indexType:l.config.indexType,copyKnowledgeBase:s,embeddingModelId:y})}),b=await a.json();if(!a.ok)throw r(b.fieldErrors??{}),Error(b.error??"Could not create cloud project.");return G(b.server.id),await e(),Y.toast.success(b.copiedDocuments?"Knowledge base indexing started...":"Cloud project created.",{position:"bottom-left"}),b.server.id}catch(a){return Y.toast.error(a instanceof Error?a.message:"Could not create cloud project.",{position:"bottom-left"}),null}finally{E(!1)}}async function a1(){if("env"===c){tG(d,_),localStorage.setItem(tF(d),JSON.stringify(T)),b(!1),Y.toast.success("Environment configuration saved.",{position:"bottom-left"});return}if(j(null),"vercel"===c){if(!am||!ao){h("provider"),j("provider"),Y.toast.error("Please enter both a Vercel Token and a Project name.",{position:"bottom-left"});return}}else if(!au||!aw||!aA){h("provider"),j("provider"),Y.toast.error("Please fill in all SSH connection details.",{position:"bottom-left"});return}for(let a of O)if(a.required&&!T[a.key]){h("general"),j("general"),Y.toast.error(`Please provide a value for ${a.key}.`,{position:"bottom-left"});return}if(a$){h("general"),j("general"),Y.toast.error("You must configure a cloud vector store (e.g. Pinecone) to deploy.",{position:"bottom-left"});return}if(!w&&!await a_()){h("general"),j("general");return}if(!F&&l?.config.vectorStore==="lancedb"&&"lancedb"!==m){await a0()&&M(!0);return}"vercel"===c?a2(F??d):a3(F??d,void 0)}async function a2(a){aR(!0),Y.toast.info("Triggering deployment started !!",{position:"bottom-left"});try{let c={...T};_&&(c.SERVER_API_KEY=_,tG(a,_));let e=await tq(am,ao,a,c);if(e.success){localStorage.setItem(tB,am),localStorage.setItem(tC(a),ao),localStorage.setItem(tD(a),e.url),localStorage.setItem(tE(a),"vercel"),tz(a,{provider:"vercel",project:e.projectName??ao,url:e.url,status:e.status}),a!==d&&await f(a);let c=e.projectCreated?"Project created and will be available in a few seconds":"Server has been deployed successfully!";Y.toast.success((0,z.jsx)("div",{className:"flex flex-col gap-1",children:(0,z.jsx)("span",{children:c})}),{position:"bottom-left"}),b(!1)}else Y.toast.error(e.error||"Failed to deploy files to Vercel.",{position:"bottom-left"})}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}async function a3(a,c){let d;aR(!0),Y.toast.info("Connecting to server and deploying via SSH...",{duration:1e4,position:"bottom-left"});let e=aS.current?.host||au,f=aS.current?.username||aw,g=aS.current?.auth||{type:ay,value:aA},h=aS.current?.envVars||(d={...T},_&&(d.SERVER_API_KEY=_,tG(a,_)),d);try{let d={serverId:a,host:e,username:f,privateKeyOrPassword:g,envVars:h};c&&(d.newPassword=c);let i=await fetch("/api/deploy/ssh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!i.body)throw Error("No response from server.");let j=i.body.getReader(),k=new TextDecoder,l=!1,m="";for(;!l;){let{value:c,done:d}=await j.read();if(l=d,c){let d=(m+=k.decode(c,{stream:!0})).split("\n\n");for(let c of(m=d.pop()||"",d))if(c.startsWith("data: "))try{let d=JSON.parse(c.slice(6));if("log"===d.type)aF(a=>[...a,d.message]);else if("password_change_required"===d.type){aS.current={host:e,username:f,auth:g,envVars:h},aR(!1),aJ(""),aL(""),aH(!0);return}else"password_changed"===d.type?(navigator.clipboard.writeText(d.newPassword),Y.toast.warning("Server password updated.",{duration:6e4,position:"bottom-left"})):"done"===d.type?d.success?(localStorage.setItem(tD(a),d.url),localStorage.setItem(tE(a),"hetzner"),tz(a,{provider:"hetzner",project:e,url:d.url,status:"ready"}),Y.toast.success("Server deployed via SSH successfully!",{position:"bottom-left"}),aS.current=null,b(!1)):Y.toast.error(d.error||"Failed to deploy via SSH.",{position:"bottom-left"}):"error"===d.type&&Y.toast.error(d.error||"Failed to deploy.",{position:"bottom-left"})}catch(a){}}}}catch(a){Y.toast.error(a.message||"An unexpected error occurred.",{position:"bottom-left"})}finally{aR(!1)}}(0,A.useEffect)(()=>{L&&aV?.status==="completed"&&F&&(M(!1),"vercel"===c?a2(F):"env"!==c&&a3(F))},[aV?.status,L,F,c]);let a4=async()=>{aI?aI!==aK?Y.toast.error("Passwords do not match.",{position:"bottom-left"}):aI.length<8?Y.toast.error("Password must be at least 8 characters.",{position:"bottom-left"}):(aH(!1),aF(a=>[...a,"","--- Retrying with new password ---"]),await a3(aT,aI)):Y.toast.error("Enter a new password.",{position:"bottom-left"})},a5="general"===g;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(tk.Sheet,{open:a&&!aG,onOpenChange:a=>{aQ||b(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full max-w-[90%]! w-187.5! overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"env"===c?"Environment Settings":`Deploy to ${"vercel"===c?"Vercel":"Server"}`}),(0,z.jsx)(tk.SheetDescription,{children:"env"===c?"Configure environment variables and storage.":"Configure your deployment settings before launching."})]})}),(0,z.jsxs)("div",{className:"flex-1 px-6 overflow-y-auto",children:["env"!==c&&(0,z.jsx)(aa.Tabs,{value:g,onValueChange:a=>h(a),children:(0,z.jsxs)(aa.TabsList,{className:" rounded-md border bg-muted/20 w-fit ",children:[(0,z.jsxs)(aa.TabsTrigger,{value:"general",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"general"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(C.Settings2,{className:"size-3.5 mr-1.5"}),"General"]}),(0,z.jsxs)(aa.TabsTrigger,{value:"provider",className:`h-8 rounded-md px-4 text-xs font-medium transition-all data-[state=active]:bg-background data-[state=active]: ${"provider"===i?"text-destructive border-destructive/60":""}`,children:[(0,z.jsx)(tj.Cloud,{className:"size-3.5 mr-1.5"}),"Provider"]})]})}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${!a5?"hidden":"block"}`,children:[(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Vector Storage"}),(0,z.jsxs)("label",{className:"flex items-center gap-2 text-xs font-medium cursor-pointer bg-muted/20 px-2.5 py-1 rounded-md border",children:[(0,z.jsx)("input",{type:"checkbox",className:"shrink-0",checked:s,onChange:a=>t(a.target.checked)}),"Include Knowledge Base"]})]}),(0,z.jsxs)("div",{className:"space-y-3 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)(X.Select,{value:m,onValueChange:a=>{n(a),p(tJ(a)),r({}),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-50 bg-background",children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[tI[m]&&(0,z.jsx)(ah.ProviderIcon,{src:tI[m].iconSrc,alt:aZ.label,pillBg:tI[m].pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:aZ.label})]})}),(0,z.jsx)(X.SelectContent,{children:tn.VECTOR_STORE_LIST.map(a=>{let b=tI[a.id],c="coming-soon"===a.installStatus;return(0,z.jsx)(X.SelectItem,{value:a.id,disabled:c,children:(0,z.jsxs)("span",{className:"flex items-center gap-2.5",children:[b&&(0,z.jsx)(ah.ProviderIcon,{src:b.iconSrc,alt:a.label,pillBg:b.pillBg,size:16}),(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label}),c&&(0,z.jsx)("span",{className:"ml-2 text-[9px] text-muted-foreground border rounded-full px-1.5",children:"Soon"})]})},a.id)})})]}),(0,z.jsxs)(U.Button,{variant:w?"secondary":"outline",size:"sm",onClick:a_,disabled:u||a$,children:[u?(0,z.jsx)(Q.Loader2,{className:"size-3.5 mr-2 animate-spin"}):w?(0,z.jsx)(th,{className:"size-3.5 mr-2 text-emerald-500"}):(0,z.jsx)(ti,{className:"size-3.5 mr-2"}),w?"Verified":"Verify"]})]}),a$&&(0,z.jsx)("p",{className:"text-xs text-destructive",children:"You must select a cloud storage provider before deploying."}),(0,z.jsx)(to,{store:aZ,values:o,errors:q,indexType:l?.config.indexType,onChange:(a,b)=>{p(c=>({...c,[a]:b})),r(b=>({...b,[a]:""})),x(!1)}}),(0,z.jsxs)("div",{className:"pt-2 border-t mt-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold mb-3",children:"Embedding Model"}),(0,z.jsxs)(X.Select,{value:y,onValueChange:a=>{B(a||""),x(!1)},children:[(0,z.jsx)(X.SelectTrigger,{className:"w-full bg-white",children:(0,z.jsx)("span",{className:"font-medium text-sm",children:aY?.label??"Default"})}),(0,z.jsx)(X.SelectContent,{children:aX.map(a=>(0,z.jsx)(X.SelectItem,{value:a.id,children:(0,z.jsx)("span",{className:"font-medium text-sm",children:a.label})},a.id))})]})]})]})]}),(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsx)("h3",{className:"text-sm font-semibold tracking-tight",children:"Environment Variables"}),(0,z.jsxs)("div",{className:"grid gap-4 p-4 rounded-xl border bg-muted/10",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SERVER_API_KEY"," ",(0,z.jsx)("span",{className:"text-xs font-normal text-muted-foreground",children:"(Optional)"})]}),(0,z.jsxs)("div",{className:"flex gap-2",children:[(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ac?"text":"password",value:_,onChange:a=>ab(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ad(!ac),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",onClick:()=>{ab("larkup-"+Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15))},children:(0,z.jsx)(tg,{className:"size-4"})})]})]}),O.map(a=>(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:[a.key,a.required&&(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})," ",T[a.key]&&(0,z.jsx)("span",{className:"text-emerald-500 text-[10px] ml-2",children:"Pre-filled"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:ae[a.key]?"text":"password",value:T[a.key]||"",onChange:b=>Z({...T,[a.key]:b.target.value})}),(0,z.jsx)("button",{type:"button",onClick:()=>af(b=>({...b,[a.key]:!b[a.key]})),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]}),a.help&&(0,z.jsx)("p",{className:"text-xs text-muted-foreground",children:a.help})]},a.key))]})]})]}),(0,z.jsxs)("div",{className:`mt-5 space-y-8 ${a5?"hidden":"block"}`,children:["vercel"===c?(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{className:"flex justify-between w-full items-center",children:[(0,z.jsxs)("span",{children:["Vercel Token ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)("a",{href:"https://vercel.com/account/tokens",target:"_blank",rel:"noreferrer",className:"text-[10px] font-medium text-muted-foreground underline hover:text-foreground",children:"Get token"})]}),(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aq?"text":"password",value:am,onChange:a=>an(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>ar(!aq),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Project Name ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:ao,onChange:a=>ap(a.target.value)})]})]}):(0,z.jsxs)("div",{className:"space-y-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["Server IP / Hostname ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:au,onChange:a=>av(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)(W.Label,{children:["SSH Username ",(0,z.jsx)("span",{className:"text-destructive ml-1",children:"*"})]}),(0,z.jsx)(V.Input,{value:aw,onChange:a=>ax(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsxs)("div",{className:"flex gap-2 mb-2",children:[(0,z.jsx)(tl.Badge,{variant:"key"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("key"),children:"Private Key"}),(0,z.jsx)(tl.Badge,{variant:"password"===ay?"default":"outline",className:"cursor-pointer",onClick:()=>az("password"),children:"Password"})]}),"key"===ay?(0,z.jsx)("textarea",{className:"min-h-30 rounded-md border bg-transparent px-3 py-2 text-sm font-mono",value:aA,onChange:a=>aB(a.target.value)}):(0,z.jsxs)("div",{className:"relative flex-1",children:[(0,z.jsx)(V.Input,{type:aC?"text":"password",value:aA,onChange:a=>aB(a.target.value)}),(0,z.jsx)("button",{type:"button",onClick:()=>aD(!aC),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground",children:(0,z.jsx)(S.Eye,{className:"size-4"})})]})]})]}),aQ&&aE.length>0&&(0,z.jsx)("div",{className:"bg-black text-[#00ff00] font-mono text-[10px] p-3 rounded-md h-50 overflow-y-auto break-all whitespace-pre-wrap flex flex-col-reverse",children:(0,z.jsx)("div",{children:aE.map((a,b)=>(0,z.jsx)("div",{children:a},b))})})]}),L&&(0,z.jsxs)("div",{className:"mt-8 space-y-3 rounded-lg border p-5 bg-muted/10",children:[(0,z.jsxs)("div",{className:"flex justify-between text-sm font-medium",children:[(0,z.jsx)("span",{children:aV?.status==="completed"?"Knowledge base uploaded":"Uploading knowledge base"}),(0,z.jsxs)("span",{className:"tabular-nums",children:[aW,"%"]})]}),(0,z.jsx)(tm.Progress,{value:aW,className:"h-2"}),(0,z.jsx)("p",{className:"text-xs text-muted-foreground pt-1",children:aV?.warning||`${aV?.processedChunks??0} / ${aV?.totalChunks??0} chunks`})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 z-10 border-t bg-background px-6 py-4 flex items-center justify-between mt-auto",children:[(0,z.jsx)(U.Button,{variant:"outline",className:"px-5",onClick:()=>b(!1),disabled:aQ||L,children:"Cancel"}),(0,z.jsxs)(U.Button,{className:"px-7",onClick:a1,disabled:aQ||L,children:[(aQ||L)&&(0,z.jsx)(Q.Loader2,{className:"mr-2 size-4 animate-spin"}),"env"===c?"Save Settings":"Deploy"]})]})]})}),(0,z.jsx)(tk.Sheet,{open:aG,onOpenChange:a=>{a||(aS.current=null),aH(a)},children:(0,z.jsxs)(tk.SheetContent,{className:"flex flex-col h-full sm:max-w-md w-full overflow-y-auto p-0 border-l",children:[(0,z.jsx)("div",{className:"p-6 pb-0 space-y-1",children:(0,z.jsxs)(tk.SheetHeader,{className:"text-left",children:[(0,z.jsx)(tk.SheetTitle,{children:"Password Change Required"}),(0,z.jsx)(tk.SheetDescription,{children:"Your server requires a password change on first login."})]})}),(0,z.jsxs)("div",{className:"flex-1 p-6 overflow-y-auto grid gap-4",children:[(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"New Password"}),(0,z.jsx)(V.Input,{type:"password",value:aI,onChange:a=>aJ(a.target.value)})]}),(0,z.jsxs)("div",{className:"grid gap-2",children:[(0,z.jsx)(W.Label,{children:"Confirm Password"}),(0,z.jsx)(V.Input,{type:"password",value:aK,onChange:a=>aL(a.target.value)})]})]}),(0,z.jsxs)("div",{className:"sticky bottom-0 border-t bg-background px-6 py-4 flex justify-between",children:[(0,z.jsx)(U.Button,{variant:"outline",onClick:()=>aH(!1),children:"Cancel"}),(0,z.jsx)(U.Button,{onClick:a4,children:"Change & Deploy"})]})]})})]})}function tL({serverId:a="default",showUtilities:b=!0,compact:c=!1,openTarget:d,openSignal:e}){let[f,g]=(0,A.useState)(!1),[h,i]=(0,A.useState)(null),j=(0,A.useRef)(0),k=a=>{i(a),g(!0)},l=a=>{Y.toast.success(`Downloading deployment package for ${a}...`),window.open(`/api/server/download?provider=${a}`)};return(0,A.useEffect)(()=>{d&&e&&e!==j.current&&(j.current=e,k(d))},[e,d]),(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[b&&(0,z.jsx)(ac.TooltipProvider,{children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{delay:0,render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:`${c?"h-8 w-8":"h-9 w-9"} shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>k("env"),children:(0,z.jsx)(C.Settings2,{className:"size-4"})})}),(0,z.jsx)(ac.TooltipContent,{children:(0,z.jsx)("p",{children:"Environment Variables"})})]})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"default",size:"default",className:`${c?"h-8":"h-9"} w-32.5 justify-start gap-1 rounded-md`}),children:(0,z.jsxs)("div",{className:"w-full flex items-center h-8 justify-between rounded-lg",children:[(0,z.jsxs)("div",{className:"flex items-center",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 mr-2"}),"Deploy"]}),(0,z.jsx)(tf.ChevronDown,{})]})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-50",children:[(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("vercel"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/vercel.svg",className:"size-4 mr-2",alt:"Vercel"}),"Vercel"]})}),(0,z.jsx)(aE.DropdownMenuItem,{onClick:()=>k("hetzner"),children:(0,z.jsxs)("p",{className:"flex items-center",children:[(0,z.jsx)("img",{src:"/hetzner.svg",className:"size-4 mr-2",alt:"Hetzner"}),"Hetzner"]})}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/azure.svg",className:"size-4 mr-2",alt:"Azure"}),"Azure"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-app-service"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Service"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("azure-container-apps"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Container Apps"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("azure"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Virtual Machines"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/aws.svg",className:"size-4 mr-2",alt:"AWS"}),"AWS"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-elastic-beanstalk"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Elastic Beanstalk"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("aws-app-runner"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Runner / Fargate"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("aws"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"EC2"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/gcp.svg",className:"size-4 mr-2",alt:"GCP"}),"GCP"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-app-engine"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("gcp-cloud-run"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Cloud Run"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Serverless containers"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("gcp"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Compute Engine"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]}),(0,z.jsxs)(aE.DropdownMenuSub,{children:[(0,z.jsxs)(aE.DropdownMenuSubTrigger,{children:[(0,z.jsx)("img",{src:"/icons/digital-ocean.webp",className:"size-4 mr-2",alt:"DigitalOcean"}),"DigitalOcean"]}),(0,z.jsxs)(aE.DropdownMenuSubContent,{className:"w-60",children:[(0,z.jsx)(aE.DropdownMenuItem,{disabled:!0,className:"h-auto",onClick:()=>l("digitalocean-app-platform"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"App Platform"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Managed PaaS"})]})}),(0,z.jsx)(aE.DropdownMenuItem,{className:"h-auto",onClick:()=>k("digitalocean"),children:(0,z.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,z.jsx)("span",{children:"Droplets"}),(0,z.jsx)("span",{className:"text-[10px] text-muted-foreground",children:"Full IaaS"})]})})]})]})]})]}),(0,z.jsx)(tK,{open:f,onOpenChange:g,target:h,serverId:a})]})}let tM=(0,tp.createServerReference)("60ea4ad1fe472ddb6bec9ab5b1a25f7b1c6808aab8",tp.callServer,void 0,tp.findSourceMapURL,"getVercelDeploymentStatus"),tN=a=>fetch(a).then(a=>a.json());function tO(a){return a.replace(/\/$/,"")}function tP(a){return`${tO(a)}/reference`}function tQ({url:a,project:b,compact:c=!1}){return(0,z.jsxs)("a",{href:tP(a),target:"_blank",rel:"noreferrer","aria-label":`Open API reference for ${b}`,className:(0,M.cn)((0,U.buttonVariants)({variant:c?"ghost":"outline",size:c?"icon":"sm"}),c?"size-8 sm:hidden":"hidden h-8 gap-1.5 px-2 text-xs sm:inline-flex"),children:[(0,z.jsx)(ar.ExternalLink,{className:c?"size-4":"size-3"}),!c&&"API reference"]})}function tR(){let{activeServer:a,refresh:b}=(0,$.useWorkspace)(),c=a?.id||"default",[d,e]=(0,A.useState)(null),[f,g]=(0,A.useState)(""),[h,i]=(0,A.useState)(!1),[j,k]=(0,A.useState)(null),[l,m]=(0,A.useState)(!1),[n,o]=(0,A.useState)(0),[p,q]=(0,A.useState)(!1),[r,s]=(0,A.useState)([]),[t,u]=(0,A.useState)(null),[v,w]=(0,A.useState)(""),[x,y]=(0,A.useState)(null),[B,C]=(0,A.useState)(!1),[D,E]=(0,A.useState)(0),F=(0,A.useRef)(new Set);(0,A.useEffect)(()=>{let a=localStorage.getItem("rag_server_api_key");a&&g(a),o(tv(c)),s(tx(c)),F.current.clear()},[c]),(0,A.useEffect)(()=>{let a=localStorage.getItem("vercel_token"),b=r.filter(a=>"vercel"===a.provider);if(!a||0===b.length)return;let d=b.filter(a=>"queued"===a.status||"building"===a.status||"ready"===a.status&&!F.current.has(a.id));if(0===d.length)return;let e=!1,f=async()=>{let b=await Promise.all(d.map(async b=>({deployment:b,result:await tM(a,b.project)})));if(!e)for(let{deployment:a,result:d}of b){"ready"===d.status&&F.current.add(a.id);let b=d.hasProductionAlias?d.url:void 0;"unknown"!==d.status&&(a.status!==d.status||b&&a.url!==b)&&s(tA(c,a.id,{status:d.status,url:b}))}};f();let g=d.some(a=>"queued"===a.status||"building"===a.status)?window.setInterval(()=>void f(),8e3):void 0;return()=>{e=!0,g&&window.clearInterval(g)}},[r,c]),(0,A.useEffect)(()=>{let a=a=>{a.detail===c&&(s(tx(c)),o(tv(c)))};return window.addEventListener("larkup-deployments-change",a),()=>window.removeEventListener("larkup-deployments-change",a)},[c]);let{data:G,mutate:H}=(0,P.default)("/api/server/local",tN,{refreshInterval:a=>5e3*!!a?.state.running}),I=G?.state;async function J(a){e(a);let d="start"===a;H({state:{...I,running:d}},!1),(0,ao.mutate)("/api/servers",a=>a?{...a,servers:a.servers.map(a=>a.id===c?{...a,running:d}:a)}:a,!1);try{let c=localStorage.getItem("rag_server_api_key")||"",d=await fetch("/api/server/local",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a,serverApiKey:c})}),e=await d.json();"start"===a?e.state?.running?Y.toast.success("Server is running."):(Y.toast.error(e.state?.lastError??"Server did not start."),(0,ao.mutate)("/api/servers")):Y.toast.success("Server stopped."),H(),b()}catch{Y.toast.error("Could not reach the server controller."),(0,ao.mutate)("/api/servers"),H()}finally{e(null)}}function K(a){let b=localStorage.getItem("rag_server_api_key")||"";g(a),localStorage.setItem("rag_server_api_key",a),a!==b&&o(tw(c))}function L(a){return r.length>0&&a!==(localStorage.getItem("rag_server_api_key")||"")?(y(a),C(!0),!1):(K(a),!0)}function N(a){if(null!==x&&K(x),y(null),C(!1),a){E(a=>a+1),Y.toast.info("New API key saved. Configure the Vercel redeploy to sync it remotely.");return}Y.toast.info("API key updated locally. Redeploy cloud servers when you are ready to sync it.")}async function O(){await navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),1500)}async function R(a){f?(await navigator.clipboard.writeText(f),k(a),setTimeout(()=>k(null),1500),Y.toast.success("Cloud API key copied")):Y.toast.error("Generate or enter an API key before copying it.")}async function W(){I?.endpoint&&(await navigator.clipboard.writeText(I.endpoint),m(!0),setTimeout(()=>m(!1),1500))}return(0,z.jsxs)("main",{className:"mx-auto w-full max-w-5xl px-6 ",children:[(0,z.jsxs)("header",{className:"mb-12",children:[(0,z.jsx)("h2",{className:"text-lg font-semibold tracking-tight",children:"Server"}),(0,z.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Test locally, then deploy one retrieval and chat server anywhere."})]}),(0,z.jsxs)("section",{className:"mb-14",children:[(0,z.jsxs)("div",{className:"flex items-center justify-between",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(as,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Local server"})]}),(0,z.jsxs)("span",{className:"flex items-center gap-2 text-xs",children:[I?.running?(0,z.jsxs)("span",{className:"relative flex size-2",children:[(0,z.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,z.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}):(0,z.jsx)("span",{className:"size-1.5 rounded-full bg-muted-foreground/40"}),(0,z.jsx)("span",{className:I?.running?"font-medium text-emerald-600 dark:text-emerald-400":"text-muted-foreground",children:I?.running?`running on :${I.port}`:"stopped"})]})]}),(0,z.jsx)("p",{className:"mt-2 max-w-xl text-sm text-muted-foreground",children:"Start the server locally to test your AI endpoints. Your configuration and API keys are applied automatically."}),I?.lastError&&!I.running&&(0,z.jsxs)(aF.Alert,{variant:"destructive",children:[(0,z.jsx)(aF.AlertTitle,{children:"Launch failed"}),(0,z.jsx)(aF.AlertDescription,{className:"wrap-break-word",children:I.lastError})]}),I?.running?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border border-border",children:[(0,z.jsxs)("button",{type:"button",onClick:W,className:"flex w-full items-center justify-between gap-3 border-b border-border bg-muted/30 px-4 py-3 text-left",children:[(0,z.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5 font-mono text-sm",children:[(0,z.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md border bg-background text-muted-foreground",children:(0,z.jsx)(at.Copy,{className:"size-3.5"})}),(0,z.jsx)("span",{className:"truncate",children:I.endpoint})]}),(0,z.jsx)("span",{className:"shrink-0 text-xs text-muted-foreground",children:l?"Copied":"Click to copy"})]}),(0,z.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-4 py-3",children:[(0,z.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,z.jsx)(te,{serverUrl:I.endpoint}),(0,z.jsxs)(aG.Dialog,{children:[(0,z.jsxs)(aG.DialogTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"sm",className:"h-8 text-xs px-2 gap-1.5"}),children:[(0,z.jsx)(as,{className:"size-3"}),"Try it (cURL)"]}),(0,z.jsxs)(aG.DialogContent,{className:"max-w-2xl!",children:[(0,z.jsxs)(aG.DialogHeader,{children:[(0,z.jsx)(aG.DialogTitle,{children:"cURL Example"}),(0,z.jsx)(aG.DialogDescription,{children:"You can use this command to test your RAG server endpoint."})]}),(0,z.jsxs)("div",{className:"relative rounded-md bg-muted p-4 mt-2 border border-border/50",children:[(0,z.jsx)("pre",{className:"font-mono text-xs overflow-x-auto text-foreground pb-4 pr-6",children:(0,z.jsx)("code",{children:`curl -X POST ${I.endpoint}/query \\
|
|
60
60
|
-H "Content-Type: application/json" \\${f?`
|
|
61
61
|
-H "Authorization: Bearer ${f}" \\`:""}
|
|
62
|
-
-d '{"query":"hello"}'`})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>{navigator.clipboard.writeText(`curl -X POST ${I.endpoint}/query -H "Content-Type: application/json"${f?` -H "Authorization: Bearer ${f}"`:""} -d '{"query":"hello"}'`),Y.toast.success("Command copied")},children:(0,z.jsx)(at.Copy,{className:"size-3"})})]})]})]}),(0,z.jsxs)("a",{href:tP(I.endpoint),target:"_blank",rel:"noreferrer",className:(0,M.cn)((0,U.buttonVariants)({variant:"outline",size:"sm"}),"h-8 gap-1.5 text-xs"),children:[(0,z.jsx)(ar.ExternalLink,{className:"size-3"}),"API reference"]})]}),(0,z.jsxs)(U.Button,{size:"sm",variant:"destructive",onClick:()=>J("stop"),disabled:null!==d,children:["stop"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(aq.Square,{className:"size-4"}),"Stop server"]})]})]}):(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsxs)(U.Button,{size:"sm",onClick:()=>J("start"),disabled:null!==d,children:["start"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(ap.Play,{className:"size-4"}),"start"===d?"Starting…":"Launch server"]}),(0,z.jsx)(te,{serverUrl:I?.endpoint||"http://localhost:8080",disabled:!0})]})]}),(0,z.jsxs)("div",{className:"grid gap-14 border-t border-border pt-12 md:grid-cols-2 md:gap-10",children:[(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Deploy to cloud"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Deploy your AI server to Vercel for production use."}),(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsx)(tL,{serverId:c,showUtilities:!0,compact:!0,openTarget:"vercel",openSignal:D}),(0,z.jsxs)(U.Button,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:O,children:[h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"}),"Copy API key"]})]})]}),(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ay,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Server API key"})]}),(0,z.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["Clients must send this key in the"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"Authorization"})," ","header."]}),(0,z.jsxs)("div",{className:"mt-5 flex items-center gap-2",children:[(0,z.jsx)(V.Input,{type:p?"text":"password",value:f,onChange:a=>g(a.target.value),onBlur:()=>L(f),placeholder:"sk-...",className:"h-8 flex-1 font-mono text-xs"}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>q(a=>!a),children:p?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:O,disabled:!f,children:h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:function(){L("sk-"+Array.from(crypto.getRandomValues(new Uint8Array(24))).map(a=>a.toString(16).padStart(2,"0")).join(""))&&Y.toast.success("API key generated")},"aria-label":"Generate a new API key"}),children:(0,z.jsx)(av.RefreshCw,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:"Generate a new API key"})]})})]}),(0,z.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Stored locally in your browser. Generate a new key or paste your own."})]})]}),(0,z.jsxs)("section",{className:"mt-14 border-t border-border pt-10",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aB.Globe,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Cloud deployments"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Each deployment exposes its API endpoint and interactive API reference."}),r.length>0?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border",children:[(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b bg-muted/30 px-4 py-2 text-xs text-muted-foreground sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsx)("span",{className:"hidden sm:block",children:"Provider"}),(0,z.jsx)("span",{children:"API endpoint"}),(0,z.jsx)("span",{className:"hidden sm:block",children:"Reference"}),(0,z.jsx)("span",{children:"Actions"})]}),r.map(a=>(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b bg-background px-4 py-3 last:border-b-0 sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsxs)("span",{className:"hidden items-center gap-2 text-sm font-medium sm:flex",children:["vercel"===a.provider?(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-3.5"}):(0,z.jsx)(aB.Globe,{className:"size-3.5"}),a.provider,a.status&&(0,z.jsx)("span",{className:(0,M.cn)("rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium capitalize","ready"===a.status&&"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400","error"===a.status&&"bg-background text-foreground",("building"===a.status||"queued"===a.status)&&"border-orange-500/20 bg-orange-500/10 text-orange-700 dark:text-orange-400"),children:a.status}),(a.apiKeyVersion??0)!==n&&(0,z.jsx)("span",{className:"rounded-sm border border-orange-500/20 bg-orange-500/10 px-1.5 py-0.5 text-[10px] font-medium text-orange-700 dark:text-orange-400",children:"Key redeploy required"})]}),t===a.id?(0,z.jsx)(V.Input,{value:v,onChange:a=>w(a.target.value),className:"h-8 font-mono text-xs","aria-label":"Deployment URL"}):(0,z.jsx)("a",{href:tt(a),target:"_blank",rel:"noreferrer",className:"truncate font-mono text-xs hover:underline",children:tO(tt(a)).replace(/^https?:\/\//,"")}),(0,z.jsx)(tQ,{url:tt(a),project:a.project}),(0,z.jsx)("div",{className:"flex items-center gap-1",children:t===a.id?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{try{var b;let d=new URL(v).toString();s((b=a.id,tA(c,b,{url:d}))),u(null)}catch{Y.toast.error("Enter a valid deployment URL.")}},"aria-label":"Save deployment URL",children:(0,z.jsx)(au.CheckCircle2,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>u(null),"aria-label":"Cancel editing deployment URL",children:(0,z.jsx)(aA.X,{className:"size-4"})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>R(a.id),disabled:!f,"aria-label":"Copy cloud API key"}),children:j===a.id?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:j===a.id?"Cloud API key copied":(a.apiKeyVersion??0)===n?"Copy cloud API key":"Copy local key — redeploy to apply it"})]})}),(0,z.jsx)(tQ,{url:tt(a),project:a.project,compact:!0}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{u(a.id),w(tt(a))},"aria-label":"Edit deployment URL",children:(0,z.jsx)(az.Pencil,{className:"size-4"})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",children:(0,z.jsx)(aD,{className:"size-4"})})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-37.5",children:["vercel"===a.provider&&(0,z.jsxs)(aE.DropdownMenuItem,{onClick:()=>{let b=a.url.replace(/^https?:\/\//,"");window.open(`https://${b}/_logs`,"_blank")},children:[(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-4 mr-2 dark:invert"}),"View in Vercel"]}),(0,z.jsxs)(aE.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>{var b;let d;return s((b=a.id,d=tx(c).filter(a=>a.id!==b),ty(c,d),d))},children:[(0,z.jsx)(aw.Trash2,{className:"size-4 mr-2"}),"Delete"]})]})]})]})})]},a.id))]}):(0,z.jsxs)("div",{className:"flex flex-col border border-border rounded-md items-center px-4 py-6 justify-center gap-2 mt-5",children:[(0,z.jsx)("div",{className:"bg-white p-1 border border-border rounded-md",children:(0,z.jsx)(aC.default,{className:"size-5"})}),(0,z.jsx)("p",{className:" rounded-lg text-sm text-muted-foreground text-center mx-auto",children:"No cloud deployments yet. Deploy to a provider above to add one here."})]})]}),(0,z.jsx)(aH.AlertDialog,{open:B,onOpenChange:C,children:(0,z.jsxs)(aH.AlertDialogContent,{className:"max-w-xl! w-full!",children:[(0,z.jsxs)(aH.AlertDialogHeader,{children:[(0,z.jsx)(aH.AlertDialogTitle,{children:"Deploy this new API key?"}),(0,z.jsx)(aH.AlertDialogDescription,{children:"Existing cloud deployments keep their current key until you redeploy them. Choose whether to update locally only, or open a Vercel redeploy with this new key so your local and remote API keys stay in sync."})]}),(0,z.jsxs)(aH.AlertDialogFooter,{className:"mt-3",children:[(0,z.jsx)(aH.AlertDialogCancel,{className:"mr-auto",size:"sm",onClick:()=>{g(localStorage.getItem("rag_server_api_key")||""),y(null)},children:"Cancel"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Update locally only"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",onClick:()=>N(!0),children:"Update & deploy to Vercel"})]})]})})]})}let tS=(0,G.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);var tT=a.i(733105);new Date(0).toISOString();let tU=`You are a powerful data analysis assistant with access to a knowledge base, corpus introspection tools, tabular data tools, and a code sandbox.
|
|
62
|
+
-d '{"query":"hello"}'`})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"absolute top-2 right-2 h-6 w-6 text-muted-foreground hover:text-foreground",onClick:()=>{navigator.clipboard.writeText(`curl -X POST ${I.endpoint}/query -H "Content-Type: application/json"${f?` -H "Authorization: Bearer ${f}"`:""} -d '{"query":"hello"}'`),Y.toast.success("Command copied")},children:(0,z.jsx)(at.Copy,{className:"size-3"})})]})]})]}),(0,z.jsxs)(U.Button,{variant:"outline",size:"sm",disabled:"start"===d||!I.running,render:(0,z.jsx)("a",{href:tP(I.endpoint),target:"_blank",rel:"noreferrer"}),className:"h-8 gap-1.5 text-xs",children:[(0,z.jsx)(ar.ExternalLink,{className:"size-3"}),"API reference"]})]}),(0,z.jsxs)(U.Button,{size:"sm",variant:"destructive",onClick:()=>J("stop"),disabled:null!==d,children:["stop"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(aq.Square,{className:"size-4"}),"Stop server"]})]})]}):(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsxs)(U.Button,{size:"sm",onClick:()=>J("start"),disabled:null!==d,children:["start"===d?(0,z.jsx)(Q.Loader2,{className:"size-4 animate-spin"}):(0,z.jsx)(ap.Play,{className:"size-4"}),"start"===d?"Starting…":"Launch server"]}),(0,z.jsx)(te,{serverUrl:I?.endpoint||"http://localhost:8080",disabled:!0})]})]}),(0,z.jsxs)("div",{className:"grid gap-14 border-t border-border pt-12 md:grid-cols-2 md:gap-10",children:[(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ax.Rocket,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Deploy to cloud"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Deploy your AI server to Vercel for production use."}),(0,z.jsxs)("div",{className:"mt-5 flex flex-wrap gap-2",children:[(0,z.jsx)(tL,{serverId:c,showUtilities:!0,compact:!0,openTarget:"vercel",openSignal:D}),(0,z.jsxs)(U.Button,{variant:"outline",size:"sm",className:"h-8 gap-2",onClick:O,children:[h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"}),"Copy API key"]})]})]}),(0,z.jsxs)("section",{children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(ay,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Server API key"})]}),(0,z.jsxs)("p",{className:"mt-2 text-sm text-muted-foreground",children:["Clients must send this key in the"," ",(0,z.jsx)("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground",children:"Authorization"})," ","header."]}),(0,z.jsxs)("div",{className:"mt-5 flex items-center gap-2",children:[(0,z.jsx)(V.Input,{type:p?"text":"password",value:f,onChange:a=>g(a.target.value),onBlur:()=>L(f),placeholder:"sk-...",className:"h-8 flex-1 font-mono text-xs"}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:()=>q(a=>!a),children:p?(0,z.jsx)(T.EyeOff,{className:"size-4"}):(0,z.jsx)(S.Eye,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:O,disabled:!f,children:h?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"outline",size:"icon",className:"size-8",onClick:function(){L("sk-"+Array.from(crypto.getRandomValues(new Uint8Array(24))).map(a=>a.toString(16).padStart(2,"0")).join(""))&&Y.toast.success("API key generated")},"aria-label":"Generate a new API key"}),children:(0,z.jsx)(av.RefreshCw,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:"Generate a new API key"})]})})]}),(0,z.jsx)("p",{className:"mt-2 text-xs text-muted-foreground",children:"Stored locally in your browser. Generate a new key or paste your own."})]})]}),(0,z.jsxs)("section",{className:"mt-14 border-t border-border pt-10",children:[(0,z.jsxs)("div",{className:"flex items-center gap-2",children:[(0,z.jsx)(aB.Globe,{className:"size-4 text-muted-foreground"}),(0,z.jsx)("h3",{className:"text-sm font-medium",children:"Cloud deployments"})]}),(0,z.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Each deployment exposes its API endpoint and interactive API reference."}),r.length>0?(0,z.jsxs)("div",{className:"mt-5 overflow-hidden rounded-lg border",children:[(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b bg-muted/30 px-4 py-2 text-xs text-muted-foreground sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsx)("span",{className:"hidden sm:block",children:"Provider"}),(0,z.jsx)("span",{children:"API endpoint"}),(0,z.jsx)("span",{className:"hidden sm:block",children:"Reference"}),(0,z.jsx)("span",{children:"Actions"})]}),r.map(a=>(0,z.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b bg-background px-4 py-3 last:border-b-0 sm:grid-cols-[140px_minmax(0,1fr)_auto_auto]",children:[(0,z.jsxs)("span",{className:"hidden items-center gap-2 text-sm font-medium sm:flex",children:["vercel"===a.provider?(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-3.5"}):(0,z.jsx)(aB.Globe,{className:"size-3.5"}),a.provider,a.status&&(0,z.jsx)("span",{className:(0,M.cn)("rounded-full border border-border px-1.5 py-0.5 text-[10px] font-medium capitalize","ready"===a.status&&"border-green-500/20 bg-green-500/10 text-green-700 dark:text-green-400","error"===a.status&&"bg-background text-foreground",("building"===a.status||"queued"===a.status)&&"border-orange-500/20 bg-orange-500/10 text-orange-700 dark:text-orange-400"),children:a.status}),(a.apiKeyVersion??0)!==n&&(0,z.jsx)("span",{className:"rounded-sm border border-orange-500/20 bg-orange-500/10 px-1.5 py-0.5 text-[10px] font-medium text-orange-700 dark:text-orange-400",children:"Key redeploy required"})]}),t===a.id?(0,z.jsx)(V.Input,{value:v,onChange:a=>w(a.target.value),className:"h-8 font-mono text-xs","aria-label":"Deployment URL"}):(0,z.jsx)("a",{href:tt(a),target:"_blank",rel:"noreferrer",className:"truncate font-mono text-xs hover:underline",children:tO(tt(a)).replace(/^https?:\/\//,"")}),(0,z.jsx)(tQ,{url:tt(a),project:a.project}),(0,z.jsx)("div",{className:"flex items-center gap-1",children:t===a.id?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{try{var b;let d=new URL(v).toString();s((b=a.id,tA(c,b,{url:d}))),u(null)}catch{Y.toast.error("Enter a valid deployment URL.")}},"aria-label":"Save deployment URL",children:(0,z.jsx)(au.CheckCircle2,{className:"size-4"})}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>u(null),"aria-label":"Cancel editing deployment URL",children:(0,z.jsx)(aA.X,{className:"size-4"})})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(ac.TooltipProvider,{delay:200,children:(0,z.jsxs)(ac.Tooltip,{children:[(0,z.jsx)(ac.TooltipTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>R(a.id),disabled:!f,"aria-label":"Copy cloud API key"}),children:j===a.id?(0,z.jsx)(au.CheckCircle2,{className:"size-4 text-emerald-500"}):(0,z.jsx)(at.Copy,{className:"size-4"})}),(0,z.jsx)(ac.TooltipContent,{children:j===a.id?"Cloud API key copied":(a.apiKeyVersion??0)===n?"Copy cloud API key":"Copy local key — redeploy to apply it"})]})}),(0,z.jsx)(tQ,{url:tt(a),project:a.project,compact:!0}),(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",onClick:()=>{u(a.id),w(tt(a))},"aria-label":"Edit deployment URL",children:(0,z.jsx)(az.Pencil,{className:"size-4"})}),(0,z.jsxs)(aE.DropdownMenu,{children:[(0,z.jsx)(aE.DropdownMenuTrigger,{render:(0,z.jsx)(U.Button,{variant:"ghost",size:"icon",className:"size-8",children:(0,z.jsx)(aD,{className:"size-4"})})}),(0,z.jsxs)(aE.DropdownMenuContent,{align:"end",className:"w-37.5",children:["vercel"===a.provider&&(0,z.jsxs)(aE.DropdownMenuItem,{onClick:()=>{let b=a.url.replace(/^https?:\/\//,"");window.open(`https://${b}/_logs`,"_blank")},children:[(0,z.jsx)("img",{src:"/vercel.svg",alt:"Vercel",className:"size-4 mr-2 dark:invert"}),"View in Vercel"]}),(0,z.jsxs)(aE.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>{var b;let d;return s((b=a.id,d=tx(c).filter(a=>a.id!==b),ty(c,d),d))},children:[(0,z.jsx)(aw.Trash2,{className:"size-4 mr-2"}),"Delete"]})]})]})]})})]},a.id))]}):(0,z.jsxs)("div",{className:"flex flex-col border border-border rounded-md items-center px-4 py-6 justify-center gap-2 mt-5",children:[(0,z.jsx)("div",{className:"bg-white p-1 border border-border rounded-md",children:(0,z.jsx)(aC.default,{className:"size-5"})}),(0,z.jsx)("p",{className:" rounded-lg text-sm text-muted-foreground text-center mx-auto",children:"No cloud deployments yet. Deploy to a provider above to add one here."})]})]}),(0,z.jsx)(aH.AlertDialog,{open:B,onOpenChange:C,children:(0,z.jsxs)(aH.AlertDialogContent,{className:"max-w-xl! w-full!",children:[(0,z.jsxs)(aH.AlertDialogHeader,{children:[(0,z.jsx)(aH.AlertDialogTitle,{children:"Deploy this new API key?"}),(0,z.jsx)(aH.AlertDialogDescription,{children:"Existing cloud deployments keep their current key until you redeploy them. Choose whether to update locally only, or open a Vercel redeploy with this new key so your local and remote API keys stay in sync."})]}),(0,z.jsxs)(aH.AlertDialogFooter,{className:"mt-3",children:[(0,z.jsx)(aH.AlertDialogCancel,{className:"mr-auto",size:"sm",onClick:()=>{g(localStorage.getItem("rag_server_api_key")||""),y(null)},children:"Cancel"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",variant:"ghost",onClick:()=>N(!1),children:"Update locally only"}),(0,z.jsx)(aH.AlertDialogAction,{size:"sm",onClick:()=>N(!0),children:"Update & deploy to Vercel"})]})]})})]})}let tS=(0,G.default)("maximize",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]);var tT=a.i(733105);new Date(0).toISOString();let tU=`You are a powerful data analysis assistant with access to a knowledge base, corpus introspection tools, tabular data tools, and a code sandbox.
|
|
63
63
|
|
|
64
64
|
You have these tools:
|
|
65
65
|
1. "searchKnowledgeBase" — semantic search over the RAG knowledge base. Returns top-K most relevant document chunks.
|
|
@@ -95,7 +95,9 @@ CRITICAL RULES FOR CHARTS AND VISUALIZATIONS:
|
|
|
95
95
|
- The UI renders generateVisualization output as an interactive Recharts chart.
|
|
96
96
|
|
|
97
97
|
CRITICAL RULES FOR IMAGES AND KNOWLEDGE BASE:
|
|
98
|
-
-
|
|
98
|
+
- Never emit Markdown image syntax () or invent an image URL. The chat renderer does not trust model-supplied image URLs.
|
|
99
|
+
- To show an indexed image, use presentMedia with the exact mediaAssetId returned by search results. The UI will render the verified local media citation for you.
|
|
100
|
+
- If no exact mediaAssetId is available, describe the image in text and say that a preview is unavailable; do not fabricate or link to an image.
|
|
99
101
|
- The image description in the search results is only a brief, high-level summary.
|
|
100
102
|
- If the user asks a detailed or structural question about an image (e.g., "what columns are in the film table in the diagram?", "how many items are listed?"), you MUST use the "analyzeImageDeeply" tool. Pass the 'imageUrl' and a detailed prompt to get the exact information you need directly from the image before answering.
|
|
101
103
|
- Do not hallucinate or guess details about images. If the high-level summary doesn't contain the answer, use analyzeImageDeeply.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[825358,a=>{"use strict";var b=a.i(887556),c=a.i(865769);function d(a){return RegExp(`/${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=[/?#]|$)`)}function e(a){return(0,b.useEffect)(()=>{var b;a.beforeSend&&(null==(b=window.va)||b.call(window,"beforeSend",a.beforeSend))},[a.beforeSend]),(0,b.useEffect)(()=>{!function(a={debug:!0},b){}({framework:a.framework||"react",basePath:a.basePath??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}(),...void 0!==a.route&&{disableAutoTrack:!0},...a},a.configString??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}())},[]),(0,b.useEffect)(()=>{a.route&&a.path&&function({route:a,path:b}){var c;null==(c=window.va)||c.call(window,"pageview",{route:a,path:b})}({route:a.route,path:a.path})},[a.route,a.path]),null}function f(a){let f,g,h,{route:i,path:j}=(f=(0,c.useParams)(),g=(0,c.useSearchParams)(),h=(0,c.usePathname)(),f?{route:function(a,b){if(!a||!b)return a;let c=a;try{let a=Object.entries(b);for(let[b,e]of a)if(!Array.isArray(e)){let a=d(e);a.test(c)&&(c=c.replace(a,`/[${b}]`))}for(let[b,e]of a)if(Array.isArray(e)){let a=d(e.join("/"));a.test(c)&&(c=c.replace(a,`/[...${b}]`))}return c}catch{return a}}(h,Object.keys(f).length?f:Object.fromEntries(g.entries())),path:h}:{route:null,path:h});return b.default.createElement(e,{path:j,route:i,...a,basePath:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH}(),configString:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_CLIENT_CONFIG}(),framework:"next"})}a.s(["Analytics",0,function(a){return b.default.createElement(b.Suspense,{fallback:null},b.default.createElement(f,{...a}))}])},554502,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=(a,b,c,d,e,f,g,h)=>{let i=document.documentElement,j=["light","dark"];function k(b){var c;(Array.isArray(a)?a:[a]).forEach(a=>{let c="class"===a,d=c&&f?e.map(a=>f[a]||a):e;c?(i.classList.remove(...d),i.classList.add(f&&f[b]?f[b]:b)):i.setAttribute(a,b)}),c=b,h&&j.includes(c)&&(i.style.colorScheme=c)}if(d)k(d);else try{let a=localStorage.getItem(b)||c,d=g&&"system"===a?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;k(d)}catch(a){}},e=c.createContext(void 0),f={setTheme:a=>{},themes:[]};c.memo(({forcedTheme:a,storageKey:b,attribute:e,enableSystem:f,enableColorScheme:g,defaultTheme:h,value:i,themes:j,nonce:k,scriptProps:l})=>{let m=JSON.stringify([e,b,h,a,j,i,f,g]).slice(1,-1);return c.createElement("script",{...l,suppressHydrationWarning:!0,nonce:k,dangerouslySetInnerHTML:{__html:`(${d.toString()})(${m})`}})});var g=a.i(635153),h=a.i(689958),h=h,i=a.i(859416),i=i,j=a.i(583142),j=j,k=a.i(318467),k=k,l=a.i(49656),l=l;a.s(["Toaster",0,({...a})=>{var d;let{theme:m="system"}=null!=(d=c.useContext(e))?d:f;return(0,b.jsx)(g.Toaster,{closeButton:!0,theme:m,className:"toaster group z-9999999! ",icons:{success:(0,b.jsx)(h.default,{className:"size-5 text-white",fill:"#10b981"}),info:(0,b.jsx)(i.default,{className:"size-5 text-white",fill:"#3b82f6"}),warning:(0,b.jsx)(j.default,{className:"size-5 text-white",fill:"#f59e0b"}),error:(0,b.jsx)(k.default,{className:"size-5 text-white",fill:"#ef4444"}),loading:(0,b.jsx)(l.default,{className:"size-5 animate-spin text-muted-foreground"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)",zIndex:999999},toastOptions:{classNames:{toast:"group toast items-start group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900 group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:",icon:"mt-0.5",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",success:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",error:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",warning:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",info:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900"}},...a})}],554502)},881150,a=>{"use strict";var b=a.i(360809),c=a.i(295805),d=a.i(887556),e=a.i(349839),f=a.i(865769),g=a.i(610520),h=a.i(486903),i=a.i(566005),j=a.i(326729);let k=(0,j.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var l=a.i(816995),m=a.i(371629),n=a.i(74192),o=a.i(599335),p=a.i(567087);let q=(0,j.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var r=a.i(25791),s=a.i(446338),t=a.i(895839),u=a.i(94842),v=a.i(161859),w=a.i(7812),x=a.i(635153),y=a.i(93718),z=a.i(541487),A=a.i(343578);function B({target:a,open:c,onOpenChange:e}){let{deleteServer:f}=(0,v.useWorkspace)(),[g,h]=(0,d.useState)(!1);async function i(){if(a){h(!0);try{await f(a.id),x.toast.success(`Deleted "${a.name}".`),e(!1)}catch{x.toast.error("Could not delete the server.")}finally{h(!1)}}}return(0,b.jsx)(A.Dialog,{open:c,onOpenChange:e,children:(0,b.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Delete “",a?.name,"”?"]}),(0,b.jsx)(A.DialogDescription,{children:"This permanently removes the server's documents, index, vector data, and generated files. This cannot be undone."})]}),(0,b.jsxs)(A.DialogFooter,{children:[(0,b.jsx)(z.Button,{variant:"outline",onClick:()=>e(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(z.Button,{variant:"destructive",onClick:()=>void i(),disabled:g,children:[g&&(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}),"Delete server"]})]})]})})}function C(){let{servers:a,activeServer:c,activateServer:e}=(0,v.useWorkspace)(),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(u.DropdownMenu,{children:[(0,b.jsxs)(u.DropdownMenuTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary/12 text-primary",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsx)("span",{className:"flex min-w-0 flex-1 flex-col",children:(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:c?.name??"No server"}),c?.running&&(0,b.jsx)(D,{})]})}),(0,b.jsx)(q,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,b.jsxs)(u.DropdownMenuContent,{align:"start",sideOffset:6,className:"w-(--anchor-width) min-w-[260px]",children:[(0,b.jsxs)(u.DropdownMenuGroup,{children:[(0,b.jsx)(u.DropdownMenuLabel,{children:"Your servers"}),a.map(a=>{let d=a.id===c?.id;return(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>{d||e(a.id)},className:"gap-2",children:[(0,b.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,b.jsxs)("span",{className:"flex items-center gap-2 text-[11px] text-muted-foreground tabular-nums",children:[(0,b.jsxs)("span",{children:[a.docCount," docs"]}),a.indexed&&(0,b.jsx)("span",{children:"· indexed"}),a.running&&(0,b.jsxs)("span",{className:"flex items-center gap-1 text-green-500",children:[(0,b.jsx)(D,{}),"live"]})]})]}),d&&(0,b.jsx)(p.Check,{className:"size-4 shrink-0 text-primary"})]},a.id)})]}),(0,b.jsx)(u.DropdownMenuSeparator,{}),(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>g(!0),className:"gap-2 h-9",children:[(0,b.jsx)(s.Plus,{className:"size-4"}),"New server"]}),c&&(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>i(c),className:"gap-2 h-9",children:[(0,b.jsx)(r.Pencil,{className:"size-4"}),"Rename current"]}),c&&a.length>1&&(0,b.jsxs)(u.DropdownMenuItem,{variant:"destructive",onClick:()=>k(c),className:"gap-2",children:[(0,b.jsx)(t.Trash2,{className:"size-4"}),"Delete current"]})]})]}),(0,b.jsx)(w.ServerFormDialog,{mode:"create",open:f,onOpenChange:g}),(0,b.jsx)(w.ServerFormDialog,{mode:"rename",target:h,open:null!==h,onOpenChange:a=>!a&&i(null)}),(0,b.jsx)(B,{target:j,open:null!==j,onOpenChange:a=>!a&&k(null)})]})}function D(){return(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]})}let E={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},F=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function G(){let a=(0,f.usePathname)(),{pageStyle:g,navBg:h}=(0,c.useThemeCustomizer)(),{activeServer:i}=(0,v.useWorkspace)(),[j,k]=(0,d.useState)(!0);(0,d.useEffect)(()=>{"false"===localStorage.getItem("sidebar-collapsed")&&k(!1)},[]);let p=()=>{let a=!j;k(a),localStorage.setItem("sidebar-collapsed",String(a))},q=h?E[h]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("aside",{className:(0,n.cn)("sticky top-0 hidden h-screen shrink-0 flex-col self-start py-4 md:flex transition-all duration-300 ease-in-out",j?"w-18":"w-60",q?"":"bg-background","fused"===g?"border-r border-border":""),style:q?{backgroundColor:q}:void 0,children:[(0,b.jsx)("div",{className:(0,n.cn)("flex w-full items-center mb-6",j?"justify-center px-3":"justify-between px-4"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,"aria-label":"Expand sidebar",className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105"}),children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:"Expand sidebar"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(e.default,{href:"/chat",className:"flex items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Larkup"})]}),(0,b.jsx)("button",{onClick:p,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"Collapse sidebar",children:(0,b.jsx)(l.ChevronLeft,{className:"size-3.5"})})]})}),(0,b.jsx)("nav",{className:(0,n.cn)("flex flex-1 flex-col w-full",j?"items-center px-3 gap-3":"px-3 gap-1.5"),children:F.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex size-10 items-center justify-center rounded-xl transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground")}),children:(0,b.jsx)(d,{className:"size-4.5",strokeWidth:f?2.25:1.75})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:c.label})]},c.id):(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex items-center gap-3 rounded-xl px-3 py-2.5 text-[13px] font-medium transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-4.5 shrink-0",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"truncate",children:c.label})]},c.id)})}),(0,b.jsx)("div",{className:(0,n.cn)("w-full pt-3",j?"px-2":"px-3"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,className:"flex w-full items-center justify-center py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"}),children:(0,b.jsxs)("div",{className:"relative size-8 rounded-lg border border-border bg-card flex items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:[(0,b.jsx)(m.Server,{className:"size-4"}),(0,b.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 flex size-2.5",children:i?.running?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-green-500 border border-card"})]}):(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-gray-500 border border-card"})})]})}),(0,b.jsxs)(o.TooltipContent,{side:"right",sideOffset:10,children:[i?.name??"No server"," (",i?.running?"Live":"Offline",")"]})]}):(0,b.jsx)(C,{})})]})})}let H={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},I=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function J(){let a=(0,f.usePathname)(),{username:d}=(0,v.useWorkspace)(),{navBg:g}=(0,c.useThemeCustomizer)(),h=g?H[g]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("header",{className:(0,n.cn)("sticky top-0 z-50 flex h-14 shrink-0 items-center gap-6 border-b border-border px-4 md:px-6",h?"":"bg-[#F5F5F4]"),style:h?{backgroundColor:h}:void 0,children:[(0,b.jsxs)(e.default,{href:"/chat","aria-label":"larkup home",className:"flex items-center gap-2.5 shrink-0",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"font-semibold tracking-tight text-foreground hidden sm:inline-block",children:"Larkup"})]}),(0,b.jsx)("nav",{className:"flex h-full items-center gap-1",children:I.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,className:(0,n.cn)("group relative flex items-center gap-2 h-full px-3 text-[13px] font-medium transition-colors outline-none",f?"text-primary":"text-muted-foreground hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-[16px]",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"hidden md:inline",children:c.label}),(0,b.jsx)("span",{className:(0,n.cn)("absolute bottom-0 left-2 right-2 h-[2px] rounded-full bg-primary transition-opacity",f?"opacity-100":"opacity-0")})]},c.id)})}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(C,{}),d&&(0,b.jsxs)("span",{className:"hidden text-sm text-muted-foreground md:block",children:["Hi, ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:d})]})]})]})})}let K=(0,j.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var L=a.i(842586),M=a.i(254472),M=M,N=a.i(961644),O=a.i(555404),P=a.i(572727),Q=a.i(4455);let R=["vercel_ai_gateway","openai","google","mistral","custom"];function S(){let{setUsername:a,createServer:c,refresh:e}=(0,v.useWorkspace)(),g=(0,f.useRouter)(),[h,i]=(0,d.useState)(""),[j,k]=(0,d.useState)("vercel_ai_gateway"),[l,m]=(0,d.useState)(""),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)("vercel_ai_gateway"),[s,t]=(0,d.useState)(""),[u,w]=(0,d.useState)(null),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(!1),[F,G]=(0,d.useState)(null),H="custom"===j,I="custom"===p,J=D||H||j!==p?s:l,S=async()=>{C(!0);try{let b=await fetch("/api/config"),{config:d}=await b.json(),f={...d};H&&n?(f.embeddingProvider="custom",f.embeddingModelId=`custom:${n.modelName}`,f.embeddingApiKey=n.apiKey||void 0,f.customEmbeddings=[n]):(f.embeddingProvider=j,f.embeddingApiKey=l),D?I&&u?(f.chatProvider="custom",f.chatModelId=`custom:${u.modelName}`,f.chatApiKey=u.apiKey||void 0,f.customChatModels=[u]):(f.chatProvider=p,f.chatApiKey=J):H&&n||(f.chatProvider=j,f.chatApiKey=l);let i=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embeddingProvider:f.embeddingProvider,embeddingApiKey:f.embeddingApiKey,embeddingModelId:f.embeddingModelId,customEmbeddings:f.customEmbeddings,chatProvider:f.chatProvider,chatApiKey:f.chatApiKey,chatModelId:f.chatModelId,customChatModels:f.customChatModels})});if(!i.ok){let a=await i.json();x.toast.error(a.error||"Verification failed — please check your API key.",{duration:8e3}),C(!1);return}h.trim()&&await a(h.trim()),await c("my-larkup"),await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},T=async()=>{C(!0);try{h.trim()&&await a(h.trim()),await c("my-larkup"),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},U=(a,c)=>(0,b.jsxs)(O.Select,{value:a,onValueChange:a=>{var b;"custom"===(b=a??"")?("embedding"===c?k("custom"):q("custom"),G(c)):"embedding"===c?(k(b),o(null),!D&&q(b)):(q(b),w(null))},children:[(0,b.jsx)(O.SelectTrigger,{className:"w-full bg-white/90 hover:bg-white",children:(0,b.jsx)("span",{className:"flex items-center gap-2",children:P.PROVIDER_META[a]?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(P.ProviderIcon,{src:P.PROVIDER_META[a].iconSrc,alt:P.PROVIDER_META[a].label,pillBg:P.PROVIDER_META[a].pillBg,size:16}),P.PROVIDER_META[a].label]}):"Select provider"})}),(0,b.jsx)(O.SelectContent,{children:R.map(a=>{let c=P.PROVIDER_META[a];return c?(0,b.jsx)(O.SelectItem,{value:a,children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(P.ProviderIcon,{src:c.iconSrc,alt:c.label,pillBg:c.pillBg,size:16}),(0,b.jsxs)("span",{children:[c.label,"vercel_ai_gateway"===a&&" (Recommended)","custom"===a&&" (OpenAI-compatible)"]})]})},a):null})})]}),V=(a,c)=>(0,b.jsxs)("div",{className:"mt-1.5 flex items-center gap-2 rounded-lg border border-green-200 bg-green-50/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-green-600 text-xs",children:"✓"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs font-medium text-foreground",children:a.modelName}),(0,b.jsx)("button",{type:"button",onClick:()=>G(c),className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(r.Pencil,{className:"size-3"})})]});return(0,b.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background",children:[(0,b.jsxs)("div",{className:"pointer-events-none fixed inset-0 overflow-hidden",children:[(0,b.jsx)("div",{className:"absolute -left-20 -top-20 h-125 w-125 rounded-full bg-stone-200/40 blur-3xl animate-pulse"}),(0,b.jsx)("div",{className:"absolute -bottom-32 -right-32 h-150 w-150 rounded-full bg-amber-100/30 blur-3xl animate-pulse [animation-delay:1s]"})]}),(0,b.jsx)("div",{className:"relative z-10 flex min-h-full w-full flex-col items-center justify-center px-6 py-12",children:(0,b.jsxs)("div",{className:"flex w-full max-w-lg flex-col items-center gap-8 animate-fade-up",children:[(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"flex size-14 items-center justify-center rounded-xl bg-primary text-primary-foreground ",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-8",alt:"Larkup"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Welcome to Larkup"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Let's set up your AI models. You can change these later in Settings."})]})]}),(0,b.jsxs)("div",{className:"w-full space-y-5 rounded-2xl p-6 backdrop-blur-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Your Name (Optional)"}),(0,b.jsx)(N.Input,{value:h,onChange:a=>i(a.target.value),placeholder:"How should we call you?",className:"bg-background/50"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Embedding Provider"}),U(j,"embedding"),H&&n&&V(n,"embedding"),H&&!n&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!H&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("label",{className:"text-xs font-medium text-foreground",children:["API Key",!D&&(0,b.jsxs)("span",{className:"text-muted-foreground font-normal",children:[" ","(used for both embedding & chat)"]})]}),(0,b.jsx)(N.Input,{type:"password",value:l,onChange:a=>m(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>E(!D),className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[D?(0,b.jsx)(M.default,{className:"size-3.5"}):(0,b.jsx)(L.ChevronDown,{className:"size-3.5"}),"Use a different chat model"]}),D&&(0,b.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/40 bg-muted/20 p-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat Provider"}),U(p,"chat"),I&&u&&V(u,"chat"),I&&!u&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!I&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat API Key"}),(0,b.jsx)(N.Input,{type:"password",value:s,onChange:a=>t(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"More providers and fine-grained model selection available in Settings → AI Models."}),(0,b.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,b.jsx)(z.Button,{variant:"outline",className:"flex-1",onClick:T,disabled:B,children:"Skip for now"}),(0,b.jsx)(z.Button,{className:"flex-1",onClick:S,disabled:B||!(()=>{if(H){if(!n)return!1}else if(!l)return!1;if(D){if(I){if(!u)return!1}else if(!J)return!1}return!0})(),children:B?(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}):(0,b.jsxs)(b.Fragment,{children:["Continue ",(0,b.jsx)(K,{className:"ml-1.5 size-4"})]})})]})]})]})}),(0,b.jsx)(A.Dialog,{open:null!==F,onOpenChange:a=>{a||("embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null))},children:(0,b.jsxs)(A.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Custom ","embedding"===F?"Embedding":"Chat"," Model"]}),(0,b.jsxs)(A.DialogDescription,{children:["Connect an OpenAI-compatible ","embedding"===F?"embedding":"chat"," ","model. Test the connection before adding."]})]}),F&&(0,b.jsx)(Q.CustomModelForm,{type:F,onSave:a=>{"embedding"===F?(o(a),k("custom")):"chat"===F&&(w(a),q("custom")),G(null)},onCancel:()=>{"embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null)}})]})})]})}let T={"panel-default":"#FAFAFA","panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"};a.s(["ClientLayoutWrapper",0,function({children:a}){let{pageStyle:d,panelBg:e,layout:g}=(0,c.useThemeCustomizer)(),h=(0,f.usePathname)(),i=h?.includes("/chat"),{isFirstRun:j,isLoading:k}=(0,v.useWorkspace)(),l=T[e],m=l?{backgroundColor:l}:void 0;return!k&&j?(0,b.jsx)(S,{}):k?(0,b.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,b.jsx)("div",{className:"size-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):"topnav"===g?(0,b.jsxs)("div",{className:"flex flex-col h-screen overflow-hidden",children:[(0,b.jsx)(J,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"h-full flex flex-col bg-background text-foreground",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]}):(0,b.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,b.jsx)(G,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"fused"===d?"h-screen flex flex-col bg-background text-foreground overflow-hidden":"h-screen flex flex-col md:rounded-l-2xl border-l border-border bg-panel text-panel-foreground overflow-hidden",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]})}],881150)},316105,a=>{"use strict";var b=a.i(360809),c=a.i(717383),d=a.i(93718),e=a.i(887556),f=a.i(113413),g=a.i(326729);let h=(0,g.default)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var i=a.i(489132);let j=(0,g.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var k=a.i(486903),l=a.i(733105);let m=(0,g.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var n=a.i(99109),o=a.i(671008),p=a.i(22496),q=a.i(426490);let r=(0,g.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var s=a.i(953191),t=a.i(96607),u=a.i(541487),v=a.i(655208),w=a.i(299574),x=a.i(483115),y=a.i(95507),z=a.i(635153),A=a.i(717994),B=a.i(343578);let C=a=>fetch(a).then(a=>a.json()),D=["chunking","embedding","upserting"];function E({open:a,onOpenChange:g,trigger:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),m=void 0!==a,r=m?a:k,s=m&&g?g:l,{data:t,isLoading:v,mutate:w}=(0,c.default)("/api/index",C,{refreshInterval:a=>a?.run&&D.includes(a.run.status)?1e3:0}),G=(0,e.useRef)(void 0);(0,e.useEffect)(()=>{let a=t?.run?.warning;a&&a!==G.current?z.toast.warning(a,{id:"rate-limit-warning",duration:7e4}):!a&&G.current&&(z.toast.dismiss("rate-limit-warning"),z.toast.success("Rate limit resolved — resuming indexing.",{duration:3e3})),G.current=a},[t?.run?.warning]);let[I,J]=(0,e.useState)(!1);async function K(a=!1){j(!0);try{let b=await fetch("/api/index",{method:"POST",body:JSON.stringify({incremental:a}),headers:{"Content-Type":"application/json"}}),c=await b.json();if(!b.ok)return void z.toast.error(c.error??"Could not start indexing.");z.toast.success("Indexing started."),w()}catch{z.toast.error("Could not start indexing.")}finally{j(!1)}}async function L(){j(!0);try{if(!(await fetch("/api/index",{method:"DELETE"})).ok)return void z.toast.error("Could not cancel indexing.");z.toast.success("Indexing cancelled."),w()}catch{z.toast.error("Could not cancel indexing.")}finally{j(!1)}}return(0,e.useEffect)(()=>{let a=t?.run?.status;a&&D.includes(a)?J(!0):I&&"completed"===a&&(J(!1),s(!1),z.toast.success("Indexing completed successfully!"))},[t?.run?.status,I,s]),(0,b.jsxs)(B.Dialog,{open:r,onOpenChange:s,children:[h?(0,b.jsx)(B.DialogTrigger,{render:(0,e.isValidElement)(h)?h:(0,b.jsx)("button",{children:h})}):(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t?.run?.status==="completed"&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i,variant:"outline",children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index Data"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),(0,b.jsx)(B.DialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t?.ready||t?.unindexedCount===0,children:[(0,b.jsx)(o.Layers,{className:"size-4 mr-2"}),"Index Data"]})})]}),(0,b.jsxs)(B.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto ",children:[(0,b.jsxs)(B.DialogHeader,{children:[(0,b.jsx)(B.DialogTitle,{children:"Index Data"}),(0,b.jsx)(B.DialogDescription,{children:"Chunk, embed, and index into your selected vector database."})]}),v||!t?(0,b.jsx)("div",{className:"py-6",children:(0,b.jsx)(y.Skeleton,{className:"h-40 w-full"})}):(0,b.jsxs)("div",{className:"space-y-6 py-4",children:[(0,b.jsx)(F,{config:t.config,docCount:t.docCount,charCount:t.charCount}),!t.ready&&(0,b.jsxs)(x.Alert,{variant:"default",children:[(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-orange-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-orange-500!",children:"Not ready to index"}),(0,b.jsx)(x.AlertDescription,{children:(0,b.jsx)("ul",{className:"list-disc pl-4",children:t.blockers.map(a=>(0,b.jsx)("li",{children:a},a))})})]}),(0,b.jsx)(H,{run:t.run,running:!!(t.run&&D.includes(t.run.status))}),t.ready&&!t.run&&(0,b.jsxs)(x.Alert,{children:[(0,b.jsx)(n.Info,{className:"size-4 text-blue-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-blue-600 dark:text-blue-400",children:"Before you start indexing"}),(0,b.jsxs)(x.AlertDescription,{className:"text-muted-foreground space-y-1",children:[(0,b.jsxs)("p",{children:["Once indexing begins, two settings become"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"locked"})," to the existing index:"]}),(0,b.jsxs)("ul",{className:"list-disc pl-4 space-y-0.5",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Embedding model"})," — you can swap to any model with the"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"same vector dimensions"}),", but switching to a model with different dimensions will require a full re-index."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Vector store"})," — changing the store after indexing requires starting fresh."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)(u.Button,{onClick:()=>K(t.run?.status==="completed"),disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i||t.run?.status==="completed"&&0===t.unindexedCount,size:"lg",children:[t.run&&D.includes(t.run.status)||i?(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin mr-2"}):(0,b.jsx)(p.Play,{className:"size-4 mr-2"}),t.run&&D.includes(t.run.status)?"Indexing…":i?"Starting…":t.run?.status==="completed"?`Index new documents (${t.unindexedCount})`:`Start indexing (${t.unindexedCount})`]}),t.run?.status==="completed"&&!(t.run&&D.includes(t.run.status))&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{variant:"outline",size:"lg",disabled:i,children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index All"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),!!(t.run&&D.includes(t.run.status))&&(0,b.jsx)(u.Button,{onClick:L,disabled:i,size:"lg",variant:"destructive",children:"Cancel"})]}),(0,b.jsx)(u.Button,{variant:"ghost",size:"lg",onClick:()=>s(!1),children:"Close"})]})]})]})]})}function F({config:a,docCount:c,charCount:d}){let e=(0,s.getEmbeddingModel)(a.embeddingModelId),f=(0,t.getVectorStore)(a.vectorStore),g=[{icon:j,label:"Embedding model",value:e?.label??a.embeddingModelId,hint:e?`${e.dimensions} dims`:void 0},{icon:k.Database,label:"Vector store",value:f?.label??a.vectorStore},{icon:h,label:"Index type",value:a.indexType.toUpperCase()},{icon:r,label:"Chunking",value:`${a.chunking.chunkSize} / ${a.chunking.chunkOverlap}`,hint:"size / overlap"},{icon:l.FileText,label:"Corpus",value:`${c.toLocaleString()} docs`,hint:`${d.toLocaleString()} chars`}];return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold mb-4",children:[(0,b.jsx)(o.Layers,{className:"size-4 text-primary"}),"Index configuration"]}),(0,b.jsx)("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-5 sm:grid-cols-3",children:g.map(a=>(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("dt",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,b.jsx)(a.icon,{className:"size-3.5"}),a.label]}),(0,b.jsxs)("dd",{className:"text-sm font-medium leading-tight",children:[a.value,a.hint&&(0,b.jsx)("span",{className:"ml-1.5 font-mono text-[11px] font-normal text-muted-foreground",children:a.hint})]})]},a.label))})]})}let G={idle:{label:"Idle"},chunking:{label:"Chunking",phase:"Splitting documents into chunks"},embedding:{label:"Embedding",phase:"Generating vector embeddings"},upserting:{label:"Storing",phase:"Writing vectors to the store"},completed:{label:"Completed"},failed:{label:"Failed"}};function H({run:a,running:c}){if(!a)return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground flex flex-col items-center justify-center gap-1 py-8 text-center",children:[(0,b.jsx)(m,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,b.jsx)("p",{className:"text-sm font-medium",children:"No index built yet"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Build a Larkup index to embed your corpus and make it searchable."})]});let e=G[a.status],g=a.totalChunks>0?Math.round(a.processedChunks/a.totalChunks*100):5*!!c;return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4 space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold",children:["completed"===a.status?(0,b.jsx)(i.CheckCircle2,{className:"size-4 text-primary"}):"failed"===a.status?(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-destructive"}):(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),e.label]}),(0,b.jsx)(J,{status:a.status})]}),"failed"===a.status?(0,b.jsx)(b.Fragment,{}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:e.phase??"Done"}),(0,b.jsxs)("span",{className:"font-mono tabular-nums",children:[a.processedChunks.toLocaleString(),a.totalChunks>0&&` / ${a.totalChunks.toLocaleString()}`," chunks"]})]}),(0,b.jsx)(v.Progress,{value:g,className:"**:data-[slot=progress-indicator]:bg-green-600"})]}),(0,b.jsxs)("dl",{className:"grid grid-cols-2 gap-4 pt-1 sm:grid-cols-4",children:[(0,b.jsx)(I,{label:"Documents",value:a.docCount.toLocaleString()}),(0,b.jsx)(I,{label:"Chunks",value:a.totalChunks.toLocaleString()}),(0,b.jsx)(I,{label:"Dimensions",value:a.dimensions?a.dimensions.toLocaleString():"—"}),(0,b.jsx)(I,{label:"Duration",value:a.durationMs?`${(a.durationMs/1e3).toFixed(1)}s`:c?"running…":"—"})]})]})]})}function I({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("dt",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"font-mono text-sm tabular-nums",children:c})]})}function J({status:a}){return"completed"===a?(0,b.jsx)(w.Badge,{className:"bg-primary/12 text-primary hover:bg-primary/12",children:"Ready"}):"failed"===a?(0,b.jsx)(w.Badge,{variant:"destructive",children:"Failed"}):D.includes(a)?(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-green-600",children:[(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}),"Live"]}):null}let K=a=>fetch(a).then(a=>a.json()),L=["chunking","embedding","upserting"];a.s(["GlobalIndexProgress",0,function(){let{data:a}=(0,c.default)("/api/index",K,{refreshInterval:a=>a?.run&&L.includes(a.run.status)?1e3:0});if(!(a?.run&&L.includes(a.run.status))||!a?.run)return null;let{run:e}=a,f=e.totalChunks>0?Math.round(e.processedChunks/e.totalChunks*100):5;return(0,b.jsx)("div",{className:"fixed bottom-6 right-6 z-50",children:(0,b.jsx)(E,{trigger:(0,b.jsxs)("button",{className:"flex items-center gap-3 rounded-full border bg-background px-4 py-2 text-sm font-medium transition-all hover:bg-muted/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),(0,b.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,b.jsx)("span",{className:"text-xs leading-none text-muted-foreground",children:"Storing..."}),(0,b.jsxs)("span",{className:"leading-none",children:[f,"%"]})]})]})})})}],316105)},150760,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=a.i(216615),e=a.i(567087),f=a.i(536095),g=a.i(50667),h=a.i(541487);let i={docker:"docker compose pull && docker compose up -d",npm:"larkup update"};a.s(["UpdateBanner",0,function(){let[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r="0.1.26",s="true"===process.env.NEXT_PUBLIC_DOCKER_ENV||"true"===process.env.NEXT_PUBLIC_RUNNING_IN_DOCKER?"docker":"npm";(0,c.useEffect)(()=>{},[r]);let t=async()=>{if("desktop"===s){o(!0);try{let{check:b}=await a.A(914053),{relaunch:c}=await a.A(69832),d=await b();d?(await d.downloadAndInstall(),await c()):o(!1)}catch(a){console.error("Auto-update failed:",a),o(!1),window.open("https://larkup.de/download","_blank")}}else try{await navigator.clipboard.writeText(i[s]),q(!0),window.setTimeout(()=>q(!1),2e3)}catch(a){console.error("Could not copy update command:",a)}};return l&&j?(0,b.jsx)("div",{role:"status","aria-live":"polite",className:"relative z-50 border-b border-border bg-background px-3 py-2 text-foreground sm:px-4",children:(0,b.jsxs)("div",{className:"mx-auto flex min-h-7 max-w-screen-2xl items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background",children:(0,b.jsx)(d.ArrowUp,{className:"size-3.5","aria-hidden":"true"})}),(0,b.jsxs)("p",{className:"min-w-0 text-xs sm:text-sm",children:[(0,b.jsxs)("span",{className:"font-medium",children:["Larkup v",j," is available."]})," ",(0,b.jsxs)("span",{className:"hidden text-muted-foreground sm:inline",children:["You're using v",r,"."]})]}),"desktop"!==s&&(0,b.jsx)("code",{className:"ml-auto hidden max-w-[38rem] truncate rounded-[5px] border border-border bg-muted/40 px-2 py-1 font-mono text-[11px] text-muted-foreground lg:block",children:i[s]}),(0,b.jsx)(h.Button,{type:"button",variant:"desktop"===s?"default":"outline",size:"xs",onClick:t,disabled:n,"aria-label":"desktop"===s?"Update Larkup now":"Copy update command",className:"desktop"===s?"ml-auto":"ml-auto lg:ml-0",children:"desktop"===s?n?"Updating...":"Update now":p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e.Check,{"aria-hidden":"true"}),"Copied"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Copy,{"aria-hidden":"true"}),"Copy command"]})}),(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>{try{localStorage.setItem("larkup-update-dismissed",JSON.stringify({timestamp:Date.now()}))}catch{}m(!1)},"aria-label":"Dismiss update notification",title:"Remind me tomorrow",children:(0,b.jsx)(g.X,{"aria-hidden":"true"})})]})}):null}])}];
|
|
1
|
+
module.exports=[825358,a=>{"use strict";var b=a.i(887556),c=a.i(865769);function d(a){return RegExp(`/${a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=[/?#]|$)`)}function e(a){return(0,b.useEffect)(()=>{var b;a.beforeSend&&(null==(b=window.va)||b.call(window,"beforeSend",a.beforeSend))},[a.beforeSend]),(0,b.useEffect)(()=>{!function(a={debug:!0},b){}({framework:a.framework||"react",basePath:a.basePath??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_BASEPATH}(),...void 0!==a.route&&{disableAutoTrack:!0},...a},a.configString??function(){if("u">typeof process&&void 0!==process.env)return process.env.REACT_APP_VERCEL_OBSERVABILITY_CLIENT_CONFIG}())},[]),(0,b.useEffect)(()=>{a.route&&a.path&&function({route:a,path:b}){var c;null==(c=window.va)||c.call(window,"pageview",{route:a,path:b})}({route:a.route,path:a.path})},[a.route,a.path]),null}function f(a){let f,g,h,{route:i,path:j}=(f=(0,c.useParams)(),g=(0,c.useSearchParams)(),h=(0,c.usePathname)(),f?{route:function(a,b){if(!a||!b)return a;let c=a;try{let a=Object.entries(b);for(let[b,e]of a)if(!Array.isArray(e)){let a=d(e);a.test(c)&&(c=c.replace(a,`/[${b}]`))}for(let[b,e]of a)if(Array.isArray(e)){let a=d(e.join("/"));a.test(c)&&(c=c.replace(a,`/[...${b}]`))}return c}catch{return a}}(h,Object.keys(f).length?f:Object.fromEntries(g.entries())),path:h}:{route:null,path:h});return b.default.createElement(e,{path:j,route:i,...a,basePath:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_BASEPATH}(),configString:function(){if("u">typeof process&&void 0!==process.env)return process.env.NEXT_PUBLIC_VERCEL_OBSERVABILITY_CLIENT_CONFIG}(),framework:"next"})}a.s(["Analytics",0,function(a){return b.default.createElement(b.Suspense,{fallback:null},b.default.createElement(f,{...a}))}])},554502,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=(a,b,c,d,e,f,g,h)=>{let i=document.documentElement,j=["light","dark"];function k(b){var c;(Array.isArray(a)?a:[a]).forEach(a=>{let c="class"===a,d=c&&f?e.map(a=>f[a]||a):e;c?(i.classList.remove(...d),i.classList.add(f&&f[b]?f[b]:b)):i.setAttribute(a,b)}),c=b,h&&j.includes(c)&&(i.style.colorScheme=c)}if(d)k(d);else try{let a=localStorage.getItem(b)||c,d=g&&"system"===a?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a;k(d)}catch(a){}},e=c.createContext(void 0),f={setTheme:a=>{},themes:[]};c.memo(({forcedTheme:a,storageKey:b,attribute:e,enableSystem:f,enableColorScheme:g,defaultTheme:h,value:i,themes:j,nonce:k,scriptProps:l})=>{let m=JSON.stringify([e,b,h,a,j,i,f,g]).slice(1,-1);return c.createElement("script",{...l,suppressHydrationWarning:!0,nonce:k,dangerouslySetInnerHTML:{__html:`(${d.toString()})(${m})`}})});var g=a.i(635153),h=a.i(689958),h=h,i=a.i(859416),i=i,j=a.i(583142),j=j,k=a.i(318467),k=k,l=a.i(49656),l=l;a.s(["Toaster",0,({...a})=>{var d;let{theme:m="system"}=null!=(d=c.useContext(e))?d:f;return(0,b.jsx)(g.Toaster,{closeButton:!0,theme:m,className:"toaster group z-9999999! ",icons:{success:(0,b.jsx)(h.default,{className:"size-5 text-white",fill:"#10b981"}),info:(0,b.jsx)(i.default,{className:"size-5 text-white",fill:"#3b82f6"}),warning:(0,b.jsx)(j.default,{className:"size-5 text-white",fill:"#f59e0b"}),error:(0,b.jsx)(k.default,{className:"size-5 text-white",fill:"#ef4444"}),loading:(0,b.jsx)(l.default,{className:"size-5 animate-spin text-muted-foreground"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)",zIndex:999999},toastOptions:{classNames:{toast:"group toast items-start group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900 group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:",icon:"mt-0.5",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",success:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",error:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",warning:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900",info:"group-[.toaster]:!bg-[#F9F9F7] dark:group-[.toaster]:!bg-zinc-900"}},...a})}],554502)},881150,a=>{"use strict";var b=a.i(360809),c=a.i(295805),d=a.i(887556),e=a.i(349839),f=a.i(865769),g=a.i(610520),h=a.i(486903),i=a.i(566005),j=a.i(326729);let k=(0,j.default)("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);var l=a.i(816995),m=a.i(371629),n=a.i(74192),o=a.i(599335),p=a.i(567087);let q=(0,j.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);var r=a.i(25791),s=a.i(446338),t=a.i(895839),u=a.i(94842),v=a.i(161859),w=a.i(7812),x=a.i(635153),y=a.i(93718),z=a.i(541487),A=a.i(343578);function B({target:a,open:c,onOpenChange:e}){let{deleteServer:f}=(0,v.useWorkspace)(),[g,h]=(0,d.useState)(!1);async function i(){if(a){h(!0);try{await f(a.id),x.toast.success(`Deleted "${a.name}".`),e(!1)}catch{x.toast.error("Could not delete the server.")}finally{h(!1)}}}return(0,b.jsx)(A.Dialog,{open:c,onOpenChange:e,children:(0,b.jsxs)(A.DialogContent,{className:"sm:max-w-md",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Delete “",a?.name,"”?"]}),(0,b.jsx)(A.DialogDescription,{children:"This permanently removes the server's documents, index, vector data, and generated files. This cannot be undone."})]}),(0,b.jsxs)(A.DialogFooter,{children:[(0,b.jsx)(z.Button,{variant:"outline",onClick:()=>e(!1),disabled:g,children:"Cancel"}),(0,b.jsxs)(z.Button,{variant:"destructive",onClick:()=>void i(),disabled:g,children:[g&&(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}),"Delete server"]})]})]})})}function C(){let{servers:a,activeServer:c,activateServer:e}=(0,v.useWorkspace)(),[f,g]=(0,d.useState)(!1),[h,i]=(0,d.useState)(null),[j,k]=(0,d.useState)(null);return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(u.DropdownMenu,{children:[(0,b.jsxs)(u.DropdownMenuTrigger,{render:(0,b.jsx)("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg border border-border bg-card px-2 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary/12 text-primary",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsx)("span",{className:"flex min-w-0 flex-1 flex-col",children:(0,b.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:c?.name??"No server"}),c?.running&&(0,b.jsx)(D,{})]})}),(0,b.jsx)(q,{className:"size-4 shrink-0 text-muted-foreground"})]}),(0,b.jsxs)(u.DropdownMenuContent,{align:"start",sideOffset:6,className:"w-(--anchor-width) min-w-[260px]",children:[(0,b.jsxs)(u.DropdownMenuGroup,{children:[(0,b.jsx)(u.DropdownMenuLabel,{children:"Your servers"}),a.map(a=>{let d=a.id===c?.id;return(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>{d||e(a.id)},className:"gap-2",children:[(0,b.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,b.jsx)(m.Server,{className:"size-3.5"})}),(0,b.jsxs)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,b.jsxs)("span",{className:"flex items-center gap-2 text-[11px] text-muted-foreground tabular-nums",children:[(0,b.jsxs)("span",{children:[a.docCount," docs"]}),a.indexed&&(0,b.jsx)("span",{children:"· indexed"}),a.running&&(0,b.jsxs)("span",{className:"flex items-center gap-1 text-green-500",children:[(0,b.jsx)(D,{}),"live"]})]})]}),d&&(0,b.jsx)(p.Check,{className:"size-4 shrink-0 text-primary"})]},a.id)})]}),(0,b.jsx)(u.DropdownMenuSeparator,{}),(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>g(!0),className:"gap-2 h-9",children:[(0,b.jsx)(s.Plus,{className:"size-4"}),"New server"]}),c&&(0,b.jsxs)(u.DropdownMenuItem,{onClick:()=>i(c),className:"gap-2 h-9",children:[(0,b.jsx)(r.Pencil,{className:"size-4"}),"Rename current"]}),c&&a.length>1&&(0,b.jsxs)(u.DropdownMenuItem,{variant:"destructive",onClick:()=>k(c),className:"gap-2",children:[(0,b.jsx)(t.Trash2,{className:"size-4"}),"Delete current"]})]})]}),(0,b.jsx)(w.ServerFormDialog,{mode:"create",open:f,onOpenChange:g}),(0,b.jsx)(w.ServerFormDialog,{mode:"rename",target:h,open:null!==h,onOpenChange:a=>!a&&i(null)}),(0,b.jsx)(B,{target:j,open:null!==j,onOpenChange:a=>!a&&k(null)})]})}function D(){return(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-500"})]})}let E={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},F=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function G(){let a=(0,f.usePathname)(),{pageStyle:g,navBg:h}=(0,c.useThemeCustomizer)(),{activeServer:i}=(0,v.useWorkspace)(),[j,k]=(0,d.useState)(!0);(0,d.useEffect)(()=>{"false"===localStorage.getItem("sidebar-collapsed")&&k(!1)},[]);let p=()=>{let a=!j;k(a),localStorage.setItem("sidebar-collapsed",String(a))},q=h?E[h]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("aside",{className:(0,n.cn)("sticky top-0 hidden h-screen shrink-0 flex-col self-start py-4 md:flex transition-all duration-300 ease-in-out",j?"w-18":"w-60",q?"":"bg-background","fused"===g?"border-r border-border":""),style:q?{backgroundColor:q}:void 0,children:[(0,b.jsx)("div",{className:(0,n.cn)("flex w-full items-center mb-6",j?"justify-center px-3":"justify-between px-4"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,"aria-label":"Expand sidebar",className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105"}),children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:"Expand sidebar"})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(e.default,{href:"/chat",className:"flex items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"text-sm font-semibold tracking-tight text-foreground",children:"Larkup"})]}),(0,b.jsx)("button",{onClick:p,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors","aria-label":"Collapse sidebar",children:(0,b.jsx)(l.ChevronLeft,{className:"size-3.5"})})]})}),(0,b.jsx)("nav",{className:(0,n.cn)("flex flex-1 flex-col w-full",j?"items-center px-3 gap-3":"px-3 gap-1.5"),children:F.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex size-10 items-center justify-center rounded-xl transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground")}),children:(0,b.jsx)(d,{className:"size-4.5",strokeWidth:f?2.25:1.75})}),(0,b.jsx)(o.TooltipContent,{side:"right",sideOffset:10,children:c.label})]},c.id):(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,onClick:b=>{"chat"===c.id&&"/chat"===a&&(b.preventDefault(),window.dispatchEvent(new CustomEvent("new-chat")))},className:(0,n.cn)("group relative flex items-center gap-3 rounded-xl px-3 py-2.5 text-[13px] font-medium transition-all duration-200 outline-none focus-visible:ring-2 focus-visible:ring-ring",f?"bg-[#F0F0F0] text-foreground":"text-muted-foreground hover:bg-[#EBEBEB] hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-4.5 shrink-0",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"truncate",children:c.label})]},c.id)})}),(0,b.jsx)("div",{className:(0,n.cn)("w-full pt-3",j?"px-2":"px-3"),children:j?(0,b.jsxs)(o.Tooltip,{children:[(0,b.jsx)(o.TooltipTrigger,{render:(0,b.jsx)("button",{onClick:p,className:"flex w-full items-center justify-center py-1.5 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors"}),children:(0,b.jsxs)("div",{className:"relative size-8 rounded-lg border border-border bg-card flex items-center justify-center text-muted-foreground transition-colors group-hover:text-foreground",children:[(0,b.jsx)(m.Server,{className:"size-4"}),(0,b.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 flex size-2.5",children:i?.running?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-500 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-green-500 border border-card"})]}):(0,b.jsx)("span",{className:"relative inline-flex size-full rounded-full bg-gray-500 border border-card"})})]})}),(0,b.jsxs)(o.TooltipContent,{side:"right",sideOffset:10,children:[i?.name??"No server"," (",i?.running?"Live":"Offline",")"]})]}):(0,b.jsx)(C,{})})]})})}let H={"panel-default":void 0,"panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"},I=[{id:"chat",label:"Chat",href:"/chat",icon:g.MessageCircle},{id:"data",label:"Data",href:"/data",icon:h.Database},{id:"analytics",label:"Analytics",href:"/analytics",icon:k},{id:"settings",label:"Settings",href:"/settings",icon:i.Settings}];function J(){let a=(0,f.usePathname)(),{username:d}=(0,v.useWorkspace)(),{navBg:g}=(0,c.useThemeCustomizer)(),h=g?H[g]:void 0;return(0,b.jsx)(o.TooltipProvider,{delay:150,children:(0,b.jsxs)("header",{className:(0,n.cn)("sticky top-0 z-50 flex h-14 shrink-0 items-center gap-6 border-b border-border px-4 md:px-6",h?"":"bg-[#F5F5F4]"),style:h?{backgroundColor:h}:void 0,children:[(0,b.jsxs)(e.default,{href:"/chat","aria-label":"larkup home",className:"flex items-center gap-2.5 shrink-0",children:[(0,b.jsx)("span",{className:"flex size-9 items-center justify-center rounded-xl bg-primary text-primary-foreground transition-transform hover:scale-105",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-5",alt:"logo"})}),(0,b.jsx)("span",{className:"font-semibold tracking-tight text-foreground hidden sm:inline-block",children:"Larkup"})]}),(0,b.jsx)("nav",{className:"flex h-full items-center gap-1",children:I.map(c=>{let d=c.icon,f=a===c.href||"/"!==c.href&&a?.startsWith(c.href);return(0,b.jsxs)(e.default,{href:c.href,"aria-current":f?"page":void 0,className:(0,n.cn)("group relative flex items-center gap-2 h-full px-3 text-[13px] font-medium transition-colors outline-none",f?"text-primary":"text-muted-foreground hover:text-foreground"),children:[(0,b.jsx)(d,{className:"size-[16px]",strokeWidth:f?2.25:1.75}),(0,b.jsx)("span",{className:"hidden md:inline",children:c.label}),(0,b.jsx)("span",{className:(0,n.cn)("absolute bottom-0 left-2 right-2 h-[2px] rounded-full bg-primary transition-opacity",f?"opacity-100":"opacity-0")})]},c.id)})}),(0,b.jsx)("div",{className:"flex-1"}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)(C,{}),d&&(0,b.jsxs)("span",{className:"hidden text-sm text-muted-foreground md:block",children:["Hi, ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:d})]})]})]})})}let K=(0,j.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var L=a.i(842586),M=a.i(254472),M=M,N=a.i(961644),O=a.i(555404),P=a.i(572727),Q=a.i(4455);let R=["vercel_ai_gateway","openai","google","mistral","custom"];function S(){let{setUsername:a,createServer:c,refresh:e}=(0,v.useWorkspace)(),g=(0,f.useRouter)(),[h,i]=(0,d.useState)(""),[j,k]=(0,d.useState)("vercel_ai_gateway"),[l,m]=(0,d.useState)(""),[n,o]=(0,d.useState)(null),[p,q]=(0,d.useState)("vercel_ai_gateway"),[s,t]=(0,d.useState)(""),[u,w]=(0,d.useState)(null),[B,C]=(0,d.useState)(!1),[D,E]=(0,d.useState)(!1),[F,G]=(0,d.useState)(null),H="custom"===j,I="custom"===p,J=D||H||j!==p?s:l,S=async()=>{C(!0);try{let b=await fetch("/api/config"),{config:d}=await b.json(),f={...d};H&&n?(f.embeddingProvider="custom",f.embeddingModelId=`custom:${n.modelName}`,f.embeddingApiKey=n.apiKey||void 0,f.customEmbeddings=[n]):(f.embeddingProvider=j,f.embeddingApiKey=l),D?I&&u?(f.chatProvider="custom",f.chatModelId=`custom:${u.modelName}`,f.chatApiKey=u.apiKey||void 0,f.customChatModels=[u]):(f.chatProvider=p,f.chatApiKey=J):H&&n||(f.chatProvider=j,f.chatApiKey=l);let i=await fetch("/api/config/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({embeddingProvider:f.embeddingProvider,embeddingApiKey:f.embeddingApiKey,embeddingModelId:f.embeddingModelId,customEmbeddings:f.customEmbeddings,chatProvider:f.chatProvider,chatApiKey:f.chatApiKey,chatModelId:f.chatModelId,customChatModels:f.customChatModels})});if(!i.ok){let a=await i.json();x.toast.error(a.error||"Verification failed — please check your API key.",{duration:8e3}),C(!1);return}h.trim()&&await a(h.trim()),await c("my-larkup"),await fetch("/api/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)}),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},T=async()=>{C(!0);try{h.trim()&&await a(h.trim()),await c("my-larkup"),e(),g.push("/chat")}catch(a){x.toast.error("Failed to complete setup")}finally{C(!1)}},U=(a,c)=>(0,b.jsxs)(O.Select,{value:a,onValueChange:a=>{var b;"custom"===(b=a??"")?("embedding"===c?k("custom"):q("custom"),G(c)):"embedding"===c?(k(b),o(null),!D&&q(b)):(q(b),w(null))},children:[(0,b.jsx)(O.SelectTrigger,{className:"w-full bg-white/90 hover:bg-white",children:(0,b.jsx)("span",{className:"flex items-center gap-2",children:P.PROVIDER_META[a]?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(P.ProviderIcon,{src:P.PROVIDER_META[a].iconSrc,alt:P.PROVIDER_META[a].label,pillBg:P.PROVIDER_META[a].pillBg,size:16}),P.PROVIDER_META[a].label]}):"Select provider"})}),(0,b.jsx)(O.SelectContent,{children:R.map(a=>{let c=P.PROVIDER_META[a];return c?(0,b.jsx)(O.SelectItem,{value:a,children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(P.ProviderIcon,{src:c.iconSrc,alt:c.label,pillBg:c.pillBg,size:16}),(0,b.jsxs)("span",{children:[c.label,"vercel_ai_gateway"===a&&" (Recommended)","custom"===a&&" (OpenAI-compatible)"]})]})},a):null})})]}),V=(a,c)=>(0,b.jsxs)("div",{className:"mt-1.5 flex items-center gap-2 rounded-lg border border-green-200 bg-green-50/50 px-3 py-2",children:[(0,b.jsx)("span",{className:"text-green-600 text-xs",children:"✓"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs font-medium text-foreground",children:a.modelName}),(0,b.jsx)("button",{type:"button",onClick:()=>G(c),className:"text-muted-foreground hover:text-foreground transition-colors",children:(0,b.jsx)(r.Pencil,{className:"size-3"})})]});return(0,b.jsxs)("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-background",children:[(0,b.jsxs)("div",{className:"pointer-events-none fixed inset-0 overflow-hidden",children:[(0,b.jsx)("div",{className:"absolute -left-20 -top-20 h-125 w-125 rounded-full bg-stone-200/40 blur-3xl animate-pulse"}),(0,b.jsx)("div",{className:"absolute -bottom-32 -right-32 h-150 w-150 rounded-full bg-amber-100/30 blur-3xl animate-pulse [animation-delay:1s]"})]}),(0,b.jsx)("div",{className:"relative z-10 flex min-h-full w-full flex-col items-center justify-center px-6 py-12",children:(0,b.jsxs)("div",{className:"flex w-full max-w-lg flex-col items-center gap-8 animate-fade-up",children:[(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"flex size-14 items-center justify-center rounded-xl bg-primary text-primary-foreground ",children:(0,b.jsx)("img",{src:"/logo9.png",className:"size-8",alt:"Larkup"})}),(0,b.jsxs)("div",{children:[(0,b.jsx)("h1",{className:"text-2xl font-bold tracking-tight text-foreground",children:"Welcome to Larkup"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"Let's set up your AI models. You can change these later in Settings."})]})]}),(0,b.jsxs)("div",{className:"w-full space-y-5 rounded-2xl p-6 backdrop-blur-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Your Name (Optional)"}),(0,b.jsx)(N.Input,{value:h,onChange:a=>i(a.target.value),placeholder:"How should we call you?",className:"bg-background/50"})]}),(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Embedding Provider"}),U(j,"embedding"),H&&n&&V(n,"embedding"),H&&!n&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!H&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("label",{className:"text-xs font-medium text-foreground",children:["API Key",!D&&(0,b.jsxs)("span",{className:"text-muted-foreground font-normal",children:[" ","(used for both embedding & chat)"]})]}),(0,b.jsx)(N.Input,{type:"password",value:l,onChange:a=>m(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]}),(0,b.jsxs)("button",{type:"button",onClick:()=>E(!D),className:"flex w-full items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[D?(0,b.jsx)(M.default,{className:"size-3.5"}):(0,b.jsx)(L.ChevronDown,{className:"size-3.5"}),"Use a different chat model"]}),D&&(0,b.jsxs)("div",{className:"space-y-3 rounded-xl border border-border/40 bg-muted/20 p-4",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat Provider"}),U(p,"chat"),I&&u&&V(u,"chat"),I&&!u&&(0,b.jsx)("p",{className:"text-[11px] text-amber-600 mt-1",children:"Please configure and test your custom model to continue."})]}),!I&&(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-foreground",children:"Chat API Key"}),(0,b.jsx)(N.Input,{type:"password",value:s,onChange:a=>t(a.target.value),placeholder:"sk-...",className:"bg-background/50"})]})]}),(0,b.jsx)("p",{className:"text-[11px] text-muted-foreground",children:"More providers and fine-grained model selection available in Settings → AI Models."}),(0,b.jsxs)("div",{className:"pt-2 flex gap-3",children:[(0,b.jsx)(z.Button,{variant:"outline",className:"flex-1",onClick:T,disabled:B,children:"Skip for now"}),(0,b.jsx)(z.Button,{className:"flex-1",onClick:S,disabled:B||!(()=>{if(H){if(!n)return!1}else if(!l)return!1;if(D){if(I){if(!u)return!1}else if(!J)return!1}return!0})(),children:B?(0,b.jsx)(y.Loader2,{className:"size-4 animate-spin"}):(0,b.jsxs)(b.Fragment,{children:["Continue ",(0,b.jsx)(K,{className:"ml-1.5 size-4"})]})})]})]})]})}),(0,b.jsx)(A.Dialog,{open:null!==F,onOpenChange:a=>{a||("embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null))},children:(0,b.jsxs)(A.DialogContent,{className:"max-w-xl",children:[(0,b.jsxs)(A.DialogHeader,{children:[(0,b.jsxs)(A.DialogTitle,{children:["Custom ","embedding"===F?"Embedding":"Chat"," Model"]}),(0,b.jsxs)(A.DialogDescription,{children:["Connect an OpenAI-compatible ","embedding"===F?"embedding":"chat"," ","model. Test the connection before adding."]})]}),F&&(0,b.jsx)(Q.CustomModelForm,{type:F,onSave:a=>{"embedding"===F?(o(a),k("custom")):"chat"===F&&(w(a),q("custom")),G(null)},onCancel:()=>{"embedding"!==F||n||k("vercel_ai_gateway"),"chat"!==F||u||q("vercel_ai_gateway"),G(null)}})]})})]})}let T={"panel-default":"#FAFAFA","panel-white":"#FFFFFF","panel-fafafa":"#FAFAFA","panel-warm":"#F7F1EA","panel-soft":"#FBFAF8","panel-silver":"#F8F8F8","panel-stone":"#F5F5F2"};a.s(["ClientLayoutWrapper",0,function({children:a}){let{pageStyle:d,panelBg:e,layout:g}=(0,c.useThemeCustomizer)(),h=(0,f.usePathname)(),i=h?.includes("/chat"),{isFirstRun:j,isLoading:k}=(0,v.useWorkspace)(),l=T[e],m=l?{backgroundColor:l}:void 0;return!k&&j?(0,b.jsx)(S,{}):k?(0,b.jsx)("div",{className:"flex h-screen items-center justify-center",children:(0,b.jsx)("div",{className:"size-6 animate-spin rounded-full border-2 border-primary border-t-transparent"})}):"topnav"===g?(0,b.jsxs)("div",{className:"flex flex-col h-screen overflow-hidden",children:[(0,b.jsx)(J,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"h-full flex flex-col bg-background text-foreground",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]}):(0,b.jsxs)("div",{className:"flex h-screen overflow-hidden",children:[(0,b.jsx)(G,{}),(0,b.jsx)("main",{className:"min-w-0 flex-1 overflow-hidden",children:(0,b.jsx)("div",{className:"fused"===d?"h-screen flex flex-col bg-background text-foreground overflow-hidden":"h-screen flex flex-col md:rounded-l-2xl border-l border-border bg-panel text-panel-foreground overflow-hidden",style:m,children:(0,b.jsx)("div",{className:(0,n.cn)("flex-1 min-h-0",i||h?.includes("/settings")||h?.includes("/analytics")?"overflow-hidden flex flex-col":"overflow-auto"),children:(0,b.jsx)("div",{className:(0,n.cn)("h-full w-full",i||h?.includes("/settings")||h?.includes("/analytics")?"flex-1 min-h-0 flex flex-col":"container mx-auto pb-8"),children:a})})})})]})}],881150)},316105,a=>{"use strict";var b=a.i(360809),c=a.i(717383),d=a.i(93718),e=a.i(887556),f=a.i(113413),g=a.i(326729);let h=(0,g.default)("boxes",[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]]);var i=a.i(489132);let j=(0,g.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);var k=a.i(486903),l=a.i(733105);let m=(0,g.default)("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]);var n=a.i(99109),o=a.i(671008),p=a.i(22496),q=a.i(426490);let r=(0,g.default)("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);var s=a.i(953191),t=a.i(96607),u=a.i(541487),v=a.i(655208),w=a.i(299574),x=a.i(483115),y=a.i(95507),z=a.i(635153),A=a.i(717994),B=a.i(343578);let C=a=>fetch(a).then(a=>a.json()),D=["chunking","embedding","upserting"];function E({open:a,onOpenChange:g,trigger:h}){let[i,j]=(0,e.useState)(!1),[k,l]=(0,e.useState)(!1),m=void 0!==a,r=m?a:k,s=m&&g?g:l,{data:t,isLoading:v,mutate:w}=(0,c.default)("/api/index",C,{refreshInterval:a=>a?.run&&D.includes(a.run.status)?1e3:0}),G=(0,e.useRef)(void 0);(0,e.useEffect)(()=>{let a=t?.run?.warning;a&&a!==G.current?z.toast.warning(a,{id:"rate-limit-warning",duration:7e4}):!a&&G.current&&(z.toast.dismiss("rate-limit-warning"),z.toast.success("Rate limit resolved — resuming indexing.",{duration:3e3})),G.current=a},[t?.run?.warning]);let[I,J]=(0,e.useState)(!1);async function K(a=!1){j(!0);try{let b=await fetch("/api/index",{method:"POST",body:JSON.stringify({incremental:a}),headers:{"Content-Type":"application/json"}}),c=await b.json();if(!b.ok)return void z.toast.error(c.error??"Could not start indexing.");z.toast.success("Indexing started."),w()}catch{z.toast.error("Could not start indexing.")}finally{j(!1)}}async function L(){j(!0);try{if(!(await fetch("/api/index",{method:"DELETE"})).ok)return void z.toast.error("Could not cancel indexing.");z.toast.success("Indexing cancelled."),w()}catch{z.toast.error("Could not cancel indexing.")}finally{j(!1)}}return(0,e.useEffect)(()=>{let a=t?.run?.status;a&&D.includes(a)?J(!0):I&&"completed"===a&&(J(!1),s(!1),z.toast.success("Indexing completed successfully!"))},[t?.run?.status,I,s]),(0,b.jsxs)(B.Dialog,{open:r,onOpenChange:s,children:[h?(0,b.jsx)(B.DialogTrigger,{render:(0,e.isValidElement)(h)?h:(0,b.jsx)("button",{children:h})}):(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t?.run?.status==="completed"&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i,variant:"outline",children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index Data"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),(0,b.jsx)(B.DialogTrigger,{render:(0,b.jsxs)(u.Button,{disabled:!t?.ready||t?.unindexedCount===0,children:[(0,b.jsx)(o.Layers,{className:"size-4 mr-2"}),"Index Data"]})})]}),(0,b.jsxs)(B.DialogContent,{className:"max-w-2xl max-h-[90vh] overflow-y-auto ",children:[(0,b.jsxs)(B.DialogHeader,{children:[(0,b.jsx)(B.DialogTitle,{children:"Index Data"}),(0,b.jsx)(B.DialogDescription,{children:"Chunk, embed, and index into your selected vector database."})]}),v||!t?(0,b.jsx)("div",{className:"py-6",children:(0,b.jsx)(y.Skeleton,{className:"h-40 w-full"})}):(0,b.jsxs)("div",{className:"space-y-6 py-4",children:[(0,b.jsx)(F,{config:t.config,docCount:t.docCount,charCount:t.charCount}),!t.ready&&(0,b.jsxs)(x.Alert,{variant:"default",children:[(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-orange-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-orange-500!",children:"Not ready to index"}),(0,b.jsx)(x.AlertDescription,{children:(0,b.jsx)("ul",{className:"list-disc pl-4",children:t.blockers.map(a=>(0,b.jsx)("li",{children:a},a))})})]}),(0,b.jsx)(H,{run:t.run,running:!!(t.run&&D.includes(t.run.status))}),t.ready&&!t.run&&(0,b.jsxs)(x.Alert,{children:[(0,b.jsx)(n.Info,{className:"size-4 text-blue-500!"}),(0,b.jsx)(x.AlertTitle,{className:"text-blue-600 dark:text-blue-400",children:"Before you start indexing"}),(0,b.jsxs)(x.AlertDescription,{className:"text-muted-foreground space-y-1",children:[(0,b.jsxs)("p",{children:["Once indexing begins, two settings become"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"locked"})," to the existing index:"]}),(0,b.jsxs)("ul",{className:"list-disc pl-4 space-y-0.5",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Embedding model"})," — you can swap to any model with the"," ",(0,b.jsx)("span",{className:"font-medium text-foreground",children:"same vector dimensions"}),", but switching to a model with different dimensions will require a full re-index."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-medium text-foreground",children:"Vector store"})," — changing the store after indexing requires starting fresh."]})]})]})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)(u.Button,{onClick:()=>K(t.run?.status==="completed"),disabled:!t.ready||!!(t.run&&D.includes(t.run.status))||i||t.run?.status==="completed"&&0===t.unindexedCount,size:"lg",children:[t.run&&D.includes(t.run.status)||i?(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin mr-2"}):(0,b.jsx)(p.Play,{className:"size-4 mr-2"}),t.run&&D.includes(t.run.status)?"Indexing…":i?"Starting…":t.run?.status==="completed"?`Index new documents (${t.unindexedCount})`:`Start indexing (${t.unindexedCount})`]}),t.run?.status==="completed"&&!(t.run&&D.includes(t.run.status))&&(0,b.jsxs)(A.AlertDialog,{children:[(0,b.jsx)(A.AlertDialogTrigger,{render:(0,b.jsxs)(u.Button,{variant:"outline",size:"lg",disabled:i,children:[(0,b.jsx)(q.RotateCcw,{className:"size-4 mr-2"}),"Re-Index All"]})}),(0,b.jsxs)(A.AlertDialogContent,{children:[(0,b.jsxs)(A.AlertDialogHeader,{children:[(0,b.jsx)(A.AlertDialogTitle,{children:"Are you sure you want to re-index data?"}),(0,b.jsx)(A.AlertDialogDescription,{children:"This will rebuild the entire index from scratch. All documents will be re-processed."})]}),(0,b.jsxs)(A.AlertDialogFooter,{children:[(0,b.jsx)(A.AlertDialogCancel,{children:"Cancel"}),(0,b.jsx)(A.AlertDialogAction,{onClick:()=>{s(!0),K(!1)},children:"Continue"})]})]})]}),!!(t.run&&D.includes(t.run.status))&&(0,b.jsx)(u.Button,{onClick:L,disabled:i,size:"lg",variant:"destructive",children:"Cancel"})]}),(0,b.jsx)(u.Button,{variant:"ghost",size:"lg",onClick:()=>s(!1),children:"Close"})]})]})]})]})}function F({config:a,docCount:c,charCount:d}){let e=(0,s.getEmbeddingModel)(a.embeddingModelId),f=(0,t.getVectorStore)(a.vectorStore),g=[{icon:j,label:"Embedding model",value:e?.label??a.embeddingModelId,hint:e?`${e.dimensions} dims`:void 0},{icon:k.Database,label:"Vector store",value:f?.label??a.vectorStore},{icon:h,label:"Index type",value:a.indexType.toUpperCase()},{icon:r,label:"Chunking",value:`${a.chunking.chunkSize} / ${a.chunking.chunkOverlap}`,hint:"size / overlap"},{icon:l.FileText,label:"Corpus",value:`${c.toLocaleString()} docs`,hint:`${d.toLocaleString()} chars`}];return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold mb-4",children:[(0,b.jsx)(o.Layers,{className:"size-4 text-primary"}),"Index configuration"]}),(0,b.jsx)("dl",{className:"grid grid-cols-2 gap-x-6 gap-y-5 sm:grid-cols-3",children:g.map(a=>(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("dt",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,b.jsx)(a.icon,{className:"size-3.5"}),a.label]}),(0,b.jsxs)("dd",{className:"text-sm font-medium leading-tight",children:[a.value,a.hint&&(0,b.jsx)("span",{className:"ml-1.5 font-mono text-[11px] font-normal text-muted-foreground",children:a.hint})]})]},a.label))})]})}let G={idle:{label:"Idle"},chunking:{label:"Chunking",phase:"Splitting documents into chunks"},embedding:{label:"Embedding",phase:"Generating vector embeddings"},upserting:{label:"Storing",phase:"Writing vectors to the store"},completed:{label:"Completed"},failed:{label:"Failed"}};function H({run:a,running:c}){if(!a)return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground flex flex-col items-center justify-center gap-1 py-8 text-center",children:[(0,b.jsx)(m,{className:"mb-1 size-6 text-muted-foreground/60"}),(0,b.jsx)("p",{className:"text-sm font-medium",children:"No index built yet"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Build a Larkup index to embed your corpus and make it searchable."})]});let e=G[a.status],g=a.totalChunks>0?Math.round(a.processedChunks/a.totalChunks*100):5*!!c;return(0,b.jsxs)("div",{className:"rounded-xl border bg-card text-card-foreground p-4 space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-row items-center justify-between",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 text-base font-semibold",children:["completed"===a.status?(0,b.jsx)(i.CheckCircle2,{className:"size-4 text-primary"}):"failed"===a.status?(0,b.jsx)(f.AlertTriangle,{className:"size-4 text-destructive"}):(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),e.label]}),(0,b.jsx)(J,{status:a.status})]}),"failed"===a.status?(0,b.jsx)(b.Fragment,{}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:e.phase??"Done"}),(0,b.jsxs)("span",{className:"font-mono tabular-nums",children:[a.processedChunks.toLocaleString(),a.totalChunks>0&&` / ${a.totalChunks.toLocaleString()}`," chunks"]})]}),(0,b.jsx)(v.Progress,{value:g,className:"**:data-[slot=progress-indicator]:bg-green-600"})]}),(0,b.jsxs)("dl",{className:"grid grid-cols-2 gap-4 pt-1 sm:grid-cols-4",children:[(0,b.jsx)(I,{label:"Documents",value:a.docCount.toLocaleString()}),(0,b.jsx)(I,{label:"Chunks",value:a.totalChunks.toLocaleString()}),(0,b.jsx)(I,{label:"Dimensions",value:a.dimensions?a.dimensions.toLocaleString():"—"}),(0,b.jsx)(I,{label:"Duration",value:a.durationMs?`${(a.durationMs/1e3).toFixed(1)}s`:c?"running…":"—"})]})]})]})}function I({label:a,value:c}){return(0,b.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,b.jsx)("dt",{className:"text-xs text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"font-mono text-sm tabular-nums",children:c})]})}function J({status:a}){return"completed"===a?(0,b.jsx)(w.Badge,{className:"bg-primary/12 text-primary hover:bg-primary/12",children:"Ready"}):"failed"===a?(0,b.jsx)(w.Badge,{variant:"destructive",children:"Failed"}):D.includes(a)?(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-green-600",children:[(0,b.jsxs)("span",{className:"relative flex size-2",children:[(0,b.jsx)("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-600 opacity-75"}),(0,b.jsx)("span",{className:"relative inline-flex size-2 rounded-full bg-green-600"})]}),"Live"]}):null}let K=a=>fetch(a).then(a=>a.json()),L=["chunking","embedding","upserting"];a.s(["GlobalIndexProgress",0,function(){let{data:a}=(0,c.default)("/api/index",K,{refreshInterval:a=>a?.run&&L.includes(a.run.status)?1e3:0});if(!(a?.run&&L.includes(a.run.status))||!a?.run)return null;let{run:e}=a,f=e.totalChunks>0?Math.round(e.processedChunks/e.totalChunks*100):5;return(0,b.jsx)("div",{className:"fixed bottom-6 right-6 z-50",children:(0,b.jsx)(E,{trigger:(0,b.jsxs)("button",{className:"flex items-center gap-3 rounded-full border bg-background px-4 py-2 text-sm font-medium transition-all hover:bg-muted/50 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[(0,b.jsx)(d.Loader2,{className:"size-4 animate-spin text-primary"}),(0,b.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,b.jsx)("span",{className:"text-xs leading-none text-muted-foreground",children:"Storing..."}),(0,b.jsxs)("span",{className:"leading-none",children:[f,"%"]})]})]})})})}],316105)},150760,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=a.i(216615),e=a.i(567087),f=a.i(536095),g=a.i(50667),h=a.i(541487);let i={docker:"docker compose pull && docker compose up -d",npm:"larkup update"};a.s(["UpdateBanner",0,function(){let[j,k]=(0,c.useState)(null),[l,m]=(0,c.useState)(!1),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(!1),r="0.1.28",s="true"===process.env.NEXT_PUBLIC_DOCKER_ENV||"true"===process.env.NEXT_PUBLIC_RUNNING_IN_DOCKER?"docker":"npm";(0,c.useEffect)(()=>{},[r]);let t=async()=>{if("desktop"===s){o(!0);try{let{check:b}=await a.A(914053),{relaunch:c}=await a.A(69832),d=await b();d?(await d.downloadAndInstall(),await c()):o(!1)}catch(a){console.error("Auto-update failed:",a),o(!1),window.open("https://larkup.de/download","_blank")}}else try{await navigator.clipboard.writeText(i[s]),q(!0),window.setTimeout(()=>q(!1),2e3)}catch(a){console.error("Could not copy update command:",a)}};return l&&j?(0,b.jsx)("div",{role:"status","aria-live":"polite",className:"relative z-50 border-b border-border bg-background px-3 py-2 text-foreground sm:px-4",children:(0,b.jsxs)("div",{className:"mx-auto flex min-h-7 max-w-screen-2xl items-center gap-2.5",children:[(0,b.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full bg-foreground text-background",children:(0,b.jsx)(d.ArrowUp,{className:"size-3.5","aria-hidden":"true"})}),(0,b.jsxs)("p",{className:"min-w-0 text-xs sm:text-sm",children:[(0,b.jsxs)("span",{className:"font-medium",children:["Larkup v",j," is available."]})," ",(0,b.jsxs)("span",{className:"hidden text-muted-foreground sm:inline",children:["You're using v",r,"."]})]}),"desktop"!==s&&(0,b.jsx)("code",{className:"ml-auto hidden max-w-[38rem] truncate rounded-[5px] border border-border bg-muted/40 px-2 py-1 font-mono text-[11px] text-muted-foreground lg:block",children:i[s]}),(0,b.jsx)(h.Button,{type:"button",variant:"desktop"===s?"default":"outline",size:"xs",onClick:t,disabled:n,"aria-label":"desktop"===s?"Update Larkup now":"Copy update command",className:"desktop"===s?"ml-auto":"ml-auto lg:ml-0",children:"desktop"===s?n?"Updating...":"Update now":p?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(e.Check,{"aria-hidden":"true"}),"Copied"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Copy,{"aria-hidden":"true"}),"Copy command"]})}),(0,b.jsx)(h.Button,{type:"button",variant:"ghost",size:"icon-xs",onClick:()=>{try{localStorage.setItem("larkup-update-dismissed",JSON.stringify({timestamp:Date.now()}))}catch{}m(!1)},"aria-label":"Dismiss update notification",title:"Remind me tomorrow",children:(0,b.jsx)(g.X,{"aria-hidden":"true"})})]})}):null}])}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=_1yqlx1m._.js.map
|
package/.next/server/chunks/ssr/apps_web_components_analytics_analytics-dashboard_tsx_1056-z3._.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[231619,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=a.i(527178),e=a.i(896728),f=a.i(989933),g=a.i(42050),h=a.i(361771),i=a.i(396744),j=a.i(54782),k=a.i(982048),l=a.i(383236),m=a.i(332714),n=a.i(75036),o=a.i(555404),p=a.i(326729);let q=(0,p.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var r=a.i(486903),s=a.i(93718);let t=(0,p.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var u=a.i(491543),v=a.i(717383);let w=a=>fetch(a).then(a=>a.json());function x(a,b,c){if("all"===b||!a)return a||[];let d=30;"7d"===b?d=7:"14d"===b?d=14:"30d"===b?d=30:"90d"===b&&(d=90);let e=[],f=new Date,g=new Map(a.map(a=>[a.date,a]));for(let a=d-1;a>=0;a--){let b=new Date(f);b.setDate(b.getDate()-a);let d=b.toISOString().split("T")[0];g.has(d)?e.push(g.get(d)):e.push({date:d,...c()})}return e}function y(a){return(a/1e6).toFixed(2)+"M"}a.s(["AnalyticsDashboard",0,function(){var a;let[p,z]=(0,c.useState)("overview"),[A,B]=(0,c.useState)("14d"),{data:C,isLoading:D,error:E}=(0,v.default)(`/api/analytics?timeframe=${A}`,w);if(D)return(0,b.jsxs)("div",{className:"p-8 flex-col gap-2 text-center text-muted-foreground animate-pulse flex items-center justify-center h-full",children:[(0,b.jsx)(s.Loader2,{className:"size-6 animate-spin"}),(0,b.jsx)("span",{className:"text-[15px]",children:"Loading analytics data..."})]});if(E||!C)return(0,b.jsx)("div",{className:"p-8 text-center text-destructive",children:"Failed to load analytics data."});let F=!C.serverTimeSeries?.length||C.serverTimeSeries.every(a=>0===a.requests),G=!C.embeddingTimeSeries?.length||C.embeddingTimeSeries.every(a=>0===a.tokens),H=!C.chatTimeSeries?.length||C.chatTimeSeries.every(a=>0===a.tokens),I=({title:a,description:c})=>(0,b.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-md",children:(0,b.jsxs)("div",{className:"flex flex-col items-center space-y-2 dark:bg-zinc-900/90 px-5 py-4 rounded-lg max-w-xl text-center",children:[(0,b.jsx)("div",{className:"p-2 border border-border/70 rounded-lg bg-white",children:(0,b.jsx)(q,{className:"size-6 text-black/80"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-[16px] font-semibold text-foreground",children:a}),(0,b.jsx)("p",{className:"text-[13px] text-muted-foreground",children:c})]})]})});return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Total Cost"}),(0,b.jsx)(q,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:0===(a=C.totalCost)?"$0.00":a<.01?a<1e-4?"<$0.0001":`$${a.toFixed(4)}`:`$${a.toFixed(2)}`}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Across all paid models"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Chat Tokens"}),(0,b.jsx)(t,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:y(C.totalChatTokens)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed in conversations"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Embedding Tokens"}),(0,b.jsx)(r.Database,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:y(C.totalEmbeddingTokens)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed during indexing"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Total Requests"}),(0,b.jsx)(u.Zap,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:C.totalRequests.toLocaleString()}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"To local RAG server this week"})]})]})]}),(0,b.jsxs)(n.Tabs,{value:p,onValueChange:z,className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,b.jsxs)(n.TabsList,{className:"inline-flex bg-white/70 dark:bg-muted/70 h-9 items-center justify-center rounded-lg border border-border p-0.5 text-muted-foreground",children:[(0,b.jsxs)(n.TabsTrigger,{value:"overview",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(q,{className:"size-3.5 mr-1.5"}),"Server Traffic"]}),(0,b.jsxs)(n.TabsTrigger,{value:"indexing",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(r.Database,{className:"size-3.5 mr-1.5"}),"Indexing Usage"]}),(0,b.jsxs)(n.TabsTrigger,{value:"chat",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(t,{className:"size-3.5 mr-1.5"}),"Chat Usage"]})]}),(0,b.jsx)("div",{className:"flex items-center",children:(0,b.jsxs)(o.Select,{value:A,onValueChange:a=>a&&B(a),children:[(0,b.jsx)(o.SelectTrigger,{className:"w-[140px] h-10! text-sm bg-white dark:bg-background focus:ring-0 focus:border-input data-[state=open]:ring-0 data-[state=open]:border-input outline-none focus:outline-none",children:(0,b.jsxs)(o.SelectValue,{placeholder:"Select timeframe",children:["7d"===A&&"Last 7 days","14d"===A&&"Last 14 days","30d"===A&&"Last 30 days","90d"===A&&"Last 90 days","all"===A&&"All time"]})}),(0,b.jsxs)(o.SelectContent,{children:[(0,b.jsx)(o.SelectItem,{value:"7d",children:"Last 7 days"}),(0,b.jsx)(o.SelectItem,{value:"14d",children:"Last 14 days"}),(0,b.jsx)(o.SelectItem,{value:"30d",children:"Last 30 days"}),(0,b.jsx)(o.SelectItem,{value:"90d",children:"Last 90 days"}),(0,b.jsx)(o.SelectItem,{value:"all",children:"All time"})]})]})})]}),(0,b.jsx)(n.TabsContent,{value:"overview",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none! rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Requests to RAG Server"}),(0,b.jsx)(m.CardDescription,{children:"Daily requests sent to your local or remote deployed RAG endpoints."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[F&&(0,b.jsx)(I,{title:"No Server Traffic Yet",description:"Once you start sending requests to the RAG server, usage will appear here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(g.BarChart,{data:x(C.serverTimeSeries,A,()=>({requests:0,avgLatencyMs:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"},cursor:{fill:"var(--color-muted)",opacity:.4}}),(0,b.jsx)(f.Bar,{dataKey:"requests",fill:"#3b82f6",radius:[4,4,0,0],maxBarSize:40,activeBar:{className:"outline-none focus:outline-none"}})]})})]})})]})}),(0,b.jsx)(n.TabsContent,{value:"indexing",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Indexing Token Usage"}),(0,b.jsx)(m.CardDescription,{children:"Daily tokens processed for document indexing."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[G&&(0,b.jsx)(I,{title:"No Indexing Data Yet",description:"Add documents to your knowledge bases to see embedding token usage here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(e.AreaChart,{data:x(C.embeddingTimeSeries,A,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)("defs",{children:(0,b.jsxs)("linearGradient",{id:"colorIndexing",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"5%",stopColor:"#f97316",stopOpacity:.3}),(0,b.jsx)("stop",{offset:"95%",stopColor:"#f97316",stopOpacity:0})]})}),(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a>=1e3?a/1e3+"k":a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,b.jsx)(d.Area,{type:"monotone",dataKey:"tokens",stroke:"#f97316",strokeWidth:2,fillOpacity:1,fill:"url(#colorIndexing)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})}),(0,b.jsx)(n.TabsContent,{value:"chat",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Chat Token Usage"}),(0,b.jsx)(m.CardDescription,{children:"Daily tokens processed for chat completions."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[H&&(0,b.jsx)(I,{title:"No Chat Data Yet",description:"Chat with the AI to see your token usage metrics here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(e.AreaChart,{data:x(C.chatTimeSeries,A,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)("defs",{children:(0,b.jsxs)("linearGradient",{id:"colorChat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),(0,b.jsx)("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a>=1e3?a/1e3+"k":a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,b.jsx)(d.Area,{type:"monotone",dataKey:"tokens",stroke:"#3b82f6",strokeWidth:2,fillOpacity:1,fill:"url(#colorChat)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})})]})]})}],231619)}];
|
|
1
|
+
module.exports=[231619,a=>{"use strict";var b=a.i(360809),c=a.i(887556),d=a.i(527178),e=a.i(896728),f=a.i(989933),g=a.i(42050),h=a.i(361771),i=a.i(396744),j=a.i(54782),k=a.i(982048),l=a.i(383236),m=a.i(332714),n=a.i(75036),o=a.i(555404),p=a.i(326729);let q=(0,p.default)("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);var r=a.i(486903),s=a.i(93718);let t=(0,p.default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);var u=a.i(491543),v=a.i(717383);let w=a=>fetch(a).then(a=>a.json());function x(a,b,c){if("all"===b||!a)return a||[];let d=30;"7d"===b?d=7:"14d"===b?d=14:"30d"===b?d=30:"90d"===b&&(d=90);let e=[],f=new Date,g=new Map(a.map(a=>[a.date,a]));for(let a=d-1;a>=0;a--){let b=new Date(f);b.setDate(b.getDate()-a);let d=b.toISOString().split("T")[0];g.has(d)?e.push(g.get(d)):e.push({date:d,...c()})}return e}function y(a){return(a/1e6).toFixed(2)+"M"}a.s(["AnalyticsDashboard",0,function(){var a;let[p,z]=(0,c.useState)("overview"),[A,B]=(0,c.useState)("14d"),{data:C,isLoading:D,error:E}=(0,v.default)(`/api/analytics?timeframe=${A}`,w);if(D)return(0,b.jsxs)("div",{className:"p-8 flex-col gap-2 text-center text-muted-foreground animate-pulse flex items-center justify-center h-full",children:[(0,b.jsx)(s.Loader2,{className:"size-6 animate-spin"}),(0,b.jsx)("span",{className:"text-[15px]",children:"Loading analytics data..."})]});if(E||!C)return(0,b.jsx)("div",{className:"p-8 text-center text-destructive",children:"Failed to load analytics data."});let F=!C.serverTimeSeries?.length||C.serverTimeSeries.every(a=>0===a.requests),G=!C.embeddingTimeSeries?.length||C.embeddingTimeSeries.every(a=>0===a.tokens),H=!C.chatTimeSeries?.length||C.chatTimeSeries.every(a=>0===a.tokens),I=({title:a,description:c})=>(0,b.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-md",children:(0,b.jsxs)("div",{className:"flex flex-col items-center space-y-2 dark:bg-zinc-900/90 px-5 py-4 rounded-lg max-w-xl text-center",children:[(0,b.jsx)("div",{className:"p-2 border border-border/70 rounded-lg bg-white",children:(0,b.jsx)(q,{className:"size-6 text-black/80"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-[16px] font-semibold text-foreground",children:a}),(0,b.jsx)("p",{className:"text-[13px] text-muted-foreground",children:c})]})]})});return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Total Cost"}),(0,b.jsx)(q,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:0===(a=C.totalCost)?"$0.00":a<.01?a<1e-4?"<$0.0001":`$${a.toFixed(4)}`:`$${a.toFixed(2)}`}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Across all paid models"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Chat Tokens"}),(0,b.jsx)(t,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:y(C.totalChatTokens)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed in conversations"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Embedding Tokens"}),(0,b.jsx)(r.Database,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:y(C.totalEmbeddingTokens)}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Processed during indexing"})]})]}),(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,b.jsx)(m.CardTitle,{className:"text-sm font-medium",children:"Total Requests"}),(0,b.jsx)(u.Zap,{className:"size-4 text-muted-foreground"})]}),(0,b.jsxs)(m.CardContent,{children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:C.totalRequests.toLocaleString()}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"To local RAG server this week"})]})]})]}),(0,b.jsxs)(n.Tabs,{value:p,onValueChange:z,className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[(0,b.jsxs)(n.TabsList,{className:"inline-flex bg-white/70 dark:bg-muted/70 h-9 items-center justify-center rounded-lg border border-border p-0.5 text-muted-foreground",children:[(0,b.jsxs)(n.TabsTrigger,{value:"indexing",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(r.Database,{className:"size-3.5 mr-1.5"}),"Indexing Usage"]}),(0,b.jsxs)(n.TabsTrigger,{value:"chat",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(t,{className:"size-3.5 mr-1.5"}),"Chat Usage"]}),(0,b.jsxs)(n.TabsTrigger,{value:"overview",className:"inline-flex items-center h-9 justify-center whitespace-nowrap rounded-md px-3 py-1 text-xs font-medium transition-all focus-visible:outline-none data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]: hover:text-foreground",children:[(0,b.jsx)(q,{className:"size-3.5 mr-1.5"}),"Server Traffic"]})]}),(0,b.jsx)("div",{className:"flex items-center",children:(0,b.jsxs)(o.Select,{value:A,onValueChange:a=>a&&B(a),children:[(0,b.jsx)(o.SelectTrigger,{className:"w-[140px] h-10! text-sm bg-white dark:bg-background focus:ring-0 focus:border-input data-[state=open]:ring-0 data-[state=open]:border-input outline-none focus:outline-none",children:(0,b.jsxs)(o.SelectValue,{placeholder:"Select timeframe",children:["7d"===A&&"Last 7 days","14d"===A&&"Last 14 days","30d"===A&&"Last 30 days","90d"===A&&"Last 90 days","all"===A&&"All time"]})}),(0,b.jsxs)(o.SelectContent,{children:[(0,b.jsx)(o.SelectItem,{value:"7d",children:"Last 7 days"}),(0,b.jsx)(o.SelectItem,{value:"14d",children:"Last 14 days"}),(0,b.jsx)(o.SelectItem,{value:"30d",children:"Last 30 days"}),(0,b.jsx)(o.SelectItem,{value:"90d",children:"Last 90 days"}),(0,b.jsx)(o.SelectItem,{value:"all",children:"All time"})]})]})})]}),(0,b.jsx)(n.TabsContent,{value:"overview",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none! rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Requests to RAG Server"}),(0,b.jsx)(m.CardDescription,{children:"Daily requests sent to your local or remote deployed RAG endpoints."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[F&&(0,b.jsx)(I,{title:"No Server Traffic Yet",description:"Once you start sending requests to the RAG server, usage will appear here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(g.BarChart,{data:x(C.serverTimeSeries,A,()=>({requests:0,avgLatencyMs:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"},cursor:{fill:"var(--color-muted)",opacity:.4}}),(0,b.jsx)(f.Bar,{dataKey:"requests",fill:"#3b82f6",radius:[4,4,0,0],maxBarSize:40,activeBar:{className:"outline-none focus:outline-none"}})]})})]})})]})}),(0,b.jsx)(n.TabsContent,{value:"indexing",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Indexing Token Usage"}),(0,b.jsx)(m.CardDescription,{children:"Daily tokens processed for document indexing."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[G&&(0,b.jsx)(I,{title:"No Indexing Data Yet",description:"Add documents to your knowledge bases to see embedding token usage here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(e.AreaChart,{data:x(C.embeddingTimeSeries,A,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)("defs",{children:(0,b.jsxs)("linearGradient",{id:"colorIndexing",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"5%",stopColor:"#f97316",stopOpacity:.3}),(0,b.jsx)("stop",{offset:"95%",stopColor:"#f97316",stopOpacity:0})]})}),(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a>=1e3?a/1e3+"k":a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,b.jsx)(d.Area,{type:"monotone",dataKey:"tokens",stroke:"#f97316",strokeWidth:2,fillOpacity:1,fill:"url(#colorIndexing)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})}),(0,b.jsx)(n.TabsContent,{value:"chat",className:"space-y-4",children:(0,b.jsxs)(m.Card,{className:"shadow-none rounded-xl",children:[(0,b.jsxs)(m.CardHeader,{children:[(0,b.jsx)(m.CardTitle,{children:"Chat Token Usage"}),(0,b.jsx)(m.CardDescription,{children:"Daily tokens processed for chat completions."})]}),(0,b.jsx)(m.CardContent,{className:"px-2 sm:p-6",children:(0,b.jsxs)("div",{className:"h-[300px] w-full relative",children:[H&&(0,b.jsx)(I,{title:"No Chat Data Yet",description:"Chat with the AI to see your token usage metrics here."}),(0,b.jsx)(i.ResponsiveContainer,{width:"100%",height:"100%",className:"[&_.recharts-surface]:outline-none [&_.recharts-wrapper]:outline-none",children:(0,b.jsxs)(e.AreaChart,{data:x(C.chatTimeSeries,A,()=>({tokens:0,cost:0,requests:0})),margin:{top:10,right:30,left:0,bottom:0},children:[(0,b.jsx)("defs",{children:(0,b.jsxs)("linearGradient",{id:"colorChat",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,b.jsx)("stop",{offset:"5%",stopColor:"#3b82f6",stopOpacity:.3}),(0,b.jsx)("stop",{offset:"95%",stopColor:"#3b82f6",stopOpacity:0})]})}),(0,b.jsx)(h.CartesianGrid,{strokeDasharray:"3 3",vertical:!1,stroke:"currentColor",strokeOpacity:.1}),(0,b.jsx)(k.XAxis,{dataKey:"date",stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,minTickGap:20,tickFormatter:a=>{if(!a.includes("-"))return a;let[b,c,d]=a.split("-");return new Date(parseInt(b,10),parseInt(c,10)-1,parseInt(d,10)).toLocaleDateString("en-US",{month:"short",day:"numeric"})}}),(0,b.jsx)(l.YAxis,{allowDecimals:!1,stroke:"currentColor",strokeOpacity:.5,fontSize:12,tickLine:!1,axisLine:!1,tickFormatter:a=>`${a>=1e3?a/1e3+"k":a}`}),(0,b.jsx)(j.Tooltip,{contentStyle:{backgroundColor:"var(--color-background)",borderColor:"var(--color-border)",borderRadius:"8px"},itemStyle:{color:"var(--color-foreground)"}}),(0,b.jsx)(d.Area,{type:"monotone",dataKey:"tokens",stroke:"#3b82f6",strokeWidth:2,fillOpacity:1,fill:"url(#colorChat)",activeDot:{r:4,className:"outline-none focus:outline-none",strokeWidth:0}})]})})]})})]})})]})]})}],231619)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=apps_web_components_analytics_analytics-dashboard_tsx_1056-z3._.js.map
|
|
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
|
|
|
7
7
|
"static/chunks/0cz1d0mv5g_q7.js"
|
|
8
8
|
],
|
|
9
9
|
"lowPriorityFiles": [
|
|
10
|
-
"static/
|
|
11
|
-
"static/
|
|
12
|
-
"static/
|
|
10
|
+
"static/bDwMIFYSTVBKUJkJJx77o/_buildManifest.js",
|
|
11
|
+
"static/bDwMIFYSTVBKUJkJJx77o/_ssgManifest.js",
|
|
12
|
+
"static/bDwMIFYSTVBKUJkJJx77o/_clientMiddlewareManifest.js"
|
|
13
13
|
],
|
|
14
14
|
"rootMainFiles": [
|
|
15
15
|
"static/chunks/27fi1xpxq8d86.js",
|