planche 0.7.11 → 0.7.12
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/README.md +4 -2
- package/app/assets/{AboutDialog-CNjQdT5u.js → AboutDialog-BgXjXtZM.js} +1 -1
- package/app/assets/ConnectDialog-C4hFXJNz.js +1 -0
- package/app/assets/CopyDatabaseDialog-BDhBi8q_.js +1 -0
- package/app/assets/CopyTableDialog-yVaE4uZc.js +1 -0
- package/app/assets/CreateDatabaseDialog-CRl_uxJn.js +1 -0
- package/app/assets/DataDiffDialog-DeWk86vx.js +1 -0
- package/app/assets/{DownloadToCSVDialog-fZOrfJCY.js → DownloadToCSVDialog-CKR8db_j.js} +2 -2
- package/app/assets/EditSchemaDialog-DlNhqzPf.js +1 -0
- package/app/assets/FindReplaceDialog--7xgdbg2.js +1 -0
- package/app/assets/{FlushDialog-DuPXbGV8.js → FlushDialog-D16P2NwU.js} +1 -1
- package/app/assets/LinkColumnDialog-RMXrjpQw.js +1 -0
- package/app/assets/LocalHistoryDialog-CFWlMqmC.js +1 -0
- package/app/assets/ProcessListDialog-yeLScIOg.js +1 -0
- package/app/assets/QuickCommandPalette-Bnx9pn3q.js +1 -0
- package/app/assets/RowFormDialog-BxKCVqqy.js +2 -0
- package/app/assets/{SafetySettingsDialog-COTjlwgg.js → SafetySettingsDialog-COkaLd2E.js} +1 -1
- package/app/assets/SchemaDiffDialog-D9M93PUV.js +7 -0
- package/app/assets/{SchemaToHTMLDialog-6ZXb_qWR.js → SchemaToHTMLDialog-DVrwIeO4.js} +1 -1
- package/app/assets/StatusDialog-Cd9Dcile.js +1 -0
- package/app/assets/{TermsDialog-Bj_qh6sW.js → TermsDialog-B8Ehf7Ck.js} +1 -1
- package/app/assets/UserAddDialog-B5m0NAuK.js +1 -0
- package/app/assets/UserManagerDialog-BsmJC6nO.js +1 -0
- package/app/assets/VariablesDialog-Dth7P3eJ.js +1 -0
- package/app/assets/{button-BRD_vJ8s.js → button--s6nUzD8.js} +1 -1
- package/app/assets/chevron-up-QmvRX9Fw.js +1 -0
- package/app/assets/connection-store-CAPTzFtT.js +1 -0
- package/app/assets/{database-C07SXivf.js → database-4FcrMRGA.js} +1 -1
- package/app/assets/{dialog-1MXGAorC.js → dialog-CJoWJzRo.js} +1 -1
- package/app/assets/{dist-BnghYOTd.js → dist-CBYDYlja.js} +1 -1
- package/app/assets/{dist-Bo6CxCQ0.js → dist-DgJHEXPr.js} +1 -1
- package/app/assets/{dist-DGLzi2V0.js → dist-pKt0y9E-.js} +1 -1
- package/app/assets/{engine-tGsnPQEm.js → engine-DWYEiSZM.js} +1 -1
- package/app/assets/{i18n-ByO9kvGG.js → i18n-C-w8Q5E_.js} +1 -1
- package/app/assets/main-CvsCEaFQ.js +940 -0
- package/app/assets/main-pmntwMQg.css +2 -0
- package/app/assets/pro-usage-Dp3liEjn.js +1 -0
- package/app/assets/{query-execution-Bqix04tS.js → query-execution-ODxyrvnD.js} +3 -3
- package/app/assets/{query-store-Cu277RoH.js → query-store-CRp9AQS5.js} +1 -1
- package/app/assets/{select-teWP1vRl.js → select-BUFSgZ7u.js} +1 -1
- package/app/assets/{settings-store-hXzC7s8K.js → settings-store-CYHWBgNo.js} +1 -1
- package/app/assets/table-copy-_VnDBCJc.js +1 -0
- package/app/assets/{ui-store-VGM_km-l.js → ui-store-DfspmPOn.js} +1 -1
- package/app/assets/{use-engine-CkfCgSB4.js → use-engine-DSWrApw6.js} +1 -1
- package/app/assets/{user-store-dpr5Uk1B.js → user-store-l9ZslFwK.js} +1 -1
- package/app/index.html +17 -16
- package/package.json +1 -1
- package/app/assets/ConnectDialog-JmGFmUJv.js +0 -1
- package/app/assets/CopyDatabaseDialog-BeIaHJEE.js +0 -1
- package/app/assets/CopyTableDialog-RTJBBuHd.js +0 -1
- package/app/assets/CreateDatabaseDialog-EQk84TRf.js +0 -1
- package/app/assets/DataDiffDialog-Bsk7fEYT.js +0 -1
- package/app/assets/EditSchemaDialog-C8sd3QZp.js +0 -1
- package/app/assets/FindReplaceDialog-Q-kOCd30.js +0 -1
- package/app/assets/LinkColumnDialog-Vfx3YnVz.js +0 -1
- package/app/assets/LocalHistoryDialog-D7PbCc1T.js +0 -1
- package/app/assets/ProcessListDialog-BcrS--N5.js +0 -1
- package/app/assets/QuickCommandPalette-DgmR-AEB.js +0 -1
- package/app/assets/RowFormDialog-BeY3wZoM.js +0 -2
- package/app/assets/SchemaDiffDialog-DShgozcV.js +0 -7
- package/app/assets/StatusDialog-DYnmWcrB.js +0 -1
- package/app/assets/UserAddDialog-WJfSy3UY.js +0 -1
- package/app/assets/UserManagerDialog-Bp3YK2PA.js +0 -1
- package/app/assets/VariablesDialog-CofNmdTr.js +0 -1
- package/app/assets/chevron-up-DVdt2433.js +0 -1
- package/app/assets/connection-store-Cn79Ey1H.js +0 -1
- package/app/assets/main-BKsXOMU1.css +0 -2
- package/app/assets/main-DKTBYrT9.js +0 -940
- package/app/assets/table-copy-NGGO-qDb.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-
|
|
2
|
-
import{
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-CvsCEaFQ.js","assets/ui-store-DfspmPOn.js","assets/button--s6nUzD8.js","assets/i18n-C-w8Q5E_.js","assets/dist-CBYDYlja.js","assets/dist-pKt0y9E-.js","assets/dist-DgJHEXPr.js","assets/app-storage-B6v72zLH.js","assets/connection-store-CAPTzFtT.js","assets/query-store-CRp9AQS5.js","assets/settings-store-CYHWBgNo.js","assets/database-4FcrMRGA.js","assets/dbms-Bsjvyvsp.js","assets/engine-DWYEiSZM.js","assets/schema-nodes-D3-cz2Xk.js","assets/use-engine-DSWrApw6.js","assets/pro-usage-Dp3liEjn.js","assets/table-copy-_VnDBCJc.js","assets/table-definition-Bs5VSn0X.js","assets/main-pmntwMQg.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as e,h as t,n,v as r}from"./ui-store-DfspmPOn.js";import{a as i,i as a}from"./i18n-C-w8Q5E_.js";import{t as o}from"./connection-store-CAPTzFtT.js";import{n as s}from"./query-store-CRp9AQS5.js";import{n as c}from"./settings-store-CYHWBgNo.js";import{N as l,b as u,j as d,o as f,r as p}from"./database-4FcrMRGA.js";import{a as m,o as h}from"./dbms-Bsjvyvsp.js";import{n as g,r as ee}from"./engine-DWYEiSZM.js";import{n as te,t as ne}from"./schema-nodes-D3-cz2Xk.js";var _=l(`editors`,()=>new Map),v=(e,t)=>`${e}:${t}`;function re(e,t,n){return _.set(v(e,t),n),()=>{_.get(v(e,t))===n&&_.delete(v(e,t))}}function y(e,t){return _.get(v(e,t))}function ie(e,t){let n=y(e,t),r=n?.getModel();if(!n||!r)return null;let i=n.getSelection();if(i&&!i.isEmpty())return{selection:r.getValueInRange(i)};let a=n.getPosition();return{cursorOffset:a?r.getOffsetAt(a):0}}var ae={undo:`undo`,redo:`redo`,cut:`editor.action.clipboardCutAction`,copy:`editor.action.clipboardCopyAction`,paste:`editor.action.clipboardPasteAction`,selectAll:`editor.action.selectAll`};function oe(e,t,n){let r=y(e,t);return r?(r.focus(),r.trigger(`menu`,ae[n],null),!0):!1}var se=[`<=>`,`->>`,`->`,`<>`,`!=`,`<=`,`>=`,`<<`,`>>`,`:=`,`||`,`&&`];function b(e){return/[A-Za-z_$\u0080-\uFFFF]/.test(e)}function x(e){return/[A-Za-z0-9_$\u0080-\uFFFF]/.test(e)}function S(e){return e>=`0`&&e<=`9`}function C(e){return e===` `||e===` `||e===`
|
|
3
3
|
`||e===`\r`||e===`\f`||e===`\v`}var ce=class{input;syntax;pos=0;delimiter;significantInStatement=0;constructor(e,t,n=`;`){this.input=e,this.syntax=t,this.delimiter=n}tokenize(){let e=[];for(;this.pos<this.input.length;){let t=this.next();t.kind===`terminator`||t.kind===`delimiter_command`?this.significantInStatement=0:t.kind!==`space`&&t.kind!==`comment`&&this.significantInStatement++,e.push(t)}return e}atLineStart(e){let t=e-1;for(;t>=0&&(this.input[t]===` `||this.input[t]===` `);)t--;return t<0||this.input[t]===`
|
|
4
4
|
`}make(e,t,n){let r=this.input.slice(t,n),i={kind:e,value:r,start:t,end:n};return e===`identifier`&&(i.upper=r.toUpperCase()),i}next(){let e=this.input,t=this.pos,n=e[t];if(C(n)){let n=t+1;for(;n<e.length&&C(e[n]);)n++;return this.pos=n,this.make(`space`,t,n)}if(e.startsWith(this.delimiter,t))return this.pos=t+this.delimiter.length,this.make(`terminator`,t,this.pos);if(n===`#`&&this.syntax.hashComments)return this.lineComment(t);if(n===`-`&&e[t+1]===`-`){let n=e[t+2];if(!this.syntax.dashCommentNeedsSpace||n===void 0||C(n))return this.lineComment(t)}if(n===`/`&&e[t+1]===`*`){let n=e.indexOf(`*/`,t+2);return this.pos=n===-1?e.length:n+2,this.make(`comment`,t,this.pos)}if(n===`$`&&this.syntax.dollarQuotes){let n=/^\$([A-Za-z_\u0080-\uFFFF][A-Za-z0-9_\u0080-\uFFFF]*)?\$/.exec(e.slice(t,t+64));if(n){let r=e.indexOf(n[0],t+n[0].length);return this.pos=r===-1?e.length:r+n[0].length,this.make(`string`,t,this.pos)}}if((n===`e`||n===`E`)&&e[t+1]===`'`&&this.syntax.dollarQuotes){this.pos=t+1;let e=this.quoted(t+1,`'`,`string`,!0);return this.make(`string`,t,e.end)}if(n===`'`)return this.quoted(t,`'`,`string`,this.syntax.backslashEscapes);if(n===`"`)return this.syntax.doubleQuoteIsIdentifier?this.quoted(t,`"`,`quoted_identifier`,!1):this.quoted(t,`"`,`string`,this.syntax.backslashEscapes);if((n===`x`||n===`X`||n===`b`||n===`B`||n===`n`||n===`N`)&&e[t+1]===`'`){this.pos=t+1;let e=this.quoted(t+1,`'`,`string`,this.syntax.backslashEscapes);return this.make(`string`,t,e.end)}if(n==="`")return this.quoted(t,"`",`quoted_identifier`,!1);if(n===`[`&&this.syntax.bracketIdentifiers){let n=e.indexOf(`]`,t+1);return this.pos=n===-1?e.length:n+1,this.make(`quoted_identifier`,t,this.pos)}if(S(n)||n===`.`&&S(e[t+1]??``))return this.number(t);if(n===`@`){let n=t+1;if(e[n]===`@`&&n++,e[n]===`'`||e[n]===`"`||e[n]==="`"){let r=e[n];this.pos=n;let i=this.quoted(n,r,`string`,this.syntax.backslashEscapes);return this.make(`variable`,t,i.end)}for(;n<e.length&&(x(e[n])||e[n]===`.`);)n++;return this.pos=n,this.make(`variable`,t,n)}if((n===`:`||n===`$`)&&b(e[t+1]??``)&&e[t+1]!==`$`){let n=t+1;for(;n<e.length&&x(e[n]);)n++;return this.pos=n,this.make(`variable`,t,n)}if(n===`?`){let n=t+1;for(;n<e.length&&S(e[n]);)n++;return this.pos=n,this.make(`placeholder`,t,n)}if(b(n)){let n=t+1;for(;n<e.length&&x(e[n])&&!e.startsWith(this.delimiter,n);)n++;let r=e.slice(t,n).toUpperCase();if(r===`DELIMITER`&&this.syntax.delimiterCommand&&this.significantInStatement===0){let r=n;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;let i=r;for(;i<e.length&&!C(e[i]);)i++;if(i>r)return this.delimiter=e.slice(r,i),this.pos=i,this.make(`delimiter_command`,t,i)}if(r===`GO`&&this.syntax.goBatchSeparator&&this.atLineStart(t)){let r=n;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;for(;r<e.length&&S(e[r]);)r++;for(;r<e.length&&(e[r]===` `||e[r]===` `||e[r]===`\r`);)r++;if(r>=e.length||e[r]===`
|
|
5
5
|
`)return this.pos=r,this.make(`delimiter_command`,t,r)}return this.pos=n,this.make(`identifier`,t,n)}if(n===`/`&&this.syntax.plsqlBlocks&&this.atLineStart(t)){let n=t+1;for(;n<e.length&&(e[n]===` `||e[n]===` `||e[n]===`\r`);)n++;if(n>=e.length||e[n]===`
|
|
6
6
|
`)return this.pos=n,this.make(`delimiter_command`,t,n)}if(n===`(`)return this.pos=t+1,this.make(`lparen`,t,this.pos);if(n===`)`)return this.pos=t+1,this.make(`rparen`,t,this.pos);for(let n of se)if(e.startsWith(n,t))return this.pos=t+n.length,this.make(`operator`,t,this.pos);return`=<>!+-*/%^~&|`.includes(n)?(this.pos=t+1,this.make(`operator`,t,this.pos)):`,.;:[]{}`.includes(n)?(this.pos=t+1,this.make(`punct`,t,this.pos)):(this.pos=t+1,this.make(`unknown`,t,this.pos))}lineComment(e){let t=this.input,n=e;for(;n<t.length&&t[n]!==`
|
|
7
|
-
`;)n++;return this.pos=n,this.make(`comment`,e,n)}quoted(e,t,n,r){let i=this.input,a=e+1;for(;a<i.length;){let e=i[a];if(r&&e===`\\`){a+=2;continue}if(e===t){if(i[a+1]===t){a+=2;continue}a++;break}a++}return this.pos=Math.min(a,i.length),this.make(n,e,this.pos)}number(e){let t=this.input,n=e;if(t[n]===`0`&&(t[n+1]===`x`||t[n+1]===`X`))for(n+=2;n<t.length&&/[0-9A-Fa-f]/.test(t[n]);)n++;else if(t[n]===`0`&&(t[n+1]===`b`||t[n+1]===`B`)&&(t[n+2]===`0`||t[n+2]===`1`))for(n+=2;n<t.length&&(t[n]===`0`||t[n]===`1`);)n++;else{for(;n<t.length&&S(t[n]);)n++;if(t[n]===`.`)for(n++;n<t.length&&S(t[n]);)n++;if((t[n]===`e`||t[n]===`E`)&&(S(t[n+1]??``)||(t[n+1]===`+`||t[n+1]===`-`)&&S(t[n+2]??``)))for(n+=2;n<t.length&&S(t[n]);)n++}return this.pos=n,this.make(`number`,e,n)}},le=new Set([`BEGIN`,`CASE`,`IF`,`LOOP`,`WHILE`,`REPEAT`]);function w(e){return e.kind!==`space`&&e.kind!==`comment`}function ue(e,t){let n=[],r=[],i=[],a=0,o=!1,s=t=>{for(let n=t+1;n<e.length;n++)if(w(e[n]))return e[n]},c=e=>{r.length!==0&&(n.push({tokens:r,start:r[0].start,end:r[r.length-1].end,terminated:e}),r=[],i=[],a=0,o=!1)};for(let n=0;n<e.length;n++){let l=e[n];if(l.kind===`delimiter_command`){i.length>0?c(!1):r=[];continue}if(l.kind===`terminator`){if(a>0&&l.value===`;`){r.push({...l,kind:`punct`}),i.push(l);continue}r.push(l),c(!0);continue}if(r.push(l),w(l)){if(l.kind===`identifier`){let e=l.upper,r=i.length===0;if(o&&(o=!1,le.has(e))){i.push(l);continue}if(e===`END`)a>0&&a--,o=!0;else if(e===`BEGIN`){let e=s(n),o=i[i.length-1];r?(t.plsqlBlocks||e?.kind===`identifier`&&e.upper===`NOT`)&&a++:!(e=>e!==void 0&&(e.kind===`operator`||e.kind===`rparen`||e.kind===`punct`&&(e.value===`,`||e.value===`.`)||e.kind===`identifier`&&e.upper===`FROM`))(e)&&!(o&&(o.kind===`operator`||o.kind===`punct`&&(o.value===`,`||o.value===`.`)))&&a++}else if(e===`CASE`)a++;else if(a>0&&(e===`IF`||e===`LOOP`||e===`WHILE`||e===`REPEAT`)){let e=s(n);e?.kind!==`lparen`&&(e?.kind!==`identifier`||e.upper!==`EXISTS`&&e.upper!==`NOT`)&&a++}}i.push(l)}}return c(!1),n}var de=new Set([`SELECT`,`VALUES`,`TABLE`,`WITH`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`CHECK`,`CHECKSUM`,`ANALYZE`,`OPTIMIZE`,`REPAIR`,`PRAGMA`]),fe=new Set([`SELECT`,`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`VALUES`,`TABLE`,`MERGE`]),pe=new Set([`TABLE`,`DATABASE`,`SCHEMA`,`TABLESPACE`]),me=new Set([`WHERE`,`SET`,`USING`,`ORDER`,`LIMIT`,`JOIN`,`INNER`,`LEFT`,`RIGHT`,`CROSS`,`NATURAL`,`STRAIGHT_JOIN`,`ON`,`PARTITION`,`AS`,`RETURNING`,`INDEXED`,`NOT`]);function T(e){if(e.kind!==`quoted_identifier`)return e.value;let t=e.value[0],n=t===`[`?`]`:t,r=e.value.slice(1,e.value.endsWith(n)?-1:void 0);return t!==`[`&&(r=r.replaceAll(n+n,n)),r}function E(e){return e.kind===`identifier`||e.kind===`quoted_identifier`}function D(e,t,n=me){let r=[];for(;t<e.length;){let i=e[t];if(!E(i)||i.kind===`identifier`&&n.has(i.upper))break;let a=[T(i)];for(t++;t+1<e.length&&e[t].kind===`punct`&&e[t].value===`.`&&E(e[t+1]);)a.push(T(e[t+1])),t+=2;if(r.push(a.join(`.`)),e[t]?.kind===`punct`&&e[t].value===`,`){t++;continue}break}return{names:r,next:t}}function O(e,t,n=0){let r=0;for(let i=n;i<e.length;i++){let n=e[i];if(n.kind===`lparen`)r++;else if(n.kind===`rparen`)r=Math.max(0,r-1);else if(r===0&&n.kind===`identifier`&&n.upper===t)return i}return-1}function he(e){let t=0;for(;t<e.length&&e[t].kind===`lparen`;)t++;if(t>=e.length||e[t].kind!==`identifier`)return{kind:``,index:t};if(e[t].upper!==`WITH`)return{kind:e[t].upper,index:t};let n=0,r=!1;for(let i=t+1;i<e.length;i++){let t=e[i];if(t.kind===`lparen`){n++,r=!1;continue}if(t.kind===`rparen`){n--,r=n===0;continue}if(n===0&&r&&t.kind===`identifier`&&fe.has(t.upper))return{kind:t.upper,index:i};r=!1}return{kind:`WITH`,index:t}}function ge(e,t){let n=O(e,`LIMIT`,t);if(n===-1)return null;let r=e[n+1];if(!r||r.kind!==`number`)return null;let i=e[n+2],a=e[n+3];return i?.kind===`punct`&&i.value===`,`&&a?.kind===`number`?{offset:Number(r.value),count:Number(a.value)}:i?.kind===`identifier`&&i.upper===`OFFSET`&&a?.kind===`number`?{offset:Number(a.value),count:Number(r.value)}:{offset:0,count:Number(r.value)}}function _e(e,t,n){let r=t=>e[t]?.kind===`identifier`?e[t].upper:void 0;switch(t){case`DROP`:{let t=n+1;r(t)===`TEMPORARY`&&t++;let i=r(t);if(!i)return null;t++,r(t)===`IF`&&(t+=2);let{names:a}=D(e,t,new Set([`ON`,`RESTRICT`,`CASCADE`]));return{action:`DROP`,objectType:i,names:a,dataLoss:pe.has(i)}}case`TRUNCATE`:{let t=n+1;r(t)===`TABLE`&&t++;let{names:i}=D(e,t);return{action:`TRUNCATE`,objectType:`TABLE`,names:i,dataLoss:!0}}case`DELETE`:{if(O(e,`WHERE`,n)!==-1)return null;let t=n+1;for(;r(t)===`LOW_PRIORITY`||r(t)===`QUICK`||r(t)===`IGNORE`;)t++;return{action:`DELETE_ALL`,names:r(t)===`FROM`?D(e,t+1).names:D(e,t,new Set([`FROM`])).names,dataLoss:!0}}case`UPDATE`:{if(O(e,`WHERE`,n)!==-1)return null;let t=n+1;for(;r(t)===`LOW_PRIORITY`||r(t)===`IGNORE`||r(t)===`OR`;)t+=r(t)===`OR`?2:1;let{names:i}=D(e,t);return{action:`UPDATE_ALL`,names:i,dataLoss:!0}}case`ALTER`:{if(r(n+1)!==`TABLE`)return null;let{names:t}=D(e,n+2,new Set([`ADD`,`DROP`,`MODIFY`,`CHANGE`,`RENAME`,`ALTER`])),i=[],a=0;for(let t=n+2;t<e.length;t++){let n=e[t];if(n.kind===`lparen`){a++;continue}if(n.kind===`rparen`){a--;continue}if(a!==0||n.kind!==`identifier`||n.upper!==`DROP`)continue;let r=e[t+1],o=r?.kind===`identifier`?r.upper:``;if(o===`COLUMN`){let n=e[t+2];n&&E(n)&&i.push(T(n))}else o===`PARTITION`?i.push(`PARTITION ${D(e,t+2).names.join(`, `)}`):r&&E(r)&&![`PRIMARY`,`FOREIGN`,`INDEX`,`KEY`,`CONSTRAINT`,`CHECK`,`DEFAULT`,`TABLESPACE`].includes(o)&&i.push(T(r))}return i.length===0?null:{action:`ALTER_DROP`,objectType:`TABLE`,names:t.map(e=>`${e} (${i.join(`, `)})`),dataLoss:!0}}default:return null}}function ve(e,t){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=e.terminated?e.tokens.slice(0,-1):e.tokens,i=r.length?r[r.length-1].end:e.start,a=t.slice(e.start,i).trim(),{kind:o,index:s}=he(n),c=de.has(o)||O(n,`RETURNING`,s)!==-1,l=c?ge(n,s):null,u=_e(n,o,s);return{sql:a,raw:t.slice(e.start,e.end),start:e.start,end:e.end,tokens:e.tokens,kind:o,isEmpty:n.length===0,returnsRows:c,limit:l,destructive:u}}function k(e,t){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=n.findIndex(e=>e.kind!==`lparen`);return O(n,t.toUpperCase(),Math.max(0,r))!==-1}function A(e){return e.start+e.raw.indexOf(e.sql)}function ye(e){let t=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),n=0;for(;n<t.length&&t[n].kind===`lparen`;)n++;let r=t[n];if(!r||r.kind!==`identifier`||r.upper!==`SELECT`)return-1;let i=r,a=t[n+1];return a?.kind===`identifier`&&(a.upper===`DISTINCT`||a.upper===`ALL`)&&(i=a),i.end-A(e)}var j=class{syntax;constructor(e){this.syntax=`syntax`in e?e.syntax:e}tokenize(e,t=`;`){return new ce(e,this.syntax,t).tokenize()}parse(e,t=`;`){return ue(this.tokenize(e,t),this.syntax).map(t=>ve(t,e))}statements(e,t=`;`){return this.parse(e,t).filter(e=>!e.isEmpty)}},be=new Set([`ORDER`,`LIMIT`,`RETURNING`,`OUTPUT`,`OPTION`]);function M(e,t,n,r){return n?e.slice(n.start-t,(r?r.start:2**53-1)-t).trim():``}function N(e,t,n){let r=t;for(;r<n&&e[r].kind===`identifier`&&(e[r].upper===`ONLY`||e[r].upper===`LOW_PRIORITY`||e[r].upper===`IGNORE`||e[r].upper===`QUICK`);)r++;if(r>=n||!E(e[r]))return null;let i=T(e[r]),a=e[r].kind===`quoted_identifier`;for(r++;r+1<n&&e[r].kind===`punct`&&e[r].value===`.`&&E(e[r+1]);)i=T(e[r+1]),a=e[r+1].kind===`quoted_identifier`,r+=2;return r<n&&e[r].kind===`identifier`&&e[r].upper===`AS`&&r++,r<n&&E(e[r])&&!(e[r].kind===`identifier`&&[`SET`,`WHERE`,`JOIN`,`INNER`,`LEFT`,`RIGHT`,`CROSS`,`USING`,`FROM`,`ON`,`NATURAL`,`STRAIGHT_JOIN`,`WITH`,`OUTPUT`].includes(e[r].upper))?(e[r].kind,e[r].value):a?`"${i.replaceAll(`"`,`""`)}"`:i}function xe(e,t=`"`){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=A(e),i=e.sql,a=e=>(e.startsWith(t)||e.startsWith(`"`)||e.startsWith("`")||e.startsWith(`[`),e),o=n[0];if(!o||o.kind!==`identifier`||o.upper!==`UPDATE`&&o.upper!==`DELETE`)return null;let s=O(n,`WHERE`),c=-1;for(let e of be){let t=O(n,e,s===-1?1:s);t!==-1&&(c===-1||t<c)&&(c=t)}let l=e=>e===-1?n.length:e,u=s===-1?``:` `+M(i,r,n[s],n[l(c)]),d=``;if(c!==-1&&(n[c].upper===`ORDER`||n[c].upper===`LIMIT`)){let e=[`RETURNING`,`OUTPUT`,`OPTION`].map(e=>O(n,e,c)).filter(e=>e!==-1);d=` `+M(i,r,n[c],e.length?n[Math.min(...e)]:void 0)}let f,p,m;if(o.upper===`UPDATE`){let e=O(n,`SET`);if(e===-1)return null;let t=O(n,`FROM`,e),a=e,o=M(i,r,n[1],n[a]);if(!o||n[1].kind===`lparen`)return null;if(p=N(n,1,a),m=o,t!==-1&&(s===-1||t<s)){let e=M(i,r,n[t+1],n[l(s===-1?c:s)]);f=p!==null&&RegExp(`(^|[\\s,])${p.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}(\\s|$|,)`,`i`).test(e)?e:`${o}, ${e}`}else f=o}else{let e=O(n,`FROM`);if(e===-1)return null;let t=O(n,`USING`,e),a=l(t===-1?s===-1?c:s:t),o=M(i,r,n[e+1],n[a]);if(!o||n[e+1]?.kind===`lparen`)return null;let u=M(i,r,n[1],n[e]),d=u?u.split(`,`)[0].trim().replace(/^(LOW_PRIORITY|QUICK|IGNORE)\s+/i,``):``;p=d||N(n,e+1,a),m=d||o;let h=t===-1?``:M(i,r,n[t+1],n[l(s===-1?c:s)]);f=h?`${o}, ${h}`:o}return p?{select:`SELECT ${a(p)}.* FROM ${f}${u}${d}`,count:d?`SELECT COUNT(*) AS affected FROM (SELECT 1 AS one FROM ${f}${u}${d}) planche_preview`:`SELECT COUNT(*) AS affected FROM ${f}${u}`,table:m,limited:/\bLIMIT\b/i.test(d)}:null}function P(e){return o.getState().activeConnections.find(t=>t.id===e)?.database||ne(u.getState().trees[e]??[])}function Se(e,t,n,r){return g(e).tree.objectPath(t,n,r,P(e))}function F(e,t){return g(e).tree.namespacePath(t,P(e))}function I(e,t){for(let n of e){if(n.id===t)return n;let e=I(n.children,t);if(e)return e}return null}async function Ce(e,t,n){let r=u.getState;for(let i=0;i<t.length;i++){let a=r().trees[e];if(!a)return!1;let o=I(a,t[i]);if(!o)return!1;if(i===t.length-1)return r().setSelected(e,o.id),!0;o.children.length===0&&!o.isLeaf?await n(e,o):o.isExpanded||r().setExpanded(e,o.id,!0)}return!1}function L(e,t){for(let n of e){if(n.id===t)return n;let e=L(n.children,t);if(e)return e}return null}function R(e,t){let n=u.getState(),r=n.trees[e];if(!r||!t)return;let i=F(e,t),a=null;for(let t of i){let i=L(r,t);if(!i||(a=i,i.isLeaf))break;!i.isExpanded&&i.children.length>0&&n.setExpanded(e,i.id,!0)}!a||a.id!==i[i.length-1]||(n.setSelected(e,a.id),!a.isExpanded&&a.children.length>0&&n.setExpanded(e,a.id,!0))}var z=e(n(),1);function we(e,t,n){let r=[];function i(e){for(let n of e){if(r.push(n),n.id===t||n.children.length>0&&i(n.children))return!0;r.pop()}return!1}i(e);for(let e=r.length-1;e>=0;e--)if(r[e].type===n)return r[e];return null}function B(e,t){for(let n of e){if(n.id===t)return n;if(n.children.length>0){let e=B(n.children,t);if(e)return e}}return null}var V=l(`schemaTreeLoadingRoots`,()=>new Set);function H(e){let t=o.getState().activeConnections.find(t=>t.id===e);return t?.serverConnectionId?{engine:g(e),run:p(t.serverConnectionId),database:t.database||void 0}:null}function Te(){let{setTree:e,setChildren:t,setNodeMetadata:n,setLoading:a}=u(),o=(0,z.useCallback)(async t=>{let n=H(t);if(n&&!V.has(t)){V.add(t);try{e(t,await n.engine.tree.loadRoot(n))}catch(n){let a=n instanceof Error?n.message:String(n);console.error(`Failed to load databases:`,n),r.getState().setFooterMessage(i.t(`schema.tree.loadDatabasesFailed`,{message:a})),e(t,[])}finally{V.delete(t)}}},[e]),s=(0,z.useCallback)(async(e,r)=>{if(!u.getState().trees[e])return;let i=H(e);if(i&&!r.isLeaf){a(e,r.id,!0);try{let a=await i.engine.tree.loadChildren(i,r);t(e,r.id,a),Promise.all(a.filter(e=>e.type===h.FOLDER&&e.metadata?.countable).map(async t=>{try{let r=await i.engine.tree.loadChildren(i,t);n(e,t.id,{count:r.length})}catch(e){console.error(`Failed to count ${t.text}:`,e)}}))}catch(t){console.error(`Failed to load children:`,t),a(e,r.id,!1)}}},[t,n,a]);return{loadDatabases:o,loadChildren:s,refreshNode:(0,z.useCallback)(async(e,t)=>{await s(e,t)},[s]),createNode:m,findNode:B,findAncestor:we}}async function U(e,t){let n=u.getState().trees[e];if(!n||!t)return;let r=H(e);if(!r)return;let i=F(e,t),a=te(n,i[i.length-1]);!a||a.children.length===0||await Promise.all(a.children.filter(e=>e.type===h.FOLDER).map(async t=>{try{let n=await r.engine.tree.loadChildren(r,t),i=u.getState();(t.children.length>0||t.isExpanded)&&i.setChildren(e,t.id,n),t.metadata?.countable&&i.setNodeMetadata(e,t.id,{count:n.length})}catch(e){console.error(`Failed to refresh ${t.text}:`,e)}}))}var W=class extends Error{sql;constructor(e,t){super(e),this.name=`QueryError`,this.sql=t}},G=class extends Error{constructor(e=`Cancelled`){super(e),this.name=`ExecutionCancelled`}};function Ee(e){let t=e.fields??[],n=e.records??[];return{fields:t.map(e=>({name:e.name,type:e.type,orgTable:e.orgTable??e.table??``,orgName:e.orgName??e.name,db:e.db??``})),rows:n.map(e=>{let n={};return t.forEach((t,r)=>{n[t.name]=e[r]}),n}),affectedRows:e.affectedRows??0,insertId:e.insertId??0,message:e.message??(n.length>0?i.t(`services.query.rowsReturned`,{count:n.length}):i.t(`services.query.rowsAffected`,{count:e.affectedRows??0}))}}async function K(e,t,n,r=ee(t)){let i=new Set(e.fields.map(e=>e.orgTable).filter(Boolean));if(i.size!==1)return e;let a=[...i][0];try{let i=await r.introspect.getPrimaryKeys(p(t),n,a);i.length>0&&(e.primaryKeys=i)}catch{}return!e.primaryKeys?.length&&e.fields.some(e=>e.name===`_rowid_`)&&(e.primaryKeys=[d]),e}var De=new Set([`SELECT`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`VALUES`,`TABLE`,`WITH`,`USE`,`SET`,`CHECK`,`CHECKSUM`]);function q(e){return e.kind===`PRAGMA`?!e.sql.includes(`=`):!(!De.has(e.kind)||e.destructive||e.kind===`SELECT`&&k(e,`INTO`))}var Oe=new Set([`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`MERGE`,`LOAD`]),ke=new Set([`CREATE`,`ALTER`,`DROP`,`TRUNCATE`,`RENAME`,`GRANT`,`REVOKE`,`FLUSH`,`LOCK`,`UNLOCK`]),Ae=new Set([`CREATE`,`ALTER`,`DROP`,`RENAME`]);function je(e){return Oe.has(e.kind)||!!e.destructive?.dataLoss}function Me(e,t,n=`limit`){if(t<=0||e.kind!==`SELECT`||e.limit!==null||k(e,`LIMIT`)||k(e,`INTO`)||k(e,`FOR`)||k(e,`LOCK`))return{sql:e.sql,limited:!1};if(n===`top`){if(k(e,`TOP`)||k(e,`OFFSET`))return{sql:e.sql,limited:!1};let n=ye(e);return n===-1?{sql:e.sql,limited:!1}:{sql:`${e.sql.slice(0,n)} TOP ${t}${e.sql.slice(n)}`,limited:!0}}return n===`fetch`?k(e,`FETCH`)||/\bROWNUM\b/i.test(e.sql)?{sql:e.sql,limited:!1}:{sql:`${e.sql} FETCH FIRST ${t} ROWS ONLY`,limited:!0}:{sql:`${e.sql} LIMIT ${t}`,limited:!0}}function Ne(e,t=0){let n=J();return n<=0?``:e.limitClause(n,t)}function J(){return c.getState().resultRowLimit}function Pe(e){let t=e.destructive,n=t.names.length?t.names.join(`, `):i.t(`services.destructive.unknownTarget`);switch(t.action){case`DROP`:return`DROP ${t.objectType} ${n}`;case`TRUNCATE`:return`TRUNCATE ${n}`;case`DELETE_ALL`:return i.t(`services.destructive.deleteAll`,{target:n});case`UPDATE_ALL`:return i.t(`services.destructive.updateAll`,{target:n});case`ALTER_DROP`:return i.t(`services.destructive.alterDrop`,{target:n})}}async function Fe(e){if(!c.getState().confirmDestructive)return!0;let t=e.filter(e=>e.destructive?.dataLoss);return t.length===0||r.getState().requestDestructiveConfirm({title:i.t(`services.destructive.title`,{count:t.length}),description:i.t(`services.destructive.description`),statements:t.map(Pe),confirmLabel:i.t(`services.runAnyway`)})}async function Ie(e,t){if(!e.readOnly)return;let n=t.filter(e=>!q(e));if(n.length===0)return;let a=`${e.hostName||e.host}`;if(!c.getState().allowReadOnlyOverride)throw new W(i.t(`services.readOnly.refused`,{label:a,count:n.length}));if(!await r.getState().requestDestructiveConfirm({title:i.t(`services.readOnly.title`,{label:a}),description:i.t(`services.readOnly.description`),statements:n.map(e=>e.sql.length>120?e.sql.slice(0,117)+`...`:e.sql),confirmLabel:i.t(`services.runAnyway`)}))throw new G(`Cancelled: connection is read-only.`)}function Y(e,t){let n=o.getState(),r=n.activeConnections.find(t=>t.id===e);if(!r?.serverConnectionId)throw new W(i.t(`services.query.notConnected`));if(n.pendingReopen[e])throw new W(i.t(`services.query.fileNotOpen`));return{connId:e,serverConnId:r.serverConnectionId,conn:r,engine:g(e),tabId:t}}async function X(e,t,n){let r=new j(e.engine).statements(t);if(e.conn.scratchpad){let{materializeFederated:t}=await a(async()=>{let{materializeFederated:e}=await import(`./main-DKTBYrT9.js`).then(e=>e.I);return{materializeFederated:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]));for(let n of r)n.sql=await t(e.connId,n.sql)}if(await Ie(e.conn,r),!n.skipDestructiveConfirm&&!await Fe(r))throw new G;return r}async function Z(e,n,a){let{connId:c,serverConnId:l,engine:u,tabId:d}=e,p=n.stmt?.kind??``,m=()=>o.getState();if(e.conn.transactionMode===`manual`&&u.capabilities.transactions&&n.stmt&&je(n.stmt)&&!m().transactionOpen[c]){let e=await f(l,u.getQuery(`START_TRANSACTION`),a||void 0);if(!e.success)throw new W(e.message??i.t(`services.transaction.startFailed`));m().setTransactionOpen(c,!0),r.getState().setFooterMessage(i.t(`services.transaction.started`))}let h=await f(l,n.sql,a||void 0);if(!h.success){let r=h.message??i.t(`services.query.failed`);throw s.getState().recordExecution({connectionId:c,tabId:d,query:n.sql,database:a,executionTime:h.execTime,error:r,kind:p||void 0}),t(`query_execute`,{dbms:e.conn.dbms,kind:p||`unknown`,source:d?`editor`:`app`,success:!1}),new W(r,n.sql)}let g=Ee(h);return p===`COMMIT`||p===`ROLLBACK`?m().setTransactionOpen(c,!1):p===`START`||p===`BEGIN`?m().setTransactionOpen(c,!0):ke.has(p)&&m().transactionOpen[c]&&u.capabilities.implicitCommitDdl&&(m().setTransactionOpen(c,!1),r.getState().setFooterMessage(i.t(`services.transaction.implicitCommit`,{kind:p}))),Ae.has(p)&&U(c,a),e.skipHistory||s.getState().recordExecution({connectionId:c,tabId:d,query:n.sql,database:a,executionTime:h.execTime,kind:p||void 0,...g.fields.length>0?{rowCount:g.rows.length}:{affectedRows:g.affectedRows}}),t(`query_execute`,{dbms:e.conn.dbms,kind:p||`unknown`,source:d?`editor`:`app`,success:!0,exec_time_ms:Math.round(h.execTime??0)}),{qr:g,execTime:h.execTime}}async function Le(e,t,n={}){let r=Y(e,n.tabId??null);r.skipHistory=n.skipHistory;let a=t.trim();if(!a)throw new W(i.t(`services.query.nothingToExecute`));let o=await X(r,a,n),s=o.length>0?o.map(e=>({sql:e.sql,stmt:e})):[{sql:a,stmt:null}],c=n.database??``,l=null;for(let e of s){let{qr:t}=await Z(r,e,c);n.primaryKeys&&t.fields.length>0&&c&&await K(t,r.serverConnId,c,r.engine),l=t}return l}function Re(e,t){let n=s.getState().tabs[e]?.find(e=>e.id===t);if(!n)return null;let r=ie(e,t);if(r&&`selection`in r)return r.selection;let i=r&&`cursorOffset`in r?r.cursorOffset:n.query.length,a=new j(g(e)).statements(n.query);return a.length===0?null:(a.find(e=>i>=A(e)&&i<=e.end)??[...a].reverse().find(e=>e.end<=i)??a[0]).sql}async function Q(e,t,n={}){let r=()=>s.getState(),a=r().tabs[e]?.find(e=>e.id===t);if(!a)return;let o=(n.sql??a.query)?.trim();if(!o)return;let l,u;try{l=Y(e,t),u=await X(l,o,{})}catch(n){if(n instanceof G){n.message!==`Cancelled`&&r().setError(e,t,n.message);return}r().setError(e,t,n instanceof Error?n.message:String(n));return}let d=c.getState();if(d.previewAffectedRows)try{await Ve(l,u,a.database||``)}catch(e){if(e instanceof G)return;throw e}let f=u.length>0?u.map(e=>({...Me(e,d.resultRowLimit,l.engine.syntax.limitStyle),stmt:e})):[{sql:o,limited:!1,stmt:null}];r().captureSnapshot(e,t,`execute`),r().setExecuting(e,t,!0),r().setError(e,t,null);let p=[],m=a.database||``;try{for(let n of f){let{qr:a,execTime:o}=await Z(l,n,m);if(a.sql=n.stmt?.sql??n.sql,a.executionTime=o,n.limited&&a.rows.length>=d.resultRowLimit&&(a.limited=!0,a.message=i.t(`services.query.rowsReturnedLimited`,{count:a.rows.length,limit:d.resultRowLimit})),!m&&a.fields.length>0){let n=a.fields.find(e=>e.db)?.db;n&&(m=n,r().setDatabase(e,t,m),R(e,m))}a.fields.length>0&&m&&await K(a,l.serverConnId,m,l.engine),p.push(a)}r().setResults(e,t,p)}catch(n){p.length>0&&r().setResults(e,t,p),r().setError(e,t,n instanceof Error?n.message:String(n),n instanceof W?n.sql:null)}}var ze=50;function Be(e,t,n){return e.syntax.limitStyle===`top`?t.replace(/^SELECT\b/i,`SELECT TOP ${n}`):`${t} ${e.limitClause(n)}`}async function Ve(e,t,n){for(let i of t){if(i.kind!==`UPDATE`&&i.kind!==`DELETE`)continue;let t=xe(i);if(!t)continue;let a=null,o=[],s=[],c,l=await f(e.serverConnId,t.count,n||void 0);if(l.success){let r=Number(l.records[0]?.[0]);a=Number.isFinite(r)?r:null;let i=await f(e.serverConnId,t.limited?t.select:Be(e.engine,t.select,ze),n||void 0);i.success?(o=i.fields.map(e=>e.name),s=i.records):c=i.message}else c=l.message;if(!await r.getState().requestDryRun({statement:i.sql,previewSql:t.select,count:a,fields:o,rows:s,truncated:a!==null&&s.length<a,error:c}))throw new G}}async function $(e,t){let n=o.getState(),a=n.activeConnections.find(t=>t.id===e);if(!a?.serverConnectionId)return;let s=g(e);try{let e=await f(a.serverConnectionId,s.getQuery(t));if(!e.success)throw new W(e.message??i.t(`services.transaction.commandFailed`,{name:t}));r.getState().setFooterMessage(t===`COMMIT`?i.t(`services.transaction.committed`):i.t(`services.transaction.rolledBack`))}catch(e){r.getState().setFooterMessage(i.t(`services.transaction.commandFailedWith`,{name:t,message:e instanceof Error?e.message:String(e)}))}finally{n.setTransactionOpen(e,!1)}}var He=e=>$(e,`COMMIT`),Ue=e=>$(e,`ROLLBACK`);export{T as _,Re as a,re as b,Le as c,U as d,Te as f,j as g,Se as h,Q as i,J as l,Ce as m,W as n,q as o,R as p,He as r,Ue as s,G as t,Ne as u,A as v,oe as x,y};
|
|
7
|
+
`;)n++;return this.pos=n,this.make(`comment`,e,n)}quoted(e,t,n,r){let i=this.input,a=e+1;for(;a<i.length;){let e=i[a];if(r&&e===`\\`){a+=2;continue}if(e===t){if(i[a+1]===t){a+=2;continue}a++;break}a++}return this.pos=Math.min(a,i.length),this.make(n,e,this.pos)}number(e){let t=this.input,n=e;if(t[n]===`0`&&(t[n+1]===`x`||t[n+1]===`X`))for(n+=2;n<t.length&&/[0-9A-Fa-f]/.test(t[n]);)n++;else if(t[n]===`0`&&(t[n+1]===`b`||t[n+1]===`B`)&&(t[n+2]===`0`||t[n+2]===`1`))for(n+=2;n<t.length&&(t[n]===`0`||t[n]===`1`);)n++;else{for(;n<t.length&&S(t[n]);)n++;if(t[n]===`.`)for(n++;n<t.length&&S(t[n]);)n++;if((t[n]===`e`||t[n]===`E`)&&(S(t[n+1]??``)||(t[n+1]===`+`||t[n+1]===`-`)&&S(t[n+2]??``)))for(n+=2;n<t.length&&S(t[n]);)n++}return this.pos=n,this.make(`number`,e,n)}},le=new Set([`BEGIN`,`CASE`,`IF`,`LOOP`,`WHILE`,`REPEAT`]);function w(e){return e.kind!==`space`&&e.kind!==`comment`}function ue(e,t){let n=[],r=[],i=[],a=0,o=!1,s=t=>{for(let n=t+1;n<e.length;n++)if(w(e[n]))return e[n]},c=e=>{r.length!==0&&(n.push({tokens:r,start:r[0].start,end:r[r.length-1].end,terminated:e}),r=[],i=[],a=0,o=!1)};for(let n=0;n<e.length;n++){let l=e[n];if(l.kind===`delimiter_command`){i.length>0?c(!1):r=[];continue}if(l.kind===`terminator`){if(a>0&&l.value===`;`){r.push({...l,kind:`punct`}),i.push(l);continue}r.push(l),c(!0);continue}if(r.push(l),w(l)){if(l.kind===`identifier`){let e=l.upper,r=i.length===0;if(o&&(o=!1,le.has(e))){i.push(l);continue}if(e===`END`)a>0&&a--,o=!0;else if(e===`BEGIN`){let e=s(n),o=i[i.length-1];r?(t.plsqlBlocks||e?.kind===`identifier`&&e.upper===`NOT`)&&a++:!(e=>e!==void 0&&(e.kind===`operator`||e.kind===`rparen`||e.kind===`punct`&&(e.value===`,`||e.value===`.`)||e.kind===`identifier`&&e.upper===`FROM`))(e)&&!(o&&(o.kind===`operator`||o.kind===`punct`&&(o.value===`,`||o.value===`.`)))&&a++}else if(e===`CASE`)a++;else if(a>0&&(e===`IF`||e===`LOOP`||e===`WHILE`||e===`REPEAT`)){let e=s(n);e?.kind!==`lparen`&&(e?.kind!==`identifier`||e.upper!==`EXISTS`&&e.upper!==`NOT`)&&a++}}i.push(l)}}return c(!1),n}var de=new Set([`SELECT`,`VALUES`,`TABLE`,`WITH`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`CHECK`,`CHECKSUM`,`ANALYZE`,`OPTIMIZE`,`REPAIR`,`PRAGMA`]),fe=new Set([`SELECT`,`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`VALUES`,`TABLE`,`MERGE`]),pe=new Set([`TABLE`,`DATABASE`,`SCHEMA`,`TABLESPACE`]),me=new Set([`WHERE`,`SET`,`USING`,`ORDER`,`LIMIT`,`JOIN`,`INNER`,`LEFT`,`RIGHT`,`CROSS`,`NATURAL`,`STRAIGHT_JOIN`,`ON`,`PARTITION`,`AS`,`RETURNING`,`INDEXED`,`NOT`]);function T(e){if(e.kind!==`quoted_identifier`)return e.value;let t=e.value[0],n=t===`[`?`]`:t,r=e.value.slice(1,e.value.endsWith(n)?-1:void 0);return t!==`[`&&(r=r.replaceAll(n+n,n)),r}function E(e){return e.kind===`identifier`||e.kind===`quoted_identifier`}function D(e,t,n=me){let r=[];for(;t<e.length;){let i=e[t];if(!E(i)||i.kind===`identifier`&&n.has(i.upper))break;let a=[T(i)];for(t++;t+1<e.length&&e[t].kind===`punct`&&e[t].value===`.`&&E(e[t+1]);)a.push(T(e[t+1])),t+=2;if(r.push(a.join(`.`)),e[t]?.kind===`punct`&&e[t].value===`,`){t++;continue}break}return{names:r,next:t}}function O(e,t,n=0){let r=0;for(let i=n;i<e.length;i++){let n=e[i];if(n.kind===`lparen`)r++;else if(n.kind===`rparen`)r=Math.max(0,r-1);else if(r===0&&n.kind===`identifier`&&n.upper===t)return i}return-1}function he(e){let t=0;for(;t<e.length&&e[t].kind===`lparen`;)t++;if(t>=e.length||e[t].kind!==`identifier`)return{kind:``,index:t};if(e[t].upper!==`WITH`)return{kind:e[t].upper,index:t};let n=0,r=!1;for(let i=t+1;i<e.length;i++){let t=e[i];if(t.kind===`lparen`){n++,r=!1;continue}if(t.kind===`rparen`){n--,r=n===0;continue}if(n===0&&r&&t.kind===`identifier`&&fe.has(t.upper))return{kind:t.upper,index:i};r=!1}return{kind:`WITH`,index:t}}function ge(e,t){let n=O(e,`LIMIT`,t);if(n===-1)return null;let r=e[n+1];if(!r||r.kind!==`number`)return null;let i=e[n+2],a=e[n+3];return i?.kind===`punct`&&i.value===`,`&&a?.kind===`number`?{offset:Number(r.value),count:Number(a.value)}:i?.kind===`identifier`&&i.upper===`OFFSET`&&a?.kind===`number`?{offset:Number(a.value),count:Number(r.value)}:{offset:0,count:Number(r.value)}}function _e(e,t,n){let r=t=>e[t]?.kind===`identifier`?e[t].upper:void 0;switch(t){case`DROP`:{let t=n+1;r(t)===`TEMPORARY`&&t++;let i=r(t);if(!i)return null;t++,r(t)===`IF`&&(t+=2);let{names:a}=D(e,t,new Set([`ON`,`RESTRICT`,`CASCADE`]));return{action:`DROP`,objectType:i,names:a,dataLoss:pe.has(i)}}case`TRUNCATE`:{let t=n+1;r(t)===`TABLE`&&t++;let{names:i}=D(e,t);return{action:`TRUNCATE`,objectType:`TABLE`,names:i,dataLoss:!0}}case`DELETE`:{if(O(e,`WHERE`,n)!==-1)return null;let t=n+1;for(;r(t)===`LOW_PRIORITY`||r(t)===`QUICK`||r(t)===`IGNORE`;)t++;return{action:`DELETE_ALL`,names:r(t)===`FROM`?D(e,t+1).names:D(e,t,new Set([`FROM`])).names,dataLoss:!0}}case`UPDATE`:{if(O(e,`WHERE`,n)!==-1)return null;let t=n+1;for(;r(t)===`LOW_PRIORITY`||r(t)===`IGNORE`||r(t)===`OR`;)t+=r(t)===`OR`?2:1;let{names:i}=D(e,t);return{action:`UPDATE_ALL`,names:i,dataLoss:!0}}case`ALTER`:{if(r(n+1)!==`TABLE`)return null;let{names:t}=D(e,n+2,new Set([`ADD`,`DROP`,`MODIFY`,`CHANGE`,`RENAME`,`ALTER`])),i=[],a=0;for(let t=n+2;t<e.length;t++){let n=e[t];if(n.kind===`lparen`){a++;continue}if(n.kind===`rparen`){a--;continue}if(a!==0||n.kind!==`identifier`||n.upper!==`DROP`)continue;let r=e[t+1],o=r?.kind===`identifier`?r.upper:``;if(o===`COLUMN`){let n=e[t+2];n&&E(n)&&i.push(T(n))}else o===`PARTITION`?i.push(`PARTITION ${D(e,t+2).names.join(`, `)}`):r&&E(r)&&![`PRIMARY`,`FOREIGN`,`INDEX`,`KEY`,`CONSTRAINT`,`CHECK`,`DEFAULT`,`TABLESPACE`].includes(o)&&i.push(T(r))}return i.length===0?null:{action:`ALTER_DROP`,objectType:`TABLE`,names:t.map(e=>`${e} (${i.join(`, `)})`),dataLoss:!0}}default:return null}}function ve(e,t){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=e.terminated?e.tokens.slice(0,-1):e.tokens,i=r.length?r[r.length-1].end:e.start,a=t.slice(e.start,i).trim(),{kind:o,index:s}=he(n),c=de.has(o)||O(n,`RETURNING`,s)!==-1,l=c?ge(n,s):null,u=_e(n,o,s);return{sql:a,raw:t.slice(e.start,e.end),start:e.start,end:e.end,tokens:e.tokens,kind:o,isEmpty:n.length===0,returnsRows:c,limit:l,destructive:u}}function k(e,t){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=n.findIndex(e=>e.kind!==`lparen`);return O(n,t.toUpperCase(),Math.max(0,r))!==-1}function A(e){return e.start+e.raw.indexOf(e.sql)}function ye(e){let t=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),n=0;for(;n<t.length&&t[n].kind===`lparen`;)n++;let r=t[n];if(!r||r.kind!==`identifier`||r.upper!==`SELECT`)return-1;let i=r,a=t[n+1];return a?.kind===`identifier`&&(a.upper===`DISTINCT`||a.upper===`ALL`)&&(i=a),i.end-A(e)}var j=class{syntax;constructor(e){this.syntax=`syntax`in e?e.syntax:e}tokenize(e,t=`;`){return new ce(e,this.syntax,t).tokenize()}parse(e,t=`;`){return ue(this.tokenize(e,t),this.syntax).map(t=>ve(t,e))}statements(e,t=`;`){return this.parse(e,t).filter(e=>!e.isEmpty)}},be=new Set([`ORDER`,`LIMIT`,`RETURNING`,`OUTPUT`,`OPTION`]);function M(e,t,n,r){return n?e.slice(n.start-t,(r?r.start:2**53-1)-t).trim():``}function N(e,t,n){let r=t;for(;r<n&&e[r].kind===`identifier`&&(e[r].upper===`ONLY`||e[r].upper===`LOW_PRIORITY`||e[r].upper===`IGNORE`||e[r].upper===`QUICK`);)r++;if(r>=n||!E(e[r]))return null;let i=T(e[r]),a=e[r].kind===`quoted_identifier`;for(r++;r+1<n&&e[r].kind===`punct`&&e[r].value===`.`&&E(e[r+1]);)i=T(e[r+1]),a=e[r+1].kind===`quoted_identifier`,r+=2;return r<n&&e[r].kind===`identifier`&&e[r].upper===`AS`&&r++,r<n&&E(e[r])&&!(e[r].kind===`identifier`&&[`SET`,`WHERE`,`JOIN`,`INNER`,`LEFT`,`RIGHT`,`CROSS`,`USING`,`FROM`,`ON`,`NATURAL`,`STRAIGHT_JOIN`,`WITH`,`OUTPUT`].includes(e[r].upper))?(e[r].kind,e[r].value):a?`"${i.replaceAll(`"`,`""`)}"`:i}function xe(e,t=`"`){let n=e.tokens.filter(e=>w(e)&&e.kind!==`terminator`),r=A(e),i=e.sql,a=e=>(e.startsWith(t)||e.startsWith(`"`)||e.startsWith("`")||e.startsWith(`[`),e),o=n[0];if(!o||o.kind!==`identifier`||o.upper!==`UPDATE`&&o.upper!==`DELETE`)return null;let s=O(n,`WHERE`),c=-1;for(let e of be){let t=O(n,e,s===-1?1:s);t!==-1&&(c===-1||t<c)&&(c=t)}let l=e=>e===-1?n.length:e,u=s===-1?``:` `+M(i,r,n[s],n[l(c)]),d=``;if(c!==-1&&(n[c].upper===`ORDER`||n[c].upper===`LIMIT`)){let e=[`RETURNING`,`OUTPUT`,`OPTION`].map(e=>O(n,e,c)).filter(e=>e!==-1);d=` `+M(i,r,n[c],e.length?n[Math.min(...e)]:void 0)}let f,p,m;if(o.upper===`UPDATE`){let e=O(n,`SET`);if(e===-1)return null;let t=O(n,`FROM`,e),a=e,o=M(i,r,n[1],n[a]);if(!o||n[1].kind===`lparen`)return null;if(p=N(n,1,a),m=o,t!==-1&&(s===-1||t<s)){let e=M(i,r,n[t+1],n[l(s===-1?c:s)]);f=p!==null&&RegExp(`(^|[\\s,])${p.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}(\\s|$|,)`,`i`).test(e)?e:`${o}, ${e}`}else f=o}else{let e=O(n,`FROM`);if(e===-1)return null;let t=O(n,`USING`,e),a=l(t===-1?s===-1?c:s:t),o=M(i,r,n[e+1],n[a]);if(!o||n[e+1]?.kind===`lparen`)return null;let u=M(i,r,n[1],n[e]),d=u?u.split(`,`)[0].trim().replace(/^(LOW_PRIORITY|QUICK|IGNORE)\s+/i,``):``;p=d||N(n,e+1,a),m=d||o;let h=t===-1?``:M(i,r,n[t+1],n[l(s===-1?c:s)]);f=h?`${o}, ${h}`:o}return p?{select:`SELECT ${a(p)}.* FROM ${f}${u}${d}`,count:d?`SELECT COUNT(*) AS affected FROM (SELECT 1 AS one FROM ${f}${u}${d}) planche_preview`:`SELECT COUNT(*) AS affected FROM ${f}${u}`,table:m,limited:/\bLIMIT\b/i.test(d)}:null}function P(e){return o.getState().activeConnections.find(t=>t.id===e)?.database||ne(u.getState().trees[e]??[])}function Se(e,t,n,r){return g(e).tree.objectPath(t,n,r,P(e))}function F(e,t){return g(e).tree.namespacePath(t,P(e))}function I(e,t){for(let n of e){if(n.id===t)return n;let e=I(n.children,t);if(e)return e}return null}async function Ce(e,t,n){let r=u.getState;for(let i=0;i<t.length;i++){let a=r().trees[e];if(!a)return!1;let o=I(a,t[i]);if(!o)return!1;if(i===t.length-1)return r().setSelected(e,o.id),!0;o.children.length===0&&!o.isLeaf?await n(e,o):o.isExpanded||r().setExpanded(e,o.id,!0)}return!1}function L(e,t){for(let n of e){if(n.id===t)return n;let e=L(n.children,t);if(e)return e}return null}function R(e,t){let n=u.getState(),r=n.trees[e];if(!r||!t)return;let i=F(e,t),a=null;for(let t of i){let i=L(r,t);if(!i||(a=i,i.isLeaf))break;!i.isExpanded&&i.children.length>0&&n.setExpanded(e,i.id,!0)}!a||a.id!==i[i.length-1]||(n.setSelected(e,a.id),!a.isExpanded&&a.children.length>0&&n.setExpanded(e,a.id,!0))}var z=r(t(),1);function we(e,t,n){let r=[];function i(e){for(let n of e){if(r.push(n),n.id===t||n.children.length>0&&i(n.children))return!0;r.pop()}return!1}i(e);for(let e=r.length-1;e>=0;e--)if(r[e].type===n)return r[e];return null}function B(e,t){for(let n of e){if(n.id===t)return n;if(n.children.length>0){let e=B(n.children,t);if(e)return e}}return null}var V=l(`schemaTreeLoadingRoots`,()=>new Set);function H(e){let t=o.getState().activeConnections.find(t=>t.id===e);return t?.serverConnectionId?{engine:g(e),run:p(t.serverConnectionId),database:t.database||void 0}:null}function Te(){let{setTree:e,setChildren:t,setNodeMetadata:r,setLoading:a}=u(),o=(0,z.useCallback)(async t=>{let r=H(t);if(r&&!V.has(t)){V.add(t);try{e(t,await r.engine.tree.loadRoot(r))}catch(r){let a=r instanceof Error?r.message:String(r);console.error(`Failed to load databases:`,r),n.getState().setFooterMessage(i.t(`schema.tree.loadDatabasesFailed`,{message:a})),e(t,[])}finally{V.delete(t)}}},[e]),s=(0,z.useCallback)(async(e,n)=>{if(!u.getState().trees[e])return;let i=H(e);if(i&&!n.isLeaf){a(e,n.id,!0);try{let a=await i.engine.tree.loadChildren(i,n);t(e,n.id,a),Promise.all(a.filter(e=>e.type===h.FOLDER&&e.metadata?.countable).map(async t=>{try{let n=await i.engine.tree.loadChildren(i,t);r(e,t.id,{count:n.length})}catch(e){console.error(`Failed to count ${t.text}:`,e)}}))}catch(t){console.error(`Failed to load children:`,t),a(e,n.id,!1)}}},[t,r,a]);return{loadDatabases:o,loadChildren:s,refreshNode:(0,z.useCallback)(async(e,t)=>{await s(e,t)},[s]),createNode:m,findNode:B,findAncestor:we}}async function U(e,t){let n=u.getState().trees[e];if(!n||!t)return;let r=H(e);if(!r)return;let i=F(e,t),a=te(n,i[i.length-1]);!a||a.children.length===0||await Promise.all(a.children.filter(e=>e.type===h.FOLDER).map(async t=>{try{let n=await r.engine.tree.loadChildren(r,t),i=u.getState();(t.children.length>0||t.isExpanded)&&i.setChildren(e,t.id,n),t.metadata?.countable&&i.setNodeMetadata(e,t.id,{count:n.length})}catch(e){console.error(`Failed to refresh ${t.text}:`,e)}}))}var W=class extends Error{sql;constructor(e,t){super(e),this.name=`QueryError`,this.sql=t}},G=class extends Error{constructor(e=`Cancelled`){super(e),this.name=`ExecutionCancelled`}};function Ee(e){let t=e.fields??[],n=e.records??[];return{fields:t.map(e=>({name:e.name,type:e.type,orgTable:e.orgTable??e.table??``,orgName:e.orgName??e.name,db:e.db??``})),rows:n.map(e=>{let n={};return t.forEach((t,r)=>{n[t.name]=e[r]}),n}),affectedRows:e.affectedRows??0,insertId:e.insertId??0,message:e.message??(n.length>0?i.t(`services.query.rowsReturned`,{count:n.length}):i.t(`services.query.rowsAffected`,{count:e.affectedRows??0}))}}async function K(e,t,n,r=ee(t)){let i=new Set(e.fields.map(e=>e.orgTable).filter(Boolean));if(i.size!==1)return e;let a=[...i][0];try{let i=await r.introspect.getPrimaryKeys(p(t),n,a);i.length>0&&(e.primaryKeys=i)}catch{}return!e.primaryKeys?.length&&e.fields.some(e=>e.name===`_rowid_`)&&(e.primaryKeys=[d]),e}var De=new Set([`SELECT`,`SHOW`,`EXPLAIN`,`DESCRIBE`,`DESC`,`HELP`,`VALUES`,`TABLE`,`WITH`,`USE`,`SET`,`CHECK`,`CHECKSUM`]);function q(e){return e.kind===`PRAGMA`?!e.sql.includes(`=`):!(!De.has(e.kind)||e.destructive||e.kind===`SELECT`&&k(e,`INTO`))}var Oe=new Set([`INSERT`,`UPDATE`,`DELETE`,`REPLACE`,`MERGE`,`LOAD`]),ke=new Set([`CREATE`,`ALTER`,`DROP`,`TRUNCATE`,`RENAME`,`GRANT`,`REVOKE`,`FLUSH`,`LOCK`,`UNLOCK`]),Ae=new Set([`CREATE`,`ALTER`,`DROP`,`RENAME`]);function je(e){return Oe.has(e.kind)||!!e.destructive?.dataLoss}function Me(e,t,n=`limit`){if(t<=0||e.kind!==`SELECT`||e.limit!==null||k(e,`LIMIT`)||k(e,`INTO`)||k(e,`FOR`)||k(e,`LOCK`))return{sql:e.sql,limited:!1};if(n===`top`){if(k(e,`TOP`)||k(e,`OFFSET`))return{sql:e.sql,limited:!1};let n=ye(e);return n===-1?{sql:e.sql,limited:!1}:{sql:`${e.sql.slice(0,n)} TOP ${t}${e.sql.slice(n)}`,limited:!0}}return n===`fetch`?k(e,`FETCH`)||/\bROWNUM\b/i.test(e.sql)?{sql:e.sql,limited:!1}:{sql:`${e.sql} FETCH FIRST ${t} ROWS ONLY`,limited:!0}:{sql:`${e.sql} LIMIT ${t}`,limited:!0}}function Ne(e,t=0){let n=J();return n<=0?``:e.limitClause(n,t)}function J(){return c.getState().resultRowLimit}function Pe(e){let t=e.destructive,n=t.names.length?t.names.join(`, `):i.t(`services.destructive.unknownTarget`);switch(t.action){case`DROP`:return`DROP ${t.objectType} ${n}`;case`TRUNCATE`:return`TRUNCATE ${n}`;case`DELETE_ALL`:return i.t(`services.destructive.deleteAll`,{target:n});case`UPDATE_ALL`:return i.t(`services.destructive.updateAll`,{target:n});case`ALTER_DROP`:return i.t(`services.destructive.alterDrop`,{target:n})}}async function Fe(e){if(!c.getState().confirmDestructive)return!0;let t=e.filter(e=>e.destructive?.dataLoss);return t.length===0||n.getState().requestDestructiveConfirm({title:i.t(`services.destructive.title`,{count:t.length}),description:i.t(`services.destructive.description`),statements:t.map(Pe),confirmLabel:i.t(`services.runAnyway`)})}async function Ie(e,t){if(!e.readOnly)return;let r=t.filter(e=>!q(e));if(r.length===0)return;let a=`${e.hostName||e.host}`;if(!c.getState().allowReadOnlyOverride)throw new W(i.t(`services.readOnly.refused`,{label:a,count:r.length}));if(!await n.getState().requestDestructiveConfirm({title:i.t(`services.readOnly.title`,{label:a}),description:i.t(`services.readOnly.description`),statements:r.map(e=>e.sql.length>120?e.sql.slice(0,117)+`...`:e.sql),confirmLabel:i.t(`services.runAnyway`)}))throw new G(`Cancelled: connection is read-only.`)}function Y(e,t){let n=o.getState(),r=n.activeConnections.find(t=>t.id===e);if(!r?.serverConnectionId)throw new W(i.t(`services.query.notConnected`));if(n.pendingReopen[e])throw new W(i.t(`services.query.fileNotOpen`));return{connId:e,serverConnId:r.serverConnectionId,conn:r,engine:g(e),tabId:t}}async function X(e,t,n){let r=new j(e.engine).statements(t);if(e.conn.scratchpad){let{materializeFederated:t}=await a(async()=>{let{materializeFederated:e}=await import(`./main-CvsCEaFQ.js`).then(e=>e.I);return{materializeFederated:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]));for(let n of r)n.sql=await t(e.connId,n.sql)}if(await Ie(e.conn,r),!n.skipDestructiveConfirm&&!await Fe(r))throw new G;return r}async function Z(t,r,a){let{connId:c,serverConnId:l,engine:u,tabId:d}=t,p=r.stmt?.kind??``,m=()=>o.getState();if(t.conn.transactionMode===`manual`&&u.capabilities.transactions&&r.stmt&&je(r.stmt)&&!m().transactionOpen[c]){let e=await f(l,u.getQuery(`START_TRANSACTION`),a||void 0);if(!e.success)throw new W(e.message??i.t(`services.transaction.startFailed`));m().setTransactionOpen(c,!0),n.getState().setFooterMessage(i.t(`services.transaction.started`))}let h=await f(l,r.sql,a||void 0);if(!h.success){let n=h.message??i.t(`services.query.failed`);throw s.getState().recordExecution({connectionId:c,tabId:d,query:r.sql,database:a,executionTime:h.execTime,error:n,kind:p||void 0}),e(`query_execute`,{dbms:t.conn.dbms,kind:p||`unknown`,source:d?`editor`:`app`,success:!1}),new W(n,r.sql)}let g=Ee(h);return p===`COMMIT`||p===`ROLLBACK`?m().setTransactionOpen(c,!1):p===`START`||p===`BEGIN`?m().setTransactionOpen(c,!0):ke.has(p)&&m().transactionOpen[c]&&u.capabilities.implicitCommitDdl&&(m().setTransactionOpen(c,!1),n.getState().setFooterMessage(i.t(`services.transaction.implicitCommit`,{kind:p}))),Ae.has(p)&&U(c,a),t.skipHistory||s.getState().recordExecution({connectionId:c,tabId:d,query:r.sql,database:a,executionTime:h.execTime,kind:p||void 0,...g.fields.length>0?{rowCount:g.rows.length}:{affectedRows:g.affectedRows}}),e(`query_execute`,{dbms:t.conn.dbms,kind:p||`unknown`,source:d?`editor`:`app`,success:!0,exec_time_ms:Math.round(h.execTime??0)}),{qr:g,execTime:h.execTime}}async function Le(e,t,n={}){let r=Y(e,n.tabId??null);r.skipHistory=n.skipHistory;let a=t.trim();if(!a)throw new W(i.t(`services.query.nothingToExecute`));let o=await X(r,a,n),s=o.length>0?o.map(e=>({sql:e.sql,stmt:e})):[{sql:a,stmt:null}],c=n.database??``,l=null;for(let e of s){let{qr:t}=await Z(r,e,c);n.primaryKeys&&t.fields.length>0&&c&&await K(t,r.serverConnId,c,r.engine),l=t}return l}function Re(e,t){let n=s.getState().tabs[e]?.find(e=>e.id===t);if(!n)return null;let r=ie(e,t);if(r&&`selection`in r)return r.selection;let i=r&&`cursorOffset`in r?r.cursorOffset:n.query.length,a=new j(g(e)).statements(n.query);return a.length===0?null:(a.find(e=>i>=A(e)&&i<=e.end)??[...a].reverse().find(e=>e.end<=i)??a[0]).sql}async function Q(e,t,n={}){let r=()=>s.getState(),a=r().tabs[e]?.find(e=>e.id===t);if(!a)return;let o=(n.sql??a.query)?.trim();if(!o)return;let l,u;try{l=Y(e,t),u=await X(l,o,{})}catch(n){if(n instanceof G){n.message!==`Cancelled`&&r().setError(e,t,n.message);return}r().setError(e,t,n instanceof Error?n.message:String(n));return}let d=c.getState();if(d.previewAffectedRows)try{await Ve(l,u,a.database||``)}catch(e){if(e instanceof G)return;throw e}let f=u.length>0?u.map(e=>({...Me(e,d.resultRowLimit,l.engine.syntax.limitStyle),stmt:e})):[{sql:o,limited:!1,stmt:null}];r().captureSnapshot(e,t,`execute`),r().setExecuting(e,t,!0),r().setError(e,t,null);let p=[],m=a.database||``;try{for(let n of f){let{qr:a,execTime:o}=await Z(l,n,m);if(a.sql=n.stmt?.sql??n.sql,a.executionTime=o,n.limited&&a.rows.length>=d.resultRowLimit&&(a.limited=!0,a.message=i.t(`services.query.rowsReturnedLimited`,{count:a.rows.length,limit:d.resultRowLimit})),!m&&a.fields.length>0){let n=a.fields.find(e=>e.db)?.db;n&&(m=n,r().setDatabase(e,t,m),R(e,m))}a.fields.length>0&&m&&await K(a,l.serverConnId,m,l.engine),p.push(a)}r().setResults(e,t,p)}catch(n){p.length>0&&r().setResults(e,t,p),r().setError(e,t,n instanceof Error?n.message:String(n),n instanceof W?n.sql:null)}}var ze=50;function Be(e,t,n){return e.syntax.limitStyle===`top`?t.replace(/^SELECT\b/i,`SELECT TOP ${n}`):`${t} ${e.limitClause(n)}`}async function Ve(e,t,r){for(let i of t){if(i.kind!==`UPDATE`&&i.kind!==`DELETE`)continue;let t=xe(i);if(!t)continue;let a=null,o=[],s=[],c,l=await f(e.serverConnId,t.count,r||void 0);if(l.success){let n=Number(l.records[0]?.[0]);a=Number.isFinite(n)?n:null;let i=await f(e.serverConnId,t.limited?t.select:Be(e.engine,t.select,ze),r||void 0);i.success?(o=i.fields.map(e=>e.name),s=i.records):c=i.message}else c=l.message;if(!await n.getState().requestDryRun({statement:i.sql,previewSql:t.select,count:a,fields:o,rows:s,truncated:a!==null&&s.length<a,error:c}))throw new G}}async function $(e,t){let r=o.getState(),a=r.activeConnections.find(t=>t.id===e);if(!a?.serverConnectionId)return;let s=g(e);try{let e=await f(a.serverConnectionId,s.getQuery(t));if(!e.success)throw new W(e.message??i.t(`services.transaction.commandFailed`,{name:t}));n.getState().setFooterMessage(t===`COMMIT`?i.t(`services.transaction.committed`):i.t(`services.transaction.rolledBack`))}catch(e){n.getState().setFooterMessage(i.t(`services.transaction.commandFailedWith`,{name:t,message:e instanceof Error?e.message:String(e)}))}finally{r.setTransactionOpen(e,!1)}}var He=e=>$(e,`COMMIT`),Ue=e=>$(e,`ROLLBACK`);export{T as _,Re as a,re as b,Le as c,U as d,Te as f,j as g,Se as h,Q as i,J as l,Ce as m,W as n,q as o,R as p,He as r,Ue as s,G as t,Ne as u,A as v,oe as x,y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./ui-store-
|
|
1
|
+
import{r as e}from"./ui-store-DfspmPOn.js";import{i as t,t as n}from"./app-storage-B6v72zLH.js";import{n as r}from"./connection-store-CAPTzFtT.js";import{n as i}from"./settings-store-CYHWBgNo.js";var a=/--[^\n]*|\/\*[\s\S]*?\*\/|\$([A-Za-z_]\w*)?\$[\s\S]*?\$\1\$|'(?:[^']|'')*'|"(?:[^"]|"")*"|\[[^\]]*\]|[A-Za-z_][\w$#]*|\S/g,o=`'***'`,s=/((?:password|pwd)\s*=\s*)[^;'"]+/gi;function c(e){let t=[];for(let n of e.matchAll(a)){let e=n[0];if(e.startsWith(`--`)||e.startsWith(`/*`))continue;let r=e[0],i=r===`'`||r===`"`||r===`$`?`literal`:/[A-Za-z_]/.test(r)?`word`:`other`;t.push({text:e,start:n.index,end:n.index+e.length,kind:i})}return t}var l=e=>e?.kind===`word`?e.text.toUpperCase():``;function u(e){let t=c(e),n=[],r=e=>{!e||e.kind===`other`||n.push({start:e.start,end:e.end,text:e.kind===`literal`?o:`***`})},i=e=>{let n=t[e];return n?n.kind===`literal`?{token:n,span:1}:n.kind===`word`&&/^[NE]$/i.test(n.text)&&t[e+1]?.kind===`literal`?{token:t[e+1],span:2}:null:null};for(let e=0;e<t.length;e++){let a=t[e];if(a.kind===`literal`){s.test(a.text)&&(s.lastIndex=0,n.push({start:a.start,end:a.end,text:a.text.replace(s,`$1***`)})),s.lastIndex=0;continue}if(a.kind!==`word`)continue;let o=a.text.toUpperCase();if(o===`IDENTIFIED`){let n=e+1;if(l(t[n])===`WITH`&&(n+=2),l(t[n])!==`BY`&&l(t[n])!==`AS`||(n+=1,(l(t[n])===`PASSWORD`||l(t[n])===`VALUES`)&&(n+=1),l(t[n])===`RANDOM`))continue;let a=i(n);a?(r(a.token),n+=a.span):t[n]?.kind===`word`&&(r(t[n]),n+=1),l(t[n])===`REPLACE`&&r(i(n+1)?.token??t[n+1]);continue}if(o===`PASSWORD`){let n=e+1;if(t[n]?.text===`(`){r(i(n+1)?.token);continue}if(l(t[n])===`FOR`)for(;n<t.length&&t[n].text!==`=`;)n++;t[n]?.text===`=`&&(n+=1),r(i(n)?.token)}}if(n.length===0)return e;n.sort((e,t)=>e.start-t.start);let a=``,u=0;for(let t of n)t.start<u||(a+=e.slice(u,t.start)+t.text,u=t.end);return a+e.slice(u)}var d=30,f=200,p=Object.freeze([]);function m(e,t,n){return e.map(e=>e.id===t?{...e,...n}:e)}function h(e){let t=e;if(delete t.erdOpen,delete t.erdDatabase,t.tabs&&typeof t.tabs==`object`){let e=t.tabs;for(let t of Object.keys(e))e[t]=e[t].map(e=>{if(!Array.isArray(e.results)){let t={...e};return delete t.result,{...t,results:[]}}return e})}return t}var g=e()(t((e,t)=>({tabs:{},activeTabId:{},history:[],snapshots:{},addQueryTab:(t,n)=>e(e=>{let r=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:[...r,n]},activeTabId:{...e.activeTabId,[t]:n.id}}}),removeQueryTab:(e,n)=>t().removeQueryTabs(e,[n]),removeQueryTabs:(t,n)=>e(e=>{let r=new Set(n),i=(e.tabs[t]??[]).filter(e=>!r.has(e.id)),a=e.activeTabId[t],o=a&&r.has(a)?i.length>0?i[i.length-1].id:null:a,s={...e.snapshots[t]};for(let e of n)delete s[e];return{tabs:{...e.tabs,[t]:i},activeTabId:{...e.activeTabId,[t]:o},snapshots:{...e.snapshots,[t]:s}}}),reorderQueryTab:(t,n,i)=>e(e=>({tabs:{...e.tabs,[t]:r(e.tabs[t]??[],n,i)}})),setActiveQueryTab:(t,n)=>e(e=>({activeTabId:{...e.activeTabId,[t]:n}})),setEditorContent:(t,n,r)=>e(e=>{let i=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(i,n,{query:r})}}}),setResults:(t,n,r)=>e(e=>{let i=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(i,n,{results:r,isExecuting:!1,error:null})}}}),setExecuting:(t,n,r)=>e(e=>{let i=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(i,n,{isExecuting:r})}}}),setError:(t,n,r,i=null)=>e(e=>{let a=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(a,n,{error:r,errorSql:r?i:null,isExecuting:!1})}}}),setDatabase:(t,n,r)=>e(e=>{let i=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(i,n,{database:r})}}}),setExecutionTime:(t,n,r)=>e(e=>{let i=e.tabs[t]??[];return{tabs:{...e.tabs,[t]:m(i,n,{executionTime:r})}}}),addHistory:t=>e(e=>({history:[t,...e.history].slice(0,500)})),recordExecution:({connectionId:e,tabId:n,query:r,database:i,executionTime:a,error:o,kind:s,rowCount:c,affectedRows:l})=>t().addHistory({id:crypto.randomUUID(),query:u(r),database:i,timestamp:Date.now(),executionTime:a,success:!o,connectionId:e,tabId:n??void 0,...o?{error:o}:{},...s?{kind:s}:{},...c==null?{}:{rowCount:c},...l==null?{}:{affectedRows:l}}),clearHistory:()=>e({history:[]}),captureSnapshot:(t,n,r)=>e(e=>{let i=e.tabs[t]?.find(e=>e.id===n),a=u(i?.query??``);if(!a.trim())return{};let o=e.snapshots[t]?.[n]??[];if(o[0]?.text===a)return{};let s=[{text:a,timestamp:Date.now(),reason:r},...o].slice(0,d);return{snapshots:{...e.snapshots,[t]:{...e.snapshots[t],[n]:s}}}})}),{name:`planche-query`,storage:n(),version:2,migrate:h,partialize:e=>({tabs:Object.fromEntries(Object.entries(e.tabs).map(([e,t])=>[e,t.map(e=>({...e,isExecuting:!1,results:[],error:null,errorSql:null,executionTime:null}))])),activeTabId:e.activeTabId,history:i.getState().persistQueryHistory?e.history.slice(0,f):[],snapshots:i.getState().persistQueryHistory?Object.fromEntries(Object.entries(e.snapshots).map(([t,n])=>{let r=new Set((e.tabs[t]??[]).map(e=>e.id));return[t,Object.fromEntries(Object.entries(n).filter(([e])=>r.has(e)).map(([e,t])=>[e,t.slice(0,d)]))]})):{}})}));export{g as n,p as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,m as t}from"./ui-store-VGM_km-l.js";import{St as n,gt as r,ht as i,xt as a}from"./main-DKTBYrT9.js";import{b as o,l as s,o as c,p as l,s as u,u as d}from"./button-BRD_vJ8s.js";import{S as f,_ as p,b as m,d as h,f as g,g as _,h as v,m as y,p as b,u as x,v as S,x as C,y as w}from"./dist-BnghYOTd.js";import{n as T,t as E}from"./dist-DGLzi2V0.js";import{a as D,i as O,r as k,t as A}from"./dist-Bo6CxCQ0.js";import{t as j}from"./chevron-up-DVdt2433.js";var M=e(o(),1),N=e(t(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=s(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=a(V),[G,te]=f(V,[W,D]),K=D(),[ne,q]=G(V),[re,ie]=G(V);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[S,C]=N.useState(!1),E=T(l),[D,k]=w({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,j]=w({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(A);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>j(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,j]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=p(),B=Array.from(F).map(e=>e.props.value).join(`;`),U=N.useCallback(e=>{L(t=>new Set(t).add(e))},[]),W=N.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),G={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:z,value:A,onValueChange:j,open:D,onOpenChange:k,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(O,{..._,children:(0,I.jsx)(ne,{scope:t,...G,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:U,onNativeOptionRemove:W,children:Ve(g)?g(G):n})})})})}R(J,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Be,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=N.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=K(n),o=q(oe,n),s=o.disabled||r,c=l(t,o.onTriggerChange),d=U(n),f=N.useRef(`touch`),[p,m,h]=He(e=>{let t=d().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),g=R(e=>{s||(o.onOpenChange(!0),h()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$(o.value)?``:void 0,...i,ref:c,onClick:C(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:C(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:C(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=q(ce,n),{onValueNodeHasChildrenChange:d}=c,f=a!==void 0,p=l(t,c.onValueNodeChange);m(()=>{d(f)},[d,f]);let h=$(c.value);return(0,I.jsx)(u.span,{...s,asChild:!h&&s.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?o:a},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(b,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,me=N.forwardRef(R(function(e,t){let n=fe(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeSelect),[o,s]=N.useState();return m(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(S,{present:r||a.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:o})})},`SelectContent`)),he=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ge,Z]=G(Y),_e=d(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:b,avoidCollisions:S,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=l(t,D),[j,M]=N.useState(null),[P,ee]=N.useState(null),F=U(n),[L,z]=N.useState(!1),B=N.useRef(!1);N.useEffect(()=>{if(E)return x(E)},[E]),g();let V=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),H=N.useCallback(()=>V([j,E]),[V,j,E]);N.useEffect(()=>{L&&H()},[L,H]);let{onOpenChange:W,triggerPointerDownPosRef:G}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(G.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(G.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||W(!1),document.removeEventListener(`pointermove`,t),G.current=null},`handlePointerUp`);return G.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,W,G]),N.useEffect(()=>{let e=R(()=>W(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[W]);let[te,K]=He(e=>{let t=F().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(B.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),ie=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&ee(e)},[T.value]),J=r===`popper`?be:ye,ae=J===be?{side:s,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:b,avoidCollisions:S}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:ne,selectedItem:j,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:H,selectedItemText:P,position:r,isPositioned:L,searchRef:te,children:(0,I.jsx)(h,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(y,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:C(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(J,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>z(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:C(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&K(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>V(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=q(Y,n),o=Z(Y,n),[s,c]=N.useState(null),[d,f]=N.useState(null),p=l(t,f),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=o,S=N.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&d&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-X,d=E(a,[X,Math.max(X,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-X,d=E(a,[X,Math.max(X,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=h(),c=window.innerHeight-X*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=c-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=o.length>0&&y===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?T:0)+t+m);s.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;s.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?w:0)+k)+M;s.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}s.style.margin=`${X}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,s,d,v,y,b,a.dir,r]);m(()=>S(),[S]);let[C,w]=N.useState();m(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=N.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=K(n);return(0,I.jsx)(k,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(Y,{}),Ce=`SelectViewport`,we=N.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Z(Ce,n),o=Se(Ce,n),s=l(t,a.onViewportChange),c=N.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:C(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=N.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=q(De,n),c=Z(De,n),d=s.value===r,[f,m]=N.useState(a??``),[h,g]=N.useState(!1),v=_(e=>c.itemRefCallback?.(e,r,i)),y=l(t,v),b=p(),x=N.useRef(`touch`),S=R(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:d,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":b,"data-highlighted":h?``:void 0,"aria-selected":d&&h,"data-state":d?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:y,onFocus:C(o.onFocus,()=>g(!0)),onBlur:C(o.onBlur,()=>g(!1)),onClick:C(o.onClick,()=>{x.current!==`mouse`&&S()}),onPointerUp:C(o.onPointerUp,()=>{x.current===`mouse`&&S()}),onPointerDown:C(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:C(o.onPointerMove,e=>{x.current=e.pointerType,i?c.onItemLeave?.():x.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:C(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:C(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&S(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=q(Q,n),s=Z(Q,n),c=ke(Q,n),d=ie(Q,n),[f,p]=N.useState(null),h=_(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),g=l(t,p,c.onItemTextChange,h),v=f?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:v},c.value),[c.disabled,c.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return m(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:c.textId,...a,ref:g}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?M.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),Me=`SelectItemIndicator`,Ne=N.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Me,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,a]=N.useState(!1),o=l(t,r.onScrollButtonChange);return m(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ie=`SelectScrollDownButton`,Le=N.forwardRef(R(function(e,t){let n=Z(Ie,e.__scopeSelect),r=Se(Ie,e.__scopeSelect),[i,a]=N.useState(!1),o=l(t,r.onScrollButtonChange);return m(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Re=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),o=N.useRef(null),s=U(n),c=N.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return N.useEffect(()=>()=>c(),[c]),m(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:C(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:C(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:C(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},r){let i=q(ze,e),{value:a,onValueChange:o,required:s,disabled:c,name:d,autoComplete:f,form:p}=i,{nativeOptions:m,nativeSelectKey:h}=i,g=N.useRef(null),_=l(r,g),v=a??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:s,tabIndex:-1,name:d,autoComplete:f,disabled:c,form:p,onChange:e=>o(e.target.value),...t,style:{...n,...t.style},ref:_,defaultValue:v,children:[$(a)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=_(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),R((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(He,`useTypeaheadSearch`);function Ue(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=We(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(Ue,`findNextItem`);function We(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(We,`wrapArray`);function Ge({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ke({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function qe({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:c(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(i,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:c(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:c(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(Ze,{})]})})}function Ye({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:c(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(Ne,{children:(0,I.jsx)(r,{className:`size-4`})})}),(0,I.jsx)(je,{children:t})]})}function Xe({className:e,...t}){return(0,I.jsx)(Fe,{"data-slot":`select-scroll-up-button`,className:c(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(j,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:c(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(i,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
1
|
+
import{h as e,v as t}from"./ui-store-DfspmPOn.js";import{St as n,gt as r,ht as i,xt as a}from"./main-CvsCEaFQ.js";import{b as o,l as s,o as c,p as l,s as u,u as d}from"./button--s6nUzD8.js";import{S as f,_ as p,b as m,d as h,f as g,g as _,h as v,m as y,p as b,u as x,v as S,x as C,y as w}from"./dist-CBYDYlja.js";import{n as T,t as E}from"./dist-pKt0y9E-.js";import{a as D,i as O,r as k,t as A}from"./dist-DgJHEXPr.js";import{t as j}from"./chevron-up-QmvRX9Fw.js";var M=t(o(),1),N=t(e(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=s(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=a(V),[G,te]=f(V,[W,D]),K=D(),[ne,q]=G(V),[re,ie]=G(V);function J(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[S,C]=N.useState(!1),E=T(l),[D,k]=w({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,j]=w({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(A);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>j(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,j]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=p(),B=Array.from(F).map(e=>e.props.value).join(`;`),U=N.useCallback(e=>{L(t=>new Set(t).add(e))},[]),W=N.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),G={required:m,trigger:v,onTriggerChange:y,valueNode:b,onValueNodeChange:x,valueNodeHasChildren:S,onValueNodeHasChildrenChange:C,contentId:z,value:A,onValueChange:j,open:D,onOpenChange:k,dir:E,triggerPointerDownPosRef:M,disabled:f,name:u,autoComplete:d,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(O,{..._,children:(0,I.jsx)(ne,{scope:t,...G,children:(0,I.jsx)(H.Provider,{scope:t,children:(0,I.jsx)(re,{scope:t,onNativeOptionAdd:U,onNativeOptionRemove:W,children:Ve(g)?g(G):n})})})})}R(J,`SelectProvider`);var ae=R(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,I.jsx)(J,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,I.jsxs)(I.Fragment,{children:[n,e?(0,I.jsx)(Be,{__scopeSelect:t}):null]})})},`Select`),oe=`SelectTrigger`,se=N.forwardRef(R(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=K(n),o=q(oe,n),s=o.disabled||r,c=l(t,o.onTriggerChange),d=U(n),f=N.useRef(`touch`),[p,m,h]=He(e=>{let t=d().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onValueChange(n.value)}),g=R(e=>{s||(o.onOpenChange(!0),h()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...a,children:(0,I.jsx)(u.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":$(o.value)?``:void 0,...i,ref:c,onClick:C(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:C(i.onPointerDown,e=>{f.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(g(e),e.preventDefault())}),onKeyDown:C(i.onKeyDown,e=>{let t=p.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&m(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(g(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=q(ce,n),{onValueNodeHasChildrenChange:d}=c,f=a!==void 0,p=l(t,c.onValueNodeChange);m(()=>{d(f)},[d,f]);let h=$(c.value);return(0,I.jsx)(u.span,{...s,asChild:!h&&s.asChild,ref:p,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?o:a},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(u.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[de,fe]=G(`SelectPortal`,{forceMount:void 0}),pe=R(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,I.jsx)(de,{scope:e.__scopeSelect,forceMount:n,children:(0,I.jsx)(b,{asChild:!0,...r})})},`SelectPortal`),Y=`SelectContent`,me=N.forwardRef(R(function(e,t){let n=fe(Y,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeSelect),[o,s]=N.useState();return m(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(S,{present:r||a.open,children:({present:e})=>e?(0,I.jsx)(ve,{...i,ref:t}):(0,I.jsx)(he,{...i,fragment:o})})},`SelectContent`)),he=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?M.createPortal((0,I.jsx)(ge,{scope:n,children:(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),X=10,[ge,Z]=G(Y),_e=d(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:b,avoidCollisions:S,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=l(t,D),[j,M]=N.useState(null),[P,ee]=N.useState(null),F=U(n),[L,z]=N.useState(!1),B=N.useRef(!1);N.useEffect(()=>{if(E)return x(E)},[E]),g();let V=N.useCallback(e=>{let[t,...n]=F().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&O&&(O.scrollTop=0),n===r&&O&&(O.scrollTop=O.scrollHeight),n?.focus(),document.activeElement!==i))return},[F,O]),H=N.useCallback(()=>V([j,E]),[V,j,E]);N.useEffect(()=>{L&&H()},[L,H]);let{onOpenChange:W,triggerPointerDownPosRef:G}=T;N.useEffect(()=>{if(E){let e={x:0,y:0},t=R(t=>{e={x:Math.abs(Math.round(t.pageX)-(G.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(G.current?.y??0))}},`handlePointerMove`),n=R(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(E)||W(!1),document.removeEventListener(`pointermove`,t),G.current=null},`handlePointerUp`);return G.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[E,W,G]),N.useEffect(()=>{let e=R(()=>W(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[W]);let[te,K]=He(e=>{let t=F().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ne=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&(M(e),r&&(B.current=!0))},[T.value]),re=N.useCallback(()=>E?.focus(),[E]),ie=N.useCallback((e,t,n)=>{let r=!B.current&&!n;(T.value!==void 0&&T.value===t||r)&&ee(e)},[T.value]),J=r===`popper`?be:ye,ae=J===be?{side:s,sideOffset:c,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:p,collisionPadding:m,sticky:_,hideWhenDetached:b,avoidCollisions:S}:{};return(0,I.jsx)(ge,{scope:n,content:E,viewport:O,onViewportChange:k,itemRefCallback:ne,selectedItem:j,onItemLeave:re,itemTextRefCallback:ie,focusSelectedItem:H,selectedItemText:P,position:r,isPositioned:L,searchRef:te,children:(0,I.jsx)(h,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(y,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:C(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(v,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>T.onOpenChange(!1),children:(0,I.jsx)(J,{role:`listbox`,id:T.contentId,"data-state":T.open?`open`:`closed`,dir:T.dir,onContextMenu:e=>e.preventDefault(),...w,...ae,onPlaced:()=>z(!0),ref:A,style:{display:`flex`,flexDirection:`column`,outline:`none`,...w.style},onKeyDown:C(w.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&K(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=F().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>V(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),ye=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=q(Y,n),o=Z(Y,n),[s,c]=N.useState(null),[d,f]=N.useState(null),p=l(t,f),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=o,S=N.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&d&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-X,d=E(a,[X,Math.max(X,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-X,d=E(a,[X,Math.max(X,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=h(),c=window.innerHeight-X*2,l=v.scrollHeight,u=window.getComputedStyle(d),f=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=f+p+l+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=c-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=o.length>0&&y===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?T:0)+t+m);s.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;s.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?w:0)+k)+M;s.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}s.style.margin=`${X}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,s,d,v,y,b,a.dir,r]);m(()=>S(),[S]);let[C,w]=N.useState();m(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);let T=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,I.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(u.div,{...i,ref:p,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),be=N.forwardRef(R(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=X,...a}=e,o=K(n);return(0,I.jsx)(k,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[xe,Se]=G(Y,{}),Ce=`SelectViewport`,we=N.forwardRef(R(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Z(Ce,n),o=Se(Ce,n),s=l(t,a.onViewportChange),c=N.useRef(0);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,I.jsx)(H.Slot,{scope:n,children:(0,I.jsx)(u.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:C(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-X*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[Te,Ee]=G(`SelectGroup`),De=`SelectItem`,[Oe,ke]=G(De),Ae=N.forwardRef(R(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=q(De,n),c=Z(De,n),d=s.value===r,[f,m]=N.useState(a??``),[h,g]=N.useState(!1),v=_(e=>c.itemRefCallback?.(e,r,i)),y=l(t,v),b=p(),x=N.useRef(`touch`),S=R(()=>{i||(s.onValueChange(r),s.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:d,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:(0,I.jsx)(u.div,{role:`option`,"aria-labelledby":b,"data-highlighted":h?``:void 0,"aria-selected":d&&h,"data-state":d?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:y,onFocus:C(o.onFocus,()=>g(!0)),onBlur:C(o.onBlur,()=>g(!1)),onClick:C(o.onClick,()=>{x.current!==`mouse`&&S()}),onPointerUp:C(o.onPointerUp,()=>{x.current===`mouse`&&S()}),onPointerDown:C(o.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:C(o.onPointerMove,e=>{x.current=e.pointerType,i?c.onItemLeave?.():x.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:C(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:C(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&S(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=q(Q,n),s=Z(Q,n),c=ke(Q,n),d=ie(Q,n),[f,p]=N.useState(null),h=_(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),g=l(t,p,c.onItemTextChange,h),v=f?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:c.value,disabled:c.disabled,children:v},c.value),[c.disabled,c.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return m(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u.span,{id:c.textId,...a,ref:g}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!$(o.value)?M.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),Me=`SelectItemIndicator`,Ne=N.forwardRef(R(function(e,t){let{__scopeSelect:n,...r}=e;return ke(Me,n).isSelected?(0,I.jsx)(u.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,a]=N.useState(!1),o=l(t,r.onScrollButtonChange);return m(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ie=`SelectScrollDownButton`,Le=N.forwardRef(R(function(e,t){let n=Z(Ie,e.__scopeSelect),r=Se(Ie,e.__scopeSelect),[i,a]=N.useState(!1),o=l(t,r.onScrollButtonChange);return m(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),Re=N.forwardRef(R(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Z(`SelectScrollButton`,n),o=N.useRef(null),s=U(n),c=N.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return N.useEffect(()=>()=>c(),[c]),m(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,I.jsx)(u.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:C(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:C(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:C(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},r){let i=q(ze,e),{value:a,onValueChange:o,required:s,disabled:c,name:d,autoComplete:f,form:p}=i,{nativeOptions:m,nativeSelectKey:h}=i,g=N.useRef(null),_=l(r,g),v=a??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(u.select,{"aria-hidden":!0,required:s,tabIndex:-1,name:d,autoComplete:f,disabled:c,form:p,onChange:e=>o(e.target.value),...t,style:{...n,...t.style},ref:_,defaultValue:v,children:[$(a)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=_(e),n=N.useRef(``),r=N.useRef(0),i=N.useCallback(e=>{let i=n.current+e;t(i),R((function e(t){n.current=t,window.clearTimeout(r.current),t!==``&&(r.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(i)},[t]),a=N.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return N.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}R(He,`useTypeaheadSearch`);function Ue(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=We(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}R(Ue,`findNextItem`);function We(e,t){return e.map((n,r)=>e[(t+r)%e.length])}R(We,`wrapArray`);function Ge({...e}){return(0,I.jsx)(ae,{"data-slot":`select`,...e})}function Ke({...e}){return(0,I.jsx)(le,{"data-slot":`select-value`,...e})}function qe({className:e,size:t=`default`,children:n,...r}){return(0,I.jsxs)(se,{"data-slot":`select-trigger`,"data-size":t,className:c(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,I.jsx)(ue,{asChild:!0,children:(0,I.jsx)(i,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:c(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:c(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,I.jsx)(Ze,{})]})})}function Ye({className:e,children:t,...n}){return(0,I.jsxs)(Ae,{"data-slot":`select-item`,className:c(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,I.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,I.jsx)(Ne,{children:(0,I.jsx)(r,{className:`size-4`})})}),(0,I.jsx)(je,{children:t})]})}function Xe({className:e,...t}){return(0,I.jsx)(Fe,{"data-slot":`select-scroll-up-button`,className:c(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(j,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:c(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(i,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,r as t}from"./ui-store-
|
|
1
|
+
import{c as e,r as t}from"./ui-store-DfspmPOn.js";import{i as n,t as r}from"./app-storage-B6v72zLH.js";var i={confirmDestructive:!0,warnInEditor:!0,previewAffectedRows:!0,allowReadOnlyOverride:!0,previewGridCommit:!0,resultRowLimit:500,executeScope:`script`},a=t()(n(t=>({...i,locale:`auto`,onboardingDismissed:!1,termsAcceptedVersion:0,analyticsEnabled:!0,persistQueryHistory:!0,update:e=>t(e),setOnboardingDismissed:e=>t({onboardingDismissed:e}),acceptTerms:()=>{e(`terms_accept`,{version:1}),t({termsAcceptedVersion:1})},setLocale:n=>{e(`locale_change`,{locale:n}),t({locale:n})},setAnalyticsEnabled:e=>t({analyticsEnabled:e}),setPersistQueryHistory:e=>t({persistQueryHistory:e})}),{name:`planche-settings`,storage:r()})),o=()=>a(e=>e.termsAcceptedVersion>=1);export{a as n,o as r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,n as t}from"./ui-store-DfspmPOn.js";import{a as n}from"./i18n-C-w8Q5E_.js";import{t as r}from"./connection-store-CAPTzFtT.js";import{r as i}from"./database-4FcrMRGA.js";import{c as a,d as o,n as s}from"./query-execution-ODxyrvnD.js";import{i as c}from"./dbms-Bsjvyvsp.js";import{n as l}from"./engine-DWYEiSZM.js";import{t as u}from"./pro-usage-Dp3liEjn.js";import{t as d}from"./table-definition-Bs5VSn0X.js";var f=500;function p(e){let t=r.getState().activeConnections.find(t=>t.id===e);if(!t?.serverConnectionId)throw new s(n.t(`services.query.notConnected`));return t.serverConnectionId}async function m(e,t){let r=l(e.connectionId),a=i(p(e.connectionId)),[o,c,u]=await Promise.all([r.introspect.listColumns(a,e.database,e.table),r.introspect.listIndexes(a,e.database,e.table),r.capabilities.tableProperties?r.introspect.getTableInfo(a,e.database,e.table):Promise.resolve(null)]);if(o.length===0)throw new s(n.t(`table.copy.noColumns`));let f=d(t.database,t.table,o,c,u);return l(t.connectionId).capabilities.tableProperties||(f.options={engine:``,charset:``,collation:``,autoIncrement:``,comment:f.options.comment}),f}async function h(e){let t=l(e.connectionId),n=i(p(e.connectionId)),r=await t.introspect.listTables(n,e.database),a=e.table.toLowerCase();return r.some(e=>e.name.toLowerCase()===a)}function g(e,t,n,r,i,a,o){let s=r.map(t=>e.quoteIdentifier(t)).join(`, `),c=i.length>0?i.map(t=>e.quoteIdentifier(t)).join(`, `):`1`,l=`SELECT ${s} FROM ${e.qualify(t,n)} ORDER BY ${c}`;switch(e.syntax.limitStyle){case`top`:return`${l} OFFSET ${a} ROWS FETCH NEXT ${o} ROWS ONLY`;case`fetch`:return`${l} OFFSET ${a} ROWS FETCH FIRST ${o} ROWS ONLY`;default:return`${l} LIMIT ${o} OFFSET ${a}`}}function _(e){return e&&typeof e==`object`&&e.type===`Buffer`&&Array.isArray(e.data)?Uint8Array.from(e.data):e}async function v(e,t,n,r){try{let i=await e(`SELECT COUNT(*) AS n FROM ${t.qualify(n,r)}`,n),a=Number(i.records[0]?.[0]);return Number.isFinite(a)?a:null}catch{return null}}async function y(d,m=()=>{},y){let{source:b,target:x}=d,S=l(b.connectionId),C=l(x.connectionId),w=i(p(b.connectionId)),T=r.getState().activeConnections.find(e=>e.id===b.connectionId),E=r.getState().activeConnections.find(e=>e.id===x.connectionId);if(await h(x)){if(d.onConflict===`abort`)throw new s(n.t(`table.copy.exists`,{table:x.table}));let e=C.getQuery(`DROP_TABLE`,x.database,x.table,``);if(!await t.getState().requestDestructiveConfirm({title:n.t(`table.copy.dropTitle`,{table:x.table}),description:n.t(`table.copy.dropDescription`),typeToConfirm:x.table,statements:[e],confirmLabel:n.t(`table.copy.dropConfirm`)}))throw new s(n.t(`table.copy.cancelled`));await a(x.connectionId,e,{database:x.database,skipDestructiveConfirm:!0})}m({phase:`create`,copied:0,total:null}),await a(x.connectionId,d.createSql,{database:x.database});let D=0;if(d.mode===`structure_data`){m({phase:`count`,copied:0,total:null});let e=await S.introspect.listColumns(w,b.database,b.table),t=e.map(e=>e.name),r=e.filter(e=>e.key===`PRI`).map(e=>e.name);if(r.length===0)try{r=await S.introspect.getPrimaryKeys(w,b.database,b.table)}catch{}let i=await v(w,S,b.database,b.table),o=d.batchSize??f;m({phase:`copy`,copied:0,total:i});for(let e=0;;e+=o){if(y?.aborted)throw new s(n.t(`table.copy.cancelled`));let l=await w(g(S,b.database,b.table,t,r,e,o),b.database);if(l.records.length===0)break;let u=l.fields.map(e=>e.name),d=c(l).map(e=>u.map(t=>_(e[t]))),f=C.ddl.insertRows(x.database,x.table,u,d);if(await a(x.connectionId,f,{database:x.database,skipHistory:!0}),D+=d.length,m({phase:`copy`,copied:D,total:i}),l.records.length<o)break}}return m({phase:`done`,copied:D,total:D}),o(x.connectionId,x.database),u(`copy_table`),e(`table_copy`,{source_dbms:T?.dbms??`unknown`,target_dbms:E?.dbms??`unknown`,mode:d.mode,cross_connection:b.connectionId!==x.connectionId}),{rows:D}}export{y as n,g as r,m as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),d=o(((e,t)=>{t.exports=u()})),f=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,p={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},m=e=>p[e],h=e=>e.replace(f,m),g={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:h,transDefaultProps:void 0},_=(e={})=>{g={...g,...e}},v=()=>g,y,b=e=>{y=e},x=()=>y,S=l(d(),1),C=`G-2FYJTCC2TH`,w=!1,T=!1,E=!1,D=`planche.internalTraffic`;function O(){if(typeof window>`u`)return!1;try{let e=new URLSearchParams(window.location.search).get(`internal`);return e===`1`?localStorage.setItem(D,`1`):e===`0`&&localStorage.removeItem(D),localStorage.getItem(D)===`1`}catch{return!1}}function k(){let e=typeof document<`u`&&document.querySelector(`meta[name="planche-agent"]`)!==null;return!!C&&typeof window<`u`&&!e}function A(){window.dataLayer=window.dataLayer??[],window.dataLayer.push(arguments)}function j(){if(w)return;w=!0,window.gtag=A,A(`js`,new Date),A(`config`,C,{anonymize_ip:!0,allow_google_signals:!1,allow_ad_personalization_signals:!1,app_version:`0.1.1`,...E?{traffic_type:`internal`}:{}});let e=document.createElement(`script`);e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(C)}`,document.head.appendChild(e)}function M(e){E=O(),T=e&&k(),k()&&(window[`ga-disable-${C}`]=!T,T&&j())}function N(e){if(T)try{A(`set`,`user_properties`,e)}catch{}}function P(e){return e===0?`0`:e===1?`1`:e<=3?`2-3`:e<=10?`4-10`:`10+`}function F(e,t={}){if(!T)return;let n={};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);try{A(`event`,e,n)}catch{}}var I=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},L=(e=>e?I(e):I),R=e=>e;function z(e,t=R){let n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}var B=e=>{let t=L(e),n=e=>z(t,e);return Object.assign(n,t),n},V=(e=>e?B(e):B),H=V()((e,t)=>({activeDialog:null,destructiveConfirm:null,dryRun:null,message:null,prompt:null,dialogProps:void 0,footerMessage:``,pendingGridEdits:{},transportVersion:0,isLoading:!1,welcomeVisible:!1,setWelcomeVisible:t=>e({welcomeVisible:t}),progress:0,contextMenu:{visible:!1,x:0,y:0,nodeType:null,nodeId:null},openDialog:(t,...n)=>{F(`dialog_open`,{dialog:t}),e({activeDialog:t,dialogProps:n[0]})},closeDialog:()=>e({activeDialog:null,dialogProps:void 0}),requestDestructiveConfirm:n=>{let r=t().destructiveConfirm;return r?.resolve(!1),new Promise(t=>{e({destructiveConfirm:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveDestructiveConfirm:n=>{let r=t().destructiveConfirm;r&&(e({destructiveConfirm:null}),r.resolve(n))},requestDryRun:n=>{let r=t().dryRun;return r?.resolve(!1),new Promise(t=>{e({dryRun:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveDryRun:n=>{let r=t().dryRun;r&&(e({dryRun:null}),r.resolve(n))},showMessage:n=>{let r=t().message;return r?.resolve(),new Promise(t=>{e({message:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveMessage:()=>{let n=t().message;n&&(e({message:null}),n.resolve())},requestPrompt:n=>{let r=t().prompt;return r?.resolve(null),new Promise(t=>{e({prompt:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolvePrompt:n=>{let r=t().prompt;r&&(e({prompt:null}),r.resolve(n))},setFooterMessage:t=>e({footerMessage:t}),setPendingGridEdits:(t,n)=>e(e=>{if(!!e.pendingGridEdits[t]===n)return{};let r={...e.pendingGridEdits};return n?r[t]=!0:delete r[t],{pendingGridEdits:r}}),bumpTransportVersion:()=>e(e=>({transportVersion:e.transportVersion+1})),setLoading:t=>e({isLoading:t}),setProgress:t=>e({progress:t}),showContextMenu:(t,n,r,i)=>e({contextMenu:{visible:!0,x:t,y:n,nodeType:r,nodeId:i}}),hideContextMenu:()=>e(e=>({contextMenu:{...e.contextMenu,visible:!1}}))}));function U(...e){return H(t=>t.activeDialog&&e.includes(t.activeDialog)?t.dialogProps:void 0)}export{l as _,k as a,F as c,v as d,_ as f,s as g,o as h,P as i,x as l,d as m,H as n,M as o,h as p,V as r,N as s,U as t,b as u};
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n)),u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),d=o(((e,t)=>{t.exports=u()})),f=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,p={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},m=e=>p[e],h=e=>e.replace(f,m),g={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:h,transDefaultProps:void 0},_=(e={})=>{g={...g,...e}},v=()=>g,y,b=e=>{y=e},x=()=>y,S=l(d(),1),C=`G-2FYJTCC2TH`,w=!1,T=!1,E=!1,D=`planche.internalTraffic`;function O(){if(typeof window>`u`)return!1;try{let e=new URLSearchParams(window.location.search).get(`internal`);return e===`1`?localStorage.setItem(D,`1`):e===`0`&&localStorage.removeItem(D),localStorage.getItem(D)===`1`}catch{return!1}}function k(){let e=typeof document<`u`&&document.querySelector(`meta[name="planche-agent"]`)!==null;return!!C&&typeof window<`u`&&!e}function A(){window.dataLayer=window.dataLayer??[],window.dataLayer.push(arguments)}function j(){if(w)return;w=!0,window.gtag=A,A(`js`,new Date),A(`config`,C,{anonymize_ip:!0,allow_google_signals:!1,allow_ad_personalization_signals:!1,app_version:`0.1.1`,...E?{traffic_type:`internal`}:{}});let e=document.createElement(`script`);e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${encodeURIComponent(C)}`,document.head.appendChild(e)}function M(e){E=O(),T=e&&k(),k()&&(window[`ga-disable-${C}`]=!T,T&&j())}function N(e){if(T)try{A(`set`,`user_properties`,e)}catch{}}function P(e){return e===0?`0`:e===1?`1`:e<=3?`2-3`:e<=10?`4-10`:`10+`}function F(e){return e<=1?`1`:e<=5?`2-5`:e<=20?`6-20`:e<=50?`21-50`:e<=100?`51-100`:`100+`}function I(e,t={}){if(!T)return;let n={};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);try{A(`event`,e,n)}catch{}}var L=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},R=(e=>e?L(e):L),z=e=>e;function B(e,t=z){let n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}var V=e=>{let t=R(e),n=e=>B(t,e);return Object.assign(n,t),n},H=(e=>e?V(e):V),U=H()((e,t)=>({activeDialog:null,destructiveConfirm:null,dryRun:null,message:null,prompt:null,dialogProps:void 0,footerMessage:``,pendingGridEdits:{},transportVersion:0,isLoading:!1,welcomeVisible:!1,setWelcomeVisible:t=>e({welcomeVisible:t}),progress:0,contextMenu:{visible:!1,x:0,y:0,nodeType:null,nodeId:null},openDialog:(t,...n)=>{I(`dialog_open`,{dialog:t}),e({activeDialog:t,dialogProps:n[0]})},closeDialog:()=>e({activeDialog:null,dialogProps:void 0}),requestDestructiveConfirm:n=>{let r=t().destructiveConfirm;return r?.resolve(!1),new Promise(t=>{e({destructiveConfirm:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveDestructiveConfirm:n=>{let r=t().destructiveConfirm;r&&(e({destructiveConfirm:null}),r.resolve(n))},requestDryRun:n=>{let r=t().dryRun;return r?.resolve(!1),new Promise(t=>{e({dryRun:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveDryRun:n=>{let r=t().dryRun;r&&(e({dryRun:null}),r.resolve(n))},showMessage:n=>{let r=t().message;return r?.resolve(),new Promise(t=>{e({message:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolveMessage:()=>{let n=t().message;n&&(e({message:null}),n.resolve())},requestPrompt:n=>{let r=t().prompt;return r?.resolve(null),new Promise(t=>{e({prompt:{id:(r?.id??0)+1,request:n,resolve:t}})})},resolvePrompt:n=>{let r=t().prompt;r&&(e({prompt:null}),r.resolve(n))},setFooterMessage:t=>e({footerMessage:t}),setPendingGridEdits:(t,n)=>e(e=>{if(!!e.pendingGridEdits[t]===n)return{};let r={...e.pendingGridEdits};return n?r[t]=!0:delete r[t],{pendingGridEdits:r}}),bumpTransportVersion:()=>e(e=>({transportVersion:e.transportVersion+1})),setLoading:t=>e({isLoading:t}),setProgress:t=>e({progress:t}),showContextMenu:(t,n,r,i)=>e({contextMenu:{visible:!0,x:t,y:n,nodeType:r,nodeId:i}}),hideContextMenu:()=>e(e=>({contextMenu:{...e.contextMenu,visible:!1}}))}));function W(...e){return U(t=>t.activeDialog&&e.includes(t.activeDialog)?t.dialogProps:void 0)}export{s as _,k as a,I as c,b as d,v as f,o as g,d as h,P as i,F as l,h as m,U as n,M as o,_ as p,H as r,N as s,W as t,x as u,l as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./connection-store-
|
|
1
|
+
import{t as e}from"./connection-store-CAPTzFtT.js";import{n as t}from"./dbms-Bsjvyvsp.js";function n(n){let r=e(e=>e.activeConnections.find(e=>e.id===n)?.dbms);return t(r)}function r(){let n=e(e=>e.activeConnections.find(t=>t.id===e.activeConnectionId)?.dbms);return t(n)}export{n,r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./ui-store-
|
|
1
|
+
import{r as e}from"./ui-store-DfspmPOn.js";var t=(e,t)=>`${t}@${e}`,n=e()(e=>({users:{},selectedUser:{},isLoading:{},setUsers:(t,n)=>e(e=>({users:{...e.users,[t]:n}})),setSelectedUser:(t,n)=>e(e=>({selectedUser:{...e.selectedUser,[t]:n}})),addUser:(t,n)=>e(e=>({users:{...e.users,[t]:[...e.users[t]??[],n]}})),updateUser:(n,r,i,a)=>e(e=>({users:{...e.users,[n]:(e.users[n]??[]).map(e=>t(e.host,e.user)===t(r,i)?{...e,...a}:e)}})),removeUser:(n,r,i)=>e(e=>{let a=e.selectedUser[n],o=a&&t(a.host,a.user)===t(r,i);return{users:{...e.users,[n]:(e.users[n]??[]).filter(e=>t(e.host,e.user)!==t(r,i))},selectedUser:{...e.selectedUser,[n]:o?null:a??null}}}),setLoading:(t,n)=>e(e=>({isLoading:{...e.isLoading,[t]:n}})),clear:t=>e(e=>{let n={...e.users},r={...e.selectedUser};return delete n[t],delete r[t],{users:n,selectedUser:r}})})),r=[];export{n,r as t};
|
package/app/index.html
CHANGED
|
@@ -49,26 +49,27 @@
|
|
|
49
49
|
"offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }
|
|
50
50
|
}
|
|
51
51
|
</script>
|
|
52
|
-
<script type="module" crossorigin src="/assets/ui-store-
|
|
53
|
-
<script type="module" crossorigin src="/assets/button
|
|
54
|
-
<script type="module" crossorigin src="/assets/i18n-
|
|
55
|
-
<script type="module" crossorigin src="/assets/dist-
|
|
56
|
-
<script type="module" crossorigin src="/assets/dist-
|
|
57
|
-
<script type="module" crossorigin src="/assets/dist-
|
|
52
|
+
<script type="module" crossorigin src="/assets/ui-store-DfspmPOn.js"></script>
|
|
53
|
+
<script type="module" crossorigin src="/assets/button--s6nUzD8.js"></script>
|
|
54
|
+
<script type="module" crossorigin src="/assets/i18n-C-w8Q5E_.js"></script>
|
|
55
|
+
<script type="module" crossorigin src="/assets/dist-CBYDYlja.js"></script>
|
|
56
|
+
<script type="module" crossorigin src="/assets/dist-pKt0y9E-.js"></script>
|
|
57
|
+
<script type="module" crossorigin src="/assets/dist-DgJHEXPr.js"></script>
|
|
58
58
|
<script type="module" crossorigin src="/assets/app-storage-B6v72zLH.js"></script>
|
|
59
|
-
<script type="module" crossorigin src="/assets/connection-store-
|
|
60
|
-
<script type="module" crossorigin src="/assets/settings-store-
|
|
61
|
-
<script type="module" crossorigin src="/assets/query-store-
|
|
62
|
-
<script type="module" crossorigin src="/assets/database-
|
|
59
|
+
<script type="module" crossorigin src="/assets/connection-store-CAPTzFtT.js"></script>
|
|
60
|
+
<script type="module" crossorigin src="/assets/settings-store-CYHWBgNo.js"></script>
|
|
61
|
+
<script type="module" crossorigin src="/assets/query-store-CRp9AQS5.js"></script>
|
|
62
|
+
<script type="module" crossorigin src="/assets/database-4FcrMRGA.js"></script>
|
|
63
63
|
<script type="module" crossorigin src="/assets/dbms-Bsjvyvsp.js"></script>
|
|
64
|
-
<script type="module" crossorigin src="/assets/engine-
|
|
64
|
+
<script type="module" crossorigin src="/assets/engine-DWYEiSZM.js"></script>
|
|
65
65
|
<script type="module" crossorigin src="/assets/schema-nodes-D3-cz2Xk.js"></script>
|
|
66
|
-
<script type="module" crossorigin src="/assets/query-execution-
|
|
67
|
-
<script type="module" crossorigin src="/assets/use-engine-
|
|
66
|
+
<script type="module" crossorigin src="/assets/query-execution-ODxyrvnD.js"></script>
|
|
67
|
+
<script type="module" crossorigin src="/assets/use-engine-DSWrApw6.js"></script>
|
|
68
|
+
<script type="module" crossorigin src="/assets/pro-usage-Dp3liEjn.js"></script>
|
|
68
69
|
<script type="module" crossorigin src="/assets/table-definition-Bs5VSn0X.js"></script>
|
|
69
|
-
<script type="module" crossorigin src="/assets/table-copy-
|
|
70
|
-
<script type="module" crossorigin src="/assets/main-
|
|
71
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
70
|
+
<script type="module" crossorigin src="/assets/table-copy-_VnDBCJc.js"></script>
|
|
71
|
+
<script type="module" crossorigin src="/assets/main-CvsCEaFQ.js"></script>
|
|
72
|
+
<link rel="stylesheet" crossorigin href="/assets/main-pmntwMQg.css">
|
|
72
73
|
</head>
|
|
73
74
|
<body>
|
|
74
75
|
<section id="landing">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "planche",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"description": "Local agent for Planche \u2014 lets the browser-based Planche SQL client reach MySQL/MariaDB/PostgreSQL/SQLite/SQL Server/Oracle/Neon/Supabase/Cloudflare D1 databases from your machine.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"homepage": "https://planche.dev",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t,n,t as r}from"./ui-store-VGM_km-l.js";import{$ as i,C as a,F as o,M as s,N as c,S as l,a as u,b as d,c as f,d as p,i as m,j as h,l as g,n as _,o as v,r as y,s as b,u as x,w as S,x as C,y as w}from"./main-DKTBYrT9.js";import{l as T,m as E,t as D}from"./button-BRD_vJ8s.js";import{a as O,i as k,n as A,r as j,t as M}from"./select-teWP1vRl.js";import{t as N}from"./connection-store-Cn79Ey1H.js";import{n as ee}from"./query-store-Cu277RoH.js";import{A as P,M as F,S as te,T as ne,b as re,k as I,l as L,m as ie,n as ae,s as R,t as oe,w as se}from"./database-C07SXivf.js";import{n as z,t as B}from"./dbms-Bsjvyvsp.js";import{a as ce,i as le,n as ue,o as de,t as fe}from"./dialog-1MXGAorC.js";var V=e(t(),1),H=new Set([`postgres:`,`postgresql:`]);function U(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!H.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var W=T(),G=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],K={enabled:!1,host:``,port:22,user:``,auth:`key`};function q({label:e,htmlFor:t,children:n}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,W.jsx)(g,{htmlFor:t,children:e}),n]})}function pe({value:e,onChange:t}){let{t:n}=E();function r(n,r){t({...e,[n]:r})}let i=e.dbms===`sqlite`,a=e.transport??`browser`,l=i&&a===`browser`,u=P.has(e.dbms),d=e.dbms===`d1`,f=B.find(t=>t.id===e.dbms)?.capabilities,m=e.ssh??K,[h,g]=(0,V.useState)(``),_=h.trim()===``?`empty`:U(h)?`applied`:`invalid`,y=e.dbms===`supabase`&&e.port===6543;function S(n){g(n);let r=U(n);r&&t({...e,host:r.host??e.host,port:r.port??B.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function C(n){t({...e,ssh:{...m,...n}})}async function w(e){e&&C({privateKey:await e.text(),privateKeyName:e.name})}return(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,W.jsx)(q,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,W.jsx)(x,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.dataSource`),children:(0,W.jsxs)(M,{value:e.dbms,onValueChange:n=>{let r=B.find(e=>e.id===n);if(!r)return;let i=r.id,a=P.has(i)||i===`d1`;g(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||u||d?b(i):e.user,database:e.database&&!a&&!u&&!d?e.database:v(i)??e.database})},children:[(0,W.jsx)(k,{id:`conn-dbms`,className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsx)(A,{children:B.map(e=>(0,W.jsx)(j,{value:e.id,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(p,{dbms:e.id}),e.label]})},e.id))})]})}),u&&(0,W.jsx)(q,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(x,{id:`conn-uri`,type:`password`,autoComplete:`off`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:h,onChange:e=>S(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${_===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(_===`invalid`?`connection.form.connectionStringInvalid`:_===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),i&&(0,W.jsxs)(q,{label:n(`connection.form.openVia`),children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:a===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:a===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(a===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),l?(0,W.jsx)(q,{label:n(`connection.form.databaseFile`),children:(0,W.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,W.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{R(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,W.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,W.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!l&&(0,W.jsx)(q,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,W.jsx)(x,{id:`conn-authToken`,type:`password`,placeholder:n(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>r(`authToken`,e.target.value.trim())})}),l?null:d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,W.jsx)(x,{id:`conn-d1-account`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>r(`accountId`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:(0,W.jsx)(x,{id:`conn-d1-database`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>r(`databaseId`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(x,{id:`conn-pass`,type:`password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):i?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,W.jsx)(x,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>r(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,W.jsx)(x,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>r(`host`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,W.jsx)(x,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||B.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),y&&(0,W.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:n(`connection.form.supabasePoolerWarning`)}),(F(e.dbms)||e.dbms===`mssql`||e.dbms===`oracle`)&&(0,W.jsx)(q,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,W.jsx)(x,{id:`conn-database`,placeholder:v(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,W.jsx)(q,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,W.jsx)(x,{id:`conn-user`,placeholder:b(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,W.jsx)(q,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,W.jsx)(x,{id:`conn-pass`,type:`password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),u&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),!u&&e.dbms!==`oracle`&&(0,W.jsx)(q,{label:n(`connection.form.tls`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>r(`ssl`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsEnable`)]}),(0,W.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>r(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsVerify`)]})]})}),!u&&(0,W.jsx)(q,{label:n(`connection.form.charset`),children:(0,W.jsxs)(M,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsx)(A,{children:G.map(e=>(0,W.jsx)(j,{value:e,children:e},e))})]})})]}),!i&&!u&&!d&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[n(`connection.form.ssh`),(0,W.jsx)(o,{className:`ml-2`})]}),(0,W.jsx)(q,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:m.enabled,onChange:e=>C({enabled:e.target.checked}),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),m.enabled&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(x,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:m.host,onChange:e=>C({host:e.target.value.trim()})}),(0,W.jsx)(x,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:m.port,onChange:e=>C({port:Number(e.target.value)||22})})]})}),(0,W.jsx)(q,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,W.jsx)(x,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:m.user,onChange:e=>C({user:e.target.value.trim()})})}),(0,W.jsx)(q,{label:n(`connection.form.sshAuth`),children:(0,W.jsxs)(M,{value:m.auth,onValueChange:e=>C({auth:e}),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsxs)(A,{children:[(0,W.jsx)(j,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,W.jsx)(j,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,W.jsx)(j,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),m.auth===`password`&&(0,W.jsx)(q,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,W.jsx)(x,{id:`conn-ssh-pass`,type:`password`,value:m.password??``,onChange:e=>C({password:e.target.value})})}),m.auth===`key`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(q,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{w(e.target.files?.[0]),e.target.value=``}}),(0,W.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:m.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,W.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:m.privateKeyName,children:m.privateKey?m.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,W.jsx)(q,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,W.jsx)(x,{id:`conn-ssh-passphrase`,type:`password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:m.passphrase??``,onChange:e=>C({passphrase:e.target.value})})})]}),m.auth===`agent`&&(0,W.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,W.jsx)(q,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,W.jsx)(`div`,{className:`flex items-center`,children:(0,W.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>r(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,W.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,W.jsx)(q,{label:n(`connection.form.environment`),children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[s.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,W.jsx)(`button`,{type:`button`,title:c(t.id),"aria-label":c(t.id),"aria-pressed":n,onClick:()=>r(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${n?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,W.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,W.jsx)(q,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>r(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,W.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),f?.transactions!==!1&&(0,W.jsx)(q,{label:n(`connection.form.transactions`),children:(0,W.jsxs)(M,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,W.jsx)(k,{className:`w-full`,children:(0,W.jsx)(O,{})}),(0,W.jsxs)(A,{children:[(0,W.jsx)(j,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,W.jsx)(j,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}function J(){let{t:e}=E(),{activeDialog:t,closeDialog:o,showMessage:s}=n(),[c,g]=(0,V.useState)(!1),{savedConnections:v,addSavedConnection:b,updateSavedConnection:x,deleteSavedConnection:T,openConnection:O}=N(),k=r(`connect`)?.profileId,[A,j]=(0,V.useState)(()=>k??null),[M,P]=(0,V.useState)(()=>{let e=k?v.find(e=>e.id===k):void 0;return e?{...e}:null}),F=t===`connect`,[R,B]=(0,V.useState)(null),[H,U]=(0,V.useState)(null),G=f(e=>e.url),K=f(e=>e.token);(0,V.useEffect)(()=>{if(!F)return;let e=!1;return(async()=>{try{let t=await te();if(e||t.state!==`online`||!t.gateway){e||B(null);return}let n=await se();e||(B({name:n.gateway,profiles:n.profiles}),U(null))}catch(t){e||U(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[F,G,K]);function q(t){let r=v.find(e=>e.gatewayProfile===t.name);if(r){Y(r);return}let i=y(t);b(i),Y(i),n.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function J(e){e||(o(),j(null),P(null))}function Y(e){j(e.id),P({...e})}function me(e){P(e),x(e.id,e)}function he(){let e=u();b(e),j(e.id),P(e)}function ge(){A&&(T(A),j(null),P(null))}let[_e,X]=(0,V.useState)(!1),ve=ee(e=>e.addQueryTab);function Z(t){let n=N.getState().activeConnections.some(e=>e.id===t.id);if(O(t),n){re.getState().removeTree(t.id),o(),j(null),P(null);return}ve(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),o(),j(null),P(null)}async function ye(t){let r=await oe(t.id,{interactive:!0});if(!r)return;let i={...t,file:r.fileName,serverConnectionId:r.connectionId};x(t.id,{file:r.fileName}),Z(i),N.getState().setFileDetached(t.id,r.fileDetached),r.restoredUnsaved?n.getState().setFooterMessage(e(r.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:r.fileName})):r.wal&&!r.walApplied?n.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:r.fileName})):r.walApplied&&n.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:r.fileName}))}async function Q(t,r){try{return await r(t)}catch(i){let a=ne(i);if(!a||!(`ssh`in t)||!t.ssh||!await n.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,a),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw i;return r({...t,ssh:{...t.ssh,acceptHostKey:a.fingerprint}})}}async function $(){if(M){X(!0);try{if(L(M)===`browser`){await ye(M);return}let t=await Q(I(M),e=>ae(e,M.authToken||void 0));t.success?Z({...M,serverConnectionId:t.connectionId}):s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{X(!1)}}}async function be(){if(M){if(L(M)===`browser`){s({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}g(!0);try{let t=await Q(I(M),e=>ie(e,M.authToken||void 0));t.success?s({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)}):s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`)})}catch(t){s({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}}return(0,W.jsx)(fe,{open:F,onOpenChange:J,children:(0,W.jsxs)(ue,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,W.jsx)(ce,{children:(0,W.jsx)(de,{children:e(`connection.dialog.title`)})}),(0,W.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,W.jsx)(i,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,W.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(R||H)&&(0,W.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,W.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),R?` — ${R.name}`:``]}),H&&(0,W.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:H})}),R?.profiles.map(t=>(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,W.jsx)(p,{dbms:_[t.driver],className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:t.name}),(0,W.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,W.jsx)(D,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>q(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,W.jsx)(h,{className:`h-full`,children:(0,W.jsxs)(w,{className:`table-fixed`,children:[(0,W.jsx)(a,{children:(0,W.jsxs)(S,{children:[(0,W.jsx)(l,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,W.jsx)(l,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,W.jsx)(l,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,W.jsx)(d,{children:v.length===0?(0,W.jsx)(S,{children:(0,W.jsx)(C,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):v.map(t=>(0,W.jsxs)(S,{"data-state":A===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>Y(t),onDoubleClick:()=>{Y(t),$()},children:[(0,W.jsx)(C,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,W.jsx)(C,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:`${t.user}@${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(L(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:`${t.user}@${t.host}:${t.port}`}),(0,W.jsx)(C,{className:`truncate`,title:z(t.dbms).label,children:(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,W.jsx)(p,{dbms:t.dbms,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:z(t.dbms).label})]})})]},t.id))})]})})]}),(0,W.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:M?(0,W.jsxs)(W.Fragment,{children:[L(M)!==`browser`&&(0,W.jsx)(`div`,{className:`p-4 pb-0`,children:(0,W.jsx)(m,{})}),M.gatewayProfile?(0,W.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,W.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,W.jsx)(p,{dbms:M.dbms,className:`size-4`}),M.hostName]}),(0,W.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:M.gatewayProfile})}),(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),M.database?` · ${M.database}`:``]})]}):(0,W.jsx)(pe,{value:M,onChange:me})]}):(0,W.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,W.jsxs)(le,{className:`sm:justify-between`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(D,{variant:`outline`,onClick:he,children:e(`connection.dialog.addNew`)}),(0,W.jsx)(D,{variant:`destructive`,onClick:ge,disabled:!A,children:e(`connection.dialog.delete`)})]}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(D,{variant:`outline`,onClick:be,disabled:!M||c,children:e(`connection.dialog.testConnection`)}),(0,W.jsx)(D,{onClick:$,disabled:!M||_e,children:e(`connection.dialog.connect`)}),(0,W.jsx)(D,{variant:`outline`,onClick:()=>J(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{J as ConnectDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t,n,t as r}from"./ui-store-VGM_km-l.js";import{l as i,u as a}from"./main-DKTBYrT9.js";import{l as o,m as s,t as c}from"./button-BRD_vJ8s.js";import{a as l,i as u,n as d,o as f,t as p}from"./dialog-1MXGAorC.js";var m=e(t(),1),h=o();function g(){let{t:e}=s(),{activeDialog:t,closeDialog:o}=n(),g=r(`copy-database`),_=t===`copy-database`,v=g?.database??``,[y,b]=(0,m.useState)(``),[x,S]=(0,m.useState)(`structure_data`);function C(e){e||(o(),b(``),S(`structure_data`))}function w(){o()}return(0,h.jsx)(p,{open:_,onOpenChange:C,children:(0,h.jsxs)(d,{className:`sm:max-w-[450px]`,children:[(0,h.jsx)(l,{children:(0,h.jsx)(f,{children:e(`database.copy.title`)})}),(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{children:e(`database.copy.source`)}),(0,h.jsx)(a,{value:v,disabled:!0})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,h.jsx)(a,{id:`target-db-name`,value:y,onChange:e=>b(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,h.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,h.jsx)(i,{children:e(`database.copy.options`)}),(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,h.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:x===`structure_data`,onChange:()=>S(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,h.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,h.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:x===`structure_only`,onChange:()=>S(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),(0,h.jsxs)(u,{children:[(0,h.jsx)(c,{variant:`outline`,onClick:()=>C(!1),children:e(`database.copy.cancel`)}),(0,h.jsx)(c,{onClick:w,disabled:!y.trim(),children:e(`database.copy.copy`)})]})]})})}export{g as CopyDatabaseDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t,n,t as r}from"./ui-store-VGM_km-l.js";import{P as i,l as a,u as o}from"./main-DKTBYrT9.js";import{l as s,m as ee,t as c}from"./button-BRD_vJ8s.js";import{a as l,i as u,n as d,r as f,t as p}from"./select-teWP1vRl.js";import{t as te}from"./connection-store-Cn79Ey1H.js";import{r as m}from"./database-C07SXivf.js";import{t as ne}from"./query-execution-Bqix04tS.js";import{n as h}from"./engine-tGsnPQEm.js";import{n as re,t as ie}from"./table-copy-NGGO-qDb.js";import{a as ae,i as oe,n as g,o as se,t as ce}from"./dialog-1MXGAorC.js";var _=e(t(),1),v=s(),y=e=>e instanceof Error?e.message:String(e),b=e=>e.hostName||e.host||e.file||e.id,le=`w-full rounded border bg-background px-2 py-1 text-xs font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 min-h-[160px] resize-y`;function x(){let{t:e}=ee(),t=n(e=>e.activeDialog),s=n(e=>e.closeDialog),x=n(e=>e.showMessage),S=r(`copy-table`),C=te(e=>e.activeConnections),w=t===`copy-table`,T=S?.connectionId??``,E=String(S?.metadata?.database??``),D=S?.nodeText??``,O=C.find(e=>e.id===T),ue=C.filter(e=>e.serverConnectionId),[k,de]=(0,_.useState)(T),[A,j]=(0,_.useState)([]),[M,N]=(0,_.useState)(``),[P,F]=(0,_.useState)(D),[I,L]=(0,_.useState)(`structure_data`),[R,z]=(0,_.useState)(`abort`),[B,V]=(0,_.useState)(``),[H,U]=(0,_.useState)(null),[W,G]=(0,_.useState)(null),[K,q]=(0,_.useState)(null),[J,Y]=(0,_.useState)(!1),X=(0,_.useRef)(null),Z=C.find(e=>e.id===k),Q=Z?h(k):null,fe=!!O&&!!Z&&h(T).id===Q?.id;(0,_.useEffect)(()=>{if(!w||!Z?.serverConnectionId)return;let e=!1,t=h(k),n=m(Z.serverConnectionId);return(async()=>{j([]);try{let r=await t.introspect.listDatabases(n);if(e)return;j(r);let i=k===T,a=i||r.includes(E)?E:r[0]??``;N(a),F(e=>i&&a===E&&e===D?`${D}_copy`:e)}catch(t){e||q(y(t))}})(),()=>{e=!0}},[w,k]),(0,_.useEffect)(()=>{if(!w||!Z||!M||!P.trim()||!O)return;let e=!1;return(async()=>{U(null);try{let t=await ie({connectionId:T,database:E,table:D},{connectionId:k,database:M,table:P.trim()});e||V(h(k).ddl.createTable(t))}catch(t){e||U(y(t))}})(),()=>{e=!0}},[w,k,M,P]);function $(e){if(!e){if(J){X.current?.abort();return}s()}}async function pe(){if(!M||!P.trim()||!B.trim())return;Y(!0),q(null),G({phase:`create`,copied:0,total:null});let t=new AbortController;X.current=t;try{let n=await re({source:{connectionId:T,database:E,table:D},target:{connectionId:k,database:M,table:P.trim()},mode:I,onConflict:R,createSql:B},G,t.signal);s(),await x({title:e(`table.copy.doneTitle`),description:I===`structure_data`?e(`table.copy.doneRows`,{count:n.rows,table:P.trim()}):e(`table.copy.doneStructure`,{table:P.trim()}),tone:`success`})}catch(e){e instanceof ne||q(y(e)),G(null)}finally{Y(!1),X.current=null}}let me=W?.phase===`copy`&&W.total?Math.min(100,Math.round(W.copied/W.total*100)):null,he=W?W.phase===`create`?e(`table.copy.progressCreate`):W.phase===`count`?e(`table.copy.progressCount`):W.phase===`copy`?e(`table.copy.progressRows`,{copied:W.copied,total:W.total??`?`}):e(`table.copy.progressDone`):``;return(0,v.jsx)(ce,{open:w,onOpenChange:$,children:(0,v.jsxs)(g,{className:`sm:max-w-[640px]`,children:[(0,v.jsx)(ae,{children:(0,v.jsx)(se,{children:e(`table.copy.title`)})}),(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.source`)}),(0,v.jsx)(o,{value:O?`${b(O)} / ${E} / ${D}`:``,disabled:!0})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-conn`,children:e(`table.copy.targetConnection`)}),(0,v.jsxs)(p,{value:k,onValueChange:de,disabled:J,children:[(0,v.jsx)(u,{id:`copy-target-conn`,className:`w-full`,children:(0,v.jsx)(l,{})}),(0,v.jsx)(d,{children:ue.map(t=>(0,v.jsxs)(f,{value:t.id,children:[b(t),t.readOnly?` (${e(`table.copy.readOnly`)})`:``]},t.id))})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-db`,children:e(`table.copy.targetDatabase`)}),(0,v.jsxs)(p,{value:M,onValueChange:N,disabled:J||A.length===0,children:[(0,v.jsx)(u,{id:`copy-target-db`,className:`w-full`,children:(0,v.jsx)(l,{placeholder:e(`table.copy.loading`)})}),(0,v.jsx)(d,{children:A.map(e=>(0,v.jsx)(f,{value:e,children:e},e))})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-target-table`,children:e(`table.copy.targetTable`)}),(0,v.jsx)(o,{id:`copy-target-table`,value:P,onChange:e=>F(e.target.value),disabled:J,spellCheck:!1})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.what`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_data`,onChange:()=>L(`structure_data`),disabled:J}),e(`table.copy.structureAndData`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-mode`,checked:I===`structure_only`,onChange:()=>L(`structure_only`),disabled:J}),e(`table.copy.structureOnly`)]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{children:e(`table.copy.ifExists`)}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`abort`,onChange:()=>z(`abort`),disabled:J}),e(`table.copy.abort`)]}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer text-destructive`,children:[(0,v.jsx)(`input`,{type:`radio`,name:`copy-conflict`,checked:R===`drop`,onChange:()=>z(`drop`),disabled:J}),e(`table.copy.dropAndRecreate`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(a,{htmlFor:`copy-ddl`,children:e(`table.copy.preview`)}),!fe&&Q&&(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`table.copy.crossEngineHint`,{engine:Q.label})}),(0,v.jsx)(`textarea`,{id:`copy-ddl`,className:le,value:B,onChange:e=>V(e.target.value),disabled:J,spellCheck:!1}),H&&(0,v.jsx)(`p`,{className:`text-xs text-destructive`,children:H})]}),W&&(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(i,{value:me??(W.phase===`done`?100:0)}),(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:he})]}),K&&(0,v.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K})]}),(0,v.jsxs)(oe,{children:[(0,v.jsx)(c,{variant:`outline`,onClick:()=>$(!1),children:e(J?`table.copy.stop`:`table.copy.cancel`)}),(0,v.jsx)(c,{onClick:()=>{pe()},disabled:J||!M||!P.trim()||!B.trim()||!!H,children:e(`table.copy.copy`)})]})]})})}export{x as CopyTableDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t,n}from"./ui-store-VGM_km-l.js";import{l as r,u as i}from"./main-DKTBYrT9.js";import{l as a,m as o,t as s}from"./button-BRD_vJ8s.js";import{a as c,i as l,n as u,r as d,t as f}from"./select-teWP1vRl.js";import{a as p,i as m,n as h,o as g,t as _}from"./dialog-1MXGAorC.js";var v=e(t(),1),y=a(),b=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],x={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function S(){let{t:e}=o(),{activeDialog:t,closeDialog:a}=n(),S=t===`create-database`,[C,w]=(0,v.useState)(``),[T,E]=(0,v.useState)(`utf8mb4`),[D,O]=(0,v.useState)(`utf8mb4_general_ci`);function k(e){e||(a(),w(``),E(`utf8mb4`),O(`utf8mb4_general_ci`))}function A(e){E(e);let t=x[e];O(t?.[0]??``)}function j(){a()}let M=x[T]??[];return(0,y.jsx)(_,{open:S,onOpenChange:k,children:(0,y.jsxs)(h,{className:`sm:max-w-[450px]`,children:[(0,y.jsx)(p,{children:(0,y.jsx)(g,{children:e(`database.create.title`)})}),(0,y.jsxs)(`div`,{className:`space-y-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,y.jsx)(i,{id:`db-name`,value:C,onChange:e=>w(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,y.jsxs)(f,{value:T,onValueChange:A,children:[(0,y.jsx)(l,{id:`db-charset`,className:`w-full`,children:(0,y.jsx)(c,{})}),(0,y.jsx)(u,{children:b.map(e=>(0,y.jsx)(d,{value:e,children:e},e))})]})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(r,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,y.jsxs)(f,{value:D,onValueChange:O,children:[(0,y.jsx)(l,{id:`db-collation`,className:`w-full`,children:(0,y.jsx)(c,{})}),(0,y.jsx)(u,{children:M.map(e=>(0,y.jsx)(d,{value:e,children:e},e))})]})]})]}),(0,y.jsxs)(m,{children:[(0,y.jsx)(s,{variant:`outline`,onClick:()=>k(!1),children:e(`database.create.cancel`)}),(0,y.jsx)(s,{onClick:j,disabled:!C.trim(),children:e(`database.create.create`)})]})]})})}export{S as CreateDatabaseDialog};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,c as t,m as n,n as r,t as i}from"./ui-store-VGM_km-l.js";import{A as a,R as o,_ as s,g as c,l,v as u}from"./main-DKTBYrT9.js";import{l as d,m as f,t as p}from"./button-BRD_vJ8s.js";import{a as m,i as h,n as g,r as _,t as v}from"./select-teWP1vRl.js";import{t as y}from"./connection-store-Cn79Ey1H.js";import{O as b,r as x}from"./database-C07SXivf.js";import{n as S}from"./engine-tGsnPQEm.js";import{a as ee,i as te,n as C,o as w,t as ne}from"./dialog-1MXGAorC.js";var T=e(n(),1),E=d(),re=e=>e instanceof Error?e.message:String(e),D=e=>e.hostName||e.host||e.file||e.id,O=5e4;function k({id:e,label:t,side:n,onChange:r,connections:i,disabled:a}){let{t:o}=f(),[s,c]=(0,T.useState)([]),[u,d]=(0,T.useState)([]),p=i.find(e=>e.id===n.connectionId);return(0,T.useEffect)(()=>{if(!p?.serverConnectionId)return;let e=!1;return(async()=>{try{let t=await S(p.id).introspect.listDatabases(x(p.serverConnectionId));if(e)return;c(t),t.includes(n.database)||r({connectionId:p.id,database:t[0]??``,table:``})}catch{e||c([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId]),(0,T.useEffect)(()=>{if(!p?.serverConnectionId||!n.database)return;let e=!1;return(async()=>{try{let t=await S(p.id).introspect.listTables(x(p.serverConnectionId),n.database);if(e)return;let i=t.map(e=>e.name);d(i),n.table&&!i.includes(n.table)&&r({...n,table:``})}catch{e||d([])}})(),()=>{e=!0}},[p?.id,p?.serverConnectionId,n.database]),(0,E.jsxs)(`div`,{className:`space-y-2 rounded-md border p-3`,children:[(0,E.jsx)(l,{className:`font-medium`,children:t}),(0,E.jsxs)(v,{value:n.connectionId,onValueChange:e=>r({connectionId:e,database:``,table:``}),disabled:a,children:[(0,E.jsx)(h,{id:`${e}-conn`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.diff.pickConnection`)})}),(0,E.jsx)(g,{children:i.map(e=>(0,E.jsx)(_,{value:e.id,children:D(e)},e.id))})]}),(0,E.jsxs)(v,{value:n.database,onValueChange:e=>r({...n,database:e,table:``}),disabled:a||s.length===0,children:[(0,E.jsx)(h,{id:`${e}-db`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.diff.pickDatabase`)})}),(0,E.jsx)(g,{children:s.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]}),(0,E.jsxs)(v,{value:n.table,onValueChange:e=>r({...n,table:e}),disabled:a||u.length===0,children:[(0,E.jsx)(h,{id:`${e}-table`,className:`w-full`,children:(0,E.jsx)(m,{placeholder:o(`database.dataDiff.pickTable`)})}),(0,E.jsx)(g,{children:u.map(e=>(0,E.jsx)(_,{value:e,children:e},e))})]})]})}async function A(e,t){let n=await o({connectionId:e.connectionId,database:e.database,table:e.table,limit:O,onProgress:t}),r=[];for await(let e of n.pages)r.push(...e);return{rows:r,columns:n.fields.map(e=>e.name),capped:r.length>=O}}function j({diff:e,row:t,other:n,changed:r}){let{t:i}=f(),a=[...e.keyColumns,...e.compareColumns];return(0,E.jsxs)(`table`,{className:`w-full text-xs font-mono`,children:[(0,E.jsx)(`thead`,{className:`text-muted-foreground`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.column`)}),(0,E.jsx)(`th`,{className:`text-left font-normal pr-2`,children:i(`database.diff.source`)}),(0,E.jsx)(`th`,{className:`text-left font-normal`,children:i(`database.diff.target`)})]})}),(0,E.jsx)(`tbody`,{children:a.map(e=>(0,E.jsxs)(`tr`,{className:r?.includes(e)?`text-amber-600 dark:text-amber-400`:``,children:[(0,E.jsx)(`td`,{className:`pr-2 align-top whitespace-nowrap`,children:e}),(0,E.jsx)(`td`,{className:`pr-2 align-top break-all`,children:s(t[e])}),(0,E.jsx)(`td`,{className:`align-top break-all`,children:n?s(n[e]):`—`})]},e))})]})}function M(){let{t:e}=f(),n=r(e=>e.activeDialog),o=r(e=>e.closeDialog),l=i(`data-diff`),d=y(e=>e.activeConnections),m=(0,T.useMemo)(()=>d.filter(e=>e.serverConnectionId),[d]),h=y(e=>e.activeConnectionId),g=n===`data-diff`,[_,v]=(0,T.useState)(()=>l&&m.some(e=>e.id===l.connectionId)?{connectionId:l.connectionId,database:l.database,table:l.table}:{connectionId:h&&m.some(e=>e.id===h)?h:m[0]?.id??``,database:``,table:``}),[D,M]=(0,T.useState)(()=>({connectionId:m.find(e=>e.id!==_.connectionId)?.id??_.connectionId,database:``,table:``})),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[L,R]=(0,T.useState)(`changed`),[z,B]=(0,T.useState)(0),[V,oe]=(0,T.useState)(!1),[H,U]=(0,T.useState)(!1),[W,G]=(0,T.useState)({source:null,target:null}),[K,q]=(0,T.useState)(null),se=e=>M(e.database&&!e.table&&_.table?{...e,table:_.table}:e),J=_.connectionId===D.connectionId&&_.database===D.database&&_.table===D.table,ce=!!_.table&&!!D.table&&!J,Y=D.connectionId?S(D.connectionId):null;async function X(){U(!0),q(null),I(null);try{let n=y.getState().activeConnections.find(e=>e.id===_.connectionId);if(!n?.serverConnectionId)throw Error(e(`services.query.notConnected`));let r=await S(_.connectionId).introspect.getPrimaryKeys(x(n.serverConnectionId),_.database,_.table);if(r.length===0)throw Error(e(`database.dataDiff.noPrimaryKey`,{table:_.table}));G({source:{loaded:0,total:null},target:{loaded:0,total:null}});let[i,a]=await Promise.all([A(_,e=>G(t=>({...t,source:e}))),A(D,e=>G(t=>({...t,target:e})))]);if(r.some(e=>!a.columns.includes(e)))throw Error(e(`database.dataDiff.keyMissingInTarget`,{columns:r.join(`, `)}));let o=u(i.rows,a.rows,r,i.columns,a.columns);P(r),ae(i.capped||a.capped),I(o),R(o.changed.length>0?`changed`:o.added.length>0?`added`:`removed`),B(0),b(`compare_data`),t(`data_diff`,{source_dbms:S(_.connectionId).id,target_dbms:Y?.id??`unknown`,added:o.added.length,changed:o.changed.length,removed:o.removed.length})}catch(e){q(re(e))}finally{U(!1),G({source:null,target:null})}}let Z=e=>e?e.total===null?e.loaded.toLocaleString():`${e.loaded.toLocaleString()} / ${e.total.toLocaleString()}`:``,Q=(0,T.useMemo)(()=>F&&Y?c(F,Y,{database:D.database,table:D.table},{includeDeletes:V}):``,[F,Y,D.database,D.table,V]);function le(){Q&&(a(D.connectionId,Q,D.database,e(`database.dataDiff.tabTitle`,{table:D.table})),o())}let $=F?L===`added`?F.added:L===`removed`?F.removed:F.changed.map(e=>e.source):[],ue=!!F&&F.added.length+F.changed.length+F.removed.length>0,de=e=>N.map(t=>s(e[t])).join(`, `);return(0,E.jsx)(ne,{open:g,onOpenChange:e=>{e||o()},children:(0,E.jsxs)(C,{className:`sm:max-w-[900px]`,children:[(0,E.jsx)(ee,{children:(0,E.jsx)(w,{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)(k,{id:`ddiff-source`,label:e(`database.diff.source`),side:_,onChange:v,connections:m,disabled:H}),(0,E.jsx)(k,{id:`ddiff-target`,label:e(`database.diff.target`),side:D,onChange:se,connections:m,disabled:H})]}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.hint`,{cap:O.toLocaleString()})}),J&&_.table&&(0,E.jsx)(`p`,{className:`text-xs text-destructive`,children:e(`database.dataDiff.sameSide`)}),K&&(0,E.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:K}),H&&(W.source||W.target)&&(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`database.dataDiff.loading`,{source:Z(W.source),target:Z(W.target)})}),F&&(0,E.jsxs)(`div`,{className:`space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e(`database.dataDiff.summary`,{key:N.join(`, `),added:F.added.length,changed:F.changed.length,removed:F.removed.length,identical:F.identical})}),ie&&(0,E.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:e(`database.dataDiff.capped`,{cap:O.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)(j,{diff:F,row:F.changed[z].source,other:F.changed[z].target,changed:F.changed[z].columns}):L===`removed`?(0,E.jsx)(j,{diff:F,row:{},other:$[z]}):(0,E.jsx)(j,{diff:F,row:$[z]}):(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children: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=>oe(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:o,children:e(`database.diff.close`)}),(0,E.jsx)(p,{variant:`secondary`,onClick:()=>{X()},disabled:!ce||H,children:e(H?`database.diff.comparing`:`database.diff.compare`)}),(0,E.jsx)(p,{onClick:le,disabled:!ue,children:e(`database.diff.openScript`)})]})]})})}export{M as DataDiffDialog};
|