@lunora/studio 1.0.0-alpha.330 → 1.0.0-alpha.332

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 (191) hide show
  1. package/dist/index.d.mts +26 -12
  2. package/dist/index.d.ts +26 -12
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  9. package/dist/packem_chunks/ExportImportPanel.mjs +6 -3
  10. package/dist/packem_chunks/FileBrowser.mjs +4 -4
  11. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  12. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  13. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  14. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  15. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  16. package/dist/packem_chunks/MailPanel.mjs +1 -1
  17. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  18. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  19. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  20. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  21. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  22. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  23. package/dist/packem_chunks/SqlEditorPanel.mjs +2 -2
  24. package/dist/packem_chunks/TableEditor.mjs +1 -1
  25. package/dist/packem_chunks/agents-panel.mjs +1 -1
  26. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  27. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  28. package/dist/packem_chunks/architecture-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  30. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  31. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  32. package/dist/packem_chunks/containers-panel.mjs +1 -1
  33. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  34. package/dist/packem_chunks/evals-panel.mjs +1 -1
  35. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  36. package/dist/packem_chunks/flags-panel.mjs +1 -1
  37. package/dist/packem_chunks/issues-panel.mjs +1 -1
  38. package/dist/packem_chunks/kv-browser.mjs +1 -1
  39. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  40. package/dist/packem_chunks/migrations-route.mjs +1 -1
  41. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  42. package/dist/packem_chunks/payments-panel.mjs +1 -1
  43. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  44. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  45. package/dist/packem_chunks/queues-panel.mjs +1 -1
  46. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  47. package/dist/packem_chunks/rls-panel.mjs +1 -1
  48. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  49. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  50. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  51. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  52. package/dist/packem_chunks/traces-panel.mjs +1 -1
  53. package/dist/packem_chunks/users-panel.mjs +1 -1
  54. package/dist/packem_chunks/vector-browser.mjs +1 -1
  55. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  56. package/dist/packem_shared/{ApiDocsPanel-6yZaaxch.mjs → ApiDocsPanel-Py7C4ibM.mjs} +1 -1
  57. package/dist/packem_shared/{ApiReferencePanel-mwEK_vL7.mjs → ApiReferencePanel-DlYVADAy.mjs} +1 -1
  58. package/dist/packem_shared/{CommandPalette-CcTVGQvw.mjs → CommandPalette-CM1hqAOD.mjs} +1 -1
  59. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs +1 -0
  60. package/dist/packem_shared/{DataBrowser-B6xr6S3s.mjs → DataBrowser-DxlLv5x1.mjs} +2 -2
  61. package/dist/packem_shared/GlobalDataBrowser-TFTQpSVj.mjs +1 -0
  62. package/dist/packem_shared/{HomePanel-DBUgY2yE.mjs → HomePanel-BVz2sDQ4.mjs} +1 -1
  63. package/dist/packem_shared/{MigrationsPanel-_H327LDl.mjs → MigrationsPanel-fUyhbt0w.mjs} +1 -1
  64. package/dist/packem_shared/{OpenRpcReferencePanel-DJg4AbuZ.mjs → OpenRpcReferencePanel-CPIr-u-J.mjs} +1 -1
  65. package/dist/packem_shared/ScheduledJobs-zSeU_6cN.mjs +1 -0
  66. package/dist/packem_shared/{Studio-s4EbmwaL.mjs → Studio-CNqMkRmB.mjs} +1 -1
  67. package/dist/packem_shared/{StudioApp-D1e2uc7_.mjs → StudioApp-BG3kyQ-I.mjs} +1 -1
  68. package/dist/packem_shared/{advisor-view-kg9uZT7H.mjs → advisor-view-CXiPdw4B.mjs} +1 -1
  69. package/dist/packem_shared/{data-grid-XIuWrWDy.mjs → data-grid-BHTuvSI7.mjs} +1 -1
  70. package/dist/packem_shared/{diagram-export-panel-DrYRni_b.mjs → diagram-export-panel-BMLzao0Y.mjs} +1 -1
  71. package/dist/packem_shared/{error-alert-Dr4RMEID.mjs → error-alert-D-ftqyo-.mjs} +1 -1
  72. package/dist/packem_shared/{grid-features-6mTvrzgT.mjs → grid-features-CIdZ8Dqo.mjs} +2 -2
  73. package/dist/packem_shared/{home-panel-CKbpgpz9.mjs → home-panel-CF-MfsnH.mjs} +1 -1
  74. package/dist/packem_shared/internal-BXEjuLPN.mjs +2 -0
  75. package/dist/packem_shared/{log-line-DP0b3YT5.mjs → log-line-BWDt_F56.mjs} +1 -1
  76. package/dist/packem_shared/{recording-client-BbX9ql7w.mjs → recording-client-CFBkH4uZ.mjs} +1 -1
  77. package/dist/packem_shared/{reference-view-DNdYDPow.mjs → reference-view-BrsL8UGn.mjs} +3 -3
  78. package/dist/packem_shared/{schema-diagram-DKBYRWsL.mjs → schema-diagram-LRfchcoA.mjs} +1 -1
  79. package/dist/packem_shared/{sql-result-table-B7g48CHO.mjs → sql-result-table-COsfUSGc.mjs} +1 -1
  80. package/dist/packem_shared/{studio-BTM7dITm.mjs → studio-BcHsk7mT.mjs} +1 -1
  81. package/dist/packem_shared/table-list-sidebar-DwqtHSHU.mjs +1 -0
  82. package/dist/packem_shared/{use-admin-query-B2jU5P5u.mjs → use-admin-query-I1uILsUP.mjs} +1 -1
  83. package/dist/packem_shared/{use-admin-spec-CISwmdXM.mjs → use-admin-spec-BdNLZbTO.mjs} +1 -1
  84. package/dist/packem_shared/{use-async-submit-CgvRHgaD.mjs → use-async-submit-2eBBD0-m.mjs} +1 -1
  85. package/dist/packem_shared/{use-auth-config-B9w5-1-p.mjs → use-auth-config-DQ8tNyBh.mjs} +1 -1
  86. package/dist/packem_shared/{use-open-trace-CUyoDXjN.mjs → use-open-trace-B_0LbTD7.mjs} +1 -1
  87. package/dist/packem_shared/{use-sql-assistant-CK6G1ycr.mjs → use-sql-assistant-DetnUyFf.mjs} +1 -1
  88. package/dist/standalone/chunk-22MSJQDH.js +1 -0
  89. package/dist/standalone/chunk-2GYGUDJS.js +2 -0
  90. package/dist/standalone/chunk-34HRTSIP.js +1 -0
  91. package/dist/standalone/{chunk-A4R7GZQS.js → chunk-3O4QTTSY.js} +3 -3
  92. package/dist/standalone/{chunk-X472RKFD.js → chunk-4CGBMYO3.js} +3 -3
  93. package/dist/standalone/chunk-4DPZVEBK.js +1 -0
  94. package/dist/standalone/{chunk-NA7GP6EE.js → chunk-4NSXTCPY.js} +1 -1
  95. package/dist/standalone/{chunk-PLVFYL6L.js → chunk-4ZPDCXIA.js} +1 -1
  96. package/dist/standalone/chunk-5QXC7TAH.js +1 -0
  97. package/dist/standalone/{chunk-C5KBRXQG.js → chunk-5XSZGYSM.js} +1 -1
  98. package/dist/standalone/{chunk-3RSD3XAG.js → chunk-5ZCMUHYK.js} +1 -1
  99. package/dist/standalone/chunk-6UKEJNM5.js +1 -0
  100. package/dist/standalone/{chunk-5OMZCVRF.js → chunk-74IYYDDI.js} +9 -9
  101. package/dist/standalone/{chunk-D6ZXOSCM.js → chunk-7FTJLXZH.js} +1 -1
  102. package/dist/standalone/{chunk-2EYOYWS2.js → chunk-7Q256NLI.js} +1 -1
  103. package/dist/standalone/{chunk-DQSV2OFA.js → chunk-AH56E26M.js} +1 -1
  104. package/dist/standalone/{chunk-BPBEVNUM.js → chunk-B3SX5SBI.js} +2 -2
  105. package/dist/standalone/{chunk-D3HPOVEQ.js → chunk-B475OGG2.js} +1 -1
  106. package/dist/standalone/{chunk-QBTZMN5E.js → chunk-BDAZK3QX.js} +1 -1
  107. package/dist/standalone/{chunk-KRVD6WPH.js → chunk-BOGUQHYU.js} +1 -1
  108. package/dist/standalone/{chunk-DS2DTZFS.js → chunk-CHF23IX6.js} +3 -3
  109. package/dist/standalone/{chunk-OU56VN3R.js → chunk-CLXX5RVY.js} +1 -1
  110. package/dist/standalone/{chunk-G3NIGELJ.js → chunk-E75V5AEB.js} +1 -1
  111. package/dist/standalone/{chunk-2PNG3QHQ.js → chunk-EFXC3EHZ.js} +1 -1
  112. package/dist/standalone/{chunk-S63L3TCR.js → chunk-ENRGUWYC.js} +1 -1
  113. package/dist/standalone/{chunk-D746I7ZX.js → chunk-EWMBX5N2.js} +1 -1
  114. package/dist/standalone/{chunk-ULW7I6FO.js → chunk-F4HMMGVL.js} +1 -1
  115. package/dist/standalone/{chunk-V3RAWH63.js → chunk-FZJY5QLO.js} +1 -1
  116. package/dist/standalone/{chunk-K7OJ77CA.js → chunk-G3ZNPPY3.js} +1 -1
  117. package/dist/standalone/{chunk-X2YHVCMH.js → chunk-GUDC24NJ.js} +1 -1
  118. package/dist/standalone/{chunk-FCVKROK5.js → chunk-HIJGQX6F.js} +1 -1
  119. package/dist/standalone/chunk-HQPW3EZF.js +6 -0
  120. package/dist/standalone/chunk-HXO6YGKL.js +1 -0
  121. package/dist/standalone/{chunk-AQFI2GWT.js → chunk-IKT6EYHN.js} +1 -1
  122. package/dist/standalone/{chunk-MRFJSQBZ.js → chunk-IVZT3XO6.js} +1 -1
  123. package/dist/standalone/chunk-J2OLAMJR.js +1 -0
  124. package/dist/standalone/{chunk-I5RZUA4J.js → chunk-J4BVPEXN.js} +1 -1
  125. package/dist/standalone/{chunk-ZBRLJQ46.js → chunk-JKOBTLQU.js} +2 -2
  126. package/dist/standalone/{chunk-CVPVFONU.js → chunk-JYPEPARL.js} +1 -1
  127. package/dist/standalone/{chunk-ZQ4C2DMJ.js → chunk-K2EHRNYW.js} +1 -1
  128. package/dist/standalone/{chunk-SZIEPXZM.js → chunk-K3ST3XOT.js} +1 -1
  129. package/dist/standalone/{chunk-PDF22AMX.js → chunk-K73JDHTM.js} +1 -1
  130. package/dist/standalone/{chunk-P6UD4I65.js → chunk-KDF7XOVW.js} +1 -1
  131. package/dist/standalone/{chunk-CYWRJGWD.js → chunk-LVCMJJQO.js} +1 -1
  132. package/dist/standalone/{chunk-I23ULEUU.js → chunk-LXCVA5SP.js} +1 -1
  133. package/dist/standalone/{chunk-WMPXMPVF.js → chunk-M45NNDDU.js} +1 -1
  134. package/dist/standalone/{chunk-HYKN42SO.js → chunk-MC44447W.js} +1 -1
  135. package/dist/standalone/{chunk-DXYCOA4Y.js → chunk-NBYAGXMZ.js} +1 -1
  136. package/dist/standalone/{chunk-WS7WNXF3.js → chunk-NRAAYZ4C.js} +3 -3
  137. package/dist/standalone/{chunk-TM5C7YPO.js → chunk-NSNRU3CH.js} +1 -1
  138. package/dist/standalone/{chunk-VASJTDMU.js → chunk-PSMQQV6S.js} +1 -1
  139. package/dist/standalone/chunk-QMECH2OK.js +1 -0
  140. package/dist/standalone/{chunk-PH4VNMUO.js → chunk-QMENQICE.js} +1 -1
  141. package/dist/standalone/{chunk-QJACMRR5.js → chunk-RC6CRS3F.js} +1 -1
  142. package/dist/standalone/{chunk-LXBSXLLK.js → chunk-RFRFJ6GK.js} +1 -1
  143. package/dist/standalone/chunk-RNVXXJBN.js +1 -0
  144. package/dist/standalone/{chunk-YGNPACVK.js → chunk-SHY25BCU.js} +1 -1
  145. package/dist/standalone/{chunk-J5NS6XO4.js → chunk-T6XTWQC2.js} +1 -1
  146. package/dist/standalone/{chunk-AFX6YYGP.js → chunk-TBEEPT5P.js} +1 -1
  147. package/dist/standalone/{chunk-74WMPCOL.js → chunk-TRUA26Q4.js} +1 -1
  148. package/dist/standalone/{chunk-Y57U7WES.js → chunk-U2ACS5ID.js} +1 -1
  149. package/dist/standalone/{chunk-2W67FQCF.js → chunk-VDC6JP4A.js} +1 -1
  150. package/dist/standalone/chunk-VESZYIB4.js +1 -0
  151. package/dist/standalone/{chunk-MCHTZFX6.js → chunk-VFAP6A6G.js} +1 -1
  152. package/dist/standalone/{chunk-LSEISHAB.js → chunk-VNBONC2Q.js} +1 -1
  153. package/dist/standalone/{chunk-OMN44W6V.js → chunk-VQRCJJXS.js} +1 -1
  154. package/dist/standalone/{chunk-DVX5J34S.js → chunk-W4CQMJH3.js} +1 -1
  155. package/dist/standalone/{chunk-6XIDYONR.js → chunk-WAJZ4QKG.js} +1 -1
  156. package/dist/standalone/{chunk-3CBQDJ4S.js → chunk-WDGITBC6.js} +1 -1
  157. package/dist/standalone/{chunk-2G3B5PAO.js → chunk-WVWCUB4S.js} +1 -1
  158. package/dist/standalone/{chunk-GPNP4QSZ.js → chunk-X4MAMXRE.js} +1 -1
  159. package/dist/standalone/chunk-X6XAMP4E.js +7 -0
  160. package/dist/standalone/{chunk-6B7YJY6X.js → chunk-XDWPHAV6.js} +1 -1
  161. package/dist/standalone/{chunk-2QXJTBVX.js → chunk-XKISL2CG.js} +1 -1
  162. package/dist/standalone/chunk-XVE6WFB4.js +1 -0
  163. package/dist/standalone/chunk-YCQP3TYK.js +5 -0
  164. package/dist/standalone/chunk-ZBHXISOD.js +1 -0
  165. package/dist/standalone/{chunk-FBGCQYRO.js → chunk-ZFW3QEVE.js} +1 -1
  166. package/dist/standalone/{chunk-TSNDFT5D.js → chunk-ZVXBXVS3.js} +1 -1
  167. package/dist/standalone/{chunk-FGVGIVB6.js → chunk-ZWLIXZWR.js} +1 -1
  168. package/dist/standalone/studio.js +1 -1
  169. package/dist/styles.css +1 -1
  170. package/package.json +5 -5
  171. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs +0 -1
  172. package/dist/packem_shared/GlobalDataBrowser-DlBYI85g.mjs +0 -1
  173. package/dist/packem_shared/ScheduledJobs-CscRWLW-.mjs +0 -1
  174. package/dist/packem_shared/internal-S7SDbbPa.mjs +0 -2
  175. package/dist/packem_shared/table-list-sidebar-DcvrtBkE.mjs +0 -1
  176. package/dist/standalone/chunk-3ADTLIRI.js +0 -1
  177. package/dist/standalone/chunk-5LEVE36K.js +0 -1
  178. package/dist/standalone/chunk-7XYNQ3JS.js +0 -1
  179. package/dist/standalone/chunk-AJSSEAMP.js +0 -1
  180. package/dist/standalone/chunk-DSXEICMD.js +0 -1
  181. package/dist/standalone/chunk-GV2QZP42.js +0 -2
  182. package/dist/standalone/chunk-GV6O3NPO.js +0 -1
  183. package/dist/standalone/chunk-GXYXVKOM.js +0 -1
  184. package/dist/standalone/chunk-HHT7X6VO.js +0 -1
  185. package/dist/standalone/chunk-HKQSHNFB.js +0 -1
  186. package/dist/standalone/chunk-JQXA2OYK.js +0 -1
  187. package/dist/standalone/chunk-KXYSX2SV.js +0 -1
  188. package/dist/standalone/chunk-NXVOCK3P.js +0 -5
  189. package/dist/standalone/chunk-PAAYRW3Q.js +0 -9
  190. package/dist/standalone/chunk-YPY2NU35.js +0 -3
  191. package/dist/standalone/chunk-YQQTRX55.js +0 -1
