@lunora/studio 1.0.0-alpha.30 → 1.0.0-alpha.32

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 (185) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.js +10 -10
  3. package/dist/mount.d.ts +1 -1
  4. package/dist/mount.js +3 -2
  5. package/dist/packem_chunks/ApiTab.js +3 -3
  6. package/dist/packem_chunks/AuditPanel.js +7 -7
  7. package/dist/packem_chunks/ExportImportPanel.js +5 -4
  8. package/dist/packem_chunks/FileBrowser.js +2 -2
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +72 -70
  11. package/dist/packem_chunks/HealthPanel.js +3 -3
  12. package/dist/packem_chunks/InsightsPanel.js +4 -3
  13. package/dist/packem_chunks/LogsPanel.js +6 -6
  14. package/dist/packem_chunks/MailPanel.js +8 -7
  15. package/dist/packem_chunks/MetricsPanel.js +3 -3
  16. package/dist/packem_chunks/MigrationsPanel.js +7 -7
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +3 -2
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +11 -8
  20. package/dist/packem_chunks/SettingsPanel.js +50 -49
  21. package/dist/packem_chunks/SqlEditorPanel.js +5 -4
  22. package/dist/packem_chunks/TableEditor.js +3 -3
  23. package/dist/packem_chunks/analytics-panel.js +1 -1
  24. package/dist/packem_chunks/auth-config-panel.js +1 -1
  25. package/dist/packem_chunks/auth-sessions-panel.js +2 -2
  26. package/dist/packem_chunks/containers-panel.js +247 -0
  27. package/dist/packem_chunks/dashboards-panel.js +3 -2
  28. package/dist/packem_chunks/fanout-panel.js +31 -30
  29. package/dist/packem_chunks/flags-panel.js +6 -6
  30. package/dist/packem_chunks/kv-browser.js +2 -2
  31. package/dist/packem_chunks/log-drains-panel.js +1 -1
  32. package/dist/packem_chunks/organizations-panel.js +3 -3
  33. package/dist/packem_chunks/payments-panel.js +6 -5
  34. package/dist/packem_chunks/permissions-panel.js +12 -11
  35. package/dist/packem_chunks/queues-panel.js +32 -31
  36. package/dist/packem_chunks/rls-panel.js +86 -84
  37. package/dist/packem_chunks/schedule-panel.js +3 -3
  38. package/dist/packem_chunks/sparkline.js +1 -1
  39. package/dist/packem_chunks/storage-rules-panel.js +27 -25
  40. package/dist/packem_chunks/subscriptions-panel.js +33 -31
  41. package/dist/packem_chunks/users-panel.js +3 -3
  42. package/dist/packem_chunks/vector-browser.js +1 -1
  43. package/dist/packem_chunks/workflows-panel.js +2 -2
  44. package/dist/packem_shared/{ApiDocsPanel-B6u_wnz-.js → ApiDocsPanel-Cu6mD4u7.js} +1 -1
  45. package/dist/packem_shared/{ApiReferencePanel-Drz4UO0a.js → ApiReferencePanel-Co_wpRF2.js} +1 -1
  46. package/dist/packem_shared/{CommandPalette-B5BertvU.js → CommandPalette-BUPpbpMc.js} +1 -1
  47. package/dist/packem_shared/{DataBrowser-ANTHLWWh.js → DataBrowser-DSNK1tPg.js} +5 -5
  48. package/dist/packem_shared/{GlobalDataBrowser-CjgTG_wa.js → GlobalDataBrowser-ErfvIs1S.js} +3 -3
  49. package/dist/packem_shared/{HomePanel-c2FodE9t.js → HomePanel-DQk3P8xX.js} +3 -3
  50. package/dist/packem_shared/{OpenRpcReferencePanel-CspFdbUT.js → OpenRpcReferencePanel-DLWzrIx9.js} +1 -1
  51. package/dist/packem_shared/{ScheduledJobs-BEJXtsBn.js → ScheduledJobs-ClaNpZsg.js} +2 -2
  52. package/dist/packem_shared/{Studio-CVTtA_sB.js → Studio-CFTYGEUt.js} +4 -4
  53. package/dist/packem_shared/{StudioApp-BSYV2fz6.js → StudioApp-Cy9vUwVl.js} +1 -1
  54. package/dist/packem_shared/{advisor-view-DzqyvUU3.js → advisor-view-D3-U4kRR.js} +5 -5
  55. package/dist/packem_shared/alert-CdAET2K_.js +68 -0
  56. package/dist/packem_shared/{app.d-B6MyY_al.d.ts → app.d-CNLRTrWw.d.ts} +1 -1
  57. package/dist/packem_shared/{bar-chart-Bb__F5-u.js → bar-chart-DSwcWIRy.js} +4 -3
  58. package/dist/packem_shared/{browser-storage-d03UsV7v.js → browser-storage-tLOxkIHd.js} +3 -67
  59. package/dist/packem_shared/{data-grid-Dsg6nRjo.js → data-grid-Jz8FqQ2C.js} +1 -1
  60. package/dist/packem_shared/error-alert-BBT6D22d.js +114 -0
  61. package/dist/packem_shared/{grid-features-D7nNzBYm.js → grid-features-CUr8Z1_O.js} +1 -1
  62. package/dist/packem_shared/{home-panel-aOR_drVv.js → home-panel-Bo-Mgrkn.js} +4 -2
  63. package/dist/packem_shared/{internal-FcNZ3beb.js → internal-DTsYVn-g.js} +30 -1
  64. package/dist/packem_shared/{reference-view-Doy1XlQq.js → reference-view-CSKyUyPl.js} +3 -2
  65. package/dist/packem_shared/{sparkline-KgMPHS4u.js → sparkline-BnA1kC9X.js} +1 -1
  66. package/dist/packem_shared/{studio-dMTJ-kRR.js → studio-Dg2e-dsR.js} +587 -560
  67. package/dist/packem_shared/{table-list-sidebar-VMo0ftxD.js → table-list-sidebar-B5psdSV1.js} +1 -1
  68. package/dist/packem_shared/{use-admin-query-BViPA3US.js → use-admin-query-BHPKmPuj.js} +2 -1
  69. package/dist/packem_shared/{use-auth-capabilities-BHkoBnbZ.js → use-auth-capabilities-C-VH0oJJ.js} +1 -1
  70. package/dist/standalone/{chunk-N4JI6VQD.js → chunk-25VHPD2I.js} +1 -1
  71. package/dist/standalone/chunk-2GGMGPEP.js +1 -0
  72. package/dist/standalone/{chunk-BHTPZS7L.js → chunk-3CJW6NWG.js} +1 -1
  73. package/dist/standalone/chunk-4H2OJBXO.js +1 -0
  74. package/dist/standalone/chunk-4MLAVZP4.js +1 -0
  75. package/dist/standalone/chunk-55YA7ZZI.js +76 -0
  76. package/dist/standalone/chunk-5OH3VPZF.js +1 -0
  77. package/dist/standalone/chunk-6GFEVKJP.js +1 -0
  78. package/dist/standalone/{chunk-ITLLHEVG.js → chunk-764T6X6X.js} +1 -1
  79. package/dist/standalone/chunk-7M3F6U4L.js +1 -0
  80. package/dist/standalone/{chunk-KGS7KM4A.js → chunk-7VF3IAAW.js} +1 -1
  81. package/dist/standalone/chunk-AJIUI7DD.js +1 -0
  82. package/dist/standalone/{chunk-5NSZVXCS.js → chunk-BACPICH6.js} +1 -1
  83. package/dist/standalone/chunk-BET2625I.js +1 -0
  84. package/dist/standalone/chunk-BQUQS7QN.js +1 -0
  85. package/dist/standalone/chunk-CKSHCYGC.js +2 -0
  86. package/dist/standalone/chunk-DCECRP45.js +1 -0
  87. package/dist/standalone/chunk-DFP2DADO.js +1 -0
  88. package/dist/standalone/chunk-DORBUITF.js +1 -0
  89. package/dist/standalone/chunk-DVKPRFIJ.js +1 -0
  90. package/dist/standalone/chunk-E6WUCLSI.js +1 -0
  91. package/dist/standalone/chunk-E7WLF6IU.js +1 -0
  92. package/dist/standalone/chunk-EVPLBWUT.js +8 -0
  93. package/dist/standalone/chunk-FCSPAJW4.js +1 -0
  94. package/dist/standalone/chunk-G2ICR3DL.js +1 -0
  95. package/dist/standalone/{chunk-2DS7JLWL.js → chunk-GJ6PGSES.js} +5 -5
  96. package/dist/standalone/chunk-GMSGZDDH.js +13 -0
  97. package/dist/standalone/chunk-GVRM4U6W.js +2 -0
  98. package/dist/standalone/chunk-GZDWDDXN.js +1 -0
  99. package/dist/standalone/chunk-ISJAJWYI.js +1 -0
  100. package/dist/standalone/{chunk-G2TFEWEQ.js → chunk-JIDZFLTB.js} +1 -1
  101. package/dist/standalone/{chunk-RMYA7NAH.js → chunk-K3GNLVYK.js} +1 -1
  102. package/dist/standalone/chunk-K4ZDRTQM.js +1 -0
  103. package/dist/standalone/{chunk-ASLGNHAX.js → chunk-LI43EKM6.js} +1 -1
  104. package/dist/standalone/chunk-MFPTVCJ6.js +1 -0
  105. package/dist/standalone/chunk-MPYFGAOW.js +1 -0
  106. package/dist/standalone/{chunk-TICVNLPM.js → chunk-O3NAGRTR.js} +1 -1
  107. package/dist/standalone/chunk-OV2WFAJX.js +1 -0
  108. package/dist/standalone/chunk-PA3LN4XJ.js +1 -0
  109. package/dist/standalone/chunk-PD6WPVYU.js +1 -0
  110. package/dist/standalone/{chunk-7PBZKXYA.js → chunk-PN5NCZDX.js} +1 -1
  111. package/dist/standalone/{chunk-YJGANMU7.js → chunk-PVZI3CXP.js} +10 -9
  112. package/dist/standalone/chunk-PZ7HD5T2.js +1 -0
  113. package/dist/standalone/{chunk-UGMRUEBU.js → chunk-QAFAJBAW.js} +1 -1
  114. package/dist/standalone/{chunk-6VTGE3WJ.js → chunk-QBAT52GB.js} +1 -1
  115. package/dist/standalone/chunk-QHIIRFG7.js +1 -0
  116. package/dist/standalone/chunk-RSEEHNFI.js +1 -0
  117. package/dist/standalone/chunk-SFJ5F4DX.js +1 -0
  118. package/dist/standalone/{chunk-3BP4BTLR.js → chunk-SGDQIWAR.js} +3 -3
  119. package/dist/standalone/chunk-SYEIXTEU.js +1 -0
  120. package/dist/standalone/chunk-T5HRXUSY.js +1 -0
  121. package/dist/standalone/{chunk-OD2POGPJ.js → chunk-TDL7NEWA.js} +1 -1
  122. package/dist/standalone/chunk-TM7CMA7X.js +1 -0
  123. package/dist/standalone/chunk-U4OAQPBT.js +1 -0
  124. package/dist/standalone/chunk-UDSVXA42.js +1 -0
  125. package/dist/standalone/chunk-UK64ZSUW.js +1 -0
  126. package/dist/standalone/chunk-VEZO7G5Q.js +3 -0
  127. package/dist/standalone/chunk-VSHUSN6T.js +1 -0
  128. package/dist/standalone/chunk-VYMCCC6O.js +1 -0
  129. package/dist/standalone/{chunk-7RYIQKZA.js → chunk-WXPWVBIY.js} +1 -1
  130. package/dist/standalone/chunk-X72PYOEW.js +1 -0
  131. package/dist/standalone/chunk-X7MMBSNW.js +1 -0
  132. package/dist/standalone/{chunk-6RC6L33K.js → chunk-XIGIWZLO.js} +3 -3
  133. package/dist/standalone/chunk-XNJNSCLM.js +1 -0
  134. package/dist/standalone/{chunk-NNISYDNI.js → chunk-XUGSA2NG.js} +1 -1
  135. package/dist/standalone/{chunk-VXBZQIGY.js → chunk-Y2ZPNDL7.js} +1 -1
  136. package/dist/standalone/chunk-YM6BBZDN.js +1 -0
  137. package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
  138. package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
  139. package/dist/standalone/studio.js +30 -30
  140. package/dist/styles.css +1 -1
  141. package/package.json +6 -5
  142. package/dist/standalone/chunk-2PDQ4KZ6.js +0 -1
  143. package/dist/standalone/chunk-57LYXHXH.js +0 -1
  144. package/dist/standalone/chunk-63XKJQTQ.js +0 -1
  145. package/dist/standalone/chunk-7POIIWC5.js +0 -3
  146. package/dist/standalone/chunk-AB6QGMBF.js +0 -1
  147. package/dist/standalone/chunk-D7HKX4DI.js +0 -1
  148. package/dist/standalone/chunk-DGWTR4G7.js +0 -1
  149. package/dist/standalone/chunk-DSX53PBM.js +0 -1
  150. package/dist/standalone/chunk-DV2MNASX.js +0 -1
  151. package/dist/standalone/chunk-E7AVZZKO.js +0 -1
  152. package/dist/standalone/chunk-EGJX34WM.js +0 -1
  153. package/dist/standalone/chunk-FCR3HKFV.js +0 -1
  154. package/dist/standalone/chunk-FQKNJSRA.js +0 -76
  155. package/dist/standalone/chunk-GABMIICA.js +0 -1
  156. package/dist/standalone/chunk-GZXPPJVK.js +0 -1
  157. package/dist/standalone/chunk-HFBRE65A.js +0 -1
  158. package/dist/standalone/chunk-HFMQNUBC.js +0 -1
  159. package/dist/standalone/chunk-HG7Q5B3H.js +0 -1
  160. package/dist/standalone/chunk-HTQL7AXU.js +0 -1
  161. package/dist/standalone/chunk-KG3QTFWE.js +0 -1
  162. package/dist/standalone/chunk-KODWGUAB.js +0 -1
  163. package/dist/standalone/chunk-MGFEVTRI.js +0 -1
  164. package/dist/standalone/chunk-N2QDG3MW.js +0 -1
  165. package/dist/standalone/chunk-O4PXDNR3.js +0 -1
  166. package/dist/standalone/chunk-OXCK3ZUG.js +0 -1
  167. package/dist/standalone/chunk-P7DSVO4U.js +0 -1
  168. package/dist/standalone/chunk-PKAM3N5C.js +0 -1
  169. package/dist/standalone/chunk-QGXGBHQO.js +0 -1
  170. package/dist/standalone/chunk-QHA3TAEJ.js +0 -1
  171. package/dist/standalone/chunk-QQWC62X7.js +0 -1
  172. package/dist/standalone/chunk-S53RUBW5.js +0 -1
  173. package/dist/standalone/chunk-SB4GT6PK.js +0 -1
  174. package/dist/standalone/chunk-SHIOUDOT.js +0 -1
  175. package/dist/standalone/chunk-SIDRSX7Y.js +0 -1
  176. package/dist/standalone/chunk-VJPQUBN6.js +0 -8
  177. package/dist/standalone/chunk-VMJKJWG6.js +0 -1
  178. package/dist/standalone/chunk-VPDPN5RR.js +0 -2
  179. package/dist/standalone/chunk-VSEGZA3J.js +0 -1
  180. package/dist/standalone/chunk-W7PCVQTE.js +0 -1
  181. package/dist/standalone/chunk-XLILSHPE.js +0 -1
  182. package/dist/standalone/chunk-XURNGQSS.js +0 -1
  183. package/dist/standalone/chunk-YQQJ4N6U.js +0 -1
  184. package/dist/standalone/chunk-ZH7UES4T.js +0 -2
  185. package/dist/standalone/chunk-ZQCVDXDL.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as Me,b as De,c as X,d as ve}from"./chunk-KG3QTFWE.js";import{a as Ae}from"./chunk-XURNGQSS.js";import{a as Oe}from"./chunk-KGS7KM4A.js";import"./chunk-7PBZKXYA.js";import"./chunk-6VTGE3WJ.js";import"./chunk-UGMRUEBU.js";import"./chunk-AHILM3ZP.js";import"./chunk-ITLLHEVG.js";import"./chunk-NNISYDNI.js";import"./chunk-5OIBXYZM.js";import"./chunk-FQKNJSRA.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import"./chunk-OD2POGPJ.js";import"./chunk-KEGAWN6Y.js";import{a as Ee,b as qe,c as Ie,d as he,e as Re,f as Le}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as we}from"./chunk-RMYA7NAH.js";import{b as ke}from"./chunk-TBMYIZIO.js";import"./chunk-BHTPZS7L.js";import"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as re}from"./chunk-AQGOX5DK.js";import"./chunk-ZH7UES4T.js";import{f as be}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as G,e as se,f as le,g as Te,i as V}from"./chunk-YJGANMU7.js";import{a as r,e as pe,f as Ct,g as Tt,h as kt,j as ne}from"./chunk-RRCPZMC2.js";var Y=pe(Tt(),1);var q=pe(Ct(),1);var s=pe(kt(),1);var wt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Et=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ae=String.fromCodePoint(0),qt=new RegExp(`${ae}${String.raw`(\d+)`}${ae}`,"gu"),It=wt.map(n=>({pattern:new RegExp(String.raw`\b${n.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:n})),Rt=Et.map(n=>({pattern:new RegExp(String.raw`\s+${n.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
1
+ import{a as De,b as X,c as ve}from"./chunk-4H2OJBXO.js";import{a as Oe}from"./chunk-6GFEVKJP.js";import{a as Me}from"./chunk-7VF3IAAW.js";import"./chunk-PN5NCZDX.js";import"./chunk-QBAT52GB.js";import"./chunk-QAFAJBAW.js";import"./chunk-AHILM3ZP.js";import"./chunk-764T6X6X.js";import"./chunk-XUGSA2NG.js";import"./chunk-5OIBXYZM.js";import"./chunk-55YA7ZZI.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import"./chunk-TDL7NEWA.js";import"./chunk-KEGAWN6Y.js";import{a as Ee}from"./chunk-XNJNSCLM.js";import{a as qe,b as Ie,c as Re,d as he,e as Le,f as Ae}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as we}from"./chunk-K3GNLVYK.js";import{b as ke}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as re}from"./chunk-AQGOX5DK.js";import"./chunk-CKSHCYGC.js";import{f as be}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as G,e as se,f as le,g as Te,k as V}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as r,e as pe,f as Ct,g as Tt,h as kt,j as ne}from"./chunk-RRCPZMC2.js";var Y=pe(Tt(),1);var q=pe(Ct(),1);var s=pe(kt(),1);var wt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Et=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ae=String.fromCodePoint(0),qt=new RegExp(`${ae}${String.raw`(\d+)`}${ae}`,"gu"),It=wt.map(n=>({pattern:new RegExp(String.raw`\b${n.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:n})),Rt=Et.map(n=>({pattern:new RegExp(String.raw`\s+${n.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
2
  ${n}`})),Lt=r(n=>{let e=[],t=n.replaceAll(/'(?:[^']|'')*'/gu,l=>(e.push(l),`${ae}${(e.length-1).toString()}${ae}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:l,replacement:a}of It)t=t.replaceAll(l,a);for(let{pattern:l,replacement:a}of Rt)t=t.replaceAll(l,a);return t=t.replaceAll(qt,(l,a)=>e[Number(a)]??""),t},"formatSql"),ie=8,At=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Ot=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Mt=/[\w$]/,Pe=r(n=>n!==void 0&&Mt.test(n),"isWordChar"),_e=r(n=>{let e=n.length;for(;e>0&&Pe(n[e-1]);)e-=1;return n.slice(e)},"trailingWord"),He=r((n,e)=>{let o=e;for(;o>0&&Pe(n[o-1]);)o-=1;return{end:e,start:o,text:n.slice(o,e)}},"tokenAt"),$e=r((n,e)=>{let o=n.slice(0,e).trimEnd();return o.endsWith(".")||Ot.has(_e(o).toUpperCase())},"prefersColumns"),Dt=r((n,e)=>{let o=n.slice(0,e);if(!o.endsWith("."))return;let t=_e(o.slice(0,-1));return t===""?void 0:t},"qualifierTable"),Ne=r((n,e)=>n.toLowerCase().startsWith(e.toLowerCase()),"matches"),Be=r((n,e,o,t)=>{let l=[];for(let a of n)if(Ne(a,e)&&(l.push(t(a)),l.length>=o))break;return l},"takeMatches"),$t=r((n,e,o)=>{let t=new Map;for(let[l,a]of Object.entries(n.columns))for(let d of a)if(Ne(d,e)&&!t.has(d)&&(t.set(d,l),t.size>=o))return[...t].map(([m,c])=>({detail:c,kind:"column",label:m}));return[...t].map(([l,a])=>({detail:a,kind:"column",label:l}))},"takeColumnMatches"),Bt=r((n,e,o)=>{let t=He(n,e),l=Dt(n,t.start);if(l!==void 0){let u=o.columns[l]??o.columns[l.toLowerCase()]??[];return Be(u,t.text,ie,y=>({detail:l,kind:"column",label:y}))}if(t.text===""&&!$e(n,t.start))return[];let a=Be(o.tables,t.text,ie,u=>({kind:"table",label:u})),d=$t(o,t.text,ie),m=At.filter(u=>t.text!==""&&Ne(u,t.text)&&u.toLowerCase()!==t.text.toLowerCase()).map(u=>({kind:"keyword",label:u}));return($e(n,t.start)?[...d,...a,...m]:[...a,...d,...m]).slice(0,ie)},"suggestionsFor"),Pt=r((n,e,o)=>{let t=He(n,e),l=n.slice(0,t.start)+o.label+n.slice(t.end);return{caret:t.start+o.label.length,value:l}},"acceptSuggestion"),_t=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Ht=r((n,e)=>{let o=globalThis.getComputedStyle(n),t=globalThis.document.createElement("div"),{style:l}=t;l.position="absolute",l.visibility="hidden",l.whiteSpace="pre-wrap",l.overflowWrap="break-word";for(let c of _t)l[c]=o[c];t.textContent=n.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=n.value.slice(Math.max(0,e))||".",t.append(a),globalThis.document.body.append(t);let d=a.offsetLeft-n.scrollLeft,m=a.offsetTop-n.scrollTop;return t.remove(),{left:d,top:m}},"caretOffset"),Wt=r((n,e,o)=>{let t=(0,Y.c)(13),[l,a]=(0,q.useState)(null),d;t[0]!==n||t[1]!==e?(d=r((N,x)=>{let S=Bt(N,x,n);if(S.length===0){a(null);return}let h=e.current,{left:w,top:T}=h===null?{left:0,top:0}:Ht(h,x);a({active:0,left:w,suggestions:S,top:T})},"t0"),t[0]=n,t[1]=e,t[2]=d):d=t[2];let m=d,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=r(()=>{a(null)},"t1"),t[3]=c):c=t[3];let u=c,y;t[4]===Symbol.for("react.memo_cache_sentinel")?(y=r(N=>{a(x=>{if(x===null)return x;let S=x.suggestions.length,h=(x.active+N+S)%S;return{...x,active:h}})},"t2"),t[4]=y):y=t[4];let g=y,v;t[5]!==o||t[6]!==l||t[7]!==e?(v=r(()=>{let N=e.current;if(l===null||N===null)return!1;let x=l.suggestions[l.active];if(x===void 0)return!1;let S=Pt(N.value,N.selectionStart,x);return o(S.value),a(null),requestAnimationFrame(()=>{let h=e.current;h!==null&&(h.focus(),h.setSelectionRange(S.caret,S.caret))}),!0},"t3"),t[5]=o,t[6]=l,t[7]=e,t[8]=v):v=t[8];let p=v,f;return t[9]!==p||t[10]!==m||t[11]!==l?(f={close:u,commit:p,move:g,refresh:m,state:l},t[9]=p,t[10]=m,t[11]=l,t[12]=f):f=t[12],f},"useSqlAutocomplete"),Ft={column:"column",keyword:"keyword",table:"table"},zt=20,Ut=r(n=>{let e=(0,Y.c)(17),{listboxId:o,onPick:t,state:l}=n,a=G(),d;e[0]!==l?(d=l===null?void 0:{left:l.left,top:l.top+zt},e[0]=l,e[1]=d):d=e[1];let m=d;if(l===null)return null;let c;if(e[2]!==o||e[3]!==t||e[4]!==l.active||e[5]!==l.suggestions||e[6]!==a){let y;e[8]!==o||e[9]!==t||e[10]!==l.active||e[11]!==a?(y=r((g,v)=>(0,s.jsxDEV)("li",{"aria-selected":v===l.active,className:ne("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",v===l.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${o}-opt-${v.toString()}`,onMouseDown:r(p=>{p.preventDefault(),t(v)},"onMouseDown"),role:"option",children:[(0,s.jsxDEV)("span",{className:"truncate font-mono",children:g.label},void 0,!1),g.detail!==void 0&&(0,s.jsxDEV)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail},void 0,!1),(0,s.jsxDEV)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Ft[g.kind])},void 0,!1)]},`${g.kind}:${g.label}`,!0),"t32"),e[8]=o,e[9]=t,e[10]=l.active,e[11]=a,e[12]=y):y=e[12],c=l.suggestions.map(y),e[2]=o,e[3]=t,e[4]=l.active,e[5]=l.suggestions,e[6]=a,e[7]=c}else c=e[7];let u;return e[13]!==o||e[14]!==m||e[15]!==c?(u=(0,s.jsxDEV)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:o,role:"listbox",style:m,children:c},void 0,!1),e[13]=o,e[14]=m,e[15]=c,e[16]=u):u=e[16],u},"AutocompletePopover"),We=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Yt=r(n=>{let e=(0,Y.c)(29),{active:o,onDelete:t,onSelect:l,query:a}=n,d=G(),m;e[0]!==l||e[1]!==a.id?(m=r(()=>{l(a.id)},"t1"),e[0]=l,e[1]=a.id,e[2]=m):m=e[2];let c=m,u;e[3]!==t||e[4]!==a.id?(u=r(O=>{O.stopPropagation(),t(a.id)},"t2"),e[3]=t,e[4]=a.id,e[5]=u):u=e[5];let y=u,g=o?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",v;e[6]!==g?(v=ne("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=v):v=e[7];let p=`sql-query-${a.id}`,f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M4 6h16M4 12h10M4 18h7"},void 0,!1)},void 0,!1),e[8]=f):f=e[8];let N;e[9]!==a.name?(N=(0,s.jsxDEV)("span",{className:"truncate",children:a.name},void 0,!1),e[9]=a.name,e[10]=N):N=e[10];let x;e[11]!==o||e[12]!==c||e[13]!==v||e[14]!==p||e[15]!==N?(x=(0,s.jsxDEV)("button",{"aria-pressed":o,className:v,"data-testid":p,onClick:c,type:"button",children:[f,N]},void 0,!0),e[11]=o,e[12]=c,e[13]=v,e[14]=p,e[15]=N,e[16]=x):x=e[16];let S;e[17]!==d?(S=d("Delete query"),e[17]=d,e[18]=S):S=e[18];let h;e[19]!==d?(h=d("Delete query"),e[19]=d,e[20]=h):h=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[21]=w):w=e[21];let T;e[22]!==y||e[23]!==h||e[24]!==S?(T=(0,s.jsxDEV)("button",{"aria-label":S,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:y,title:h,type:"button",children:w},void 0,!1),e[22]=y,e[23]=h,e[24]=S,e[25]=T):T=e[25];let R;return e[26]!==T||e[27]!==x?(R=(0,s.jsxDEV)("li",{className:"group/q flex items-center",children:[x,T]},void 0,!0),e[26]=T,e[27]=x,e[28]=R):R=e[28],R},"QueryRow"),jt=r(n=>{let e=(0,Y.c)(58),{activeId:o,history:t,listRef:l,onClearHistory:a,onDelete:d,onLoadHistory:m,onLoadTemplate:c,onNew:u,onSearchChange:y,onSelect:g,queries:v,search:p}=n,f=G(),N;if(e[0]!==v||e[1]!==p){let k=p.trim().toLowerCase();N=k===""?[...v]:v.filter(j=>j.name.toLowerCase().includes(k)),e[0]=v,e[1]=p,e[2]=N}else N=e[2];let x=N,S;e[3]!==f?(S=f("Search queries\u2026"),e[3]=f,e[4]=S):S=e[4];let h;e[5]!==y||e[6]!==p||e[7]!==S?(h=(0,s.jsxDEV)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:y,placeholder:S,type:"text",value:p},void 0,!1),e[5]=y,e[6]=p,e[7]=S,e[8]=h):h=e[8];let w;e[9]!==f?(w=f("New query"),e[9]=f,e[10]=w):w=e[10];let T;e[11]!==f?(T=f("New query"),e[11]=f,e[12]=T):T=e[12];let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1),e[13]=R):R=e[13];let O;e[14]!==u||e[15]!==w||e[16]!==T?(O=(0,s.jsxDEV)("button",{"aria-label":w,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:u,title:T,type:"button",children:R},void 0,!1),e[14]=u,e[15]=w,e[16]=T,e[17]=O):O=e[17];let A;e[18]!==h||e[19]!==O?(A=(0,s.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[h,O]},void 0,!0),e[18]=h,e[19]=O,e[20]=A):A=e[20];let M;e[21]!==f?(M=f("Private"),e[21]=f,e[22]=M):M=e[22];let z;e[23]!==M?(z=(0,s.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M},void 0,!1),e[23]=M,e[24]=z):z=e[24];let B;e[25]!==o||e[26]!==x||e[27]!==l||e[28]!==d||e[29]!==g||e[30]!==f?(B=x.length===0?(0,s.jsxDEV)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:f("No saved queries yet \u2014 they save to this browser as you type.")},void 0,!1):(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:l,children:x.map(k=>(0,s.jsxDEV)(Yt,{active:o===k.id,onDelete:d,onSelect:g,query:k},k.id,!1))},void 0,!1),e[25]=o,e[26]=x,e[27]=l,e[28]=d,e[29]=g,e[30]=f,e[31]=B):B=e[31];let P;e[32]!==z||e[33]!==B?(P=(0,s.jsxDEV)("div",{children:[z,B]},void 0,!0),e[32]=z,e[33]=B,e[34]=P):P=e[34];let H;e[35]!==f?(H=f("Reference"),e[35]=f,e[36]=H):H=e[36];let U;e[37]!==H?(U=(0,s.jsxDEV)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:H},void 0,!1),e[37]=H,e[38]=U):U=e[38];let I;e[39]!==c?(I=We.map(k=>(0,s.jsxDEV)("li",{children:(0,s.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":k.sql,onClick:c,type:"button",children:[(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"},void 0,!1)},void 0,!1),k.label]},void 0,!0)},k.label,!1)),e[39]=c,e[40]=I):I=e[40];let L;e[41]!==I?(L=(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px",children:I},void 0,!1),e[41]=I,e[42]=L):L=e[42];let D;e[43]!==U||e[44]!==L?(D=(0,s.jsxDEV)("div",{children:[U,L]},void 0,!0),e[43]=U,e[44]=L,e[45]=D):D=e[45];let _;e[46]!==t||e[47]!==a||e[48]!==m||e[49]!==f?(_=t.length>0&&(0,s.jsxDEV)("div",{children:[(0,s.jsxDEV)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,s.jsxDEV)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")},void 0,!1),(0,s.jsxDEV)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:f("Clear history")},void 0,!1)]},void 0,!0),(0,s.jsxDEV)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(k=>(0,s.jsxDEV)("li",{children:(0,s.jsxDEV)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":k.sql,"data-testid":"sql-history-item",onClick:m,title:k.sql,type:"button",children:[(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"},void 0,!1)},void 0,!1),(0,s.jsxDEV)("span",{className:"truncate font-mono",children:k.sql},void 0,!1)]},void 0,!0)},`${k.at.toString()}:${k.sql}`,!1))},void 0,!1)]},void 0,!0),e[46]=t,e[47]=a,e[48]=m,e[49]=f,e[50]=_):_=e[50];let $;e[51]!==P||e[52]!==D||e[53]!==_?($=(0,s.jsxDEV)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[P,D,_]},void 0,!0),e[51]=P,e[52]=D,e[53]=_,e[54]=$):$=e[54];let E;return e[55]!==$||e[56]!==A?(E=(0,s.jsxDEV)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[A,$]},void 0,!0),e[55]=$,e[56]=A,e[57]=E):E=e[57],E},"SqlQuerySidebar"),Kt=se(re.listTables),Gt=se(re.readTablePage),Jt=r(n=>{let e=(0,Y.c)(16),o=be(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[l,a]=(0,q.useState)(t),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[m,c]=(0,q.useState)(d),u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];let y=(0,q.useRef)(u),g,v;e[3]!==o||e[4]!==n?(g=r(()=>{let h={cancelled:!1};return V(r(async()=>{try{let T=await o.query(Kt,{},le(n));h.cancelled||(a(T.map(Vt)),c({}),y.current=new Set)}catch{h.cancelled||(a([]),c({}),y.current=new Set)}},"load")()),()=>{h.cancelled=!0}},"t3"),v=[o,n],e[3]=o,e[4]=n,e[5]=g,e[6]=v):(g=e[5],v=e[6]),(0,q.useEffect)(g,v);let p;e[7]!==o||e[8]!==n?(p=r(h=>{if(y.current.has(h))return;y.current.add(h),V(r(async()=>{try{let T=await o.query(Gt,{limit:1,offset:0,table:h},le(n));c(R=>({...R,[h]:T.columns}))}catch{y.current.delete(h)}},"fetchColumns")())},"t5"),e[7]=o,e[8]=n,e[9]=p):p=e[9];let f=p,N;e[10]!==m||e[11]!==l?(N={columns:m,tables:l},e[10]=m,e[11]=l,e[12]=N):N=e[12];let x=N,S;return e[13]!==f||e[14]!==x?(S={probe:f,schema:x},e[13]=f,e[14]=x,e[15]=S):S=e[15],S},"useSqlSchema"),ge=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Qt=r(n=>{let e=new Set;ge.lastIndex=0;let o=ge.exec(n);for(;o!==null;)e.add(o[1]??o[2]),o=ge.exec(n);return[...e]},"referencedTables");function Vt(n){return n.name}r(Vt,"_temp$2");var Xt="lunora-studio-sql-tabs",Zt="lunora-studio-sql-active-tab",ye=12,Z=r((n="",e="")=>({activeId:null,id:ve("tab"),name:e,sql:n}),"makeTab"),eo=r(()=>{let n=(0,Y.c)(5),[e,o]=X(Zt),t;n[0]!==o?(t=r(m=>{o(c=>{let u=c[0]??"";return[typeof m=="function"?m(u):m]})},"t0"),n[0]=o,n[1]=t):t=n[1];let l=t,a=e[0]??"",d;return n[2]!==l||n[3]!==a?(d=[a,l],n[2]=l,n[3]=a,n[4]=d):d=n[4],d},"usePersistedActive"),to=r(n=>{let[e,o]=X(Xt),[t,l]=eo(),a=(0,q.useRef)(null);e.length===0&&a.current===null&&(a.current=n()),(0,q.useEffect)(()=>{if(e.length===0&&a.current!==null){let c=a.current;o([c])}},[o,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(c=>c.id===t)?t:d[0]?.id??"",setActiveId:l,setTabs:o,tabs:d}},"usePersistedTabs"),Fe=r(n=>n.activeId===null&&n.sql.trim()!=="","isDirty"),oo=r((n,e)=>[...n,e].slice(-ye),"addTab"),no=r((n,e,o)=>{let t=n.findIndex(d=>d.id===e);if(t===-1)return{activeId:n[0]?.id??"",tabs:[...n]};let l=n.filter(d=>d.id!==e);if(l.length===0){let d=o();return{activeId:d.id,tabs:[d]}}return{activeId:l[Math.min(t,l.length-1)].id,tabs:l}},"closeTab"),so=r((n,e)=>{let o=n.filter(t=>t.id===e);return o.length===0?{activeId:n[0]?.id??"",tabs:[...n]}:{activeId:e,tabs:o}},"closeOtherTabs"),lo=r((n,e,o)=>{let t=n.findIndex(a=>a.id===e);if(t===-1)return{activeId:o,tabs:[...n]};let l=n.slice(0,t+1);return{activeId:l.some(a=>a.id===o)?o:e,tabs:l}},"closeTabsToRight"),ro=r(n=>{let e=n();return{activeId:e.id,tabs:[e]}},"closeAllTabs"),io=r((n,e,o)=>{if(n==="others")return e.filter(t=>t.id!==o);if(n==="right"){let t=e.findIndex(l=>l.id===o);return t===-1?[]:e.slice(t+1)}return[...e]},"tabsClosedBy"),ao=r((n,e)=>n.trim()===""?e:(n.split(`
3
- `)[0]??n).slice(0,24),"derivedTabLabel"),co=r(n=>{let e=(0,Y.c)(14),{initial:o,onCancel:t,onCommit:l,placeholder:a,testId:d}=n,m=G(),c=mo,u;e[0]!==l?(u=r(N=>{l(N.currentTarget.value.trim())},"t1"),e[0]=l,e[1]=u):u=e[1];let y=u,g;e[2]!==t||e[3]!==l?(g=r(N=>{N.key==="Enter"?l(N.currentTarget.value.trim()):N.key==="Escape"&&t()},"t2"),e[2]=t,e[3]=l,e[4]=g):g=e[4];let v=g,p;e[5]!==m?(p=m("Tab title"),e[5]=m,e[6]=p):p=e[6];let f;return e[7]!==o||e[8]!==y||e[9]!==v||e[10]!==a||e[11]!==p||e[12]!==d?(f=(0,s.jsxDEV)("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:o,onBlur:y,onKeyDown:v,placeholder:a,ref:c,type:"text"},void 0,!1),e[7]=o,e[8]=y,e[9]=v,e[10]=a,e[11]=p,e[12]=d,e[13]=f):f=e[13],f},"TabRenameInput"),uo=r(n=>{let e=(0,Y.c)(29),{idBase:o,onDiscard:t,onKeep:l}=n,a=G(),d=`sql-tab-close-prompt-${o}`,m;e[0]!==a?(m=a("Discard?"),e[0]=a,e[1]=m):m=e[1];let c;e[2]!==m?(c=(0,s.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=c):c=e[3];let u;e[4]!==a?(u=a("Discard changes"),e[4]=a,e[5]=u):u=e[5];let y=`sql-tab-close-confirm-${o}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M5 13l4 4L19 7"},void 0,!1)},void 0,!1),e[8]=v):v=e[8];let p;e[9]!==t||e[10]!==u||e[11]!==y||e[12]!==g?(p=(0,s.jsxDEV)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":y,onClick:t,title:g,type:"button",children:v},void 0,!1),e[9]=t,e[10]=u,e[11]=y,e[12]=g,e[13]=p):p=e[13];let f;e[14]!==a?(f=a("Keep editing"),e[14]=a,e[15]=f):f=e[15];let N=`sql-tab-close-cancel-${o}`,x;e[16]!==a?(x=a("Keep editing"),e[16]=a,e[17]=x):x=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1),e[18]=S):S=e[18];let h;e[19]!==l||e[20]!==N||e[21]!==x||e[22]!==f?(h=(0,s.jsxDEV)("button",{"aria-label":f,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:l,title:x,type:"button",children:S},void 0,!1),e[19]=l,e[20]=N,e[21]=x,e[22]=f,e[23]=h):h=e[23];let w;return e[24]!==d||e[25]!==h||e[26]!==c||e[27]!==p?(w=(0,s.jsxDEV)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,p,h]},void 0,!0),e[24]=d,e[25]=h,e[26]=c,e[27]=p,e[28]=w):w=e[28],w},"TabCloseConfirm"),fo=r(n=>{let e=(0,Y.c)(47),{active:o,canClose:t,onClose:l,onMenu:a,onRename:d,onSelect:m,tab:c}=n,u=G(),[y,g]=(0,q.useState)(!1),[v,p]=(0,q.useState)(!1),f;e[0]!==a||e[1]!==c.id?(f=r(W=>{a(c.id,W)},"t1"),e[0]=a,e[1]=c.id,e[2]=f):f=e[2];let N=f,x;e[3]!==m||e[4]!==c.id?(x=r(()=>{m(c.id)},"t2"),e[3]=m,e[4]=c.id,e[5]=x):x=e[5];let S=x,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=r(()=>{g(!0)},"t3"),e[6]=h):h=e[6];let w=h,T;e[7]!==l||e[8]!==c?(T=r(W=>{W.stopPropagation(),Fe(c)?p(!0):l(c.id)},"t4"),e[7]=l,e[8]=c,e[9]=T):T=e[9];let R=T,O;e[10]!==l||e[11]!==c.id?(O=r(W=>{W.stopPropagation(),p(!1),l(c.id)},"t5"),e[10]=l,e[11]=c.id,e[12]=O):O=e[12];let A=O,M;e[13]===Symbol.for("react.memo_cache_sentinel")?(M=r(W=>{W.stopPropagation(),p(!1)},"t6"),e[13]=M):M=e[13];let z=M,B;e[14]!==d||e[15]!==c.id?(B=r(W=>{d(c.id,W),g(!1)},"t7"),e[14]=d,e[15]=c.id,e[16]=B):B=e[16];let P=B,H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H=r(()=>{g(!1)},"t8"),e[17]=H):H=e[17];let U=H,I;e[18]!==c.name?(I=c.name.trim(),e[18]=c.name,e[19]=I):I=e[19];let L=I,D;e[20]!==u||e[21]!==c.sql?(D=ao(c.sql,u("Untitled")),e[20]=u,e[21]=c.sql,e[22]=D):D=e[22];let _=D,$=o?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",E;e[23]!==$?(E=ne("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",$),e[23]=$,e[24]=E):E=e[24];let k=`sql-tab-${c.id}`,j;e[25]!==o||e[26]!==P||e[27]!==L||e[28]!==_||e[29]!==y||e[30]!==S||e[31]!==u||e[32]!==c.id?(j=y?(0,s.jsxDEV)(co,{initial:L,onCancel:U,onCommit:P,placeholder:_,testId:`sql-tab-rename-${c.id}`},void 0,!1):(0,s.jsxDEV)("button",{"aria-pressed":o,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:w,title:u("Double-click to rename"),type:"button",children:L===""?_:L},void 0,!1),e[25]=o,e[26]=P,e[27]=L,e[28]=_,e[29]=y,e[30]=S,e[31]=u,e[32]=c.id,e[33]=j):j=e[33];let K;e[34]!==t||e[35]!==A||e[36]!==v||e[37]!==R||e[38]!==u||e[39]!==c.id?(K=t&&(v?(0,s.jsxDEV)(uo,{idBase:c.id,onDiscard:A,onKeep:z},void 0,!1):(0,s.jsxDEV)("button",{"aria-label":u("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:R,title:u("Close tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1)},void 0,!1)),e[34]=t,e[35]=A,e[36]=v,e[37]=R,e[38]=u,e[39]=c.id,e[40]=K):K=e[40];let J;return e[41]!==N||e[42]!==E||e[43]!==k||e[44]!==j||e[45]!==K?(J=(0,s.jsxDEV)("div",{className:E,"data-testid":k,onContextMenu:N,children:[j,K]},void 0,!0),e[41]=N,e[42]=E,e[43]=k,e[44]=j,e[45]=K,e[46]=J):J=e[46],J},"TabButton");function mo(n){n?.focus(),n?.select()}r(mo,"_temp$1");var po=se(re.runSql),bo="lunora-studio-sql-queries",ho="lunora-studio-sql-history",vo=25,go={minWidth:"2.75rem",paddingInline:"0.5rem"},xe={error:null,pane:"results",result:null},xo=r(n=>{let e=(0,Y.c)(16),{result:o}=n;if(o.columns.length===0){let c=o.rowCount===0?"0 rows":"",u;return e[0]!==c?(u=(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground",children:c},void 0,!1),e[0]=c,e[1]=u):u=e[1],u}let t;e[2]!==o.columns?(t=o.columns.map(yo),e[2]=o.columns,e[3]=t):t=e[3];let l;e[4]!==t?(l=(0,s.jsxDEV)(qe,{className:"sticky top-0 z-10 bg-muted",children:(0,s.jsxDEV)(he,{children:t},void 0,!1)},void 0,!1),e[4]=t,e[5]=l):l=e[5];let a;if(e[6]!==o.columns||e[7]!==o.rows){let c;e[9]!==o.columns?(c=r((u,y)=>(0,s.jsxDEV)(he,{"data-testid":"sql-row",children:o.columns.map(g=>(0,s.jsxDEV)(Le,{className:"max-w-md truncate font-mono text-xs",children:(0,s.jsxDEV)(Ae,{value:u[g]},void 0,!1)},g,!1))},y,!1),"t42"),e[9]=o.columns,e[10]=c):c=e[10],a=o.rows.map(c),e[6]=o.columns,e[7]=o.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,s.jsxDEV)(Ie,{children:a},void 0,!1),e[11]=a,e[12]=d):d=e[12];let m;return e[13]!==l||e[14]!==d?(m=(0,s.jsxDEV)(Ee,{"data-testid":"sql-rows",children:[l,d]},void 0,!0),e[13]=l,e[14]=d,e[15]=m):m=e[15],m},"SqlResultTable"),Ao=r(({initialShardKey:n})=>{let e=be(),o=G(),[t,l]=X(bo),[a,d]=X(ho),[m,c]=(0,q.useState)(""),u=r(()=>Z(We[0]?.sql??""),"seedTab"),{activeId:y,setActiveId:g,setTabs:v,tabs:p}=to(u),[f,N]=(0,q.useState)({}),[x,S]=(0,q.useState)(n??""),[h,w]=(0,q.useState)(!1),[T,R]=(0,q.useState)(null),[O,A]=(0,q.useState)(null),M=(0,q.useRef)(null),z=(0,q.useRef)(null),B=(0,q.useRef)(null),P=(0,q.useId)(),{probe:H,schema:U}=Jt(x),I=p.find(i=>i.id===y)??p[0]??Z(),L=I.sql,{activeId:D}=I,_=f[I.id]??xe,{error:$,result:E}=_,k=_.pane,j=r(i=>{v(b=>b.map(C=>C.id===I.id?{...C,...i}:C))},"patchActiveTab"),K=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{error:i.error,pane:i.pane??C.pane,result:i.result}}})},"setActiveOutput"),J=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{...C,pane:i}}})},"setActivePane"),W=r(i=>{j({sql:i}),D!==null&&l(b=>b.map(C=>C.id===D?{...C,sql:i}:C))},"setDraft"),ze=Wt(U,z,W),{close:ce,commit:Se,move:de,refresh:ee,state:Q}=ze,Ue=r(i=>{de(i-(Q?.active??0)),Se()},"onPickSuggestion");(0,q.useEffect)(()=>{let i=z.current;i!==null&&i===document.activeElement&&ee(i.value,i.selectionStart)},[ee,U]);let Ye=r(i=>{d(b=>b[0]?.sql===i?b:[{at:Date.now(),sql:i},...b.filter(F=>F.sql!==i)].slice(0,vo))},"recordHistory"),ue=r(async i=>{if(L.trim()==="")return;w(!0);let b=i==="explain"?`EXPLAIN QUERY PLAN ${L}`:L;try{let C=await e.query(po,{sql:b},le(x));K({error:null,pane:i,result:C}),ke(x),Ye(b)}catch(C){K({error:Te(C),pane:i,result:null})}finally{w(!1)}},"run"),je=r(()=>{V(ue("results"))},"onRun"),Ke=r(i=>{let{selectionStart:b,value:C}=i.target;W(C);for(let F of Qt(C))H(F);ee(C,b)},"onDraftChange"),Ge=r(i=>{let b=i.currentTarget;ee(b.value,b.selectionStart)},"onEditorSelect"),Je=r(i=>{if(Q!==null){if(i.key==="ArrowDown"){i.preventDefault(),de(1);return}if(i.key==="ArrowUp"){i.preventDefault(),de(-1);return}if(i.key==="Escape"){i.preventDefault(),ce();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&Se()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),V(ue(k)))},"onEditorKeyDown"),Qe=r(()=>{requestAnimationFrame(()=>{ce()})},"onEditorBlur"),Ve=r(i=>{M.current!==null&&(M.current.scrollTop=i.currentTarget.scrollTop)},"onEditorScroll"),te=r((i,b)=>{v(C=>C.map(F=>F.id===I.id?{...F,activeId:b,sql:i}:F)),K({error:null,result:null})},"loadIntoActiveTab"),Xe=r(()=>{let i={id:ve("q"),name:o("Untitled query"),sql:""};l(b=>[i,...b]),te("",i.id)},"newQuery"),Ze=r(i=>{let b=t.find(C=>C.id===i);b!==void 0&&(te(b.sql,i),B.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"selectQuery"),et=r(i=>{l(b=>b.filter(C=>C.id!==i)),v(b=>b.map(C=>C.activeId===i?{...C,activeId:null}:C))},"deleteQuery"),tt=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadTemplate"),ot=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadFromHistory"),nt=r(()=>{d([])},"clearHistory"),st=r(()=>{W(Lt(L))},"formatDraft"),lt=r(()=>{if(p.length>=ye)return;let i=Z();v(b=>oo(b,i)),g(i.id)},"addEditorTab"),oe=r(i=>{R(null),A(null),v(i.tabs),g(i.activeId);let b=new Set(i.tabs.map(C=>C.id));N(C=>Object.fromEntries(Object.entries(C).filter(([F])=>b.has(F))))},"commitTabs"),rt=r(i=>{oe(no(p,i,Z))},"closeEditorTab"),Ce=r((i,b)=>{oe(i==="others"?so(p,b):i==="right"?lo(p,b,y):ro(Z))},"applyBulk"),fe=r(i=>{T!==null&&(io(i,p,T.id).some(b=>Fe(b))?A(i):Ce(i,T.id))},"requestBulk"),it=r((i,b)=>{b.preventDefault(),A(null),R({id:i,x:b.clientX,y:b.clientY})},"openTabMenu"),at=r(()=>{R(null),A(null)},"closeTabMenu"),ct=r(i=>{i.preventDefault(),R(null),A(null)},"onBackdropContextMenu"),dt=r(()=>{fe("others")},"onCloseOthers"),ut=r(()=>{fe("right")},"onCloseToRight"),ft=r(()=>{fe("all")},"onCloseAll"),mt=r(()=>{T!==null&&O!==null&&Ce(O,T.id),A(null)},"confirmBulk"),pt=r(()=>{A(null)},"cancelBulk"),bt=T===null?void 0:{left:T.x,top:T.y},ht=r(i=>{ce(),g(i)},"selectTab"),vt=r((i,b)=>{v(C=>C.map(F=>F.id===i?{...F,name:b}:F))},"renameTab"),gt=r(()=>{J("results")},"showResults"),xt=r(()=>{V(ue("explain"))},"showExplain"),yt=r(()=>{J("chart")},"showChart"),Nt=L.split(`
4
- `).length,St=r(i=>{c(i.target.value)},"onSearchChange"),me=r(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"tabClass");return(0,s.jsxDEV)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,s.jsxDEV)(jt,{activeId:D,history:a,listRef:B,onClearHistory:nt,onDelete:et,onLoadHistory:ot,onLoadTemplate:tt,onNew:Xe,onSearchChange:St,onSelect:Ze,queries:t,search:m},void 0,!1),(0,s.jsxDEV)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p.map(i=>(0,s.jsxDEV)(fo,{active:i.id===I.id,canClose:p.length>1,onClose:rt,onMenu:it,onRename:vt,onSelect:ht,tab:i},i.id,!1)),(0,s.jsxDEV)("button",{"aria-label":o("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:p.length>=ye,onClick:lt,title:o("New tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0),T!==null&&(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:at,onContextMenu:ct,role:"presentation"},void 0,!1),(0,s.jsxDEV)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:bt,children:O===null?(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:p.length<=1,onClick:dt,role:"menuitem",type:"button",children:o("Close other tabs")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:p.findIndex(i=>i.id===T.id)>=p.length-1,onClick:ut,role:"menuitem",type:"button",children:o("Close tabs to the right")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:ft,role:"menuitem",type:"button",children:o("Close all tabs")},void 0,!1)]},void 0,!0):(0,s.jsxDEV)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,s.jsxDEV)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")},void 0,!1),(0,s.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:mt,type:"button",children:o("Discard")},void 0,!1),(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:pt,type:"button",children:o("Cancel")},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex min-h-0 flex-1",children:[(0,s.jsxDEV)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:M,style:go,children:Array.from({length:Nt},(i,b)=>(0,s.jsxDEV)("div",{children:b+1},b,!1))},void 0,!1),(0,s.jsxDEV)("div",{className:"relative min-w-0 flex-1",children:[(0,s.jsxDEV)("textarea",{"aria-activedescendant":Q===null?void 0:`${P}-opt-${Q.active.toString()}`,"aria-autocomplete":"list","aria-controls":Q===null?void 0:P,"aria-expanded":Q!==null,"aria-label":o("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ke,onKeyDown:Je,onScroll:Ve,onSelect:Ge,placeholder:"SELECT * FROM \u2026",ref:z,role:"combobox",spellCheck:!1,value:L},void 0,!1),(0,s.jsxDEV)(Ut,{listboxId:P,onPick:Ue,state:Q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,s.jsxDEV)("button",{className:me(k==="results"),"data-testid":"sql-tab-results",onClick:gt,type:"button",children:o("Results")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="chart"),"data-testid":"sql-tab-chart",onClick:yt,type:"button",children:o("Chart")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="explain"),"data-testid":"sql-tab-explain",onClick:xt,type:"button",children:o("Explain")},void 0,!1),(0,s.jsxDEV)("div",{className:"ms-auto flex items-center gap-2",children:[E!==null&&E.columns.length>0&&(0,s.jsxDEV)(Oe,{columns:E.columns,name:"query-result",rows:E.rows},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:h,onClick:st,type:"button",children:o("Format")},void 0,!1),(0,s.jsxDEV)(we,{onChange:S,testId:"sql-shard-input",value:x},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:h,onClick:je,type:"button",children:[o(h?"Running\u2026":"Run"),(0,s.jsxDEV)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-auto",children:[$!==null&&(0,s.jsxDEV)(De,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:$},void 0,!1),$===null&&E===null&&(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:o("Click Run to execute your query.")},void 0,!1),$===null&&E!==null&&(0,s.jsxDEV)("div",{"data-testid":"sql-result",children:[k==="chart"?(0,s.jsxDEV)(Me,{result:E},void 0,!1):(0,s.jsxDEV)(xo,{result:E},void 0,!1),(0,s.jsxDEV)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:E.truncated?o("Showing the first {max} of {count} rows.",{count:E.rowCount,max:E.rows.length}):o("{count} rows",{count:E.rowCount})},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"SqlEditorPanel");function yo(n){return(0,s.jsxDEV)(Re,{children:n},n,!1)}r(yo,"_temp");export{Ao as SqlEditorPanel};
3
+ `)[0]??n).slice(0,24),"derivedTabLabel"),co=r(n=>{let e=(0,Y.c)(14),{initial:o,onCancel:t,onCommit:l,placeholder:a,testId:d}=n,m=G(),c=mo,u;e[0]!==l?(u=r(N=>{l(N.currentTarget.value.trim())},"t1"),e[0]=l,e[1]=u):u=e[1];let y=u,g;e[2]!==t||e[3]!==l?(g=r(N=>{N.key==="Enter"?l(N.currentTarget.value.trim()):N.key==="Escape"&&t()},"t2"),e[2]=t,e[3]=l,e[4]=g):g=e[4];let v=g,p;e[5]!==m?(p=m("Tab title"),e[5]=m,e[6]=p):p=e[6];let f;return e[7]!==o||e[8]!==y||e[9]!==v||e[10]!==a||e[11]!==p||e[12]!==d?(f=(0,s.jsxDEV)("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:o,onBlur:y,onKeyDown:v,placeholder:a,ref:c,type:"text"},void 0,!1),e[7]=o,e[8]=y,e[9]=v,e[10]=a,e[11]=p,e[12]=d,e[13]=f):f=e[13],f},"TabRenameInput"),uo=r(n=>{let e=(0,Y.c)(29),{idBase:o,onDiscard:t,onKeep:l}=n,a=G(),d=`sql-tab-close-prompt-${o}`,m;e[0]!==a?(m=a("Discard?"),e[0]=a,e[1]=m):m=e[1];let c;e[2]!==m?(c=(0,s.jsxDEV)("span",{className:"text-[11px] text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=c):c=e[3];let u;e[4]!==a?(u=a("Discard changes"),e[4]=a,e[5]=u):u=e[5];let y=`sql-tab-close-confirm-${o}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let v;e[8]===Symbol.for("react.memo_cache_sentinel")?(v=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M5 13l4 4L19 7"},void 0,!1)},void 0,!1),e[8]=v):v=e[8];let p;e[9]!==t||e[10]!==u||e[11]!==y||e[12]!==g?(p=(0,s.jsxDEV)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":y,onClick:t,title:g,type:"button",children:v},void 0,!1),e[9]=t,e[10]=u,e[11]=y,e[12]=g,e[13]=p):p=e[13];let f;e[14]!==a?(f=a("Keep editing"),e[14]=a,e[15]=f):f=e[15];let N=`sql-tab-close-cancel-${o}`,x;e[16]!==a?(x=a("Keep editing"),e[16]=a,e[17]=x):x=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1),e[18]=S):S=e[18];let h;e[19]!==l||e[20]!==N||e[21]!==x||e[22]!==f?(h=(0,s.jsxDEV)("button",{"aria-label":f,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:l,title:x,type:"button",children:S},void 0,!1),e[19]=l,e[20]=N,e[21]=x,e[22]=f,e[23]=h):h=e[23];let w;return e[24]!==d||e[25]!==h||e[26]!==c||e[27]!==p?(w=(0,s.jsxDEV)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,p,h]},void 0,!0),e[24]=d,e[25]=h,e[26]=c,e[27]=p,e[28]=w):w=e[28],w},"TabCloseConfirm"),fo=r(n=>{let e=(0,Y.c)(47),{active:o,canClose:t,onClose:l,onMenu:a,onRename:d,onSelect:m,tab:c}=n,u=G(),[y,g]=(0,q.useState)(!1),[v,p]=(0,q.useState)(!1),f;e[0]!==a||e[1]!==c.id?(f=r(W=>{a(c.id,W)},"t1"),e[0]=a,e[1]=c.id,e[2]=f):f=e[2];let N=f,x;e[3]!==m||e[4]!==c.id?(x=r(()=>{m(c.id)},"t2"),e[3]=m,e[4]=c.id,e[5]=x):x=e[5];let S=x,h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=r(()=>{g(!0)},"t3"),e[6]=h):h=e[6];let w=h,T;e[7]!==l||e[8]!==c?(T=r(W=>{W.stopPropagation(),Fe(c)?p(!0):l(c.id)},"t4"),e[7]=l,e[8]=c,e[9]=T):T=e[9];let R=T,O;e[10]!==l||e[11]!==c.id?(O=r(W=>{W.stopPropagation(),p(!1),l(c.id)},"t5"),e[10]=l,e[11]=c.id,e[12]=O):O=e[12];let A=O,M;e[13]===Symbol.for("react.memo_cache_sentinel")?(M=r(W=>{W.stopPropagation(),p(!1)},"t6"),e[13]=M):M=e[13];let z=M,B;e[14]!==d||e[15]!==c.id?(B=r(W=>{d(c.id,W),g(!1)},"t7"),e[14]=d,e[15]=c.id,e[16]=B):B=e[16];let P=B,H;e[17]===Symbol.for("react.memo_cache_sentinel")?(H=r(()=>{g(!1)},"t8"),e[17]=H):H=e[17];let U=H,I;e[18]!==c.name?(I=c.name.trim(),e[18]=c.name,e[19]=I):I=e[19];let L=I,D;e[20]!==u||e[21]!==c.sql?(D=ao(c.sql,u("Untitled")),e[20]=u,e[21]=c.sql,e[22]=D):D=e[22];let _=D,$=o?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",E;e[23]!==$?(E=ne("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",$),e[23]=$,e[24]=E):E=e[24];let k=`sql-tab-${c.id}`,j;e[25]!==o||e[26]!==P||e[27]!==L||e[28]!==_||e[29]!==y||e[30]!==S||e[31]!==u||e[32]!==c.id?(j=y?(0,s.jsxDEV)(co,{initial:L,onCancel:U,onCommit:P,placeholder:_,testId:`sql-tab-rename-${c.id}`},void 0,!1):(0,s.jsxDEV)("button",{"aria-pressed":o,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:w,title:u("Double-click to rename"),type:"button",children:L===""?_:L},void 0,!1),e[25]=o,e[26]=P,e[27]=L,e[28]=_,e[29]=y,e[30]=S,e[31]=u,e[32]=c.id,e[33]=j):j=e[33];let K;e[34]!==t||e[35]!==A||e[36]!==v||e[37]!==R||e[38]!==u||e[39]!==c.id?(K=t&&(v?(0,s.jsxDEV)(uo,{idBase:c.id,onDiscard:A,onKeep:z},void 0,!1):(0,s.jsxDEV)("button",{"aria-label":u("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:R,title:u("Close tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M6 6l12 12M18 6 6 18"},void 0,!1)},void 0,!1)},void 0,!1)),e[34]=t,e[35]=A,e[36]=v,e[37]=R,e[38]=u,e[39]=c.id,e[40]=K):K=e[40];let J;return e[41]!==N||e[42]!==E||e[43]!==k||e[44]!==j||e[45]!==K?(J=(0,s.jsxDEV)("div",{className:E,"data-testid":k,onContextMenu:N,children:[j,K]},void 0,!0),e[41]=N,e[42]=E,e[43]=k,e[44]=j,e[45]=K,e[46]=J):J=e[46],J},"TabButton");function mo(n){n?.focus(),n?.select()}r(mo,"_temp$1");var po=se(re.runSql),bo="lunora-studio-sql-queries",ho="lunora-studio-sql-history",vo=25,go={minWidth:"2.75rem",paddingInline:"0.5rem"},xe={error:null,pane:"results",result:null},xo=r(n=>{let e=(0,Y.c)(16),{result:o}=n;if(o.columns.length===0){let c=o.rowCount===0?"0 rows":"",u;return e[0]!==c?(u=(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground",children:c},void 0,!1),e[0]=c,e[1]=u):u=e[1],u}let t;e[2]!==o.columns?(t=o.columns.map(yo),e[2]=o.columns,e[3]=t):t=e[3];let l;e[4]!==t?(l=(0,s.jsxDEV)(Ie,{className:"sticky top-0 z-10 bg-muted",children:(0,s.jsxDEV)(he,{children:t},void 0,!1)},void 0,!1),e[4]=t,e[5]=l):l=e[5];let a;if(e[6]!==o.columns||e[7]!==o.rows){let c;e[9]!==o.columns?(c=r((u,y)=>(0,s.jsxDEV)(he,{"data-testid":"sql-row",children:o.columns.map(g=>(0,s.jsxDEV)(Ae,{className:"max-w-md truncate font-mono text-xs",children:(0,s.jsxDEV)(Oe,{value:u[g]},void 0,!1)},g,!1))},y,!1),"t42"),e[9]=o.columns,e[10]=c):c=e[10],a=o.rows.map(c),e[6]=o.columns,e[7]=o.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,s.jsxDEV)(Re,{children:a},void 0,!1),e[11]=a,e[12]=d):d=e[12];let m;return e[13]!==l||e[14]!==d?(m=(0,s.jsxDEV)(qe,{"data-testid":"sql-rows",children:[l,d]},void 0,!0),e[13]=l,e[14]=d,e[15]=m):m=e[15],m},"SqlResultTable"),Oo=r(({initialShardKey:n})=>{let e=be(),o=G(),[t,l]=X(bo),[a,d]=X(ho),[m,c]=(0,q.useState)(""),u=r(()=>Z(We[0]?.sql??""),"seedTab"),{activeId:y,setActiveId:g,setTabs:v,tabs:p}=to(u),[f,N]=(0,q.useState)({}),[x,S]=(0,q.useState)(n??""),[h,w]=(0,q.useState)(!1),[T,R]=(0,q.useState)(null),[O,A]=(0,q.useState)(null),M=(0,q.useRef)(null),z=(0,q.useRef)(null),B=(0,q.useRef)(null),P=(0,q.useId)(),{probe:H,schema:U}=Jt(x),I=p.find(i=>i.id===y)??p[0]??Z(),L=I.sql,{activeId:D}=I,_=f[I.id]??xe,{error:$,result:E}=_,k=_.pane,j=r(i=>{v(b=>b.map(C=>C.id===I.id?{...C,...i}:C))},"patchActiveTab"),K=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{error:i.error,pane:i.pane??C.pane,result:i.result}}})},"setActiveOutput"),J=r(i=>{N(b=>{let C=b[I.id]??xe;return{...b,[I.id]:{...C,pane:i}}})},"setActivePane"),W=r(i=>{j({sql:i}),D!==null&&l(b=>b.map(C=>C.id===D?{...C,sql:i}:C))},"setDraft"),ze=Wt(U,z,W),{close:ce,commit:Se,move:de,refresh:ee,state:Q}=ze,Ue=r(i=>{de(i-(Q?.active??0)),Se()},"onPickSuggestion");(0,q.useEffect)(()=>{let i=z.current;i!==null&&i===document.activeElement&&ee(i.value,i.selectionStart)},[ee,U]);let Ye=r(i=>{d(b=>b[0]?.sql===i?b:[{at:Date.now(),sql:i},...b.filter(F=>F.sql!==i)].slice(0,vo))},"recordHistory"),ue=r(async i=>{if(L.trim()==="")return;w(!0);let b=i==="explain"?`EXPLAIN QUERY PLAN ${L}`:L;try{let C=await e.query(po,{sql:b},le(x));K({error:null,pane:i,result:C}),ke(x),Ye(b)}catch(C){K({error:Te(C),pane:i,result:null})}finally{w(!1)}},"run"),je=r(()=>{V(ue("results"))},"onRun"),Ke=r(i=>{let{selectionStart:b,value:C}=i.target;W(C);for(let F of Qt(C))H(F);ee(C,b)},"onDraftChange"),Ge=r(i=>{let b=i.currentTarget;ee(b.value,b.selectionStart)},"onEditorSelect"),Je=r(i=>{if(Q!==null){if(i.key==="ArrowDown"){i.preventDefault(),de(1);return}if(i.key==="ArrowUp"){i.preventDefault(),de(-1);return}if(i.key==="Escape"){i.preventDefault(),ce();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&Se()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),V(ue(k)))},"onEditorKeyDown"),Qe=r(()=>{requestAnimationFrame(()=>{ce()})},"onEditorBlur"),Ve=r(i=>{M.current!==null&&(M.current.scrollTop=i.currentTarget.scrollTop)},"onEditorScroll"),te=r((i,b)=>{v(C=>C.map(F=>F.id===I.id?{...F,activeId:b,sql:i}:F)),K({error:null,result:null})},"loadIntoActiveTab"),Xe=r(()=>{let i={id:ve("q"),name:o("Untitled query"),sql:""};l(b=>[i,...b]),te("",i.id)},"newQuery"),Ze=r(i=>{let b=t.find(C=>C.id===i);b!==void 0&&(te(b.sql,i),B.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"selectQuery"),et=r(i=>{l(b=>b.filter(C=>C.id!==i)),v(b=>b.map(C=>C.activeId===i?{...C,activeId:null}:C))},"deleteQuery"),tt=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadTemplate"),ot=r(i=>{te(i.currentTarget.dataset.sql??"",null)},"loadFromHistory"),nt=r(()=>{d([])},"clearHistory"),st=r(()=>{W(Lt(L))},"formatDraft"),lt=r(()=>{if(p.length>=ye)return;let i=Z();v(b=>oo(b,i)),g(i.id)},"addEditorTab"),oe=r(i=>{R(null),A(null),v(i.tabs),g(i.activeId);let b=new Set(i.tabs.map(C=>C.id));N(C=>Object.fromEntries(Object.entries(C).filter(([F])=>b.has(F))))},"commitTabs"),rt=r(i=>{oe(no(p,i,Z))},"closeEditorTab"),Ce=r((i,b)=>{oe(i==="others"?so(p,b):i==="right"?lo(p,b,y):ro(Z))},"applyBulk"),fe=r(i=>{T!==null&&(io(i,p,T.id).some(b=>Fe(b))?A(i):Ce(i,T.id))},"requestBulk"),it=r((i,b)=>{b.preventDefault(),A(null),R({id:i,x:b.clientX,y:b.clientY})},"openTabMenu"),at=r(()=>{R(null),A(null)},"closeTabMenu"),ct=r(i=>{i.preventDefault(),R(null),A(null)},"onBackdropContextMenu"),dt=r(()=>{fe("others")},"onCloseOthers"),ut=r(()=>{fe("right")},"onCloseToRight"),ft=r(()=>{fe("all")},"onCloseAll"),mt=r(()=>{T!==null&&O!==null&&Ce(O,T.id),A(null)},"confirmBulk"),pt=r(()=>{A(null)},"cancelBulk"),bt=T===null?void 0:{left:T.x,top:T.y},ht=r(i=>{ce(),g(i)},"selectTab"),vt=r((i,b)=>{v(C=>C.map(F=>F.id===i?{...F,name:b}:F))},"renameTab"),gt=r(()=>{J("results")},"showResults"),xt=r(()=>{V(ue("explain"))},"showExplain"),yt=r(()=>{J("chart")},"showChart"),Nt=L.split(`
4
+ `).length,St=r(i=>{c(i.target.value)},"onSearchChange"),me=r(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"tabClass");return(0,s.jsxDEV)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,s.jsxDEV)(jt,{activeId:D,history:a,listRef:B,onClearHistory:nt,onDelete:et,onLoadHistory:ot,onLoadTemplate:tt,onNew:Xe,onSearchChange:St,onSelect:Ze,queries:t,search:m},void 0,!1),(0,s.jsxDEV)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p.map(i=>(0,s.jsxDEV)(fo,{active:i.id===I.id,canClose:p.length>1,onClose:rt,onMenu:it,onRename:vt,onSelect:ht,tab:i},i.id,!1)),(0,s.jsxDEV)("button",{"aria-label":o("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:p.length>=ye,onClick:lt,title:o("New tab"),type:"button",children:(0,s.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M12 5v14M5 12h14"},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0),T!==null&&(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:at,onContextMenu:ct,role:"presentation"},void 0,!1),(0,s.jsxDEV)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:bt,children:O===null?(0,s.jsxDEV)(s.Fragment,{children:[(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:p.length<=1,onClick:dt,role:"menuitem",type:"button",children:o("Close other tabs")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:p.findIndex(i=>i.id===T.id)>=p.length-1,onClick:ut,role:"menuitem",type:"button",children:o("Close tabs to the right")},void 0,!1),(0,s.jsxDEV)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:ft,role:"menuitem",type:"button",children:o("Close all tabs")},void 0,!1)]},void 0,!0):(0,s.jsxDEV)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,s.jsxDEV)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")},void 0,!1),(0,s.jsxDEV)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:mt,type:"button",children:o("Discard")},void 0,!1),(0,s.jsxDEV)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:pt,type:"button",children:o("Cancel")},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex min-h-0 flex-1",children:[(0,s.jsxDEV)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:M,style:go,children:Array.from({length:Nt},(i,b)=>(0,s.jsxDEV)("div",{children:b+1},b,!1))},void 0,!1),(0,s.jsxDEV)("div",{className:"relative min-w-0 flex-1",children:[(0,s.jsxDEV)("textarea",{"aria-activedescendant":Q===null?void 0:`${P}-opt-${Q.active.toString()}`,"aria-autocomplete":"list","aria-controls":Q===null?void 0:P,"aria-expanded":Q!==null,"aria-label":o("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ke,onKeyDown:Je,onScroll:Ve,onSelect:Ge,placeholder:"SELECT * FROM \u2026",ref:z,role:"combobox",spellCheck:!1,value:L},void 0,!1),(0,s.jsxDEV)(Ut,{listboxId:P,onPick:Ue,state:Q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",children:[(0,s.jsxDEV)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,s.jsxDEV)("button",{className:me(k==="results"),"data-testid":"sql-tab-results",onClick:gt,type:"button",children:o("Results")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="chart"),"data-testid":"sql-tab-chart",onClick:yt,type:"button",children:o("Chart")},void 0,!1),(0,s.jsxDEV)("button",{className:me(k==="explain"),"data-testid":"sql-tab-explain",onClick:xt,type:"button",children:o("Explain")},void 0,!1),(0,s.jsxDEV)("div",{className:"ms-auto flex items-center gap-2",children:[E!==null&&E.columns.length>0&&(0,s.jsxDEV)(Me,{columns:E.columns,name:"query-result",rows:E.rows},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:h,onClick:st,type:"button",children:o("Format")},void 0,!1),(0,s.jsxDEV)(we,{onChange:S,testId:"sql-shard-input",value:x},void 0,!1),(0,s.jsxDEV)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:h,onClick:je,type:"button",children:[o(h?"Running\u2026":"Run"),(0,s.jsxDEV)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,s.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-auto",children:[$!==null&&(0,s.jsxDEV)(Ee,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:$},void 0,!1),$===null&&E===null&&(0,s.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:o("Click Run to execute your query.")},void 0,!1),$===null&&E!==null&&(0,s.jsxDEV)("div",{"data-testid":"sql-result",children:[k==="chart"?(0,s.jsxDEV)(De,{result:E},void 0,!1):(0,s.jsxDEV)(xo,{result:E},void 0,!1),(0,s.jsxDEV)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:E.truncated?o("Showing the first {max} of {count} rows.",{count:E.rowCount,max:E.rows.length}):o("{count} rows",{count:E.rowCount})},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"SqlEditorPanel");function yo(n){return(0,s.jsxDEV)(Le,{children:n},n,!1)}r(yo,"_temp");export{Oo as SqlEditorPanel};
@@ -0,0 +1 @@
1
+ import{a as C}from"./chunk-J6J54MBP.js";import{a as E}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as x,b as I,c as N,d as u,e as l,f as o}from"./chunk-GTM65MVX.js";import{a as g}from"./chunk-AQGOX5DK.js";import{a as A}from"./chunk-TAD43CG5.js";import{b as y}from"./chunk-DVKPRFIJ.js";import{a as m,e as h}from"./chunk-SEU5V7I6.js";import{b as v}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as S,n as b}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as c,e as Q,h as V}from"./chunk-RRCPZMC2.js";var e=Q(V(),1);var P=new Set(["active","trialing"]),D=new Set(["past_due","unpaid"]),a=c((t,s)=>{if(t[s]!==void 0)return t[s];let d=t.__doc__;if(typeof d=="string")try{let n=JSON.parse(d);if(n!==null&&typeof n=="object"&&!Array.isArray(n))return n[s]}catch{}},"readField"),i=c(t=>typeof t=="string"?t:typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"?String(t):"","text"),F=c(t=>P.has(t)?"default":D.has(t)?"destructive":"outline","badgeVariant"),K=c(({limit:t=100})=>{let s=S(),d=y(g.readTablePage,{filters:[],limit:t,offset:0,orderBy:[],search:"",table:"subscriptions"}),n=y(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"});C(()=>{d.refetch(),n.refetch()},!0);let f=d.data?.rows??[],R=n.data?.rows??[],B=d.error??n.error,w=d.error===null?n.errorSource:d.errorSource,T=f.filter(r=>P.has(i(a(r,"state")))).length,j=R.toSorted((r,p)=>Number(a(p,"processedAt")??0)-Number(a(r,"processedAt")??0));return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxDEV)(m,{className:"justify-between gap-0 py-0",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Subscriptions")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T},void 0,!1),(0,e.jsxDEV)(v,{variant:"default",children:s("{count} active",{count:T})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:s("{total} total",{total:f.length})},void 0,!1)]},void 0,!0)},void 0,!1),B===null?void 0:(0,e.jsxDEV)(E,{error:w},void 0,!1),f.length===0&&!d.isLoading?(0,e.jsxDEV)(A,{testId:"payments-empty",title:s("No subscriptions yet")},void 0,!1):(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:[(0,e.jsxDEV)(I,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(l,{children:s("Provider")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Reference")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Plan")},void 0,!1),(0,e.jsxDEV)(l,{children:s("State")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Renews")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(N,{children:f.map(r=>{let p=i(a(r,"state"));return(0,e.jsxDEV)(u,{"data-testid":"payment-subscription-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"referenceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"priceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:(0,e.jsxDEV)(v,{variant:F(p),children:p},void 0,!1)},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"currentPeriodEnd"))},void 0,!1)]},i(a(r,"providerSubscriptionId")),!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Recent webhook events")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:(0,e.jsxDEV)(N,{children:j.map(r=>(0,e.jsxDEV)(u,{"data-testid":"payment-event-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{className:"font-medium",children:i(a(r,"type"))},void 0,!1),(0,e.jsxDEV)(o,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"processedAt"))},void 0,!1)]},i(a(r,"providerEventId")),!0))},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PaymentsPanel");export{K as PaymentsPanel};
@@ -0,0 +1 @@
1
+ import{a as Q}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as O,b as $,c as j,d as S,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-AQGOX5DK.js";import{a as _}from"./chunk-TAD43CG5.js";import{b as F}from"./chunk-DVKPRFIJ.js";import{a as B,e as D}from"./chunk-SEU5V7I6.js";import{b as k}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as R,e as M,g as z,h as J}from"./chunk-RRCPZMC2.js";var q=M(z(),1);var l=M(J(),1);var V=["read","insert","update","delete"],K=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"operationLabel"),W=R(e=>{let s=new Map;for(let t of e){let r=s.get(t.table)??{operations:new Set,procedures:[],table:t.table};r.operations.add(t.on),r.procedures.includes(t.procedure)||r.procedures.push(t.procedure),s.set(t.table,r)}return[...s.values()].toSorted((t,r)=>t.table.localeCompare(r.table))},"groupByTable"),ie=R(()=>{let e=(0,q.c)(49),s=U(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];let{data:r,error:C,errorSource:I}=F(L.rlsPolicies,t),f=r!==void 0,p,d,m,a,u,h,v,b,o;if(e[1]!==r||e[2]!==C||e[3]!==I||e[4]!==f||e[5]!==s){let G=W(Array.isArray(r?.policies)?r.policies:[]),P;e[15]!==r?(P=Array.isArray(r?.roles)?r.roles:[],e[15]=r,e[16]=P):P=e[16],d=P,v="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(o=C!==null&&(0,l.jsxDEV)(Q,{error:I,testId:"rls-error"},void 0,!1),e[17]=C,e[18]=I,e[19]=o):o=e[19],h="flex flex-col gap-2",p=B,m="overflow-hidden py-0";let A;e[20]!==s?(A=s("Policies"),e[20]=s,e[21]=A):A=e[21],e[22]!==A?(a=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A},void 0,!1)},void 0,!1),e[22]=A,e[23]=a):a=e[23],u=f&&G.length===0?(0,l.jsxDEV)(_,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-policies-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Table")},void 0,!1),V.map(i=>(0,l.jsxDEV)(n,{children:K(s,i)},i,!1)),(0,l.jsxDEV)(n,{children:s("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:G.map(i=>(0,l.jsxDEV)(S,{"data-testid":`rls-table-${i.table}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:i.table},void 0,!1),V.map(H=>(0,l.jsxDEV)(c,{children:i.operations.has(H)?(0,l.jsxDEV)(k,{variant:"secondary",children:s("Guarded")},void 0,!1):(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1)},H,!1)),(0,l.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")},void 0,!1)]},i.table,!0))},void 0,!1)]},void 0,!0)},void 0,!1),e[1]=r,e[2]=C,e[3]=I,e[4]=f,e[5]=s,e[6]=p,e[7]=d,e[8]=m,e[9]=a,e[10]=u,e[11]=h,e[12]=v,e[13]=b,e[14]=o}else p=e[6],d=e[7],m=e[8],a=e[9],u=e[10],h=e[11],v=e[12],b=e[13],o=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==a||e[27]!==u?(x=(0,l.jsxDEV)(p,{className:m,children:[a,u]},void 0,!0),e[24]=p,e[25]=m,e[26]=a,e[27]=u,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=(0,l.jsxDEV)("section",{className:h,children:x},void 0,!1),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let g;e[34]!==y?(g=(0,l.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,l.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1)},void 0,!1),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==f||e[37]!==d||e[38]!==s?(T=f&&d.length===0?(0,l.jsxDEV)(_,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")},void 0,!1):(0,l.jsxDEV)(D,{className:"px-0",children:(0,l.jsxDEV)(O,{"data-testid":"rls-roles-table",children:[(0,l.jsxDEV)($,{children:(0,l.jsxDEV)(S,{children:[(0,l.jsxDEV)(n,{children:s("Role")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Description")},void 0,!1),(0,l.jsxDEV)(n,{children:s("Permissions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(j,{children:d.map(Y)},void 0,!1)]},void 0,!0)},void 0,!1),e[36]=f,e[37]=d,e[38]=s,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2",children:(0,l.jsxDEV)(B,{className:"overflow-hidden py-0",children:[g,T]},void 0,!0)},void 0,!1),e[40]=g,e[41]=T,e[42]=w):w=e[42];let E;return e[43]!==w||e[44]!==v||e[45]!==b||e[46]!==o||e[47]!==N?(E=(0,l.jsxDEV)("div",{className:v,"data-testid":b,children:[o,N,w]},void 0,!0),e[43]=w,e[44]=v,e[45]=b,e[46]=o,e[47]=N,e[48]=E):E=e[48],E},"RlsPanel");function X(e){return(0,l.jsxDEV)(k,{variant:"outline",children:e},e,!1)}R(X,"_temp");function Y(e){return(0,l.jsxDEV)(S,{"data-testid":`rls-role-${e.name}`,children:[(0,l.jsxDEV)(c,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,l.jsxDEV)(c,{className:"text-muted-foreground",children:e.description??""},void 0,!1),(0,l.jsxDEV)(c,{children:e.permissions.length===0?(0,l.jsxDEV)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"},void 0,!1):(0,l.jsxDEV)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)},void 0,!1)},void 0,!1)]},e.name,!0)}R(Y,"_temp2");export{ie as default};
@@ -1 +1 @@
1
- import{c as e}from"./chunk-YQQJ4N6U.js";import{d as c}from"./chunk-YJGANMU7.js";import{a as t,e as s,f as g,h}from"./chunk-RRCPZMC2.js";var m=s(g(),1);var n=s(h(),1);var y=t(({children:f,confirmLabel:l,disabled:r=!1,onConfirm:p,testId:o})=>{let a=c(),[u,i]=(0,m.useState)(!1),d=t(()=>{i(!0)},"startConfirm"),C=t(()=>{i(!1)},"cancelConfirm"),v=t(()=>{i(!1),p()},"acceptConfirm");return u?(0,n.jsxDEV)("span",{className:"inline-flex items-center gap-1","data-testid":`${o}-prompt`,role:"group",children:[(0,n.jsxDEV)(e,{"data-testid":`${o}-confirm`,disabled:r,onClick:v,size:"sm",type:"button",variant:"destructive",children:l??a("Confirm")},void 0,!1),(0,n.jsxDEV)(e,{"data-testid":`${o}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0):(0,n.jsxDEV)(e,{"data-testid":o,disabled:r,onClick:d,size:"sm",type:"button",variant:"outline",children:f},void 0,!1)},"ConfirmButton");export{y as a};
1
+ import{c as e}from"./chunk-UK64ZSUW.js";import{d as c}from"./chunk-PVZI3CXP.js";import{a as t,e as s,f as g,h}from"./chunk-RRCPZMC2.js";var m=s(g(),1);var n=s(h(),1);var y=t(({children:f,confirmLabel:l,disabled:r=!1,onConfirm:p,testId:o})=>{let a=c(),[u,i]=(0,m.useState)(!1),d=t(()=>{i(!0)},"startConfirm"),C=t(()=>{i(!1)},"cancelConfirm"),v=t(()=>{i(!1),p()},"acceptConfirm");return u?(0,n.jsxDEV)("span",{className:"inline-flex items-center gap-1","data-testid":`${o}-prompt`,role:"group",children:[(0,n.jsxDEV)(e,{"data-testid":`${o}-confirm`,disabled:r,onClick:v,size:"sm",type:"button",variant:"destructive",children:l??a("Confirm")},void 0,!1),(0,n.jsxDEV)(e,{"data-testid":`${o}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:a("Cancel")},void 0,!1)]},void 0,!0):(0,n.jsxDEV)(e,{"data-testid":o,disabled:r,onClick:d,size:"sm",type:"button",variant:"outline",children:f},void 0,!1)},"ConfirmButton");export{y as a};
@@ -0,0 +1 @@
1
+ import{a as w}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as C,b as $,c as A,d as v,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as S}from"./chunk-AQGOX5DK.js";import{a as T}from"./chunk-TAD43CG5.js";import{b as k}from"./chunk-DVKPRFIJ.js";import{a as N,e as R}from"./chunk-SEU5V7I6.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as p,e as x,g as O,h as B}from"./chunk-RRCPZMC2.js";var I=x(O(),1);var t=x(B(),1);var D=p((e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],"operationLabel"),E={delete:2,list:3,read:0,write:1},_=p(e=>[...e].toSorted((r,a)=>r.bucket.localeCompare(a.bucket)||E[r.on]-E[a.on]||(r.prefix??"").localeCompare(a.prefix??"")),"sortRules"),Q=p(()=>{let e=(0,I.c)(14),r=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:d,errorSource:i}=k(S.storageRules,a),h=l!==void 0,f;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==r){let g=_(Array.isArray(l?.rules)?l.rules:[]),m;e[7]!==d||e[8]!==i?(m=d!==null&&(0,t.jsxDEV)(w,{error:i,testId:"storage-rules-error"},void 0,!1),e[7]=d,e[8]=i,e[9]=m):m=e[9];let s;e[10]!==r?(s=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=s):s=e[11];let u;e[12]!==s?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s},void 0,!1),e[12]=s,e[13]=u):u=e[13],f=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[m,u,h&&g.length===0?(0,t.jsxDEV)(T,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")},void 0,!1):(0,t.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(R,{className:"px-0",children:(0,t.jsxDEV)(C,{"data-testid":"storage-rules-table",children:[(0,t.jsxDEV)($,{children:(0,t.jsxDEV)(v,{children:[(0,t.jsxDEV)(n,{children:r("Bucket")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Operation")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Key prefix")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(A,{children:g.map(o=>(0,t.jsxDEV)(v,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[(0,t.jsxDEV)(c,{className:"font-mono text-xs",children:o.bucket},void 0,!1),(0,t.jsxDEV)(c,{children:(0,t.jsxDEV)(y,{variant:"secondary",children:D(r,o.on)},void 0,!1)},void 0,!1),(0,t.jsxDEV)(c,{className:"font-mono text-xs",children:o.prefix??(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("(whole bucket)")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:o.procedure},void 0,!1)]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=r,e[6]=f}else f=e[6];return f},"StorageRulesPanel");export{Q as StorageRulesPanel};
@@ -0,0 +1 @@
1
+ import{a as H}from"./chunk-J6J54MBP.js";import{a as R,b as _,c as $,d as N,e as o,f as r}from"./chunk-GTM65MVX.js";import{c as S}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{a as w}from"./chunk-TAD43CG5.js";import{a as E}from"./chunk-DVKPRFIJ.js";import{a as C,e as k}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as A}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as g,k as I,n as B}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as m,e as T,g as j,h as z}from"./chunk-RRCPZMC2.js";var Q=T(j(),1);var t=T(z(),1);var L=200,K=m(()=>{let e=(0,Q.c)(21),d=A(),s=g(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",L],e[0]=u):u=e[0];let h;e[1]!==d?(h=m(()=>d.listAuthSessions({limit:L}),"t1"),e[1]=d,e[2]=h):h=e[2];let l=E(u,h),{error:v}=l,i=l.data?.rows??null,p;e[3]!==l?(p=m(()=>{l.refetch()},"t2"),e[3]=l,e[4]=p):p=e[4],H(p,!0);let x;e[5]!==d||e[6]!==l?(x=m(a=>{I((async()=>{await d.revokeAuthSession({sessionId:a}),l.refetch()})())},"t3"),e[5]=d,e[6]=l,e[7]=x):x=e[7];let y=x,n;e[8]!==v?(n=v!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:v},void 0,!1),e[8]=v,e[9]=n):n=e[9];let c;e[10]!==i||e[11]!==s?(c=i!==null&&i.length===0&&(0,t.jsxDEV)(w,{testId:"auth-sessions-empty",title:s("No active sessions.")},void 0,!1),e[10]=i,e[11]=s,e[12]=c):c=e[12];let f;e[13]!==y||e[14]!==i||e[15]!==s?(f=i!==null&&i.length>0&&(0,t.jsxDEV)(C,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(k,{className:"px-0",children:(0,t.jsxDEV)(R,{"data-testid":"auth-sessions-table",children:[(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(N,{children:[(0,t.jsxDEV)(o,{children:s("user")},void 0,!1),(0,t.jsxDEV)(o,{children:s("expires")},void 0,!1),(0,t.jsxDEV)(o,{children:s("ip")},void 0,!1),(0,t.jsxDEV)(o,{children:s("user agent")},void 0,!1),(0,t.jsxDEV)(o,{children:s("impersonated by")},void 0,!1),(0,t.jsxDEV)(o,{"aria-label":s("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($,{children:i.map(a=>(0,t.jsxDEV)(N,{"data-testid":`auth-session-${a.id}`,children:[(0,t.jsxDEV)(r,{className:"font-mono text-xs",children:a.userId},void 0,!1),(0,t.jsxDEV)(r,{className:"text-muted-foreground tabular-nums",children:B(a.expiresAt)},void 0,!1),(0,t.jsxDEV)(r,{children:a.ipAddress??""},void 0,!1),(0,t.jsxDEV)(r,{className:"max-w-40 truncate",children:a.userAgent??""},void 0,!1),(0,t.jsxDEV)(r,{className:"font-mono text-xs",children:a.impersonatedBy??""},void 0,!1),(0,t.jsxDEV)(r,{children:(0,t.jsxDEV)(S,{"data-testid":`auth-session-revoke-${a.id}`,onClick:m(()=>{y(a.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")},void 0,!1)},void 0,!1)]},a.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[13]=y,e[14]=i,e[15]=s,e[16]=f):f=e[16];let b;return e[17]!==n||e[18]!==c||e[19]!==f?(b=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[n,c,f]},void 0,!0),e[17]=n,e[18]=c,e[19]=f,e[20]=b):b=e[20],b},"AuthSessionsPanel");export{K as AuthSessionsPanel};
@@ -0,0 +1 @@
1
+ import{a as E}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as q,b as A,c as S,d as b,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as w}from"./chunk-AQGOX5DK.js";import{a as T}from"./chunk-TAD43CG5.js";import{b as C}from"./chunk-DVKPRFIJ.js";import{a as g,e as Q}from"./chunk-SEU5V7I6.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as y}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as p,e as N,f as I,g as D,h as k}from"./chunk-RRCPZMC2.js";var _=N(D(),1),M=N(I(),1);var t=N(k(),1);var U=p(()=>{let e=(0,_.c)(18),o=y(),m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];let{data:n,error:h,errorSource:x}=C(w.listQueues,m),v=n!==void 0,u;e[1]!==n?(u=Array.isArray(n?.queues)?[...n.queues].toSorted(B):[],e[1]=n,e[2]=u):u=e[2];let f=u,r;e[3]!==h||e[4]!==x?(r=h!==null&&(0,t.jsxDEV)(E,{error:x,testId:"queues-error"},void 0,!1),e[3]=h,e[4]=x,e[5]=r):r=e[5];let a;e[6]!==o?(a=o("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[6]=o,e[7]=a):a=e[7];let s;e[8]!==a?(s=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[8]=a,e[9]=s):s=e[9];let d;e[10]!==v||e[11]!==f||e[12]!==o?(d=v&&f.length===0?(0,t.jsxDEV)(T,{description:o("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:o("No queues defined")},void 0,!1):(0,t.jsxDEV)(g,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Q,{className:"px-0",children:(0,t.jsxDEV)(q,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(A,{children:(0,t.jsxDEV)(b,{children:[(0,t.jsxDEV)(l,{children:o("Export")},void 0,!1),(0,t.jsxDEV)(l,{children:o("Queue")},void 0,!1),(0,t.jsxDEV)(l,{children:o("Mode")},void 0,!1),(0,t.jsxDEV)(l,{children:o("Binding")},void 0,!1),(0,t.jsxDEV)(l,{children:o("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(S,{children:f.map(H)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[10]=v,e[11]=f,e[12]=o,e[13]=d):d=e[13];let c;return e[14]!==r||e[15]!==s||e[16]!==d?(c=(0,t.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[r,s,d]},void 0,!0),e[14]=r,e[15]=s,e[16]=d,e[17]=c):c=e[17],c},"QueuesPanel");function B(e,o){return e.exportName.localeCompare(o.exportName)}p(B,"_temp");function H(e){return(0,t.jsxDEV)(b,{"data-testid":`queues-row-${e.exportName}`,children:[(0,t.jsxDEV)(i,{className:"font-mono text-xs",children:e.exportName},void 0,!1),(0,t.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:e.name},void 0,!1),(0,t.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:e.mode},void 0,!1),(0,t.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:e.binding},void 0,!1),(0,t.jsxDEV)(i,{className:"font-mono text-xs text-muted-foreground",children:e.deadLetterQueue??"\u2014"},void 0,!1)]},e.exportName,!0)}p(H,"_temp2");export{U as default};
@@ -0,0 +1 @@
1
+ import{a as S,b as w,c as W,i as H,w as E}from"./chunk-O3NAGRTR.js";import{a as K,b as C,j as M}from"./chunk-CKSHCYGC.js";import{a as V}from"./chunk-ZHVTQ37P.js";import{a as s,e as g,f as v,h as ee,j as U}from"./chunk-RRCPZMC2.js";var q=g(v(),1);var m=g(v(),1);var h=g(v(),1);var $=h.createContext(void 0);$.displayName="CompositeRootContext";function A(n=!1){let t=h.useContext($);if(t===void 0&&!n)throw new Error("Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.");return t}s(A,"useCompositeRootContext");var F=g(v(),1);function L(n){let{focusableWhenDisabled:t,disabled:r,composite:d=!1,tabIndex:o=0,isNativeButton:i}=n,c=d&&t!==!1,b=d&&t===!1;return{props:F.useMemo(()=>{let a={onKeyDown(p){r&&t&&p.key!=="Tab"&&p.preventDefault()}};return d||(a.tabIndex=o,!i&&r&&(a.tabIndex=t?o:-1)),(i&&(t||c)||!i&&r)&&(a["aria-disabled"]=r),i&&(!t||b)&&(a.disabled=r),a},[d,r,t,c,b,i,o])}}s(L,"useFocusableWhenDisabled");function j(n={}){let{disabled:t=!1,focusableWhenDisabled:r,tabIndex:d=0,native:o=!0,composite:i}=n,c=m.useRef(null),b=A(!0),l=i??b!==void 0,{props:a}=L({focusableWhenDisabled:r,disabled:t,composite:l,tabIndex:d,isNativeButton:o});m.useEffect(()=>{if(!c.current)return;let u=k(c.current);if(o){if(!u){let f=w.captureOwnerStack?.()||"";E(`A component that acts as a button expected a native <button> because the \`nativeButton\` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the \`render\` prop, or set \`nativeButton\` to \`false\`.${f}`)}}else if(u){let f=w.captureOwnerStack?.()||"";E(`A component that acts as a button expected a non-<button> because the \`nativeButton\` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as \`role\` or \`aria-disabled\`). Use a non-<button> in the \`render\` prop, or set \`nativeButton\` to \`true\`.${f}`)}},[o]);let p=m.useCallback(()=>{let u=c.current;k(u)&&l&&t&&a.disabled===void 0&&u.disabled&&(u.disabled=!1)},[t,a.disabled,l]);S(p,[p]);let R=m.useCallback((u={})=>{let{onClick:f,onMouseDown:B,onKeyUp:J,onKeyDown:Q,onPointerDown:X,...Y}=u;return K({onClick(e){if(t){e.preventDefault();return}f?.(e)},onMouseDown(e){t||B?.(e)},onKeyDown(e){if(t||(C(e),Q?.(e),e.baseUIHandlerPrevented))return;let P=e.target===e.currentTarget,x=e.currentTarget,z=k(x),_=!o&&te(x),I=P&&(o?z:!_),T=e.key==="Enter",O=e.key===" ",D=x.getAttribute("role"),Z=D?.startsWith("menuitem")||D==="option"||D==="gridcell";if(P&&l&&O){if(e.defaultPrevented&&Z)return;e.preventDefault(),_||o&&z?(x.click(),e.preventBaseUIHandler()):I&&(f?.(e),e.preventBaseUIHandler());return}I&&(!o&&(O||T)&&e.preventDefault(),!o&&T&&f?.(e))},onKeyUp(e){if(!t){if(C(e),J?.(e),e.target===e.currentTarget&&o&&l&&k(e.currentTarget)&&e.key===" "){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!o&&!l&&e.key===" "&&f?.(e)}},onPointerDown(e){if(t){e.preventDefault();return}X?.(e)}},o?{type:"button"}:{role:"button"},a,Y)},[t,a,l,o]),N=W(u=>{c.current=u,p()});return{getButtonProps:R,buttonRef:N}}s(j,"useButton");function k(n){return H(n)&&n.tagName==="BUTTON"}s(k,"isButtonElement");function te(n){return!!(n?.tagName==="A"&&n?.href)}s(te,"isValidLinkElement");var y=q.forwardRef(s(function(t,r){let{render:d,className:o,disabled:i=!1,focusableWhenDisabled:c=!1,nativeButton:b=!0,style:l,...a}=t,{getButtonProps:p,buttonRef:R}=j({disabled:i,focusableWhenDisabled:c,native:b});return M("button",t,{state:{disabled:i},ref:[r,R],props:[a,p]})},"Button"));y.displayName="Button";var G=g(ee(),1);var oe=V("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",xs:"h-6 gap-1 rounded-md px-2 text-xs has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-md px-2.5 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2",icon:"size-8","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-md","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function we({className:n,variant:t="default",size:r="default",...d}){return(0,G.jsxDEV)(y,{"data-slot":"button",className:U(oe({variant:t,size:r,className:n})),...d},void 0,!1)}s(we,"Button");export{A as a,j as b,we as c};
@@ -0,0 +1,3 @@
1
+ import{a as J}from"./chunk-TDL7NEWA.js";import{a as P}from"./chunk-VLXV72QE.js";import{a as B}from"./chunk-K3GNLVYK.js";import{b as j}from"./chunk-TBMYIZIO.js";import"./chunk-3CJW6NWG.js";import{c as D}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as f}from"./chunk-AQGOX5DK.js";import{c as L}from"./chunk-DVKPRFIJ.js";import{a as v,e as y}from"./chunk-SEU5V7I6.js";import"./chunk-CKSHCYGC.js";import{f as _}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as E,e as S,f as w,g as b,k as I}from"./chunk-PVZI3CXP.js";import{b as N}from"./chunk-GMSGZDDH.js";import{a as o,e as R,f as K,h as U}from"./chunk-RRCPZMC2.js";var c=R(K(),1);var e=R(U(),1);var V=S(f.exportShard),X=S(f.importShard),z=o(m=>m.map(a=>JSON.stringify(a)).join(`
2
+ `),"toNdjson"),G=o(m=>{let a=[],x=m.split(`
3
+ `);for(let[r,n]of x.entries()){let h=n.trim();if(h==="")continue;let l=JSON.parse(h);if(typeof l!="object"||l===null)throw new N("INTERNAL",`line ${(r+1).toString()}: expected a { table, doc } object`);let s=l;if(typeof s.table!="string"||typeof s.doc!="object"||s.doc===null||Array.isArray(s.doc))throw new N("INTERNAL",`line ${(r+1).toString()}: expected a { table, doc } object`);a.push(s)}return a},"parseNdjson"),ie=o(({initialShardKey:m})=>{let a=_(),x=L(),r=E(),[n,h]=(0,c.useState)(m??""),[l,s]=(0,c.useState)(""),[C,p]=(0,c.useState)(!1),[T,u]=(0,c.useState)(null),[i,g]=(0,c.useState)(null),[A,O]=(0,c.useState)(null),$=o(async()=>{p(!0),u(null),g(null);try{let t=await a.query(V,{},w(n));j(n),s(z(t.rows)),O(t.rows.length)}catch(t){u(b(t))}finally{p(!1)}},"exportShard"),k=o(async()=>{p(!0),u(null),g(null),O(null);let t;try{t=G(l)}catch(d){u(r("Invalid NDJSON: {message}",{message:b(d)})),p(!1);return}try{let d=await a.query(X,{rows:t},w(n));j(n),g(d),x(f.readTablePage),x(f.listTables)}catch(d){u(b(d))}finally{p(!1)}},"importShard"),M=i===null?0:Object.values(i.inserted).reduce((t,d)=>t+d,0),q=o(()=>{I($())},"runExport"),F=o(()=>{I(k())},"runImport"),H=o(t=>{s(t.target.value)},"onNdjsonChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-export-import",children:[(0,e.jsxDEV)(v,{className:"rounded-xl border border-border bg-card shadow-xs",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Export")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(y,{className:"flex flex-col gap-3 p-4",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(B,{onChange:h,testId:"ei-shard-input",value:n},void 0,!1),(0,e.jsxDEV)(D,{"data-testid":"ei-export",disabled:C,onClick:q,type:"button",children:r("Export")},void 0,!1)]},void 0,!0),A!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:r("Exported {count} rows.",{count:A})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)(v,{className:"rounded-xl border border-border bg-card shadow-xs",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Import")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(y,{className:"flex flex-col gap-3 p-4",children:[(0,e.jsxDEV)(P,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:H,placeholder:'{"table":"messages","doc":{\u2026}}',value:l},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:(0,e.jsxDEV)(J,{confirmLabel:r("Import (writes rows)?"),disabled:C||l.trim()==="",onConfirm:F,testId:"ei-import",children:r("Import")},void 0,!1)},void 0,!1),i!==null&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:r("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:i.conflicts,errors:i.errors.length,inserted:M})},void 0,!1),i.errors.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:i.errors.map(t=>(0,e.jsxDEV)("li",{className:"text-xs text-destructive",children:r("line {line} ({table}): {message}",{line:t.line,message:t.message,table:t.table})},`${t.table}-${t.line.toString()}`,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),T!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:T},void 0,!1)]},void 0,!0)},"ExportImportPanel");export{ie as ExportImportPanel};
@@ -0,0 +1 @@
1
+ import{a as d,b as u}from"./chunk-55YA7ZZI.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import"./chunk-KEGAWN6Y.js";import"./chunk-HV7G6DFP.js";import"./chunk-3OA7PECS.js";import"./chunk-GMSGZDDH.js";import{a as c,e as m,g as p,h as v}from"./chunk-RRCPZMC2.js";var h=m(p(),1);var o=m(v(),1);var y={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},g=c(n=>{let e=(0,h.c)(6),{data:i}=n,a,r;if(e[0]!==i){r=Symbol.for("react.early_return_sentinel");e:{let f=i.slice(-16);if(f.length<3){r=null;break e}a=f.map(_)}e[0]=i,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;let s=a,t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=(0,o.jsxDEV)(u,{dataKey:"value"},void 0,!1),e[3]=t):t=e[3];let l;return e[4]!==s?(l=(0,o.jsxDEV)("div",{"aria-hidden":"true",className:"h-8 w-28",children:(0,o.jsxDEV)(d,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:y,data:s,children:t},void 0,!1)},void 0,!1),e[4]=s,e[5]=l):l=e[5],l},"Sparkline");function _(n,e){return{index:e,value:n}}c(_,"_temp");export{g as Sparkline};
@@ -0,0 +1 @@
1
+ import{a as le}from"./chunk-O77VNUFD.js";import{b as ae}from"./chunk-FKO3HO6I.js";import{a as ne}from"./chunk-TQ36RWOP.js";import{a as oe}from"./chunk-WXPWVBIY.js";import{a as re}from"./chunk-2K47A3P6.js";import{a as se}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as te}from"./chunk-K3GNLVYK.js";import{b as ee}from"./chunk-TBMYIZIO.js";import{R as E}from"./chunk-3CJW6NWG.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as U}from"./chunk-AQGOX5DK.js";import{a as Z}from"./chunk-TAD43CG5.js";import{b as K}from"./chunk-DVKPRFIJ.js";import{b as D}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as X}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as i,e as z,f as Te,g as qe,h as Pe,j as R}from"./chunk-RRCPZMC2.js";var T=z(qe(),1);var m=z(Te(),1);var r=z(Pe(),1);var Y=400,Me=36,Oe={height:Y,overflow:"auto"},ue={left:0,position:"absolute",top:0,width:"100%"},Ae={debug:"secondary",error:"destructive",info:"outline",warn:"secondary"},Fe={error:"destructive",ok:"secondary"},_e=i(a=>{let e=(0,T.c)(21),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.timestamp?(u=new Date(t.timestamp).toLocaleString(),e[2]=t.timestamp,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Ae[t.level],g;e[6]!==t.level||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-20 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.level},void 0,!1)},void 0,!1),e[6]=t.level,e[7]=y,e[8]=g):g=e[8];let b=t.functionPath??"\u2014",p;e[9]!==b?(p=(0,r.jsxDEV)("span",{className:"w-48 shrink-0 truncate text-muted-foreground",role:"gridcell",children:b},void 0,!1),e[9]=b,e[10]=p):p=e[10];let h;e[11]!==t.message?(h=(0,r.jsxDEV)("span",{className:"flex-1 truncate",role:"gridcell",children:t.message},void 0,!1),e[11]=t.message,e[12]=h):h=e[12];let x;return e[13]!==l||e[14]!==n||e[15]!==f||e[16]!==c||e[17]!==g||e[18]!==p||e[19]!==h?(x=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-row",ref:n,role:"row",style:f,children:[c,g,p,h]},void 0,!0),e[13]=l,e[14]=n,e[15]=f,e[16]=c,e[17]=g,e[18]=p,e[19]=h,e[20]=x):x=e[20],x},"LogRow"),ie=i(a=>a.length===0?"\u2014":a.join(", "),"tablesLabel"),Ve=i(a=>{let e=(0,T.c)(37),{entry:t,index:l,measureRef:n,start:o}=a,d=`translateY(${String(o)}px)`,v;e[0]!==d?(v={...ue,transform:d},e[0]=d,e[1]=v):v=e[1];let f=v,u;e[2]!==t.ts?(u=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=u):u=e[3];let c;e[4]!==u?(c=(0,r.jsxDEV)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:u},void 0,!1),e[4]=u,e[5]=c):c=e[5];let y=Fe[t.outcome],g;e[6]!==t.outcome||e[7]!==y?(g=(0,r.jsxDEV)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsxDEV)(D,{variant:y,children:t.outcome},void 0,!1)},void 0,!1),e[6]=t.outcome,e[7]=y,e[8]=g):g=e[8];let b;e[9]!==t.functionPath?(b=(0,r.jsxDEV)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath},void 0,!1),e[9]=t.functionPath,e[10]=b):b=e[10];let p=t.shardKey??"\u2014",h;e[11]!==p?(h=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:p},void 0,!1),e[11]=p,e[12]=h):h=e[12];let x=t.userId??"\u2014",L;e[13]!==x?(L=(0,r.jsxDEV)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x},void 0,!1),e[13]=x,e[14]=L):L=e[14];let k;e[15]!==t.durationMs?(k=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=k):k=e[16];let I=`${String(k)}ms`,w;e[17]!==I?(w=(0,r.jsxDEV)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:I},void 0,!1),e[17]=I,e[18]=w):w=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${ie(t.tablesRead)} \xB7 w:${ie(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let N;e[24]!==S?(N=(0,r.jsxDEV)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S},void 0,!1),e[24]=S,e[25]=N):N=e[25];let C;return e[26]!==l||e[27]!==n||e[28]!==f||e[29]!==L||e[30]!==w||e[31]!==N||e[32]!==c||e[33]!==g||e[34]!==b||e[35]!==h?(C=(0,r.jsxDEV)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":l,"data-testid":"lg-req-row",ref:n,role:"row",style:f,children:[c,g,b,h,L,w,N]},void 0,!0),e[26]=l,e[27]=n,e[28]=f,e[29]=L,e[30]=w,e[31]=N,e[32]=c,e[33]=g,e[34]=b,e[35]=h,e[36]=C):C=e[36],C},"RequestRow"),de=i(a=>{let{entries:e}=a??{};return Array.isArray(e)?e:[]},"entriesOf"),$e=i(a=>{let e={};return a.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=a.functionPathPrefix.trim()),a.userId.trim()!==""&&(e.userId=a.userId.trim()),a.tableTouched.trim()!==""&&(e.tableTouched=a.tableTouched.trim()),(a.outcome==="ok"||a.outcome==="error")&&(e.outcome=a.outcome),e},"buildRequestQuery"),me=["debug","info","warn","error"],Be={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},ze=i((a,e)=>{let t=e.search.trim().toLowerCase(),l=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-Be[e.range];return a.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||l!==""&&!(o.functionPath??"").toLowerCase().includes(l)?!1:t===""||o.message.toLowerCase().includes(t))},"filterLogs"),De="\u2014",Ke=i(a=>{let e=new Map,t=new Map;for(let o of a){e.set(o.level,(e.get(o.level)??0)+1);let d=o.functionPath??De;t.set(d,(t.get(d)??0)+1)}let l=me.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,d])=>({count:d,key:o})).toSorted((o,d)=>d.count===o.count?o.key.localeCompare(d.key):d.count-o.count);return{byLevel:l,byPath:n,total:a.length}},"summarizeLogs"),Ue=i(a=>{let e=(0,T.c)(11),{level:t,onToggle:l,selected:n}=a,o;e[0]!==t||e[1]!==l?(o=i(()=>{l(t)},"t1"),e[0]=t,e[1]=l,e[2]=o):o=e[2];let d=o,v=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",f;e[3]!==v?(f=R("rounded-md border px-2 py-1 text-xs",v),e[3]=v,e[4]=f):f=e[4];let u=`logs-level-${t}`,c;return e[5]!==t||e[6]!==d||e[7]!==n||e[8]!==f||e[9]!==u?(c=(0,r.jsxDEV)("button",{"aria-pressed":n,className:f,"data-testid":u,onClick:d,type:"button",children:t},void 0,!1),e[5]=t,e[6]=d,e[7]=n,e[8]=f,e[9]=u,e[10]=c):c=e[10],c},"LevelToggle"),ce=i(a=>{let e=(0,T.c)(7),{bucket:t}=a,l;e[0]!==t.key?(l=(0,r.jsxDEV)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key},void 0,!1),e[0]=t.key,e[1]=l):l=e[1];let n;e[2]!==t.count?(n=(0,r.jsxDEV)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count},void 0,!1),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==l||e[5]!==n?(o=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[l,n]},void 0,!0),e[4]=l,e[5]=n,e[6]=o):o=e[6],o},"SummaryBucketRow"),nt=i(({initialShardKey:a})=>{let e=X(),[t,l]=(0,m.useState)("requests"),[n,o]=(0,m.useState)(a??""),[d,v]=(0,m.useState)(""),[f,u]=(0,m.useState)(()=>new Set),[c,y]=(0,m.useState)(""),[g,b]=(0,m.useState)("all"),[p,h]=(0,m.useState)(!1),[x,L]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[w,S]=(0,m.useState)(""),[N,C]=(0,m.useState)("all"),q=re(n.trim(),400),fe=$e({functionPathPrefix:x,outcome:N,tableTouched:w,userId:k}),Q=K(U.getRequestLog,fe,{enabled:t==="requests",live:!0,shardKey:q}),W=K(U.getLogs,{},{enabled:t==="errors",live:!0,shardKey:q}),A=t==="requests"?Q:W,{error:G,errorSource:he,isLoading:H,liveError:ge}=A,ve=de(W.data),j=de(Q.data);(0,m.useEffect)(()=>{A.data!==void 0&&ee(q)},[A.data,q]);let F=ze(ve,{levels:f,now:Date.now(),path:c,range:g,search:d}),_=Ke(F),V=t==="requests"?j.length:F.length,$=t==="errors"&&p,P=(0,m.useMemo)(()=>G!==null?"error":V===0?H?$?"summary":"list":"empty":$?"summary":"list",[V,H,G,$]),J=(0,m.useRef)(null),M=ae({count:V,estimateSize:i(()=>Me,"estimateSize"),getScrollElement:i(()=>J.current,"getScrollElement"),initialRect:{height:Y,width:800},observeElementRect:i((s,B)=>le(s,B,Y),"observeElementRect"),overscan:8}),pe=M.getVirtualItems(),be={height:M.getTotalSize(),position:"relative",width:"100%"},xe=i(s=>{v(s.target.value)},"onSearchChange"),ye=i(s=>{u(B=>{let O=new Set(B);return O.has(s)?O.delete(s):O.add(s),O})},"toggleLevel"),we=i(s=>{y(s.target.value)},"onLogPathChange"),Ne=i(s=>{b(s.target.value)},"onTimeRangeChange"),Le=i(()=>{h(s=>!s)},"toggleSummary"),Se=i(s=>{L(s.target.value)},"onPathChange"),ke=i(s=>{I(s.target.value)},"onUserChange"),Ce=i(s=>{S(s.target.value)},"onTableChange"),Ee=i(s=>{C(s.target.value)},"onOutcomeChange"),Ie=i(()=>{l("requests"),h(!1)},"showRequests"),Re=i(()=>{l("errors"),h(!1)},"showErrors");return(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[(0,r.jsxDEV)("button",{"aria-selected":t==="requests",className:R("px-3 py-1 text-sm",t==="requests"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-requests",onClick:Ie,role:"tab",type:"button",children:e("Requests")},void 0,!1),(0,r.jsxDEV)("button",{"aria-selected":t==="errors",className:R("px-3 py-1 text-sm",t==="errors"?"bg-muted font-medium":"text-muted-foreground"),"data-testid":"lg-view-errors",onClick:Re,role:"tab",type:"button",children:e("Errors")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(te,{onChange:o,testId:"lg-shard-input",value:n},void 0,!1),(0,r.jsxDEV)(oe,{message:ge,prefix:"lg"},void 0,!1),(0,r.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:e("Open in Cloudflare")},void 0,!1)]},void 0,!0),t==="errors"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Search messages"),className:"h-8 w-48","data-testid":"lg-search",onChange:xe,placeholder:e("search message"),value:d},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-40","data-testid":"logs-path-filter",onChange:we,placeholder:e("filter path"),value:c},void 0,!1),(0,r.jsxDEV)("div",{"aria-label":e("Level filter"),className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:me.map(s=>(0,r.jsxDEV)(Ue,{level:s,onToggle:ye,selected:f.has(s)},s,!1))},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Time range"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:Ne,value:g,children:[(0,r.jsxDEV)("option",{value:"all",children:e("All time")},void 0,!1),(0,r.jsxDEV)("option",{value:"5m",children:e("Last 5m")},void 0,!1),(0,r.jsxDEV)("option",{value:"15m",children:e("Last 15m")},void 0,!1),(0,r.jsxDEV)("option",{value:"1h",children:e("Last hour")},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("button",{"aria-pressed":p,className:R("h-8 rounded-md border px-3 text-sm",p?"border-border bg-muted font-medium":"border-input text-muted-foreground"),"data-testid":"logs-summary-toggle",onClick:Le,type:"button",children:e(p?"List":"Summary")},void 0,!1)]},void 0,!0),t==="requests"&&(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxDEV)(E,{"aria-label":e("Function path"),className:"h-8 w-44","data-testid":"lg-req-path",onChange:Se,placeholder:e("file:function"),value:x},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("User id"),className:"h-8 w-32","data-testid":"lg-req-user",onChange:ke,placeholder:e("userId"),value:k},void 0,!1),(0,r.jsxDEV)(E,{"aria-label":e("Table touched"),className:"h-8 w-32","data-testid":"lg-req-table",onChange:Ce,placeholder:e("table"),value:w},void 0,!1),(0,r.jsxDEV)("select",{"aria-label":e("Outcome filter"),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:Ee,value:N,children:[(0,r.jsxDEV)("option",{value:"all",children:e("all")},void 0,!1),(0,r.jsxDEV)("option",{value:"ok",children:e("ok")},void 0,!1),(0,r.jsxDEV)("option",{value:"error",children:e("error")},void 0,!1)]},void 0,!0)]},void 0,!0),P==="error"&&(0,r.jsxDEV)(se,{error:he,testId:"lg-error"},void 0,!1),P==="empty"&&(0,r.jsxDEV)(Z,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M4 5h16M4 12h16M4 19h10"},void 0,!1)},void 0,!1),testId:"lg-empty",title:e("No logs.")},void 0,!1),P==="summary"&&(0,r.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[(0,r.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:e("{count} entries",{count:_.total})},void 0,!1),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By level")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:_.byLevel.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{children:[(0,r.jsxDEV)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:e("By function")},void 0,!1),(0,r.jsxDEV)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:_.byPath.map(s=>(0,r.jsxDEV)(ce,{bucket:s},s.key,!1))},void 0,!1)]},void 0,!0)]},void 0,!0),P==="list"&&(0,r.jsxDEV)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:J,style:Oe,children:(0,r.jsxDEV)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:be,children:pe.map(s=>t==="requests"?(0,r.jsxDEV)(Ve,{entry:j[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1):(0,r.jsxDEV)(_e,{entry:F[s.index],index:s.index,measureRef:M.measureElement,start:s.start},s.key,!1))},void 0,!1)},void 0,!1)]},void 0,!0)},"LogsPanel");export{nt as LogsPanel,ze as filterLogs,Ke as summarizeLogs};
@@ -1 +1 @@
1
- import{d as n}from"./chunk-YJGANMU7.js";import{a as l,e as a,g as u,h as d}from"./chunk-RRCPZMC2.js";var c=a(u(),1);var v=a(d(),1);var x=l(f=>{let e=(0,c.c)(6),{message:r,prefix:m}=f,o=n();if(r===void 0)return null;let i=`${m}-live-error`,t;e[0]!==r||e[1]!==o?(t=o("Live unavailable: {liveError}",{liveError:r}),e[0]=r,e[1]=o,e[2]=t):t=e[2];let s;return e[3]!==i||e[4]!==t?(s=(0,v.jsxDEV)("span",{className:"text-xs text-destructive","data-testid":i,role:"status",children:t},void 0,!1),e[3]=i,e[4]=t,e[5]=s):s=e[5],s},"LiveError");export{x as a};
1
+ import{d as n}from"./chunk-PVZI3CXP.js";import{a as l,e as a,g as u,h as d}from"./chunk-RRCPZMC2.js";var c=a(u(),1);var v=a(d(),1);var x=l(f=>{let e=(0,c.c)(6),{message:r,prefix:m}=f,o=n();if(r===void 0)return null;let i=`${m}-live-error`,t;e[0]!==r||e[1]!==o?(t=o("Live unavailable: {liveError}",{liveError:r}),e[0]=r,e[1]=o,e[2]=t):t=e[2];let s;return e[3]!==i||e[4]!==t?(s=(0,v.jsxDEV)("span",{className:"text-xs text-destructive","data-testid":i,role:"status",children:t},void 0,!1),e[3]=i,e[4]=t,e[5]=s):s=e[5],s},"LiveError");export{x as a};
@@ -0,0 +1 @@
1
+ import{a as R}from"./chunk-WXPWVBIY.js";import{a as w,b as O,c as D,d as C,e as v,f as h}from"./chunk-GTM65MVX.js";import{a as L}from"./chunk-AQGOX5DK.js";import{a as S}from"./chunk-TAD43CG5.js";import{b as _}from"./chunk-DVKPRFIJ.js";import{a as A,e as I}from"./chunk-SEU5V7I6.js";import{b as E}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as b}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as u,e as T,f as M,g as P,h as V}from"./chunk-RRCPZMC2.js";var B=T(P(),1),K=T(M(),1);var t=T(V(),1);var k="container:",F={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},H=u(e=>{let r=e.indexOf(":");if(r===-1)return{event:e.trim()};let a=e.slice(r+1).trim(),s=e.slice(0,r).trim();return a===""?{event:s}:{detail:a,event:s}},"parseContainerMessage"),W=u(e=>{let r=new Map;for(let a of e){let s=a.functionPath??"";if(!s.startsWith(k))continue;let n=s.slice(k.length);if(n==="")continue;let i=r.get(n);if(i!==void 0&&i.timestamp>=a.timestamp)continue;let{detail:x,event:o}=H(a.message);r.set(n,{detail:x,event:o,level:a.level,name:n,state:F[o]??"unknown",timestamp:a.timestamp})}return[...r.values()].toSorted((a,s)=>a.name.localeCompare(s.name))},"foldContainerInstances"),$={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},j=u(e=>{let{entries:r}=e??{};return Array.isArray(r)?r:[]},"entriesOf"),ee=u(()=>{let e=(0,B.c)(23),r=b(),a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);let{data:n,error:i,liveError:x}=_(L.getLogs,a,s),o=n!==void 0,N;e[2]!==n?(N=W(j(n)),e[2]=n,e[3]=N):N=e[3];let g=N,l;e[4]!==i?(l=i!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:i},void 0,!1),e[4]=i,e[5]=l):l=e[5];let c;e[6]!==r?(c=r("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per container \u2014 ports and health checks aren't carried in that stream."),e[6]=r,e[7]=c):c=e[7];let d;e[8]!==c?(d=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:c},void 0,!1),e[8]=c,e[9]=d):d=e[9];let m;e[10]!==x?(m=(0,t.jsxDEV)(R,{message:x,prefix:"containers"},void 0,!1),e[10]=x,e[11]=m):m=e[11];let f;e[12]!==d||e[13]!==m?(f=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[d,m]},void 0,!0),e[12]=d,e[13]=m,e[14]=f):f=e[14];let p;e[15]!==o||e[16]!==g||e[17]!==r?(p=o&&g.length===0?(0,t.jsxDEV)(S,{description:r("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:r("No container activity")},void 0,!1):(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(I,{className:"px-0",children:(0,t.jsxDEV)(w,{"data-testid":"containers-table",children:[(0,t.jsxDEV)(O,{children:(0,t.jsxDEV)(C,{children:[(0,t.jsxDEV)(v,{children:r("Container")},void 0,!1),(0,t.jsxDEV)(v,{children:r("State")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Last event")},void 0,!1),(0,t.jsxDEV)(v,{children:r("Detail")},void 0,!1),(0,t.jsxDEV)(v,{children:r("When")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(D,{children:g.map(G)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[15]=o,e[16]=g,e[17]=r,e[18]=p):p=e[18];let y;return e[19]!==l||e[20]!==f||e[21]!==p?(y=(0,t.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[l,f,p]},void 0,!0),e[19]=l,e[20]=f,e[21]=p,e[22]=y):y=e[22],y},"ContainersPanel");function G(e){return(0,t.jsxDEV)(C,{"data-testid":`containers-row-${e.name}`,children:[(0,t.jsxDEV)(h,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,t.jsxDEV)(h,{children:(0,t.jsxDEV)(E,{variant:$[e.state],children:e.state},void 0,!1)},void 0,!1),(0,t.jsxDEV)(h,{className:"font-mono text-xs text-muted-foreground",children:e.event},void 0,!1),(0,t.jsxDEV)(h,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"},void 0,!1),(0,t.jsxDEV)(h,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()},void 0,!1)]},e.name,!0)}u(G,"_temp");export{ee as ContainersPanel};