planche 0.7.13 → 0.7.14
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/app/assets/{AboutDialog-CxhMAbHE.js → AboutDialog-C2slR8bc.js} +1 -1
- package/app/assets/ConnectDialog-C8dt0P44.js +1 -0
- package/app/assets/{CopyDatabaseDialog-BwviLOYR.js → CopyDatabaseDialog-koQ5voA2.js} +1 -1
- package/app/assets/{CopyTableDialog-y2yVCEoe.js → CopyTableDialog-xXGEdqR9.js} +1 -1
- package/app/assets/{CreateDatabaseDialog-v63m43WC.js → CreateDatabaseDialog-DbPAPaHA.js} +1 -1
- package/app/assets/{DataDiffDialog-BQvHEwN1.js → DataDiffDialog-BdmXW-yR.js} +1 -1
- package/app/assets/{DownloadToCSVDialog-DGQnI5eb.js → DownloadToCSVDialog-DUbNM9Aj.js} +1 -1
- package/app/assets/{EditSchemaDialog-DhC0D6ws.js → EditSchemaDialog-B5iWTTUl.js} +1 -1
- package/app/assets/{FindReplaceDialog-CluDq2uv.js → FindReplaceDialog-C-w-ut2O.js} +1 -1
- package/app/assets/{FlushDialog-DgeG-OGF.js → FlushDialog-EHw9oFc3.js} +1 -1
- package/app/assets/{LinkColumnDialog-DBbb55b5.js → LinkColumnDialog-CNRoaG10.js} +1 -1
- package/app/assets/{LocalHistoryDialog-BZcsP3oj.js → LocalHistoryDialog-C0tH4J4m.js} +1 -1
- package/app/assets/{ProcessListDialog-DpH-Mybn.js → ProcessListDialog-CI60dW_R.js} +1 -1
- package/app/assets/{QuickCommandPalette-CjZVdpv1.js → QuickCommandPalette-gFz_jGQW.js} +1 -1
- package/app/assets/{RowFormDialog-Cb8MAzWF.js → RowFormDialog-JCW7a_UW.js} +1 -1
- package/app/assets/{SafetySettingsDialog-fO9X1PFB.js → SafetySettingsDialog-DGiLgyln.js} +1 -1
- package/app/assets/{SchemaDiffDialog-DdRHijgZ.js → SchemaDiffDialog-M9KKdtQR.js} +1 -1
- package/app/assets/{SchemaToHTMLDialog-HbVvnUOc.js → SchemaToHTMLDialog-BysAUGf0.js} +1 -1
- package/app/assets/{StatusDialog-B2pVC65w.js → StatusDialog-CsIIrMcJ.js} +1 -1
- package/app/assets/{TermsDialog-B8Ehf7Ck.js → TermsDialog-BzlyiBiw.js} +1 -1
- package/app/assets/{UserAddDialog-CzmcUU7I.js → UserAddDialog-R6QSi55s.js} +1 -1
- package/app/assets/{UserManagerDialog-YBOODqbg.js → UserManagerDialog-PgTmxk8V.js} +1 -1
- package/app/assets/{VariablesDialog-Dg5CDmWn.js → VariablesDialog-DSdBh3UG.js} +1 -1
- package/app/assets/app-storage-C_1RLCyI.js +1 -0
- package/app/assets/{connection-store-CAPTzFtT.js → connection-store-DjSajhjh.js} +1 -1
- package/app/assets/database-Dvj2X-0B.js +1 -0
- package/app/assets/{dbms-Bsjvyvsp.js → dbms-CSyCOszD.js} +1 -1
- package/app/assets/de-p3F2-Dhp.js +2 -0
- package/app/assets/{engine-DWYEiSZM.js → engine-CzHq4UCB.js} +1 -1
- package/app/assets/fr-BghB2Ohx.js +2 -0
- package/app/assets/{i18n-NLG6supM.js → i18n-gQOmt8le.js} +2 -2
- package/app/assets/ja-O-EyR07G.js +2 -0
- package/app/assets/ko-5jmwV68n.js +2 -0
- package/app/assets/main-ot9WNZX1.js +940 -0
- package/app/assets/pro-usage-BnI7zYsZ.js +1 -0
- package/app/assets/{query-execution-BZE0rVpK.js → query-execution-C2muZJbT.js} +3 -3
- package/app/assets/{query-store-CRp9AQS5.js → query-store-yK1eqNW-.js} +1 -1
- package/app/assets/{schema-nodes-D3-cz2Xk.js → schema-nodes-2owuMIuw.js} +1 -1
- package/app/assets/{select-DAm5iaPc.js → select-DlF-eYgr.js} +1 -1
- package/app/assets/{settings-store-CYHWBgNo.js → settings-store-CSRx4hwh.js} +1 -1
- package/app/assets/{table-copy-93YWKupe.js → table-copy-B1tGampL.js} +1 -1
- package/app/assets/use-engine-CwOU9o8-.js +1 -0
- package/app/assets/zh-BIU7z3hl.js +2 -0
- package/app/index.html +18 -16
- package/app/landing.css +13 -6
- package/dist/index.js +525 -22
- package/package.json +9 -4
- package/app/assets/ConnectDialog-Dk5tee_2.js +0 -1
- package/app/assets/app-storage-B6v72zLH.js +0 -1
- package/app/assets/database-ezjCHdX9.js +0 -1
- package/app/assets/de-DP-iF2aJ.js +0 -2
- package/app/assets/fr-DFtpsn6X.js +0 -2
- package/app/assets/ja--An7okvc.js +0 -2
- package/app/assets/ko-C-OjtONK.js +0 -2
- package/app/assets/main-Cs_AF7Zo.js +0 -940
- package/app/assets/pro-usage-VlZJ74Cl.js +0 -1
- package/app/assets/use-engine-DSWrApw6.js +0 -1
- package/app/assets/zh-C4dUMxzb.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./ui-store-DfspmPOn.js";import{t}from"./main-
|
|
1
|
+
import{n as e}from"./ui-store-DfspmPOn.js";import{t}from"./main-ot9WNZX1.js";import{l as n,m as r,t as i}from"./button--s6nUzD8.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-CJoWJzRo.js";var d=n(),f=`https://planche.dev`,p=`/third-party-notices.txt`;function m(){let n=e(e=>e.activeDialog),m=e(e=>e.closeDialog),{t:h}=r();return(0,d.jsx)(u,{open:n===`about`,onOpenChange:e=>{e||m()},children:(0,d.jsxs)(s,{className:`sm:max-w-[440px]`,children:[(0,d.jsx)(a,{children:(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(t,{size:44,className:`shrink-0`}),(0,d.jsxs)(`div`,{className:`grid gap-1`,children:[(0,d.jsx)(c,{children:h(`about.title`)}),(0,d.jsx)(l,{children:h(`about.tagline`)})]})]})}),(0,d.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,d.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.version`)}),(0,d.jsx)(`dd`,{children:`0.1.1`}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.website`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:f,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:f})}),(0,d.jsx)(`dt`,{className:`text-muted-foreground`,children:h(`about.licenses`)}),(0,d.jsx)(`dd`,{children:(0,d.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:h(`about.licensesLink`)})})]}),(0,d.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`© 2026 Juwon Jeong. `,h(`about.rights`)]}),(0,d.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:h(`about.disclaimer`)}),(0,d.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-muted-foreground`,children:[(0,d.jsx)(`p`,{className:`mb-1 font-medium text-amber-600 dark:text-amber-400`,children:h(`pro.noticeTitle`)}),(0,d.jsx)(`p`,{children:h(`pro.notice`)})]})]}),(0,d.jsx)(o,{children:(0,d.jsx)(i,{onClick:m,children:h(`settings.done`)})})]})})}export{m as AboutDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{$ as i,C as a,F as o,M as s,N as c,S as l,a as u,b as d,c as f,d as p,i as m,j as h,l as g,n as _,o as v,r as y,s as b,u as x,w as S,x as C,y as w}from"./main-ot9WNZX1.js";import{l as T,m as E,t as D}from"./button--s6nUzD8.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-DlF-eYgr.js";import{t as N}from"./connection-store-DjSajhjh.js";import{n as ee}from"./query-store-yK1eqNW-.js";import{A as P,M as F,S as te,T as ne,b as re,k as I,l as L,m as ie,n as ae,s as R,t as oe,w as se}from"./database-Dvj2X-0B.js";import{n as z,t as B}from"./dbms-CSyCOszD.js";import{a as ce,i as le,n as ue,o as de,t as fe}from"./dialog-CJoWJzRo.js";var V=r(e(),1),H=new Set([`postgres:`,`postgresql:`]);function U(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!H.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var W=T(),G=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],K={enabled:!1,host:``,port:22,user:``,auth:`key`};function q({label:e,htmlFor:t,children:n}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,W.jsx)(g,{htmlFor:t,children:e}),n]})}function pe({value:e,onChange:t}){let{t:n}=E();function r(n,r){t({...e,[n]:r})}let i=e.dbms===`sqlite`,a=e.transport??`browser`,l=i&&a===`browser`,u=P.has(e.dbms),d=e.dbms===`d1`,f=e.dbms===`do`,m=B.find(t=>t.id===e.dbms)?.capabilities,h=e.ssh??K,[g,_]=(0,V.useState)(``),y=g.trim()===``?`empty`:U(g)?`applied`:`invalid`,S=e.dbms===`supabase`&&e.port===6543;function C(n){_(n);let r=U(n);r&&t({...e,host:r.host??e.host,port:r.port??B.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function w(n){t({...e,ssh:{...h,...n}})}async function T(e){e&&w({privateKey:await e.text(),privateKeyName:e.name})}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,W.jsx)(q,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,W.jsx)(x,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.dataSource`),children:(0,W.jsxs)(M,{value:e.dbms,onValueChange:n=>{let r=B.find(e=>e.id===n);if(!r)return;let i=r.id,a=P.has(i)||i===`d1`||i===`do`;_(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||u||d||f?b(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!u&&!d&&!f?e.database:v(i)??e.database})},children:[(0,W.jsx)(k,{id:`conn-dbms`,className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsx)(A,{children:B.map(e=>(0,W.jsx)(j,{value:e.id,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(p,{dbms:e.id}),e.label]})},e.id))})]})}),u&&(0,W.jsx)(q,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(x,{id:`conn-uri`,type:`password`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:g,onChange:e=>C(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${y===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(y===`invalid`?`connection.form.connectionStringInvalid`:y===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),i&&(0,W.jsxs)(q,{label:n(`connection.form.openVia`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:a===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:a===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(a===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),l?(0,W.jsx)(q,{label:n(`connection.form.databaseFile`),children:(0,W.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,W.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{R(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,W.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,W.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!l&&(0,W.jsx)(q,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,W.jsx)(x,{id:`conn-authToken`,type:`password`,placeholder:n(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>r(`authToken`,e.target.value.trim())})}),l?null:f?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,W.jsx)(x,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,W.jsx)(x,{id:`conn-d1-account`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>r(`accountId`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:(0,W.jsx)(x,{id:`conn-d1-database`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>r(`databaseId`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(x,{id:`conn-pass`,type:`password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,W.jsx)(x,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>r(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,W.jsx)(x,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>r(`host`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,W.jsx)(x,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||B.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),S&&(0,W.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:n(`connection.form.supabasePoolerWarning`)}),(F(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,W.jsx)(q,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,W.jsx)(x,{id:`conn-database`,placeholder:v(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,W.jsx)(x,{id:`conn-user`,placeholder:b(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(x,{id:`conn-pass`,type:`password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),u&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!u&&e.dbms!==`oracle`&&(0,W.jsx)(q,{label:n(`connection.form.tls`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>r(`ssl`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsEnable`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>r(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsVerify`)]})]})}),!u&&(0,W.jsx)(q,{label:n(`connection.form.charset`),children:(0,W.jsxs)(M,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsx)(A,{children:G.map(e=>(0,W.jsx)(j,{value:e,children:e},e))})]})})]}),!i&&!u&&!d&&!f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[n(`connection.form.ssh`),(0,W.jsx)(o,{className:`ml-2`})]}),(0,W.jsx)(q,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:h.enabled,onChange:e=>w({enabled:e.target.checked}),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),h.enabled&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(x,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:h.host,onChange:e=>w({host:e.target.value.trim()})}),(0,W.jsx)(x,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:h.port,onChange:e=>w({port:Number(e.target.value)||22})})]})}),(0,W.jsx)(q,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,W.jsx)(x,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:h.user,onChange:e=>w({user:e.target.value.trim()})})}),(0,W.jsx)(q,{label:n(`connection.form.sshAuth`),children:(0,W.jsxs)(M,{value:h.auth,onValueChange:e=>w({auth:e}),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsxs)(A,{children:[(0,W.jsx)(j,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,W.jsx)(j,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,W.jsx)(j,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),h.auth===`password`&&(0,W.jsx)(q,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,W.jsx)(x,{id:`conn-ssh-pass`,type:`password`,value:h.password??``,onChange:e=>w({password:e.target.value})})}),h.auth===`key`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{T(e.target.files?.[0]),e.target.value=``}}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:h.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:h.privateKeyName,children:h.privateKey?h.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,W.jsx)(q,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,W.jsx)(x,{id:`conn-ssh-passphrase`,type:`password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:h.passphrase??``,onChange:e=>w({passphrase:e.target.value})})})]}),h.auth===`agent`&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,W.jsx)(q,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>r(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,W.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,W.jsx)(q,{label:n(`connection.form.environment`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[s.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,W.jsx)(`button`,{type:`button`,title:c(t.id),"aria-label":c(t.id),"aria-pressed":n,onClick:()=>r(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${n?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,W.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,W.jsx)(q,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>r(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),m?.transactions!==!1&&(0,W.jsx)(q,{label:n(`connection.form.transactions`),children:(0,W.jsxs)(M,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsxs)(A,{children:[(0,W.jsx)(j,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,W.jsx)(j,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}function J(){let{t:e}=E(),{activeDialog:r,closeDialog:o,showMessage:s}=t(),[c,g]=(0,V.useState)(!1),{savedConnections:v,addSavedConnection:b,updateSavedConnection:x,deleteSavedConnection:T,openConnection:O}=N(),k=n(`connect`)?.profileId,[A,j]=(0,V.useState)(()=>k??null),[M,P]=(0,V.useState)(()=>{let e=k?v.find(e=>e.id===k):void 0;return e?{...e}:null}),F=r===`connect`,[R,B]=(0,V.useState)(null),[H,U]=(0,V.useState)(null),G=f(e=>e.url),K=f(e=>e.token);(0,V.useEffect)(()=>{if(!F)return;let e=!1;return(async()=>{try{let t=await te();if(e||t.state!==`online`||!t.gateway){e||B(null);return}let n=await se();e||(B({name:n.gateway,profiles:n.profiles}),U(null))}catch(t){e||U(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[F,G,K]);function q(n){let r=v.find(e=>e.gatewayProfile===n.name);if(r){Y(r);return}let i=y(n);b(i),Y(i),t.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:n.name}))}function J(e){e||(o(),j(null),P(null))}function Y(e){j(e.id),P({...e})}function me(e){P(e),x(e.id,e)}function he(){let e=u();b(e),j(e.id),P(e)}function ge(){A&&(T(A),j(null),P(null))}let[_e,X]=(0,V.useState)(!1),ve=ee(e=>e.addQueryTab);function Z(t){let n=N.getState().activeConnections.some(e=>e.id===t.id);if(O(t),n){re.getState().removeTree(t.id),o(),j(null),P(null);return}ve(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),o(),j(null),P(null)}async function ye(n){let r=await oe(n.id,{interactive:!0});if(!r)return;let i={...n,file:r.fileName,serverConnectionId:r.connectionId};x(n.id,{file:r.fileName}),Z(i),N.getState().setFileDetached(n.id,r.fileDetached),r.restoredUnsaved?t.getState().setFooterMessage(e(r.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:r.fileName})):r.wal&&!r.walApplied?t.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:r.fileName})):r.walApplied&&t.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:r.fileName}))}async function Q(n,r){try{return await r(n)}catch(i){let a=ne(i);if(!a||!(`ssh`in n)||!n.ssh||!await t.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,a),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw i;return r({...n,ssh:{...n.ssh,acceptHostKey:a.fingerprint}})}}async function $(){if(M){X(!0);try{if(L(M)===`browser`){await ye(M);return}let t=await Q(I(M),e=>ae(e,M.authToken||void 0));t.success?Z({...M,serverConnectionId:t.connectionId}):s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{X(!1)}}}async function be(){if(M){if(L(M)===`browser`){s({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}g(!0);try{let t=await Q(I(M),e=>ie(e,M.authToken||void 0));t.success?s({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}}return(0,W.jsx)(fe,{open:F,onOpenChange:J,children:(0,W.jsxs)(ue,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,W.jsx)(ce,{children:(0,W.jsx)(de,{children:e(`connection.dialog.title`)})}),(0,W.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,W.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,W.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(R||H)&&(0,W.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,W.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),R?` — ${R.name}`:``]}),H&&(0,W.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:H})}),R?.profiles.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,W.jsx)(p,{dbms:_[t.driver],className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,W.jsx)(D,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>q(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,W.jsx)(h,{className:`h-full`,children:(0,W.jsxs)(w,{className:`table-fixed`,children:[(0,W.jsx)(a,{children:(0,W.jsxs)(S,{children:[(0,W.jsx)(l,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,W.jsx)(l,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,W.jsx)(l,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,W.jsx)(d,{children:v.length===0?(0,W.jsx)(S,{children:(0,W.jsx)(C,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):v.map(t=>(0,W.jsxs)(S,{"data-state":A===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Y(t),onDoubleClick:()=>{Y(t),$()},children:[(0,W.jsx)(C,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,W.jsx)(C,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(L(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user}@${t.host}:${t.port}`}),(0,W.jsx)(C,{className:`truncate`,title:z(t.dbms).label,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(p,{dbms:t.dbms,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:z(t.dbms).label})]})})]},t.id))})]})})]}),(0,W.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,W.jsxs)(W.Fragment,{children:[L(M)!==`browser`&&(0,W.jsx)(`div`,{className:`p-4 pb-0`,children:(0,W.jsx)(m,{})}),M.gatewayProfile?(0,W.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,W.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,W.jsx)(p,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,W.jsx)(pe,{value:M,onChange:me})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,W.jsxs)(le,{className:`sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(D,{variant:`outline`,onClick:he,children:e(`connection.dialog.addNew`)}),(0,W.jsx)(D,{variant:`destructive`,onClick:ge,disabled:!A,children:e(`connection.dialog.delete`)})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(D,{variant:`outline`,onClick:be,disabled:!M||c,children:e(`connection.dialog.testConnection`)}),(0,W.jsx)(D,{onClick:$,disabled:!M||_e,children:e(`connection.dialog.connect`)}),(0,W.jsx)(D,{variant:`outline`,onClick:()=>J(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{J as ConnectDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{l as i,u as a}from"./main-
|
|
1
|
+
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{l as i,u as a}from"./main-ot9WNZX1.js";import{l as o,m as s,t as c}from"./button--s6nUzD8.js";import{a as l,i as u,n as d,o as f,t as p}from"./dialog-CJoWJzRo.js";var m=r(e(),1),h=o();function g(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=t(),g=n(`copy-database`),_=r===`copy-database`,v=g?.database??``,[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(`structure_data`);function C(e){e||(o(),b(``),S(`structure_data`))}function w(){o()}return(0,h.jsx)(p,{open:_,onOpenChange:C,children:(0,h.jsxs)(d,{className:`sm:max-w-[450px]`,children:[(0,h.jsx)(l,{children:(0,h.jsx)(f,{children:e(`database.copy.title`)})}),(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{children:e(`database.copy.source`)}),(0,h.jsx)(a,{value:v,disabled:!0})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,h.jsx)(a,{id:`target-db-name`,value:y,onChange:e=>b(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{children:e(`database.copy.options`)}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,h.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:x===`structure_data`,onChange:()=>S(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,h.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:x===`structure_only`,onChange:()=>S(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),(0,h.jsxs)(u,{children:[(0,h.jsx)(c,{variant:`outline`,onClick:()=>C(!1),children:e(`database.copy.cancel`)}),(0,h.jsx)(c,{onClick:w,disabled:!y.trim(),children:e(`database.copy.copy`)})]})]})})}export{g as CopyDatabaseDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{P as i,l as a,u as o}from"./main-
|
|
1
|
+
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{P as i,l as a,u as o}from"./main-ot9WNZX1.js";import{l as s,m as ee,t as c}from"./button--s6nUzD8.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-DlF-eYgr.js";import{t as te}from"./connection-store-DjSajhjh.js";import{r as ne}from"./database-Dvj2X-0B.js";import{t as re}from"./query-execution-C2muZJbT.js";import{n as m}from"./engine-CzHq4UCB.js";import{n as ie,t as h}from"./table-copy-B1tGampL.js";import{a as ae,i as g,n as oe,o as se,t as ce}from"./dialog-CJoWJzRo.js";var _=r(e(),1),v=s(),y=e=>e instanceof Error?e.message:String(e),b=e=>e.hostName||e.host||e.file||e.id,le=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function x(){let{t:e}=ee(),r=t(e=>e.activeDialog),s=t(e=>e.closeDialog),x=t(e=>e.showMessage),S=n(`copy-table`),C=te(e=>e.activeConnections),w=r===`copy-table`,T=S?.connectionId??``,E=String(S?.metadata?.database??``),D=S?.nodeText??``,O=C.find(e=>e.id===T),ue=C.filter(e=>e.serverConnectionId),[k,de]=(0,_.useState)(T),[A,j]=(0,_.useState)([]),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(D),[I,L]=(0,_.useState)(`structure_data`),[R,z]=(0,_.useState)(`abort`),[B,V]=(0,_.useState)(``),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),[K,q]=(0,_.useState)(null),[J,Y]=(0,_.useState)(!1),X=(0,_.useRef)(null),Z=C.find(e=>e.id===k),Q=Z?m(k):null,fe=!!O&&!!Z&&m(T).id===Q?.id;(0,_.useEffect)(()=>{if(!w||!Z?.serverConnectionId)return;let e=!1,t=m(k),n=ne(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=k===T,a=i||r.includes(E)?E:r[0]??``;N(a),F(e=>i&&a===E&&e===D?`${D}_copy`:e)}catch(t){e||q(y(t))}})(),()=>{e=!0}},[w,k]),(0,_.useEffect)(()=>{if(!w||!Z||!M||!P.trim()||!O)return;let e=!1;return(async()=>{U(null);try{let t=await h({connectionId:T,database:E,table:D},{connectionId:k,database:M,table:P.trim()});e||V(m(k).ddl.createTable(t))}catch(t){e||U(y(t))}})(),()=>{e=!0}},[w,k,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}s()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await ie({source:{connectionId:T,database:E,table:D},target:{connectionId:k,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);s(),await x({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof re||q(y(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,v.jsx)(ce,{open:w,onOpenChange:$,children:(0,v.jsxs)(oe,{className:`sm:max-w-[640px]`,children:[(0,v.jsx)(ae,{children:(0,v.jsx)(se,{children:e(`table.copy.title`)})}),(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.source`)}),(0,v.jsx)(o,{value:O?`${b(O)} / ${E} / ${D}`:``,disabled:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,v.jsxs)(p,{value:k,onValueChange:de,disabled:J,children:[(0,v.jsx)(u,{id:`copy-target-conn`,className:`w-full`,children:(0,v.jsx)(l,{})}),(0,v.jsx)(d,{children:ue.map(t=>(0,v.jsxs)(f,{value:t.id,children:[b(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,v.jsxs)(p,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,v.jsx)(u,{id:`copy-target-db`,className:`w-full`,children:(0,v.jsx)(l,{placeholder:e(`table.copy.loading`)})}),(0,v.jsx)(d,{children:A.map(e=>(0,v.jsx)(f,{value:e,children:e},e))})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,v.jsx)(o,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.what`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.ifExists`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,v.jsx)(`textarea`,{id:`copy-ddl`,className:le,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,v.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(i,{value:me??(W.phase===`done`?100:0)}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,v.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,v.jsxs)(g,{children:[(0,v.jsx)(c,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,v.jsx)(c,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{x as CopyTableDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{l as r,u as i}from"./main-
|
|
1
|
+
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{l as r,u as i}from"./main-ot9WNZX1.js";import{l as a,m as o,t as s}from"./button--s6nUzD8.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-DlF-eYgr.js";import{a as p,i as m,n as h,o as g,t as _}from"./dialog-CJoWJzRo.js";var v=n(e(),1),y=a(),b=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],x={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function S(){let{t:e}=o(),{activeDialog:n,closeDialog:a}=t(),S=n===`create-database`,[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(`utf8mb4`),[D,O]=(0,v.useState)(`utf8mb4_general_ci`);function k(e){e||(a(),w(``),E(`utf8mb4`),O(`utf8mb4_general_ci`))}function A(e){E(e);let t=x[e];O(t?.[0]??``)}function j(){a()}let M=x[T]??[];return(0,y.jsx)(_,{open:S,onOpenChange:k,children:(0,y.jsxs)(h,{className:`sm:max-w-[450px]`,children:[(0,y.jsx)(p,{children:(0,y.jsx)(g,{children:e(`database.create.title`)})}),(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,y.jsx)(i,{id:`db-name`,value:C,onChange:e=>w(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,y.jsxs)(f,{value:T,onValueChange:A,children:[(0,y.jsx)(l,{id:`db-charset`,className:`w-full`,children:(0,y.jsx)(c,{})}),(0,y.jsx)(u,{children:b.map(e=>(0,y.jsx)(d,{value:e,children:e},e))})]})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,y.jsxs)(f,{value:D,onValueChange:O,children:[(0,y.jsx)(l,{id:`db-collation`,className:`w-full`,children:(0,y.jsx)(c,{})}),(0,y.jsx)(u,{children:M.map(e=>(0,y.jsx)(d,{value:e,children:e},e))})]})]})]}),(0,y.jsxs)(m,{children:[(0,y.jsx)(s,{variant:`outline`,onClick:()=>k(!1),children:e(`database.create.cancel`)}),(0,y.jsx)(s,{onClick:j,disabled:!C.trim(),children:e(`database.create.create`)})]})]})})}export{S as CreateDatabaseDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,h as t,n,t as r,v as i}from"./ui-store-DfspmPOn.js";import{A as a,R as o,_ as s,g as c,l,v as u}from"./main-
|
|
1
|
+
import{c as e,h as t,n,t as r,v as i}from"./ui-store-DfspmPOn.js";import{A as a,R as o,_ as s,g as c,l,v as u}from"./main-ot9WNZX1.js";import{l as d,m as f,t as p}from"./button--s6nUzD8.js";import{a as m,i as h,n as g,r as _,t as v}from"./select-DlF-eYgr.js";import{t as y}from"./connection-store-DjSajhjh.js";import{r as b}from"./database-Dvj2X-0B.js";import{n as x}from"./engine-CzHq4UCB.js";import{t as ee}from"./pro-usage-BnI7zYsZ.js";import{a as te,i as ne,n as S,o as C,t as w}from"./dialog-CJoWJzRo.js";var T=i(t(),1),E=d(),re=e=>e instanceof Error?e.message:String(e),D=e=>e.hostName||e.host||e.file||e.id,O=5e4;function k({id:e,label:t,side:n,onChange:r,connections:i,disabled:a}){let{t:o}=f(),[s,c]=(0,T.useState)([]),[u,d]=(0,T.useState)([]),p=i.find(e=>e.id===n.connectionId);return(0,T.useEffect)(()=>{if(!p?.serverConnectionId)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listDatabases(b(p.serverConnectionId));if(e)return;c(t),t.includes(n.database)||r({connectionId:p.id,database:t[0]??``,table:``})}catch{e||c([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId]),(0,T.useEffect)(()=>{if(!p?.serverConnectionId||!n.database)return;let e=!1;return(async()=>{try{let t=await x(p.id).introspect.listTables(b(p.serverConnectionId),n.database);if(e)return;let i=t.map(e=>e.name);d(i),n.table&&!i.includes(n.table)&&r({...n,table:``})}catch{e||d([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId,n.database]),(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,E.jsx)(l,{className:`font-medium`,children:t}),(0,E.jsxs)(v,{value:n.connectionId,onValueChange:e=>r({connectionId:e,database:``,table:``}),disabled:a,children:[(0,E.jsx)(h,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.diff.pickConnection`)})}),(0,E.jsx)(g,{children:i.map(e=>(0,E.jsx)(_,{value:e.id,children:D(e)},e.id))})]}),(0,E.jsxs)(v,{value:n.database,onValueChange:e=>r({...n,database:e,table:``}),disabled:a||s.length===0,children:[(0,E.jsx)(h,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.diff.pickDatabase`)})}),(0,E.jsx)(g,{children:s.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{value:n.table,onValueChange:e=>r({...n,table:e}),disabled:a||u.length===0,children:[(0,E.jsx)(h,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.dataDiff.pickTable`)})}),(0,E.jsx)(g,{children:u.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]})]})}async function A(e,t){let n=await o({connectionId:e.connectionId,database:e.database,table:e.table,limit:O,onProgress:t}),r=[];for await(let e of n.pages)r.push(...e);return{rows:r,columns:n.fields.map(e=>e.name),capped:r.length>=O}}function j({diff:e,row:t,other:n,changed:r}){let{t:i}=f(),a=[...e.keyColumns,...e.compareColumns];return(0,E.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,E.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:i(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:a.map(e=>(0,E.jsxs)(`tr`,{className:r?.includes(e)?`text-amber-600 dark:text-amber-400`:``,children:[(0,E.jsx)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:e}),(0,E.jsx)(`td`,{className:`pr-2 align-top break-all`,children:s(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?s(n[e]):`—`})]},e))})]})}function M(){let{t}=f(),i=n(e=>e.activeDialog),o=n(e=>e.closeDialog),l=r(`data-diff`),d=y(e=>e.activeConnections),m=(0,T.useMemo)(()=>d.filter(e=>e.serverConnectionId),[d]),h=y(e=>e.activeConnectionId),g=i===`data-diff`,[_,v]=(0,T.useState)(()=>l&&m.some(e=>e.id===l.connectionId)?{connectionId:l.connectionId,database:l.database,table:l.table}:{connectionId:h&&m.some(e=>e.id===h)?h:m[0]?.id??``,database:``,table:``}),[D,M]=(0,T.useState)(()=>({connectionId:m.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[L,R]=(0,T.useState)(`changed`),[z,B]=(0,T.useState)(0),[V,oe]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)({source:null,target:null}),[K,q]=(0,T.useState)(null),se=e=>M(e.database&&!e.table&&_.table?{...e,table:_.table}:e),J=_.connectionId===D.connectionId&&_.database===D.database&&_.table===D.table,ce=!!_.table&&!!D.table&&!J,Y=D.connectionId?x(D.connectionId):null;async function X(){U(!0),q(null),I(null);try{let n=y.getState().activeConnections.find(e=>e.id===_.connectionId);if(!n?.serverConnectionId)throw Error(t(`services.query.notConnected`));let r=await x(_.connectionId).introspect.getPrimaryKeys(b(n.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(t(`database.dataDiff.noPrimaryKey`,{table:_.table}));G({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([A(_,e=>G(t=>({...t,source:e}))),A(D,e=>G(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(t(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=u(i.rows,a.rows,r,i.columns,a.columns);P(r),ae(i.capped||a.capped),I(o),R(o.changed.length>0?`changed`:o.added.length>0?`added`:`removed`),B(0),ee(`compare_data`),e(`data_diff`,{source_dbms:x(_.connectionId).id,target_dbms:Y?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){q(re(e))}finally{U(!1),G({source:null,target:null})}}let Z=e=>e?e.total===null?e.loaded.toLocaleString():`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:``,Q=(0,T.useMemo)(()=>F&&Y?c(F,Y,{database:D.database,table:D.table},{includeDeletes:V}):``,[F,Y,D.database,D.table,V]);function le(){Q&&(a(D.connectionId,Q,D.database,t(`database.dataDiff.tabTitle`,{table:D.table})),o())}let $=F?L===`added`?F.added:L===`removed`?F.removed:F.changed.map(e=>e.source):[],ue=!!F&&F.added.length+F.changed.length+F.removed.length>0,de=e=>N.map(t=>s(e[t])).join(`, `);return(0,E.jsx)(w,{open:g,onOpenChange:e=>{e||o()},children:(0,E.jsxs)(S,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(te,{children:(0,E.jsx)(C,{children:t(`database.dataDiff.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-3`,children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,E.jsx)(k,{id:`ddiff-source`,label:t(`database.diff.source`),side:_,onChange:v,connections:m,disabled:H}),(0,E.jsx)(k,{id:`ddiff-target`,label:t(`database.diff.target`),side:D,onChange:se,connections:m,disabled:H})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`database.dataDiff.hint`,{cap:O.toLocaleString()})}),J&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:t(`database.dataDiff.sameSide`)}),K&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K}),H&&(W.source||W.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`database.dataDiff.loading`,{source:Z(W.source),target:Z(W.target)})}),F&&(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:t(`database.dataDiff.summary`,{key:N.join(`, `),added:F.added.length,changed:F.changed.length,removed:F.removed.length,identical:F.identical})}),ie&&(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:t(`database.dataDiff.capped`,{cap:O.toLocaleString()})}),(F.sourceOnlyColumns.length>0||F.targetOnlyColumns.length>0)&&(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:t(`database.dataDiff.ignoredColumns`,{columns:[...F.sourceOnlyColumns,...F.targetOnlyColumns].join(`, `)})})]}),(0,E.jsx)(`div`,{className:`flex gap-1 text-xs`,children:[`added`,`changed`,`removed`].map(e=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{R(e),B(0)},className:`rounded border px-2 py-0.5 ${L===e?`bg-accent`:``}`,children:t(`database.dataDiff.${e}`,{count:e===`added`?F.added.length:e===`removed`?F.removed.length:F.changed.length})},e))}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] gap-3 h-[280px]`,children:[(0,E.jsxs)(`ul`,{className:`overflow-auto rounded-md border text-sm font-mono`,children:[$.slice(0,2e3).map((e,t)=>(0,E.jsx)(`li`,{className:`px-2 py-1 cursor-pointer ${z===t?`bg-accent`:``}`,onClick:()=>B(t),children:de(e)},t)),$.length===0&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:t(`database.dataDiff.none`)}),$.length>2e3&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:t(`database.dataDiff.more`,{count:$.length-2e3})})]}),(0,E.jsx)(`div`,{className:`overflow-auto rounded-md border p-2`,children:$[z]?L===`changed`?(0,E.jsx)(j,{diff:F,row:F.changed[z].source,other:F.changed[z].target,changed:F.changed[z].columns}):L===`removed`?(0,E.jsx)(j,{diff:F,row:{},other:$[z]}):(0,E.jsx)(j,{diff:F,row:$[z]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`database.diff.selectTable`)})})]}),(0,E.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>oe(e.target.checked)}),(0,E.jsx)(`span`,{className:V?`text-destructive`:``,children:t(`database.dataDiff.includeDeletes`)})]})]})]}),(0,E.jsxs)(ne,{children:[(0,E.jsx)(p,{variant:`outline`,onClick:o,children:t(`database.diff.close`)}),(0,E.jsx)(p,{variant:`secondary`,onClick:()=>{X()},disabled:!ce||H,children:t(H?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(p,{onClick:le,disabled:!ue,children:t(`database.diff.openScript`)})]})]})})}export{M as DataDiffDialog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{c as e,h as t,n,v as r}from"./ui-store-DfspmPOn.js";import{P as i,R as a,l as o,u as s}from"./main-
|
|
1
|
+
import{c as e,h as t,n,v as r}from"./ui-store-DfspmPOn.js";import{P as i,R as a,l as o,u as s}from"./main-ot9WNZX1.js";import{l as c,m as l,t as u}from"./button--s6nUzD8.js";import{a as d,i as f,n as p,r as m,t as h}from"./select-DlF-eYgr.js";import{t as g}from"./connection-store-DjSajhjh.js";import{n as _}from"./query-store-yK1eqNW-.js";import{r as v}from"./database-Dvj2X-0B.js";import{n as y}from"./query-execution-C2muZJbT.js";import{n as b}from"./engine-CzHq4UCB.js";import{a as x,i as S,n as C,o as w,t as T}from"./dialog-CJoWJzRo.js";import{t as E}from"./file-name-CnYBZPf9.js";var D=r(t(),1);function O(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
|
|
2
2
|
`)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}var k=(e,t)=>e.map(e=>O(e,t)).join(t)+`
|
|
3
3
|
`;async function A(e){let t=E(e);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:t,types:[{description:`CSV`,accept:{"text/csv":[`.csv`]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new j}let n=[``];return{write:async e=>{n.push(e)},finish:async()=>{let e=new Blob(n,{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(e),i=document.createElement(`a`);i.href=r,i.download=t,i.click(),URL.revokeObjectURL(r)},abort:async()=>{n.length=0}}}var j=class extends Error{constructor(){super(`CSV export cancelled`)}};async function M(t){let n=await A(`${t.table}.csv`),r=0;try{let i=await a({connectionId:t.connectionId,database:t.database,table:t.table,signal:t.signal,onProgress:t.onProgress}),o=i.fields.map(e=>e.name);t.includeHeaders&&await n.write(k(o,t.delimiter));for await(let e of i.pages)await n.write(e.map(e=>k(o.map(t=>e[t]),t.delimiter)).join(``)),r+=e.length;return await n.finish(),e(`export_csv`,{source:`table`,rows:r}),r}catch(e){throw await n.abort().catch(()=>void 0),e}}function N(t,n,r,i,a=`query_result.csv`){let o=t.map(e=>e.name),s=[``];i&&s.push(k(o,r));for(let e of n)s.push(k(o.map(t=>e[t]),r));let c=new Blob(s,{type:`text/csv;charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=E(a),u.click(),URL.revokeObjectURL(l),e(`export_csv`,{source:`result`,rows:n.length})}var P=c(),F=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function I(){let{t:e}=l(),{activeDialog:t,closeDialog:r}=n(),a=g(e=>e.activeConnectionId),c=_(),E=t===`export-csv`,[O,k]=(0,D.useState)(`query_result`),[A,I]=(0,D.useState)(``),[L,R]=(0,D.useState)([]),[z,B]=(0,D.useState)(``),[V,H]=(0,D.useState)(`,`),[U,W]=(0,D.useState)(!0),[G,K]=(0,D.useState)(!1),[q,J]=(0,D.useState)(null),[Y,X]=(0,D.useState)(null),Z=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(!E||!a)return;let e=g.getState().activeConnections.find(e=>e.id===a);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await b(a).introspect.listDatabases(v(e.serverConnectionId));if(t)return;R(n);let r=c.tabs[a]?.find(e=>e.id===c.activeTabId[a])?.database||``;B(e=>n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||R([])}})(),()=>{t=!0}},[E,a]);function Q(e){if(!e){if(G){Z.current?.abort();return}r(),k(`query_result`),I(``),H(`,`),W(!0)}}async function $(){if(!a)return;if(X(null),O===`query_result`){let e=c.activeTabId[a],t=(c.tabs[a]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;N(t.fields,t.rows,V,U),r();return}if(!A.trim()||!z)return;let t=new AbortController;Z.current=t,K(!0),J({loaded:0,total:null});try{let i=await M({connectionId:a,database:z,table:A.trim(),delimiter:V,includeHeaders:U,onProgress:J,signal:t.signal});n.getState().setFooterMessage(e(`database.csv.done`,{count:i,table:A.trim()})),r()}catch(e){!(e instanceof j)&&!(e instanceof y&&t.signal.aborted)&&X(e instanceof Error?e.message:String(e))}finally{K(!1),J(null),Z.current=null}}let ee=q?.total?Math.min(100,Math.round(q.loaded/q.total*100)):null;return(0,P.jsx)(T,{open:E,onOpenChange:Q,children:(0,P.jsxs)(C,{className:`sm:max-w-[450px]`,children:[(0,P.jsx)(x,{children:(0,P.jsx)(w,{children:e(`database.csv.title`)})}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(o,{children:e(`database.csv.target`)}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:O===`query_result`,onChange:()=>k(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:O===`table_data`,onChange:()=>k(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),O===`table_data`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(o,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,P.jsxs)(h,{value:z,onValueChange:B,disabled:L.length===0,children:[(0,P.jsx)(f,{id:`csv-database`,className:`w-full`,children:(0,P.jsx)(d,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,P.jsx)(p,{children:L.map(e=>(0,P.jsx)(m,{value:e,children:e},e))})]})]}),(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(o,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,P.jsx)(s,{id:`csv-table-name`,value:A,onChange:e=>I(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsx)(o,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,P.jsxs)(h,{value:V,onValueChange:H,children:[(0,P.jsx)(f,{id:`csv-delimiter`,className:`w-full`,children:(0,P.jsx)(d,{})}),(0,P.jsx)(p,{children:F.map(t=>(0,P.jsx)(m,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,P.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>W(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),q&&(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsx)(i,{value:ee??0}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:q.total===null?e(`database.csv.progressUnknown`,{loaded:q.loaded}):e(`database.csv.progress`,{loaded:q.loaded,total:q.total})})]}),Y&&(0,P.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:Y}),(0,P.jsxs)(S,{children:[(0,P.jsx)(u,{variant:`outline`,onClick:()=>Q(!1),children:e(G?`database.csv.stop`:`database.csv.cancel`)}),(0,P.jsx)(u,{onClick:$,disabled:G||O===`table_data`&&!A.trim(),children:e(G?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{I as DownloadToCSVDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{C as i,Ct as a,D as o,E as s,O as c,S as l,T as u,U as d,b as f,j as p,l as m,u as h,w as g,x as _,y as v}from"./main-Cs_AF7Zo.js";import{l as y,m as b,t as x}from"./button--s6nUzD8.js";import{a as S,i as C,n as w,r as T,t as E}from"./select-DAm5iaPc.js";import{t as D}from"./connection-store-CAPTzFtT.js";import{r as O}from"./database-ezjCHdX9.js";import{n as k}from"./engine-DWYEiSZM.js";import{n as A,t as j}from"./use-engine-DSWrApw6.js";import{a as M,i as N,n as P,o as F,t as I}from"./dialog-CJoWJzRo.js";var L=r(e(),1);function R(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function z(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function B(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function V(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var H=y(),U=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,W=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,K=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function q({columns:e,onChange:t}){let{t:n}=b(),r=j().getDataTypes(),a=(0,L.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function o(){t([...e,R()])}function s(){e.length>0&&t(e.slice(0,-1))}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(p,{className:`flex-1`,children:(0,H.jsxs)(v,{className:U,children:[(0,H.jsx)(i,{className:W,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(l,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,H.jsx)(l,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,H.jsx)(l,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,H.jsx)(l,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,H.jsx)(l,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,H.jsx)(l,{children:n(`table.schema.colComment`)})]})}),(0,H.jsx)(f,{children:e.length===0?(0,H.jsx)(g,{children:(0,H.jsx)(_,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,H.jsxs)(g,{children:[(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.field,onChange:t=>a(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,H.jsx)(_,{children:(0,H.jsxs)(E,{value:e.type,onValueChange:t=>a(e.id,`type`,t),children:[(0,H.jsx)(C,{className:K,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:r.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.length,onChange:t=>a(e.id,`length`,t.target.value)})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.defaultValue,onChange:t=>a(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>a(e.id,`pk`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>a(e.id,`notNull`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>a(e.id,`unsigned`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>a(e.id,`autoIncrement`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>a(e.id,`zerofill`,t.target.checked)})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.comment,onChange:t=>a(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:o,children:n(`table.schema.add`)}),(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:s,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var J=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function Y({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:a}=b(),[o,s]=(0,L.useState)(t.name),[c,l]=(0,L.useState)(t.type),[u,d]=(0,L.useState)(t.columns);function f(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function p(){r({id:t.id,name:c===`PRIMARY`?`PRIMARY`:o,type:c,columns:u})}return(0,H.jsx)(I,{open:e,onOpenChange:e=>{e||i()},children:(0,H.jsxs)(P,{className:`sm:max-w-[500px]`,children:[(0,H.jsx)(M,{children:(0,H.jsx)(F,{children:t.name?a(`table.index.editTitle`):a(`table.index.addTitle`)})}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`idx-name`,children:a(`table.index.name`)}),(0,H.jsx)(h,{id:`idx-name`,value:c===`PRIMARY`?`PRIMARY`:o,onChange:e=>s(e.target.value),disabled:c===`PRIMARY`,placeholder:a(`table.index.namePlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`idx-type`,children:a(`table.index.type`)}),(0,H.jsxs)(E,{value:c,onValueChange:e=>l(e),children:[(0,H.jsx)(C,{id:`idx-type`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:J.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{children:a(`table.index.columns`)}),(0,H.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`table.index.noColumns`)}):n.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.field),onChange:()=>f(e.field)}),(0,H.jsx)(`span`,{children:e.field||a(`table.index.unnamed`)}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(x,{variant:`outline`,onClick:i,children:a(`table.index.cancel`)}),(0,H.jsx)(x,{onClick:p,disabled:u.length===0,children:a(`table.index.ok`)})]})]})})}function X({indexes:e,availableColumns:t,onChange:n}){let{t:r}=b(),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1);function u(){let e=z();o(e),c(!0)}function d(e){o({...e}),c(!0)}function m(){e.length>0&&n(e.slice(0,-1))}function h(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),c(!1),o(null)}function y(){c(!1),o(null)}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(p,{className:`flex-1`,children:(0,H.jsxs)(v,{className:U+` [&_td]:px-2`,children:[(0,H.jsx)(i,{className:W,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(l,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,H.jsx)(l,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,H.jsx)(l,{children:r(`table.indexes.colColumns`)})]})}),(0,H.jsx)(f,{children:e.length===0?(0,H.jsx)(g,{children:(0,H.jsx)(_,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,H.jsxs)(g,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,H.jsx)(_,{children:e.name}),(0,H.jsx)(_,{children:e.type}),(0,H.jsx)(_,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:m,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),a&&(0,H.jsx)(Y,{open:s,index:a,availableColumns:t,onSave:h,onClose:y})]})}var Z=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Q=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],$={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function ee({properties:e,onChange:t}){let{t:n}=b();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=$[r]?.[0]??``),t(i)}let i=$[e.charset]??[];return(0,H.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,H.jsxs)(E,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,H.jsx)(C,{id:`prop-engine`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:Z.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,H.jsxs)(E,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,H.jsx)(C,{id:`prop-charset`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:Q.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,H.jsxs)(E,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,H.jsx)(C,{id:`prop-collation`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:i.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,H.jsx)(h,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,H.jsx)(h,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function te({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:o}){let s=d(e=>e.themeId),c=A(e),l=s===`light`||s===`light-blue`||s===`solarized-light`?`vs`:`vs-dark`,u=(0,L.useMemo)(()=>c.ddl.createTable(V(t,n,r,i,o)),[c,t,n,r,i,o]);return(0,H.jsx)(`div`,{className:`h-[320px]`,children:(0,H.jsx)(a,{height:`100%`,language:`sql`,theme:l,value:u,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function ne(){let{t:e}=b(),{activeDialog:r,closeDialog:i}=t(),a=n(`create-table`,`alter-table`,`duplicate-table-structure`),l=r===`create-table`||r===`alter-table`||r===`duplicate-table-structure`,d=r===`alter-table`,f=r===`duplicate-table-structure`,p=a?.nodeText??``,g=a?.metadata?.database??``,[_,v]=(0,L.useState)(``),[y,S]=(0,L.useState)([R()]),[C,w]=(0,L.useState)([]),[T,E]=(0,L.useState)(B()),[j,z]=(0,L.useState)(!1),V=a?.connectionId??D.getState().activeConnectionId,U=A(V);(0,L.useEffect)(()=>{l&&(d||f?(v(f?`${p}_copy`:p),W()):(v(``),S([R()]),w([]),E(B())))},[l,r]);async function W(){let e=D.getState(),t=a?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!g||!p)return;z(!0);let{introspect:r,capabilities:i}=k(t),o=O(n);try{let e=await r.listColumns(o,g,p);if(e.length>0){let t=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});S(t)}let t=await r.listIndexes(o,g,p);if(t.length>0&&w(t.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]}))),i.tableProperties){let e=await r.getTableInfo(o,g,p);e&&E({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e)}finally{z(!1)}}function G(e){e||i()}function K(){i()}let J=e(d?`table.dialog.alterTitle`:f?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),Y=e(d?`table.dialog.alter`:`table.dialog.create`);return(0,H.jsx)(I,{open:l,onOpenChange:G,children:(0,H.jsxs)(P,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,H.jsx)(M,{children:(0,H.jsx)(F,{children:J})}),(0,H.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,H.jsx)(m,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,H.jsx)(h,{id:`table-name`,value:_,onChange:e=>v(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:d})]}),j?(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,H.jsxs)(u,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,H.jsxs)(o,{children:[(0,H.jsx)(c,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,H.jsx)(c,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),U.capabilities.tableProperties&&(0,H.jsx)(c,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,H.jsx)(c,{value:`sql`,children:`SQL`})]}),(0,H.jsx)(s,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(q,{columns:y,onChange:S})}),(0,H.jsx)(s,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(X,{indexes:C,availableColumns:y,onChange:w})}),(0,H.jsx)(s,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(ee,{properties:T,onChange:E})}),(0,H.jsx)(s,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,H.jsx)(te,{connectionId:V,database:g,tableName:_,columns:y,indexes:C,properties:T})})]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(x,{variant:`outline`,onClick:()=>G(!1),children:e(`table.dialog.cancel`)}),(0,H.jsx)(x,{onClick:K,disabled:j,children:Y})]})]})})}export{ne as EditSchemaDialog};
|
|
1
|
+
import{h as e,n as t,t as n,v as r}from"./ui-store-DfspmPOn.js";import{C as i,Ct as a,D as o,E as s,O as c,S as l,T as u,U as d,b as f,j as p,l as m,u as h,w as g,x as _,y as v}from"./main-ot9WNZX1.js";import{l as y,m as b,t as x}from"./button--s6nUzD8.js";import{a as S,i as C,n as w,r as T,t as E}from"./select-DlF-eYgr.js";import{t as D}from"./connection-store-DjSajhjh.js";import{r as O}from"./database-Dvj2X-0B.js";import{n as k}from"./engine-CzHq4UCB.js";import{n as A,t as j}from"./use-engine-CwOU9o8-.js";import{a as M,i as N,n as P,o as F,t as I}from"./dialog-CJoWJzRo.js";var L=r(e(),1);function R(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function z(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function B(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function V(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var H=y(),U=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,W=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,K=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function q({columns:e,onChange:t}){let{t:n}=b(),r=j().getDataTypes(),a=(0,L.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function o(){t([...e,R()])}function s(){e.length>0&&t(e.slice(0,-1))}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(p,{className:`flex-1`,children:(0,H.jsxs)(v,{className:U,children:[(0,H.jsx)(i,{className:W,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(l,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,H.jsx)(l,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,H.jsx)(l,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,H.jsx)(l,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,H.jsx)(l,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,H.jsx)(l,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,H.jsx)(l,{children:n(`table.schema.colComment`)})]})}),(0,H.jsx)(f,{children:e.length===0?(0,H.jsx)(g,{children:(0,H.jsx)(_,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,H.jsxs)(g,{children:[(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.field,onChange:t=>a(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,H.jsx)(_,{children:(0,H.jsxs)(E,{value:e.type,onValueChange:t=>a(e.id,`type`,t),children:[(0,H.jsx)(C,{className:K,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:r.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.length,onChange:t=>a(e.id,`length`,t.target.value)})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.defaultValue,onChange:t=>a(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>a(e.id,`pk`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>a(e.id,`notNull`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>a(e.id,`unsigned`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>a(e.id,`autoIncrement`,t.target.checked)})}),(0,H.jsx)(_,{className:`text-center`,children:(0,H.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>a(e.id,`zerofill`,t.target.checked)})}),(0,H.jsx)(_,{children:(0,H.jsx)(h,{className:G,value:e.comment,onChange:t=>a(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:o,children:n(`table.schema.add`)}),(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:s,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var J=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function Y({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:a}=b(),[o,s]=(0,L.useState)(t.name),[c,l]=(0,L.useState)(t.type),[u,d]=(0,L.useState)(t.columns);function f(e){d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function p(){r({id:t.id,name:c===`PRIMARY`?`PRIMARY`:o,type:c,columns:u})}return(0,H.jsx)(I,{open:e,onOpenChange:e=>{e||i()},children:(0,H.jsxs)(P,{className:`sm:max-w-[500px]`,children:[(0,H.jsx)(M,{children:(0,H.jsx)(F,{children:t.name?a(`table.index.editTitle`):a(`table.index.addTitle`)})}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`idx-name`,children:a(`table.index.name`)}),(0,H.jsx)(h,{id:`idx-name`,value:c===`PRIMARY`?`PRIMARY`:o,onChange:e=>s(e.target.value),disabled:c===`PRIMARY`,placeholder:a(`table.index.namePlaceholder`)})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`idx-type`,children:a(`table.index.type`)}),(0,H.jsxs)(E,{value:c,onValueChange:e=>l(e),children:[(0,H.jsx)(C,{id:`idx-type`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:J.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{children:a(`table.index.columns`)}),(0,H.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`table.index.noColumns`)}):n.map(e=>(0,H.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.field),onChange:()=>f(e.field)}),(0,H.jsx)(`span`,{children:e.field||a(`table.index.unnamed`)}),(0,H.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(x,{variant:`outline`,onClick:i,children:a(`table.index.cancel`)}),(0,H.jsx)(x,{onClick:p,disabled:u.length===0,children:a(`table.index.ok`)})]})]})})}function X({indexes:e,availableColumns:t,onChange:n}){let{t:r}=b(),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(!1);function u(){let e=z();o(e),c(!0)}function d(e){o({...e}),c(!0)}function m(){e.length>0&&n(e.slice(0,-1))}function h(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),c(!1),o(null)}function y(){c(!1),o(null)}return(0,H.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,H.jsx)(p,{className:`flex-1`,children:(0,H.jsxs)(v,{className:U+` [&_td]:px-2`,children:[(0,H.jsx)(i,{className:W,children:(0,H.jsxs)(g,{children:[(0,H.jsx)(l,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,H.jsx)(l,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,H.jsx)(l,{children:r(`table.indexes.colColumns`)})]})}),(0,H.jsx)(f,{children:e.length===0?(0,H.jsx)(g,{children:(0,H.jsx)(_,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,H.jsxs)(g,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,H.jsx)(_,{children:e.name}),(0,H.jsx)(_,{children:e.type}),(0,H.jsx)(_,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,H.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,H.jsx)(x,{size:`sm`,variant:`outline`,onClick:m,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),a&&(0,H.jsx)(Y,{open:s,index:a,availableColumns:t,onSave:h,onClose:y})]})}var Z=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Q=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],$={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function ee({properties:e,onChange:t}){let{t:n}=b();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=$[r]?.[0]??``),t(i)}let i=$[e.charset]??[];return(0,H.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,H.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,H.jsxs)(E,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,H.jsx)(C,{id:`prop-engine`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:Z.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,H.jsxs)(E,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,H.jsx)(C,{id:`prop-charset`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:Q.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,H.jsxs)(E,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,H.jsx)(C,{id:`prop-collation`,className:`w-full`,children:(0,H.jsx)(S,{})}),(0,H.jsx)(w,{children:i.map(e=>(0,H.jsx)(T,{value:e,children:e},e))})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,H.jsx)(h,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(m,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,H.jsx)(h,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function te({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:o}){let s=d(e=>e.themeId),c=A(e),l=s===`light`||s===`light-blue`||s===`solarized-light`?`vs`:`vs-dark`,u=(0,L.useMemo)(()=>c.ddl.createTable(V(t,n,r,i,o)),[c,t,n,r,i,o]);return(0,H.jsx)(`div`,{className:`h-[320px]`,children:(0,H.jsx)(a,{height:`100%`,language:`sql`,theme:l,value:u,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function ne(){let{t:e}=b(),{activeDialog:r,closeDialog:i}=t(),a=n(`create-table`,`alter-table`,`duplicate-table-structure`),l=r===`create-table`||r===`alter-table`||r===`duplicate-table-structure`,d=r===`alter-table`,f=r===`duplicate-table-structure`,p=a?.nodeText??``,g=a?.metadata?.database??``,[_,v]=(0,L.useState)(``),[y,S]=(0,L.useState)([R()]),[C,w]=(0,L.useState)([]),[T,E]=(0,L.useState)(B()),[j,z]=(0,L.useState)(!1),V=a?.connectionId??D.getState().activeConnectionId,U=A(V);(0,L.useEffect)(()=>{l&&(d||f?(v(f?`${p}_copy`:p),W()):(v(``),S([R()]),w([]),E(B())))},[l,r]);async function W(){let e=D.getState(),t=a?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!g||!p)return;z(!0);let{introspect:r,capabilities:i}=k(t),o=O(n);try{let e=await r.listColumns(o,g,p);if(e.length>0){let t=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});S(t)}let t=await r.listIndexes(o,g,p);if(t.length>0&&w(t.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]}))),i.tableProperties){let e=await r.getTableInfo(o,g,p);e&&E({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e)}finally{z(!1)}}function G(e){e||i()}function K(){i()}let J=e(d?`table.dialog.alterTitle`:f?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),Y=e(d?`table.dialog.alter`:`table.dialog.create`);return(0,H.jsx)(I,{open:l,onOpenChange:G,children:(0,H.jsxs)(P,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,H.jsx)(M,{children:(0,H.jsx)(F,{children:J})}),(0,H.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,H.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,H.jsx)(m,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,H.jsx)(h,{id:`table-name`,value:_,onChange:e=>v(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:d})]}),j?(0,H.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,H.jsxs)(u,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,H.jsxs)(o,{children:[(0,H.jsx)(c,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,H.jsx)(c,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),U.capabilities.tableProperties&&(0,H.jsx)(c,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,H.jsx)(c,{value:`sql`,children:`SQL`})]}),(0,H.jsx)(s,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(q,{columns:y,onChange:S})}),(0,H.jsx)(s,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(X,{indexes:C,availableColumns:y,onChange:w})}),(0,H.jsx)(s,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,H.jsx)(ee,{properties:T,onChange:E})}),(0,H.jsx)(s,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,H.jsx)(te,{connectionId:V,database:g,tableName:_,columns:y,indexes:C,properties:T})})]})]}),(0,H.jsxs)(N,{children:[(0,H.jsx)(x,{variant:`outline`,onClick:()=>G(!1),children:e(`table.dialog.cancel`)}),(0,H.jsx)(x,{onClick:K,disabled:j,children:Y})]})]})})}export{ne as EditSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{ht as r,l as i,u as a}from"./main-
|
|
1
|
+
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{ht as r,l as i,u as a}from"./main-ot9WNZX1.js";import{i as o,l as s,m as c,t as l}from"./button--s6nUzD8.js";import{t as u}from"./chevron-up-QmvRX9Fw.js";var d=n(e(),1),f=s();function p(){let{t:e}=c(),{activeDialog:n,closeDialog:s}=t(),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(!1),[C,w]=(0,d.useState)(0);if(n!==`find-replace`)return null;function T(){s()}function E(){w(0)}function D(){}function O(){}function k(){}return(0,f.jsxs)(`div`,{className:`fixed top-12 right-4 z-50 bg-background border rounded-md shadow-lg p-3 w-[400px] space-y-2`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(a,{placeholder:e(`command.findReplace.findPlaceholder`),value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.shiftKey||E()),e.key===`Escape`&&T()},className:`flex-1 h-7 text-sm`,autoFocus:!0}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap min-w-[60px] text-center`,children:C>0?e(`command.findReplace.found`,{count:C}):e(`command.findReplace.noResults`)}),(0,f.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:D,title:e(`command.findReplace.previous`),children:(0,f.jsx)(u,{className:`h-4 w-4`})}),(0,f.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:E,title:e(`command.findReplace.next`),children:(0,f.jsx)(r,{className:`h-4 w-4`})}),(0,f.jsx)(l,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:T,title:e(`command.findReplace.close`),children:(0,f.jsx)(o,{className:`h-4 w-4`})})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,f.jsx)(a,{placeholder:e(`command.findReplace.replacePlaceholder`),value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`&&T()},className:`flex-1 h-7 text-sm`}),(0,f.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:O,children:e(`command.findReplace.replace`)}),(0,f.jsx)(l,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:k,children:e(`command.findReplace.all`)})]}),(0,f.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,f.jsxs)(i,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.caseSensitive`)]}),(0,f.jsxs)(i,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.regex`)]}),(0,f.jsxs)(i,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,f.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.wholeWord`)]})]})]})}export{p as FindReplaceDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./ui-store-DfspmPOn.js";import{l as t,m as n,t as r}from"./button--s6nUzD8.js";import{t as i}from"./connection-store-
|
|
1
|
+
import{n as e}from"./ui-store-DfspmPOn.js";import{l as t,m as n,t as r}from"./button--s6nUzD8.js";import{t as i}from"./connection-store-DjSajhjh.js";import{o as a}from"./database-Dvj2X-0B.js";import{a as o,i as s,n as c,o as l,t as u}from"./dialog-CJoWJzRo.js";var d=t(),f=[`FLUSH HOSTS`,`FLUSH LOGS`,`FLUSH PRIVILEGES`,`FLUSH STATUS`,`FLUSH TABLES`,`FLUSH THREADS`,`FLUSH QUERY CACHE`,`FLUSH DES_KEY_FILE`,`FLUSH RELAY LOGS`,`FLUSH SLOW LOGS`,`FLUSH BINARY LOGS`,`FLUSH ENGINE LOGS`,`FLUSH ERROR LOGS`,`FLUSH GENERAL LOGS`,`FLUSH USER_RESOURCES`,`FLUSH OPTIMIZER_COSTS`];function p(){let e=i.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}function m(){let{t}=n(),{activeDialog:i,closeDialog:m,setFooterMessage:h}=e(),g=i===`flush`;function _(e){e||m()}async function v(e){let n=p();if(!n){h(t(`command.noActiveConnection`));return}try{await a(n,e),h(t(`command.flush.executed`,{command:e}))}catch(n){h(t(`command.flush.executeError`,{command:e,message:n instanceof Error?n.message:String(n)}))}}return(0,d.jsx)(u,{open:g,onOpenChange:_,children:(0,d.jsxs)(c,{className:`sm:max-w-[500px]`,children:[(0,d.jsx)(o,{children:(0,d.jsx)(l,{children:t(`command.flush.title`)})}),(0,d.jsx)(`div`,{className:`grid grid-cols-2 gap-2 py-2`,children:f.map(e=>(0,d.jsx)(r,{variant:`outline`,size:`sm`,className:`justify-start text-xs h-8`,onClick:()=>{v(e)},children:e},e))}),(0,d.jsx)(s,{children:(0,d.jsx)(r,{variant:`outline`,onClick:()=>_(!1),children:t(`command.close`)})})]})})}export{m as FlushDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,h as t,n,t as ee,v as r}from"./ui-store-DfspmPOn.js";import{H as i,V as a,l as o,u as s}from"./main-
|
|
1
|
+
import{c as e,h as t,n,t as ee,v as r}from"./ui-store-DfspmPOn.js";import{H as i,V as a,l as o,u as s}from"./main-ot9WNZX1.js";import{l as c,m as l,t as u}from"./button--s6nUzD8.js";import{a as d,i as f,n as p,r as m,t as h}from"./select-DlF-eYgr.js";import{t as g}from"./connection-store-DjSajhjh.js";import{r as _}from"./database-Dvj2X-0B.js";import{n as v}from"./engine-CzHq4UCB.js";import{t as y}from"./pro-usage-BnI7zYsZ.js";import{a as b,i as x,n as S,o as C,t as w}from"./dialog-CJoWJzRo.js";var T=r(t(),1),E=c(),D=e=>e instanceof Error?e.message:String(e);function O(){let{t}=l(),r=n(e=>e.activeDialog),c=n(e=>e.closeDialog),O=ee(`link-column`),k=r===`link-column`&&!!O,A=O?.connectionId??``,j=g(e=>e.activeConnections),M=j.filter(e=>e.serverConnectionId),N=i(e=>e.links),P=i(e=>e.setLink),F=i(e=>e.removeLink),I=O?a(N,A,O.database,O.table).find(e=>e.column===O.column)??null:null,[L,R]=(0,T.useState)(I?.targetConnectionId??A),z=j.find(e=>e.id===L)?.serverConnectionId,[B,V]=(0,T.useState)([]),[H,U]=(0,T.useState)([]),[W,G]=(0,T.useState)([]),[K,q]=(0,T.useState)(I?.targetDatabase??O?.database??``),[J,Y]=(0,T.useState)(I?.targetTable??``),[X,Z]=(0,T.useState)(I?.targetColumn??``),[Q,$]=(0,T.useState)(null);if((0,T.useEffect)(()=>{if(!k||!z)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listDatabases(_(z));if(e)return;V(t),q(e=>t.includes(e)?e:t[0]??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L]),(0,T.useEffect)(()=>{if(!k||!z||!K)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listTables(_(z),K);if(e)return;U(t.map(e=>e.name))}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K]),(0,T.useEffect)(()=>{if(!k||!z||!K||!J)return;let e=!1;return(async()=>{try{let t=await v(L).introspect.listColumns(_(z),K,J);if(e)return;G(t.map(e=>e.name)),Z(e=>t.some(t=>t.name===e)?e:t.find(e=>e.key===`PRI`)?.name??t[0]?.name??``)}catch(t){e||$(D(t))}})(),()=>{e=!0}},[k,z,L,K,J]),!O)return null;function te(){if(!O||!K||!J||!X)return;let t=L!==A;P(A,{database:O.database,table:O.table,column:O.column,...t?{targetConnectionId:L}:{},targetDatabase:K,targetTable:J,targetColumn:X}),y(`column_link`),e(`column_link_set`,{dbms:v(A).id,target_dbms:v(L).id,cross_database:K!==O.database,cross_connection:t}),c()}function ne(){O&&(F(A,O),c())}return(0,E.jsx)(w,{open:k,onOpenChange:e=>{e||c()},children:(0,E.jsxs)(S,{className:`sm:max-w-[460px]`,children:[(0,E.jsx)(b,{children:(0,E.jsx)(C,{children:t(`result.link.title`)})}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(o,{children:t(`result.link.source`)}),(0,E.jsx)(s,{value:`${O.database}.${O.table}.${O.column}`,disabled:!0})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`result.link.hint`)}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(o,{htmlFor:`link-conn`,children:t(`result.link.targetConnection`)}),(0,E.jsxs)(h,{value:L,onValueChange:e=>{R(e),Y(``),U([]),G([])},children:[(0,E.jsx)(f,{id:`link-conn`,className:`w-full`,children:(0,E.jsx)(d,{})}),(0,E.jsx)(p,{children:M.map(e=>(0,E.jsx)(m,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(o,{htmlFor:`link-db`,children:t(`result.link.targetDatabase`)}),(0,E.jsxs)(h,{value:K,onValueChange:e=>{q(e),Y(``),G([])},children:[(0,E.jsx)(f,{id:`link-db`,className:`w-full`,children:(0,E.jsx)(d,{})}),(0,E.jsx)(p,{children:B.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(o,{htmlFor:`link-table`,children:t(`result.link.targetTable`)}),(0,E.jsxs)(h,{value:J,onValueChange:Y,disabled:H.length===0,children:[(0,E.jsx)(f,{id:`link-table`,className:`w-full`,children:(0,E.jsx)(d,{placeholder:t(`result.link.pickTable`)})}),(0,E.jsx)(p,{children:H.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(o,{htmlFor:`link-column`,children:t(`result.link.targetColumn`)}),(0,E.jsxs)(h,{value:X,onValueChange:Z,disabled:W.length===0,children:[(0,E.jsx)(f,{id:`link-column`,className:`w-full`,children:(0,E.jsx)(d,{placeholder:t(`result.link.pickColumn`)})}),(0,E.jsx)(p,{children:W.map(e=>(0,E.jsx)(m,{value:e,children:e},e))})]})]}),Q&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:Q})]}),(0,E.jsxs)(x,{children:[I&&(0,E.jsx)(u,{variant:`destructive`,onClick:ne,className:`mr-auto`,children:t(`result.link.remove`)}),(0,E.jsx)(u,{variant:`outline`,onClick:c,children:t(`result.link.cancel`)}),(0,E.jsx)(u,{onClick:te,disabled:!K||!J||!X,children:t(`result.link.save`)})]})]})})}export{O as LinkColumnDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{j as r}from"./main-
|
|
1
|
+
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{j as r}from"./main-ot9WNZX1.js";import{l as i,m as a,t as o}from"./button--s6nUzD8.js";import{t as s}from"./connection-store-DjSajhjh.js";import{n as c}from"./query-store-yK1eqNW-.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./dialog-CJoWJzRo.js";var h=n(e(),1),g=i(),_={execute:`command.localHistory.reason.execute`,replaced:`command.localHistory.reason.replaced`,restore:`command.localHistory.reason.restore`};function v(){let{t:e}=a(),n=t(e=>e.activeDialog),i=t(e=>e.closeDialog),v=t(e=>e.setFooterMessage),y=s(e=>e.activeConnectionId),b=c(e=>y?e.activeTabId[y]:null),x=c(e=>y&&b?e.snapshots[y]?.[b]:void 0)??[],[S,C]=(0,h.useState)(0),w=x[S];function T(){if(!y||!b||!w)return;let t=c.getState();t.captureSnapshot(y,b,`restore`),t.setEditorContent(y,b,w.text),v(e(`command.localHistory.restored`)),i()}return(0,g.jsx)(m,{open:n===`local-history`,onOpenChange:e=>{e||i()},children:(0,g.jsxs)(d,{className:`flex max-h-[80vh] flex-col sm:max-w-[860px]`,children:[(0,g.jsxs)(l,{children:[(0,g.jsx)(f,{children:e(`command.localHistory.title`)}),(0,g.jsx)(p,{children:e(`command.localHistory.description`)})]}),x.length===0?(0,g.jsx)(`div`,{className:`py-8 text-center text-sm text-muted-foreground`,children:e(`command.localHistory.empty`)}):(0,g.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[240px_1fr] gap-3`,children:[(0,g.jsx)(r,{className:`h-[420px] rounded-md border`,children:(0,g.jsx)(`ul`,{className:`divide-y`,children:x.map((t,n)=>(0,g.jsx)(`li`,{children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>C(n),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-xs hover:bg-accent ${n===S?`bg-accent`:``}`,children:[(0,g.jsx)(`span`,{className:`font-medium`,children:new Date(t.timestamp).toLocaleString()}),(0,g.jsxs)(`span`,{className:`text-muted-foreground`,children:[e(_[t.reason]),` · `,e(`command.localHistory.chars`,{count:t.text.length})]})]})},t.timestamp+`:`+n))})}),(0,g.jsx)(`pre`,{className:`h-[420px] overflow-auto rounded-md border bg-muted p-3 font-mono text-xs whitespace-pre-wrap`,children:w?.text})]}),(0,g.jsxs)(u,{children:[(0,g.jsx)(o,{variant:`outline`,onClick:i,children:e(`command.close`)}),(0,g.jsx)(o,{onClick:T,disabled:!w,children:e(`command.localHistory.restore`)})]})]})})}export{v as LocalHistoryDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{C as r,S as i,b as a,bt as o,dt as s,et as ee,gt as te,tt as ne,vt as re,w as c,x as l,y as u,yt as ie}from"./main-Cs_AF7Zo.js";import{a as d,i as ae,l as f,m as oe,t as p}from"./button--s6nUzD8.js";import{a as m}from"./i18n-NLG6supM.js";import{t as h}from"./connection-store-CAPTzFtT.js";import{o as g}from"./database-ezjCHdX9.js";import{t as _}from"./engine-DWYEiSZM.js";import{a as se,i as v,n as y,o as b,t as ce}from"./dialog-CJoWJzRo.js";var le=d(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),ue=d(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),x=d(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),de=d(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),S=n(e(),1),C=f(),w=10,fe=[2,5,10,30];function T(){let e=h.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function pe(){let e=T();if(!e)throw Error(m.t(`command.noActiveConnection`));let t=await g(e,_().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function E(e){return/^(sleep|idle)/i.test(e.Command??``)}function me(e){return/lock/i.test(e.State??``)}function he(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function D(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function O(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function k({icon:e,label:t,value:n,tone:r}){return(0,C.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,C.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function A(){let{t:e}=oe(),{activeDialog:n,closeDialog:d,setFooterMessage:f,requestDestructiveConfirm:m}=t(),[h,A]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(5),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(``),[z,ge]=(0,S.useState)(!1),[B,_e]=(0,S.useState)(!0),[V,H]=(0,S.useState)(!1),[U,ve]=(0,S.useState)(null),[W,G]=(0,S.useState)(!1),K=(0,S.useRef)(null),q=n===`process-list`,J=(0,S.useCallback)(()=>Promise.resolve().then(()=>(H(!0),pe())).then(e=>{A(e),ve(new Date)}).catch(t=>f(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[f,e]);(0,S.useEffect)(()=>{q&&J()},[q,J]),(0,S.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),j&&q&&(K.current=setInterval(()=>{J()},N*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[j,N,q,J]);function Y(e){e||(M(!1),I(null),R(``),d())}let X=(0,S.useMemo)(()=>{let e=h.filter(E).length,t=h.filter(e=>!E(e)).reduce((e,t)=>Math.max(e,D(t)),0);return{total:h.length,active:h.length-e,idle:e,longest:t}},[h]),Z=(0,S.useMemo)(()=>{let e=L.trim().toLowerCase();return h.filter(t=>z&&E(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?D(t)-D(e):D(e)-D(t))},[h,L,z,B]),Q=h.find(e=>e.Id===F)??null,ye=(0,S.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){f(e(`command.processList.selectToKill`));return}let r=T();if(!r)return;let i=h.find(e=>e.Id===n),a=_().getQuery(`KILL_QUERY`,String(n));if(await m({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[a]}))try{await g(r,a),f(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){f(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,C.jsx)(ce,{open:q,onOpenChange:Y,children:(0,C.jsxs)(y,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,C.jsx)(se,{children:(0,C.jsxs)(b,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,C.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(k,{icon:(0,C.jsx)(le,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,C.jsx)(k,{icon:(0,C.jsx)(o,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,C.jsx)(k,{icon:(0,C.jsx)(ue,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,C.jsx)(k,{icon:(0,C.jsx)(de,{}),label:e(`command.processList.stats.longest`),value:O(X.longest),tone:X.longest>=w?`warn`:void 0})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative`,children:[(0,C.jsx)(ee,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,C.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,C.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,C.jsx)(ae,{className:`size-3`})})]}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:j,onChange:e=>M(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,C.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:N,onChange:e=>P(Number(e.target.value)),disabled:!j,children:fe.map(e=>(0,C.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,C.jsxs)(p,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,C.jsx)(ne,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,C.jsxs)(u,{className:`text-xs`,children:[(0,C.jsx)(r,{className:`sticky top-0 z-10 bg-background`,children:(0,C.jsxs)(c,{children:[(0,C.jsx)(i,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,C.jsx)(i,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,C.jsx)(i,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,C.jsx)(i,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,C.jsx)(i,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,C.jsx)(i,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,C.jsx)(ie,{className:`size-3 text-primary`}):(0,C.jsx)(re,{className:`size-3 text-primary`})]})}),(0,C.jsx)(i,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,C.jsx)(i,{children:e(`command.processList.columns.info`)}),(0,C.jsx)(i,{className:`w-[50px]`})]})}),(0,C.jsx)(a,{children:Z.length===0?(0,C.jsx)(c,{children:(0,C.jsx)(l,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:h.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let n=E(t),r=D(t),i=!n&&r>=w,a=me(t),o=he(t);return(0,C.jsxs)(c,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${n?`text-muted-foreground`:``} ${a?`bg-destructive/5`:i?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,C.jsx)(l,{className:`font-mono tabular-nums`,children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,o&&(0,C.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,C.jsx)(l,{children:t.User}),(0,C.jsx)(l,{className:`font-mono`,children:t.Host}),(0,C.jsx)(l,{className:`font-mono`,children:t.db??``}),(0,C.jsx)(l,{children:(0,C.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${n?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,C.jsx)(l,{className:`tabular-nums ${i?`font-semibold text-catppuccin-yellow`:``}`,children:O(r)}),(0,C.jsx)(l,{className:a?`font-medium text-destructive`:``,children:t.State}),(0,C.jsx)(l,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,C.jsx)(l,{className:`text-right`,children:(0,C.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,C.jsx)(x,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,C.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,C.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,C.jsx)(te,{className:`size-3`}):(0,C.jsx)(s,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,C.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,C.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(p,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,C.jsx)(p,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{A as ProcessListDialog};
|
|
1
|
+
import{h as e,n as t,v as n}from"./ui-store-DfspmPOn.js";import{C as r,S as i,b as a,bt as o,dt as s,et as ee,gt as te,tt as ne,vt as re,w as c,x as l,y as u,yt as ie}from"./main-ot9WNZX1.js";import{a as d,i as ae,l as f,m as oe,t as p}from"./button--s6nUzD8.js";import{a as m}from"./i18n-gQOmt8le.js";import{t as h}from"./connection-store-DjSajhjh.js";import{o as g}from"./database-Dvj2X-0B.js";import{t as _}from"./engine-CzHq4UCB.js";import{a as se,i as v,n as y,o as b,t as ce}from"./dialog-CJoWJzRo.js";var le=d(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),ue=d(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),x=d(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),de=d(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),S=n(e(),1),C=f(),w=10,fe=[2,5,10,30];function T(){let e=h.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function pe(){let e=T();if(!e)throw Error(m.t(`command.noActiveConnection`));let t=await g(e,_().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function E(e){return/^(sleep|idle)/i.test(e.Command??``)}function me(e){return/lock/i.test(e.State??``)}function he(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function D(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function O(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function k({icon:e,label:t,value:n,tone:r}){return(0,C.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,C.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function A(){let{t:e}=oe(),{activeDialog:n,closeDialog:d,setFooterMessage:f,requestDestructiveConfirm:m}=t(),[h,A]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(5),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(``),[z,ge]=(0,S.useState)(!1),[B,_e]=(0,S.useState)(!0),[V,H]=(0,S.useState)(!1),[U,ve]=(0,S.useState)(null),[W,G]=(0,S.useState)(!1),K=(0,S.useRef)(null),q=n===`process-list`,J=(0,S.useCallback)(()=>Promise.resolve().then(()=>(H(!0),pe())).then(e=>{A(e),ve(new Date)}).catch(t=>f(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[f,e]);(0,S.useEffect)(()=>{q&&J()},[q,J]),(0,S.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),j&&q&&(K.current=setInterval(()=>{J()},N*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[j,N,q,J]);function Y(e){e||(M(!1),I(null),R(``),d())}let X=(0,S.useMemo)(()=>{let e=h.filter(E).length,t=h.filter(e=>!E(e)).reduce((e,t)=>Math.max(e,D(t)),0);return{total:h.length,active:h.length-e,idle:e,longest:t}},[h]),Z=(0,S.useMemo)(()=>{let e=L.trim().toLowerCase();return h.filter(t=>z&&E(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?D(t)-D(e):D(e)-D(t))},[h,L,z,B]),Q=h.find(e=>e.Id===F)??null,ye=(0,S.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){f(e(`command.processList.selectToKill`));return}let r=T();if(!r)return;let i=h.find(e=>e.Id===n),a=_().getQuery(`KILL_QUERY`,String(n));if(await m({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[a]}))try{await g(r,a),f(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){f(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,C.jsx)(ce,{open:q,onOpenChange:Y,children:(0,C.jsxs)(y,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,C.jsx)(se,{children:(0,C.jsxs)(b,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,C.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(k,{icon:(0,C.jsx)(le,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,C.jsx)(k,{icon:(0,C.jsx)(o,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,C.jsx)(k,{icon:(0,C.jsx)(ue,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,C.jsx)(k,{icon:(0,C.jsx)(de,{}),label:e(`command.processList.stats.longest`),value:O(X.longest),tone:X.longest>=w?`warn`:void 0})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative`,children:[(0,C.jsx)(ee,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,C.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,C.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,C.jsx)(ae,{className:`size-3`})})]}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:j,onChange:e=>M(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,C.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:N,onChange:e=>P(Number(e.target.value)),disabled:!j,children:fe.map(e=>(0,C.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,C.jsxs)(p,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,C.jsx)(ne,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,C.jsxs)(u,{className:`text-xs`,children:[(0,C.jsx)(r,{className:`sticky top-0 z-10 bg-background`,children:(0,C.jsxs)(c,{children:[(0,C.jsx)(i,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,C.jsx)(i,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,C.jsx)(i,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,C.jsx)(i,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,C.jsx)(i,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,C.jsx)(i,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,C.jsx)(ie,{className:`size-3 text-primary`}):(0,C.jsx)(re,{className:`size-3 text-primary`})]})}),(0,C.jsx)(i,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,C.jsx)(i,{children:e(`command.processList.columns.info`)}),(0,C.jsx)(i,{className:`w-[50px]`})]})}),(0,C.jsx)(a,{children:Z.length===0?(0,C.jsx)(c,{children:(0,C.jsx)(l,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:h.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let n=E(t),r=D(t),i=!n&&r>=w,a=me(t),o=he(t);return(0,C.jsxs)(c,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${n?`text-muted-foreground`:``} ${a?`bg-destructive/5`:i?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,C.jsx)(l,{className:`font-mono tabular-nums`,children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,o&&(0,C.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,C.jsx)(l,{children:t.User}),(0,C.jsx)(l,{className:`font-mono`,children:t.Host}),(0,C.jsx)(l,{className:`font-mono`,children:t.db??``}),(0,C.jsx)(l,{children:(0,C.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${n?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,C.jsx)(l,{className:`tabular-nums ${i?`font-semibold text-catppuccin-yellow`:``}`,children:O(r)}),(0,C.jsx)(l,{className:a?`font-medium text-destructive`:``,children:t.State}),(0,C.jsx)(l,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,C.jsx)(l,{className:`text-right`,children:(0,C.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,C.jsx)(x,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,C.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,C.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,C.jsx)(te,{className:`size-3`}):(0,C.jsx)(s,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,C.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,C.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(p,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,C.jsx)(p,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{A as ProcessListDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,h as t,n,v as r}from"./ui-store-DfspmPOn.js";import{B as i,F as a,G as o,J as s,K as c,L as l,Q as u,U as d,W as f,Y as p,Z as m,at as ee,bt as h,dt as g,et as _,gt as v,it as te,lt as y,nt as b,q as x,rt as S,st as ne,tt as C,ut as w,z as T}from"./main-Cs_AF7Zo.js";import{a as E,f as D,l as O,m as k,o as A,s as j}from"./button--s6nUzD8.js";import{r as M,t as N}from"./i18n-NLG6supM.js";import{_ as P,a as F,o as I,r as re,t as ie}from"./dist-CBYDYlja.js";import{t as L}from"./connection-store-CAPTzFtT.js";import{n as ae}from"./query-store-CRp9AQS5.js";import{n as oe,r as se}from"./settings-store-CYHWBgNo.js";import{r as ce,s as le}from"./query-execution-BZE0rVpK.js";import{t as ue}from"./use-engine-DSWrApw6.js";import{a as de,n as R,o as z,r as B,t as fe}from"./dialog-CJoWJzRo.js";var pe=E(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),me=E(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),he=E(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),ge=E(`database-zap`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]),_e=E(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ve=E(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),ye=E(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),be=E(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),xe=E(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Se=E(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ce=E(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),we=E(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Te=E(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Ee=E(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),De=E(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Oe=E(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ke=E(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ae=E(`shield-alert`,[[`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`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),je=E(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),Me=E(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),V=r(t(),1),Ne=1,Pe=.9,Fe=.8,Ie=.17,H=.1,U=.999,W=.9999,Le=.99,Re=/[\\\/_+.#"@\[\(\{&]/,ze=/[\\\/_+.#"@\[\(\{&]/g,Be=/[\s-]/,Ve=/[\s-]/g;function He(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ne:Le;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=He(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ne:Re.test(e.charAt(l-1))?(d*=Fe,p=e.slice(i,l-1).match(ze),p&&i>0&&(d*=U**+p.length)):Be.test(e.charAt(l-1))?(d*=Pe,m=e.slice(i,l-1).match(Ve),m&&i>0&&(d*=U**+m.length)):(d*=Ie,i>0&&(d*=U**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=W)),(d<H&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=He(e,t,n,r,l+1,a+2,o),f*H>d&&(d=f*H)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Ue(e){return e.toLowerCase().replace(Ve,` `)}function We(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,He(e,t,Ue(e),Ue(t),0,0,{})}var G=`[cmdk-group=""]`,Ge=`[cmdk-group-items=""]`,Ke=`[cmdk-group-heading=""]`,qe=`[cmdk-item=""]`,Je=`${qe}:not([aria-disabled="true"])`,Ye=`cmdk-item-select`,K=`data-value`,Xe=(e,t,n)=>We(e,t,n),Ze=V.createContext(void 0),q=()=>V.useContext(Ze),Qe=V.createContext(void 0),$e=()=>V.useContext(Qe),et=V.createContext(void 0),tt=V.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),s=ft(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:ee=!1,vimBindings:h=!0,...g}=e,_=P(),v=P(),te=P(),y=V.useRef(null),b=mt();Y(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,x.emit()}},[u]),Y(()=>{b(6,E)},[]);let x=V.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)T(),C(),b(1,w);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(te);e?e.focus():(i=document.getElementById(_))==null||i.focus()}if(b(7,()=>{n.current.selectedItemId=D()?.id,x.emit()}),r||b(5,E),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}x.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),S=V.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,ne(t,r)),b(2,()=>{C(),x.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),b(3,()=>{T(),C(),n.current.value||w(),x.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=D();b(4,()=>{T(),t?.getAttribute(`id`)===e&&w(),x.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:_,inputId:te,labelId:v,listInnerRef:y}),[]);function ne(e,t){let r=s.current?.filter??Xe;return e?r(e,n.current.search,t):0}function C(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=y.current;O().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Ge);t?t.appendChild(e.parentElement===t?e:e.closest(`${Ge} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Ge} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=y.current?.querySelector(`${G}[${K}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function w(){let e=O().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(K);x.setState(`value`,e||void 0)}function T(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=ne(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function E(){var e;let t=D();t&&(t.parentElement?.firstChild===t&&((e=t.closest(G)?.querySelector(Ke))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function D(){return y.current?.querySelector(`${qe}[aria-selected="true"]`)}function O(){return Array.from(y.current?.querySelectorAll(Je)||[])}function k(e){let t=O()[e];t&&x.setState(`value`,t.getAttribute(K))}function A(e){var t;let n=D(),r=O(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&x.setState(`value`,a.getAttribute(K))}function M(e){let t=D()?.closest(G),n;for(;t&&!n;)t=e>0?ut(t,G):dt(t,G),n=t?.querySelector(Je);n?x.setState(`value`,n.getAttribute(K)):A(e)}let N=()=>k(O().length-1),F=e=>{e.preventDefault(),e.metaKey?N():e.altKey?M(1):A(1)},I=e=>{e.preventDefault(),e.metaKey?k(0):e.altKey?M(-1):A(-1)};return V.createElement(j.div,{ref:t,tabIndex:-1,...g,"cmdk-root":``,onKeyDown:e=>{var t;(t=g.onKeyDown)==null||t.call(g,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:h&&e.ctrlKey&&F(e);break;case`ArrowDown`:F(e);break;case`p`:case`k`:h&&e.ctrlKey&&I(e);break;case`ArrowUp`:I(e);break;case`Home`:e.preventDefault(),k(0);break;case`End`:e.preventDefault(),N();break;case`Enter`:{e.preventDefault();let t=D();if(t){let e=new Event(Ye);t.dispatchEvent(e)}}}}},V.createElement(`label`,{"cmdk-label":``,htmlFor:S.inputId,id:S.labelId,style:gt},c),Q(e,e=>V.createElement(Qe.Provider,{value:x},V.createElement(Ze.Provider,{value:S},e))))}),nt=V.forwardRef((e,t)=>{let n=P(),r=V.useRef(null),i=V.useContext(et),a=q(),o=ft(e),s=o.current?.forceMount??i?.forceMount;Y(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=pt(n,r,[e.value,e.children,r],e.keywords),l=$e(),u=Z(e=>e.value&&e.value===c.current),d=Z(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);V.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ye,f),()=>t.removeEventListener(Ye,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:ee,onSelect:h,forceMount:g,keywords:_,...v}=e;return V.createElement(j.div,{ref:D(r,t),...v,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),rt=V.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=P(),s=V.useRef(null),c=V.useRef(null),l=P(),u=q(),d=Z(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Y(()=>u.group(o),[]),pt(o,s,[e.value,e.heading,c]);let f=V.useMemo(()=>({id:o,forceMount:i}),[i]);return V.createElement(j.div,{ref:D(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&V.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Q(e,e=>V.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},V.createElement(et.Provider,{value:f},e))))}),it=V.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=V.useRef(null),a=Z(e=>!e.search);return!n&&!a?null:V.createElement(j.div,{ref:D(i,t),...r,"cmdk-separator":``,role:`separator`})}),at=V.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=$e(),o=Z(e=>e.search),s=Z(e=>e.selectedItemId),c=q();return V.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),V.createElement(j.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ot=V.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=V.useRef(null),o=V.useRef(null),s=Z(e=>e.selectedItemId),c=q();return V.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),V.createElement(j.div,{ref:D(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Q(e,e=>V.createElement(`div`,{ref:D(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),st=V.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return V.createElement(ie,{open:n,onOpenChange:r},V.createElement(I,{container:o},V.createElement(F,{"cmdk-overlay":``,className:i}),V.createElement(re,{"aria-label":e.label,"cmdk-dialog":``,className:a},V.createElement(tt,{ref:t,...s}))))}),ct=V.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?V.createElement(j.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),lt=V.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return V.createElement(j.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>V.createElement(`div`,{"aria-hidden":!0},e)))}),J=Object.assign(tt,{List:ot,Item:nt,Input:at,Group:rt,Separator:it,Dialog:st,Empty:ct,Loading:lt});function ut(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function dt(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function ft(e){let t=V.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?V.useEffect:V.useLayoutEffect;function X(e){let t=V.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=$e(),n=()=>e(t.snapshot());return V.useSyncExternalStore(t.subscribe,n,n)}function pt(e,t,n,r=[]){let i=V.useRef(),a=q();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(K,s),i.current=s}),i}var mt=()=>{let[e,t]=V.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function ht(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&V.isValidElement(t)?V.cloneElement(ht(t),{ref:t.ref},n(t.props.children)):n(t)}var gt={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=O();function _t({className:e,...t}){return(0,$.jsx)(J,{"data-slot":`command`,className:A(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function vt({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,...a}){return(0,$.jsxs)(fe,{...a,children:[(0,$.jsxs)(de,{className:`sr-only`,children:[(0,$.jsx)(z,{children:e}),(0,$.jsx)(B,{children:t})]}),(0,$.jsx)(R,{className:A(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,$.jsx)(_t,{className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function yt({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,$.jsx)(_,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(J.Input,{"data-slot":`command-input`,className:A(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function bt({className:e,...t}){return(0,$.jsx)(J.List,{"data-slot":`command-list`,className:A(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function xt({...e}){return(0,$.jsx)(J.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function St({className:e,...t}){return(0,$.jsx)(J.Group,{"data-slot":`command-group`,className:A(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Ct({className:e,...t}){return(0,$.jsx)(J.Item,{"data-slot":`command-item`,className:A(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function wt({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:A(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var Tt={sky:`text-catppuccin-sky`,blue:`text-catppuccin-blue`,green:`text-catppuccin-green`,teal:`text-catppuccin-teal`,mauve:`text-catppuccin-mauve`,lavender:`text-catppuccin-lavender`,peach:`text-catppuccin-peach`,yellow:`text-catppuccin-yellow`,red:`text-catppuccin-red`};function Et({theme:e}){let{background:t,blue:n,mauve:r,green:i}=e.colors;return(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 overflow-hidden rounded-sm border border-catppuccin-surface2`,children:[t,n,r,i].map((e,t)=>(0,$.jsx)(`span`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function Dt(){let{t}=k(),{activeDialog:r,closeDialog:_,openDialog:E}=n(),D=n(e=>e.setWelcomeVisible),O=n(e=>e.setFooterMessage),{executeCurrentQuery:j,executeCurrentStatement:P,executeWholeScript:F,addNewQueryTab:I,disconnectActive:re}=c(),{capabilities:ie}=ue(),de=se(),R=L(e=>e.activeConnections.find(t=>t.id===e.activeConnectionId)),z=L(e=>e.activeConnectionId?e.transactionOpen[e.activeConnectionId]??!1:!1),B=L(e=>e.updateProfile),fe=d(e=>e.themeId),Ne=d(e=>e.setTheme),Pe=oe(e=>e.locale),Fe=oe(e=>e.setLocale),Ie=r===`quick-command`,H=R!==void 0,U=(0,V.useCallback)(e=>{_(),e()},[_]),W=(0,V.useCallback)(e=>O(e instanceof Error?e.message:String(e)),[O]),Le=()=>{let t=L.getState().activeConnectionId;t&&(o.getState().openERD(t),e(`erd_open`),ae.getState().setActiveQueryTab(t,`erd`))},Re=[{heading:t(`palette.groups.connection`),commands:[{id:`connect`,label:t(`palette.commands.connect`),icon:we,tone:`sky`,shortcut:`Alt+N`,keywords:[`connect`,`server`,`profile`,`login`],disabled:!de,action:()=>U(()=>E(`connect`))},{id:`disconnect`,label:t(`palette.commands.disconnect`),icon:s,tone:`red`,keywords:[`disconnect`,`close`],disabled:!H,action:()=>U(()=>{re()})},{id:`read-only`,label:t(`menu.connection.readOnly`),icon:ee,tone:`yellow`,keywords:[`read only`,`safety`,`guard`],disabled:!H,checked:R?.readOnly===!0,action:()=>U(()=>{R&&B(R.id,{readOnly:!R.readOnly})})},{id:`manual-transactions`,capability:`transactions`,label:t(`menu.connection.manualTransactions`),icon:ne,tone:`lavender`,keywords:[`transaction`,`manual`,`autocommit`],disabled:!H,checked:R?.transactionMode===`manual`,action:()=>U(()=>{R&&B(R.id,{transactionMode:R.transactionMode===`manual`?`auto`:`manual`})})},{id:`commit`,capability:`transactions`,label:t(`toolbar.commit`),icon:v,tone:`green`,keywords:[`commit`,`transaction`],disabled:!z||!R,action:()=>U(()=>{R&&ce(R.id).catch(W)})},{id:`rollback`,capability:`transactions`,label:t(`toolbar.rollback`),icon:p,tone:`peach`,keywords:[`rollback`,`transaction`,`undo`],disabled:!z||!R,action:()=>U(()=>{R&&le(R.id).catch(W)})}]},{heading:t(`palette.groups.query`),commands:[{id:`execute`,label:t(`palette.commands.executeQuery`),icon:S,tone:`green`,shortcut:`F9`,keywords:[`run`,`execute`,`sql`],disabled:!H,action:()=>U(()=>{j()})},{id:`execute-statement`,label:t(`menu.query.executeStatementAtCursor`),icon:he,tone:`green`,shortcut:`Ctrl+Enter`,keywords:[`run`,`statement`,`cursor`],disabled:!H,action:()=>U(()=>{P()})},{id:`execute-script`,label:t(`menu.query.executeWholeScript`),icon:Oe,tone:`teal`,shortcut:`Ctrl+Shift+Enter`,keywords:[`run`,`script`,`batch`],disabled:!H,action:()=>U(()=>{F()})},{id:`new-tab`,label:t(`palette.commands.newQueryTab`),icon:b,tone:`blue`,shortcut:`Alt+T`,keywords:[`new`,`tab`,`editor`],disabled:!H,action:()=>U(()=>I())},{id:`find-replace`,label:t(`menu.query.findReplace`),icon:Te,tone:`lavender`,keywords:[`find`,`replace`,`search`],disabled:!H,action:()=>U(()=>E(`find-replace`))},{id:`local-history`,label:t(`menu.query.localHistory`),icon:xe,tone:`mauve`,keywords:[`history`,`snapshot`,`undo`],disabled:!H,action:()=>U(()=>E(`local-history`))}]},{heading:t(`palette.groups.database`),commands:[{id:`create-db`,capability:`multipleDatabases`,label:t(`palette.commands.createDatabase`),icon:w,tone:`blue`,keywords:[`create`,`database`,`schema`],disabled:!H,action:()=>U(()=>E(`create-database`))},{id:`alter-db`,capability:`multipleDatabases`,label:t(`menu.database.alter`),icon:ge,tone:`blue`,keywords:[`alter`,`database`,`charset`],disabled:!H,action:()=>U(()=>E(`alter-database`))},{id:`copy-db`,capability:`multipleDatabases`,label:t(`menu.database.copy`),icon:g,tone:`sky`,keywords:[`copy`,`clone`,`database`],disabled:!H,action:()=>U(()=>E(`copy-database`))},{id:`schema-diff`,label:t(`menu.database.compare`),icon:ye,tone:`mauve`,keywords:[`compare`,`diff`,`schema`,`sync`],pro:!0,disabled:!H,action:()=>U(()=>E(`schema-diff`))},{id:`data-diff`,label:t(`menu.database.compareData`),icon:be,tone:`mauve`,keywords:[`compare`,`diff`,`data`,`rows`],pro:!0,disabled:!H,action:()=>U(()=>E(`data-diff`))}]},{heading:t(`palette.groups.table`),commands:[{id:`create-table`,label:t(`palette.commands.createTable`),icon:u,tone:`green`,keywords:[`create`,`table`],disabled:!H,action:()=>U(()=>E(`create-table`))},{id:`alter-table`,label:t(`palette.commands.alterTable`),icon:Me,tone:`yellow`,keywords:[`alter`,`table`,`column`],disabled:!H,action:()=>U(()=>E(`alter-table`))},{id:`duplicate-table`,label:t(`menu.table.duplicateStructure`),icon:me,tone:`teal`,keywords:[`duplicate`,`structure`,`table`],disabled:!H,action:()=>U(()=>E(`duplicate-table-structure`))}]},{heading:t(`menu.export.title`),commands:[{id:`export-csv`,label:t(`menu.export.csv`),icon:ve,tone:`green`,keywords:[`export`,`csv`,`excel`],disabled:!H,action:()=>U(()=>E(`export-csv`))},{id:`export-html`,label:t(`menu.export.schemaHtml`),icon:_e,tone:`peach`,keywords:[`export`,`html`,`schema`,`documentation`],disabled:!H,action:()=>U(()=>E(`export-html`))}]},{heading:t(`palette.groups.tools`),commands:[{id:`process-list`,capability:`processList`,label:t(`palette.commands.processList`),icon:h,tone:`red`,keywords:[`process`,`kill`,`connections`],disabled:!H,action:()=>U(()=>E(`process-list`))},{id:`variables`,capability:`variables`,label:t(`palette.commands.serverVariables`),icon:ke,tone:`lavender`,keywords:[`variables`,`server`,`settings`],disabled:!H,action:()=>U(()=>E(`variables`))},{id:`status`,capability:`status`,label:t(`palette.commands.serverStatus`),icon:m,tone:`teal`,keywords:[`status`,`server`,`metrics`],disabled:!H,action:()=>U(()=>E(`status`))},{id:`flush`,capability:`flush`,label:t(`palette.commands.flush`),icon:C,tone:`peach`,keywords:[`flush`,`cache`,`reload`],disabled:!H,action:()=>U(()=>E(`flush`))},{id:`user-manager`,capability:`users`,label:t(`palette.commands.userManager`),icon:x,tone:`blue`,keywords:[`users`,`grants`,`privileges`],disabled:!H,action:()=>U(()=>E(`user-manager`))},{id:`scratchpad`,label:t(`menu.tools.scratchpad`),icon:te,tone:`yellow`,keywords:[`scratchpad`,`sqlite`,`local`],pro:!0,action:()=>U(()=>{i().catch(W)})},{id:`federated`,label:t(`menu.tools.federated`),icon:je,tone:`mauve`,keywords:[`federated`,`cross`,`join`,`connections`],pro:!0,action:()=>U(()=>{l().catch(W)})},{id:`erd`,label:t(`menu.tools.viewErd`),icon:Ce,tone:`sky`,keywords:[`erd`,`diagram`,`relations`],disabled:!H,action:()=>U(Le)}]},{heading:t(`menu.settings.theme`),commands:f().map(e=>({id:`theme-${e.id}`,label:e.name,tone:`lavender`,keywords:[`theme`,`color`,`appearance`,`dark`,`light`,e.id],checked:fe===e.id,swatch:e,action:()=>U(()=>Ne(e.id))}))},{heading:t(`menu.settings.language`),commands:[`auto`,...N].map(e=>({id:`locale-${e}`,label:e===`auto`?t(`language.auto`,{name:t(`language.${M()}`)}):t(`language.${e}`),icon:Se,tone:`teal`,keywords:[`language`,`locale`,`i18n`,e],checked:Pe===e,action:()=>U(()=>Fe(e))}))},{heading:t(`menu.settings.title`),commands:[{id:`safety-settings`,label:t(`menu.settings.safety`),icon:Ae,tone:`yellow`,keywords:[`safety`,`settings`,`row limit`,`preferences`],action:()=>U(()=>E(`safety-settings`))}]},{heading:t(`menu.help.title`),commands:[{id:`documentation`,label:t(`menu.help.documentation`),icon:pe,tone:`blue`,keywords:[`docs`,`documentation`,`manual`,`help`],action:()=>U(()=>{window.open(T(),`_blank`,`noopener,noreferrer`)})},{id:`getting-started`,label:t(`menu.help.gettingStarted`),icon:Ee,tone:`green`,keywords:[`welcome`,`onboarding`,`sample`,`getting started`],action:()=>U(()=>D(!0))},{id:`terms`,label:t(`menu.help.terms`),icon:De,tone:`peach`,keywords:[`terms`,`privacy`,`legal`],action:()=>U(()=>E(`terms`))},{id:`about`,label:t(`menu.help.about`),icon:y,tone:`sky`,keywords:[`about`,`version`,`agent`],action:()=>U(()=>E(`about`))}]}];function ze(e){e||_()}let Be=Re.map(e=>({...e,commands:e.commands.filter(e=>!e.capability||ie[e.capability])})).filter(e=>e.commands.length>0);return(0,$.jsxs)(vt,{open:Ie,onOpenChange:ze,title:t(`palette.title`),description:t(`palette.description`),children:[(0,$.jsx)(yt,{placeholder:t(`palette.inputPlaceholder`)}),(0,$.jsxs)(bt,{className:`max-h-[60vh]`,children:[(0,$.jsx)(xt,{children:t(`palette.empty`)}),Be.map(e=>(0,$.jsx)(St,{heading:e.heading,children:e.commands.map(t=>(0,$.jsxs)(Ct,{value:`${e.heading} ${t.label}`,keywords:t.keywords,disabled:t.disabled,onSelect:t.action,children:[t.swatch?(0,$.jsx)(Et,{theme:t.swatch}):t.icon?(0,$.jsx)(t.icon,{className:A(`size-4`,Tt[t.tone])}):null,(0,$.jsx)(`span`,{className:`truncate`,children:t.label}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[t.pro&&(0,$.jsx)(a,{className:`ml-0`}),t.checked&&(0,$.jsx)(v,{className:`size-3.5 text-catppuccin-green`}),t.shortcut&&(0,$.jsx)(wt,{className:`ml-0`,children:t.shortcut})]})]},t.id))},e.heading))]})]})}export{Dt as QuickCommandPalette};
|
|
1
|
+
import{c as e,h as t,n,v as r}from"./ui-store-DfspmPOn.js";import{B as i,F as a,G as o,J as s,K as c,L as l,Q as u,U as d,W as f,Y as p,Z as m,at as ee,bt as h,dt as g,et as _,gt as v,it as te,lt as y,nt as b,q as x,rt as S,st as ne,tt as C,ut as w,z as T}from"./main-ot9WNZX1.js";import{a as E,f as D,l as O,m as k,o as A,s as j}from"./button--s6nUzD8.js";import{r as M,t as N}from"./i18n-gQOmt8le.js";import{_ as P,a as F,o as I,r as re,t as ie}from"./dist-CBYDYlja.js";import{t as L}from"./connection-store-DjSajhjh.js";import{n as ae}from"./query-store-yK1eqNW-.js";import{n as oe,r as se}from"./settings-store-CSRx4hwh.js";import{r as ce,s as le}from"./query-execution-C2muZJbT.js";import{t as ue}from"./use-engine-CwOU9o8-.js";import{a as de,n as R,o as z,r as B,t as fe}from"./dialog-CJoWJzRo.js";var pe=E(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),me=E(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),he=E(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),ge=E(`database-zap`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 15 21.84`,key:`14ibmq`}],[`path`,{d:`M21 5V8`,key:`1marbg`}],[`path`,{d:`M21 12L18 17H22L19 22`,key:`zafso`}],[`path`,{d:`M3 12A9 3 0 0 0 14.59 14.87`,key:`1y4wr8`}]]),_e=E(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ve=E(`file-spreadsheet`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]),ye=E(`git-compare`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`path`,{d:`M11 18H8a2 2 0 0 1-2-2V9`,key:`19pyzm`}]]),be=E(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),xe=E(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),Se=E(`languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ce=E(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),we=E(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),Te=E(`replace`,[[`path`,{d:`M14 4a1 1 0 0 1 1-1`,key:`dhj8ez`}],[`path`,{d:`M15 10a1 1 0 0 1-1-1`,key:`1mnyi5`}],[`path`,{d:`M21 4a1 1 0 0 0-1-1`,key:`sfs9ap`}],[`path`,{d:`M21 9a1 1 0 0 1-1 1`,key:`mp6qeo`}],[`path`,{d:`m3 7 3 3 3-3`,key:`x25e72`}],[`path`,{d:`M6 10V5a2 2 0 0 1 2-2h2`,key:`15xut4`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}]]),Ee=E(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),De=E(`scale`,[[`path`,{d:`M12 3v18`,key:`108xh3`}],[`path`,{d:`m19 8 3 8a5 5 0 0 1-6 0zV7`,key:`zcdpyk`}],[`path`,{d:`M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1`,key:`1yorad`}],[`path`,{d:`m5 8 3 8a5 5 0 0 1-6 0zV7`,key:`eua70x`}],[`path`,{d:`M7 21h10`,key:`1b0cd5`}]]),Oe=E(`scroll-text`,[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]),ke=E(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Ae=E(`shield-alert`,[[`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`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),je=E(`waypoints`,[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]),Me=E(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),V=r(t(),1),Ne=1,Pe=.9,Fe=.8,Ie=.17,H=.1,U=.999,W=.9999,Le=.99,Re=/[\\\/_+.#"@\[\(\{&]/,ze=/[\\\/_+.#"@\[\(\{&]/g,Be=/[\s-]/,Ve=/[\s-]/g;function He(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ne:Le;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=He(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ne:Re.test(e.charAt(l-1))?(d*=Fe,p=e.slice(i,l-1).match(ze),p&&i>0&&(d*=U**+p.length)):Be.test(e.charAt(l-1))?(d*=Pe,m=e.slice(i,l-1).match(Ve),m&&i>0&&(d*=U**+m.length)):(d*=Ie,i>0&&(d*=U**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=W)),(d<H&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=He(e,t,n,r,l+1,a+2,o),f*H>d&&(d=f*H)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Ue(e){return e.toLowerCase().replace(Ve,` `)}function We(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,He(e,t,Ue(e),Ue(t),0,0,{})}var G=`[cmdk-group=""]`,Ge=`[cmdk-group-items=""]`,Ke=`[cmdk-group-heading=""]`,qe=`[cmdk-item=""]`,Je=`${qe}:not([aria-disabled="true"])`,Ye=`cmdk-item-select`,K=`data-value`,Xe=(e,t,n)=>We(e,t,n),Ze=V.createContext(void 0),q=()=>V.useContext(Ze),Qe=V.createContext(void 0),$e=()=>V.useContext(Qe),et=V.createContext(void 0),tt=V.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),s=ft(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:ee=!1,vimBindings:h=!0,...g}=e,_=P(),v=P(),te=P(),y=V.useRef(null),b=mt();Y(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,x.emit()}},[u]),Y(()=>{b(6,E)},[]);let x=V.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)T(),C(),b(1,w);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(te);e?e.focus():(i=document.getElementById(_))==null||i.focus()}if(b(7,()=>{n.current.selectedItemId=D()?.id,x.emit()}),r||b(5,E),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}x.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),S=V.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,ne(t,r)),b(2,()=>{C(),x.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),b(3,()=>{T(),C(),n.current.value||w(),x.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=D();b(4,()=>{T(),t?.getAttribute(`id`)===e&&w(),x.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:_,inputId:te,labelId:v,listInnerRef:y}),[]);function ne(e,t){let r=s.current?.filter??Xe;return e?r(e,n.current.search,t):0}function C(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=y.current;O().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Ge);t?t.appendChild(e.parentElement===t?e:e.closest(`${Ge} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Ge} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=y.current?.querySelector(`${G}[${K}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function w(){let e=O().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(K);x.setState(`value`,e||void 0)}function T(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=ne(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function E(){var e;let t=D();t&&(t.parentElement?.firstChild===t&&((e=t.closest(G)?.querySelector(Ke))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function D(){return y.current?.querySelector(`${qe}[aria-selected="true"]`)}function O(){return Array.from(y.current?.querySelectorAll(Je)||[])}function k(e){let t=O()[e];t&&x.setState(`value`,t.getAttribute(K))}function A(e){var t;let n=D(),r=O(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&x.setState(`value`,a.getAttribute(K))}function M(e){let t=D()?.closest(G),n;for(;t&&!n;)t=e>0?ut(t,G):dt(t,G),n=t?.querySelector(Je);n?x.setState(`value`,n.getAttribute(K)):A(e)}let N=()=>k(O().length-1),F=e=>{e.preventDefault(),e.metaKey?N():e.altKey?M(1):A(1)},I=e=>{e.preventDefault(),e.metaKey?k(0):e.altKey?M(-1):A(-1)};return V.createElement(j.div,{ref:t,tabIndex:-1,...g,"cmdk-root":``,onKeyDown:e=>{var t;(t=g.onKeyDown)==null||t.call(g,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:h&&e.ctrlKey&&F(e);break;case`ArrowDown`:F(e);break;case`p`:case`k`:h&&e.ctrlKey&&I(e);break;case`ArrowUp`:I(e);break;case`Home`:e.preventDefault(),k(0);break;case`End`:e.preventDefault(),N();break;case`Enter`:{e.preventDefault();let t=D();if(t){let e=new Event(Ye);t.dispatchEvent(e)}}}}},V.createElement(`label`,{"cmdk-label":``,htmlFor:S.inputId,id:S.labelId,style:gt},c),Q(e,e=>V.createElement(Qe.Provider,{value:x},V.createElement(Ze.Provider,{value:S},e))))}),nt=V.forwardRef((e,t)=>{let n=P(),r=V.useRef(null),i=V.useContext(et),a=q(),o=ft(e),s=o.current?.forceMount??i?.forceMount;Y(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=pt(n,r,[e.value,e.children,r],e.keywords),l=$e(),u=Z(e=>e.value&&e.value===c.current),d=Z(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);V.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(Ye,f),()=>t.removeEventListener(Ye,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:ee,onSelect:h,forceMount:g,keywords:_,...v}=e;return V.createElement(j.div,{ref:D(r,t),...v,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),rt=V.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=P(),s=V.useRef(null),c=V.useRef(null),l=P(),u=q(),d=Z(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Y(()=>u.group(o),[]),pt(o,s,[e.value,e.heading,c]);let f=V.useMemo(()=>({id:o,forceMount:i}),[i]);return V.createElement(j.div,{ref:D(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&V.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Q(e,e=>V.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},V.createElement(et.Provider,{value:f},e))))}),it=V.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=V.useRef(null),a=Z(e=>!e.search);return!n&&!a?null:V.createElement(j.div,{ref:D(i,t),...r,"cmdk-separator":``,role:`separator`})}),at=V.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=$e(),o=Z(e=>e.search),s=Z(e=>e.selectedItemId),c=q();return V.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),V.createElement(j.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ot=V.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=V.useRef(null),o=V.useRef(null),s=Z(e=>e.selectedItemId),c=q();return V.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),V.createElement(j.div,{ref:D(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Q(e,e=>V.createElement(`div`,{ref:D(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),st=V.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return V.createElement(ie,{open:n,onOpenChange:r},V.createElement(I,{container:o},V.createElement(F,{"cmdk-overlay":``,className:i}),V.createElement(re,{"aria-label":e.label,"cmdk-dialog":``,className:a},V.createElement(tt,{ref:t,...s}))))}),ct=V.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?V.createElement(j.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),lt=V.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return V.createElement(j.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>V.createElement(`div`,{"aria-hidden":!0},e)))}),J=Object.assign(tt,{List:ot,Item:nt,Input:at,Group:rt,Separator:it,Dialog:st,Empty:ct,Loading:lt});function ut(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function dt(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function ft(e){let t=V.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?V.useEffect:V.useLayoutEffect;function X(e){let t=V.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=$e(),n=()=>e(t.snapshot());return V.useSyncExternalStore(t.subscribe,n,n)}function pt(e,t,n,r=[]){let i=V.useRef(),a=q();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(K,s),i.current=s}),i}var mt=()=>{let[e,t]=V.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function ht(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&V.isValidElement(t)?V.cloneElement(ht(t),{ref:t.ref},n(t.props.children)):n(t)}var gt={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=O();function _t({className:e,...t}){return(0,$.jsx)(J,{"data-slot":`command`,className:A(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function vt({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,...a}){return(0,$.jsxs)(fe,{...a,children:[(0,$.jsxs)(de,{className:`sr-only`,children:[(0,$.jsx)(z,{children:e}),(0,$.jsx)(B,{children:t})]}),(0,$.jsx)(R,{className:A(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,$.jsx)(_t,{className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function yt({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,$.jsx)(_,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(J.Input,{"data-slot":`command-input`,className:A(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function bt({className:e,...t}){return(0,$.jsx)(J.List,{"data-slot":`command-list`,className:A(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function xt({...e}){return(0,$.jsx)(J.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function St({className:e,...t}){return(0,$.jsx)(J.Group,{"data-slot":`command-group`,className:A(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Ct({className:e,...t}){return(0,$.jsx)(J.Item,{"data-slot":`command-item`,className:A(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function wt({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:A(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var Tt={sky:`text-catppuccin-sky`,blue:`text-catppuccin-blue`,green:`text-catppuccin-green`,teal:`text-catppuccin-teal`,mauve:`text-catppuccin-mauve`,lavender:`text-catppuccin-lavender`,peach:`text-catppuccin-peach`,yellow:`text-catppuccin-yellow`,red:`text-catppuccin-red`};function Et({theme:e}){let{background:t,blue:n,mauve:r,green:i}=e.colors;return(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 overflow-hidden rounded-sm border border-catppuccin-surface2`,children:[t,n,r,i].map((e,t)=>(0,$.jsx)(`span`,{className:`flex-1`,style:{backgroundColor:e}},t))})}function Dt(){let{t}=k(),{activeDialog:r,closeDialog:_,openDialog:E}=n(),D=n(e=>e.setWelcomeVisible),O=n(e=>e.setFooterMessage),{executeCurrentQuery:j,executeCurrentStatement:P,executeWholeScript:F,addNewQueryTab:I,disconnectActive:re}=c(),{capabilities:ie}=ue(),de=se(),R=L(e=>e.activeConnections.find(t=>t.id===e.activeConnectionId)),z=L(e=>e.activeConnectionId?e.transactionOpen[e.activeConnectionId]??!1:!1),B=L(e=>e.updateProfile),fe=d(e=>e.themeId),Ne=d(e=>e.setTheme),Pe=oe(e=>e.locale),Fe=oe(e=>e.setLocale),Ie=r===`quick-command`,H=R!==void 0,U=(0,V.useCallback)(e=>{_(),e()},[_]),W=(0,V.useCallback)(e=>O(e instanceof Error?e.message:String(e)),[O]),Le=()=>{let t=L.getState().activeConnectionId;t&&(o.getState().openERD(t),e(`erd_open`),ae.getState().setActiveQueryTab(t,`erd`))},Re=[{heading:t(`palette.groups.connection`),commands:[{id:`connect`,label:t(`palette.commands.connect`),icon:we,tone:`sky`,shortcut:`Alt+N`,keywords:[`connect`,`server`,`profile`,`login`],disabled:!de,action:()=>U(()=>E(`connect`))},{id:`disconnect`,label:t(`palette.commands.disconnect`),icon:s,tone:`red`,keywords:[`disconnect`,`close`],disabled:!H,action:()=>U(()=>{re()})},{id:`read-only`,label:t(`menu.connection.readOnly`),icon:ee,tone:`yellow`,keywords:[`read only`,`safety`,`guard`],disabled:!H,checked:R?.readOnly===!0,action:()=>U(()=>{R&&B(R.id,{readOnly:!R.readOnly})})},{id:`manual-transactions`,capability:`transactions`,label:t(`menu.connection.manualTransactions`),icon:ne,tone:`lavender`,keywords:[`transaction`,`manual`,`autocommit`],disabled:!H,checked:R?.transactionMode===`manual`,action:()=>U(()=>{R&&B(R.id,{transactionMode:R.transactionMode===`manual`?`auto`:`manual`})})},{id:`commit`,capability:`transactions`,label:t(`toolbar.commit`),icon:v,tone:`green`,keywords:[`commit`,`transaction`],disabled:!z||!R,action:()=>U(()=>{R&&ce(R.id).catch(W)})},{id:`rollback`,capability:`transactions`,label:t(`toolbar.rollback`),icon:p,tone:`peach`,keywords:[`rollback`,`transaction`,`undo`],disabled:!z||!R,action:()=>U(()=>{R&&le(R.id).catch(W)})}]},{heading:t(`palette.groups.query`),commands:[{id:`execute`,label:t(`palette.commands.executeQuery`),icon:S,tone:`green`,shortcut:`F9`,keywords:[`run`,`execute`,`sql`],disabled:!H,action:()=>U(()=>{j()})},{id:`execute-statement`,label:t(`menu.query.executeStatementAtCursor`),icon:he,tone:`green`,shortcut:`Ctrl+Enter`,keywords:[`run`,`statement`,`cursor`],disabled:!H,action:()=>U(()=>{P()})},{id:`execute-script`,label:t(`menu.query.executeWholeScript`),icon:Oe,tone:`teal`,shortcut:`Ctrl+Shift+Enter`,keywords:[`run`,`script`,`batch`],disabled:!H,action:()=>U(()=>{F()})},{id:`new-tab`,label:t(`palette.commands.newQueryTab`),icon:b,tone:`blue`,shortcut:`Alt+T`,keywords:[`new`,`tab`,`editor`],disabled:!H,action:()=>U(()=>I())},{id:`find-replace`,label:t(`menu.query.findReplace`),icon:Te,tone:`lavender`,keywords:[`find`,`replace`,`search`],disabled:!H,action:()=>U(()=>E(`find-replace`))},{id:`local-history`,label:t(`menu.query.localHistory`),icon:xe,tone:`mauve`,keywords:[`history`,`snapshot`,`undo`],disabled:!H,action:()=>U(()=>E(`local-history`))}]},{heading:t(`palette.groups.database`),commands:[{id:`create-db`,capability:`multipleDatabases`,label:t(`palette.commands.createDatabase`),icon:w,tone:`blue`,keywords:[`create`,`database`,`schema`],disabled:!H,action:()=>U(()=>E(`create-database`))},{id:`alter-db`,capability:`multipleDatabases`,label:t(`menu.database.alter`),icon:ge,tone:`blue`,keywords:[`alter`,`database`,`charset`],disabled:!H,action:()=>U(()=>E(`alter-database`))},{id:`copy-db`,capability:`multipleDatabases`,label:t(`menu.database.copy`),icon:g,tone:`sky`,keywords:[`copy`,`clone`,`database`],disabled:!H,action:()=>U(()=>E(`copy-database`))},{id:`schema-diff`,label:t(`menu.database.compare`),icon:ye,tone:`mauve`,keywords:[`compare`,`diff`,`schema`,`sync`],pro:!0,disabled:!H,action:()=>U(()=>E(`schema-diff`))},{id:`data-diff`,label:t(`menu.database.compareData`),icon:be,tone:`mauve`,keywords:[`compare`,`diff`,`data`,`rows`],pro:!0,disabled:!H,action:()=>U(()=>E(`data-diff`))}]},{heading:t(`palette.groups.table`),commands:[{id:`create-table`,label:t(`palette.commands.createTable`),icon:u,tone:`green`,keywords:[`create`,`table`],disabled:!H,action:()=>U(()=>E(`create-table`))},{id:`alter-table`,label:t(`palette.commands.alterTable`),icon:Me,tone:`yellow`,keywords:[`alter`,`table`,`column`],disabled:!H,action:()=>U(()=>E(`alter-table`))},{id:`duplicate-table`,label:t(`menu.table.duplicateStructure`),icon:me,tone:`teal`,keywords:[`duplicate`,`structure`,`table`],disabled:!H,action:()=>U(()=>E(`duplicate-table-structure`))}]},{heading:t(`menu.export.title`),commands:[{id:`export-csv`,label:t(`menu.export.csv`),icon:ve,tone:`green`,keywords:[`export`,`csv`,`excel`],disabled:!H,action:()=>U(()=>E(`export-csv`))},{id:`export-html`,label:t(`menu.export.schemaHtml`),icon:_e,tone:`peach`,keywords:[`export`,`html`,`schema`,`documentation`],disabled:!H,action:()=>U(()=>E(`export-html`))}]},{heading:t(`palette.groups.tools`),commands:[{id:`process-list`,capability:`processList`,label:t(`palette.commands.processList`),icon:h,tone:`red`,keywords:[`process`,`kill`,`connections`],disabled:!H,action:()=>U(()=>E(`process-list`))},{id:`variables`,capability:`variables`,label:t(`palette.commands.serverVariables`),icon:ke,tone:`lavender`,keywords:[`variables`,`server`,`settings`],disabled:!H,action:()=>U(()=>E(`variables`))},{id:`status`,capability:`status`,label:t(`palette.commands.serverStatus`),icon:m,tone:`teal`,keywords:[`status`,`server`,`metrics`],disabled:!H,action:()=>U(()=>E(`status`))},{id:`flush`,capability:`flush`,label:t(`palette.commands.flush`),icon:C,tone:`peach`,keywords:[`flush`,`cache`,`reload`],disabled:!H,action:()=>U(()=>E(`flush`))},{id:`user-manager`,capability:`users`,label:t(`palette.commands.userManager`),icon:x,tone:`blue`,keywords:[`users`,`grants`,`privileges`],disabled:!H,action:()=>U(()=>E(`user-manager`))},{id:`scratchpad`,label:t(`menu.tools.scratchpad`),icon:te,tone:`yellow`,keywords:[`scratchpad`,`sqlite`,`local`],pro:!0,action:()=>U(()=>{i().catch(W)})},{id:`federated`,label:t(`menu.tools.federated`),icon:je,tone:`mauve`,keywords:[`federated`,`cross`,`join`,`connections`],pro:!0,action:()=>U(()=>{l().catch(W)})},{id:`erd`,label:t(`menu.tools.viewErd`),icon:Ce,tone:`sky`,keywords:[`erd`,`diagram`,`relations`],disabled:!H,action:()=>U(Le)}]},{heading:t(`menu.settings.theme`),commands:f().map(e=>({id:`theme-${e.id}`,label:e.name,tone:`lavender`,keywords:[`theme`,`color`,`appearance`,`dark`,`light`,e.id],checked:fe===e.id,swatch:e,action:()=>U(()=>Ne(e.id))}))},{heading:t(`menu.settings.language`),commands:[`auto`,...N].map(e=>({id:`locale-${e}`,label:e===`auto`?t(`language.auto`,{name:t(`language.${M()}`)}):t(`language.${e}`),icon:Se,tone:`teal`,keywords:[`language`,`locale`,`i18n`,e],checked:Pe===e,action:()=>U(()=>Fe(e))}))},{heading:t(`menu.settings.title`),commands:[{id:`safety-settings`,label:t(`menu.settings.safety`),icon:Ae,tone:`yellow`,keywords:[`safety`,`settings`,`row limit`,`preferences`],action:()=>U(()=>E(`safety-settings`))}]},{heading:t(`menu.help.title`),commands:[{id:`documentation`,label:t(`menu.help.documentation`),icon:pe,tone:`blue`,keywords:[`docs`,`documentation`,`manual`,`help`],action:()=>U(()=>{window.open(T(),`_blank`,`noopener,noreferrer`)})},{id:`getting-started`,label:t(`menu.help.gettingStarted`),icon:Ee,tone:`green`,keywords:[`welcome`,`onboarding`,`sample`,`getting started`],action:()=>U(()=>D(!0))},{id:`terms`,label:t(`menu.help.terms`),icon:De,tone:`peach`,keywords:[`terms`,`privacy`,`legal`],action:()=>U(()=>E(`terms`))},{id:`about`,label:t(`menu.help.about`),icon:y,tone:`sky`,keywords:[`about`,`version`,`agent`],action:()=>U(()=>E(`about`))}]}];function ze(e){e||_()}let Be=Re.map(e=>({...e,commands:e.commands.filter(e=>!e.capability||ie[e.capability])})).filter(e=>e.commands.length>0);return(0,$.jsxs)(vt,{open:Ie,onOpenChange:ze,title:t(`palette.title`),description:t(`palette.description`),children:[(0,$.jsx)(yt,{placeholder:t(`palette.inputPlaceholder`)}),(0,$.jsxs)(bt,{className:`max-h-[60vh]`,children:[(0,$.jsx)(xt,{children:t(`palette.empty`)}),Be.map(e=>(0,$.jsx)(St,{heading:e.heading,children:e.commands.map(t=>(0,$.jsxs)(Ct,{value:`${e.heading} ${t.label}`,keywords:t.keywords,disabled:t.disabled,onSelect:t.action,children:[t.swatch?(0,$.jsx)(Et,{theme:t.swatch}):t.icon?(0,$.jsx)(t.icon,{className:A(`size-4`,Tt[t.tone])}):null,(0,$.jsx)(`span`,{className:`truncate`,children:t.label}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[t.pro&&(0,$.jsx)(a,{className:`ml-0`}),t.checked&&(0,$.jsx)(v,{className:`size-3.5 text-catppuccin-green`}),t.shortcut&&(0,$.jsx)(wt,{className:`ml-0`,children:t.shortcut})]})]},t.id))},e.heading))]})]})}export{Dt as QuickCommandPalette};
|