planche 0.8.0 → 0.8.2
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-CC7jb8_P.js → AboutDialog-3SX5EV22.js} +1 -1
- package/app/assets/AiSettingsDialog-DIhTViGS.js +1 -0
- package/app/assets/ConnectDialog-B9B2pmBd.js +1 -0
- package/app/assets/CopyDatabaseDialog-DV7zQRd2.js +1 -0
- package/app/assets/{CopyTableDialog-mjYPJxx8.js → CopyTableDialog-1A2wKslg.js} +1 -1
- package/app/assets/{CreateDatabaseDialog-K9LU6SFa.js → CreateDatabaseDialog-CLiJJQgN.js} +1 -1
- package/app/assets/CreateSchemaDialog-DD_28Eub.js +1 -0
- package/app/assets/DataDiffDialog-hIvWJqmh.js +1 -0
- package/app/assets/{DownloadToCSVDialog-cWxA73M8.js → DownloadToCSVDialog-CLpJ8bDP.js} +2 -2
- package/app/assets/EditSchemaDialog-B8ONt2sC.js +2 -0
- package/app/assets/FindReplaceDialog-H1fQsF0u.js +1 -0
- package/app/assets/{FlushDialog-C1ahiGEa.js → FlushDialog-Cu_3tGcK.js} +1 -1
- package/app/assets/{GeneralSettingsDialog-CSoV6bfv.js → GeneralSettingsDialog-xgxhF9Gn.js} +1 -1
- package/app/assets/GroupByDialog-BCDcazzJ.js +1 -0
- package/app/assets/LicenseDialog-DQHhxdtR.js +1 -0
- package/app/assets/{LinkColumnDialog-Dtz38QJy.js → LinkColumnDialog-V430TeVp.js} +1 -1
- package/app/assets/LocalHistoryDialog-BA_7Fo9B.js +1 -0
- package/app/assets/McpSetupDialog-BFoqHq0W.js +1 -0
- package/app/assets/ProcessListDialog-C580troj.js +1 -0
- package/app/assets/QuerySettingsDialog-CxaKHHfo.js +1 -0
- package/app/assets/QuickCommandPalette-DI4_5uY6.js +1 -0
- package/app/assets/RowFormDialog-DXK8CWzh.js +2 -0
- package/app/assets/{SafetySettingsDialog-D4p0vAK7.js → SafetySettingsDialog-D5yLNWsA.js} +1 -1
- package/app/assets/{SchemaDiffDialog-BIxIvBGm.js → SchemaDiffDialog-DsXAMyhh.js} +2 -2
- package/app/assets/{SchemaToHTMLDialog-CalQNcBO.js → SchemaToHTMLDialog-CDrt2YXj.js} +2 -2
- package/app/assets/StatusDialog-CnIJeQpO.js +1 -0
- package/app/assets/SyncDialog-DXLRjtc3.js +1 -0
- package/app/assets/{TermsDialog-CMGa972R.js → TermsDialog-D4K_QWCp.js} +1 -1
- package/app/assets/{UserAddDialog-D_Ntb9Oc.js → UserAddDialog-DPBPQ90W.js} +1 -1
- package/app/assets/UserManagerDialog-_slF5p1Y.js +1 -0
- package/app/assets/VariablesDialog-IdnBQyHZ.js +1 -0
- package/app/assets/connection-store-D-Lp5EFj.js +1 -0
- package/app/assets/contract-neLPq0_M.js +1 -0
- package/app/assets/database-CfYjCIA2.js +1 -0
- package/app/assets/de-U48bWKTK.js +2 -0
- package/app/assets/{engine-s5WfEr4n.js → engine-Ja9hkC7I.js} +1 -1
- package/app/assets/{error-hints-AQZemZKj.js → error-hints-9kGurk72.js} +1 -1
- package/app/assets/fr-B_almVyv.js +2 -0
- package/app/assets/i18n-BQcNT-sS.js +2 -0
- package/app/assets/{ja-BKUEaPbL.js → ja-BS_mc_Gc.js} +2 -2
- package/app/assets/ko-DgeKS5Bf.js +2 -0
- package/app/assets/main-BwM1zx0B.js +959 -0
- package/app/assets/main-D2x95iIF.css +2 -0
- package/app/assets/{pro-upsell-akqEMS8_.js → pro-upsell-BH-enstO.js} +1 -1
- package/app/assets/pro-usage-D4Iv3hEs.js +1 -0
- package/app/assets/query-execution-_bzhSmJm.js +2 -0
- package/app/assets/{query-store-dYiA8oM5.js → query-store-Cf_KUo80.js} +1 -1
- package/app/assets/{select-DwgCtoqv.js → select-CtfiGpCP.js} +1 -1
- package/app/assets/{settings-controls-DrW8_eiX.js → settings-controls-DyukG7E2.js} +1 -1
- package/app/assets/settings-store-DzQ3BP5e.js +1 -0
- package/app/assets/table-copy-JytHH7NG.js +1 -0
- package/app/assets/tunneling-C--CCnwy.js +6 -0
- package/app/assets/zh-CoZStBZ6.js +2 -0
- package/app/index.html +15 -16
- package/package.json +1 -1
- package/app/assets/AiSettingsDialog-1t0_9610.js +0 -1
- package/app/assets/ConnectDialog-C8novVo3.js +0 -1
- package/app/assets/CopyDatabaseDialog-BZaC4BRf.js +0 -1
- package/app/assets/CreateSchemaDialog-IMU6kUwh.js +0 -1
- package/app/assets/DataDiffDialog-DcPx4VLE.js +0 -1
- package/app/assets/EditSchemaDialog-UuUlGY4B.js +0 -2
- package/app/assets/FindReplaceDialog-BphY4fYD.js +0 -1
- package/app/assets/GroupByDialog-CO8in38J.js +0 -1
- package/app/assets/LicenseDialog-d17TldUe.js +0 -1
- package/app/assets/LocalHistoryDialog-B8WdxxF7.js +0 -1
- package/app/assets/ProcessListDialog-D0hVqOEu.js +0 -1
- package/app/assets/QuerySettingsDialog-C-chLD8U.js +0 -1
- package/app/assets/QuickCommandPalette-BhTxG9s-.js +0 -1
- package/app/assets/RowFormDialog-MZivb9nJ.js +0 -2
- package/app/assets/StatusDialog-C49Nlkmj.js +0 -1
- package/app/assets/SyncDialog-DgjppEJu.js +0 -1
- package/app/assets/UserManagerDialog-BTOhBvd9.js +0 -1
- package/app/assets/VariablesDialog-BTVi_JEh.js +0 -1
- package/app/assets/connection-store-BnO3WqEO.js +0 -1
- package/app/assets/contract-W8-jEnEI.js +0 -1
- package/app/assets/database-BvWJHB7q.js +0 -1
- package/app/assets/de-DPmJYeTi.js +0 -2
- package/app/assets/fr-BLVbrMir.js +0 -2
- package/app/assets/i18n-D0mAAGED.js +0 -2
- package/app/assets/ko-XOd5LtL3.js +0 -2
- package/app/assets/license-store-D_XwbbCs.js +0 -1
- package/app/assets/main-C-Gt0g0g.js +0 -958
- package/app/assets/main-C3ej0FPT.css +0 -2
- package/app/assets/pro-gate-DZATEYdR.js +0 -1
- package/app/assets/pro-usage-C661VD02.js +0 -1
- package/app/assets/query-execution-CZvQYEUq.js +0 -2
- package/app/assets/settings-store-BBVuUVjA.js +0 -1
- package/app/assets/table-copy-LtbDgIEc.js +0 -1
- package/app/assets/tunneling-BPoIRxJA.js +0 -1
- package/app/assets/zh-DNy8t_lA.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./main-
|
|
1
|
+
import{t as e}from"./main-BwM1zx0B.js";import{n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-FBpgH0QJ.js";var d=n(),f=`https://planche.dev`,p=`/third-party-notices.txt`;function m(){let n=t(e=>e.activeDialog),m=t(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)(e,{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{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n,w as r}from"./main-BwM1zx0B.js";import{h as i,n as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-CtfiGpCP.js";import{i as m,n as h}from"./settings-store-DzQ3BP5e.js";import{b as g,c as _,d as v}from"./tunneling-C--CCnwy.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(i(),1),E=o(),D={autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0};function O(){let{t:e}=s(),[i,a]=(0,T.useState)(null),[o,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(`anthropic`),[S,C]=(0,T.useState)(``),[w,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(``),[j,M]=(0,T.useState)(!1),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(!1),[L,R]=(0,T.useState)(!1),[z,B]=(0,T.useState)(null),V=h(e=>e.setAiPreferences),H=(0,T.useCallback)(()=>{v().then(e=>{a(e);let t=h.getState().aiPreferences,n=e.storage!==`none`;x(n?e.provider:t.provider),C(n?e.model:t.model),O((n?e.baseUrl:t.baseUrl)??``),M(n?e.storage===`file`:t.remember),P(e.clis??[]),I(e.anthropicProfile===!0)}).catch(()=>y(!0))},[]);(0,T.useEffect)(H,[H]);let U=(0,T.useCallback)(e=>{x(e),C(t=>m(t,e))},[]),W=(0,T.useCallback)(()=>{R(!0),B(null),g({provider:b,model:S.trim()||void 0,baseUrl:w.trim()||void 0,key:k,remember:j}).then(t=>{a(t),A(``),V({provider:b,model:S.trim()||t.model,baseUrl:w.trim(),remember:j}),B(e(`settings.ai.saved`)),r()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[b,S,w,k,j,V,e]),G=(0,T.useCallback)(()=>{R(!0),B(null),_().then(e=>{a(e),A(``),r()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[]);if(o)return(0,E.jsx)(`p`,{className:`rounded-md border p-3 text-xs text-muted-foreground`,children:e(`settings.ai.unreachable`)});if(!i)return null;let K=i.fromEnvironment,q=b===`cli`||b===`anthropic-profile`;return(0,E.jsxs)(`div`,{className:`grid gap-3 rounded-md border p-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.intro`)}),(0,E.jsx)(`p`,{className:`text-xs`,children:i.storage===`environment`?e(`settings.ai.configuredEnv`):i.storage===`file`?e(`settings.ai.configuredFile`,{path:i.path}):i.storage===`session`?e(`settings.ai.configuredSession`):e(`settings.ai.none`)}),!K&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-provider`,className:`text-sm font-medium`,children:e(`settings.ai.provider`)}),(0,E.jsxs)(p,{value:b,onValueChange:e=>U(e),children:[(0,E.jsx)(u,{id:`ai-provider`,children:(0,E.jsx)(l,{})}),(0,E.jsxs)(d,{children:[(0,E.jsx)(f,{value:`anthropic`,children:`Anthropic`}),(0,E.jsx)(f,{value:`anthropic-profile`,children:e(`settings.ai.profile`)}),(0,E.jsx)(f,{value:`openai`,children:e(`settings.ai.openaiCompatible`)}),(0,E.jsx)(f,{value:`gemini`,children:`Google Gemini`}),(0,E.jsx)(f,{value:`cli`,children:e(`settings.ai.cli`)})]})]})]}),b===`cli`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.cliHint`)}),N.length===0?(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.cliNone`)}):(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-cli`,className:`text-sm font-medium`,children:e(`settings.ai.cliCommand`)}),(0,E.jsxs)(p,{value:N.includes(S)?S:N[0],onValueChange:C,children:[(0,E.jsx)(u,{id:`ai-cli`,children:(0,E.jsx)(l,{})}),(0,E.jsx)(d,{children:N.map(e=>(0,E.jsx)(f,{value:e,children:e},e))})]})]})]}):(0,E.jsxs)(`div`,{className:`grid gap-3`,children:[b===`anthropic-profile`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.profileHint`)}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.profileNone`)})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(t,{htmlFor:`ai-model`,className:`text-sm font-medium`,children:e(`settings.ai.model`)}),(0,E.jsx)(n,{id:`ai-model`,value:S,onChange:e=>C(e.target.value),spellCheck:!1,...D})]})]}),b===`openai`&&(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,E.jsx)(t,{htmlFor:`ai-base-url`,className:`text-sm font-medium`,children:e(`settings.ai.baseUrl`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.baseUrlHint`)})]}),(0,E.jsx)(n,{id:`ai-base-url`,value:w,onChange:e=>O(e.target.value),placeholder:`https://api.openai.com/v1`,spellCheck:!1,...D})]}),q||(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(t,{htmlFor:`ai-key`,className:`text-sm font-medium`,children:e(`settings.ai.key`)}),(0,E.jsx)(n,{id:`ai-key`,type:`password`,value:k,onChange:e=>A(e.target.value),spellCheck:!1,placeholder:i.configured?`••••••••`:``,...D,autoComplete:`new-password`}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.keyHint`)})]}),q||(0,E.jsxs)(`label`,{htmlFor:`ai-remember`,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,E.jsx)(`input`,{id:`ai-remember`,type:`checkbox`,checked:j,onChange:e=>M(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,E.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings.ai.remember`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.rememberHint`,{path:i.path})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(c,{size:`sm`,onClick:W,disabled:L||(b===`cli`?N.length===0:!q&&!k.trim()),children:e(`settings.ai.save`)}),i.configured&&(0,E.jsx)(c,{size:`sm`,variant:`ghost`,onClick:G,disabled:L,children:e(`settings.ai.forget`)}),z&&(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z})]})]})]})}function k(){let e=a(e=>e.activeDialog),t=a(e=>e.closeDialog),{t:n}=s();return(0,E.jsx)(w,{open:e===`ai-settings`,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(x,{className:`sm:max-w-[560px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:n(`settings.ai.title`)}),(0,E.jsx)(C,{children:n(`settings.ai.description`)})]}),(0,E.jsx)(O,{}),(0,E.jsx)(b,{children:(0,E.jsx)(c,{onClick:t,children:n(`settings.done`)})})]})})}export{k as AiSettingsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,B as n,C as r,F as i,L as a,S as o,a as s,b as c,c as l,ht as u,i as d,it as f,k as p,l as m,n as h,o as g,r as _,s as v,u as y,v as b,x,y as S}from"./main-BwM1zx0B.js";import{h as C,n as w,t as T}from"./ui-store-5IssrgmG.js";import{l as E,m as D,t as O}from"./button-B2EsmMJs.js";import{a as k,i as A,n as j,r as M,t as N}from"./select-CtfiGpCP.js";import{t as P}from"./connection-store-D-Lp5EFj.js";import{E as F,O as I,T as L,a as R,f as ee,m as te}from"./tunneling-C--CCnwy.js";import{n as ne}from"./query-store-Cf_KUo80.js";import{S as re,d as z,g as ie,i as ae,l as B,r as oe}from"./database-CfYjCIA2.js";import{n as V,t as H}from"./dbms-BwnatOMe.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./dialog-FBpgH0QJ.js";var U=e(C(),1),W=new Set([`postgres:`,`postgresql:`]);function G(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(!W.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 K=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function q(e,t){let n;try{let t=new URL(e);if(!K.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var J=E(),Y=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],X={enabled:!1,host:``,port:22,user:``,auth:`key`};function Z({label:e,htmlFor:t,children:n}){return(0,J.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,J.jsx)(l,{htmlFor:t,children:e}),n]})}function fe({value:e,onChange:r}){let{t:i}=D();function o(t,n){r({...e,[t]:n})}let[s,c]=(0,U.useState)([]),l=e.dbms===`d1`?e.devUrl??``:``;(0,U.useEffect)(()=>{if(!l){c([]);return}let e=new AbortController,t=setTimeout(()=>{q(l,e.signal).then(c)},300);return()=>{clearTimeout(t),e.abort()}},[l]);let u=e.dbms===`sqlite`,d=e.transport??`browser`,f=u&&d===`browser`,h=F.has(e.dbms),_=e.dbms===`d1`,b=e.dbms===`do`,x=H.find(t=>t.id===e.dbms)?.capabilities,S=e.ssh??X,[C,w]=(0,U.useState)(``),T=C.trim()===``?`empty`:G(C)?`applied`:`invalid`,E=e.dbms===`supabase`&&e.port===6543;function P(t){w(t);let n=G(t);n&&r({...e,host:n.host??e.host,port:n.port??H.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:n.user??e.user,pass:n.pass??e.pass,database:n.database??e.database})}function L(t){r({...e,ssh:{...S,...t}})}async function R(e){e&&L({privateKey:await e.text(),privateKeyName:e.name})}return(0,J.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,J.jsx)(Z,{label:i(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,J.jsx)(m,{id:`conn-hostName`,placeholder:i(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>o(`hostName`,e.target.value)})}),(0,J.jsx)(Z,{label:i(`connection.form.dataSource`),children:(0,J.jsxs)(N,{value:e.dbms,onValueChange:t=>{let n=H.find(e=>e.id===t);if(!n)return;let i=n.id,a=F.has(i)||i===`d1`||i===`do`;w(``),r({...e,dbms:i,transactionMode:n.capabilities.transactions?e.transactionMode:`auto`,port:n.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||h||_||b?v(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!h&&!_&&!b?e.database:g(i)??e.database})},children:[(0,J.jsx)(A,{id:`conn-dbms`,className:`w-full`,children:(0,J.jsx)(k,{})}),(0,J.jsx)(j,{children:H.map(e=>(0,J.jsx)(M,{value:e.id,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(y,{dbms:e.id}),e.label]})},e.id))})]})}),h&&(0,J.jsx)(Z,{label:i(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(m,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,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:C,onChange:e=>P(e.target.value)}),(0,J.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${T===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:i(T===`invalid`?`connection.form.connectionStringInvalid`:T===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),u&&(0,J.jsxs)(Z,{label:i(`connection.form.openVia`),children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:d===`browser`,onChange:()=>o(`transport`,`browser`),className:`accent-primary`}),i(`connection.form.viaBrowser`)]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:d===`tunnel`,onChange:()=>o(`transport`,`tunnel`),className:`accent-primary`}),i(`connection.form.viaAgent`)]})]}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(d===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),f?(0,J.jsx)(Z,{label:i(`connection.form.databaseFile`),children:(0,J.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,J.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{B(e.id),o(`file`,``)},children:i(`connection.form.changeFile`)})]}):(0,J.jsx)(`p`,{children:i(`connection.form.filePickerHint`)}),(0,J.jsx)(`p`,{className:`mt-1`,children:i(`connection.form.fileRememberedHint`)})]})}):null,!f&&(0,J.jsx)(Z,{label:i(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,J.jsx)(m,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:i(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>o(`authToken`,e.target.value.trim())})}),f?null:b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,J.jsx)(m,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>o(`devUrl`,e.target.value.trim())})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.doHint`)}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.doLimitsHint`)})]}):_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,J.jsx)(m,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>o(`devUrl`,e.target.value.trim())})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.d1DevUrlHint`)}),(0,J.jsx)(Z,{label:i(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,J.jsx)(m,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>o(`accountId`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:i(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:s.length>0?(0,J.jsxs)(N,{value:e.databaseId??``,onValueChange:e=>o(`databaseId`,e),children:[(0,J.jsx)(A,{id:`conn-d1-database`,children:(0,J.jsx)(k,{placeholder:i(`connection.form.d1PickDatabase`)})}),(0,J.jsx)(j,{children:s.map(e=>(0,J.jsxs)(M,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,J.jsx)(m,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>o(`databaseId`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:i(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(m,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>o(`pass`,e.target.value.trim())}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:i(`connection.form.savePasswordHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>o(`savePassword`,e.target.checked)}),i(`connection.form.savePassword`)]})]})}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.d1Hint`)}),(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.d1LimitsHint`)})]}):u?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,J.jsx)(m,{id:`conn-file`,placeholder:i(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>o(`file`,e.target.value)})}),(0,J.jsx)(Z,{label:i(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>o(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`connection.form.createIfMissingHint`)})]})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.host`),htmlFor:`conn-host`,children:(0,J.jsx)(m,{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=>o(`host`,e.target.value)})}),(0,J.jsx)(Z,{label:i(`connection.form.port`),htmlFor:`conn-port`,children:(0,J.jsx)(m,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>o(`port`,Number(t.target.value)||H.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),E&&(0,J.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:i(`connection.form.supabasePoolerWarning`)}),(I(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,J.jsx)(Z,{label:e.dbms===`oracle`?i(`connection.form.serviceName`):i(`connection.form.database`),htmlFor:`conn-database`,children:(0,J.jsx)(m,{id:`conn-database`,placeholder:g(e.dbms),value:e.database??``,onChange:e=>o(`database`,e.target.value.trim())})}),(0,J.jsx)(Z,{label:i(`connection.form.user`),htmlFor:`conn-user`,children:(0,J.jsx)(m,{id:`conn-user`,autoComplete:`off`,placeholder:v(e.dbms),value:e.user,onChange:e=>o(`user`,e.target.value)})}),(0,J.jsx)(Z,{label:i(`connection.form.password`),htmlFor:`conn-pass`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(m,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>o(`pass`,e.target.value)}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:i(`connection.form.savePasswordHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>o(`savePassword`,e.target.checked)}),i(`connection.form.savePassword`)]})]})}),h&&(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.managedTlsHint`)}),!h&&e.dbms!==`oracle`&&(0,J.jsx)(Z,{label:i(`connection.form.tls`),children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>o(`ssl`,e.target.checked),className:`size-4 accent-primary`}),i(`connection.form.tlsEnable`)]}),(0,J.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:i(`connection.form.tlsVerifyHint`),children:[(0,J.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>o(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),i(`connection.form.tlsVerify`)]})]})}),!h&&(0,J.jsx)(Z,{label:i(`connection.form.charset`),children:(0,J.jsxs)(N,{value:e.charset,onValueChange:e=>o(`charset`,e),children:[(0,J.jsx)(A,{className:`w-full`,children:(0,J.jsx)(k,{})}),(0,J.jsx)(j,{children:Y.map(e=>(0,J.jsx)(M,{value:e,children:e},e))})]})})]}),!u&&!h&&!_&&!b&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[i(`connection.form.ssh`),(0,J.jsx)(n,{className:`ml-2`})]}),(0,J.jsx)(Z,{label:i(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:S.enabled,onChange:e=>{(!e.target.checked||a(`ssh_tunnel`))&&L({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`connection.form.sshTunnelHint`)})]})}),S.enabled&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(m,{id:`conn-ssh-host`,placeholder:i(`connection.form.sshHostPlaceholder`),value:S.host,onChange:e=>L({host:e.target.value.trim()})}),(0,J.jsx)(m,{"aria-label":i(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:S.port,onChange:e=>L({port:Number(e.target.value)||22})})]})}),(0,J.jsx)(Z,{label:i(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,J.jsx)(m,{id:`conn-ssh-user`,placeholder:i(`connection.form.sshUserPlaceholder`),value:S.user,onChange:e=>L({user:e.target.value.trim()})})}),(0,J.jsx)(Z,{label:i(`connection.form.sshAuth`),children:(0,J.jsxs)(N,{value:S.auth,onValueChange:e=>L({auth:e}),children:[(0,J.jsx)(A,{className:`w-full`,children:(0,J.jsx)(k,{})}),(0,J.jsxs)(j,{children:[(0,J.jsx)(M,{value:`key`,children:i(`connection.form.sshAuthKey`)}),(0,J.jsx)(M,{value:`password`,children:i(`connection.form.sshAuthPassword`)}),(0,J.jsx)(M,{value:`agent`,children:i(`connection.form.sshAuthAgent`)})]})]})}),S.auth===`password`&&(0,J.jsx)(Z,{label:i(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,J.jsx)(m,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:S.password??``,onChange:e=>L({password:e.target.value})})}),S.auth===`key`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{label:i(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,J.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{R(e.target.files?.[0]),e.target.value=``}}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:S.privateKey?i(`connection.form.changeFile`):i(`connection.form.sshKeyPick`)}),(0,J.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:S.privateKeyName,children:S.privateKey?S.privateKeyName||i(`connection.form.sshKeyLoaded`):i(`connection.form.sshKeyHint`)})]})}),(0,J.jsx)(Z,{label:i(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,J.jsx)(m,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:i(`connection.form.sshPassphrasePlaceholder`),value:S.passphrase??``,onChange:e=>L({passphrase:e.target.value})})})]}),S.auth===`agent`&&(0,J.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.sshAuthAgentHint`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.sshTargetHint`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:i(`connection.form.sshSecretsHint`)})]})]}),(0,J.jsx)(Z,{label:i(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,J.jsx)(`div`,{className:`flex items-center`,children:(0,J.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>o(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,J.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:i(`connection.form.safety`)}),(0,J.jsx)(Z,{label:i(`connection.form.environment`),children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[p.map(n=>{let r=(e.environmentColor??`none`)===n.id;return(0,J.jsx)(`button`,{type:`button`,title:t(n.id),"aria-label":t(n.id),"aria-pressed":r,onClick:()=>o(`environmentColor`,n.id),className:`size-6 rounded-full border-2 transition-transform ${r?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:n.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:n.hex}},n.id)}),(0,J.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:i(`connection.form.environmentHint`)})]})}),(0,J.jsx)(Z,{label:i(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>o(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`connection.form.readOnlyHint`)})]})}),x?.transactions!==!1&&(0,J.jsx)(Z,{label:i(`connection.form.transactions`),children:(0,J.jsxs)(N,{value:e.transactionMode??`auto`,onValueChange:e=>o(`transactionMode`,e),children:[(0,J.jsx)(A,{className:`w-full`,children:(0,J.jsx)(k,{})}),(0,J.jsxs)(j,{children:[(0,J.jsx)(M,{value:`auto`,children:i(`connection.form.txAuto`)}),(0,J.jsx)(M,{value:`manual`,children:i(`connection.form.txManual`)})]})]})})]})}function Q(){let{t:e}=D(),{activeDialog:t,closeDialog:n,showMessage:a}=w(),[l,p]=(0,U.useState)(!1),{savedConnections:m,addSavedConnection:g,updateSavedConnection:v,deleteSavedConnection:C,openConnection:E}=P(),k=T(`connect`)?.profileId,[A,j]=(0,U.useState)(()=>k??null),[M,N]=(0,U.useState)(()=>{let e=k?m.find(e=>e.id===k):void 0;return e?{...e}:null}),F=t===`connect`,[I,B]=(0,U.useState)(null),[H,W]=(0,U.useState)(null),G=i(e=>e.url),K=i(e=>e.token);(0,U.useEffect)(()=>{if(!F)return;let e=!1;return(async()=>{try{let t=await R();if(e||t.state!==`online`||!t.gateway){e||B(null);return}let n=await ee();e||(B({name:n.gateway,profiles:n.profiles}),W(null))}catch(t){e||W(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[F,G,K]);function q(t){let n=m.find(e=>e.gatewayProfile===t.name);if(n){X(n);return}let r=_(t);g(r),X(r),w.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function Y(e){e||(n(),j(null),N(null))}function X(e){j(e.id),N({...e})}function Z(e){N(e),v(e.id,e)}function Q(){let e=s();g(e),j(e.id),N(e)}function pe(){A&&(C(A),j(null),N(null))}let[me,$]=(0,U.useState)(!1),he=ne(e=>e.addQueryTab);function ge(t){let r=P.getState().activeConnections.some(e=>e.id===t.id);if(E(t),re.getState().removeTree(t.id),r){n(),j(null),N(null);return}he(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),n(),j(null),N(null)}async function _e(t){let n=await oe(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};v(t.id,{file:n.fileName}),ge(r),P.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?w.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?w.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&w.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function ve(t,n){try{return await n(t)}catch(r){let i=te(r);if(!i||!(`ssh`in t)||!t.ssh||!await w.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function ye(){if(M){$(!0);try{if(z(M)===`browser`){await _e(M);return}let t=await ve(L(M),e=>ae(e,M.authToken||void 0));t.success?ge({...M,serverConnectionId:t.connectionId}):a({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){a({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{$(!1)}}}async function be(){if(M){if(z(M)===`browser`){a({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}p(!0);try{let t=await ve(L(M),e=>ie(e,M.authToken||void 0));t.success?a({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):a({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){a({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{p(!1)}}}return(0,J.jsx)(de,{open:F,onOpenChange:Y,children:(0,J.jsxs)(le,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,J.jsx)(se,{children:(0,J.jsx)(ue,{children:e(`connection.dialog.title`)})}),(0,J.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,J.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,J.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,J.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(I||H)&&(0,J.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,J.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),I?` — ${I.name}`:``]}),H&&(0,J.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:H})}),I?.profiles.map(t=>(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,J.jsx)(y,{dbms:h[t.driver],className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:t.name}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,J.jsx)(O,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>q(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,J.jsx)(f,{className:`h-full`,children:(0,J.jsxs)(b,{className:`table-fixed`,children:[(0,J.jsx)(o,{children:(0,J.jsxs)(r,{children:[(0,J.jsx)(x,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,J.jsx)(x,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,J.jsx)(x,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,J.jsx)(S,{children:m.length===0?(0,J.jsx)(r,{children:(0,J.jsx)(c,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):m.map(t=>(0,J.jsxs)(r,{"data-state":A===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>X(t),onDoubleClick:()=>{X(t),ye()},children:[(0,J.jsx)(c,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,J.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||(z(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,J.jsx)(c,{className:`truncate`,title:V(t.dbms).label,children:(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,J.jsx)(y,{dbms:t.dbms,className:`size-3.5`}),(0,J.jsx)(`span`,{className:`truncate`,children:V(t.dbms).label})]})})]},t.id))})]})})]}),(0,J.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,J.jsxs)(J.Fragment,{children:[z(M)!==`browser`&&(0,J.jsx)(`div`,{className:`p-4 pb-0`,children:(0,J.jsx)(d,{})}),M.gatewayProfile?(0,J.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,J.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,J.jsx)(y,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,J.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,J.jsx)(fe,{value:M,onChange:Z})]}):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,J.jsxs)(ce,{className:`sm:justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(O,{variant:`outline`,onClick:Q,children:e(`connection.dialog.addNew`)}),(0,J.jsx)(O,{variant:`destructive`,onClick:pe,disabled:!A,children:e(`connection.dialog.delete`)})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(O,{variant:`outline`,onClick:be,disabled:!M||l,children:e(`connection.dialog.testConnection`)}),(0,J.jsx)(O,{onClick:ye,disabled:!M||me,children:e(`connection.dialog.connect`)}),(0,J.jsx)(O,{variant:`outline`,onClick:()=>Y(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{Q as ConnectDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-BwM1zx0B.js";import{h as r,n as i,t as a}from"./ui-store-5IssrgmG.js";import{l as o,m as s,t as c}from"./button-B2EsmMJs.js";import{t as l}from"./connection-store-D-Lp5EFj.js";import{a as u}from"./database-CfYjCIA2.js";import{n as d}from"./engine-Ja9hkC7I.js";import{l as f,m as p}from"./query-execution-_bzhSmJm.js";import{n as m,t as h}from"./table-copy-JytHH7NG.js";import{a as g,i as _,n as v,o as y,t as b}from"./dialog-FBpgH0QJ.js";var x=e(r(),1),S=o();function C(){let{t:e}=s(),{activeDialog:r,closeDialog:o}=i(),C=a(`copy-database`),w=r===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(o(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=l.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=d(t),i=l.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await f(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=u(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await h(a,s);await m({source:a,target:s,mode:O,onConflict:`abort`,createSql:d(t).ddl.createTable(c)})}await p(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(b,{open:w,onOpenChange:P,children:(0,S.jsxs)(v,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(g,{children:(0,S.jsx)(y,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.source`)}),(0,S.jsx)(n,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(n,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(t,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(_,{children:[(0,S.jsx)(c,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(c,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r}from"./main-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,j as n,l as r}from"./main-BwM1zx0B.js";import{h as i,n as a,t as ee}from"./ui-store-5IssrgmG.js";import{l as o,m as te,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-CtfiGpCP.js";import{t as ne}from"./connection-store-D-Lp5EFj.js";import{a as re}from"./database-CfYjCIA2.js";import{n as p}from"./engine-Ja9hkC7I.js";import{t as ie}from"./query-execution-_bzhSmJm.js";import{n as ae,t as oe}from"./table-copy-JytHH7NG.js";import{a as m,i as se,n as ce,o as le,t as h}from"./dialog-FBpgH0QJ.js";var g=e(i(),1),_=o(),v=e=>e instanceof Error?e.message:String(e),y=e=>e.hostName||e.host||e.file||e.id,ue=`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 b(){let{t:e}=te(),i=a(e=>e.activeDialog),o=a(e=>e.closeDialog),b=a(e=>e.showMessage),x=ee(`copy-table`),S=ne(e=>e.activeConnections),C=i===`copy-table`,w=x?.connectionId??``,T=String(x?.metadata?.database??``),E=x?.nodeText??``,D=S.find(e=>e.id===w),de=S.filter(e=>e.serverConnectionId),[O,k]=(0,g.useState)(w),[A,j]=(0,g.useState)([]),[M,N]=(0,g.useState)(``),[P,F]=(0,g.useState)(E),[I,L]=(0,g.useState)(`structure_data`),[R,z]=(0,g.useState)(`abort`),[B,V]=(0,g.useState)(``),[H,U]=(0,g.useState)(null),[W,G]=(0,g.useState)(null),[K,q]=(0,g.useState)(null),[J,Y]=(0,g.useState)(!1),X=(0,g.useRef)(null),Z=S.find(e=>e.id===O),Q=Z?p(O):null,fe=!!D&&!!Z&&p(w).id===Q?.id;(0,g.useEffect)(()=>{if(!C||!Z?.serverConnectionId)return;let e=!1,t=p(O),n=re(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=O===w,a=i||r.includes(T)?T:r[0]??``;N(a),F(e=>i&&a===T&&e===E?`${E}_copy`:e)}catch(t){e||q(v(t))}})(),()=>{e=!0}},[C,O]),(0,g.useEffect)(()=>{if(!C||!Z||!M||!P.trim()||!D)return;let e=!1;return(async()=>{U(null);try{let t=await oe({connectionId:w,database:T,table:E},{connectionId:O,database:M,table:P.trim()});e||V(p(O).ddl.createTable(t))}catch(t){e||U(v(t))}})(),()=>{e=!0}},[C,O,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}o()}}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 ae({source:{connectionId:w,database:T,table:E},target:{connectionId:O,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);o(),await b({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 ie||q(v(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,_.jsx)(h,{open:C,onOpenChange:$,children:(0,_.jsxs)(ce,{className:`sm:max-w-[640px]`,children:[(0,_.jsx)(m,{children:(0,_.jsx)(le,{children:e(`table.copy.title`)})}),(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.source`)}),(0,_.jsx)(r,{value:D?`${y(D)} / ${T} / ${E}`:``,disabled:!0})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,_.jsxs)(f,{value:O,onValueChange:k,disabled:J,children:[(0,_.jsx)(l,{id:`copy-target-conn`,className:`w-full`,children:(0,_.jsx)(c,{})}),(0,_.jsx)(u,{children:de.map(t=>(0,_.jsxs)(d,{value:t.id,children:[y(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,_.jsxs)(f,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,_.jsx)(l,{id:`copy-target-db`,className:`w-full`,children:(0,_.jsx)(c,{placeholder:e(`table.copy.loading`)})}),(0,_.jsx)(u,{children:A.map(e=>(0,_.jsx)(d,{value:e,children:e},e))})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,_.jsx)(r,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.what`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{children:e(`table.copy.ifExists`)}),(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,_.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsx)(t,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,_.jsx)(`textarea`,{id:`copy-ddl`,className:ue,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,_.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,_.jsxs)(`div`,{className:`space-y-1`,children:[(0,_.jsx)(n,{value:me??(W.phase===`done`?100:0)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,_.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,_.jsxs)(se,{children:[(0,_.jsx)(s,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,_.jsx)(s,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{b as CopyTableDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./main-BwM1zx0B.js";import{h as r,n as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-CtfiGpCP.js";import{t as p}from"./connection-store-D-Lp5EFj.js";import{n as m}from"./engine-Ja9hkC7I.js";import{l as h,m as g}from"./query-execution-_bzhSmJm.js";import{a as _,i as v,n as y,o as b,t as x}from"./dialog-FBpgH0QJ.js";var S=e(r(),1),C=a(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={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 E(){let{t:e}=o(),{activeDialog:r,closeDialog:a}=i(),E=r===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(a(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=p.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=m(e).getQuery(`CREATE_DATABASE`,t,k,j);await h(e,n),await g(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(n,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(f,{value:k,onValueChange:R,children:[(0,C.jsx)(l,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:w.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(t,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(f,{value:j,onValueChange:M,children:[(0,C.jsx)(l,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(c,{})}),(0,C.jsx)(u,{children:B.map(e=>(0,C.jsx)(d,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(s,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(s,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,c as n,l as r}from"./main-BwM1zx0B.js";import{h as i,n as a,t as o}from"./ui-store-5IssrgmG.js";import{l as s,m as c,t as l}from"./button-B2EsmMJs.js";import{t as u}from"./connection-store-D-Lp5EFj.js";import{n as d}from"./engine-Ja9hkC7I.js";import{l as f,m as p}from"./query-execution-_bzhSmJm.js";import{a as m,i as h,n as g,o as _,t as v}from"./dialog-FBpgH0QJ.js";var y=e(i(),1),b=s();function x(){let{t:e}=c(),{activeDialog:i,closeDialog:s}=a(),x=o(`create-schema`),S=i===`create-schema`,[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null);function k(e){e||(s(),w(``),O(null))}async function A(){let e=x?.connectionId??u.getState().activeConnectionId,t=C.trim();if(!(!e||!t)){O(null),E(!0);try{await f(e,d(e).getQuery(`CREATE_SCHEMA`,t)),await p(e),k(!1)}catch(e){O(e instanceof Error?e.message:String(e))}finally{E(!1)}}}return(0,b.jsx)(v,{open:S,onOpenChange:k,children:(0,b.jsxs)(g,{className:`sm:max-w-[420px]`,children:[(0,b.jsx)(m,{children:(0,b.jsx)(_,{children:e(`database.schema.createTitle`)})}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(n,{htmlFor:`schema-name`,children:e(`database.schema.name`)}),(0,b.jsx)(r,{id:`schema-name`,value:C,autoFocus:!0,placeholder:e(`database.schema.namePlaceholder`),onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!t(e)&&A()}})]}),D&&(0,b.jsx)(`p`,{className:`text-xs text-destructive leading-relaxed`,children:D}),(0,b.jsxs)(h,{children:[(0,b.jsx)(l,{variant:`outline`,onClick:()=>k(!1),children:e(`database.schema.cancel`)}),(0,b.jsx)(l,{onClick:()=>void A(),disabled:!C.trim()||T,children:e(`database.schema.create`)})]})]})})}export{x as CreateSchemaDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,_ as n,c as r,g as i,h as a,tt as o}from"./main-BwM1zx0B.js";import{c as s,h as c,n as l,t as u}from"./ui-store-5IssrgmG.js";import{l as d,m as f,t as p}from"./button-B2EsmMJs.js";import{a as m,i as h,n as g,r as _,t as v}from"./select-CtfiGpCP.js";import{t as y}from"./connection-store-D-Lp5EFj.js";import{a as b}from"./database-CfYjCIA2.js";import{n as x}from"./engine-Ja9hkC7I.js";import{t as ee}from"./pro-usage-D4Iv3hEs.js";import{a as S,i as te,n as ne,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(c(),1),E=d(),D=e=>e instanceof Error?e.message:String(e),O=e=>e.hostName||e.host||e.file||e.id,k=5e4;function A({id:e,label:t,side:n,onChange:i,connections:a,disabled:o}){let{t:s}=f(),[c,l]=(0,T.useState)([]),[u,d]=(0,T.useState)([]),p=a.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;l(t),t.includes(n.database)||i({connectionId:p.id,database:t[0]??``,table:``})}catch{e||l([])}})(),()=>{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 r=t.map(e=>e.name);d(r),n.table&&!r.includes(n.table)&&i({...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)(r,{className:`font-medium`,children:t}),(0,E.jsxs)(v,{value:n.connectionId,onValueChange:e=>i({connectionId:e,database:``,table:``}),disabled:o,children:[(0,E.jsx)(h,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickConnection`)})}),(0,E.jsx)(g,{children:a.map(e=>(0,E.jsx)(_,{value:e.id,children:O(e)},e.id))})]}),(0,E.jsxs)(v,{value:n.database,onValueChange:e=>i({...n,database:e,table:``}),disabled:o||c.length===0,children:[(0,E.jsx)(h,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.diff.pickDatabase`)})}),(0,E.jsx)(g,{children:c.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{value:n.table,onValueChange:e=>i({...n,table:e}),disabled:o||u.length===0,children:[(0,E.jsx)(h,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:s(`database.dataDiff.pickTable`)})}),(0,E.jsx)(g,{children:u.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]})]})}async function j(e,n){let r=await t({connectionId:e.connectionId,database:e.database,table:e.table,limit:k,onProgress:n}),i=[];for await(let e of r.pages)i.push(...e);return{rows:i,columns:r.fields.map(e=>e.name),capped:i.length>=k}}function M({diff:e,row:t,other:n,changed:r}){let{t:a}=f(),o=[...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:a(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:a(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:a(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:o.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:i(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?i(n[e]):`—`})]},e))})]})}function N(){let{t:e}=f(),t=l(e=>e.activeDialog),r=l(e=>e.closeDialog),c=u(`data-diff`),d=y(e=>e.activeConnections),m=(0,T.useMemo)(()=>d.filter(e=>e.serverConnectionId),[d]),h=y(e=>e.activeConnectionId),g=t===`data-diff`,[_,v]=(0,T.useState)(()=>c&&m.some(e=>e.id===c.connectionId)?{connectionId:c.connectionId,database:c.database,table:c.table}:{connectionId:h&&m.some(e=>e.id===h)?h:m[0]?.id??``,database:``,table:``}),[O,N]=(0,T.useState)(()=>({connectionId:m.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[P,re]=(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,H]=(0,T.useState)(!1),[U,W]=(0,T.useState)(!1),[G,K]=(0,T.useState)({source:null,target:null}),[q,J]=(0,T.useState)(null),oe=e=>N(e.database&&!e.table&&_.table?{...e,table:_.table}:e),Y=_.connectionId===O.connectionId&&_.database===O.database&&_.table===O.table,se=!!_.table&&!!O.table&&!Y,X=O.connectionId?x(O.connectionId):null;async function ce(){W(!0),J(null),I(null);try{let t=y.getState().activeConnections.find(e=>e.id===_.connectionId);if(!t?.serverConnectionId)throw Error(e(`services.query.notConnected`));let r=await x(_.connectionId).introspect.getPrimaryKeys(b(t.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(e(`database.dataDiff.noPrimaryKey`,{table:_.table}));K({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([j(_,e=>K(t=>({...t,source:e}))),j(O,e=>K(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(e(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=n(i.rows,a.rows,r,i.columns,a.columns);re(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`),s(`data_diff`,{source_dbms:x(_.connectionId).id,target_dbms:X?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){J(D(e))}finally{W(!1),K({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&&X?a(F,X,{database:O.database,table:O.table},{includeDeletes:V}):``,[F,X,O.database,O.table,V]);function le(){Q&&(o(O.connectionId,Q,O.database,e(`database.dataDiff.tabTitle`,{table:O.table})),r())}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=>P.map(t=>i(e[t])).join(`, `);return(0,E.jsx)(w,{open:g,onOpenChange:e=>{e||r()},children:(0,E.jsxs)(ne,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(S,{children:(0,E.jsx)(C,{children:e(`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)(A,{id:`ddiff-source`,label:e(`database.diff.source`),side:_,onChange:v,connections:m,disabled:U}),(0,E.jsx)(A,{id:`ddiff-target`,label:e(`database.diff.target`),side:O,onChange:oe,connections:m,disabled:U})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.hint`,{cap:k.toLocaleString()})}),Y&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.dataDiff.sameSide`)}),q&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:q}),U&&(G.source||G.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.loading`,{source:Z(G.source),target:Z(G.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:e(`database.dataDiff.summary`,{key:P.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:e(`database.dataDiff.capped`,{cap:k.toLocaleString()})}),(F.sourceOnlyColumns.length>0||F.targetOnlyColumns.length>0)&&(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.ignoredColumns`,{columns:[...F.sourceOnlyColumns,...F.targetOnlyColumns].join(`, `)})})]}),(0,E.jsx)(`div`,{className:`flex gap-1 text-xs`,children:[`added`,`changed`,`removed`].map(t=>(0,E.jsx)(`button`,{type:`button`,onClick:()=>{R(t),B(0)},className:`rounded border px-2 py-0.5 ${L===t?`bg-accent`:``}`,children:e(`database.dataDiff.${t}`,{count:t===`added`?F.added.length:t===`removed`?F.removed.length:F.changed.length})},t))}),(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:e(`database.dataDiff.none`)}),$.length>2e3&&(0,E.jsx)(`li`,{className:`px-2 py-1 text-muted-foreground`,children:e(`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)(M,{diff:F,row:F.changed[z].source,other:F.changed[z].target,changed:F.changed[z].columns}):L===`removed`?(0,E.jsx)(M,{diff:F,row:{},other:$[z]}):(0,E.jsx)(M,{diff:F,row:$[z]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`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=>H(e.target.checked)}),(0,E.jsx)(`span`,{className:V?`text-destructive`:``,children:e(`database.dataDiff.includeDeletes`)})]})]})]}),(0,E.jsxs)(te,{children:[(0,E.jsx)(p,{variant:`outline`,onClick:r,children:e(`database.diff.close`)}),(0,E.jsx)(p,{variant:`secondary`,onClick:()=>{ce()},disabled:!se||U,children:e(U?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(p,{onClick:le,disabled:!ue,children:e(`database.diff.openScript`)})]})]})})}export{N as DataDiffDialog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{U as t,c as n,j as r,l as i}from"./main-BwM1zx0B.js";import{c as a,h as o,n as s,t as c}from"./ui-store-5IssrgmG.js";import{l,m as u,t as d}from"./button-B2EsmMJs.js";import{a as f,i as p,n as m,r as h,t as g}from"./select-CtfiGpCP.js";import{t as _}from"./connection-store-D-Lp5EFj.js";import{n as v}from"./query-store-Cf_KUo80.js";import{a as y}from"./database-CfYjCIA2.js";import{o as b}from"./dbms-BwnatOMe.js";import{n as x}from"./engine-Ja9hkC7I.js";import{n as S}from"./query-execution-_bzhSmJm.js";import{a as ee,i as te,n as ne,o as re,t as ie}from"./dialog-FBpgH0QJ.js";import{t as C}from"./file-name-CnYBZPf9.js";var w=e(o(),1);function T(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 E=(e,t)=>e.map(e=>T(e,t)).join(t)+`
|
|
3
|
-
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).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 M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let
|
|
3
|
+
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).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 M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let n=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),r=0;try{let i=await t({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),o=i.fields.map(e=>e.name);e.includeHeaders&&await n.write(E(o,e.delimiter));for await(let t of i.pages)await n.write(t.map(t=>E(o.map(e=>t[e]),e.delimiter)).join(``)),r+=t.length;return await n.finish(),a(`export_csv`,{source:`table`,rows:r,format:O(e.delimiter)}),r}catch(e){throw await n.abort().catch(()=>void 0),e}}function P(e,t,n,r,i){let o=e.map(e=>e.name),s=[``];r&&s.push(E(o,n));for(let e of t)s.push(E(o.map(t=>e[t]),n));let c=new Blob(s,{type:`${A(n)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(i??`query_result${k(n)}`),u.click(),URL.revokeObjectURL(l),a(`export_csv`,{source:`result`,rows:t.length,format:O(n)})}var F=l(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=u(),{activeDialog:t,closeDialog:a}=s(),o=c(`export-csv`),l=_(e=>e.activeConnectionId),C=v(),T=t===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(o?.nodeText&&(o.nodeType===b.TABLE||o.nodeType===b.VIEW)){let e=o.metadata?.database;return{table:o.nodeText,database:typeof e==`string`?e:``}}if(!l)return null;let e=(C.tabs[l]??[]).find(e=>e.id===C.activeTabId[l]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(o?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!l)return;let e=_.getState().activeConnections.find(e=>e.id===l);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await x(l).introspect.listDatabases(y(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[l]?.find(e=>e.id===C.activeTabId[l])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,l]);function $(e){if(!e){if(W){X.current?.abort();return}a(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!l)return;if(Y(null),E===`query_result`){let e=C.activeTabId[l],t=(C.tabs[l]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),a();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let n=await N({connectionId:l,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});s.getState().setFooterMessage(e(`database.csv.done`,{count:n,table:k.trim(),format:Z})),a()}catch(e){!(e instanceof M)&&!(e instanceof S&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(ie,{open:T,onOpenChange:$,children:(0,F.jsxs)(ne,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(ee,{children:(0,F.jsx)(re,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(n,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(n,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(g,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(p,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(f,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(m,{children:j.map(e=>(0,F.jsx)(h,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(n,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(i,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(n,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(g,{value:B,onValueChange:V,children:[(0,F.jsx)(p,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(f,{})}),(0,F.jsx)(m,{children:I.map(t=>(0,F.jsx)(h,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(r,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(te,{children:[(0,F.jsx)(d,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(d,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,D as n,E as r,J as i,O as a,Rt as o,S as s,T as c,b as l,c as u,it as d,l as f,nt as p,rt as m,v as h,x as g,y as _}from"./main-BwM1zx0B.js";import{h as v,n as y,t as ee}from"./ui-store-5IssrgmG.js";import{l as b,m as x,t as S}from"./button-B2EsmMJs.js";import{a as C,i as w,n as T,r as E,t as D}from"./select-CtfiGpCP.js";import{t as O}from"./connection-store-D-Lp5EFj.js";import{a as te}from"./database-CfYjCIA2.js";import{n as k}from"./engine-Ja9hkC7I.js";import{l as ne,p as re}from"./query-execution-_bzhSmJm.js";import{i as ie}from"./table-copy-JytHH7NG.js";import{a as A,i as j,n as M,o as N,t as P}from"./dialog-FBpgH0QJ.js";var F=e(v(),1);function I(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function L(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function R(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function z(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 B=b(),V=`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`,H=`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]`,U=`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`,W=`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 ae({columns:e,onChange:n}){let{t:r}=x(),i=p().getDataTypes(),a=(0,F.useCallback)((t,r,i)=>{n(e.map(e=>e.id===t?{...e,[r]:i}:e))},[e,n]);function o(){n([...e,I()])}function c(){e.length>0&&n(e.slice(0,-1))}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(d,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V,children:[(0,B.jsx)(s,{className:H,children:(0,B.jsxs)(t,{children:[(0,B.jsx)(g,{className:`w-[120px]`,children:r(`table.schema.colField`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:r(`table.schema.colType`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:r(`table.schema.colLength`)}),(0,B.jsx)(g,{className:`w-[100px]`,children:r(`table.schema.colDefault`)}),(0,B.jsx)(g,{className:`w-[40px]`,children:r(`table.schema.colPk`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:r(`table.schema.colNotNull`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:r(`table.schema.colUnsigned`)}),(0,B.jsx)(g,{className:`w-[70px]`,children:r(`table.schema.colAutoIncrement`)}),(0,B.jsx)(g,{className:`w-[60px]`,children:r(`table.schema.colZerofill`)}),(0,B.jsx)(g,{children:r(`table.schema.colComment`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(t,{children:(0,B.jsx)(l,{colSpan:10,className:`text-center text-muted-foreground`,children:r(`table.schema.empty`)})}):e.map(e=>(0,B.jsxs)(t,{children:[(0,B.jsx)(l,{children:(0,B.jsx)(f,{className:U,value:e.field,onChange:t=>a(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,B.jsx)(l,{children:(0,B.jsxs)(D,{value:e.type,onValueChange:t=>a(e.id,`type`,t),children:[(0,B.jsx)(w,{className:W,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:i.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})}),(0,B.jsx)(l,{children:(0,B.jsx)(f,{className:U,value:e.length,onChange:t=>a(e.id,`length`,t.target.value)})}),(0,B.jsx)(l,{children:(0,B.jsx)(f,{className:U,value:e.defaultValue,onChange:t=>a(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,B.jsx)(l,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>a(e.id,`pk`,t.target.checked)})}),(0,B.jsx)(l,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>a(e.id,`notNull`,t.target.checked)})}),(0,B.jsx)(l,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>a(e.id,`unsigned`,t.target.checked)})}),(0,B.jsx)(l,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>a(e.id,`autoIncrement`,t.target.checked)})}),(0,B.jsx)(l,{className:`text-center`,children:(0,B.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>a(e.id,`zerofill`,t.target.checked)})}),(0,B.jsx)(l,{children:(0,B.jsx)(f,{className:U,value:e.comment,onChange:t=>a(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:o,children:r(`table.schema.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:c,disabled:e.length===0,children:r(`table.schema.remove`)})]})]})}var G=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function K({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:a}=x(),[o,s]=(0,F.useState)(t.name),[c,l]=(0,F.useState)(t.type),[d,p]=(0,F.useState)(t.columns);function m(e){p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function h(){r({id:t.id,name:c===`PRIMARY`?`PRIMARY`:o,type:c,columns:d})}return(0,B.jsx)(P,{open:e,onOpenChange:e=>{e||i()},children:(0,B.jsxs)(M,{className:`sm:max-w-[500px]`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:t.name?a(`table.index.editTitle`):a(`table.index.addTitle`)})}),(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`idx-name`,children:a(`table.index.name`)}),(0,B.jsx)(f,{id:`idx-name`,value:c===`PRIMARY`?`PRIMARY`:o,onChange:e=>s(e.target.value),disabled:c===`PRIMARY`,placeholder:a(`table.index.namePlaceholder`)})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`idx-type`,children:a(`table.index.type`)}),(0,B.jsxs)(D,{value:c,onValueChange:e=>l(e),children:[(0,B.jsx)(w,{id:`idx-type`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:G.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{children:a(`table.index.columns`)}),(0,B.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`table.index.noColumns`)}):n.map(e=>(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:d.includes(e.field),onChange:()=>m(e.field)}),(0,B.jsx)(`span`,{children:e.field||a(`table.index.unnamed`)}),(0,B.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:i,children:a(`table.index.cancel`)}),(0,B.jsx)(S,{onClick:h,disabled:d.length===0,children:a(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:n,onChange:r}){let{t:i}=x(),[a,o]=(0,F.useState)(null),[c,u]=(0,F.useState)(!1);function f(){let e=L();o(e),u(!0)}function p(e){o({...e}),u(!0)}function m(){e.length>0&&r(e.slice(0,-1))}function v(t){e.find(e=>e.id===t.id)?r(e.map(e=>e.id===t.id?t:e)):r([...e,t]),u(!1),o(null)}function y(){u(!1),o(null)}return(0,B.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,B.jsx)(d,{className:`flex-1`,children:(0,B.jsxs)(h,{className:V+` [&_td]:px-2`,children:[(0,B.jsx)(s,{className:H,children:(0,B.jsxs)(t,{children:[(0,B.jsx)(g,{className:`w-[150px]`,children:i(`table.indexes.colName`)}),(0,B.jsx)(g,{className:`w-[120px]`,children:i(`table.indexes.colType`)}),(0,B.jsx)(g,{children:i(`table.indexes.colColumns`)})]})}),(0,B.jsx)(_,{children:e.length===0?(0,B.jsx)(t,{children:(0,B.jsx)(l,{colSpan:3,className:`text-center text-muted-foreground`,children:i(`table.indexes.empty`)})}):e.map(e=>(0,B.jsxs)(t,{className:`cursor-pointer`,onDoubleClick:()=>p(e),children:[(0,B.jsx)(l,{children:e.name}),(0,B.jsx)(l,{children:e.type}),(0,B.jsx)(l,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,B.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:f,children:i(`table.indexes.add`)}),(0,B.jsx)(S,{size:`sm`,variant:`outline`,onClick:m,disabled:e.length===0,children:i(`table.indexes.remove`)})]}),a&&(0,B.jsx)(K,{open:c,index:a,availableColumns:n,onSave:v,onClose:y})]})}var q=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],J=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],Y={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 se({properties:e,onChange:t}){let{t:n}=x();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=Y[r]?.[0]??``),t(i)}let i=Y[e.charset]??[];return(0,B.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,B.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,B.jsxs)(D,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,B.jsx)(w,{id:`prop-engine`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:q.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,B.jsxs)(D,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,B.jsx)(w,{id:`prop-charset`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:J.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,B.jsxs)(D,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,B.jsx)(w,{id:`prop-collation`,className:`w-full`,children:(0,B.jsx)(C,{})}),(0,B.jsx)(T,{children:i.map(e=>(0,B.jsx)(E,{value:e,children:e},e))})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,B.jsx)(f,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,B.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,B.jsx)(u,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,B.jsx)(f,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:a,properties:s}){let c=i(e=>e.themeId),l=m(e),u=c===`light`||c===`light-blue`||c===`solarized-light`?`vs`:`vs-dark`,d=(0,F.useMemo)(()=>l.ddl.createTable(z(t,n,r,a,s)),[l,t,n,r,a,s]);return(0,B.jsx)(`div`,{className:`h-[320px]`,children:(0,B.jsx)(o,{height:`100%`,language:`sql`,theme:u,value:d,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function X(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Z(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function Q(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function $(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function le({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?$(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Z(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),X(i)!==X(r)){let e=a.alterColumn(t,n,Z(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,Q(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,Q(r)));return{statements:o,destructive:s,unsupported:c}}function ue(){let{t:e}=x(),{activeDialog:t,closeDialog:i}=y(),o=ee(`create-table`,`alter-table`,`duplicate-table-structure`),s=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,d=t===`duplicate-table-structure`,p=o?.nodeText??``,h=o?.metadata?.database??``,[g,_]=(0,F.useState)(``),[v,b]=(0,F.useState)([I()]),[C,w]=(0,F.useState)([]),[T,E]=(0,F.useState)(R()),[D,L]=(0,F.useState)(!1),[V,H]=(0,F.useState)(!1),[U,W]=(0,F.useState)(null),[G,K]=(0,F.useState)(null),q=o?.connectionId??O.getState().activeConnectionId,J=m(q);(0,F.useEffect)(()=>{s&&(W(null),K(null),l||d?(_(d?`${p}_copy`:p),Y()):(_(``),b([I()]),w([]),E(R())))},[s,t]);async function Y(){let e=O.getState(),t=o?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!h||!p)return;L(!0);let{introspect:r,capabilities:i}=k(t),a=te(n);try{let e=await r.listColumns(a,h,p),t=[];if(e.length>0){let n=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}});b(n),t=n}let n=await r.listIndexes(a,h,p),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),w(o)),K({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,h,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),W(e instanceof Error?e.message:String(e))}finally{L(!1)}}function X(e){e||i()}async function Z(){let t=o?.connectionId??O.getState().activeConnectionId;if(!t||!g.trim())return;let n=k(t);W(null);let r,a=[];if(l){if(!G)return;let t=le({engine:n,database:h,table:p,before:G,after:{columns:v,indexes:C}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
|
|
2
|
+
`),a=t.destructive}else{let e=d?C.map(e=>({...e,name:ie(e.name,p,g.trim())})):C;r=n.ddl.createTable(z(h,g.trim(),v,e,T))}H(!0);try{await ne(t,r,{skipDestructiveConfirm:a.length===0}),await re(t,h),i()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}}let Q=e(l?`table.dialog.alterTitle`:d?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),$=e(l?`table.dialog.alter`:`table.dialog.create`);return(0,B.jsx)(P,{open:s,onOpenChange:X,children:(0,B.jsxs)(M,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,B.jsx)(A,{children:(0,B.jsx)(N,{children:Q})}),(0,B.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,B.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,B.jsx)(u,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,B.jsx)(f,{id:`table-name`,value:g,onChange:e=>_(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:l})]}),D?(0,B.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,B.jsxs)(c,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,B.jsxs)(n,{children:[(0,B.jsx)(a,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,B.jsx)(a,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),J.capabilities.tableProperties&&(0,B.jsx)(a,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,B.jsx)(a,{value:`sql`,children:`SQL`})]}),(0,B.jsx)(r,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(ae,{columns:v,onChange:b})}),(0,B.jsx)(r,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(oe,{indexes:C,availableColumns:v,onChange:w})}),(0,B.jsx)(r,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,B.jsx)(se,{properties:T,onChange:E})}),(0,B.jsx)(r,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,B.jsx)(ce,{connectionId:q,database:h,tableName:g,columns:v,indexes:C,properties:T})})]})]}),U&&(0,B.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:U}),(0,B.jsxs)(j,{children:[(0,B.jsx)(S,{variant:`outline`,onClick:()=>X(!1),children:e(`table.dialog.cancel`)}),(0,B.jsx)(S,{onClick:()=>void Z(),disabled:D||V||!g.trim(),children:V?e(`table.dialog.applying`):$})]})]})})}export{ue as EditSchemaDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Mt as n,c as r,l as i}from"./main-BwM1zx0B.js";import{h as a,n as o}from"./ui-store-5IssrgmG.js";import{i as s,l as c,m as l,t as u}from"./button-B2EsmMJs.js";import{t as d}from"./chevron-up-CBnVjNE1.js";import{t as f}from"./connection-store-D-Lp5EFj.js";import{n as p}from"./query-store-Cf_KUo80.js";import{n as m,o as h,s as g,t as _}from"./editor-registry-ukUyoekH.js";var v=e(a(),1),y=c();function b(){let{t:e}=l(),{activeDialog:a,closeDialog:c}=o(),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(0),M=f(e=>e.activeConnectionId)??``,N=p(e=>M?e.activeTabId[M]:void 0)??``;if(a!==`find-replace`)return null;let P={query:b,caseSensitive:w,regex:E,wholeWord:O},F=M!==``&&N!==``&&b!==``;function I(){c()}function L(){j(F?m(M,N,P,`next`):0)}function R(){j(F?m(M,N,P,`prev`):0)}function z(){F&&j(g(M,N,P,S))}function B(){F&&(h(M,N,P,S),j(_(M,N,P)))}return(0,y.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,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(i,{placeholder:e(`command.findReplace.findPlaceholder`),value:b,onChange:e=>x(e.target.value),onKeyDown:e=>{t(e)||(e.key===`Enter`&&(e.shiftKey?R():L()),e.key===`Escape`&&I())},className:`flex-1 h-7 text-sm`,autoFocus:!0}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap min-w-[60px] text-center`,children:A>0?e(`command.findReplace.found`,{count:A}):e(`command.findReplace.noResults`)}),(0,y.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:R,title:e(`command.findReplace.previous`),children:(0,y.jsx)(d,{className:`h-4 w-4`})}),(0,y.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:L,title:e(`command.findReplace.next`),children:(0,y.jsx)(n,{className:`h-4 w-4`})}),(0,y.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:I,title:e(`command.findReplace.close`),children:(0,y.jsx)(s,{className:`h-4 w-4`})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(i,{placeholder:e(`command.findReplace.replacePlaceholder`),value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Escape`&&I()},className:`flex-1 h-7 text-sm`}),(0,y.jsx)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:z,children:e(`command.findReplace.replace`)}),(0,y.jsx)(u,{variant:`outline`,size:`sm`,className:`h-7 text-xs`,onClick:B,children:e(`command.findReplace.all`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,y.jsxs)(r,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.caseSensitive`)]}),(0,y.jsxs)(r,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.regex`)]}),(0,y.jsxs)(r,{className:`flex items-center gap-1.5 text-xs font-normal cursor-pointer`,children:[(0,y.jsx)(`input`,{type:`checkbox`,checked:O,onChange:e=>k(e.target.checked),className:`rounded border-input`}),e(`command.findReplace.wholeWord`)]})]})]})}export{b as FindReplaceDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-
|
|
1
|
+
import{n as e}from"./ui-store-5IssrgmG.js";import{l as t,m as n,t as r}from"./button-B2EsmMJs.js";import{t as i}from"./connection-store-D-Lp5EFj.js";import{c as a}from"./database-CfYjCIA2.js";import{a as o,i as s,n as c,o as l,t as u}from"./dialog-FBpgH0QJ.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{a as e,n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{r as a,t as o}from"./i18n-
|
|
1
|
+
import{a as e,n as t}from"./ui-store-5IssrgmG.js";import{l as n,m as r,t as i}from"./button-B2EsmMJs.js";import{r as a,t as o}from"./i18n-BQcNT-sS.js";import{a as s,i as c,n as l,r as u,t as d}from"./select-CtfiGpCP.js";import{n as f}from"./settings-store-DzQ3BP5e.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./dialog-FBpgH0QJ.js";import{t as y}from"./settings-controls-DyukG7E2.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,it as n,l as r,lt as i,tt as a,wt as ee}from"./main-BwM1zx0B.js";import{c as te,h as o,n as s,t as ne}from"./ui-store-5IssrgmG.js";import{l as c,m as re,t as l}from"./button-B2EsmMJs.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-CtfiGpCP.js";import{t as h}from"./connection-store-D-Lp5EFj.js";import{a as g}from"./database-CfYjCIA2.js";import{n as _}from"./engine-Ja9hkC7I.js";import{a as ie,d as v}from"./query-execution-_bzhSmJm.js";import{a as ae,i as oe,n as y,o as b,r as se,t as ce}from"./dialog-FBpgH0QJ.js";var x=e(o(),1),le=[`SUM`,`AVG`,`MIN`,`MAX`],S=`row_count`;function ue(e,t){if(t.columns.length===0)return``;let n=t=>e.quoteIdentifier(t),r=t.columns.map(n),i=[...r,`COUNT(*) AS ${n(S)}`];if(t.aggregate){let{fn:e,column:r}=t.aggregate;i.push(`${e}(${n(r)}) AS ${n(`${e.toLowerCase()}_${r}`)}`)}let a=[];return t.where&&a.push(t.where),a.push(`GROUP BY ${r.join(`, `)}`),t.minCount&&t.minCount>1&&a.push(`HAVING COUNT(*) >= ${Math.floor(t.minCount)}`),a.push(`ORDER BY COUNT(*) DESC`),t.limit>0&&a.push(e.limitClause(t.limit)),e.getQuery(`SELECT_TABLE`,t.database,t.table,i.join(`, `),a.join(` `))}function C(e){let t=new Set;for(let n of e){let e=n.columns[0];e&&t.add(e.toLowerCase())}return t}function w(e,t){return t.has(e.toLowerCase())}function de(e,t){let n=C(t);return e.some(e=>w(e,n))}var T=c(),E=`none`,fe=/\b(int|dec|numeric|number|float|double|real|money|serial)/i;function D(){let{t:e}=re(),o=s(e=>e.activeDialog),c=s(e=>e.closeDialog),S=ne(`group-by`),D=o===`group-by`,O=h(e=>e.activeConnections),pe=h(e=>e.activeConnectionId),me=(0,x.useMemo)(()=>O.filter(e=>e.serverConnectionId),[O]),[k,he]=(0,x.useState)(()=>S?.connectionId??pe??``),[A,j]=(0,x.useState)(()=>S?.database??``),[M,N]=(0,x.useState)(()=>S?.table??``),[P,F]=(0,x.useState)([]),[I,L]=(0,x.useState)([]),R=S&&k===S.connectionId&&A===S.database&&M===S.table?S.where??``:``,[z,ge]=(0,x.useState)([]),[B,_e]=(0,x.useState)([]),[V,H]=(0,x.useState)(()=>S?.column?[S.column]:[]),[U,ve]=(0,x.useState)(E),[W,ye]=(0,x.useState)(``),[G,be]=(0,x.useState)(`1`),[K,xe]=(0,x.useState)(!0),[q,J]=(0,x.useState)(``),[Se,Y]=(0,x.useState)(!1),X=e=>h.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId;(0,x.useEffect)(()=>{if(!D||!k)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await _(k).introspect.listDatabases(g(e));if(t)return;F(n),j(e=>e&&n.includes(e)?e:n[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k]),(0,x.useEffect)(()=>{if(!D||!k||!A)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{try{let n=await _(k).introspect.listTables(g(e),A);if(t)return;let r=n.map(e=>e.name);L(r),N(e=>e&&r.includes(e)?e:r[0]??``)}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A]),(0,x.useEffect)(()=>{if(!D||!k||!M)return;let e=X(k);if(!e)return;let t=!1;return(async()=>{let n=g(e),r=_(k).introspect;try{let[e,i]=await Promise.all([r.listColumns(n,A,M),r.listIndexes(n,A,M).catch(()=>[])]);if(t)return;ge(e),_e(i),H(t=>t.filter(t=>e.some(e=>e.name===t)))}catch(e){t||J(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[D,k,A,M]);let Ce=(0,x.useMemo)(()=>C(B),[B]),we=(0,x.useMemo)(()=>z.filter(e=>fe.test(e.type)),[z]),Z=(0,x.useMemo)(()=>!k||V.length===0?``:ue(_(k),{database:A,table:M,columns:V,aggregate:U!==E&&W?{fn:U,column:W}:null,where:K?R:``,minCount:Number(G)||1,limit:v()}),[k,A,M,V,U,W,G,K,R]),Q=V.length>0&&B.length>0&&!de(V,B);function Te(e){H(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function $(e){te(`group_by`,{action:e,dbms:_(k).id,columns:V.length,aggregate:U,filtered:!!(K&&R),indexed:!Q})}function Ee(){Z&&($(`open`),a(k,Z,A,e(`database.groupBy.tabTitle`,{table:M})),c())}async function De(){if(!Z)return;$(`run`),Y(!0);let t=a(k,Z,A,e(`database.groupBy.tabTitle`,{table:M}));c();try{await ie(k,t)}finally{Y(!1)}}return(0,T.jsx)(ce,{open:D,onOpenChange:e=>{e||c()},children:(0,T.jsxs)(y,{className:`flex max-h-[85vh] flex-col sm:max-w-[720px]`,children:[(0,T.jsxs)(ae,{children:[(0,T.jsx)(b,{children:e(`database.groupBy.title`)}),(0,T.jsx)(se,{children:e(`database.groupBy.description`,{table:M})})]}),q&&(0,T.jsx)(`p`,{className:`rounded-md border border-destructive/40 px-3 py-2 text-xs text-destructive`,children:q}),(0,T.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.connection`)}),(0,T.jsxs)(m,{value:k,onValueChange:he,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:me.map(e=>(0,T.jsx)(p,{value:e.id,children:e.hostName||e.host||e.file||e.id},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.database`)}),(0,T.jsxs)(m,{value:A,onValueChange:j,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:P.map(e=>(0,T.jsx)(p,{value:e,children:e},e))})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.table`)}),(0,T.jsxs)(m,{value:M,onValueChange:N,children:[(0,T.jsx)(d,{className:`h-8 text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsx)(f,{children:I.map(e=>(0,T.jsx)(p,{value:e,children:e},e))})]})]})]}),(0,T.jsxs)(`div`,{className:`grid min-h-0 grid-cols-[1fr_1fr] gap-4`,children:[(0,T.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-1.5`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.columns`)}),(0,T.jsx)(n,{className:`h-[260px] rounded-md border`,children:(0,T.jsx)(`ul`,{className:`p-1`,children:z.map(t=>{let n=w(t.name,Ce);return(0,T.jsx)(`li`,{children:(0,T.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1 text-xs hover:bg-accent`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:V.includes(t.name),onChange:()=>Te(t.name)}),(0,T.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),(0,T.jsx)(`span`,{className:`truncate text-muted-foreground`,children:t.type}),n&&(0,T.jsx)(ee,{className:`ml-auto h-3 w-3 shrink-0 text-muted-foreground`,"aria-label":e(`database.groupBy.indexed`)})]})},t.name)})})})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.aggregate`)}),(0,T.jsxs)(`div`,{className:`flex gap-2`,children:[(0,T.jsxs)(m,{value:U,onValueChange:ve,children:[(0,T.jsx)(d,{className:`h-8 w-[110px] text-xs`,children:(0,T.jsx)(u,{})}),(0,T.jsxs)(f,{children:[(0,T.jsx)(p,{value:E,children:e(`database.groupBy.countOnly`)}),le.map(e=>(0,T.jsx)(p,{value:e,children:e},e))]})]}),(0,T.jsxs)(m,{value:W,onValueChange:ye,disabled:U===E,children:[(0,T.jsx)(d,{className:`h-8 flex-1 text-xs`,children:(0,T.jsx)(u,{placeholder:e(`database.groupBy.column`)})}),(0,T.jsx)(f,{children:we.map(e=>(0,T.jsx)(p,{value:e.name,children:e.name},e.name))})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(t,{htmlFor:`gb-min`,className:`text-xs`,children:e(`database.groupBy.minCount`)}),(0,T.jsx)(r,{id:`gb-min`,type:`number`,min:1,value:G,onChange:e=>be(e.target.value),className:`h-8 text-xs`})]}),R&&(0,T.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:K,onChange:e=>xe(e.target.checked)}),e(`database.groupBy.useFilter`)]}),Q&&(0,T.jsxs)(`p`,{className:`flex gap-1.5 rounded-md border border-dashed px-2 py-1.5 text-xs text-muted-foreground`,children:[(0,T.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,T.jsx)(`span`,{children:e(`database.groupBy.noIndexWarning`)})]})]})]}),(0,T.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,T.jsx)(t,{className:`text-xs`,children:e(`database.groupBy.preview`)}),(0,T.jsx)(`pre`,{className:`max-h-[120px] overflow-auto rounded-md border bg-muted p-2 font-mono text-xs whitespace-pre-wrap`,children:Z||e(`database.groupBy.pickColumn`)})]}),(0,T.jsxs)(oe,{children:[(0,T.jsx)(l,{variant:`outline`,onClick:c,children:e(`command.close`)}),(0,T.jsx)(l,{variant:`outline`,onClick:Ee,disabled:!Z,children:e(`database.groupBy.openInTab`)}),(0,T.jsx)(l,{onClick:De,disabled:!Z||Se,children:e(`database.groupBy.run`)})]})]})})}export{D as GroupByDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,R as n,c as r,t as i,z as a}from"./main-BwM1zx0B.js";import{h as o,n as s,t as c}from"./ui-store-5IssrgmG.js";import{l,m as u,t as d}from"./button-B2EsmMJs.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-FBpgH0QJ.js";import{t as v}from"./pro-upsell-BH-enstO.js";var y=e(o(),1),b=l();function x(e){return e.state===`invalid`?e.reason===`no-public-key`?`pro.notConfigured`:e.reason===`no-webcrypto`?`pro.noWebcrypto`:`pro.invalidKey`:null}function S(){let e=s(e=>e.activeDialog),o=s(e=>e.closeDialog),l=c(`license`),{key:S,status:C,activate:w,clear:T}=n(),{t:E}=u(),[D,O]=(0,y.useState)(S),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!l?.feature||!!S),N=(0,y.useRef)(null),[P,F]=(0,y.useState)(a()?null:E(`pro.notConfigured`)),I=async()=>{A(!0);let e=x(await w(D.trim()));F(e?E(e):null),A(!1)},L=C.state===`valid`||C.state===`expired`?C.claim:null,R=l?.feature?E(`pro.blocked`,{feature:E(`pro.features.${l.feature}`)}):null;return(0,b.jsx)(_,{open:e===`license`,onOpenChange:e=>{e||o()},children:(0,b.jsxs)(m,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>{N.current&&(e.preventDefault(),N.current.focus())},children:[(0,b.jsx)(f,{children:(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,b.jsx)(i,{size:44}),(0,b.jsx)(t,{className:`absolute -right-2 -bottom-1 ml-0`})]}),(0,b.jsxs)(`div`,{className:`grid gap-1`,children:[(0,b.jsx)(h,{children:E(`pro.licenseTitle`)}),(0,b.jsx)(g,{children:R??E(`pro.licenseDescription`)})]})]})}),(0,b.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[C.state===`valid`&&(0,b.jsxs)(`div`,{className:`rounded-md border border-emerald-500/40 bg-emerald-500/5 p-3 text-xs`,children:[(0,b.jsx)(`p`,{className:`font-medium text-emerald-600 dark:text-emerald-400`,children:E(`pro.active`)}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.licensedTo`,{email:L?.sub})}),(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:E(`pro.validUntil`,{date:L?.exp})})]}),C.state===`expired`&&(0,b.jsx)(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-amber-600 dark:text-amber-400`,children:E(`pro.expiredOn`,{date:L?.exp})}),R&&(0,b.jsx)(v,{highlight:l?.feature,innerRef:N}),!j&&(0,b.jsx)(`button`,{type:`button`,onClick:()=>M(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:E(`pro.haveKey`)}),(0,b.jsxs)(`div`,{className:j?`grid gap-1.5`:`hidden`,children:[(0,b.jsx)(r,{htmlFor:`license-key`,children:E(`pro.keyLabel`)}),(0,b.jsx)(`textarea`,{id:`license-key`,value:D,onChange:e=>{O(e.target.value),F(null)},spellCheck:!1,rows:3,className:`w-full resize-none rounded-md border bg-transparent p-2 font-mono text-xs outline-none focus-visible:ring-1 focus-visible:ring-ring`}),P&&(0,b.jsx)(`p`,{className:`text-xs text-destructive`,children:P})]})]}),(0,b.jsxs)(p,{children:[S&&(0,b.jsx)(d,{variant:`ghost`,onClick:()=>{T(),O(``)},children:E(`pro.remove`)}),j&&(0,b.jsx)(d,{disabled:k||!D.trim()||D.trim()===S,onClick:()=>{I()},children:E(`pro.activate`)}),(0,b.jsx)(d,{variant:`secondary`,onClick:o,children:E(`settings.done`)})]})]})})}export{S as LicenseDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,c as n,l as r,q as i}from"./main-BwM1zx0B.js";import{c as ee,h as a,n as o,t as s}from"./ui-store-5IssrgmG.js";import{l as c,m as l,t as u}from"./button-B2EsmMJs.js";import{a as d,i as f,n as p,r as m,t as h}from"./select-CtfiGpCP.js";import{t as g}from"./connection-store-D-Lp5EFj.js";import{a as _}from"./database-CfYjCIA2.js";import{n as v}from"./engine-Ja9hkC7I.js";import{t as y}from"./pro-usage-D4Iv3hEs.js";import{a as b,i as x,n as S,o as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(a(),1),E=c(),D=e=>e instanceof Error?e.message:String(e);function O(){let{t:e}=l(),a=o(e=>e.activeDialog),c=o(e=>e.closeDialog),O=s(`link-column`),k=a===`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?t(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 e=L!==A;P(A,{database:O.database,table:O.table,column:O.column,...e?{targetConnectionId:L}:{},targetDatabase:K,targetTable:J,targetColumn:X}),y(`column_link`),ee(`column_link_set`,{dbms:v(A).id,target_dbms:v(L).id,cross_database:K!==O.database,cross_connection:e}),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:e(`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)(n,{children:e(`result.link.source`)}),(0,E.jsx)(r,{value:`${O.database}.${O.table}.${O.column}`,disabled:!0})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`result.link.hint`)}),(0,E.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,E.jsx)(n,{htmlFor:`link-conn`,children:e(`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)(n,{htmlFor:`link-db`,children:e(`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)(n,{htmlFor:`link-table`,children:e(`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:e(`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)(n,{htmlFor:`link-column`,children:e(`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:e(`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:e(`result.link.remove`)}),(0,E.jsx)(u,{variant:`outline`,onClick:c,children:e(`result.link.cancel`)}),(0,E.jsx)(u,{onClick:te,disabled:!K||!J||!X,children:e(`result.link.save`)})]})]})})}export{O as LinkColumnDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{J as t,gt as n,it as r,l as i,tt as ee,ut as a,zt as o}from"./main-BwM1zx0B.js";import{c as s,h as c,i as l,n as u}from"./ui-store-5IssrgmG.js";import{l as d,m as f,t as p}from"./button-B2EsmMJs.js";import{i as m,t as h}from"./connection-store-D-Lp5EFj.js";import{n as g}from"./settings-store-DzQ3BP5e.js";import{n as _,t as v}from"./query-store-Cf_KUo80.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./dialog-FBpgH0QJ.js";var T=e(c(),1),E=d(),D={execute:`command.localHistory.reason.execute`,edit:`command.localHistory.reason.edit`,replaced:`command.localHistory.reason.replaced`,restore:`command.localHistory.reason.restore`,close:`command.localHistory.reason.close`},O=Object.freeze([]);function k(e){let t=(Date.now()-e)/36e5;return t<1?`<1h`:t<24?`1-24h`:t<168?`1-7d`:`7d+`}function A(){let{t:e}=f(),c=u(e=>e.activeDialog),d=u(e=>e.closeDialog),A=u(e=>e.setFooterMessage),j=h(e=>e.activeConnectionId),M=_(e=>j?e.activeTabId[j]:null),N=_(e=>j?e.tabs[j]??v:v),P=m(e=>j?e.revisions[j]??O:O),F=g(e=>e.persistQueryHistory),I=t(e=>e.themeId),L=I===`light`||I===`light-blue`||I===`solarized-light`?`vs`:`vs-dark`,[R,z]=(0,T.useState)(!0),[B,V]=(0,T.useState)(``),[H,U]=(0,T.useState)(null),[W,G]=(0,T.useState)(`current`),K=N.find(e=>e.id===M),q=c===`local-history`;(0,T.useEffect)(()=>{if(!q)return;let e=M?P.filter(e=>e.docId===M).length:0;s(`local_history_open`,{revisions:l(P.length),tab_revisions:l(e)})},[q]);let J=(0,T.useMemo)(()=>{let e=B.trim().toLowerCase();return P.filter(t=>R&&M&&t.docId!==M?!1:!e||t.text.toLowerCase().includes(e)||t.title.toLowerCase().includes(e))},[P,B,R,M]),Y=K?.query??``,X=J.find(e=>e.id===H)??J.find(e=>e.text!==Y)??J[0],Z=(0,T.useMemo)(()=>{if(!X)return;let e=P.filter(e=>e.docId===X.docId);return e[e.findIndex(e=>e.id===X.id)+1]},[P,X]),Q=W===`current`?Y:Z?.text??``;function $(e,t){s(`local_history_recover`,{action:e,reason:t.reason,age:k(t.timestamp),same_tab:t.docId===M,compare:W})}function te(){if(!j||!M||!X)return;$(`restore`,X);let t=_.getState();t.captureRevision(j,M,`restore`),t.setEditorContent(j,M,X.text),A(e(`command.localHistory.restored`)),d()}function ne(){!j||!X||($(`new_tab`,X),ee(j,X.text,X.database,X.title),A(e(`command.localHistory.openedInTab`)),d())}function re(e){j&&(m.getState().removeRevision(j,e.id),H===e.id&&U(null))}function ie(){j&&(m.getState().clearRevisions(j),U(null))}return(0,E.jsx)(w,{open:q,onOpenChange:e=>{e||d()},children:(0,E.jsxs)(x,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:e(`command.localHistory.title`)}),(0,E.jsx)(C,{children:e(`command.localHistory.description`)})]}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border border-dashed px-3 py-2 text-xs text-muted-foreground`,children:e(`command.localHistory.notPersisted`)}),(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,E.jsxs)(`div`,{className:`relative min-w-[200px] flex-1`,children:[(0,E.jsx)(n,{className:`absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(i,{value:B,onChange:e=>V(e.target.value),placeholder:e(`command.localHistory.searchPlaceholder`),className:`h-8 pl-7 text-xs`})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!0),className:`px-2 py-1 text-xs ${R?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.scopeTab`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`border-l px-2 py-1 text-xs ${R?`hover:bg-accent/50`:`bg-accent`}`,children:e(`command.localHistory.scopeAll`)})]}),(0,E.jsxs)(`div`,{className:`flex overflow-hidden rounded-md border`,children:[(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`current`),className:`px-2 py-1 text-xs ${W===`current`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.compareCurrent`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>G(`previous`),className:`border-l px-2 py-1 text-xs ${W===`previous`?`bg-accent`:`hover:bg-accent/50`}`,children:e(`command.localHistory.comparePrevious`)})]})]}),J.length===0?(0,E.jsx)(`div`,{className:`py-10 text-center text-sm text-muted-foreground`,children:P.length===0?e(`command.localHistory.empty`):e(`command.localHistory.noMatch`)}):(0,E.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[260px_1fr] gap-3`,children:[(0,E.jsx)(r,{className:`h-[440px] rounded-md border`,children:(0,E.jsx)(`ul`,{className:`divide-y`,children:J.map(t=>(0,E.jsxs)(`li`,{className:`group relative`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>U(t.id),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 pr-8 text-left text-xs hover:bg-accent ${t.id===X?.id?`bg-accent`:``}`,children:[(0,E.jsx)(`span`,{className:`font-medium`,children:new Date(t.timestamp).toLocaleString()}),(0,E.jsxs)(`span`,{className:`w-full truncate text-muted-foreground`,children:[t.title,` · `,e(D[t.reason]),` · `,e(`command.localHistory.chars`,{count:t.text.length})]})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>re(t),title:e(`command.localHistory.delete`),className:`absolute right-1.5 top-1.5 rounded p-1 text-muted-foreground opacity-0 hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100`,children:(0,E.jsx)(a,{className:`h-3.5 w-3.5`})})]},t.id))})}),(0,E.jsxs)(`div`,{className:`flex h-[440px] flex-col overflow-hidden rounded-md border`,children:[(0,E.jsx)(`div`,{className:`border-b bg-muted/40 px-3 py-1.5 text-xs text-muted-foreground`,children:W===`current`?e(`command.localHistory.diffAgainstCurrent`):Z?e(`command.localHistory.diffAgainstPrevious`,{time:new Date(Z.timestamp).toLocaleString()}):e(`command.localHistory.noPrevious`)}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(o,{language:`sql`,theme:L,original:X?.text??``,modified:Q,options:{readOnly:!0,renderSideBySide:!1,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,renderOverviewRuler:!1}})})]})]}),(0,E.jsxs)(b,{className:`sm:justify-between`,children:[(0,E.jsx)(p,{variant:`ghost`,onClick:ie,disabled:P.length===0,children:e(`command.localHistory.clearAll`)}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(p,{variant:`outline`,onClick:d,children:e(`command.close`)}),(0,E.jsx)(p,{variant:`outline`,onClick:ne,disabled:!X,children:e(`command.localHistory.openInNewTab`)}),(0,E.jsx)(p,{onClick:te,disabled:!X||!K,children:e(`command.localHistory.restore`)})]})]})]})})}export{A as LocalHistoryDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Nt as t,Ot as n}from"./main-BwM1zx0B.js";import{h as r,n as i}from"./ui-store-5IssrgmG.js";import{l as a,m as o,t as s}from"./button-B2EsmMJs.js";import{S as c,p as l}from"./tunneling-C--CCnwy.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./dialog-FBpgH0QJ.js";var g=e(r(),1),_=a();function v({text:e,label:r}){let[i,a]=(0,g.useState)(!1),o=(0,g.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),1600)})},[e]);return(0,_.jsxs)(`div`,{className:`grid gap-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-medium`,children:r}),(0,_.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-2 text-xs`,onClick:o,children:i?(0,_.jsx)(t,{className:`size-3`}):(0,_.jsx)(n,{className:`size-3`})})]}),(0,_.jsx)(`pre`,{"data-selectable":!0,className:`max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md border bg-muted/40 p-2 text-[11px] leading-snug`,children:e})]})}function y(){let e=i(e=>e.activeDialog),t=i(e=>e.closeDialog),{t:n}=o(),[r,a]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!1),C=e===`mcp-setup`;(0,g.useEffect)(()=>{C&&l().then(e=>{a(e),S(!1)}).catch(e=>b(e instanceof Error?e.message:String(e)))},[C]);let w=(0,g.useCallback)(()=>{c().then(()=>{a(null),S(!0)})},[]),T=r?`claude mcp add --transport http planche ${r.url} \\\n -H "Authorization: Bearer ${r.token}"`:``,E=r?JSON.stringify({mcpServers:{planche:{type:`http`,url:r.url,headers:{Authorization:`Bearer ${r.token}`}}}},null,2):``;return(0,_.jsx)(h,{open:C,onOpenChange:e=>{e||t()},children:(0,_.jsxs)(f,{className:`sm:max-w-[620px]`,children:[(0,_.jsxs)(u,{children:[(0,_.jsx)(p,{children:n(`mcp.title`)}),(0,_.jsx)(m,{children:n(`mcp.description`)})]}),(0,_.jsxs)(`div`,{className:`grid gap-3`,children:[(0,_.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:[[`readsLabel`,`reads`],[`writesLabel`,`writes`],[`needsLabel`,`needs`],[`tokenLabel`,`token`]].map(([e,t])=>(0,_.jsxs)(g.Fragment,{children:[(0,_.jsx)(`dt`,{className:`font-medium`,children:n(`mcp.${e}`)}),(0,_.jsx)(`dd`,{className:`text-muted-foreground`,children:n(`mcp.${t}`)})]},e))}),y&&(0,_.jsx)(`p`,{className:`rounded-md border border-destructive/40 p-2 text-xs text-destructive`,children:y}),x&&(0,_.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:n(`mcp.revoked`)}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v,{text:T,label:n(`mcp.command`)}),(0,_.jsx)(v,{text:E,label:n(`mcp.json`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`mcp.stored`,{path:r.path})})]})]}),(0,_.jsxs)(d,{children:[r&&(0,_.jsx)(s,{variant:`ghost`,size:`sm`,onClick:w,children:n(`mcp.revoke`)}),(0,_.jsx)(s,{size:`sm`,onClick:t,children:n(`settings.done`)})]})]})})}export{y as McpSetupDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,Ft as n,It as r,Lt as i,Nt as a,Ot as o,S as s,_t as ee,b as c,gt as l,v as te,x as u,y as ne}from"./main-BwM1zx0B.js";import{h as d,n as f}from"./ui-store-5IssrgmG.js";import{a as p,i as re,l as m,m as ie,t as h}from"./button-B2EsmMJs.js";import{a as g}from"./i18n-BQcNT-sS.js";import{t as _}from"./connection-store-D-Lp5EFj.js";import{c as v}from"./database-CfYjCIA2.js";import{t as y}from"./engine-Ja9hkC7I.js";import{a as ae,i as b,n as x,o as oe,t as se}from"./dialog-FBpgH0QJ.js";var ce=p(`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`}]]),le=p(`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`}]]),ue=p(`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`}]]),S=p(`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`}]]),C=e(d(),1),w=m(),T=10,de=[2,5,10,30];function E(){let e=_.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function fe(){let e=E();if(!e)throw Error(g.t(`command.noActiveConnection`));let t=await v(e,y().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 D(e){return/^(sleep|idle)/i.test(e.Command??``)}function pe(e){return/lock/i.test(e.State??``)}function me(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function O(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function k(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 A({icon:e,label:t,value:n,tone:r}){return(0,w.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,w.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,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,w.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function j(){let{t:e}=ie(),{activeDialog:d,closeDialog:p,setFooterMessage:m,requestDestructiveConfirm:g}=f(),[_,j]=(0,C.useState)([]),[M,N]=(0,C.useState)(!1),[P,he]=(0,C.useState)(5),[F,I]=(0,C.useState)(null),[L,R]=(0,C.useState)(``),[z,ge]=(0,C.useState)(!1),[B,_e]=(0,C.useState)(!0),[V,H]=(0,C.useState)(!1),[U,ve]=(0,C.useState)(null),[W,G]=(0,C.useState)(!1),K=(0,C.useRef)(null),q=d===`process-list`,J=(0,C.useCallback)(()=>Promise.resolve().then(()=>(H(!0),fe())).then(e=>{j(e),ve(new Date)}).catch(t=>m(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[m,e]);(0,C.useEffect)(()=>{q&&J()},[q,J]),(0,C.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),M&&q&&(K.current=setInterval(()=>{J()},P*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[M,P,q,J]);function Y(e){e||(N(!1),I(null),R(``),p())}let X=(0,C.useMemo)(()=>{let e=_.filter(D).length,t=_.filter(e=>!D(e)).reduce((e,t)=>Math.max(e,O(t)),0);return{total:_.length,active:_.length-e,idle:e,longest:t}},[_]),Z=(0,C.useMemo)(()=>{let e=L.trim().toLowerCase();return _.filter(t=>z&&D(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?O(t)-O(e):O(e)-O(t))},[_,L,z,B]),Q=_.find(e=>e.Id===F)??null,ye=(0,C.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){m(e(`command.processList.selectToKill`));return}let r=E();if(!r)return;let i=_.find(e=>e.Id===n),a=y().getQuery(`KILL_QUERY`,String(n));if(await g({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 v(r,a),m(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){m(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,w.jsx)(se,{open:q,onOpenChange:Y,children:(0,w.jsxs)(x,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,w.jsx)(ae,{children:(0,w.jsxs)(oe,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,w.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,w.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,w.jsx)(A,{icon:(0,w.jsx)(ce,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,w.jsx)(A,{icon:(0,w.jsx)(i,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,w.jsx)(A,{icon:(0,w.jsx)(le,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,w.jsx)(A,{icon:(0,w.jsx)(S,{}),label:e(`command.processList.stats.longest`),value:k(X.longest),tone:X.longest>=T?`warn`:void 0})]}),(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative`,children:[(0,w.jsx)(l,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,w.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,w.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,w.jsx)(re,{className:`size-3`})})]}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,w.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:M,onChange:e=>N(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,w.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:P,onChange:e=>he(Number(e.target.value)),disabled:!M,children:de.map(e=>(0,w.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,w.jsxs)(h,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,w.jsx)(ee,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,w.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,w.jsxs)(te,{className:`text-xs`,children:[(0,w.jsx)(s,{className:`sticky top-0 z-10 bg-background`,children:(0,w.jsxs)(t,{children:[(0,w.jsx)(u,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,w.jsx)(u,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,w.jsx)(u,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,w.jsx)(u,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,w.jsx)(r,{className:`size-3 text-primary`}):(0,w.jsx)(n,{className:`size-3 text-primary`})]})}),(0,w.jsx)(u,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,w.jsx)(u,{children:e(`command.processList.columns.info`)}),(0,w.jsx)(u,{className:`w-[50px]`})]})}),(0,w.jsx)(ne,{children:Z.length===0?(0,w.jsx)(t,{children:(0,w.jsx)(c,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:_.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(n=>{let r=D(n),i=O(n),a=!r&&i>=T,o=pe(n),s=me(n);return(0,w.jsxs)(t,{"data-state":F===n.Id?`selected`:void 0,className:`cursor-pointer ${r?`text-muted-foreground`:``} ${o?`bg-destructive/5`:a?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(n.Id),children:[(0,w.jsx)(c,{className:`font-mono tabular-nums`,children:(0,w.jsxs)(`span`,{className:`flex items-center gap-1`,children:[n.Id,s&&(0,w.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,w.jsx)(c,{children:n.User}),(0,w.jsx)(c,{className:`font-mono`,children:n.Host}),(0,w.jsx)(c,{className:`font-mono`,children:n.db??``}),(0,w.jsx)(c,{children:(0,w.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${r?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:n.Command})}),(0,w.jsx)(c,{className:`tabular-nums ${a?`font-semibold text-catppuccin-yellow`:``}`,children:k(i)}),(0,w.jsx)(c,{className:o?`font-medium text-destructive`:``,children:n.State}),(0,w.jsx)(c,{className:`max-w-[260px] truncate font-mono`,title:n.Info??``,children:n.Info??``}),(0,w.jsx)(c,{className:`text-right`,children:(0,w.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(),$(n.Id)},children:(0,w.jsx)(ue,{className:`size-3.5`})})})]},n.Id)})})]})}),Q&&(0,w.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,w.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,w.jsx)(`div`,{className:`flex-1`}),(0,w.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,w.jsx)(a,{className:`size-3`}):(0,w.jsx)(o,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,w.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,w.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,w.jsxs)(b,{children:[(0,w.jsx)(h,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,w.jsx)(h,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{j as ProcessListDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,l as t}from"./main-BwM1zx0B.js";import{n}from"./ui-store-5IssrgmG.js";import{l as r,m as i,t as a}from"./button-B2EsmMJs.js";import{a as o,i as s,n as c,r as l,t as u}from"./select-CtfiGpCP.js";import{n as d}from"./settings-store-DzQ3BP5e.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-FBpgH0QJ.js";import{t as v}from"./settings-controls-DyukG7E2.js";var y=r();function b(){let r=n(e=>e.activeDialog),b=n(e=>e.closeDialog),x=d(),S=x.update,{t:C}=i();return(0,y.jsx)(_,{open:r===`query-settings`,onOpenChange:e=>{e||b()},children:(0,y.jsxs)(m,{className:`sm:max-w-[560px]`,children:[(0,y.jsxs)(f,{children:[(0,y.jsx)(h,{children:C(`settings.query.title`)}),(0,y.jsx)(g,{children:C(`settings.query.description`)})]}),(0,y.jsxs)(`div`,{className:`grid gap-2`,children:[(0,y.jsx)(v,{id:`s-dryrun`,checked:x.previewAffectedRows,onChange:e=>S({previewAffectedRows:e}),pro:!0,label:`Dry run`,hint:`Before an UPDATE or DELETE runs, read its WHERE (joins included) as a SELECT and show how many rows it would change, with a sample of them, to confirm.`}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[1fr_140px] items-center gap-3 rounded-md border p-3`,children:[(0,y.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,y.jsx)(e,{htmlFor:`s-limit`,className:`text-sm font-medium`,children:`Result row limit`}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`LIMIT appended to SELECTs that have none. 0 disables.`})]}),(0,y.jsx)(t,{id:`s-limit`,type:`number`,min:0,step:100,value:x.resultRowLimit,onChange:e=>S({resultRowLimit:Math.max(0,Number(e.target.value)||0)})})]}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,y.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,y.jsx)(`span`,{className:`text-sm font-medium`,children:`F9 / Run button executes`}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Ctrl+Enter always runs the statement at the cursor; Ctrl+Shift+Enter the whole script.`})]}),(0,y.jsxs)(u,{value:x.executeScope,onValueChange:e=>S({executeScope:e}),children:[(0,y.jsx)(s,{children:(0,y.jsx)(o,{})}),(0,y.jsxs)(c,{children:[(0,y.jsx)(l,{value:`script`,children:`Whole script`}),(0,y.jsx)(l,{value:`statement`,children:`Statement at cursor`})]})]})]})]}),(0,y.jsx)(p,{children:(0,y.jsx)(a,{onClick:b,children:C(`settings.done`)})})]})})}export{b as QuerySettingsDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,Ct as n,Dt as r,G as i,H as a,J as o,L as s,Lt as c,Nt as l,Ot as u,Tt as d,W as f,X as p,Y as m,Z as ee,_t as te,at as h,bt as g,ct as ne,dt as re,ft as _,gt as v,mt as y,nt as b,ot as ie,pt as x,st as S,vt as C,xt as ae,yt as w}from"./main-BwM1zx0B.js";import{c as T,h as E,n as D}from"./ui-store-5IssrgmG.js";import{a as O,f as k,l as A,m as j,o as M,s as N}from"./button-B2EsmMJs.js";import{r as oe,t as se}from"./i18n-BQcNT-sS.js";import{_ as P,a as ce,o as le,r as ue,t as de}from"./dist-BYhFWvmC.js";import{t as F}from"./connection-store-D-Lp5EFj.js";import{n as fe,r as pe}from"./settings-store-DzQ3BP5e.js";import{n as me,t as he}from"./query-store-Cf_KUo80.js";import{n as ge,t as _e}from"./database-CfYjCIA2.js";import{c as ve,i as ye}from"./query-execution-_bzhSmJm.js";import{a as be,n as I,o as xe,r as Se,t as Ce}from"./dialog-FBpgH0QJ.js";var we=O(`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`}]]),Te=O(`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`}]]),Ee=O(`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`}]]),De=O(`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`}]]),Oe=O(`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`}]]),ke=O(`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`}]]),Ae=O(`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`}]]),je=O(`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`}]]),Me=O(`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`}]]),Ne=O(`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`}]]),Pe=O(`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`}]]),Fe=O(`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`}]]),Ie=O(`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`}]]),Le=O(`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`}]]),Re=O(`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`}]]),ze=O(`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`}]]),Be=O(`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`}]]),Ve=O(`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`}]]),He=O(`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`}]]),L=e(E(),1),Ue=1,We=.9,Ge=.8,Ke=.17,R=.1,z=.999,qe=.9999,B=.99,V=/[\\\/_+.#"@\[\(\{&]/,Je=/[\\\/_+.#"@\[\(\{&]/g,Ye=/[\s-]/,H=/[\s-]/g;function U(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Ue:B;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=U(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Ue:V.test(e.charAt(l-1))?(d*=Ge,p=e.slice(i,l-1).match(Je),p&&i>0&&(d*=z**+p.length)):Ye.test(e.charAt(l-1))?(d*=We,m=e.slice(i,l-1).match(H),m&&i>0&&(d*=z**+m.length)):(d*=Ke,i>0&&(d*=z**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=qe)),(d<R&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=U(e,t,n,r,l+1,a+2,o),f*R>d&&(d=f*R)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Xe(e){return e.toLowerCase().replace(H,` `)}function Ze(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,U(e,t,Xe(e),Xe(t),0,0,{})}var W=`[cmdk-group=""]`,G=`[cmdk-group-items=""]`,Qe=`[cmdk-group-heading=""]`,$e=`[cmdk-item=""]`,et=`${$e}:not([aria-disabled="true"])`,tt=`cmdk-item-select`,K=`data-value`,nt=(e,t,n)=>Ze(e,t,n),rt=L.createContext(void 0),q=()=>L.useContext(rt),it=L.createContext(void 0),at=()=>L.useContext(it),ot=L.createContext(void 0),st=L.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=vt(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:ee=!1,vimBindings:te=!0,...h}=e,g=P(),ne=P(),re=P(),_=L.useRef(null),v=bt();Y(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,y.emit()}},[u]),Y(()=>{v(6,ae)},[]);let y=L.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`)C(),x(),v(1,S);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(re);e?e.focus():(i=document.getElementById(g))==null||i.focus()}if(v(7,()=>{n.current.selectedItemId=w()?.id,y.emit()}),r||v(5,ae),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}y.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),b=L.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,ie(t,r)),v(2,()=>{x(),y.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]))),v(3,()=>{C(),x(),n.current.value||S(),y.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=w();v(4,()=>{C(),t?.getAttribute(`id`)===e&&S(),y.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:g,inputId:re,labelId:ne,listInnerRef:_}),[]);function ie(e,t){let r=s.current?.filter??nt;return e?r(e,n.current.search,t):0}function x(){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=_.current;T().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(G);t?t.appendChild(e.parentElement===t?e:e.closest(`${G} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${G} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=_.current?.querySelector(`${W}[${K}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function S(){let e=T().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(K);y.setState(`value`,e||void 0)}function C(){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=ie(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 ae(){var e;let t=w();t&&(t.parentElement?.firstChild===t&&((e=t.closest(W)?.querySelector(Qe))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function w(){return _.current?.querySelector(`${$e}[aria-selected="true"]`)}function T(){return Array.from(_.current?.querySelectorAll(et)||[])}function E(e){let t=T()[e];t&&y.setState(`value`,t.getAttribute(K))}function D(e){var t;let n=w(),r=T(),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&&y.setState(`value`,a.getAttribute(K))}function O(e){let t=w()?.closest(W),n;for(;t&&!n;)t=e>0?gt(t,W):_t(t,W),n=t?.querySelector(et);n?y.setState(`value`,n.getAttribute(K)):D(e)}let k=()=>E(T().length-1),A=e=>{e.preventDefault(),e.metaKey?k():e.altKey?O(1):D(1)},j=e=>{e.preventDefault(),e.metaKey?E(0):e.altKey?O(-1):D(-1)};return L.createElement(N.div,{ref:t,tabIndex:-1,...h,"cmdk-root":``,onKeyDown:e=>{var t;(t=h.onKeyDown)==null||t.call(h,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:te&&e.ctrlKey&&A(e);break;case`ArrowDown`:A(e);break;case`p`:case`k`:te&&e.ctrlKey&&j(e);break;case`ArrowUp`:j(e);break;case`Home`:e.preventDefault(),E(0);break;case`End`:e.preventDefault(),k();break;case`Enter`:{e.preventDefault();let t=w();if(t){let e=new Event(tt);t.dispatchEvent(e)}}}}},L.createElement(`label`,{"cmdk-label":``,htmlFor:b.inputId,id:b.labelId,style:St},c),Q(e,e=>L.createElement(it.Provider,{value:y},L.createElement(rt.Provider,{value:b},e))))}),ct=L.forwardRef((e,t)=>{let n=P(),r=L.useRef(null),i=L.useContext(ot),a=q(),o=vt(e),s=o.current?.forceMount??i?.forceMount;Y(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=yt(n,r,[e.value,e.children,r],e.keywords),l=at(),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);L.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(tt,f),()=>t.removeEventListener(tt,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:te,forceMount:h,keywords:g,...ne}=e;return L.createElement(N.div,{ref:k(r,t),...ne,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)}),lt=L.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=P(),s=L.useRef(null),c=L.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),[]),yt(o,s,[e.value,e.heading,c]);let f=L.useMemo(()=>({id:o,forceMount:i}),[i]);return L.createElement(N.div,{ref:k(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&L.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Q(e,e=>L.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},L.createElement(ot.Provider,{value:f},e))))}),ut=L.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=L.useRef(null),a=Z(e=>!e.search);return!n&&!a?null:L.createElement(N.div,{ref:k(i,t),...r,"cmdk-separator":``,role:`separator`})}),dt=L.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=at(),o=Z(e=>e.search),s=Z(e=>e.selectedItemId),c=q();return L.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),L.createElement(N.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)}})}),ft=L.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=L.useRef(null),o=L.useRef(null),s=Z(e=>e.selectedItemId),c=q();return L.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)}}},[]),L.createElement(N.div,{ref:k(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Q(e,e=>L.createElement(`div`,{ref:k(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),pt=L.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return L.createElement(de,{open:n,onOpenChange:r},L.createElement(le,{container:o},L.createElement(ce,{"cmdk-overlay":``,className:i}),L.createElement(ue,{"aria-label":e.label,"cmdk-dialog":``,className:a},L.createElement(st,{ref:t,...s}))))}),mt=L.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?L.createElement(N.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ht=L.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return L.createElement(N.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>L.createElement(`div`,{"aria-hidden":!0},e)))}),J=Object.assign(st,{List:ft,Item:ct,Input:dt,Group:lt,Separator:ut,Dialog:pt,Empty:mt,Loading:ht});function gt(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function _t(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function vt(e){let t=L.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?L.useEffect:L.useLayoutEffect;function X(e){let t=L.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=at(),n=()=>e(t.snapshot());return L.useSyncExternalStore(t.subscribe,n,n)}function yt(e,t,n,r=[]){let i=L.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 bt=()=>{let[e,t]=L.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 xt(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&&L.isValidElement(t)?L.cloneElement(xt(t),{ref:t.ref},n(t.props.children)):n(t)}var St={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=A();function Ct({className:e,...t}){return(0,$.jsx)(J,{"data-slot":`command`,className:M(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function wt({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:r,showCloseButton:i=!0,...a}){return(0,$.jsxs)(Ce,{...a,children:[(0,$.jsxs)(be,{className:`sr-only`,children:[(0,$.jsx)(xe,{children:e}),(0,$.jsx)(Se,{children:t})]}),(0,$.jsx)(I,{className:M(`overflow-hidden p-0`,r),showCloseButton:i,children:(0,$.jsx)(Ct,{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 Tt({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)(v,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(J.Input,{"data-slot":`command-input`,className:M(`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 Et({className:e,...t}){return(0,$.jsx)(J.List,{"data-slot":`command-list`,className:M(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function Dt({...e}){return(0,$.jsx)(J.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function Ot({className:e,...t}){return(0,$.jsx)(J.Group,{"data-slot":`command-group`,className:M(`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 kt({className:e,...t}){return(0,$.jsx)(J.Item,{"data-slot":`command-item`,className:M(`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 At({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:M(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}var jt={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 Mt({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 Nt(){let{t:e}=j(),{activeDialog:v,closeDialog:E,openDialog:O}=D(),k=D(e=>e.setWelcomeVisible),A=D(e=>e.setFooterMessage),{executeCurrentQuery:N,executeCurrentStatement:P,executeWholeScript:ce,addNewQueryTab:le,disconnectActive:ue}=ee(),{capabilities:de}=b(),be=pe(),I=F(e=>e.activeConnections.find(t=>t.id===e.activeConnectionId)),xe=F(e=>e.activeConnectionId?e.transactionOpen[e.activeConnectionId]??!1:!1),Se=F(e=>e.updateProfile),Ce=o(e=>e.themeId),Ue=o(e=>e.setTheme),We=fe(e=>e.locale),Ge=fe(e=>e.setLocale),Ke=v===`quick-command`,R=I!==void 0,z=me(e=>{let t=F.getState().activeConnectionId;if(!t)return!1;let n=e.activeTabId[t];return(e.tabs[t]??he).find(e=>e.id===n)?.isExecuting??!1});async function qe(){let e=F.getState().activeConnectionId;if(!e)return;let t=ge(await _e(e));t&&D.getState().setFooterMessage(t)}let B=(0,L.useCallback)(e=>{E(),e()},[E]),V=(0,L.useCallback)(e=>A(e instanceof Error?e.message:String(e)),[A]),Je=()=>{let e=F.getState().activeConnectionId;e&&(p.getState().openERD(e),T(`erd_open`),me.getState().setActiveQueryTab(e,`erd`))},Ye=[{heading:e(`palette.groups.connection`),commands:[{id:`connect`,label:e(`palette.commands.connect`),icon:Fe,tone:`sky`,shortcut:`Alt+N`,keywords:[`connect`,`server`,`profile`,`login`],disabled:!be,action:()=>B(()=>O(`connect`))},{id:`disconnect`,label:e(`palette.commands.disconnect`),icon:S,tone:`red`,keywords:[`disconnect`,`close`],disabled:!R,action:()=>B(()=>{ue()})},{id:`read-only`,label:e(`menu.connection.readOnly`),icon:ae,tone:`yellow`,keywords:[`read only`,`safety`,`guard`],disabled:!R,checked:I?.readOnly===!0,action:()=>B(()=>{I&&Se(I.id,{readOnly:!I.readOnly})})},{id:`manual-transactions`,capability:`transactions`,label:e(`menu.connection.manualTransactions`),icon:n,tone:`lavender`,keywords:[`transaction`,`manual`,`autocommit`],disabled:!R,checked:I?.transactionMode===`manual`,action:()=>B(()=>{I&&Se(I.id,{transactionMode:I.transactionMode===`manual`?`auto`:`manual`})})},{id:`commit`,capability:`transactions`,label:e(`toolbar.commit`),icon:l,tone:`green`,keywords:[`commit`,`transaction`],disabled:!xe||!I,action:()=>B(()=>{I&&ye(I.id).catch(V)})},{id:`rollback`,capability:`transactions`,label:e(`toolbar.rollback`),icon:ne,tone:`peach`,keywords:[`rollback`,`transaction`,`undo`],disabled:!xe||!I,action:()=>B(()=>{I&&ve(I.id).catch(V)})}]},{heading:e(`palette.groups.query`),commands:[{id:`execute`,label:e(`palette.commands.executeQuery`),icon:w,tone:`green`,shortcut:`F9`,keywords:[`run`,`execute`,`sql`],disabled:!R,action:()=>B(()=>{N()})},{id:`stop-query`,label:e(`result.running.stop`),icon:x,tone:`red`,keywords:[`stop`,`cancel`,`abort`,`kill`],disabled:!z,action:()=>B(()=>{qe()})},{id:`execute-statement`,label:e(`menu.query.executeStatementAtCursor`),icon:Ee,tone:`green`,shortcut:`Ctrl+Enter`,keywords:[`run`,`statement`,`cursor`],disabled:!R,action:()=>B(()=>{P()})},{id:`execute-script`,label:e(`menu.query.executeWholeScript`),icon:ze,tone:`teal`,shortcut:`Ctrl+Shift+Enter`,keywords:[`run`,`script`,`batch`],disabled:!R,action:()=>B(()=>{ce()})},{id:`new-tab`,label:e(`palette.commands.newQueryTab`),icon:C,tone:`blue`,shortcut:`Alt+T`,keywords:[`new`,`tab`,`editor`],disabled:!R,action:()=>B(()=>le())},{id:`find-replace`,label:e(`menu.query.findReplace`),icon:Ie,tone:`lavender`,keywords:[`find`,`replace`,`search`],disabled:!R,action:()=>B(()=>O(`find-replace`))},{id:`local-history`,label:e(`menu.query.localHistory`),icon:Me,tone:`mauve`,keywords:[`history`,`snapshot`,`undo`],disabled:!R,action:()=>B(()=>O(`local-history`))}]},{heading:e(`palette.groups.database`),commands:[{id:`create-db`,capability:`multipleDatabases`,label:e(`palette.commands.createDatabase`),icon:r,tone:`blue`,keywords:[`create`,`database`,`schema`],disabled:!R,action:()=>B(()=>O(`create-database`))},{id:`alter-db`,capability:`multipleDatabases`,label:e(`menu.database.alter`),icon:De,tone:`blue`,keywords:[`alter`,`database`,`charset`],disabled:!R,action:()=>B(()=>O(`alter-database`))},{id:`copy-db`,capability:`multipleDatabases`,label:e(`menu.database.copy`),icon:u,tone:`sky`,keywords:[`copy`,`clone`,`database`],disabled:!R,action:()=>B(()=>O(`copy-database`))},{id:`schema-diff`,label:e(`menu.database.compare`),icon:Ae,tone:`mauve`,keywords:[`compare`,`diff`,`schema`,`sync`],pro:`compare_schemas`,disabled:!R,action:()=>B(()=>O(`schema-diff`))},{id:`data-diff`,label:e(`menu.database.compareData`),icon:je,tone:`mauve`,keywords:[`compare`,`diff`,`data`,`rows`],pro:`compare_data`,disabled:!R,action:()=>B(()=>O(`data-diff`))},{id:`group-by`,label:e(`menu.database.groupBy`),icon:y,tone:`mauve`,keywords:[`group`,`count`,`aggregate`,`distinct`,`summary`],disabled:!R,action:()=>B(()=>O(`group-by`))}]},{heading:e(`palette.groups.table`),commands:[{id:`create-table`,label:e(`palette.commands.createTable`),icon:_,tone:`green`,keywords:[`create`,`table`],disabled:!R,action:()=>B(()=>O(`create-table`))},{id:`alter-table`,label:e(`palette.commands.alterTable`),icon:h,tone:`yellow`,keywords:[`alter`,`table`,`column`],disabled:!R,action:()=>B(()=>O(`alter-table`))},{id:`duplicate-table`,label:e(`menu.table.duplicateStructure`),icon:Te,tone:`teal`,keywords:[`duplicate`,`structure`,`table`],disabled:!R,action:()=>B(()=>O(`duplicate-table-structure`))}]},{heading:e(`menu.export.title`),commands:[{id:`export-csv`,label:e(`menu.export.csv`),icon:ke,tone:`green`,keywords:[`export`,`csv`,`excel`],disabled:!R,action:()=>B(()=>O(`export-csv`))},{id:`export-html`,label:e(`menu.export.schemaHtml`),icon:Oe,tone:`peach`,keywords:[`export`,`html`,`schema`,`documentation`],disabled:!R,action:()=>B(()=>O(`export-html`))}]},{heading:e(`palette.groups.tools`),commands:[{id:`process-list`,capability:`processList`,label:e(`palette.commands.processList`),icon:c,tone:`red`,keywords:[`process`,`kill`,`connections`],disabled:!R,action:()=>B(()=>O(`process-list`))},{id:`variables`,capability:`variables`,label:e(`palette.commands.serverVariables`),icon:Be,tone:`lavender`,keywords:[`variables`,`server`,`settings`],disabled:!R,action:()=>B(()=>O(`variables`))},{id:`status`,capability:`status`,label:e(`palette.commands.serverStatus`),icon:re,tone:`teal`,keywords:[`status`,`server`,`metrics`],disabled:!R,action:()=>B(()=>O(`status`))},{id:`flush`,capability:`flush`,label:e(`palette.commands.flush`),icon:te,tone:`peach`,keywords:[`flush`,`cache`,`reload`],disabled:!R,action:()=>B(()=>O(`flush`))},{id:`user-manager`,capability:`users`,label:e(`palette.commands.userManager`),icon:ie,tone:`blue`,keywords:[`users`,`grants`,`privileges`],disabled:!R,action:()=>B(()=>O(`user-manager`))},{id:`scratchpad`,label:e(`menu.tools.scratchpad`),icon:g,tone:`yellow`,keywords:[`scratchpad`,`sqlite`,`local`],pro:`scratchpad`,action:()=>B(()=>{i().catch(V)})},{id:`federated`,label:e(`menu.tools.federated`),icon:He,tone:`mauve`,keywords:[`federated`,`cross`,`join`,`connections`],pro:`federated`,action:()=>B(()=>{a().catch(V)})},{id:`erd`,label:e(`menu.tools.viewErd`),icon:Pe,tone:`sky`,keywords:[`erd`,`diagram`,`relations`],disabled:!R,action:()=>B(Je)}]},{heading:e(`menu.settings.theme`),commands:m().map(e=>({id:`theme-${e.id}`,label:e.name,tone:`lavender`,keywords:[`theme`,`color`,`appearance`,`dark`,`light`,e.id],checked:Ce===e.id,swatch:e,action:()=>B(()=>Ue(e.id))}))},{heading:e(`menu.settings.language`),commands:[`auto`,...se].map(t=>({id:`locale-${t}`,label:t===`auto`?e(`language.auto`,{name:e(`language.${oe()}`)}):e(`language.${t}`),icon:Ne,tone:`teal`,keywords:[`language`,`locale`,`i18n`,t],checked:We===t,action:()=>B(()=>Ge(t))}))},{heading:e(`menu.settings.title`),commands:[{id:`safety-settings`,label:e(`menu.settings.safety`),icon:Ve,tone:`yellow`,keywords:[`safety`,`settings`,`row limit`,`preferences`],action:()=>B(()=>O(`safety-settings`))}]},{heading:e(`menu.help.title`),commands:[{id:`documentation`,label:e(`menu.help.documentation`),icon:we,tone:`blue`,keywords:[`docs`,`documentation`,`manual`,`help`],action:()=>B(()=>{window.open(f(),`_blank`,`noopener,noreferrer`)})},{id:`getting-started`,label:e(`menu.help.gettingStarted`),icon:Le,tone:`green`,keywords:[`welcome`,`onboarding`,`sample`,`getting started`],action:()=>B(()=>k(!0))},{id:`terms`,label:e(`menu.help.terms`),icon:Re,tone:`peach`,keywords:[`terms`,`privacy`,`legal`],action:()=>B(()=>O(`terms`))},{id:`about`,label:e(`menu.help.about`),icon:d,tone:`sky`,keywords:[`about`,`version`,`agent`],action:()=>B(()=>O(`about`))}]}];function H(e){e||E()}let U=Ye.map(e=>({...e,commands:e.commands.filter(e=>!e.capability||de[e.capability])})).filter(e=>e.commands.length>0);return(0,$.jsxs)(wt,{open:Ke,onOpenChange:H,title:e(`palette.title`),description:e(`palette.description`),children:[(0,$.jsx)(Tt,{placeholder:e(`palette.inputPlaceholder`)}),(0,$.jsxs)(Et,{className:`max-h-[60vh]`,children:[(0,$.jsx)(Dt,{children:e(`palette.empty`)}),U.map(e=>(0,$.jsx)(Ot,{heading:e.heading,children:e.commands.map(n=>(0,$.jsxs)(kt,{value:`${e.heading} ${n.label}`,keywords:n.keywords,disabled:n.disabled,onSelect:()=>{(!n.pro||s(n.pro))&&n.action()},children:[n.swatch?(0,$.jsx)(Mt,{theme:n.swatch}):n.icon?(0,$.jsx)(n.icon,{className:M(`size-4`,jt[n.tone])}):null,(0,$.jsx)(`span`,{className:`truncate`,children:n.label}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[n.pro&&(0,$.jsx)(t,{className:`ml-0`}),n.checked&&(0,$.jsx)(l,{className:`size-3.5 text-catppuccin-green`}),n.shortcut&&(0,$.jsx)(At,{className:`ml-0`,children:n.shortcut})]})]},n.id))},e.heading))]})]})}export{Nt as QuickCommandPalette};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{At as t,Pt as n,St as r,d as i,f as a,kt as o,m as s,p as c,rt as l,wt as u}from"./main-BwM1zx0B.js";import{h as d,n as f,t as p}from"./ui-store-5IssrgmG.js";import{a as m,l as h,m as g,t as _}from"./button-B2EsmMJs.js";import{t as v}from"./connection-store-D-Lp5EFj.js";import{n as y}from"./settings-store-DzQ3BP5e.js";import{a as b}from"./database-CfYjCIA2.js";import{l as x,t as S}from"./query-execution-_bzhSmJm.js";import{a as C,i as w,n as T,o as E,r as ee,t as D}from"./dialog-FBpgH0QJ.js";var O=m(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),k=e(d(),1);function A(e){let t=e.slice(e.indexOf(`(`)+1,e.lastIndexOf(`)`)),n=[],r=/'((?:[^']|'')*)'/g,i;for(;i=r.exec(t);)n.push(i[1].replaceAll(`''`,`'`));return n}function j(e,t={}){let{oracleDate:n=!1}=t,r=e.type.trim(),i=r.toLowerCase(),a=/\bunsigned\b/.test(i);if(/^enum\(/.test(i))return{kind:`enum`,options:A(r)};if(/^set\(/.test(i))return{kind:`set`,options:A(r)};if(/^(tinyint\(1\)|bool|boolean|bit\(1\)|bit)(?![\w(])/.test(i))return{kind:`boolean`};let o=/^number(?:\((\d+|\*)(?:,\s*(-?\d+))?\))?$/.exec(i);if(o)return o[2]&&Number(o[2])>0?{kind:`decimal`}:o[1]?{kind:`integer`}:{kind:`decimal`};if(/^(tinyint|smallint|mediumint|int|integer|bigint|int2|int4|int8|serial|bigserial|smallserial)\b/.test(i))return{kind:`integer`,unsigned:a};if(/^(decimal|numeric|float|double|real|money|float4|float8|double precision)\b/.test(i))return{kind:`decimal`,unsigned:a};if(/^(datetime2|datetime|timestamp|smalldatetime|datetimeoffset)\b/.test(i))return{kind:`datetime`};if(/^date\b/.test(i))return{kind:n?`datetime`:`date`};if(/^(time|timetz)\b/.test(i))return{kind:`time`};if(/^(json|jsonb)\b/.test(i))return{kind:`json`};if(/^(uuid|uniqueidentifier)\b/.test(i))return{kind:`uuid`};if(/^(blob|tinyblob|mediumblob|longblob|binary|varbinary|bytea|raw|image|bfile)\b/.test(i))return{kind:`binary`};if(/^(text|ntext|tinytext|mediumtext|longtext|clob|nclob|long)\b/.test(i)||/^n?(?:var)?char2?\(max\)/.test(i))return{kind:`text`};let s=/^n?(?:var)?char2?(?:acter)?(?:\s+varying)?\((\d+)(?:\s+(?:char|byte))?\)/.exec(i);return s?{kind:`string`,maxLength:Number(s[1])}:{kind:`string`}}var M=/auto_increment|identity|generated/i;function N(e){return M.test(e.extra)||/^(serial|bigserial|smallserial)\b/i.test(e.type)?{mode:`auto`,text:``}:e.defaultValue===null?e.nullable?{mode:`null`,text:``}:{mode:`value`,text:``}:{mode:`default`,text:``}}function P(e){return e==null?{mode:`keep`,text:``}:{mode:`keep`,text:F(e)}}function F(e){if(e==null)return``;if(typeof e==`object`){if(ArrayBuffer.isView(e))return``;if(e instanceof Date)return e.toISOString();try{return JSON.stringify(e,null,2)}catch{return String(e)}}return String(e)}function I(e,t){let n=t.trim();switch(e.kind){case`integer`:{if(!/^[+-]?\d+$/.test(n))return{error:`integer`};if(e.unsigned&&n.startsWith(`-`))return{error:`unsigned`};let t=Number(n);return{value:Number.isSafeInteger(t)?t:BigInt(n)}}case`decimal`:return n===``||Number.isNaN(Number(n))?{error:`number`}:{value:Number(n)};case`boolean`:return{value:n===`true`||n===`1`};case`json`:try{return{value:JSON.parse(n===``?`null`:n)}}catch{return{error:`json`}}case`set`:return{value:n};case`date`:return n&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?{error:`date`}:{value:n};case`datetime`:return n&&!/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?)?)?([+-]\d{2}:?\d{2}|Z)?$/.test(n)?{error:`datetime`}:{value:n};case`time`:return n&&!/^-?\d{1,3}:\d{2}(:\d{2}(\.\d+)?)?$/.test(n)?{error:`time`}:{value:n};default:return{value:t}}}var L=h(),R={integer:`result.rowForm.invalid.integer`,unsigned:`result.rowForm.invalid.unsigned`,number:`result.rowForm.invalid.number`,json:`result.rowForm.invalid.json`,date:`result.rowForm.invalid.date`,datetime:`result.rowForm.invalid.datetime`,time:`result.rowForm.invalid.time`};function z(e){return String(e).padStart(2,`0`)}function B(e){let t=new Date,n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`,r=`${z(t.getHours())}:${z(t.getMinutes())}:${z(t.getSeconds())}`;return e===`date`?n:e===`time`?r:`${n} ${r}`}function V(e){let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(!t)return;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?void 0:n}function H({spec:e,state:t,disabled:r,onText:l}){let{t:u}=g(),d=`w-full rounded border bg-background px-2 py-1 text-sm font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50`;switch(e.kind){case`boolean`:return(0,L.jsxs)(`select`,{className:d,value:t.text===`true`||t.text===`1`?`true`:`false`,onChange:e=>l(e.target.value),disabled:r,children:[(0,L.jsx)(`option`,{value:`true`,children:`TRUE`}),(0,L.jsx)(`option`,{value:`false`,children:`FALSE`})]});case`enum`:return(0,L.jsxs)(`select`,{className:d,value:t.text,onChange:e=>l(e.target.value),disabled:r,children:[!e.options?.includes(t.text)&&(0,L.jsx)(`option`,{value:t.text,children:t.text||`—`}),e.options?.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]});case`set`:{let n=new Set(t.text.split(`,`).map(e=>e.trim()).filter(Boolean));return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 rounded border bg-background px-2 py-1.5`,children:e.options?.map(t=>(0,L.jsxs)(`label`,{className:`flex items-center gap-1 text-xs font-mono`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:n.has(t),disabled:r,onChange:r=>{let i=new Set(n);r.target.checked?i.add(t):i.delete(t),l(e.options.filter(e=>i.has(e)).join(`,`))}}),t]},t))})}case`integer`:case`decimal`:return(0,L.jsx)(`input`,{className:`${d} tabular-nums`,inputMode:`decimal`,value:t.text,onChange:e=>l(e.target.value),disabled:r,placeholder:e.kind===`integer`?`0`:`0.00`});case`date`:case`datetime`:{let[f,p]=t.text.trim().split(/[ T]/);return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${d} flex-1`,value:t.text,onChange:e=>l(e.target.value),disabled:r,placeholder:e.kind===`date`?`YYYY-MM-DD`:`YYYY-MM-DD HH:MM:SS`}),(0,L.jsxs)(a,{children:[(0,L.jsx)(s,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:r,title:u(`result.rowForm.pickDate`),children:(0,L.jsx)(n,{className:`size-3.5`})})}),(0,L.jsx)(c,{className:`w-auto p-0`,align:`end`,children:(0,L.jsx)(i,{mode:`single`,selected:V(f??``),defaultMonth:V(f??``),onSelect:t=>{if(!t)return;let n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`;l(e.kind===`date`?n:`${n} ${p||`00:00:00`}`)}})})]}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:r,onClick:()=>l(B(e.kind)),title:u(`result.rowForm.now`),children:(0,L.jsx)(o,{className:`size-3.5`})})]})}case`time`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${d} flex-1`,value:t.text,onChange:e=>l(e.target.value),disabled:r,placeholder:`HH:MM:SS`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:r,onClick:()=>l(B(`time`)),title:u(`result.rowForm.now`),children:(0,L.jsx)(o,{className:`size-3.5`})})]});case`json`:{let e=!0;try{t.text.trim()&&JSON.parse(t.text)}catch{e=!1}return(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`textarea`,{className:`${d} min-h-[96px] resize-y text-xs ${e?``:`border-destructive`}`,value:t.text,onChange:e=>l(e.target.value),disabled:r,spellCheck:!1,placeholder:`{}`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:r||!e||!t.text.trim(),onClick:()=>{try{l(JSON.stringify(JSON.parse(t.text),null,2))}catch{}},children:[(0,L.jsx)(O,{className:`size-3`}),u(`result.rowForm.formatJson`)]}),!e&&(0,L.jsx)(`span`,{className:`text-[10px] text-destructive`,children:u(`result.rowForm.invalid.json`)})]})]})}case`text`:return(0,L.jsx)(`textarea`,{className:`${d} min-h-[72px] resize-y`,value:t.text,onChange:e=>l(e.target.value),disabled:r,spellCheck:!1});case`binary`:return(0,L.jsx)(`div`,{className:`rounded border bg-muted/40 px-2 py-1 text-xs italic text-muted-foreground`,children:u(`result.rowForm.binaryUnsupported`)});case`uuid`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${d} flex-1`,value:t.text,onChange:e=>l(e.target.value),disabled:r,placeholder:`00000000-0000-0000-0000-000000000000`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:r,onClick:()=>l(crypto.randomUUID()),title:u(`result.rowForm.generateUuid`),children:(0,L.jsx)(O,{className:`size-3.5`})})]});default:{let n=t.text.length>80||t.text.includes(`
|
|
2
|
+
`);return(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[n?(0,L.jsx)(`textarea`,{className:`${d} min-h-[56px] resize-y`,value:t.text,onChange:e=>l(e.target.value),disabled:r,spellCheck:!1}):(0,L.jsx)(`input`,{className:d,value:t.text,onChange:e=>l(e.target.value),disabled:r,maxLength:e.maxLength}),e.maxLength&&(0,L.jsxs)(`div`,{className:`text-right text-[10px] tabular-nums ${t.text.length>e.maxLength?`text-destructive`:`text-muted-foreground`}`,children:[t.text.length,`/`,e.maxLength]})]})}}}function U(){let{t:e}=g(),n=p(`row-form`),i=f(e=>e.closeDialog),a=f(e=>e.setFooterMessage),o=l(n?.connectionId??``),s=v(e=>n?e.transactionOpen[n.connectionId]:!1),[c,d]=(0,k.useState)(null),[m,h]=(0,k.useState)(null),[O,A]=(0,k.useState)({}),[M,F]=(0,k.useState)({}),[z,B]=(0,k.useState)(null),[V,U]=(0,k.useState)(!1),W=n?.mode===`edit`;(0,k.useEffect)(()=>{if(!n)return;let e=!1,t=b(n.serverConnectionId);return o.introspect.listColumns(t,n.database,n.table).then(t=>{if(e)return;d(t);let r={};for(let e of t)if(n.mode===`edit`){let t=n.fields.find(t=>t.orgName===e.name);r[e.name]=P(t?n.row?.[t.name]:void 0)}else r[e.name]=N(e);A(r)}).catch(t=>{e||h(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[n?.serverConnectionId,n?.database,n?.table,n?.mode]);let G=(0,k.useMemo)(()=>new Map((c??[]).map(e=>[e.name,j(e,{oracleDate:o.id===`oracle`})])),[c,o.id]),K=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{...n[e],mode:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),q=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{mode:`value`,text:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),J=(0,k.useMemo)(()=>({__default:!0}),[]),Y=(0,k.useCallback)(()=>{if(!c)return null;let t=new Map,n={};for(let r of c){let i=O[r.name],a=G.get(r.name);if(!i||i.mode===`auto`||i.mode===`keep`)continue;if(i.mode===`null`){t.set(r.name,null);continue}if(i.mode==="default"){t.set(r.name,J);continue}let o=I(a,i.text);if(`error`in o){n[r.name]=e(R[o.error]??`result.rowForm.invalid.number`);continue}if(a.maxLength&&typeof o.value==`string`&&o.value.length>a.maxLength){n[r.name]=e(`result.rowForm.invalid.length`,{max:a.maxLength});continue}t.set(r.name,o.value)}return F(n),Object.keys(n).length>0?null:{values:t}},[c,O,G,e,J]),X=(0,k.useCallback)(e=>{if(!n)return null;let t=e=>e===J?`DEFAULT`:o.quoteLiteral(e);if(n.mode===`insert`){let r=[...e];return r.length===0?o.getQuery(`INSERT_DEFAULT_VALUES`,n.database,n.table):o.getQuery(`INSERT_TABLE`,n.database,n.table,r.map(([e])=>o.quoteIdentifier(e)).join(`, `),r.map(([,e])=>t(e)).join(`, `))}return!n.where||e.size===0?null:o.getQuery(`UPDATE_TABLE`,n.database,n.table,[...e].map(([e,n])=>`${o.quoteIdentifier(e)} = ${t(n)}`).join(`, `),n.where)},[n,o,J]),Z=(0,k.useMemo)(()=>{if(!c)return``;let e=new Map;for(let t of c){let n=O[t.name];if(!(!n||n.mode===`auto`||n.mode===`keep`)){if(n.mode===`null`)e.set(t.name,null);else if(n.mode==="default")e.set(t.name,J);else{let r=I(G.get(t.name),n.text);e.set(t.name,`error`in r?n.text:r.value)}}}return X(e)??``},[c,O,G,X,J]),Q=e=>{let t={};for(let[r,i]of e){if(i===J)continue;let e=n?.fields.find(e=>e.orgName===r);t[e?.name??r]=typeof i==`bigint`?i.toString():i}return t},te=()=>{let e=Y();!e||!n||(n.onStage?.(n.mode,Q(e.values)),i())},ne=async()=>{let t=Y();if(!t||!n)return;let r=X(t.values);if(!r){B(e(`result.rowForm.nothingToWrite`));return}U(!0),B(null);try{if(y.getState().previewGridCommit&&!await f.getState().requestDestructiveConfirm({title:e(W?`result.rowForm.confirmUpdateTitle`:`result.rowForm.confirmInsertTitle`,{table:`${n.database}.${n.table}`}),statements:[r],confirmLabel:e(W?`result.rowForm.update`:`result.rowForm.insert`)}))return;await x(n.connectionId,r,{database:n.database,skipDestructiveConfirm:!0}),a(e(W?`result.rowForm.updated`:`result.rowForm.inserted`,{table:`${n.database}.${n.table}`})),n.onCommitted?.(n.mode,Q(t.values)),i()}catch(e){if(e instanceof S)return;B(e instanceof Error?e.message:String(e))}finally{U(!1)}};if(!n)return null;let $=(e,t,n,r)=>(0,L.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${r===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,onClick:()=>K(e,t),children:n});return(0,L.jsx)(D,{open:!0,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(T,{className:`flex max-h-[90vh] flex-col sm:max-w-[860px]`,children:[(0,L.jsxs)(C,{children:[(0,L.jsx)(E,{children:e(W?`result.rowForm.editTitle`:`result.rowForm.insertTitle`)}),(0,L.jsxs)(ee,{className:`font-mono text-xs`,children:[n.database,`.`,n.table]})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto rounded-md border`,children:[m&&(0,L.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:m}),!c&&!m&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,L.jsx)(r,{className:`size-4 animate-spin`}),e(`result.rowForm.loading`)]}),c&&(0,L.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background`,children:(0,L.jsxs)(`tr`,{className:`text-left text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,L.jsx)(`th`,{className:`w-[38%] border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colColumn`)}),(0,L.jsx)(`th`,{className:`border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colValue`)})]})}),(0,L.jsx)(`tbody`,{children:c.map(r=>{let i=O[r.name]??{mode:`value`,text:``},a=G.get(r.name),o=i.mode===`auto`,s=M[r.name],c=r.key===`PRI`,l=n.fields.find(e=>e.orgName===r.name),d=!!l&&!!n.row&&n.row[l.name]===null;return(0,L.jsxs)(`tr`,{className:`align-top ${s?`bg-destructive/5`:`hover:bg-muted/30`}`,children:[(0,L.jsxs)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,title:r.name,children:r.name}),c&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold text-catppuccin-yellow`,children:[(0,L.jsx)(u,{className:`size-2.5`}),`PK`]})]}),(0,L.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded bg-muted px-1 py-px font-mono`,children:r.type}),!r.nullable&&(0,L.jsx)(`span`,{children:`NOT NULL`}),r.defaultValue!==null&&(0,L.jsxs)(`span`,{className:`font-mono`,title:e(`result.rowForm.defaultValue`),children:[`= `,r.defaultValue]}),r.extra&&(0,L.jsx)(`span`,{children:r.extra})]}),r.comment&&(0,L.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:r.comment})]}),(0,L.jsx)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i.mode===`keep`?(0,L.jsx)(`div`,{className:`cursor-text truncate rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs text-muted-foreground`,onClick:()=>K(r.name,`value`),title:e(`result.rowForm.clickToChange`),children:d?(0,L.jsx)(`span`,{className:`italic`,children:`NULL`}):i.text||(0,L.jsx)(`span`,{className:`italic`,children:e(`result.rowForm.empty`)})}):i.mode===`value`?(0,L.jsx)(H,{spec:a,state:i,disabled:!1,onText:e=>q(r.name,e)}):(0,L.jsx)(`div`,{className:`rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs italic text-muted-foreground`,children:i.mode===`null`?`NULL`:i.mode==="default"?`DEFAULT (${r.defaultValue??``})`:e(`result.rowForm.autoHint`)}),s&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-[11px] text-destructive`,children:[(0,L.jsx)(t,{className:`size-3`}),s]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded border bg-background p-0.5`,children:[W&&$(r.name,`keep`,e(`result.rowForm.mode.keep`),i.mode),(o||!W&&/auto_increment|identity/i.test(r.extra))&&$(r.name,`auto`,e(`result.rowForm.mode.auto`),i.mode),$(r.name,`value`,e(`result.rowForm.mode.value`),i.mode),r.nullable&&$(r.name,`null`,`NULL`,i.mode),r.defaultValue!==null&&$(r.name,`default`,`DEFAULT`,i.mode)]})]})})]},r.name)})})]})]}),c&&(0,L.jsxs)(`div`,{className:`shrink-0 rounded-md border bg-muted/30`,children:[(0,L.jsx)(`div`,{className:`border-b px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`result.rowForm.preview`)}),(0,L.jsx)(`pre`,{className:`max-h-24 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Z||(0,L.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`result.rowForm.nothingToWrite`)})})]}),z&&(0,L.jsx)(`div`,{className:`shrink-0 rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:z}),(0,L.jsxs)(w,{className:`items-center`,children:[s&&(0,L.jsx)(`span`,{className:`mr-auto text-[11px] text-catppuccin-yellow`,children:e(`result.rowForm.inTransaction`)}),(0,L.jsx)(_,{variant:`outline`,onClick:()=>i(),disabled:V,children:e(`command.close`)}),n.onStage&&(0,L.jsx)(_,{variant:`outline`,onClick:te,disabled:V||!c,title:e(`result.rowForm.stageHint`),children:e(W?`result.rowForm.stageEdit`:`result.rowForm.stageInsert`)}),(0,L.jsxs)(_,{onClick:()=>void ne(),disabled:V||!c,children:[V&&(0,L.jsx)(r,{className:`mr-1 size-3.5 animate-spin`}),e(W?`result.rowForm.update`:`result.rowForm.insert`)]})]})]})})}export{U as RowFormDialog};
|