db-studio 1.7.7 → 1.7.10
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/dist/core-dist/assets/{_pathlessLayout-BU3Kyxsk.js → _pathlessLayout-Dh-wnEbU.js} +2 -2
- package/dist/core-dist/assets/{_queryId-CCHTTBV8.js → _queryId-k0QvsBGf.js} +1 -1
- package/dist/core-dist/assets/{_table-CJoa4R3j.js → _table-BuJCKd_h.js} +3 -3
- package/dist/core-dist/assets/{_table-DUXAj26I.js → _table-cCBv5kB-.js} +1 -1
- package/dist/core-dist/assets/{cdoe-editor-D9sNd-1b.js → cdoe-editor-IGx3GQWB.js} +1 -1
- package/dist/core-dist/assets/chat-sidebar-D2GaNd69.js +2 -0
- package/dist/core-dist/assets/{dist-BEhHk7ZM.js → dist-ZzQZZhtF.js} +1 -1
- package/dist/core-dist/assets/{dist-BI9dZvr6.js → dist-v6aWpqmu.js} +1 -1
- package/dist/core-dist/assets/{index-CcB1R3kx.js → index-BtQYs6UF.js} +11 -11
- package/dist/core-dist/assets/{queries.store-CitCTkPZ.js → queries.store-BtuppsNj.js} +1 -1
- package/dist/core-dist/assets/{runner-Be0RXHJn.js → runner-VSPg2lHo.js} +1 -1
- package/dist/core-dist/assets/{runner-tab-_ttjqcHa.js → runner-tab-BQH-lTnK.js} +3 -3
- package/dist/core-dist/assets/{scroll-area-B6qID65r.js → scroll-area-BnT9xy-y.js} +1 -1
- package/dist/core-dist/assets/{tooltip-BpcLhRow.js → tooltip-B3DXDN3Y.js} +1 -1
- package/dist/core-dist/assets/{use-delete-column-DUq6S2en.js → use-delete-column-B-oY2CU8.js} +1 -1
- package/dist/core-dist/assets/use-rate-limit-BenJo7Lk.js +1 -0
- package/dist/core-dist/index.html +1 -1
- package/dist/index.js +88 -86
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/core-dist/assets/chat-sidebar-Bsby7756.js +0 -2
- package/dist/core-dist/assets/use-rate-limit-HDhI0oS3.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chat-sidebar-
|
|
2
|
-
import{r as qe}from"./rolldown-runtime-Bnw7wDfq.js";import{_ as we,c as re,d as $e,g as G,h as De,v as le,x as Be}from"./tanstack-DyfKDo5s.js";import{A as Ve,D as Te,E as Ue,G as Ge,J as Ke,L as We,M as Xe,O as Ye,P as Je,U as je,_ as oe,d as Ee,g as Ze,h as es,i as ie,j as ss,l as ts,m as ce,nt as as,p as ns,s as rs,v as ls}from"./icons-BywMJ5og.js";import{Ot as os,d as is,f as cs,l as ds,m as us,p as ms,u as hs}from"./radix-ui-C0u6gLux.js";import{It as xs}from"./monaco-editor-B6TxHuqP.js";import{$ as P,A as fs,B as _e,Et as y,F as ps,I as bs,L as js,M as k,N as ge,Ot as S,P as gs,Q,S as vs,St as ys,X as H,Z as q,_t as ke,c as Cs,ct as de,dt as ue,et as $,ft as me,ht as he,i as se,it as D,j as Ns,k as Ss,mt as xe,nt as B,o as ws,ot as Ds,pt as L,s as Ts,st as z,tt as V,wt as j,xt as Es,yt as _s}from"./index-CcB1R3kx.js";import{t as ks}from"./scroll-area-B6qID65r.js";import{i as X,n as Y,t as J}from"./tooltip-BpcLhRow.js";import{t as zs}from"./use-rate-limit-HDhI0oS3.js";import{n as M}from"./dist-BEhHk7ZM.js";import{a as Os,c as Is,i as Fs,l as Rs,n as U,o as As,r as Ls,s as Ms,t as Ps,u as Qs}from"./dist-BI9dZvr6.js";import{t as te}from"./queries.store-CitCTkPZ.js";var ve={AUTHOR:"Hüsam 🥑 <devhsmq@gmail.com>",AUTHOR_NAME:"Hüsam",AUTHOR_AVATAR:"/avocado.png",AUTHOR_USERNAME:"husamql3",AUTHOR_GITHUB_LINK:"https://github.com/husamql3",SITE_DESCRIPTION:"The modern pgAdmin alternative that works with every database.",SITE_KEYWORDS:["pgadmin alternative","database client","database gui","database browser","sql editor","postgresql client","mysql client","table editor","ai sql","er diagram"],SITE_TITLE:"DB Studio",SITE_NAME:"dbstudio.sh",SITE_URL:"https://dbstudio.sh",SITE_X_LINK:"https://x.com/dbstudio_sh",SITE_GITHUB_LINK:"https://github.com/husamql3/db-studio",SITE_GITHUB_NEW_ISSUE_LINK:"https://github.com/husamql3/db-studio/issues/new/choose",SITE_DOCS_LINK:"https://dbstudio.sh/docs",SITE_CHANGELOG_LINK:"https://dbstudio.sh/changelog",SITE_ROADMAP_LINK:"https://dbstudio.sh/roadmap",SITE_IMAGE:"https://dbstudio.sh/og-image.png",SITE_IMAGE_WIDTH:"1200",SITE_IMAGE_HEIGHT:"630",SITE_IMAGE_ALT:"dbstudio.sh – Modern database management studio",SITE_COLOR:"#1447e6"},o=qe(as(),1),ze={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ye=o.createContext&&o.createContext(ze),Hs=["attr","size","title"];function qs(s,t){if(s==null)return{};var a,n,r=$s(s,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(s,a)&&(r[a]=s[a])}return r}function $s(s,t){if(s==null)return{};var a={};for(var n in s)if({}.hasOwnProperty.call(s,n)){if(t.indexOf(n)!==-1)continue;a[n]=s[n]}return a}function Z(){return Z=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(s[n]=a[n])}return s},Z.apply(null,arguments)}function Ce(s,t){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),a.push.apply(a,n)}return a}function ee(s){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Ce(Object(a),!0).forEach(function(n){Bs(s,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):Ce(Object(a)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(a,n))})}return s}function Bs(s,t,a){return(t=Vs(t))in s?Object.defineProperty(s,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[t]=a,s}function Vs(s){var t=Us(s,"string");return typeof t=="symbol"?t:t+""}function Us(s,t){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var n=a.call(s,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function Oe(s){return s&&s.map((t,a)=>o.createElement(t.tag,ee({key:a},t.attr),Oe(t.child)))}function Gs(s){return t=>o.createElement(Ks,Z({attr:ee({},s.attr)},t),Oe(s.child))}function Ks(s){var t=a=>{var{attr:n,size:r,title:l}=s,u=qs(s,Hs),i=r||a.size||"1em",m;return a.className&&(m=a.className),s.className&&(m=(m?m+" ":"")+s.className),o.createElement("svg",Z({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:m,style:ee(ee({color:s.color||a.color},a.style),s.style),height:i,width:i,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),s.children)};return ye!==void 0?o.createElement(ye.Consumer,null,a=>t(a)):t(ze)}function Ws(s){return Gs({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"},child:[]},{tag:"path",attr:{d:"M9 18c-4.51 2-5-2-7-2"},child:[]}]})(s)}var e=os(),Xs=(0,o.lazy)(()=>xs(()=>import("./chat-sidebar-Bsby7756.js").then(s=>({default:s.ChatSidebar})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Ys=()=>{const{isSheetOpen:s,openSheet:t}=ke(),{rateLimit:a,isLoadingRateLimit:n}=zs(),{remaining:r=0,limit:l=0}=a??{remaining:0,limit:0},i=(m=>m===0?"bg-red-500":m<=5?"bg-yellow-500":"bg-emerald-500")(r);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsxs)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12 relative",onClick:()=>t("ai-assistant"),children:[(0,e.jsx)(ts,{className:"size-5"}),(0,e.jsx)("span",{className:y("absolute top-2 right-2 h-2 w-2 rounded-full ring-2 ring-background",i)})]})}),(0,e.jsx)(Y,{side:"bottom",className:"text-xs",children:!n&&(r>0?(0,e.jsxs)("p",{children:[r,"/",l," messages remaining"]}):(0,e.jsx)("p",{children:"AI Assistant"}))})]}),s("ai-assistant")&&(0,e.jsx)(o.Suspense,{fallback:null,children:(0,e.jsx)(Xs,{})})]})},Js=()=>{const{pathname:s}=re(),t=s.split("/")[1]||"table";return(0,e.jsx)("div",{className:"flex h-full items-center",children:Ds.map(a=>(0,e.jsx)(De,{to:`/${a}`,className:"h-full flex items-center",children:(0,e.jsx)(j,{variant:"ghost",className:y("flex-1 px-4 border-l-0 border-y-0 border-r border-zinc-800 h-full rounded-none",t===a?"bg-zinc-900 text-white":"text-zinc-400"),children:a})},a))})},Zs=()=>{const{sidebar:{isOpen:s,isPinned:t},setSidebarOpen:a,setSidebarPinned:n}=se(),r=()=>{a(!s),n(!t)};return(0,e.jsx)(j,{variant:"ghost",onClick:r,className:"h-full aspect-square border-l-0 border-y-0 border-r border-zinc-800 rounded-none",children:(0,e.jsx)(ls,{className:"size-5"})})},et=()=>(0,e.jsxs)("div",{className:"border-b border-zinc-800 w-full flex items-center justify-between bg-black h-12",children:[(0,e.jsxs)("div",{className:"flex items-center h-full",children:[(0,e.jsx)(Zs,{}),(0,e.jsx)(Js,{})]}),(0,e.jsxs)("div",{className:"flex items-center h-full",children:[(0,e.jsx)(Ys,{}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12",asChild:!0,children:(0,e.jsx)("a",{href:ve.SITE_GITHUB_NEW_ISSUE_LINK,target:"_blank",rel:"noopener noreferrer","aria-label":"Create a new GitHub issue",children:(0,e.jsx)(Ke,{className:"size-5"})})})}),(0,e.jsx)(Y,{children:(0,e.jsx)("p",{children:"Report a bug"})})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12",asChild:!0,children:(0,e.jsx)("a",{href:ve.SITE_GITHUB_LINK,target:"_blank",rel:"noopener noreferrer","aria-label":"View the db-studio GitHub repository",children:(0,e.jsx)(Ws,{className:"size-5"})})})}),(0,e.jsx)(Y,{children:(0,e.jsx)("p",{children:"View on GitHub"})})]})]})]});function Ie({...s}){return(0,e.jsx)(cs,{"data-slot":"context-menu",...s})}function Fe({className:s,...t}){return(0,e.jsx)(us,{"data-slot":"context-menu-trigger",className:y("select-none",s),...t})}function Re({className:s,...t}){return(0,e.jsx)(is,{children:(0,e.jsx)(ds,{"data-slot":"context-menu-content",className:y("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-context-menu-content-available-height) origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto",s),...t})})}function E({className:s,inset:t,variant:a="default",...n}){return(0,e.jsx)(hs,{"data-slot":"context-menu-item","data-inset":t,"data-variant":a,className:y("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",s),...n})}function Ne({className:s,...t}){return(0,e.jsx)(ms,{"data-slot":"context-menu-separator",className:y("bg-border/50 -mx-1 my-1 h-px",s),...t})}var ne=({folderId:s,isExpanded:t,onToggle:a,count:n,name:r,showContextMenu:l=!1})=>{const u=G(),{deleteFolder:i,getQueriesByFolder:m,addQuery:h,updateFolder:d}=te(),[C,f]=(0,o.useState)(!1),[g,c]=(0,o.useState)(""),[p,N]=(0,o.useState)(!1),w=(0,o.useCallback)(()=>{if(s){if(m(s).length>0){N(!0);return}i(s)}},[i,s,m]),x=(0,o.useCallback)(()=>{s&&(i(s),N(!1))},[i,s]),v=(0,o.useCallback)(()=>{u({to:"/runner/$queryId",params:{queryId:h(void 0,s)}})},[h,s,u]),O=(0,o.useCallback)(()=>{c(r),f(!0)},[r]),K=(0,o.useCallback)(()=>{s&&g.trim()&&(d(s,{name:g.trim()}),f(!1),c(""))},[s,g,d]);return(0,e.jsxs)(e.Fragment,{children:[l?(0,e.jsxs)(Ie,{children:[(0,e.jsx)(Fe,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",onClick:a,className:y("w-full flex gap-2 px-4 py-2 text-sm transition-colors text-left","hover:bg-zinc-800/50 hover:text-zinc-100 focus:outline-none focus:bg-zinc-800/50","text-zinc-400 items-center"),children:[(0,e.jsx)(je,{className:y("size-4 transition-transform duration-200",t?"rotate-90":"")}),(0,e.jsx)("span",{className:"flex-1",children:r}),(0,e.jsx)(U,{children:n})]})}),(0,e.jsxs)(Re,{children:[(0,e.jsxs)(E,{onClick:v,children:[(0,e.jsx)(ce,{className:"size-4"}),"Add a new query"]}),(0,e.jsxs)(E,{onClick:O,children:[(0,e.jsx)(oe,{className:"size-4"}),"Rename folder"]}),(0,e.jsxs)(E,{onClick:w,children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete folder"]})]})]}):(0,e.jsxs)("button",{type:"button",onClick:a,className:y("w-full flex gap-2 px-4 py-2 text-sm transition-colors text-left","hover:bg-zinc-800/50 hover:text-zinc-100 focus:outline-none focus:bg-zinc-800/50","text-zinc-400 items-center"),children:[(0,e.jsx)(je,{className:y("size-4 transition-transform duration-200",t?"rotate-90":"")}),(0,e.jsx)("span",{className:"flex-1",children:r}),(0,e.jsx)(U,{children:n})]}),(0,e.jsx)(q,{open:C,onOpenChange:f,children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Rename Folder"}),(0,e.jsx)(P,{children:"Enter a new name for this folder."})]}),(0,e.jsx)(H,{value:g,onChange:T=>c(T.target.value),placeholder:"Folder name",onKeyDown:T=>{T.key==="Enter"&&K()},autoFocus:!0}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{f(!1),c("")},children:"Cancel"}),(0,e.jsx)(j,{onClick:K,disabled:!g.trim(),children:"Rename"})]})]})}),(0,e.jsx)(Ls,{open:p,onOpenChange:N,children:(0,e.jsxs)(As,{children:[(0,e.jsxs)(Rs,{children:[(0,e.jsx)(Qs,{children:"Delete Folder"}),(0,e.jsxs)(Ms,{children:["This folder contains ",n," ",n===1?"query":"queries",". Deleting this folder will also delete all queries inside it. This action cannot be undone."]})]}),(0,e.jsxs)(Is,{children:[(0,e.jsx)(Os,{children:"Cancel"}),(0,e.jsx)(Fs,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Folder"})]})]})})]})},W=({id:s,tableName:t,isNested:a=!1,showContextMenu:n=!0})=>{const r=G(),{deleteQuery:l,addQuery:u,getQuery:i,toggleFavorite:m,updateQuery:h,moveQuery:d,folders:C,addFolder:f}=te(),{queryId:g}=we({strict:!1}),c=g===s,p=i(s),N=p?.isFavorite??!1,[w,x]=(0,o.useState)(!1),[v,O]=(0,o.useState)(""),[K,T]=(0,o.useState)(!1),[ae,I]=(0,o.useState)(void 0),[F,_]=(0,o.useState)(!1),[R,A]=(0,o.useState)(""),fe=(0,o.useCallback)(()=>{r({to:"/runner/$queryId",params:{queryId:s}})},[r,s]),Ae=(0,o.useCallback)(()=>{l(s),g===s&&r({to:"/runner"}),S.success("Query deleted successfully")},[l,s,r,g]),Le=(0,o.useCallback)(()=>{r({to:"/runner/$queryId",params:{queryId:u(`${i(s)?.name} (Copy)`)}}),S.success("Query duplicated successfully")},[u,i,r,s]),Me=(0,o.useCallback)(()=>{m(s),S.success("Query favorited successfully")},[m,s]),Pe=(0,o.useCallback)(()=>{O(p?.name??""),x(!0)},[p?.name]),pe=(0,o.useCallback)(()=>{v.trim()&&(h(s,{name:v.trim()}),x(!1),O(""),S.success("Query renamed successfully"))},[s,v,h]),Qe=(0,o.useCallback)(()=>{I(p?.folderId),_(!1),A(""),T(!0)},[p?.folderId]),He=(0,o.useCallback)(b=>{b==="__create_new__"?(_(!0),I(void 0)):(_(!1),I(b==="__none__"?void 0:b))},[]),be=(0,o.useCallback)(()=>{if(F&&R.trim()){const b=Math.random().toString(36).substring(2,15);f({id:b,name:R.trim(),isExpanded:!0,isFavorite:!1}),d(s,b),S.success("Query moved to new folder successfully")}else F||(d(s,ae),S.success("Query moved to selected folder successfully"));T(!1),_(!1),A(""),I(void 0)},[F,R,ae,s,f,d]);return(0,e.jsxs)("li",{className:"relative",children:[n?(0,e.jsxs)(Ie,{children:[(0,e.jsx)(Fe,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",onClick:fe,className:y("w-full flex gap-2 py-2 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",c?"text-zinc-100 bg-accent/10":"text-zinc-400",a?"px-4 pl-12":"px-4"),children:[c&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsx)("span",{className:"flex-1",children:t})]})}),(0,e.jsxs)(Re,{children:[(0,e.jsxs)(E,{onClick:Pe,children:[(0,e.jsx)(oe,{className:"size-4"}),"Rename query"]}),(0,e.jsxs)(E,{onClick:Le,children:[(0,e.jsx)(Je,{className:"size-4"}),"Duplicate query"]}),(0,e.jsxs)(E,{onClick:Me,children:[(0,e.jsx)(rs,{className:N?"size-4 fill-current":"size-4"}),N?"Remove from favorites":"Add to favorites"]}),(0,e.jsx)(Ne,{}),(0,e.jsxs)(E,{onClick:Qe,children:[(0,e.jsx)(Ue,{className:"size-4"}),"Move to folder"]}),(0,e.jsx)(Ne,{}),(0,e.jsxs)(E,{onClick:Ae,children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete query"]})]})]}):(0,e.jsxs)("button",{type:"button",onClick:fe,className:y("w-full flex gap-2 py-2 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",c?"text-zinc-100 bg-accent/10":"text-zinc-400",a?"px-4 pl-12":"px-4"),children:[c&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsx)("span",{className:"flex-1",children:t})]}),(0,e.jsx)(q,{open:w,onOpenChange:x,children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Rename Query"}),(0,e.jsx)(P,{children:"Enter a new name for this query."})]}),(0,e.jsx)(H,{value:v,onChange:b=>O(b.target.value),placeholder:"Query name",onKeyDown:b=>{b.key==="Enter"&&pe()},autoFocus:!0}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{x(!1),O("")},children:"Cancel"}),(0,e.jsx)(j,{onClick:pe,disabled:!v.trim(),children:"Rename"})]})]})}),(0,e.jsx)(q,{open:K,onOpenChange:b=>{T(b),b||(_(!1),A(""),I(void 0))},children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Move to Folder"}),(0,e.jsx)(P,{children:"Select a folder to move this query to."})]}),(0,e.jsx)("div",{className:"space-y-4",children:F?(0,e.jsx)(H,{value:R,onChange:b=>A(b.target.value),placeholder:"Folder name",onKeyDown:b=>{b.key==="Enter"&&R.trim()&&be(),b.key==="Escape"&&(_(!1),A(""))},autoFocus:!0}):(0,e.jsxs)(ue,{value:ae??"__none__",onValueChange:He,children:[(0,e.jsx)(xe,{className:"w-full",children:(0,e.jsx)(he,{placeholder:"Select a folder"})}),(0,e.jsxs)(me,{children:[(0,e.jsx)(L,{value:"__none__",children:"No folder"}),C.map(b=>(0,e.jsx)(L,{value:b.id,children:b.name},b.id)),(0,e.jsx)(L,{value:"__create_new__",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Te,{className:"size-4"}),"Create a new folder"]})})]})]})}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{T(!1),_(!1),A(""),I(void 0)},children:"Cancel"}),(0,e.jsx)(j,{onClick:be,disabled:F&&!R.trim(),children:F?"Create & Move":"Move"})]})]})})]})},st=()=>{const[s]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),{folders:t,queries:a,getFavoriteQueries:n,getQueriesByFolder:r,toggleFolder:l}=te(),[u,i]=(0,o.useState)(!0),[m,h]=(0,o.useState)(!0),d=a.filter(c=>!c.isFavorite).length,C=n(),f=C.length,g=a.filter(c=>!c.folderId&&!c.isFavorite);if(s){const c=a.filter(p=>p.name.toLowerCase().includes(s.toLowerCase()));return c.length===0?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"No queries found matching"}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:c.map(p=>(0,e.jsx)(W,{id:p.id,tableName:p.name},p.id))})}return(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,e.jsx)(ne,{name:"Favorites",isExpanded:u,onToggle:()=>i(!u),count:f}),u&&C.map(c=>(0,e.jsx)(W,{id:c.id,tableName:c.name},c.id)),(0,e.jsx)(vs,{className:"bg-zinc-800"}),(0,e.jsx)(ne,{name:"Queries",isExpanded:m,onToggle:()=>h(!m),count:d}),m&&(0,e.jsxs)(e.Fragment,{children:[t.map(c=>{const p=r(c.id),N=p.length;return(0,e.jsxs)("div",{children:[(0,e.jsx)(ne,{folderId:c.id,name:c.name,isExpanded:c.isExpanded,onToggle:()=>l(c.id),count:N,showContextMenu:!0}),c.isExpanded&&p.map(w=>(0,e.jsx)(W,{id:w.id,tableName:w.name,isNested:!0,showContextMenu:!0},w.id))]},c.id)}),g.map(c=>(0,e.jsx)(W,{id:c.id,tableName:c.name,showContextMenu:!0},c.id))]})]})},tt=()=>{const{addQuery:s,addFolder:t}=te(),a=G(),n=(0,o.useRef)(null),[r,l]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),u=h=>{l(h.target.value)},i=()=>{a({to:"/runner/$queryId",params:{queryId:s()}})},m=()=>{t({id:Math.random().toString(36).substring(2,15),name:"New Folder",isExpanded:!0,isFavorite:!1})};return(0,e.jsxs)("div",{className:"p-3 space-y-2 border-b border-zinc-800",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)(j,{className:"flex-1 justify-start h-8",onClick:i,children:[(0,e.jsx)(ce,{className:"size-4"}),"Add Query"]}),(0,e.jsxs)(j,{className:"flex-1 justify-start h-8",onClick:m,children:[(0,e.jsx)(Te,{className:"size-4"}),"Add Folder"]})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(Ee,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,e.jsx)(H,{ref:n,placeholder:"Search queries",value:r??"",onChange:u,className:"rounded-sm h-8 pl-8 pr-8"}),(0,e.jsx)(U,{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs",children:"/"})]})]})},at=()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(tt,{}),(0,e.jsx)(st,{})]}),nt=()=>{const{selectedDatabase:s}=z(),{mutateAsync:t,isPending:a}=le({mutationFn:async r=>{const l=(await de.get(`/tables/${r}/schema`,{params:{db:s??""}})).data.data.schema;return await navigator.clipboard.writeText(l),l}});return{copyTableSchema:async r=>S.promise(t(r),{loading:"Copying table schema...",success:"Table schema copied to clipboard",error:l=>l.message||"Failed to copy table schema"}),isCopyingSchema:a}},rt=()=>{const s=Be(),{selectedDatabase:t}=z(),{mutateAsync:a,isPending:n,reset:r}=le({mutationFn:async({tableName:i,cascade:m=!1})=>(await de.delete(`/tables/${i}`,{params:{db:t??"",cascade:m?"true":"false"}})).data.data,onSuccess:async()=>{await s.invalidateQueries({queryKey:[D.CACHE_KEYS.TABLES_LIST]})}});return{deleteTable:async i=>a({tableName:i,cascade:!1}),forceDeleteTable:async i=>a({tableName:i,cascade:!0}),isDeletingTable:n,resetDeleteResult:r}},lt=()=>{const{selectedDatabase:s}=z(),{mutateAsync:t,isPending:a}=le({mutationFn:async({tableName:r,format:l})=>{const u=await de.get(`/tables/${r}/export`,{params:{db:s??"",format:l},responseType:"blob"}),i=u.headers["content-disposition"]?.match(/filename="(.+)"/)?.[1]||`${r}_export.${l}`,m=new Blob([u.data],{type:u.headers["content-type"]}),h=window.URL.createObjectURL(m),d=document.createElement("a");d.href=h,d.download=i,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(h)}});return{exportFile:async({tableName:r,format:l})=>S.promise(t({tableName:r,format:l}),{loading:"Exporting file...",success:"File exported successfully",error:u=>u.message||"Failed to export file"}),isExportingFile:a}},ot=({tableName:s})=>{const t=G(),{copyTableSchema:a,isCopyingSchema:n}=nt(),{exportFile:r,isExportingFile:l}=lt(),{deleteTable:u,forceDeleteTable:i,isDeletingTable:m}=rt(),[h,d]=(0,o.useState)(!1),[C,f]=(0,o.useState)(!1),[g,c]=(0,o.useState)([]),p=()=>{navigator.clipboard.writeText(s),S.success("Table name copied to clipboard")},N=async()=>{const v=await u(s);v.fkViolation?(c(v.relatedRecords),d(!1),f(!0)):(S.success(`Deleted table "${s}" with ${v.deletedCount} rows`),d(!1),t({to:"/"}))},w=async()=>{const v=await i(s);S.success(`Force deleted table "${s}" with ${v.deletedCount} rows`),f(!1),t({to:"/"})},x=()=>{f(!1),c([])};return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(Ss,{children:[(0,e.jsx)(js,{children:(0,e.jsx)(j,{variant:"ghost",size:"icon-sm",children:(0,e.jsx)(Ve,{})})}),(0,e.jsx)(fs,{className:"w-56",align:"start",children:(0,e.jsxs)(Ns,{children:[(0,e.jsxs)(k,{onClick:p,children:[(0,e.jsx)(We,{className:"size-4"}),"Copy name"]}),(0,e.jsxs)(k,{onClick:()=>a(s),disabled:n,children:[(0,e.jsx)(Ye,{className:"size-4"}),"Copy table schema"]}),(0,e.jsx)(ge,{}),(0,e.jsxs)(k,{onClick:()=>t({to:"/schema/$table",params:{table:s}}),children:[(0,e.jsx)(oe,{className:"size-4"}),"Edit table"]}),(0,e.jsxs)(gs,{children:[(0,e.jsxs)(bs,{children:[(0,e.jsx)(ss,{className:"size-4"}),"Export data"]}),(0,e.jsxs)(ps,{children:[(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"csv"}),disabled:l,children:"Export as CSV"}),(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"json"}),disabled:l,children:"Export as JSON"}),(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"xlsx"}),disabled:l,children:"Export as Excel"})]})]}),(0,e.jsx)(ge,{}),(0,e.jsxs)(k,{variant:"destructive",onClick:()=>d(!0),children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete table"]})]})})]}),(0,e.jsx)(it,{isOpen:h,onOpenChange:d,tableName:s,onDelete:N,isDeleting:m}),(0,e.jsx)(ct,{isOpen:C,onOpenChange:f,tableName:s,relatedRecords:g,onForceDelete:w,onCancel:x,isDeleting:m})]})},it=({isOpen:s,onOpenChange:t,tableName:a,onDelete:n,isDeleting:r})=>(0,e.jsx)(q,{open:s,onOpenChange:t,children:(0,e.jsxs)(Q,{className:"max-w-md",children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Delete Table"}),(0,e.jsxs)(P,{children:["Are you sure you want to delete the table"," ",(0,e.jsxs)("span",{className:"font-semibold text-foreground",children:['"',a,'"']}),"? This action cannot be undone and all data will be permanently lost."]})]}),(0,e.jsxs)($,{className:"gap-2",children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>t(!1),disabled:r,children:"Cancel"}),(0,e.jsx)(j,{variant:"destructive",onClick:n,disabled:r,children:r?"Deleting...":"Delete Table"})]})]})}),ct=({isOpen:s,onOpenChange:t,tableName:a,relatedRecords:n,onForceDelete:r,onCancel:l,isDeleting:u})=>(0,e.jsx)(q,{open:s,onOpenChange:t,children:(0,e.jsxs)(Q,{className:"max-w-xl! max-h-[calc(100vh-1rem)]!",children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Cannot Delete - Foreign Key Constraint"}),(0,e.jsxs)(P,{children:["The table ",(0,e.jsxs)("span",{className:"font-semibold text-foreground",children:['"',a,'"']})," ","cannot be deleted because it is referenced by records in other tables. You can either cancel the operation or force delete, which will also delete all related records."]})]}),(0,e.jsx)("div",{className:"space-y-4 max-h-64 overflow-y-auto",children:n.map((i,m)=>(0,e.jsxs)("div",{className:"border border-zinc-700 rounded-md p-3",children:[(0,e.jsxs)("div",{className:"font-medium text-sm mb-2",children:["Table: ",(0,e.jsx)("span",{className:"text-primary",children:i.tableName}),(0,e.jsxs)("span",{className:"text-muted-foreground ml-2",children:["(",i.records.length," record",i.records.length!==1?"s":"",")"]})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mb-2",children:["References column: ",i.columnName]}),(0,e.jsx)("div",{className:"bg-zinc-900 rounded p-2 text-xs overflow-x-auto",children:(0,e.jsxs)("pre",{className:"whitespace-pre-wrap",children:[JSON.stringify(i.records.slice(0,5),null,2),i.records.length>5&&(0,e.jsxs)("div",{className:"text-muted-foreground mt-2",children:["... and ",i.records.length-5," more"]})]})})]},`${i.tableName}-${i.columnName}-${m}`))}),(0,e.jsxs)($,{className:"gap-2",children:[(0,e.jsx)(j,{variant:"outline",onClick:l,disabled:u,children:"Cancel"}),(0,e.jsx)(j,{variant:"destructive",onClick:r,disabled:u,children:u?"Deleting...":"Force Delete All"})]})]})}),dt=({tableName:s,rowCount:t,schemaName:a})=>{const n=we({strict:!1}),{pathname:r}=re(),l=n.table===s;return(0,e.jsx)("li",{className:"relative",children:(0,e.jsxs)(De,{to:r.startsWith("/schema")?"/schema/$table":"/table/$table",params:{table:s},className:y("w-full flex gap-0.5 px-4 py-1.5 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",l?"text-white bg-zinc-800/50":"text-zinc-400"),children:[l&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsxs)("span",{className:"flex-1 truncate",children:[a&&a!=="public"?`${a}.`:"",s]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 h-5",children:[l&&(0,e.jsx)(ot,{tableName:s}),(0,e.jsx)(U,{children:t})]})]})})},ut=()=>{const[s]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),[t,a]=M(D.ACTIVE_SCHEMA,{defaultValue:"all"}),{dbType:n}=z(),{tablesList:r=[],isLoadingTablesList:l,errorTablesList:u}=_e(),i=(0,o.useMemo)(()=>Array.from(new Set(r.map(d=>d.schemaName).filter(d=>!!d))).sort(),[r]),m=n==="pg"&&i.length>1,h=r?.filter(d=>{const C=t==="all"||d.schemaName===t,f=d.tableName.toLowerCase().includes(s.toLowerCase());return C&&f});return(0,o.useEffect)(()=>{!m||t==="all"||i.includes(t)||a("all")},[i,t,a,m]),l?(0,e.jsx)("div",{className:"flex-1 h-full overflow-y-auto pb-3 flex items-center justify-center",children:(0,e.jsx)(Cs,{size:"size-6"})}):u?(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:["Error: ",u.message]}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3",children:h&&h.length>0?(0,e.jsx)("ul",{children:h?.map(d=>(0,e.jsx)(dt,{schemaName:d.schemaName,tableName:d.tableName,rowCount:d.rowCount},d.schemaName?`${d.schemaName}.${d.tableName}`:d.tableName))}):s?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:"No tables found matching"}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:"No tables available"})})},mt=()=>{const s=(0,o.useRef)(null),[t,a]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),{openSheet:n}=ke(),{dbType:r}=z();return Ps("/",l=>{l.preventDefault(),s.current&&s.current.focus()},{preventDefault:!0}),(0,e.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[r!=="mongodb"&&(0,e.jsxs)(j,{className:"w-full justify-start h-8",onClick:()=>n("add-table"),children:[(0,e.jsx)(ce,{className:"size-4"}),"Add Table"]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(Ee,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,e.jsx)(H,{ref:s,placeholder:"Search tables",value:t??"",onChange:l=>a(l.target.value.trim()),className:"rounded-sm h-8 pl-8 pr-8"}),(0,e.jsx)(U,{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs",children:"/"})]})]})},ht=()=>{const[s,t]=M(D.ACTIVE_SCHEMA,{defaultValue:"all"}),{dbType:a}=z(),{tablesList:n=[]}=_e(),r=(0,o.useMemo)(()=>Array.from(new Set(n.map(l=>l.schemaName).filter(l=>!!l))).sort(),[n]);return a==="pg"&&r.length>1?(0,e.jsx)("div",{className:"px-3 pb-2 pt-3",children:(0,e.jsxs)(ue,{value:s,onValueChange:t,children:[(0,e.jsx)(xe,{className:"w-full justify-between",children:(0,e.jsx)(he,{placeholder:"Select schema"})}),(0,e.jsxs)(me,{children:[(0,e.jsx)(L,{value:"all",children:"All schemas"}),r.map(l=>(0,e.jsx)(L,{value:l,children:l},l))]})]})}):null},Se=()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(ht,{}),(0,e.jsx)(mt,{}),(0,e.jsx)(ks,{className:"flex-1 overflow-y-auto pb-3 block h-full w-full",children:(0,e.jsx)(ut,{})})]});function xt(){const{databases:s,isLoadingDatabases:t,refetchDatabases:a,isRefetchingDatabases:n}=Ts(),{connectionInfo:r,isLoadingConnectionInfo:l}=ws(),{selectedDatabase:u,setSelectedDatabase:i}=z(),m=G(),[h,d]=(0,o.useState)(!1),C=g=>{i(g),m({to:"/table",search:{}})},f=async()=>{await a(),S.success("Databases refreshed")};return(0,e.jsx)("div",{className:"mt-auto border-t bg-background",children:(0,e.jsxs)("div",{className:"p-4 space-y-2",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Xe,{className:"h-4 w-4 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm font-medium",children:"Database"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",size:"icon",className:"h-6 w-6 hover:bg-accent",onClick:f,disabled:t||n,children:(0,e.jsx)(ns,{className:y("h-3.5 w-3.5",(t||n)&&"animate-spin")})})}),(0,e.jsx)(Y,{children:"Refresh databases"})]})]}),(0,e.jsxs)(ue,{value:u||"",onValueChange:C,children:[(0,e.jsx)(xe,{className:"h-9 text-xs font-mono w-full",disabled:t||n,children:(0,e.jsx)(he,{placeholder:"Select database..."})}),(0,e.jsx)(me,{children:s?.map(g=>(0,e.jsx)(L,{value:g.name,className:"font-mono text-xs",children:g.name},g.name))})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(j,{variant:"ghost",className:"w-full hover:bg-accent flex items-center justify-between",onClick:()=>d(!h),disabled:l||n,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex items-center justify-center",children:(0,e.jsxs)("div",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-green-500"})]})}),(0,e.jsx)("span",{className:"text-xs font-medium text-green-600",children:"Connected"})]}),(0,e.jsx)(Ge,{className:y("size-3 text-muted-foreground transition-transform",h&&"rotate-180")})]}),h&&r&&(0,e.jsxs)("div",{className:"space-y-1.5 px-2 py-2 rounded-md bg-muted/30",children:[(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Host"}),(0,e.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[r.host,":",r.port]})]}),(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"User"}),(0,e.jsx)("span",{className:"text-xs font-mono text-foreground",children:r.user})]}),(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Databases"}),(0,e.jsx)("span",{className:"text-xs font-mono font-medium text-foreground",children:s?.length||0})]})]})]})]})})}var ft=()=>{const{sidebar:{isPinned:s},toggleSidebarPinned:t}=se();return(0,e.jsx)("div",{className:"flex items-center justify-between h-9 border-b border-zinc-800",children:(0,e.jsx)(j,{variant:"ghost",size:"lg",onClick:t,className:"size-9 flex items-center justify-center transition hover:bg-transparent! focus-visible:ring-0 focus-visible:ring-offset-0",title:s?"Unpin sidebar":"Pin sidebar",children:s?(0,e.jsx)(Ze,{className:"size-4"}):(0,e.jsx)(es,{className:"size-4"})})})},pt=({children:s})=>{const{sidebar:{width:t,isOpen:a,isPinned:n},setSidebarWidth:r,setSidebarOpen:l}=se(),u=(0,o.useRef)(!1),i=(0,o.useRef)(0),m=(0,o.useRef)(0),h=(0,o.useRef)(null),d=(0,o.useRef)(null),C=(0,o.useCallback)(x=>{u.current&&requestAnimationFrame(()=>{const v=x.clientX-i.current;r(m.current+v)})},[r]),f=(0,o.useCallback)(()=>{u.current=!1,document.body.style.cursor="",document.body.style.userSelect="";const x=document.getElementById("resize-overlay");x&&x.remove()},[]),g=(0,o.useCallback)(x=>{x.preventDefault(),u.current=!0,i.current=x.clientX,m.current=t,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const v=document.createElement("div");v.id="resize-overlay",v.style.cssText="position:fixed;inset:0;z-index:9999;cursor:col-resize;",document.body.appendChild(v)},[t]),c=(0,o.useCallback)(()=>{n||l(!0)},[n,l]),p=(0,o.useCallback)(()=>{n||l(!1)},[n,l]),N=(0,o.useCallback)(x=>{n||a||u.current||(x.clientX<=D.HOVER_ZONE?(h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{l(!0)},D.HOVER_DELAY)):x.clientX>D.HOVER_ZONE+50&&h.current&&clearTimeout(h.current))},[n,a,l]),w=x=>{n||l(x)};return(0,o.useEffect)(()=>(document.addEventListener("mousemove",C),document.addEventListener("mouseup",f),document.addEventListener("mousemove",N),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",f),document.removeEventListener("mousemove",N),h.current&&clearTimeout(h.current)}),[C,f,N]),(0,o.useEffect)(()=>{const x=d.current;if(x)return x.addEventListener("mouseenter",c),x.addEventListener("mouseleave",p),()=>{x.removeEventListener("mouseenter",c),x.removeEventListener("mouseleave",p)}},[c,p]),(0,e.jsxs)(_s,{open:a,onOpenChange:w,modal:!1,children:[(0,e.jsx)(ys,{className:"sr-only",children:"Open Sidebar"}),(0,e.jsx)(Es,{ref:d,side:"left",showCloseButton:!1,isPinned:n,className:y("bg-black border-r border-zinc-800 p-0","transition-transform duration-300 ease-out"),style:{width:`${t}px`},onOpenAutoFocus:x=>x.preventDefault(),children:(0,e.jsxs)("div",{className:"relative h-full flex flex-col",children:[s,(0,e.jsx)("div",{role:"button",tabIndex:0,onMouseDown:g,className:y("absolute top-0 right-0 w-2 h-full cursor-col-resize z-50","hover:bg-blue-500/50 transition-colors group"),title:"Drag to resize",children:(0,e.jsx)("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 w-2 h-12 bg-blue-500 opacity-0 group-hover:opacity-100 transition-opacity rounded-full"})})]})})]})},bt=()=>{const{pathname:s}=re(),t=s.split("/")[1],a=(0,o.useMemo)(()=>{switch(console.log(t),t){case"":case"table":case"schema":return(0,e.jsx)(Se,{});case"runner":return(0,e.jsx)(at,{});default:return(0,e.jsx)(Se,{})}},[t]);return(0,e.jsxs)(pt,{children:[(0,e.jsx)(ft,{}),a,(0,e.jsx)(xt,{})]})};function kt(){const{sidebar:{isPinned:s,width:t}}=se();return(0,e.jsxs)("div",{className:"bg-zinc-950 w-dvw flex h-dvh max-h-dvh overflow-hidden relative",children:[(0,e.jsx)(bt,{}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col h-full overflow-hidden ",style:{marginLeft:s?`${t}px`:"0"},children:[(0,e.jsx)(et,{}),(0,e.jsx)($e,{})]})]})}export{kt as component};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chat-sidebar-D2GaNd69.js","assets/rolldown-runtime-Bnw7wDfq.js","assets/index-BtQYs6UF.js","assets/monaco-editor-B6TxHuqP.js","assets/monaco-editor-DVSAlpqy.css","assets/radix-ui-C0u6gLux.js","assets/icons-BywMJ5og.js","assets/tanstack-DyfKDo5s.js","assets/bundle-mjs-DkNbwow-.js","assets/react-dom-JJlWtX5O.js","assets/index-Dv6o03bL.css","assets/chunk-BO2N2NFS-BWASkQ7r.js","assets/scroll-area-BnT9xy-y.js","assets/tooltip-B3DXDN3Y.js","assets/use-rate-limit-BenJo7Lk.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as qe}from"./rolldown-runtime-Bnw7wDfq.js";import{_ as we,c as re,d as $e,g as G,h as De,v as le,x as Be}from"./tanstack-DyfKDo5s.js";import{A as Ve,D as Te,E as Ue,G as Ge,J as Ke,L as We,M as Xe,O as Ye,P as Je,U as je,_ as oe,d as Ee,g as Ze,h as es,i as ie,j as ss,l as ts,m as ce,nt as as,p as ns,s as rs,v as ls}from"./icons-BywMJ5og.js";import{Ot as os,d as is,f as cs,l as ds,m as us,p as ms,u as hs}from"./radix-ui-C0u6gLux.js";import{It as xs}from"./monaco-editor-B6TxHuqP.js";import{$ as P,A as fs,B as _e,Ct as ps,Dt as y,F as bs,I as js,L as gs,M as k,N as ge,P as vs,Q,S as ys,St as Cs,Tt as j,X as H,Z as q,bt as Ns,c as Ss,ct as de,et as $,ft as ue,gt as me,ht as he,i as se,it as D,j as ws,k as Ds,kt as S,mt as L,nt as B,o as Ts,ot as Es,pt as xe,s as _s,st as z,tt as V,vt as ke}from"./index-BtQYs6UF.js";import{t as ks}from"./scroll-area-BnT9xy-y.js";import{i as X,n as Y,t as J}from"./tooltip-B3DXDN3Y.js";import{t as zs}from"./use-rate-limit-BenJo7Lk.js";import{n as M}from"./dist-ZzQZZhtF.js";import{a as Os,c as Is,i as Fs,l as Rs,n as U,o as As,r as Ls,s as Ms,t as Ps,u as Qs}from"./dist-v6aWpqmu.js";import{t as te}from"./queries.store-BtuppsNj.js";var ve={AUTHOR:"Hüsam 🥑 <devhsmq@gmail.com>",AUTHOR_NAME:"Hüsam",AUTHOR_AVATAR:"/avocado.png",AUTHOR_USERNAME:"husamql3",AUTHOR_GITHUB_LINK:"https://github.com/husamql3",SITE_DESCRIPTION:"The modern pgAdmin alternative that works with every database.",SITE_KEYWORDS:["pgadmin alternative","database client","database gui","database browser","sql editor","postgresql client","mysql client","table editor","ai sql","er diagram"],SITE_TITLE:"DB Studio",SITE_NAME:"dbstudio.sh",SITE_URL:"https://dbstudio.sh",SITE_X_LINK:"https://x.com/dbstudio_sh",SITE_GITHUB_LINK:"https://github.com/husamql3/db-studio",SITE_GITHUB_NEW_ISSUE_LINK:"https://github.com/husamql3/db-studio/issues/new/choose",SITE_DOCS_LINK:"https://dbstudio.sh/docs",SITE_CHANGELOG_LINK:"https://dbstudio.sh/changelog",SITE_ROADMAP_LINK:"https://dbstudio.sh/roadmap",SITE_IMAGE:"https://dbstudio.sh/og-image.png",SITE_IMAGE_WIDTH:"1200",SITE_IMAGE_HEIGHT:"630",SITE_IMAGE_ALT:"dbstudio.sh – Modern database management studio",SITE_COLOR:"#1447e6"},o=qe(as(),1),ze={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},ye=o.createContext&&o.createContext(ze),Hs=["attr","size","title"];function qs(s,t){if(s==null)return{};var a,n,r=$s(s,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(s);for(n=0;n<l.length;n++)a=l[n],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(s,a)&&(r[a]=s[a])}return r}function $s(s,t){if(s==null)return{};var a={};for(var n in s)if({}.hasOwnProperty.call(s,n)){if(t.indexOf(n)!==-1)continue;a[n]=s[n]}return a}function Z(){return Z=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var n in a)({}).hasOwnProperty.call(a,n)&&(s[n]=a[n])}return s},Z.apply(null,arguments)}function Ce(s,t){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);t&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(s,r).enumerable})),a.push.apply(a,n)}return a}function ee(s){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Ce(Object(a),!0).forEach(function(n){Bs(s,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):Ce(Object(a)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(a,n))})}return s}function Bs(s,t,a){return(t=Vs(t))in s?Object.defineProperty(s,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[t]=a,s}function Vs(s){var t=Us(s,"string");return typeof t=="symbol"?t:t+""}function Us(s,t){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var n=a.call(s,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function Oe(s){return s&&s.map((t,a)=>o.createElement(t.tag,ee({key:a},t.attr),Oe(t.child)))}function Gs(s){return t=>o.createElement(Ks,Z({attr:ee({},s.attr)},t),Oe(s.child))}function Ks(s){var t=a=>{var{attr:n,size:r,title:l}=s,u=qs(s,Hs),i=r||a.size||"1em",m;return a.className&&(m=a.className),s.className&&(m=(m?m+" ":"")+s.className),o.createElement("svg",Z({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,n,u,{className:m,style:ee(ee({color:s.color||a.color},a.style),s.style),height:i,width:i,xmlns:"http://www.w3.org/2000/svg"}),l&&o.createElement("title",null,l),s.children)};return ye!==void 0?o.createElement(ye.Consumer,null,a=>t(a)):t(ze)}function Ws(s){return Gs({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"},child:[]},{tag:"path",attr:{d:"M9 18c-4.51 2-5-2-7-2"},child:[]}]})(s)}var e=os(),Xs=(0,o.lazy)(()=>xs(()=>import("./chat-sidebar-D2GaNd69.js").then(s=>({default:s.ChatSidebar})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]))),Ys=()=>{const{isSheetOpen:s,openSheet:t}=ke(),{rateLimit:a,isLoadingRateLimit:n}=zs(),{remaining:r=0,limit:l=0}=a??{remaining:0,limit:0},i=(m=>m===0?"bg-red-500":m<=5?"bg-yellow-500":"bg-emerald-500")(r);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsxs)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12 relative",onClick:()=>t("ai-assistant"),children:[(0,e.jsx)(ts,{className:"size-5"}),(0,e.jsx)("span",{className:y("absolute top-2 right-2 h-2 w-2 rounded-full ring-2 ring-background",i)})]})}),(0,e.jsx)(Y,{side:"bottom",className:"text-xs",children:!n&&(r>0?(0,e.jsxs)("p",{children:[r,"/",l," messages remaining"]}):(0,e.jsx)("p",{children:"AI Assistant"}))})]}),s("ai-assistant")&&(0,e.jsx)(o.Suspense,{fallback:null,children:(0,e.jsx)(Xs,{})})]})},Js=()=>{const{pathname:s}=re(),t=s.split("/")[1]||"table";return(0,e.jsx)("div",{className:"flex h-full items-center",children:Es.map(a=>(0,e.jsx)(De,{to:`/${a}`,className:"h-full flex items-center",children:(0,e.jsx)(j,{variant:"ghost",className:y("flex-1 px-4 border-l-0 border-y-0 border-r border-zinc-800 h-full rounded-none",t===a?"bg-zinc-900 text-white":"text-zinc-400"),children:a})},a))})},Zs=()=>{const{sidebar:{isOpen:s,isPinned:t},setSidebarOpen:a,setSidebarPinned:n}=se(),r=()=>{a(!s),n(!t)};return(0,e.jsx)(j,{variant:"ghost",onClick:r,className:"h-full aspect-square border-l-0 border-y-0 border-r border-zinc-800 rounded-none",children:(0,e.jsx)(ls,{className:"size-5"})})},et=()=>(0,e.jsxs)("div",{className:"border-b border-zinc-800 w-full flex items-center justify-between bg-black h-12",children:[(0,e.jsxs)("div",{className:"flex items-center h-full",children:[(0,e.jsx)(Zs,{}),(0,e.jsx)(Js,{})]}),(0,e.jsxs)("div",{className:"flex items-center h-full",children:[(0,e.jsx)(Ys,{}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12",asChild:!0,children:(0,e.jsx)("a",{href:ve.SITE_GITHUB_NEW_ISSUE_LINK,target:"_blank",rel:"noopener noreferrer","aria-label":"Create a new GitHub issue",children:(0,e.jsx)(Ke,{className:"size-5"})})})}),(0,e.jsx)(Y,{children:(0,e.jsx)("p",{children:"Report a bug"})})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",className:"border-r-0 border-y-0 border-l border-zinc-800 rounded-none h-full w-12",asChild:!0,children:(0,e.jsx)("a",{href:ve.SITE_GITHUB_LINK,target:"_blank",rel:"noopener noreferrer","aria-label":"View the db-studio GitHub repository",children:(0,e.jsx)(Ws,{className:"size-5"})})})}),(0,e.jsx)(Y,{children:(0,e.jsx)("p",{children:"View on GitHub"})})]})]})]});function Ie({...s}){return(0,e.jsx)(cs,{"data-slot":"context-menu",...s})}function Fe({className:s,...t}){return(0,e.jsx)(us,{"data-slot":"context-menu-trigger",className:y("select-none",s),...t})}function Re({className:s,...t}){return(0,e.jsx)(is,{children:(0,e.jsx)(ds,{"data-slot":"context-menu-content",className:y("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-lg p-1 shadow-md ring-1 duration-100 z-50 max-h-(--radix-context-menu-content-available-height) origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto",s),...t})})}function E({className:s,inset:t,variant:a="default",...n}){return(0,e.jsx)(hs,{"data-slot":"context-menu-item","data-inset":t,"data-variant":a,className:y("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground min-h-7 gap-2 rounded-md px-2 py-1 text-xs/relaxed [&_svg:not([class*='size-'])]:size-3.5 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",s),...n})}function Ne({className:s,...t}){return(0,e.jsx)(ms,{"data-slot":"context-menu-separator",className:y("bg-border/50 -mx-1 my-1 h-px",s),...t})}var ne=({folderId:s,isExpanded:t,onToggle:a,count:n,name:r,showContextMenu:l=!1})=>{const u=G(),{deleteFolder:i,getQueriesByFolder:m,addQuery:h,updateFolder:d}=te(),[C,f]=(0,o.useState)(!1),[g,c]=(0,o.useState)(""),[p,N]=(0,o.useState)(!1),w=(0,o.useCallback)(()=>{if(s){if(m(s).length>0){N(!0);return}i(s)}},[i,s,m]),x=(0,o.useCallback)(()=>{s&&(i(s),N(!1))},[i,s]),v=(0,o.useCallback)(()=>{u({to:"/runner/$queryId",params:{queryId:h(void 0,s)}})},[h,s,u]),O=(0,o.useCallback)(()=>{c(r),f(!0)},[r]),K=(0,o.useCallback)(()=>{s&&g.trim()&&(d(s,{name:g.trim()}),f(!1),c(""))},[s,g,d]);return(0,e.jsxs)(e.Fragment,{children:[l?(0,e.jsxs)(Ie,{children:[(0,e.jsx)(Fe,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",onClick:a,className:y("w-full flex gap-2 px-4 py-2 text-sm transition-colors text-left","hover:bg-zinc-800/50 hover:text-zinc-100 focus:outline-none focus:bg-zinc-800/50","text-zinc-400 items-center"),children:[(0,e.jsx)(je,{className:y("size-4 transition-transform duration-200",t?"rotate-90":"")}),(0,e.jsx)("span",{className:"flex-1",children:r}),(0,e.jsx)(U,{children:n})]})}),(0,e.jsxs)(Re,{children:[(0,e.jsxs)(E,{onClick:v,children:[(0,e.jsx)(ce,{className:"size-4"}),"Add a new query"]}),(0,e.jsxs)(E,{onClick:O,children:[(0,e.jsx)(oe,{className:"size-4"}),"Rename folder"]}),(0,e.jsxs)(E,{onClick:w,children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete folder"]})]})]}):(0,e.jsxs)("button",{type:"button",onClick:a,className:y("w-full flex gap-2 px-4 py-2 text-sm transition-colors text-left","hover:bg-zinc-800/50 hover:text-zinc-100 focus:outline-none focus:bg-zinc-800/50","text-zinc-400 items-center"),children:[(0,e.jsx)(je,{className:y("size-4 transition-transform duration-200",t?"rotate-90":"")}),(0,e.jsx)("span",{className:"flex-1",children:r}),(0,e.jsx)(U,{children:n})]}),(0,e.jsx)(q,{open:C,onOpenChange:f,children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Rename Folder"}),(0,e.jsx)(P,{children:"Enter a new name for this folder."})]}),(0,e.jsx)(H,{value:g,onChange:T=>c(T.target.value),placeholder:"Folder name",onKeyDown:T=>{T.key==="Enter"&&K()},autoFocus:!0}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{f(!1),c("")},children:"Cancel"}),(0,e.jsx)(j,{onClick:K,disabled:!g.trim(),children:"Rename"})]})]})}),(0,e.jsx)(Ls,{open:p,onOpenChange:N,children:(0,e.jsxs)(As,{children:[(0,e.jsxs)(Rs,{children:[(0,e.jsx)(Qs,{children:"Delete Folder"}),(0,e.jsxs)(Ms,{children:["This folder contains ",n," ",n===1?"query":"queries",". Deleting this folder will also delete all queries inside it. This action cannot be undone."]})]}),(0,e.jsxs)(Is,{children:[(0,e.jsx)(Os,{children:"Cancel"}),(0,e.jsx)(Fs,{onClick:x,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Folder"})]})]})})]})},W=({id:s,tableName:t,isNested:a=!1,showContextMenu:n=!0})=>{const r=G(),{deleteQuery:l,addQuery:u,getQuery:i,toggleFavorite:m,updateQuery:h,moveQuery:d,folders:C,addFolder:f}=te(),{queryId:g}=we({strict:!1}),c=g===s,p=i(s),N=p?.isFavorite??!1,[w,x]=(0,o.useState)(!1),[v,O]=(0,o.useState)(""),[K,T]=(0,o.useState)(!1),[ae,I]=(0,o.useState)(void 0),[F,_]=(0,o.useState)(!1),[R,A]=(0,o.useState)(""),fe=(0,o.useCallback)(()=>{r({to:"/runner/$queryId",params:{queryId:s}})},[r,s]),Ae=(0,o.useCallback)(()=>{l(s),g===s&&r({to:"/runner"}),S.success("Query deleted successfully")},[l,s,r,g]),Le=(0,o.useCallback)(()=>{r({to:"/runner/$queryId",params:{queryId:u(`${i(s)?.name} (Copy)`)}}),S.success("Query duplicated successfully")},[u,i,r,s]),Me=(0,o.useCallback)(()=>{m(s),S.success("Query favorited successfully")},[m,s]),Pe=(0,o.useCallback)(()=>{O(p?.name??""),x(!0)},[p?.name]),pe=(0,o.useCallback)(()=>{v.trim()&&(h(s,{name:v.trim()}),x(!1),O(""),S.success("Query renamed successfully"))},[s,v,h]),Qe=(0,o.useCallback)(()=>{I(p?.folderId),_(!1),A(""),T(!0)},[p?.folderId]),He=(0,o.useCallback)(b=>{b==="__create_new__"?(_(!0),I(void 0)):(_(!1),I(b==="__none__"?void 0:b))},[]),be=(0,o.useCallback)(()=>{if(F&&R.trim()){const b=Math.random().toString(36).substring(2,15);f({id:b,name:R.trim(),isExpanded:!0,isFavorite:!1}),d(s,b),S.success("Query moved to new folder successfully")}else F||(d(s,ae),S.success("Query moved to selected folder successfully"));T(!1),_(!1),A(""),I(void 0)},[F,R,ae,s,f,d]);return(0,e.jsxs)("li",{className:"relative",children:[n?(0,e.jsxs)(Ie,{children:[(0,e.jsx)(Fe,{asChild:!0,children:(0,e.jsxs)("button",{type:"button",onClick:fe,className:y("w-full flex gap-2 py-2 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",c?"text-zinc-100 bg-accent/10":"text-zinc-400",a?"px-4 pl-12":"px-4"),children:[c&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsx)("span",{className:"flex-1",children:t})]})}),(0,e.jsxs)(Re,{children:[(0,e.jsxs)(E,{onClick:Pe,children:[(0,e.jsx)(oe,{className:"size-4"}),"Rename query"]}),(0,e.jsxs)(E,{onClick:Le,children:[(0,e.jsx)(Je,{className:"size-4"}),"Duplicate query"]}),(0,e.jsxs)(E,{onClick:Me,children:[(0,e.jsx)(rs,{className:N?"size-4 fill-current":"size-4"}),N?"Remove from favorites":"Add to favorites"]}),(0,e.jsx)(Ne,{}),(0,e.jsxs)(E,{onClick:Qe,children:[(0,e.jsx)(Ue,{className:"size-4"}),"Move to folder"]}),(0,e.jsx)(Ne,{}),(0,e.jsxs)(E,{onClick:Ae,children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete query"]})]})]}):(0,e.jsxs)("button",{type:"button",onClick:fe,className:y("w-full flex gap-2 py-2 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",c?"text-zinc-100 bg-accent/10":"text-zinc-400",a?"px-4 pl-12":"px-4"),children:[c&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsx)("span",{className:"flex-1",children:t})]}),(0,e.jsx)(q,{open:w,onOpenChange:x,children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Rename Query"}),(0,e.jsx)(P,{children:"Enter a new name for this query."})]}),(0,e.jsx)(H,{value:v,onChange:b=>O(b.target.value),placeholder:"Query name",onKeyDown:b=>{b.key==="Enter"&&pe()},autoFocus:!0}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{x(!1),O("")},children:"Cancel"}),(0,e.jsx)(j,{onClick:pe,disabled:!v.trim(),children:"Rename"})]})]})}),(0,e.jsx)(q,{open:K,onOpenChange:b=>{T(b),b||(_(!1),A(""),I(void 0))},children:(0,e.jsxs)(Q,{children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Move to Folder"}),(0,e.jsx)(P,{children:"Select a folder to move this query to."})]}),(0,e.jsx)("div",{className:"space-y-4",children:F?(0,e.jsx)(H,{value:R,onChange:b=>A(b.target.value),placeholder:"Folder name",onKeyDown:b=>{b.key==="Enter"&&R.trim()&&be(),b.key==="Escape"&&(_(!1),A(""))},autoFocus:!0}):(0,e.jsxs)(ue,{value:ae??"__none__",onValueChange:He,children:[(0,e.jsx)(he,{className:"w-full",children:(0,e.jsx)(me,{placeholder:"Select a folder"})}),(0,e.jsxs)(xe,{children:[(0,e.jsx)(L,{value:"__none__",children:"No folder"}),C.map(b=>(0,e.jsx)(L,{value:b.id,children:b.name},b.id)),(0,e.jsx)(L,{value:"__create_new__",children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Te,{className:"size-4"}),"Create a new folder"]})})]})]})}),(0,e.jsxs)($,{children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>{T(!1),_(!1),A(""),I(void 0)},children:"Cancel"}),(0,e.jsx)(j,{onClick:be,disabled:F&&!R.trim(),children:F?"Create & Move":"Move"})]})]})})]})},st=()=>{const[s]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),{folders:t,queries:a,getFavoriteQueries:n,getQueriesByFolder:r,toggleFolder:l}=te(),[u,i]=(0,o.useState)(!0),[m,h]=(0,o.useState)(!0),d=a.filter(c=>!c.isFavorite).length,C=n(),f=C.length,g=a.filter(c=>!c.folderId&&!c.isFavorite);if(s){const c=a.filter(p=>p.name.toLowerCase().includes(s.toLowerCase()));return c.length===0?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:"No queries found matching"}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto",children:c.map(p=>(0,e.jsx)(W,{id:p.id,tableName:p.name},p.id))})}return(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,e.jsx)(ne,{name:"Favorites",isExpanded:u,onToggle:()=>i(!u),count:f}),u&&C.map(c=>(0,e.jsx)(W,{id:c.id,tableName:c.name},c.id)),(0,e.jsx)(ys,{className:"bg-zinc-800"}),(0,e.jsx)(ne,{name:"Queries",isExpanded:m,onToggle:()=>h(!m),count:d}),m&&(0,e.jsxs)(e.Fragment,{children:[t.map(c=>{const p=r(c.id),N=p.length;return(0,e.jsxs)("div",{children:[(0,e.jsx)(ne,{folderId:c.id,name:c.name,isExpanded:c.isExpanded,onToggle:()=>l(c.id),count:N,showContextMenu:!0}),c.isExpanded&&p.map(w=>(0,e.jsx)(W,{id:w.id,tableName:w.name,isNested:!0,showContextMenu:!0},w.id))]},c.id)}),g.map(c=>(0,e.jsx)(W,{id:c.id,tableName:c.name,showContextMenu:!0},c.id))]})]})},tt=()=>{const{addQuery:s,addFolder:t}=te(),a=G(),n=(0,o.useRef)(null),[r,l]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),u=h=>{l(h.target.value)},i=()=>{a({to:"/runner/$queryId",params:{queryId:s()}})},m=()=>{t({id:Math.random().toString(36).substring(2,15),name:"New Folder",isExpanded:!0,isFavorite:!1})};return(0,e.jsxs)("div",{className:"p-3 space-y-2 border-b border-zinc-800",children:[(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsxs)(j,{className:"flex-1 justify-start h-8",onClick:i,children:[(0,e.jsx)(ce,{className:"size-4"}),"Add Query"]}),(0,e.jsxs)(j,{className:"flex-1 justify-start h-8",onClick:m,children:[(0,e.jsx)(Te,{className:"size-4"}),"Add Folder"]})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(Ee,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,e.jsx)(H,{ref:n,placeholder:"Search queries",value:r??"",onChange:u,className:"rounded-sm h-8 pl-8 pr-8"}),(0,e.jsx)(U,{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs",children:"/"})]})]})},at=()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(tt,{}),(0,e.jsx)(st,{})]}),nt=()=>{const{selectedDatabase:s}=z(),{mutateAsync:t,isPending:a}=le({mutationFn:async r=>{const l=(await de.get(`/tables/${r}/schema`,{params:{db:s??""}})).data.data.schema;return await navigator.clipboard.writeText(l),l}});return{copyTableSchema:async r=>S.promise(t(r),{loading:"Copying table schema...",success:"Table schema copied to clipboard",error:l=>l.message||"Failed to copy table schema"}),isCopyingSchema:a}},rt=()=>{const s=Be(),{selectedDatabase:t}=z(),{mutateAsync:a,isPending:n,reset:r}=le({mutationFn:async({tableName:i,cascade:m=!1})=>(await de.delete(`/tables/${i}`,{params:{db:t??"",cascade:m?"true":"false"}})).data.data,onSuccess:async()=>{await s.invalidateQueries({queryKey:[D.CACHE_KEYS.TABLES_LIST]})}});return{deleteTable:async i=>a({tableName:i,cascade:!1}),forceDeleteTable:async i=>a({tableName:i,cascade:!0}),isDeletingTable:n,resetDeleteResult:r}},lt=()=>{const{selectedDatabase:s}=z(),{mutateAsync:t,isPending:a}=le({mutationFn:async({tableName:r,format:l})=>{const u=await de.get(`/tables/${r}/export`,{params:{db:s??"",format:l},responseType:"blob"}),i=u.headers["content-disposition"]?.match(/filename="(.+)"/)?.[1]||`${r}_export.${l}`,m=new Blob([u.data],{type:u.headers["content-type"]}),h=window.URL.createObjectURL(m),d=document.createElement("a");d.href=h,d.download=i,document.body.appendChild(d),d.click(),document.body.removeChild(d),window.URL.revokeObjectURL(h)}});return{exportFile:async({tableName:r,format:l})=>S.promise(t({tableName:r,format:l}),{loading:"Exporting file...",success:"File exported successfully",error:u=>u.message||"Failed to export file"}),isExportingFile:a}},ot=({tableName:s})=>{const t=G(),{copyTableSchema:a,isCopyingSchema:n}=nt(),{exportFile:r,isExportingFile:l}=lt(),{deleteTable:u,forceDeleteTable:i,isDeletingTable:m}=rt(),[h,d]=(0,o.useState)(!1),[C,f]=(0,o.useState)(!1),[g,c]=(0,o.useState)([]),p=()=>{navigator.clipboard.writeText(s),S.success("Table name copied to clipboard")},N=async()=>{const v=await u(s);v.fkViolation?(c(v.relatedRecords),d(!1),f(!0)):(S.success(`Deleted table "${s}" with ${v.deletedCount} rows`),d(!1),t({to:"/"}))},w=async()=>{const v=await i(s);S.success(`Force deleted table "${s}" with ${v.deletedCount} rows`),f(!1),t({to:"/"})},x=()=>{f(!1),c([])};return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(Ds,{children:[(0,e.jsx)(gs,{children:(0,e.jsx)(j,{variant:"ghost",size:"icon-sm",children:(0,e.jsx)(Ve,{})})}),(0,e.jsx)(fs,{className:"w-56",align:"start",children:(0,e.jsxs)(ws,{children:[(0,e.jsxs)(k,{onClick:p,children:[(0,e.jsx)(We,{className:"size-4"}),"Copy name"]}),(0,e.jsxs)(k,{onClick:()=>a(s),disabled:n,children:[(0,e.jsx)(Ye,{className:"size-4"}),"Copy table schema"]}),(0,e.jsx)(ge,{}),(0,e.jsxs)(k,{onClick:()=>t({to:"/schema/$table",params:{table:s}}),children:[(0,e.jsx)(oe,{className:"size-4"}),"Edit table"]}),(0,e.jsxs)(vs,{children:[(0,e.jsxs)(js,{children:[(0,e.jsx)(ss,{className:"size-4"}),"Export data"]}),(0,e.jsxs)(bs,{children:[(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"csv"}),disabled:l,children:"Export as CSV"}),(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"json"}),disabled:l,children:"Export as JSON"}),(0,e.jsx)(k,{onClick:()=>r({tableName:s,format:"xlsx"}),disabled:l,children:"Export as Excel"})]})]}),(0,e.jsx)(ge,{}),(0,e.jsxs)(k,{variant:"destructive",onClick:()=>d(!0),children:[(0,e.jsx)(ie,{className:"size-4"}),"Delete table"]})]})})]}),(0,e.jsx)(it,{isOpen:h,onOpenChange:d,tableName:s,onDelete:N,isDeleting:m}),(0,e.jsx)(ct,{isOpen:C,onOpenChange:f,tableName:s,relatedRecords:g,onForceDelete:w,onCancel:x,isDeleting:m})]})},it=({isOpen:s,onOpenChange:t,tableName:a,onDelete:n,isDeleting:r})=>(0,e.jsx)(q,{open:s,onOpenChange:t,children:(0,e.jsxs)(Q,{className:"max-w-md",children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Delete Table"}),(0,e.jsxs)(P,{children:["Are you sure you want to delete the table"," ",(0,e.jsxs)("span",{className:"font-semibold text-foreground",children:['"',a,'"']}),"? This action cannot be undone and all data will be permanently lost."]})]}),(0,e.jsxs)($,{className:"gap-2",children:[(0,e.jsx)(j,{variant:"outline",onClick:()=>t(!1),disabled:r,children:"Cancel"}),(0,e.jsx)(j,{variant:"destructive",onClick:n,disabled:r,children:r?"Deleting...":"Delete Table"})]})]})}),ct=({isOpen:s,onOpenChange:t,tableName:a,relatedRecords:n,onForceDelete:r,onCancel:l,isDeleting:u})=>(0,e.jsx)(q,{open:s,onOpenChange:t,children:(0,e.jsxs)(Q,{className:"max-w-xl! max-h-[calc(100vh-1rem)]!",children:[(0,e.jsxs)(V,{children:[(0,e.jsx)(B,{children:"Cannot Delete - Foreign Key Constraint"}),(0,e.jsxs)(P,{children:["The table ",(0,e.jsxs)("span",{className:"font-semibold text-foreground",children:['"',a,'"']})," ","cannot be deleted because it is referenced by records in other tables. You can either cancel the operation or force delete, which will also delete all related records."]})]}),(0,e.jsx)("div",{className:"space-y-4 max-h-64 overflow-y-auto",children:n.map((i,m)=>(0,e.jsxs)("div",{className:"border border-zinc-700 rounded-md p-3",children:[(0,e.jsxs)("div",{className:"font-medium text-sm mb-2",children:["Table: ",(0,e.jsx)("span",{className:"text-primary",children:i.tableName}),(0,e.jsxs)("span",{className:"text-muted-foreground ml-2",children:["(",i.records.length," record",i.records.length!==1?"s":"",")"]})]}),(0,e.jsxs)("div",{className:"text-xs text-muted-foreground mb-2",children:["References column: ",i.columnName]}),(0,e.jsx)("div",{className:"bg-zinc-900 rounded p-2 text-xs overflow-x-auto",children:(0,e.jsxs)("pre",{className:"whitespace-pre-wrap",children:[JSON.stringify(i.records.slice(0,5),null,2),i.records.length>5&&(0,e.jsxs)("div",{className:"text-muted-foreground mt-2",children:["... and ",i.records.length-5," more"]})]})})]},`${i.tableName}-${i.columnName}-${m}`))}),(0,e.jsxs)($,{className:"gap-2",children:[(0,e.jsx)(j,{variant:"outline",onClick:l,disabled:u,children:"Cancel"}),(0,e.jsx)(j,{variant:"destructive",onClick:r,disabled:u,children:u?"Deleting...":"Force Delete All"})]})]})}),dt=({tableName:s,rowCount:t,schemaName:a})=>{const n=we({strict:!1}),{pathname:r}=re(),l=n.table===s;return(0,e.jsx)("li",{className:"relative",children:(0,e.jsxs)(De,{to:r.startsWith("/schema")?"/schema/$table":"/table/$table",params:{table:s},className:y("w-full flex gap-0.5 px-4 py-1.5 text-sm transition-colors text-left","hover:text-zinc-100 focus:outline-none focus:bg-accent/10 focus:text-zinc-100 justify-start items-center",l?"text-white bg-zinc-800/50":"text-zinc-400"),children:[l&&(0,e.jsx)("span",{className:"absolute left-0 top-0 bottom-0 w-1 bg-accent"}),(0,e.jsxs)("span",{className:"flex-1 truncate",children:[a&&a!=="public"?`${a}.`:"",s]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 h-5",children:[l&&(0,e.jsx)(ot,{tableName:s}),(0,e.jsx)(U,{children:t})]})]})})},ut=()=>{const[s]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),[t,a]=M(D.ACTIVE_SCHEMA,{defaultValue:"all"}),{dbType:n}=z(),{tablesList:r=[],isLoadingTablesList:l,errorTablesList:u}=_e(),i=(0,o.useMemo)(()=>Array.from(new Set(r.map(d=>d.schemaName).filter(d=>!!d))).sort(),[r]),m=n==="pg"&&i.length>1,h=r?.filter(d=>{const C=t==="all"||d.schemaName===t,f=d.tableName.toLowerCase().includes(s.toLowerCase());return C&&f});return(0,o.useEffect)(()=>{!m||t==="all"||i.includes(t)||a("all")},[i,t,a,m]),l?(0,e.jsx)("div",{className:"flex-1 h-full overflow-y-auto pb-3 flex items-center justify-center",children:(0,e.jsx)(Ss,{size:"size-6"})}):u?(0,e.jsxs)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:["Error: ",u.message]}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3",children:h&&h.length>0?(0,e.jsx)("ul",{children:h?.map(d=>(0,e.jsx)(dt,{schemaName:d.schemaName,tableName:d.tableName,rowCount:d.rowCount},d.schemaName?`${d.schemaName}.${d.tableName}`:d.tableName))}):s?(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:"No tables found matching"}):(0,e.jsx)("div",{className:"flex-1 overflow-y-auto pb-3 h-full flex items-center justify-center",children:"No tables available"})})},mt=()=>{const s=(0,o.useRef)(null),[t,a]=M(D.SIDEBAR_SEARCH,{defaultValue:""}),{openSheet:n}=ke(),{dbType:r}=z();return Ps("/",l=>{l.preventDefault(),s.current&&s.current.focus()},{preventDefault:!0}),(0,e.jsxs)("div",{className:"px-3 pb-3 pt-2 space-y-2",children:[r!=="mongodb"&&(0,e.jsxs)(j,{className:"w-full justify-start h-8",onClick:()=>n("add-table"),children:[(0,e.jsx)(ce,{className:"size-4"}),"Add Table"]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(Ee,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),(0,e.jsx)(H,{ref:s,placeholder:"Search tables",value:t??"",onChange:l=>a(l.target.value.trim()),className:"rounded-sm h-8 pl-8 pr-8"}),(0,e.jsx)(U,{className:"absolute right-2 top-1/2 -translate-y-1/2 text-xs",children:"/"})]})]})},ht=()=>{const[s,t]=M(D.ACTIVE_SCHEMA,{defaultValue:"all"}),{dbType:a}=z(),{tablesList:n=[]}=_e(),r=(0,o.useMemo)(()=>Array.from(new Set(n.map(l=>l.schemaName).filter(l=>!!l))).sort(),[n]);return a==="pg"&&r.length>1?(0,e.jsx)("div",{className:"px-3 pt-3",children:(0,e.jsxs)(ue,{value:s,onValueChange:t,children:[(0,e.jsx)(he,{className:"w-full justify-between h-8",children:(0,e.jsx)(me,{placeholder:"Select schema"})}),(0,e.jsxs)(xe,{children:[(0,e.jsx)(L,{value:"all",children:"All schemas"}),r.map(l=>(0,e.jsx)(L,{value:l,children:l},l))]})]})}):null},Se=()=>(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(ht,{}),(0,e.jsx)(mt,{}),(0,e.jsx)(ks,{className:"flex-1 overflow-y-auto pb-3 block h-full w-full",children:(0,e.jsx)(ut,{})})]});function xt(){const{databases:s,isLoadingDatabases:t,refetchDatabases:a,isRefetchingDatabases:n}=_s(),{connectionInfo:r,isLoadingConnectionInfo:l}=Ts(),{selectedDatabase:u,setSelectedDatabase:i}=z(),m=G(),[h,d]=(0,o.useState)(!1),C=g=>{i(g),m({to:"/table",search:{}})},f=async()=>{await a(),S.success("Databases refreshed")};return(0,e.jsx)("div",{className:"mt-auto border-t bg-background",children:(0,e.jsxs)("div",{className:"p-4 space-y-2",children:[(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(Xe,{className:"h-4 w-4 text-muted-foreground"}),(0,e.jsx)("span",{className:"text-sm font-medium",children:"Database"})]}),(0,e.jsxs)(J,{children:[(0,e.jsx)(X,{asChild:!0,children:(0,e.jsx)(j,{variant:"ghost",size:"icon",className:"h-6 w-6 hover:bg-accent",onClick:f,disabled:t||n,children:(0,e.jsx)(ns,{className:y("h-3.5 w-3.5",(t||n)&&"animate-spin")})})}),(0,e.jsx)(Y,{children:"Refresh databases"})]})]}),(0,e.jsxs)(ue,{value:u||"",onValueChange:C,children:[(0,e.jsx)(he,{className:"h-9 text-xs font-mono w-full",disabled:t||n,children:(0,e.jsx)(me,{placeholder:"Select database..."})}),(0,e.jsx)(xe,{children:s?.map(g=>(0,e.jsx)(L,{value:g.name,className:"font-mono text-xs",children:g.name},g.name))})]})]}),(0,e.jsxs)("div",{className:"space-y-2",children:[(0,e.jsxs)(j,{variant:"ghost",className:"w-full hover:bg-accent flex items-center justify-between",onClick:()=>d(!h),disabled:l||n,children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"flex items-center justify-center",children:(0,e.jsxs)("div",{className:"relative flex h-2 w-2",children:[(0,e.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),(0,e.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-green-500"})]})}),(0,e.jsx)("span",{className:"text-xs font-medium text-green-600",children:"Connected"})]}),(0,e.jsx)(Ge,{className:y("size-3 text-muted-foreground transition-transform",h&&"rotate-180")})]}),h&&r&&(0,e.jsxs)("div",{className:"space-y-1.5 px-2 py-2 rounded-md bg-muted/30",children:[(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Host"}),(0,e.jsxs)("span",{className:"text-xs font-mono text-foreground",children:[r.host,":",r.port]})]}),(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"User"}),(0,e.jsx)("span",{className:"text-xs font-mono text-foreground",children:r.user})]}),(0,e.jsxs)("div",{className:"flex justify-between items-center",children:[(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"Databases"}),(0,e.jsx)("span",{className:"text-xs font-mono font-medium text-foreground",children:s?.length||0})]})]})]})]})})}var ft=()=>{const{sidebar:{isPinned:s},toggleSidebarPinned:t}=se();return(0,e.jsx)("div",{className:"flex items-center justify-between h-9 border-b border-zinc-800",children:(0,e.jsx)(j,{variant:"ghost",size:"lg",onClick:t,className:"size-9 flex items-center justify-center transition hover:bg-transparent! focus-visible:ring-0 focus-visible:ring-offset-0",title:s?"Unpin sidebar":"Pin sidebar",children:s?(0,e.jsx)(Ze,{className:"size-4"}):(0,e.jsx)(es,{className:"size-4"})})})},pt=({children:s})=>{const{sidebar:{width:t,isOpen:a,isPinned:n},setSidebarWidth:r,setSidebarOpen:l}=se(),u=(0,o.useRef)(!1),i=(0,o.useRef)(0),m=(0,o.useRef)(0),h=(0,o.useRef)(null),d=(0,o.useRef)(null),C=(0,o.useCallback)(x=>{u.current&&requestAnimationFrame(()=>{const v=x.clientX-i.current;r(m.current+v)})},[r]),f=(0,o.useCallback)(()=>{u.current=!1,document.body.style.cursor="",document.body.style.userSelect="";const x=document.getElementById("resize-overlay");x&&x.remove()},[]),g=(0,o.useCallback)(x=>{x.preventDefault(),u.current=!0,i.current=x.clientX,m.current=t,document.body.style.cursor="col-resize",document.body.style.userSelect="none";const v=document.createElement("div");v.id="resize-overlay",v.style.cssText="position:fixed;inset:0;z-index:9999;cursor:col-resize;",document.body.appendChild(v)},[t]),c=(0,o.useCallback)(()=>{n||l(!0)},[n,l]),p=(0,o.useCallback)(()=>{n||l(!1)},[n,l]),N=(0,o.useCallback)(x=>{n||a||u.current||(x.clientX<=D.HOVER_ZONE?(h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{l(!0)},D.HOVER_DELAY)):x.clientX>D.HOVER_ZONE+50&&h.current&&clearTimeout(h.current))},[n,a,l]),w=x=>{n||l(x)};return(0,o.useEffect)(()=>(document.addEventListener("mousemove",C),document.addEventListener("mouseup",f),document.addEventListener("mousemove",N),()=>{document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",f),document.removeEventListener("mousemove",N),h.current&&clearTimeout(h.current)}),[C,f,N]),(0,o.useEffect)(()=>{const x=d.current;if(x)return x.addEventListener("mouseenter",c),x.addEventListener("mouseleave",p),()=>{x.removeEventListener("mouseenter",c),x.removeEventListener("mouseleave",p)}},[c,p]),(0,e.jsxs)(Ns,{open:a,onOpenChange:w,modal:!1,children:[(0,e.jsx)(ps,{className:"sr-only",children:"Open Sidebar"}),(0,e.jsx)(Cs,{ref:d,side:"left",showCloseButton:!1,isPinned:n,className:y("bg-black border-r border-zinc-800 p-0","transition-transform duration-300 ease-out"),style:{width:`${t}px`},onOpenAutoFocus:x=>x.preventDefault(),children:(0,e.jsxs)("div",{className:"relative h-full flex flex-col",children:[s,(0,e.jsx)("div",{role:"button",tabIndex:0,onMouseDown:g,className:y("absolute top-0 right-0 w-2 h-full cursor-col-resize z-50","hover:bg-blue-500/50 transition-colors group"),title:"Drag to resize",children:(0,e.jsx)("div",{className:"absolute right-0 top-1/2 -translate-y-1/2 w-2 h-12 bg-blue-500 opacity-0 group-hover:opacity-100 transition-opacity rounded-full"})})]})})]})},bt=()=>{const{pathname:s}=re(),t=s.split("/")[1],a=(0,o.useMemo)(()=>{switch(console.log(t),t){case"":case"table":case"schema":return(0,e.jsx)(Se,{});case"runner":return(0,e.jsx)(at,{});default:return(0,e.jsx)(Se,{})}},[t]);return(0,e.jsxs)(pt,{children:[(0,e.jsx)(ft,{}),a,(0,e.jsx)(xt,{})]})};function kt(){const{sidebar:{isPinned:s,width:t}}=se();return(0,e.jsxs)("div",{className:"bg-zinc-950 w-dvw flex h-dvh max-h-dvh overflow-hidden relative",children:[(0,e.jsx)(bt,{}),(0,e.jsxs)("div",{className:"flex-1 flex flex-col h-full overflow-hidden ",style:{marginLeft:s?`${t}px`:"0"},children:[(0,e.jsx)(et,{}),(0,e.jsx)($e,{})]})]})}export{kt as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ot as t}from"./radix-ui-C0u6gLux.js";import{t as o}from"./index-
|
|
1
|
+
import{Ot as t}from"./radix-ui-C0u6gLux.js";import{t as o}from"./index-BtQYs6UF.js";import{t as e}from"./runner-tab-BQH-lTnK.js";var m=t();function a(){const{queryId:r}=o.useParams();return(0,m.jsx)(e,{queryId:r})}export{a as component};
|