planche 0.9.4 → 0.9.6

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.
Files changed (82) hide show
  1. package/app/assets/{BVZGLNq_.js → -BrRFEsd.js} +1 -1
  2. package/app/assets/{7hKKrols.js → 0kBxoQTC.js} +1 -1
  3. package/app/assets/{Bjx1jzlk.js → 2T9lxo0j.js} +1 -1
  4. package/app/assets/{Dya0zxo6.js → 4Sc28RjY.js} +1 -1
  5. package/app/assets/{oXAkF219.js → 7H3wwOVq.js} +1 -1
  6. package/app/assets/{Ngd1VEiY.js → B-c9Bbn-.js} +1 -1
  7. package/app/assets/{BdhjYiGI.js → B0E81kOo.js} +1 -1
  8. package/app/assets/{BaTnCkNR.js → B2Zfb92y.js} +1 -1
  9. package/app/assets/{gvCOWBS0.js → B3XTjmoU.js} +1 -1
  10. package/app/assets/B44ZD3qB.js +1 -0
  11. package/app/assets/{CN1CF2CU.js → B6XenN2A.js} +1 -1
  12. package/app/assets/{BvkNY7SP.js → B8FE8vBX.js} +1 -1
  13. package/app/assets/{UJzcIbfW.js → BChuqxvg.js} +1 -1
  14. package/app/assets/{BTpuv2bS.js → BI62eGZp.js} +1 -1
  15. package/app/assets/{DjsycSVl.js → BJAxKOmG.js} +1 -1
  16. package/app/assets/{Cm-pfCIP.js → BJJw3SB5.js} +1 -1
  17. package/app/assets/{CDfygETm.js → BMDe5-Uv.js} +1 -1
  18. package/app/assets/{MeOkctzz.js → BZxviYfr.js} +1 -1
  19. package/app/assets/{CcaDuuFY.js → Bab8stSv.js} +1 -1
  20. package/app/assets/{CCJEQIo6.js → Bc5IXAIN.js} +1 -1
  21. package/app/assets/Bfg3uD4T.css +2 -0
  22. package/app/assets/{C-8Bh-gu.js → BgLjiapn.js} +1 -1
  23. package/app/assets/{BkujllIu.js → Bi01vkJ0.js} +1 -1
  24. package/app/assets/{62772Vyq.js → Bl1BkaRv.js} +1 -1
  25. package/app/assets/{C_qmv4pB.js → BlX_ty5A.js} +1 -1
  26. package/app/assets/{CGpFMM6B.js → Bt7l7S-A.js} +1 -1
  27. package/app/assets/{W81Xd8P5.js → Btah5WTi.js} +1 -1
  28. package/app/assets/{pDR31rvF.js → C6zXHuU2.js} +1 -1
  29. package/app/assets/{CH4cEkW4.js → C7Nv9Pjy.js} +1 -1
  30. package/app/assets/{u9a-WHjb.js → C7RCbZO-.js} +1 -1
  31. package/app/assets/{yfRSh-O-.js → C8cs68si.js} +1 -1
  32. package/app/assets/{_N3A-NTc.js → CCgoXW8B.js} +1 -1
  33. package/app/assets/{C82F2LSh.js → CFUqug8N.js} +1 -1
  34. package/app/assets/{CRYDH2ct.js → CLIa5Zav.js} +1 -1
  35. package/app/assets/{kTwcxyaO.js → CRlZzqQn.js} +1 -1
  36. package/app/assets/{DKObYbZY.js → C_PrLsEz.js} +1 -1
  37. package/app/assets/{D3VPMNTU.js → CaSbNoIz.js} +1 -1
  38. package/app/assets/{34iJa-68.js → CbZfSgjv.js} +1 -1
  39. package/app/assets/{DG0u2CPf.js → Cco5kfvu.js} +1 -1
  40. package/app/assets/{CZRhmV_L.js → CdhLxfdD.js} +2 -2
  41. package/app/assets/{2WcjYcT6.js → ChXl0ZSz.js} +1 -1
  42. package/app/assets/{D-DAzfgs.js → CiyWCtv6.js} +1 -1
  43. package/app/assets/{zdvaVsTo.js → Cm3uXWC-.js} +1 -1
  44. package/app/assets/{DXExbVos.js → CoR3wLxS.js} +1 -1
  45. package/app/assets/{D4DxtYTA.js → Cykx3CBw.js} +104 -104
  46. package/app/assets/{BI5Ig187.js → D03FsQo0.js} +1 -1
  47. package/app/assets/{CxaujQob.js → D34ytwl6.js} +1 -1
  48. package/app/assets/{IqMoIce-.js → D5jvnKzI.js} +1 -1
  49. package/app/assets/{Yn5aIyLX.js → D8__nlZs.js} +1 -1
  50. package/app/assets/{DT8Xdk78.js → D9CjRjHv.js} +1 -1
  51. package/app/assets/{2HDxyxt3.js → DDx1LRaR.js} +1 -1
  52. package/app/assets/{C1JbR1mO.js → DFM5Hmvq.js} +1 -1
  53. package/app/assets/{D4c1cZWk.js → DIL6_Ktc.js} +1 -1
  54. package/app/assets/{Cw4TnfXm.js → DOwJs576.js} +1 -1
  55. package/app/assets/{CtsakJNi.js → DQ6CDi_T.js} +1 -1
  56. package/app/assets/{BRKvj3qd.js → DVLsUPLR.js} +1 -1
  57. package/app/assets/{BHsv1P4D.js → DgbhC5QI.js} +1 -1
  58. package/app/assets/{DPKD37gk.js → Dqj9jTkq.js} +1 -1
  59. package/app/assets/{C3AWL5gC.js → DtRvUs3i.js} +1 -1
  60. package/app/assets/{CoUCmmSB.js → Dw7TfwlR.js} +1 -1
  61. package/app/assets/{NL8WOYEo.js → DxCkE8VP.js} +1 -1
  62. package/app/assets/DyMqorDP.js +1 -0
  63. package/app/assets/{BihjBM79.js → Dz-fZF1j.js} +1 -1
  64. package/app/assets/{DOy06rIE.js → HrKYroWS.js} +1 -1
  65. package/app/assets/{iz6RnRcO.js → NrVAX4Mt.js} +1 -1
  66. package/app/assets/{DXQPcWS6.js → O2uVOEYK.js} +1 -1
  67. package/app/assets/{BB2_KYgp.js → SD00AQlE.js} +1 -1
  68. package/app/assets/{yLCKuLgs.js → SqM4MUAZ.js} +1 -1
  69. package/app/assets/{C3aiaYZP.js → WvnnIt2x.js} +1 -1
  70. package/app/assets/{CKUISE0C.js → YJL2b-cO.js} +1 -1
  71. package/app/assets/{Buf-_p3w.js → iupVT1Sx.js} +1 -1
  72. package/app/assets/{BtBUwOf0.js → jfKIbXa5.js} +1 -1
  73. package/app/assets/{BWPrOT1U.js → jz2lP5X-.js} +1 -1
  74. package/app/assets/{C76CctEl.js → lXSI1SY-.js} +1 -1
  75. package/app/assets/{AR0v7sKO.js → lmacLN8z.js} +1 -1
  76. package/app/assets/{Cme0nCT7.js → uQNGLsg0.js} +2 -2
  77. package/app/assets/{CyX8oVsa.js → voJYJ5aN.js} +1 -1
  78. package/app/index.html +20 -20
  79. package/package.json +1 -1
  80. package/app/assets/92hmrkfN.css +0 -2
  81. package/app/assets/B5FoXN4H.js +0 -1
  82. package/app/assets/UEkRIZwQ.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{o as t,p as n}from"./CyX8oVsa.js";import{a as r,i,t as a,u as o}from"./Dya0zxo6.js";import{i as s,r as c}from"./C76CctEl.js";import{C as l,D as u,O as d,T as f,a as p,i as m,n as ee,o as h,t as g}from"./kTwcxyaO.js";import{a as _,i as v,n as y,r as b,t as x}from"./34iJa-68.js";import{r as S,t as C}from"./Nro86Y63.js";import{A as w,f as T,j as E,t as D,w as O}from"./iz6RnRcO.js";import{O as k,g as A,m as te,o as ne}from"./zdvaVsTo.js";import{n as j,t as re}from"./BihjBM79.js";import{n as ie}from"./C_qmv4pB.js";import{C as ae,_ as oe,f as M,i as se,r as ce,u as N}from"./BVZGLNq_.js";import{At as le,C as ue,H as de,Jt as fe,N as pe,P as me,S as P,T as F,a as he,an as I,b as ge,c as L,ct as _e,en as ve,i as ye,in as be,l as R,lt as xe,n as Se,nn as Ce,o as z,r as we,rn as Te,s as B,st as Ee,tn as V,u as H,vt as De,w as Oe,x as ke,z as Ae}from"./D4DxtYTA.js";import{t as U}from"./CnYBZPf9.js";var W=e(n(),1),G=c(),K=Object.defineProperty,q=(e,t)=>K(e,`name`,{value:t,configurable:!0}),je=`DropdownMenu`,[Me,Ne]=d(je,[I]),J=I(),[Pe,Fe]=Me(je),Ie=q(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=J(t),u=W.useRef(null),[d,p]=f({prop:i,defaultProp:a??!1,onChange:o,caller:je});return(0,G.jsx)(Pe,{scope:t,triggerId:l(),triggerRef:u,contentId:l(),open:d,onOpenChange:p,onOpenToggle:W.useCallback(()=>p(e=>!e),[p]),modal:s,children:(0,G.jsx)(be,{...c,open:d,onOpenChange:p,dir:r,modal:s,children:n})})},`DropdownMenu`),Le=`DropdownMenuTrigger`,Re=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=Fe(Le,n),c=J(n),l=o(t,s.triggerRef);return(0,G.jsx)(ve,{asChild:!0,...c,children:(0,G.jsx)(r.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:l,onPointerDown:u(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:u(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ze=q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=J(t);return(0,G.jsx)(Te,{...r,...n})},`DropdownMenuPortal`),Be=`DropdownMenuContent`,Ve=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Fe(Be,n),a=J(n),o=W.useRef(!1);return(0,G.jsx)(V,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:u(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:u(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),He=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=J(n);return(0,G.jsx)(Ce,{...i,...r,ref:t})},`DropdownMenuItem`)),Ue=Ie,We=Re,Ge=ze,Ke=Ve,qe=He,Je=new Set([`postgres:`,`postgresql:`]);function Ye(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!Je.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var Xe=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function Ze(e,t){let n;try{let t=new URL(e);if(!Xe.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var Qe=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],$e={enabled:!1,host:``,port:22,user:``,auth:`key`};function Y({label:e,htmlFor:t,children:n}){return(0,G.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,G.jsx)(L,{htmlFor:t,children:e}),n]})}function et({value:e,onChange:t}){let{t:n}=s();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){o([]);return}let e=new AbortController,t=setTimeout(()=>{Ze(c,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,d=l&&u===`browser`,f=C.has(e.dbms),p=e.dbms===`d1`,m=e.dbms===`do`,ee=w.find(t=>t.id===e.dbms)?.capabilities,h=e.ssh??$e,[g,T]=(0,W.useState)(``),D=g.trim()===``?`empty`:Ye(g)?`applied`:`invalid`,O=e.dbms===`supabase`&&e.port===6543;function k(n){T(n);let r=Ye(n);r&&t({...e,host:r.host??e.host,port:r.port??w.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function A(n){t({...e,ssh:{...h,...n}})}async function te(e){e&&A({privateKey:await e.text(),privateKeyName:e.name})}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,G.jsx)(Y,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,G.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.dataSource`),children:(0,G.jsxs)(x,{value:e.dbms,onValueChange:n=>{let r=w.find(e=>e.id===n);if(!r)return;let i=r.id,a=C.has(i)||i===`d1`||i===`do`;T(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||f||p||m||e.user===B(e.dbms)?B(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!m?e.database:z(i)??e.database})},children:[(0,G.jsx)(v,{id:`conn-dbms`,className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:w.map(e=>(0,G.jsx)(b,{value:e.id,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,G.jsx)(Y,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(R,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:g,onChange:e=>k(e.target.value)}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${D===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(D===`invalid`?`connection.form.connectionStringInvalid`:D===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),l&&(0,G.jsxs)(Y,{label:n(`connection.form.openVia`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),d?(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),children:(0,G.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{N(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,G.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,G.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,G.jsx)(Y,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,G.jsx)(R,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>r(`authToken`,e.target.value.trim())})}),d?null:m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,G.jsx)(R,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,G.jsx)(R,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,G.jsx)(Y,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,G.jsx)(R,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>r(`accountId`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,G.jsxs)(x,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,G.jsx)(v,{id:`conn-d1-database`,children:(0,G.jsx)(_,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,G.jsx)(y,{children:i.map(e=>(0,G.jsxs)(b,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,G.jsx)(R,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>r(`databaseId`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,G.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>r(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,G.jsx)(R,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>r(`host`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,G.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||w.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),O&&(0,G.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:n(`connection.form.supabasePoolerWarning`)}),z(e.dbms)!==void 0&&(0,G.jsx)(Y,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,G.jsx)(R,{id:`conn-database`,placeholder:z(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,G.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:B(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),(()=>{let t=E(e.dbms),r=`formHint`in t?t.formHint:void 0;return r?(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(r)}):null})(),!f&&e.dbms!==`oracle`&&(0,G.jsx)(Y,{label:n(`connection.form.tls`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>r(`ssl`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsEnable`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>r(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsVerify`)]})]})}),!f&&S(E(e.dbms))&&(0,G.jsx)(Y,{label:n(`connection.form.charset`),children:(0,G.jsxs)(x,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:Qe.map(e=>(0,G.jsx)(b,{value:e,children:e},e))})]})})]}),!l&&!f&&!p&&!m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[n(`connection.form.ssh`),(0,G.jsx)(de,{className:`ml-2`})]}),(0,G.jsx)(Y,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:h.enabled,onChange:e=>{(!e.target.checked||Ae(`ssh_tunnel`))&&A({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),h.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:h.host,onChange:e=>A({host:e.target.value.trim()})}),(0,G.jsx)(R,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:h.port,onChange:e=>A({port:Number(e.target.value)||22})})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,G.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:h.user,onChange:e=>A({user:e.target.value.trim()})})}),(0,G.jsx)(Y,{label:n(`connection.form.sshAuth`),children:(0,G.jsxs)(x,{value:h.auth,onValueChange:e=>A({auth:e}),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,G.jsx)(b,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,G.jsx)(b,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),h.auth===`password`&&(0,G.jsx)(Y,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,G.jsx)(R,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:h.password??``,onChange:e=>A({password:e.target.value})})}),h.auth===`key`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{te(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:h.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:h.privateKeyName,children:h.privateKey?h.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,G.jsx)(R,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:h.passphrase??``,onChange:e=>A({passphrase:e.target.value})})})]}),h.auth===`agent`&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,G.jsx)(Y,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:(0,G.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>r(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,G.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,G.jsx)(Y,{label:n(`connection.form.environment`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[pe.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,G.jsx)(`button`,{type:`button`,title:me(t.id),"aria-label":me(t.id),"aria-pressed":n,onClick:()=>r(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${n?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,G.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>r(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,G.jsx)(Y,{label:n(`connection.form.transactions`),children:(0,G.jsxs)(x,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,G.jsx)(b,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var tt=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function nt(e){return!e.sample&&!e.scratchpad}function rt(e,t,n=new Date){let r=t?e:O(e),i={...r};for(let e of tt)delete i[e];if(i.pass||delete i.pass,i.authToken||delete i.authToken,r.ssh){let e={...r.ssh};for(let t of[`password`,`passphrase`,`privateKey`])e[t]||delete e[t];i.ssh=e}return{planche:`connection`,version:1,exportedAt:n.toISOString(),secrets:t,connection:i}}function it(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Not a JSON file`)}let n=t;if(!n||n.planche!==`connection`||!n.connection||typeof n.connection!=`object`)throw Error(`Not a Planche connection file`);if(typeof n.connection.dbms!=`string`||!n.connection.dbms)throw Error(`The connection has no database type`);return n}var X=(e,t=``)=>typeof e==`string`?e:t,Z=e=>typeof e==`boolean`?e:void 0,at=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Q=e=>e===void 0||e===``?void 0:e;function ot(e){if(!e||typeof e!=`object`)return;let t=e,n=t.auth===`key`||t.auth===`agent`?t.auth:`password`;return{enabled:t.enabled===!0,host:X(t.host),port:at(t.port,22),user:X(t.user),auth:n,password:Q(X(t.password)),privateKey:Q(X(t.privateKey)),privateKeyName:Q(X(t.privateKeyName)),passphrase:Q(X(t.passphrase))}}function st(e,t,n=crypto.randomUUID()){let r=e.connection,i=Z(r.savePassword),a={id:n,hostName:ct(X(r.hostName),t),host:X(r.host),user:X(r.user),pass:X(r.pass),charset:X(r.charset,`utf8`),port:at(r.port,0),dbms:r.dbms,database:Q(X(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:Q(X(r.file)),createIfMissing:Z(r.createIfMissing),ssl:Z(r.ssl),sslVerify:Z(r.sslVerify),accountId:Q(X(r.accountId)),databaseId:Q(X(r.databaseId)),devUrl:Q(X(r.devUrl)),ssh:ot(r.ssh),gatewayProfile:Q(X(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:X(r.authToken),readOnly:Z(r.readOnly),environmentColor:Q(X(r.environmentColor)),transactionMode:Q(X(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function ct(e,t){if(!e||!t.some(t=>t.hostName===e))return e;for(let n=2;;n++){let r=`${e} (${n})`;if(!t.some(e=>e.hostName===r))return r}}async function lt(e,t,n=`application/json`){let r=U(e);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:r,types:[{accept:{[n]:[`.${r.split(`.`).pop()??`txt`}`]}}]})).createWritable();return await e.write(t),await e.close(),!0}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return!1}let i=URL.createObjectURL(new Blob([t],{type:n})),a=document.createElement(`a`);return a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),!0}function ut(e=`.json,application/json`){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.onchange=async()=>{let e=n.files?.[0];t(e?await e.text():null)},n.oncancel=()=>t(null),n.click()})}function dt({...e}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu`,...e})}function ft({...e}){return(0,G.jsx)(We,{"data-slot":`dropdown-menu-trigger`,...e})}function pt({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(Ge,{children:(0,G.jsx)(Ke,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:i(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 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`,e),...n})})}function mt({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(qe,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:i(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function $(e,n,r){let i=_e(r);return t(`connection_error`,{action:e,dbms:n,reason:i}),Ee(i)}function ht(){let{t:e}=s(),{activeDialog:t,closeDialog:n,showMessage:r}=j(),[i,o]=(0,W.useState)(!1),{savedConnections:c,addSavedConnection:l,updateSavedConnection:u,deleteSavedConnection:d,openConnection:f}=D(),_=re(`connect`)?.profileId,[v,y]=(0,W.useState)(()=>_??null),[b,x]=(0,W.useState)(()=>{let e=_?c.find(e=>e.id===_):void 0;return e?{...e}:null}),S=t===`connect`,[C,w]=(0,W.useState)(null),[O,N]=(0,W.useState)(null),de=xe(e=>e.url),pe=xe(e=>e.token);(0,W.useEffect)(()=>{if(!S)return;let e=!1;return(async()=>{try{let t=await ne();if(e||t.state!==`online`||!t.gateway){e||w(null);return}let n=await te();e||(w({name:n.gateway,profiles:n.profiles}),N(null))}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[S,de,pe]);function me(t){let n=c.find(e=>e.gatewayProfile===t.name);if(n){L(n);return}let r=we(t);l(r),L(r),j.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function I(e){e||(n(),y(null),x(null))}function L(e){y(e.id),x({...e})}function _e(e){x(e),u(e.id,e)}function ve(){let e=he();l(e),y(e.id),x(e)}function be(){v&&(d(v),y(null),x(null))}async function R(t){let n=c.find(e=>e.id===v);if(!n||!nt(n))return;let r=n.hostName||e(`connection.dialog.unnamed`),i=rt(D.getState().resolveCredentials(n),t);await lt(`planche-connection-${r}.json`,JSON.stringify(i,null,2))&&j.getState().setFooterMessage(e(`connection.dialog.exported`,{name:r}))}async function Ce(){let t=await ut();if(t!==null)try{let n=st(it(t),D.getState().savedConnections);l(n),y(n.id),x(n),j.getState().setFooterMessage(e(`connection.dialog.imported`,{name:n.hostName||e(`connection.dialog.unnamed`)}))}catch(t){r({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let z=v!==null&&c.some(e=>e.id===v&&nt(e)),[Te,B]=(0,W.useState)(!1),Ee=ie(e=>e.addQueryTab);function V(t){let r=D.getState().activeConnections.some(e=>e.id===t.id);if(f(t),ae.getState().removeTree(t.id),T(t.id),r){n(),y(null),x(null);return}Ee(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),n(),y(null),x(null)}async function Ae(t){let n=await ce(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};u(t.id,{file:n.fileName}),V(r),D.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?j.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?j.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&j.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function U(t,n){try{return await n(t)}catch(r){let i=A(r);if(!i||!(`ssh`in t)||!t.ssh||!await j.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function K(){if(b){B(!0);try{if(M(b)===`browser`){await Ae(b);return}let t=await U(k(b),e=>se(e,b.authToken||void 0));if(t.success)V({...b,serverConnectionId:t.connectionId});else{let n=$(`connect`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`connect`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{B(!1)}}}async function q(){if(b){if(M(b)===`browser`){r({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}o(!0);try{let t=await U(k(b),e=>oe(e,b.authToken||void 0));if(t.success)r({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)});else{let n=$(`test`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`test`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{o(!1)}}}return(0,G.jsx)(g,{open:S,onOpenChange:I,children:(0,G.jsxs)(ee,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,G.jsx)(p,{children:(0,G.jsx)(h,{children:e(`connection.dialog.title`)})}),(0,G.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,G.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,G.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(C||O)&&(0,G.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,G.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),C?` — ${C.name}`:``]}),O&&(0,G.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:O})}),C?.profiles.map(t=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,G.jsx)(H,{dbms:Se[t.driver],className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:t.name}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,G.jsx)(a,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>me(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,G.jsx)(De,{className:`h-full`,children:(0,G.jsxs)(ge,{className:`table-fixed`,children:[(0,G.jsx)(Oe,{children:(0,G.jsxs)(F,{children:[(0,G.jsx)(ue,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,G.jsx)(ue,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,G.jsx)(ue,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,G.jsx)(ke,{children:c.length===0?(0,G.jsx)(F,{children:(0,G.jsx)(P,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):c.map(t=>(0,G.jsxs)(F,{"data-state":v===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>L(t),onDoubleClick:()=>{L(t),K()},children:[(0,G.jsx)(P,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,G.jsx)(P,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(M(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`}),(0,G.jsx)(P,{className:`truncate`,title:E(t.dbms).label,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:E(t.dbms).label})]})})]},t.id))})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:b?(0,G.jsxs)(G.Fragment,{children:[M(b)!==`browser`&&(0,G.jsx)(`div`,{className:`p-4 pb-0`,children:(0,G.jsx)(ye,{})}),b.gatewayProfile?(0,G.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:b.dbms,className:`size-4`}),b.hostName]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:b.gatewayProfile})}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[b.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),b.database?` · ${b.database}`:``]})]}):(0,G.jsx)(et,{value:b,onChange:_e})]}):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,G.jsxs)(m,{className:`sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:ve,children:e(`connection.dialog.addNew`)}),(0,G.jsx)(a,{variant:`destructive`,onClick:be,disabled:!v,children:e(`connection.dialog.delete`)}),(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(a,{variant:`outline`,disabled:!z,children:[e(`connection.dialog.export`),(0,G.jsx)(fe,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,G.jsxs)(pt,{align:`start`,children:[(0,G.jsx)(mt,{onSelect:()=>void R(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,G.jsx)(mt,{onSelect:()=>void R(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>void Ce(),children:e(`connection.dialog.import`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:q,disabled:!b||i,children:e(`connection.dialog.testConnection`)}),(0,G.jsx)(a,{onClick:K,disabled:!b||Te,children:e(`connection.dialog.connect`)}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>I(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{ht as ConnectDialog};
1
+ import{r as e}from"./hePW80VL.js";import{o as t,p as n}from"./voJYJ5aN.js";import{a as r,i,t as a,u as o}from"./4Sc28RjY.js";import{i as s,r as c}from"./lXSI1SY-.js";import{C as l,D as u,O as d,T as f,a as p,i as m,n as ee,o as h,t as g}from"./CRlZzqQn.js";import{a as _,i as v,n as y,r as b,t as x}from"./CbZfSgjv.js";import{r as S,t as C}from"./Nro86Y63.js";import{A as w,f as T,j as E,t as D,w as O}from"./NrVAX4Mt.js";import{O as k,g as A,m as te,o as ne}from"./Cm3uXWC-.js";import{n as j,t as re}from"./Dz-fZF1j.js";import{n as ie}from"./BlX_ty5A.js";import{C as ae,_ as oe,f as M,i as se,r as ce,u as N}from"./-BrRFEsd.js";import{At as le,C as ue,H as de,Jt as fe,N as pe,P as me,S as P,T as F,a as he,an as I,b as ge,c as L,ct as _e,en as ve,i as ye,in as be,l as R,lt as xe,n as Se,nn as Ce,o as z,r as we,rn as Te,s as B,st as Ee,tn as V,u as H,vt as De,w as Oe,x as ke,z as Ae}from"./Cykx3CBw.js";import{t as U}from"./CnYBZPf9.js";var W=e(n(),1),G=c(),K=Object.defineProperty,q=(e,t)=>K(e,`name`,{value:t,configurable:!0}),je=`DropdownMenu`,[Me,Ne]=d(je,[I]),J=I(),[Pe,Fe]=Me(je),Ie=q(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=J(t),u=W.useRef(null),[d,p]=f({prop:i,defaultProp:a??!1,onChange:o,caller:je});return(0,G.jsx)(Pe,{scope:t,triggerId:l(),triggerRef:u,contentId:l(),open:d,onOpenChange:p,onOpenToggle:W.useCallback(()=>p(e=>!e),[p]),modal:s,children:(0,G.jsx)(be,{...c,open:d,onOpenChange:p,dir:r,modal:s,children:n})})},`DropdownMenu`),Le=`DropdownMenuTrigger`,Re=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,disabled:i=!1,...a}=e,s=Fe(Le,n),c=J(n),l=o(t,s.triggerRef);return(0,G.jsx)(ve,{asChild:!0,...c,children:(0,G.jsx)(r.button,{type:`button`,id:s.triggerId,"aria-haspopup":`menu`,"aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?`open`:`closed`,"data-disabled":i?``:void 0,disabled:i,...a,ref:l,onPointerDown:u(e.onPointerDown,e=>{!i&&e.button===0&&e.ctrlKey===!1&&(s.onOpenToggle(),s.open||e.preventDefault())}),onKeyDown:u(e.onKeyDown,e=>{i||([`Enter`,` `].includes(e.key)&&s.onOpenToggle(),e.key===`ArrowDown`&&s.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),ze=q(e=>{let{__scopeDropdownMenu:t,...n}=e,r=J(t);return(0,G.jsx)(Te,{...r,...n})},`DropdownMenuPortal`),Be=`DropdownMenuContent`,Ve=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Fe(Be,n),a=J(n),o=W.useRef(!1);return(0,G.jsx)(V,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:u(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:u(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),He=W.forwardRef(q(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=J(n);return(0,G.jsx)(Ce,{...i,...r,ref:t})},`DropdownMenuItem`)),Ue=Ie,We=Re,Ge=ze,Ke=Ve,qe=He,Je=new Set([`postgres:`,`postgresql:`]);function Ye(e){let t=e.trim().replace(/^psql\s+(['"])?/,``).replace(/['"]$/,``);if(!/^postgres(ql)?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}if(!Je.has(n.protocol.toLowerCase())||!n.hostname)return null;let r=e=>{try{return decodeURIComponent(e)}catch{return e}},i={host:n.hostname};n.port&&(i.port=Number(n.port)),n.username&&(i.user=r(n.username)),n.password&&(i.pass=r(n.password));let a=r(n.pathname.replace(/^\//,``));return a&&(i.database=a),i}var Xe=new Set([`localhost`,`127.0.0.1`,`[::1]`,`::1`,`0.0.0.0`]);async function Ze(e,t){let n;try{let t=new URL(e);if(!Xe.has(t.hostname.toLowerCase()))return[];n=t.origin}catch{return[]}try{let e=await fetch(`${n}/cdn-cgi/local/explorer/api/d1/database`,{signal:t});if(!e.ok)return[];let r=await e.json(),i=new Map;for(let e of r.result??[])e.uuid&&i.set(e.uuid,{name:e.name??e.uuid,id:e.uuid});return[...i.values()]}catch{return[]}}var Qe=[`utf8`,`utf8mb4`,`latin1`,`ascii`,`euckr`,`sjis`,`big5`],$e={enabled:!1,host:``,port:22,user:``,auth:`key`};function Y({label:e,htmlFor:t,children:n}){return(0,G.jsxs)(`div`,{className:`grid grid-cols-[120px_minmax(0,1fr)] items-center gap-2`,children:[(0,G.jsx)(L,{htmlFor:t,children:e}),n]})}function et({value:e,onChange:t}){let{t:n}=s();function r(n,r){t({...e,[n]:r})}let[i,o]=(0,W.useState)([]),c=e.dbms===`d1`?e.devUrl??``:``;(0,W.useEffect)(()=>{if(!c){o([]);return}let e=new AbortController,t=setTimeout(()=>{Ze(c,e.signal).then(o)},300);return()=>{clearTimeout(t),e.abort()}},[c]);let l=e.dbms===`sqlite`,u=e.transport??`browser`,d=l&&u===`browser`,f=C.has(e.dbms),p=e.dbms===`d1`,m=e.dbms===`do`,ee=w.find(t=>t.id===e.dbms)?.capabilities,h=e.ssh??$e,[g,T]=(0,W.useState)(``),D=g.trim()===``?`empty`:Ye(g)?`applied`:`invalid`,O=e.dbms===`supabase`&&e.port===6543;function k(n){T(n);let r=Ye(n);r&&t({...e,host:r.host??e.host,port:r.port??w.find(t=>t.id===e.dbms)?.defaultPort??e.port,user:r.user??e.user,pass:r.pass??e.pass,database:r.database??e.database})}function A(n){t({...e,ssh:{...h,...n}})}async function te(e){e&&A({privateKey:await e.text(),privateKeyName:e.name})}return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 p-4`,children:[(0,G.jsx)(Y,{label:n(`connection.form.hostName`),htmlFor:`conn-hostName`,children:(0,G.jsx)(R,{id:`conn-hostName`,placeholder:n(`connection.form.hostNamePlaceholder`),value:e.hostName,onChange:e=>r(`hostName`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.dataSource`),children:(0,G.jsxs)(x,{value:e.dbms,onValueChange:n=>{let r=w.find(e=>e.id===n);if(!r)return;let i=r.id,a=C.has(i)||i===`d1`||i===`do`;T(``),t({...e,dbms:i,transactionMode:r.capabilities.transactions?e.transactionMode:`auto`,port:r.defaultPort??e.port,host:a&&e.host===`localhost`?``:!a&&e.host===``?`localhost`:e.host,user:a||f||p||m||e.user===B(e.dbms)?B(i):e.user,devUrl:i===`do`?e.devUrl||`http://localhost:8787`:e.devUrl,database:e.database&&!a&&!f&&!p&&!m?e.database:z(i)??e.database})},children:[(0,G.jsx)(v,{id:`conn-dbms`,className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:w.map(e=>(0,G.jsx)(b,{value:e.id,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:e.id}),e.label]})},e.id))})]})}),f&&(0,G.jsx)(Y,{label:n(`connection.form.connectionString`),htmlFor:`conn-uri`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(R,{id:`conn-uri`,type:`password`,autoComplete:`new-password`,spellCheck:!1,className:`font-mono text-xs`,placeholder:e.dbms===`neon`?`postgresql://neondb_owner:npg_…@ep-….neon.tech/neondb?sslmode=require`:`postgresql://postgres.[ref]:[password]@aws-0-….pooler.supabase.com:5432/postgres`,value:g,onChange:e=>k(e.target.value)}),(0,G.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed ${D===`invalid`?`text-destructive`:`text-muted-foreground`}`,children:n(D===`invalid`?`connection.form.connectionStringInvalid`:D===`applied`?`connection.form.connectionStringApplied`:e.dbms===`neon`?`connection.form.neonHint`:`connection.form.supabaseHint`)})]})}),l&&(0,G.jsxs)(Y,{label:n(`connection.form.openVia`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`browser`,checked:u===`browser`,onChange:()=>r(`transport`,`browser`),className:`accent-primary`}),n(`connection.form.viaBrowser`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`radio`,name:`transport`,value:`tunnel`,checked:u===`tunnel`,onChange:()=>r(`transport`,`tunnel`),className:`accent-primary`}),n(`connection.form.viaAgent`)]})]}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(u===`browser`?`connection.form.viaBrowserHint`:`connection.form.viaAgentHint`)})]}),d?(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),children:(0,G.jsxs)(`div`,{className:`min-w-0 text-xs text-muted-foreground leading-relaxed`,children:[e.file?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`min-w-0 break-all text-foreground`,title:e.file,children:e.file}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-6 shrink-0 px-2 text-xs`,onClick:()=>{N(e.id),r(`file`,``)},children:n(`connection.form.changeFile`)})]}):(0,G.jsx)(`p`,{children:n(`connection.form.filePickerHint`)}),(0,G.jsx)(`p`,{className:`mt-1`,children:n(`connection.form.fileRememberedHint`)})]})}):null,!d&&(0,G.jsx)(Y,{label:n(`connection.form.authToken`),htmlFor:`conn-authToken`,children:(0,G.jsx)(R,{id:`conn-authToken`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.authTokenPlaceholder`),value:e.authToken,onChange:e=>r(`authToken`,e.target.value.trim())})}),d?null:m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.doDevUrl`),htmlFor:`conn-do-url`,children:(0,G.jsx)(R,{id:`conn-do-url`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doHint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.doLimitsHint`)})]}):p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.d1DevUrl`),htmlFor:`conn-d1-dev`,children:(0,G.jsx)(R,{id:`conn-d1-dev`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`http://localhost:8787`,value:e.devUrl??``,onChange:e=>r(`devUrl`,e.target.value.trim())})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1DevUrlHint`)}),(0,G.jsx)(Y,{label:n(`connection.form.d1AccountId`),htmlFor:`conn-d1-account`,children:(0,G.jsx)(R,{id:`conn-d1-account`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:e.accountId??``,onChange:e=>r(`accountId`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.d1DatabaseId`),htmlFor:`conn-d1-database`,children:i.length>0?(0,G.jsxs)(x,{value:e.databaseId??``,onValueChange:e=>r(`databaseId`,e),children:[(0,G.jsx)(v,{id:`conn-d1-database`,children:(0,G.jsx)(_,{placeholder:n(`connection.form.d1PickDatabase`)})}),(0,G.jsx)(y,{children:i.map(e=>(0,G.jsxs)(b,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]}):(0,G.jsx)(R,{id:`conn-d1-database`,autoComplete:`off`,className:`font-mono text-xs`,spellCheck:!1,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:e.databaseId??``,onChange:e=>r(`databaseId`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.d1ApiToken`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value.trim())}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1Hint`)}),(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.d1LimitsHint`)})]}):l?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.databaseFile`),htmlFor:`conn-file`,children:(0,G.jsx)(R,{id:`conn-file`,placeholder:n(`connection.form.filePathPlaceholder`),value:e.file??``,onChange:e=>r(`file`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.createIfMissing`),htmlFor:`conn-create`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-create`,type:`checkbox`,checked:e.createIfMissing??!1,onChange:e=>r(`createIfMissing`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.createIfMissingHint`)})]})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.host`),htmlFor:`conn-host`,children:(0,G.jsx)(R,{id:`conn-host`,placeholder:e.dbms===`neon`?`ep-….aws.neon.tech`:e.dbms===`supabase`?`aws-0-….pooler.supabase.com`:`localhost`,value:e.host,onChange:e=>r(`host`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.port`),htmlFor:`conn-port`,children:(0,G.jsx)(R,{id:`conn-port`,type:`number`,value:e.port,onChange:t=>r(`port`,Number(t.target.value)||w.find(t=>t.id===e.dbms)?.defaultPort||3306)})}),O&&(0,G.jsx)(`p`,{className:`col-start-2 rounded-md border border-yellow-500/40 bg-yellow-500/10 px-2 py-1.5 text-xs leading-relaxed text-foreground`,children:n(`connection.form.supabasePoolerWarning`)}),z(e.dbms)!==void 0&&(0,G.jsx)(Y,{label:e.dbms===`oracle`?n(`connection.form.serviceName`):n(`connection.form.database`),htmlFor:`conn-database`,children:(0,G.jsx)(R,{id:`conn-database`,placeholder:z(e.dbms),value:e.database??``,onChange:e=>r(`database`,e.target.value.trim())})}),(0,G.jsx)(Y,{label:n(`connection.form.user`),htmlFor:`conn-user`,children:(0,G.jsx)(R,{id:`conn-user`,autoComplete:`off`,placeholder:B(e.dbms),value:e.user,onChange:e=>r(`user`,e.target.value)})}),(0,G.jsx)(Y,{label:n(`connection.form.password`),htmlFor:`conn-pass`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(R,{id:`conn-pass`,type:`password`,autoComplete:`new-password`,value:e.pass,onChange:e=>r(`pass`,e.target.value)}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs whitespace-nowrap cursor-pointer`,title:n(`connection.form.savePasswordHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.savePassword??!0,onChange:e=>r(`savePassword`,e.target.checked)}),n(`connection.form.savePassword`)]})]})}),f&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.managedTlsHint`)}),(()=>{let t=E(e.dbms),r=`formHint`in t?t.formHint:void 0;return r?(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(r)}):null})(),!f&&e.dbms!==`oracle`&&(0,G.jsx)(Y,{label:n(`connection.form.tls`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:e.ssl??!1,onChange:e=>r(`ssl`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsEnable`)]}),(0,G.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs cursor-pointer ${e.ssl?``:`opacity-50`}`,title:n(`connection.form.tlsVerifyHint`),children:[(0,G.jsx)(`input`,{type:`checkbox`,disabled:!e.ssl,checked:e.sslVerify??!1,onChange:e=>r(`sslVerify`,e.target.checked),className:`size-4 accent-primary`}),n(`connection.form.tlsVerify`)]})]})}),!f&&S(E(e.dbms))&&(0,G.jsx)(Y,{label:n(`connection.form.charset`),children:(0,G.jsxs)(x,{value:e.charset,onValueChange:e=>r(`charset`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsx)(y,{children:Qe.map(e=>(0,G.jsx)(b,{value:e,children:e},e))})]})})]}),!l&&!f&&!p&&!m&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mt-1 flex items-center border-t pt-3 text-xs font-medium text-muted-foreground`,children:[n(`connection.form.ssh`),(0,G.jsx)(de,{className:`ml-2`})]}),(0,G.jsx)(Y,{label:n(`connection.form.sshTunnel`),htmlFor:`conn-ssh`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh`,type:`checkbox`,checked:h.enabled,onChange:e=>{(!e.target.checked||Ae(`ssh_tunnel`))&&A({enabled:e.target.checked})},className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.sshTunnelHint`)})]})}),h.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshHost`),htmlFor:`conn-ssh-host`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{id:`conn-ssh-host`,placeholder:n(`connection.form.sshHostPlaceholder`),value:h.host,onChange:e=>A({host:e.target.value.trim()})}),(0,G.jsx)(R,{"aria-label":n(`connection.form.sshPort`),type:`number`,className:`w-24 shrink-0`,value:h.port,onChange:e=>A({port:Number(e.target.value)||22})})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshUser`),htmlFor:`conn-ssh-user`,children:(0,G.jsx)(R,{id:`conn-ssh-user`,placeholder:n(`connection.form.sshUserPlaceholder`),value:h.user,onChange:e=>A({user:e.target.value.trim()})})}),(0,G.jsx)(Y,{label:n(`connection.form.sshAuth`),children:(0,G.jsxs)(x,{value:h.auth,onValueChange:e=>A({auth:e}),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`key`,children:n(`connection.form.sshAuthKey`)}),(0,G.jsx)(b,{value:`password`,children:n(`connection.form.sshAuthPassword`)}),(0,G.jsx)(b,{value:`agent`,children:n(`connection.form.sshAuthAgent`)})]})]})}),h.auth===`password`&&(0,G.jsx)(Y,{label:n(`connection.form.sshPassword`),htmlFor:`conn-ssh-pass`,children:(0,G.jsx)(R,{id:`conn-ssh-pass`,type:`password`,autoComplete:`new-password`,value:h.password??``,onChange:e=>A({password:e.target.value})})}),h.auth===`key`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Y,{label:n(`connection.form.sshKey`),htmlFor:`conn-ssh-key`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-ssh-key`,type:`file`,className:`hidden`,onChange:e=>{te(e.target.files?.[0]),e.target.value=``}}),(0,G.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 shrink-0 px-2 text-xs`,onClick:()=>document.getElementById(`conn-ssh-key`)?.click(),children:h.privateKey?n(`connection.form.changeFile`):n(`connection.form.sshKeyPick`)}),(0,G.jsx)(`span`,{className:`min-w-0 truncate text-xs text-muted-foreground`,title:h.privateKeyName,children:h.privateKey?h.privateKeyName||n(`connection.form.sshKeyLoaded`):n(`connection.form.sshKeyHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.sshPassphrase`),htmlFor:`conn-ssh-passphrase`,children:(0,G.jsx)(R,{id:`conn-ssh-passphrase`,type:`password`,autoComplete:`new-password`,placeholder:n(`connection.form.sshPassphrasePlaceholder`),value:h.passphrase??``,onChange:e=>A({passphrase:e.target.value})})})]}),h.auth===`agent`&&(0,G.jsx)(`p`,{className:`col-start-2 text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshAuthAgentHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshTargetHint`)}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:n(`connection.form.sshSecretsHint`)})]})]}),(0,G.jsx)(Y,{label:n(`connection.form.autoConnection`),htmlFor:`conn-auto`,children:(0,G.jsx)(`div`,{className:`flex items-center`,children:(0,G.jsx)(`input`,{id:`conn-auto`,type:`checkbox`,checked:e.autoConnection,onChange:e=>r(`autoConnection`,e.target.checked),className:`size-4 accent-primary cursor-pointer`})})}),(0,G.jsx)(`div`,{className:`mt-1 border-t pt-3 text-xs font-medium text-muted-foreground`,children:n(`connection.form.safety`)}),(0,G.jsx)(Y,{label:n(`connection.form.environment`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[pe.map(t=>{let n=(e.environmentColor??`none`)===t.id;return(0,G.jsx)(`button`,{type:`button`,title:me(t.id),"aria-label":me(t.id),"aria-pressed":n,onClick:()=>r(`environmentColor`,t.id),className:`size-6 rounded-full border-2 transition-transform ${n?`scale-110 border-foreground`:`border-transparent hover:scale-105`}`,style:{background:t.id===`none`?`repeating-linear-gradient(45deg, transparent, transparent 3px, var(--muted-foreground) 3px, var(--muted-foreground) 4px)`:t.hex}},t.id)}),(0,G.jsx)(`span`,{className:`ml-1 text-xs text-muted-foreground`,children:n(`connection.form.environmentHint`)})]})}),(0,G.jsx)(Y,{label:n(`connection.form.readOnly`),htmlFor:`conn-readonly`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{id:`conn-readonly`,type:`checkbox`,checked:e.readOnly??!1,onChange:e=>r(`readOnly`,e.target.checked),className:`size-4 accent-primary cursor-pointer`}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`connection.form.readOnlyHint`)})]})}),ee?.transactions!==!1&&(0,G.jsx)(Y,{label:n(`connection.form.transactions`),children:(0,G.jsxs)(x,{value:e.transactionMode??`auto`,onValueChange:e=>r(`transactionMode`,e),children:[(0,G.jsx)(v,{className:`w-full`,children:(0,G.jsx)(_,{})}),(0,G.jsxs)(y,{children:[(0,G.jsx)(b,{value:`auto`,children:n(`connection.form.txAuto`)}),(0,G.jsx)(b,{value:`manual`,children:n(`connection.form.txManual`)})]})]})})]})}var tt=[`id`,`serverConnectionId`,`sample`,`scratchpad`,`autoConnection`];function nt(e){return!e.sample&&!e.scratchpad}function rt(e,t,n=new Date){let r=t?e:O(e),i={...r};for(let e of tt)delete i[e];if(i.pass||delete i.pass,i.authToken||delete i.authToken,r.ssh){let e={...r.ssh};for(let t of[`password`,`passphrase`,`privateKey`])e[t]||delete e[t];i.ssh=e}return{planche:`connection`,version:1,exportedAt:n.toISOString(),secrets:t,connection:i}}function it(e){let t;try{t=JSON.parse(e)}catch{throw Error(`Not a JSON file`)}let n=t;if(!n||n.planche!==`connection`||!n.connection||typeof n.connection!=`object`)throw Error(`Not a Planche connection file`);if(typeof n.connection.dbms!=`string`||!n.connection.dbms)throw Error(`The connection has no database type`);return n}var X=(e,t=``)=>typeof e==`string`?e:t,Z=e=>typeof e==`boolean`?e:void 0,at=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:t,Q=e=>e===void 0||e===``?void 0:e;function ot(e){if(!e||typeof e!=`object`)return;let t=e,n=t.auth===`key`||t.auth===`agent`?t.auth:`password`;return{enabled:t.enabled===!0,host:X(t.host),port:at(t.port,22),user:X(t.user),auth:n,password:Q(X(t.password)),privateKey:Q(X(t.privateKey)),privateKeyName:Q(X(t.privateKeyName)),passphrase:Q(X(t.passphrase))}}function st(e,t,n=crypto.randomUUID()){let r=e.connection,i=Z(r.savePassword),a={id:n,hostName:ct(X(r.hostName),t),host:X(r.host),user:X(r.user),pass:X(r.pass),charset:X(r.charset,`utf8`),port:at(r.port,0),dbms:r.dbms,database:Q(X(r.database)),transport:r.transport===`tunnel`||r.transport===`browser`?r.transport:void 0,file:Q(X(r.file)),createIfMissing:Z(r.createIfMissing),ssl:Z(r.ssl),sslVerify:Z(r.sslVerify),accountId:Q(X(r.accountId)),databaseId:Q(X(r.databaseId)),devUrl:Q(X(r.devUrl)),ssh:ot(r.ssh),gatewayProfile:Q(X(r.gatewayProfile)),autoConnection:!1,savePassword:i??!0,authToken:X(r.authToken),readOnly:Z(r.readOnly),environmentColor:Q(X(r.environmentColor)),transactionMode:Q(X(r.transactionMode))};for(let e of Object.keys(a))a[e]===void 0&&delete a[e];return a}function ct(e,t){if(!e||!t.some(t=>t.hostName===e))return e;for(let n=2;;n++){let r=`${e} (${n})`;if(!t.some(e=>e.hostName===r))return r}}async function lt(e,t,n=`application/json`){let r=U(e);if(typeof window.showSaveFilePicker==`function`)try{let e=await(await window.showSaveFilePicker({suggestedName:r,types:[{accept:{[n]:[`.${r.split(`.`).pop()??`txt`}`]}}]})).createWritable();return await e.write(t),await e.close(),!0}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return!1}let i=URL.createObjectURL(new Blob([t],{type:n})),a=document.createElement(`a`);return a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),!0}function ut(e=`.json,application/json`){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.onchange=async()=>{let e=n.files?.[0];t(e?await e.text():null)},n.oncancel=()=>t(null),n.click()})}function dt({...e}){return(0,G.jsx)(Ue,{"data-slot":`dropdown-menu`,...e})}function ft({...e}){return(0,G.jsx)(We,{"data-slot":`dropdown-menu-trigger`,...e})}function pt({className:e,sideOffset:t=4,...n}){return(0,G.jsx)(Ge,{children:(0,G.jsx)(Ke,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:i(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 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`,e),...n})})}function mt({className:e,inset:t,variant:n=`default`,...r}){return(0,G.jsx)(qe,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:i(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function $(e,n,r){let i=_e(r);return t(`connection_error`,{action:e,dbms:n,reason:i}),Ee(i)}function ht(){let{t:e}=s(),{activeDialog:t,closeDialog:n,showMessage:r}=j(),[i,o]=(0,W.useState)(!1),{savedConnections:c,addSavedConnection:l,updateSavedConnection:u,deleteSavedConnection:d,openConnection:f}=D(),_=re(`connect`)?.profileId,[v,y]=(0,W.useState)(()=>_??null),[b,x]=(0,W.useState)(()=>{let e=_?c.find(e=>e.id===_):void 0;return e?{...e}:null}),S=t===`connect`,[C,w]=(0,W.useState)(null),[O,N]=(0,W.useState)(null),de=xe(e=>e.url),pe=xe(e=>e.token);(0,W.useEffect)(()=>{if(!S)return;let e=!1;return(async()=>{try{let t=await ne();if(e||t.state!==`online`||!t.gateway){e||w(null);return}let n=await te();e||(w({name:n.gateway,profiles:n.profiles}),N(null))}catch(t){e||N(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[S,de,pe]);function me(t){let n=c.find(e=>e.gatewayProfile===t.name);if(n){L(n);return}let r=we(t);l(r),L(r),j.getState().setFooterMessage(e(`connection.dialog.gatewayAdded`,{name:t.name}))}function I(e){e||(n(),y(null),x(null))}function L(e){y(e.id),x({...e})}function _e(e){x(e),u(e.id,e)}function ve(){let e=he();l(e),y(e.id),x(e)}function be(){v&&(d(v),y(null),x(null))}async function R(t){let n=c.find(e=>e.id===v);if(!n||!nt(n))return;let r=n.hostName||e(`connection.dialog.unnamed`),i=rt(D.getState().resolveCredentials(n),t);await lt(`planche-connection-${r}.json`,JSON.stringify(i,null,2))&&j.getState().setFooterMessage(e(`connection.dialog.exported`,{name:r}))}async function Ce(){let t=await ut();if(t!==null)try{let n=st(it(t),D.getState().savedConnections);l(n),y(n.id),x(n),j.getState().setFooterMessage(e(`connection.dialog.imported`,{name:n.hostName||e(`connection.dialog.unnamed`)}))}catch(t){r({tone:`error`,title:e(`connection.dialog.importFailedTitle`),description:t instanceof Error?t.message:String(t)})}}let z=v!==null&&c.some(e=>e.id===v&&nt(e)),[Te,B]=(0,W.useState)(!1),Ee=ie(e=>e.addQueryTab);function V(t){let r=D.getState().activeConnections.some(e=>e.id===t.id);if(f(t),ae.getState().removeTree(t.id),T(t.id),r){n(),y(null),x(null);return}Ee(t.id,{id:`tab-${Date.now()}`,title:e(`connection.dialog.firstQueryTab`),query:``,database:``,isExecuting:!1,results:[],error:null,executionTime:null}),n(),y(null),x(null)}async function Ae(t){let n=await ce(t.id,{interactive:!0});if(!n)return;let r={...t,file:n.fileName,serverConnectionId:n.connectionId};u(t.id,{file:n.fileName}),V(r),D.getState().setFileDetached(t.id,n.fileDetached),n.restoredUnsaved?j.getState().setFooterMessage(e(n.diskChanged?`connection.dialog.restoredUnsavedDiskChanged`:`connection.dialog.restoredUnsaved`,{file:n.fileName})):n.wal&&!n.walApplied?j.getState().setFooterMessage(e(`connection.dialog.walPending`,{file:n.fileName})):n.walApplied&&j.getState().setFooterMessage(e(`connection.dialog.walApplied`,{file:n.fileName}))}async function U(t,n){try{return await n(t)}catch(r){let i=A(r);if(!i||!(`ssh`in t)||!t.ssh||!await j.getState().requestDestructiveConfirm({title:e(`connection.dialog.hostKeyTitle`),description:e(`connection.dialog.hostKeyDescription`,i),confirmLabel:e(`connection.dialog.hostKeyAccept`)}))throw r;return n({...t,ssh:{...t.ssh,acceptHostKey:i.fingerprint}})}}async function K(){if(b){B(!0);try{if(M(b)===`browser`){await Ae(b);return}let t=await U(k(b),e=>se(e,b.authToken||void 0));if(t.success)V({...b,serverConnectionId:t.connectionId});else{let n=$(`connect`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`connect`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.connectFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{B(!1)}}}async function q(){if(b){if(M(b)===`browser`){r({tone:`info`,title:e(`connection.dialog.testConnection`),description:e(`connection.dialog.browserTestHint`)});return}o(!0);try{let t=await U(k(b),e=>oe(e,b.authToken||void 0));if(t.success)r({tone:`success`,title:e(`connection.dialog.testSuccess`),description:e(`connection.dialog.testSuccessDescription`)});else{let n=$(`test`,b.dbms,Error(t.message??``));r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t.message??e(`connection.dialog.unknownError`),...n})}}catch(t){let n=$(`test`,b.dbms,t);r({tone:`error`,title:e(`connection.dialog.testFailedTitle`),description:t instanceof Error?t.message:String(t),...n})}finally{o(!1)}}}return(0,G.jsx)(g,{open:S,onOpenChange:I,children:(0,G.jsxs)(ee,{className:`sm:max-w-[1100px] h-[85vh] max-h-[85vh] flex flex-col`,children:[(0,G.jsx)(p,{children:(0,G.jsx)(h,{children:e(`connection.dialog.title`)})}),(0,G.jsxs)(`p`,{className:`flex items-start gap-2 rounded-md border border-catppuccin-green/40 bg-catppuccin-green/10 px-3 py-2 text-xs leading-relaxed text-foreground`,children:[(0,G.jsx)(le,{className:`mt-0.5 size-4 shrink-0 text-catppuccin-green`,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:e(`connection.dialog.privacy`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-1 gap-4 overflow-hidden min-h-0`,children:[(0,G.jsxs)(`div`,{className:`w-[460px] shrink-0 border rounded-md overflow-hidden flex flex-col`,children:[(C||O)&&(0,G.jsxs)(`div`,{className:`border-b p-2 text-xs space-y-1 max-h-40 overflow-auto`,children:[(0,G.jsxs)(`p`,{className:`font-medium`,children:[e(`connection.dialog.gatewayTitle`),C?` — ${C.name}`:``]}),O&&(0,G.jsx)(`p`,{className:`text-destructive`,children:e(`connection.dialog.gatewayLoadFailed`,{error:O})}),C?.profiles.map(t=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 truncate`,children:[(0,G.jsx)(H,{dbms:Se[t.driver],className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:t.name}),(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,t.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),`)`]})]}),(0,G.jsx)(a,{size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>me(t),children:e(`connection.dialog.gatewayAdd`)})]},t.name))]}),(0,G.jsx)(De,{className:`h-full`,children:(0,G.jsxs)(ge,{className:`table-fixed`,children:[(0,G.jsx)(Oe,{children:(0,G.jsxs)(F,{children:[(0,G.jsx)(ue,{className:`w-[32%]`,children:e(`connection.dialog.colHostName`)}),(0,G.jsx)(ue,{className:`w-[40%]`,children:e(`connection.dialog.colTarget`)}),(0,G.jsx)(ue,{className:`w-[28%]`,children:e(`connection.dialog.colDbms`)})]})}),(0,G.jsx)(ke,{children:c.length===0?(0,G.jsx)(F,{children:(0,G.jsx)(P,{colSpan:3,className:`text-center text-muted-foreground`,children:e(`connection.dialog.noSaved`)})}):c.map(t=>(0,G.jsxs)(F,{"data-state":v===t.id?`selected`:void 0,className:`cursor-pointer`,onClick:()=>L(t),onDoubleClick:()=>{L(t),K()},children:[(0,G.jsx)(P,{className:`truncate font-medium`,title:t.hostName,children:t.hostName||e(`connection.dialog.unnamed`)}),(0,G.jsx)(P,{className:`truncate`,title:t.dbms===`sqlite`?t.file:t.dbms===`d1`?t.databaseId:t.dbms===`do`?t.devUrl:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`,children:t.dbms===`sqlite`?t.file||(M(t)===`browser`?e(`connection.dialog.pickOnConnect`):e(`connection.dialog.noFile`)):t.dbms===`d1`?t.databaseId||`—`:t.dbms===`do`?t.devUrl||`—`:`${t.user?`${t.user}@`:``}${t.host}:${t.port}`}),(0,G.jsx)(P,{className:`truncate`,title:E(t.dbms).label,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(H,{dbms:t.dbms,className:`size-3.5`}),(0,G.jsx)(`span`,{className:`truncate`,children:E(t.dbms).label})]})})]},t.id))})]})})]}),(0,G.jsx)(`div`,{className:`flex-1 border rounded-md overflow-auto`,children:b?(0,G.jsxs)(G.Fragment,{children:[M(b)!==`browser`&&(0,G.jsx)(`div`,{className:`p-4 pb-0`,children:(0,G.jsx)(ye,{})}),b.gatewayProfile?(0,G.jsxs)(`div`,{className:`p-4 space-y-2 text-sm`,children:[(0,G.jsxs)(`p`,{className:`font-medium flex items-center gap-2`,children:[(0,G.jsx)(H,{dbms:b.dbms,className:`size-4`}),b.hostName]}),(0,G.jsx)(`p`,{className:`text-muted-foreground`,children:e(`connection.dialog.gatewayProfileHint`,{name:b.gatewayProfile})}),(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[b.readOnly?e(`connection.dialog.gatewayReadOnly`):e(`connection.dialog.gatewayWritable`),b.database?` · ${b.database}`:``]})]}):(0,G.jsx)(et,{value:b,onChange:_e})]}):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground text-sm`,children:e(`connection.dialog.selectPrompt`)})})]}),(0,G.jsxs)(m,{className:`sm:justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:ve,children:e(`connection.dialog.addNew`)}),(0,G.jsx)(a,{variant:`destructive`,onClick:be,disabled:!v,children:e(`connection.dialog.delete`)}),(0,G.jsxs)(dt,{children:[(0,G.jsx)(ft,{asChild:!0,children:(0,G.jsxs)(a,{variant:`outline`,disabled:!z,children:[e(`connection.dialog.export`),(0,G.jsx)(fe,{className:`ml-1 size-3.5`,"aria-hidden":!0})]})}),(0,G.jsxs)(pt,{align:`start`,children:[(0,G.jsx)(mt,{onSelect:()=>void R(!1),children:e(`connection.dialog.exportWithoutSecrets`)}),(0,G.jsx)(mt,{onSelect:()=>void R(!0),children:e(`connection.dialog.exportWithSecrets`)})]})]}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>void Ce(),children:e(`connection.dialog.import`)})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(a,{variant:`outline`,onClick:q,disabled:!b||i,children:e(`connection.dialog.testConnection`)}),(0,G.jsx)(a,{onClick:K,disabled:!b||Te,children:e(`connection.dialog.connect`)}),(0,G.jsx)(a,{variant:`outline`,onClick:()=>I(!1),children:e(`connection.dialog.close`)})]})]})]})})}export{ht as ConnectDialog};
@@ -1 +1 @@
1
- import{t as e}from"./Dya0zxo6.js";import{i as t,r as n}from"./C76CctEl.js";import{a as r,i,n as a,o,r as s,t as c}from"./kTwcxyaO.js";import{n as l}from"./BihjBM79.js";import{Y as u,t as d}from"./D4DxtYTA.js";var f=n(),p=`https://planche.dev`,m=`/third-party-notices.txt`;function h(){let n=l(e=>e.activeDialog),h=l(e=>e.closeDialog),{t:g}=t();return(0,f.jsx)(c,{open:n===`about`,onOpenChange:e=>{e||h()},children:(0,f.jsxs)(a,{className:`sm:max-w-[440px]`,children:[(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,f.jsx)(d,{size:44,className:`shrink-0`}),(0,f.jsxs)(`div`,{className:`grid gap-1`,children:[(0,f.jsx)(o,{children:g(`about.title`)}),(0,f.jsx)(s,{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.9.3`}),(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:u.terms,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.terms`)}),(0,f.jsx)(`a`,{href:u.privacy,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.privacy`)}),(0,f.jsx)(`a`,{href:u.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)(i,{children:(0,f.jsx)(e,{onClick:h,children:g(`settings.done`)})})]})})}export{h as AboutDialog};
1
+ import{t as e}from"./4Sc28RjY.js";import{i as t,r as n}from"./lXSI1SY-.js";import{a as r,i,n as a,o,r as s,t as c}from"./CRlZzqQn.js";import{n as l}from"./Dz-fZF1j.js";import{Y as u,t as d}from"./Cykx3CBw.js";var f=n(),p=`https://planche.dev`,m=`/third-party-notices.txt`;function h(){let n=l(e=>e.activeDialog),h=l(e=>e.closeDialog),{t:g}=t();return(0,f.jsx)(c,{open:n===`about`,onOpenChange:e=>{e||h()},children:(0,f.jsxs)(a,{className:`sm:max-w-[440px]`,children:[(0,f.jsx)(r,{children:(0,f.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,f.jsx)(d,{size:44,className:`shrink-0`}),(0,f.jsxs)(`div`,{className:`grid gap-1`,children:[(0,f.jsx)(o,{children:g(`about.title`)}),(0,f.jsx)(s,{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.9.6`}),(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:u.terms,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.terms`)}),(0,f.jsx)(`a`,{href:u.privacy,target:`_blank`,rel:`noreferrer`,className:`underline underline-offset-2`,children:g(`about.privacy`)}),(0,f.jsx)(`a`,{href:u.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)(i,{children:(0,f.jsx)(e,{onClick:h,children:g(`settings.done`)})})]})})}export{h as AboutDialog};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{t as n}from"./Dya0zxo6.js";import{i as r,r as i}from"./C76CctEl.js";import{a,i as o,n as s,o as c,t as l}from"./kTwcxyaO.js";import{t as u}from"./iz6RnRcO.js";import{n as d,t as f}from"./BihjBM79.js";import{a as p}from"./BVZGLNq_.js";import{r as m}from"./CH4cEkW4.js";import{a as h,h as g}from"./CZRhmV_L.js";import{K as _,c as v,l as y,q as b}from"./D4DxtYTA.js";var x=e(t(),1),S=i();function C(){let{t:e}=r(),{activeDialog:t,closeDialog:i}=d(),C=f(`copy-database`),w=t===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(i(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=u.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=m(t),i=u.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await h(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=p(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await _(a,s);await b({source:a,target:s,mode:O,onConflict:`abort`,createSql:m(t).ddl.createTable(c)})}await g(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(l,{open:w,onOpenChange:P,children:(0,S.jsxs)(s,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(a,{children:(0,S.jsx)(c,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{children:e(`database.copy.source`)}),(0,S.jsx)(y,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(y,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(o,{children:[(0,S.jsx)(n,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(n,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
1
+ import{r as e}from"./hePW80VL.js";import{p as t}from"./voJYJ5aN.js";import{t as n}from"./4Sc28RjY.js";import{i as r,r as i}from"./lXSI1SY-.js";import{a,i as o,n as s,o as c,t as l}from"./CRlZzqQn.js";import{t as u}from"./NrVAX4Mt.js";import{n as d,t as f}from"./Dz-fZF1j.js";import{a as p}from"./-BrRFEsd.js";import{r as m}from"./C7Nv9Pjy.js";import{a as h,h as g}from"./CdhLxfdD.js";import{K as _,c as v,l as y,q as b}from"./Cykx3CBw.js";var x=e(t(),1),S=i();function C(){let{t:e}=r(),{activeDialog:t,closeDialog:i}=d(),C=f(`copy-database`),w=t===`copy-database`,T=C?.database??``,[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(`structure_data`),[A,j]=(0,x.useState)(null),[M,N]=(0,x.useState)(null);function P(e){e||(i(),N(null),j(null),D(``),k(`structure_data`))}async function F(){let t=u.getState().activeConnectionId,n=E.trim();if(!t||!n||!T)return;N(null);let r=m(t),i=u.getState().activeConnections.find(e=>e.id===t);if(i?.serverConnectionId)try{j(e(`database.copy.creating`,{database:n})),await h(t,r.getQuery(`CREATE_DATABASE`,n,`utf8mb4`,`utf8mb4_general_ci`));let a=p(i.serverConnectionId),o=await r.introspect.listTables(a,T);for(let[r,i]of o.entries()){j(e(`database.copy.copying`,{table:i.name,index:r+1,total:o.length}));let a={connectionId:t,database:T,table:i.name},s={connectionId:t,database:n,table:i.name},c=await _(a,s);await b({source:a,target:s,mode:O,onConflict:`abort`,createSql:m(t).ddl.createTable(c)})}await g(t),P(!1)}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(null)}}return(0,S.jsx)(l,{open:w,onOpenChange:P,children:(0,S.jsxs)(s,{className:`sm:max-w-[450px]`,children:[(0,S.jsx)(a,{children:(0,S.jsx)(c,{children:e(`database.copy.title`)})}),(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{children:e(`database.copy.source`)}),(0,S.jsx)(y,{value:T,disabled:!0})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{htmlFor:`target-db-name`,children:e(`database.copy.target`)}),(0,S.jsx)(y,{id:`target-db-name`,value:E,onChange:e=>D(e.target.value),placeholder:e(`database.copy.targetPlaceholder`)})]}),(0,S.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,S.jsx)(v,{children:e(`database.copy.options`)}),(0,S.jsxs)(`div`,{className:`space-y-2`,children:[(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_data`,checked:O===`structure_data`,onChange:()=>k(`structure_data`)}),e(`database.copy.structureAndData`)]}),(0,S.jsxs)(`label`,{className:`flex items-center gap-2 text-sm cursor-pointer`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`copy-option`,value:`structure_only`,checked:O===`structure_only`,onChange:()=>k(`structure_only`)}),e(`database.copy.structureOnly`)]})]})]})]}),A&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:A}),M&&(0,S.jsx)(`p`,{className:`px-1 text-xs text-destructive leading-relaxed`,children:M}),(0,S.jsxs)(o,{children:[(0,S.jsx)(n,{variant:`outline`,onClick:()=>P(!1),children:e(`database.copy.cancel`)}),(0,S.jsx)(n,{onClick:()=>void F(),disabled:!E.trim()||A!==null,children:e(`database.copy.copy`)})]})]})})}export{C as CopyDatabaseDialog};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{a as n,d as r,i,o as a,s as o,t as s,u as c}from"./Dya0zxo6.js";import{r as l,t as u}from"./C76CctEl.js";var d=e(t(),1),f=l(),p=Object.defineProperty,m=(e,t)=>p(e,`name`,{value:t,configurable:!0});function h(e,t){let n=d.createContext(t);n.displayName=e+`Context`;let r=m(e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=d.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return m(i,`useContext`),[r,i]}m(h,`createContext`);function g(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=m(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=d.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return m(s,`useContext`),[o,s]}m(r,`createContext`);let i=m(()=>{let t=n.map(e=>d.createContext(e));return m(function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,_(i,...t)]}m(g,`createContextScope`);function _(...e){let t=e[0];if(e.length===1)return t;let n=m(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return m(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}m(_,`composeContextScopes`);var v=Object.defineProperty,y=(e,t)=>v(e,`name`,{value:t,configurable:!0}),b=!!(typeof window<`u`&&window.document&&window.document.createElement);function x(e,t,{checkForDefaultPrevented:n=!0}={}){return y(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}y(x,`composeEventHandlers`);function ee(e){if(!b)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}y(ee,`getOwnerWindow`);function S(e){if(!b)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}y(S,`getOwnerDocument`);function C(e,t=!1){let{activeElement:n}=S(e);if(!n?.nodeName)return null;if(te(n)&&n.contentDocument)return C(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=S(n).getElementById(e);if(t)return t}}return n}y(C,`getActiveElement`);function te(e){return e.tagName===`IFRAME`}y(te,`isFrame`);var w=globalThis?.document?d.useLayoutEffect:()=>{},ne=Object.defineProperty,re=(e,t)=>ne(e,`name`,{value:t,configurable:!0}),T=d.useEffectEvent,E=d.useInsertionEffect;function D(e){if(typeof T==`function`)return T(e);let t=d.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof E==`function`?E(()=>{t.current=e}):w(()=>{t.current=e}),d.useMemo(()=>((...e)=>t.current?.(...e)),[])}re(D,`useEffectEvent`);var ie=Object.defineProperty,O=(e,t)=>ie(e,`name`,{value:t,configurable:!0}),ae=d.useInsertionEffect||w;function oe({prop:e,defaultProp:t,onChange:n=O(()=>{},`onChange`),caller:r}){let[i,a,o]=se({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,d.useCallback(t=>{if(s){let n=ce(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}O(oe,`useControllableState`);function se({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return ae(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}O(se,`useUncontrolledState`);function ce(e){return typeof e==`function`}O(ce,`isFunction`);var le=Symbol(`RADIX:SYNC_STATE`);function ue(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=D(o),u=[{...n,state:a}];r&&u.push(r);let[f,p]=d.useReducer((t,n)=>{if(n.type===le)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),m=f.state,h=d.useRef(m);d.useEffect(()=>{h.current!==m&&(h.current=m,c||l(m))},[m,h,c]);let g=d.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:le,state:i})},[i,f.state,c]),[g,p]}O(ue,`useControllableStateReducer`);var de=e(r(),1),fe=Object.defineProperty,k=(e,t)=>fe(e,`name`,{value:t,configurable:!0});function pe(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}k(pe,`useStateMachine`);var A=k(e=>{let{present:t,children:n}=e,r=me(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=ge(r.ref,_e(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null},`Presence`);function me(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),o=d.useRef(void 0),[s,c]=pe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{s===`mounted`?(a.current=o.current??j(r.current),o.current=void 0):a.current=`none`},[s]),w(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=j(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),w(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=k(a=>{let o=j(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=k(e=>{e.target===t&&(a.current=j(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:d.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=j(t)}else r.current=null;n(e)},[])}}k(me,`usePresence`);function he(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}k(he,`setRef`);function ge(...e){let t=d.useRef(e);return t.current=e,d.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=he(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():he(n[e],null)}}},[])}k(ge,`useStableComposedRefs`);function j(e){return e?.animationName||`none`}k(j,`getAnimationName`);function _e(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}k(_e,`getElementRef`);var ve=Object.defineProperty,ye=(e,t)=>ve(e,`name`,{value:t,configurable:!0}),be=d.useId||(()=>void 0),xe=0;function M(e){let[t,n]=d.useState(be());return w(()=>{e||n(e=>e??String(xe++))},[e]),e||(t?`radix-${t}`:``)}ye(M,`useId`);var Se=Object.defineProperty,Ce=(e,t)=>Se(e,`name`,{value:t,configurable:!0});function N(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ce(N,`useCallbackRef`);var we=Object.defineProperty,P=(e,t)=>we(e,`name`,{value:t,configurable:!0}),Te=`dismissableLayer.update`,Ee=`dismissableLayer.pointerDownOutside`,De=`dismissableLayer.focusOutside`,Oe,ke=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ae=d.forwardRef(P(function(e,t){let{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...p}=e,m=d.useContext(ke),[h,g]=d.useState(null),_=h?.ownerDocument??globalThis?.document,[,v]=d.useState({}),y=c(t,g),b=Array.from(m.layers),[ee]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),S=ee?b.indexOf(ee):-1,C=h?b.indexOf(h):-1,te=m.layersWithOutsidePointerEventsDisabled.size>0,w=C>=S,ne=d.useRef(!1),re=Ne(e=>{o?.(e),l?.(e),e.defaultPrevented||u?.()},{ownerDocument:_,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:ne,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...m.branches].some(t=>t.contains(e));return w&&!t},[m.branches,w])}),T=Pe(e=>{if(i&&ne.current)return;let t=e.target;[...m.branches].some(e=>e.contains(t))||(s?.(e),l?.(e),e.defaultPrevented||u?.())},_),E=h?C===b.length-1:!1,D=N(e=>{e.key===`Escape`&&(a?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))});return d.useEffect(()=>{if(E)return _.addEventListener(`keydown`,D,{capture:!0}),()=>_.removeEventListener(`keydown`,D,{capture:!0})},[_,E,D]),d.useEffect(()=>{if(h)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(Oe=_.body.style.pointerEvents,_.body.style.pointerEvents=`none`),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),Fe(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(h),m.layersWithOutsidePointerEventsDisabled.size===0&&(_.body.style.pointerEvents=Oe))}},[h,_,r,m]),d.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),Fe())},[h,m]),d.useEffect(()=>{let e=P(()=>v({}),`handleUpdate`);return document.addEventListener(Te,e),()=>document.removeEventListener(Te,e)},[]),(0,f.jsx)(n.div,{...p,ref:y,style:{pointerEvents:te?w?`auto`:`none`:void 0,...e.style},onFocusCapture:x(e.onFocusCapture,T.onFocusCapture),onBlurCapture:x(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:x(e.onPointerDownCapture,re.onPointerDownCapture)})},`DismissableLayer`));function je(){let e=d.useContext(ke),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}P(je,`useDismissableLayerSurface`);var Me=P(()=>!0,`IS_TRUE`);function Ne(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Me}=t,s=N(e),c=d.useRef(!1),l=d.useRef(!1),u=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}P(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}P(t,`isOutsideInteractionIntercepted`);function d(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&f.current()},0)}P(d,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}P(p,`handleInteractionBubble`);let m=P(a=>{if(a.target&&!c.current){let d=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||Ie(Ee,s,p,{discrete:!0})};if(P(d,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?d():(n.removeEventListener(`click`,f.current),f.current=d,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,d,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,f.current);for(let e of h)n.removeEventListener(e,d,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:P(()=>c.current=!0,`onPointerDownCapture`)}}P(Ne,`usePointerDownOutside`);function Pe(e,t=globalThis?.document){let n=N(e),r=d.useRef(!1);return d.useEffect(()=>{let e=P(e=>{e.target&&!r.current&&Ie(De,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:P(()=>r.current=!0,`onFocusCapture`),onBlurCapture:P(()=>r.current=!1,`onBlurCapture`)}}P(Pe,`useFocusOutside`);function Fe(){let e=new CustomEvent(Te);document.dispatchEvent(e)}P(Fe,`dispatchUpdate`);function Ie(e,t,n,{discrete:r}){let i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?a(i,o):i.dispatchEvent(o)}P(Ie,`handleAndDispatchCustomEvent`);var Le=Object.defineProperty,F=(e,t)=>Le(e,`name`,{value:t,configurable:!0}),Re=`focusScope.autoFocusOnMount`,ze=`focusScope.autoFocusOnUnmount`,Be={bubbles:!1,cancelable:!0},Ve=d.forwardRef(F(function(e,t){let{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[l,u]=d.useState(null),p=N(a),m=N(o),h=d.useRef(null),g=c(t,u),_=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let e=function(e){if(_.paused||!l)return;let t=e.target;l.contains(t)?h.current=t:I(h.current,{select:!0})},t=function(e){if(_.paused||!l)return;let t=e.relatedTarget;t!==null&&(l.contains(t)||I(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&I(l)};F(e,`handleFocusIn`),F(t,`handleFocusOut`),F(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[i,l,_.paused]),d.useEffect(()=>{if(l){Je.add(_);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(Re,Be);l.addEventListener(Re,p),l.dispatchEvent(t),t.defaultPrevented||(He(Ze(We(l)),{select:!0}),document.activeElement===e&&I(l))}return()=>{l.removeEventListener(Re,p),setTimeout(()=>{let t=new CustomEvent(ze,Be);l.addEventListener(ze,m),l.dispatchEvent(t),t.defaultPrevented||I(e??document.body,{select:!0}),l.removeEventListener(ze,m),Je.remove(_)},0)}}},[l,p,m,_]);let v=d.useCallback(e=>{if(!r&&!i||_.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){let t=e.currentTarget,[i,a]=Ue(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&I(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&I(a,{select:!0})):n===t&&e.preventDefault()}},[r,i,_.paused]);return(0,f.jsx)(n.div,{tabIndex:-1,...s,ref:g,onKeyDown:v})},`FocusScope`));function He(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(I(r,{select:t}),document.activeElement!==n)return}F(He,`focusFirst`);function Ue(e){let t=We(e);return[Ge(t,e),Ge(t.reverse(),e)]}F(Ue,`getTabbableEdges`);function We(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:F(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}F(We,`getTabbableCandidates`);function Ge(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Ke(r,{upTo:t})))return r}F(Ge,`findVisible`);function Ke(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}F(Ke,`isHidden`);function qe(e){return e instanceof HTMLInputElement&&`select`in e}F(qe,`isSelectableInput`);function I(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&qe(e)&&t&&e.select()}}F(I,`focus`);var Je=Ye();function Ye(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Xe(e,t),e.unshift(t)},remove(t){e=Xe(e,t),e[0]?.resume()}}}F(Ye,`createFocusScopesStack`);function Xe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}F(Xe,`arrayRemove`);function Ze(e){return e.filter(e=>e.tagName!==`A`)}F(Ze,`removeLinks`);var Qe=Object.defineProperty,$e=d.forwardRef(((e,t)=>Qe(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:r,...i}=e,[a,o]=d.useState(!1);w(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?de.createPortal((0,f.jsx)(n.div,{...i,ref:t}),s):null},`Portal`)),et=Object.defineProperty,tt=(e,t)=>et(e,`name`,{value:t,configurable:!0}),L=0,R=null;function nt(e){return z(),e.children}tt(nt,`FocusGuards`);function z(){d.useEffect(()=>{R||={start:rt(),end:rt()};let{start:e,end:t}=R;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),L++,()=>{L===1&&(R?.start.remove(),R?.end.remove(),R=null),L=Math.max(0,L-1)}},[])}tt(z,`useFocusGuards`);function rt(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}tt(rt,`createFocusGuard`);var B=function(){return B=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},B.apply(this,arguments)};function it(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function at(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var V=`right-scroll-bar-position`,H=`width-before-scroll-bar`,ot=`with-scroll-bars-hidden`,st=`--removed-body-scroll-bar-size`;function ct(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function lt(e,t){var n=(0,d.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ut=typeof window<`u`?d.useLayoutEffect:d.useEffect,dt=new WeakMap;function ft(e,t){var n=lt(t||null,function(t){return e.forEach(function(e){return ct(e,t)})});return ut(function(){var t=dt.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ct(e,null)}),i.forEach(function(e){r.has(e)||ct(e,a)})}dt.set(n,e)},[e]),n}function pt(e){return e}function mt(e,t){t===void 0&&(t=pt);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ht(e){e===void 0&&(e={});var t=mt(null);return t.options=B({async:!0,ssr:!1},e),t}var gt=function(e){var t=e.sideCar,n=it(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return d.createElement(r,B({},n))};gt.isSideCarExport=!0;function _t(e,t){return e.useMedium(t),gt}var vt=ht(),yt=function(){},U=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:yt,onWheelCapture:yt,onTouchMoveCapture:yt}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=it(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),ee=p,S=ft([n,t]),C=B(B({},x),i);return d.createElement(d.Fragment,null,u&&d.createElement(ee,{sideCar:vt,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?d.cloneElement(d.Children.only(s),B(B({},C),{ref:S})):d.createElement(y,B({},C,{className:c,ref:S}),s))});U.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},U.classNames={fullWidth:H,zeroRight:V};var bt=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function xt(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=bt();return t&&e.setAttribute(`nonce`,t),e}function St(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ct(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var wt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=xt())&&(St(t,n),Ct(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Tt=function(){var e=wt();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Et=function(){var e=Tt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Dt={left:0,top:0,right:0,gap:0},Ot=function(e){return parseInt(e||``,10)||0},kt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ot(n),Ot(r),Ot(i)]},At=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Dt;var t=kt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},jt=Et(),W=`data-scroll-locked`,Mt=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
1
+ import{r as e}from"./hePW80VL.js";import{p as t}from"./voJYJ5aN.js";import{a as n,d as r,i,o as a,s as o,t as s,u as c}from"./4Sc28RjY.js";import{r as l,t as u}from"./lXSI1SY-.js";var d=e(t(),1),f=l(),p=Object.defineProperty,m=(e,t)=>p(e,`name`,{value:t,configurable:!0});function h(e,t){let n=d.createContext(t);n.displayName=e+`Context`;let r=m(e=>{let{children:t,...r}=e,i=d.useMemo(()=>r,Object.values(r));return(0,f.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=d.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return m(i,`useContext`),[r,i]}m(h,`createContext`);function g(e,t=[]){let n=[];function r(t,r){let i=d.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=m(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=d.useMemo(()=>o,Object.values(o));return(0,f.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=d.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return m(s,`useContext`),[o,s]}m(r,`createContext`);let i=m(()=>{let t=n.map(e=>d.createContext(e));return m(function(n){let r=n?.[e]||t;return d.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,_(i,...t)]}m(g,`createContextScope`);function _(...e){let t=e[0];if(e.length===1)return t;let n=m(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return m(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return d.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}m(_,`composeContextScopes`);var v=Object.defineProperty,y=(e,t)=>v(e,`name`,{value:t,configurable:!0}),b=!!(typeof window<`u`&&window.document&&window.document.createElement);function x(e,t,{checkForDefaultPrevented:n=!0}={}){return y(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}y(x,`composeEventHandlers`);function ee(e){if(!b)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}y(ee,`getOwnerWindow`);function S(e){if(!b)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}y(S,`getOwnerDocument`);function C(e,t=!1){let{activeElement:n}=S(e);if(!n?.nodeName)return null;if(te(n)&&n.contentDocument)return C(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=S(n).getElementById(e);if(t)return t}}return n}y(C,`getActiveElement`);function te(e){return e.tagName===`IFRAME`}y(te,`isFrame`);var w=globalThis?.document?d.useLayoutEffect:()=>{},ne=Object.defineProperty,re=(e,t)=>ne(e,`name`,{value:t,configurable:!0}),T=d.useEffectEvent,E=d.useInsertionEffect;function D(e){if(typeof T==`function`)return T(e);let t=d.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof E==`function`?E(()=>{t.current=e}):w(()=>{t.current=e}),d.useMemo(()=>((...e)=>t.current?.(...e)),[])}re(D,`useEffectEvent`);var ie=Object.defineProperty,O=(e,t)=>ie(e,`name`,{value:t,configurable:!0}),ae=d.useInsertionEffect||w;function oe({prop:e,defaultProp:t,onChange:n=O(()=>{},`onChange`),caller:r}){let[i,a,o]=se({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,d.useCallback(t=>{if(s){let n=ce(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}O(oe,`useControllableState`);function se({defaultProp:e,onChange:t}){let[n,r]=d.useState(e),i=d.useRef(n),a=d.useRef(t);return ae(()=>{a.current=t},[t]),d.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}O(se,`useUncontrolledState`);function ce(e){return typeof e==`function`}O(ce,`isFunction`);var le=Symbol(`RADIX:SYNC_STATE`);function ue(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=D(o),u=[{...n,state:a}];r&&u.push(r);let[f,p]=d.useReducer((t,n)=>{if(n.type===le)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),m=f.state,h=d.useRef(m);d.useEffect(()=>{h.current!==m&&(h.current=m,c||l(m))},[m,h,c]);let g=d.useMemo(()=>i===void 0?f:{...f,state:i},[f,i]);return d.useEffect(()=>{c&&!Object.is(i,f.state)&&p({type:le,state:i})},[i,f.state,c]),[g,p]}O(ue,`useControllableStateReducer`);var de=e(r(),1),fe=Object.defineProperty,k=(e,t)=>fe(e,`name`,{value:t,configurable:!0});function pe(e,t){return d.useReducer((e,n)=>t[e][n]??e,e)}k(pe,`useStateMachine`);var A=k(e=>{let{present:t,children:n}=e,r=me(t),i=typeof n==`function`?n({present:r.isPresent}):d.Children.only(n),a=ge(r.ref,_e(i));return typeof n==`function`||r.isPresent?d.cloneElement(i,{ref:a}):null},`Presence`);function me(e){let[t,n]=d.useState(),r=d.useRef(null),i=d.useRef(e),a=d.useRef(`none`),o=d.useRef(void 0),[s,c]=pe(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return d.useEffect(()=>{s===`mounted`?(a.current=o.current??j(r.current),o.current=void 0):a.current=`none`},[s]),w(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=j(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),w(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=k(a=>{let o=j(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=k(e=>{e.target===t&&(a.current=j(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:d.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=j(t)}else r.current=null;n(e)},[])}}k(me,`usePresence`);function he(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}k(he,`setRef`);function ge(...e){let t=d.useRef(e);return t.current=e,d.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=he(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():he(n[e],null)}}},[])}k(ge,`useStableComposedRefs`);function j(e){return e?.animationName||`none`}k(j,`getAnimationName`);function _e(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}k(_e,`getElementRef`);var ve=Object.defineProperty,ye=(e,t)=>ve(e,`name`,{value:t,configurable:!0}),be=d.useId||(()=>void 0),xe=0;function M(e){let[t,n]=d.useState(be());return w(()=>{e||n(e=>e??String(xe++))},[e]),e||(t?`radix-${t}`:``)}ye(M,`useId`);var Se=Object.defineProperty,Ce=(e,t)=>Se(e,`name`,{value:t,configurable:!0});function N(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ce(N,`useCallbackRef`);var we=Object.defineProperty,P=(e,t)=>we(e,`name`,{value:t,configurable:!0}),Te=`dismissableLayer.update`,Ee=`dismissableLayer.pointerDownOutside`,De=`dismissableLayer.focusOutside`,Oe,ke=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Ae=d.forwardRef(P(function(e,t){let{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:l,onDismiss:u,...p}=e,m=d.useContext(ke),[h,g]=d.useState(null),_=h?.ownerDocument??globalThis?.document,[,v]=d.useState({}),y=c(t,g),b=Array.from(m.layers),[ee]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),S=ee?b.indexOf(ee):-1,C=h?b.indexOf(h):-1,te=m.layersWithOutsidePointerEventsDisabled.size>0,w=C>=S,ne=d.useRef(!1),re=Ne(e=>{o?.(e),l?.(e),e.defaultPrevented||u?.()},{ownerDocument:_,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:ne,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:d.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...m.branches].some(t=>t.contains(e));return w&&!t},[m.branches,w])}),T=Pe(e=>{if(i&&ne.current)return;let t=e.target;[...m.branches].some(e=>e.contains(t))||(s?.(e),l?.(e),e.defaultPrevented||u?.())},_),E=h?C===b.length-1:!1,D=N(e=>{e.key===`Escape`&&(a?.(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))});return d.useEffect(()=>{if(E)return _.addEventListener(`keydown`,D,{capture:!0}),()=>_.removeEventListener(`keydown`,D,{capture:!0})},[_,E,D]),d.useEffect(()=>{if(h)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(Oe=_.body.style.pointerEvents,_.body.style.pointerEvents=`none`),m.layersWithOutsidePointerEventsDisabled.add(h)),m.layers.add(h),Fe(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(h),m.layersWithOutsidePointerEventsDisabled.size===0&&(_.body.style.pointerEvents=Oe))}},[h,_,r,m]),d.useEffect(()=>()=>{h&&(m.layers.delete(h),m.layersWithOutsidePointerEventsDisabled.delete(h),Fe())},[h,m]),d.useEffect(()=>{let e=P(()=>v({}),`handleUpdate`);return document.addEventListener(Te,e),()=>document.removeEventListener(Te,e)},[]),(0,f.jsx)(n.div,{...p,ref:y,style:{pointerEvents:te?w?`auto`:`none`:void 0,...e.style},onFocusCapture:x(e.onFocusCapture,T.onFocusCapture),onBlurCapture:x(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:x(e.onPointerDownCapture,re.onPointerDownCapture)})},`DismissableLayer`));function je(){let e=d.useContext(ke),[t,n]=d.useState(null);return d.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}P(je,`useDismissableLayerSurface`);var Me=P(()=>!0,`IS_TRUE`);function Ne(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Me}=t,s=N(e),c=d.useRef(!1),l=d.useRef(!1),u=d.useRef(new Map),f=d.useRef(()=>{});return d.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}P(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}P(t,`isOutsideInteractionIntercepted`);function d(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&f.current()},0)}P(d,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}P(p,`handleInteractionBubble`);let m=P(a=>{if(a.target&&!c.current){let d=function(){n.removeEventListener(`click`,f.current);let r=t();e(),r||Ie(Ee,s,p,{discrete:!0})};if(P(d,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,f.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?d():(n.removeEventListener(`click`,f.current),f.current=d,n.addEventListener(`click`,f.current,{once:!0}))}else n.removeEventListener(`click`,f.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,d,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,f.current);for(let e of h)n.removeEventListener(e,d,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:P(()=>c.current=!0,`onPointerDownCapture`)}}P(Ne,`usePointerDownOutside`);function Pe(e,t=globalThis?.document){let n=N(e),r=d.useRef(!1);return d.useEffect(()=>{let e=P(e=>{e.target&&!r.current&&Ie(De,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:P(()=>r.current=!0,`onFocusCapture`),onBlurCapture:P(()=>r.current=!1,`onBlurCapture`)}}P(Pe,`useFocusOutside`);function Fe(){let e=new CustomEvent(Te);document.dispatchEvent(e)}P(Fe,`dispatchUpdate`);function Ie(e,t,n,{discrete:r}){let i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?a(i,o):i.dispatchEvent(o)}P(Ie,`handleAndDispatchCustomEvent`);var Le=Object.defineProperty,F=(e,t)=>Le(e,`name`,{value:t,configurable:!0}),Re=`focusScope.autoFocusOnMount`,ze=`focusScope.autoFocusOnUnmount`,Be={bubbles:!1,cancelable:!0},Ve=d.forwardRef(F(function(e,t){let{loop:r=!1,trapped:i=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...s}=e,[l,u]=d.useState(null),p=N(a),m=N(o),h=d.useRef(null),g=c(t,u),_=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let e=function(e){if(_.paused||!l)return;let t=e.target;l.contains(t)?h.current=t:I(h.current,{select:!0})},t=function(e){if(_.paused||!l)return;let t=e.relatedTarget;t!==null&&(l.contains(t)||I(h.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&I(l)};F(e,`handleFocusIn`),F(t,`handleFocusOut`),F(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return l&&r.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[i,l,_.paused]),d.useEffect(()=>{if(l){Je.add(_);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(Re,Be);l.addEventListener(Re,p),l.dispatchEvent(t),t.defaultPrevented||(He(Ze(We(l)),{select:!0}),document.activeElement===e&&I(l))}return()=>{l.removeEventListener(Re,p),setTimeout(()=>{let t=new CustomEvent(ze,Be);l.addEventListener(ze,m),l.dispatchEvent(t),t.defaultPrevented||I(e??document.body,{select:!0}),l.removeEventListener(ze,m),Je.remove(_)},0)}}},[l,p,m,_]);let v=d.useCallback(e=>{if(!r&&!i||_.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,n=document.activeElement;if(t&&n){let t=e.currentTarget,[i,a]=Ue(t);i&&a?!e.shiftKey&&n===a?(e.preventDefault(),r&&I(i,{select:!0})):e.shiftKey&&n===i&&(e.preventDefault(),r&&I(a,{select:!0})):n===t&&e.preventDefault()}},[r,i,_.paused]);return(0,f.jsx)(n.div,{tabIndex:-1,...s,ref:g,onKeyDown:v})},`FocusScope`));function He(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(I(r,{select:t}),document.activeElement!==n)return}F(He,`focusFirst`);function Ue(e){let t=We(e);return[Ge(t,e),Ge(t.reverse(),e)]}F(Ue,`getTabbableEdges`);function We(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:F(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}F(We,`getTabbableCandidates`);function Ge(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Ke(r,{upTo:t})))return r}F(Ge,`findVisible`);function Ke(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}F(Ke,`isHidden`);function qe(e){return e instanceof HTMLInputElement&&`select`in e}F(qe,`isSelectableInput`);function I(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&qe(e)&&t&&e.select()}}F(I,`focus`);var Je=Ye();function Ye(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Xe(e,t),e.unshift(t)},remove(t){e=Xe(e,t),e[0]?.resume()}}}F(Ye,`createFocusScopesStack`);function Xe(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}F(Xe,`arrayRemove`);function Ze(e){return e.filter(e=>e.tagName!==`A`)}F(Ze,`removeLinks`);var Qe=Object.defineProperty,$e=d.forwardRef(((e,t)=>Qe(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:r,...i}=e,[a,o]=d.useState(!1);w(()=>o(!0),[]);let s=r||a&&globalThis?.document?.body;return s?de.createPortal((0,f.jsx)(n.div,{...i,ref:t}),s):null},`Portal`)),et=Object.defineProperty,tt=(e,t)=>et(e,`name`,{value:t,configurable:!0}),L=0,R=null;function nt(e){return z(),e.children}tt(nt,`FocusGuards`);function z(){d.useEffect(()=>{R||={start:rt(),end:rt()};let{start:e,end:t}=R;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),L++,()=>{L===1&&(R?.start.remove(),R?.end.remove(),R=null),L=Math.max(0,L-1)}},[])}tt(z,`useFocusGuards`);function rt(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}tt(rt,`createFocusGuard`);var B=function(){return B=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},B.apply(this,arguments)};function it(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function at(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var V=`right-scroll-bar-position`,H=`width-before-scroll-bar`,ot=`with-scroll-bars-hidden`,st=`--removed-body-scroll-bar-size`;function ct(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function lt(e,t){var n=(0,d.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var ut=typeof window<`u`?d.useLayoutEffect:d.useEffect,dt=new WeakMap;function ft(e,t){var n=lt(t||null,function(t){return e.forEach(function(e){return ct(e,t)})});return ut(function(){var t=dt.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||ct(e,null)}),i.forEach(function(e){r.has(e)||ct(e,a)})}dt.set(n,e)},[e]),n}function pt(e){return e}function mt(e,t){t===void 0&&(t=pt);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function ht(e){e===void 0&&(e={});var t=mt(null);return t.options=B({async:!0,ssr:!1},e),t}var gt=function(e){var t=e.sideCar,n=it(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return d.createElement(r,B({},n))};gt.isSideCarExport=!0;function _t(e,t){return e.useMedium(t),gt}var vt=ht(),yt=function(){},U=d.forwardRef(function(e,t){var n=d.useRef(null),r=d.useState({onScrollCapture:yt,onWheelCapture:yt,onTouchMoveCapture:yt}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,f=e.shards,p=e.sideCar,m=e.noRelative,h=e.noIsolation,g=e.inert,_=e.allowPinchZoom,v=e.as,y=v===void 0?`div`:v,b=e.gapMode,x=it(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),ee=p,S=ft([n,t]),C=B(B({},x),i);return d.createElement(d.Fragment,null,u&&d.createElement(ee,{sideCar:vt,removeScrollBar:l,shards:f,noRelative:m,noIsolation:h,inert:g,setCallbacks:a,allowPinchZoom:!!_,lockRef:n,gapMode:b}),o?d.cloneElement(d.Children.only(s),B(B({},C),{ref:S})):d.createElement(y,B({},C,{className:c,ref:S}),s))});U.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},U.classNames={fullWidth:H,zeroRight:V};var bt=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function xt(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=bt();return t&&e.setAttribute(`nonce`,t),e}function St(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ct(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var wt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=xt())&&(St(t,n),Ct(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Tt=function(){var e=wt();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Et=function(){var e=Tt();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},Dt={left:0,top:0,right:0,gap:0},Ot=function(e){return parseInt(e||``,10)||0},kt=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Ot(n),Ot(r),Ot(i)]},At=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return Dt;var t=kt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},jt=Et(),W=`data-scroll-locked`,Mt=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
2
2
  .${ot} {
3
3
  overflow: hidden ${r};
4
4
  padding-right: ${s}px ${r};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{i as n,r}from"./C76CctEl.js";import{n as i}from"./BihjBM79.js";import{t as a}from"./BaTnCkNR.js";import{i as o,t as s}from"./Udlj1Cgf.js";import{t as c}from"./C3aiaYZP.js";import{t as l}from"./_zaonxnw.js";var u=e(t(),1),d=r(),f=[`id`,`addr`,`name`,`user`,`db`,`age`,`idle`,`cmd`,`flags`];function p({connectionId:e,tabId:t}){let{t:r}=n(),p=a(e,t,``),[m,h]=(0,u.useState)(null),[g,_]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),b=(0,u.useCallback)(async()=>{try{h(o(String(await p.read(`CLIENT LIST`))));let e=await p.tryRead(`CLIENT ID`);_(e===null?null:String(e)),y(null)}catch(e){y(l(e))}},[p]);(0,u.useEffect)(()=>{Promise.resolve().then(()=>b())},[b]);let x=async e=>{let t=`CLIENT KILL ID ${e.id}`;if(await i.getState().requestDestructiveConfirm({title:r(`tools.redis.killTitle`,{addr:e.addr}),description:r(`tools.redis.killDescription`),statements:[t],confirmLabel:r(`tools.redis.kill`)}))try{await p.write(t,{confirmed:!0}),await b()}catch(e){e instanceof Error&&e.name===`ExecutionCancelled`||y(l(e))}};return(0,d.jsx)(c,{title:r(`tools.redis.clients`),onRefresh:b,autoRefresh:!0,error:v,onDismissError:()=>y(null),children:m&&(0,d.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,d.jsx)(`thead`,{className:`sticky top-0 bg-muted text-left text-muted-foreground`,children:(0,d.jsxs)(`tr`,{children:[f.map(e=>(0,d.jsx)(`th`,{className:`px-3 py-1.5`,children:e},e)),(0,d.jsx)(`th`,{className:`w-20`})]})}),(0,d.jsx)(`tbody`,{children:m.map(e=>{let t=e.id===g;return(0,d.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/40 ${t?`bg-primary/5`:``}`,children:[f.map(n=>(0,d.jsxs)(`td`,{className:`px-3 py-1 font-mono`,children:[n===`age`||n===`idle`?s(Number(e[n])):e[n]??``,n===`id`&&t&&(0,d.jsx)(`span`,{className:`ml-2 rounded bg-primary/15 px-1 text-[10px] text-primary`,children:r(`tools.redis.thisApp`)})]},n)),(0,d.jsx)(`td`,{className:`px-2 py-1 text-right`,children:!t&&!p.readOnly&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void x(e),className:`rounded border px-2 py-0.5 text-muted-foreground hover:border-destructive/40 hover:text-destructive`,children:r(`tools.redis.kill`)})})]},e.id)})})]})})}export{p as Clients};
1
+ import{r as e}from"./hePW80VL.js";import{p as t}from"./voJYJ5aN.js";import{i as n,r}from"./lXSI1SY-.js";import{n as i}from"./Dz-fZF1j.js";import{t as a}from"./B2Zfb92y.js";import{i as o,t as s}from"./Udlj1Cgf.js";import{t as c}from"./WvnnIt2x.js";import{t as l}from"./_zaonxnw.js";var u=e(t(),1),d=r(),f=[`id`,`addr`,`name`,`user`,`db`,`age`,`idle`,`cmd`,`flags`];function p({connectionId:e,tabId:t}){let{t:r}=n(),p=a(e,t,``),[m,h]=(0,u.useState)(null),[g,_]=(0,u.useState)(null),[v,y]=(0,u.useState)(null),b=(0,u.useCallback)(async()=>{try{h(o(String(await p.read(`CLIENT LIST`))));let e=await p.tryRead(`CLIENT ID`);_(e===null?null:String(e)),y(null)}catch(e){y(l(e))}},[p]);(0,u.useEffect)(()=>{Promise.resolve().then(()=>b())},[b]);let x=async e=>{let t=`CLIENT KILL ID ${e.id}`;if(await i.getState().requestDestructiveConfirm({title:r(`tools.redis.killTitle`,{addr:e.addr}),description:r(`tools.redis.killDescription`),statements:[t],confirmLabel:r(`tools.redis.kill`)}))try{await p.write(t,{confirmed:!0}),await b()}catch(e){e instanceof Error&&e.name===`ExecutionCancelled`||y(l(e))}};return(0,d.jsx)(c,{title:r(`tools.redis.clients`),onRefresh:b,autoRefresh:!0,error:v,onDismissError:()=>y(null),children:m&&(0,d.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,d.jsx)(`thead`,{className:`sticky top-0 bg-muted text-left text-muted-foreground`,children:(0,d.jsxs)(`tr`,{children:[f.map(e=>(0,d.jsx)(`th`,{className:`px-3 py-1.5`,children:e},e)),(0,d.jsx)(`th`,{className:`w-20`})]})}),(0,d.jsx)(`tbody`,{children:m.map(e=>{let t=e.id===g;return(0,d.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/40 ${t?`bg-primary/5`:``}`,children:[f.map(n=>(0,d.jsxs)(`td`,{className:`px-3 py-1 font-mono`,children:[n===`age`||n===`idle`?s(Number(e[n])):e[n]??``,n===`id`&&t&&(0,d.jsx)(`span`,{className:`ml-2 rounded bg-primary/15 px-1 text-[10px] text-primary`,children:r(`tools.redis.thisApp`)})]},n)),(0,d.jsx)(`td`,{className:`px-2 py-1 text-right`,children:!t&&!p.readOnly&&(0,d.jsx)(`button`,{type:`button`,onClick:()=>void x(e),className:`rounded border px-2 py-0.5 text-muted-foreground hover:border-destructive/40 hover:text-destructive`,children:r(`tools.redis.kill`)})})]},e.id)})})]})})}export{p as Clients};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{i as n,r,t as i}from"./C76CctEl.js";import{t as a}from"./CcaDuuFY.js";import{P as o,R as s}from"./iz6RnRcO.js";import{n as c}from"./BihjBM79.js";import{n as l}from"./C_qmv4pB.js";import{C as u}from"./BVZGLNq_.js";import{g as d}from"./CZRhmV_L.js";import{E as f,Ft as p,Gt as m,Mt as h,Nt as g,Yt as _,d as v,jt as y,pt as b,wt as x,y as S}from"./D4DxtYTA.js";import{a as C,c as w,d as T,f as E,h as D,i as O,l as k,m as A,n as j,o as M,p as N,r as P,s as F,t as I,u as L}from"./CtsakJNi.js";import{n as R}from"./BaTnCkNR.js";var z=e(t(),1),B=r(),V=300;function H({columns:e,rows:t,rowKey:r,readOnly:a,onEdit:o,onDelete:s,addColumns:c,onAdd:l,addExtra:u}){let{t:d}=n(),[f,m]=(0,z.useState)(null),[h,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)({}),[S,C]=(0,z.useState)(!1),w=async e=>{v(!0);try{await e()}catch{}finally{v(!1)}},T=e=>w(async()=>{!f||!o||(await o(e,f.column,f.value),m(null))}),E=()=>w(async()=>{l&&(await l(y),b({}),C(!1))});return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!a&&l&&c&&(0,B.jsx)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1.5`,children:S?(0,B.jsxs)(B.Fragment,{children:[c.map(e=>(0,B.jsx)(`input`,{className:`h-7 rounded border bg-background px-2 text-xs ${e.numeric?`w-24`:`min-w-40 flex-1`}`,placeholder:e.label,value:y[e.key]??``,onChange:t=>b({...y,[e.key]:t.target.value}),onKeyDown:e=>{e.key===`Enter`&&E()}},e.key)),u,(0,B.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>void E(),className:`flex h-7 items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 text-xs text-primary hover:bg-primary/20 disabled:opacity-40`,children:[(0,B.jsx)(_,{className:`size-3`}),d(`keyViewer.add`)]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),b({})},className:`flex h-7 items-center rounded border px-2 text-xs text-muted-foreground hover:text-foreground`,children:d(`keyViewer.cancel`)})]}):(0,B.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(g,{className:`size-3`}),d(`keyViewer.addRow`)]})}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,B.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:(0,B.jsxs)(`tr`,{children:[e.map(e=>(0,B.jsx)(`th`,{className:`border-b px-3 py-1.5 text-left font-medium text-muted-foreground ${e.numeric?`w-28`:``}`,children:e.label},e.key)),!a&&(o||s)&&(0,B.jsx)(`th`,{className:`w-16 border-b`})]})}),(0,B.jsx)(`tbody`,{children:t.map((t,n)=>{let c=r(t,n);return(0,B.jsxs)(`tr`,{className:`group border-b border-border/50 hover:bg-muted/40`,children:[e.map(e=>{let n=f?.row===c&&f.column===e.key,r=t[e.key]??``;return(0,B.jsx)(`td`,{className:`px-3 py-1 align-top font-mono ${e.numeric?`text-right tabular-nums`:``}`,children:n?(0,B.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,B.jsx)(`textarea`,{autoFocus:!0,className:`min-h-7 w-full resize-y rounded border bg-background px-1.5 py-1 font-mono text-xs`,rows:Math.min(8,Math.max(1,r.split(`
1
+ import{r as e}from"./hePW80VL.js";import{p as t}from"./voJYJ5aN.js";import{i as n,r,t as i}from"./lXSI1SY-.js";import{t as a}from"./Bab8stSv.js";import{P as o,R as s}from"./NrVAX4Mt.js";import{n as c}from"./Dz-fZF1j.js";import{n as l}from"./BlX_ty5A.js";import{C as u}from"./-BrRFEsd.js";import{g as d}from"./CdhLxfdD.js";import{E as f,Ft as p,Gt as m,Mt as h,Nt as g,Yt as _,d as v,jt as y,pt as b,wt as x,y as S}from"./Cykx3CBw.js";import{a as C,c as w,d as T,f as E,h as D,i as O,l as k,m as A,n as j,o as M,p as N,r as P,s as F,t as I,u as L}from"./DQ6CDi_T.js";import{n as R}from"./B2Zfb92y.js";var z=e(t(),1),B=r(),V=300;function H({columns:e,rows:t,rowKey:r,readOnly:a,onEdit:o,onDelete:s,addColumns:c,onAdd:l,addExtra:u}){let{t:d}=n(),[f,m]=(0,z.useState)(null),[h,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)({}),[S,C]=(0,z.useState)(!1),w=async e=>{v(!0);try{await e()}catch{}finally{v(!1)}},T=e=>w(async()=>{!f||!o||(await o(e,f.column,f.value),m(null))}),E=()=>w(async()=>{l&&(await l(y),b({}),C(!1))});return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!a&&l&&c&&(0,B.jsx)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-2 border-b px-3 py-1.5`,children:S?(0,B.jsxs)(B.Fragment,{children:[c.map(e=>(0,B.jsx)(`input`,{className:`h-7 rounded border bg-background px-2 text-xs ${e.numeric?`w-24`:`min-w-40 flex-1`}`,placeholder:e.label,value:y[e.key]??``,onChange:t=>b({...y,[e.key]:t.target.value}),onKeyDown:e=>{e.key===`Enter`&&E()}},e.key)),u,(0,B.jsxs)(`button`,{type:`button`,disabled:h,onClick:()=>void E(),className:`flex h-7 items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 text-xs text-primary hover:bg-primary/20 disabled:opacity-40`,children:[(0,B.jsx)(_,{className:`size-3`}),d(`keyViewer.add`)]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),b({})},className:`flex h-7 items-center rounded border px-2 text-xs text-muted-foreground hover:text-foreground`,children:d(`keyViewer.cancel`)})]}):(0,B.jsxs)(`button`,{type:`button`,onClick:()=>C(!0),className:`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(g,{className:`size-3`}),d(`keyViewer.addRow`)]})}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[(0,B.jsxs)(`table`,{className:`w-full border-collapse text-xs`,children:[(0,B.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted`,children:(0,B.jsxs)(`tr`,{children:[e.map(e=>(0,B.jsx)(`th`,{className:`border-b px-3 py-1.5 text-left font-medium text-muted-foreground ${e.numeric?`w-28`:``}`,children:e.label},e.key)),!a&&(o||s)&&(0,B.jsx)(`th`,{className:`w-16 border-b`})]})}),(0,B.jsx)(`tbody`,{children:t.map((t,n)=>{let c=r(t,n);return(0,B.jsxs)(`tr`,{className:`group border-b border-border/50 hover:bg-muted/40`,children:[e.map(e=>{let n=f?.row===c&&f.column===e.key,r=t[e.key]??``;return(0,B.jsx)(`td`,{className:`px-3 py-1 align-top font-mono ${e.numeric?`text-right tabular-nums`:``}`,children:n?(0,B.jsxs)(`div`,{className:`flex items-start gap-1`,children:[(0,B.jsx)(`textarea`,{autoFocus:!0,className:`min-h-7 w-full resize-y rounded border bg-background px-1.5 py-1 font-mono text-xs`,rows:Math.min(8,Math.max(1,r.split(`
2
2
  `).length)),value:f.value,onChange:e=>m({...f,value:e.target.value}),onKeyDown:e=>{e.key===`Escape`&&m(null),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&T(t)}}),(0,B.jsx)(`button`,{type:`button`,disabled:h,title:d(`keyViewer.save`),onClick:()=>void T(t),className:`rounded p-1 text-primary hover:bg-primary/10`,children:(0,B.jsx)(_,{className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:d(`keyViewer.cancel`),onClick:()=>m(null),className:`rounded p-1 text-muted-foreground hover:bg-muted`,children:(0,B.jsx)(i,{className:`size-3.5`})})]}):e.render?e.render(r):(0,B.jsx)(`span`,{className:`whitespace-pre-wrap break-all`,title:r.length>V?r:void 0,children:r.length>V?`${r.slice(0,V)}…`:r})},e.key)}),!a&&(o||s)&&(0,B.jsx)(`td`,{className:`px-1 py-1 align-top`,children:(0,B.jsxs)(`div`,{className:`flex justify-end gap-0.5 opacity-0 group-hover:opacity-100`,children:[o&&e.some(e=>e.editable)&&(0,B.jsx)(`button`,{type:`button`,title:d(`keyViewer.edit`),onClick:()=>{let n=e.find(e=>e.editable);m({row:c,column:n.key,value:t[n.key]??``})},className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,B.jsx)(p,{className:`size-3`})}),s&&(0,B.jsx)(`button`,{type:`button`,disabled:h,title:d(`keyViewer.deleteRow`),onClick:()=>void w(()=>s(t)),className:`rounded p-1 text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,B.jsx)(x,{className:`size-3`})})]})})]},c)})})]}),t.length===0&&(0,B.jsx)(`p`,{className:`p-6 text-center text-xs text-muted-foreground`,children:d(`keyViewer.empty`)})]})]})}var U=e=>e instanceof Error?e.message:String(e);function W(e){let{access:t,onChanged:n,onError:r}=e;return(0,z.useCallback)(async(e,i)=>{try{await t.write(e),await i?.(),n()}catch(e){if(e instanceof Error&&e.name===`ExecutionCancelled`)return;throw r(U(e)),e}},[t,n,r])}function G({onApply:e}){let{t}=n(),[r,i]=(0,z.useState)(``);return(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(y,{className:`size-3.5 text-muted-foreground`}),(0,B.jsx)(`input`,{className:`h-7 w-56 rounded border bg-background px-2 text-xs`,placeholder:t(`keyViewer.filterPlaceholder`),value:r,onChange:e=>i(e.target.value),onKeyDown:t=>{t.key===`Enter`&&e(j(r))}})]})}function K({shown:e,total:t,hasMore:r,onMore:i,loading:a}){let{t:o}=n();return(0,B.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-3 border-t px-3 py-1 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{children:t===null?o(`keyViewer.shown`,{count:e}):o(`keyViewer.shownOf`,{count:e,total:t})}),r&&(0,B.jsx)(`button`,{type:`button`,disabled:a,onClick:i,className:`rounded border bg-background px-2 py-0.5 hover:text-foreground disabled:opacity-40`,children:o(`keyViewer.loadMore`)})]})}function q({props:e,load:t,save:r}){let{t:i}=n(),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(!1),[d,p]=(0,z.useState)(`preview`),[m,h]=(0,z.useState)(!1),{onError:g}=e,_=(0,z.useCallback)(async(e=!1)=>{try{let n=await t(e);o(n.text),c(n.text),u(n.partial)}catch(e){g(U(e))}},[t,g]);(0,z.useEffect)(()=>{Promise.resolve().then(()=>_())},[_]);let y=S(s),b=d===`preview`&&y.kind!==`text`,x=a!==null&&s!==a,C=async()=>{h(!0);try{await r(s),o(s)}catch{}finally{h(!1)}};if(a===null)return(0,B.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:i(`keyViewer.loading`)});let w=e=>`rounded px-2 py-0.5 ${e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`}`;return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-2 border-b px-3 py-1.5 text-xs`,children:[y.kind!==`text`&&(0,B.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded border p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,className:w(b),onClick:()=>p(`preview`),children:i(y.kind===`json`?`keyViewer.viewTree`:`keyViewer.viewHtml`)}),(0,B.jsx)(`button`,{type:`button`,className:w(!b),onClick:()=>p(`text`),children:i(`keyViewer.viewText`)})]}),!b&&y.kind===`json`&&!e.access.readOnly&&!l&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>c(A(s)??s),className:`rounded border bg-background px-2 py-0.5 text-muted-foreground hover:text-foreground`,children:i(`keyViewer.formatJson`)}),l&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-catppuccin-yellow`,children:i(`keyViewer.truncated`,{size:P(1048576)})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void _(!0),className:`rounded border bg-background px-2 py-0.5 text-muted-foreground hover:text-foreground`,children:i(`keyViewer.loadFull`)})]}),(0,B.jsx)(`div`,{className:`flex-1`}),!e.access.readOnly&&!l&&(0,B.jsxs)(B.Fragment,{children:[x&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>c(a),className:`rounded border bg-background px-2 py-0.5 text-muted-foreground hover:text-foreground`,children:i(`keyViewer.revert`)}),(0,B.jsx)(`button`,{type:`button`,disabled:!x||m,onClick:()=>void C(),className:`rounded border border-primary/30 bg-primary/10 px-2 py-0.5 text-primary hover:bg-primary/20 disabled:opacity-40`,children:i(`keyViewer.save`)})]})]}),b&&y.kind===`json`?(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto py-3 pl-7 pr-3 font-mono text-xs`,children:(0,B.jsx)(f,{value:y.document,defaultExpanded:!0})}):b&&y.kind===`html`?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(v,{html:s})}):(0,B.jsx)(`textarea`,{className:`min-h-0 flex-1 resize-none bg-background p-3 font-mono text-xs outline-none`,spellCheck:!1,readOnly:e.access.readOnly||l,value:s,onChange:e=>c(e.target.value)})]})}function J(e){let{access:t,keyName:n,length:r,ttl:i}=e,a=W(e),o=(0,z.useCallback)(async e=>{let i=!e&&r!==null&&r>1048576,a=await t.read(C.getString(n,i?I:void 0));return{text:a==null?``:String(a),partial:i}},[t,n,r]),s=(0,z.useCallback)(async e=>{try{await a(C.setString(n,e))}catch(t){if(!/syntax|KEEPTTL/i.test(U(t)))throw t;await a(C.setStringWithTtl(n,e,i))}},[a,n,i]);return(0,B.jsx)(q,{props:e,load:o,save:s})}function Y(e){let{access:t,keyName:n}=e,r=W(e),i=(0,z.useCallback)(async()=>{let e=await t.read(C.getJson(n));return{text:e==null?``:String(e),partial:!1}},[t,n]),a=(0,z.useCallback)(async e=>{JSON.parse(e),await r(C.setJson(n,e))},[r,n]);return(0,B.jsx)(q,{props:e,load:i,save:a})}function X(e,t,n){let{access:r,onError:i}=e,[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(`0`),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(!1),[p,m]=(0,z.useState)(!1),h=(0,z.useCallback)(async(e,a,s)=>{f(!0);try{let i=e,l=[];do{let e=n(await r.read(t(i,a)));l.push(...e.items),i=e.cursor}while(i!==`0`&&l.length===0);o(e=>s?[...e,...l]:l),c(i),m(!0)}catch(e){i(U(e))}finally{f(!1)}},[r,t,n,i]);return(0,z.useEffect)(()=>{Promise.resolve().then(()=>h(`0`,l,!1))},[h,l]),{items:a,setItems:o,loading:d,started:p,hasMore:p&&s!==`0`,loadMore:()=>void h(s,l,!0),applyFilter:u,reload:()=>void h(`0`,l,!1)}}function Z(e){let{t}=n(),{keyName:r,length:i,access:a}=e,o=W(e),s=X(e,(0,z.useCallback)((e,t)=>C.scan(r,`hash`,e,t),[r]),w),c=[{key:`field`,label:t(`keyViewer.field`)},{key:`value`,label:t(`keyViewer.value`),editable:!0}];return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{className:`flex flex-shrink-0 items-center gap-2 border-b px-3 py-1.5`,children:(0,B.jsx)(G,{onApply:s.applyFilter})}),(0,B.jsx)(H,{columns:c,rows:s.items.map(e=>({field:e.field,value:e.value})),rowKey:e=>e.field,readOnly:a.readOnly,onEdit:(e,t,n)=>o(C.hashSet(r,e.field,n),()=>{s.setItems(t=>t.map(t=>t.field===e.field?{...t,value:n}:t))}),onDelete:e=>o(C.hashDelete(r,e.field),()=>{s.setItems(t=>t.filter(t=>t.field!==e.field))}),addColumns:c.map(e=>({...e,editable:!1})),onAdd:e=>o(C.hashSet(r,e.field??``,e.value??``),s.reload)}),(0,B.jsx)(K,{shown:s.items.length,total:i,hasMore:s.hasMore,onMore:s.loadMore,loading:s.loading})]})}function Q(e){let{t}=n(),{keyName:r,length:i,access:a}=e,o=W(e),s=X(e,(0,z.useCallback)((e,t)=>C.scan(r,`set`,e,t),[r]),L),c=[{key:`member`,label:t(`keyViewer.member`)}];return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{className:`flex flex-shrink-0 items-center gap-2 border-b px-3 py-1.5`,children:(0,B.jsx)(G,{onApply:s.applyFilter})}),(0,B.jsx)(H,{columns:c,rows:s.items.map(e=>({member:e})),rowKey:e=>e.member,readOnly:a.readOnly,onDelete:e=>o(C.setRemove(r,e.member),()=>{s.setItems(t=>t.filter(t=>t!==e.member))}),addColumns:c,onAdd:e=>o(C.setAdd(r,e.member??``),s.reload)}),(0,B.jsx)(K,{shown:s.items.length,total:i,hasMore:s.hasMore,onMore:s.loadMore,loading:s.loading})]})}function ee(e){let{t}=n(),{keyName:r,length:i,access:a}=e,o=W(e),s=X(e,(0,z.useCallback)((e,t)=>C.scan(r,`zset`,e,t),[r]),N),c=[{key:`member`,label:t(`keyViewer.member`)},{key:`score`,label:t(`keyViewer.score`),editable:!0,numeric:!0}],l=[...s.items].sort((e,t)=>Number(e.score)-Number(t.score)).map(e=>({member:e.member,score:e.score}));return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(`div`,{className:`flex flex-shrink-0 items-center gap-2 border-b px-3 py-1.5`,children:(0,B.jsx)(G,{onApply:s.applyFilter})}),(0,B.jsx)(H,{columns:c,rows:l,rowKey:e=>e.member,readOnly:a.readOnly,onEdit:(e,t,n)=>o(C.zsetAdd(r,e.member,n.trim()),()=>{s.setItems(t=>t.map(t=>t.member===e.member?{...t,score:n.trim()}:t))}),onDelete:e=>o(C.zsetRemove(r,e.member),()=>{s.setItems(t=>t.filter(t=>t.member!==e.member))}),addColumns:[{key:`member`,label:t(`keyViewer.member`)},{key:`score`,label:t(`keyViewer.score`),numeric:!0}],onAdd:e=>o(C.zsetAdd(r,e.member??``,(e.score??`0`).trim()||`0`),s.reload)}),(0,B.jsx)(K,{shown:s.items.length,total:i,hasMore:s.hasMore,onMore:s.loadMore,loading:s.loading})]})}function te(e){let{t}=n(),{keyName:r,length:i,access:a,onError:o}=e,s=W(e),[c,l]=(0,z.useState)([]),[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(!1),m=(0,z.useCallback)(async e=>{d(!0);try{let t=k(await a.read(C.listRange(r,e)));l(n=>e===0?t:[...n,...t])}catch(e){o(U(e))}finally{d(!1)}},[a,r,o]);(0,z.useEffect)(()=>{Promise.resolve().then(()=>m(0))},[m]);let h=[{key:`index`,label:t(`keyViewer.index`),numeric:!0},{key:`value`,label:t(`keyViewer.value`),editable:!0}];return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(H,{columns:h,rows:c.map((e,t)=>({index:String(t),value:e})),rowKey:e=>e.index,readOnly:a.readOnly,onEdit:(e,t,n)=>s(C.listSet(r,Number(e.index),n),()=>{l(t=>t.map((t,r)=>r===Number(e.index)?n:t))}),onDelete:async e=>{let t=M();await s(C.listSet(r,Number(e.index),t)),await s(C.listRemoveOne(r,t),()=>m(0))},addColumns:[{key:`value`,label:t(`keyViewer.value`)}],addExtra:(0,B.jsxs)(`select`,{value:f?`head`:`tail`,onChange:e=>p(e.target.value===`head`),className:`h-7 rounded border bg-background px-1 text-xs`,children:[(0,B.jsx)(`option`,{value:`tail`,children:t(`keyViewer.pushTail`)}),(0,B.jsx)(`option`,{value:`head`,children:t(`keyViewer.pushHead`)})]}),onAdd:e=>s(C.listPush(r,e.value??``,f),()=>m(0))}),(0,B.jsx)(K,{shown:c.length,total:i,hasMore:i!==null&&c.length<i,onMore:()=>void m(c.length),loading:u})]})}function ne(e){let{t}=n(),{keyName:r,length:i,access:a,onError:o}=e,s=W(e),[c,l]=(0,z.useState)([]),[u,d]=(0,z.useState)(!1),f=(0,z.useCallback)(async e=>{d(!0);try{let t=T(await a.read(C.streamRange(r,e)));l(n=>e?[...n,...t]:t)}catch(e){o(U(e))}finally{d(!1)}},[a,r,o]);(0,z.useEffect)(()=>{Promise.resolve().then(()=>f())},[f]);let p=c.map(e=>({id:e.id,fields:JSON.stringify(e.fields)})),m=[{key:`id`,label:t(`keyViewer.entryId`)},{key:`fields`,label:t(`keyViewer.fields`),render:e=>(0,B.jsx)(`dl`,{className:`grid grid-cols-[max-content_1fr] gap-x-3`,children:JSON.parse(e).map(([e,t],n)=>(0,B.jsxs)(`div`,{className:`contents`,children:[(0,B.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,B.jsx)(`dd`,{className:`break-all`,children:t})]},n))})}];return(0,B.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,B.jsx)(H,{columns:m,rows:p,rowKey:e=>e.id,readOnly:a.readOnly,onDelete:e=>s(C.streamDelete(r,e.id),()=>{l(t=>t.filter(t=>t.id!==e.id))}),addColumns:[{key:`fields`,label:t(`keyViewer.entryFieldsPlaceholder`)}],onAdd:e=>{let n=F((e.fields??``).replaceAll(`;`,`
3
3
  `));return n.length===0?(o(t(`keyViewer.entryFieldsRequired`)),Promise.reject(Error(t(`keyViewer.entryFieldsRequired`)))):s(C.streamAdd(r,n),()=>f())}}),(0,B.jsx)(K,{shown:c.length,total:i,hasMore:i!==null&&c.length<i,onMore:()=>void f(c[c.length-1]?.id),loading:u})]})}var re={string:J,hash:Z,list:te,set:Q,zset:ee,stream:ne,"ReJSON-RL":Y};function $(e,t,n,r=null){for(let i of e){if(i.type===s.KEY&&i.metadata?.database===t&&i.metadata.key===n)return r;let e=$(i.children,t,n,i);if(e)return e}return null}function ie({connectionId:e,tabId:t,item:r}){let{t:s}=n(),f=R(e,t,r),{loadChildren:g}=d(),[v,y]=(0,z.useState)(null),[S,w]=(0,z.useState)(!1),[T,k]=(0,z.useState)(null),[A,j]=(0,z.useState)(0),[M,N]=(0,z.useState)(null),[F,I]=(0,z.useState)(null),L=r.name,V=(0,z.useCallback)(async()=>{if(f.connected)try{let e=String(await f.read(C.type(L)));if(e===`none`){w(!0),y(null);return}let t=C.length(L,e),[n,r,i,a]=await Promise.all([f.read(C.ttl(L)),t?f.tryRead(t):Promise.resolve(null),f.tryRead(C.memory(L)),f.tryRead(C.encoding(L))]),o=E(n);w(o===`gone`),y({type:e,ttl:o===`gone`?null:o,length:D(r),memory:D(i),encoding:typeof a==`string`?a:null})}catch(e){k(e instanceof Error?e.message:String(e))}},[f,L]);(0,z.useEffect)(()=>{Promise.resolve().then(()=>V())},[V]);let H=(0,z.useCallback)(t=>{let n=$(u.getState().trees[e]??[],r.database,t);n&&g(e,n)},[e,r.database,g]),U=async e=>{try{k(null),await e()}catch(e){if(e instanceof Error&&e.name===`ExecutionCancelled`)return;k(e instanceof Error?e.message:String(e))}},W=n=>U(async()=>{if(!n||n===L){N(null);return}let i=await f.write(C.renameIfFree(L,n));if(Number(i)!==1)throw Error(s(`keyViewer.renameTaken`,{name:n}));N(null),H(L),l.getState().setSourceItem(e,t,{database:r.database,name:n})}),G=e=>U(async()=>{let t=Number(e);if(e.trim()===``)await f.write(C.persist(L));else if(!Number.isInteger(t)||t<=0)throw Error(s(`keyViewer.ttlInvalid`));else await f.write(C.expire(L,t));I(null),await V()}),K=()=>U(async()=>{let n=C.remove(L);await c.getState().requestDestructiveConfirm({title:s(`keyViewer.deleteTitle`,{name:L}),description:s(`keyViewer.deleteDescription`),statements:[n],confirmLabel:s(`keyViewer.delete`)})&&(await f.write(n,{confirmed:!0}),H(L),l.getState().removeQueryTab(e,t))}),q=()=>{v&&b(e,o(v.type,L),r.database,L)};if(!f.connected)return(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:s(`keyViewer.notConnected`)});let J=v?re[v.type]:void 0,Y=`flex h-7 items-center gap-1 rounded border bg-background px-2 text-xs text-muted-foreground hover:text-foreground disabled:opacity-40`;return(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsxs)(`div`,{className:`flex flex-shrink-0 flex-wrap items-center gap-x-3 gap-y-1.5 border-b bg-muted/30 px-3 py-1.5 text-xs`,children:[v&&(0,B.jsx)(`span`,{className:`rounded bg-primary/15 px-1.5 py-0.5 font-mono text-[10px] font-semibold uppercase text-primary`,children:v.type===`ReJSON-RL`?`json`:v.type}),M===null?(0,B.jsxs)(`span`,{className:`flex items-center gap-1 font-mono text-sm font-medium`,children:[L,!f.readOnly&&!S&&(0,B.jsx)(`button`,{type:`button`,title:s(`keyViewer.rename`),onClick:()=>N(L),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,B.jsx)(p,{className:`size-3`})})]}):(0,B.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(`input`,{autoFocus:!0,className:`h-7 w-72 rounded border bg-background px-2 font-mono text-xs`,value:M,onChange:e=>N(e.target.value),onKeyDown:e=>{e.key===`Enter`&&W(M),e.key===`Escape`&&N(null)}}),(0,B.jsx)(`button`,{type:`button`,title:s(`keyViewer.save`),onClick:()=>void W(M),className:`rounded p-1 text-primary hover:bg-primary/10`,children:(0,B.jsx)(_,{className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:s(`keyViewer.cancel`),onClick:()=>N(null),className:`rounded p-1 text-muted-foreground hover:bg-muted`,children:(0,B.jsx)(i,{className:`size-3.5`})})]}),v&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[(0,B.jsx)(m,{className:`size-3`}),F===null?(0,B.jsx)(`button`,{type:`button`,disabled:f.readOnly,onClick:()=>I(v.ttl===null?``:String(v.ttl)),className:`rounded px-1 hover:bg-muted hover:text-foreground disabled:hover:bg-transparent`,title:f.readOnly?void 0:s(`keyViewer.ttlEdit`),children:v.ttl===null?s(`keyViewer.noExpiry`):O(v.ttl)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{autoFocus:!0,className:`h-6 w-24 rounded border bg-background px-1.5 text-xs`,placeholder:s(`keyViewer.ttlPlaceholder`),value:F,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G(F),e.key===`Escape`&&I(null)}}),(0,B.jsx)(`button`,{type:`button`,title:s(`keyViewer.save`),onClick:()=>void G(F),className:`rounded p-1 text-primary hover:bg-primary/10`,children:(0,B.jsx)(_,{className:`size-3.5`})}),(0,B.jsx)(`button`,{type:`button`,title:s(`keyViewer.cancel`),onClick:()=>I(null),className:`rounded p-1 hover:bg-muted`,children:(0,B.jsx)(i,{className:`size-3.5`})})]})]}),v.length!==null&&(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:s(v.type===`string`?`keyViewer.bytes`:`keyViewer.length`,{count:v.length})}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,title:v.encoding?s(`keyViewer.encoding`,{encoding:v.encoding}):void 0,children:s(`keyViewer.memory`,{size:P(v.memory)})})]}),(0,B.jsx)(`div`,{className:`flex-1`}),(0,B.jsxs)(`button`,{type:`button`,className:Y,onClick:()=>{k(null),j(e=>e+1),V()},children:[(0,B.jsx)(h,{className:`size-3`}),s(`keyViewer.refresh`)]}),(0,B.jsxs)(`button`,{type:`button`,className:Y,disabled:!v,onClick:q,children:[(0,B.jsx)(a,{className:`size-3`}),s(`keyViewer.openInConsole`)]}),!f.readOnly&&!S&&(0,B.jsxs)(`button`,{type:`button`,className:`${Y} hover:border-destructive/40 hover:text-destructive`,onClick:()=>void K(),children:[(0,B.jsx)(x,{className:`size-3`}),s(`keyViewer.delete`)]})]}),T&&(0,B.jsxs)(`div`,{className:`flex flex-shrink-0 items-start gap-2 border-b border-destructive/30 bg-destructive/10 px-3 py-1.5 text-xs text-destructive`,children:[(0,B.jsx)(`span`,{className:`flex-1 whitespace-pre-wrap`,children:T}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>k(null),children:(0,B.jsx)(i,{className:`size-3.5`})})]}),S?(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:s(`keyViewer.gone`)}):v?J?(0,B.jsx)(J,{access:f,keyName:L,length:v.length,ttl:v.ttl,onChanged:()=>void V(),onError:k},`${L}:${A}`):(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:s(`keyViewer.unsupported`,{type:v.type})}):(0,B.jsx)(`p`,{className:`p-6 text-sm text-muted-foreground`,children:s(`keyViewer.loading`)})]})}export{ie as RedisKeyViewer};
@@ -1 +1 @@
1
- import{r as e}from"./hePW80VL.js";import{p as t}from"./CyX8oVsa.js";import{a as n,d as r,i,s as a,u as o}from"./Dya0zxo6.js";import{r as s}from"./C76CctEl.js";import{r as c,t as l}from"./UJzcIbfW.js";import{C as u,D as d,E as f,O as p,S as m,T as h,_ as g,b as _,g as v,v as y,w as b,x,y as S}from"./kTwcxyaO.js";import{n as C,t as w}from"./Ngd1VEiY.js";import{t as T}from"./B5FoXN4H.js";import{Jt as E,Yt as D,cn as O,ln as k,on as A,sn as j}from"./D4DxtYTA.js";var M=e(r(),1),N=e(t(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=s(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=p(V,[W,k]),K=k(),[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:d,autoComplete:f,disabled:p,required:m,form:g,internal_do_not_use_render:_}=e,v=K(t),[y,b]=N.useState(null),[x,S]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,k]=h({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,j]=h({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(A);N.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=R(()=>j(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,j]);let ee=!y||!!g||!!y.closest(`form`),[F,L]=N.useState(new Set),z=u(),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:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:A,onValueChange:j,open:D,onOpenChange:k,dir:E,triggerPointerDownPosRef:M,disabled:p,name:d,autoComplete:f,form:g,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(O,{...v,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):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:r,disabled:i=!1,...a}=e,s=K(r),c=q(oe,r),l=c.disabled||i,u=o(t,c.onTriggerChange),f=U(r),p=N.useRef(`touch`),[m,h,g]=He(e=>{let t=f().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===c.value));n!==void 0&&c.onValueChange(n.value)}),_=R(e=>{l||(c.onOpenChange(!0),g()),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)(n.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,...a,ref:u,onClick:d(a.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:d(a.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:d(a.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&h(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:r,className:i,style:a,children:s,placeholder:c=``,...l}=e,u=q(ce,r),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=o(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(n.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:r,children:i,...a}=e;return(0,I.jsx)(n.span,{"aria-hidden":!0,...a,ref:t,children:i||`▼`})},`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)(S,{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=a(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=o(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 v(E)},[E]),y();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:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,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)(g,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:d(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,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:d(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:r,onPlaced:i,...a}=e,s=q(Y,r),c=Z(Y,r),[l,u]=N.useState(null),[d,p]=N.useState(null),m=o(t,p),h=U(r),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(),r=b.getBoundingClientRect();if(s.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,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 i=t.right-r.right,a=window.innerWidth-n.right-i,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`,i?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,i]);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:r,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)(n.div,{...a,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.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)(j,{...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:r,nonce:i,...a}=e,s=Z(Ce,r),c=Se(Ce,r),l=o(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:i}),(0,I.jsx)(H.Slot,{scope:r,children:(0,I.jsx)(n.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:d(a.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:r,value:i,disabled:a=!1,textValue:s,...c}=e,l=q(De,r),f=Z(De,r),p=l.value===i,[h,g]=N.useState(s??``),[_,v]=N.useState(!1),y=m(e=>f.itemRefCallback?.(e,i,a)),b=o(t,y),x=u(),S=N.useRef(`touch`),C=R(()=>{a||(l.onValueChange(i),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:r,value:i,disabled:a,textId:x,isSelected:p,onItemTextChange:N.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:r,value:i,disabled:a,textValue:h,children:(0,I.jsx)(n.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...c,ref:b,onFocus:d(c.onFocus,()=>v(!0)),onBlur:d(c.onBlur,()=>v(!1)),onClick:d(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:d(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:d(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:d(c.onPointerMove,e=>{S.current=e.pointerType,a?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:d(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:d(c.onKeyDown,e=>{a||e.target!==e.currentTarget||(f.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:r,className:i,style:a,...s}=e,c=q(Q,r),l=Z(Q,r),u=ke(Q,r),d=ie(Q,r),[p,h]=N.useState(null),g=m(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=o(t,h,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)(n.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:r,...i}=e;return ke(Me,r).isSelected?(0,I.jsx)(n.span,{"aria-hidden":!0,...i,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref: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,a]=N.useState(!1),s=o(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;a(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref: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:r,onAutoScroll:i,...a}=e,o=Z(`SelectScrollButton`,r),s=N.useRef(null),c=U(r),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)(n.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:d(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(i,50))}),onPointerMove:d(a.onPointerMove,()=>{o.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(i,50))}),onPointerLeave:d(a.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},r){let i=q(ze,e),{value:a,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=i,{nativeOptions:m,nativeSelectKey:h}=i,g=N.useRef(null),_=o(r,g),v=a??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(n.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:[$(a)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=m(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)(D,{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{p as t}from"./voJYJ5aN.js";import{a as n,d as r,i,s as a,u as o}from"./4Sc28RjY.js";import{r as s}from"./lXSI1SY-.js";import{r as c,t as l}from"./BChuqxvg.js";import{C as u,D as d,E as f,O as p,S as m,T as h,_ as g,b as _,g as v,v as y,w as b,x,y as S}from"./CRlZzqQn.js";import{n as C,t as w}from"./B-c9Bbn-.js";import{t as T}from"./DyMqorDP.js";import{Jt as E,Yt as D,cn as O,ln as k,on as A,sn as j}from"./Cykx3CBw.js";var M=e(r(),1),N=e(t(),1),P=Object.defineProperty,ee=(e,t)=>P(e,`name`,{value:t,configurable:!0});function F(e){let t=N.useRef({value:e,previous:e});return N.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}ee(F,`usePrevious`);var I=s(),L=Object.defineProperty,R=(e,t)=>L(e,`name`,{value:t,configurable:!0}),z=[` `,`Enter`,`ArrowUp`,`ArrowDown`],B=[` `,`Enter`],V=`Select`,[H,U,W]=l(V),[G,te]=p(V,[W,k]),K=k(),[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:d,autoComplete:f,disabled:p,required:m,form:g,internal_do_not_use_render:_}=e,v=K(t),[y,b]=N.useState(null),[x,S]=N.useState(null),[w,T]=N.useState(!1),E=C(l),[D,k]=h({prop:r,defaultProp:i??!1,onChange:a,caller:V}),[A,j]=h({prop:o,defaultProp:s,onChange:c,caller:V}),M=N.useRef(null),P=N.useRef(A);N.useEffect(()=>{let e=g?y?.ownerDocument.getElementById(g):y?.form;if(e instanceof HTMLFormElement){let t=R(()=>j(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[g,y,j]);let ee=!y||!!g||!!y.closest(`form`),[F,L]=N.useState(new Set),z=u(),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:y,onTriggerChange:b,valueNode:x,onValueNodeChange:S,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:A,onValueChange:j,open:D,onOpenChange:k,dir:E,triggerPointerDownPosRef:M,disabled:p,name:d,autoComplete:f,form:g,nativeOptions:F,nativeSelectKey:B,isFormControl:ee};return(0,I.jsx)(O,{...v,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):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:r,disabled:i=!1,...a}=e,s=K(r),c=q(oe,r),l=c.disabled||i,u=o(t,c.onTriggerChange),f=U(r),p=N.useRef(`touch`),[m,h,g]=He(e=>{let t=f().filter(e=>!e.disabled),n=Ue(t,e,t.find(e=>e.value===c.value));n!==void 0&&c.onValueChange(n.value)}),_=R(e=>{l||(c.onOpenChange(!0),g()),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)(n.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,...a,ref:u,onClick:d(a.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:d(a.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:d(a.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&h(e.key),!(t&&e.key===` `)&&z.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),ce=`SelectValue`,le=N.forwardRef(R(function(e,t){let{__scopeSelect:r,className:i,style:a,children:s,placeholder:c=``,...l}=e,u=q(ce,r),{onValueNodeHasChildrenChange:d}=u,p=s!==void 0,m=o(t,u.onValueNodeChange);f(()=>{d(p)},[d,p]);let h=$(u.value);return(0,I.jsx)(n.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:r,children:i,...a}=e;return(0,I.jsx)(n.span,{"aria-hidden":!0,...a,ref:t,children:i||`▼`})},`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)(S,{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=a(`SelectContent.RemoveScroll`),ve=N.forwardRef(R(function(e,t){let{__scopeSelect:n}=e,{position:r=`item-aligned`,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:s,side:c,sideOffset:l,align:u,alignOffset:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,sticky:b,hideWhenDetached:S,avoidCollisions:C,...w}=e,T=q(Y,n),[E,D]=N.useState(null),[O,k]=N.useState(null),A=o(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 v(E)},[E]),y();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:f,arrowPadding:p,collisionBoundary:m,collisionPadding:h,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)(g,{as:_e,allowPinchZoom:!0,children:(0,I.jsx)(_,{asChild:!0,trapped:T.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:d(i,e=>{T.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,I.jsx)(x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,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:d(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:r,onPlaced:i,...a}=e,s=q(Y,r),c=Z(Y,r),[l,u]=N.useState(null),[d,p]=N.useState(null),m=o(t,p),h=U(r),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(),r=b.getBoundingClientRect();if(s.dir!==`rtl`){let i=r.left-t.left,a=n.left-i,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 i=t.right-r.right,a=window.innerWidth-n.right-i,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`,i?.(),requestAnimationFrame(()=>g.current=!0)}},[h,s.trigger,s.valueNode,l,d,v,y,b,s.dir,i]);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:r,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)(n.div,{...a,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...a.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)(j,{...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:r,nonce:i,...a}=e,s=Z(Ce,r),c=Se(Ce,r),l=o(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:i}),(0,I.jsx)(H.Slot,{scope:r,children:(0,I.jsx)(n.div,{"data-radix-select-viewport":``,role:`presentation`,...a,ref:l,style:{position:`relative`,flex:1,overflow:`hidden auto`,...a.style},onScroll:d(a.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:r,value:i,disabled:a=!1,textValue:s,...c}=e,l=q(De,r),f=Z(De,r),p=l.value===i,[h,g]=N.useState(s??``),[_,v]=N.useState(!1),y=m(e=>f.itemRefCallback?.(e,i,a)),b=o(t,y),x=u(),S=N.useRef(`touch`),C=R(()=>{a||(l.onValueChange(i),l.onOpenChange(!1))},`handleSelect`);return(0,I.jsx)(Oe,{scope:r,value:i,disabled:a,textId:x,isSelected:p,onItemTextChange:N.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,I.jsx)(H.ItemSlot,{scope:r,value:i,disabled:a,textValue:h,children:(0,I.jsx)(n.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":p&&_,"data-state":p?`checked`:`unchecked`,"aria-disabled":a||void 0,"data-disabled":a?``:void 0,tabIndex:a?void 0:-1,...c,ref:b,onFocus:d(c.onFocus,()=>v(!0)),onBlur:d(c.onBlur,()=>v(!1)),onClick:d(c.onClick,()=>{S.current!==`mouse`&&C()}),onPointerUp:d(c.onPointerUp,()=>{S.current===`mouse`&&C()}),onPointerDown:d(c.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:d(c.onPointerMove,e=>{S.current=e.pointerType,a?f.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:d(c.onPointerLeave,e=>{e.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:d(c.onKeyDown,e=>{a||e.target!==e.currentTarget||(f.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:r,className:i,style:a,...s}=e,c=q(Q,r),l=Z(Q,r),u=ke(Q,r),d=ie(Q,r),[p,h]=N.useState(null),g=m(e=>l.itemTextRefCallback?.(e,u.value,u.disabled)),_=o(t,h,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)(n.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:r,...i}=e;return ke(Me,r).isSelected?(0,I.jsx)(n.span,{"aria-hidden":!0,...i,ref:t}):null},`SelectItemIndicator`)),Pe=`SelectScrollUpButton`,Fe=N.forwardRef(R(function(e,t){let n=Z(Pe,e.__scopeSelect),r=Se(Pe,e.__scopeSelect),[i,a]=N.useState(!1),s=o(t,r.onScrollButtonChange);return f(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref: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,a]=N.useState(!1),s=o(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;a(n)};R(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,I.jsx)(Re,{...e,ref: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:r,onAutoScroll:i,...a}=e,o=Z(`SelectScrollButton`,r),s=N.useRef(null),c=U(r),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)(n.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:d(a.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(i,50))}),onPointerMove:d(a.onPointerMove,()=>{o.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(i,50))}),onPointerLeave:d(a.onPointerLeave,()=>{l()})})},`SelectScrollButtonImpl`)),ze=`SelectBubbleInput`,Be=N.forwardRef(R(function({__scopeSelect:e,...t},r){let i=q(ze,e),{value:a,onValueChange:s,required:l,disabled:u,name:d,autoComplete:f,form:p}=i,{nativeOptions:m,nativeSelectKey:h}=i,g=N.useRef(null),_=o(r,g),v=a??``,y=F(v),b=Array.from(m).some(e=>(e.props.value??``)===``);return N.useEffect(()=>{let e=g.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set;if(y!==v&&n){let t=new Event(`change`,{bubbles:!0});n.call(e,v),e.dispatchEvent(t)}},[y,v]),(0,I.jsxs)(n.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:[$(a)&&!b?(0,I.jsx)(`option`,{value:``}):null,Array.from(m)]},h)},`SelectBubbleInput`));function Ve(e){return typeof e==`function`}R(Ve,`isFunction`);function $(e){return e===``||e===void 0}R($,`shouldShowPlaceholder`);function He(e){let t=m(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)(D,{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{p as t}from"./CyX8oVsa.js";import{i as n,r}from"./C76CctEl.js";import{F as i}from"./iz6RnRcO.js";import{ft as a,mt as o}from"./D4DxtYTA.js";import{r as s}from"./CtsakJNi.js";import{t as c}from"./BaTnCkNR.js";import{t as l}from"./CxaujQob.js";import{t as u}from"./C3aiaYZP.js";import{t as d}from"./_zaonxnw.js";var f=e(t(),1);function p(e){let t=e.indexOf(`:`);return t===-1?`(no prefix)`:e.slice(0,t+1)}function m(e){return e<0?`none`:e<36e5?`lt1h`:e<864e5?`lt1d`:e<6048e5?`lt1w`:`ge1w`}function h(){let e=()=>({count:0,bytes:0});return{analyzed:0,totalBytes:0,byType:{},byPrefix:{},ttl:{none:e(),lt1h:e(),lt1d:e(),lt1w:e(),ge1w:e()},top:[],missingSizes:0}}function g(e,t,n){let r=e[t]??={count:0,bytes:0};r.count+=1,r.bytes+=n}function _(e,t){let n={...e,byType:{...e.byType},byPrefix:{...e.byPrefix},ttl:{...e.ttl},top:[...e.top]};for(let e of Object.keys(n.byType))n.byType[e]={...n.byType[e]};for(let e of Object.keys(n.byPrefix))n.byPrefix[e]={...n.byPrefix[e]};for(let e of Object.keys(n.ttl))n.ttl[e]={...n.ttl[e]};for(let e of t){if(e.ttlMs===-2||e.type===`none`)continue;let t=e.bytes??0;e.bytes===null&&(n.missingSizes+=1),n.analyzed+=1,n.totalBytes+=t,g(n.byType,e.type,t),g(n.byPrefix,p(e.key),t);let r=n.ttl[m(e.ttlMs)];r.count+=1,r.bytes+=t,e.bytes!==null&&(n.top.length<50||t>n.top[n.top.length-1].bytes)&&(n.top.push({key:e.key,type:e.type,bytes:t}),n.top.sort((e,t)=>t.bytes-e.bytes),n.top.length>50&&(n.top.length=50))}return n}function v(e){return Object.entries(e).sort((e,t)=>t[1].bytes-e[1].bytes||t[1].count-e[1].count)}var y=r(),b=300,x=[1e4,1e5,1e6];function S({title:e,rows:t,onRow:n}){return(0,y.jsxs)(`section`,{className:`min-w-0`,children:[(0,y.jsx)(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,y.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:(0,y.jsx)(`tbody`,{children:t.map(([e,t,r,i])=>(0,y.jsxs)(`tr`,{className:`border-b border-border/50 ${n?`cursor-pointer hover:bg-muted/50`:``}`,onClick:n?()=>n(e):void 0,children:[(0,y.jsx)(`td`,{className:`max-w-0 truncate py-1 pr-2 font-mono`,title:e,children:e}),(0,y.jsx)(`td`,{className:`w-20 py-1 text-right tabular-nums text-muted-foreground`,children:t}),(0,y.jsx)(`td`,{className:`w-24 py-1 text-right tabular-nums`,children:r}),(0,y.jsx)(`td`,{className:`w-14 py-1 text-right tabular-nums text-muted-foreground`,children:i??``})]},e))})})]})}function C({connectionId:e,tabId:t,input:r}){let{t:p}=n(),m=c(e,t,``),[g,C]=(0,f.useState)(r.trim().split(/\s+/)[0]||`db0`),[w,T]=(0,f.useState)(x[1]),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!1),[M,N]=(0,f.useState)(null),P=(0,f.useRef)(!1),[F,I]=(0,f.useState)(0),L=async()=>{P.current=!1,j(!0),N(null);let e=h();D(e);try{let t=Number(await m.read(`DBSIZE`,g));k({scanned:0,total:Number.isFinite(t)?t:null});let n=`0`,r=0;do{let a=await m.read(`SCAN ${n} COUNT ${b}`,g);n=String(a[0]);let o=a[1].slice(0,Math.max(0,w-r));if(o.length>0){let t=await m.readBatch(o.flatMap(e=>{let t=i(e);return[`MEMORY USAGE ${t}`,`TYPE ${t}`,`PTTL ${t}`]}),g),n=o.map((e,n)=>{let[r,i,a]=t.slice(n*3,n*3+3);return{key:e,type:typeof i==`string`?i:`unknown`,bytes:r instanceof Error||r==null?null:Number(r),ttlMs:a instanceof Error?-1:Number(a)}});e=_(e,n),D(e)}r+=o.length,k({scanned:r,total:Number.isFinite(t)?t:null})}while(n!==`0`&&r<w&&!P.current)}catch(e){N(d(e))}finally{j(!1),I(e=>e+1)}},R=e=>E&&E.totalBytes>0?`${(e/E.totalBytes*100).toFixed(1)}%`:``,z={none:p(`tools.redis.ttlNone`),lt1h:`< 1h`,lt1d:`< 1d`,lt1w:`< 1w`,ge1w:`≥ 1w`},B=O?.total?Math.min(100,Math.round(O.scanned/O.total*100)):null;return(0,y.jsx)(u,{title:p(`tools.redis.memory`),onRefresh:async()=>{A||await L()},error:M,onDismissError:()=>N(null),actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(l,{access:m,value:g,onChange:C,disabled:A,version:F}),(0,y.jsx)(`select`,{value:w,disabled:A,onChange:e=>T(Number(e.target.value)),className:`h-7 rounded border bg-background px-1 text-xs`,children:x.map(e=>(0,y.jsx)(`option`,{value:e,children:p(`tools.redis.upTo`,{count:e.toLocaleString()})},e))}),A?(0,y.jsx)(`button`,{type:`button`,onClick:()=>{P.current=!0},className:`flex h-7 items-center rounded border bg-background px-2 text-muted-foreground hover:text-foreground`,children:p(`tools.stop`)}):(0,y.jsx)(`button`,{type:`button`,onClick:()=>void L(),className:`flex h-7 items-center rounded border border-primary/30 bg-primary/10 px-2 text-primary hover:bg-primary/20`,children:p(`tools.redis.analyze`)})]}),children:(0,y.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.memoryNote`)}),O&&(0,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.jsx)(`div`,{className:`h-1.5 w-full max-w-xl overflow-hidden rounded bg-muted`,children:(0,y.jsx)(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${B??(A?30:100)}%`}})}),(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[p(`tools.redis.scanned`,{scanned:O.scanned.toLocaleString(),total:O.total?.toLocaleString()??`?`}),!A&&O.total!==null&&O.scanned<O.total&&` · ${p(`tools.redis.partial`)}`]})]}),E&&E.analyzed===0&&!A&&(0,y.jsx)(`p`,{className:`rounded border border-dashed p-6 text-center text-sm text-muted-foreground`,children:p(`tools.redis.noKeys`,{database:g})}),E&&E.analyzed>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-6 text-sm`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.keysAnalyzed`)}),(0,y.jsx)(`div`,{className:`font-semibold tabular-nums`,children:E.analyzed.toLocaleString()})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.totalMemory`)}),(0,y.jsx)(`div`,{className:`font-semibold`,children:s(E.totalBytes)})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.average`)}),(0,y.jsx)(`div`,{className:`font-semibold`,children:s(Math.round(E.totalBytes/E.analyzed))})]})]}),E.missingSizes>0&&(0,y.jsx)(`p`,{className:`text-xs text-catppuccin-yellow`,children:p(`tools.redis.missingSizes`,{count:E.missingSizes})}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-6`,children:[(0,y.jsx)(S,{title:p(`tools.redis.byType`),rows:v(E.byType).map(([e,t])=>[e,t.count.toLocaleString(),s(t.bytes),R(t.bytes)])}),(0,y.jsx)(S,{title:p(`tools.redis.byTtl`),rows:Object.keys(z).map(e=>[z[e],E.ttl[e].count.toLocaleString(),s(E.ttl[e].bytes),R(E.ttl[e].bytes)])}),(0,y.jsx)(S,{title:p(`tools.redis.byPrefix`),rows:v(E.byPrefix).slice(0,100).map(([e,t])=>[e,t.count.toLocaleString(),s(t.bytes),R(t.bytes)]),onRow:m.readOnly?void 0:t=>{t.endsWith(`:`)&&o(e,`redis-delete`,p(`tools.redis.delete`),`${g} ${t}*`)}}),(0,y.jsx)(S,{title:p(`tools.redis.largest`),rows:E.top.map(e=>[e.key,e.type,s(e.bytes)]),onRow:t=>a(e,{database:g,name:t})})]}),!m.readOnly&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.prefixHint`)})]})]})})}export{C as MemoryAnalysis};
1
+ import{r as e}from"./hePW80VL.js";import{p as t}from"./voJYJ5aN.js";import{i as n,r}from"./lXSI1SY-.js";import{F as i}from"./NrVAX4Mt.js";import{ft as a,mt as o}from"./Cykx3CBw.js";import{r as s}from"./DQ6CDi_T.js";import{t as c}from"./B2Zfb92y.js";import{t as l}from"./D34ytwl6.js";import{t as u}from"./WvnnIt2x.js";import{t as d}from"./_zaonxnw.js";var f=e(t(),1);function p(e){let t=e.indexOf(`:`);return t===-1?`(no prefix)`:e.slice(0,t+1)}function m(e){return e<0?`none`:e<36e5?`lt1h`:e<864e5?`lt1d`:e<6048e5?`lt1w`:`ge1w`}function h(){let e=()=>({count:0,bytes:0});return{analyzed:0,totalBytes:0,byType:{},byPrefix:{},ttl:{none:e(),lt1h:e(),lt1d:e(),lt1w:e(),ge1w:e()},top:[],missingSizes:0}}function g(e,t,n){let r=e[t]??={count:0,bytes:0};r.count+=1,r.bytes+=n}function _(e,t){let n={...e,byType:{...e.byType},byPrefix:{...e.byPrefix},ttl:{...e.ttl},top:[...e.top]};for(let e of Object.keys(n.byType))n.byType[e]={...n.byType[e]};for(let e of Object.keys(n.byPrefix))n.byPrefix[e]={...n.byPrefix[e]};for(let e of Object.keys(n.ttl))n.ttl[e]={...n.ttl[e]};for(let e of t){if(e.ttlMs===-2||e.type===`none`)continue;let t=e.bytes??0;e.bytes===null&&(n.missingSizes+=1),n.analyzed+=1,n.totalBytes+=t,g(n.byType,e.type,t),g(n.byPrefix,p(e.key),t);let r=n.ttl[m(e.ttlMs)];r.count+=1,r.bytes+=t,e.bytes!==null&&(n.top.length<50||t>n.top[n.top.length-1].bytes)&&(n.top.push({key:e.key,type:e.type,bytes:t}),n.top.sort((e,t)=>t.bytes-e.bytes),n.top.length>50&&(n.top.length=50))}return n}function v(e){return Object.entries(e).sort((e,t)=>t[1].bytes-e[1].bytes||t[1].count-e[1].count)}var y=r(),b=300,x=[1e4,1e5,1e6];function S({title:e,rows:t,onRow:n}){return(0,y.jsxs)(`section`,{className:`min-w-0`,children:[(0,y.jsx)(`h3`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e}),(0,y.jsx)(`table`,{className:`w-full border-collapse text-xs`,children:(0,y.jsx)(`tbody`,{children:t.map(([e,t,r,i])=>(0,y.jsxs)(`tr`,{className:`border-b border-border/50 ${n?`cursor-pointer hover:bg-muted/50`:``}`,onClick:n?()=>n(e):void 0,children:[(0,y.jsx)(`td`,{className:`max-w-0 truncate py-1 pr-2 font-mono`,title:e,children:e}),(0,y.jsx)(`td`,{className:`w-20 py-1 text-right tabular-nums text-muted-foreground`,children:t}),(0,y.jsx)(`td`,{className:`w-24 py-1 text-right tabular-nums`,children:r}),(0,y.jsx)(`td`,{className:`w-14 py-1 text-right tabular-nums text-muted-foreground`,children:i??``})]},e))})})]})}function C({connectionId:e,tabId:t,input:r}){let{t:p}=n(),m=c(e,t,``),[g,C]=(0,f.useState)(r.trim().split(/\s+/)[0]||`db0`),[w,T]=(0,f.useState)(x[1]),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(null),[A,j]=(0,f.useState)(!1),[M,N]=(0,f.useState)(null),P=(0,f.useRef)(!1),[F,I]=(0,f.useState)(0),L=async()=>{P.current=!1,j(!0),N(null);let e=h();D(e);try{let t=Number(await m.read(`DBSIZE`,g));k({scanned:0,total:Number.isFinite(t)?t:null});let n=`0`,r=0;do{let a=await m.read(`SCAN ${n} COUNT ${b}`,g);n=String(a[0]);let o=a[1].slice(0,Math.max(0,w-r));if(o.length>0){let t=await m.readBatch(o.flatMap(e=>{let t=i(e);return[`MEMORY USAGE ${t}`,`TYPE ${t}`,`PTTL ${t}`]}),g),n=o.map((e,n)=>{let[r,i,a]=t.slice(n*3,n*3+3);return{key:e,type:typeof i==`string`?i:`unknown`,bytes:r instanceof Error||r==null?null:Number(r),ttlMs:a instanceof Error?-1:Number(a)}});e=_(e,n),D(e)}r+=o.length,k({scanned:r,total:Number.isFinite(t)?t:null})}while(n!==`0`&&r<w&&!P.current)}catch(e){N(d(e))}finally{j(!1),I(e=>e+1)}},R=e=>E&&E.totalBytes>0?`${(e/E.totalBytes*100).toFixed(1)}%`:``,z={none:p(`tools.redis.ttlNone`),lt1h:`< 1h`,lt1d:`< 1d`,lt1w:`< 1w`,ge1w:`≥ 1w`},B=O?.total?Math.min(100,Math.round(O.scanned/O.total*100)):null;return(0,y.jsx)(u,{title:p(`tools.redis.memory`),onRefresh:async()=>{A||await L()},error:M,onDismissError:()=>N(null),actions:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(l,{access:m,value:g,onChange:C,disabled:A,version:F}),(0,y.jsx)(`select`,{value:w,disabled:A,onChange:e=>T(Number(e.target.value)),className:`h-7 rounded border bg-background px-1 text-xs`,children:x.map(e=>(0,y.jsx)(`option`,{value:e,children:p(`tools.redis.upTo`,{count:e.toLocaleString()})},e))}),A?(0,y.jsx)(`button`,{type:`button`,onClick:()=>{P.current=!0},className:`flex h-7 items-center rounded border bg-background px-2 text-muted-foreground hover:text-foreground`,children:p(`tools.stop`)}):(0,y.jsx)(`button`,{type:`button`,onClick:()=>void L(),className:`flex h-7 items-center rounded border border-primary/30 bg-primary/10 px-2 text-primary hover:bg-primary/20`,children:p(`tools.redis.analyze`)})]}),children:(0,y.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.memoryNote`)}),O&&(0,y.jsxs)(`div`,{className:`space-y-1`,children:[(0,y.jsx)(`div`,{className:`h-1.5 w-full max-w-xl overflow-hidden rounded bg-muted`,children:(0,y.jsx)(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${B??(A?30:100)}%`}})}),(0,y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[p(`tools.redis.scanned`,{scanned:O.scanned.toLocaleString(),total:O.total?.toLocaleString()??`?`}),!A&&O.total!==null&&O.scanned<O.total&&` · ${p(`tools.redis.partial`)}`]})]}),E&&E.analyzed===0&&!A&&(0,y.jsx)(`p`,{className:`rounded border border-dashed p-6 text-center text-sm text-muted-foreground`,children:p(`tools.redis.noKeys`,{database:g})}),E&&E.analyzed>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap gap-6 text-sm`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.keysAnalyzed`)}),(0,y.jsx)(`div`,{className:`font-semibold tabular-nums`,children:E.analyzed.toLocaleString()})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.totalMemory`)}),(0,y.jsx)(`div`,{className:`font-semibold`,children:s(E.totalBytes)})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.average`)}),(0,y.jsx)(`div`,{className:`font-semibold`,children:s(Math.round(E.totalBytes/E.analyzed))})]})]}),E.missingSizes>0&&(0,y.jsx)(`p`,{className:`text-xs text-catppuccin-yellow`,children:p(`tools.redis.missingSizes`,{count:E.missingSizes})}),(0,y.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(320px,1fr))] gap-6`,children:[(0,y.jsx)(S,{title:p(`tools.redis.byType`),rows:v(E.byType).map(([e,t])=>[e,t.count.toLocaleString(),s(t.bytes),R(t.bytes)])}),(0,y.jsx)(S,{title:p(`tools.redis.byTtl`),rows:Object.keys(z).map(e=>[z[e],E.ttl[e].count.toLocaleString(),s(E.ttl[e].bytes),R(E.ttl[e].bytes)])}),(0,y.jsx)(S,{title:p(`tools.redis.byPrefix`),rows:v(E.byPrefix).slice(0,100).map(([e,t])=>[e,t.count.toLocaleString(),s(t.bytes),R(t.bytes)]),onRow:m.readOnly?void 0:t=>{t.endsWith(`:`)&&o(e,`redis-delete`,p(`tools.redis.delete`),`${g} ${t}*`)}}),(0,y.jsx)(S,{title:p(`tools.redis.largest`),rows:E.top.map(e=>[e.key,e.type,s(e.bytes)]),onRow:t=>a(e,{database:g,name:t})})]}),!m.readOnly&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:p(`tools.redis.prefixHint`)})]})]})})}export{C as MemoryAnalysis};