@@ -1,2 +1,2 @@
1
- import{E as se}from"../packem_shared/error-alert-Dr4RMEID.mjs";import{B as ie}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as v}from"../packem_shared/button-q0UYSmrn.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-S7SDbbPa.mjs";import{c as pe}from"react/compiler-runtime";import{useLunora as fe}from"@lunora/react";import{useState as R}from"react";import{u as xe}from"../packem_shared/use-admin-query-B2jU5P5u.mjs";import{useAutoRefresh as be}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...i}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...i})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],N=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const i=e.trim().toLowerCase();return i===""?r:r.filter(o=>`${o.subject} ${N(o.to)} ${N(o.cc)}`.toLowerCase().includes(i))},Se=(r,e)=>{if(r.length!==0)return r.find(i=>i.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(38),{limit:i}=r,o=fe();let p;e[0]!==i?(p={limit:i},e[0]=i,e[1]=p):p=e[1];const{data:O,error:w,errorSource:y,isLoading:b,refetch:l}=xe(J.getCapturedMail,p),[C,f]=R(null),[H,S]=R(null),[g,s]=R("html"),[c,B]=R(""),x=O?.entries??[],a=w??C,h=w===null?C:y;let T;e[2]!==o||e[3]!==l?(T=async()=>{f(null);try{await o.query(Te,{},X("")),S(null),l()}catch(m){f(Z(m))}},e[2]=o,e[3]=l,e[4]=T):T=e[4];const D=T;let k;e[5]!==o||e[6]!==l?(k=async()=>{f(null);try{await o.query(ke,{},X("")),l()}catch(m){f(Z(m))}},e[5]=o,e[6]=l,e[7]=k):k=e[7];const q=k;let A;e[8]!==l?(A=()=>{l()},e[8]=l,e[9]=A):A=e[9],be(A,!0);let E;e[10]!==D?(E=()=>{ee(D())},e[10]=D,e[11]=E):E=e[11];const U=E;let L;e[12]!==q?(L=()=>{ee(q())},e[12]=q,e[13]=L):L=e[13];const W=L;let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=m=>{B(m.currentTarget.value)},e[14]=_):_=e[14];const K=_;let M;e[15]===Symbol.for("react.memo_cache_sentinel")?(M=m=>{const{id:u}=m.currentTarget.dataset;u!==void 0&&S(u)},e[15]=M):M=e[15];const Q=M;let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=m=>{const u=m.currentTarget.dataset.tab;(u==="headers"||u==="html"||u==="text")&&s(u)},e[16]=I):I=e[16];const V=I,j=Ce(x,c),$=Se(j,H),d=ye($);let z;e[17]!==d?(z=()=>{d!==void 0&&he(d)},e[17]=d,e[18]=z):z=e[18];const Y=z;let F;e[19]!==d?(F=()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},e[19]=d,e[20]=F):F=e[20];const G=F;let P;return e[21]!==x||e[22]!==a||e[23]!==h||e[24]!==c||e[25]!==b||e[26]!==d||e[27]!==U||e[28]!==Y||e[29]!==K||e[30]!==G||e[31]!==Q||e[32]!==V||e[33]!==W||e[34]!==$||e[35]!==g||e[36]!==j?(P={entries:x,error:a,errorSource:h,filter:c,isLoading:b,link:d,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:$,tab:g,visible:j},e[21]=x,e[22]=a,e[23]=h,e[24]=c,e[25]=b,e[26]=d,e[27]=U,e[28]=Y,e[29]=K,e[30]=G,e[31]=Q,e[32]=V,e[33]=W,e[34]=$,e[35]=g,e[36]=j,e[37]=P):P=e[37],P},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,Le=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:i,error:o,errorSource:p,filter:O,isLoading:w,link:y,onClear:b,onCopyLink:l,onFilterChange:C,onOpenLink:f,onSelectMessage:H,onSelectTab:S,onSendTest:g,selected:s,tab:c,visible:B}=Ae({limit:r}),x=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(v,{"data-testid":"mail-send-test",onClick:g,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(v,{"data-testid":"mail-clear",disabled:i.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),i.length>0&&t(ie,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:i.length})})]}),o!==null&&t(se,{error:p,testId:"mail-error"}),o===null&&!w&&i.length===0&&t(oe,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),i.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:C,placeholder:e("Filter messages"),type:"search",value:O}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:B.map(a=>{const h=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${h?"bg-muted":""}`,"data-active":h,"data-id":a.id,"data-testid":"mail-list-item",onClick:H,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:N(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:N(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:N(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(v,{"data-testid":"mail-copy-link",disabled:y===void 0,onClick:l,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(v,{"data-testid":"mail-open-link",disabled:y===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(v,{"aria-selected":c===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===a?"secondary":"ghost",children:x(a)},a))}),n("div",{className:"min-h-[12rem]",children:[c==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:Le(s.html),title:e("Email preview")})),c==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),c==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,h])=>`${a}: ${h}`).join(`
1
+ import{E as se}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as oe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as g}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ie}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ne}from"../packem_shared/input-CXhxesPC.mjs";import{S as le}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{Separator as de}from"@base-ui/react/separator";import{c as ce}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as t,jsxs as n,Fragment as me}from"react/jsx-runtime";import{useT as ue}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as ae,d as X,b as Z,f as ee,g as he,h as te}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as pe}from"react/compiler-runtime";import{useLunora as fe}from"@lunora/react";import{useState as F}from"react";import{u as xe}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useAutoRefresh as be}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";function ge({className:r,orientation:e="horizontal",...o}){return t(de,{"data-slot":"separator",orientation:e,className:ce("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",r),...o})}const ve=/https?:\/\/[^\s"'<>)]+/i,re=r=>r===void 0?void 0:ve.exec(r)?.[0],v=r=>r===void 0?"":Array.isArray(r)?r.join(", "):r,Ne=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,we=/&(?:amp|#0*38|#x0*26);/giu,ye=r=>r===void 0?void 0:((r.html===void 0?void 0:Ne.exec(r.html)?.[1])??re(r.text)??re(r.html))?.replaceAll(we,"&"),Ce=(r,e)=>{const o=e.trim().toLowerCase();return o===""?r:r.filter(i=>`${i.subject} ${v(i.to)} ${v(i.cc)}`.toLowerCase().includes(o))},Se=(r,e)=>{if(r.length!==0)return r.find(o=>o.id===e)??r[0]},Te=ae(J.clearCapturedMail),ke=ae(J.sendTestMail),Ae=r=>{const e=pe(36),{limit:o}=r,i=fe();let p;e[0]!==o?(p={limit:o},e[0]=o,e[1]=p):p=e[1];const{data:P,error:N,errorSource:w,isLoading:b,poll:R,refetch:m}=xe(J.getCapturedMail,p),[y,f]=F(null),[O,C]=F(null),[s,h]=F("html"),[x,H]=F(""),a=P?.entries??[],u=N??y,B=N===null?y:w;let S;e[2]!==i||e[3]!==m?(S=async()=>{f(null);try{await i.query(Te,{},X("")),C(null),m()}catch(d){f(Z(d))}},e[2]=i,e[3]=m,e[4]=S):S=e[4];const D=S;let T;e[5]!==i||e[6]!==m?(T=async()=>{f(null);try{await i.query(ke,{},X("")),m()}catch(d){f(Z(d))}},e[5]=i,e[6]=m,e[7]=T):T=e[7];const q=T;be(R,!0);let k;e[8]!==D?(k=()=>{ee(D())},e[8]=D,e[9]=k):k=e[9];const U=k;let A;e[10]!==q?(A=()=>{ee(q())},e[10]=q,e[11]=A):A=e[11];const W=A;let E;e[12]===Symbol.for("react.memo_cache_sentinel")?(E=d=>{H(d.currentTarget.value)},e[12]=E):E=e[12];const K=E;let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=d=>{const{id:c}=d.currentTarget.dataset;c!==void 0&&C(c)},e[13]=L):L=e[13];const Q=L;let _;e[14]===Symbol.for("react.memo_cache_sentinel")?(_=d=>{const c=d.currentTarget.dataset.tab;(c==="headers"||c==="html"||c==="text")&&h(c)},e[14]=_):_=e[14];const V=_,M=Ce(a,x),I=Se(M,O),l=ye(I);let j;e[15]!==l?(j=()=>{l!==void 0&&he(l)},e[15]=l,e[16]=j):j=e[16];const Y=j;let $;e[17]!==l?($=()=>{l!==void 0&&"window"in globalThis&&globalThis.window.open(l,"_blank","noopener")},e[17]=l,e[18]=$):$=e[18];const G=$;let z;return e[19]!==a||e[20]!==u||e[21]!==B||e[22]!==x||e[23]!==b||e[24]!==l||e[25]!==U||e[26]!==Y||e[27]!==K||e[28]!==G||e[29]!==Q||e[30]!==V||e[31]!==W||e[32]!==I||e[33]!==s||e[34]!==M?(z={entries:a,error:u,errorSource:B,filter:x,isLoading:b,link:l,onClear:U,onCopyLink:Y,onFilterChange:K,onOpenLink:G,onSelectMessage:Q,onSelectTab:V,onSendTest:W,selected:I,tab:s,visible:M},e[19]=a,e[20]=u,e[21]=B,e[22]=x,e[23]=b,e[24]=l,e[25]=U,e[26]=Y,e[27]=K,e[28]=G,e[29]=Q,e[30]=V,e[31]=W,e[32]=I,e[33]=s,e[34]=M,e[35]=z):z=e[35],z},Ee=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,Le=r=>`${Ee}${r}`,Qe=({limit:r=100})=>{const e=ue(),{entries:o,error:i,errorSource:p,filter:P,isLoading:N,link:w,onClear:b,onCopyLink:R,onFilterChange:m,onOpenLink:y,onSelectMessage:f,onSelectTab:O,onSendTest:C,selected:s,tab:h,visible:x}=Ae({limit:r}),H=a=>e(a==="html"?"HTML":a==="text"?"Plain text":"Headers");return n("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(g,{"data-testid":"mail-send-test",onClick:C,size:"sm",type:"button",variant:"outline",children:e("Send test")}),t(g,{"data-testid":"mail-clear",disabled:o.length===0,onClick:b,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),o.length>0&&t(oe,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:o.length})})]}),i!==null&&t(se,{error:p,testId:"mail-error"}),i===null&&!N&&o.length===0&&t(ie,{description:e("Email your app sends in dev is captured here — nothing is delivered."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("path",{d:"M4 5h16v14H4z"}),t("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),o.length>0&&n("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[n("div",{className:"flex flex-col gap-2",children:[t(ne,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:m,placeholder:e("Filter messages"),type:"search",value:P}),t(le,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:t("ul",{className:"divide-y",children:x.map(a=>{const u=a.id===s?.id;return t("li",{children:n("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":a.id,"data-testid":"mail-list-item",onClick:f,type:"button",children:[t("span",{className:"w-full truncate font-medium",children:a.subject||e("(no subject)")}),t("span",{className:"w-full truncate text-xs text-muted-foreground",children:v(a.to)}),t("span",{className:"text-xs text-muted-foreground tabular-nums",children:te(a.capturedAt,"—")})]})},a.id)})})})]}),s!==void 0&&n("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[n("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:s.subject||e("(no subject)")}),n("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[t("dt",{children:e("From")}),t("dd",{className:"truncate font-mono",children:s.from??"—"}),t("dt",{children:e("To")}),t("dd",{className:"truncate font-mono",children:v(s.to)}),s.cc!==void 0&&s.cc.length>0&&n(me,{children:[t("dt",{children:e("Cc")}),t("dd",{className:"truncate font-mono",children:v(s.cc)})]}),t("dt",{children:e("Sent")}),t("dd",{className:"tabular-nums",children:te(s.capturedAt,"—")})]})]}),n("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[t(g,{"data-testid":"mail-copy-link",disabled:w===void 0,onClick:R,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),t(g,{"data-testid":"mail-open-link",disabled:w===void 0,onClick:y,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),t(ge,{}),t("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(a=>t(g,{"aria-selected":h===a,"data-tab":a,"data-testid":`mail-tab-${a}`,onClick:O,role:"tab",size:"sm",type:"button",variant:h===a?"secondary":"ghost",children:H(a)},a))}),n("div",{className:"min-h-[12rem]",children:[h==="html"&&(s.html===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):t("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:Le(s.html),title:e("Email preview")})),h==="text"&&(s.text===void 0?t("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:s.text})),h==="headers"&&(s.headers===void 0||Object.keys(s.headers).length===0?t("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):t("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(s.headers).map(([a,u])=>`${a}: ${u}`).join(`
2
2
  `)}))]})]})]})]})};export{Qe as MailPanel};
@@ -1 +1 @@
1
- import{useLunora as ht}from"@lunora/react";import{useState as pe,useRef as Je,useEffect as et,useMemo as gt}from"react";import{L as pt}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as Ve}from"../packem_shared/use-admin-query-B2jU5P5u.mjs";import{u as bt}from"../packem_shared/use-open-trace-CUyoDXjN.mjs";import{u as vt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as xe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{i as Nt,m as Xe,f as St,d as wt,b as qt,c as Tt}from"../packem_shared/internal-S7SDbbPa.mjs";import{r as _t,l as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as Le}from"react/compiler-runtime";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as Ze}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as he,a as ge,b as Pe,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as je,e as oe,T as ot,c as de,a as ct,d as dt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as mt}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as n,jsx as t,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as It,computeLatencyPercentiles as Dt,enrichQueryStats as $t,shardsToAggregate as At}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as me}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as rt,c as Lt,h as Et}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as st,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as zt,LineChart as Ot,Line as Kt}from"recharts";import{E as Bt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Pt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as Vt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,a)=>`${i}:${e}:${kt(a??{})}`,ft=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,jt=(i,e)=>ft(i,e),Gt=i=>ft(i.kind,i),We=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Jt=i=>Array.isArray(i?.series)?i.series:[],Wt="FUNCTION_NOT_FOUND",Xt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const a of i.series)e.set(ut(a.kind,a.name,a.attributes),a.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=Le(18),{name:a,onOpenTrace:s,traceId:r}=i,f=xe();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let o;e[1]!==r?(o=r.slice(0,8),e[1]=r,e[2]=o):o=e[2];const l=o;if(s===void 0){const d=`mt-instrument-trace-${a}`;let p;return e[3]!==l||e[4]!==d||e[5]!==r?(p=t("span",{className:"text-muted-foreground","data-testid":d,title:r,children:l}),e[3]=l,e[4]=d,e[5]=r,e[6]=p):p=e[6],p}const h=`mt-instrument-trace-${a}`;let v;e[7]!==s||e[8]!==r?(v=()=>{s(r)},e[7]=s,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==f||e[11]!==r?(w=f("Open the exemplar trace {trace}",{trace:r}),e[10]=f,e[11]=r,e[12]=w):w=e[12];let g;return e[13]!==l||e[14]!==h||e[15]!==v||e[16]!==w?(g=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":h,onClick:v,title:w,type:"button",children:l}),e[13]=l,e[14]=h,e[15]=v,e[16]=w,e[17]=g):g=e[17],g},er=i=>{const e=Le(105),{onOpenTrace:a,shardKey:s}=i,r=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let o;e[1]!==s?(o={live:!0,shardKey:s},e[1]=s,e[2]=o):o=e[2];const{data:l,error:h,errorSource:v}=Ve(Fe.getMetricSeries,f,o);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let g;e[4]!==s?(g={live:!0,shardKey:s},e[4]=s,e[5]=g):g=e[5];const{data:d}=Ve(Fe.getMetricHistory,w,g);let p,y,q,C,c,T,x,b,_,R,u,M,k;if(e[6]!==l||e[7]!==h||e[8]!==v||e[9]!==d||e[10]!==a||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{const F=Jt(l),z=Nt(v)===Wt;if(h!==null&&!z){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let P;e[27]!==m?(P=t("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=P):P=e[28];let Q;e[29]!==h||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:h}),e[29]=h,e[30]=r,e[31]=Q):Q=e[31];let U;e[32]!==Q?(U=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=U):U=e[33];let V;e[34]!==P||e[35]!==U?(V=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[P,U]}),e[34]=P,e[35]=U,e[36]=V):V=e[36],b=V;break e}if(F.length===0){b=null;break e}const O=Xt(d);let L;e[37]!==r?(L=m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=L):L=e[38];const H=L;c="flex flex-col gap-2",T="mt-instruments";let B;e[39]!==r?(B=r("Instruments"),e[39]=r,e[40]=B):B=e[40],e[41]!==B?(x=t("h3",{className:"text-sm font-semibold text-foreground",children:B}),e[41]=B,e[42]=x):x=e[42],C=he,k="overflow-hidden py-0",q=ge,M="px-0",y=ot,R="mt-instruments-table";let E;e[43]!==r?(E=r("name"),e[43]=r,e[44]=E):E=e[44];let K;e[45]!==E?(K=t(de,{children:E}),e[45]=E,e[46]=K):K=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let J;e[49]!==G?(J=t(de,{children:G}),e[49]=G,e[50]=J):J=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let Z;e[57]!==Y?(Z=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=Z):Z=e[58];let ee;e[59]!==r?(ee=r("range"),e[59]=r,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=t(de,{className:"text-right",children:ee}),e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==r?(re=r("trend"),e[63]=r,e[64]=re):re=e[64];let se;e[65]!==re?(se=t(de,{children:re}),e[65]=re,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ae;e[69]!==le?(ae=t(de,{children:le}),e[69]=le,e[70]=ae):ae=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let ne;e[73]!==ie?(ne=t(de,{children:ie}),e[73]=ie,e[74]=ne):ne=e[74],e[75]!==K||e[76]!==J||e[77]!==X||e[78]!==Z||e[79]!==te||e[80]!==se||e[81]!==ae||e[82]!==ne?(u=t(ct,{children:n(je,{children:[K,J,X,Z,te,se,ae,ne]})}),e[75]=K,e[76]=J,e[77]=X,e[78]=Z,e[79]=te,e[80]=se,e[81]=ae,e[82]=ne,e[83]=u):u=e[83],p=dt,_=F.map(m=>{const P=Rt(m.attributes),Q=ut(m.kind,m.name,m.attributes),V=(O.get(Q)??[]).map(ue=>jt(m.kind,ue));return n(je,{"data-testid":`mt-instrument-${m.name}`,children:[t(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),t(oe,{children:t(Ze,{variant:Yt[m.kind],children:H(m.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:We(Gt(m))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${We(m.min)}–${We(m.max)}`}),t(oe,{children:V.length>=2?t(mt,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:V,testId:`mt-instrument-trend-${m.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Zt,{name:m.name,onOpenTrace:a,traceId:m.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:P,children:P===""?"—":P})]},Q)})}e[6]=l,e[7]=h,e[8]=v,e[9]=d,e[10]=a,e[11]=r,e[12]=p,e[13]=y,e[14]=q,e[15]=C,e[16]=c,e[17]=T,e[18]=x,e[19]=b,e[20]=_,e[21]=R,e[22]=u,e[23]=M,e[24]=k}else p=e[12],y=e[13],q=e[14],C=e[15],c=e[16],T=e[17],x=e[18],b=e[19],_=e[20],R=e[21],u=e[22],M=e[23],k=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let I;e[84]!==p||e[85]!==_?(I=t(p,{children:_}),e[84]=p,e[85]=_,e[86]=I):I=e[86];let D;e[87]!==y||e[88]!==I||e[89]!==R||e[90]!==u?(D=n(y,{"data-testid":R,children:[u,I]}),e[87]=y,e[88]=I,e[89]=R,e[90]=u,e[91]=D):D=e[91];let S;e[92]!==q||e[93]!==D||e[94]!==M?(S=t(q,{className:M,children:D}),e[92]=q,e[93]=D,e[94]=M,e[95]=S):S=e[95];let N;e[96]!==C||e[97]!==S||e[98]!==k?(N=t(C,{className:k,children:S}),e[96]=C,e[97]=S,e[98]=k,e[99]=N):N=e[99];let A;return e[100]!==c||e[101]!==T||e[102]!==x||e[103]!==N?(A=n("section",{className:c,"data-testid":T,children:[x,N]}),e[100]=c,e[101]=T,e[102]=x,e[103]=N,e[104]=A):A=e[104],A},tr=i=>{const e=Le(74),{aggregate:a,shardResults:s}=i,r=xe();let f;e[0]!==r?(f=r("Shards"),e[0]=r,e[1]=f):f=e[1];let o;e[2]!==a.failed||e[3]!==a.reachable||e[4]!==r?(o=a.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:a.failed,reachable:a.reachable}):r("{reachable} reachable",{reachable:a.reachable}),e[2]=a.failed,e[3]=a.reachable,e[4]=r,e[5]=o):o=e[5];let l;e[6]!==f||e[7]!==o?(l=t(me,{label:f,testId:"mt-agg-shards",value:o}),e[6]=f,e[7]=o,e[8]=l):l=e[8];let h;e[9]!==r?(h=r("Total requests"),e[9]=r,e[10]=h):h=e[10];let v;e[11]!==a.totalRequests||e[12]!==h?(v=t(me,{label:h,testId:"mt-agg-requests",value:a.totalRequests}),e[11]=a.totalRequests,e[12]=h,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let g;e[16]!==a.totalErrors||e[17]!==w?(g=t(me,{label:w,testId:"mt-agg-errors",value:a.totalErrors}),e[16]=a.totalErrors,e[17]=w,e[18]=g):g=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let p;e[21]!==a.totalDatabaseSize?(p=Xe(a.totalDatabaseSize),e[21]=a.totalDatabaseSize,e[22]=p):p=e[22];let y;e[23]!==d||e[24]!==p?(y=t(me,{label:d,testId:"mt-agg-db-size",value:p}),e[23]=d,e[24]=p,e[25]=y):y=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let C;e[28]!==a.hitRate||e[29]!==r?(C=a.hitRate===null?r("no cache configured"):`${(a.hitRate*100).toFixed(1)}%`,e[28]=a.hitRate,e[29]=r,e[30]=C):C=e[30];let c;e[31]!==q||e[32]!==C?(c=t(me,{label:q,testId:"mt-agg-cache",value:C}),e[31]=q,e[32]=C,e[33]=c):c=e[33];let T;e[34]!==y||e[35]!==c||e[36]!==l||e[37]!==v||e[38]!==g?(T=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[l,v,g,y,c]}),e[34]=y,e[35]=c,e[36]=l,e[37]=v,e[38]=g,e[39]=T):T=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=t(de,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let R;e[46]!==_?(R=t(de,{children:_}),e[46]=_,e[47]=R):R=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let M;e[50]!==u?(M=t(de,{children:u}),e[50]=u,e[51]=M):M=e[51];let k;e[52]!==r?(k=r("db size"),e[52]=r,e[53]=k):k=e[53];let I;e[54]!==k?(I=t(de,{children:k}),e[54]=k,e[55]=I):I=e[55];let D;e[56]!==b||e[57]!==R||e[58]!==M||e[59]!==I?(D=t(ct,{children:n(je,{children:[b,R,M,I]})}),e[56]=b,e[57]=R,e[58]=M,e[59]=I,e[60]=D):D=e[60];let S;if(e[61]!==s||e[62]!==r){let z;e[64]!==r?(z=O=>n(je,{"data-testid":`mt-agg-row-${O.shard}`,children:[t(oe,{children:O.shard}),O.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:O.error??r("unreachable")}):n(Ye,{children:[t(oe,{className:"tabular-nums",children:O.metrics.requests}),t(oe,{className:"tabular-nums",children:O.metrics.errors}),t(oe,{className:"tabular-nums",children:Xe(O.metrics.databaseSize)})]})]},O.shard),e[64]=r,e[65]=z):z=e[65],S=s.map(z),e[61]=s,e[62]=r,e[63]=S}else S=e[63];let N;e[66]!==S?(N=t(dt,{children:S}),e[66]=S,e[67]=N):N=e[67];let A;e[68]!==D||e[69]!==N?(A=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(ot,{"data-testid":"mt-agg-table",children:[D,N]})})}),e[68]=D,e[69]=N,e[70]=A):A=e[70];let F;return e[71]!==T||e[72]!==A?(F=n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[T,A]}),e[71]=T,e[72]=A,e[73]=F):F=e[73],F},rr=i=>{const e=Le(75),{currentDelta:a,errorRate:s,history:r,latencyPercentiles:f,metrics:o}=i,l=xe(),{cache:h}=o;let v;e[0]!==r||e[1]!==l?(v=r.length>=2?t(mt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=l,e[2]=v):v=e[2];let w;e[3]!==a||e[4]!==r.length||e[5]!==l?(w=r.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${a.toLocaleString()}`})," ",l("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples…")}),e[3]=a,e[4]=r.length,e[5]=l,e[6]=w):w=e[6];let g;e[7]!==l?(g=l("Requests"),e[7]=l,e[8]=g):g=e[8];let d;e[9]!==o.requests||e[10]!==v||e[11]!==w||e[12]!==g?(d=t(me,{chart:v,footer:w,label:g,testId:"mt-requests",value:o.requests}),e[9]=o.requests,e[10]=v,e[11]=w,e[12]=g,e[13]=d):d=e[13];let p;e[14]!==s||e[15]!==l?(p=l("{rate} error rate",{rate:s}),e[14]=s,e[15]=l,e[16]=p):p=e[16];let y;e[17]!==l?(y=l("Errors"),e[17]=l,e[18]=y):y=e[18];let q;e[19]!==s||e[20]!==o.errors?(q=n(Ye,{children:[o.errors," (",s,")"]}),e[19]=s,e[20]=o.errors,e[21]=q):q=e[21];let C;e[22]!==p||e[23]!==y||e[24]!==q?(C=t(me,{footer:p,label:y,testId:"mt-errors",value:q}),e[22]=p,e[23]=y,e[24]=q,e[25]=C):C=e[25];let c;e[26]!==f.p90?(c=f.p90>0?`P90 ${rt(f.p90)}`:void 0,e[26]=f.p90,e[27]=c):c=e[27];let T;e[28]!==l?(T=l("P95 latency"),e[28]=l,e[29]=T):T=e[29];let x;e[30]!==f.p95?(x=f.p95>0?rt(f.p95):"—",e[30]=f.p95,e[31]=x):x=e[31];let b;e[32]!==T||e[33]!==x||e[34]!==c?(b=t(me,{footer:c,label:T,testId:"mt-p95",value:x}),e[32]=T,e[33]=x,e[34]=c,e[35]=b):b=e[35];let _;e[36]!==h||e[37]!==l?(_=h?`${h.entries.toLocaleString()} ${l("cache entries")}`:void 0,e[36]=h,e[37]=l,e[38]=_):_=e[38];let R;e[39]!==l?(R=l("Database size"),e[39]=l,e[40]=R):R=e[40];let u;e[41]!==o.databaseSize?(u=Xe(o.databaseSize),e[41]=o.databaseSize,e[42]=u):u=e[42];let M;e[43]!==_||e[44]!==R||e[45]!==u?(M=t(me,{footer:_,label:R,testId:"mt-db-size",value:u}),e[43]=_,e[44]=R,e[45]=u,e[46]=M):M=e[46];let k;e[47]!==l?(k=l("Shard"),e[47]=l,e[48]=k):k=e[48];let I;e[49]!==o.shard||e[50]!==k?(I=t(me,{label:k,testId:"mt-shard",value:o.shard}),e[49]=o.shard,e[50]=k,e[51]=I):I=e[51];let D;e[52]!==l?(D=l("Uptime"),e[52]=l,e[53]=D):D=e[53];let S;e[54]!==o.uptimeMs?(S=Lt(o.uptimeMs),e[54]=o.uptimeMs,e[55]=S):S=e[55];let N;e[56]!==D||e[57]!==S?(N=t(me,{label:D,testId:"mt-uptime",value:S}),e[56]=D,e[57]=S,e[58]=N):N=e[58];let A;e[59]!==l?(A=l("Cache hit rate"),e[59]=l,e[60]=A):A=e[60];let F;e[61]!==h||e[62]!==l?(F=h?l("{rate} ({count} entries)",{count:h.entries,rate:Et(h.hits,h.misses)}):l("no cache configured"),e[61]=h,e[62]=l,e[63]=F):F=e[63];let z;e[64]!==A||e[65]!==F?(z=t(me,{label:A,testId:"mt-cache",value:F}),e[64]=A,e[65]=F,e[66]=z):z=e[66];let O;return e[67]!==b||e[68]!==M||e[69]!==I||e[70]!==N||e[71]!==z||e[72]!==d||e[73]!==C?(O=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,C,b,M,I,N,z]}),e[67]=b,e[68]=M,e[69]=I,e[70]=N,e[71]=z,e[72]=d,e[73]=C,e[74]=O):O=e[74],O},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Ee=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),sr=i=>{const e=Le(3),{level:a}=i;if(a==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(Ze,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(a==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=s):s=e[2],s},lr=(i,e)=>{const a=[...i];return a.sort((s,r)=>{switch(e){case"avgTime":return r.avgDurationMs-s.avgDurationMs;case"execCount":return r.execCount-s.execCount;case"rowsRead":return r.rowsRead-s.rowsRead;default:return r.totalDurationMs-s.totalDurationMs}}),a},ar=i=>{const e=Le(161),{queryStats:a}=i,s=xe(),[r,f]=pe("totalTime");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[l,h]=pe(o);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=k=>{k!==null&&f(k)},e[1]=v):v=e[1];const w=v;let g,d,p,y,q,C,c,T,x,b;if(e[2]!==l||e[3]!==a||e[4]!==r||e[5]!==s){p=Symbol.for("react.early_return_sentinel");e:{const k=lr(a,r);let I;e[16]!==a?(I=a.filter(ir),e[16]=a,e[17]=I):I=e[17];const D=I.length;let S;e[18]!==a?(S=a.filter(nr),e[18]=a,e[19]=S):S=e[19];const N=S.length;let A;e[20]!==a?(A=a.filter(or),e[20]=a,e[21]=A):A=e[21];const F=A.length;let z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z=$=>{h(ce=>{const j=new Set(ce);return j.has($)?j.delete($):j.add($),j})},e[22]=z):z=e[22];const O=z;if(a.length===0){let $;e[23]!==s?($=s("No query insights yet"),e[23]=s,e[24]=$):$=e[24];let ce;e[25]!==$?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:$}),e[25]=$,e[26]=ce):ce=e[26];let j;e[27]!==s?(j=s("Query insights appear once statements are executed against this shard."),e[27]=s,e[28]=j):j=e[28];let fe;e[29]!==j?(fe=t("p",{className:"mt-1 text-sm",children:j}),e[29]=j,e[30]=fe):fe=e[30];let Be;e[31]!==ce||e[32]!==fe?(Be=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[ce,fe]})})}),e[31]=ce,e[32]=fe,e[33]=Be):Be=e[33],p=Be;break e}c="space-y-4",T="qi-root";let L;e[34]!==s?(L=s("Critical queries"),e[34]=s,e[35]=L):L=e[35];let H;e[36]!==L?(H=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=H):H=e[37];let B;e[38]!==D?(B=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=B):B=e[39];let E;e[40]!==s?(E=s(">100ms avg execution"),e[40]=s,e[41]=E):E=e[41];let K;e[42]!==E?(K=t("p",{className:"text-xs text-muted-foreground",children:E}),e[42]=E,e[43]=K):K=e[43];let G;e[44]!==B||e[45]!==K?(G=n(ge,{children:[B,K]}),e[44]=B,e[45]=K,e[46]=G):G=e[46];let J;e[47]!==H||e[48]!==G?(J=n(he,{children:[H,G]}),e[47]=H,e[48]=G,e[49]=J):J=e[49];let W;e[50]!==s?(W=s("Moderate queries"),e[50]=s,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==N?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:N}),e[54]=N,e[55]=Y):Y=e[55];let Z;e[56]!==s?(Z=s("50–100ms avg execution"),e[56]=s,e[57]=Z):Z=e[57];let ee;e[58]!==Z?(ee=t("p",{className:"text-xs text-muted-foreground",children:Z}),e[58]=Z,e[59]=ee):ee=e[59];let te;e[60]!==Y||e[61]!==ee?(te=n(ge,{children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==X||e[64]!==te?(re=n(he,{children:[X,te]}),e[63]=X,e[64]=te,e[65]=re):re=e[65];let se;e[66]!==s?(se=s("Fast queries"),e[66]=s,e[67]=se):se=e[67];let le;e[68]!==se?(le=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ae;e[70]!==F?(ae=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:F}),e[70]=F,e[71]=ae):ae=e[71];let ie;e[72]!==s?(ie=s("<50ms avg execution"),e[72]=s,e[73]=ie):ie=e[73];let ne;e[74]!==ie?(ne=t("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=ne):ne=e[75];let m;e[76]!==ae||e[77]!==ne?(m=n(ge,{children:[ae,ne]}),e[76]=ae,e[77]=ne,e[78]=m):m=e[78];let P;e[79]!==le||e[80]!==m?(P=n(he,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=P):P=e[81],e[82]!==J||e[83]!==re||e[84]!==P?(x=n("div",{className:"grid gap-4 md:grid-cols-3",children:[J,re,P]}),e[82]=J,e[83]=re,e[84]=P,e[85]=x):x=e[85];let Q;e[86]!==s?(Q=s("Query leaderboard"),e[86]=s,e[87]=Q):Q=e[87];let U;e[88]!==Q?(U=t("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=U):U=e[89];let V;e[90]!==r||e[91]!==s?(V=s("Slow queries sorted by {sortField}",{sortField:s(r)}),e[90]=r,e[91]=s,e[92]=V):V=e[92];let ue;e[93]!==V?(ue=t("p",{className:"text-sm text-muted-foreground",children:V}),e[93]=V,e[94]=ue):ue=e[94];let be;e[95]!==U||e[96]!==ue?(be=n("div",{children:[U,ue]}),e[95]=U,e[96]=ue,e[97]=be):be=e[97];let ve;e[98]!==s?(ve=s("Sort by"),e[98]=s,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=t("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==s?(Ne=s("Sort queries by"),e[102]=s,e[103]=Ne):Ne=e[103];let ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(ze=t(Qt,{}),e[104]=ze):ze=e[104];let Se;e[105]!==Ne?(Se=t(Ht,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:ze}),e[105]=Ne,e[106]=Se):Se=e[106];let we;e[107]!==s?(we=s("Total time"),e[107]=s,e[108]=we):we=e[108];let qe;e[109]!==we?(qe=t(He,{value:"totalTime",children:we}),e[109]=we,e[110]=qe):qe=e[110];let Te;e[111]!==s?(Te=s("Avg time"),e[111]=s,e[112]=Te):Te=e[112];let _e;e[113]!==Te?(_e=t(He,{value:"avgTime",children:Te}),e[113]=Te,e[114]=_e):_e=e[114];let Ce;e[115]!==s?(Ce=s("Execution count"),e[115]=s,e[116]=Ce):Ce=e[116];let Re;e[117]!==Ce?(Re=t(He,{value:"execCount",children:Ce}),e[117]=Ce,e[118]=Re):Re=e[118];let Me;e[119]!==s?(Me=s("Rows read"),e[119]=s,e[120]=Me):Me=e[120];let ke;e[121]!==Me?(ke=t(He,{value:"rowsRead",children:Me}),e[121]=Me,e[122]=ke):ke=e[122];let Ie;e[123]!==qe||e[124]!==_e||e[125]!==Re||e[126]!==ke?(Ie=n(Ut,{children:[qe,_e,Re,ke]}),e[123]=qe,e[124]=_e,e[125]=Re,e[126]=ke,e[127]=Ie):Ie=e[127];let De;e[128]!==r||e[129]!==Se||e[130]!==Ie?(De=n(Vt,{onValueChange:w,value:r,children:[Se,Ie]}),e[128]=r,e[129]=Se,e[130]=Ie,e[131]=De):De=e[131];let $e;e[132]!==ye||e[133]!==De?($e=n("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=$e):$e=e[134],e[135]!==be||e[136]!==$e?(b=n("div",{className:"flex items-center justify-between",children:[be,$e]}),e[135]=be,e[136]=$e,e[137]=b):b=e[137],d=he;let Ae;e[138]!==s?(Ae=s("Statements"),e[138]=s,e[139]=Ae):Ae=e[139];let Oe;e[140]!==Ae?(Oe=t(Qe,{children:Ae}),e[140]=Ae,e[141]=Oe):Oe=e[141],C=n(Pe,{children:[Oe,t(Mt,{children:s("{count} tracked statements",{count:k.length})})]}),g=ge,y="space-y-2";let Ke;e[142]!==l||e[143]!==s?(Ke=$=>{const ce=$.normalizedSql,j=l.has(ce),fe=Ge($.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":j,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{O(ce)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(sr,{level:fe}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:$.normalizedSql})]}),n("div",{className:"flex shrink-0 items-center gap-4",children:[n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("avg")})]}),$.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ue($.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:s("calls")})]})]})]}),j&&n("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[n("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:s("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:$.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[$.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:s("p50")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsWritten)})]})]})]})]},ce)},e[142]=l,e[143]=s,e[144]=Ke):Ke=e[144],q=k.map(Ke)}e[2]=l,e[3]=a,e[4]=r,e[5]=s,e[6]=g,e[7]=d,e[8]=p,e[9]=y,e[10]=q,e[11]=C,e[12]=c,e[13]=T,e[14]=x,e[15]=b}else g=e[6],d=e[7],p=e[8],y=e[9],q=e[10],C=e[11],c=e[12],T=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==y||e[146]!==q?(_=t("div",{className:y,children:q}),e[145]=y,e[146]=q,e[147]=_):_=e[147];let R;e[148]!==g||e[149]!==_?(R=t(g,{children:_}),e[148]=g,e[149]=_,e[150]=R):R=e[150];let u;e[151]!==d||e[152]!==R||e[153]!==C?(u=n(d,{children:[C,R]}),e[151]=d,e[152]=R,e[153]=C,e[154]=u):u=e[154];let M;return e[155]!==u||e[156]!==c||e[157]!==T||e[158]!==x||e[159]!==b?(M=n("div",{className:c,"data-testid":T,children:[x,b,u]}),e[155]=u,e[156]=c,e[157]=T,e[158]=x,e[159]=b,e[160]=M):M=e[160],M};function ir(i){return Ge(i.avgDurationMs)==="critical"}function nr(i){return Ge(i.avgDurationMs)==="warning"}function or(i){return Ge(i.avgDurationMs)==="good"}const cr=["1m","5m","15m","1h"],dr=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),mr=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:dr(e.bucketMs)})),ur=({shardKey:i=""})=>{const e=xe(),[a,s]=pe("15m"),f=Ve(Fe.getQueryInsights,{range:a},{live:!0,shardKey:i}).data,o=mr(f?.buckets??[]);return n("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cr.map(l=>t("button",{"aria-pressed":l===a,className:Pt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",l===a&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${l}`,onClick:()=>{s(l)},type:"button",children:l},l))}),f?.capped===!0&&t(Ze,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?t(Bt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):n("div",{className:"grid gap-4 lg:grid-cols-2",children:[n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(st,{height:140,width:"100%",children:n(Ft,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(st,{height:140,width:"100%",children:n(Ot,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(ar,{queryStats:f?.entries??[]})]})},fr=Tt(Fe.getMetrics),hr=(i,e)=>i?e:"overview",Qr=({initialShardKey:i})=>{const e=ht(),a=xe(),{queryShardKey:s,setShardKey:r,shardKey:f}=vt(i),[o,l]=pe("overview"),[h,v]=pe([]),w=Je(null),g=Je(null),d=Je(!0);et(()=>(d.current=!0,()=>{d.current=!1}),[]);const p=bt(s),{data:y,error:q,liveError:C}=Ve(Fe.getMetrics,{},{live:!0,shardKey:s}),c=y??null;et(()=>{if(y===void 0)return;_t(s);const L=y,H=w.current,B=g.current!==null&&g.current!==L.shard;if(g.current=L.shard,w.current=L.requests,B){v([]);return}H!==null&&L.requests>=H&&v(E=>[...E,L.requests-H].slice(-30))},[y,s]);const[T,x]=pe(null),[b,_]=pe(!1),R=async()=>{_(!0);const L=f,H=At(L,Ct());try{const B=await Promise.all(H.map(async E=>{try{const K=await e.query(fr,{},wt(E));return{error:null,metrics:K,shard:E===""?K.shard:E}}catch(K){return{error:qt(K),metrics:null,shard:E===""?"__root__":E}}}));d.current&&x({results:B,shard:L})}finally{d.current&&_(!1)}},u=T?.shard===f?T.results:null,M=u===null?null:It(u),k=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,I=h.length>0?h.at(-1):0,D=c?Dt(c):{p90:0,p95:0},S=gt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[c]),N=hr(S!==void 0,o),A=()=>{St(R())},F=()=>{x(null)},z=()=>{l("overview")},O=()=>{l("query-insights")};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(xt,{onChange:r,testId:"mt-shard-input",value:f}),t(pt,{message:C,prefix:"mt"}),t(tt,{"data-testid":"mt-aggregate",disabled:b,onClick:A,size:"sm",type:"button",variant:"secondary",children:a(b?"Aggregating…":"All shards")}),u!==null&&t(tt,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:a("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:a("Open in Cloudflare")})]}),q!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),S!==void 0&&n("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:z,type:"button",children:a("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:O,type:"button",children:[a("Query insights"),S.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:S.length})]})]}),N==="query-insights"&&S!==void 0&&t(ur,{shardKey:s}),N==="overview"&&c!==null&&t(rr,{currentDelta:I,errorRate:k,history:h,latencyPercentiles:D,metrics:c}),N==="overview"&&c===null&&null,N==="overview"&&t(er,{onOpenTrace:p,shardKey:s}),N==="overview"&&M!==null&&u!==null&&t(tr,{aggregate:M,shardResults:u})]})};export{Qr as MetricsPanel};
1
+ import{useLunora as ht}from"@lunora/react";import{useState as pe,useRef as Je,useEffect as et,useMemo as gt}from"react";import{L as pt}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xt}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{u as bt}from"../packem_shared/use-open-trace-B_0LbTD7.mjs";import{u as vt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as xe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as yt}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as qt,c as Tt}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _t,l as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{c as Le}from"react/compiler-runtime";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as Ze}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as he,a as ge,b as Pe,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as oe,T as ot,c as de,a as ct,d as dt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as mt}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as n,jsx as t,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as It,computeLatencyPercentiles as Dt,enrichQueryStats as $t,shardsToAggregate as At}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as me}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as rt,c as Lt,h as Et}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as st,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as zt,LineChart as Ot,Line as Kt}from"recharts";import{E as Bt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Pt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,a)=>`${i}:${e}:${kt(a??{})}`,ft=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ft(i,e),Gt=i=>ft(i.kind,i),We=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Jt=i=>Array.isArray(i?.series)?i.series:[],Wt="FUNCTION_NOT_FOUND",Xt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const a of i.series)e.set(ut(a.kind,a.name,a.attributes),a.points);return e},Yt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=Le(18),{name:a,onOpenTrace:s,traceId:r}=i,f=xe();if(r===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let o;e[1]!==r?(o=r.slice(0,8),e[1]=r,e[2]=o):o=e[2];const l=o;if(s===void 0){const d=`mt-instrument-trace-${a}`;let p;return e[3]!==l||e[4]!==d||e[5]!==r?(p=t("span",{className:"text-muted-foreground","data-testid":d,title:r,children:l}),e[3]=l,e[4]=d,e[5]=r,e[6]=p):p=e[6],p}const h=`mt-instrument-trace-${a}`;let v;e[7]!==s||e[8]!==r?(v=()=>{s(r)},e[7]=s,e[8]=r,e[9]=v):v=e[9];let w;e[10]!==f||e[11]!==r?(w=f("Open the exemplar trace {trace}",{trace:r}),e[10]=f,e[11]=r,e[12]=w):w=e[12];let g;return e[13]!==l||e[14]!==h||e[15]!==v||e[16]!==w?(g=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":h,onClick:v,title:w,type:"button",children:l}),e[13]=l,e[14]=h,e[15]=v,e[16]=w,e[17]=g):g=e[17],g},er=i=>{const e=Le(105),{onOpenTrace:a,shardKey:s}=i,r=xe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let o;e[1]!==s?(o={live:!0,shardKey:s},e[1]=s,e[2]=o):o=e[2];const{data:l,error:h,errorSource:v}=je(Fe.getMetricSeries,f,o);let w;e[3]===Symbol.for("react.memo_cache_sentinel")?(w={},e[3]=w):w=e[3];let g;e[4]!==s?(g={live:!0,shardKey:s},e[4]=s,e[5]=g):g=e[5];const{data:d}=je(Fe.getMetricHistory,w,g);let p,y,q,C,c,T,x,b,_,R,u,M,k;if(e[6]!==l||e[7]!==h||e[8]!==v||e[9]!==d||e[10]!==a||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{const F=Jt(l),z=Nt(v)===Wt;if(h!==null&&!z){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let P;e[27]!==m?(P=t("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=P):P=e[28];let Q;e[29]!==h||e[30]!==r?(Q=r("Instruments unavailable: {error}",{error:h}),e[29]=h,e[30]=r,e[31]=Q):Q=e[31];let U;e[32]!==Q?(U=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:Q}),e[32]=Q,e[33]=U):U=e[33];let j;e[34]!==P||e[35]!==U?(j=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[P,U]}),e[34]=P,e[35]=U,e[36]=j):j=e[36],b=j;break e}if(F.length===0){b=null;break e}const O=Xt(d);let L;e[37]!==r?(L=m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=r,e[38]=L):L=e[38];const H=L;c="flex flex-col gap-2",T="mt-instruments";let B;e[39]!==r?(B=r("Instruments"),e[39]=r,e[40]=B):B=e[40],e[41]!==B?(x=t("h3",{className:"text-sm font-semibold text-foreground",children:B}),e[41]=B,e[42]=x):x=e[42],C=he,k="overflow-hidden py-0",q=ge,M="px-0",y=ot,R="mt-instruments-table";let E;e[43]!==r?(E=r("name"),e[43]=r,e[44]=E):E=e[44];let K;e[45]!==E?(K=t(de,{children:E}),e[45]=E,e[46]=K):K=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let J;e[49]!==G?(J=t(de,{children:G}),e[49]=G,e[50]=J):J=e[50];let W;e[51]!==r?(W=r("value"),e[51]=r,e[52]=W):W=e[52];let X;e[53]!==W?(X=t(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==r?(Y=r("count"),e[55]=r,e[56]=Y):Y=e[56];let Z;e[57]!==Y?(Z=t(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=Z):Z=e[58];let ee;e[59]!==r?(ee=r("range"),e[59]=r,e[60]=ee):ee=e[60];let te;e[61]!==ee?(te=t(de,{className:"text-right",children:ee}),e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==r?(re=r("trend"),e[63]=r,e[64]=re):re=e[64];let se;e[65]!==re?(se=t(de,{children:re}),e[65]=re,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ae;e[69]!==le?(ae=t(de,{children:le}),e[69]=le,e[70]=ae):ae=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let ne;e[73]!==ie?(ne=t(de,{children:ie}),e[73]=ie,e[74]=ne):ne=e[74],e[75]!==K||e[76]!==J||e[77]!==X||e[78]!==Z||e[79]!==te||e[80]!==se||e[81]!==ae||e[82]!==ne?(u=t(ct,{children:n(Ve,{children:[K,J,X,Z,te,se,ae,ne]})}),e[75]=K,e[76]=J,e[77]=X,e[78]=Z,e[79]=te,e[80]=se,e[81]=ae,e[82]=ne,e[83]=u):u=e[83],p=dt,_=F.map(m=>{const P=Rt(m.attributes),Q=ut(m.kind,m.name,m.attributes),j=(O.get(Q)??[]).map(ue=>Vt(m.kind,ue));return n(Ve,{"data-testid":`mt-instrument-${m.name}`,children:[t(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),t(oe,{children:t(Ze,{variant:Yt[m.kind],children:H(m.kind)})}),t(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:We(Gt(m))}),t(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),t(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${We(m.min)}–${We(m.max)}`}),t(oe,{children:j.length>=2?t(mt,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:j,testId:`mt-instrument-trend-${m.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(oe,{className:"font-mono text-xs",children:t(Zt,{name:m.name,onOpenTrace:a,traceId:m.exemplarTraceId})}),t(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:P,children:P===""?"—":P})]},Q)})}e[6]=l,e[7]=h,e[8]=v,e[9]=d,e[10]=a,e[11]=r,e[12]=p,e[13]=y,e[14]=q,e[15]=C,e[16]=c,e[17]=T,e[18]=x,e[19]=b,e[20]=_,e[21]=R,e[22]=u,e[23]=M,e[24]=k}else p=e[12],y=e[13],q=e[14],C=e[15],c=e[16],T=e[17],x=e[18],b=e[19],_=e[20],R=e[21],u=e[22],M=e[23],k=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let I;e[84]!==p||e[85]!==_?(I=t(p,{children:_}),e[84]=p,e[85]=_,e[86]=I):I=e[86];let D;e[87]!==y||e[88]!==I||e[89]!==R||e[90]!==u?(D=n(y,{"data-testid":R,children:[u,I]}),e[87]=y,e[88]=I,e[89]=R,e[90]=u,e[91]=D):D=e[91];let S;e[92]!==q||e[93]!==D||e[94]!==M?(S=t(q,{className:M,children:D}),e[92]=q,e[93]=D,e[94]=M,e[95]=S):S=e[95];let N;e[96]!==C||e[97]!==S||e[98]!==k?(N=t(C,{className:k,children:S}),e[96]=C,e[97]=S,e[98]=k,e[99]=N):N=e[99];let A;return e[100]!==c||e[101]!==T||e[102]!==x||e[103]!==N?(A=n("section",{className:c,"data-testid":T,children:[x,N]}),e[100]=c,e[101]=T,e[102]=x,e[103]=N,e[104]=A):A=e[104],A},tr=i=>{const e=Le(74),{aggregate:a,shardResults:s}=i,r=xe();let f;e[0]!==r?(f=r("Shards"),e[0]=r,e[1]=f):f=e[1];let o;e[2]!==a.failed||e[3]!==a.reachable||e[4]!==r?(o=a.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:a.failed,reachable:a.reachable}):r("{reachable} reachable",{reachable:a.reachable}),e[2]=a.failed,e[3]=a.reachable,e[4]=r,e[5]=o):o=e[5];let l;e[6]!==f||e[7]!==o?(l=t(me,{label:f,testId:"mt-agg-shards",value:o}),e[6]=f,e[7]=o,e[8]=l):l=e[8];let h;e[9]!==r?(h=r("Total requests"),e[9]=r,e[10]=h):h=e[10];let v;e[11]!==a.totalRequests||e[12]!==h?(v=t(me,{label:h,testId:"mt-agg-requests",value:a.totalRequests}),e[11]=a.totalRequests,e[12]=h,e[13]=v):v=e[13];let w;e[14]!==r?(w=r("Total errors"),e[14]=r,e[15]=w):w=e[15];let g;e[16]!==a.totalErrors||e[17]!==w?(g=t(me,{label:w,testId:"mt-agg-errors",value:a.totalErrors}),e[16]=a.totalErrors,e[17]=w,e[18]=g):g=e[18];let d;e[19]!==r?(d=r("Total database size"),e[19]=r,e[20]=d):d=e[20];let p;e[21]!==a.totalDatabaseSize?(p=Xe(a.totalDatabaseSize),e[21]=a.totalDatabaseSize,e[22]=p):p=e[22];let y;e[23]!==d||e[24]!==p?(y=t(me,{label:d,testId:"mt-agg-db-size",value:p}),e[23]=d,e[24]=p,e[25]=y):y=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let C;e[28]!==a.hitRate||e[29]!==r?(C=a.hitRate===null?r("no cache configured"):`${(a.hitRate*100).toFixed(1)}%`,e[28]=a.hitRate,e[29]=r,e[30]=C):C=e[30];let c;e[31]!==q||e[32]!==C?(c=t(me,{label:q,testId:"mt-agg-cache",value:C}),e[31]=q,e[32]=C,e[33]=c):c=e[33];let T;e[34]!==y||e[35]!==c||e[36]!==l||e[37]!==v||e[38]!==g?(T=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[l,v,g,y,c]}),e[34]=y,e[35]=c,e[36]=l,e[37]=v,e[38]=g,e[39]=T):T=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=t(de,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let R;e[46]!==_?(R=t(de,{children:_}),e[46]=_,e[47]=R):R=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let M;e[50]!==u?(M=t(de,{children:u}),e[50]=u,e[51]=M):M=e[51];let k;e[52]!==r?(k=r("db size"),e[52]=r,e[53]=k):k=e[53];let I;e[54]!==k?(I=t(de,{children:k}),e[54]=k,e[55]=I):I=e[55];let D;e[56]!==b||e[57]!==R||e[58]!==M||e[59]!==I?(D=t(ct,{children:n(Ve,{children:[b,R,M,I]})}),e[56]=b,e[57]=R,e[58]=M,e[59]=I,e[60]=D):D=e[60];let S;if(e[61]!==s||e[62]!==r){let z;e[64]!==r?(z=O=>n(Ve,{"data-testid":`mt-agg-row-${O.shard}`,children:[t(oe,{children:O.shard}),O.metrics===null?t(oe,{className:"text-destructive",colSpan:3,children:O.error??r("unreachable")}):n(Ye,{children:[t(oe,{className:"tabular-nums",children:O.metrics.requests}),t(oe,{className:"tabular-nums",children:O.metrics.errors}),t(oe,{className:"tabular-nums",children:Xe(O.metrics.databaseSize)})]})]},O.shard),e[64]=r,e[65]=z):z=e[65],S=s.map(z),e[61]=s,e[62]=r,e[63]=S}else S=e[63];let N;e[66]!==S?(N=t(dt,{children:S}),e[66]=S,e[67]=N):N=e[67];let A;e[68]!==D||e[69]!==N?(A=t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(ot,{"data-testid":"mt-agg-table",children:[D,N]})})}),e[68]=D,e[69]=N,e[70]=A):A=e[70];let F;return e[71]!==T||e[72]!==A?(F=n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[T,A]}),e[71]=T,e[72]=A,e[73]=F):F=e[73],F},rr=i=>{const e=Le(75),{currentDelta:a,errorRate:s,history:r,latencyPercentiles:f,metrics:o}=i,l=xe(),{cache:h}=o;let v;e[0]!==r||e[1]!==l?(v=r.length>=2?t(mt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=l,e[2]=v):v=e[2];let w;e[3]!==a||e[4]!==r.length||e[5]!==l?(w=r.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${a.toLocaleString()}`})," ",l("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples…")}),e[3]=a,e[4]=r.length,e[5]=l,e[6]=w):w=e[6];let g;e[7]!==l?(g=l("Requests"),e[7]=l,e[8]=g):g=e[8];let d;e[9]!==o.requests||e[10]!==v||e[11]!==w||e[12]!==g?(d=t(me,{chart:v,footer:w,label:g,testId:"mt-requests",value:o.requests}),e[9]=o.requests,e[10]=v,e[11]=w,e[12]=g,e[13]=d):d=e[13];let p;e[14]!==s||e[15]!==l?(p=l("{rate} error rate",{rate:s}),e[14]=s,e[15]=l,e[16]=p):p=e[16];let y;e[17]!==l?(y=l("Errors"),e[17]=l,e[18]=y):y=e[18];let q;e[19]!==s||e[20]!==o.errors?(q=n(Ye,{children:[o.errors," (",s,")"]}),e[19]=s,e[20]=o.errors,e[21]=q):q=e[21];let C;e[22]!==p||e[23]!==y||e[24]!==q?(C=t(me,{footer:p,label:y,testId:"mt-errors",value:q}),e[22]=p,e[23]=y,e[24]=q,e[25]=C):C=e[25];let c;e[26]!==f.p90?(c=f.p90>0?`P90 ${rt(f.p90)}`:void 0,e[26]=f.p90,e[27]=c):c=e[27];let T;e[28]!==l?(T=l("P95 latency"),e[28]=l,e[29]=T):T=e[29];let x;e[30]!==f.p95?(x=f.p95>0?rt(f.p95):"—",e[30]=f.p95,e[31]=x):x=e[31];let b;e[32]!==T||e[33]!==x||e[34]!==c?(b=t(me,{footer:c,label:T,testId:"mt-p95",value:x}),e[32]=T,e[33]=x,e[34]=c,e[35]=b):b=e[35];let _;e[36]!==h||e[37]!==l?(_=h?`${h.entries.toLocaleString()} ${l("cache entries")}`:void 0,e[36]=h,e[37]=l,e[38]=_):_=e[38];let R;e[39]!==l?(R=l("Database size"),e[39]=l,e[40]=R):R=e[40];let u;e[41]!==o.databaseSize?(u=Xe(o.databaseSize),e[41]=o.databaseSize,e[42]=u):u=e[42];let M;e[43]!==_||e[44]!==R||e[45]!==u?(M=t(me,{footer:_,label:R,testId:"mt-db-size",value:u}),e[43]=_,e[44]=R,e[45]=u,e[46]=M):M=e[46];let k;e[47]!==l?(k=l("Shard"),e[47]=l,e[48]=k):k=e[48];let I;e[49]!==o.shard||e[50]!==k?(I=t(me,{label:k,testId:"mt-shard",value:o.shard}),e[49]=o.shard,e[50]=k,e[51]=I):I=e[51];let D;e[52]!==l?(D=l("Uptime"),e[52]=l,e[53]=D):D=e[53];let S;e[54]!==o.uptimeMs?(S=Lt(o.uptimeMs),e[54]=o.uptimeMs,e[55]=S):S=e[55];let N;e[56]!==D||e[57]!==S?(N=t(me,{label:D,testId:"mt-uptime",value:S}),e[56]=D,e[57]=S,e[58]=N):N=e[58];let A;e[59]!==l?(A=l("Cache hit rate"),e[59]=l,e[60]=A):A=e[60];let F;e[61]!==h||e[62]!==l?(F=h?l("{rate} ({count} entries)",{count:h.entries,rate:Et(h.hits,h.misses)}):l("no cache configured"),e[61]=h,e[62]=l,e[63]=F):F=e[63];let z;e[64]!==A||e[65]!==F?(z=t(me,{label:A,testId:"mt-cache",value:F}),e[64]=A,e[65]=F,e[66]=z):z=e[66];let O;return e[67]!==b||e[68]!==M||e[69]!==I||e[70]!==N||e[71]!==z||e[72]!==d||e[73]!==C?(O=n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,C,b,M,I,N,z]}),e[67]=b,e[68]=M,e[69]=I,e[70]=N,e[71]=z,e[72]=d,e[73]=C,e[74]=O):O=e[74],O},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Ee=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),sr=i=>{const e=Le(3),{level:a}=i;if(a==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t(Ze,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(a==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=t("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=s):s=e[2],s},lr=(i,e)=>{const a=[...i];return a.sort((s,r)=>{switch(e){case"avgTime":return r.avgDurationMs-s.avgDurationMs;case"execCount":return r.execCount-s.execCount;case"rowsRead":return r.rowsRead-s.rowsRead;default:return r.totalDurationMs-s.totalDurationMs}}),a},ar=i=>{const e=Le(161),{queryStats:a}=i,s=xe(),[r,f]=pe("totalTime");let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=new Set,e[0]=o):o=e[0];const[l,h]=pe(o);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=k=>{k!==null&&f(k)},e[1]=v):v=e[1];const w=v;let g,d,p,y,q,C,c,T,x,b;if(e[2]!==l||e[3]!==a||e[4]!==r||e[5]!==s){p=Symbol.for("react.early_return_sentinel");e:{const k=lr(a,r);let I;e[16]!==a?(I=a.filter(ir),e[16]=a,e[17]=I):I=e[17];const D=I.length;let S;e[18]!==a?(S=a.filter(nr),e[18]=a,e[19]=S):S=e[19];const N=S.length;let A;e[20]!==a?(A=a.filter(or),e[20]=a,e[21]=A):A=e[21];const F=A.length;let z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z=$=>{h(ce=>{const V=new Set(ce);return V.has($)?V.delete($):V.add($),V})},e[22]=z):z=e[22];const O=z;if(a.length===0){let $;e[23]!==s?($=s("No query insights yet"),e[23]=s,e[24]=$):$=e[24];let ce;e[25]!==$?(ce=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:$}),e[25]=$,e[26]=ce):ce=e[26];let V;e[27]!==s?(V=s("Query insights appear once statements are executed against this shard."),e[27]=s,e[28]=V):V=e[28];let fe;e[29]!==V?(fe=t("p",{className:"mt-1 text-sm",children:V}),e[29]=V,e[30]=fe):fe=e[30];let Be;e[31]!==ce||e[32]!==fe?(Be=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[ce,fe]})})}),e[31]=ce,e[32]=fe,e[33]=Be):Be=e[33],p=Be;break e}c="space-y-4",T="qi-root";let L;e[34]!==s?(L=s("Critical queries"),e[34]=s,e[35]=L):L=e[35];let H;e[36]!==L?(H=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=H):H=e[37];let B;e[38]!==D?(B=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=B):B=e[39];let E;e[40]!==s?(E=s(">100ms avg execution"),e[40]=s,e[41]=E):E=e[41];let K;e[42]!==E?(K=t("p",{className:"text-xs text-muted-foreground",children:E}),e[42]=E,e[43]=K):K=e[43];let G;e[44]!==B||e[45]!==K?(G=n(ge,{children:[B,K]}),e[44]=B,e[45]=K,e[46]=G):G=e[46];let J;e[47]!==H||e[48]!==G?(J=n(he,{children:[H,G]}),e[47]=H,e[48]=G,e[49]=J):J=e[49];let W;e[50]!==s?(W=s("Moderate queries"),e[50]=s,e[51]=W):W=e[51];let X;e[52]!==W?(X=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==N?(Y=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:N}),e[54]=N,e[55]=Y):Y=e[55];let Z;e[56]!==s?(Z=s("50–100ms avg execution"),e[56]=s,e[57]=Z):Z=e[57];let ee;e[58]!==Z?(ee=t("p",{className:"text-xs text-muted-foreground",children:Z}),e[58]=Z,e[59]=ee):ee=e[59];let te;e[60]!==Y||e[61]!==ee?(te=n(ge,{children:[Y,ee]}),e[60]=Y,e[61]=ee,e[62]=te):te=e[62];let re;e[63]!==X||e[64]!==te?(re=n(he,{children:[X,te]}),e[63]=X,e[64]=te,e[65]=re):re=e[65];let se;e[66]!==s?(se=s("Fast queries"),e[66]=s,e[67]=se):se=e[67];let le;e[68]!==se?(le=t(Pe,{className:"pb-2",children:t(Qe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ae;e[70]!==F?(ae=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:F}),e[70]=F,e[71]=ae):ae=e[71];let ie;e[72]!==s?(ie=s("<50ms avg execution"),e[72]=s,e[73]=ie):ie=e[73];let ne;e[74]!==ie?(ne=t("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=ne):ne=e[75];let m;e[76]!==ae||e[77]!==ne?(m=n(ge,{children:[ae,ne]}),e[76]=ae,e[77]=ne,e[78]=m):m=e[78];let P;e[79]!==le||e[80]!==m?(P=n(he,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=P):P=e[81],e[82]!==J||e[83]!==re||e[84]!==P?(x=n("div",{className:"grid gap-4 md:grid-cols-3",children:[J,re,P]}),e[82]=J,e[83]=re,e[84]=P,e[85]=x):x=e[85];let Q;e[86]!==s?(Q=s("Query leaderboard"),e[86]=s,e[87]=Q):Q=e[87];let U;e[88]!==Q?(U=t("h3",{className:"text-lg font-semibold",children:Q}),e[88]=Q,e[89]=U):U=e[89];let j;e[90]!==r||e[91]!==s?(j=s("Slow queries sorted by {sortField}",{sortField:s(r)}),e[90]=r,e[91]=s,e[92]=j):j=e[92];let ue;e[93]!==j?(ue=t("p",{className:"text-sm text-muted-foreground",children:j}),e[93]=j,e[94]=ue):ue=e[94];let be;e[95]!==U||e[96]!==ue?(be=n("div",{children:[U,ue]}),e[95]=U,e[96]=ue,e[97]=be):be=e[97];let ve;e[98]!==s?(ve=s("Sort by"),e[98]=s,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=t("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==s?(Ne=s("Sort queries by"),e[102]=s,e[103]=Ne):Ne=e[103];let ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(ze=t(Qt,{}),e[104]=ze):ze=e[104];let Se;e[105]!==Ne?(Se=t(Ht,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:ze}),e[105]=Ne,e[106]=Se):Se=e[106];let we;e[107]!==s?(we=s("Total time"),e[107]=s,e[108]=we):we=e[108];let qe;e[109]!==we?(qe=t(He,{value:"totalTime",children:we}),e[109]=we,e[110]=qe):qe=e[110];let Te;e[111]!==s?(Te=s("Avg time"),e[111]=s,e[112]=Te):Te=e[112];let _e;e[113]!==Te?(_e=t(He,{value:"avgTime",children:Te}),e[113]=Te,e[114]=_e):_e=e[114];let Ce;e[115]!==s?(Ce=s("Execution count"),e[115]=s,e[116]=Ce):Ce=e[116];let Re;e[117]!==Ce?(Re=t(He,{value:"execCount",children:Ce}),e[117]=Ce,e[118]=Re):Re=e[118];let Me;e[119]!==s?(Me=s("Rows read"),e[119]=s,e[120]=Me):Me=e[120];let ke;e[121]!==Me?(ke=t(He,{value:"rowsRead",children:Me}),e[121]=Me,e[122]=ke):ke=e[122];let Ie;e[123]!==qe||e[124]!==_e||e[125]!==Re||e[126]!==ke?(Ie=n(Ut,{children:[qe,_e,Re,ke]}),e[123]=qe,e[124]=_e,e[125]=Re,e[126]=ke,e[127]=Ie):Ie=e[127];let De;e[128]!==r||e[129]!==Se||e[130]!==Ie?(De=n(jt,{onValueChange:w,value:r,children:[Se,Ie]}),e[128]=r,e[129]=Se,e[130]=Ie,e[131]=De):De=e[131];let $e;e[132]!==ye||e[133]!==De?($e=n("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=$e):$e=e[134],e[135]!==be||e[136]!==$e?(b=n("div",{className:"flex items-center justify-between",children:[be,$e]}),e[135]=be,e[136]=$e,e[137]=b):b=e[137],d=he;let Ae;e[138]!==s?(Ae=s("Statements"),e[138]=s,e[139]=Ae):Ae=e[139];let Oe;e[140]!==Ae?(Oe=t(Qe,{children:Ae}),e[140]=Ae,e[141]=Oe):Oe=e[141],C=n(Pe,{children:[Oe,t(Mt,{children:s("{count} tracked statements",{count:k.length})})]}),g=ge,y="space-y-2";let Ke;e[142]!==l||e[143]!==s?(Ke=$=>{const ce=$.normalizedSql,V=l.has(ce),fe=Ge($.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":V,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{O(ce)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(sr,{level:fe}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:$.normalizedSql})]}),n("div",{className:"flex shrink-0 items-center gap-4",children:[n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("avg")})]}),$.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ee($.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:s("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Ue($.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:s("calls")})]})]})]}),V&&n("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[n("div",{children:[t("p",{className:"mb-2 text-sm font-medium",children:s("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:$.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[$.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:s("p50")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Ee($.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:s("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Ue($.rowsWritten)})]})]})]})]},ce)},e[142]=l,e[143]=s,e[144]=Ke):Ke=e[144],q=k.map(Ke)}e[2]=l,e[3]=a,e[4]=r,e[5]=s,e[6]=g,e[7]=d,e[8]=p,e[9]=y,e[10]=q,e[11]=C,e[12]=c,e[13]=T,e[14]=x,e[15]=b}else g=e[6],d=e[7],p=e[8],y=e[9],q=e[10],C=e[11],c=e[12],T=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==y||e[146]!==q?(_=t("div",{className:y,children:q}),e[145]=y,e[146]=q,e[147]=_):_=e[147];let R;e[148]!==g||e[149]!==_?(R=t(g,{children:_}),e[148]=g,e[149]=_,e[150]=R):R=e[150];let u;e[151]!==d||e[152]!==R||e[153]!==C?(u=n(d,{children:[C,R]}),e[151]=d,e[152]=R,e[153]=C,e[154]=u):u=e[154];let M;return e[155]!==u||e[156]!==c||e[157]!==T||e[158]!==x||e[159]!==b?(M=n("div",{className:c,"data-testid":T,children:[x,b,u]}),e[155]=u,e[156]=c,e[157]=T,e[158]=x,e[159]=b,e[160]=M):M=e[160],M};function ir(i){return Ge(i.avgDurationMs)==="critical"}function nr(i){return Ge(i.avgDurationMs)==="warning"}function or(i){return Ge(i.avgDurationMs)==="good"}const cr=["1m","5m","15m","1h"],dr=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),mr=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:dr(e.bucketMs)})),ur=({shardKey:i=""})=>{const e=xe(),[a,s]=pe("15m"),f=je(Fe.getQueryInsights,{range:a},{live:!0,shardKey:i}).data,o=mr(f?.buckets??[]);return n("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cr.map(l=>t("button",{"aria-pressed":l===a,className:Pt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",l===a&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${l}`,onClick:()=>{s(l)},type:"button",children:l},l))}),f?.capped===!0&&t(Ze,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),o.length===0?t(Bt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):n("div",{className:"grid gap-4 lg:grid-cols-2",children:[n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),t(st,{height:140,width:"100%",children:n(Ft,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),n("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[t("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),t(st,{height:140,width:"100%",children:n(Ot,{data:o,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(at,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{fontSize:10,tickLine:!1,width:32}),t(nt,{}),t(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(ar,{queryStats:f?.entries??[]})]})},fr=Tt(Fe.getMetrics),hr=(i,e)=>i?e:"overview",Qr=({initialShardKey:i})=>{const e=ht(),a=xe(),{queryShardKey:s,setShardKey:r,shardKey:f}=vt(i),[o,l]=pe("overview"),[h,v]=pe([]),w=Je(null),g=Je(null),d=Je(!0);et(()=>(d.current=!0,()=>{d.current=!1}),[]);const p=bt(s),{data:y,error:q,liveError:C}=je(Fe.getMetrics,{},{live:!0,shardKey:s}),c=y??null;et(()=>{if(y===void 0)return;_t(s);const L=y,H=w.current,B=g.current!==null&&g.current!==L.shard;if(g.current=L.shard,w.current=L.requests,B){v([]);return}H!==null&&L.requests>=H&&v(E=>[...E,L.requests-H].slice(-30))},[y,s]);const[T,x]=pe(null),[b,_]=pe(!1),R=async()=>{_(!0);const L=f,H=At(L,Ct());try{const B=await Promise.all(H.map(async E=>{try{const K=await e.query(fr,{},wt(E));return{error:null,metrics:K,shard:E===""?K.shard:E}}catch(K){return{error:qt(K),metrics:null,shard:E===""?"__root__":E}}}));d.current&&x({results:B,shard:L})}finally{d.current&&_(!1)}},u=T?.shard===f?T.results:null,M=u===null?null:It(u),k=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,I=h.length>0?h.at(-1):0,D=c?Dt(c):{p90:0,p95:0},S=gt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[c]),N=hr(S!==void 0,o),A=()=>{St(R())},F=()=>{x(null)},z=()=>{l("overview")},O=()=>{l("query-insights")};return n("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[n("div",{className:"flex flex-wrap items-center gap-2",children:[t(xt,{onChange:r,testId:"mt-shard-input",value:f}),t(pt,{message:C,prefix:"mt"}),t(tt,{"data-testid":"mt-aggregate",disabled:b,onClick:A,size:"sm",type:"button",variant:"secondary",children:a(b?"Aggregating…":"All shards")}),u!==null&&t(tt,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:a("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:a("Open in Cloudflare")})]}),q!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),S!==void 0&&n("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[t("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:z,type:"button",children:a("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:O,type:"button",children:[a("Query insights"),S.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:S.length})]})]}),N==="query-insights"&&S!==void 0&&t(ur,{shardKey:s}),N==="overview"&&c!==null&&t(rr,{currentDelta:I,errorRate:k,history:h,latencyPercentiles:D,metrics:c}),N==="overview"&&c===null&&null,N==="overview"&&t(er,{onOpenTrace:p,shardKey:s}),N==="overview"&&M!==null&&u!==null&&t(tr,{aggregate:M,shardResults:u})]})};export{Qr as MetricsPanel};
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-Dr4RMEID.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-B2jU5P5u.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ee}from"../packem_shared/internal-S7SDbbPa.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
1
+ import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as ee}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
@@ -1 +1 @@
1
- import{c as Ke}from"react/compiler-runtime";import{useLunora as We}from"@lunora/react";import{useState as k,useEffect as Xe}from"react";import{ConfirmButton as Ee}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as Ye}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as et}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Pe}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs";import{u as rt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{useT as qe}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as De,d as _e,i as Fe,b as Ae,f as we}from"../packem_shared/internal-S7SDbbPa.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Le=De(ze.getPitrBookmark),st=De(ze.pitrRestore),ot=/^\d+$/u,$e=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=qe();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=$e(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=We(),t=qe(),r=u??"",f=rt(r),[v,y]=k(null),[p,je]=k(""),[de,Me]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Oe]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Le,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Ae(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Oe(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return we(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),Xe(ue,pe);let he;e[6]!==l||e[7]!==r?(he=()=>{we((async()=>{try{const o=await l.query(Le,{},_e(r));y(o.current)}catch{}})())},e[6]=l,e[7]=r,e[8]=he):he=e[8],tt(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{je(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=$e(p),C=()=>{if(m===void 0)return;const c=r;we((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Le,{time:m.epochMs},_e(c))}}catch(N){a={error:Ae(N)}}f.current===c&&("result"in a?(Me(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Me(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{we((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Ae(N)),Fe(N)==="PITR_UNAVAILABLE"&&Oe(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const Ce=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Te=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Be=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let L;e[53]!==me?(L=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=L):L=e[54];let M;e[55]!==t?(M=t("Current bookmark"),e[55]=t,e[56]=M):M=e[56];let O;e[57]!==M?(O=s("h3",{className:"mb-2 text-sm font-semibold",children:M}),e[57]=M,e[58]=O):O=e[58];let E;e[59]!==v?(E=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=E):E=e[60];let U;e[61]!==E?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:E}),e[61]=E,e[62]=U):U=e[62];let F;e[63]!==O||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[O,U]}),e[63]=O,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let q;e[68]!==K?(q=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=q):q=e[69];let z;e[70]!==t?(z=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=z):z=e[71];let D;e[72]!==z?(D=s(Pe,{htmlFor:"pitr-time",children:z}),e[72]=z,e[73]=D):D=e[73];let $;e[74]!==p?($=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=$):$=e[75];const Ie=ce||w||m===void 0;let j;e[76]!==t?(j=t("Preview"),e[76]=t,e[77]=j):j=e[77];let H;e[78]!==C||e[79]!==Ie||e[80]!==j?(H=s(et,{"data-testid":"pitr-preview",disabled:Ie,onClick:C,size:"sm",type:"button",variant:"outline",children:j}),e[78]=C,e[79]=Ie,e[80]=j,e[81]=H):H=e[81];let V;e[82]!==$||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[$,H]}),e[82]=$,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==D||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[D,V,G,Z]}),e[90]=D,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Pe,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Pe,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Se=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==Ce||e[117]!==Te||e[118]!==Se||e[119]!==oe?(le=s("div",{children:s(Ee,{confirmLabel:Ce,disabled:Se,onConfirm:Te,testId:"pitr-restore",children:oe})}),e[116]=Ce,e[117]=Te,e[118]=Se,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==q||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[q,J,ee,se,le]}),e[121]=q,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Be||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Ye,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Ee,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Be,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Be,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==L||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,L,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=L,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
1
+ import{c as Ke}from"react/compiler-runtime";import{useLunora as We}from"@lunora/react";import{useState as k,useEffect as Xe}from"react";import{ConfirmButton as Ee}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as Ye}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as et}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as tt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{u as rt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Le=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=We(),t=je(),r=u??"",f=rt(r),[v,y]=k(null),[p,$e]=k(""),[de,Me]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Oe]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Le,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Oe(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),Xe(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Le,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],tt(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Le,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Me(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Me(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Oe(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let L;e[53]!==me?(L=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=L):L=e[54];let M;e[55]!==t?(M=t("Current bookmark"),e[55]=t,e[56]=M):M=e[56];let O;e[57]!==M?(O=s("h3",{className:"mb-2 text-sm font-semibold",children:M}),e[57]=M,e[58]=O):O=e[58];let E;e[59]!==v?(E=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=E):E=e[60];let U;e[61]!==E?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:E}),e[61]=E,e[62]=U):U=e[62];let F;e[63]!==O||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[O,U]}),e[63]=O,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(et,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Ee,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Ye,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Ee,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==L||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,L,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=L,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
@@ -1 +1 @@
1
- import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as Oe,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-S7SDbbPa.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as tt}from"@lunora/react";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as lt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-DKBYRWsL.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Oe(Me.listTables),it=Oe(Me.listTableIndexes),rt=Oe(Me.readTablePage),dt=Oe(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=tt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=lt(m),[o,u]=_(""),[i,v]=_(null),[f,L]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O={},e[1]=O):O=e[1];const[$,z]=_(O),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;L(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),L($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):L($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Le(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let L;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(L=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=L):L=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let O;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(O=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=O):O=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==O||e[28]!==C||e[29]!==u||e[30]!==L?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,L,O,C]}),e[27]=O,e[28]=C,e[29]=u,e[30]=L,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Le();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Le(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,L]=_(""),[S,G]=_(Ct),[y,O]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),L(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{L(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{O(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Le();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:L,globalTables:S,indexes:G,refresh:y,setShardKey:O,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==O||e[17]!==C?(D=l(Ze,{onChange:O,testId:"sc-shard-input",value:C}),e[16]=O,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==L||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:L===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=L,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
1
+ import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as Oe,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as tt}from"@lunora/react";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as lt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-LRfchcoA.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Oe(Me.listTables),it=Oe(Me.listTableIndexes),rt=Oe(Me.readTablePage),dt=Oe(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=tt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=lt(m),[o,u]=_(""),[i,v]=_(null),[f,L]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let O;e[1]===Symbol.for("react.memo_cache_sentinel")?(O={},e[1]=O):O=e[1];const[$,z]=_(O),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;L(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),L($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):L($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Le(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let L;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(L=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=L):L=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let O;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(O=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=O):O=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==O||e[28]!==C||e[29]!==u||e[30]!==L?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,L,O,C]}),e[27]=O,e[28]=C,e[29]=u,e[30]=L,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Le();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Le(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,L]=_(""),[S,G]=_(Ct),[y,O]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),L(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{L(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{O(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Le();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:L,globalTables:S,indexes:G,refresh:y,setShardKey:O,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==O||e[17]!==C?(D=l(Ze,{onChange:O,testId:"sc-shard-input",value:C}),e[16]=O,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==L||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:L===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=L,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
@@ -1 +1 @@
1
- import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-B2jU5P5u.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{A as f}from"../packem_shared/advisor-view-kg9uZT7H.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
1
+ import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{A as f}from"../packem_shared/advisor-view-CXiPdw4B.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
@@ -1 +1 @@
1
- import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-Dr4RMEID.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card-By2O8ULa.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-B2jU5P5u.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{C as ne}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{r as ae,u as ie,s as oe}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as d,jsx as r}from"react/jsx-runtime";const de={binding:"outline",secret:"destructive",var:"secondary"},ce=(s,e)=>{if(s===void 0)return[];const u=[];return s.workerUrl!==void 0&&u.push({label:e("URL"),value:s.workerUrl}),s.environment!==void 0&&u.push({label:e("Environment"),value:s.environment}),s.deploymentId!==void 0&&u.push({label:e("Deployment"),value:s.deploymentId}),s.versionTag!==void 0&&u.push({label:e("Version"),value:s.versionTag}),u},z=s=>{const e=G(18),{modifier:u,name:t,label:p}=s,F=ie();let b;e[0]!==t?(b=a=>{if(!["Escape","Tab"].includes(a.key)){if(a.shiftKey){a.preventDefault();return}a.preventDefault(),oe(t,a.key)}},e[0]=t,e[1]=b):b=e[1];const c=b,m=`set-shortcut-${t}`;let f;e[2]!==p?(f=r("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=f):f=e[3];let h;e[4]!==u?(h=r("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];const n=`set-shortcut-input-${t}`,x=F[t];let i;e[6]!==p||e[7]!==c||e[8]!==n||e[9]!==x?(i=r("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":n,onKeyDown:c,readOnly:!0,value:x}),e[6]=p,e[7]=c,e[8]=n,e[9]=x,e[10]=i):i=e[10];let l;e[11]!==h||e[12]!==i?(l=d("dd",{className:"flex items-center gap-1.5",children:[h,i]}),e[11]=h,e[12]=i,e[13]=l):l=e[13];let o;return e[14]!==m||e[15]!==f||e[16]!==l?(o=d("div",{className:"contents","data-testid":m,children:[f,l]}),e[14]=m,e[15]=f,e[16]=l,e[17]=o):o=e[17],o},Ce=s=>{const e=G(85),{initialShardKey:u}=s,t=se();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const F=u??"";let b;e[1]!==F?(b={shardKey:F},e[1]=F,e[2]=b):b=e[2];const{data:c,error:m,errorSource:f,isLoading:h}=re(le.getSettings,p,b);let n,x,i,l,o,a,g;if(e[3]!==m||e[4]!==f||e[5]!==c?.deploy||e[6]!==c?.settings||e[7]!==t){const q=ce(c?.deploy,t);let H;e[15]!==c?.settings?(H=c?.settings??[],e[15]=c?.settings,e[16]=H):H=e[16],n=H,x="flex flex-col gap-4",i="lunora-settings";let j;e[17]!==t?(j=t("Open in Cloudflare"),e[17]=t,e[18]=j):j=e[18],e[19]!==j?(l=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:j})}),e[19]=j,e[20]=l):l=e[20];let B;e[21]!==t?(B=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=t,e[22]=B):B=e[22],e[23]!==B?(o=r("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=o):o=e[24],e[25]!==m||e[26]!==f?(a=m!==null&&r(X,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=a):a=e[27],g=q.length>0&&d(M,{className:"py-0","data-testid":"set-deploy",children:[r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),r(P,{className:"py-3",children:r("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:q.map(me)})})]}),e[3]=m,e[4]=f,e[5]=c?.deploy,e[6]=c?.settings,e[7]=t,e[8]=n,e[9]=x,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=g}else n=e[8],x=e[9],i=e[10],l=e[11],o=e[12],a=e[13],g=e[14];let N;e[28]!==t?(N=t("Keyboard shortcuts"),e[28]=t,e[29]=N):N=e[29];let v;e[30]!==N?(v=r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[30]=N,e[31]=v):v=e[31];let y;e[32]!==t?(y=t("Reset"),e[32]=t,e[33]=y):y=e[33];let k;e[34]!==y?(k=r("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ae,type:"button",children:y}),e[34]=y,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==t?(C=t("Command palette"),e[39]=t,e[40]=C):C=e[40];let T;e[41]!==C?(T=r(z,{label:C,modifier:"⌘/Ctrl",name:"palette"}),e[41]=C,e[42]=T):T=e[42];let S;e[43]!==t?(S=t("Operation console"),e[43]=t,e[44]=S):S=e[44];let R;e[45]!==S?(R=r(z,{label:S,modifier:"Ctrl",name:"console"}),e[45]=S,e[46]=R):R=e[46];let _;e[47]!==T||e[48]!==R?(_=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[T,R]}),e[47]=T,e[48]=R,e[49]=_):_=e[49];let D;e[50]!==t?(D=t("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=t,e[51]=D):D=e[51];let E;e[52]!==D?(E=r("p",{className:"pt-3 text-xs text-muted-foreground",children:D}),e[52]=D,e[53]=E):E=e[53];let I;e[54]!==_||e[55]!==E?(I=d(P,{className:"py-3",children:[_,E]}),e[54]=_,e[55]=E,e[56]=I):I=e[56];let K;e[57]!==w||e[58]!==I?(K=d(M,{className:"py-0","data-testid":"set-preferences",children:[w,I]}),e[57]=w,e[58]=I,e[59]=K):K=e[59];let A;e[60]!==t?(A=t("Environment & bindings"),e[60]=t,e[61]=A):A=e[61];let O;e[62]!==A?(O=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[62]=A,e[63]=O):O=e[63];let U;e[64]!==m||e[65]!==h||e[66]!==n.length||e[67]!==t?(U=m===null&&!h&&n.length===0&&r("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[64]=m,e[65]=h,e[66]=n.length,e[67]=t,e[68]=U):U=e[68];let L;e[69]!==n||e[70]!==t?(L=n.length>0&&r(P,{className:"px-0 py-0",children:d(Z,{"data-testid":"set-table",children:[r(ee,{children:d(J,{children:[r(Q,{children:t("name")}),r(Q,{children:t("kind")}),r(Q,{children:t("value")})]})}),r(te,{children:n.map(fe)})]})}),e[69]=n,e[70]=t,e[71]=L):L=e[71];let $;e[72]!==O||e[73]!==U||e[74]!==L?($=d(M,{className:"py-0",children:[O,U,L]}),e[72]=O,e[73]=U,e[74]=L,e[75]=$):$=e[75];let V;return e[76]!==K||e[77]!==$||e[78]!==x||e[79]!==i||e[80]!==l||e[81]!==o||e[82]!==a||e[83]!==g?(V=d("div",{className:x,"data-testid":i,children:[l,o,a,g,K,$]}),e[76]=K,e[77]=$,e[78]=x,e[79]=i,e[80]=l,e[81]=o,e[82]=a,e[83]=g,e[84]=V):V=e[84],V};function me(s){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[r("dt",{className:"text-muted-foreground",children:s.label}),r("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}function fe(s){return d(J,{"data-testid":"set-row",children:[r(W,{className:"font-mono text-xs font-medium",children:s.name}),r(W,{children:r(Y,{variant:de[s.kind],children:s.bindingType??s.kind})}),r(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??r("span",{className:"text-muted-foreground",children:"—"})})]},s.name)}export{Ce as SettingsPanel};
1
+ import{c as G}from"react/compiler-runtime";import{E as X}from"../packem_shared/error-alert-D-ftqyo-.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as P}from"../packem_shared/card-By2O8ULa.mjs";import{T as Z,a as ee,b as J,c as Q,d as te,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-I1uILsUP.mjs";import{useT as se}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as le}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{C as ne}from"../packem_shared/cf-links-CBJ5SywP.mjs";import{r as ae,u as ie,s as oe}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as d,jsx as r}from"react/jsx-runtime";const de={binding:"outline",secret:"destructive",var:"secondary"},ce=(s,e)=>{if(s===void 0)return[];const u=[];return s.workerUrl!==void 0&&u.push({label:e("URL"),value:s.workerUrl}),s.environment!==void 0&&u.push({label:e("Environment"),value:s.environment}),s.deploymentId!==void 0&&u.push({label:e("Deployment"),value:s.deploymentId}),s.versionTag!==void 0&&u.push({label:e("Version"),value:s.versionTag}),u},z=s=>{const e=G(18),{modifier:u,name:t,label:p}=s,F=ie();let b;e[0]!==t?(b=a=>{if(!["Escape","Tab"].includes(a.key)){if(a.shiftKey){a.preventDefault();return}a.preventDefault(),oe(t,a.key)}},e[0]=t,e[1]=b):b=e[1];const c=b,m=`set-shortcut-${t}`;let f;e[2]!==p?(f=r("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=f):f=e[3];let h;e[4]!==u?(h=r("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];const n=`set-shortcut-input-${t}`,x=F[t];let i;e[6]!==p||e[7]!==c||e[8]!==n||e[9]!==x?(i=r("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":n,onKeyDown:c,readOnly:!0,value:x}),e[6]=p,e[7]=c,e[8]=n,e[9]=x,e[10]=i):i=e[10];let l;e[11]!==h||e[12]!==i?(l=d("dd",{className:"flex items-center gap-1.5",children:[h,i]}),e[11]=h,e[12]=i,e[13]=l):l=e[13];let o;return e[14]!==m||e[15]!==f||e[16]!==l?(o=d("div",{className:"contents","data-testid":m,children:[f,l]}),e[14]=m,e[15]=f,e[16]=l,e[17]=o):o=e[17],o},Ce=s=>{const e=G(85),{initialShardKey:u}=s,t=se();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];const F=u??"";let b;e[1]!==F?(b={shardKey:F},e[1]=F,e[2]=b):b=e[2];const{data:c,error:m,errorSource:f,isLoading:h}=re(le.getSettings,p,b);let n,x,i,l,o,a,g;if(e[3]!==m||e[4]!==f||e[5]!==c?.deploy||e[6]!==c?.settings||e[7]!==t){const q=ce(c?.deploy,t);let H;e[15]!==c?.settings?(H=c?.settings??[],e[15]=c?.settings,e[16]=H):H=e[16],n=H,x="flex flex-col gap-4",i="lunora-settings";let j;e[17]!==t?(j=t("Open in Cloudflare"),e[17]=t,e[18]=j):j=e[18],e[19]!==j?(l=r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:ne,rel:"noreferrer",target:"_blank",children:j})}),e[19]=j,e[20]=l):l=e[20];let B;e[21]!==t?(B=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=t,e[22]=B):B=e[22],e[23]!==B?(o=r("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=o):o=e[24],e[25]!==m||e[26]!==f?(a=m!==null&&r(X,{error:f,testId:"set-error"}),e[25]=m,e[26]=f,e[27]=a):a=e[27],g=q.length>0&&d(M,{className:"py-0","data-testid":"set-deploy",children:[r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),r(P,{className:"py-3",children:r("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:q.map(me)})})]}),e[3]=m,e[4]=f,e[5]=c?.deploy,e[6]=c?.settings,e[7]=t,e[8]=n,e[9]=x,e[10]=i,e[11]=l,e[12]=o,e[13]=a,e[14]=g}else n=e[8],x=e[9],i=e[10],l=e[11],o=e[12],a=e[13],g=e[14];let N;e[28]!==t?(N=t("Keyboard shortcuts"),e[28]=t,e[29]=N):N=e[29];let v;e[30]!==N?(v=r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[30]=N,e[31]=v):v=e[31];let y;e[32]!==t?(y=t("Reset"),e[32]=t,e[33]=y):y=e[33];let k;e[34]!==y?(k=r("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ae,type:"button",children:y}),e[34]=y,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=d("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==t?(C=t("Command palette"),e[39]=t,e[40]=C):C=e[40];let T;e[41]!==C?(T=r(z,{label:C,modifier:"⌘/Ctrl",name:"palette"}),e[41]=C,e[42]=T):T=e[42];let S;e[43]!==t?(S=t("Operation console"),e[43]=t,e[44]=S):S=e[44];let R;e[45]!==S?(R=r(z,{label:S,modifier:"Ctrl",name:"console"}),e[45]=S,e[46]=R):R=e[46];let _;e[47]!==T||e[48]!==R?(_=d("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[T,R]}),e[47]=T,e[48]=R,e[49]=_):_=e[49];let D;e[50]!==t?(D=t("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=t,e[51]=D):D=e[51];let E;e[52]!==D?(E=r("p",{className:"pt-3 text-xs text-muted-foreground",children:D}),e[52]=D,e[53]=E):E=e[53];let I;e[54]!==_||e[55]!==E?(I=d(P,{className:"py-3",children:[_,E]}),e[54]=_,e[55]=E,e[56]=I):I=e[56];let K;e[57]!==w||e[58]!==I?(K=d(M,{className:"py-0","data-testid":"set-preferences",children:[w,I]}),e[57]=w,e[58]=I,e[59]=K):K=e[59];let A;e[60]!==t?(A=t("Environment & bindings"),e[60]=t,e[61]=A):A=e[61];let O;e[62]!==A?(O=r("header",{className:"border-b border-border px-4 py-3",children:r("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A})}),e[62]=A,e[63]=O):O=e[63];let U;e[64]!==m||e[65]!==h||e[66]!==n.length||e[67]!==t?(U=m===null&&!h&&n.length===0&&r("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[64]=m,e[65]=h,e[66]=n.length,e[67]=t,e[68]=U):U=e[68];let L;e[69]!==n||e[70]!==t?(L=n.length>0&&r(P,{className:"px-0 py-0",children:d(Z,{"data-testid":"set-table",children:[r(ee,{children:d(J,{children:[r(Q,{children:t("name")}),r(Q,{children:t("kind")}),r(Q,{children:t("value")})]})}),r(te,{children:n.map(fe)})]})}),e[69]=n,e[70]=t,e[71]=L):L=e[71];let $;e[72]!==O||e[73]!==U||e[74]!==L?($=d(M,{className:"py-0",children:[O,U,L]}),e[72]=O,e[73]=U,e[74]=L,e[75]=$):$=e[75];let V;return e[76]!==K||e[77]!==$||e[78]!==x||e[79]!==i||e[80]!==l||e[81]!==o||e[82]!==a||e[83]!==g?(V=d("div",{className:x,"data-testid":i,children:[l,o,a,g,K,$]}),e[76]=K,e[77]=$,e[78]=x,e[79]=i,e[80]=l,e[81]=o,e[82]=a,e[83]=g,e[84]=V):V=e[84],V};function me(s){return d("div",{className:"contents","data-testid":"set-deploy-row",children:[r("dt",{className:"text-muted-foreground",children:s.label}),r("dd",{className:"truncate font-mono text-xs",title:s.value,children:s.value})]},s.label)}function fe(s){return d(J,{"data-testid":"set-row",children:[r(W,{className:"font-mono text-xs font-medium",children:s.name}),r(W,{children:r(Y,{variant:de[s.kind],children:s.bindingType??s.kind})}),r(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:s.value??r("span",{className:"text-muted-foreground",children:"—"})})]},s.name)}export{Ce as SettingsPanel};