db-studio 1.10.0 → 1.11.0

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 (90) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/index.js.map +1 -1
  3. package/dist/web-dist/assets/{_pathlessLayout-eo6iLvBo.js → _pathlessLayout-CJRtdlfu.js} +73 -73
  4. package/dist/web-dist/assets/_pathlessLayout-CJRtdlfu.js.map +1 -0
  5. package/dist/web-dist/assets/_pathlessLayout-ciCuJ1PR.js +1 -0
  6. package/dist/web-dist/assets/{_pathlessLayout-CEv6uosT.js.map → _pathlessLayout-ciCuJ1PR.js.map} +1 -1
  7. package/dist/web-dist/assets/_queryId-6swfGplM.js +1 -0
  8. package/dist/web-dist/assets/{_queryId-Bq64AuuI.js.map → _queryId-6swfGplM.js.map} +1 -1
  9. package/dist/web-dist/assets/{_table-Bt9of1on.js → _table-DHk3bHnN.js} +1 -1
  10. package/dist/web-dist/assets/{_table-Bt9of1on.js.map → _table-DHk3bHnN.js.map} +1 -1
  11. package/dist/web-dist/assets/_table-dUsH_2LP.js +1 -0
  12. package/dist/web-dist/assets/{_table-CQhKMAcZ.js.map → _table-dUsH_2LP.js.map} +1 -1
  13. package/dist/web-dist/assets/{browser-CFsrLhq1.js → browser-CKmBpcoz.js} +1 -1
  14. package/dist/web-dist/assets/{browser-CFsrLhq1.js.map → browser-CKmBpcoz.js.map} +1 -1
  15. package/dist/web-dist/assets/code-editor-C9H5SO98.js +9 -0
  16. package/dist/web-dist/assets/code-editor-C9H5SO98.js.map +1 -0
  17. package/dist/web-dist/assets/database.store-BvoUSH8Y.js +1 -0
  18. package/dist/web-dist/assets/database.store-BvoUSH8Y.js.map +1 -0
  19. package/dist/web-dist/assets/{dist-B90HBock.js → dist-C-7rnx4R.js} +1 -1
  20. package/dist/web-dist/assets/{dist-B90HBock.js.map → dist-C-7rnx4R.js.map} +1 -1
  21. package/dist/web-dist/assets/highlighted-body-OFNGDK62-qZDgwznf.js +1 -0
  22. package/dist/web-dist/assets/{highlighted-body-OFNGDK62-BGFI1Y6G.js.map → highlighted-body-OFNGDK62-qZDgwznf.js.map} +1 -1
  23. package/dist/web-dist/assets/icons-0UA1AvNu.js +1 -0
  24. package/dist/web-dist/assets/icons-0UA1AvNu.js.map +1 -0
  25. package/dist/web-dist/assets/index-BSNZ1oRs.js +35 -0
  26. package/dist/web-dist/assets/index-BSNZ1oRs.js.map +1 -0
  27. package/dist/web-dist/assets/index-BWKgNfEb.css +2 -0
  28. package/dist/web-dist/assets/{indexes-BKOZUa9Z.js → indexes-D-oUHra7.js} +1 -1
  29. package/dist/web-dist/assets/{indexes-BKOZUa9Z.js.map → indexes-D-oUHra7.js.map} +1 -1
  30. package/dist/web-dist/assets/{logs-DHha3vDy.js → logs-wkipM6zd.js} +1 -1
  31. package/dist/web-dist/assets/{logs-DHha3vDy.js.map → logs-wkipM6zd.js.map} +1 -1
  32. package/dist/web-dist/assets/mermaid-GHXKKRXX-BZ1Tdv8E.js +1 -0
  33. package/dist/web-dist/assets/middleware-CCyr6cvp.js +1 -0
  34. package/dist/web-dist/assets/middleware-CCyr6cvp.js.map +1 -0
  35. package/dist/web-dist/assets/popover-WwEzK7ho.js +1 -0
  36. package/dist/web-dist/assets/popover-WwEzK7ho.js.map +1 -0
  37. package/dist/web-dist/assets/query-runner-B-lngX3P.js +9 -0
  38. package/dist/web-dist/assets/query-runner-B-lngX3P.js.map +1 -0
  39. package/dist/web-dist/assets/{radix-ui-BUv2Nuc1.js → radix-ui-6dcJ5m4U.js} +1 -1
  40. package/dist/web-dist/assets/{radix-ui-BUv2Nuc1.js.map → radix-ui-6dcJ5m4U.js.map} +1 -1
  41. package/dist/web-dist/assets/react-B_x-GW6a.js +1 -0
  42. package/dist/web-dist/assets/react-B_x-GW6a.js.map +1 -0
  43. package/dist/web-dist/assets/{react-dom-0lXVP1OR.js → react-dom-CsRkF-uK.js} +1 -1
  44. package/dist/web-dist/assets/{react-dom-0lXVP1OR.js.map → react-dom-CsRkF-uK.js.map} +1 -1
  45. package/dist/web-dist/assets/{redis-value-CJoRCZun.js → redis-value-Dq29EMpv.js} +1 -1
  46. package/dist/web-dist/assets/{redis-value-CJoRCZun.js.map → redis-value-Dq29EMpv.js.map} +1 -1
  47. package/dist/web-dist/assets/runner-CL63BPMX.js +1 -0
  48. package/dist/web-dist/assets/{runner-CZKDzRoU.js.map → runner-CL63BPMX.js.map} +1 -1
  49. package/dist/web-dist/assets/schema-BNzZaUjg.js +64 -0
  50. package/dist/web-dist/assets/schema-BNzZaUjg.js.map +1 -0
  51. package/dist/web-dist/assets/{schema-0sozVL-z.js → schema-CIr5j9z3.js} +1 -1
  52. package/dist/web-dist/assets/{schema-0sozVL-z.js.map → schema-CIr5j9z3.js.map} +1 -1
  53. package/dist/web-dist/assets/{table-CPQhgD-a.js → table-BoQghHv7.js} +1 -1
  54. package/dist/web-dist/assets/{table-CPQhgD-a.js.map → table-BoQghHv7.js.map} +1 -1
  55. package/dist/web-dist/assets/tanstack-C-qfmRNM.js +10 -0
  56. package/dist/web-dist/assets/tanstack-C-qfmRNM.js.map +1 -0
  57. package/dist/web-dist/assets/toggle-group-CxRlYNqR.js +1 -0
  58. package/dist/web-dist/assets/toggle-group-CxRlYNqR.js.map +1 -0
  59. package/dist/web-dist/assets/{tooltip-DinwklI8.js → tooltip-1-bWFncb.js} +2 -2
  60. package/dist/web-dist/assets/{tooltip-DinwklI8.js.map → tooltip-1-bWFncb.js.map} +1 -1
  61. package/dist/web-dist/assets/{visualizer-DTPn0ywW.js → visualizer-qFaRAy7F.js} +1 -1
  62. package/dist/web-dist/assets/{visualizer-DTPn0ywW.js.map → visualizer-qFaRAy7F.js.map} +1 -1
  63. package/dist/web-dist/index.html +13 -11
  64. package/package.json +1 -1
  65. package/dist/web-dist/assets/_pathlessLayout-CEv6uosT.js +0 -1
  66. package/dist/web-dist/assets/_pathlessLayout-eo6iLvBo.js.map +0 -1
  67. package/dist/web-dist/assets/_queryId-Bq64AuuI.js +0 -1
  68. package/dist/web-dist/assets/_table-CQhKMAcZ.js +0 -1
  69. package/dist/web-dist/assets/code-editor-DQ86aZkm.js +0 -9
  70. package/dist/web-dist/assets/code-editor-DQ86aZkm.js.map +0 -1
  71. package/dist/web-dist/assets/database.store-KDHkiedw.js +0 -1
  72. package/dist/web-dist/assets/database.store-KDHkiedw.js.map +0 -1
  73. package/dist/web-dist/assets/highlighted-body-OFNGDK62-BGFI1Y6G.js +0 -1
  74. package/dist/web-dist/assets/icons-Bm7rSZLJ.js +0 -1
  75. package/dist/web-dist/assets/icons-Bm7rSZLJ.js.map +0 -1
  76. package/dist/web-dist/assets/index-BtqHnOp0.js +0 -23
  77. package/dist/web-dist/assets/index-BtqHnOp0.js.map +0 -1
  78. package/dist/web-dist/assets/index-ktDWx_UP.css +0 -2
  79. package/dist/web-dist/assets/mermaid-GHXKKRXX-DjR37lQN.js +0 -1
  80. package/dist/web-dist/assets/popover-Cm3PsrMh.js +0 -1
  81. package/dist/web-dist/assets/popover-Cm3PsrMh.js.map +0 -1
  82. package/dist/web-dist/assets/query-runner-6BhVPaC9.js +0 -9
  83. package/dist/web-dist/assets/query-runner-6BhVPaC9.js.map +0 -1
  84. package/dist/web-dist/assets/runner-CZKDzRoU.js +0 -1
  85. package/dist/web-dist/assets/schema-cZHeTHA0.js +0 -64
  86. package/dist/web-dist/assets/schema-cZHeTHA0.js.map +0 -1
  87. package/dist/web-dist/assets/tanstack-D6l4LIt3.js +0 -10
  88. package/dist/web-dist/assets/tanstack-D6l4LIt3.js.map +0 -1
  89. package/dist/web-dist/assets/toggle-group-BRWnLosM.js +0 -1
  90. package/dist/web-dist/assets/toggle-group-BRWnLosM.js.map +0 -1
