planche 0.8.13 → 0.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/assets/{SFsWRs4-.js → B6E7IbMa.js} +1 -1
- package/app/assets/{CUK2WAdf.js → BBLekwhn.js} +1 -1
- package/app/assets/{DSmKDd5u.js → BLPGwQub.js} +1 -1
- package/app/assets/{BW4K9UH-.js → BUcTqhSL.js} +1 -1
- package/app/assets/{BRc4Nt6e.js → BX4n4TJQ.js} +1 -1
- package/app/assets/{Bhquh17w.js → BZ6aghND.js} +4 -4
- package/app/assets/{CeXMO4BR.js → BbFio3pA.js} +1 -1
- package/app/assets/{y4cmNs6-.js → Bdp1DKAx.js} +1 -1
- package/app/assets/{COfwwXGO.js → Bpq2Whsw.js} +2 -2
- package/app/assets/{CiFkP-9S.js → BuhEpB12.js} +1 -1
- package/app/assets/{B2csuorb.js → BxW20weH.js} +1 -1
- package/app/assets/{hrOpaTVU.js → C-8gMuEc.js} +1 -1
- package/app/assets/{DTDWV2fP.js → C29gYFqD.js} +1 -1
- package/app/assets/{CqK9ewb_.js → C3PpGnxB.js} +1 -1
- package/app/assets/{fI8KJgQa.js → CNC8pjhK.js} +1 -1
- package/app/assets/{y664aOTm.js → CSYxJn5_.js} +1 -1
- package/app/assets/{DzVnJu74.js → CkPnfgzt.js} +1 -1
- package/app/assets/{CpSudzcZ.js → ClIJYMXh.js} +1 -1
- package/app/assets/{DkPnEF-y.js → ClQzFEcL.js} +1 -1
- package/app/assets/{Bajzqc8D.js → CoSpkBZh.js} +1 -1
- package/app/assets/{Bs-p2SdN.js → CxGlndnu.js} +1 -1
- package/app/assets/{DMRY-PmY.js → D3ZaTPbf.js} +1 -1
- package/app/assets/{CMoC9sLj.js → DF5d9evm.js} +1 -1
- package/app/assets/{DWMVPRon.js → DGpfJHer.js} +1 -1
- package/app/assets/{Dc12Sye0.js → DOU2MWdA.js} +1 -1
- package/app/assets/{qXWuX5B-.js → DXtaGfxh.js} +1 -1
- package/app/assets/{CVpOAP2j.js → DdHg_zlz.js} +1 -1
- package/app/assets/{CrT26gRf.js → DiIO0MJM.js} +1 -1
- package/app/assets/{useqs8Jk.js → DnZlL3PP.js} +1 -1
- package/app/assets/{CbmIWIww.js → H8HkC925.js} +1 -1
- package/app/assets/{9kM6GVHV.js → VZqLr_d1.js} +1 -1
- package/app/assets/{Bjm-okwb.js → _OOlglTI.js} +1 -1
- package/app/assets/{OjAiMU9J.js → mA5FXiEh.js} +2 -2
- package/app/assets/{DW8BZVdB.js → mZyfO6B4.js} +1 -1
- package/app/assets/{DIJgEIiP.js → uVZVQeN3.js} +1 -1
- package/app/index.html +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./B1pia_Rg.js";import{l as t,m as n,t as r}from"./pjlgs2cl.js";import{K as i,t as a}from"./
|
|
1
|
+
import{n as e}from"./B1pia_Rg.js";import{l as t,m as n,t as r}from"./pjlgs2cl.js";import{K as i,t as a}from"./BZ6aghND.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./BgkATqP8.js";var f=t(),p=`https://planche.dev`,m=`/third-party-notices.txt`;function h(){let t=e(e=>e.activeDialog),h=e(e=>e.closeDialog),{t:g}=n();return(0,f.jsx)(d,{open:t===`about`,onOpenChange:e=>{e||h()},children:(0,f.jsxs)(c,{className:`sm:max-w-[440px]`,children:[(0,f.jsx)(o,{children:(0,f.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,f.jsx)(a,{size:44,className:`shrink-0`}),(0,f.jsxs)(`div`,{className:`grid gap-1`,children:[(0,f.jsx)(l,{children:g(`about.title`)}),(0,f.jsx)(u,{children:g(`about.tagline`)})]})]})}),(0,f.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,f.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1`,children:[(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.version`)}),(0,f.jsx)(`dd`,{children:`0.1.1`}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.website`)}),(0,f.jsx)(`dd`,{children:(0,f.jsx)(`a`,{href:p,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:p})}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.licenses`)}),(0,f.jsx)(`dd`,{children:(0,f.jsx)(`a`,{href:m,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.licensesLink`)})}),(0,f.jsx)(`dt`,{className:`text-muted-foreground`,children:g(`about.legal`)}),(0,f.jsxs)(`dd`,{className:`flex gap-3`,children:[(0,f.jsx)(`a`,{href:i.terms,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.terms`)}),(0,f.jsx)(`a`,{href:i.privacy,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.privacy`)}),(0,f.jsx)(`a`,{href:i.refund,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.refund`)})]})]}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`© 2026 Juwon Jeong. `,g(`about.rights`)]}),(0,f.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:g(`about.disclaimer`)}),(0,f.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-muted-foreground`,children:[(0,f.jsx)(`p`,{className:`mb-1 font-medium text-amber-600 dark:text-amber-400`,children:g(`pro.noticeTitle`)}),(0,f.jsx)(`p`,{children:g(`pro.notice`)})]})]}),(0,f.jsx)(s,{children:(0,f.jsx)(r,{onClick:h,children:g(`settings.done`)})})]})})}export{h as AboutDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{a as o,i as s,n as c,r as l,t as u}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{a as o,i as s,n as c,r as l,t as u}from"./BuhEpB12.js";import{t as d}from"./BCmzDvBt.js";import{n as f}from"./pneb1la9.js";import{l as p,m}from"./mA5FXiEh.js";import{c as h,l as g}from"./BZ6aghND.js";import{a as _,i as v,n as y,o as b,t as x}from"./BgkATqP8.js";var S=e(t(),1),C=r(),w=[`utf8mb4`,`utf8`,`latin1`,`ascii`,`binary`,`cp1251`,`euckr`,`gb2312`,`gbk`,`sjis`,`ucs2`,`utf16`,`utf32`],T={utf8mb4:[`utf8mb4_general_ci`,`utf8mb4_unicode_ci`,`utf8mb4_bin`,`utf8mb4_0900_ai_ci`],utf8:[`utf8_general_ci`,`utf8_unicode_ci`,`utf8_bin`],latin1:[`latin1_swedish_ci`,`latin1_general_ci`,`latin1_bin`],ascii:[`ascii_general_ci`,`ascii_bin`],binary:[`binary`],cp1251:[`cp1251_general_ci`,`cp1251_bin`],euckr:[`euckr_korean_ci`,`euckr_bin`],gb2312:[`gb2312_chinese_ci`,`gb2312_bin`],gbk:[`gbk_chinese_ci`,`gbk_bin`],sjis:[`sjis_japanese_ci`,`sjis_bin`],ucs2:[`ucs2_general_ci`,`ucs2_unicode_ci`,`ucs2_bin`],utf16:[`utf16_general_ci`,`utf16_unicode_ci`,`utf16_bin`],utf32:[`utf32_general_ci`,`utf32_unicode_ci`,`utf32_bin`]};function E(){let{t:e}=i(),{activeDialog:t,closeDialog:r}=n(),E=t===`create-database`,[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(`utf8mb4`),[j,M]=(0,S.useState)(`utf8mb4_general_ci`),[N,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null);function L(e){e||(r(),I(null),O(``),A(`utf8mb4`),M(`utf8mb4_general_ci`))}function R(e){A(e);let t=T[e];M(t?.[0]??``)}async function z(){let e=d.getState().activeConnectionId,t=D.trim();if(!(!e||!t)){I(null),P(!0);try{let n=f(e).getQuery(`CREATE_DATABASE`,t,k,j);await p(e,n),await m(e),L(!1)}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}}let B=T[k]??[];return(0,C.jsx)(x,{open:E,onOpenChange:L,children:(0,C.jsxs)(y,{className:`sm:max-w-[450px]`,children:[(0,C.jsx)(_,{children:(0,C.jsx)(b,{children:e(`database.create.title`)})}),(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-name`,children:e(`database.create.name`)}),(0,C.jsx)(g,{id:`db-name`,value:D,onChange:e=>O(e.target.value),placeholder:e(`database.create.namePlaceholder`)})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-charset`,children:e(`database.create.charset`)}),(0,C.jsxs)(u,{value:k,onValueChange:R,children:[(0,C.jsx)(s,{id:`db-charset`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:w.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]}),(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(h,{htmlFor:`db-collation`,children:e(`database.create.collation`)}),(0,C.jsxs)(u,{value:j,onValueChange:M,children:[(0,C.jsx)(s,{id:`db-collation`,className:`w-full`,children:(0,C.jsx)(o,{})}),(0,C.jsx)(c,{children:B.map(e=>(0,C.jsx)(l,{value:e,children:e},e))})]})]})]}),F&&(0,C.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:F}),(0,C.jsxs)(v,{children:[(0,C.jsx)(a,{variant:`outline`,onClick:()=>L(!1),children:e(`database.create.cancel`)}),(0,C.jsx)(a,{onClick:()=>void z(),disabled:!D.trim()||N,children:e(`database.create.create`)})]})]})})}export{E as CreateDatabaseDialog};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./B1pia_Rg.js";import{l as a,m as o,t as s}from"./pjlgs2cl.js";import{a as c,i as l,n as u,r as d,t as f}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{c as t,h as n,n as r,t as i}from"./B1pia_Rg.js";import{l as a,m as o,t as s}from"./pjlgs2cl.js";import{a as c,i as l,n as u,r as d,t as f}from"./BuhEpB12.js";import{_ as p,t as m}from"./BCmzDvBt.js";import{n as ee}from"./BO_H_8D-.js";import{a as te}from"./CS2mpWDL.js";import{n as ne}from"./pneb1la9.js";import{n as re}from"./mA5FXiEh.js";import{H as h,M as ie,c as g,l as _}from"./BZ6aghND.js";import{a as v,i as y,n as b,o as x,t as S}from"./BgkATqP8.js";import{t as C}from"./CnYBZPf9.js";var w=e(n(),1);function T(e,t){let n=e==null?``:typeof e==`object`?JSON.stringify(e):String(e);return!(typeof e==`number`||typeof e==`bigint`||/^[-+]?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(n))&&/^[=+\-@\t\r]/.test(n)&&(n=`'${n}`),n.includes(t)||n.includes(`"`)||n.includes(`
|
|
2
2
|
`)||n.includes(`\r`)?`"${n.replace(/"/g,`""`)}"`:n}var E=(e,t)=>e.map(e=>T(e,t)).join(t)+`
|
|
3
|
-
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let n=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),r=0;try{let i=await h({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),a=i.fields.map(e=>e.name);e.includeHeaders&&await n.write(E(a,e.delimiter));for await(let t of i.pages)await n.write(t.map(t=>E(a.map(e=>t[e]),e.delimiter)).join(``)),r+=t.length;return await n.finish(),t(`export_csv`,{
|
|
3
|
+
`,D=e=>e===` `,O=e=>D(e)?`TSV`:`CSV`,k=e=>D(e)?`.tsv`:`.csv`,A=e=>D(e)?`text/tab-separated-values`:`text/csv`;async function j(e,t){let n=C(e),r=A(t);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:n,types:[{description:O(t),accept:{[r]:[k(t)]}}]})).createWritable();return await e.write(``),{write:t=>e.write(t),finish:()=>e.close(),abort:()=>e.abort()}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw new M}let i=[``];return{write:async e=>{i.push(e)},finish:async()=>{let e=new Blob(i,{type:`${r};charset=utf-8;`}),t=URL.createObjectURL(e),a=document.createElement(`a`);a.href=t,a.download=n,a.click(),URL.revokeObjectURL(t)},abort:async()=>{i.length=0}}}var M=class extends Error{constructor(){super(`CSV export cancelled`)}};async function N(e){let n=await j(`${e.table}${k(e.delimiter)}`,e.delimiter),r=0;try{let i=await h({connectionId:e.connectionId,database:e.database,table:e.table,signal:e.signal,onProgress:e.onProgress}),a=i.fields.map(e=>e.name);e.includeHeaders&&await n.write(E(a,e.delimiter));for await(let t of i.pages)await n.write(t.map(t=>E(a.map(e=>t[e]),e.delimiter)).join(``)),r+=t.length;return await n.finish(),t(`export_csv`,{origin:`table`,rows:r,format:O(e.delimiter)}),r}catch(e){throw await n.abort().catch(()=>void 0),e}}function P(e,n,r,i,a){let o=e.map(e=>e.name),s=[``];i&&s.push(E(o,r));for(let e of n)s.push(E(o.map(t=>e[t]),r));let c=new Blob(s,{type:`${A(r)};charset=utf-8;`}),l=URL.createObjectURL(c),u=document.createElement(`a`);u.href=l,u.download=C(a??`query_result${k(r)}`),u.click(),URL.revokeObjectURL(l),t(`export_csv`,{origin:`result`,rows:n.length,format:O(r)})}var F=a(),I=[{value:`,`,label:`database.csv.delimiterComma`},{value:` `,label:`database.csv.delimiterTab`},{value:`;`,label:`database.csv.delimiterSemicolon`},{value:`|`,label:`database.csv.delimiterPipe`}];function L(){let{t:e}=o(),{activeDialog:t,closeDialog:n}=r(),a=i(`export-csv`),h=m(e=>e.activeConnectionId),C=ee(),T=t===`export-csv`,[E,O]=(0,w.useState)(`query_result`),[k,A]=(0,w.useState)(``),[j,L]=(0,w.useState)([]),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(`,`),[H,U]=(0,w.useState)(!0),[W,G]=(0,w.useState)(!1),[K,q]=(0,w.useState)(null),[J,Y]=(0,w.useState)(null),X=(0,w.useRef)(null),Z=D(B)?`TSV`:`CSV`,Q=()=>{if(a?.nodeText&&(a.nodeType===p.TABLE||a.nodeType===p.VIEW)){let e=a.metadata?.database;return{table:a.nodeText,database:typeof e==`string`?e:``}}if(!h)return null;let e=(C.tabs[h]??[]).find(e=>e.id===C.activeTabId[h]);return e?.sourceTable?{table:e.sourceTable.table,database:e.sourceTable.database}:null};(0,w.useEffect)(()=>{if(!T)return;let e=Q();V(a?.delimiter??`,`),e&&(A(e.table),O(`table_data`))},[T]),(0,w.useEffect)(()=>{if(!T||!h)return;let e=m.getState().activeConnections.find(e=>e.id===h);if(!e?.serverConnectionId)return;let t=!1;return(async()=>{try{let n=await ne(h).introspect.listDatabases(te(e.serverConnectionId));if(t)return;L(n);let r=C.tabs[h]?.find(e=>e.id===C.activeTabId[h])?.database||``,i=Q()?.database||``;z(e=>n.includes(i)?i:n.includes(e)?e:n.includes(r)?r:n.length===1?n[0]:``)}catch{t||L([])}})(),()=>{t=!0}},[T,h]);function $(e){if(!e){if(W){X.current?.abort();return}n(),O(`query_result`),A(``),V(`,`),U(!0)}}async function ae(){if(!h)return;if(Y(null),E===`query_result`){let e=C.activeTabId[h],t=(C.tabs[h]??[]).find(t=>t.id===e)?.results?.[0];if(!t||t.rows.length===0)return;P(t.fields,t.rows,B,H),n();return}if(!k.trim()||!R)return;let t=new AbortController;X.current=t,G(!0),q({loaded:0,total:null});try{let i=await N({connectionId:h,database:R,table:k.trim(),delimiter:B,includeHeaders:H,onProgress:q,signal:t.signal});r.getState().setFooterMessage(e(`database.csv.done`,{count:i,table:k.trim(),format:Z})),n()}catch(e){!(e instanceof M)&&!(e instanceof re&&t.signal.aborted)&&Y(e instanceof Error?e.message:String(e))}finally{G(!1),q(null),X.current=null}}let oe=K?.total?Math.min(100,Math.round(K.loaded/K.total*100)):null;return(0,F.jsx)(S,{open:T,onOpenChange:$,children:(0,F.jsxs)(b,{className:`sm:max-w-[450px]`,children:[(0,F.jsx)(v,{children:(0,F.jsx)(x,{children:e(`database.csv.title`,{format:Z})})}),(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{children:e(`database.csv.target`)}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`query_result`,checked:E===`query_result`,onChange:()=>O(`query_result`)}),e(`database.csv.targetQueryResult`)]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`radio`,name:`csv-target`,value:`table_data`,checked:E===`table_data`,onChange:()=>O(`table_data`)}),e(`database.csv.targetTableData`)]})]})]}),E===`table_data`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-database`,children:e(`database.csv.database`)}),(0,F.jsxs)(f,{value:R,onValueChange:z,disabled:j.length===0,children:[(0,F.jsx)(l,{id:`csv-database`,className:`w-full`,children:(0,F.jsx)(c,{placeholder:e(`database.csv.databasePlaceholder`)})}),(0,F.jsx)(u,{children:j.map(e=>(0,F.jsx)(d,{value:e,children:e},e))})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-table-name`,children:e(`database.csv.tableName`)}),(0,F.jsx)(_,{id:`csv-table-name`,value:k,onChange:e=>A(e.target.value),placeholder:e(`database.csv.tableNamePlaceholder`)})]})]}),(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsx)(g,{htmlFor:`csv-delimiter`,children:e(`database.csv.delimiter`)}),(0,F.jsxs)(f,{value:B,onValueChange:V,children:[(0,F.jsx)(l,{id:`csv-delimiter`,className:`w-full`,children:(0,F.jsx)(c,{})}),(0,F.jsx)(u,{children:I.map(t=>(0,F.jsx)(d,{value:t.value,children:e(t.label)},t.value))})]})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>U(e.target.checked)}),e(`database.csv.includeHeaders`)]})]}),K&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(ie,{value:oe??0}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K.total===null?e(`database.csv.progressUnknown`,{loaded:K.loaded}):e(`database.csv.progress`,{loaded:K.loaded,total:K.total})})]}),J&&(0,F.jsx)(`p`,{className:`text-sm text-destructive whitespace-pre-wrap`,children:J}),(0,F.jsxs)(y,{children:[(0,F.jsx)(s,{variant:`outline`,onClick:()=>$(!1),children:e(W?`database.csv.stop`:`database.csv.cancel`)}),(0,F.jsx)(s,{onClick:ae,disabled:W||E===`table_data`&&!k.trim(),children:e(W?`database.csv.downloading`:`database.csv.download`)})]})]})})}export{L as DownloadToCSVDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t}from"./B1pia_Rg.js";import{b as n,l as r,o as i,p as a,s as o,u as s}from"./pjlgs2cl.js";import{r as c,t as l}from"./bgQ-QVd7.js";import{S as u,_ as d,b as f,d as p,f as m,g as h,h as g,m as _,p as v,u as y,v as b,x,y as S}from"./CF6jyexg.js";import{n as C,t as w}from"./CEtGUZGE.js";import{t as T}from"./CZoj-eMm.js";import{Lt as E,Qt as D,Rt as O,Xt as k,Yt as A,Zt as j}from"./Bhquh17w.js";var M=e(n(),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=r(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=u(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:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,O]=S({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[k,A]=S({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(k);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>A(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=d(),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:w,onValueNodeHasChildrenChange:T,contentId:z,value:k,onValueChange:A,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:u,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(j,{..._,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,s=K(n),c=q(oe,n),l=c.disabled||r,u=a(t,c.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===c.value));n!==void 0&&c.onValueChange(n.value)}),g=R(e=>{l||(c.onOpenChange(!0),h()),e&&(c.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...s,children:(0,I.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":`none`,dir:c.dir,"data-state":c.open?`open`:`closed`,disabled:l,"data-disabled":l?``:void 0,"data-placeholder":$(c.value)?``:void 0,...i,ref:u,onClick:x(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:x(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:x(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:s,placeholder:c=``,...l}=e,u=q(ce,n),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=a(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?c:s},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(o.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)(v,{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 f(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(b,{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=s(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=a(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 y(E)},[E]),m();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:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C}:{};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)(p,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:x(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,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:x(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,s=q(Y,n),c=Z(Y,n),[l,u]=N.useState(null),[d,p]=N.useState(null),m=a(t,p),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=N.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&v&&y&&b){let e=s.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(s.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let a=h(),o=window.innerHeight-X*2,c=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+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=o-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;l.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);l.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;l.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?T:0)+k)+M;l.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}l.style.margin=`${X}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=o+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,r]);f(()=>S(),[S]);let[C,T]=N.useState();f(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);let E=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:(0,I.jsx)(`div`,{ref:u,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(o.div,{...i,ref:m,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,s=Z(Ce,n),c=Se(Ce,n),l=a(t,s.onViewportChange),u=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)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:x(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=c;if(r?.current&&n){let e=Math.abs(u.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`)}}}u.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:s,...c}=e,l=q(De,n),u=Z(De,n),f=l.value===r,[p,m]=N.useState(s??``),[g,_]=N.useState(!1),v=h(e=>u.itemRefCallback?.(e,r,i)),y=a(t,v),b=d(),S=N.useRef(`touch`),C=R(()=>{i||(l.onValueChange(r),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,I.jsx)(o.div,{role:`option`,"aria-labelledby":b,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:y,onFocus:x(c.onFocus,()=>_(!0)),onBlur:x(c.onBlur,()=>_(!1)),onClick:x(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:x(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:x(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:x(c.onPointerMove,e=>{S.current=e.pointerType,i?u.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:x(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:x(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...s}=e,c=q(Q,n),l=Z(Q,n),u=ke(Q,n),d=ie(Q,n),[p,m]=N.useState(null),g=h(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=a(t,m,u.onItemTextChange,g),v=p?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return f(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.span,{id:u.textId,...s,ref:_}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?M.createPortal(s.children,c.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)(o.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,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(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:s,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,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(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:s,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),s=N.useRef(null),c=U(n),l=N.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return N.useEffect(()=>()=>l(),[l]),f(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,I.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:x(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:x(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:x(i.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},n){let r=q(ze,e),{value:i,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=r,{nativeOptions:m,nativeSelectKey:h}=r,g=N.useRef(null),_=a(n,g),v=i??``,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)(o.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:u,form:p,onChange:e=>s(e.target.value),...t,style:{...c,...t.style},ref:_,defaultValue:v,children:[$(i)&&!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=h(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:i(`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)(E,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:i(`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,...a,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:i(`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:i(`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)(O,{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:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(T,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(E,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t}from"./B1pia_Rg.js";import{b as n,l as r,o as i,p as a,s as o,u as s}from"./pjlgs2cl.js";import{r as c,t as l}from"./bgQ-QVd7.js";import{S as u,_ as d,b as f,d as p,f as m,g as h,h as g,m as _,p as v,u as y,v as b,x,y as S}from"./CF6jyexg.js";import{n as C,t as w}from"./CEtGUZGE.js";import{t as T}from"./CZoj-eMm.js";import{Lt as E,Qt as D,Rt as O,Xt as k,Yt as A,Zt as j}from"./BZ6aghND.js";var M=e(n(),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=r(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=u(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:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,_=K(t),[v,y]=N.useState(null),[b,x]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,O]=S({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[k,A]=S({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(k);N.useEffect(()=>{let e=h?v?.ownerDocument.getElementById(h):v?.form;if(e instanceof HTMLFormElement){let t=R(()=>A(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,v,A]);let ee=!v||!!h||!!v.closest(`form`),[F,L]=N.useState(new Set),z=d(),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:w,onValueNodeHasChildrenChange:T,contentId:z,value:k,onValueChange:A,open:D,onOpenChange:O,dir:E,triggerPointerDownPosRef:M,disabled:p,name:u,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(j,{..._,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,s=K(n),c=q(oe,n),l=c.disabled||r,u=a(t,c.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===c.value));n!==void 0&&c.onValueChange(n.value)}),g=R(e=>{l||(c.onOpenChange(!0),h()),e&&(c.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,I.jsx)(A,{asChild:!0,...s,children:(0,I.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":`none`,dir:c.dir,"data-state":c.open?`open`:`closed`,disabled:l,"data-disabled":l?``:void 0,"data-placeholder":$(c.value)?``:void 0,...i,ref:u,onClick:x(i.onClick,e=>{e.currentTarget.focus(),f.current!==`mouse`&&g(e)}),onPointerDown:x(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:x(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:s,placeholder:c=``,...l}=e,u=q(ce,n),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=a(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,I.jsx)(N.Fragment,{children:h?c:s},h?`placeholder`:`value`)})},`SelectValue`)),ue=N.forwardRef(R(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,I.jsx)(o.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)(v,{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 f(()=>{s(new DocumentFragment)},[]),(0,I.jsx)(b,{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=s(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=a(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 y(E)},[E]),m();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:c,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:v,sticky:b,hideWhenDetached:S,avoidCollisions:C}:{};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)(p,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:x(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,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:x(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,s=q(Y,n),c=Z(Y,n),[l,u]=N.useState(null),[d,p]=N.useState(null),m=a(t,p),h=U(n),g=N.useRef(!1),_=N.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=N.useCallback(()=>{if(s.trigger&&s.valueNode&&l&&d&&v&&y&&b){let e=s.trigger.getBoundingClientRect(),t=d.getBoundingClientRect(),n=s.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(s.dir!==`rtl`){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-X,d=w(a,[X,Math.max(X,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let a=h(),o=window.innerHeight-X*2,c=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+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),T=parseInt(C.paddingTop,10),E=parseInt(C.paddingBottom,10),D=e.top+e.height/2-X,O=o-D,k=y.offsetHeight/2,A=y.offsetTop+k,j=f+p+A,M=x-j;if(j<=D){let e=a.length>0&&y===a[a.length-1].ref.current;l.style.bottom=`0px`;let t=d.clientHeight-v.offsetTop-v.offsetHeight,n=j+Math.max(O,k+(e?E:0)+t+m);l.style.height=n+`px`}else{let e=a.length>0&&y===a[0].ref.current;l.style.top=`0px`;let t=Math.max(D,f+v.offsetTop+(e?T:0)+k)+M;l.style.height=t+`px`,v.scrollTop=j-D+v.offsetTop}l.style.margin=`${X}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=o+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,r]);f(()=>S(),[S]);let[C,T]=N.useState();f(()=>{d&&T(window.getComputedStyle(d).zIndex)},[d]);let E=N.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,I.jsx)(xe,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:E,children:(0,I.jsx)(`div`,{ref:u,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,I.jsx)(o.div,{...i,ref:m,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,s=Z(Ce,n),c=Se(Ce,n),l=a(t,s.onViewportChange),u=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)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:x(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=c;if(r?.current&&n){let e=Math.abs(u.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`)}}}u.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:s,...c}=e,l=q(De,n),u=Z(De,n),f=l.value===r,[p,m]=N.useState(s??``),[g,_]=N.useState(!1),v=h(e=>u.itemRefCallback?.(e,r,i)),y=a(t,v),b=d(),S=N.useRef(`touch`),C=R(()=>{i||(l.onValueChange(r),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:n,value:r,disabled:i,textId:b,isSelected:f,onItemTextChange:N.useCallback(e=>{m(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:n,value:r,disabled:i,textValue:p,children:(0,I.jsx)(o.div,{role:`option`,"aria-labelledby":b,"data-highlighted":g?``:void 0,"aria-selected":f&&g,"data-state":f?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...c,ref:y,onFocus:x(c.onFocus,()=>_(!0)),onBlur:x(c.onBlur,()=>_(!1)),onClick:x(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:x(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:x(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:x(c.onPointerMove,e=>{S.current=e.pointerType,i?u.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:x(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&u.onItemLeave?.()}),onKeyDown:x(c.onKeyDown,e=>{i||e.target!==e.currentTarget||(u.searchRef?.current===``||e.key!==` `)&&(B.includes(e.key)&&C(),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),Q=`SelectItemText`,je=N.forwardRef(R(function(e,t){let{__scopeSelect:n,className:r,style:i,...s}=e,c=q(Q,n),l=Z(Q,n),u=ke(Q,n),d=ie(Q,n),[p,m]=N.useState(null),g=h(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=a(t,m,u.onItemTextChange,g),v=p?.textContent,y=N.useMemo(()=>(0,I.jsx)(`option`,{value:u.value,disabled:u.disabled,children:v},u.value),[u.disabled,u.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=d;return f(()=>(b(y),()=>x(y)),[b,x,y]),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o.span,{id:u.textId,...s,ref:_}),u.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?M.createPortal(s.children,c.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)(o.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,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;o(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:s,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,o]=N.useState(!1),s=a(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;o(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:s,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),s=N.useRef(null),c=U(n),l=N.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return N.useEffect(()=>()=>l(),[l]),f(()=>{c().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[c]),(0,I.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:x(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:x(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:x(i.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},n){let r=q(ze,e),{value:i,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=r,{nativeOptions:m,nativeSelectKey:h}=r,g=N.useRef(null),_=a(n,g),v=i??``,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)(o.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:d,autoComplete:f,disabled:u,form:p,onChange:e=>s(e.target.value),...t,style:{...c,...t.style},ref:_,defaultValue:v,children:[$(i)&&!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=h(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:i(`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)(E,{className:`size-4 opacity-50`})})]})}function Je({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...a}){return(0,I.jsx)(pe,{children:(0,I.jsxs)(me,{"data-slot":`select-content`,className:i(`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,...a,children:[(0,I.jsx)(Xe,{}),(0,I.jsx)(we,{className:i(`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:i(`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)(O,{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:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(T,{className:`size-4`})})}function Ze({className:e,...t}){return(0,I.jsx)(Le,{"data-slot":`select-scroll-down-button`,className:i(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,I.jsx)(E,{className:`size-4`})})}export{Ke as a,qe as i,Je as n,Ye as r,Ge as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{S as o,p as s}from"./DEEGN6UG.js";import{Nt as c,Rt as l}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{S as o,p as s}from"./DEEGN6UG.js";import{Nt as c,Rt as l}from"./BZ6aghND.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./BgkATqP8.js";var g=e(t(),1),_=r();function v({text:e,label:t}){let[n,r]=(0,g.useState)(!1),i=(0,g.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1600)})},[e]);return(0,_.jsxs)(`div`,{className:`grid gap-1`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-medium`,children:t}),(0,_.jsx)(a,{variant:`ghost`,size:`sm`,className:`h-6 gap-1 px-2 text-xs`,onClick:i,children:n?(0,_.jsx)(l,{className:`size-3`}):(0,_.jsx)(c,{className:`size-3`})})]}),(0,_.jsx)(`pre`,{"data-selectable":!0,className:`max-h-32 overflow-auto whitespace-pre-wrap break-all rounded-md border bg-muted/40 p-2 text-[11px] leading-snug`,children:e})]})}function y(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{t:r}=i(),[c,l]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),[x,S]=(0,g.useState)(!1),C=e===`mcp-setup`;(0,g.useEffect)(()=>{C&&s().then(e=>{l(e),S(!1)}).catch(e=>b(e instanceof Error?e.message:String(e)))},[C]);let w=(0,g.useCallback)(()=>{o().then(()=>{l(null),S(!0)})},[]),T=c?`claude mcp add --transport http planche ${c.url} \\\n -H "Authorization: Bearer ${c.token}"`:``,E=c?JSON.stringify({mcpServers:{planche:{type:`http`,url:c.url,headers:{Authorization:`Bearer ${c.token}`}}}},null,2):``;return(0,_.jsx)(h,{open:C,onOpenChange:e=>{e||t()},children:(0,_.jsxs)(f,{className:`sm:max-w-[620px]`,children:[(0,_.jsxs)(u,{children:[(0,_.jsx)(p,{children:r(`mcp.title`)}),(0,_.jsx)(m,{children:r(`mcp.description`)})]}),(0,_.jsxs)(`div`,{className:`grid gap-3`,children:[(0,_.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:[[`readsLabel`,`reads`],[`writesLabel`,`writes`],[`needsLabel`,`needs`],[`tokenLabel`,`token`]].map(([e,t])=>(0,_.jsxs)(g.Fragment,{children:[(0,_.jsx)(`dt`,{className:`font-medium`,children:r(`mcp.${e}`)}),(0,_.jsx)(`dd`,{className:`text-muted-foreground`,children:r(`mcp.${t}`)})]},e))}),y&&(0,_.jsx)(`p`,{className:`rounded-md border border-destructive/40 p-2 text-xs text-destructive`,children:y}),x&&(0,_.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:r(`mcp.revoked`)}),c&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(v,{text:T,label:r(`mcp.command`)}),(0,_.jsx)(v,{text:E,label:r(`mcp.json`)}),(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mcp.stored`,{path:c.path})})]})]}),(0,_.jsxs)(d,{children:[c&&(0,_.jsx)(a,{variant:`ghost`,size:`sm`,onClick:w,children:r(`mcp.revoke`)}),(0,_.jsx)(a,{size:`sm`,onClick:t,children:r(`settings.done`)})]})]})})}export{y as McpSetupDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{a as o,i as s,n as c,r as l,t as u}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{a as o,i as s,n as c,r as l,t as u}from"./BuhEpB12.js";import{i as d,n as f}from"./D6kbK-ng.js";import{b as p,c as m,d as h}from"./DEEGN6UG.js";import{c as g,l as _,w as v}from"./BZ6aghND.js";import{a as y,i as b,n as x,o as S,r as C,t as w}from"./BgkATqP8.js";var T=e(t(),1),E=r(),D={autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,"data-bwignore":!0};function O(){let{t:e}=i(),[t,n]=(0,T.useState)(null),[r,y]=(0,T.useState)(!1),[b,x]=(0,T.useState)(`anthropic`),[S,C]=(0,T.useState)(``),[w,O]=(0,T.useState)(``),[k,A]=(0,T.useState)(``),[j,M]=(0,T.useState)(!1),[N,P]=(0,T.useState)([]),[F,I]=(0,T.useState)(!1),[L,R]=(0,T.useState)(!1),[z,B]=(0,T.useState)(null),V=f(e=>e.setAiPreferences),H=(0,T.useCallback)(()=>{h().then(e=>{n(e);let t=f.getState().aiPreferences,r=e.storage!==`none`;x(r?e.provider:t.provider),C(r?e.model:t.model),O((r?e.baseUrl:t.baseUrl)??``),M(r?e.storage===`file`:t.remember),P(e.clis??[]),I(e.anthropicProfile===!0)}).catch(()=>y(!0))},[]);(0,T.useEffect)(H,[H]);let U=(0,T.useCallback)(e=>{x(e),C(t=>d(t,e))},[]),W=(0,T.useCallback)(()=>{R(!0),B(null),p({provider:b,model:S.trim()||void 0,baseUrl:w.trim()||void 0,key:k,remember:j}).then(t=>{n(t),A(``),V({provider:b,model:S.trim()||t.model,baseUrl:w.trim(),remember:j}),B(e(`settings.ai.saved`)),v()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[b,S,w,k,j,V,e]),G=(0,T.useCallback)(()=>{R(!0),B(null),m().then(e=>{n(e),A(``),v()}).catch(e=>B(e instanceof Error?e.message:String(e))).finally(()=>R(!1))},[]);if(r)return(0,E.jsx)(`p`,{className:`rounded-md border p-3 text-xs text-muted-foreground`,children:e(`settings.ai.unreachable`)});if(!t)return null;let K=t.fromEnvironment,q=b===`cli`||b===`anthropic-profile`;return(0,E.jsxs)(`div`,{className:`grid gap-3 rounded-md border p-3`,children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.intro`)}),(0,E.jsx)(`p`,{className:`text-xs`,children:t.storage===`environment`?e(`settings.ai.configuredEnv`):t.storage===`file`?e(t.provider===`cli`||t.provider===`anthropic-profile`?`settings.ai.configuredChoice`:`settings.ai.configuredFile`,{path:t.path,provider:t.provider===`cli`?t.model:e(`settings.ai.profile`)}):t.storage===`session`?e(`settings.ai.configuredSession`):e(`settings.ai.none`)}),!K&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-provider`,className:`text-sm font-medium`,children:e(`settings.ai.provider`)}),(0,E.jsxs)(u,{value:b,onValueChange:e=>U(e),children:[(0,E.jsx)(s,{id:`ai-provider`,children:(0,E.jsx)(o,{})}),(0,E.jsxs)(c,{children:[(0,E.jsx)(l,{value:`anthropic`,children:`Anthropic`}),(0,E.jsx)(l,{value:`anthropic-profile`,children:e(`settings.ai.profile`)}),(0,E.jsx)(l,{value:`openai`,children:e(`settings.ai.openaiCompatible`)}),(0,E.jsx)(l,{value:`gemini`,children:`Google Gemini`}),(0,E.jsx)(l,{value:`cli`,children:e(`settings.ai.cli`)})]})]})]}),b===`cli`?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.cliHint`)}),N.length===0?(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.cliNone`)}):(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-cli`,className:`text-sm font-medium`,children:e(`settings.ai.cliCommand`)}),(0,E.jsxs)(u,{value:N.includes(S)?S:N[0],onValueChange:C,children:[(0,E.jsx)(s,{id:`ai-cli`,children:(0,E.jsx)(o,{})}),(0,E.jsx)(c,{children:N.map(e=>(0,E.jsx)(l,{value:e,children:e},e))})]})]})]}):(0,E.jsxs)(`div`,{className:`grid gap-3`,children:[b===`anthropic-profile`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.profileHint`)}),!F&&(0,E.jsx)(`p`,{className:`rounded-md border p-2 text-xs text-muted-foreground`,children:e(`settings.ai.profileNone`)})]}),(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsx)(g,{htmlFor:`ai-model`,className:`text-sm font-medium`,children:e(`settings.ai.model`)}),(0,E.jsx)(_,{id:`ai-model`,value:S,onChange:e=>C(e.target.value),spellCheck:!1,...D})]})]}),b===`openai`&&(0,E.jsxs)(`div`,{className:`grid grid-cols-[1fr_220px] items-center gap-3`,children:[(0,E.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,E.jsx)(g,{htmlFor:`ai-base-url`,className:`text-sm font-medium`,children:e(`settings.ai.baseUrl`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.baseUrlHint`)})]}),(0,E.jsx)(_,{id:`ai-base-url`,value:w,onChange:e=>O(e.target.value),placeholder:`https://api.openai.com/v1`,spellCheck:!1,...D})]}),q||(0,E.jsxs)(`div`,{className:`grid gap-1`,children:[(0,E.jsx)(g,{htmlFor:`ai-key`,className:`text-sm font-medium`,children:e(`settings.ai.key`)}),(0,E.jsx)(_,{id:`ai-key`,type:`password`,value:k,onChange:e=>A(e.target.value),spellCheck:!1,placeholder:t.configured?`••••••••`:``,...D,autoComplete:`new-password`}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.keyHint`)})]}),q||(0,E.jsxs)(`label`,{htmlFor:`ai-remember`,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,E.jsx)(`input`,{id:`ai-remember`,type:`checkbox`,checked:j,onChange:e=>M(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,E.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,E.jsx)(`span`,{className:`text-sm font-medium`,children:e(`settings.ai.remember`)}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`settings.ai.rememberHint`,{path:t.path})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(a,{size:`sm`,onClick:W,disabled:L||(b===`cli`?N.length===0:!q&&!k.trim()),children:e(`settings.ai.save`)}),t.configured&&(0,E.jsx)(a,{size:`sm`,variant:`ghost`,onClick:G,disabled:L,children:e(`settings.ai.forget`)}),z&&(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z})]})]})]})}function k(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{t:r}=i();return(0,E.jsx)(w,{open:e===`ai-settings`,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(x,{className:`sm:max-w-[560px]`,children:[(0,E.jsxs)(y,{children:[(0,E.jsx)(S,{children:r(`settings.ai.title`)}),(0,E.jsx)(C,{children:r(`settings.ai.description`)})]}),(0,E.jsx)(O,{}),(0,E.jsx)(b,{children:(0,E.jsx)(a,{onClick:t,children:r(`settings.done`)})})]})})}export{k as AiSettingsDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./B1pia_Rg.js";import{l as i,m as a,t as o}from"./pjlgs2cl.js";import{a as s,i as c,n as l,r as u,t as d}from"./CiFkP-9S.js";import{t as f}from"./BCmzDvBt.js";import{a as p}from"./CS2mpWDL.js";import{n as m}from"./pneb1la9.js";import{l as h,p as g}from"./OjAiMU9J.js";import{$t as _,C as v,D as y,E as b,G as ee,O as te,S as x,T as S,Z as C,b as w,c as T,ct as ne,k as E,l as D,lt as O,st as k,v as A,x as j,y as M}from"./Bhquh17w.js";import{a as N,i as P,n as F,o as I,t as L}from"./BgkATqP8.js";var R=e(t(),1);function z(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function B(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function re(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function ie(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var V=i(),H=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,U=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:t}){let{t:n}=a(),r=k().getDataTypes(),i=(0,R.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function f(){t([...e,z()])}function p(){e.length>0&&t(e.slice(0,-1))}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,V.jsx)(j,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,V.jsx)(j,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,V.jsx)(j,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,V.jsx)(j,{children:n(`table.schema.colComment`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,V.jsxs)(v,{children:[(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.field,onChange:t=>i(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,V.jsx)(w,{children:(0,V.jsxs)(d,{value:e.type,onValueChange:t=>i(e.id,`type`,t),children:[(0,V.jsx)(c,{className:G,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:r.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.length,onChange:t=>i(e.id,`length`,t.target.value)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.defaultValue,onChange:t=>i(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>i(e.id,`pk`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>i(e.id,`notNull`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>i(e.id,`unsigned`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>i(e.id,`autoIncrement`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>i(e.id,`zerofill`,t.target.checked)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.comment,onChange:t=>i(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,children:n(`table.schema.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:p,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var K=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function q({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:f}=a(),[p,m]=(0,R.useState)(t.name),[h,g]=(0,R.useState)(t.type),[_,v]=(0,R.useState)(t.columns);function y(e){v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){r({id:t.id,name:h===`PRIMARY`?`PRIMARY`:p,type:h,columns:_})}return(0,V.jsx)(L,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(F,{className:`sm:max-w-[500px]`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:t.name?f(`table.index.editTitle`):f(`table.index.addTitle`)})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-name`,children:f(`table.index.name`)}),(0,V.jsx)(D,{id:`idx-name`,value:h===`PRIMARY`?`PRIMARY`:p,onChange:e=>m(e.target.value),disabled:h===`PRIMARY`,placeholder:f(`table.index.namePlaceholder`)})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-type`,children:f(`table.index.type`)}),(0,V.jsxs)(d,{value:h,onValueChange:e=>g(e),children:[(0,V.jsx)(c,{id:`idx-type`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:K.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{children:f(`table.index.columns`)}),(0,V.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`table.index.noColumns`)}):n.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.field),onChange:()=>y(e.field)}),(0,V.jsx)(`span`,{children:e.field||f(`table.index.unnamed`)}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:f(`table.index.cancel`)}),(0,V.jsx)(o,{onClick:b,disabled:_.length===0,children:f(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:t,onChange:n}){let{t:r}=a(),[i,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(!1);function u(){let e=B();s(e),l(!0)}function d(e){s({...e}),l(!0)}function f(){e.length>0&&n(e.slice(0,-1))}function p(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),l(!1),s(null)}function m(){l(!1),s(null)}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H+` [&_td]:px-2`,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,V.jsx)(j,{children:r(`table.indexes.colColumns`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,V.jsxs)(v,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,V.jsx)(w,{children:e.name}),(0,V.jsx)(w,{children:e.type}),(0,V.jsx)(w,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),i&&(0,V.jsx)(q,{open:c,index:i,availableColumns:t,onSave:p,onClose:m})]})}var J=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Y=[`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 se({properties:e,onChange:t}){let{t:n}=a();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=X[r]?.[0]??``),t(i)}let i=X[e.charset]??[];return(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,V.jsxs)(d,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,V.jsx)(c,{id:`prop-engine`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:J.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,V.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,V.jsx)(c,{id:`prop-charset`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:Y.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,V.jsxs)(d,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,V.jsx)(c,{id:`prop-collation`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:i.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,V.jsx)(D,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,V.jsx)(D,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:a}){let o=C(e=>e.themeId),s=ne(e),c=S(o),l=(0,R.useMemo)(()=>s.ddl.createTable(ie(t,n,r,i,a)),[s,t,n,r,i,a]);return(0,V.jsx)(`div`,{className:`h-[320px]`,children:(0,V.jsx)(_,{height:`100%`,language:`sql`,theme:c,value:l,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function Z(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Q(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function $(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function le(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function ue({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?le(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Q(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),Z(i)!==Z(r)){let e=a.alterColumn(t,n,Q(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,$(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,$(r)));return{statements:o,destructive:s,unsupported:c}}function de(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),s=r(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,u=t===`duplicate-table-structure`,d=s?.nodeText??``,_=s?.metadata?.database??``,[v,x]=(0,R.useState)(``),[S,C]=(0,R.useState)([z()]),[w,O]=(0,R.useState)([]),[k,A]=(0,R.useState)(re()),[j,M]=(0,R.useState)(!1),[B,H]=(0,R.useState)(!1),[U,W]=(0,R.useState)(null),[G,K]=(0,R.useState)(null),q=s?.connectionId??f.getState().activeConnectionId,J=ne(q);(0,R.useEffect)(()=>{c&&(W(null),K(null),l||u?(x(u?`${d}_copy`:d),Y()):(x(``),C([z()]),O([]),A(re())))},[c,t]);async function Y(){let e=f.getState(),t=s?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!_||!d)return;M(!0);let{introspect:r,capabilities:i}=m(t),a=p(n);try{let e=await r.listColumns(a,_,d),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});C(n),t=n}let n=await r.listIndexes(a,_,d),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),O(o)),K({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,_,d);e&&A({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{M(!1)}}function X(e){e||i()}async function Z(){let t=s?.connectionId??f.getState().activeConnectionId;if(!t||!v.trim())return;let n=m(t);W(null);let r,a=[];if(l){if(!G)return;let t=ue({engine:n,database:_,table:d,before:G,after:{columns:S,indexes:w}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./B1pia_Rg.js";import{l as i,m as a,t as o}from"./pjlgs2cl.js";import{a as s,i as c,n as l,r as u,t as d}from"./BuhEpB12.js";import{t as f}from"./BCmzDvBt.js";import{a as p}from"./CS2mpWDL.js";import{n as m}from"./pneb1la9.js";import{l as h,p as g}from"./mA5FXiEh.js";import{$t as _,C as v,D as y,E as b,G as ee,O as te,S as x,T as S,Z as C,b as w,c as T,ct as ne,k as E,l as D,lt as O,st as k,v as A,x as j,y as M}from"./BZ6aghND.js";import{a as N,i as P,n as F,o as I,t as L}from"./BgkATqP8.js";var R=e(t(),1);function z(){return{id:crypto.randomUUID(),field:``,type:`varchar`,length:``,defaultValue:``,pk:!1,notNull:!1,unsigned:!1,autoIncrement:!1,zerofill:!1,comment:``}}function B(){return{id:crypto.randomUUID(),name:``,type:`INDEX`,columns:[]}}function re(){return{engine:`InnoDB`,charset:`utf8mb4`,collation:`utf8mb4_general_ci`,autoIncrement:``,comment:``}}function ie(e,t,n,r,i){return{database:e,name:t,columns:n.map(e=>({name:e.field,type:e.type,length:e.length,defaultValue:e.defaultValue,primaryKey:e.pk,notNull:e.notNull,unsigned:e.unsigned,autoIncrement:e.autoIncrement,zerofill:e.zerofill,comment:e.comment})),indexes:r.map(e=>({name:e.name,type:e.type,columns:[...e.columns]})),options:{...i}}}var V=i(),H=`w-auto min-w-full [&_td]:bg-muted [&_td]:border-r [&_td]:border-border/60 [&_td:last-child]:border-r-0 [&_td]:p-0 [&_td]:h-8 [&_tr:nth-child(even)_td]:bg-muted/60 [&_tr:focus-within_td]:bg-primary/5`,U=`sticky top-0 z-10 bg-catppuccin-crust shadow-[inset_0_-1px_0_var(--border)] [&_th]:h-8 [&_th]:bg-catppuccin-crust [&_th]:font-semibold [&_th]:text-foreground [&_th]:uppercase [&_th]:tracking-wide [&_th]:text-[11px]`,W=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none ring-0 focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary dark:bg-transparent`,G=`h-8 w-full min-w-0 rounded-none border-0 bg-transparent px-2 text-xs shadow-none focus-visible:bg-primary/10 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-primary data-[state=open]:bg-primary/10 dark:bg-transparent dark:hover:bg-transparent`;function ae({columns:e,onChange:t}){let{t:n}=a(),r=k().getDataTypes(),i=(0,R.useCallback)((n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},[e,t]);function f(){t([...e,z()])}function p(){e.length>0&&t(e.slice(0,-1))}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colField`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:n(`table.schema.colType`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colLength`)}),(0,V.jsx)(j,{className:`w-[100px]`,children:n(`table.schema.colDefault`)}),(0,V.jsx)(j,{className:`w-[40px]`,children:n(`table.schema.colPk`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colNotNull`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colUnsigned`)}),(0,V.jsx)(j,{className:`w-[70px]`,children:n(`table.schema.colAutoIncrement`)}),(0,V.jsx)(j,{className:`w-[60px]`,children:n(`table.schema.colZerofill`)}),(0,V.jsx)(j,{children:n(`table.schema.colComment`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:10,className:`text-center text-muted-foreground`,children:n(`table.schema.empty`)})}):e.map(e=>(0,V.jsxs)(v,{children:[(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.field,onChange:t=>i(e.id,`field`,t.target.value),placeholder:`column_name`})}),(0,V.jsx)(w,{children:(0,V.jsxs)(d,{value:e.type,onValueChange:t=>i(e.id,`type`,t),children:[(0,V.jsx)(c,{className:G,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:r.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.length,onChange:t=>i(e.id,`length`,t.target.value)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.defaultValue,onChange:t=>i(e.id,`defaultValue`,t.target.value),placeholder:`NULL`})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.pk,onChange:t=>i(e.id,`pk`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.notNull,onChange:t=>i(e.id,`notNull`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.unsigned,onChange:t=>i(e.id,`unsigned`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.autoIncrement,onChange:t=>i(e.id,`autoIncrement`,t.target.checked)})}),(0,V.jsx)(w,{className:`text-center`,children:(0,V.jsx)(`input`,{type:`checkbox`,checked:e.zerofill,onChange:t=>i(e.id,`zerofill`,t.target.checked)})}),(0,V.jsx)(w,{children:(0,V.jsx)(D,{className:W,value:e.comment,onChange:t=>i(e.id,`comment`,t.target.value)})})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,children:n(`table.schema.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:p,disabled:e.length===0,children:n(`table.schema.remove`)})]})]})}var K=[`PRIMARY`,`UNIQUE`,`INDEX`,`FULLTEXT`];function q({open:e,index:t,availableColumns:n,onSave:r,onClose:i}){let{t:f}=a(),[p,m]=(0,R.useState)(t.name),[h,g]=(0,R.useState)(t.type),[_,v]=(0,R.useState)(t.columns);function y(e){v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}function b(){r({id:t.id,name:h===`PRIMARY`?`PRIMARY`:p,type:h,columns:_})}return(0,V.jsx)(L,{open:e,onOpenChange:e=>{e||i()},children:(0,V.jsxs)(F,{className:`sm:max-w-[500px]`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:t.name?f(`table.index.editTitle`):f(`table.index.addTitle`)})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-name`,children:f(`table.index.name`)}),(0,V.jsx)(D,{id:`idx-name`,value:h===`PRIMARY`?`PRIMARY`:p,onChange:e=>m(e.target.value),disabled:h===`PRIMARY`,placeholder:f(`table.index.namePlaceholder`)})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`idx-type`,children:f(`table.index.type`)}),(0,V.jsxs)(d,{value:h,onValueChange:e=>g(e),children:[(0,V.jsx)(c,{id:`idx-type`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:K.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{children:f(`table.index.columns`)}),(0,V.jsx)(`div`,{className:`border rounded-md p-2 max-h-[200px] overflow-y-auto space-y-1`,children:n.length===0?(0,V.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`table.index.noColumns`)}):n.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer hover:bg-muted/50 rounded px-1 py-0.5`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.field),onChange:()=>y(e.field)}),(0,V.jsx)(`span`,{children:e.field||f(`table.index.unnamed`)}),(0,V.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.type,`)`]})]},e.id))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:i,children:f(`table.index.cancel`)}),(0,V.jsx)(o,{onClick:b,disabled:_.length===0,children:f(`table.index.ok`)})]})]})})}function oe({indexes:e,availableColumns:t,onChange:n}){let{t:r}=a(),[i,s]=(0,R.useState)(null),[c,l]=(0,R.useState)(!1);function u(){let e=B();s(e),l(!0)}function d(e){s({...e}),l(!0)}function f(){e.length>0&&n(e.slice(0,-1))}function p(t){e.find(e=>e.id===t.id)?n(e.map(e=>e.id===t.id?t:e)):n([...e,t]),l(!1),s(null)}function m(){l(!1),s(null)}return(0,V.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,V.jsx)(O,{className:`flex-1`,children:(0,V.jsxs)(A,{className:H+` [&_td]:px-2`,children:[(0,V.jsx)(x,{className:U,children:(0,V.jsxs)(v,{children:[(0,V.jsx)(j,{className:`w-[150px]`,children:r(`table.indexes.colName`)}),(0,V.jsx)(j,{className:`w-[120px]`,children:r(`table.indexes.colType`)}),(0,V.jsx)(j,{children:r(`table.indexes.colColumns`)})]})}),(0,V.jsx)(M,{children:e.length===0?(0,V.jsx)(v,{children:(0,V.jsx)(w,{colSpan:3,className:`text-center text-muted-foreground`,children:r(`table.indexes.empty`)})}):e.map(e=>(0,V.jsxs)(v,{className:`cursor-pointer`,onDoubleClick:()=>d(e),children:[(0,V.jsx)(w,{children:e.name}),(0,V.jsx)(w,{children:e.type}),(0,V.jsx)(w,{children:e.columns.join(`, `)})]},e.id))})]})}),(0,V.jsxs)(`div`,{className:`flex gap-2 p-2 border-t`,children:[(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:u,children:r(`table.indexes.add`)}),(0,V.jsx)(o,{size:`sm`,variant:`outline`,onClick:f,disabled:e.length===0,children:r(`table.indexes.remove`)})]}),i&&(0,V.jsx)(q,{open:c,index:i,availableColumns:t,onSave:p,onClose:m})]})}var J=[`InnoDB`,`MyISAM`,`MEMORY`,`CSV`,`ARCHIVE`,`BLACKHOLE`,`MRG_MYISAM`,`FEDERATED`,`PERFORMANCE_SCHEMA`],Y=[`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 se({properties:e,onChange:t}){let{t:n}=a();function r(n,r){let i={...e,[n]:r};n===`charset`&&(i.collation=X[r]?.[0]??``),t(i)}let i=X[e.charset]??[];return(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-engine`,children:n(`table.properties.engine`)}),(0,V.jsxs)(d,{value:e.engine,onValueChange:e=>r(`engine`,e),children:[(0,V.jsx)(c,{id:`prop-engine`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:J.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-charset`,children:n(`table.properties.charset`)}),(0,V.jsxs)(d,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,V.jsx)(c,{id:`prop-charset`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:Y.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-collation`,children:n(`table.properties.collation`)}),(0,V.jsxs)(d,{value:e.collation,onValueChange:e=>r(`collation`,e),children:[(0,V.jsx)(c,{id:`prop-collation`,className:`w-full`,children:(0,V.jsx)(s,{})}),(0,V.jsx)(l,{children:i.map(e=>(0,V.jsx)(u,{value:e,children:e},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-auto-incr`,children:n(`table.properties.autoIncrement`)}),(0,V.jsx)(D,{id:`prop-auto-incr`,type:`number`,value:e.autoIncrement,onChange:e=>r(`autoIncrement`,e.target.value),placeholder:n(`table.properties.autoIncrementPlaceholder`)})]})]}),(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(T,{htmlFor:`prop-comment`,children:n(`table.properties.comment`)}),(0,V.jsx)(D,{id:`prop-comment`,value:e.comment,onChange:e=>r(`comment`,e.target.value)})]})]})}function ce({connectionId:e,database:t,tableName:n,columns:r,indexes:i,properties:a}){let o=C(e=>e.themeId),s=ne(e),c=S(o),l=(0,R.useMemo)(()=>s.ddl.createTable(ie(t,n,r,i,a)),[s,t,n,r,i,a]);return(0,V.jsx)(`div`,{className:`h-[320px]`,children:(0,V.jsx)(_,{height:`100%`,language:`sql`,theme:c,value:l,options:{readOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:13,lineNumbers:`on`,wordWrap:`on`}})})}function Z(e){return JSON.stringify([e.type,e.length,e.defaultValue,e.pk,e.notNull,e.unsigned,e.autoIncrement,e.zerofill,e.comment])}function Q(e){return{name:e.field,type:e.length?`${e.type}(${e.length})`:e.type,nullable:!e.notNull,key:e.pk?`PRI`:``,defaultValue:e.defaultValue===``?null:e.defaultValue,extra:e.autoIncrement?`auto_increment`:``,comment:e.comment,collation:null}}function $(e){return{name:e.name,type:e.type,columns:[...e.columns]}}function le(e,t){return e.name===t.name&&e.type===t.type&&e.columns.join(`,`)===t.columns.join(`,`)}function ue({engine:e,database:t,table:n,before:r,after:i}){let{ddl:a}=e,o=[],s=[],c=[],l=new Map(r.columns.map(e=>[e.id,e])),u=new Map(i.columns.map(e=>[e.id,e])),d=new Map(r.indexes.map(e=>[e.id,e])),f=new Map(i.indexes.map(e=>[e.id,e])),p=[];for(let[e,r]of d){let i=f.get(e);i?le(r,i)||(o.push(a.dropIndex(t,n,r.name)),p.push(i)):o.push(a.dropIndex(t,n,r.name))}for(let[e,r]of u){let i=l.get(e);if(!i){r.field.trim()&&o.push(a.addColumn(t,n,Q(r)));continue}if(i.field!==r.field&&o.push(a.renameColumn(t,n,i.field,r.field)),Z(i)!==Z(r)){let e=a.alterColumn(t,n,Q(r));e?o.push(e):c.push(r.field)}}for(let[e,r]of l)if(!u.has(e)){let e=a.dropColumn(t,n,r.field);o.push(e),s.push(e)}for(let e of p)o.push(a.createIndex(t,n,$(e)));for(let[e,r]of f)!d.has(e)&&r.columns.length>0&&o.push(a.createIndex(t,n,$(r)));return{statements:o,destructive:s,unsupported:c}}function de(){let{t:e}=a(),{activeDialog:t,closeDialog:i}=n(),s=r(`create-table`,`alter-table`,`duplicate-table-structure`),c=t===`create-table`||t===`alter-table`||t===`duplicate-table-structure`,l=t===`alter-table`,u=t===`duplicate-table-structure`,d=s?.nodeText??``,_=s?.metadata?.database??``,[v,x]=(0,R.useState)(``),[S,C]=(0,R.useState)([z()]),[w,O]=(0,R.useState)([]),[k,A]=(0,R.useState)(re()),[j,M]=(0,R.useState)(!1),[B,H]=(0,R.useState)(!1),[U,W]=(0,R.useState)(null),[G,K]=(0,R.useState)(null),q=s?.connectionId??f.getState().activeConnectionId,J=ne(q);(0,R.useEffect)(()=>{c&&(W(null),K(null),l||u?(x(u?`${d}_copy`:d),Y()):(x(``),C([z()]),O([]),A(re())))},[c,t]);async function Y(){let e=f.getState(),t=s?.connectionId??e.activeConnectionId,n=e.activeConnections.find(e=>e.id===t)?.serverConnectionId;if(!n||!_||!d)return;M(!0);let{introspect:r,capabilities:i}=m(t),a=p(n);try{let e=await r.listColumns(a,_,d),t=[];if(e.length>0){let n=e.map(e=>{let t=e.type,n=t.match(/^(\w+)(?:\(([^)]+)\))?/);return{id:crypto.randomUUID(),field:e.name,type:n?.[1]?.toLowerCase()??t.toLowerCase(),length:n?.[2]??``,defaultValue:e.defaultValue??``,pk:e.key===`PRI`,notNull:!e.nullable,unsigned:t.includes(`unsigned`),autoIncrement:e.extra.includes(`auto_increment`),zerofill:t.includes(`zerofill`),comment:e.comment}});C(n),t=n}let n=await r.listIndexes(a,_,d),o=[];if(n.length>0&&(o=n.map(e=>({id:crypto.randomUUID(),name:e.name,type:e.type===`SPATIAL`?`INDEX`:e.type,columns:[...e.columns]})),O(o)),K({columns:t,indexes:o}),i.tableProperties){let e=await r.getTableInfo(a,_,d);e&&A({engine:e.engine??`InnoDB`,charset:(e.collation??`utf8mb4`).replace(/_.*/,``),collation:e.collation??`utf8mb4_unicode_ci`,autoIncrement:e.autoIncrement??``,comment:e.comment})}}catch(e){console.error(`Failed to load table schema:`,e),W(e instanceof Error?e.message:String(e))}finally{M(!1)}}function X(e){e||i()}async function Z(){let t=s?.connectionId??f.getState().activeConnectionId;if(!t||!v.trim())return;let n=m(t);W(null);let r,a=[];if(l){if(!G)return;let t=ue({engine:n,database:_,table:d,before:G,after:{columns:S,indexes:w}});if(t.unsupported.length>0){W(e(`table.dialog.cannotAlterColumns`,{engine:n.label,columns:t.unsupported.join(`, `)}));return}if(t.statements.length===0){i();return}r=t.statements.join(`
|
|
2
2
|
`),a=t.destructive}else{let e=u?w.map(e=>({...e,name:ee(e.name,d,v.trim())})):w;r=n.ddl.createTable(ie(_,v.trim(),S,e,k))}H(!0);try{await h(t,r,{skipDestructiveConfirm:a.length===0}),await g(t,_),i()}catch(e){W(e instanceof Error?e.message:String(e))}finally{H(!1)}}let Q=e(l?`table.dialog.alterTitle`:u?`table.dialog.duplicateTitle`:`table.dialog.createTitle`),$=e(l?`table.dialog.alter`:`table.dialog.create`);return(0,V.jsx)(L,{open:c,onOpenChange:X,children:(0,V.jsxs)(F,{className:`sm:max-w-[1000px] max-h-[80vh] flex flex-col`,children:[(0,V.jsx)(N,{children:(0,V.jsx)(I,{children:Q})}),(0,V.jsxs)(`div`,{className:`space-y-3 flex-1 overflow-hidden flex flex-col min-h-0`,children:[(0,V.jsxs)(`div`,{className:`space-y-1.5 px-1`,children:[(0,V.jsx)(T,{htmlFor:`table-name`,children:e(`table.dialog.tableName`)}),(0,V.jsx)(D,{id:`table-name`,value:v,onChange:e=>x(e.target.value),placeholder:e(`table.dialog.tableNamePlaceholder`),disabled:l})]}),j?(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:e(`table.dialog.loading`)}):(0,V.jsxs)(b,{defaultValue:`schema`,className:`flex-1 min-h-0 flex flex-col`,children:[(0,V.jsxs)(te,{children:[(0,V.jsx)(E,{value:`schema`,children:e(`table.dialog.tabSchema`)}),(0,V.jsx)(E,{value:`indexes`,children:e(`table.dialog.tabIndexes`)}),J.capabilities.tableProperties&&(0,V.jsx)(E,{value:`properties`,children:e(`table.dialog.tabProperties`)}),(0,V.jsx)(E,{value:`sql`,children:`SQL`})]}),(0,V.jsx)(y,{value:`schema`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(ae,{columns:S,onChange:C})}),(0,V.jsx)(y,{value:`indexes`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(oe,{indexes:w,availableColumns:S,onChange:O})}),(0,V.jsx)(y,{value:`properties`,className:`flex-1 min-h-0 overflow-auto border rounded-md`,children:(0,V.jsx)(se,{properties:k,onChange:A})}),(0,V.jsx)(y,{value:`sql`,className:`flex-1 min-h-0 border rounded-md`,children:(0,V.jsx)(ce,{connectionId:q,database:_,tableName:v,columns:S,indexes:w,properties:k})})]})]}),U&&(0,V.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:U}),(0,V.jsxs)(P,{children:[(0,V.jsx)(o,{variant:`outline`,onClick:()=>X(!1),children:e(`table.dialog.cancel`)}),(0,V.jsx)(o,{onClick:()=>void Z(),disabled:j||B||!v.trim(),children:B?e(`table.dialog.applying`):$})]})]})})}export{de as EditSchemaDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{F as o,L as s,N as c,P as l,c as u,jt as d,l as f,nt as p}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{l as r,m as i,t as a}from"./pjlgs2cl.js";import{F as o,L as s,N as c,P as l,c as u,jt as d,l as f,nt as p}from"./BZ6aghND.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./BgkATqP8.js";import{t as b}from"./CoSpkBZh.js";var x=e(t(),1);function S(){let e=s(e=>e.status.state===`valid`);return!o()||e}var C=r(),w={offline:`sync.offline`,server:`sync.serverError`,unauthorized:`sync.serverError`,conflict:`sync.serverError`,"bad-passphrase":`sync.wrongPassphrase`,malformed:`sync.wrongPassphrase`,unsupported:`sync.serverError`};function T(){let e=n(e=>e.activeDialog),t=n(e=>e.closeDialog),{phase:r,user:o,busy:s,error:T,lastSyncedAt:E,vault:D,refresh:O,createVault:k,unlock:A,push:j,signOut:M,forgetVault:N,closeAccount:P,setError:F}=c(),{t:I}=i(),L=S(),[R,z]=(0,x.useState)(``),[B,V]=(0,x.useState)(``),[H,U]=(0,x.useState)(!1),[W,G]=(0,x.useState)(!1);(0,x.useEffect)(()=>{O()},[O]);let K=R.length>0&&R.length<10,q=B.length>0&&R!==B,J=R.length>=10&&R===B,Y=T?I(w[T]??`sync.serverError`):null,X=D?Object.keys(D.profiles).length:0,Z=()=>{z(``),V(``),F(null)};return(0,C.jsx)(y,{open:e===`sync`,onOpenChange:e=>{e||t()},children:(0,C.jsxs)(g,{className:`max-h-[85vh] overflow-y-auto sm:max-w-[560px]`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,C.jsxs)(m,{children:[(0,C.jsx)(_,{children:I(`sync.title`)}),(0,C.jsxs)(v,{children:[I(`sync.description`),o&&(0,C.jsx)(`span`,{className:`mt-1 block text-xs`,children:I(`sync.signedInAs`,{email:o.email??o.id})})]})]}),(0,C.jsxs)(`div`,{className:`grid gap-3 text-sm`,children:[(0,C.jsx)(`p`,{className:`rounded-md border bg-muted/40 p-3 text-xs text-muted-foreground`,children:I(`sync.stored`)}),r===`unavailable`&&(0,C.jsx)(`p`,{className:`rounded-md border border-amber-500/40 bg-amber-500/5 p-3 text-xs text-amber-600 dark:text-amber-400`,children:p()?I(`sync.unavailable`):I(`sync.notDeployed`)}),r===`signed-out`&&(0,C.jsxs)(a,{onClick:()=>{window.location.href=l(`github`,window.location.href)},children:[(0,C.jsx)(d,{className:`size-4`}),I(`sync.signIn`)]}),o&&!L&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.needsPro`)}),(0,C.jsx)(b,{highlight:`sync`})]}),L&&r===`no-vault`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.createTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.createHint`)}),(0,C.jsx)(u,{htmlFor:`sync-pass`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-pass`,type:`password`,autoComplete:`new-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(u,{htmlFor:`sync-confirm`,children:I(`sync.confirm`)}),(0,C.jsx)(f,{id:`sync-confirm`,type:`password`,autoComplete:`new-password`,value:B,onChange:e=>{V(e.target.value),F(null)}}),K&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.tooShort`,{count:10})}),q&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:I(`sync.mismatch`)}),(0,C.jsx)(a,{disabled:!J||s,onClick:()=>{k(R).then(Z)},children:I(`sync.enable`)})]}),L&&r===`locked`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsx)(`p`,{className:`text-sm font-medium`,children:I(`sync.unlockTitle`)}),(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.unlockHint`)}),(0,C.jsx)(u,{htmlFor:`sync-unlock`,children:I(`sync.passphrase`)}),(0,C.jsx)(f,{id:`sync-unlock`,type:`password`,autoComplete:`current-password`,value:R,onChange:e=>{z(e.target.value),F(null)}}),(0,C.jsx)(a,{disabled:!R||s,onClick:()=>{A(R).then(Z)},children:I(`sync.unlock`)})]}),L&&r===`ready`&&(0,C.jsxs)(`div`,{className:`grid gap-2`,children:[(0,C.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[E?I(`sync.lastSynced`,{when:new Date(E).toLocaleString()}):I(`sync.neverSynced`),` · `,I(`sync.profiles`,{count:X})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(a,{variant:`secondary`,disabled:s,onClick:()=>{U(!1),j()},children:I(`sync.syncNow`)}),(0,C.jsx)(a,{variant:`ghost`,disabled:s,onClick:()=>{c.getState().lock(),Z()},children:I(`sync.changePassphrase`)})]}),H?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteVaultConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:s,onClick:()=>{N().then(()=>U(!1))},children:I(`sync.deleteVault`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>U(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(a,{variant:`ghost`,className:`justify-start px-0 text-destructive`,onClick:()=>U(!0),children:I(`sync.deleteVault`)})]}),o&&(W?(0,C.jsxs)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,C.jsx)(`p`,{className:`mb-2 text-xs`,children:I(`sync.deleteAccountConfirm`)}),(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsx)(a,{variant:`destructive`,disabled:s,onClick:()=>{P().then(()=>G(!1))},children:I(`sync.deleteAccount`)}),(0,C.jsx)(a,{variant:`ghost`,onClick:()=>G(!1),children:I(`settings.done`)})]})]}):(0,C.jsx)(`button`,{type:`button`,onClick:()=>G(!0),className:`w-fit rounded-sm text-xs text-muted-foreground underline underline-offset-2 hover:text-destructive focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,children:I(`sync.deleteAccount`)})),s&&(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:I(`sync.working`)}),Y&&(0,C.jsx)(`p`,{className:`text-xs text-destructive`,children:Y})]}),(0,C.jsxs)(h,{children:[o&&(0,C.jsx)(a,{variant:`ghost`,disabled:s,onClick:()=>{M().then(Z)},children:I(`sync.signOut`)}),(0,C.jsx)(a,{onClick:t,children:I(`settings.done`)})]})]})})}export{T as SyncDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{a as r,i,l as a,m as o,t as s}from"./pjlgs2cl.js";import{a as c}from"./D0jMUNSI.js";import{t as l}from"./BCmzDvBt.js";import{c as u}from"./CS2mpWDL.js";import{t as d}from"./pneb1la9.js";import{Bt as f,C as p,Ht as ee,Nt as te,Rt as ne,S as re,St as ie,Vt as ae,b as m,v as h,x as g,xt as _,y as oe}from"./Bhquh17w.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./BgkATqP8.js";var v=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),y=r(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),b=r(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),x=r(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),S=e(t(),1),C=a(),w=10,fe=[2,5,10,30];function T(){let e=l.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function pe(){let e=T();if(!e)throw Error(c.t(`command.noActiveConnection`));let t=await u(e,d().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function E(e){return/^(sleep|idle)/i.test(e.Command??``)}function me(e){return/lock/i.test(e.State??``)}function he(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function D(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function O(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function k({icon:e,label:t,value:n,tone:r}){return(0,C.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,C.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function A(){let{t:e}=o(),{activeDialog:t,closeDialog:r,setFooterMessage:a,requestDestructiveConfirm:c}=n(),[l,A]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(5),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(``),[z,ge]=(0,S.useState)(!1),[B,_e]=(0,S.useState)(!0),[V,H]=(0,S.useState)(!1),[U,ve]=(0,S.useState)(null),[W,G]=(0,S.useState)(!1),K=(0,S.useRef)(null),q=t===`process-list`,J=(0,S.useCallback)(()=>Promise.resolve().then(()=>(H(!0),pe())).then(e=>{A(e),ve(new Date)}).catch(t=>a(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[a,e]);(0,S.useEffect)(()=>{q&&J()},[q,J]),(0,S.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),j&&q&&(K.current=setInterval(()=>{J()},N*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[j,N,q,J]);function Y(e){e||(M(!1),I(null),R(``),r())}let X=(0,S.useMemo)(()=>{let e=l.filter(E).length,t=l.filter(e=>!E(e)).reduce((e,t)=>Math.max(e,D(t)),0);return{total:l.length,active:l.length-e,idle:e,longest:t}},[l]),Z=(0,S.useMemo)(()=>{let e=L.trim().toLowerCase();return l.filter(t=>z&&E(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?D(t)-D(e):D(e)-D(t))},[l,L,z,B]),Q=l.find(e=>e.Id===F)??null,ye=(0,S.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){a(e(`command.processList.selectToKill`));return}let r=T();if(!r)return;let i=l.find(e=>e.Id===n),o=d().getQuery(`KILL_QUERY`,String(n));if(await c({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[o]}))try{await u(r,o),a(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){a(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,C.jsx)(de,{open:q,onOpenChange:Y,children:(0,C.jsxs)(le,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,C.jsx)(se,{children:(0,C.jsxs)(ue,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,C.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(k,{icon:(0,C.jsx)(v,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,C.jsx)(k,{icon:(0,C.jsx)(ee,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,C.jsx)(k,{icon:(0,C.jsx)(y,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,C.jsx)(k,{icon:(0,C.jsx)(x,{}),label:e(`command.processList.stats.longest`),value:O(X.longest),tone:X.longest>=w?`warn`:void 0})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative`,children:[(0,C.jsx)(_,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,C.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,C.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,C.jsx)(i,{className:`size-3`})})]}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:j,onChange:e=>M(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,C.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:N,onChange:e=>P(Number(e.target.value)),disabled:!j,children:fe.map(e=>(0,C.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,C.jsxs)(s,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,C.jsx)(ie,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,C.jsxs)(h,{className:`text-xs`,children:[(0,C.jsx)(re,{className:`sticky top-0 z-10 bg-background`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(g,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,C.jsx)(g,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,C.jsx)(g,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,C.jsx)(ae,{className:`size-3 text-primary`}):(0,C.jsx)(f,{className:`size-3 text-primary`})]})}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,C.jsx)(g,{children:e(`command.processList.columns.info`)}),(0,C.jsx)(g,{className:`w-[50px]`})]})}),(0,C.jsx)(oe,{children:Z.length===0?(0,C.jsx)(p,{children:(0,C.jsx)(m,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:l.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let n=E(t),r=D(t),i=!n&&r>=w,a=me(t),o=he(t);return(0,C.jsxs)(p,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${n?`text-muted-foreground`:``} ${a?`bg-destructive/5`:i?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,C.jsx)(m,{className:`font-mono tabular-nums`,children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,o&&(0,C.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,C.jsx)(m,{children:t.User}),(0,C.jsx)(m,{className:`font-mono`,children:t.Host}),(0,C.jsx)(m,{className:`font-mono`,children:t.db??``}),(0,C.jsx)(m,{children:(0,C.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${n?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,C.jsx)(m,{className:`tabular-nums ${i?`font-semibold text-catppuccin-yellow`:``}`,children:O(r)}),(0,C.jsx)(m,{className:a?`font-medium text-destructive`:``,children:t.State}),(0,C.jsx)(m,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,C.jsx)(m,{className:`text-right`,children:(0,C.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,C.jsx)(b,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,C.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,C.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,C.jsx)(ne,{className:`size-3`}):(0,C.jsx)(te,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,C.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,C.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,C.jsxs)(ce,{children:[(0,C.jsx)(s,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,C.jsx)(s,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{A as ProcessListDialog};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{a as r,i,l as a,m as o,t as s}from"./pjlgs2cl.js";import{a as c}from"./D0jMUNSI.js";import{t as l}from"./BCmzDvBt.js";import{c as u}from"./CS2mpWDL.js";import{t as d}from"./pneb1la9.js";import{Bt as f,C as p,Ht as ee,Nt as te,Rt as ne,S as re,St as ie,Vt as ae,b as m,v as h,x as g,xt as _,y as oe}from"./BZ6aghND.js";import{a as se,i as ce,n as le,o as ue,t as de}from"./BgkATqP8.js";var v=r(`list-ordered`,[[`path`,{d:`M11 5h10`,key:`1cz7ny`}],[`path`,{d:`M11 12h10`,key:`1438ji`}],[`path`,{d:`M11 19h10`,key:`11t30w`}],[`path`,{d:`M4 4h1v5`,key:`10yrso`}],[`path`,{d:`M4 9h2`,key:`r1h2o0`}],[`path`,{d:`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`,key:`xtkcd5`}]]),y=r(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),b=r(`skull`,[[`path`,{d:`m12.5 17-.5-1-.5 1h1z`,key:`3me087`}],[`path`,{d:`M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z`,key:`1o5pge`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}]]),x=r(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),S=e(t(),1),C=a(),w=10,fe=[2,5,10,30];function T(){let e=l.getState();return e.activeConnections.find(t=>t.id===e.activeConnectionId)?.serverConnectionId??null}async function pe(){let e=T();if(!e)throw Error(c.t(`command.noActiveConnection`));let t=await u(e,d().getQuery(`SHOW_PROCESS_LIST`));return t.records.map(e=>{let n={};return t.fields.forEach((t,r)=>{n[t.name]=e[r]}),{...n,Id:String(n.Id)}})}function E(e){return/^(sleep|idle)/i.test(e.Command??``)}function me(e){return/lock/i.test(e.State??``)}function he(e){return/PROCESSLIST|pg_stat_activity/i.test(e.Info??``)}function D(e){let t=Number(e.Time);return Number.isFinite(t)?t:0}function O(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function k({icon:e,label:t,value:n,tone:r}){return(0,C.jsxs)(`div`,{className:`flex min-w-[120px] flex-1 items-center gap-2.5 rounded-md border bg-muted/30 px-3 py-1.5`,children:[(0,C.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md [&_svg]:size-3.5 ${r===`warn`?`bg-catppuccin-yellow/15 text-catppuccin-yellow`:`bg-primary/10 text-primary`}`,children:e}),(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:t}),(0,C.jsx)(`div`,{className:`truncate text-sm font-semibold tabular-nums`,children:n})]})]})}function A(){let{t:e}=o(),{activeDialog:t,closeDialog:r,setFooterMessage:a,requestDestructiveConfirm:c}=n(),[l,A]=(0,S.useState)([]),[j,M]=(0,S.useState)(!1),[N,P]=(0,S.useState)(5),[F,I]=(0,S.useState)(null),[L,R]=(0,S.useState)(``),[z,ge]=(0,S.useState)(!1),[B,_e]=(0,S.useState)(!0),[V,H]=(0,S.useState)(!1),[U,ve]=(0,S.useState)(null),[W,G]=(0,S.useState)(!1),K=(0,S.useRef)(null),q=t===`process-list`,J=(0,S.useCallback)(()=>Promise.resolve().then(()=>(H(!0),pe())).then(e=>{A(e),ve(new Date)}).catch(t=>a(e(`command.processList.loadError`,{message:t instanceof Error?t.message:String(t)}))).finally(()=>H(!1)),[a,e]);(0,S.useEffect)(()=>{q&&J()},[q,J]),(0,S.useEffect)(()=>(K.current&&=(clearInterval(K.current),null),j&&q&&(K.current=setInterval(()=>{J()},N*1e3)),()=>{K.current&&=(clearInterval(K.current),null)}),[j,N,q,J]);function Y(e){e||(M(!1),I(null),R(``),r())}let X=(0,S.useMemo)(()=>{let e=l.filter(E).length,t=l.filter(e=>!E(e)).reduce((e,t)=>Math.max(e,D(t)),0);return{total:l.length,active:l.length-e,idle:e,longest:t}},[l]),Z=(0,S.useMemo)(()=>{let e=L.trim().toLowerCase();return l.filter(t=>z&&E(t)?!1:!e||[t.Id,t.User,t.Host,t.db,t.Command,t.State,t.Info].some(t=>(t??``).toString().toLowerCase().includes(e))).sort((e,t)=>B?D(t)-D(e):D(e)-D(t))},[l,L,z,B]),Q=l.find(e=>e.Id===F)??null,ye=(0,S.useCallback)(()=>{Q?.Info&&navigator.clipboard.writeText(Q.Info).then(()=>{G(!0),setTimeout(()=>G(!1),1500)})},[Q]);async function $(t){let n=t??F;if(!n){a(e(`command.processList.selectToKill`));return}let r=T();if(!r)return;let i=l.find(e=>e.Id===n),o=d().getQuery(`KILL_QUERY`,String(n));if(await c({title:e(`command.processList.killConfirmTitle`,{id:n}),description:e(`command.processList.killConfirmDescription`,{user:i?.User??`?`,host:i?.Host??`?`}),confirmLabel:e(`command.processList.killProcess`),statements:[o]}))try{await u(r,o),a(e(`command.processList.killed`,{id:n})),F===n&&I(null),J()}catch(t){a(e(`command.processList.killError`,{message:t instanceof Error?t.message:String(t)}))}}return(0,C.jsx)(de,{open:q,onOpenChange:Y,children:(0,C.jsxs)(le,{className:`flex max-h-[85vh] flex-col sm:max-w-[1000px]`,children:[(0,C.jsx)(se,{children:(0,C.jsxs)(ue,{className:`flex items-center gap-2`,children:[e(`command.processList.title`),U&&(0,C.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e(`command.processList.updatedAt`,{time:U.toLocaleTimeString(void 0,{hour12:!1})})})]})}),(0,C.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,C.jsx)(k,{icon:(0,C.jsx)(v,{}),label:e(`command.processList.stats.total`),value:X.total}),(0,C.jsx)(k,{icon:(0,C.jsx)(ee,{}),label:e(`command.processList.stats.active`),value:X.active}),(0,C.jsx)(k,{icon:(0,C.jsx)(y,{}),label:e(`command.processList.stats.idle`),value:X.idle}),(0,C.jsx)(k,{icon:(0,C.jsx)(x,{}),label:e(`command.processList.stats.longest`),value:O(X.longest),tone:X.longest>=w?`warn`:void 0})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative`,children:[(0,C.jsx)(_,{className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,C.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background pl-7 pr-6 text-xs placeholder:text-muted-foreground`,placeholder:e(`command.processList.filterPlaceholder`),value:L,onChange:e=>R(e.target.value)}),L&&(0,C.jsx)(`button`,{type:`button`,className:`absolute right-1.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>R(``),children:(0,C.jsx)(i,{className:`size-3`})})]}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:z,onChange:e=>ge(e.target.checked)}),e(`command.processList.hideIdle`)]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs`,children:[(0,C.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:j,onChange:e=>M(e.target.checked)}),e(`command.processList.autoRefresh`)]}),(0,C.jsx)(`select`,{className:`h-7 rounded border bg-background px-1.5 text-xs disabled:opacity-50`,value:N,onChange:e=>P(Number(e.target.value)),disabled:!j,children:fe.map(e=>(0,C.jsxs)(`option`,{value:e,children:[e,`s`]},e))}),(0,C.jsxs)(s,{variant:`outline`,size:`sm`,className:`h-7`,onClick:()=>{J()},disabled:V,children:[(0,C.jsx)(ie,{className:`mr-1 size-3.5 ${V?`animate-spin`:``}`}),e(`command.processList.refresh`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded-md border`,children:(0,C.jsxs)(h,{className:`text-xs`,children:[(0,C.jsx)(re,{className:`sticky top-0 z-10 bg-background`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(g,{className:`w-[70px]`,children:e(`command.processList.columns.id`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.user`)}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.host`)}),(0,C.jsx)(g,{className:`w-[100px]`,children:e(`command.processList.columns.db`)}),(0,C.jsx)(g,{className:`w-[90px]`,children:e(`command.processList.columns.command`)}),(0,C.jsx)(g,{className:`w-[80px] cursor-pointer select-none`,onClick:()=>_e(e=>!e),children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e(`command.processList.columns.time`),B?(0,C.jsx)(ae,{className:`size-3 text-primary`}):(0,C.jsx)(f,{className:`size-3 text-primary`})]})}),(0,C.jsx)(g,{className:`w-[130px]`,children:e(`command.processList.columns.state`)}),(0,C.jsx)(g,{children:e(`command.processList.columns.info`)}),(0,C.jsx)(g,{className:`w-[50px]`})]})}),(0,C.jsx)(oe,{children:Z.length===0?(0,C.jsx)(p,{children:(0,C.jsx)(m,{colSpan:9,className:`py-8 text-center text-muted-foreground`,children:l.length===0?e(`command.processList.empty`):e(`command.processList.noMatch`)})}):Z.map(t=>{let n=E(t),r=D(t),i=!n&&r>=w,a=me(t),o=he(t);return(0,C.jsxs)(p,{"data-state":F===t.Id?`selected`:void 0,className:`cursor-pointer ${n?`text-muted-foreground`:``} ${a?`bg-destructive/5`:i?`bg-catppuccin-yellow/5`:``}`,onClick:()=>I(t.Id),children:[(0,C.jsx)(m,{className:`font-mono tabular-nums`,children:(0,C.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.Id,o&&(0,C.jsx)(`span`,{className:`rounded bg-primary/10 px-1 text-[9px] font-semibold text-primary`,title:e(`command.processList.selfHint`),children:e(`command.processList.self`)})]})}),(0,C.jsx)(m,{children:t.User}),(0,C.jsx)(m,{className:`font-mono`,children:t.Host}),(0,C.jsx)(m,{className:`font-mono`,children:t.db??``}),(0,C.jsx)(m,{children:(0,C.jsx)(`span`,{className:`rounded px-1.5 py-px text-[10px] font-medium ${n?`bg-muted`:`bg-green-500/10 text-green-600 dark:text-green-400`}`,children:t.Command})}),(0,C.jsx)(m,{className:`tabular-nums ${i?`font-semibold text-catppuccin-yellow`:``}`,children:O(r)}),(0,C.jsx)(m,{className:a?`font-medium text-destructive`:``,children:t.State}),(0,C.jsx)(m,{className:`max-w-[260px] truncate font-mono`,title:t.Info??``,children:t.Info??``}),(0,C.jsx)(m,{className:`text-right`,children:(0,C.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,title:e(`command.processList.kill`),onClick:e=>{e.stopPropagation(),$(t.Id)},children:(0,C.jsx)(b,{className:`size-3.5`})})})]},t.Id)})})]})}),Q&&(0,C.jsxs)(`div`,{className:`shrink-0 rounded-md border`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b bg-muted/30 px-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`command.processList.statementOf`,{id:Q.Id})}),(0,C.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[Q.User,`@`,Q.Host,Q.db?` · ${Q.db}`:``]}),(0,C.jsx)(`div`,{className:`flex-1`}),(0,C.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40`,onClick:ye,disabled:!Q.Info,children:[W?(0,C.jsx)(ne,{className:`size-3`}):(0,C.jsx)(te,{className:`size-3`}),e(W?`command.processList.copied`:`command.processList.copy`)]})]}),(0,C.jsx)(`pre`,{className:`max-h-32 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Q.Info||(0,C.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`command.processList.noStatement`)})})]}),(0,C.jsxs)(ce,{children:[(0,C.jsx)(s,{variant:`destructive`,onClick:()=>{$()},disabled:!F,children:e(`command.processList.killProcess`)}),(0,C.jsx)(s,{variant:`outline`,onClick:()=>Y(!1),children:e(`command.close`)})]})]})})}export{A as ProcessListDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{a as r,l as i,m as a,o,t as s}from"./pjlgs2cl.js";import{t as c}from"./BCmzDvBt.js";import{a as l}from"./CS2mpWDL.js";import{i as u}from"./DbqogdCK.js";import{n as d}from"./pneb1la9.js";import{l as f}from"./OjAiMU9J.js";import{It as p,Mt as m,_t as h,c as g,ht as _,lt as v}from"./Bhquh17w.js";import{a as y,i as b,n as x,o as S,t as C}from"./BgkATqP8.js";import{n as w,t as T}from"./C0bzfYFC.js";var E=r(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),D=r(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),O=e(t(),1),k=i();function A({databases:e,tables:t,onSelectScope:n}){let{t:r}=a(),[i,s]=(0,O.useState)(new Set),[c,l]=(0,O.useState)(`global`),u=(0,O.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),d=[{id:`global`,text:r(`user.grantTree.globalPrivileges`),type:`global`,children:e.map(e=>({id:`db:${e}`,text:e,type:`database`,database:e,children:(t[e]??[]).map(t=>({id:`tbl:${e}.${t}`,text:t,type:`table`,database:e,table:t}))}))}];function f(e){l(e.id),n({level:e.type,database:e.database,table:e.table})}function g(e,t){let n=e.children&&e.children.length>0,r=i.has(e.id),a=c===e.id,s=E;return e.type===`database`&&(s=m),e.type===`table`&&(s=h),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:o(`flex items-center gap-1 px-2 py-0.5 cursor-pointer text-sm hover:bg-accent rounded-sm`,a&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${t*16+4}px`},onClick:()=>{f(e),n&&u(e.id)},children:[n?(0,k.jsx)(p,{className:o(`h-3 w-3 transition-transform shrink-0`,r&&`rotate-90`)}):(0,k.jsx)(`span`,{className:`w-3 shrink-0`}),(0,k.jsx)(s,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,k.jsx)(`span`,{className:`truncate`,children:e.text})]}),r&&e.children?.map(e=>g(e,t+1))]},e.id)}return(0,k.jsx)(v,{className:`h-full`,children:(0,k.jsx)(`div`,{className:`py-1`,children:d.map(e=>g(e,0))})})}var j={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`SUPER`,`PROCESS`,`RELOAD`,`SHUTDOWN`,`SHOW DATABASES`,`LOCK TABLES`,`EXECUTE`,`REPLICATION SLAVE`,`REPLICATION CLIENT`,`CREATE VIEW`,`SHOW VIEW`,`CREATE ROUTINE`,`ALTER ROUTINE`,`CREATE USER`,`EVENT`,`TRIGGER`,`CREATE TABLESPACE`]},M={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`LOCK TABLES`,`EXECUTE`,`CREATE VIEW`,`SHOW VIEW`,`CREATE ROUTINE`,`ALTER ROUTINE`,`EVENT`,`TRIGGER`]},N={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`TRIGGER`]},P={global:`user.privileges.globalTitle`,database:`user.privileges.databaseTitle`,table:`user.privileges.tableTitle`},F={Data:`user.privileges.categoryData`,Structure:`user.privileges.categoryStructure`,Administration:`user.privileges.categoryAdministration`};function I({scope:e,privileges:t,onChange:n}){let{t:r}=a(),i=(0,O.useMemo)(()=>e===`global`?j:e===`database`?M:N,[e]),o=(0,O.useMemo)(()=>Object.values(i).flat(),[i]);function c(e){n({...t,[e]:!t[e]})}function l(){let e={...t};for(let t of o)e[t]=!0;n(e)}function u(){let e={...t};for(let t of o)e[t]=!1;n(e)}return(0,k.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:r(P[e])}),(0,k.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,k.jsx)(s,{variant:`outline`,size:`sm`,onClick:l,children:r(`user.privileges.checkAll`)}),(0,k.jsx)(s,{variant:`outline`,size:`sm`,onClick:u,children:r(`user.privileges.uncheckAll`)})]})]}),(0,k.jsx)(v,{className:`flex-1`,children:(0,k.jsx)(`div`,{className:`p-3 space-y-4`,children:Object.entries(i).map(([e,n])=>(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:F[e]?r(F[e]):e}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:n.map(e=>(0,k.jsxs)(g,{className:`flex items-center gap-2 text-sm font-normal cursor-pointer py-1`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t[e]??!1,onChange:()=>c(e),className:`rounded border-input`}),e]},e))})]},e))})})]})}var L={SELECT:`Select_priv`,INSERT:`Insert_priv`,UPDATE:`Update_priv`,DELETE:`Delete_priv`,CREATE:`Create_priv`,ALTER:`Alter_priv`,DROP:`Drop_priv`,INDEX:`Index_priv`,REFERENCES:`References_priv`,"GRANT OPTION":`Grant_priv`,SUPER:`Super_priv`,PROCESS:`Process_priv`,RELOAD:`Reload_priv`,SHUTDOWN:`Shutdown_priv`,"SHOW DATABASES":`Show_db_priv`,"LOCK TABLES":`Lock_tables_priv`,EXECUTE:`Execute_priv`,"REPLICATION SLAVE":`Repl_slave_priv`,"REPLICATION CLIENT":`Repl_client_priv`,"CREATE VIEW":`Create_view_priv`,"SHOW VIEW":`Show_view_priv`,"CREATE ROUTINE":`Create_routine_priv`,"ALTER ROUTINE":`Alter_routine_priv`,"CREATE USER":`Create_user_priv`,EVENT:`Event_priv`,TRIGGER:`Trigger_priv`,"CREATE TABLESPACE":`Create_tablespace_priv`,"CREATE TEMPORARY TABLES":`Create_tmp_table_priv`,FILE:`File_priv`};function R(e){let t={};for(let n of e.split(`,`)){let e=n.trim().toUpperCase();e&&(t[e]=!0)}return t}function z(e){let t={};for(let[n,r]of Object.entries(L)){let i=e[r];i!==void 0&&(t[n]=String(i).toUpperCase()===`Y`)}return t}function B(e,t){let n=t=>e.quoteIdentifier(t);return t.level===`global`?`*.*`:t.level===`database`?`${n(t.database??``)}.*`:`${n(t.database??``)}.${n(t.table??``)}`}async function V(e,t,n,r,i){if(i.level===`global`){let i=await e(t.getQuery(`USER_PRIV`,n,r)),a=u(i)[0];return a?z(a):{}}if(i.level===`database`){let a=await e(t.getQuery(`USER_DATABASE_PRIV`,n,r)),o=u(a).find(e=>String(e.Db)===i.database);return o?z(o):{}}let a=await e(t.getQuery(`USER_TABLE_PRIV`,n,r)),o=u(a).find(e=>String(e.Db)===i.database&&String(e.Table_name)===i.table);return o?R(String(o.Table_priv??``)):{}}function H(e,t,n,r,i,a){let o=B(e,r),s=[],c=[],l=null;for(let e of new Set([...Object.keys(i),...Object.keys(a)])){let t=i[e]===!0,n=a[e]===!0;if(t!==n){if(e===`GRANT OPTION`){l=n;continue}(n?s:c).push(e)}}let u=[];if(s.length>0||l===!0){let r=s.length>0?s.join(`, `):`USAGE`;u.push(e.getQuery(`GRANT`,r,t,n,o,l===!0?`WITH GRANT OPTION`:``))}return c.length>0&&u.push(e.getQuery(`REVOKE`,c.join(`, `),t,n,o)),l===!1&&u.push(e.getQuery(`REVOKE`,`GRANT OPTION`,t,n,o)),u}function U(e){return c.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId??null}function W(){let{t:e}=a(),{activeDialog:t,closeDialog:r,openDialog:i,setFooterMessage:u}=n(),p=c(e=>e.activeConnectionId)??``,m=w(e=>e.users[p]??T),h=w(e=>e.selectedUser[p]??null),g=w(e=>e.setSelectedUser),E=w(e=>e.removeUser),j=e=>g(p,e),M=(e,t)=>E(p,e,t),[N,P]=(0,O.useState)({level:`global`}),[F,L]=(0,O.useState)({}),[R,z]=(0,O.useState)([]),[B,W]=(0,O.useState)({}),[G,K]=(0,O.useState)({}),[q,J]=(0,O.useState)(!1),Y=t===`user-manager`;(0,O.useEffect)(()=>{if(!Y||!p)return;let e=U(p);if(!e)return;let t=!1;return d(p).introspect.listDatabases(l(e)).then(e=>{t||z(e)}).catch(()=>{t||z([])}),()=>{t=!0}},[Y,p]),(0,O.useEffect)(()=>{let e=N.database;if(!Y||!p||!e||B[e])return;let t=U(p);if(!t)return;let n=!1;return d(p).introspect.listTables(l(t),e).then(t=>{n||W(n=>({...n,[e]:t.map(e=>e.name)}))}).catch(()=>void 0),()=>{n=!0}},[Y,p,N.database,B]),(0,O.useEffect)(()=>{if(!Y||!p||!h){K({}),L({});return}let e=U(p);if(!e)return;let t=!1;return V(l(e),d(p),h.user,h.host,N).then(e=>{t||(K(e),L(e))}).catch(()=>{t||(K({}),L({}))}),()=>{t=!0}},[Y,p,h,N]);function X(e){e||(r(),j(null),P({level:`global`}),L({}))}let Z=(0,O.useCallback)(e=>{P(e),L({})},[]);function Q(){i(`user-add`)}async function $(){if(!h||!p)return;let{user:t,host:n}=h;J(!0);try{await f(p,d(p).getQuery(`DELETE_USER`,t,n)),M(n,t),j(null),u(e(`user.manager.removed`,{user:t,host:n}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{J(!1)}}async function ee(){if(!h||!p){u(e(`user.manager.selectUserFirst`));return}let t=H(d(p),h.user,h.host,N,G,F);if(t.length===0){u(e(`user.manager.noChanges`));return}J(!0);try{for(let e of t)await f(p,e);K(F),u(e(`user.manager.applied`))}catch(e){u(e instanceof Error?e.message:String(e))}finally{J(!1)}}return(0,k.jsx)(C,{open:Y,onOpenChange:X,children:(0,k.jsxs)(x,{className:`sm:max-w-[80vw] max-h-[70vh] flex flex-col`,children:[(0,k.jsx)(y,{children:(0,k.jsx)(S,{children:e(`user.manager.title`)})}),(0,k.jsxs)(`div`,{className:`flex flex-1 gap-0 overflow-hidden min-h-0 border rounded-md`,children:[(0,k.jsxs)(`div`,{className:`w-[200px] shrink-0 border-r flex flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 p-2 border-b`,children:[(0,k.jsx)(s,{variant:`ghost`,size:`sm`,onClick:Q,title:e(`user.manager.addUser`),children:(0,k.jsx)(D,{className:`h-4 w-4`})}),(0,k.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void $(),disabled:!h||q,title:e(`user.manager.removeUser`),children:(0,k.jsx)(_,{className:`h-4 w-4`})})]}),(0,k.jsx)(v,{className:`flex-1`,children:(0,k.jsx)(`div`,{className:`py-1`,children:m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground text-center`,children:e(`user.manager.noUsers`)}):m.map(e=>{let t=h?.user===e.user&&h?.host===e.host;return(0,k.jsx)(`div`,{className:o(`flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm hover:bg-accent`,t&&`bg-accent text-accent-foreground`),onClick:()=>j(e),children:(0,k.jsxs)(`span`,{className:`truncate`,children:[e.user,`@`,e.host]})},`${e.user}@${e.host}`)})})})]}),(0,k.jsxs)(`div`,{className:`w-[250px] shrink-0 border-r`,children:[(0,k.jsx)(`div`,{className:`p-2 border-b text-sm font-medium`,children:e(`user.manager.grantScope`)}),(0,k.jsx)(A,{connectionId:``,databases:R,tables:B,onSelectScope:Z})]}),(0,k.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,k.jsx)(I,{scope:N.level,privileges:F,onChange:L})})]}),(0,k.jsxs)(b,{children:[(0,k.jsx)(s,{onClick:()=>void ee(),disabled:q,children:e(`user.manager.apply`)}),(0,k.jsx)(s,{variant:`outline`,onClick:()=>X(!1),children:e(`user.manager.close`)})]})]})})}export{W as UserManagerDialog};
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n}from"./B1pia_Rg.js";import{a as r,l as i,m as a,o,t as s}from"./pjlgs2cl.js";import{t as c}from"./BCmzDvBt.js";import{a as l}from"./CS2mpWDL.js";import{i as u}from"./DbqogdCK.js";import{n as d}from"./pneb1la9.js";import{l as f}from"./mA5FXiEh.js";import{It as p,Mt as m,_t as h,c as g,ht as _,lt as v}from"./BZ6aghND.js";import{a as y,i as b,n as x,o as S,t as C}from"./BgkATqP8.js";import{n as w,t as T}from"./C0bzfYFC.js";var E=r(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),D=r(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),O=e(t(),1),k=i();function A({databases:e,tables:t,onSelectScope:n}){let{t:r}=a(),[i,s]=(0,O.useState)(new Set),[c,l]=(0,O.useState)(`global`),u=(0,O.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),d=[{id:`global`,text:r(`user.grantTree.globalPrivileges`),type:`global`,children:e.map(e=>({id:`db:${e}`,text:e,type:`database`,database:e,children:(t[e]??[]).map(t=>({id:`tbl:${e}.${t}`,text:t,type:`table`,database:e,table:t}))}))}];function f(e){l(e.id),n({level:e.type,database:e.database,table:e.table})}function g(e,t){let n=e.children&&e.children.length>0,r=i.has(e.id),a=c===e.id,s=E;return e.type===`database`&&(s=m),e.type===`table`&&(s=h),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:o(`flex items-center gap-1 px-2 py-0.5 cursor-pointer text-sm hover:bg-accent rounded-sm`,a&&`bg-accent text-accent-foreground`),style:{paddingLeft:`${t*16+4}px`},onClick:()=>{f(e),n&&u(e.id)},children:[n?(0,k.jsx)(p,{className:o(`h-3 w-3 transition-transform shrink-0`,r&&`rotate-90`)}):(0,k.jsx)(`span`,{className:`w-3 shrink-0`}),(0,k.jsx)(s,{className:`h-4 w-4 text-muted-foreground shrink-0`}),(0,k.jsx)(`span`,{className:`truncate`,children:e.text})]}),r&&e.children?.map(e=>g(e,t+1))]},e.id)}return(0,k.jsx)(v,{className:`h-full`,children:(0,k.jsx)(`div`,{className:`py-1`,children:d.map(e=>g(e,0))})})}var j={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`SUPER`,`PROCESS`,`RELOAD`,`SHUTDOWN`,`SHOW DATABASES`,`LOCK TABLES`,`EXECUTE`,`REPLICATION SLAVE`,`REPLICATION CLIENT`,`CREATE VIEW`,`SHOW VIEW`,`CREATE ROUTINE`,`ALTER ROUTINE`,`CREATE USER`,`EVENT`,`TRIGGER`,`CREATE TABLESPACE`]},M={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`LOCK TABLES`,`EXECUTE`,`CREATE VIEW`,`SHOW VIEW`,`CREATE ROUTINE`,`ALTER ROUTINE`,`EVENT`,`TRIGGER`]},N={Data:[`SELECT`,`INSERT`,`UPDATE`,`DELETE`],Structure:[`CREATE`,`ALTER`,`DROP`,`INDEX`,`REFERENCES`],Administration:[`GRANT OPTION`,`TRIGGER`]},P={global:`user.privileges.globalTitle`,database:`user.privileges.databaseTitle`,table:`user.privileges.tableTitle`},F={Data:`user.privileges.categoryData`,Structure:`user.privileges.categoryStructure`,Administration:`user.privileges.categoryAdministration`};function I({scope:e,privileges:t,onChange:n}){let{t:r}=a(),i=(0,O.useMemo)(()=>e===`global`?j:e===`database`?M:N,[e]),o=(0,O.useMemo)(()=>Object.values(i).flat(),[i]);function c(e){n({...t,[e]:!t[e]})}function l(){let e={...t};for(let t of o)e[t]=!0;n(e)}function u(){let e={...t};for(let t of o)e[t]=!1;n(e)}return(0,k.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 p-2 border-b`,children:[(0,k.jsx)(`span`,{className:`text-sm font-medium`,children:r(P[e])}),(0,k.jsxs)(`div`,{className:`ml-auto flex gap-1`,children:[(0,k.jsx)(s,{variant:`outline`,size:`sm`,onClick:l,children:r(`user.privileges.checkAll`)}),(0,k.jsx)(s,{variant:`outline`,size:`sm`,onClick:u,children:r(`user.privileges.uncheckAll`)})]})]}),(0,k.jsx)(v,{className:`flex-1`,children:(0,k.jsx)(`div`,{className:`p-3 space-y-4`,children:Object.entries(i).map(([e,n])=>(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h4`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:F[e]?r(F[e]):e}),(0,k.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:n.map(e=>(0,k.jsxs)(g,{className:`flex items-center gap-2 text-sm font-normal cursor-pointer py-1`,children:[(0,k.jsx)(`input`,{type:`checkbox`,checked:t[e]??!1,onChange:()=>c(e),className:`rounded border-input`}),e]},e))})]},e))})})]})}var L={SELECT:`Select_priv`,INSERT:`Insert_priv`,UPDATE:`Update_priv`,DELETE:`Delete_priv`,CREATE:`Create_priv`,ALTER:`Alter_priv`,DROP:`Drop_priv`,INDEX:`Index_priv`,REFERENCES:`References_priv`,"GRANT OPTION":`Grant_priv`,SUPER:`Super_priv`,PROCESS:`Process_priv`,RELOAD:`Reload_priv`,SHUTDOWN:`Shutdown_priv`,"SHOW DATABASES":`Show_db_priv`,"LOCK TABLES":`Lock_tables_priv`,EXECUTE:`Execute_priv`,"REPLICATION SLAVE":`Repl_slave_priv`,"REPLICATION CLIENT":`Repl_client_priv`,"CREATE VIEW":`Create_view_priv`,"SHOW VIEW":`Show_view_priv`,"CREATE ROUTINE":`Create_routine_priv`,"ALTER ROUTINE":`Alter_routine_priv`,"CREATE USER":`Create_user_priv`,EVENT:`Event_priv`,TRIGGER:`Trigger_priv`,"CREATE TABLESPACE":`Create_tablespace_priv`,"CREATE TEMPORARY TABLES":`Create_tmp_table_priv`,FILE:`File_priv`};function R(e){let t={};for(let n of e.split(`,`)){let e=n.trim().toUpperCase();e&&(t[e]=!0)}return t}function z(e){let t={};for(let[n,r]of Object.entries(L)){let i=e[r];i!==void 0&&(t[n]=String(i).toUpperCase()===`Y`)}return t}function B(e,t){let n=t=>e.quoteIdentifier(t);return t.level===`global`?`*.*`:t.level===`database`?`${n(t.database??``)}.*`:`${n(t.database??``)}.${n(t.table??``)}`}async function V(e,t,n,r,i){if(i.level===`global`){let i=await e(t.getQuery(`USER_PRIV`,n,r)),a=u(i)[0];return a?z(a):{}}if(i.level===`database`){let a=await e(t.getQuery(`USER_DATABASE_PRIV`,n,r)),o=u(a).find(e=>String(e.Db)===i.database);return o?z(o):{}}let a=await e(t.getQuery(`USER_TABLE_PRIV`,n,r)),o=u(a).find(e=>String(e.Db)===i.database&&String(e.Table_name)===i.table);return o?R(String(o.Table_priv??``)):{}}function H(e,t,n,r,i,a){let o=B(e,r),s=[],c=[],l=null;for(let e of new Set([...Object.keys(i),...Object.keys(a)])){let t=i[e]===!0,n=a[e]===!0;if(t!==n){if(e===`GRANT OPTION`){l=n;continue}(n?s:c).push(e)}}let u=[];if(s.length>0||l===!0){let r=s.length>0?s.join(`, `):`USAGE`;u.push(e.getQuery(`GRANT`,r,t,n,o,l===!0?`WITH GRANT OPTION`:``))}return c.length>0&&u.push(e.getQuery(`REVOKE`,c.join(`, `),t,n,o)),l===!1&&u.push(e.getQuery(`REVOKE`,`GRANT OPTION`,t,n,o)),u}function U(e){return c.getState().activeConnections.find(t=>t.id===e)?.serverConnectionId??null}function W(){let{t:e}=a(),{activeDialog:t,closeDialog:r,openDialog:i,setFooterMessage:u}=n(),p=c(e=>e.activeConnectionId)??``,m=w(e=>e.users[p]??T),h=w(e=>e.selectedUser[p]??null),g=w(e=>e.setSelectedUser),E=w(e=>e.removeUser),j=e=>g(p,e),M=(e,t)=>E(p,e,t),[N,P]=(0,O.useState)({level:`global`}),[F,L]=(0,O.useState)({}),[R,z]=(0,O.useState)([]),[B,W]=(0,O.useState)({}),[G,K]=(0,O.useState)({}),[q,J]=(0,O.useState)(!1),Y=t===`user-manager`;(0,O.useEffect)(()=>{if(!Y||!p)return;let e=U(p);if(!e)return;let t=!1;return d(p).introspect.listDatabases(l(e)).then(e=>{t||z(e)}).catch(()=>{t||z([])}),()=>{t=!0}},[Y,p]),(0,O.useEffect)(()=>{let e=N.database;if(!Y||!p||!e||B[e])return;let t=U(p);if(!t)return;let n=!1;return d(p).introspect.listTables(l(t),e).then(t=>{n||W(n=>({...n,[e]:t.map(e=>e.name)}))}).catch(()=>void 0),()=>{n=!0}},[Y,p,N.database,B]),(0,O.useEffect)(()=>{if(!Y||!p||!h){K({}),L({});return}let e=U(p);if(!e)return;let t=!1;return V(l(e),d(p),h.user,h.host,N).then(e=>{t||(K(e),L(e))}).catch(()=>{t||(K({}),L({}))}),()=>{t=!0}},[Y,p,h,N]);function X(e){e||(r(),j(null),P({level:`global`}),L({}))}let Z=(0,O.useCallback)(e=>{P(e),L({})},[]);function Q(){i(`user-add`)}async function $(){if(!h||!p)return;let{user:t,host:n}=h;J(!0);try{await f(p,d(p).getQuery(`DELETE_USER`,t,n)),M(n,t),j(null),u(e(`user.manager.removed`,{user:t,host:n}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{J(!1)}}async function ee(){if(!h||!p){u(e(`user.manager.selectUserFirst`));return}let t=H(d(p),h.user,h.host,N,G,F);if(t.length===0){u(e(`user.manager.noChanges`));return}J(!0);try{for(let e of t)await f(p,e);K(F),u(e(`user.manager.applied`))}catch(e){u(e instanceof Error?e.message:String(e))}finally{J(!1)}}return(0,k.jsx)(C,{open:Y,onOpenChange:X,children:(0,k.jsxs)(x,{className:`sm:max-w-[80vw] max-h-[70vh] flex flex-col`,children:[(0,k.jsx)(y,{children:(0,k.jsx)(S,{children:e(`user.manager.title`)})}),(0,k.jsxs)(`div`,{className:`flex flex-1 gap-0 overflow-hidden min-h-0 border rounded-md`,children:[(0,k.jsxs)(`div`,{className:`w-[200px] shrink-0 border-r flex flex-col`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1 p-2 border-b`,children:[(0,k.jsx)(s,{variant:`ghost`,size:`sm`,onClick:Q,title:e(`user.manager.addUser`),children:(0,k.jsx)(D,{className:`h-4 w-4`})}),(0,k.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void $(),disabled:!h||q,title:e(`user.manager.removeUser`),children:(0,k.jsx)(_,{className:`h-4 w-4`})})]}),(0,k.jsx)(v,{className:`flex-1`,children:(0,k.jsx)(`div`,{className:`py-1`,children:m.length===0?(0,k.jsx)(`div`,{className:`px-3 py-4 text-sm text-muted-foreground text-center`,children:e(`user.manager.noUsers`)}):m.map(e=>{let t=h?.user===e.user&&h?.host===e.host;return(0,k.jsx)(`div`,{className:o(`flex items-center gap-2 px-3 py-1.5 cursor-pointer text-sm hover:bg-accent`,t&&`bg-accent text-accent-foreground`),onClick:()=>j(e),children:(0,k.jsxs)(`span`,{className:`truncate`,children:[e.user,`@`,e.host]})},`${e.user}@${e.host}`)})})})]}),(0,k.jsxs)(`div`,{className:`w-[250px] shrink-0 border-r`,children:[(0,k.jsx)(`div`,{className:`p-2 border-b text-sm font-medium`,children:e(`user.manager.grantScope`)}),(0,k.jsx)(A,{connectionId:``,databases:R,tables:B,onSelectScope:Z})]}),(0,k.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,k.jsx)(I,{scope:N.level,privileges:F,onChange:L})})]}),(0,k.jsxs)(b,{children:[(0,k.jsx)(s,{onClick:()=>void ee(),disabled:q,children:e(`user.manager.apply`)}),(0,k.jsx)(s,{variant:`outline`,onClick:()=>X(!1),children:e(`user.manager.close`)})]})]})})}export{W as UserManagerDialog};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./B1pia_Rg.js";import{a as i,l as a,m as o,t as s}from"./pjlgs2cl.js";import{t as c}from"./BCmzDvBt.js";import{n as l}from"./D6kbK-ng.js";import{a as u}from"./CS2mpWDL.js";import{l as d,t as f}from"./
|
|
1
|
+
import{r as e}from"./hePW80VL.js";import{h as t,n,t as r}from"./B1pia_Rg.js";import{a as i,l as a,m as o,t as s}from"./pjlgs2cl.js";import{t as c}from"./BCmzDvBt.js";import{n as l}from"./D6kbK-ng.js";import{a as u}from"./CS2mpWDL.js";import{l as d,t as f}from"./mA5FXiEh.js";import{Dt as p,Ft as m,Pt as h,ct as g,d as _,f as v,kt as y,m as b,p as x,zt as S}from"./BZ6aghND.js";import{a as C,i as w,n as ee,o as T,r as E,t as D}from"./BgkATqP8.js";var O=i(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),k=e(t(),1);function A(e){let t=e.slice(e.indexOf(`(`)+1,e.lastIndexOf(`)`)),n=[],r=/'((?:[^']|'')*)'/g,i;for(;i=r.exec(t);)n.push(i[1].replaceAll(`''`,`'`));return n}function j(e,t={}){let{oracleDate:n=!1}=t,r=e.type.trim(),i=r.toLowerCase(),a=/\bunsigned\b/.test(i);if(/^enum\(/.test(i))return{kind:`enum`,options:A(r)};if(/^set\(/.test(i))return{kind:`set`,options:A(r)};if(/^(tinyint\(1\)|bool|boolean|bit\(1\)|bit)(?![\w(])/.test(i))return{kind:`boolean`};let o=/^number(?:\((\d+|\*)(?:,\s*(-?\d+))?\))?$/.exec(i);if(o)return o[2]&&Number(o[2])>0?{kind:`decimal`}:o[1]?{kind:`integer`}:{kind:`decimal`};if(/^(tinyint|smallint|mediumint|int|integer|bigint|int2|int4|int8|serial|bigserial|smallserial)\b/.test(i))return{kind:`integer`,unsigned:a};if(/^(decimal|numeric|float|double|real|money|float4|float8|double precision)\b/.test(i))return{kind:`decimal`,unsigned:a};if(/^(datetime2|datetime|timestamp|smalldatetime|datetimeoffset)\b/.test(i))return{kind:`datetime`};if(/^date\b/.test(i))return{kind:n?`datetime`:`date`};if(/^(time|timetz)\b/.test(i))return{kind:`time`};if(/^(json|jsonb)\b/.test(i))return{kind:`json`};if(/^(uuid|uniqueidentifier)\b/.test(i))return{kind:`uuid`};if(/^(blob|tinyblob|mediumblob|longblob|binary|varbinary|bytea|raw|image|bfile)\b/.test(i))return{kind:`binary`};if(/^(text|ntext|tinytext|mediumtext|longtext|clob|nclob|long)\b/.test(i)||/^n?(?:var)?char2?\(max\)/.test(i))return{kind:`text`};let s=/^n?(?:var)?char2?(?:acter)?(?:\s+varying)?\((\d+)(?:\s+(?:char|byte))?\)/.exec(i);return s?{kind:`string`,maxLength:Number(s[1])}:{kind:`string`}}var M=/auto_increment|identity|generated/i;function N(e){return M.test(e.extra)||/^(serial|bigserial|smallserial)\b/i.test(e.type)?{mode:`auto`,text:``}:e.defaultValue===null?e.nullable?{mode:`null`,text:``}:{mode:`value`,text:``}:{mode:`default`,text:``}}function P(e){return e==null?{mode:`keep`,text:``}:{mode:`keep`,text:F(e)}}function F(e){if(e==null)return``;if(typeof e==`object`){if(ArrayBuffer.isView(e))return``;if(e instanceof Date)return e.toISOString();try{return JSON.stringify(e,null,2)}catch{return String(e)}}return String(e)}function I(e,t){let n=t.trim();switch(e.kind){case`integer`:{if(!/^[+-]?\d+$/.test(n))return{error:`integer`};if(e.unsigned&&n.startsWith(`-`))return{error:`unsigned`};let t=Number(n);return{value:Number.isSafeInteger(t)?t:BigInt(n)}}case`decimal`:return n===``||Number.isNaN(Number(n))?{error:`number`}:{value:Number(n)};case`boolean`:return{value:n===`true`||n===`1`};case`json`:try{return{value:JSON.parse(n===``?`null`:n)}}catch{return{error:`json`}}case`set`:return{value:n};case`date`:return n&&!/^\d{4}-\d{2}-\d{2}$/.test(n)?{error:`date`}:{value:n};case`datetime`:return n&&!/^\d{4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?)?)?([+-]\d{2}:?\d{2}|Z)?$/.test(n)?{error:`datetime`}:{value:n};case`time`:return n&&!/^-?\d{1,3}:\d{2}(:\d{2}(\.\d+)?)?$/.test(n)?{error:`time`}:{value:n};default:return{value:t}}}var L=a(),R={integer:`result.rowForm.invalid.integer`,unsigned:`result.rowForm.invalid.unsigned`,number:`result.rowForm.invalid.number`,json:`result.rowForm.invalid.json`,date:`result.rowForm.invalid.date`,datetime:`result.rowForm.invalid.datetime`,time:`result.rowForm.invalid.time`};function z(e){return String(e).padStart(2,`0`)}function B(e){let t=new Date,n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`,r=`${z(t.getHours())}:${z(t.getMinutes())}:${z(t.getSeconds())}`;return e===`date`?n:e===`time`?r:`${n} ${r}`}function V(e){let t=/^(\d{4})-(\d{2})-(\d{2})/.exec(e.trim());if(!t)return;let n=new Date(Number(t[1]),Number(t[2])-1,Number(t[3]));return Number.isNaN(n.getTime())?void 0:n}function H({spec:e,state:t,disabled:n,onText:r}){let{t:i}=o(),a=`w-full rounded border bg-background px-2 py-1 text-sm font-mono outline-none focus:ring-1 focus:ring-primary disabled:opacity-50`;switch(e.kind){case`boolean`:return(0,L.jsxs)(`select`,{className:a,value:t.text===`true`||t.text===`1`?`true`:`false`,onChange:e=>r(e.target.value),disabled:n,children:[(0,L.jsx)(`option`,{value:`true`,children:`TRUE`}),(0,L.jsx)(`option`,{value:`false`,children:`FALSE`})]});case`enum`:return(0,L.jsxs)(`select`,{className:a,value:t.text,onChange:e=>r(e.target.value),disabled:n,children:[!e.options?.includes(t.text)&&(0,L.jsx)(`option`,{value:t.text,children:t.text||`—`}),e.options?.map(e=>(0,L.jsx)(`option`,{value:e,children:e},e))]});case`set`:{let i=new Set(t.text.split(`,`).map(e=>e.trim()).filter(Boolean));return(0,L.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 rounded border bg-background px-2 py-1.5`,children:e.options?.map(t=>(0,L.jsxs)(`label`,{className:`flex items-center gap-1 text-xs font-mono`,children:[(0,L.jsx)(`input`,{type:`checkbox`,className:`accent-primary`,checked:i.has(t),disabled:n,onChange:n=>{let a=new Set(i);n.target.checked?a.add(t):a.delete(t),r(e.options.filter(e=>a.has(e)).join(`,`))}}),t]},t))})}case`integer`:case`decimal`:return(0,L.jsx)(`input`,{className:`${a} tabular-nums`,inputMode:`decimal`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:e.kind===`integer`?`0`:`0.00`});case`date`:case`datetime`:{let[o,s]=t.text.trim().split(/[ T]/);return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:e.kind===`date`?`YYYY-MM-DD`:`YYYY-MM-DD HH:MM:SS`}),(0,L.jsxs)(v,{children:[(0,L.jsx)(b,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background p-1.5 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,title:i(`result.rowForm.pickDate`),children:(0,L.jsx)(S,{className:`size-3.5`})})}),(0,L.jsx)(x,{className:`w-auto p-0`,align:`end`,children:(0,L.jsx)(_,{mode:`single`,selected:V(o??``),defaultMonth:V(o??``),onSelect:t=>{if(!t)return;let n=`${t.getFullYear()}-${z(t.getMonth()+1)}-${z(t.getDate())}`;r(e.kind===`date`?n:`${n} ${s||`00:00:00`}`)}})})]}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(B(e.kind)),title:i(`result.rowForm.now`),children:(0,L.jsx)(h,{className:`size-3.5`})})]})}case`time`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:`HH:MM:SS`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(B(`time`)),title:i(`result.rowForm.now`),children:(0,L.jsx)(h,{className:`size-3.5`})})]});case`json`:{let e=!0;try{t.text.trim()&&JSON.parse(t.text)}catch{e=!1}return(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`textarea`,{className:`${a} min-h-[96px] resize-y text-xs ${e?``:`border-destructive`}`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1,placeholder:`{}`}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 rounded border bg-background px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n||!e||!t.text.trim(),onClick:()=>{try{r(JSON.stringify(JSON.parse(t.text),null,2))}catch{}},children:[(0,L.jsx)(O,{className:`size-3`}),i(`result.rowForm.formatJson`)]}),!e&&(0,L.jsx)(`span`,{className:`text-[10px] text-destructive`,children:i(`result.rowForm.invalid.json`)})]})]})}case`text`:return(0,L.jsx)(`textarea`,{className:`${a} min-h-[72px] resize-y`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1});case`binary`:return(0,L.jsx)(`div`,{className:`rounded border bg-muted/40 px-2 py-1 text-xs italic text-muted-foreground`,children:i(`result.rowForm.binaryUnsupported`)});case`uuid`:return(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`input`,{className:`${a} flex-1`,value:t.text,onChange:e=>r(e.target.value),disabled:n,placeholder:`00000000-0000-0000-0000-000000000000`}),(0,L.jsx)(`button`,{type:`button`,className:`rounded border bg-background px-1.5 py-1 text-muted-foreground hover:text-foreground disabled:opacity-50`,disabled:n,onClick:()=>r(crypto.randomUUID()),title:i(`result.rowForm.generateUuid`),children:(0,L.jsx)(O,{className:`size-3.5`})})]});default:{let i=t.text.length>80||t.text.includes(`
|
|
2
2
|
`);return(0,L.jsxs)(`div`,{className:`space-y-0.5`,children:[i?(0,L.jsx)(`textarea`,{className:`${a} min-h-[56px] resize-y`,value:t.text,onChange:e=>r(e.target.value),disabled:n,spellCheck:!1}):(0,L.jsx)(`input`,{className:a,value:t.text,onChange:e=>r(e.target.value),disabled:n,maxLength:e.maxLength}),e.maxLength&&(0,L.jsxs)(`div`,{className:`text-right text-[10px] tabular-nums ${t.text.length>e.maxLength?`text-destructive`:`text-muted-foreground`}`,children:[t.text.length,`/`,e.maxLength]})]})}}}function U(){let{t:e}=o(),t=r(`row-form`),i=n(e=>e.closeDialog),a=n(e=>e.setFooterMessage),h=g(t?.connectionId??``),_=c(e=>t?e.transactionOpen[t.connectionId]:!1),[v,b]=(0,k.useState)(null),[x,S]=(0,k.useState)(null),[O,A]=(0,k.useState)({}),[M,F]=(0,k.useState)({}),[z,B]=(0,k.useState)(null),[V,U]=(0,k.useState)(!1),W=t?.mode===`edit`;(0,k.useEffect)(()=>{if(!t)return;let e=!1,n=u(t.serverConnectionId);return h.introspect.listColumns(n,t.database,t.table).then(n=>{if(e)return;b(n);let r={};for(let e of n)if(t.mode===`edit`){let n=t.fields.find(t=>t.orgName===e.name);r[e.name]=P(n?t.row?.[n.name]:void 0)}else r[e.name]=N(e);A(r)}).catch(t=>{e||S(t instanceof Error?t.message:String(t))}),()=>{e=!0}},[t?.serverConnectionId,t?.database,t?.table,t?.mode]);let G=(0,k.useMemo)(()=>new Map((v??[]).map(e=>[e.name,j(e,{oracleDate:h.id===`oracle`})])),[v,h.id]),K=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{...n[e],mode:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),q=(0,k.useCallback)((e,t)=>{A(n=>({...n,[e]:{mode:`value`,text:t}})),F(t=>{let n={...t};return delete n[e],n})},[]),J=(0,k.useMemo)(()=>({__default:!0}),[]),Y=(0,k.useCallback)(()=>{if(!v)return null;let t=new Map,n={};for(let r of v){let i=O[r.name],a=G.get(r.name);if(!i||i.mode===`auto`||i.mode===`keep`)continue;if(i.mode===`null`){t.set(r.name,null);continue}if(i.mode==="default"){t.set(r.name,J);continue}let o=I(a,i.text);if(`error`in o){n[r.name]=e(R[o.error]??`result.rowForm.invalid.number`);continue}if(a.maxLength&&typeof o.value==`string`&&o.value.length>a.maxLength){n[r.name]=e(`result.rowForm.invalid.length`,{max:a.maxLength});continue}t.set(r.name,o.value)}return F(n),Object.keys(n).length>0?null:{values:t}},[v,O,G,e,J]),X=(0,k.useCallback)(e=>{if(!t)return null;let n=e=>e===J?`DEFAULT`:h.quoteLiteral(e);if(t.mode===`insert`){let r=[...e];return r.length===0?h.getQuery(`INSERT_DEFAULT_VALUES`,t.database,t.table):h.getQuery(`INSERT_TABLE`,t.database,t.table,r.map(([e])=>h.quoteIdentifier(e)).join(`, `),r.map(([,e])=>n(e)).join(`, `))}return!t.where||e.size===0?null:h.getQuery(`UPDATE_TABLE`,t.database,t.table,[...e].map(([e,t])=>`${h.quoteIdentifier(e)} = ${n(t)}`).join(`, `),t.where)},[t,h,J]),Z=(0,k.useMemo)(()=>{if(!v)return``;let e=new Map;for(let t of v){let n=O[t.name];if(!(!n||n.mode===`auto`||n.mode===`keep`)){if(n.mode===`null`)e.set(t.name,null);else if(n.mode==="default")e.set(t.name,J);else{let r=I(G.get(t.name),n.text);e.set(t.name,`error`in r?n.text:r.value)}}}return X(e)??``},[v,O,G,X,J]),Q=e=>{let n={};for(let[r,i]of e){if(i===J)continue;let e=t?.fields.find(e=>e.orgName===r);n[e?.name??r]=typeof i==`bigint`?i.toString():i}return n},te=()=>{let e=Y();!e||!t||(t.onStage?.(t.mode,Q(e.values)),i())},ne=async()=>{let r=Y();if(!r||!t)return;let o=X(r.values);if(!o){B(e(`result.rowForm.nothingToWrite`));return}U(!0),B(null);try{if(l.getState().previewGridCommit&&!await n.getState().requestDestructiveConfirm({title:e(W?`result.rowForm.confirmUpdateTitle`:`result.rowForm.confirmInsertTitle`,{table:`${t.database}.${t.table}`}),statements:[o],confirmLabel:e(W?`result.rowForm.update`:`result.rowForm.insert`)}))return;await d(t.connectionId,o,{database:t.database,skipDestructiveConfirm:!0}),a(e(W?`result.rowForm.updated`:`result.rowForm.inserted`,{table:`${t.database}.${t.table}`})),t.onCommitted?.(t.mode,Q(r.values)),i()}catch(e){if(e instanceof f)return;B(e instanceof Error?e.message:String(e))}finally{U(!1)}};if(!t)return null;let $=(e,t,n,r)=>(0,L.jsx)(`button`,{type:`button`,className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${r===t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`}`,onClick:()=>K(e,t),children:n});return(0,L.jsx)(D,{open:!0,onOpenChange:e=>{e||i()},children:(0,L.jsxs)(ee,{className:`flex max-h-[90vh] flex-col sm:max-w-[860px]`,children:[(0,L.jsxs)(C,{children:[(0,L.jsx)(T,{children:e(W?`result.rowForm.editTitle`:`result.rowForm.insertTitle`)}),(0,L.jsxs)(E,{className:`font-mono text-xs`,children:[t.database,`.`,t.table]})]}),(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto rounded-md border`,children:[x&&(0,L.jsx)(`div`,{className:`rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:x}),!v&&!x&&(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-10 text-sm text-muted-foreground`,children:[(0,L.jsx)(p,{className:`size-4 animate-spin`}),e(`result.rowForm.loading`)]}),v&&(0,L.jsxs)(`table`,{className:`w-full border-separate border-spacing-0 text-sm`,children:[(0,L.jsx)(`thead`,{className:`sticky top-0 z-10 bg-background`,children:(0,L.jsxs)(`tr`,{className:`text-left text-[10px] uppercase tracking-wide text-muted-foreground`,children:[(0,L.jsx)(`th`,{className:`w-[38%] border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colColumn`)}),(0,L.jsx)(`th`,{className:`border-b px-2 py-1.5 font-medium`,children:e(`result.rowForm.colValue`)})]})}),(0,L.jsx)(`tbody`,{children:v.map(n=>{let r=O[n.name]??{mode:`value`,text:``},i=G.get(n.name),a=r.mode===`auto`,o=M[n.name],s=n.key===`PRI`,c=t.fields.find(e=>e.orgName===n.name),l=!!c&&!!t.row&&t.row[c.name]===null;return(0,L.jsxs)(`tr`,{className:`align-top ${o?`bg-destructive/5`:`hover:bg-muted/30`}`,children:[(0,L.jsxs)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`truncate font-mono text-sm font-medium`,title:n.name,children:n.name}),s&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 rounded border border-catppuccin-yellow/50 px-1 text-[9px] font-semibold text-catppuccin-yellow`,children:[(0,L.jsx)(y,{className:`size-2.5`}),`PK`]})]}),(0,L.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[10px] text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`rounded bg-muted px-1 py-px font-mono`,children:n.type}),!n.nullable&&(0,L.jsx)(`span`,{children:`NOT NULL`}),n.defaultValue!==null&&(0,L.jsxs)(`span`,{className:`font-mono`,title:e(`result.rowForm.defaultValue`),children:[`= `,n.defaultValue]}),n.extra&&(0,L.jsx)(`span`,{children:n.extra})]}),n.comment&&(0,L.jsx)(`div`,{className:`mt-0.5 text-[10px] text-muted-foreground/80`,children:n.comment})]}),(0,L.jsx)(`td`,{className:`border-b border-border/60 px-2 py-2`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r.mode===`keep`?(0,L.jsx)(`div`,{className:`cursor-text truncate rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs text-muted-foreground`,onClick:()=>K(n.name,`value`),title:e(`result.rowForm.clickToChange`),children:l?(0,L.jsx)(`span`,{className:`italic`,children:`NULL`}):r.text||(0,L.jsx)(`span`,{className:`italic`,children:e(`result.rowForm.empty`)})}):r.mode===`value`?(0,L.jsx)(H,{spec:i,state:r,disabled:!1,onText:e=>q(n.name,e)}):(0,L.jsx)(`div`,{className:`rounded border border-dashed bg-muted/30 px-2 py-1 font-mono text-xs italic text-muted-foreground`,children:r.mode===`null`?`NULL`:r.mode==="default"?`DEFAULT (${n.defaultValue??``})`:e(`result.rowForm.autoHint`)}),o&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 text-[11px] text-destructive`,children:[(0,L.jsx)(m,{className:`size-3`}),o]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded border bg-background p-0.5`,children:[W&&$(n.name,`keep`,e(`result.rowForm.mode.keep`),r.mode),(a||!W&&/auto_increment|identity/i.test(n.extra))&&$(n.name,`auto`,e(`result.rowForm.mode.auto`),r.mode),$(n.name,`value`,e(`result.rowForm.mode.value`),r.mode),n.nullable&&$(n.name,`null`,`NULL`,r.mode),n.defaultValue!==null&&$(n.name,`default`,`DEFAULT`,r.mode)]})]})})]},n.name)})})]})]}),v&&(0,L.jsxs)(`div`,{className:`shrink-0 rounded-md border bg-muted/30`,children:[(0,L.jsx)(`div`,{className:`border-b px-3 py-1 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e(`result.rowForm.preview`)}),(0,L.jsx)(`pre`,{className:`max-h-24 overflow-auto whitespace-pre-wrap break-words px-3 py-2 font-mono text-xs`,children:Z||(0,L.jsx)(`span`,{className:`italic text-muted-foreground`,children:e(`result.rowForm.nothingToWrite`)})})]}),z&&(0,L.jsx)(`div`,{className:`shrink-0 rounded border border-destructive/40 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:z}),(0,L.jsxs)(w,{className:`items-center`,children:[_&&(0,L.jsx)(`span`,{className:`mr-auto text-[11px] text-catppuccin-yellow`,children:e(`result.rowForm.inTransaction`)}),(0,L.jsx)(s,{variant:`outline`,onClick:()=>i(),disabled:V,children:e(`command.close`)}),t.onStage&&(0,L.jsx)(s,{variant:`outline`,onClick:te,disabled:V||!v,title:e(`result.rowForm.stageHint`),children:e(W?`result.rowForm.stageEdit`:`result.rowForm.stageInsert`)}),(0,L.jsxs)(s,{onClick:()=>void ne(),disabled:V||!v,children:[V&&(0,L.jsx)(p,{className:`mr-1 size-3.5 animate-spin`}),e(W?`result.rowForm.update`:`result.rowForm.insert`)]})]})]})})}export{U as RowFormDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,n as t}from"./B1pia_Rg.js";import{l as n,m as r,t as i}from"./pjlgs2cl.js";import{r as a,t as o}from"./D0jMUNSI.js";import{a as s,i as c,n as l,r as u,t as d}from"./
|
|
1
|
+
import{a as e,n as t}from"./B1pia_Rg.js";import{l as n,m as r,t as i}from"./pjlgs2cl.js";import{r as a,t as o}from"./D0jMUNSI.js";import{a as s,i as c,n as l,r as u,t as d}from"./BuhEpB12.js";import{n as f}from"./D6kbK-ng.js";import{a as p,i as m,n as h,o as g,r as _,t as v}from"./BgkATqP8.js";import{t as y}from"./ClQzFEcL.js";var b=n();function x(){let n=t(e=>e.activeDialog),x=t(e=>e.closeDialog),S=f(),{t:C}=r();return(0,b.jsx)(v,{open:n===`general-settings`,onOpenChange:e=>{e||x()},children:(0,b.jsxs)(h,{className:`sm:max-w-[560px]`,children:[(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:C(`settings.general.title`)}),(0,b.jsx)(_,{children:C(`settings.general.description`)})]}),(0,b.jsxs)(`div`,{className:`grid gap-2`,children:[(0,b.jsx)(y,{id:`s-history`,checked:S.persistQueryHistory,onChange:e=>S.setPersistQueryHistory(e),label:C(`settings.persistHistory`),hint:C(`settings.persistHistoryHint`)}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[1fr_200px] items-center gap-3 rounded-md border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,b.jsx)(`span`,{className:`text-sm font-medium`,children:C(`settings.language`)}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:C(`settings.languageHint`)})]}),(0,b.jsxs)(d,{value:S.locale,onValueChange:e=>S.setLocale(e),children:[(0,b.jsx)(c,{children:(0,b.jsx)(s,{})}),(0,b.jsxs)(l,{children:[(0,b.jsx)(u,{value:`auto`,children:C(`language.auto`,{name:C(`language.${a()}`)})}),o.map(e=>(0,b.jsx)(u,{value:e,children:C(`language.${e}`)},e))]})]})]}),(0,b.jsx)(y,{id:`s-analytics`,checked:S.analyticsEnabled,onChange:S.setAnalyticsEnabled,label:C(`settings.analytics`),hint:e()?C(`settings.analyticsHint`):C(`settings.analyticsUnavailableHint`)})]}),(0,b.jsx)(m,{children:(0,b.jsx)(i,{onClick:x,children:C(`settings.done`)})})]})})}export{x as GeneralSettingsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"./pjlgs2cl.js";import{z as t}from"./
|
|
1
|
+
import{l as e}from"./pjlgs2cl.js";import{z as t}from"./BZ6aghND.js";var n=e();function r({id:e,checked:r,onChange:i,label:a,hint:o,pro:s}){return(0,n.jsxs)(`label`,{htmlFor:e,className:`flex cursor-pointer items-start gap-3 rounded-md border p-3 hover:bg-accent/40`,children:[(0,n.jsx)(`input`,{id:e,type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-0.5 size-4 accent-primary`}),(0,n.jsxs)(`span`,{className:`grid flex-1 gap-0.5`,children:[(0,n.jsxs)(`span`,{className:`flex items-center text-sm font-medium`,children:[a,s?(0,n.jsx)(t,{}):null]}),(0,n.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]})}export{r as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e,m as t}from"./pjlgs2cl.js";import{t as n}from"./neLPq0_M.js";import{Rt as r}from"./
|
|
1
|
+
import{l as e,m as t}from"./pjlgs2cl.js";import{t as n}from"./neLPq0_M.js";import{Rt as r}from"./BZ6aghND.js";var i={currency:`USD`,annualPerMonth:8,annualTotal:96,monthly:10},a=e=>`$${e}`,o=e(),s=`https://planche.dev/pricing/`;function c({highlight:e,innerRef:c}){let{t:l}=t(),u=e?[e,...n.filter(t=>t!==e)]:[...n];return(0,o.jsxs)(`div`,{className:`grid gap-3 rounded-xl border border-primary/50 bg-muted/20 p-4 shadow-[inset_0_0_0_1px_hsl(var(--primary)/0.15)]`,children:[(0,o.jsx)(`p`,{className:`text-[0.7rem] font-semibold uppercase tracking-[0.09em] text-muted-foreground`,children:`Pro`}),(0,o.jsxs)(`div`,{className:`grid gap-1`,children:[(0,o.jsxs)(`p`,{className:`flex items-baseline gap-1.5`,children:[(0,o.jsx)(`span`,{className:`text-3xl font-semibold leading-none text-foreground`,children:a(i.annualPerMonth)}),(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l(`pro.perMonth`)})]}),(0,o.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`pro.priceNote`,{annual:a(i.annualTotal),monthly:a(i.monthly)})})]}),(0,o.jsx)(`ul`,{className:`grid gap-2 text-xs`,children:u.map(t=>(0,o.jsxs)(`li`,{className:`flex gap-2`,children:[(0,o.jsx)(r,{className:`mt-0.5 size-3 shrink-0 ${t===e?`text-primary`:`text-emerald-500/80`}`}),(0,o.jsxs)(`span`,{className:`grid gap-0.5`,children:[(0,o.jsx)(`span`,{className:t===e?`font-medium text-foreground`:`text-foreground/90`,children:l(`pro.features.${t}`)}),(0,o.jsx)(`span`,{className:`text-muted-foreground`,children:l(`pro.featureDetails.${t}`)})]})]},t))}),(0,o.jsx)(`a`,{ref:c,href:s,target:`_blank`,rel:`noreferrer`,className:`rounded-md bg-primary px-4 py-2 text-center text-sm font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:l(`pro.pricing`)})]})}export{c as t};
|