sqlbot 0.0.1 → 0.0.11
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/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/server/app/(chat)/ai-providers/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/chat/[threadId]/page.js +2 -2
- package/.next/standalone/.next/server/app/(chat)/chat/[threadId]/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(chat)/chat/[threadId]/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/connections/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/knowledge-base/page.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/knowledge-base/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(chat)/knowledge-base/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/page.js +1 -1
- package/.next/standalone/.next/server/app/(chat)/page.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/(chat)/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +2 -2
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/ai-providers.html +1 -1
- package/.next/standalone/.next/server/app/ai-providers.rsc +3 -3
- package/.next/standalone/.next/server/app/ai-providers.segments/!KGNoYXQp/ai-providers/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/ai-providers.segments/!KGNoYXQp/ai-providers.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/ai-providers.segments/!KGNoYXQp.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/ai-providers.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/ai-providers.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/ai-providers.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/api/chat/route.js +1 -1
- package/.next/standalone/.next/server/app/api/chat/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/health/route.js +1 -1
- package/.next/standalone/.next/server/app/api/health/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/knowledge/auto-generate/route.js +1 -1
- package/.next/standalone/.next/server/app/api/knowledge/auto-generate/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/knowledge/generate/route.js +1 -1
- package/.next/standalone/.next/server/app/api/knowledge/generate/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/trpc/[trpc]/route.js +3 -3
- package/.next/standalone/.next/server/app/api/trpc/[trpc]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/connections.html +1 -1
- package/.next/standalone/.next/server/app/connections.rsc +3 -3
- package/.next/standalone/.next/server/app/connections.segments/!KGNoYXQp/connections/__PAGE__.segment.rsc +2 -2
- package/.next/standalone/.next/server/app/connections.segments/!KGNoYXQp/connections.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/connections.segments/!KGNoYXQp.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/connections.segments/_full.segment.rsc +3 -3
- package/.next/standalone/.next/server/app/connections.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/connections.segments/_tree.segment.rsc +2 -2
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__1f49434f._.js +3 -0
- package/.next/standalone/.next/server/chunks/{[root-of-the-server]__51b79d66._.js → [root-of-the-server]__3a1fb665._.js} +6 -6
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__73947e32._.js +3 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__747722f0._.js +85 -0
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__ca89cb1f._.js +85 -0
- package/.next/standalone/.next/server/chunks/_26ec1867._.js +13 -13
- package/.next/standalone/.next/server/chunks/_430c5305._.js +13 -13
- package/.next/standalone/.next/server/chunks/_44fa1f03._.js +1 -1
- package/.next/standalone/.next/server/chunks/_75b542e9._.js +1 -1
- package/.next/standalone/.next/server/chunks/_82e2d86b._.js +11 -11
- package/.next/standalone/.next/server/chunks/_c49f2a1f._.js +13 -13
- package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__d8a3f2e3._.js → [root-of-the-server]__1ad22765._.js} +2 -2
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__2534236b._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__77c3448a._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__85abb029._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__d2e81be0._.js +3 -0
- package/.next/standalone/.next/server/chunks/ssr/_119ae296._.js +12 -12
- package/.next/standalone/.next/server/chunks/ssr/_37f7f89d._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_components_connections_connections-page_tsx_a8fa3df0._.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/src_components_knowledge-base_knowledge-base-page_tsx_10bf7f9a._.js +1 -1
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +2 -2
- package/.next/{static/chunks/b90a78e2d36034ff.js → standalone/.next/static/chunks/00f68930e8af39f1.js} +1 -1
- package/.next/standalone/.next/static/chunks/3bd88f74116ecf0b.js +1 -0
- package/.next/standalone/.next/static/chunks/89e492a83a4b53e3.js +1 -0
- package/.next/standalone/.next/static/chunks/{842e82429bd01d96.js → a3a8f6ede99c1c63.js} +1 -1
- package/.next/standalone/README.md +1 -1
- package/.next/standalone/package.json +1 -1
- package/.next/{standalone/.next/static/chunks/b90a78e2d36034ff.js → static/chunks/00f68930e8af39f1.js} +1 -1
- package/.next/static/chunks/3bd88f74116ecf0b.js +1 -0
- package/.next/static/chunks/89e492a83a4b53e3.js +1 -0
- package/.next/static/chunks/{842e82429bd01d96.js → a3a8f6ede99c1c63.js} +1 -1
- package/README.md +1 -1
- package/package.json +1 -1
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__26852352._.js +0 -85
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__5dc46bc4._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__8992d6da._.js +0 -3
- package/.next/standalone/.next/server/chunks/[root-of-the-server]__e474c328._.js +0 -85
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0e727499._.js +0 -3
- package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__4451526a._.js +0 -3
- package/.next/standalone/.next/static/chunks/000ce5d236847e14.js +0 -1
- package/.next/standalone/.next/static/chunks/7c8dab1a077d98e9.js +0 -1
- package/.next/static/chunks/000ce5d236847e14.js +0 -1
- package/.next/static/chunks/7c8dab1a077d98e9.js +0 -1
- /package/.next/standalone/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_clientMiddlewareManifest.json +0 -0
- /package/.next/standalone/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_ssgManifest.js +0 -0
- /package/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_buildManifest.js +0 -0
- /package/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,893213,e=>{"use strict";var t=e.i(843476),s=e.i(271645),a=e.i(618566),n=e.i(672464);e.i(265172);var l=e.i(639372);let r=new WeakMap;var i=e.i(60345),o=e.i(846696),c=e.i(519455),d=e.i(515288),m=e.i(658041),h=e.i(107233);let x=(0,l.atom)({connections:[],activeConnectionId:null});var u=e.i(500932),p=e.i(522016),g=e.i(110204),f=e.i(967489),b=e.i(871689),j=e.i(810980),N=e.i(16715),w=e.i(531278),y=e.i(475254);let k=(0,y.default)("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]),v=(0,y.default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);var C=e.i(283086);let S=(0,y.default)("cable",[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]]);function B(e){let s,l,r,i,o,d,m,y,B,T,E,_,I=(0,u.c)(30),{selectedConnectionId:z,entryCount:D,isRegenerating:F,onConnectionChange:M,onAddEntry:$,onGenerateFromText:P,onAutoGenerate:O,onRegenerateEmbeddings:L}=e,R=(0,a.useRouter)(),{connections:V}=(0,n.useAtomValue)(x);return I[0]!==R?(s=()=>R.push("/"),I[0]=R,I[1]=s):s=I[1],I[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(b.ArrowLeft,{className:"h-4 w-4"}),r=(0,t.jsx)("span",{className:"hidden sm:inline",children:"Back to Chat"}),I[2]=l,I[3]=r):(l=I[2],r=I[3]),I[4]!==s?(i=(0,t.jsxs)(c.Button,{variant:"ghost",size:"sm",onClick:s,className:"gap-1.5",children:[l,r]}),I[4]=s,I[5]=i):i=I[5],I[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:"flex-1"}),d=(0,t.jsx)("h1",{className:"text-sm font-semibold",children:"CLAY"}),I[6]=o,I[7]=d):(o=I[6],d=I[7]),I[8]!==i?(m=(0,t.jsxs)("div",{className:"flex items-center gap-4",children:[i,o,d]}),I[8]=i,I[9]=m):m=I[9],I[10]===Symbol.for("react.memo_cache_sentinel")?(y=(0,t.jsxs)("div",{children:[(0,t.jsxs)("h2",{className:"text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2",children:[(0,t.jsx)(j.BookOpen,{className:"h-5 w-5 sm:h-6 sm:w-6"}),"Knowledge Base"]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"Add context about your database to help AI write better queries."})]}),I[10]=y):y=I[10],I[11]!==V.length||I[12]!==D||I[13]!==F||I[14]!==$||I[15]!==O||I[16]!==P||I[17]!==L||I[18]!==z?(B=V.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap shrink-0",children:[(0,t.jsx)(c.Button,{asChild:!0,variant:"outline",size:"sm",className:"gap-1.5 text-xs",children:(0,t.jsxs)(p.default,{href:"/connections",children:[(0,t.jsx)(S,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Connections"})]})}),(0,t.jsx)(c.Button,{asChild:!0,variant:"outline",size:"sm",className:"gap-1.5 text-xs",children:(0,t.jsxs)(p.default,{href:"/ai-providers",children:[(0,t.jsx)(C.Sparkles,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"AI Providers"})]})}),(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:O,disabled:!z,className:"gap-1.5 text-xs",children:[(0,t.jsx)(v,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Auto"})," Generate"]}),(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:P,disabled:!z,className:"gap-1.5 text-xs",children:[(0,t.jsx)(k,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"From"})," Text"]}),D>0&&(0,t.jsxs)(c.Button,{variant:"outline",size:"sm",onClick:L,disabled:!z||F,className:"gap-1.5 text-xs",title:"Regenerate vector embeddings for semantic search",children:[F?(0,t.jsx)(w.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(N.RefreshCw,{className:"h-3.5 w-3.5"}),"Rebuild"]}),(0,t.jsxs)(c.Button,{size:"sm",onClick:$,disabled:!z,className:"gap-1.5",children:[(0,t.jsx)(h.Plus,{className:"h-4 w-4"}),"Add"]})]}),I[11]=V.length,I[12]=D,I[13]=F,I[14]=$,I[15]=O,I[16]=P,I[17]=L,I[18]=z,I[19]=B):B=I[19],I[20]!==B?(T=(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-start sm:justify-between gap-4",children:[y,B]}),I[20]=B,I[21]=T):T=I[21],I[22]!==V||I[23]!==M||I[24]!==z?(E=V.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(g.Label,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Connection:"}),(0,t.jsxs)(f.Select,{value:z,onValueChange:M,children:[(0,t.jsx)(f.SelectTrigger,{className:"w-full sm:w-[280px]",children:(0,t.jsx)(f.SelectValue,{placeholder:"Select a connection"})}),(0,t.jsx)(f.SelectContent,{children:V.map(A)})]})]}),I[22]=V,I[23]=M,I[24]=z,I[25]=E):E=I[25],I[26]!==T||I[27]!==E||I[28]!==m?(_=(0,t.jsx)("header",{className:"border-b border-border/40 bg-background/80 backdrop-blur sticky top-0 z-10",children:(0,t.jsxs)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-4 space-y-4",children:[m,T,E]})}),I[26]=T,I[27]=E,I[28]=m,I[29]=_):_=I[29],_}function A(e){return(0,t.jsx)(f.SelectItem,{value:e.id,children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(m.Database,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.name,(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["(",e.type,")"]})]})},e.id)}var T=e.i(793479),E=e.i(487486),_=e.i(677572),I=e.i(555436),z=e.i(284614),D=e.i(727612);function F(e){let s,a,n,l,r,i,o,d,m,h,x,p,g,f,b=(0,u.c)(34),{searchQuery:j,onSearchChange:N,activeTab:w,onTabChange:y,totalCount:k,humanCount:v,aiCount:S,onClear:B,isClearing:A}=e,F="human"===w?v:"ai"===w?S:k,M="human"===w?"Clear Human":"ai"===w?"Clear AI":"Clear All";return b[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)(I.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),b[0]=s):s=b[0],b[1]!==N?(a=e=>N(e.target.value),b[1]=N,b[2]=a):a=b[2],b[3]!==j||b[4]!==a?(n=(0,t.jsxs)("div",{className:"relative",children:[s,(0,t.jsx)(T.Input,{placeholder:"Search knowledge base...",value:j,onChange:a,className:"pl-9"})]}),b[3]=j,b[4]=a,b[5]=n):n=b[5],b[6]!==k?(l=(0,t.jsxs)(_.TabsTrigger,{value:"all",className:"gap-1 sm:gap-1.5 flex-1 sm:flex-initial text-xs sm:text-sm",children:["All",(0,t.jsx)(E.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4",children:k})]}),b[6]=k,b[7]=l):l=b[7],b[8]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(z.User,{className:"h-3.5 w-3.5"}),i=(0,t.jsx)("span",{className:"hidden xs:inline",children:"Human"}),b[8]=r,b[9]=i):(r=b[8],i=b[9]),b[10]!==v?(o=(0,t.jsxs)(_.TabsTrigger,{value:"human",className:"gap-1 sm:gap-1.5 flex-1 sm:flex-initial text-xs sm:text-sm",children:[r,i,(0,t.jsx)(E.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4",children:v})]}),b[10]=v,b[11]=o):o=b[11],b[12]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)(C.Sparkles,{className:"h-3.5 w-3.5"}),b[12]=d):d=b[12],b[13]!==S?(m=(0,t.jsxs)(_.TabsTrigger,{value:"ai",className:"gap-1 sm:gap-1.5 flex-1 sm:flex-initial text-xs sm:text-sm",children:[d,"AI",(0,t.jsx)(E.Badge,{variant:"secondary",className:"text-[10px] px-1.5 h-4",children:S})]}),b[13]=S,b[14]=m):m=b[14],b[15]!==l||b[16]!==o||b[17]!==m?(h=(0,t.jsxs)(_.TabsList,{className:"w-full sm:w-auto",children:[l,o,m]}),b[15]=l,b[16]=o,b[17]=m,b[18]=h):h=b[18],b[19]!==w||b[20]!==y||b[21]!==h?(x=(0,t.jsx)(_.Tabs,{value:w,onValueChange:y,children:h}),b[19]=w,b[20]=y,b[21]=h,b[22]=x):x=b[22],b[23]!==F||b[24]!==M||b[25]!==A||b[26]!==B?(p=F>0&&(0,t.jsxs)(c.Button,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive hover:bg-destructive/10 gap-1.5 h-8 text-xs self-end sm:self-auto",onClick:B,disabled:A,children:[(0,t.jsx)(D.Trash2,{className:"h-3.5 w-3.5"}),M]}),b[23]=F,b[24]=M,b[25]=A,b[26]=B,b[27]=p):p=b[27],b[28]!==x||b[29]!==p?(g=(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2",children:[x,p]}),b[28]=x,b[29]=p,b[30]=g):g=b[30],b[31]!==g||b[32]!==n?(f=(0,t.jsxs)("div",{className:"space-y-3",children:[n,g]}),b[31]=g,b[32]=n,b[33]=f):f=b[33],f}let M=(0,y.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var $=e.i(246349),$=$,P=e.i(788699),O=e.i(975157);function L(e){let s,a,n,l,r,i,o,m,h,x,p,g,f,b,j,N,w,y,k=(0,u.c)(44),{entry:v,onEdit:S,onDelete:B}=e,A="ai_generated"===v.source;k[0]!==v.source?(s=(0,O.cn)("text-[10px] gap-1 shrink-0","ai_generated"===v.source?"text-purple-400 bg-purple-400/10 border-purple-400/20":"text-zinc-400 bg-zinc-400/10 border-zinc-400/20"),k[0]=v.source,k[1]=s):s=k[1],k[2]!==A?(a=A?(0,t.jsx)(C.Sparkles,{className:"h-3 w-3"}):(0,t.jsx)(z.User,{className:"h-3 w-3"}),k[2]=A,k[3]=a):a=k[3];let T=A?"AI":"Human";return k[4]!==s||k[5]!==a||k[6]!==T?(n=(0,t.jsx)("div",{className:"flex items-center gap-2 mb-1",children:(0,t.jsxs)(E.Badge,{variant:"outline",className:s,children:[a,T]})}),k[4]=s,k[5]=a,k[6]=T,k[7]=n):n=k[7],k[8]!==v.title?(l=(0,t.jsx)(d.CardTitle,{className:"text-sm font-medium wrap-break-word",children:v.title}),k[8]=v.title,k[9]=l):l=k[9],k[10]!==n||k[11]!==l?(r=(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[n,l]}),k[10]=n,k[11]=l,k[12]=r):r=k[12],k[13]!==v||k[14]!==S?(i=()=>S(v),k[13]=v,k[14]=S,k[15]=i):i=k[15],k[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(P.Pencil,{className:"h-3 w-3"}),k[16]=o):o=k[16],k[17]!==i?(m=(0,t.jsx)(c.Button,{variant:"ghost",size:"sm",onClick:i,className:"h-7 w-7 p-0",children:o}),k[17]=i,k[18]=m):m=k[18],k[19]!==v.pubId||k[20]!==v.title||k[21]!==B?(h=()=>B(v.pubId,v.title),k[19]=v.pubId,k[20]=v.title,k[21]=B,k[22]=h):h=k[22],k[23]===Symbol.for("react.memo_cache_sentinel")?(x=(0,t.jsx)(D.Trash2,{className:"h-3 w-3"}),k[23]=x):x=k[23],k[24]!==h?(p=(0,t.jsx)(c.Button,{variant:"ghost",size:"sm",onClick:h,className:"h-7 w-7 p-0 text-destructive hover:text-destructive",children:x}),k[24]=h,k[25]=p):p=k[25],k[26]!==p||k[27]!==m?(g=(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[m,p]}),k[26]=p,k[27]=m,k[28]=g):g=k[28],k[29]!==g||k[30]!==r?(f=(0,t.jsx)(d.CardHeader,{className:"p-4 sm:p-6 pb-2 sm:pb-2",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:[r,g]})}),k[29]=g,k[30]=r,k[31]=f):f=k[31],k[32]!==v.content?(b=(0,t.jsx)("p",{className:"text-xs sm:text-sm text-muted-foreground whitespace-pre-wrap line-clamp-3 sm:line-clamp-4",children:v.content}),k[32]=v.content,k[33]=b):b=k[33],k[34]!==v.createdAt?(j=new Date(v.createdAt).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"}),k[34]=v.createdAt,k[35]=j):j=k[35],k[36]!==j?(N=(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/60 mt-2",children:j}),k[36]=j,k[37]=N):N=k[37],k[38]!==b||k[39]!==N?(w=(0,t.jsxs)(d.CardContent,{className:"p-4 sm:p-6 pt-0 sm:pt-0",children:[b,N]}),k[38]=b,k[39]=N,k[40]=w):w=k[40],k[41]!==f||k[42]!==w?(y=(0,t.jsxs)(d.Card,{className:"transition-all hover:border-border/80 group",children:[f,w]}),k[41]=f,k[42]=w,k[43]=y):y=k[43],y}function R(e){let a,n,l,r,i,o,m,x,p,g=(0,u.c)(40),{entries:f,isLoading:b,searchQuery:N,onEdit:y,onDelete:k,onAddFirst:v}=e,[C,S]=(0,s.useState)(1),B=Math.max(1,Math.ceil(f.length/10));g[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{S(1)},g[0]=a):a=g[0],g[1]!==f.length||g[2]!==N?(n=[f.length,N],g[1]=f.length,g[2]=N,g[3]=n):n=g[3],(0,s.useEffect)(a,n),g[4]!==C||g[5]!==B?(l=()=>{C>B&&S(B)},r=[C,B],g[4]=C,g[5]=B,g[6]=l,g[7]=r):(l=g[6],r=g[7]),(0,s.useEffect)(l,r);let A=(C-1)*10;g[8]!==f||g[9]!==A?(i=f.slice(A,A+10),g[8]=f,g[9]=A,g[10]=i):i=g[10];let T=i;if(b){let e;return g[11]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,t.jsx)(w.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),g[11]=e):e=g[11],e}if(0===f.length){let e,s,a,n,l;g[12]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("div",{className:"rounded-full bg-muted p-4 mb-4",children:(0,t.jsx)(j.BookOpen,{className:"h-8 w-8 text-muted-foreground"})}),g[12]=e):e=g[12];let r=N?"No results found":"No knowledge entries yet";g[13]!==r?(s=(0,t.jsx)("h3",{className:"text-lg font-semibold mb-1",children:r}),g[13]=r,g[14]=s):s=g[14];let i=N?"Try a different search query.":"Add knowledge about your database to help AI understand your schema, business logic, and conventions.";return g[15]!==i?(a=(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-6 text-center max-w-sm",children:i}),g[15]=i,g[16]=a):a=g[16],g[17]!==v||g[18]!==N?(n=!N&&(0,t.jsxs)(c.Button,{onClick:v,className:"gap-1.5",children:[(0,t.jsx)(h.Plus,{className:"h-4 w-4"}),"Add First Entry"]}),g[17]=v,g[18]=N,g[19]=n):n=g[19],g[20]!==a||g[21]!==n||g[22]!==s?(l=(0,t.jsx)(d.Card,{className:"border-dashed",children:(0,t.jsxs)(d.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[e,s,a,n]})}),g[20]=a,g[21]=n,g[22]=s,g[23]=l):l=g[23],l}if(g[24]!==k||g[25]!==y||g[26]!==T){let e;g[28]!==k||g[29]!==y?(e=e=>(0,t.jsx)(L,{entry:e,onEdit:y,onDelete:k},e.pubId),g[28]=k,g[29]=y,g[30]=e):e=g[30],o=T.map(e),g[24]=k,g[25]=y,g[26]=T,g[27]=o}else o=g[27];return g[31]!==o?(m=(0,t.jsx)("div",{className:"space-y-3",children:o}),g[31]=o,g[32]=m):m=g[32],g[33]!==C||g[34]!==f.length||g[35]!==B?(x=B>1&&(0,t.jsx)(V,{currentPage:C,totalPages:B,totalEntries:f.length,onPageChange:S}),g[33]=C,g[34]=f.length,g[35]=B,g[36]=x):x=g[36],g[37]!==m||g[38]!==x?(p=(0,t.jsxs)("div",{className:"space-y-4",children:[m,x]}),g[37]=m,g[38]=x,g[39]=p):p=g[39],p}function V(e){let s,a,n,l,r,i,o,d,m,h,x,p=(0,u.c)(35),{currentPage:g,totalPages:f,totalEntries:b,onPageChange:j}=e;p[0]!==g||p[1]!==f?(s=function(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let s=[],a=Math.max(2,e-1),n=Math.min(t-1,e+1);s.push(1),a>2&&s.push("...");for(let e=a;e<=n;e++)s.push(e);return n<t-1&&s.push("..."),s.push(t),s}(g,f),p[0]=g,p[1]=f,p[2]=s):s=p[2];let N=s,w=(g-1)*10+1,y=Math.min(10*g,b);p[3]!==y||p[4]!==w||p[5]!==b?(a=(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[w,"–",y," of ",b]}),p[3]=y,p[4]=w,p[5]=b,p[6]=a):a=p[6];let k=1===g;if(p[7]!==g||p[8]!==j?(n=()=>j(g-1),p[7]=g,p[8]=j,p[9]=n):n=p[9],p[10]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(M,{className:"h-4 w-4"}),p[10]=l):l=p[10],p[11]!==k||p[12]!==n?(r=(0,t.jsx)(c.Button,{variant:"outline",size:"sm",className:"h-8 w-8 p-0",disabled:k,onClick:n,children:l}),p[11]=k,p[12]=n,p[13]=r):r=p[13],p[14]!==g||p[15]!==j||p[16]!==N){let e;p[18]!==g||p[19]!==j?(e=(e,s)=>"..."===e?(0,t.jsx)("span",{className:"px-1 text-xs text-muted-foreground select-none",children:"..."},`ellipsis-${s}`):(0,t.jsx)(c.Button,{variant:e===g?"default":"outline",size:"sm",className:(0,O.cn)("h-8 w-8 p-0 text-xs",e===g&&"pointer-events-none"),onClick:()=>j(e),children:e},e),p[18]=g,p[19]=j,p[20]=e):e=p[20],i=N.map(e),p[14]=g,p[15]=j,p[16]=N,p[17]=i}else i=p[17];let v=g===f;return p[21]!==g||p[22]!==j?(o=()=>j(g+1),p[21]=g,p[22]=j,p[23]=o):o=p[23],p[24]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsx)($.default,{className:"h-4 w-4"}),p[24]=d):d=p[24],p[25]!==v||p[26]!==o?(m=(0,t.jsx)(c.Button,{variant:"outline",size:"sm",className:"h-8 w-8 p-0",disabled:v,onClick:o,children:d}),p[25]=v,p[26]=o,p[27]=m):m=p[27],p[28]!==m||p[29]!==r||p[30]!==i?(h=(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[r,i,m]}),p[28]=m,p[29]=r,p[30]=i,p[31]=h):h=p[31],p[32]!==h||p[33]!==a?(x=(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[a,h]}),p[32]=h,p[33]=a,p[34]=x):x=p[34],x}var H=e.i(624687),G=e.i(776639);function K(e){let s,a,n,l,r,i,o,d,m,h,x,p,f,b,j,N,y=(0,u.c)(42),{open:k,onOpenChange:v,editingPubId:C,form:S,onFormChange:B,isFormValid:A,isSaving:E,onSave:_}=e,I=C?"Edit Knowledge Entry":"Add Knowledge Entry";y[0]!==I?(s=(0,t.jsx)(G.DialogTitle,{children:I}),y[0]=I,y[1]=s):s=y[1];let z=C?"Update this knowledge entry.":"Add context about your database to improve AI query accuracy.";y[2]!==z?(a=(0,t.jsx)(G.DialogDescription,{children:z}),y[2]=z,y[3]=a):a=y[3],y[4]!==s||y[5]!==a?(n=(0,t.jsxs)(G.DialogHeader,{className:"shrink-0",children:[s,a]}),y[4]=s,y[5]=a,y[6]=n):n=y[6],y[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(g.Label,{htmlFor:"kb-title",children:"Title"}),y[7]=l):l=y[7],y[8]!==B?(r=e=>B(t=>({...t,title:e.target.value})),y[8]=B,y[9]=r):r=y[9],y[10]!==S.title||y[11]!==r?(i=(0,t.jsxs)("div",{className:"space-y-2",children:[l,(0,t.jsx)(T.Input,{id:"kb-title",placeholder:"e.g. User status enum values, Revenue calculation logic",value:S.title,onChange:r})]}),y[10]=S.title,y[11]=r,y[12]=i):i=y[12],y[13]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(g.Label,{htmlFor:"kb-content",children:"Content"}),y[13]=o):o=y[13],y[14]!==B?(d=e=>B(t=>({...t,content:e.target.value})),y[14]=B,y[15]=d):d=y[15],y[16]!==S.content||y[17]!==d?(m=(0,t.jsxs)("div",{className:"space-y-2",children:[o,(0,t.jsx)(H.Textarea,{id:"kb-content",placeholder:"Describe the knowledge here. For example:\n\n- Column descriptions and their meanings\n- Business logic and rules\n- Enum values and their meanings\n- Relationships between tables\n- Important data patterns or conventions",value:S.content,onChange:d,rows:6,className:"resize-y min-h-[120px] max-h-[40vh]"})]}),y[16]=S.content,y[17]=d,y[18]=m):m=y[18],y[19]!==m||y[20]!==i?(h=(0,t.jsxs)("div",{className:"space-y-4 py-2 overflow-y-auto flex-1 min-h-0",children:[i,m]}),y[19]=m,y[20]=i,y[21]=h):h=y[21],y[22]!==v?(x=(0,t.jsx)(c.Button,{variant:"outline",onClick:()=>v(!1),children:"Cancel"}),y[22]=v,y[23]=x):x=y[23];let D=!A||E;y[24]!==E?(p=E&&(0,t.jsx)(w.Loader2,{className:"h-4 w-4 animate-spin"}),y[24]=E,y[25]=p):p=y[25];let F=C?"Update":"Add Entry";return y[26]!==_||y[27]!==D||y[28]!==p||y[29]!==F?(f=(0,t.jsxs)(c.Button,{onClick:_,disabled:D,className:"gap-1.5",children:[p,F]}),y[26]=_,y[27]=D,y[28]=p,y[29]=F,y[30]=f):f=y[30],y[31]!==x||y[32]!==f?(b=(0,t.jsxs)(G.DialogFooter,{className:"shrink-0",children:[x,f]}),y[31]=x,y[32]=f,y[33]=b):b=y[33],y[34]!==h||y[35]!==b||y[36]!==n?(j=(0,t.jsxs)(G.DialogContent,{className:"sm:max-w-lg max-h-[85vh] flex! flex-col! p-4 sm:p-6",children:[n,h,b]}),y[34]=h,y[35]=b,y[36]=n,y[37]=j):j=y[37],y[38]!==v||y[39]!==k||y[40]!==j?(N=(0,t.jsx)(G.Dialog,{open:k,onOpenChange:v,children:j}),y[38]=v,y[39]=k,y[40]=j,y[41]=N):N=y[41],N}var U=e.i(168148),J=e.i(595468),W=e.i(178583);let q={phase:"idle",currentChunk:0,totalChunks:0,entriesFound:0,message:""};function Q({open:e,onOpenChange:a,connectionId:n,onImported:l}){let[r,m]=(0,s.useState)(""),[h,x]=(0,s.useState)([]),[u,p]=(0,s.useState)(new Set),[g,f]=(0,s.useState)(null),[b,j]=(0,s.useState)(!1),[N,y]=(0,s.useState)(q),v=(0,s.useRef)(null),S=i.api.knowledgeBase.create.useMutation(),B=r.length>5e3?Math.ceil(r.length/4400):1,A=(0,s.useCallback)(async()=>{if(!r.trim())return;v.current?.abort();let e=new AbortController;v.current=e,j(!0),y({phase:"analyzing",currentChunk:0,totalChunks:B,entriesFound:0,message:"Starting analysis..."});try{let s=await fetch("/api/knowledge/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r}),signal:e.signal});if(!s.ok)throw Error(`Server error: ${s.status}`);let a=s.body?.getReader();if(!a)throw Error("No response stream");let n=new TextDecoder,l="";for(;;){let{done:e,value:s}=await a.read();if(e)break;let r=(l+=n.decode(s,{stream:!0})).split("\n");for(let e of(l=r.pop()||"",r))if(e.startsWith("data: "))try{let s=JSON.parse(e.slice(6));t(s)}catch{}}if(l.startsWith("data: "))try{t(JSON.parse(l.slice(6)))}catch{}}catch(e){"AbortError"!==e.name&&o.toast.error(e.message||"Failed to generate knowledge")}finally{j(!1)}function t(e){switch(e.type){case"start":y(t=>({...t,totalChunks:e.totalChunks,message:e.totalChunks>1?`Splitting into ${e.totalChunks} chunks...`:"Analyzing text..."}));break;case"chunk_start":y(t=>({...t,currentChunk:e.chunk,message:`Analyzing chunk ${e.chunk} of ${e.totalChunks}...`}));break;case"chunk_done":y(t=>({...t,currentChunk:e.chunk,entriesFound:e.totalEntries,message:`Chunk ${e.chunk} done — ${e.entriesFound} entries found`}));break;case"done":x(e.entries||[]),p(new Set),f(e.totalChunks>1?{totalChunks:e.totalChunks,totalRawEntries:e.totalRawEntries}:null),y(e=>({...e,phase:"done"}));break;case"error":o.toast.error(e.message||"Generation failed")}}},[r,B]),T=(0,s.useCallback)(async(e,t)=>{if(n)try{await S.mutateAsync({connectionId:n,title:e.title,content:e.content,source:"ai_generated"}),p(e=>{let s=new Set(e);return s.add(t),s}),t>=0&&o.toast.success("Entry imported"),l()}catch(e){throw t>=0&&o.toast.error(e.message||"Failed to import entry"),e}},[n,S,l]),E=(0,s.useCallback)(async()=>{if(!n||0===h.length)return;let e=h.map((e,t)=>({entry:e,index:t})).filter(({index:e})=>!u.has(e));if(0===e.length)return void o.toast.info("All entries already imported");let t=Promise.allSettled(e.map(({entry:e,index:t})=>T(e,-1).then(()=>t)));o.toast.promise(t,{loading:`Importing ${e.length} entries...`,success:e=>{let t=e.filter(e=>"fulfilled"===e.status).map(e=>e.value);p(e=>{let s=new Set(e);return t.forEach(e=>s.add(e)),s});let s=e.length-t.length;return`Imported ${t.length} entries${s>0?` (${s} failed)`:""}`},error:"Failed to import entries"})},[n,h,u,T]),_=(0,s.useCallback)(()=>{v.current?.abort(),m(""),x([]),f(null),p(new Set),y(q),j(!1)},[]),I=N.totalChunks>0?Math.round(N.currentChunk/N.totalChunks*100):0;return(0,t.jsx)(G.Dialog,{open:e,onOpenChange:e=>{e||_(),a(e)},children:(0,t.jsxs)(G.DialogContent,{className:"sm:max-w-2xl flex! flex-col! max-h-[85vh] overflow-hidden p-0",children:[(0,t.jsxs)(G.DialogHeader,{className:"shrink-0 px-4 sm:px-6 pt-6 pb-0",children:[(0,t.jsxs)(G.DialogTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(C.Sparkles,{className:"h-5 w-5 text-indigo-500"}),"Generate Knowledge from Text"]}),(0,t.jsx)(G.DialogDescription,{children:"Paste documentation or notes below. AI will extract structured knowledge entries."})]}),0===h.length?(0,t.jsxs)("div",{className:"flex flex-col gap-4 flex-1 min-h-0 px-4 sm:px-6 pb-4 sm:pb-6 pt-2",children:[(0,t.jsx)(H.Textarea,{placeholder:"Paste table schemas, business rules, API docs, or any text describing your database...",value:r,onChange:e=>m(e.target.value),className:"flex-1 min-h-[150px] max-h-[50vh] resize-none font-mono text-sm",disabled:b}),b&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,t.jsx)(w.Loader2,{className:"h-4 w-4 animate-spin text-indigo-500"}),(0,t.jsx)("span",{children:N.message})]}),N.entriesFound>0&&(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[N.entriesFound," entries so far"]})]}),(0,t.jsx)(U.Progress,{value:I,className:"h-1.5"}),N.totalChunks>1&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/60 text-right",children:["Chunk ",N.currentChunk," of"," ",N.totalChunks]})]}),(0,t.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row items-start sm:items-center justify-between gap-2 shrink-0",children:[(0,t.jsx)("div",{className:"text-[11px] text-muted-foreground",children:r.length>0&&!b&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W.FileText,{className:"h-3 w-3 inline mr-1"}),r.length.toLocaleString()," chars",r.length>5e3&&(0,t.jsxs)("span",{className:"ml-1.5 text-indigo-500",children:["— will be split into ~",B," chunks"]})]})}),(0,t.jsx)(c.Button,{onClick:A,disabled:!r.trim()||b,className:"gap-2",children:b?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.Loader2,{className:"h-4 w-4 animate-spin"}),"Analyzing..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(k,{className:"h-4 w-4"}),"Generate Entries"]})})]})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 shrink-0 px-4 sm:px-6 pt-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium text-muted-foreground",children:["Found ",h.length," entries (",u.size," imported)"]}),g&&(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5",children:["Processed ",g.totalChunks," ","chunks —"," ",g.totalRawEntries-h.length," ","duplicates removed"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)(c.Button,{variant:"outline",size:"sm",onClick:_,children:"Back to Text"}),(0,t.jsx)(c.Button,{size:"sm",onClick:E,disabled:h.length===u.size,children:"Import All"})]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 sm:px-6 pb-4 sm:pb-6",children:(0,t.jsx)("div",{className:"space-y-3",children:h.map((e,s)=>{let a=u.has(s);return(0,t.jsxs)(d.Card,{className:(0,O.cn)("relative transition-all",a&&"bg-muted/50 border-green-500/30"),children:[(0,t.jsx)(d.CardHeader,{className:"p-3 sm:p-4 pb-2",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:[(0,t.jsx)("div",{className:"flex-1 min-w-0",children:(0,t.jsx)("h4",{className:"font-medium text-sm wrap-break-word",children:e.title})}),a?(0,t.jsx)(c.Button,{size:"sm",variant:"ghost",disabled:!0,className:"h-8 w-8 p-0 text-green-600 shrink-0",children:(0,t.jsx)(J.CheckCircle2,{className:"h-5 w-5"})}):(0,t.jsx)(c.Button,{size:"sm",onClick:()=>T(e,s),disabled:S.isPending,className:"h-8 px-3 text-xs shrink-0",children:"Import"})]})}),(0,t.jsx)(d.CardContent,{className:"p-3 sm:p-4 pt-0",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3",children:e.content})})]},s)})})})]})]})})}var Y=e.i(431343),X=e.i(330325);function Z(e){let s,a,n,l,r,i,o,h=(0,u.c)(39),{open:x,onOpenChange:p,entries:g,importedIndices:f,tablesExplored:b,isExploring:j,progress:N,onStartExploration:y,onImportEntry:k,onImportAll:S}=e,B=g.length>0;h[0]!==N.generatingBatch||h[1]!==N.phase||h[2]!==N.tablesExplored||h[3]!==N.totalBatches||h[4]!==N.totalTables?(s="exploring"===N.phase&&N.totalTables>0?Math.round(N.tablesExplored/N.totalTables*70):"generating"===N.phase?70+(N.totalBatches&&N.generatingBatch?Math.round((N.generatingBatch-1)/N.totalBatches*30):15):100*("done"===N.phase),h[0]=N.generatingBatch,h[1]=N.phase,h[2]=N.tablesExplored,h[3]=N.totalBatches,h[4]=N.totalTables,h[5]=s):s=h[5];let A=s;return h[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsxs)(G.DialogHeader,{className:"shrink-0 px-4 sm:px-6 pt-6 pb-0",children:[(0,t.jsxs)(G.DialogTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(v,{className:"h-5 w-5 text-blue-500"}),"Auto-Generate Knowledge"]}),(0,t.jsx)(G.DialogDescription,{children:"An AI agent will explore your database schema, sample data, and relationships to automatically generate knowledge entries."})]}),h[6]=a):a=h[6],h[7]!==B||h[8]!==j||h[9]!==y||h[10]!==N.phase?(n=!B&&!j&&"idle"===N.phase&&(0,t.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-6 py-12 px-4 sm:px-6",children:[(0,t.jsx)("div",{className:"rounded-full bg-blue-500/10 p-6",children:(0,t.jsx)(m.Database,{className:"h-10 w-10 text-blue-500"})}),(0,t.jsxs)("div",{className:"text-center max-w-sm space-y-2",children:[(0,t.jsx)("h3",{className:"text-base font-semibold",children:"Ready to explore"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"The agent will discover all tables, analyze columns, sample data, and generate knowledge about your database structure and patterns."})]}),(0,t.jsxs)(c.Button,{onClick:y,className:"gap-2",size:"lg",children:[(0,t.jsx)(Y.Play,{className:"h-4 w-4"}),"Start Exploration"]})]}),h[7]=B,h[8]=j,h[9]=y,h[10]=N.phase,h[11]=n):n=h[11],h[12]!==j||h[13]!==N.currentTable||h[14]!==N.generatingBatch||h[15]!==N.message||h[16]!==N.phase||h[17]!==N.tablesExplored||h[18]!==N.totalBatches||h[19]!==N.totalTables||h[20]!==A?(l=j&&(0,t.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-5 py-10 px-4 sm:px-6",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"rounded-full bg-blue-500/10 p-5",children:(0,t.jsx)(v,{className:"h-8 w-8 text-blue-500"})}),(0,t.jsx)("div",{className:"absolute -bottom-1 -right-1 rounded-full bg-background p-1",children:(0,t.jsx)(w.Loader2,{className:"h-5 w-5 animate-spin text-blue-500"})})]}),(0,t.jsxs)("h3",{className:"text-base font-semibold",children:["connecting"===N.phase&&"Connecting to database...","exploring"===N.phase&&"Exploring tables...","generating"===N.phase&&"Generating knowledge..."]}),(0,t.jsxs)("div",{className:"w-full max-w-sm space-y-2",children:[(0,t.jsx)(U.Progress,{value:A,className:"h-2"}),(0,t.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:N.message}),(0,t.jsxs)("span",{children:[A,"%"]})]})]}),"exploring"===N.phase&&N.currentTable&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 px-3 py-1.5 rounded-md",children:[(0,t.jsx)(X.Table2,{className:"h-3.5 w-3.5 text-blue-400"}),(0,t.jsx)("span",{className:"font-mono text-xs",children:N.currentTable}),(0,t.jsxs)("span",{className:"text-[10px] text-muted-foreground/60",children:["(",N.tablesExplored,"/",N.totalTables,")"]})]}),"generating"===N.phase&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground bg-muted/50 px-3 py-1.5 rounded-md",children:[(0,t.jsx)(C.Sparkles,{className:"h-3.5 w-3.5 text-purple-400"}),(0,t.jsx)("span",{className:"text-xs",children:N.totalBatches&&N.totalBatches>1?`AI batch ${N.generatingBatch} of ${N.totalBatches}`:"AI is analyzing the schema..."})]})]}),h[12]=j,h[13]=N.currentTable,h[14]=N.generatingBatch,h[15]=N.message,h[16]=N.phase,h[17]=N.tablesExplored,h[18]=N.totalBatches,h[19]=N.totalTables,h[20]=A,h[21]=l):l=h[21],h[22]!==g||h[23]!==B||h[24]!==f||h[25]!==j||h[26]!==S||h[27]!==k||h[28]!==p||h[29]!==b?(r=B&&!j&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 shrink-0 px-4 sm:px-6 pt-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-medium flex items-center gap-2",children:[(0,t.jsx)(J.CheckCircle2,{className:"h-4 w-4 text-green-500"}),"Generated ",g.length," entries"]}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 mt-0.5",children:["Explored ",b," tables —"," ",f.size," imported"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[(0,t.jsx)(c.Button,{variant:"outline",size:"sm",onClick:()=>p(!1),children:"Close"}),(0,t.jsx)(c.Button,{size:"sm",onClick:S,disabled:g.length===f.size,children:"Import All"})]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 sm:px-6 pb-4 sm:pb-6",children:(0,t.jsx)("div",{className:"space-y-3",children:g.map((e,s)=>{let a=f.has(s);return(0,t.jsxs)(d.Card,{className:(0,O.cn)("relative transition-all",a&&"bg-muted/50 border-green-500/30"),children:[(0,t.jsx)(d.CardHeader,{className:"p-3 sm:p-4 pb-2",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2 sm:gap-3",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"flex items-center gap-2 mb-1",children:(0,t.jsxs)(E.Badge,{variant:"outline",className:"text-[10px] gap-1 text-purple-400 bg-purple-400/10 border-purple-400/20",children:[(0,t.jsx)(C.Sparkles,{className:"h-3 w-3"}),"AI"]})}),(0,t.jsx)("h4",{className:"font-medium text-sm wrap-break-word",children:e.title})]}),a?(0,t.jsx)(c.Button,{size:"sm",variant:"ghost",disabled:!0,className:"h-8 w-8 p-0 text-green-600 shrink-0",children:(0,t.jsx)(J.CheckCircle2,{className:"h-5 w-5"})}):(0,t.jsx)(c.Button,{size:"sm",onClick:()=>k(e,s),className:"h-8 px-3 text-xs shrink-0",children:"Import"})]})}),(0,t.jsx)(d.CardContent,{className:"p-3 sm:p-4 pt-0",children:(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3 sm:line-clamp-4 whitespace-pre-wrap",children:e.content})})]},s)})})})]}),h[22]=g,h[23]=B,h[24]=f,h[25]=j,h[26]=S,h[27]=k,h[28]=p,h[29]=b,h[30]=r):r=h[30],h[31]!==n||h[32]!==l||h[33]!==r?(i=(0,t.jsxs)(G.DialogContent,{className:"sm:max-w-2xl flex! flex-col! max-h-[85vh] overflow-hidden p-0",children:[a,n,l,r]}),h[31]=n,h[32]=l,h[33]=r,h[34]=i):i=h[34],h[35]!==p||h[36]!==x||h[37]!==i?(o=(0,t.jsx)(G.Dialog,{open:x,onOpenChange:p,children:i}),h[35]=p,h[36]=x,h[37]=i,h[38]=o):o=h[38],o}let ee={title:"",content:""},et={phase:"idle",tablesExplored:0,totalTables:0};function es({initialConnections:e,initialEntries:l,initialConnectionId:p}){let g=(0,a.useRouter)(),f=(0,a.useSearchParams)().get("connectionId");!function(e,t){var s;let a,l=(0,n.useStore)(void 0),i=(s=l,(a=r.get(s))||(a=new WeakSet,r.set(s,a)),a);for(let[t,...s]of e)i.has(t)&&1||(i.add(t),l.set(t,...s))}([[x,e]]);let b=(0,n.useAtomValue)(x),[j,N]=(0,s.useState)("all"),[w,y]=(0,s.useState)(""),[k,v]=(0,s.useState)(!1),C=b.connections,S=f||C[0]?.id||"",{data:A,isLoading:T,refetch:E}=i.api.knowledgeBase.list.useQuery({connectionId:S},{enabled:!!S,initialData:S===p?{entries:l}:void 0}),_=A?.entries||[],I=i.api.knowledgeBase.delete.useMutation(),z=i.api.knowledgeBase.bulkDelete.useMutation(),D=i.api.knowledgeBase.regenerateEmbeddings.useMutation(),M=function(e){let t,a,n,l,r,c=(0,u.c)(20),{connectionId:d,onSaved:m}=e,[h,x]=(0,s.useState)(!1),[p,g]=(0,s.useState)(null),[f,b]=(0,s.useState)(ee),j=i.api.knowledgeBase.create.useMutation(),N=i.api.knowledgeBase.update.useMutation();c[0]!==f.content||c[1]!==f.title?(t=f.title.trim().length>0&&f.content.trim().length>0,c[0]=f.content,c[1]=f.title,c[2]=t):t=c[2];let w=t,y=j.isPending||N.isPending;c[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{g(null),b(ee),x(!0)},c[3]=a):a=c[3];let k=a;c[4]===Symbol.for("react.memo_cache_sentinel")?(n=e=>{g(e.pubId),b({title:e.title,content:e.content}),x(!0)},c[4]=n):n=c[4];let v=n;c[5]!==d||c[6]!==j||c[7]!==p||c[8]!==f.content||c[9]!==f.title||c[10]!==m||c[11]!==N?(l=async()=>{if(!d)return void o.toast.error("No connection selected");try{p?(await N.mutateAsync({pubId:p,title:f.title,content:f.content}),o.toast.success("Knowledge entry updated")):(await j.mutateAsync({connectionId:d,title:f.title,content:f.content}),o.toast.success("Knowledge entry added")),x(!1),m()}catch(e){o.toast.error(e.message||"Failed to save knowledge entry")}},c[5]=d,c[6]=j,c[7]=p,c[8]=f.content,c[9]=f.title,c[10]=m,c[11]=N,c[12]=l):l=c[12];let C=l;return c[13]!==h||c[14]!==p||c[15]!==f||c[16]!==C||c[17]!==w||c[18]!==y?(r={dialogOpen:h,setDialogOpen:x,editingPubId:p,form:f,setForm:b,isFormValid:w,isSaving:y,openAddDialog:k,openEditDialog:v,handleSave:C},c[13]=h,c[14]=p,c[15]=f,c[16]=C,c[17]=w,c[18]=y,c[19]=r):r=c[19],r}({connectionId:S,onSaved:()=>E()}),$=function({connectionId:e,onImported:t}){let[a,n]=(0,s.useState)(!1),[l,r]=(0,s.useState)([]),[c,d]=(0,s.useState)(new Set),[m,h]=(0,s.useState)(et),[x,u]=(0,s.useState)(!1),p=(0,s.useRef)(null),g=i.api.knowledgeBase.create.useMutation(),f=m.tablesExplored,b=(0,s.useCallback)(()=>{r([]),d(new Set),h(et),u(!1),n(!0)},[]),j=(0,s.useCallback)(async()=>{if(!e)return;p.current?.abort();let t=new AbortController;p.current=t,u(!0),r([]),h({phase:"connecting",tablesExplored:0,totalTables:0});try{let a=await fetch("/api/knowledge/auto-generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:e}),signal:t.signal});if(!a.ok)throw Error(`Server error: ${a.status}`);let n=a.body?.getReader();if(!n)throw Error("No response stream");let l=new TextDecoder,r="";for(;;){let{done:e,value:t}=await n.read();if(e)break;let a=(r+=l.decode(t,{stream:!0})).split("\n");for(let e of(r=a.pop()||"",a))if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));s(t)}catch{}}if(r.startsWith("data: "))try{let e=JSON.parse(r.slice(6));s(e)}catch{}}catch(e){"AbortError"!==e.name&&(o.toast.error(e.message||"Failed to explore database"),h(t=>({...t,phase:"error",message:e.message})))}finally{u(!1)}function s(e){switch(e.type){case"connecting":h(t=>({...t,phase:"connecting",message:`Connecting to ${e.connectionName}...`}));break;case"tables_found":h(t=>({...t,phase:"exploring",totalTables:e.totalTables,message:`Found ${e.totalTables} tables`}));break;case"exploring_table":h(t=>({...t,phase:"exploring",currentTable:e.table,tablesExplored:e.current-1,totalTables:e.total}));break;case"table_done":h(t=>({...t,tablesExplored:e.current,currentTable:e.table,message:`${e.table} — ${e.columnCount} cols, ${e.rowCount} rows`}));break;case"generating":h(t=>({...t,phase:"generating",tablesExplored:e.tablesExplored,message:"AI is analyzing the schema..."}));break;case"generating_batch":h(t=>({...t,phase:"generating",generatingBatch:e.batch,totalBatches:e.totalBatches,message:e.totalBatches>1?`Generating batch ${e.batch} of ${e.totalBatches}...`:"Generating knowledge entries..."}));break;case"batch_done":h(t=>({...t,message:`Batch ${e.batch} done — ${e.entriesFound} entries`}));break;case"done":r(e.entries||[]),h(t=>({...t,phase:"done",tablesExplored:e.tablesExplored})),e.entries?.length||o.toast.info("No knowledge entries could be generated");break;case"error":o.toast.error(e.message||"Exploration failed"),h(t=>({...t,phase:"error",message:e.message}))}}},[e]),N=(0,s.useCallback)(async(s,a)=>{if(e)try{await g.mutateAsync({connectionId:e,title:s.title,content:s.content,source:"ai_generated"}),d(e=>{let t=new Set(e);return t.add(a),t}),a>=0&&o.toast.success("Entry imported"),t()}catch(e){throw a>=0&&o.toast.error(e.message||"Failed to import entry"),e}},[e,g,t]),w=(0,s.useCallback)(async()=>{if(!e||0===l.length)return;let t=l.map((e,t)=>({entry:e,index:t})).filter(({index:e})=>!c.has(e));if(0===t.length)return void o.toast.info("All entries already imported");let s=Promise.allSettled(t.map(({entry:e,index:t})=>N(e,-1).then(()=>t)));o.toast.promise(s,{loading:`Importing ${t.length} entries...`,success:e=>{let t=e.filter(e=>"fulfilled"===e.status).map(e=>e.value);d(e=>{let s=new Set(e);return t.forEach(e=>s.add(e)),s});let s=e.length-t.length;return`Imported ${t.length} entries${s>0?` (${s} failed)`:""}`},error:"Failed to import entries"})},[e,l,c,N]);return{dialogOpen:a,setDialogOpen:n,entries:l,importedIndices:c,tablesExplored:f,isExploring:x,progress:m,openDialog:b,startExploration:j,importEntry:N,importAll:w}}({connectionId:S,onImported:()=>E()}),P=_.filter(e=>"manual"===e.source).length,O=_.filter(e=>"ai_generated"===e.source).length,L=(0,s.useMemo)(()=>{let e=_;if("human"===j?e=e.filter(e=>"manual"===e.source):"ai"===j&&(e=e.filter(e=>"ai_generated"===e.source)),w.trim()){let t=w.toLowerCase();e=e.filter(e=>e.title.toLowerCase().includes(t)||e.content.toLowerCase().includes(t))}return e},[_,j,w]),V=(0,s.useCallback)(e=>{g.push(`/knowledge-base?connectionId=${e}`)},[g]),H=(0,s.useCallback)(async(e,t)=>{if(confirm(`Delete knowledge entry "${t}"? This cannot be undone.`))try{await I.mutateAsync({pubId:e}),o.toast.success("Knowledge entry deleted"),E()}catch(e){o.toast.error(e.message||"Failed to delete knowledge entry")}},[I,E]),G=(0,s.useCallback)(async()=>{if(!S)return;let e="human"===j?"human":"ai"===j?"AI":"all";if(confirm(`Delete ${e} knowledge entries for this connection? This cannot be undone.`))try{let e="human"===j?"manual":"ai"===j?"ai_generated":void 0,t=await z.mutateAsync({connectionId:S,source:e});o.toast.success(`Deleted ${t.count} knowledge entries`),E()}catch(e){o.toast.error(e.message||"Failed to delete knowledge entries")}},[S,j,z,E]),U=(0,s.useCallback)(async()=>{if(S)try{let e=await D.mutateAsync({connectionId:S});o.toast.success(`Regenerated embeddings for ${e.count} entries`)}catch(e){o.toast.error(e.message||"Failed to regenerate embeddings")}},[S,D]);return(0,t.jsxs)("div",{className:"min-h-screen bg-background",children:[(0,t.jsx)(B,{selectedConnectionId:S,entryCount:_.length,isRegenerating:D.isPending,onConnectionChange:V,onAddEntry:M.openAddDialog,onGenerateFromText:()=>v(!0),onAutoGenerate:$.openDialog,onRegenerateEmbeddings:U}),(0,t.jsxs)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-8",children:[0===C.length&&(0,t.jsx)(d.Card,{className:"border-dashed",children:(0,t.jsxs)(d.CardContent,{className:"flex flex-col items-center justify-center py-16",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-4 mb-4",children:(0,t.jsx)(m.Database,{className:"h-8 w-8 text-muted-foreground"})}),(0,t.jsx)("h3",{className:"text-lg font-semibold mb-1",children:"No connections found"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground mb-6 text-center max-w-sm",children:"Add a database connection first, then come back to add knowledge base entries."}),(0,t.jsxs)(c.Button,{onClick:()=>g.push("/connections"),className:"gap-1.5",children:[(0,t.jsx)(h.Plus,{className:"h-4 w-4"}),"Add Connection"]})]})}),S&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)(F,{searchQuery:w,onSearchChange:y,activeTab:j,onTabChange:N,totalCount:_.length,humanCount:P,aiCount:O,onClear:G,isClearing:z.isPending}),(0,t.jsx)(R,{entries:L,isLoading:T,searchQuery:w,onEdit:M.openEditDialog,onDelete:H,onAddFirst:M.openAddDialog})]})]}),(0,t.jsx)(K,{open:M.dialogOpen,onOpenChange:M.setDialogOpen,editingPubId:M.editingPubId,form:M.form,onFormChange:M.setForm,isFormValid:M.isFormValid,isSaving:M.isSaving,onSave:M.handleSave}),(0,t.jsx)(Q,{open:k,onOpenChange:v,connectionId:S,onImported:()=>E()}),(0,t.jsx)(Z,{open:$.dialogOpen,onOpenChange:$.setDialogOpen,entries:$.entries,importedIndices:$.importedIndices,tablesExplored:$.tablesExplored,isExploring:$.isExploring,progress:$.progress,onStartExploration:$.startExploration,onImportEntry:$.importEntry,onImportAll:$.importAll})]})}e.s(["KnowledgeBasePage",()=>es],893213)}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,775258,e=>{"use strict";var s=e.i(843476),t=e.i(500932),a=e.i(60345),n=e.i(846696),l=e.i(522016),i=e.i(618566),r=e.i(519455),c=e.i(871689),o=e.i(107233),d=e.i(283086),m=e.i(810980);function h(e){let a,n,h,x,u,p,g,f,j,b,v,N,y,w,C,S=(0,t.c)(21),{onAddConnection:k}=e,_=(0,i.useRouter)();return S[0]!==_?(a=()=>_.push("/"),S[0]=_,S[1]=a):a=S[1],S[2]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsx)(c.ArrowLeft,{className:"h-4 w-4"}),h=(0,s.jsx)("span",{className:"hidden sm:inline",children:"Back to Chat"}),S[2]=n,S[3]=h):(n=S[2],h=S[3]),S[4]!==a?(x=(0,s.jsxs)(r.Button,{variant:"ghost",size:"sm",onClick:a,className:"gap-1.5",children:[n,h]}),S[4]=a,S[5]=x):x=S[5],S[6]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("div",{className:"flex-1"}),p=(0,s.jsx)("h1",{className:"text-sm font-semibold",children:"CLAY"}),S[6]=u,S[7]=p):(u=S[6],p=S[7]),S[8]!==x?(g=(0,s.jsx)("header",{className:"border-b border-border/40 bg-background/80 backdrop-blur sticky top-0 z-10",children:(0,s.jsxs)("div",{className:"max-w-5xl mx-auto flex items-center gap-4 px-4 sm:px-6 py-4",children:[x,u,p]})}),S[8]=x,S[9]=g):g=S[9],S[10]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Connections"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-1 hidden sm:block",children:"Manage your database connections. Supports PostgreSQL, Redshift, MySQL, SQLite, and CSV imports."})]}),S[10]=f):f=S[10],S[11]===Symbol.for("react.memo_cache_sentinel")?(j=(0,s.jsx)(r.Button,{asChild:!0,variant:"outline",size:"sm",className:"gap-1.5 shrink-0",children:(0,s.jsxs)(l.default,{href:"/ai-providers",children:[(0,s.jsx)(d.Sparkles,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"AI Providers"})]})}),S[11]=j):j=S[11],S[12]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsx)(r.Button,{asChild:!0,variant:"outline",size:"sm",className:"gap-1.5 shrink-0",children:(0,s.jsxs)(l.default,{href:"/knowledge-base",children:[(0,s.jsx)(m.BookOpen,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Knowledge Base"})]})}),S[12]=b):b=S[12],S[13]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(o.Plus,{className:"h-4 w-4"}),N=(0,s.jsx)("span",{className:"sm:hidden",children:"Add"}),y=(0,s.jsx)("span",{className:"hidden sm:inline",children:"Add Connection"}),S[13]=v,S[14]=N,S[15]=y):(v=S[13],N=S[14],y=S[15]),S[16]!==k?(w=(0,s.jsx)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 py-5 sm:py-8",children:(0,s.jsxs)("div",{className:"space-y-3 sm:space-y-0 sm:flex sm:items-start sm:justify-between sm:gap-4 mb-6 sm:mb-8",children:[f,(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[j,b,(0,s.jsxs)(r.Button,{onClick:k,size:"sm",className:"gap-1.5 shrink-0",children:[v,N,y]})]})]})}),S[16]=k,S[17]=w):w=S[17],S[18]!==w||S[19]!==g?(C=(0,s.jsxs)(s.Fragment,{children:[g,w]}),S[18]=w,S[19]=g,S[20]=C):C=S[20],C}var x=e.i(515288),u=e.i(658041),p=e.i(531278),g=e.i(487486),f=e.i(595468),j=e.i(390152),b=e.i(475254);let v=(0,b.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),N=(0,b.default)("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]),y=(0,b.default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);var w=e.i(330325),C=e.i(788699),S=e.i(727612),k=e.i(975157),_=e.i(294918),F=e.i(352786);let D={redshift:5439,postgresql:5432,mysql:3306,sqlite:0,csv:0},A={name:"",type:"postgresql",host:"",port:"5432",user:"",password:"",database:"",ssl:!0,filePath:""},L={redshift:{color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:"Amazon Redshift",icon:u.Database},postgresql:{color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:"PostgreSQL",icon:u.Database},mysql:{color:"text-cyan-400 bg-cyan-400/10 border-cyan-400/20",label:"MySQL",icon:u.Database},sqlite:{color:"text-violet-400 bg-violet-400/10 border-violet-400/20",label:"SQLite",icon:F.HardDrive},csv:{color:"text-green-400 bg-green-400/10 border-green-400/20",label:"CSV (SQLite)",icon:_.FileSpreadsheet}},I={color:"text-muted-foreground",label:"",icon:u.Database};function P(e){var a,n,l;let i,c,o,d,m,h,u,p,j,b,v,N,y,w,_,F,D,A,P,B,z,M,R,$=(0,t.c)(61),{connection:V,isActive:Q,isTestPending:E,onSetActive:U,onTestExisting:O,onEdit:H,onDelete:K,onImportCsv:X}=e;$[0]!==V.type?(a=V.type,i=L[a]?.icon??I.icon,$[0]=V.type,$[1]=i):i=$[1];let Y=i,G=Q&&"ring-1 ring-primary/50 border-primary/30";return($[2]!==G?(c=(0,k.cn)("transition-all relative overflow-hidden min-w-0",G),$[2]=G,$[3]=c):c=$[3],$[4]!==V.type)?(o=(0,k.cn)("rounded-lg p-1.5 sm:p-2 border shrink-0",(n=V.type,L[n]?.color??I.color)),$[4]=V.type,$[5]=o):o=$[5],($[6]!==Y?(d=(0,s.jsx)(Y,{className:"h-4 w-4"}),$[6]=Y,$[7]=d):d=$[7],$[8]!==o||$[9]!==d?(m=(0,s.jsx)("div",{className:o,children:d}),$[8]=o,$[9]=d,$[10]=m):m=$[10],$[11]!==V.name?(h=(0,s.jsx)(x.CardTitle,{className:"text-sm sm:text-base truncate",children:V.name}),$[11]=V.name,$[12]=h):h=$[12],$[13]!==Q?(u=Q&&(0,s.jsxs)(g.Badge,{variant:"default",className:"text-[10px] gap-1 shrink-0",children:[(0,s.jsx)(f.CheckCircle2,{className:"h-3 w-3"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Active"})]}),$[13]=Q,$[14]=u):u=$[14],$[15]!==h||$[16]!==u?(p=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[h,u]}),$[15]=h,$[16]=u,$[17]=p):p=$[17],$[18]!==V.type)?(l=V.type,j=L[l]?.label??l,$[18]=V.type,$[19]=j):j=$[19],$[20]!==j?(b=(0,s.jsx)(x.CardDescription,{className:"text-xs mt-0.5",children:j}),$[20]=j,$[21]=b):b=$[21],$[22]!==b||$[23]!==p?(v=(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[p,b]}),$[22]=b,$[23]=p,$[24]=v):v=$[24],$[25]!==V.id||$[26]!==H?(N=()=>H(V.id),$[25]=V.id,$[26]=H,$[27]=N):N=$[27],$[28]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(C.Pencil,{className:"h-3.5 w-3.5"}),$[28]=y):y=$[28],$[29]!==N?(w=(0,s.jsx)(r.Button,{variant:"ghost",size:"sm",onClick:N,className:"h-7 w-7 p-0",children:y}),$[29]=N,$[30]=w):w=$[30],$[31]!==V.id||$[32]!==V.name||$[33]!==K?(_=()=>K(V.id,V.name),$[31]=V.id,$[32]=V.name,$[33]=K,$[34]=_):_=$[34],$[35]===Symbol.for("react.memo_cache_sentinel")?(F=(0,s.jsx)(S.Trash2,{className:"h-3.5 w-3.5"}),$[35]=F):F=$[35],$[36]!==_?(D=(0,s.jsx)(r.Button,{variant:"ghost",size:"sm",onClick:_,className:"h-7 w-7 p-0 text-destructive hover:text-destructive",children:F}),$[36]=_,$[37]=D):D=$[37],$[38]!==w||$[39]!==D?(A=(0,s.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",children:[w,D]}),$[38]=w,$[39]=D,$[40]=A):A=$[40],$[41]!==v||$[42]!==A||$[43]!==m?(P=(0,s.jsx)(x.CardHeader,{className:"p-4 sm:p-6 pb-2 sm:pb-3",children:(0,s.jsxs)("div",{className:"flex items-center gap-2.5 sm:gap-3",children:[m,v,A]})}),$[41]=v,$[42]=A,$[43]=m,$[44]=P):P=$[44],$[45]!==V?(B=(0,s.jsx)(T,{connection:V}),$[45]=V,$[46]=B):B=$[46],$[47]!==V||$[48]!==Q||$[49]!==E||$[50]!==X||$[51]!==U||$[52]!==O?(z=(0,s.jsx)(q,{connection:V,isActive:Q,isTestPending:E,onSetActive:U,onTestExisting:O,onImportCsv:X}),$[47]=V,$[48]=Q,$[49]=E,$[50]=X,$[51]=U,$[52]=O,$[53]=z):z=$[53],$[54]!==B||$[55]!==z?(M=(0,s.jsxs)(x.CardContent,{className:"p-4 sm:p-6 pt-0 sm:pt-0 min-w-0 overflow-hidden",children:[B,z]}),$[54]=B,$[55]=z,$[56]=M):M=$[56],$[57]!==P||$[58]!==M||$[59]!==c?(R=(0,s.jsxs)(x.Card,{className:c,children:[P,M]}),$[57]=P,$[58]=M,$[59]=c,$[60]=R):R=$[60],R}function T(e){let a,n=(0,t.c)(2),{connection:l}=e;return n[0]!==l?(a=(0,s.jsx)("div",{className:"space-y-1 text-xs text-muted-foreground mb-3 sm:mb-4 min-w-0 overflow-hidden",children:"sqlite"===l.type?(0,s.jsx)(B,{label:"File",value:l.filePath||l.database||"—"}):"csv"===l.type?(0,s.jsx)(z,{csvFiles:l.csvFiles}):(0,s.jsx)(R,{connection:l})}),n[0]=l,n[1]=a):a=n[1],a}function B(e){let a,n,l,i=(0,t.c)(7),{label:r,value:c}=e;return i[0]!==r?(a=(0,s.jsx)("span",{className:"text-muted-foreground/60 w-12 sm:w-14 shrink-0",children:r}),i[0]=r,i[1]=a):a=i[1],i[2]!==c?(n=(0,s.jsx)("span",{className:"font-mono truncate min-w-0 flex-1",children:c}),i[2]=c,i[3]=n):n=i[3],i[4]!==a||i[5]!==n?(l=(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[a,n]}),i[4]=a,i[5]=n,i[6]=l):l=i[6],l}function z(e){let a,n,l=(0,t.c)(5),{csvFiles:i}=e;if(!i?.length){let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)("div",{className:"text-muted-foreground/50 italic",children:"No CSV files imported yet"}),l[0]=e):e=l[0],e}return l[1]!==i?(a=i.map(M),l[1]=i,l[2]=a):a=l[2],l[3]!==a?(n=(0,s.jsx)(s.Fragment,{children:a}),l[3]=a,l[4]=n):n=l[4],n}function M(e){return(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,s.jsx)(w.Table2,{className:"h-3 w-3 shrink-0 text-green-400/60"}),(0,s.jsx)("span",{className:"font-mono truncate min-w-0",title:e.tableName,children:e.tableName}),(0,s.jsx)("span",{className:"text-muted-foreground/40 shrink-0 text-[10px]",children:null!=e.rowCount&&`${e.rowCount} rows`})]},e.tableName)}function R(e){let a,n,l,i,r,c=(0,t.c)(13),{connection:o}=e,d=`${o.host}:${o.port}`;return c[0]!==d?(a=(0,s.jsx)(B,{label:"Host",value:d}),c[0]=d,c[1]=a):a=c[1],c[2]!==o.database?(n=(0,s.jsx)(B,{label:"DB",value:o.database}),c[2]=o.database,c[3]=n):n=c[3],c[4]!==o.user?(l=(0,s.jsx)(B,{label:"User",value:o.user}),c[4]=o.user,c[5]=l):l=c[5],c[6]!==o.ssl?(i=o.ssl&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-green-500/70 mt-1",children:[(0,s.jsx)(N,{className:"h-3 w-3"}),(0,s.jsx)("span",{children:"SSL enabled"})]}),c[6]=o.ssl,c[7]=i):i=c[7],c[8]!==a||c[9]!==n||c[10]!==l||c[11]!==i?(r=(0,s.jsxs)(s.Fragment,{children:[a,n,l,i]}),c[8]=a,c[9]=n,c[10]=l,c[11]=i,c[12]=r):r=c[12],r}function q(e){let a,n,i,c,o,d,h,x,u=(0,t.c)(25),{connection:g,isActive:f,isTestPending:b,onSetActive:N,onTestExisting:w,onImportCsv:C}=e;u[0]!==g.id||u[1]!==f||u[2]!==N?(a=!f&&(0,s.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:()=>N(g.id),className:"text-xs gap-1 h-7 px-2",children:[(0,s.jsx)(j.Plug,{className:"h-3 w-3"}),"Active"]}),u[0]=g.id,u[1]=f,u[2]=N,u[3]=a):a=u[3],u[4]!==g.id||u[5]!==w?(n=()=>w(g.id),u[4]=g.id,u[5]=w,u[6]=n):n=u[6],u[7]!==b?(i=b?(0,s.jsx)(p.Loader2,{className:"h-3 w-3 animate-spin"}):(0,s.jsx)(v,{className:"h-3 w-3"}),u[7]=b,u[8]=i):i=u[8],u[9]!==b||u[10]!==n||u[11]!==i?(c=(0,s.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:n,disabled:b,className:"text-xs gap-1 h-7 px-2",children:[i,"Test"]}),u[9]=b,u[10]=n,u[11]=i,u[12]=c):c=u[12],u[13]!==g.id||u[14]!==g.type||u[15]!==C?(o="csv"===g.type&&(0,s.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:()=>C(g.id),className:"text-xs gap-1 h-7 px-2 text-green-400 border-green-400/30 hover:bg-green-400/10",children:[(0,s.jsx)(y,{className:"h-3 w-3"}),"CSV"]}),u[13]=g.id,u[14]=g.type,u[15]=C,u[16]=o):o=u[16];let S=`/knowledge-base?connectionId=${g.id}`;return u[17]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(m.BookOpen,{className:"h-3 w-3"}),u[17]=d):d=u[17],u[18]!==S?(h=(0,s.jsx)(r.Button,{asChild:!0,variant:"outline",size:"sm",className:"text-xs gap-1 h-7 px-2",children:(0,s.jsxs)(l.default,{href:S,children:[d,"KB"]})}),u[18]=S,u[19]=h):h=u[19],u[20]!==a||u[21]!==c||u[22]!==o||u[23]!==h?(x=(0,s.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[a,c,o,h]}),u[20]=a,u[21]=c,u[22]=o,u[23]=h,u[24]=x):x=u[24],x}function $(e){let a,n,l=(0,t.c)(22),{connections:i,activeConnectionId:r,isLoading:c,isTestPending:o,onAdd:d,onSetActive:m,onTestExisting:h,onEdit:x,onDelete:u,onImportCsv:g}=e;if(c){let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)("div",{className:"flex items-center justify-center py-20",children:(0,s.jsx)(p.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}),l[0]=e):e=l[0],e}if(0===i.length){let e;return l[1]!==d?(e=(0,s.jsx)(V,{onAdd:d}),l[1]=d,l[2]=e):e=l[2],e}if(l[3]!==r||l[4]!==i||l[5]!==o||l[6]!==u||l[7]!==x||l[8]!==g||l[9]!==m||l[10]!==h){let e;l[12]!==r||l[13]!==o||l[14]!==u||l[15]!==x||l[16]!==g||l[17]!==m||l[18]!==h?(e=e=>(0,s.jsx)(P,{connection:e,isActive:e.id===r,isTestPending:o,onSetActive:m,onTestExisting:h,onEdit:x,onDelete:u,onImportCsv:g},e.id),l[12]=r,l[13]=o,l[14]=u,l[15]=x,l[16]=g,l[17]=m,l[18]=h,l[19]=e):e=l[19],a=i.map(e),l[3]=r,l[4]=i,l[5]=o,l[6]=u,l[7]=x,l[8]=g,l[9]=m,l[10]=h,l[11]=a}else a=l[11];return l[20]!==a?(n=(0,s.jsx)("div",{className:"grid gap-3 sm:gap-4 md:grid-cols-2 min-w-0",children:a}),l[20]=a,l[21]=n):n=l[21],n}function V(e){let a,n,l,i,c,d=(0,t.c)(6),{onAdd:m}=e;return d[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)("div",{className:"rounded-full bg-muted p-4 mb-4",children:(0,s.jsx)(u.Database,{className:"h-8 w-8 text-muted-foreground"})}),n=(0,s.jsx)("h3",{className:"text-base sm:text-lg font-semibold mb-1",children:"No connections yet"}),l=(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-6 text-center max-w-sm",children:"Add a database connection to start querying your data with AI."}),d[0]=a,d[1]=n,d[2]=l):(a=d[0],n=d[1],l=d[2]),d[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(o.Plus,{className:"h-4 w-4"}),d[3]=i):i=d[3],d[4]!==m?(c=(0,s.jsx)(x.Card,{className:"border-dashed",children:(0,s.jsxs)(x.CardContent,{className:"flex flex-col items-center justify-center py-10 sm:py-16 px-4",children:[a,n,l,(0,s.jsxs)(r.Button,{onClick:m,className:"gap-1.5",children:[i,"Add Your First Connection"]})]})}),d[4]=m,d[5]=c):c=d[5],c}var Q=e.i(793479),E=e.i(110204),U=e.i(776639),O=e.i(967489),H=e.i(373884),K=e.i(178583),X=e.i(37727);function Y(e,s=6){let t=[],a=[],n="",l=!1,i=0;for(;i<e.length&&t.length<s;){let s=e[i];l?'"'===s?i+1<e.length&&'"'===e[i+1]?(n+='"',i+=2):(l=!1,i++):(n+=s,i++):'"'===s?(l=!0,i++):","===s?(a.push(n.trim()),n="",i++):"\r"===s||"\n"===s?(a.push(n.trim()),n="",a.some(e=>""!==e)&&t.push(a),a=[],"\r"===s&&i+1<e.length&&"\n"===e[i+1]?i+=2:i++):(n+=s,i++)}return(n||a.length>0)&&(a.push(n.trim()),a.some(e=>""!==e)&&t.push(a)),t}function G(e){return e>1048576?`${(e/1048576).toFixed(1)} MB`:`${(e/1024).toFixed(1)} KB`}function J(e){return e.replace(/\.csv$/i,"").replace(/[^\w\s]/g,"").replace(/\s+/g,"_").toLowerCase().slice(0,64)||"imported_data"}function W(e){let a,n,l,i,c,o,d,m,h,x,u,g,f,j,b,N,y,w,C=(0,t.c)(72),{formHook:S,connections:_,onOpenCsvImport:F,onRemoveCsvTable:D}=e,{dialogOpen:A,setDialogOpen:L,editingId:I,form:P,setForm:T,isLocalType:B,testingConnection:z,testResult:M,pendingCsvFiles:R,pendingCsvFileRef:q,isFormValid:$,isSaving:V,handleTypeChange:Q,handleTestConnection:E,handleSave:O,handlePendingCsvFileSelect:H,removePendingCsvFile:K,updatePendingTableName:X}=S,Y="csv"===P.type&&"sm:max-w-xl";C[0]!==Y?(a=(0,k.cn)("sm:max-w-lg max-h-[85vh] flex! flex-col! p-4 sm:p-6",Y),C[0]=Y,C[1]=a):a=C[1];let G=I?"Edit Connection":"Add Connection";C[2]!==G?(n=(0,s.jsx)(U.DialogTitle,{children:G}),C[2]=G,C[3]=n):n=C[3];let J=I?"Update your database connection details.":"Configure a new database connection.";C[4]!==J?(l=(0,s.jsx)(U.DialogDescription,{children:J}),C[4]=J,C[5]=l):l=C[5],C[6]!==n||C[7]!==l?(i=(0,s.jsxs)(U.DialogHeader,{className:"shrink-0",children:[n,l]}),C[6]=n,C[7]=l,C[8]=i):i=C[8],C[9]!==P||C[10]!==T?(c=(0,s.jsx)(Z,{form:P,setForm:T}),C[9]=P,C[10]=T,C[11]=c):c=C[11],C[12]!==I||C[13]!==P||C[14]!==Q?(o=(0,s.jsx)(ee,{form:P,editingId:I,onTypeChange:Q}),C[12]=I,C[13]=P,C[14]=Q,C[15]=o):o=C[15],C[16]!==P||C[17]!==T?(d="sqlite"===P.type&&(0,s.jsx)(es,{form:P,setForm:T}),C[16]=P,C[17]=T,C[18]=d):d=C[18],C[19]!==I||C[20]!==P.type||C[21]!==H||C[22]!==q||C[23]!==R||C[24]!==K||C[25]!==X?(m="csv"===P.type&&!I&&(0,s.jsx)(ea,{pendingCsvFiles:R,pendingCsvFileRef:q,onFileSelect:H,onRemove:K,onUpdateTableName:X}),C[19]=I,C[20]=P.type,C[21]=H,C[22]=q,C[23]=R,C[24]=K,C[25]=X,C[26]=m):m=C[26],C[27]!==_||C[28]!==I||C[29]!==P.type||C[30]!==F||C[31]!==D||C[32]!==L?(h="csv"===P.type&&I&&(0,s.jsx)(en,{editingId:I,connections:_,onOpenCsvImport:F,onRemoveCsvTable:D,onCloseDialog:()=>L(!1)}),C[27]=_,C[28]=I,C[29]=P.type,C[30]=F,C[31]=D,C[32]=L,C[33]=h):h=C[33],C[34]!==P||C[35]!==B||C[36]!==T?(x=!B&&(0,s.jsx)(et,{form:P,setForm:T}),C[34]=P,C[35]=B,C[36]=T,C[37]=x):x=C[37],C[38]!==M?(u=M&&(0,s.jsx)(el,{testResult:M}),C[38]=M,C[39]=u):u=C[39],C[40]!==d||C[41]!==m||C[42]!==h||C[43]!==x||C[44]!==u||C[45]!==c||C[46]!==o?(g=(0,s.jsxs)("div",{className:"space-y-4 py-2 overflow-y-auto flex-1 min-h-0 -mx-4 sm:-mx-6 px-4 sm:px-6",children:[c,o,d,m,h,x,u]}),C[40]=d,C[41]=m,C[42]=h,C[43]=x,C[44]=u,C[45]=c,C[46]=o,C[47]=g):g=C[47],C[48]!==P.type||C[49]!==E||C[50]!==$||C[51]!==z?(f="csv"!==P.type&&(0,s.jsxs)(r.Button,{variant:"outline",onClick:E,disabled:!$||z,className:"gap-1.5",children:[z?(0,s.jsx)(p.Loader2,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(v,{className:"h-4 w-4"}),"Test Connection"]}),C[48]=P.type,C[49]=E,C[50]=$,C[51]=z,C[52]=f):f=C[52];let W=!$||V;C[53]!==V?(j=V&&(0,s.jsx)(p.Loader2,{className:"h-4 w-4 animate-spin"}),C[53]=V,C[54]=j):j=C[54];let ei=I?"Update":"csv"===P.type&&R.length>0?`Save & Import ${R.length} File${R.length>1?"s":""}`:"Save";return C[55]!==O||C[56]!==W||C[57]!==j||C[58]!==ei?(b=(0,s.jsxs)(r.Button,{onClick:O,disabled:W,className:"gap-1.5",children:[j,ei]}),C[55]=O,C[56]=W,C[57]=j,C[58]=ei,C[59]=b):b=C[59],C[60]!==f||C[61]!==b?(N=(0,s.jsxs)(U.DialogFooter,{className:"gap-2 sm:gap-0 shrink-0",children:[f,b]}),C[60]=f,C[61]=b,C[62]=N):N=C[62],C[63]!==g||C[64]!==a||C[65]!==N||C[66]!==i?(y=(0,s.jsxs)(U.DialogContent,{className:a,children:[i,g,N]}),C[63]=g,C[64]=a,C[65]=N,C[66]=i,C[67]=y):y=C[67],C[68]!==A||C[69]!==L||C[70]!==y?(w=(0,s.jsx)(U.Dialog,{open:A,onOpenChange:L,children:y}),C[68]=A,C[69]=L,C[70]=y,C[71]=w):w=C[71],w}function Z(e){let a,n,l,i=(0,t.c)(7),{form:r,setForm:c}=e,o="csv"===r.type?"e.g. Sales Data CSVs":"sqlite"===r.type?"e.g. Local SQLite DB":"e.g. Production Redshift";return i[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(E.Label,{htmlFor:"conn-name",children:"Connection Name"}),i[0]=a):a=i[0],i[1]!==c?(n=e=>c(s=>({...s,name:e.target.value})),i[1]=c,i[2]=n):n=i[2],i[3]!==r.name||i[4]!==o||i[5]!==n?(l=(0,s.jsxs)("div",{className:"space-y-2",children:[a,(0,s.jsx)(Q.Input,{id:"conn-name",placeholder:o,value:r.name,onChange:n})]}),i[3]=r.name,i[4]=o,i[5]=n,i[6]=l):l=i[6],l}function ee(e){let a,n,l,i,r,c=(0,t.c)(9),{form:o,editingId:d,onTypeChange:m}=e;c[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(E.Label,{children:"Database Type"}),c[0]=a):a=c[0],c[1]!==m?(n=e=>m(e),c[1]=m,c[2]=n):n=c[2];let h=!!d;return c[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(O.SelectTrigger,{children:(0,s.jsx)(O.SelectValue,{})}),c[3]=l):l=c[3],c[4]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsxs)(O.SelectContent,{children:[(0,s.jsx)(O.SelectItem,{value:"postgresql",children:"PostgreSQL"}),(0,s.jsx)(O.SelectItem,{value:"redshift",children:"Amazon Redshift"}),(0,s.jsx)(O.SelectItem,{value:"mysql",children:"MySQL"}),(0,s.jsx)(O.SelectItem,{value:"sqlite",children:"SQLite"}),(0,s.jsx)(O.SelectItem,{value:"csv",children:"CSV Import"})]}),c[4]=i):i=c[4],c[5]!==o.type||c[6]!==n||c[7]!==h?(r=(0,s.jsxs)("div",{className:"space-y-2",children:[a,(0,s.jsxs)(O.Select,{value:o.type,onValueChange:n,disabled:h,children:[l,i]})]}),c[5]=o.type,c[6]=n,c[7]=h,c[8]=r):r=c[8],r}function es(e){let a,n,l,i,r,c=(0,t.c)(9),{form:o,setForm:d}=e;return c[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(E.Label,{htmlFor:"conn-filepath",children:"Database File Path"}),c[0]=a):a=c[0],c[1]!==d?(n=e=>d(s=>({...s,filePath:e.target.value})),c[1]=d,c[2]=n):n=c[2],c[3]!==o.filePath||c[4]!==n?(l=(0,s.jsx)(Q.Input,{id:"conn-filepath",placeholder:"/path/to/your/database.db",value:o.filePath,onChange:n}),c[3]=o.filePath,c[4]=n,c[5]=l):l=c[5],c[6]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Full path to the SQLite database file on your local machine"}),c[6]=i):i=c[6],c[7]!==l?(r=(0,s.jsxs)("div",{className:"space-y-2",children:[a,l,i]}),c[7]=l,c[8]=r):r=c[8],r}function et(e){let a,n,l,i,r,c,o,d,m,h,x,u,p,g,f,j,b,v,N,y,w=(0,t.c)(46),{form:C,setForm:S}=e;w[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(E.Label,{htmlFor:"conn-host",children:"Host"}),w[0]=a):a=w[0],w[1]!==S?(n=e=>S(s=>({...s,host:e.target.value})),w[1]=S,w[2]=n):n=w[2],w[3]!==C.host||w[4]!==n?(l=(0,s.jsxs)("div",{className:"space-y-2",children:[a,(0,s.jsx)(Q.Input,{id:"conn-host",placeholder:"localhost",value:C.host,onChange:n})]}),w[3]=C.host,w[4]=n,w[5]=l):l=w[5],w[6]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(E.Label,{htmlFor:"conn-port",children:"Port"}),w[6]=i):i=w[6];let k=String(D[C.type]);return w[7]!==S?(r=e=>S(s=>({...s,port:e.target.value})),w[7]=S,w[8]=r):r=w[8],w[9]!==C.port||w[10]!==k||w[11]!==r?(c=(0,s.jsxs)("div",{className:"space-y-2",children:[i,(0,s.jsx)(Q.Input,{id:"conn-port",placeholder:k,value:C.port,onChange:r})]}),w[9]=C.port,w[10]=k,w[11]=r,w[12]=c):c=w[12],w[13]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsx)(E.Label,{htmlFor:"conn-database",children:"Database"}),w[13]=o):o=w[13],w[14]!==S?(d=e=>S(s=>({...s,database:e.target.value})),w[14]=S,w[15]=d):d=w[15],w[16]!==C.database||w[17]!==d?(m=(0,s.jsxs)("div",{className:"space-y-2",children:[o,(0,s.jsx)(Q.Input,{id:"conn-database",placeholder:"my_database",value:C.database,onChange:d})]}),w[16]=C.database,w[17]=d,w[18]=m):m=w[18],w[19]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsx)(E.Label,{htmlFor:"conn-user",children:"Username"}),w[19]=h):h=w[19],w[20]!==S?(x=e=>S(s=>({...s,user:e.target.value})),w[20]=S,w[21]=x):x=w[21],w[22]!==C.user||w[23]!==x?(u=(0,s.jsxs)("div",{className:"space-y-2",children:[h,(0,s.jsx)(Q.Input,{id:"conn-user",placeholder:"postgres",value:C.user,onChange:x})]}),w[22]=C.user,w[23]=x,w[24]=u):u=w[24],w[25]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(E.Label,{htmlFor:"conn-password",children:"Password"}),w[25]=p):p=w[25],w[26]!==S?(g=e=>S(s=>({...s,password:e.target.value})),w[26]=S,w[27]=g):g=w[27],w[28]!==C.password||w[29]!==g?(f=(0,s.jsxs)("div",{className:"space-y-2",children:[p,(0,s.jsx)(Q.Input,{id:"conn-password",type:"password",placeholder:"••••••••",value:C.password,onChange:g})]}),w[28]=C.password,w[29]=g,w[30]=f):f=w[30],w[31]!==S?(j=e=>S(s=>({...s,ssl:e.target.checked})),w[31]=S,w[32]=j):j=w[32],w[33]!==C.ssl||w[34]!==j?(b=(0,s.jsx)("input",{type:"checkbox",id:"conn-ssl",checked:C.ssl,onChange:j,className:"rounded border-border"}),w[33]=C.ssl,w[34]=j,w[35]=b):b=w[35],w[36]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsx)(E.Label,{htmlFor:"conn-ssl",className:"text-sm font-normal cursor-pointer",children:"Use SSL"}),w[36]=v):v=w[36],w[37]!==b?(N=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[b,v]}),w[37]=b,w[38]=N):N=w[38],w[39]!==m||w[40]!==u||w[41]!==f||w[42]!==N||w[43]!==l||w[44]!==c?(y=(0,s.jsxs)(s.Fragment,{children:[l,c,m,u,f,N]}),w[39]=m,w[40]=u,w[41]=f,w[42]=N,w[43]=l,w[44]=c,w[45]=y):y=w[45],y}function ea(e){let a,n,l,i,c,d,m,h,x=(0,t.c)(20),{pendingCsvFiles:u,pendingCsvFileRef:p,onFileSelect:g,onRemove:f,onUpdateTableName:j}=e;return x[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(E.Label,{className:"text-xs",children:"CSV Files"}),x[0]=a):a=x[0],x[1]!==p?(n=()=>p.current?.click(),x[1]=p,x[2]=n):n=x[2],x[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(o.Plus,{className:"h-3 w-3"}),x[3]=l):l=x[3],x[4]!==n?(i=(0,s.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:n,className:"text-xs gap-1 h-7 text-green-400 border-green-400/30 hover:bg-green-400/10",children:[l,"Add CSV"]}),x[4]=n,x[5]=i):i=x[5],x[6]!==g||x[7]!==p?(c=(0,s.jsx)("input",{ref:p,type:"file",accept:".csv",onChange:g,className:"hidden"}),x[6]=g,x[7]=p,x[8]=c):c=x[8],x[9]!==i||x[10]!==c?(d=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[a,i,c]}),x[9]=i,x[10]=c,x[11]=d):d=x[11],x[12]!==f||x[13]!==j||x[14]!==p||x[15]!==u?(m=0===u.length?(0,s.jsxs)("div",{onClick:()=>p.current?.click(),className:"rounded-lg border-2 border-dashed p-6 text-center cursor-pointer transition-colors hover:border-green-400/40 hover:bg-green-400/5",children:[(0,s.jsx)(y,{className:"h-6 w-6 text-muted-foreground/40 mx-auto mb-2"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click to add CSV files — each file becomes a queryable table"})]}):(0,s.jsx)("div",{className:"rounded-lg border divide-y",children:u.map((e,t)=>(0,s.jsxs)("div",{className:"px-3 py-2.5 space-y-1.5",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(K.FileText,{className:"h-4 w-4 shrink-0 text-green-400/70"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:e.fileName}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:[G(e.fileSize),e.previewRows.length>0&&(0,s.jsxs)(s.Fragment,{children:[" · ",e.previewRows[0]?.length||0," columns"]})]})]}),(0,s.jsx)(r.Button,{variant:"ghost",size:"sm",onClick:()=>f(t),className:"h-7 w-7 p-0 text-destructive hover:text-destructive shrink-0",children:(0,s.jsx)(X.X,{className:"h-3 w-3"})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(E.Label,{className:"text-[11px] text-muted-foreground shrink-0 w-16",children:"Table name"}),(0,s.jsx)(Q.Input,{value:e.tableName,onChange:e=>j(t,e.target.value),className:"h-7 text-xs font-mono"})]})]},t))}),x[12]=f,x[13]=j,x[14]=p,x[15]=u,x[16]=m):m=x[16],x[17]!==d||x[18]!==m?(h=(0,s.jsxs)("div",{className:"space-y-3",children:[d,m]}),x[17]=d,x[18]=m,x[19]=h):h=x[19],h}function en(e){let a,n=(0,t.c)(16),{editingId:l,connections:i,onOpenCsvImport:c,onRemoveCsvTable:o,onCloseDialog:d}=e;if(n[0]!==i||n[1]!==l||n[2]!==d||n[3]!==c||n[4]!==o){let e,t,m,h,x;n[6]!==l?(e=e=>e.id===l,n[6]=l,n[7]=e):e=n[7];let u=i.find(e),p=u?.csvFiles||[];n[8]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsx)(E.Label,{className:"text-xs",children:"Imported CSV Files"}),n[8]=t):t=n[8],n[9]!==l||n[10]!==d||n[11]!==c?(m=()=>{d(),c(l)},n[9]=l,n[10]=d,n[11]=c,n[12]=m):m=n[12],n[13]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsx)(y,{className:"h-3 w-3"}),n[13]=h):h=n[13],n[14]!==m?(x=(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[t,(0,s.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:m,className:"text-xs gap-1 h-7 text-green-400 border-green-400/30 hover:bg-green-400/10",children:[h,"Import CSV"]})]}),n[14]=m,n[15]=x):x=n[15],a=(0,s.jsxs)("div",{className:"space-y-3",children:[x,0===p.length?(0,s.jsxs)("div",{className:"rounded-lg border border-dashed p-4 text-center",children:[(0,s.jsx)(_.FileSpreadsheet,{className:"h-6 w-6 text-muted-foreground/40 mx-auto mb-2"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"No CSV files imported yet"})]}):(0,s.jsx)("div",{className:"rounded-lg border divide-y max-h-64 overflow-y-auto",children:p.map(e=>(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[(0,s.jsx)(w.Table2,{className:"h-4 w-4 shrink-0 text-green-400/70"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,s.jsx)("p",{className:"text-xs font-medium font-mono truncate",title:e.tableName,children:e.tableName}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground truncate",title:e.fileName,children:[e.fileName,null!=e.rowCount&&` \xb7 ${e.rowCount} rows`]})]}),(0,s.jsx)(r.Button,{variant:"ghost",size:"sm",onClick:()=>o(l,e.tableName),className:"h-7 w-7 p-0 shrink-0 text-destructive hover:text-destructive",children:(0,s.jsx)(S.Trash2,{className:"h-3.5 w-3.5"})})]},e.tableName))})]}),n[0]=i,n[1]=l,n[2]=d,n[3]=c,n[4]=o,n[5]=a}else a=n[5];return a}function el(e){let a,n,l,i=(0,t.c)(9),{testResult:r}=e,c=r.success?"bg-green-500/10 text-green-500 border border-green-500/20":"bg-destructive/10 text-destructive border border-destructive/20";return i[0]!==c?(a=(0,k.cn)("rounded-lg p-3 text-sm flex items-center gap-2",c),i[0]=c,i[1]=a):a=i[1],i[2]!==r.error||i[3]!==r.latencyMs||i[4]!==r.success?(n=r.success?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.CheckCircle2,{className:"h-4 w-4 shrink-0"}),(0,s.jsxs)("span",{children:["Connected successfully (",r.latencyMs,"ms)"]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.XCircle,{className:"h-4 w-4 shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:r.error})]}),i[2]=r.error,i[3]=r.latencyMs,i[4]=r.success,i[5]=n):n=i[5],i[6]!==a||i[7]!==n?(l=(0,s.jsx)("div",{className:a,children:n}),i[6]=a,i[7]=n,i[8]=l):l=i[8],l}function ei(e){let a,n,l,i,r,c,o,d,m,h,x=(0,t.c)(29),{previewRows:u,totalLineCount:p}=e;if(u.length<=1)return null;let g=u[0];if(x[0]!==g||x[1]!==u){let e,t,c=u.slice(1,6);r="rounded-lg border overflow-hidden",i="overflow-auto max-h-48",n="text-xs",x[7]!==g?(e=g.map(er),x[7]=g,x[8]=e):e=x[8],x[9]!==e?(l=(0,s.jsx)("thead",{className:"sticky top-0",children:(0,s.jsx)("tr",{className:"bg-muted/80 border-b",children:e})}),x[9]=e,x[10]=l):l=x[10],x[11]!==g?(t=(e,t)=>(0,s.jsx)("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:g.map((t,a)=>(0,s.jsx)("td",{className:"px-2.5 py-1 text-muted-foreground font-mono text-[11px] whitespace-nowrap max-w-[180px] truncate",children:(e[a]??"").length>30?(e[a]??"").slice(0,28)+"…":e[a]??""},a))},t),x[11]=g,x[12]=t):t=x[12],a=c.map(t),x[0]=g,x[1]=u,x[2]=a,x[3]=n,x[4]=l,x[5]=i,x[6]=r}else a=x[2],n=x[3],l=x[4],i=x[5],r=x[6];return x[13]!==a?(c=(0,s.jsx)("tbody",{children:a}),x[13]=a,x[14]=c):c=x[14],x[15]!==n||x[16]!==l||x[17]!==c?(o=(0,s.jsxs)("table",{className:n,children:[l,c]}),x[15]=n,x[16]=l,x[17]=c,x[18]=o):o=x[18],x[19]!==i||x[20]!==o?(d=(0,s.jsx)("div",{className:i,children:o}),x[19]=i,x[20]=o,x[21]=d):d=x[21],x[22]!==u.length||x[23]!==p?(m=p&&p>6&&(0,s.jsxs)("div",{className:"px-3 py-1 text-[10px] text-muted-foreground/60 bg-muted/30 border-t text-center",children:["Showing first ",Math.min(u.length-1,5)," rows · full file will be imported"]}),x[22]=u.length,x[23]=p,x[24]=m):m=x[24],x[25]!==r||x[26]!==d||x[27]!==m?(h=(0,s.jsxs)("div",{className:r,children:[d,m]}),x[25]=r,x[26]=d,x[27]=m,x[28]=h):h=x[28],h}function er(e,t){return(0,s.jsx)("th",{className:"px-2.5 py-1.5 text-left font-semibold text-foreground whitespace-nowrap text-[11px]",children:e.length>24?e.slice(0,22)+"…":e||`col_${t+1}`},t)}function ec(e){let a,n,l,i,c,o,d,m,h,x,u,g=(0,t.c)(37),{csvImport:f}=e,{dialogOpen:j,setDialogOpen:b,tableName:v,setTableName:N,fileName:w,fileSize:C,content:S,previewRows:k,importing:F,fileRef:D,isImportValid:A,handleFileSelect:L,handleImport:I}=f;g[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsxs)(U.DialogHeader,{className:"shrink-0",children:[(0,s.jsxs)(U.DialogTitle,{className:"flex items-center gap-2",children:[(0,s.jsx)(_.FileSpreadsheet,{className:"h-5 w-5 text-green-400"}),"Import CSV File"]}),(0,s.jsx)(U.DialogDescription,{children:"Each imported CSV becomes a queryable SQL table."})]}),g[0]=a):a=g[0],g[1]!==w||g[2]!==D||g[3]!==C||g[4]!==L||g[5]!==k?(n=(0,s.jsx)(eo,{fileRef:D,fileName:w,fileSize:C,previewRows:k,onFileSelect:L}),g[1]=w,g[2]=D,g[3]=C,g[4]=L,g[5]=k,g[6]=n):n=g[6],g[7]!==w||g[8]!==N||g[9]!==v?(l=w&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(E.Label,{htmlFor:"csv-table",className:"text-xs",children:"Table Name"}),(0,s.jsx)(Q.Input,{id:"csv-table",placeholder:"e.g. sales_data",value:v,onChange:e=>N(e.target.value),className:"h-9"}),(0,s.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["SQL table name — you'll query it as"," ",(0,s.jsxs)("code",{className:"bg-muted px-1 rounded",children:["SELECT * FROM ",v||"table_name"]})]})]}),g[7]=w,g[8]=N,g[9]=v,g[10]=l):l=g[10],g[11]!==S||g[12]!==k?(i=k.length>1&&(0,s.jsxs)("div",{className:"space-y-1.5 min-w-0",children:[(0,s.jsx)(E.Label,{className:"text-xs",children:"Preview"}),(0,s.jsx)(ei,{previewRows:k,totalLineCount:S.split("\n").length})]}),g[11]=S,g[12]=k,g[13]=i):i=g[13],g[14]!==n||g[15]!==l||g[16]!==i?(c=(0,s.jsxs)("div",{className:"space-y-4 py-2 overflow-y-auto flex-1 min-h-0",children:[n,l,i]}),g[14]=n,g[15]=l,g[16]=i,g[17]=c):c=g[17],g[18]!==b?(o=(0,s.jsx)(r.Button,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),g[18]=b,g[19]=o):o=g[19];let P=!A||F;g[20]!==F?(d=F?(0,s.jsx)(p.Loader2,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(y,{className:"h-4 w-4"}),g[20]=F,g[21]=d):d=g[21];let T=F?"Importing...":"Import";return g[22]!==I||g[23]!==P||g[24]!==d||g[25]!==T?(m=(0,s.jsxs)(r.Button,{onClick:I,disabled:P,className:"gap-1.5",children:[d,T]}),g[22]=I,g[23]=P,g[24]=d,g[25]=T,g[26]=m):m=g[26],g[27]!==m||g[28]!==o?(h=(0,s.jsxs)(U.DialogFooter,{className:"shrink-0",children:[o,m]}),g[27]=m,g[28]=o,g[29]=h):h=g[29],g[30]!==h||g[31]!==c?(x=(0,s.jsxs)(U.DialogContent,{className:"sm:max-w-xl max-h-[85vh] flex! flex-col! overflow-hidden p-4 sm:p-6",children:[a,c,h]}),g[30]=h,g[31]=c,g[32]=x):x=g[32],g[33]!==j||g[34]!==b||g[35]!==x?(u=(0,s.jsx)(U.Dialog,{open:j,onOpenChange:b,children:x}),g[33]=j,g[34]=b,g[35]=x,g[36]=u):u=g[36],u}function eo(e){let a,n,l,i,r,c=(0,t.c)(16),{fileRef:o,fileName:d,fileSize:m,previewRows:h,onFileSelect:x}=e;c[0]!==o?(a=()=>o.current?.click(),c[0]=o,c[1]=a):a=c[1];let u=d?"border-green-400/30 bg-green-400/5":"border-border";return c[2]!==u?(n=(0,k.cn)("border-2 border-dashed rounded-lg px-4 py-3 cursor-pointer transition-colors","hover:border-primary/50 hover:bg-primary/5",u),c[2]=u,c[3]=n):n=c[3],c[4]!==o||c[5]!==x?(l=(0,s.jsx)("input",{ref:o,type:"file",accept:".csv",onChange:x,className:"hidden"}),c[4]=o,c[5]=x,c[6]=l):l=c[6],c[7]!==d||c[8]!==m||c[9]!==h?(i=d?(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(K.FileText,{className:"h-5 w-5 text-green-400 shrink-0"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium truncate",children:d}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[m>0&&G(m),h.length>1&&(0,s.jsxs)(s.Fragment,{children:[" · ",h[0]?.length||0," columns detected"]})]})]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground shrink-0",children:"Change file"})]}):(0,s.jsxs)("div",{className:"flex items-center gap-3 justify-center py-2",children:[(0,s.jsx)(y,{className:"h-5 w-5 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Click to select a CSV file"})]}),c[7]=d,c[8]=m,c[9]=h,c[10]=i):i=c[10],c[11]!==a||c[12]!==n||c[13]!==l||c[14]!==i?(r=(0,s.jsxs)("div",{onClick:a,className:n,children:[l,i]}),c[11]=a,c[12]=n,c[13]=l,c[14]=i,c[15]=r):r=c[15],r}var ed=e.i(271645);function em(){let e,l,i,r,c,o,d,m,x,u,p,g,f,j=(0,t.c)(44),{data:b,isLoading:v}=a.api.connection.list.useQuery(),N=a.api.connection.delete.useMutation(),y=a.api.connection.setActive.useMutation(),w=a.api.connection.testExisting.useMutation(),C=a.api.connection.removeCsvTable.useMutation(),S=a.api.useUtils();j[0]!==b?.connections?(e=b?.connections||[],j[0]=b?.connections,j[1]=e):e=j[1];let k=e,_=b?.activeConnectionId;j[2]!==S.connection.list?(l=()=>{S.connection.list.invalidate()},j[2]=S.connection.list,j[3]=l):l=j[3];let F=l;j[4]!==F?(i={onSaved:F},j[4]=F,j[5]=i):i=j[5];let L=function({onSaved:e}){let[s,t]=(0,ed.useState)(!1),[l,i]=(0,ed.useState)(null),[r,c]=(0,ed.useState)(A),[o,d]=(0,ed.useState)(!1),[m,h]=(0,ed.useState)(null),[x,u]=(0,ed.useState)([]),p=(0,ed.useRef)(null),g=a.api.connection.add.useMutation(),f=a.api.connection.update.useMutation(),j=a.api.connection.test.useMutation(),b=a.api.connection.importCsv.useMutation(),v=a.api.useUtils(),N="sqlite"===r.type||"csv"===r.type,y=(0,ed.useCallback)(()=>{i(null),c(A),h(null),u([]),t(!0)},[]),w=(0,ed.useCallback)(async e=>{i(e),h(null);let s=await v.connection.get.fetch({id:e});if(s.connection){let e=s.connection;c({name:e.name,type:e.type,host:e.host||"",port:String(e.port||0),user:e.user||"",password:e.password||"",database:e.database||"",ssl:e.ssl||!1,filePath:e.filePath||""})}t(!0)},[v]),C=(0,ed.useCallback)(e=>{c(s=>({...s,type:e,..."sqlite"===e||"csv"===e?{host:"",port:"0",user:"",password:"",database:"",ssl:!1}:{port:String(D[e]),filePath:""}})),"csv"!==e&&u([])},[]),S=(0,ed.useCallback)(async()=>{d(!0),h(null);try{let e=await j.mutateAsync({name:r.name||"Test",type:r.type,host:r.host||"",port:parseInt(r.port)||D[r.type],user:r.user||"",password:r.password||"",database:r.database||"",ssl:r.ssl,filePath:r.filePath||void 0});h(e)}catch(e){h({success:!1,error:e.message||"Connection test failed"})}finally{d(!1)}},[r,j]),k=(0,ed.useCallback)(async()=>{try{let s={name:r.name,type:r.type,host:r.host||"",port:parseInt(r.port)||D[r.type],user:r.user||"",password:r.password||"",database:r.database||"",ssl:r.ssl,filePath:r.filePath||void 0};if(l)await f.mutateAsync({id:l,data:s}),n.toast.success("Connection updated");else{let e=await g.mutateAsync(s);if("csv"===r.type&&x.length>0&&e.connection){let s=e.connection.id,t=0;for(let e of x)try{await b.mutateAsync({connectionId:s,csvContent:e.content,tableName:e.tableName,fileName:e.fileName}),t++}catch(s){n.toast.error(`Failed to import ${e.fileName}: ${s.message}`)}n.toast.success(t>0?`Connection created with ${t} CSV file(s) imported`:"Connection added")}else n.toast.success("Connection added");u([])}t(!1),e()}catch(e){n.toast.error(e.message||"Failed to save connection")}},[r,l,g,f,b,x,e]),_=(0,ed.useCallback)(e=>{let s=e.target.files?.[0];if(!s)return;let t=J(s.name),a=new FileReader;a.onload=e=>{let a=e.target?.result||"",n=Y(a,4);u(e=>[...e,{fileName:s.name,tableName:t,content:a,fileSize:s.size,previewRows:n}])},a.readAsText(s),p.current&&(p.current.value="")},[]),F=(0,ed.useCallback)(e=>{u(s=>s.filter((s,t)=>t!==e))},[]),L=(0,ed.useCallback)((e,s)=>{u(t=>t.map((t,a)=>a===e?{...t,tableName:s}:t))},[]),I=!!r.name.trim()&&("sqlite"===r.type?!!r.filePath?.trim():"csv"===r.type?!!l||x.length>0:!!(r.host.trim()&&r.port.trim()&&r.user.trim()&&r.password.trim()&&r.database.trim()));return{dialogOpen:s,setDialogOpen:t,editingId:l,form:r,setForm:c,isLocalType:N,testingConnection:o,testResult:m,pendingCsvFiles:x,pendingCsvFileRef:p,isFormValid:I,isSaving:g.isPending||f.isPending,openAddDialog:y,openEditDialog:w,handleTypeChange:C,handleTestConnection:S,handleSave:k,handlePendingCsvFileSelect:_,removePendingCsvFile:F,updatePendingTableName:L}}(i);j[6]!==F?(r={onImported:F},j[6]=F,j[7]=r):r=j[7];let I=function({onImported:e}){let[s,t]=(0,ed.useState)(!1),[l,i]=(0,ed.useState)(null),[r,c]=(0,ed.useState)(""),[o,d]=(0,ed.useState)(""),[m,h]=(0,ed.useState)(""),[x,u]=(0,ed.useState)(0),[p,g]=(0,ed.useState)([]),[f,j]=(0,ed.useState)(!1),b=(0,ed.useRef)(null),v=a.api.connection.importCsv.useMutation(),N=(0,ed.useCallback)(e=>{i(e),c(""),d(""),h(""),u(0),g([]),t(!0),b.current&&(b.current.value="")},[]),y=(0,ed.useCallback)(e=>{let s=e.target.files?.[0];if(!s)return;d(s.name),u(s.size),c(J(s.name));let t=new FileReader;t.onload=e=>{let s=e.target?.result||"";h(s),g(Y(s,6))},t.readAsText(s)},[]),w=(0,ed.useCallback)(async()=>{if(l&&m&&r){j(!0);try{let s=await v.mutateAsync({connectionId:l,csvContent:m,tableName:r,fileName:o});n.toast.success(`Imported ${s.rowCount} rows into table "${s.tableName}"`),t(!1),e()}catch(e){n.toast.error(e.message||"Failed to import CSV")}finally{j(!1)}}},[l,m,r,o,v,e]),C=!!(m&&r.trim());return{dialogOpen:s,setDialogOpen:t,tableName:r,setTableName:c,fileName:o,fileSize:x,content:m,previewRows:p,importing:f,fileRef:b,isImportValid:C,openDialog:N,handleFileSelect:y,handleImport:w}}(r);j[8]!==N||j[9]!==F?(c=async(e,s)=>{if(confirm(`Delete connection "${s}"? This cannot be undone.`))try{await N.mutateAsync({id:e}),n.toast.success("Connection deleted"),F()}catch(e){n.toast.error(e.message||"Failed to delete connection")}},j[8]=N,j[9]=F,j[10]=c):c=j[10];let P=c;j[11]!==F||j[12]!==y?(o=async e=>{try{await y.mutateAsync({id:e}),F(),n.toast.success("Active connection updated")}catch(e){n.toast.error(e.message||"Failed to set active connection")}},j[11]=F,j[12]=y,j[13]=o):o=j[13];let T=o;j[14]!==w?(d=async e=>{try{let s=await w.mutateAsync({id:e});s.success?n.toast.success(`Connection successful (${s.latencyMs}ms)`):n.toast.error(`Connection failed: ${s.error}`)}catch(e){n.toast.error(e.message||"Test failed")}},j[14]=w,j[15]=d):d=j[15];let B=d;j[16]!==F||j[17]!==C?(m=async(e,s)=>{if(confirm(`Remove table "${s}"? This will delete the imported data.`))try{await C.mutateAsync({connectionId:e,tableName:s}),n.toast.success(`Table "${s}" removed`),F()}catch(e){n.toast.error(e.message||"Failed to remove table")}},j[16]=F,j[17]=C,j[18]=m):m=j[18];let z=m;return j[19]!==L.openAddDialog?(x=(0,s.jsx)(h,{onAddConnection:L.openAddDialog}),j[19]=L.openAddDialog,j[20]=x):x=j[20],j[21]!==_||j[22]!==k||j[23]!==I.openDialog||j[24]!==L.openAddDialog||j[25]!==L.openEditDialog||j[26]!==P||j[27]!==T||j[28]!==B||j[29]!==v||j[30]!==w.isPending?(u=(0,s.jsx)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 -mt-4 sm:-mt-8 pb-8 sm:pb-12",children:(0,s.jsx)($,{connections:k,activeConnectionId:_,isLoading:v,isTestPending:w.isPending,onAdd:L.openAddDialog,onSetActive:T,onTestExisting:B,onEdit:L.openEditDialog,onDelete:P,onImportCsv:I.openDialog})}),j[21]=_,j[22]=k,j[23]=I.openDialog,j[24]=L.openAddDialog,j[25]=L.openEditDialog,j[26]=P,j[27]=T,j[28]=B,j[29]=v,j[30]=w.isPending,j[31]=u):u=j[31],j[32]!==k||j[33]!==I.openDialog||j[34]!==L||j[35]!==z?(p=(0,s.jsx)(W,{formHook:L,connections:k,onOpenCsvImport:I.openDialog,onRemoveCsvTable:z}),j[32]=k,j[33]=I.openDialog,j[34]=L,j[35]=z,j[36]=p):p=j[36],j[37]!==I?(g=(0,s.jsx)(ec,{csvImport:I}),j[37]=I,j[38]=g):g=j[38],j[39]!==p||j[40]!==g||j[41]!==x||j[42]!==u?(f=(0,s.jsxs)("div",{className:"min-h-screen bg-background overflow-x-hidden",children:[x,u,p,g]}),j[39]=p,j[40]=g,j[41]=x,j[42]=u,j[43]=f):f=j[43],f}e.s(["ConnectionsPage",()=>em],775258)}]);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/.next/static/{H1e0tcZUy-dcOaNBJh3iW → MtWdFBWYBrNNpdc-evjbH}/_clientMiddlewareManifest.json
RENAMED
|
File without changes
|
|
File without changes
|