@@ -0,0 +1 @@
1
+ import{g as r}from"./tanstack-C-qfmRNM.js";import{kt as o}from"./radix-ui-6dcJ5m4U.js";import{t as s}from"./database.store-BvoUSH8Y.js";var e=o();function m(){const{dbType:t}=s();return t==="redis"?(0,e.jsx)(r,{to:"/browser"}):(0,e.jsx)("main",{className:"flex-1 flex items-center justify-center",children:"Select a tab to get started"})}export{m as component};
@@ -1 +1 @@
1
- {"version":3,"file":"_pathlessLayout-CEv6uosT.js","names":["Navigate","useDatabaseStore","RouteComponent","dbType","component"],"sources":["../../src/routes/_pathlessLayout/index.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute, Navigate } from \"@tanstack/react-router\";\nimport { useDatabaseStore } from \"@/stores/database.store\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { dbType } = useDatabaseStore();\n\tif (dbType === \"redis\") return <Navigate to=\"/browser\" />;\n\treturn (\n\t\t<main className=\"flex-1 flex items-center justify-center\">\n\t\t\tSelect a tab to get started\n\t\t</main>\n\t);\n}\n"],"mappings":"kJAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,OAAAA,CAAAA,EAAWF,EAAiB,EACpC,OAAIE,IAAW,WAAgB,EAAA,KAAC,EAAD,CAAU,GAAG,UAAU,CAAA,KAErD,EAAA,KAAC,OAAD,CAAM,UAAU,0CAAyC,SAAA,6BAEnD,CAAA,CAER"}
1
+ {"version":3,"file":"_pathlessLayout-ciCuJ1PR.js","names":["Navigate","useDatabaseStore","RouteComponent","dbType","component"],"sources":["../../src/routes/_pathlessLayout/index.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute, Navigate } from \"@tanstack/react-router\";\nimport { useDatabaseStore } from \"@/stores/database.store\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { dbType } = useDatabaseStore();\n\tif (dbType === \"redis\") return <Navigate to=\"/browser\" />;\n\treturn (\n\t\t<main className=\"flex-1 flex items-center justify-center\">\n\t\t\tSelect a tab to get started\n\t\t</main>\n\t);\n}\n"],"mappings":"kJAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,OAAAA,CAAAA,EAAWF,EAAiB,EACpC,OAAIE,IAAW,WAAgB,EAAA,KAAC,EAAD,CAAU,GAAG,UAAU,CAAA,KAErD,EAAA,KAAC,OAAD,CAAM,UAAU,0CAAyC,SAAA,6BAEnD,CAAA,CAER"}
@@ -0,0 +1 @@
1
+ import{kt as o}from"./radix-ui-6dcJ5m4U.js";import{n as t}from"./index-BSNZ1oRs.js";import{t as e}from"./query-runner-B-lngX3P.js";var n=o();function i(){const{queryId:r}=t.useParams();return(0,n.jsx)(e,{queryId:r})}export{i as component};
@@ -1 +1 @@
1
- {"version":3,"file":"_queryId-Bq64AuuI.js","names":["RunnerScreen","Route","RouteComponent","queryId","useParams","component"],"sources":["../../src/routes/_pathlessLayout/runner/$queryId.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { RunnerScreen } from \"@/features/query-runner\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/runner/$queryId\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { queryId } = Route.useParams();\n\treturn <RunnerScreen queryId={queryId} />;\n}\n"],"mappings":"6IAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,QAAAA,CAAAA,EAAYF,EAAMG,UAAU,EACpC,SAAO,EAAA,KAAC,EAAD,CAAuBD,QAAAA,CAAQ,CAAA,CACvC"}
1
+ {"version":3,"file":"_queryId-6swfGplM.js","names":["RunnerScreen","Route","RouteComponent","queryId","useParams","component"],"sources":["../../src/routes/_pathlessLayout/runner/$queryId.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { RunnerScreen } from \"@/features/query-runner\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/runner/$queryId\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { queryId } = Route.useParams();\n\treturn <RunnerScreen queryId={queryId} />;\n}\n"],"mappings":"6IAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,QAAAA,CAAAA,EAAYF,EAAMG,UAAU,EACpC,SAAO,EAAA,KAAC,EAAD,CAAuBD,QAAAA,CAAQ,CAAA,CACvC"}
@@ -1 +1 @@
1
- import{kt as r}from"./radix-ui-BUv2Nuc1.js";import{t}from"./schema-cZHeTHA0.js";import{n as m}from"./index-BtqHnOp0.js";var e=r();function i(){const{table:o}=m.useParams();return(0,e.jsx)("main",{className:"flex-1 flex flex-col overflow-hidden",children:(0,e.jsx)(t,{tableName:o})})}export{i as component};
1
+ import{kt as r}from"./radix-ui-6dcJ5m4U.js";import{t}from"./schema-BNzZaUjg.js";import{t as m}from"./index-BSNZ1oRs.js";var e=r();function i(){const{table:o}=m.useParams();return(0,e.jsx)("main",{className:"flex-1 flex flex-col overflow-hidden",children:(0,e.jsx)(t,{tableName:o})})}export{i as component};
@@ -1 +1 @@
1
- {"version":3,"file":"_table-Bt9of1on.js","names":["SchemaScreen","Route","RouteComponent","table","useParams","component"],"sources":["../../src/routes/_pathlessLayout/schema/$table.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { SchemaScreen } from \"@/features/schema\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/schema/$table\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { table } = Route.useParams();\n\n\treturn (\n\t\t<main className=\"flex-1 flex flex-col overflow-hidden\">\n\t\t\t<SchemaScreen tableName={table} />\n\t\t</main>\n\t);\n}\n"],"mappings":"kIAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,MAAAA,CAAAA,EAAUF,EAAMG,UAAU,EAElC,SACC,EAAA,KAAC,OAAD,CAAM,UAAU,uCACf,YAAA,EAAA,KAAC,EAAD,CAAc,UAAWD,CAAM,CAAA,CAC1B,CAAA,CAER"}
1
+ {"version":3,"file":"_table-DHk3bHnN.js","names":["SchemaScreen","Route","RouteComponent","table","useParams","component"],"sources":["../../src/routes/_pathlessLayout/schema/$table.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { SchemaScreen } from \"@/features/schema\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/schema/$table\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { table } = Route.useParams();\n\n\treturn (\n\t\t<main className=\"flex-1 flex flex-col overflow-hidden\">\n\t\t\t<SchemaScreen tableName={table} />\n\t\t</main>\n\t);\n}\n"],"mappings":"kIAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,MAAAA,CAAAA,EAAUF,EAAMG,UAAU,EAElC,SACC,EAAA,KAAC,OAAD,CAAM,UAAU,uCACf,YAAA,EAAA,KAAC,EAAD,CAAc,UAAWD,CAAM,CAAA,CAC1B,CAAA,CAER"}
@@ -0,0 +1 @@
1
+ import{kt as t}from"./radix-ui-6dcJ5m4U.js";import{u as r,y as o}from"./index-BSNZ1oRs.js";var a=t();function s(){const{table:e}=o.useParams();return(0,a.jsx)(r,{tableName:e})}export{s as component};
@@ -1 +1 @@
1
- {"version":3,"file":"_table-CQhKMAcZ.js","names":["TableScreen","Route","RouteComponent","table","useParams","component"],"sources":["../../src/routes/_pathlessLayout/table/$table.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { TableScreen } from \"@/features/tables\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/table/$table\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { table } = Route.useParams();\n\treturn <TableScreen tableName={table} />;\n}\n"],"mappings":"qGAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,MAAAA,CAAAA,EAAUF,EAAMG,UAAU,EAClC,SAAO,EAAA,KAAC,EAAD,CAAa,UAAWD,CAAM,CAAA,CACtC"}
1
+ {"version":3,"file":"_table-dUsH_2LP.js","names":["TableScreen","Route","RouteComponent","table","useParams","component"],"sources":["../../src/routes/_pathlessLayout/table/$table.tsx?tsr-split=component"],"sourcesContent":["import { createFileRoute } from \"@tanstack/react-router\";\nimport { TableScreen } from \"@/features/tables\";\n\nexport const Route = createFileRoute(\"/_pathlessLayout/table/$table\")({\n\tcomponent: RouteComponent,\n});\n\nfunction RouteComponent() {\n\tconst { table } = Route.useParams();\n\treturn <TableScreen tableName={table} />;\n}\n"],"mappings":"qGAOA,SAASE,GAAiB,CACzB,KAAM,CAAEC,MAAAA,CAAAA,EAAUF,EAAMG,UAAU,EAClC,SAAO,EAAA,KAAC,EAAD,CAAa,UAAWD,CAAM,CAAA,CACtC"}
@@ -1 +1 @@
1
- import{r as me}from"./rolldown-runtime-CXHxssQy.js";import{_ as he}from"./tanstack-D6l4LIt3.js";import{F as xe,R as fe,X as be,f as pe,h as ee,i as M,m as ge,o as ve,ot as je,p as J,rt as ye,v as Ne}from"./icons-Bm7rSZLJ.js";import{kt as ke}from"./radix-ui-BUv2Nuc1.js";import{n as we}from"./dist-B90HBock.js";import{E as Se,H as q,V as Ce,c as m,i as Z,n as Q,t as W}from"./tooltip-DinwklI8.js";import{t as Re}from"./database.store-KDHkiedw.js";import{a as I,f as De,i as Me,o as Le,r as _e,t as Te}from"./popover-Cm3PsrMh.js";import{L as B,_ as $e,c as Ee,d as Fe,f as Oe,g as ze,h as Ae,k as Pe,l as X,m as Be,o as Y,p as Je,s as Ie,v as Ke}from"./index-BtqHnOp0.js";import{i as He,n as ie,t as Ue}from"./toggle-group-BRWnLosM.js";import{a as Ve,i as Ge,n as S,o as qe,r as Ze,t as D}from"./redis-value-CJoRCZun.js";var p=me(je(),1),e=ke(),le=({text:s,label:r,className:t})=>{const[a,i]=(0,p.useState)(!1);return(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:t,onClick:async()=>{await navigator.clipboard.writeText(typeof s=="function"?s():s),i(!0),window.setTimeout(()=>i(!1),1200)},"aria-label":r,children:a?(0,e.jsx)(be,{}):(0,e.jsx)(fe,{})})}),(0,e.jsx)(Q,{children:a?"Copied":r})]})},Qe=[{label:"60s",ttlMs:6e4},{label:"10m",ttlMs:6e5},{label:"1h",ttlMs:36e5},{label:"1d",ttlMs:864e5},{label:"7d",ttlMs:6048e5}],We=s=>s===null?"—":s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KiB`:`${(s/1048576).toFixed(1)} MiB`,Xe=s=>{const r=Math.max(0,Math.ceil(s/1e3));if(r<60)return`${r}s`;const t=Math.floor(r/60);if(t<60)return`${t}m ${r%60}s`;const a=Math.floor(t/60);return a<24?`${a}h ${t%60}m`:`${Math.floor(a/24)}d ${a%24}h`},Ye=s=>{const[,r]=(0,p.useReducer)(t=>t+1,0);(0,p.useEffect)(()=>{if(!s)return;const t=window.setInterval(r,1e3);return()=>window.clearInterval(t)},[s])},es=({detail:s,label:r,loadedCount:t,fetchedAt:a,isFetching:i,pending:n,command:l,act:o,onRefresh:d,onOpenRunner:h,onDelete:c})=>{const[b,u]=(0,p.useState)(s.key),[L,H]=(0,p.useState)("");Ye(s.ttlMs>0);const C=s.ttlMs>0?s.ttlMs-(Date.now()-a):s.ttlMs,N=s.ttlMs===-1,x=!N&&C<=0,A=[{name:"TTL",value:N?"∞":x?"expired":Xe(C),hint:N?"No expiry — the key persists until deleted.":x?"The TTL elapsed; Redis has evicted or is about to evict this key.":`Expires ${new Date(a+s.ttlMs).toLocaleString()}`,alert:x},{name:"MEM",value:We(s.memoryBytes),hint:"Approximate memory usage reported by MEMORY USAGE."},{name:"LEN",value:s.length?.toLocaleString()??"—",hint:t!==null&&s.length!==null?`${t.toLocaleString()} of ${s.length.toLocaleString()} entries loaded in this view.`:"Length reported by Redis (entries, or bytes for strings)."},{name:"REV",value:s.revision.slice(0,8),hint:"Optimistic-lock revision. Writes are rejected when the key changed since this fetch."},{name:"AT",value:new Date(a).toLocaleTimeString(),hint:"When this snapshot was fetched from Redis."}];return(0,e.jsx)("header",{className:"border-b border-border",children:(0,e.jsxs)("div",{className:"flex min-h-10 items-stretch justify-between",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:[(0,e.jsxs)("div",{className:"flex min-w-0 max-w-[min(36rem,45vw)] shrink items-center gap-1 px-3 py-1.5",children:[(0,e.jsx)("code",{className:"min-w-0 truncate text-sm text-foreground",title:r,children:r||"(empty key)"}),(0,e.jsx)(le,{text:s.key.utf8??s.key.base64,label:"Copy key name",className:"shrink-0 text-muted-foreground"}),(0,e.jsx)(Le,{variant:"outline",className:"h-4 shrink-0 rounded-sm px-1.5 text-[8px] font-normal uppercase text-muted-foreground",children:s.type})]}),A.map(({name:v,value:P,hint:_,alert:T},$)=>(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsxs)("div",{className:q("flex shrink-0 cursor-default items-center gap-1.5 border-s border-border px-2 text-[10px]",$===A.length-1&&"border-e"),children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:v}),(0,e.jsx)("span",{className:q("tabular-nums",T?"text-destructive":"text-foreground"),children:P})]})}),(0,e.jsx)(Q,{side:"bottom",children:_})]},v))]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-stretch",children:[(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",onClick:d,disabled:i,children:[(0,e.jsx)(ge,{className:q(i&&"animate-spin")})," Refresh"]}),l&&(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",onClick:h,children:[(0,e.jsx)(ve,{})," Runner"]})}),(0,e.jsxs)(Q,{side:"bottom",children:["Open in the query runner as ",(0,e.jsx)("code",{className:"font-mono",children:l})]})]}),(0,e.jsxs)(Te,{children:[(0,e.jsx)(Me,{asChild:!0,children:(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",children:[(0,e.jsx)(Ne,{})," Edit"]})}),(0,e.jsx)(_e,{align:"end",className:"w-72 rounded-sm p-3 font-mono",children:(0,e.jsxs)(Ee,{className:"gap-4",children:[(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-key-rename",children:"Rename key"}),(0,e.jsxs)("form",{className:"flex",onSubmit:v=>{v.preventDefault(),!(b===null||b.base64===s.key.base64||n)&&o({action:"rename",newKey:b})},children:[(0,e.jsx)(S,{id:"redis-key-rename",value:b,onChange:u,className:"rounded-e-none font-mono"}),(0,e.jsx)(m,{type:"submit",size:"icon",className:"h-auto self-stretch rounded-s-none border-0 bg-clip-border",disabled:b===null||b.base64===s.key.base64||n,"aria-label":"Rename key",children:(0,e.jsx)(ye,{})})]})]}),(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-key-ttl-operation",children:"TTL in seconds"}),(0,e.jsxs)("form",{className:"flex",onSubmit:v=>{v.preventDefault(),!n&&o({action:"setTtl",ttlMs:L?Number(L)*1e3:null})},children:[(0,e.jsx)(I,{id:"redis-key-ttl-operation",type:"number",min:1,value:L,onChange:v=>H(v.target.value),placeholder:s.ttlMs>0?String(Math.ceil(s.ttlMs/1e3)):"Persistent",className:"rounded-e-none font-mono"}),(0,e.jsx)(m,{type:"submit",className:"h-auto self-stretch rounded-s-none border-0 bg-clip-border",disabled:n,children:"Apply"})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-1",children:[Qe.map(v=>(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",disabled:n,onClick:()=>o({action:"setTtl",ttlMs:v.ttlMs}),children:v.label},v.label)),(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",disabled:n||N,onClick:()=>o({action:"setTtl",ttlMs:null}),children:"Persist"})]}),(0,e.jsx)(Ie,{children:"Leave empty to persist the key."})]})]})})]}),(0,e.jsxs)(m,{variant:"destructive",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",disabled:n,onClick:c,children:[(0,e.jsx)(M,{})," Delete"]})]})]})})},w=Ge(""),j=s=>s.utf8??`base64:${s.base64}`,E=(s,...r)=>r.some(t=>String(t).toLowerCase().includes(s)),F=s=>{switch(s.kind){case"string":return JSON.stringify(j(s.value),null,2);case"hash":return JSON.stringify(Object.fromEntries(s.entries.map(r=>[j(r.field),j(r.value)])),null,2);case"list":return JSON.stringify(s.entries.map(r=>j(r.value)),null,2);case"set":return JSON.stringify(s.members.map(j),null,2);case"zset":return JSON.stringify(s.entries.map(r=>({member:j(r.member),score:r.score})),null,2);case"stream":return JSON.stringify(s.entries.map(r=>({id:r.id,fields:Object.fromEntries(r.fields.map(t=>[j(t.field),j(t.value)]))})),null,2);default:return""}},K=(s,r)=>{const[t,a]=(0,p.useState)(s),[i,n]=(0,p.useState)(r);return i!==r&&(n(r),a(s)),[t,a]},O=({filtered:s})=>(0,e.jsx)("div",{className:"flex h-10 items-center justify-center px-2 text-xs text-muted-foreground",children:s?"No loaded entries match the filter.":"No entries loaded."}),z=({filter:s,onFilterChange:r,shownCount:t,loadedCount:a,totalCount:i,copyJson:n,extra:l,header:o,children:d,footer:h})=>(0,e.jsxs)("div",{className:"overflow-hidden border border-border",children:[(0,e.jsxs)("div",{className:"flex h-8 items-center gap-1 border-b border-border bg-muted/10 px-1",children:[(0,e.jsx)(pe,{className:"ms-1 size-3 shrink-0 text-muted-foreground"}),(0,e.jsx)(I,{variant:"outline",value:s,onChange:c=>r(c.target.value),placeholder:"Filter loaded entries","aria-label":"Filter loaded entries",className:"h-6 flex-1 rounded-none border-none px-1 font-mono focus-visible:ring-0"}),l,(0,e.jsx)("span",{className:"shrink-0 px-1 text-[10px] tabular-nums text-muted-foreground",children:s?`${t} / ${a}`:i!==null&&i>a?`${a.toLocaleString()} of ${i.toLocaleString()}`:a.toLocaleString()}),(0,e.jsx)(le,{text:n,label:"Copy loaded entries as JSON"})]}),o,d,h]}),se=({labels:s,onSave:r,pending:t,score:a=!1})=>{const[i,n]=(0,p.useState)(w),[l,o]=(0,p.useState)(w),[d,h]=(0,p.useState)("0"),c=i===null||!a&&l===null,b=async u=>{u.preventDefault(),!(i===null||l===null)&&await r(i,a?Number(d):l)&&(n(w),o(w),h("0"))};return(0,e.jsxs)("form",{onSubmit:b,className:"grid grid-cols-[1fr_1fr_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:i,onChange:n,placeholder:s[0]}),a?(0,e.jsx)(I,{type:"number",step:"any",value:d,onChange:u=>h(u.target.value),placeholder:s[1],className:"font-mono"}):(0,e.jsx)(S,{value:l,onChange:o,placeholder:s[1]}),(0,e.jsxs)(m,{type:"submit",disabled:t||c,children:[(0,e.jsx)(ee,{})," Add"]})]})},ss=({value:s,truncated:r,act:t,pending:a,onLoadFull:i,onDownload:n})=>{const[l,o]=K(s,s.base64),d=l!==null&&l.base64!==s.base64;return(0,e.jsxs)("div",{className:"space-y-3",children:[r&&(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border pb-3 sm:grid-cols-[1fr_auto] sm:items-center",children:[(0,e.jsx)(B,{variant:"warning",title:"Preview truncated",message:"Load the full value before editing (up to the 8 MiB response cap).",className:"rounded-sm"}),(0,e.jsx)(m,{variant:"outline",onClick:i,children:"Load full"})]}),(0,e.jsx)(D,{value:s,onDownload:n}),(0,e.jsxs)("form",{onSubmit:h=>{h.preventDefault(),l!==null&&d&&t({action:"setString",value:l})},className:"border border-border p-3",children:[(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-string-value",children:"Replace value"}),(0,e.jsx)(S,{id:"redis-string-value",value:l,onChange:o})]}),(0,e.jsxs)(m,{type:"submit",className:"mt-3",disabled:r||a||!d,children:[(0,e.jsx)(J,{})," Save value"]})]})]})},rs=({field:s,value:r,act:t,pending:a})=>{const[i,n]=K(r,r.base64),l=i!==null&&i.base64!==r.base64;return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[minmax(10rem,0.7fr)_1fr_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)(D,{value:s,compact:!0}),(0,e.jsx)(S,{value:i,onChange:n}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:l?"text-primary":void 0,disabled:a||!l,onClick:()=>i!==null&&t({action:"upsertHash",field:s,value:i}),"aria-label":"Save hash value",children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"deleteHash",field:s}),"aria-label":"Delete hash field",children:(0,e.jsx)(M,{})})]})]})},ts=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),l=i.trim().toLowerCase(),o=l?s.entries.filter(d=>E(l,j(d.field),j(d.value))):s.entries;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:o.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[minmax(10rem,0.7fr)_1fr_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Field"}),(0,e.jsx)("span",{children:"Value"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{labels:["field","value"],pending:a,onSave:(d,h)=>t({action:"upsertHash",field:d,value:h})}),children:o.length===0?(0,e.jsx)(O,{filtered:l.length>0}):o.map(d=>(0,e.jsx)(rs,{field:d.field,value:d.value,act:t,pending:a},d.field.base64))})},as=({index:s,value:r,revision:t,act:a,pending:i})=>{const[n,l]=K(r,`${t}:${r.base64}`),o=n!==null&&n.base64!==r.base64;return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[3rem_1fr_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)("code",{className:"text-xs text-muted-foreground",children:s}),(0,e.jsx)(S,{value:n,onChange:l}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:o?"text-primary":void 0,disabled:i||!o,onClick:()=>n!==null&&a({action:"setList",index:s,value:n}),"aria-label":`Save list item ${s}`,children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:i,onClick:()=>a({action:"deleteList",index:s}),"aria-label":`Delete list item ${s}`,children:(0,e.jsx)(M,{})})]})]})},ns=({value:s,revision:r,total:t,act:a,pending:i})=>{const[n,l]=(0,p.useState)(""),[o,d]=(0,p.useState)(w),h=n.trim().toLowerCase(),c=h?s.entries.filter(u=>E(h,u.index,j(u.value))):s.entries,b=async u=>{o!==null&&await a({action:"pushList",side:u,value:o})&&d(w)};return(0,e.jsx)(z,{filter:n,onFilterChange:l,shownCount:c.length,loadedCount:s.entries.length,totalCount:t,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[3rem_1fr_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Index"}),(0,e.jsx)("span",{children:"Value"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsxs)("form",{onSubmit:u=>{u.preventDefault(),b("right")},className:"grid grid-cols-[1fr_auto_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:o,onChange:d,placeholder:"new item"}),(0,e.jsx)(m,{type:"button",variant:"outline",disabled:i||o===null,onClick:()=>b("left"),children:"Push left"}),(0,e.jsx)(m,{type:"submit",disabled:i||o===null,children:"Push right"})]}),children:c.length===0?(0,e.jsx)(O,{filtered:h.length>0}):c.map(u=>(0,e.jsx)(as,{index:u.index,value:u.value,revision:r,act:a,pending:i},u.index))})},is=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),[l,o]=(0,p.useState)(w),d=i.trim().toLowerCase(),h=d?s.members.filter(c=>E(d,j(c))):s.members;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:h.length,loadedCount:s.members.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[1fr_2rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Member"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsxs)("form",{onSubmit:async c=>{c.preventDefault(),l!==null&&await t({action:"addSet",member:l})&&o(w)},className:"grid grid-cols-[1fr_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:l,onChange:o,placeholder:"new member"}),(0,e.jsxs)(m,{type:"submit",disabled:a||l===null,children:[(0,e.jsx)(ee,{})," Add member"]})]}),children:h.length===0?(0,e.jsx)(O,{filtered:d.length>0}):h.map(c=>(0,e.jsxs)("div",{className:"flex min-h-8 items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)("span",{className:"min-w-0 flex-1",children:(0,e.jsx)(D,{value:c,compact:!0})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"removeSet",member:c}),"aria-label":"Remove set member",children:(0,e.jsx)(M,{})})]},c.base64))})},ls=({member:s,score:r,act:t,pending:a})=>{const[i,n]=K(String(r),String(r)),l=Number(i),o=i!==String(r);return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[1fr_8rem_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)(D,{value:s,compact:!0}),(0,e.jsx)(I,{inputMode:"decimal",value:i,onChange:d=>n(d.target.value),"aria-label":"Sorted set score",className:"font-mono"}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:o?"text-primary":void 0,disabled:a||!o||!Number.isFinite(l),onClick:()=>t({action:"upsertZset",member:s,score:l}),"aria-label":"Save sorted set score",children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"removeZset",member:s}),"aria-label":"Remove sorted set member",children:(0,e.jsx)(M,{})})]})]})},os=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),l=i.trim().toLowerCase(),o=l?s.entries.filter(d=>E(l,j(d.member),d.score)):s.entries;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:o.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[1fr_8rem_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Member"}),(0,e.jsx)("span",{children:"Score"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{score:!0,labels:["member","score"],pending:a,onSave:(d,h)=>t({action:"upsertZset",member:d,score:h})}),children:o.length===0?(0,e.jsx)(O,{filtered:l.length>0}):o.map(d=>(0,e.jsx)(ls,{member:d.member,score:d.score,act:t,pending:a},d.member.base64))})},ds=({value:s,total:r,act:t,pending:a,direction:i,onDirectionChange:n})=>{const[l,o]=(0,p.useState)(""),d=l.trim().toLowerCase(),h=d?s.entries.filter(c=>E(d,c.id,...c.fields.flatMap(b=>[j(b.field),j(b.value)]))):s.entries;return(0,e.jsx)(z,{filter:l,onFilterChange:o,shownCount:h.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),extra:(0,e.jsxs)(Ue,{type:"single",variant:"ghost",size:"sm",value:i,onValueChange:c=>c&&n(c),"aria-label":"Stream order",className:"shrink-0 rounded-none",children:[(0,e.jsx)(ie,{value:"forward",className:"h-6 rounded-none px-2 text-[10px]",children:"Oldest first"}),(0,e.jsx)(ie,{value:"backward",className:"h-6 rounded-none px-2 text-[10px]",children:"Newest first"})]}),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[10rem_1fr_2rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Entry ID"}),(0,e.jsx)("span",{children:"Fields"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{labels:["field","value"],pending:a,onSave:(c,b)=>t({action:"appendStream",id:"*",fields:[{field:c,value:b}]})}),children:h.length===0?(0,e.jsx)(O,{filtered:d.length>0}):h.map(c=>(0,e.jsxs)("div",{className:"grid grid-cols-[10rem_1fr_2rem] border-b border-border",children:[(0,e.jsx)("code",{className:"border-e border-border px-2 py-1.5 text-xs text-primary",children:c.id}),(0,e.jsx)("div",{className:"grid gap-1 px-2 py-1.5",children:c.fields.map(b=>(0,e.jsxs)("div",{className:"grid grid-cols-[minmax(8rem,0.4fr)_1fr] gap-3",children:[(0,e.jsx)(D,{value:b.field,compact:!0}),(0,e.jsx)(D,{value:b.value,compact:!0})]},b.field.base64))}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"rounded-none text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"deleteStream",id:c.id}),"aria-label":`Delete stream entry ${c.id}`,children:(0,e.jsx)(M,{})})]},c.id))})},cs=({detail:s,act:r,pending:t,onLoadFull:a,onDownload:i,streamDirection:n,onStreamDirectionChange:l})=>{const o=s.value;switch(o.kind){case"string":return(0,e.jsx)(ss,{value:o.value,truncated:o.truncated,act:r,pending:t,onLoadFull:a,onDownload:i});case"hash":return(0,e.jsx)(ts,{value:o,total:s.length,act:r,pending:t});case"list":return(0,e.jsx)(ns,{value:o,revision:s.revision,total:s.length,act:r,pending:t});case"set":return(0,e.jsx)(is,{value:o,total:s.length,act:r,pending:t});case"zset":return(0,e.jsx)(os,{value:o,total:s.length,act:r,pending:t});case"stream":return(0,e.jsx)(ds,{value:o,total:s.length,act:r,pending:t,direction:n,onDirectionChange:l});default:return(0,e.jsx)(B,{variant:"info",title:"Metadata only",message:"This Redis module type cannot be edited in this release.",className:"rounded-sm"})}},us=s=>{if(s.key.utf8===void 0)return null;const r=JSON.stringify(s.key.utf8);switch(s.type){case"string":return`GET ${r}`;case"hash":return`HGETALL ${r}`;case"list":return`LRANGE ${r} 0 -1`;case"set":return`SMEMBERS ${r}`;case"zset":return`ZRANGE ${r} 0 -1 WITHSCORES`;case"stream":return`XRANGE ${r} - + COUNT 100`;default:return null}},ms=s=>{switch(s.value.kind){case"hash":case"list":case"zset":case"stream":return s.value.entries.length;case"set":return s.value.members.length;default:return null}},hs=()=>{const s=he(),{selectedDatabase:r}=Re(),{openOverlay:t}=De(),{addQuery:a,updateQuery:i}=He(),[n,l]=Pe("key"),[o,d]=(0,p.useState)(null),[h,c]=(0,p.useState)(null),b=h===n?"backward":"forward",u=Ve(n,o===n,b),{applyAction:L,deleteKey:H,isPending:C}=qe(),N=u.data?.pages,x=N?.[0],[A,v]=(0,p.useState)(!1),[P,_]=(0,p.useState)(null),T=x?.key.utf8??(x?`binary:${x.key.base64}`:""),$=x?us(x):null,R=(0,p.useMemo)(()=>{if(!x||!N||N.length===1)return x;const f=structuredClone(x);for(const g of N.slice(1))f.value.kind==="hash"&&g.value.kind==="hash"&&f.value.entries.push(...g.value.entries),f.value.kind==="list"&&g.value.kind==="list"&&f.value.entries.push(...g.value.entries),f.value.kind==="set"&&g.value.kind==="set"&&f.value.members.push(...g.value.members),f.value.kind==="zset"&&g.value.kind==="zset"&&f.value.entries.push(...g.value.entries),f.value.kind==="stream"&&g.value.kind==="stream"&&f.value.entries.push(...g.value.entries);return f},[x,N]),U=R?ms(R):null,V=async(f,g=!1)=>{if(!n||!x)return!1;try{const k=await L(n,{expectedRevision:x.revision,force:g,operation:f});return _(null),k.deleted?l(null):(k.key.base64||"-")!==n&&l(k.key.base64||"-"),!0}catch(k){return k.status===409&&_(f),!1}},oe=()=>{if(!$)return;const f=a(`redis: ${T.slice(0,40)}`);i(f,{query:$}),s({to:"/runner/$queryId",params:{queryId:f}})},de=async()=>{if(!n||!x||x.type!=="string")return;const f=[];let g=0,k=!0;for(;k;){const y=(await Se({db:r??"",key:n,offset:g,expectedRevision:x.revision})).data.data;if(f.push(Ze(y.chunk.base64)),k=y.hasMore,y.hasMore&&(y.nextOffset===null||y.nextOffset<=g))throw new Error("Redis download made no forward progress");g=y.nextOffset??g}const ce=f.reduce((y,ue)=>y+ue.length,0),te=new Uint8Array(ce);let ae=0;for(const y of f)te.set(y,ae),ae+=y.length;const ne=URL.createObjectURL(new Blob([te.buffer])),G=document.createElement("a");G.href=ne,G.download=`${x.key.utf8?.replaceAll(/[^\w.-]+/g,"_")||"redis-value"}.bin`,G.click(),URL.revokeObjectURL(ne)};if(!n)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center bg-background font-mono",children:(0,e.jsxs)("div",{className:"max-w-sm text-center",children:[(0,e.jsx)(xe,{className:"mx-auto mb-3 size-5 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-sm font-medium text-foreground",children:"No key selected"}),(0,e.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Select a key from the navigator or create one to inspect its value."}),(0,e.jsxs)(m,{variant:"outline",className:"mt-3",onClick:()=>t("redis-browser.create-key"),children:[(0,e.jsx)(ee,{})," Create key"]})]})});if(u.isLoading)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center",children:(0,e.jsx)(Ce,{})});if(u.error||!x||!R)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,e.jsxs)("div",{className:"w-full max-w-md text-center",children:[(0,e.jsx)(B,{variant:"error",title:"Unable to load key",message:u.error?.message??"The key no longer exists.",className:"rounded-sm text-start"}),(0,e.jsx)(m,{variant:"outline",className:"mt-4",onClick:()=>l(null),children:"Back to keyspace"})]})});const re=R.length!==null&&U!==null?Math.max(0,R.length-U):null;return(0,e.jsxs)("main",{className:"flex min-h-0 flex-1 flex-col bg-background font-mono",children:[(0,e.jsx)(es,{detail:x,label:T,loadedCount:U,fetchedAt:u.dataUpdatedAt,isFetching:u.isFetching,pending:C,command:$,act:V,onRefresh:()=>u.refetch(),onOpenRunner:oe,onDelete:()=>v(!0)},x.key.base64),(0,e.jsx)(Fe,{open:A,onOpenChange:v,children:(0,e.jsxs)(Be,{children:[(0,e.jsxs)($e,{children:[(0,e.jsx)(Ke,{children:"Delete key"}),(0,e.jsxs)(Ae,{children:["Are you sure you want to delete"," ",(0,e.jsx)("code",{className:"break-all text-foreground",children:T||"(empty key)"}),"? This action cannot be undone."]})]}),(0,e.jsxs)(ze,{children:[(0,e.jsx)(Je,{children:"Cancel"}),(0,e.jsx)(Oe,{variant:"destructive",onClick:async()=>{v(!1);try{await H(n,x.revision),l(null)}catch{}},children:"Delete"})]})]})}),P&&(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border p-2 sm:grid-cols-[1fr_auto] sm:items-center",children:[(0,e.jsx)(B,{variant:"warning",title:"Revision conflict",message:"This key changed on the server. Reload it or overwrite with the pending change.",className:"rounded-sm py-2"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(m,{variant:"outline",onClick:()=>{_(null),u.refetch()},children:"Reload"}),(0,e.jsx)(m,{disabled:C,onClick:()=>V(P,!0),children:"Overwrite"})]})]}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:(0,e.jsxs)("section",{className:"p-3",children:[(0,e.jsx)(cs,{detail:R,act:V,pending:C,onLoadFull:()=>d(n),onDownload:()=>{we.promise(de(),{loading:"Downloading original Redis bytes…",success:"Redis value downloaded",error:f=>f.message||"Download failed"})},streamDirection:b,onStreamDirectionChange:f=>c(f==="backward"?n:null)},x.key.base64),u.hasNextPage&&(0,e.jsx)(m,{variant:"outline",className:"mt-3 w-full",onClick:()=>u.fetchNextPage(),disabled:u.isFetchingNextPage,children:u.isFetchingNextPage?"Loading…":x.type==="stream"&&b==="backward"?"Load 100 older entries":`Load next 100${re!==null?` (${re.toLocaleString()} remaining)`:""}`})]})})]})},Ss=hs;export{Ss as component};
1
+ import{r as me}from"./rolldown-runtime-CXHxssQy.js";import{_ as he}from"./tanstack-C-qfmRNM.js";import{$ as xe,R as fe,V as be,g as ee,h as pe,i as M,lt as ge,m as J,o as ve,ot as je,p as ye,y as Ne}from"./icons-0UA1AvNu.js";import{kt as ke}from"./radix-ui-6dcJ5m4U.js";import{n as we}from"./dist-C-7rnx4R.js";import{E as Se,H as q,V as Ce,c as m,i as Z,n as Q,t as W}from"./tooltip-1-bWFncb.js";import{t as Re}from"./database.store-BvoUSH8Y.js";import{a as I,f as De,i as Me,o as Le,r as _e,t as Te}from"./popover-WwEzK7ho.js";import{L as B,_ as $e,c as Ee,d as Fe,f as Oe,g as ze,h as Ae,k as Pe,l as X,m as Be,o as Y,p as Je,s as Ie,v as Ke}from"./index-BSNZ1oRs.js";import{i as Ve,n as ie,t as He}from"./toggle-group-CxRlYNqR.js";import{a as Ue,i as Ge,n as S,o as qe,r as Ze,t as D}from"./redis-value-Dq29EMpv.js";var p=me(ge(),1),e=ke(),le=({text:s,label:r,className:t})=>{const[a,i]=(0,p.useState)(!1);return(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:t,onClick:async()=>{await navigator.clipboard.writeText(typeof s=="function"?s():s),i(!0),window.setTimeout(()=>i(!1),1200)},"aria-label":r,children:a?(0,e.jsx)(xe,{}):(0,e.jsx)(be,{})})}),(0,e.jsx)(Q,{children:a?"Copied":r})]})},Qe=[{label:"60s",ttlMs:6e4},{label:"10m",ttlMs:6e5},{label:"1h",ttlMs:36e5},{label:"1d",ttlMs:864e5},{label:"7d",ttlMs:6048e5}],We=s=>s===null?"—":s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(1)} KiB`:`${(s/1048576).toFixed(1)} MiB`,Xe=s=>{const r=Math.max(0,Math.ceil(s/1e3));if(r<60)return`${r}s`;const t=Math.floor(r/60);if(t<60)return`${t}m ${r%60}s`;const a=Math.floor(t/60);return a<24?`${a}h ${t%60}m`:`${Math.floor(a/24)}d ${a%24}h`},Ye=s=>{const[,r]=(0,p.useReducer)(t=>t+1,0);(0,p.useEffect)(()=>{if(!s)return;const t=window.setInterval(r,1e3);return()=>window.clearInterval(t)},[s])},es=({detail:s,label:r,loadedCount:t,fetchedAt:a,isFetching:i,pending:n,command:l,act:o,onRefresh:d,onOpenRunner:h,onDelete:c})=>{const[b,u]=(0,p.useState)(s.key),[L,V]=(0,p.useState)("");Ye(s.ttlMs>0);const C=s.ttlMs>0?s.ttlMs-(Date.now()-a):s.ttlMs,N=s.ttlMs===-1,x=!N&&C<=0,A=[{name:"TTL",value:N?"∞":x?"expired":Xe(C),hint:N?"No expiry — the key persists until deleted.":x?"The TTL elapsed; Redis has evicted or is about to evict this key.":`Expires ${new Date(a+s.ttlMs).toLocaleString()}`,alert:x},{name:"MEM",value:We(s.memoryBytes),hint:"Approximate memory usage reported by MEMORY USAGE."},{name:"LEN",value:s.length?.toLocaleString()??"—",hint:t!==null&&s.length!==null?`${t.toLocaleString()} of ${s.length.toLocaleString()} entries loaded in this view.`:"Length reported by Redis (entries, or bytes for strings)."},{name:"REV",value:s.revision.slice(0,8),hint:"Optimistic-lock revision. Writes are rejected when the key changed since this fetch."},{name:"AT",value:new Date(a).toLocaleTimeString(),hint:"When this snapshot was fetched from Redis."}];return(0,e.jsx)("header",{className:"border-b border-border",children:(0,e.jsxs)("div",{className:"flex min-h-10 items-stretch justify-between",children:[(0,e.jsxs)("div",{className:"flex min-w-0 flex-1 items-stretch overflow-x-auto",children:[(0,e.jsxs)("div",{className:"flex min-w-0 max-w-[min(36rem,45vw)] shrink items-center gap-1 px-3 py-1.5",children:[(0,e.jsx)("code",{className:"min-w-0 truncate text-sm text-foreground",title:r,children:r||"(empty key)"}),(0,e.jsx)(le,{text:s.key.utf8??s.key.base64,label:"Copy key name",className:"shrink-0 text-muted-foreground"}),(0,e.jsx)(Le,{variant:"outline",className:"h-4 shrink-0 rounded-sm px-1.5 text-[8px] font-normal uppercase text-muted-foreground",children:s.type})]}),A.map(({name:v,value:P,hint:_,alert:T},$)=>(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsxs)("div",{className:q("flex shrink-0 cursor-default items-center gap-1.5 border-s border-border px-2 text-[10px]",$===A.length-1&&"border-e"),children:[(0,e.jsx)("span",{className:"text-muted-foreground",children:v}),(0,e.jsx)("span",{className:q("tabular-nums",T?"text-destructive":"text-foreground"),children:P})]})}),(0,e.jsx)(Q,{side:"bottom",children:_})]},v))]}),(0,e.jsxs)("div",{className:"flex shrink-0 items-stretch",children:[(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",onClick:d,disabled:i,children:[(0,e.jsx)(pe,{className:q(i&&"animate-spin")})," Refresh"]}),l&&(0,e.jsxs)(W,{children:[(0,e.jsx)(Z,{asChild:!0,children:(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",onClick:h,children:[(0,e.jsx)(ve,{})," Runner"]})}),(0,e.jsxs)(Q,{side:"bottom",children:["Open in the query runner as ",(0,e.jsx)("code",{className:"font-mono",children:l})]})]}),(0,e.jsxs)(Te,{children:[(0,e.jsx)(Me,{asChild:!0,children:(0,e.jsxs)(m,{variant:"ghost",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",children:[(0,e.jsx)(Ne,{})," Edit"]})}),(0,e.jsx)(_e,{align:"end",className:"w-72 rounded-sm p-3 font-mono",children:(0,e.jsxs)(Ee,{className:"gap-4",children:[(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-key-rename",children:"Rename key"}),(0,e.jsxs)("form",{className:"flex",onSubmit:v=>{v.preventDefault(),!(b===null||b.base64===s.key.base64||n)&&o({action:"rename",newKey:b})},children:[(0,e.jsx)(S,{id:"redis-key-rename",value:b,onChange:u,className:"rounded-e-none font-mono"}),(0,e.jsx)(m,{type:"submit",size:"icon",className:"h-auto self-stretch rounded-s-none border-0 bg-clip-border",disabled:b===null||b.base64===s.key.base64||n,"aria-label":"Rename key",children:(0,e.jsx)(je,{})})]})]}),(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-key-ttl-operation",children:"TTL in seconds"}),(0,e.jsxs)("form",{className:"flex",onSubmit:v=>{v.preventDefault(),!n&&o({action:"setTtl",ttlMs:L?Number(L)*1e3:null})},children:[(0,e.jsx)(I,{id:"redis-key-ttl-operation",type:"number",min:1,value:L,onChange:v=>V(v.target.value),placeholder:s.ttlMs>0?String(Math.ceil(s.ttlMs/1e3)):"Persistent",className:"rounded-e-none font-mono"}),(0,e.jsx)(m,{type:"submit",className:"h-auto self-stretch rounded-s-none border-0 bg-clip-border",disabled:n,children:"Apply"})]}),(0,e.jsxs)("div",{className:"flex flex-wrap gap-1",children:[Qe.map(v=>(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",disabled:n,onClick:()=>o({action:"setTtl",ttlMs:v.ttlMs}),children:v.label},v.label)),(0,e.jsx)(m,{type:"button",variant:"outline",size:"xs",disabled:n||N,onClick:()=>o({action:"setTtl",ttlMs:null}),children:"Persist"})]}),(0,e.jsx)(Ie,{children:"Leave empty to persist the key."})]})]})})]}),(0,e.jsxs)(m,{variant:"destructive",size:"sm",className:"h-auto rounded-none border-y-0 border-s border-e-0 border-border px-2",disabled:n,onClick:c,children:[(0,e.jsx)(M,{})," Delete"]})]})]})})},w=Ge(""),j=s=>s.utf8??`base64:${s.base64}`,E=(s,...r)=>r.some(t=>String(t).toLowerCase().includes(s)),F=s=>{switch(s.kind){case"string":return JSON.stringify(j(s.value),null,2);case"hash":return JSON.stringify(Object.fromEntries(s.entries.map(r=>[j(r.field),j(r.value)])),null,2);case"list":return JSON.stringify(s.entries.map(r=>j(r.value)),null,2);case"set":return JSON.stringify(s.members.map(j),null,2);case"zset":return JSON.stringify(s.entries.map(r=>({member:j(r.member),score:r.score})),null,2);case"stream":return JSON.stringify(s.entries.map(r=>({id:r.id,fields:Object.fromEntries(r.fields.map(t=>[j(t.field),j(t.value)]))})),null,2);default:return""}},K=(s,r)=>{const[t,a]=(0,p.useState)(s),[i,n]=(0,p.useState)(r);return i!==r&&(n(r),a(s)),[t,a]},O=({filtered:s})=>(0,e.jsx)("div",{className:"flex h-10 items-center justify-center px-2 text-xs text-muted-foreground",children:s?"No loaded entries match the filter.":"No entries loaded."}),z=({filter:s,onFilterChange:r,shownCount:t,loadedCount:a,totalCount:i,copyJson:n,extra:l,header:o,children:d,footer:h})=>(0,e.jsxs)("div",{className:"overflow-hidden border border-border",children:[(0,e.jsxs)("div",{className:"flex h-8 items-center gap-1 border-b border-border bg-muted/10 px-1",children:[(0,e.jsx)(ye,{className:"ms-1 size-3 shrink-0 text-muted-foreground"}),(0,e.jsx)(I,{variant:"outline",value:s,onChange:c=>r(c.target.value),placeholder:"Filter loaded entries","aria-label":"Filter loaded entries",className:"h-6 flex-1 rounded-none border-none px-1 font-mono focus-visible:ring-0"}),l,(0,e.jsx)("span",{className:"shrink-0 px-1 text-[10px] tabular-nums text-muted-foreground",children:s?`${t} / ${a}`:i!==null&&i>a?`${a.toLocaleString()} of ${i.toLocaleString()}`:a.toLocaleString()}),(0,e.jsx)(le,{text:n,label:"Copy loaded entries as JSON"})]}),o,d,h]}),se=({labels:s,onSave:r,pending:t,score:a=!1})=>{const[i,n]=(0,p.useState)(w),[l,o]=(0,p.useState)(w),[d,h]=(0,p.useState)("0"),c=i===null||!a&&l===null,b=async u=>{u.preventDefault(),!(i===null||l===null)&&await r(i,a?Number(d):l)&&(n(w),o(w),h("0"))};return(0,e.jsxs)("form",{onSubmit:b,className:"grid grid-cols-[1fr_1fr_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:i,onChange:n,placeholder:s[0]}),a?(0,e.jsx)(I,{type:"number",step:"any",value:d,onChange:u=>h(u.target.value),placeholder:s[1],className:"font-mono"}):(0,e.jsx)(S,{value:l,onChange:o,placeholder:s[1]}),(0,e.jsxs)(m,{type:"submit",disabled:t||c,children:[(0,e.jsx)(ee,{})," Add"]})]})},ss=({value:s,truncated:r,act:t,pending:a,onLoadFull:i,onDownload:n})=>{const[l,o]=K(s,s.base64),d=l!==null&&l.base64!==s.base64;return(0,e.jsxs)("div",{className:"space-y-3",children:[r&&(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border pb-3 sm:grid-cols-[1fr_auto] sm:items-center",children:[(0,e.jsx)(B,{variant:"warning",title:"Preview truncated",message:"Load the full value before editing (up to the 8 MiB response cap).",className:"rounded-sm"}),(0,e.jsx)(m,{variant:"outline",onClick:i,children:"Load full"})]}),(0,e.jsx)(D,{value:s,onDownload:n}),(0,e.jsxs)("form",{onSubmit:h=>{h.preventDefault(),l!==null&&d&&t({action:"setString",value:l})},className:"border border-border p-3",children:[(0,e.jsxs)(Y,{className:"gap-1.5",children:[(0,e.jsx)(X,{htmlFor:"redis-string-value",children:"Replace value"}),(0,e.jsx)(S,{id:"redis-string-value",value:l,onChange:o})]}),(0,e.jsxs)(m,{type:"submit",className:"mt-3",disabled:r||a||!d,children:[(0,e.jsx)(J,{})," Save value"]})]})]})},rs=({field:s,value:r,act:t,pending:a})=>{const[i,n]=K(r,r.base64),l=i!==null&&i.base64!==r.base64;return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[minmax(10rem,0.7fr)_1fr_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)(D,{value:s,compact:!0}),(0,e.jsx)(S,{value:i,onChange:n}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:l?"text-primary":void 0,disabled:a||!l,onClick:()=>i!==null&&t({action:"upsertHash",field:s,value:i}),"aria-label":"Save hash value",children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"deleteHash",field:s}),"aria-label":"Delete hash field",children:(0,e.jsx)(M,{})})]})]})},ts=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),l=i.trim().toLowerCase(),o=l?s.entries.filter(d=>E(l,j(d.field),j(d.value))):s.entries;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:o.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[minmax(10rem,0.7fr)_1fr_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Field"}),(0,e.jsx)("span",{children:"Value"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{labels:["field","value"],pending:a,onSave:(d,h)=>t({action:"upsertHash",field:d,value:h})}),children:o.length===0?(0,e.jsx)(O,{filtered:l.length>0}):o.map(d=>(0,e.jsx)(rs,{field:d.field,value:d.value,act:t,pending:a},d.field.base64))})},as=({index:s,value:r,revision:t,act:a,pending:i})=>{const[n,l]=K(r,`${t}:${r.base64}`),o=n!==null&&n.base64!==r.base64;return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[3rem_1fr_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)("code",{className:"text-xs text-muted-foreground",children:s}),(0,e.jsx)(S,{value:n,onChange:l}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:o?"text-primary":void 0,disabled:i||!o,onClick:()=>n!==null&&a({action:"setList",index:s,value:n}),"aria-label":`Save list item ${s}`,children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:i,onClick:()=>a({action:"deleteList",index:s}),"aria-label":`Delete list item ${s}`,children:(0,e.jsx)(M,{})})]})]})},ns=({value:s,revision:r,total:t,act:a,pending:i})=>{const[n,l]=(0,p.useState)(""),[o,d]=(0,p.useState)(w),h=n.trim().toLowerCase(),c=h?s.entries.filter(u=>E(h,u.index,j(u.value))):s.entries,b=async u=>{o!==null&&await a({action:"pushList",side:u,value:o})&&d(w)};return(0,e.jsx)(z,{filter:n,onFilterChange:l,shownCount:c.length,loadedCount:s.entries.length,totalCount:t,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[3rem_1fr_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Index"}),(0,e.jsx)("span",{children:"Value"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsxs)("form",{onSubmit:u=>{u.preventDefault(),b("right")},className:"grid grid-cols-[1fr_auto_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:o,onChange:d,placeholder:"new item"}),(0,e.jsx)(m,{type:"button",variant:"outline",disabled:i||o===null,onClick:()=>b("left"),children:"Push left"}),(0,e.jsx)(m,{type:"submit",disabled:i||o===null,children:"Push right"})]}),children:c.length===0?(0,e.jsx)(O,{filtered:h.length>0}):c.map(u=>(0,e.jsx)(as,{index:u.index,value:u.value,revision:r,act:a,pending:i},u.index))})},is=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),[l,o]=(0,p.useState)(w),d=i.trim().toLowerCase(),h=d?s.members.filter(c=>E(d,j(c))):s.members;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:h.length,loadedCount:s.members.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[1fr_2rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Member"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsxs)("form",{onSubmit:async c=>{c.preventDefault(),l!==null&&await t({action:"addSet",member:l})&&o(w)},className:"grid grid-cols-[1fr_auto] items-center gap-2 border-t border-border bg-muted/10 p-2",children:[(0,e.jsx)(S,{value:l,onChange:o,placeholder:"new member"}),(0,e.jsxs)(m,{type:"submit",disabled:a||l===null,children:[(0,e.jsx)(ee,{})," Add member"]})]}),children:h.length===0?(0,e.jsx)(O,{filtered:d.length>0}):h.map(c=>(0,e.jsxs)("div",{className:"flex min-h-8 items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)("span",{className:"min-w-0 flex-1",children:(0,e.jsx)(D,{value:c,compact:!0})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"removeSet",member:c}),"aria-label":"Remove set member",children:(0,e.jsx)(M,{})})]},c.base64))})},ls=({member:s,score:r,act:t,pending:a})=>{const[i,n]=K(String(r),String(r)),l=Number(i),o=i!==String(r);return(0,e.jsxs)("div",{className:"grid min-h-8 grid-cols-[1fr_8rem_5rem] items-center gap-2 border-b border-border px-2 py-1",children:[(0,e.jsx)(D,{value:s,compact:!0}),(0,e.jsx)(I,{inputMode:"decimal",value:i,onChange:d=>n(d.target.value),"aria-label":"Sorted set score",className:"font-mono"}),(0,e.jsxs)("div",{className:"flex",children:[(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:o?"text-primary":void 0,disabled:a||!o||!Number.isFinite(l),onClick:()=>t({action:"upsertZset",member:s,score:l}),"aria-label":"Save sorted set score",children:(0,e.jsx)(J,{})}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"removeZset",member:s}),"aria-label":"Remove sorted set member",children:(0,e.jsx)(M,{})})]})]})},os=({value:s,total:r,act:t,pending:a})=>{const[i,n]=(0,p.useState)(""),l=i.trim().toLowerCase(),o=l?s.entries.filter(d=>E(l,j(d.member),d.score)):s.entries;return(0,e.jsx)(z,{filter:i,onFilterChange:n,shownCount:o.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[1fr_8rem_5rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Member"}),(0,e.jsx)("span",{children:"Score"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{score:!0,labels:["member","score"],pending:a,onSave:(d,h)=>t({action:"upsertZset",member:d,score:h})}),children:o.length===0?(0,e.jsx)(O,{filtered:l.length>0}):o.map(d=>(0,e.jsx)(ls,{member:d.member,score:d.score,act:t,pending:a},d.member.base64))})},ds=({value:s,total:r,act:t,pending:a,direction:i,onDirectionChange:n})=>{const[l,o]=(0,p.useState)(""),d=l.trim().toLowerCase(),h=d?s.entries.filter(c=>E(d,c.id,...c.fields.flatMap(b=>[j(b.field),j(b.value)]))):s.entries;return(0,e.jsx)(z,{filter:l,onFilterChange:o,shownCount:h.length,loadedCount:s.entries.length,totalCount:r,copyJson:()=>F(s),extra:(0,e.jsxs)(He,{type:"single",variant:"ghost",size:"sm",value:i,onValueChange:c=>c&&n(c),"aria-label":"Stream order",className:"shrink-0 rounded-none",children:[(0,e.jsx)(ie,{value:"forward",className:"h-6 rounded-none px-2 text-[10px]",children:"Oldest first"}),(0,e.jsx)(ie,{value:"backward",className:"h-6 rounded-none px-2 text-[10px]",children:"Newest first"})]}),header:(0,e.jsxs)("div",{className:"grid h-8 grid-cols-[10rem_1fr_2rem] items-center border-b border-border bg-muted/20 px-2 text-[10px] uppercase tracking-wider text-muted-foreground",children:[(0,e.jsx)("span",{children:"Entry ID"}),(0,e.jsx)("span",{children:"Fields"}),(0,e.jsx)("span",{})]}),footer:(0,e.jsx)(se,{labels:["field","value"],pending:a,onSave:(c,b)=>t({action:"appendStream",id:"*",fields:[{field:c,value:b}]})}),children:h.length===0?(0,e.jsx)(O,{filtered:d.length>0}):h.map(c=>(0,e.jsxs)("div",{className:"grid grid-cols-[10rem_1fr_2rem] border-b border-border",children:[(0,e.jsx)("code",{className:"border-e border-border px-2 py-1.5 text-xs text-primary",children:c.id}),(0,e.jsx)("div",{className:"grid gap-1 px-2 py-1.5",children:c.fields.map(b=>(0,e.jsxs)("div",{className:"grid grid-cols-[minmax(8rem,0.4fr)_1fr] gap-3",children:[(0,e.jsx)(D,{value:b.field,compact:!0}),(0,e.jsx)(D,{value:b.value,compact:!0})]},b.field.base64))}),(0,e.jsx)(m,{variant:"ghost",size:"icon-sm",className:"rounded-none text-muted-foreground hover:text-destructive",disabled:a,onClick:()=>t({action:"deleteStream",id:c.id}),"aria-label":`Delete stream entry ${c.id}`,children:(0,e.jsx)(M,{})})]},c.id))})},cs=({detail:s,act:r,pending:t,onLoadFull:a,onDownload:i,streamDirection:n,onStreamDirectionChange:l})=>{const o=s.value;switch(o.kind){case"string":return(0,e.jsx)(ss,{value:o.value,truncated:o.truncated,act:r,pending:t,onLoadFull:a,onDownload:i});case"hash":return(0,e.jsx)(ts,{value:o,total:s.length,act:r,pending:t});case"list":return(0,e.jsx)(ns,{value:o,revision:s.revision,total:s.length,act:r,pending:t});case"set":return(0,e.jsx)(is,{value:o,total:s.length,act:r,pending:t});case"zset":return(0,e.jsx)(os,{value:o,total:s.length,act:r,pending:t});case"stream":return(0,e.jsx)(ds,{value:o,total:s.length,act:r,pending:t,direction:n,onDirectionChange:l});default:return(0,e.jsx)(B,{variant:"info",title:"Metadata only",message:"This Redis module type cannot be edited in this release.",className:"rounded-sm"})}},us=s=>{if(s.key.utf8===void 0)return null;const r=JSON.stringify(s.key.utf8);switch(s.type){case"string":return`GET ${r}`;case"hash":return`HGETALL ${r}`;case"list":return`LRANGE ${r} 0 -1`;case"set":return`SMEMBERS ${r}`;case"zset":return`ZRANGE ${r} 0 -1 WITHSCORES`;case"stream":return`XRANGE ${r} - + COUNT 100`;default:return null}},ms=s=>{switch(s.value.kind){case"hash":case"list":case"zset":case"stream":return s.value.entries.length;case"set":return s.value.members.length;default:return null}},hs=()=>{const s=he(),{selectedDatabase:r}=Re(),{openOverlay:t}=De(),{addQuery:a,updateQuery:i}=Ve(),[n,l]=Pe("key"),[o,d]=(0,p.useState)(null),[h,c]=(0,p.useState)(null),b=h===n?"backward":"forward",u=Ue(n,o===n,b),{applyAction:L,deleteKey:V,isPending:C}=qe(),N=u.data?.pages,x=N?.[0],[A,v]=(0,p.useState)(!1),[P,_]=(0,p.useState)(null),T=x?.key.utf8??(x?`binary:${x.key.base64}`:""),$=x?us(x):null,R=(0,p.useMemo)(()=>{if(!x||!N||N.length===1)return x;const f=structuredClone(x);for(const g of N.slice(1))f.value.kind==="hash"&&g.value.kind==="hash"&&f.value.entries.push(...g.value.entries),f.value.kind==="list"&&g.value.kind==="list"&&f.value.entries.push(...g.value.entries),f.value.kind==="set"&&g.value.kind==="set"&&f.value.members.push(...g.value.members),f.value.kind==="zset"&&g.value.kind==="zset"&&f.value.entries.push(...g.value.entries),f.value.kind==="stream"&&g.value.kind==="stream"&&f.value.entries.push(...g.value.entries);return f},[x,N]),H=R?ms(R):null,U=async(f,g=!1)=>{if(!n||!x)return!1;try{const k=await L(n,{expectedRevision:x.revision,force:g,operation:f});return _(null),k.deleted?l(null):(k.key.base64||"-")!==n&&l(k.key.base64||"-"),!0}catch(k){return k.status===409&&_(f),!1}},oe=()=>{if(!$)return;const f=a(`redis: ${T.slice(0,40)}`);i(f,{query:$}),s({to:"/runner/$queryId",params:{queryId:f}})},de=async()=>{if(!n||!x||x.type!=="string")return;const f=[];let g=0,k=!0;for(;k;){const y=(await Se({db:r??"",key:n,offset:g,expectedRevision:x.revision})).data.data;if(f.push(Ze(y.chunk.base64)),k=y.hasMore,y.hasMore&&(y.nextOffset===null||y.nextOffset<=g))throw new Error("Redis download made no forward progress");g=y.nextOffset??g}const ce=f.reduce((y,ue)=>y+ue.length,0),te=new Uint8Array(ce);let ae=0;for(const y of f)te.set(y,ae),ae+=y.length;const ne=URL.createObjectURL(new Blob([te.buffer])),G=document.createElement("a");G.href=ne,G.download=`${x.key.utf8?.replaceAll(/[^\w.-]+/g,"_")||"redis-value"}.bin`,G.click(),URL.revokeObjectURL(ne)};if(!n)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center bg-background font-mono",children:(0,e.jsxs)("div",{className:"max-w-sm text-center",children:[(0,e.jsx)(fe,{className:"mx-auto mb-3 size-5 text-muted-foreground"}),(0,e.jsx)("h1",{className:"text-sm font-medium text-foreground",children:"No key selected"}),(0,e.jsx)("p",{className:"mt-1 text-xs leading-5 text-muted-foreground",children:"Select a key from the navigator or create one to inspect its value."}),(0,e.jsxs)(m,{variant:"outline",className:"mt-3",onClick:()=>t("redis-browser.create-key"),children:[(0,e.jsx)(ee,{})," Create key"]})]})});if(u.isLoading)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center",children:(0,e.jsx)(Ce,{})});if(u.error||!x||!R)return(0,e.jsx)("main",{className:"flex flex-1 items-center justify-center bg-background p-4",children:(0,e.jsxs)("div",{className:"w-full max-w-md text-center",children:[(0,e.jsx)(B,{variant:"error",title:"Unable to load key",message:u.error?.message??"The key no longer exists.",className:"rounded-sm text-start"}),(0,e.jsx)(m,{variant:"outline",className:"mt-4",onClick:()=>l(null),children:"Back to keyspace"})]})});const re=R.length!==null&&H!==null?Math.max(0,R.length-H):null;return(0,e.jsxs)("main",{className:"flex min-h-0 flex-1 flex-col bg-background font-mono",children:[(0,e.jsx)(es,{detail:x,label:T,loadedCount:H,fetchedAt:u.dataUpdatedAt,isFetching:u.isFetching,pending:C,command:$,act:U,onRefresh:()=>u.refetch(),onOpenRunner:oe,onDelete:()=>v(!0)},x.key.base64),(0,e.jsx)(Fe,{open:A,onOpenChange:v,children:(0,e.jsxs)(Be,{children:[(0,e.jsxs)($e,{children:[(0,e.jsx)(Ke,{children:"Delete key"}),(0,e.jsxs)(Ae,{children:["Are you sure you want to delete"," ",(0,e.jsx)("code",{className:"break-all text-foreground",children:T||"(empty key)"}),"? This action cannot be undone."]})]}),(0,e.jsxs)(ze,{children:[(0,e.jsx)(Je,{children:"Cancel"}),(0,e.jsx)(Oe,{variant:"destructive",onClick:async()=>{v(!1);try{await V(n,x.revision),l(null)}catch{}},children:"Delete"})]})]})}),P&&(0,e.jsxs)("div",{className:"grid gap-2 border-b border-border p-2 sm:grid-cols-[1fr_auto] sm:items-center",children:[(0,e.jsx)(B,{variant:"warning",title:"Revision conflict",message:"This key changed on the server. Reload it or overwrite with the pending change.",className:"rounded-sm py-2"}),(0,e.jsxs)("div",{className:"flex gap-2",children:[(0,e.jsx)(m,{variant:"outline",onClick:()=>{_(null),u.refetch()},children:"Reload"}),(0,e.jsx)(m,{disabled:C,onClick:()=>U(P,!0),children:"Overwrite"})]})]}),(0,e.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:(0,e.jsxs)("section",{className:"p-3",children:[(0,e.jsx)(cs,{detail:R,act:U,pending:C,onLoadFull:()=>d(n),onDownload:()=>{we.promise(de(),{loading:"Downloading original Redis bytes…",success:"Redis value downloaded",error:f=>f.message||"Download failed"})},streamDirection:b,onStreamDirectionChange:f=>c(f==="backward"?n:null)},x.key.base64),u.hasNextPage&&(0,e.jsx)(m,{variant:"outline",className:"mt-3 w-full",onClick:()=>u.fetchNextPage(),disabled:u.isFetchingNextPage,children:u.isFetchingNextPage?"Loading…":x.type==="stream"&&b==="backward"?"Load 100 older entries":`Load next 100${re!==null?` (${re.toLocaleString()} remaining)`:""}`})]})})]})},Ss=hs;export{Ss as component};