@lunora/studio 1.0.0-alpha.79 → 1.0.0-alpha.80

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 (235) hide show
  1. package/dist/index.d.ts +28 -14
  2. package/dist/index.js +1 -1
  3. package/dist/mount.d.ts +1 -1
  4. package/dist/mount.js +1 -1
  5. package/dist/packem_chunks/ApiTab.js +1 -1
  6. package/dist/packem_chunks/AuditPanel.js +1 -1
  7. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.js +3 -3
  9. package/dist/packem_chunks/FileBrowser.js +4 -4
  10. package/dist/packem_chunks/FunctionRunner.js +1 -1
  11. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  12. package/dist/packem_chunks/HealthPanel.js +1 -1
  13. package/dist/packem_chunks/InsightsPanel.js +1 -1
  14. package/dist/packem_chunks/LogsPanel.js +1 -1
  15. package/dist/packem_chunks/MailPanel.js +2 -2
  16. package/dist/packem_chunks/MetricsPanel.js +1 -1
  17. package/dist/packem_chunks/NotificationsPanel.js +1 -1
  18. package/dist/packem_chunks/PitrPanel.js +1 -1
  19. package/dist/packem_chunks/SchemaViewer.js +1 -2
  20. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  21. package/dist/packem_chunks/SettingsPanel.js +1 -1
  22. package/dist/packem_chunks/SqlEditorPanel.js +6 -4
  23. package/dist/packem_chunks/TableEditor.js +1 -1
  24. package/dist/packem_chunks/agents-panel.js +1 -1
  25. package/dist/packem_chunks/analytics-panel.js +1 -1
  26. package/dist/packem_chunks/auth-audit-panel.js +1 -1
  27. package/dist/packem_chunks/auth-config-panel.js +1 -1
  28. package/dist/packem_chunks/auth-sessions-panel.js +1 -1
  29. package/dist/packem_chunks/containers-panel.js +1 -1
  30. package/dist/packem_chunks/dashboards-panel.js +1 -1
  31. package/dist/packem_chunks/fanout-panel.js +1 -1
  32. package/dist/packem_chunks/flags-panel.js +1 -1
  33. package/dist/packem_chunks/issues-panel.js +1 -1
  34. package/dist/packem_chunks/kv-browser.js +1 -1
  35. package/dist/packem_chunks/log-drains-panel.js +4 -4
  36. package/dist/packem_chunks/migrations-route.js +1 -0
  37. package/dist/packem_chunks/organizations-panel.js +1 -1
  38. package/dist/packem_chunks/payments-panel.js +1 -1
  39. package/dist/packem_chunks/permissions-panel.js +1 -1
  40. package/dist/packem_chunks/queues-panel.js +1 -1
  41. package/dist/packem_chunks/rls-panel.js +1 -1
  42. package/dist/packem_chunks/schedule-panel.js +1 -1
  43. package/dist/packem_chunks/sparkline.js +1 -1
  44. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  45. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  46. package/dist/packem_chunks/sync-client-panel.js +1 -1
  47. package/dist/packem_chunks/traces-panel.js +1 -1
  48. package/dist/packem_chunks/users-panel.js +1 -1
  49. package/dist/packem_chunks/vector-browser.js +1 -1
  50. package/dist/packem_chunks/workflows-panel.js +1 -1
  51. package/dist/packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js +1 -0
  52. package/dist/packem_shared/ApiDocsPanel-DfUQ1ZAF.js +2 -0
  53. package/dist/packem_shared/{ApiReferencePanel-C42v1jr6.js → ApiReferencePanel-9q8BbJl-.js} +1 -1
  54. package/dist/packem_shared/CommandPalette--SQwfTW1.js +1 -0
  55. package/dist/packem_shared/DataBrowser-CuRlztBz.js +1 -0
  56. package/dist/packem_shared/DataFilters-B26ZeqBZ.js +1 -0
  57. package/dist/packem_shared/GlobalDataBrowser-DB-vQ2_H.js +1 -0
  58. package/dist/packem_shared/HomePanel-Dcs4a3Ax.js +1 -0
  59. package/dist/packem_shared/MigrationsPanel-C2OnsqRb.js +1 -0
  60. package/dist/packem_shared/{OpenRpcReferencePanel-sGsIgYWj.js → OpenRpcReferencePanel-qOZcWXMs.js} +1 -1
  61. package/dist/packem_shared/ScheduledJobs-D8kBZWBu.js +1 -0
  62. package/dist/packem_shared/Studio-B26_pT8J.js +1 -0
  63. package/dist/packem_shared/StudioApp-bXhJeLlZ.js +1 -0
  64. package/dist/packem_shared/advisor-view-Pa8HLtBv.js +1 -0
  65. package/dist/packem_shared/{app.d-bRPJhby-.d.ts → app.d-DW7yZsfu.d.ts} +1 -3
  66. package/dist/packem_shared/bar-chart-DraN_srt.js +9 -0
  67. package/dist/packem_shared/data-grid-DcxyIXwG.js +1 -0
  68. package/dist/packem_shared/data-view-params-ClrV7XgF.js +1 -0
  69. package/dist/packem_shared/error-alert-t6cpEi0z.js +1 -0
  70. package/dist/packem_shared/grid-features-jnrD0SpX.js +6 -0
  71. package/dist/packem_shared/{home-panel-Cm88Nvqh.js → home-panel-CU6MWLHG.js} +2 -2
  72. package/dist/packem_shared/{internal-AtZ4bTal.js → internal-BSIsQVC6.js} +1 -1
  73. package/dist/packem_shared/live-status-CmuRLFKf.js +1 -0
  74. package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +1 -0
  75. package/dist/packem_shared/recording-client-DRAZEmzE.js +1 -0
  76. package/dist/packem_shared/reference-view-DnYYWr7I.js +12 -0
  77. package/dist/packem_shared/result-chart-DzJOVsaw.js +1 -0
  78. package/dist/packem_shared/schema-diagram-cg-bz_VL.js +2 -0
  79. package/dist/packem_shared/{sparkline-DtcZoU48.js → sparkline-CgjeUU2I.js} +1 -1
  80. package/dist/packem_shared/studio-q-C-acL7.js +2 -0
  81. package/dist/packem_shared/table-list-sidebar-BFkSQwlB.js +1 -0
  82. package/dist/packem_shared/use-admin-query-QJ-ibl5u.js +1 -0
  83. package/dist/packem_shared/use-async-submit-q3ymBJkD.js +1 -0
  84. package/dist/packem_shared/{use-auth-config-9S_K_W-G.js → use-auth-config-BObBpdsi.js} +1 -1
  85. package/dist/packem_shared/use-sql-assistant-CHEu2-Rk.js +1 -0
  86. package/dist/standalone/chunk-2GA4SHO7.js +1 -0
  87. package/dist/standalone/{chunk-NG6LYBPJ.js → chunk-2VDFV5TD.js} +1 -1
  88. package/dist/standalone/chunk-2WOIRKEI.js +1 -0
  89. package/dist/standalone/chunk-33CL6OHR.js +1 -0
  90. package/dist/standalone/{chunk-EIT7ERYE.js → chunk-34D36UCW.js} +1 -1
  91. package/dist/standalone/chunk-3C3CG7ZK.js +1 -0
  92. package/dist/standalone/{chunk-6CULAILE.js → chunk-3O3HAXW7.js} +1 -1
  93. package/dist/standalone/{chunk-LSEZN2ZL.js → chunk-3STOIE7Q.js} +1 -1
  94. package/dist/standalone/chunk-53WEPGUD.js +1 -0
  95. package/dist/standalone/chunk-5CVJS7ON.js +1 -0
  96. package/dist/standalone/chunk-6IKEW5LG.js +1 -0
  97. package/dist/standalone/chunk-6LNCYDZO.js +1 -0
  98. package/dist/standalone/chunk-6NY7SPDL.js +1 -0
  99. package/dist/standalone/chunk-6PNPIW6I.js +2 -0
  100. package/dist/standalone/{chunk-AVZGVZZ7.js → chunk-6VAKZALJ.js} +1 -1
  101. package/dist/standalone/chunk-6YI4WJO4.js +1 -0
  102. package/dist/standalone/{chunk-HYT2ZUNP.js → chunk-6YTSSIEJ.js} +2 -2
  103. package/dist/standalone/{chunk-KYF2E5CJ.js → chunk-7LWMHTJ3.js} +1 -1
  104. package/dist/standalone/chunk-A74VSSA2.js +4 -0
  105. package/dist/standalone/chunk-CCVXYYPJ.js +1 -0
  106. package/dist/standalone/chunk-CT5MMH4O.js +1 -0
  107. package/dist/standalone/chunk-CTNB2KIA.js +1 -0
  108. package/dist/standalone/chunk-CU55Y5TV.js +62 -0
  109. package/dist/standalone/chunk-D2RKH6JK.js +1 -0
  110. package/dist/standalone/chunk-E3NMX2VU.js +4 -0
  111. package/dist/standalone/chunk-FNPJ7GJZ.js +1 -0
  112. package/dist/standalone/chunk-FOBRNWBG.js +3 -0
  113. package/dist/standalone/chunk-G6PSMGLD.js +1 -0
  114. package/dist/standalone/chunk-GAX5IZYG.js +8 -0
  115. package/dist/standalone/chunk-GB6U2BPU.js +1 -0
  116. package/dist/standalone/chunk-GEDMLM4A.js +6 -0
  117. package/dist/standalone/chunk-GXSZH7VJ.js +13 -0
  118. package/dist/standalone/chunk-GYKVBKT5.js +1 -0
  119. package/dist/standalone/chunk-H6YOWRFB.js +1 -0
  120. package/dist/standalone/chunk-HJ3E4YF5.js +1 -0
  121. package/dist/standalone/chunk-HJD2YUQS.js +1 -0
  122. package/dist/standalone/chunk-IHQC7J35.js +1 -0
  123. package/dist/standalone/chunk-JLOWAJRR.js +1 -0
  124. package/dist/standalone/chunk-JRMMYIAF.js +1 -0
  125. package/dist/standalone/{chunk-W6TE2I2D.js → chunk-KC44QCN6.js} +1 -1
  126. package/dist/standalone/chunk-KJB7YAKB.js +1 -0
  127. package/dist/standalone/chunk-KLQYC6CC.js +1 -0
  128. package/dist/standalone/{chunk-XQGANNLS.js → chunk-KZ3ALMMP.js} +1 -1
  129. package/dist/standalone/chunk-L7R74G63.js +1 -0
  130. package/dist/standalone/{chunk-3RTTXLMU.js → chunk-OY2RVUZL.js} +1 -1
  131. package/dist/standalone/chunk-P4YLIBCN.js +1 -0
  132. package/dist/standalone/chunk-PZVU2QMX.js +1 -0
  133. package/dist/standalone/{chunk-PRJ4RJDU.js → chunk-Q7O6B7WC.js} +1 -1
  134. package/dist/standalone/chunk-QLQADHFE.js +1 -0
  135. package/dist/standalone/{chunk-7LQWFOEU.js → chunk-QXXIJAD5.js} +1 -1
  136. package/dist/standalone/chunk-QZGTH6WH.js +1 -0
  137. package/dist/standalone/chunk-RJP3WBZ4.js +1 -0
  138. package/dist/standalone/chunk-RNL6BSFM.js +1 -0
  139. package/dist/standalone/chunk-RNRJKBY3.js +4 -0
  140. package/dist/standalone/{chunk-7YEFOSPH.js → chunk-RQ7AFLIV.js} +1 -1
  141. package/dist/standalone/chunk-S252DAFP.js +1 -0
  142. package/dist/standalone/chunk-S2VVR7HI.js +1 -0
  143. package/dist/standalone/chunk-SKW6J4VW.js +1 -0
  144. package/dist/standalone/chunk-T7IUZIF4.js +1 -0
  145. package/dist/standalone/chunk-TTGOOYLF.js +1 -0
  146. package/dist/standalone/chunk-U6TNNM5U.js +1 -0
  147. package/dist/standalone/chunk-VHWOCPRK.js +1 -0
  148. package/dist/standalone/chunk-W6SAOXGH.js +6 -0
  149. package/dist/standalone/{chunk-YCRMVBPW.js → chunk-WBYSSCV2.js} +1 -1
  150. package/dist/standalone/{chunk-LFXFP4IF.js → chunk-X665E2HU.js} +1 -1
  151. package/dist/standalone/chunk-XDAT7LHC.js +1 -0
  152. package/dist/standalone/chunk-XS5LDR52.js +1 -0
  153. package/dist/standalone/chunk-Y5Y7DHFW.js +1 -0
  154. package/dist/standalone/chunk-YJYTMQJI.js +1 -0
  155. package/dist/standalone/chunk-Z2V42P7J.js +1 -0
  156. package/dist/standalone/studio.js +5 -5
  157. package/dist/styles.css +1 -1
  158. package/package.json +1 -1
  159. package/dist/packem_chunks/MigrationsPanel.js +0 -1
  160. package/dist/packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js +0 -1
  161. package/dist/packem_shared/ApiDocsPanel-CjdsxN1t.js +0 -2
  162. package/dist/packem_shared/CommandPalette-CVIaY3j8.js +0 -1
  163. package/dist/packem_shared/DataBrowser-Bfstz_au.js +0 -1
  164. package/dist/packem_shared/DataFilters-Csb30F0C.js +0 -1
  165. package/dist/packem_shared/GlobalDataBrowser-RLJ6NvOs.js +0 -1
  166. package/dist/packem_shared/HomePanel-B8EFM4u3.js +0 -1
  167. package/dist/packem_shared/ScheduledJobs-DUbo6epc.js +0 -1
  168. package/dist/packem_shared/Studio-BDtS9C5g.js +0 -1
  169. package/dist/packem_shared/StudioApp-DjLzIO9E.js +0 -1
  170. package/dist/packem_shared/advisor-view-DaCX9Jy5.js +0 -1
  171. package/dist/packem_shared/bar-chart-AryFCeoa.js +0 -9
  172. package/dist/packem_shared/data-grid-BMBKzMEJ.js +0 -1
  173. package/dist/packem_shared/data-view-params-C8T3bW1z.js +0 -1
  174. package/dist/packem_shared/error-alert-B59DnrDI.js +0 -1
  175. package/dist/packem_shared/grid-features-uZCUj955.js +0 -6
  176. package/dist/packem_shared/live-status-CGW2JHf_.js +0 -1
  177. package/dist/packem_shared/reference-view-KvhektwF.js +0 -12
  178. package/dist/packem_shared/result-chart-CwKhhKM0.js +0 -1
  179. package/dist/packem_shared/studio-BmWFd-Rz.js +0 -2
  180. package/dist/packem_shared/table-list-sidebar-CMCcNALK.js +0 -1
  181. package/dist/packem_shared/use-admin-query-Di3fLE8H.js +0 -1
  182. package/dist/packem_shared/use-async-submit-DLNCqLFq.js +0 -1
  183. package/dist/standalone/chunk-2SHUN7KF.js +0 -1
  184. package/dist/standalone/chunk-2Y36BVVM.js +0 -4
  185. package/dist/standalone/chunk-3EXLKL6V.js +0 -1
  186. package/dist/standalone/chunk-3KAERFMC.js +0 -1
  187. package/dist/standalone/chunk-4XDMVUS5.js +0 -1
  188. package/dist/standalone/chunk-5RF4QDDA.js +0 -6
  189. package/dist/standalone/chunk-5YWJNF5X.js +0 -1
  190. package/dist/standalone/chunk-66YJ3IOZ.js +0 -1
  191. package/dist/standalone/chunk-6KHEBRBB.js +0 -1
  192. package/dist/standalone/chunk-6WCIFGDW.js +0 -1
  193. package/dist/standalone/chunk-7RG3AKPY.js +0 -1
  194. package/dist/standalone/chunk-A2FPLOMJ.js +0 -1
  195. package/dist/standalone/chunk-AADXUXZO.js +0 -1
  196. package/dist/standalone/chunk-ARI4JTIH.js +0 -1
  197. package/dist/standalone/chunk-BDO4J5AP.js +0 -1
  198. package/dist/standalone/chunk-BMQJ4CAO.js +0 -1
  199. package/dist/standalone/chunk-CMUP7HPS.js +0 -1
  200. package/dist/standalone/chunk-CP7AUUOU.js +0 -1
  201. package/dist/standalone/chunk-DX3RMFQU.js +0 -8
  202. package/dist/standalone/chunk-E2CJUP53.js +0 -13
  203. package/dist/standalone/chunk-FLYO3XY5.js +0 -1
  204. package/dist/standalone/chunk-FWCKM2CU.js +0 -1
  205. package/dist/standalone/chunk-GITJXQOS.js +0 -4
  206. package/dist/standalone/chunk-GP6IRITM.js +0 -1
  207. package/dist/standalone/chunk-GXU3ATKS.js +0 -1
  208. package/dist/standalone/chunk-H5Y5NQPL.js +0 -1
  209. package/dist/standalone/chunk-HALNNKTC.js +0 -1
  210. package/dist/standalone/chunk-HK4OVYG3.js +0 -1
  211. package/dist/standalone/chunk-HQEMYD2K.js +0 -1
  212. package/dist/standalone/chunk-I4WGRDL2.js +0 -1
  213. package/dist/standalone/chunk-ISZSYNTI.js +0 -4
  214. package/dist/standalone/chunk-JWG3VRGB.js +0 -1
  215. package/dist/standalone/chunk-KDYNM3GV.js +0 -1
  216. package/dist/standalone/chunk-KP6JQSH2.js +0 -4
  217. package/dist/standalone/chunk-LLXFYRGQ.js +0 -1
  218. package/dist/standalone/chunk-LU3GW7HI.js +0 -1
  219. package/dist/standalone/chunk-M536Y2KX.js +0 -1
  220. package/dist/standalone/chunk-MVGE3JJN.js +0 -1
  221. package/dist/standalone/chunk-MXSHWB3M.js +0 -1
  222. package/dist/standalone/chunk-NL2DZKFI.js +0 -1
  223. package/dist/standalone/chunk-OGVCXKRL.js +0 -2
  224. package/dist/standalone/chunk-OPC233PZ.js +0 -1
  225. package/dist/standalone/chunk-P4CWOYFL.js +0 -1
  226. package/dist/standalone/chunk-PUY3YDXI.js +0 -1
  227. package/dist/standalone/chunk-QZMR6MUG.js +0 -1
  228. package/dist/standalone/chunk-WCWYSOCN.js +0 -62
  229. package/dist/standalone/chunk-WEO3YVP6.js +0 -3
  230. package/dist/standalone/chunk-X2FQ6B5V.js +0 -1
  231. package/dist/standalone/chunk-XIZNYKOD.js +0 -1
  232. package/dist/standalone/chunk-XS6Q6GGV.js +0 -1
  233. package/dist/standalone/chunk-Y3CQDULJ.js +0 -1
  234. package/dist/standalone/chunk-Z2JPEI2V.js +0 -1
  235. /package/dist/standalone/{chunk-4CGALXS3.js → chunk-OG4N2XHD.js} +0 -0
@@ -1 +1 @@
1
- import{c as Fe}from"react/compiler-runtime";import{useLunora as lt}from"@lunora/react";import{useNavigate as st}from"@tanstack/react-router";import{useState as ge,useRef as Ke,useEffect as Be,useMemo as nt}from"react";import{L as it}from"../packem_shared/live-status-CGW2JHf_.js";import{ShardInput as ot}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as Ve}from"../packem_shared/button-BkCrNcAs.js";import{c as he,u as fe,n as Te,f as Re,m as ct}from"../packem_shared/card-CIDGUN6K.js";import{p as ie,d as Xe,m as Ae,u as ae,n as Ye,f as Ze}from"../packem_shared/table-DdJBrClo.js";import{K as He}from"../packem_shared/use-admin-query-Di3fLE8H.js";import dt from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ee}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{c as mt}from"../packem_shared/cf-links-gbDy51nR.js";import{l as ut,k as Pe,f as Ge,c as ht,e as gt,a as ft}from"../packem_shared/internal-AtZ4bTal.js";import{r as xt,l as pt}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as bt}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{f as vt}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{S as tt}from"../packem_shared/sparkline-DtcZoU48.js";import{jsx as t,jsxs as n,Fragment as Ue}from"react/jsx-runtime";import{aggregateMetrics as Nt,computeLatencyPercentiles as yt,enrichQueryStats as $t,shardsToAggregate as wt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{N as St,y as qt,k as De,_ as kt,w as _t}from"../packem_shared/select-Bul-DeII.js";const Mt=(s,e)=>s<e?-1:s>e?1:0,We=s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s))return`[${s.map(p=>We(p)).join(",")}]`;const e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){const p=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${p} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const l=s,r=Object.keys(l).toSorted(Mt),a=[];for(const p of r){const b=l[p];b!==void 0&&a.push(`${JSON.stringify(p)}:${We(b)}`)}return`{${a.join(",")}}`},rt=(s,e,l)=>`${s}:${e}:${We(l??{})}`,at=(s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,It=(s,e)=>at(s,e),Ft=s=>at(s.kind,s),Je=s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),Ct=s=>Array.isArray(s?.series)?s.series:[],Ot="FUNCTION_NOT_FOUND",Tt=s=>{const e=new Map;if(!Array.isArray(s?.series))return e;for(const l of s.series)e.set(rt(l.kind,l.name,l.attributes),l.points);return e},Rt={counter:"secondary",gauge:"default",histogram:"outline"},Dt=s=>{const e=Fe(18),{name:l,onOpenTrace:r,traceId:a}=s,p=Ee();if(a===void 0){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=m):m=e[0],m}let b;e[1]!==a?(b=a.slice(0,8),e[1]=a,e[2]=b):b=e[2];const f=b;if(r===void 0){const m=`mt-instrument-trace-${l}`;let N;return e[3]!==f||e[4]!==m||e[5]!==a?(N=t("span",{className:"text-muted-foreground","data-testid":m,title:a,children:f}),e[3]=f,e[4]=m,e[5]=a,e[6]=N):N=e[6],N}const h=`mt-instrument-trace-${l}`;let g;e[7]!==r||e[8]!==a?(g=()=>{r(a)},e[7]=r,e[8]=a,e[9]=g):g=e[9];let v;e[10]!==p||e[11]!==a?(v=p("Open the exemplar trace {trace}",{trace:a}),e[10]=p,e[11]=a,e[12]=v):v=e[12];let u;return e[13]!==f||e[14]!==h||e[15]!==g||e[16]!==v?(u=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":h,onClick:g,title:v,type:"button",children:f}),e[13]=f,e[14]=h,e[15]=g,e[16]=v,e[17]=u):u=e[17],u},Lt=s=>{const e=Fe(105),{onOpenTrace:l,shardKey:r}=s,a=Ee();let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let b;e[1]!==r?(b={live:!0,shardKey:r},e[1]=r,e[2]=b):b=e[2];const{data:f,error:h,errorSource:g}=He(ze.getMetricSeries,p,b);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={},e[3]=v):v=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:m}=He(ze.getMetricHistory,v,u);let N,le,O,j,K,c,S,se,T,R,I,x,D;if(e[6]!==f||e[7]!==h||e[8]!==g||e[9]!==m||e[10]!==l||e[11]!==a){se=Symbol.for("react.early_return_sentinel");e:{const oe=Ct(f),de=ut(g)===Ot;if(h!==null&&!de){let o;e[25]!==a?(o=a("Instruments"),e[25]=a,e[26]=o):o=e[26];let F;e[27]!==o?(F=t("h3",{className:"text-sm font-semibold text-foreground",children:o}),e[27]=o,e[28]=F):F=e[28];let A;e[29]!==h||e[30]!==a?(A=a("Instruments unavailable: {error}",{error:h}),e[29]=h,e[30]=a,e[31]=A):A=e[31];let z;e[32]!==A?(z=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:A}),e[32]=A,e[33]=z):z=e[33];let re;e[34]!==F||e[35]!==z?(re=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[F,z]}),e[34]=F,e[35]=z,e[36]=re):re=e[36],se=re;break e}if(oe.length===0){se=null;break e}const me=Tt(m);let P;e[37]!==a?(P=o=>a(o==="counter"?"Counter":o==="gauge"?"Gauge":"Histogram"),e[37]=a,e[38]=P):P=e[38];const i=P;K="flex flex-col gap-2",c="mt-instruments";let k;e[39]!==a?(k=a("Instruments"),e[39]=a,e[40]=k):k=e[40],e[41]!==k?(S=t("h3",{className:"text-sm font-semibold text-foreground",children:k}),e[41]=k,e[42]=S):S=e[42],j=he,D="overflow-hidden py-0",O=fe,x="px-0",le=Ye,R="mt-instruments-table";let y;e[43]!==a?(y=a("name"),e[43]=a,e[44]=y):y=e[44];let w;e[45]!==y?(w=t(ie,{children:y}),e[45]=y,e[46]=w):w=e[46];let U;e[47]!==a?(U=a("kind"),e[47]=a,e[48]=U):U=e[48];let J;e[49]!==U?(J=t(ie,{children:U}),e[49]=U,e[50]=J):J=e[50];let Q;e[51]!==a?(Q=a("value"),e[51]=a,e[52]=Q):Q=e[52];let H;e[53]!==Q?(H=t(ie,{className:"text-right",children:Q}),e[53]=Q,e[54]=H):H=e[54];let W;e[55]!==a?(W=a("count"),e[55]=a,e[56]=W):W=e[56];let B;e[57]!==W?(B=t(ie,{className:"text-right",children:W}),e[57]=W,e[58]=B):B=e[58];let V;e[59]!==a?(V=a("range"),e[59]=a,e[60]=V):V=e[60];let G;e[61]!==V?(G=t(ie,{className:"text-right",children:V}),e[61]=V,e[62]=G):G=e[62];let X;e[63]!==a?(X=a("trend"),e[63]=a,e[64]=X):X=e[64];let Y;e[65]!==X?(Y=t(ie,{children:X}),e[65]=X,e[66]=Y):Y=e[66];let Z;e[67]!==a?(Z=a("trace"),e[67]=a,e[68]=Z):Z=e[68];let ee;e[69]!==Z?(ee=t(ie,{children:Z}),e[69]=Z,e[70]=ee):ee=e[70];let ce;e[71]!==a?(ce=a("dimensions"),e[71]=a,e[72]=ce):ce=e[72];let te;e[73]!==ce?(te=t(ie,{children:ce}),e[73]=ce,e[74]=te):te=e[74],e[75]!==w||e[76]!==J||e[77]!==H||e[78]!==B||e[79]!==G||e[80]!==Y||e[81]!==ee||e[82]!==te?(I=t(Xe,{children:n(Ae,{children:[w,J,H,B,G,Y,ee,te]})}),e[75]=w,e[76]=J,e[77]=H,e[78]=B,e[79]=G,e[80]=Y,e[81]=ee,e[82]=te,e[83]=I):I=e[83],N=Ze,T=oe.map(o=>{const F=vt(o.attributes),A=rt(o.kind,o.name,o.attributes),z=(me.get(A)??[]).map(re=>It(o.kind,re));return n(Ae,{"data-testid":`mt-instrument-${o.name}`,children:[t(ae,{className:"font-mono text-xs",title:o.functionPath,children:o.name}),t(ae,{children:t(et,{variant:Rt[o.kind],children:i(o.kind)})}),t(ae,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${o.name}`,children:Je(Ft(o))}),t(ae,{className:"text-right tabular-nums text-muted-foreground",children:o.count.toLocaleString()}),t(ae,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:o.min===o.max?"—":`${Je(o.min)}–${Je(o.max)}`}),t(ae,{children:z.length>=2?t(tt,{ariaLabel:a("{name} trend",{name:o.name}),className:"h-6 w-24 text-foreground",series:z,testId:`mt-instrument-trend-${o.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(ae,{className:"font-mono text-xs",children:t(Dt,{name:o.name,onOpenTrace:l,traceId:o.exemplarTraceId})}),t(ae,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:F,children:F===""?"—":F})]},A)})}e[6]=f,e[7]=h,e[8]=g,e[9]=m,e[10]=l,e[11]=a,e[12]=N,e[13]=le,e[14]=O,e[15]=j,e[16]=K,e[17]=c,e[18]=S,e[19]=se,e[20]=T,e[21]=R,e[22]=I,e[23]=x,e[24]=D}else N=e[12],le=e[13],O=e[14],j=e[15],K=e[16],c=e[17],S=e[18],se=e[19],T=e[20],R=e[21],I=e[22],x=e[23],D=e[24];if(se!==Symbol.for("react.early_return_sentinel"))return se;let E;e[84]!==N||e[85]!==T?(E=t(N,{children:T}),e[84]=N,e[85]=T,e[86]=E):E=e[86];let M;e[87]!==le||e[88]!==E||e[89]!==R||e[90]!==I?(M=n(le,{"data-testid":R,children:[I,E]}),e[87]=le,e[88]=E,e[89]=R,e[90]=I,e[91]=M):M=e[91];let L;e[92]!==O||e[93]!==M||e[94]!==x?(L=t(O,{className:x,children:M}),e[92]=O,e[93]=M,e[94]=x,e[95]=L):L=e[95];let $;e[96]!==j||e[97]!==L||e[98]!==D?($=t(j,{className:D,children:L}),e[96]=j,e[97]=L,e[98]=D,e[99]=$):$=e[99];let q;return e[100]!==K||e[101]!==c||e[102]!==S||e[103]!==$?(q=n("section",{className:K,"data-testid":c,children:[S,$]}),e[100]=K,e[101]=c,e[102]=S,e[103]=$,e[104]=q):q=e[104],q},je=s=>s>=100?"critical":s>=50?"warning":"good",Qe=s=>s<1?`${(s*1e3).toFixed(0)}μs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,Le=s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),At=s=>{const e=Fe(3),{level:l}=s;if(l==="critical"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t(et,{variant:"destructive",children:"Slow"}),e[0]=a):a=e[0],a}if(l==="warning"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=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]=a):a=e[1],a}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=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]=r):r=e[2],r},zt=s=>{const e=Fe(152),{queryStats:l}=s,r=Ee(),[a,p]=ge("totalTime");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=new Set,e[0]=b):b=e[0];const[f,h]=ge(b);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=d=>{d!==null&&p(d)},e[1]=g):g=e[1];const v=g;let u;if(e[2]!==l||e[3]!==a){u=[...l];let d;e[5]!==a?(d=(C,_)=>{switch(a){case"avgTime":return _.avgDurationMs-C.avgDurationMs;case"execCount":return _.execCount-C.execCount;case"rowsRead":return _.rowsRead-C.rowsRead;default:return _.totalDurationMs-C.totalDurationMs}},e[5]=a,e[6]=d):d=e[6],u.sort(d),e[2]=l,e[3]=a,e[4]=u}else u=e[4];const m=u;let N;e[7]!==l?(N=l.filter(Et),e[7]=l,e[8]=N):N=e[8];const le=N.length;let O;e[9]!==l?(O=l.filter(jt),e[9]=l,e[10]=O):O=e[10];const j=O.length;let K;e[11]!==l?(K=l.filter(Kt),e[11]=l,e[12]=K):K=e[12];const c=K.length;let S;e[13]===Symbol.for("react.memo_cache_sentinel")?(S=d=>{h(C=>{const _=new Set(C);return _.has(d)?_.delete(d):_.add(d),_})},e[13]=S):S=e[13];const se=S;if(l.length===0){let d;e[14]!==r?(d=r("No query insights yet"),e[14]=r,e[15]=d):d=e[15];let C;e[16]!==d?(C=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:d}),e[16]=d,e[17]=C):C=e[17];let _;e[18]!==r?(_=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=_):_=e[19];let ue;e[20]!==_?(ue=t("p",{className:"mt-1 text-sm",children:_}),e[20]=_,e[21]=ue):ue=e[21];let Oe;return e[22]!==ue||e[23]!==C?(Oe=t(he,{children:t(fe,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[C,ue]})})}),e[22]=ue,e[23]=C,e[24]=Oe):Oe=e[24],Oe}let T;e[25]!==r?(T=r("Critical queries"),e[25]=r,e[26]=T):T=e[26];let R;e[27]!==T?(R=t(Te,{className:"pb-2",children:t(Re,{className:"text-sm font-medium",children:T})}),e[27]=T,e[28]=R):R=e[28];let I;e[29]!==le?(I=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:le}),e[29]=le,e[30]=I):I=e[30];let x;e[31]!==r?(x=r(">100ms avg execution"),e[31]=r,e[32]=x):x=e[32];let D;e[33]!==x?(D=t("p",{className:"text-xs text-muted-foreground",children:x}),e[33]=x,e[34]=D):D=e[34];let E;e[35]!==D||e[36]!==I?(E=n(fe,{children:[I,D]}),e[35]=D,e[36]=I,e[37]=E):E=e[37];let M;e[38]!==E||e[39]!==R?(M=n(he,{children:[R,E]}),e[38]=E,e[39]=R,e[40]=M):M=e[40];let L;e[41]!==r?(L=r("Moderate queries"),e[41]=r,e[42]=L):L=e[42];let $;e[43]!==L?($=t(Te,{className:"pb-2",children:t(Re,{className:"text-sm font-medium",children:L})}),e[43]=L,e[44]=$):$=e[44];let q;e[45]!==j?(q=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:j}),e[45]=j,e[46]=q):q=e[46];let oe;e[47]!==r?(oe=r("50–100ms avg execution"),e[47]=r,e[48]=oe):oe=e[48];let de;e[49]!==oe?(de=t("p",{className:"text-xs text-muted-foreground",children:oe}),e[49]=oe,e[50]=de):de=e[50];let me;e[51]!==q||e[52]!==de?(me=n(fe,{children:[q,de]}),e[51]=q,e[52]=de,e[53]=me):me=e[53];let P;e[54]!==$||e[55]!==me?(P=n(he,{children:[$,me]}),e[54]=$,e[55]=me,e[56]=P):P=e[56];let i;e[57]!==r?(i=r("Fast queries"),e[57]=r,e[58]=i):i=e[58];let k;e[59]!==i?(k=t(Te,{className:"pb-2",children:t(Re,{className:"text-sm font-medium",children:i})}),e[59]=i,e[60]=k):k=e[60];let y;e[61]!==c?(y=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:c}),e[61]=c,e[62]=y):y=e[62];let w;e[63]!==r?(w=r("<50ms avg execution"),e[63]=r,e[64]=w):w=e[64];let U;e[65]!==w?(U=t("p",{className:"text-xs text-muted-foreground",children:w}),e[65]=w,e[66]=U):U=e[66];let J;e[67]!==y||e[68]!==U?(J=n(fe,{children:[y,U]}),e[67]=y,e[68]=U,e[69]=J):J=e[69];let Q;e[70]!==k||e[71]!==J?(Q=n(he,{children:[k,J]}),e[70]=k,e[71]=J,e[72]=Q):Q=e[72];let H;e[73]!==M||e[74]!==P||e[75]!==Q?(H=n("div",{className:"grid gap-4 md:grid-cols-3",children:[M,P,Q]}),e[73]=M,e[74]=P,e[75]=Q,e[76]=H):H=e[76];let W;e[77]!==r?(W=r("Query leaderboard"),e[77]=r,e[78]=W):W=e[78];let B;e[79]!==W?(B=t("h3",{className:"text-lg font-semibold",children:W}),e[79]=W,e[80]=B):B=e[80];let V;e[81]!==a||e[82]!==r?(V=r("Slow queries sorted by {sortField}",{sortField:r(a)}),e[81]=a,e[82]=r,e[83]=V):V=e[83];let G;e[84]!==V?(G=t("p",{className:"text-sm text-muted-foreground",children:V}),e[84]=V,e[85]=G):G=e[85];let X;e[86]!==B||e[87]!==G?(X=n("div",{children:[B,G]}),e[86]=B,e[87]=G,e[88]=X):X=e[88];let Y;e[89]!==r?(Y=r("Sort by"),e[89]=r,e[90]=Y):Y=e[90];let Z;e[91]!==Y?(Z=t("span",{className:"text-sm text-muted-foreground",children:Y}),e[91]=Y,e[92]=Z):Z=e[92];let ee;e[93]!==r?(ee=r("Sort queries by"),e[93]=r,e[94]=ee):ee=e[94];let ce;e[95]===Symbol.for("react.memo_cache_sentinel")?(ce=t(St,{}),e[95]=ce):ce=e[95];let te;e[96]!==ee?(te=t(qt,{"aria-label":ee,className:"w-[140px]","data-testid":"qi-sort",children:ce}),e[96]=ee,e[97]=te):te=e[97];let o;e[98]!==r?(o=r("Total time"),e[98]=r,e[99]=o):o=e[99];let F;e[100]!==o?(F=t(De,{value:"totalTime",children:o}),e[100]=o,e[101]=F):F=e[101];let A;e[102]!==r?(A=r("Avg time"),e[102]=r,e[103]=A):A=e[103];let z;e[104]!==A?(z=t(De,{value:"avgTime",children:A}),e[104]=A,e[105]=z):z=e[105];let re;e[106]!==r?(re=r("Execution count"),e[106]=r,e[107]=re):re=e[107];let xe;e[108]!==re?(xe=t(De,{value:"execCount",children:re}),e[108]=re,e[109]=xe):xe=e[109];let pe;e[110]!==r?(pe=r("Rows read"),e[110]=r,e[111]=pe):pe=e[111];let be;e[112]!==pe?(be=t(De,{value:"rowsRead",children:pe}),e[112]=pe,e[113]=be):be=e[113];let ve;e[114]!==F||e[115]!==z||e[116]!==xe||e[117]!==be?(ve=n(kt,{children:[F,z,xe,be]}),e[114]=F,e[115]=z,e[116]=xe,e[117]=be,e[118]=ve):ve=e[118];let Ne;e[119]!==a||e[120]!==te||e[121]!==ve?(Ne=n(_t,{onValueChange:v,value:a,children:[te,ve]}),e[119]=a,e[120]=te,e[121]=ve,e[122]=Ne):Ne=e[122];let ye;e[123]!==Z||e[124]!==Ne?(ye=n("div",{className:"flex items-center gap-2",children:[Z,Ne]}),e[123]=Z,e[124]=Ne,e[125]=ye):ye=e[125];let $e;e[126]!==X||e[127]!==ye?($e=n("div",{className:"flex items-center justify-between",children:[X,ye]}),e[126]=X,e[127]=ye,e[128]=$e):$e=e[128];let we;e[129]!==r?(we=r("Statements"),e[129]=r,e[130]=we):we=e[130];let Se;e[131]!==we?(Se=t(Re,{children:we}),e[131]=we,e[132]=Se):Se=e[132];let qe;e[133]!==m.length||e[134]!==r?(qe=r("{count} tracked statements",{count:m.length}),e[133]=m.length,e[134]=r,e[135]=qe):qe=e[135];let ke;e[136]!==qe?(ke=t(ct,{children:qe}),e[136]=qe,e[137]=ke):ke=e[137];let _e;e[138]!==Se||e[139]!==ke?(_e=n(Te,{children:[Se,ke]}),e[138]=Se,e[139]=ke,e[140]=_e):_e=e[140];let Me;e[141]!==f||e[142]!==m||e[143]!==r?(Me=t(fe,{children:t("div",{className:"space-y-2",children:m.map(d=>{const C=d.normalizedSql,_=f.has(C),ue=je(d.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":_,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{se(C)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(At,{level:ue}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:d.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:Qe(d.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Qe(d.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Le(d.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),_&&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:r("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:d.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Le(d.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Qe(d.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Le(d.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Le(d.rowsWritten)})]})]})]})]},C)})})}),e[141]=f,e[142]=m,e[143]=r,e[144]=Me):Me=e[144];let Ie;e[145]!==_e||e[146]!==Me?(Ie=n(he,{children:[_e,Me]}),e[145]=_e,e[146]=Me,e[147]=Ie):Ie=e[147];let Ce;return e[148]!==H||e[149]!==$e||e[150]!==Ie?(Ce=n("div",{className:"space-y-4","data-testid":"qi-root",children:[H,$e,Ie]}),e[148]=H,e[149]=$e,e[150]=Ie,e[151]=Ce):Ce=e[151],Ce};function Et(s){return je(s.avgDurationMs)==="critical"}function jt(s){return je(s.avgDurationMs)==="warning"}function Kt(s){return je(s.avgDurationMs)==="good"}const Pt=ft(ze.getMetrics),Ut=s=>{const e=Math.floor(s/1e3),l=Math.floor(e/3600),r=Math.floor(e%3600/60),a=e%60;return l>0?`${l.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${a.toString()}s`:`${a.toString()}s`},Jt=(s,e)=>s?e:"overview",Qt=(s,e)=>{const l=s+e;return l===0?"—":`${(s/l*100).toFixed(1)}%`},ne=s=>{const e=Fe(16),{chart:l,footer:r,label:a,testId:p,value:b}=s;let f;e[0]!==a?(f=t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[0]=a,e[1]=f):f=e[1];let h;e[2]!==p||e[3]!==b?(h=t("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":p,children:b}),e[2]=p,e[3]=b,e[4]=h):h=e[4];let g;e[5]!==l||e[6]!==h?(g=n("div",{className:"flex items-center justify-between gap-3",children:[h,l]}),e[5]=l,e[6]=h,e[7]=g):g=e[7];let v;e[8]!==f||e[9]!==g?(v=n("div",{className:"flex flex-col gap-2.5 p-4",children:[f,g]}),e[8]=f,e[9]=g,e[10]=v):v=e[10];let u;e[11]!==r?(u=r!=null&&t("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r}),e[11]=r,e[12]=u):u=e[12];let m;return e[13]!==v||e[14]!==u?(m=n(he,{className:"justify-between gap-0 py-0",children:[v,u]}),e[13]=v,e[14]=u,e[15]=m):m=e[15],m},fr=({initialShardKey:s})=>{const e=lt(),l=Ee(),r=st(),[a,p]=ge(s??""),[b,f]=ge("overview"),[h,g]=ge([]),v=Ke(null),u=Ke(null),m=Ke(!0);Be(()=>(m.current=!0,()=>{m.current=!1}),[]);const N=dt(a.trim(),400),le=i=>{bt({shardKey:N,traceId:i}),Ge(r({to:"/traces"}))},{data:O,error:j,liveError:K}=He(ze.getMetrics,{},{live:!0,shardKey:N}),c=O??null;Be(()=>{if(O===void 0)return;xt(N);const i=O,k=v.current,y=u.current!==null&&u.current!==i.shard;if(u.current=i.shard,v.current=i.requests,y){g([]);return}k!==null&&i.requests>=k&&g(w=>[...w,i.requests-k].slice(-30))},[O,N]);const[S,se]=ge(null),[T,R]=ge(!1),I=async()=>{R(!0);const i=wt(a,pt());try{const k=await Promise.all(i.map(async y=>{try{const w=await e.query(Pt,{},ht(y));return{error:null,metrics:w,shard:y===""?w.shard:y}}catch(w){return{error:gt(w),metrics:null,shard:y===""?"__root__":y}}}));m.current&&se(k)}finally{m.current&&R(!1)}},x=S===null?null:Nt(S),D=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,E=h.length>0?h.at(-1):0,M=c?yt(c):{p90:0,p95:0},L=i=>i<=0?"—":i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,$=nt(()=>{if(!c||!("queryStats"in c))return;const i=c.queryStats;if(!(!i||!Array.isArray(i)))return $t(i)},[c]),q=Jt($!==void 0,b),oe=()=>{Ge(I())},de=()=>{se(null)},me=()=>{f("overview")},P=()=>{f("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(ot,{onChange:p,testId:"mt-shard-input",value:a}),t(it,{message:K,prefix:"mt"}),t(Ve,{"data-testid":"mt-aggregate",disabled:T,onClick:oe,size:"sm",type:"button",variant:"secondary",children:l(T?"Aggregating…":"All shards")}),S!==null&&t(Ve,{"data-testid":"mt-aggregate-clear",onClick:de,size:"sm",type:"button",variant:"ghost",children:l("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:mt,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),j!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j}),$!==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 ${q==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:me,type:"button",children:l("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${q==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:P,type:"button",children:[l("Query insights"),$.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:$.length})]})]}),q==="query-insights"&&$!==void 0&&t(zt,{queryStats:$}),q==="overview"&&c!==null&&n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[t(ne,{chart:h.length>=2?t(tt,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"}):void 0,footer:h.length>=2?n(Ue,{children:[t("span",{className:"font-semibold text-foreground",children:`+${E.toLocaleString()}`})," ",l("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples…")}),label:l("Requests"),testId:"mt-requests",value:c.requests}),t(ne,{footer:l("{rate} error rate",{rate:D}),label:l("Errors"),testId:"mt-errors",value:n(Ue,{children:[c.errors," (",D,")"]})}),t(ne,{footer:M.p90>0?`P90 ${L(M.p90)}`:void 0,label:l("P95 latency"),testId:"mt-p95",value:M.p95>0?L(M.p95):"—"}),t(ne,{footer:c.cache===null?void 0:`${c.cache.entries.toLocaleString()} ${l("cache entries")}`,label:l("Database size"),testId:"mt-db-size",value:Pe(c.databaseSize)}),t(ne,{label:l("Shard"),testId:"mt-shard",value:c.shard}),t(ne,{label:l("Uptime"),testId:"mt-uptime",value:Ut(c.uptimeMs)}),t(ne,{label:l("Cache hit rate"),testId:"mt-cache",value:c.cache===null?l("no cache configured"):l("{rate} ({count} entries)",{count:c.cache.entries,rate:Qt(c.cache.hits,c.cache.misses)})})]}),q==="overview"&&c===null&&null,q==="overview"&&t(Lt,{onOpenTrace:le,shardKey:N}),q==="overview"&&x!==null&&S!==null&&n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[t(ne,{label:l("Shards"),testId:"mt-agg-shards",value:x.failed>0?l("{reachable} reachable, {failed} unreachable",{failed:x.failed,reachable:x.reachable}):l("{reachable} reachable",{reachable:x.reachable})}),t(ne,{label:l("Total requests"),testId:"mt-agg-requests",value:x.totalRequests}),t(ne,{label:l("Total errors"),testId:"mt-agg-errors",value:x.totalErrors}),t(ne,{label:l("Total database size"),testId:"mt-agg-db-size",value:Pe(x.totalDatabaseSize)}),t(ne,{label:l("Combined cache hit rate"),testId:"mt-agg-cache",value:x.hitRate===null?l("no cache configured"):`${(x.hitRate*100).toFixed(1)}%`})]}),t(he,{className:"overflow-hidden py-0",children:t(fe,{className:"px-0",children:n(Ye,{"data-testid":"mt-agg-table",children:[t(Xe,{children:n(Ae,{children:[t(ie,{children:l("shard")}),t(ie,{children:l("requests")}),t(ie,{children:l("errors")}),t(ie,{children:l("db size")})]})}),t(Ze,{children:S.map(i=>n(Ae,{"data-testid":`mt-agg-row-${i.shard}`,children:[t(ae,{children:i.shard}),i.metrics===null?t(ae,{className:"text-destructive",colSpan:3,children:i.error??l("unreachable")}):n(Ue,{children:[t(ae,{className:"tabular-nums",children:i.metrics.requests}),t(ae,{className:"tabular-nums",children:i.metrics.errors}),t(ae,{className:"tabular-nums",children:Pe(i.metrics.databaseSize)})]})]},i.shard))})]})})})]})]})};export{fr as MetricsPanel};
1
+ import{c as Re}from"react/compiler-runtime";import{useLunora as pt}from"@lunora/react";import{useNavigate as xt}from"@tanstack/react-router";import{useState as ue,useRef as Ge,useEffect as tt,useMemo as bt}from"react";import{L as vt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{c as he,u as ge,n as Qe,f as Ue,m as Nt}from"../packem_shared/card-CIDGUN6K.js";import{p as ie,d as ct,m as Be,u as se,n as mt,f as ut}from"../packem_shared/table-DdJBrClo.js";import{N as He}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import wt from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ae}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Oe}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{c as St}from"../packem_shared/cf-links-gbDy51nR.js";import{l as $t,k as Xe,f as at,d as kt,b as qt,g as _t}from"../packem_shared/internal-BSIsQVC6.js";import{r as Mt,l as It}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as Ct}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{f as Tt}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{S as ht}from"../packem_shared/sparkline-CgjeUU2I.js";import{jsx as t,jsxs as n,Fragment as Ye}from"react/jsx-runtime";import{aggregateMetrics as Dt,computeLatencyPercentiles as Ft,enrichQueryStats as Lt,shardsToAggregate as Ot}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{ResponsiveContainer as st,AreaChart as Rt,CartesianGrid as lt,XAxis as nt,YAxis as it,Tooltip as ot,Area as At,LineChart as zt,Line as Kt}from"recharts";import{E as Et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as jt}from"../packem_shared/utils-bhneXptQ.js";import{N as Qt,y as Ut,k as Pe,_ as Pt,w as Jt}from"../packem_shared/select-Bul-DeII.js";const Bt=(s,e)=>s<e?-1:s>e?1:0,Ze=s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s))return`[${s.map(u=>Ze(u)).join(",")}]`;const e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){const u=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${u} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const l=s,r=Object.keys(l).toSorted(Bt),a=[];for(const u of r){const c=l[u];c!==void 0&&a.push(`${JSON.stringify(u)}:${Ze(c)}`)}return`{${a.join(",")}}`},gt=(s,e,l)=>`${s}:${e}:${Ze(l??{})}`,ft=(s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,Ht=(s,e)=>ft(s,e),Wt=s=>ft(s.kind,s),Ve=s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),Gt=s=>Array.isArray(s?.series)?s.series:[],Xt="FUNCTION_NOT_FOUND",Yt=s=>{const e=new Map;if(!Array.isArray(s?.series))return e;for(const l of s.series)e.set(gt(l.kind,l.name,l.attributes),l.points);return e},Vt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=s=>{const e=Re(18),{name:l,onOpenTrace:r,traceId:a}=s,u=Ae();if(a===void 0){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t("span",{className:"text-muted-foreground",children:"—"}),e[0]=m):m=e[0],m}let c;e[1]!==a?(c=a.slice(0,8),e[1]=a,e[2]=c):c=e[2];const g=c;if(r===void 0){const m=`mt-instrument-trace-${l}`;let b;return e[3]!==g||e[4]!==m||e[5]!==a?(b=t("span",{className:"text-muted-foreground","data-testid":m,title:a,children:g}),e[3]=g,e[4]=m,e[5]=a,e[6]=b):b=e[6],b}const p=`mt-instrument-trace-${l}`;let x;e[7]!==r||e[8]!==a?(x=()=>{r(a)},e[7]=r,e[8]=a,e[9]=x):x=e[9];let v;e[10]!==u||e[11]!==a?(v=u("Open the exemplar trace {trace}",{trace:a}),e[10]=u,e[11]=a,e[12]=v):v=e[12];let h;return e[13]!==g||e[14]!==p||e[15]!==x||e[16]!==v?(h=t("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":p,onClick:x,title:v,type:"button",children:g}),e[13]=g,e[14]=p,e[15]=x,e[16]=v,e[17]=h):h=e[17],h},er=s=>{const e=Re(105),{onOpenTrace:l,shardKey:r}=s,a=Ae();let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let c;e[1]!==r?(c={live:!0,shardKey:r},e[1]=r,e[2]=c):c=e[2];const{data:g,error:p,errorSource:x}=He(Oe.getMetricSeries,u,c);let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={},e[3]=v):v=e[3];let h;e[4]!==r?(h={live:!0,shardKey:r},e[4]=r,e[5]=h):h=e[5];const{data:m}=He(Oe.getMetricHistory,v,h);let b,O,k,C,R,o,y,$,T,D,_,N,A;if(e[6]!==g||e[7]!==p||e[8]!==x||e[9]!==m||e[10]!==l||e[11]!==a){$=Symbol.for("react.early_return_sentinel");e:{const de=Gt(g),ce=$t(x)===Xt;if(p!==null&&!ce){let i;e[25]!==a?(i=a("Instruments"),e[25]=a,e[26]=i):i=e[26];let I;e[27]!==i?(I=t("h3",{className:"text-sm font-semibold text-foreground",children:i}),e[27]=i,e[28]=I):I=e[28];let F;e[29]!==p||e[30]!==a?(F=a("Instruments unavailable: {error}",{error:p}),e[29]=p,e[30]=a,e[31]=F):F=e[31];let L;e[32]!==F?(L=t("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:F}),e[32]=F,e[33]=L):L=e[33];let ae;e[34]!==I||e[35]!==L?(ae=n("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[I,L]}),e[34]=I,e[35]=L,e[36]=ae):ae=e[36],$=ae;break e}if(de.length===0){$=null;break e}const Fe=Yt(m);let d;e[37]!==a?(d=i=>a(i==="counter"?"Counter":i==="gauge"?"Gauge":"Histogram"),e[37]=a,e[38]=d):d=e[38];const K=d;R="flex flex-col gap-2",o="mt-instruments";let w;e[39]!==a?(w=a("Instruments"),e[39]=a,e[40]=w):w=e[40],e[41]!==w?(y=t("h3",{className:"text-sm font-semibold text-foreground",children:w}),e[41]=w,e[42]=y):y=e[42],C=he,A="overflow-hidden py-0",k=ge,N="px-0",O=mt,D="mt-instruments-table";let S;e[43]!==a?(S=a("name"),e[43]=a,e[44]=S):S=e[44];let Q;e[45]!==S?(Q=t(ie,{children:S}),e[45]=S,e[46]=Q):Q=e[46];let U;e[47]!==a?(U=a("kind"),e[47]=a,e[48]=U):U=e[48];let P;e[49]!==U?(P=t(ie,{children:U}),e[49]=U,e[50]=P):P=e[50];let J;e[51]!==a?(J=a("value"),e[51]=a,e[52]=J):J=e[52];let B;e[53]!==J?(B=t(ie,{className:"text-right",children:J}),e[53]=J,e[54]=B):B=e[54];let H;e[55]!==a?(H=a("count"),e[55]=a,e[56]=H):H=e[56];let W;e[57]!==H?(W=t(ie,{className:"text-right",children:H}),e[57]=H,e[58]=W):W=e[58];let G;e[59]!==a?(G=a("range"),e[59]=a,e[60]=G):G=e[60];let X;e[61]!==G?(X=t(ie,{className:"text-right",children:G}),e[61]=G,e[62]=X):X=e[62];let Y;e[63]!==a?(Y=a("trend"),e[63]=a,e[64]=Y):Y=e[64];let V;e[65]!==Y?(V=t(ie,{children:Y}),e[65]=Y,e[66]=V):V=e[66];let Z;e[67]!==a?(Z=a("trace"),e[67]=a,e[68]=Z):Z=e[68];let ee;e[69]!==Z?(ee=t(ie,{children:Z}),e[69]=Z,e[70]=ee):ee=e[70];let te;e[71]!==a?(te=a("dimensions"),e[71]=a,e[72]=te):te=e[72];let re;e[73]!==te?(re=t(ie,{children:te}),e[73]=te,e[74]=re):re=e[74],e[75]!==Q||e[76]!==P||e[77]!==B||e[78]!==W||e[79]!==X||e[80]!==V||e[81]!==ee||e[82]!==re?(_=t(ct,{children:n(Be,{children:[Q,P,B,W,X,V,ee,re]})}),e[75]=Q,e[76]=P,e[77]=B,e[78]=W,e[79]=X,e[80]=V,e[81]=ee,e[82]=re,e[83]=_):_=e[83],b=ut,T=de.map(i=>{const I=Tt(i.attributes),F=gt(i.kind,i.name,i.attributes),L=(Fe.get(F)??[]).map(ae=>Ht(i.kind,ae));return n(Be,{"data-testid":`mt-instrument-${i.name}`,children:[t(se,{className:"font-mono text-xs",title:i.functionPath,children:i.name}),t(se,{children:t(et,{variant:Vt[i.kind],children:K(i.kind)})}),t(se,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${i.name}`,children:Ve(Wt(i))}),t(se,{className:"text-right tabular-nums text-muted-foreground",children:i.count.toLocaleString()}),t(se,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:i.min===i.max?"—":`${Ve(i.min)}–${Ve(i.max)}`}),t(se,{children:L.length>=2?t(ht,{ariaLabel:a("{name} trend",{name:i.name}),className:"h-6 w-24 text-foreground",series:L,testId:`mt-instrument-trend-${i.name}`}):t("span",{className:"text-xs text-muted-foreground",children:"—"})}),t(se,{className:"font-mono text-xs",children:t(Zt,{name:i.name,onOpenTrace:l,traceId:i.exemplarTraceId})}),t(se,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:I,children:I===""?"—":I})]},F)})}e[6]=g,e[7]=p,e[8]=x,e[9]=m,e[10]=l,e[11]=a,e[12]=b,e[13]=O,e[14]=k,e[15]=C,e[16]=R,e[17]=o,e[18]=y,e[19]=$,e[20]=T,e[21]=D,e[22]=_,e[23]=N,e[24]=A}else b=e[12],O=e[13],k=e[14],C=e[15],R=e[16],o=e[17],y=e[18],$=e[19],T=e[20],D=e[21],_=e[22],N=e[23],A=e[24];if($!==Symbol.for("react.early_return_sentinel"))return $;let j;e[84]!==b||e[85]!==T?(j=t(b,{children:T}),e[84]=b,e[85]=T,e[86]=j):j=e[86];let z;e[87]!==O||e[88]!==j||e[89]!==D||e[90]!==_?(z=n(O,{"data-testid":D,children:[_,j]}),e[87]=O,e[88]=j,e[89]=D,e[90]=_,e[91]=z):z=e[91];let M;e[92]!==k||e[93]!==z||e[94]!==N?(M=t(k,{className:N,children:z}),e[92]=k,e[93]=z,e[94]=N,e[95]=M):M=e[95];let q;e[96]!==C||e[97]!==M||e[98]!==A?(q=t(C,{className:A,children:M}),e[96]=C,e[97]=M,e[98]=A,e[99]=q):q=e[99];let oe;return e[100]!==R||e[101]!==o||e[102]!==y||e[103]!==q?(oe=n("section",{className:R,"data-testid":o,children:[y,q]}),e[100]=R,e[101]=o,e[102]=y,e[103]=q,e[104]=oe):oe=e[104],oe},We=s=>s>=100?"critical":s>=50?"warning":"good",Le=s=>s<1?`${(s*1e3).toFixed(0)}μs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,Je=s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),tr=s=>{const e=Re(3),{level:l}=s;if(l==="critical"){let a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=t(et,{variant:"destructive",children:"Slow"}),e[0]=a):a=e[0],a}if(l==="warning"){let a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(a=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]=a):a=e[1],a}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=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]=r):r=e[2],r},rr=(s,e)=>{const l=[...s];return l.sort((r,a)=>{switch(e){case"avgTime":return a.avgDurationMs-r.avgDurationMs;case"execCount":return a.execCount-r.execCount;case"rowsRead":return a.rowsRead-r.rowsRead;default:return a.totalDurationMs-r.totalDurationMs}}),l},ar=s=>{const e=Re(161),{queryStats:l}=s,r=Ae(),[a,u]=ue("totalTime");let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=new Set,e[0]=c):c=e[0];const[g,p]=ue(c);let x;e[1]===Symbol.for("react.memo_cache_sentinel")?(x=A=>{A!==null&&u(A)},e[1]=x):x=e[1];const v=x;let h,m,b,O,k,C,R,o,y,$;if(e[2]!==g||e[3]!==l||e[4]!==a||e[5]!==r){b=Symbol.for("react.early_return_sentinel");e:{const A=rr(l,a);let j;e[16]!==l?(j=l.filter(sr),e[16]=l,e[17]=j):j=e[17];const z=j.length;let M;e[18]!==l?(M=l.filter(lr),e[18]=l,e[19]=M):M=e[19];const q=M.length;let oe;e[20]!==l?(oe=l.filter(nr),e[20]=l,e[21]=oe):oe=e[21];const de=oe.length;let ce;e[22]===Symbol.for("react.memo_cache_sentinel")?(ce=f=>{p(le=>{const E=new Set(le);return E.has(f)?E.delete(f):E.add(f),E})},e[22]=ce):ce=e[22];const Fe=ce;if(l.length===0){let f;e[23]!==r?(f=r("No query insights yet"),e[23]=r,e[24]=f):f=e[24];let le;e[25]!==f?(le=t("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:f}),e[25]=f,e[26]=le):le=e[26];let E;e[27]!==r?(E=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=E):E=e[28];let me;e[29]!==E?(me=t("p",{className:"mt-1 text-sm",children:E}),e[29]=E,e[30]=me):me=e[30];let je;e[31]!==le||e[32]!==me?(je=t(he,{children:t(ge,{className:"py-12",children:n("div",{className:"text-center text-muted-foreground",children:[le,me]})})}),e[31]=le,e[32]=me,e[33]=je):je=e[33],b=je;break e}R="space-y-4",o="qi-root";let d;e[34]!==r?(d=r("Critical queries"),e[34]=r,e[35]=d):d=e[35];let K;e[36]!==d?(K=t(Qe,{className:"pb-2",children:t(Ue,{className:"text-sm font-medium",children:d})}),e[36]=d,e[37]=K):K=e[37];let w;e[38]!==z?(w=t("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:z}),e[38]=z,e[39]=w):w=e[39];let S;e[40]!==r?(S=r(">100ms avg execution"),e[40]=r,e[41]=S):S=e[41];let Q;e[42]!==S?(Q=t("p",{className:"text-xs text-muted-foreground",children:S}),e[42]=S,e[43]=Q):Q=e[43];let U;e[44]!==w||e[45]!==Q?(U=n(ge,{children:[w,Q]}),e[44]=w,e[45]=Q,e[46]=U):U=e[46];let P;e[47]!==K||e[48]!==U?(P=n(he,{children:[K,U]}),e[47]=K,e[48]=U,e[49]=P):P=e[49];let J;e[50]!==r?(J=r("Moderate queries"),e[50]=r,e[51]=J):J=e[51];let B;e[52]!==J?(B=t(Qe,{className:"pb-2",children:t(Ue,{className:"text-sm font-medium",children:J})}),e[52]=J,e[53]=B):B=e[53];let H;e[54]!==q?(H=t("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:q}),e[54]=q,e[55]=H):H=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let G;e[58]!==W?(G=t("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=G):G=e[59];let X;e[60]!==H||e[61]!==G?(X=n(ge,{children:[H,G]}),e[60]=H,e[61]=G,e[62]=X):X=e[62];let Y;e[63]!==B||e[64]!==X?(Y=n(he,{children:[B,X]}),e[63]=B,e[64]=X,e[65]=Y):Y=e[65];let V;e[66]!==r?(V=r("Fast queries"),e[66]=r,e[67]=V):V=e[67];let Z;e[68]!==V?(Z=t(Qe,{className:"pb-2",children:t(Ue,{className:"text-sm font-medium",children:V})}),e[68]=V,e[69]=Z):Z=e[69];let ee;e[70]!==de?(ee=t("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:de}),e[70]=de,e[71]=ee):ee=e[71];let te;e[72]!==r?(te=r("<50ms avg execution"),e[72]=r,e[73]=te):te=e[73];let re;e[74]!==te?(re=t("p",{className:"text-xs text-muted-foreground",children:te}),e[74]=te,e[75]=re):re=e[75];let i;e[76]!==ee||e[77]!==re?(i=n(ge,{children:[ee,re]}),e[76]=ee,e[77]=re,e[78]=i):i=e[78];let I;e[79]!==Z||e[80]!==i?(I=n(he,{children:[Z,i]}),e[79]=Z,e[80]=i,e[81]=I):I=e[81],e[82]!==P||e[83]!==Y||e[84]!==I?(y=n("div",{className:"grid gap-4 md:grid-cols-3",children:[P,Y,I]}),e[82]=P,e[83]=Y,e[84]=I,e[85]=y):y=e[85];let F;e[86]!==r?(F=r("Query leaderboard"),e[86]=r,e[87]=F):F=e[87];let L;e[88]!==F?(L=t("h3",{className:"text-lg font-semibold",children:F}),e[88]=F,e[89]=L):L=e[89];let ae;e[90]!==a||e[91]!==r?(ae=r("Slow queries sorted by {sortField}",{sortField:r(a)}),e[90]=a,e[91]=r,e[92]=ae):ae=e[92];let fe;e[93]!==ae?(fe=t("p",{className:"text-sm text-muted-foreground",children:ae}),e[93]=ae,e[94]=fe):fe=e[94];let pe;e[95]!==L||e[96]!==fe?(pe=n("div",{children:[L,fe]}),e[95]=L,e[96]=fe,e[97]=pe):pe=e[97];let xe;e[98]!==r?(xe=r("Sort by"),e[98]=r,e[99]=xe):xe=e[99];let be;e[100]!==xe?(be=t("span",{className:"text-sm text-muted-foreground",children:xe}),e[100]=xe,e[101]=be):be=e[101];let ve;e[102]!==r?(ve=r("Sort queries by"),e[102]=r,e[103]=ve):ve=e[103];let ze;e[104]===Symbol.for("react.memo_cache_sentinel")?(ze=t(Qt,{}),e[104]=ze):ze=e[104];let ye;e[105]!==ve?(ye=t(Ut,{"aria-label":ve,className:"w-[140px]","data-testid":"qi-sort",children:ze}),e[105]=ve,e[106]=ye):ye=e[106];let Ne;e[107]!==r?(Ne=r("Total time"),e[107]=r,e[108]=Ne):Ne=e[108];let we;e[109]!==Ne?(we=t(Pe,{value:"totalTime",children:Ne}),e[109]=Ne,e[110]=we):we=e[110];let Se;e[111]!==r?(Se=r("Avg time"),e[111]=r,e[112]=Se):Se=e[112];let $e;e[113]!==Se?($e=t(Pe,{value:"avgTime",children:Se}),e[113]=Se,e[114]=$e):$e=e[114];let ke;e[115]!==r?(ke=r("Execution count"),e[115]=r,e[116]=ke):ke=e[116];let qe;e[117]!==ke?(qe=t(Pe,{value:"execCount",children:ke}),e[117]=ke,e[118]=qe):qe=e[118];let _e;e[119]!==r?(_e=r("Rows read"),e[119]=r,e[120]=_e):_e=e[120];let Me;e[121]!==_e?(Me=t(Pe,{value:"rowsRead",children:_e}),e[121]=_e,e[122]=Me):Me=e[122];let Ie;e[123]!==we||e[124]!==$e||e[125]!==qe||e[126]!==Me?(Ie=n(Pt,{children:[we,$e,qe,Me]}),e[123]=we,e[124]=$e,e[125]=qe,e[126]=Me,e[127]=Ie):Ie=e[127];let Ce;e[128]!==a||e[129]!==ye||e[130]!==Ie?(Ce=n(Jt,{onValueChange:v,value:a,children:[ye,Ie]}),e[128]=a,e[129]=ye,e[130]=Ie,e[131]=Ce):Ce=e[131];let Te;e[132]!==be||e[133]!==Ce?(Te=n("div",{className:"flex items-center gap-2",children:[be,Ce]}),e[132]=be,e[133]=Ce,e[134]=Te):Te=e[134],e[135]!==pe||e[136]!==Te?($=n("div",{className:"flex items-center justify-between",children:[pe,Te]}),e[135]=pe,e[136]=Te,e[137]=$):$=e[137],m=he;let De;e[138]!==r?(De=r("Statements"),e[138]=r,e[139]=De):De=e[139];let Ke;e[140]!==De?(Ke=t(Ue,{children:De}),e[140]=De,e[141]=Ke):Ke=e[141],C=n(Qe,{children:[Ke,t(Nt,{children:r("{count} tracked statements",{count:A.length})})]}),h=ge,O="space-y-2";let Ee;e[142]!==g||e[143]!==r?(Ee=f=>{const le=f.normalizedSql,E=g.has(le),me=We(f.avgDurationMs);return n("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[n("button",{"aria-expanded":E,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{Fe(le)},type:"button",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[t(tr,{level:me}),t("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:f.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:Le(f.totalDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Le(f.avgDurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),f.p95DurationMs!==void 0&&n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Le(f.p95DurationMs)}),t("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),n("div",{className:"text-right",children:[t("div",{className:"text-sm font-medium",children:Je(f.execCount)}),t("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),E&&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:r("Full statement")}),t("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:f.normalizedSql})]}),n("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[f.p50DurationMs!==void 0&&n("div",{children:[t("span",{className:"text-muted-foreground",children:r("p50")}),t("span",{className:"block font-medium tabular-nums",children:Le(f.p50DurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Exec count")}),t("span",{className:"block font-medium tabular-nums",children:Je(f.execCount)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Total time")}),t("span",{className:"block font-medium tabular-nums",children:Le(f.totalDurationMs)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Rows read")}),t("span",{className:"block font-medium tabular-nums",children:Je(f.rowsRead)})]}),n("div",{children:[t("span",{className:"text-muted-foreground",children:r("Rows written")}),t("span",{className:"block font-medium tabular-nums",children:Je(f.rowsWritten)})]})]})]})]},le)},e[142]=g,e[143]=r,e[144]=Ee):Ee=e[144],k=A.map(Ee)}e[2]=g,e[3]=l,e[4]=a,e[5]=r,e[6]=h,e[7]=m,e[8]=b,e[9]=O,e[10]=k,e[11]=C,e[12]=R,e[13]=o,e[14]=y,e[15]=$}else h=e[6],m=e[7],b=e[8],O=e[9],k=e[10],C=e[11],R=e[12],o=e[13],y=e[14],$=e[15];if(b!==Symbol.for("react.early_return_sentinel"))return b;let T;e[145]!==O||e[146]!==k?(T=t("div",{className:O,children:k}),e[145]=O,e[146]=k,e[147]=T):T=e[147];let D;e[148]!==h||e[149]!==T?(D=t(h,{children:T}),e[148]=h,e[149]=T,e[150]=D):D=e[150];let _;e[151]!==m||e[152]!==D||e[153]!==C?(_=n(m,{children:[C,D]}),e[151]=m,e[152]=D,e[153]=C,e[154]=_):_=e[154];let N;return e[155]!==_||e[156]!==R||e[157]!==o||e[158]!==y||e[159]!==$?(N=n("div",{className:R,"data-testid":o,children:[y,$,_]}),e[155]=_,e[156]=R,e[157]=o,e[158]=y,e[159]=$,e[160]=N):N=e[160],N};function sr(s){return We(s.avgDurationMs)==="critical"}function lr(s){return We(s.avgDurationMs)==="warning"}function nr(s){return We(s.avgDurationMs)==="good"}const ir=["1m","5m","15m","1h"],or=s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),dr=s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:or(e.bucketMs)})),cr=({shardKey:s=""})=>{const e=Ae(),[l,r]=ue("15m"),a=He(Oe.getQueryInsights,{range:l},{live:!0,shardKey:s}).data,u=dr(a?.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:ir.map(c=>t("button",{"aria-pressed":c===l,className:jt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",c===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${c}`,onClick:()=>{r(c)},type:"button",children:c},c))}),a?.capped===!0&&t(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),u.length===0?t(Et,{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(Rt,{data:u,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(nt,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),t(ot,{}),t(At,{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(zt,{data:u,children:[t(lt,{strokeDasharray:"3 3",vertical:!1}),t(nt,{dataKey:"label",fontSize:10,tickLine:!1}),t(it,{fontSize:10,tickLine:!1,width:32}),t(ot,{}),t(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),t(ar,{queryStats:a?.entries??[]})]})},mr=_t(Oe.getMetrics),ur=s=>{const e=Math.floor(s/1e3),l=Math.floor(e/3600),r=Math.floor(e%3600/60),a=e%60;return l>0?`${l.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${a.toString()}s`:`${a.toString()}s`},hr=(s,e)=>s?e:"overview",gr=(s,e)=>{const l=s+e;return l===0?"—":`${(s/l*100).toFixed(1)}%`},ne=s=>{const e=Re(16),{chart:l,footer:r,label:a,testId:u,value:c}=s;let g;e[0]!==a?(g=t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[0]=a,e[1]=g):g=e[1];let p;e[2]!==u||e[3]!==c?(p=t("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":u,children:c}),e[2]=u,e[3]=c,e[4]=p):p=e[4];let x;e[5]!==l||e[6]!==p?(x=n("div",{className:"flex items-center justify-between gap-3",children:[p,l]}),e[5]=l,e[6]=p,e[7]=x):x=e[7];let v;e[8]!==g||e[9]!==x?(v=n("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]}),e[8]=g,e[9]=x,e[10]=v):v=e[10];let h;e[11]!==r?(h=r!=null&&t("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r}),e[11]=r,e[12]=h):h=e[12];let m;return e[13]!==v||e[14]!==h?(m=n(he,{className:"justify-between gap-0 py-0",children:[v,h]}),e[13]=v,e[14]=h,e[15]=m):m=e[15],m},dt=s=>s<=0?"—":s<1?`${(s*1e3).toFixed(0)}μs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,jr=({initialShardKey:s})=>{const e=pt(),l=Ae(),r=xt(),[a,u]=ue(s??""),[c,g]=ue("overview"),[p,x]=ue([]),v=Ge(null),h=Ge(null),m=Ge(!0);tt(()=>(m.current=!0,()=>{m.current=!1}),[]);const b=wt(a.trim(),400),O=d=>{Ct({shardKey:b,traceId:d}),at(r({to:"/traces"}))},{data:k,error:C,liveError:R}=He(Oe.getMetrics,{},{live:!0,shardKey:b}),o=k??null;tt(()=>{if(k===void 0)return;Mt(b);const d=k,K=v.current,w=h.current!==null&&h.current!==d.shard;if(h.current=d.shard,v.current=d.requests,w){x([]);return}K!==null&&d.requests>=K&&x(S=>[...S,d.requests-K].slice(-30))},[k,b]);const[y,$]=ue(null),[T,D]=ue(!1),_=async()=>{D(!0);const d=Ot(a,It());try{const K=await Promise.all(d.map(async w=>{try{const S=await e.query(mr,{},kt(w));return{error:null,metrics:S,shard:w===""?S.shard:w}}catch(S){return{error:qt(S),metrics:null,shard:w===""?"__root__":w}}}));m.current&&$(K)}finally{m.current&&D(!1)}},N=y===null?null:Dt(y),A=o===null||o.requests===0?"—":`${(o.errors/o.requests*100).toFixed(1)}%`,j=p.length>0?p.at(-1):0,z=o?Ft(o):{p90:0,p95:0},M=bt(()=>{if(!o||!("queryStats"in o))return;const d=o.queryStats;if(!(!d||!Array.isArray(d)))return Lt(d)},[o]),q=hr(M!==void 0,c),oe=()=>{at(_())},de=()=>{$(null)},ce=()=>{g("overview")},Fe=()=>{g("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(yt,{onChange:u,testId:"mt-shard-input",value:a}),t(vt,{message:R,prefix:"mt"}),t(rt,{"data-testid":"mt-aggregate",disabled:T,onClick:oe,size:"sm",type:"button",variant:"secondary",children:l(T?"Aggregating…":"All shards")}),y!==null&&t(rt,{"data-testid":"mt-aggregate-clear",onClick:de,size:"sm",type:"button",variant:"ghost",children:l("Hide")}),t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),C!==null&&t("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:C}),M!==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 ${q==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:ce,type:"button",children:l("Overview")}),n("button",{className:`pb-2 text-sm font-medium transition-colors ${q==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:Fe,type:"button",children:[l("Query insights"),M.length>0&&t("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:M.length})]})]}),q==="query-insights"&&M!==void 0&&t(cr,{shardKey:b}),q==="overview"&&o!==null&&n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[t(ne,{chart:p.length>=2?t(ht,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:p,testId:"mt-sparkline"}):void 0,footer:p.length>=2?n(Ye,{children:[t("span",{className:"font-semibold text-foreground",children:`+${j.toLocaleString()}`})," ",l("last interval")]}):t("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples…")}),label:l("Requests"),testId:"mt-requests",value:o.requests}),t(ne,{footer:l("{rate} error rate",{rate:A}),label:l("Errors"),testId:"mt-errors",value:n(Ye,{children:[o.errors," (",A,")"]})}),t(ne,{footer:z.p90>0?`P90 ${dt(z.p90)}`:void 0,label:l("P95 latency"),testId:"mt-p95",value:z.p95>0?dt(z.p95):"—"}),t(ne,{footer:o.cache===null?void 0:`${o.cache.entries.toLocaleString()} ${l("cache entries")}`,label:l("Database size"),testId:"mt-db-size",value:Xe(o.databaseSize)}),t(ne,{label:l("Shard"),testId:"mt-shard",value:o.shard}),t(ne,{label:l("Uptime"),testId:"mt-uptime",value:ur(o.uptimeMs)}),t(ne,{label:l("Cache hit rate"),testId:"mt-cache",value:o.cache===null?l("no cache configured"):l("{rate} ({count} entries)",{count:o.cache.entries,rate:gr(o.cache.hits,o.cache.misses)})})]}),q==="overview"&&o===null&&null,q==="overview"&&t(er,{onOpenTrace:O,shardKey:b}),q==="overview"&&N!==null&&y!==null&&n("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[n("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[t(ne,{label:l("Shards"),testId:"mt-agg-shards",value:N.failed>0?l("{reachable} reachable, {failed} unreachable",{failed:N.failed,reachable:N.reachable}):l("{reachable} reachable",{reachable:N.reachable})}),t(ne,{label:l("Total requests"),testId:"mt-agg-requests",value:N.totalRequests}),t(ne,{label:l("Total errors"),testId:"mt-agg-errors",value:N.totalErrors}),t(ne,{label:l("Total database size"),testId:"mt-agg-db-size",value:Xe(N.totalDatabaseSize)}),t(ne,{label:l("Combined cache hit rate"),testId:"mt-agg-cache",value:N.hitRate===null?l("no cache configured"):`${(N.hitRate*100).toFixed(1)}%`})]}),t(he,{className:"overflow-hidden py-0",children:t(ge,{className:"px-0",children:n(mt,{"data-testid":"mt-agg-table",children:[t(ct,{children:n(Be,{children:[t(ie,{children:l("shard")}),t(ie,{children:l("requests")}),t(ie,{children:l("errors")}),t(ie,{children:l("db size")})]})}),t(ut,{children:y.map(d=>n(Be,{"data-testid":`mt-agg-row-${d.shard}`,children:[t(se,{children:d.shard}),d.metrics===null?t(se,{className:"text-destructive",colSpan:3,children:d.error??l("unreachable")}):n(Ye,{children:[t(se,{className:"tabular-nums",children:d.metrics.requests}),t(se,{className:"tabular-nums",children:d.metrics.errors}),t(se,{className:"tabular-nums",children:Xe(d.metrics.databaseSize)})]})]},d.shard))})]})})})]})]})};export{jr as MetricsPanel};
@@ -1 +1 @@
1
- import{c as W}from"react/compiler-runtime";import{useState as T}from"react";import{E as B}from"../packem_shared/error-alert-B59DnrDI.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as K,u as O}from"../packem_shared/card-CIDGUN6K.js";import{E as U}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as q}from"../packem_shared/input-JHu63lTv.js";import{n as G,d as J,m as F,p as h,f as Q,u as f}from"../packem_shared/table-DdJBrClo.js";import{K as X}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{i as ee}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",P=e=>e.endpoint??e.id,ve=()=>{const e=W(38),r=Y(),[i,R]=T("all"),[s,V]=T("");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:S,error:o,errorSource:p,isLoading:C,refetch:v}=X(Z.listPushSubscriptions,g);let N;if(e[1]!==S?.subscriptions||e[2]!==o||e[3]!==p||e[4]!==C||e[5]!==i||e[6]!==v||e[7]!==s||e[8]!==r){const A=S?.subscriptions??[],j=s.trim().toLowerCase(),E=A.filter(a=>i!=="all"&&a.kind!==i?!1:j===""?!0:`${P(a)} ${a.userId??""}`.toLowerCase().includes(j));let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=a=>{V(a.target.value)},e[10]=b):b=e[10];const D=b;let w;e[11]!==v?(w=()=>{v()},e[11]=v,e[12]=w):w=e[12];const I=w;let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=["all","web-push","fcm"],e[13]=y):y=e[13];const H=y;let l;e[14]!==i||e[15]!==r?(l=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:H.map(a=>t(z,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:()=>{R(a)},role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=l):l=e[16];let n;e[17]!==r?(n=r("Filter devices"),e[17]=r,e[18]=n):n=e[18];let c;e[19]!==r?(c=r("filter endpoint, user"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s||e[22]!==n||e[23]!==c?(d=t(q,{"aria-label":n,className:"h-8 w-56","data-testid":"nt-search",onChange:D,placeholder:c,value:s}),e[21]=s,e[22]=n,e[23]=c,e[24]=d):d=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let u;e[27]!==I||e[28]!==m?(u=t(z,{className:"ml-auto","data-testid":"nt-refresh",onClick:I,size:"sm",type:"button",variant:"outline",children:m}),e[27]=I,e[28]=m,e[29]=u):u=e[29];const L=A.length>0&&t(_,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:A.length})});let $;e[30]!==u||e[31]!==L||e[32]!==l||e[33]!==d?($=x("div",{className:"flex flex-wrap items-center gap-2",children:[l,d,u,L]}),e[30]=u,e[31]=L,e[32]=l,e[33]=d,e[34]=$):$=e[34];let k;e[35]!==o||e[36]!==p?(k=o!==null&&t(B,{error:p,testId:"nt-error"}),e[35]=o,e[36]=p,e[37]=k):k=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[$,k,o===null&&!C&&E.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.")}),E.length>0&&t(K,{className:"overflow-hidden py-0",children:t(O,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(F,{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(Q,{children:E.map(a=>{const M=P(a);return x(F,{"data-testid":"nt-row",children:[t(f,{children:t(_,{variant:"outline",children:a.kind})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs",title:M,children:M}),t(f,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(f,{className:"text-muted-foreground tabular-nums",children:ee(a.lastSeenAt,"—")}),t(f,{children:t(_,{"data-testid":`nt-status-${a.id}`,variant:te(a.lastStatus),children:a.lastStatus??r("n/a")})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},a.id)})})]})})})]}),e[1]=S?.subscriptions,e[2]=o,e[3]=p,e[4]=C,e[5]=i,e[6]=v,e[7]=s,e[8]=r,e[9]=N}else N=e[9];return N};export{ve as NotificationsPanel};
1
+ import{c as W}from"react/compiler-runtime";import{useState as T}from"react";import{E as B}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as O,u as U}from"../packem_shared/card-CIDGUN6K.js";import{E as q}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{n as J,d as K,m as F,p as h,f as Q,u as f}from"../packem_shared/table-DdJBrClo.js";import{N as X}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{i as ee}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",P=e=>e.endpoint??e.id,ve=()=>{const e=W(38),r=Y(),[i,R]=T("all"),[s,V]=T("");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:S,error:o,errorSource:p,isLoading:C,refetch:v}=X(Z.listPushSubscriptions,g);let N;if(e[1]!==S?.subscriptions||e[2]!==o||e[3]!==p||e[4]!==C||e[5]!==i||e[6]!==v||e[7]!==s||e[8]!==r){const A=S?.subscriptions??[],j=s.trim().toLowerCase(),E=A.filter(a=>i!=="all"&&a.kind!==i?!1:j===""?!0:`${P(a)} ${a.userId??""}`.toLowerCase().includes(j));let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=a=>{V(a.target.value)},e[10]=b):b=e[10];const D=b;let w;e[11]!==v?(w=()=>{v()},e[11]=v,e[12]=w):w=e[12];const I=w;let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=["all","web-push","fcm"],e[13]=y):y=e[13];const H=y;let l;e[14]!==i||e[15]!==r?(l=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:H.map(a=>t(z,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:()=>{R(a)},role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=l):l=e[16];let n;e[17]!==r?(n=r("Filter devices"),e[17]=r,e[18]=n):n=e[18];let c;e[19]!==r?(c=r("filter endpoint, user"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s||e[22]!==n||e[23]!==c?(d=t(G,{"aria-label":n,className:"h-8 w-56","data-testid":"nt-search",onChange:D,placeholder:c,value:s}),e[21]=s,e[22]=n,e[23]=c,e[24]=d):d=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let u;e[27]!==I||e[28]!==m?(u=t(z,{className:"ml-auto","data-testid":"nt-refresh",onClick:I,size:"sm",type:"button",variant:"outline",children:m}),e[27]=I,e[28]=m,e[29]=u):u=e[29];const L=A.length>0&&t(_,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:A.length})});let $;e[30]!==u||e[31]!==L||e[32]!==l||e[33]!==d?($=x("div",{className:"flex flex-wrap items-center gap-2",children:[l,d,u,L]}),e[30]=u,e[31]=L,e[32]=l,e[33]=d,e[34]=$):$=e[34];let k;e[35]!==o||e[36]!==p?(k=o!==null&&t(B,{error:p,testId:"nt-error"}),e[35]=o,e[36]=p,e[37]=k):k=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[$,k,o===null&&!C&&E.length===0&&t(q,{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.")}),E.length>0&&t(O,{className:"overflow-hidden py-0",children:t(U,{className:"max-h-[30rem] overflow-auto px-0",children:x(J,{"data-testid":"nt-table",children:[t(K,{children:x(F,{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(Q,{children:E.map(a=>{const M=P(a);return x(F,{"data-testid":"nt-row",children:[t(f,{children:t(_,{variant:"outline",children:a.kind})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs",title:M,children:M}),t(f,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(f,{className:"text-muted-foreground tabular-nums",children:ee(a.lastSeenAt,"—")}),t(f,{children:t(_,{"data-testid":`nt-status-${a.id}`,variant:te(a.lastStatus),children:a.lastStatus??r("n/a")})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},a.id)})})]})})})]}),e[1]=S?.subscriptions,e[2]=o,e[3]=p,e[4]=C,e[5]=i,e[6]=v,e[7]=s,e[8]=r,e[9]=N}else N=e[9];return N};export{ve as NotificationsPanel};
@@ -1 +1 @@
1
- import{useLunora as E}from"@lunora/react";import{useState as s,useCallback as H,useEffect as W}from"react";import{ConfirmButton as F}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as Z}from"../packem_shared/badge-BbuuAio7.js";import{u as _}from"../packem_shared/button-BkCrNcAs.js";import{u as I}from"../packem_shared/input-JHu63lTv.js";import{p as g}from"../packem_shared/label-6uP1obNF.js";import{useAutoRefresh as G}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{c as u,e as y,f as p,a as S}from"../packem_shared/internal-AtZ4bTal.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";const N=S(B.getPitrBookmark),Q=S(B.pitrRestore),de=({initialShardKey:T})=>{const m=E(),t=J(),l=T??"",[O,f]=s(null),[i,P]=s(""),[v,w]=s(null),[c,q]=s(""),[h,A]=s(!1),[o,L]=s(null),[C,n]=s(null),[x,d]=s(!1),k=H(async()=>{d(!0),n(null);try{const e=await m.query(N,{},u(l));f(e.current)}catch(e){n(y(e))}finally{d(!1)}},[m,l]);W(()=>{p(k())},[k]),G(()=>{p((async()=>{try{const e=await m.query(N,{},u(l));f(e.current)}catch{}})())},!0);const U=e=>{P(e.target.value)},j=e=>{q(e.target.value)},M=e=>{A(e.target.checked)},z=()=>{i.trim()!==""&&p((async()=>{d(!0),n(null);try{const e=await m.query(N,{time:i.trim()},u(l));w(e.forTime??null),f(e.current)}catch(e){w(null),n(y(e))}finally{d(!1)}})())},R=e=>{p((async()=>{d(!0),n(null);try{const b=await m.mutation(Q,e,u(l));L(b),await k()}catch(b){n(y(b))}finally{d(!1)}})())},K=c.trim()!==""||i.trim()!=="",$=()=>{const e=h?{restart:!0}:{};c.trim()===""?e.time=i.trim():e.bookmark=c.trim(),R(e)},D=()=>{o!==null&&R(h?{bookmark:o.undoBookmark,restart:!0}:{bookmark:o.undoBookmark})};return a("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[r("div",{className:"flex flex-wrap items-center gap-3",children:a("span",{className:"text-xs text-muted-foreground",children:[t("Shard"),": ",r("span",{className:"font-mono",children:l===""?t("root"):l})]})}),r("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),C!==null&&r("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:C}),a("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"mb-2 text-sm font-semibold",children:t("Current bookmark")}),r("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:O??r("span",{className:"text-muted-foreground",children:"—"})})]}),a("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore")}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-time",children:t("Time (ISO or epoch-ms, last 30 days)")}),a("div",{className:"flex items-center gap-2",children:[r(I,{"data-testid":"pitr-time",id:"pitr-time",onChange:U,placeholder:"2026-06-01T00:00:00.000Z",value:i}),r(_,{"data-testid":"pitr-preview",disabled:x||i.trim()==="",onClick:z,size:"sm",type:"button",variant:"outline",children:t("Preview")})]}),v!==null&&a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]})]}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-bookmark",children:t("Or an explicit bookmark (wins over time)")}),r(I,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:j,placeholder:t("bookmark string"),value:c})]}),a(g,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[r("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:M,type:"checkbox"}),t("Restart the shard now so recovery applies immediately")]}),r("div",{children:r(F,{confirmLabel:t("Confirm restore"),disabled:x||!K,onConfirm:$,testId:"pitr-restore",children:t("Restore")})})]}),o!==null&&a("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[a("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),r(Z,{variant:o.restarted?"destructive":"secondary",children:o.restarted?t("restarted now"):t("on next restart")})]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",o.restoredTo]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",o.undoBookmark]}),r("div",{children:r(F,{confirmLabel:t("Confirm undo"),disabled:x,onConfirm:D,testId:"pitr-undo",children:t("Undo restore")})})]})]})};export{de as PitrPanel};
1
+ import{useLunora as E}from"@lunora/react";import{useState as s,useCallback as H,useEffect as W}from"react";import{ConfirmButton as F}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as Z}from"../packem_shared/badge-BbuuAio7.js";import{u as _}from"../packem_shared/button-BkCrNcAs.js";import{u as I}from"../packem_shared/input-JHu63lTv.js";import{p as g}from"../packem_shared/label-6uP1obNF.js";import{useAutoRefresh as G}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{d as u,b as N,f as p,g as S}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";const y=S(B.getPitrBookmark),Q=S(B.pitrRestore),de=({initialShardKey:T})=>{const m=E(),t=J(),i=T??"",[O,f]=s(null),[l,P]=s(""),[v,w]=s(null),[c,q]=s(""),[h,A]=s(!1),[o,L]=s(null),[C,n]=s(null),[x,d]=s(!1),b=H(async()=>{d(!0),n(null);try{const e=await m.query(y,{},u(i));f(e.current)}catch(e){n(N(e))}d(!1)},[m,i]);W(()=>{p(b())},[b]),G(()=>{p((async()=>{try{const e=await m.query(y,{},u(i));f(e.current)}catch{}})())},!0);const U=e=>{P(e.target.value)},j=e=>{q(e.target.value)},M=e=>{A(e.target.checked)},z=()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{const e=await m.query(y,{time:l.trim()},u(i));w(e.forTime??null),f(e.current)}catch(e){w(null),n(N(e))}d(!1)})())},R=e=>{p((async()=>{d(!0),n(null);try{const k=await m.mutation(Q,e,u(i));L(k),await b()}catch(k){n(N(k))}d(!1)})())},K=c.trim()!==""||l.trim()!=="",$=()=>{const e=h?{restart:!0}:{};c.trim()===""?e.time=l.trim():e.bookmark=c.trim(),R(e)},D=()=>{o!==null&&R(h?{bookmark:o.undoBookmark,restart:!0}:{bookmark:o.undoBookmark})};return a("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[r("div",{className:"flex flex-wrap items-center gap-3",children:a("span",{className:"text-xs text-muted-foreground",children:[t("Shard"),": ",r("span",{className:"font-mono",children:i===""?t("root"):i})]})}),r("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),C!==null&&r("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:C}),a("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"mb-2 text-sm font-semibold",children:t("Current bookmark")}),r("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:O??r("span",{className:"text-muted-foreground",children:"—"})})]}),a("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore")}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-time",children:t("Time (ISO or epoch-ms, last 30 days)")}),a("div",{className:"flex items-center gap-2",children:[r(I,{"data-testid":"pitr-time",id:"pitr-time",onChange:U,placeholder:"2026-06-01T00:00:00.000Z",value:l}),r(_,{"data-testid":"pitr-preview",disabled:x||l.trim()==="",onClick:z,size:"sm",type:"button",variant:"outline",children:t("Preview")})]}),v!==null&&a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]})]}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-bookmark",children:t("Or an explicit bookmark (wins over time)")}),r(I,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:j,placeholder:t("bookmark string"),value:c})]}),a(g,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[r("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:M,type:"checkbox"}),t("Restart the shard now so recovery applies immediately")]}),r("div",{children:r(F,{confirmLabel:t("Confirm restore"),disabled:x||!K,onConfirm:$,testId:"pitr-restore",children:t("Restore")})})]}),o!==null&&a("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[a("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),r(Z,{variant:o.restarted?"destructive":"secondary",children:o.restarted?t("restarted now"):t("on next restart")})]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",o.restoredTo]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",o.undoBookmark]}),r("div",{children:r(F,{confirmLabel:t("Confirm undo"),disabled:x,onConfirm:D,testId:"pitr-undo",children:t("Undo restore")})})]})]})};export{de as PitrPanel};
@@ -1,2 +1 @@
1
- 'use client';
2
- import{c as Y}from"react/compiler-runtime";import{useLunora as At}from"@lunora/react";import{useState as v,useRef as Ct,useEffect as Ge}from"react";import{ShardInput as qt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ct,d as be}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as we}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as mt,n as ut,f as pt,m as ht,u as gt}from"../packem_shared/card-CIDGUN6K.js";import{E as Ut}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ae}from"../packem_shared/input-JHu63lTv.js";import Bt from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ue}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as tt}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{f as M,c as Qe,e as Ye,a as at}from"../packem_shared/internal-AtZ4bTal.js";import{r as Gt}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as Ke}from"../packem_shared/utils-bhneXptQ.js";import{Download01Icon as Kt}from"@hugeicons/core-free-icons";import{HugeiconsIcon as Dt}from"@hugeicons/react";import{Handle as vt,Position as yt,getNodesBounds as Ht,getViewportForBounds as Jt,useNodesState as Vt,useEdgesState as Wt,Background as Xt,Panel as ft,Controls as Zt,MiniMap as Qt,ReactFlow as Yt,useNodes as ea,useReactFlow as ta}from"@xyflow/react";import{h as aa,$ as la,b as na,N as dt}from"../packem_shared/dropdown-menu-C3RQ_HlW.js";import{jsx as n,jsxs as u}from"react/jsx-runtime";import{LunoraError as sa}from"@lunora/errors";import{toBlob as ra,toSvg as oa}from"html-to-image";import{useNavigate as ia}from"@tanstack/react-router";import{p as Ne}from"../packem_shared/label-6uP1obNF.js";function da(a){const e=Y(10);let t,o,r;e[0]!==a?({className:t,selected:r,...o}=a,e[0]=a,e[1]=t,e[2]=o,e[3]=r):(t=e[1],o=e[2],r=e[3]);const s=r===!0?"":void 0;let l;e[4]!==t?(l=Ke("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=l):l=e[5];let i;return e[6]!==o||e[7]!==s||e[8]!==l?(i=n("div",{"data-slot":"base-node","data-selected":s,className:l,...o}),e[6]=o,e[7]=s,e[8]=l,e[9]=i):i=e[9],i}function ca(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-header",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}function ma(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-content",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}const Nt=a=>{const e=a.ref===void 0?a.type:`${a.type} → ${a.ref}`;return a.optional===!0?`${e}?`:e},ua=a=>{const e=Y(22),{data:t,selected:o}=a,r=Ue();let s;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(s=t.loadError===!0?n("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):n("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"—"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=s):s=e[3];const l=s,i=`sd-node-${t.label}`;let m;e[4]!==t.label?(m=n("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=m):m=e[5];let d;e[6]!==t.tier?(d=n("span",{className:"ms-auto",children:n(ct,{tier:t.tier})}),e[6]=t.tier,e[7]=d):d=e[7];let f;e[8]!==m||e[9]!==d?(f=u(ca,{children:[m,d]}),e[8]=m,e[9]=d,e[10]=f):f=e[10];let g;e[11]!==t.columns||e[12]!==t.label||e[13]!==l?(g=t.columns.length===0?l:t.columns.map(x=>u("div",{className:Ke("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",x.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${x.name}`,children:[n(vt,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Left,type:"target"}),n("span",{className:"truncate font-mono",title:x.name,children:x.name}),x.pk===!0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),x.ref!==void 0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),n("span",{className:"ms-auto truncate text-muted-foreground",title:Nt(x),children:Nt(x)}),n(vt,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Right,type:"source"})]},x.name)),e[11]=t.columns,e[12]=t.label,e[13]=l,e[14]=g):g=e[14];let b;e[15]!==g?(b=n(ma,{children:g}),e[15]=g,e[16]=b):b=e[16];let p;return e[17]!==o||e[18]!==i||e[19]!==f||e[20]!==b?(p=u(da,{className:"w-64 overflow-hidden","data-testid":i,selected:o,children:[f,b]}),e[17]=o,e[18]=i,e[19]=f,e[20]=b,e[21]=p):p=e[21],p},qe=1920,et=1080,Tt=32,bt=(a,e)=>{const t=globalThis.document.createElement("a");t.href=a,t.download=e,globalThis.document.body.append(t),t.click(),t.remove()},pa=(a,e,t="schema-diagram.json")=>{const o={edges:e,exportedAt:new Date().toISOString(),nodes:a},r=JSON.stringify(o,void 0,2),s=globalThis.URL.createObjectURL(new globalThis.Blob([r],{type:"application/json"}));bt(s,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(s)},0)},_t=(a,e,t,o)=>{const r=Ht(a),{x:s,y:l,zoom:i}=Jt(r,e,t,.1,2,o);return{transform:[s,l,i],zoom:i}},ha=async(a,e,t="schema-diagram.png")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await ra(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});if(i===null)throw new sa("INTERNAL","html-to-image produced no blob");const m=globalThis.URL.createObjectURL(i);bt(m,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(m)},0)},ga=async(a,e,t="schema-diagram.svg")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await oa(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});bt(i,t)},fa=a=>38+Math.max(1,a)*28,ba=(a,e)=>{const t=new Map;for(const l of a)t.set(l,[]);for(const l of e)l.to!==l.from&&t.has(l.from)&&t.has(l.to)&&t.get(l.from)?.push(l.to);const o=new Map,r=new Set,s=l=>{const i=o.get(l);if(i!==void 0)return i;if(r.has(l))return 0;r.add(l);let m=0;for(const d of t.get(l)??[])m=Math.max(m,s(d)+1);return r.delete(l),o.set(l,m),m};for(const l of a)s(l);return o},xa=(a,e,t)=>{const o=ba(a,e),r=new Map,s=[];for(const l of a){const i=o.get(l)??0,m=r.get(i)??24;s.push({name:l,x:24+i*368,y:m}),r.set(i,m+fa(t.get(l)??0)+36)}return s},va={databaseSchema:ua},It={backgroundColor:be.shard.color},zt={backgroundColor:be.global.color},ya={global:!0,shard:!0},Na=a=>{const e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},Et=a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),wa=(a,e)=>{const t=a.map(l=>l.name),o=new Map(a.map(l=>[l.name,l.columns.length])),r=xa(t,Et(a),o),s=new Map(a.map(l=>[l.name,l]));return r.flatMap(({name:l,x:i,y:m})=>{const d=s.get(l);return d===void 0?[]:[{data:{columns:d.columns,label:l,loadError:e,tier:d.tier},id:l,position:{x:i,y:m},type:"databaseSchema"}]})},Sa=a=>{const e=new Map(a.map(t=>[t.name,t.columns]));return Et(a).flatMap(t=>{const o=e.get(t.to)??[],r=e.get(t.from)??[],s=Na(o);return!o.some(l=>l.name===s)||!r.some(l=>l.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:s,target:t.from,targetHandle:t.column}]})},$a=()=>{const a=Y(15),e=Ue();let t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),be.shard.label]}),a[0]=t):t=a[0];let o;a[1]===Symbol.for("react.memo_cache_sentinel")?(o=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),be.global.label]}),a[1]=o):o=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let s;a[3]!==e?(s=e("Primary key"),a[3]=e,a[4]=s):s=a[4];let l;a[5]!==s?(l=u("span",{className:"flex items-center gap-1",children:[r,s]}),a[5]=s,a[6]=l):l=a[6];let i;a[7]===Symbol.for("react.memo_cache_sentinel")?(i=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=i):i=a[7];let m;a[8]!==e?(m=e("Foreign key"),a[8]=e,a[9]=m):m=a[9];let d;a[10]!==m?(d=u("span",{className:"flex items-center gap-1",children:[i,m]}),a[10]=m,a[11]=d):d=a[11];let f;return a[12]!==l||a[13]!==d?(f=u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,o,l,d]}),a[12]=l,a[13]=d,a[14]=f):f=a[14],f},ka=({containerRef:a,testIdPrefix:e})=>{const t=Ue(),o=ea(),{getEdges:r}=ta(),[s,l]=v(null),i=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("png");try{await ha(b,o,`${e}-schema-diagram.png`)}finally{l(null)}}},m=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("svg");try{await ga(b,o,`${e}-schema-diagram.svg`)}finally{l(null)}}},d=()=>{l("json");try{pa(o,r(),`${e}-schema-diagram.json`)}finally{l(null)}},f=()=>{M(i())},g=()=>{M(m())};return n(ft,{position:"top-right",children:u(aa,{children:[u(la,{className:"group/button inline-flex shrink-0 cursor-pointer items-center justify-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium whitespace-nowrap hover:bg-muted disabled:pointer-events-none disabled:opacity-50","data-testid":`${e}-export-trigger`,disabled:s!==null,children:[n(Dt,{className:"size-3.5",icon:Kt,strokeWidth:2}),t("Export")]}),u(na,{align:"end",children:[n(dt,{"data-testid":`${e}-export-png`,disabled:s!==null,onClick:f,children:t("PNG")}),n(dt,{"data-testid":`${e}-export-svg`,disabled:s!==null,onClick:g,children:t("SVG")}),n(dt,{"data-testid":`${e}-export-json`,disabled:s!==null,onClick:d,children:t("JSON")})]})]})})},Ca=a=>{const e=Y(75),{columnsError:t,tables:o,testIdPrefix:r}=a,s=Ue(),[l,i]=v(ya),[m,d]=v("");let f;if(e[0]!==m||e[1]!==o||e[2]!==l){const k=m.trim().toLowerCase();f=o.filter(X=>l[X.tier]&&X.name.toLowerCase().includes(k)),e[0]=m,e[1]=o,e[2]=l,e[3]=f}else f=e[3];const g=f,b=t??!1;let p;e[4]!==b||e[5]!==g?(p=wa(g,b),e[4]=b,e[5]=g,e[6]=p):p=e[6];const x=p;let C;e[7]!==g?(C=Sa(g),e[7]=g,e[8]=C):C=e[8];const T=C,[ee,_,re]=Vt(x),[R,B,oe]=Wt(T),P=Ct(null);let O,F;e[9]!==x||e[10]!==_?(O=()=>{_(x)},F=[x,_],e[9]=x,e[10]=_,e[11]=O,e[12]=F):(O=e[11],F=e[12]),Ge(O,F);let A,ie;e[13]!==T||e[14]!==B?(A=()=>{B(T)},ie=[T,B],e[13]=T,e[14]=B,e[15]=A,e[16]=ie):(A=e[15],ie=e[16]),Ge(A,ie);let G;e[17]===Symbol.for("react.memo_cache_sentinel")?(G=k=>{d(k.target.value)},e[17]=G):G=e[17];const Se=G;let de;e[18]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{i(Ta)},e[18]=de):de=e[18];const w=de;let ce;e[19]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{i(_a)},e[19]=ce):ce=e[19];const S=ce;if(o.length===0){const k=`${r}-section`,X=`${r}-empty`;let ne;e[20]!==s?(ne=s("No tables to graph."),e[20]=s,e[21]=ne):ne=e[21];let Z;e[22]!==X||e[23]!==ne?(Z=n("p",{className:"text-sm text-muted-foreground","data-testid":X,children:ne}),e[22]=X,e[23]=ne,e[24]=Z):Z=e[24];let Q;return e[25]!==k||e[26]!==Z?(Q=n("section",{className:"flex flex-col gap-2","data-testid":k,children:Z}),e[25]=k,e[26]=Z,e[27]=Q):Q=e[27],Q}const me=`${r}-section`,te=`${r}-canvas`;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=n(Xt,{}),e[28]=E):E=e[28];let ae;e[29]!==s?(ae=s("Find table…"),e[29]=s,e[30]=ae):ae=e[30];const q=`${r}-find`;let K;e[31]!==s?(K=s("Find table…"),e[31]=s,e[32]=K):K=e[32];let L;e[33]!==m||e[34]!==ae||e[35]!==q||e[36]!==K?(L=n(Ae,{"aria-label":ae,className:"h-7 w-44 text-xs","data-testid":q,onChange:Se,placeholder:K,value:m}),e[33]=m,e[34]=ae,e[35]=q,e[36]=K,e[37]=L):L=e[37];let h;e[38]!==s?(h=s("Storage tiers"),e[38]=s,e[39]=h):h=e[39];const $=`${r}-tier-shard`,xe=l.shard?"default":"outline";let ue;e[40]===Symbol.for("react.memo_cache_sentinel")?(ue=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),e[40]=ue):ue=e[40];let D;e[41]!==$||e[42]!==xe||e[43]!==l.shard?(D=u(z,{"aria-pressed":l.shard,className:"gap-1.5","data-testid":$,onClick:w,size:"xs",type:"button",variant:xe,children:[ue,be.shard.label]}),e[41]=$,e[42]=xe,e[43]=l.shard,e[44]=D):D=e[44];const ve=`${r}-tier-global`,ye=l.global?"default":"outline";let pe;e[45]===Symbol.for("react.memo_cache_sentinel")?(pe=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),e[45]=pe):pe=e[45];let j;e[46]!==ve||e[47]!==ye||e[48]!==l.global?(j=u(z,{"aria-pressed":l.global,className:"gap-1.5","data-testid":ve,onClick:S,size:"xs",type:"button",variant:ye,children:[pe,be.global.label]}),e[46]=ve,e[47]=ye,e[48]=l.global,e[49]=j):j=e[49];let H;e[50]!==h||e[51]!==D||e[52]!==j?(H=u("div",{"aria-label":h,className:"flex items-center gap-1.5",role:"group",children:[D,j]}),e[50]=h,e[51]=D,e[52]=j,e[53]=H):H=e[53];let le;e[54]!==L||e[55]!==H?(le=n(ft,{position:"top-left",children:u("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[L,H]})}),e[54]=L,e[55]=H,e[56]=le):le=e[56];let $e,he,ge;e[57]===Symbol.for("react.memo_cache_sentinel")?($e=n(ft,{position:"bottom-left",children:n($a,{})}),he=n(Zt,{showInteractive:!1}),ge=n(Qt,{pannable:!0,zoomable:!0}),e[57]=$e,e[58]=he,e[59]=ge):($e=e[57],he=e[58],ge=e[59]);let J;e[60]!==r?(J=n(ka,{containerRef:P,testIdPrefix:r}),e[60]=r,e[61]=J):J=e[61];let V;e[62]!==R||e[63]!==ee||e[64]!==oe||e[65]!==re||e[66]!==le||e[67]!==J?(V=u(Yt,{edges:R,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:ee,nodesConnectable:!1,nodeTypes:va,onEdgesChange:oe,onNodesChange:re,children:[E,le,$e,he,ge,J]}),e[62]=R,e[63]=ee,e[64]=oe,e[65]=re,e[66]=le,e[67]=J,e[68]=V):V=e[68];let W;e[69]!==te||e[70]!==V?(W=n("div",{className:"h-[560px] w-full overflow-hidden rounded-xl border border-border bg-muted/20 shadow-xs","data-testid":te,ref:P,children:V}),e[69]=te,e[70]=V,e[71]=W):W=e[71];let fe;return e[72]!==me||e[73]!==W?(fe=n("section",{className:"flex flex-col gap-2","data-testid":me,children:W}),e[72]=me,e[73]=W,e[74]=fe):fe=e[74],fe};function Ta(a){return{...a,shard:!a.shard}}function _a(a){return{...a,global:!a.global}}const Ia="/__lunora/schema-edit",za=async a=>{const e=await fetch(Ia,{body:JSON.stringify(a),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),t=await e.json();return t.needsMigration===!0?{kind:"needs-migration",message:t.message??"This edit needs a migration."}:e.ok&&t.tables!==void 0?{diagnostics:t.diagnostics??[],kind:"ok",tables:t.tables}:{kind:"error",message:t.error??`schema edit failed (${String(e.status)})`}},Ea=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],ja="v.string()",Oa=a=>a.split(",").map(e=>e.trim()).filter(e=>e!==""),Fa=({onApplied:a,tableNames:e})=>{const t=Ue(),o=ia(),[r,s]=v(null),[l,i]=v(!1),[m,d]=v(null),[f,g]=v(""),[b,p]=v(""),[x,C]=v(ja),[T,ee]=v(e[0]??""),[_,re]=v(""),[R,B]=v(""),[oe,P]=v(!1),O=()=>{s(null),g(""),p(""),re(""),B(""),P(!1)},F=async h=>{i(!0),d(null);try{const $=await za(h);d($),$.kind==="ok"&&(a($.tables),O())}catch($){d({kind:"error",message:$ instanceof Error?$.message:String($)})}finally{i(!1)}},A=()=>{M(F({kind:"addTable",table:f.trim()}))},ie=()=>{M(F({column:b.trim(),kind:"addOptionalColumn",table:T,validator:x}))},G=()=>{M(F({fields:Oa(R),kind:"addIndex",name:_.trim(),table:T,unique:oe}))},Se=()=>{d(null),s("addTable")},de=()=>{d(null),s("addColumn")},w=()=>{d(null),s("addIndex")},ce=()=>{s("destructive"),d({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},S=h=>{g(h.target.value)},me=h=>{p(h.target.value)},te=h=>{C(h.target.value)},E=h=>{ee(h.target.value)},ae=h=>{re(h.target.value)},q=h=>{B(h.target.value)},K=h=>{P(h.target.checked)},L=()=>{M(o({to:"/migrations"}))};return u(mt,{"data-testid":"sc-editor",size:"sm",children:[u(ut,{children:[n(pt,{children:t("Edit schema")}),n(ht,{children:t("Adds a table, column, or index to lunora/schema.ts and reruns codegen.")})]}),u(gt,{children:[u("div",{className:"flex flex-wrap gap-2",children:[n(z,{"data-testid":"sc-editor-add-table",onClick:Se,size:"xs",type:"button",variant:r==="addTable"?"default":"outline",children:t("Add table")}),n(z,{"data-testid":"sc-editor-add-column",disabled:e.length===0,onClick:de,size:"xs",type:"button",variant:r==="addColumn"?"default":"outline",children:t("Add column")}),n(z,{"data-testid":"sc-editor-add-index",disabled:e.length===0,onClick:w,size:"xs",type:"button",variant:r==="addIndex"?"default":"outline",children:t("Add index")}),n(z,{"data-testid":"sc-editor-destructive",disabled:e.length===0,onClick:ce,size:"xs",type:"button",variant:r==="destructive"?"default":"ghost",children:t("Rename / drop / change type…")})]}),r==="addTable"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-table-name",children:t("Table name")}),n(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:S,value:f})]}),n(z,{"data-testid":"sc-editor-table-apply",disabled:l||f.trim()==="",onClick:A,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addColumn"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-table",children:t("Table name")}),n("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:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-name",children:t("Column name")}),n(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:me,value:b})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-type",children:t("Column type")}),n("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:te,value:x,children:Ea.map(h=>n("option",{value:h.validator,children:h.label},h.validator))})]}),n("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),n(z,{"data-testid":"sc-editor-column-apply",disabled:l||b.trim()===""||T==="",onClick:ie,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addIndex"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-table",children:t("Table name")}),n("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:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-name",children:t("Index name")}),n(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ae,value:_})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),n(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:q,value:R})]}),u(Ne,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[n("input",{checked:oe,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:K,type:"checkbox"}),n("span",{className:"text-muted-foreground",children:t("Unique")})]}),n(z,{"data-testid":"sc-editor-index-apply",disabled:l||_.trim()===""||R.trim()==="",onClick:G,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),m?.kind==="error"&&n("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:m.message}),m?.kind==="needs-migration"&&u("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[n("p",{className:"text-sm text-warning",role:"alert",children:t("This edit changes stored data and must go through a migration. Review the migration before applying.")}),n(z,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:L,size:"xs",type:"button",variant:"outline",children:t("Open Migrations")})]}),m?.kind==="ok"&&m.diagnostics.length>0&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[n("p",{className:"text-sm text-destructive",role:"alert",children:t("Codegen reported diagnostics:")}),n("ul",{className:"flex flex-col gap-0.5",children:m.diagnostics.map(h=>n("li",{className:"font-mono text-[11px] text-destructive",children:h},h))})]})]})]})},La=at(tt.listTables),Ma=at(tt.listTableIndexes),Ra=at(tt.readTablePage),Pa=at(tt.describeTables),Aa={},wt=[],St=[],qa=a=>{const e=Y(5),{open:t}=a,o=t&&"rotate-90";let r;e[0]!==o?(r=Ke("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",o),e[0]=o,e[1]=r):r=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=n("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let l;return e[3]!==r?(l=n("svg",{"aria-hidden":"true",className:r,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=r,e[4]=l):l=e[4],l},$t=a=>{const e=Y(20),{children:t,expanded:o,name:r,onToggle:s,rowCount:l,rowTestId:i,toggleTestId:m}=a;let d;e[0]!==o?(d=n(qa,{open:o}),e[0]=o,e[1]=d):d=e[1];let f;e[2]!==r?(f=n("span",{className:"truncate font-mono text-xs text-foreground",title:r,children:r}),e[2]=r,e[3]=f):f=e[3];let g;e[4]!==l?(g=u("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",l,")"]}),e[4]=l,e[5]=g):g=e[5];let b;e[6]!==o||e[7]!==s||e[8]!==d||e[9]!==f||e[10]!==g||e[11]!==m?(b=u("button",{"aria-expanded":o,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":m,onClick:s,type:"button",children:[d,f," ",g]}),e[6]=o,e[7]=s,e[8]=d,e[9]=f,e[10]=g,e[11]=m,e[12]=b):b=e[12];let p;e[13]!==t||e[14]!==o?(p=o&&n("div",{className:"px-3 pb-3 ps-8",children:t}),e[13]=t,e[14]=o,e[15]=p):p=e[15];let x;return e[16]!==i||e[17]!==b||e[18]!==p?(x=u("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[b,p]}),e[16]=i,e[17]=b,e[18]=p,e[19]=x):x=e[19],x},kt=a=>{const e=Y(5),{columns:t,testId:o}=a;let r;e[0]!==t?(r=t.map(Ba),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r||e[3]!==o?(s=n("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":o,children:r}),e[2]=r,e[3]=o,e[4]=s):s=e[4],s},Ua=a=>{const e=Y(10),{heading:t,indexes:o,testId:r}=a;let s;e[0]!==t?(s=n("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:t}),e[0]=t,e[1]=s):s=e[1];let l;e[2]!==o?(l=o.map(Ga),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==l||e[5]!==r?(i=n("ul",{className:"flex flex-col gap-1","data-testid":r,children:l}),e[4]=l,e[5]=r,e[6]=i):i=e[6];let m;return e[7]!==s||e[8]!==i?(m=u("div",{className:"pt-3",children:[s,i]}),e[7]=s,e[8]=i,e[9]=m):m=e[9],m},vl=a=>{const e=Y(126),{initialShardKey:t,initialTable:o,schemaEditable:r}=a,s=At(),l=Ue(),[i,m]=v("list"),[d,f]=v(t??""),[g,b]=v(""),[p,x]=v(null),[C,T]=v(null);let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[0]=ee):ee=e[0];const[_,re]=v(ee);let R;e[1]===Symbol.for("react.memo_cache_sentinel")?(R={},e[1]=R):R=e[1];const[B,oe]=v(R),[P,O]=v(null);let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];const[A,ie]=v(F);let G;e[3]===Symbol.for("react.memo_cache_sentinel")?(G={},e[3]=G):G=e[3];const[Se,de]=v(G),[w,ce]=v(null),[S,me]=v(null);let te;e[4]===Symbol.for("react.memo_cache_sentinel")?(te={},e[4]=te):te=e[4];const[E,ae]=v(te),[q,K]=v(null);let L;e[5]!==s?(L=async c=>{T(null);try{const y=await s.query(La,{},Qe(c));Gt(c),x(y),re({}),oe({}),O(null),ie(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c}))),de(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c})))}catch(y){const N=y;x(null),T(Ye(N))}},e[5]=s,e[6]=L):L=e[6];const h=L;let $;e[7]!==s?($=async()=>{me(null);try{ce(await s.listGlobalTables())}catch(c){const y=c;ce(null),me(Ye(y))}},e[7]=s,e[8]=$):$=e[8];const xe=$;let ue;e[9]!==d?(ue=d.trim(),e[9]=d,e[10]=ue):ue=e[10];const D=Bt(ue,400);let ve,ye;e[11]!==D||e[12]!==h||e[13]!==xe?(ye=()=>{M(h(D)),M(xe())},ve=[h,xe,D],e[11]=D,e[12]=h,e[13]=xe,e[14]=ve,e[15]=ye):(ve=e[14],ye=e[15]),Ge(ye,ve);let pe;e[16]!==s||e[17]!==_||e[18]!==P||e[19]!==d?(pe=async c=>{if(P===c){O(null);return}O(c);const y=`${d}:${c}`;if(_[y]!==void 0)return;const[N,U]=await Promise.allSettled([s.query(Ra,{limit:1,offset:0,table:c},Qe(d)),s.query(Ma,{table:c},Qe(d))]);N.status==="fulfilled"?re(I=>({...I,[y]:N.value.columns})):T(Ye(N.reason)),U.status==="fulfilled"&&oe(I=>({...I,[y]:U.value.indexes}))},e[16]=s,e[17]=_,e[18]=P,e[19]=d,e[20]=pe):pe=e[20];const j=pe;let H;e[21]!==s||e[22]!==E||e[23]!==q?(H=async c=>{if(q===c){K(null);return}if(K(c),E[c]===void 0)try{const y=await s.readGlobalTablePage({limit:1,offset:0,table:c});ae(N=>({...N,[c]:y.columns}))}catch(y){me(Ye(y))}},e[21]=s,e[22]=E,e[23]=q,e[24]=H):H=e[24];const le=H,$e=Ct(void 0);let he,ge;e[25]!==o||e[26]!==p||e[27]!==j?(he=()=>{o===void 0||p===null||$e.current===o||p.some(c=>c.name===o)&&($e.current=o,M(j(o)))},ge=[o,p,j],e[25]=o,e[26]=p,e[27]=j,e[28]=he,e[29]=ge):(he=e[28],ge=e[29]),Ge(he,ge);let J;e[30]!==s?(J=async(c,y,N)=>{const[U,I]=await Promise.all([Promise.allSettled([s.query(Pa,{tables:[...y,...N]},Qe(c))]),Promise.all(N.map(async se=>{const Be=await Promise.allSettled([s.readGlobalTablePage({limit:1,offset:0,table:se})]),xt=Be[0].status==="fulfilled"?Be[0].value:void 0;return{columns:xt?.columns??[],refs:xt?.refs??{},table:se}}))]),Lt=U[0].status==="fulfilled"?U[0].value?.columnsByTable??{}:{},Mt=U[0].status==="rejected",Rt=new Map(I.map(Ka)),Pt=[...y,...N].map(se=>{const Be=Lt[se]??[];return[se,Be.length>0?Be:Rt.get(se)??[]]});ie(se=>({...se,[c]:Object.fromEntries(Pt)})),de(se=>({...se,[c]:Mt}))},e[30]=s,e[31]=J):J=e[31];const V=J;let W,fe;e[32]!==S||e[33]!==w||e[34]!==V||e[35]!==A||e[36]!==d||e[37]!==p||e[38]!==i?(W=()=>{i!=="graph"||p===null||w===null&&S===null||A[d]!==void 0||M(V(d,p.map(Da),(w??[]).map(Ha)))},fe=[i,p,w,S,d,A,V],e[32]=S,e[33]=w,e[34]=V,e[35]=A,e[36]=d,e[37]=p,e[38]=i,e[39]=W,e[40]=fe):(W=e[39],fe=e[40]),Ge(W,fe);const k=A[d]??Aa;let X;if(e[41]!==k||e[42]!==w||e[43]!==p){let c;e[45]!==k?(c=I=>({columns:k[I.name]??St,name:I.name,tier:"shard"}),e[45]=k,e[46]=c):c=e[46];const y=(p??[]).map(c);let N;e[47]!==k?(N=I=>({columns:k[I.name]??St,name:I.name,tier:"global"}),e[47]=k,e[48]=N):N=e[48];const U=(w??[]).map(N);X=[...y,...U],e[41]=k,e[42]=w,e[43]=p,e[44]=X}else X=e[44];const ne=X;let Z;if(e[49]!==g||e[50]!==p){const c=g.trim().toLowerCase();Z=(p??[]).filter(y=>y.name.toLowerCase().includes(c)),e[49]=g,e[50]=p,e[51]=Z}else Z=e[51];const Q=Z;let De;if(e[52]!==w||e[53]!==g){const c=g.trim().toLowerCase();De=(w??[]).filter(y=>y.name.toLowerCase().includes(c)),e[52]=w,e[53]=g,e[54]=De}else De=e[54];const ke=De;let He;e[55]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{m("list")},e[55]=He):He=e[55];const jt=He;let Je;e[56]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>{m("graph")},e[56]=Je):Je=e[56];const Ot=Je;let Ve;e[57]===Symbol.for("react.memo_cache_sentinel")?(Ve=c=>{b(c.target.value)},e[57]=Ve):Ve=e[57];const Ft=Ve;let We;e[58]!==h||e[59]!==d?(We=c=>{M(h(d))},e[58]=h,e[59]=d,e[60]=We):We=e[60];const lt=We;let Ce;e[61]!==p?(Ce=p??[],e[61]=p,e[62]=Ce):Ce=e[62];let Xe;e[63]!==Ce?(Xe=Ce.map(Ja),e[63]=Ce,e[64]=Xe):Xe=e[64];const nt=Xe;let Te;e[65]!==d?(Te=n(qt,{onChange:f,testId:"sc-shard-input",value:d}),e[65]=d,e[66]=Te):Te=e[66];let _e;e[67]!==l?(_e=l("Schema view"),e[67]=l,e[68]=_e):_e=e[68];const st=i==="list",rt=i==="list"?"default":"outline";let Ie;e[69]!==l?(Ie=l("Table list"),e[69]=l,e[70]=Ie):Ie=e[70];let ze;e[71]!==st||e[72]!==rt||e[73]!==Ie?(ze=n(z,{"aria-pressed":st,"data-testid":"sc-view-list",onClick:jt,size:"xs",type:"button",variant:rt,children:Ie}),e[71]=st,e[72]=rt,e[73]=Ie,e[74]=ze):ze=e[74];const ot=i==="graph",it=i==="graph"?"default":"outline";let Ee;e[75]!==l?(Ee=l("Graph"),e[75]=l,e[76]=Ee):Ee=e[76];let je;e[77]!==ot||e[78]!==it||e[79]!==Ee?(je=n(z,{"aria-pressed":ot,"data-testid":"sc-view-graph",onClick:Ot,size:"xs",type:"button",variant:it,children:Ee}),e[77]=ot,e[78]=it,e[79]=Ee,e[80]=je):je=e[80];let Oe;e[81]!==_e||e[82]!==ze||e[83]!==je?(Oe=u("div",{"aria-label":_e,className:"flex gap-1.5","data-testid":"sc-view-toggle",role:"group",children:[ze,je]}),e[81]=_e,e[82]=ze,e[83]=je,e[84]=Oe):Oe=e[84];let Fe;e[85]!==Te||e[86]!==Oe?(Fe=u("div",{className:"flex flex-wrap items-center gap-3",children:[Te,Oe]}),e[85]=Te,e[86]=Oe,e[87]=Fe):Fe=e[87];let Le;e[88]!==lt||e[89]!==r||e[90]!==nt?(Le=r===!0&&n(Fa,{onApplied:lt,tableNames:nt}),e[88]=lt,e[89]=r,e[90]=nt,e[91]=Le):Le=e[91];let Me;e[92]!==l||e[93]!==g||e[94]!==i?(Me=i==="list"&&n(Ae,{"aria-label":l("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Ft,placeholder:l("Filter tables"),value:g}),e[92]=l,e[93]=g,e[94]=i,e[95]=Me):Me=e[95];let Re;e[96]!==ne||e[97]!==C||e[98]!==S||e[99]!==Se||e[100]!==d||e[101]!==i?(Re=i==="graph"&&u("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),n(Ca,{columnsError:Se[d]===!0,tables:ne,testIdPrefix:"sc-graph"})]}),e[96]=ne,e[97]=C,e[98]=S,e[99]=Se,e[100]=d,e[101]=i,e[102]=Re):Re=e[102];let Pe;e[103]!==_||e[104]!==C||e[105]!==P||e[106]!==ke||e[107]!==Q||e[108]!==E||e[109]!==S||e[110]!==q||e[111]!==w||e[112]!==B||e[113]!==d||e[114]!==l||e[115]!==p||e[116]!==j||e[117]!==le||e[118]!==i?(Pe=i==="list"&&u("div",{className:"flex flex-col gap-4",children:[u(mt,{"data-testid":"sc-shard-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"shard"}),n(pt,{children:l("Shard tables")}),p!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:Q.length})]}),n(ht,{children:be.shard.hint})]}),u(gt,{children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),p!==null&&p.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:l("No tables in this shard.")}),p!==null&&p.length>0&&Q.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:l("No tables match your filter.")}),Q.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:Q.map(c=>{const y=`${d}:${c.name}`,N=B[y]??[];return u($t,{expanded:P===c.name,name:c.name,onToggle:()=>{M(j(c.name))},rowCount:c.rowCount,rowTestId:`sc-table-${c.name}`,toggleTestId:`sc-toggle-${c.name}`,children:[n(kt,{columns:_[y]??wt,testId:`sc-columns-${c.name}`}),N.length>0&&n(Ua,{heading:l("Indexes"),indexes:N,testId:`sc-indexes-${c.name}`})]},c.name)})})]})]}),u(mt,{"data-testid":"sc-global-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"global"}),n(pt,{children:l("Global tables (D1)")}),w!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:ke.length})]}),n(ht,{children:be.global.hint})]}),u(gt,{children:[S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),w!==null&&w.length===0&&n(Ut,{description:be.global.hint,testId:"sc-global-empty",title:l("No global tables.")}),w!==null&&w.length>0&&ke.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:l("No tables match your filter.")}),ke.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:ke.map(c=>n($t,{expanded:q===c.name,name:c.name,onToggle:()=>{M(le(c.name))},rowCount:c.rowCount,rowTestId:`sc-global-table-${c.name}`,toggleTestId:`sc-global-toggle-${c.name}`,children:n(kt,{columns:E[c.name]??wt,testId:`sc-global-columns-${c.name}`})},c.name))})]})]})]}),e[103]=_,e[104]=C,e[105]=P,e[106]=ke,e[107]=Q,e[108]=E,e[109]=S,e[110]=q,e[111]=w,e[112]=B,e[113]=d,e[114]=l,e[115]=p,e[116]=j,e[117]=le,e[118]=i,e[119]=Pe):Pe=e[119];let Ze;return e[120]!==Fe||e[121]!==Le||e[122]!==Me||e[123]!==Re||e[124]!==Pe?(Ze=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[Fe,Le,Me,Re,Pe]}),e[120]=Fe,e[121]=Le,e[122]=Me,e[123]=Re,e[124]=Pe,e[125]=Ze):Ze=e[125],Ze};function Ba(a){return n("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:a},a)}function Ga(a){return u("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"font-mono",children:a.name}),n(we,{variant:"outline",children:a.type}),a.unique===!0&&n(we,{variant:"secondary",children:"unique"}),n("span",{className:"text-muted-foreground",children:a.fields.join(", ")})]},`${a.type}:${a.name}`)}function Ka(a){const{columns:e,refs:t,table:o}=a;return[o,e.map(r=>{const s=t[r];return s===void 0?{name:r,optional:!1,type:""}:{name:r,optional:!1,ref:s,type:"id"}})]}function Da(a){return a.name}function Ha(a){return a.name}function Ja(a){return a.name}export{vl as SchemaViewer};
1
+ import{c as Xe}from"react/compiler-runtime";import{useLunora as It}from"@lunora/react";import{useState as g,useEffect as it,useRef as $t}from"react";import{ShardInput as zt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as gt,d as dt}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as nt}from"../packem_shared/badge-BbuuAio7.js";import{f as ct,m as mt,n as ut,u as ht,c as pt}from"../packem_shared/card-CIDGUN6K.js";import{E as At}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as We}from"../packem_shared/input-JHu63lTv.js";import Ot from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as wt}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as st}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{f as Z,d as lt,b as at,g as rt}from"../packem_shared/internal-BSIsQVC6.js";import{r as jt}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as kt}from"../packem_shared/utils-bhneXptQ.js";import{S as Ft}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{useNavigate as qt}from"@tanstack/react-router";import{u as X}from"../packem_shared/button-BkCrNcAs.js";import{p as ze}from"../packem_shared/label-6uP1obNF.js";import{jsx as l,jsxs as c}from"react/jsx-runtime";const Et="/__lunora/schema-edit",Pt=async s=>{const e=await fetch(Et,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},Lt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Gt="v.string()",Dt=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Mt=s=>{const e=Xe(116),{onApplied:u,tableNames:o}=s,t=wt(),r=qt(),[n,m]=g(null),[p,i]=g(!1),[y,f]=g(null),[w,d]=g(""),[C,G]=g(""),[Q,Le]=g(Gt),[N,Ye]=g(o[0]??""),[q,Ge]=g(""),[W,ce]=g(""),[Y,Ae]=g(!1);let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee=()=>{m(null),d(""),G(""),Ge(""),ce(""),Ae(!1)},e[0]=ee):ee=e[0];const Oe=ee;let me;e[1]!==u?(me=async v=>{i(!0),f(null);try{const P=await Pt(v);f(P),P.kind==="ok"&&(u(P.tables),Oe())}catch(P){const ie=P;f({kind:"error",message:ie instanceof Error?ie.message:String(ie)})}i(!1)},e[1]=u,e[2]=me):me=e[2];const S=me;let je;e[3]!==S||e[4]!==w?(je=()=>{Z(S({kind:"addTable",table:w.trim()}))},e[3]=S,e[4]=w,e[5]=je):je=e[5];const x=je;let Fe;e[6]!==C||e[7]!==S||e[8]!==N||e[9]!==Q?(Fe=()=>{Z(S({column:C.trim(),kind:"addOptionalColumn",table:N,validator:Q}))},e[6]=C,e[7]=S,e[8]=N,e[9]=Q,e[10]=Fe):Fe=e[10];const k=Fe;let ke;e[11]!==W||e[12]!==q||e[13]!==S||e[14]!==N||e[15]!==Y?(ke=()=>{Z(S({fields:Dt(W),kind:"addIndex",name:q.trim(),table:N,unique:Y}))},e[11]=W,e[12]=q,e[13]=S,e[14]=N,e[15]=Y,e[16]=ke):ke=e[16];const Ce=ke;let D;e[17]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{f(null),m("addTable")},e[17]=D):D=e[17];const ot=D;let M;e[18]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{f(null),m("addColumn")},e[18]=M):M=e[18];const et=M;let ue;e[19]===Symbol.for("react.memo_cache_sentinel")?(ue=()=>{f(null),m("addIndex")},e[19]=ue):ue=e[19];const he=ue;let pe;e[20]!==t?(pe=()=>{m("destructive"),f({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]=pe):pe=e[21];const _e=pe;let fe;e[22]===Symbol.for("react.memo_cache_sentinel")?(fe=v=>{d(v.target.value)},e[22]=fe):fe=e[22];const De=fe;let ge;e[23]===Symbol.for("react.memo_cache_sentinel")?(ge=v=>{G(v.target.value)},e[23]=ge):ge=e[23];const Me=ge;let be;e[24]===Symbol.for("react.memo_cache_sentinel")?(be=v=>{Le(v.target.value)},e[24]=be):be=e[24];const xe=be;let ve;e[25]===Symbol.for("react.memo_cache_sentinel")?(ve=v=>{Ye(v.target.value)},e[25]=ve):ve=e[25];const Re=ve;let qe;e[26]===Symbol.for("react.memo_cache_sentinel")?(qe=v=>{Ge(v.target.value)},e[26]=qe):qe=e[26];const Be=qe;let ye;e[27]===Symbol.for("react.memo_cache_sentinel")?(ye=v=>{ce(v.target.value)},e[27]=ye):ye=e[27];const Ue=ye;let Ne;e[28]===Symbol.for("react.memo_cache_sentinel")?(Ne=v=>{Ae(v.target.checked)},e[28]=Ne):Ne=e[28];const Ve=Ne;let we;e[29]!==r?(we=()=>{Z(r({to:"/migrations"}))},e[29]=r,e[30]=we):we=e[30];const E=we;let R;e[31]!==t?(R=t("Edit schema"),e[31]=t,e[32]=R):R=e[32];let te;e[33]!==R?(te=l(ct,{children:R}),e[33]=R,e[34]=te):te=e[34];let B;e[35]!==t?(B=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=B):B=e[36];let T;e[37]!==B?(T=l(mt,{children:B}),e[37]=B,e[38]=T):T=e[38];let U;e[39]!==te||e[40]!==T?(U=c(ut,{children:[te,T]}),e[39]=te,e[40]=T,e[41]=U):U=e[41];const le=n==="addTable"?"default":"outline";let V;e[42]!==t?(V=t("Add table"),e[42]=t,e[43]=V):V=e[43];let Se;e[44]!==le||e[45]!==V?(Se=l(X,{"data-testid":"sc-editor-add-table",onClick:ot,size:"xs",type:"button",variant:le,children:V}),e[44]=le,e[45]=V,e[46]=Se):Se=e[46];const Te=o.length===0,Ze=n==="addColumn"?"default":"outline";let K;e[47]!==t?(K=t("Add column"),e[47]=t,e[48]=K):K=e[48];let Ie;e[49]!==Te||e[50]!==Ze||e[51]!==K?(Ie=l(X,{"data-testid":"sc-editor-add-column",disabled:Te,onClick:et,size:"xs",type:"button",variant:Ze,children:K}),e[49]=Te,e[50]=Ze,e[51]=K,e[52]=Ie):Ie=e[52];const $e=o.length===0,Ee=n==="addIndex"?"default":"outline";let I;e[53]!==t?(I=t("Add index"),e[53]=t,e[54]=I):I=e[54];let H;e[55]!==$e||e[56]!==Ee||e[57]!==I?(H=l(X,{"data-testid":"sc-editor-add-index",disabled:$e,onClick:he,size:"xs",type:"button",variant:Ee,children:I}),e[55]=$e,e[56]=Ee,e[57]=I,e[58]=H):H=e[58];const Pe=o.length===0,ae=n==="destructive"?"default":"ghost";let $;e[59]!==t?($=t("Rename / drop / change type…"),e[59]=t,e[60]=$):$=e[60];let ne;e[61]!==_e||e[62]!==Pe||e[63]!==ae||e[64]!==$?(ne=l(X,{"data-testid":"sc-editor-destructive",disabled:Pe,onClick:_e,size:"xs",type:"button",variant:ae,children:$}),e[61]=_e,e[62]=Pe,e[63]=ae,e[64]=$,e[65]=ne):ne=e[65];let se;e[66]!==Se||e[67]!==Ie||e[68]!==H||e[69]!==ne?(se=c("div",{className:"flex flex-wrap gap-2",children:[Se,Ie,H,ne]}),e[66]=Se,e[67]=Ie,e[68]=H,e[69]=ne,e[70]=se):se=e[70];let z;e[71]!==p||e[72]!==n||e[73]!==x||e[74]!==t||e[75]!==w?(z=n==="addTable"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(We,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:De,value:w})]}),l(X,{"data-testid":"sc-editor-table-apply",disabled:p||w.trim()==="",onClick:x,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[71]=p,e[72]=n,e[73]=x,e[74]=t,e[75]=w,e[76]=z):z=e[76];let A;e[77]!==p||e[78]!==C||e[79]!==n||e[80]!==k||e[81]!==t||e[82]!==o||e[83]!==N||e[84]!==Q?(A=n==="addColumn"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{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:Re,value:N,children:o.map(Rt)})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(We,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:Me,value:C})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{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:xe,value:Q,children:Lt.map(Bt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(X,{"data-testid":"sc-editor-column-apply",disabled:p||C.trim()===""||N==="",onClick:k,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[77]=p,e[78]=C,e[79]=n,e[80]=k,e[81]=t,e[82]=o,e[83]=N,e[84]=Q,e[85]=A):A=e[85];let O;e[86]!==p||e[87]!==W||e[88]!==q||e[89]!==n||e[90]!==Ce||e[91]!==t||e[92]!==o||e[93]!==N||e[94]!==Y?(O=n==="addIndex"&&c("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{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:Re,value:N,children:o.map(Ut)})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(We,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:Be,value:q})]}),c("div",{className:"flex flex-col gap-1 text-xs",children:[l(ze,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(We,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:Ue,value:W})]}),c(ze,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:Y,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:Ve,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(X,{"data-testid":"sc-editor-index-apply",disabled:p||q.trim()===""||W.trim()==="",onClick:Ce,size:"xs",type:"button",children:t(p?"Applying…":"Apply")}),l(X,{onClick:Oe,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[86]=p,e[87]=W,e[88]=q,e[89]=n,e[90]=Ce,e[91]=t,e[92]=o,e[93]=N,e[94]=Y,e[95]=O):O=e[95];let re;e[96]!==y?(re=y?.kind==="error"&&l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:y.message}),e[96]=y,e[97]=re):re=e[97];let oe;e[98]!==E||e[99]!==y?.kind||e[100]!==t?(oe=y?.kind==="needs-migration"&&c("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[l("p",{className:"text-sm text-warning",role:"alert",children:t("This edit changes stored data and must go through a migration. Review the migration before applying.")}),l(X,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:E,size:"xs",type:"button",variant:"outline",children:t("Open Migrations")})]}),e[98]=E,e[99]=y?.kind,e[100]=t,e[101]=oe):oe=e[101];let j;e[102]!==y||e[103]!==t?(j=y?.kind==="ok"&&y.diagnostics.length>0&&c("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[l("p",{className:"text-sm text-destructive",role:"alert",children:t("Codegen reported diagnostics:")}),l("ul",{className:"flex flex-col gap-0.5",children:y.diagnostics.map(Vt)})]}),e[102]=y,e[103]=t,e[104]=j):j=e[104];let F;e[105]!==se||e[106]!==z||e[107]!==A||e[108]!==O||e[109]!==re||e[110]!==oe||e[111]!==j?(F=c(ht,{children:[se,z,A,O,re,oe,j]}),e[105]=se,e[106]=z,e[107]=A,e[108]=O,e[109]=re,e[110]=oe,e[111]=j,e[112]=F):F=e[112];let J;return e[113]!==U||e[114]!==F?(J=c(pt,{"data-testid":"sc-editor",size:"sm",children:[U,F]}),e[113]=U,e[114]=F,e[115]=J):J=e[115],J};function Rt(s){return l("option",{value:s,children:s},s)}function Bt(s){return l("option",{value:s.validator,children:s.label},s.validator)}function Ut(s){return l("option",{value:s,children:s},s)}function Vt(s){return l("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}const Kt=rt(st.listTables),Ht=rt(st.listTableIndexes),Jt=rt(st.readTablePage),Xt=rt(st.describeTables),Zt={},bt=[],xt=[],Qt=s=>{const e=Xe(5),{open:u}=s,o=u&&"rotate-90";let t;e[0]!==o?(t=kt("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",o),e[0]=o,e[1]=t):t=e[1];let r;e[2]===Symbol.for("react.memo_cache_sentinel")?(r=l("path",{d:"m9 6 6 6-6 6"}),e[2]=r):r=e[2];let n;return e[3]!==t?(n=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:r}),e[3]=t,e[4]=n):n=e[4],n},vt=s=>{const e=Xe(20),{children:u,expanded:o,name:t,onToggle:r,rowCount:n,rowTestId:m,toggleTestId:p}=s;let i;e[0]!==o?(i=l(Qt,{open:o}),e[0]=o,e[1]=i):i=e[1];let y;e[2]!==t?(y=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=y):y=e[3];let f;e[4]!==n?(f=c("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",n,")"]}),e[4]=n,e[5]=f):f=e[5];let w;e[6]!==o||e[7]!==r||e[8]!==i||e[9]!==y||e[10]!==f||e[11]!==p?(w=c("button",{"aria-expanded":o,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":p,onClick:r,type:"button",children:[i,y," ",f]}),e[6]=o,e[7]=r,e[8]=i,e[9]=y,e[10]=f,e[11]=p,e[12]=w):w=e[12];let d;e[13]!==u||e[14]!==o?(d=o&&l("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=o,e[15]=d):d=e[15];let C;return e[16]!==m||e[17]!==w||e[18]!==d?(C=c("li",{className:"border-t border-border/60 first:border-t-0","data-testid":m,children:[w,d]}),e[16]=m,e[17]=w,e[18]=d,e[19]=C):C=e[19],C},yt=s=>{const e=Xe(5),{columns:u,testId:o}=s;let t;e[0]!==u?(t=u.map(Yt),e[0]=u,e[1]=t):t=e[1];let r;return e[2]!==t||e[3]!==o?(r=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":o,children:t}),e[2]=t,e[3]=o,e[4]=r):r=e[4],r},Wt=s=>{const e=Xe(10),{heading:u,indexes:o,testId:t}=s;let r;e[0]!==u?(r=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=r):r=e[1];let n;e[2]!==o?(n=o.map(el),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n||e[5]!==t?(m=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:n}),e[4]=n,e[5]=t,e[6]=m):m=e[6];let p;return e[7]!==r||e[8]!==m?(p=c("div",{className:"pt-3",children:[r,m]}),e[7]=r,e[8]=m,e[9]=p):p=e[9],p},Nt=s=>kt("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),_l=s=>{const e=Xe(130),{initialShardKey:u,initialTable:o,schemaEditable:t}=s,r=It(),n=wt(),[m,p]=g("graph"),[i,y]=g(u??""),[f,w]=g(""),[d,C]=g(null),[G,Q]=g(null);let Le;e[0]===Symbol.for("react.memo_cache_sentinel")?(Le={},e[0]=Le):Le=e[0];const[N,Ye]=g(Le);let q;e[1]===Symbol.for("react.memo_cache_sentinel")?(q={},e[1]=q):q=e[1];const[Ge,W]=g(q),[ce,Y]=g(null);let Ae;e[2]===Symbol.for("react.memo_cache_sentinel")?(Ae={},e[2]=Ae):Ae=e[2];const[ee,Oe]=g(Ae);let me;e[3]===Symbol.for("react.memo_cache_sentinel")?(me={},e[3]=me):me=e[3];const[S,je]=g(me),[x,Fe]=g(null),[k,ke]=g(null);let Ce;e[4]===Symbol.for("react.memo_cache_sentinel")?(Ce={},e[4]=Ce):Ce=e[4];const[D,ot]=g(Ce),[M,et]=g(null);let ue;e[5]!==r?(ue=async a=>{Q(null);try{const h=await r.query(Kt,{},lt(a));jt(a),C(h),Ye({}),W({}),Y(null),Oe(b=>Object.fromEntries(Object.entries(b).filter(L=>{const[_]=L;return _!==a}))),je(b=>Object.fromEntries(Object.entries(b).filter(L=>{const[_]=L;return _!==a})))}catch(h){const b=h;C(null),Q(at(b))}},e[5]=r,e[6]=ue):ue=e[6];const he=ue;let pe;e[7]!==r?(pe=async()=>{ke(null);try{Fe(await r.listGlobalTables())}catch(a){const h=a;Fe(null),ke(at(h))}},e[7]=r,e[8]=pe):pe=e[8];const _e=pe;let fe;e[9]!==i?(fe=i.trim(),e[9]=i,e[10]=fe):fe=e[10];const De=Ot(fe,400);let ge,Me;e[11]!==De||e[12]!==he||e[13]!==_e?(Me=()=>{Z(he(De)),Z(_e())},ge=[he,_e,De],e[11]=De,e[12]=he,e[13]=_e,e[14]=ge,e[15]=Me):(ge=e[14],Me=e[15]),it(Me,ge);let be;e[16]!==r||e[17]!==N||e[18]!==ce||e[19]!==i?(be=async a=>{if(ce===a){Y(null);return}Y(a);const h=`${i}:${a}`;if(N[h]!==void 0)return;const[b,L]=await Promise.allSettled([r.query(Jt,{limit:1,offset:0,table:a},lt(i)),r.query(Ht,{table:a},lt(i))]);b.status==="fulfilled"?Ye(_=>({..._,[h]:b.value.columns})):Q(at(b.reason)),L.status==="fulfilled"&&W(_=>({..._,[h]:L.value.indexes}))},e[16]=r,e[17]=N,e[18]=ce,e[19]=i,e[20]=be):be=e[20];const xe=be;let ve;e[21]!==r||e[22]!==D||e[23]!==M?(ve=async a=>{if(M===a){et(null);return}if(et(a),D[a]===void 0)try{const h=await r.readGlobalTablePage({limit:1,offset:0,table:a});ot(b=>({...b,[a]:h.columns}))}catch(h){ke(at(h))}},e[21]=r,e[22]=D,e[23]=M,e[24]=ve):ve=e[24];const Re=ve,qe=$t(void 0);let Be,ye;e[25]!==o||e[26]!==d||e[27]!==xe?(Be=()=>{o===void 0||d===null||qe.current===o||d.some(a=>a.name===o)&&(qe.current=o,Z(xe(o)))},ye=[o,d,xe],e[25]=o,e[26]=d,e[27]=xe,e[28]=Be,e[29]=ye):(Be=e[28],ye=e[29]),it(Be,ye);let Ue;e[30]!==r?(Ue=async(a,h,b)=>{const[L,_]=await Promise.all([Promise.allSettled([r.query(Xt,{tables:[...h,...b]},lt(a))]),Promise.all(b.map(async de=>{const Qe=await Promise.allSettled([r.readGlobalTablePage({limit:1,offset:0,table:de})]),ft=Qe[0].status==="fulfilled"?Qe[0].value:void 0;return{columns:ft?.columns??[],refs:ft?.refs??{},table:de}}))]),Ct=L[0].status==="fulfilled"?L[0].value?.columnsByTable??{}:{},_t=L[0].status==="rejected",St=new Map(_.map(tl)),Tt=[...h,...b].map(de=>{const Qe=Ct[de]??[];return[de,Qe.length>0?Qe:St.get(de)??[]]});Oe(de=>({...de,[a]:Object.fromEntries(Tt)})),je(de=>({...de,[a]:_t}))},e[30]=r,e[31]=Ue):Ue=e[31];const Ne=Ue;let Ve,we;e[32]!==k||e[33]!==x||e[34]!==Ne||e[35]!==ee||e[36]!==i||e[37]!==d||e[38]!==m?(Ve=()=>{m!=="graph"||d===null||x===null&&k===null||ee[i]!==void 0||Z(Ne(i,d.map(ll),(x??[]).map(al)))},we=[m,d,x,k,i,ee,Ne],e[32]=k,e[33]=x,e[34]=Ne,e[35]=ee,e[36]=i,e[37]=d,e[38]=m,e[39]=Ve,e[40]=we):(Ve=e[39],we=e[40]),it(Ve,we);const E=ee[i]??Zt;let R;if(e[41]!==E||e[42]!==x||e[43]!==d){let a;e[45]!==E?(a=_=>({columns:E[_.name]??xt,name:_.name,tier:"shard"}),e[45]=E,e[46]=a):a=e[46];const h=(d??[]).map(a);let b;e[47]!==E?(b=_=>({columns:E[_.name]??xt,name:_.name,tier:"global"}),e[47]=E,e[48]=b):b=e[48];const L=(x??[]).map(b);R=[...h,...L],e[41]=E,e[42]=x,e[43]=d,e[44]=R}else R=e[44];const te=R;let B;if(e[49]!==f||e[50]!==d){const a=f.trim().toLowerCase();B=(d??[]).filter(h=>h.name.toLowerCase().includes(a)),e[49]=f,e[50]=d,e[51]=B}else B=e[51];const T=B;let U;if(e[52]!==x||e[53]!==f){const a=f.trim().toLowerCase();U=(x??[]).filter(h=>h.name.toLowerCase().includes(a)),e[52]=x,e[53]=f,e[54]=U}else U=e[54];const le=U;let V;e[55]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{p("list")},e[55]=V):V=e[55];const Se=V;let Te;e[56]===Symbol.for("react.memo_cache_sentinel")?(Te=()=>{p("graph")},e[56]=Te):Te=e[56];const Ze=Te;let K;e[57]===Symbol.for("react.memo_cache_sentinel")?(K=a=>{w(a.target.value)},e[57]=K):K=e[57];const Ie=K;let $e;e[58]!==he||e[59]!==i?($e=a=>{Z(he(i))},e[58]=he,e[59]=i,e[60]=$e):$e=e[60];const Ee=$e;let I;e[61]!==d?(I=d??[],e[61]=d,e[62]=I):I=e[62];let H;e[63]!==I?(H=I.map(nl),e[63]=I,e[64]=H):H=e[64];const Pe=H;let ae;e[65]!==i?(ae=l(zt,{onChange:y,testId:"sc-shard-input",value:i}),e[65]=i,e[66]=ae):ae=e[66];let $;e[67]!==n?($=n("Schema view"),e[67]=n,e[68]=$):$=e[68];const ne=m==="graph",se=m==="graph";let z;e[69]!==se?(z=Nt(se),e[69]=se,e[70]=z):z=e[70];let A;e[71]!==n?(A=n("Graph"),e[71]=n,e[72]=A):A=e[72];let O;e[73]!==ne||e[74]!==z||e[75]!==A?(O=l("button",{"aria-selected":ne,className:z,"data-testid":"sc-view-graph",onClick:Ze,role:"tab",type:"button",children:A}),e[73]=ne,e[74]=z,e[75]=A,e[76]=O):O=e[76];const re=m==="list",oe=m==="list";let j;e[77]!==oe?(j=Nt(oe),e[77]=oe,e[78]=j):j=e[78];let F;e[79]!==n?(F=n("Table list"),e[79]=n,e[80]=F):F=e[80];let J;e[81]!==re||e[82]!==j||e[83]!==F?(J=l("button",{"aria-selected":re,className:j,"data-testid":"sc-view-list",onClick:Se,role:"tab",type:"button",children:F}),e[81]=re,e[82]=j,e[83]=F,e[84]=J):J=e[84];let v;e[85]!==$||e[86]!==O||e[87]!==J?(v=c("div",{"aria-label":$,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[O,J]}),e[85]=$,e[86]=O,e[87]=J,e[88]=v):v=e[88];let P;e[89]!==ae||e[90]!==v?(P=c("div",{className:"flex flex-wrap items-center gap-3",children:[ae,v]}),e[89]=ae,e[90]=v,e[91]=P):P=e[91];let ie;e[92]!==Ee||e[93]!==t||e[94]!==Pe?(ie=t===!0&&l(Mt,{onApplied:Ee,tableNames:Pe}),e[92]=Ee,e[93]=t,e[94]=Pe,e[95]=ie):ie=e[95];let Ke;e[96]!==n||e[97]!==f||e[98]!==m?(Ke=m==="list"&&l(We,{"aria-label":n("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Ie,placeholder:n("Filter tables"),value:f}),e[96]=n,e[97]=f,e[98]=m,e[99]=Ke):Ke=e[99];let He;e[100]!==te||e[101]!==G||e[102]!==k||e[103]!==S||e[104]!==i||e[105]!==m?(He=m==="graph"&&c("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}),k!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:k}),l(Ft,{columnsError:S[i]===!0,tables:te,testIdPrefix:"sc-graph"})]}),e[100]=te,e[101]=G,e[102]=k,e[103]=S,e[104]=i,e[105]=m,e[106]=He):He=e[106];let Je;e[107]!==N||e[108]!==G||e[109]!==ce||e[110]!==le||e[111]!==T||e[112]!==D||e[113]!==k||e[114]!==M||e[115]!==x||e[116]!==Ge||e[117]!==i||e[118]!==n||e[119]!==d||e[120]!==xe||e[121]!==Re||e[122]!==m?(Je=m==="list"&&c("div",{className:"flex flex-col gap-4",children:[c(pt,{"data-testid":"sc-shard-section",size:"sm",children:[c(ut,{children:[c("div",{className:"flex items-center gap-2",children:[l(gt,{tier:"shard"}),l(ct,{children:n("Shard tables")}),d!==null&&l(nt,{className:"ms-auto tabular-nums",variant:"outline",children:T.length})]}),l(mt,{children:dt.shard.hint})]}),c(ht,{children:[G!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:G}),d!==null&&d.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:n("No tables in this shard.")}),d!==null&&d.length>0&&T.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:n("No tables match your filter.")}),T.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:T.map(a=>{const h=`${i}:${a.name}`,b=Ge[h]??[];return c(vt,{expanded:ce===a.name,name:a.name,onToggle:()=>{Z(xe(a.name))},rowCount:a.rowCount,rowTestId:`sc-table-${a.name}`,toggleTestId:`sc-toggle-${a.name}`,children:[l(yt,{columns:N[h]??bt,testId:`sc-columns-${a.name}`}),b.length>0&&l(Wt,{heading:n("Indexes"),indexes:b,testId:`sc-indexes-${a.name}`})]},a.name)})})]})]}),c(pt,{"data-testid":"sc-global-section",size:"sm",children:[c(ut,{children:[c("div",{className:"flex items-center gap-2",children:[l(gt,{tier:"global"}),l(ct,{children:n("Global tables (D1)")}),x!==null&&l(nt,{className:"ms-auto tabular-nums",variant:"outline",children:le.length})]}),l(mt,{children:dt.global.hint})]}),c(ht,{children:[k!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:k}),x!==null&&x.length===0&&l(At,{description:dt.global.hint,testId:"sc-global-empty",title:n("No global tables.")}),x!==null&&x.length>0&&le.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:n("No tables match your filter.")}),le.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:le.map(a=>l(vt,{expanded:M===a.name,name:a.name,onToggle:()=>{Z(Re(a.name))},rowCount:a.rowCount,rowTestId:`sc-global-table-${a.name}`,toggleTestId:`sc-global-toggle-${a.name}`,children:l(yt,{columns:D[a.name]??bt,testId:`sc-global-columns-${a.name}`})},a.name))})]})]})]}),e[107]=N,e[108]=G,e[109]=ce,e[110]=le,e[111]=T,e[112]=D,e[113]=k,e[114]=M,e[115]=x,e[116]=Ge,e[117]=i,e[118]=n,e[119]=d,e[120]=xe,e[121]=Re,e[122]=m,e[123]=Je):Je=e[123];let tt;return e[124]!==P||e[125]!==ie||e[126]!==Ke||e[127]!==He||e[128]!==Je?(tt=c("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[P,ie,Ke,He,Je]}),e[124]=P,e[125]=ie,e[126]=Ke,e[127]=He,e[128]=Je,e[129]=tt):tt=e[129],tt};function Yt(s){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}function el(s){return c("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:s.name}),l(nt,{variant:"outline",children:s.type}),s.unique===!0&&l(nt,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}function tl(s){const{columns:e,refs:u,table:o}=s;return[o,e.map(t=>{const r=u[t];return r===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:r,type:"id"}})]}function ll(s){return s.name}function al(s){return s.name}function nl(s){return s.name}export{_l as SchemaViewer};
@@ -1 +1 @@
1
- import{c as u}from"react/compiler-runtime";import{K as m}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{A as g}from"../packem_shared/advisor-view-DaCX9Jy5.js";import{jsx as p}from"react/jsx-runtime";const R=(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("Live admin subscriptions are ungated")})[s.kind],k=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: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],N=()=>{const e=u(8),s=h();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:n,errorSource:d}=m(f.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:k(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:R(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 o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=p(g,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{N as default};
1
+ import{c as u}from"react/compiler-runtime";import{N as m}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{A as g}from"../packem_shared/advisor-view-Pa8HLtBv.js";import{jsx as p}from"react/jsx-runtime";const R=(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("Live admin subscriptions are ungated")})[s.kind],k=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: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],N=()=>{const e=u(8),s=h();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:n,errorSource:d}=m(f.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:k(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:R(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 o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=p(g,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{N as default};
@@ -1 +1 @@
1
- import{c as A}from"react/compiler-runtime";import"react";import{E as F}from"../packem_shared/error-alert-B59DnrDI.js";import{g as V}from"../packem_shared/badge-BbuuAio7.js";import{c as D,u as K}from"../packem_shared/card-CIDGUN6K.js";import{n as z,d as G,m as O,p as C,f as J,u as L}from"../packem_shared/table-DdJBrClo.js";import{K as M}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as P}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-CpgIo9pj.js";import{a as q}from"../packem_shared/cf-links-gbDy51nR.js";import{jsx as l,jsxs as s}from"react/jsx-runtime";const B={binding:"outline",secret:"destructive",var:"secondary"},de=o=>{const e=A(68),{initialShardKey:j}=o,t=P();let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];const S=j??"";let w;e[1]!==S?(w={shardKey:S},e[1]=S,e[2]=w):w=e[2];const{data:U,error:m,errorSource:E,isLoading:$}=M(W.getSettings,k,w);let R;e:{const n=U?.deploy;if(n===void 0){let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[3]=r):r=e[3],R=r;break e}let i;if(e[4]!==n.deploymentId||e[5]!==n.environment||e[6]!==n.versionTag||e[7]!==n.workerUrl||e[8]!==t){if(i=[],n.workerUrl!==void 0){let r;e[10]!==t?(r=t("URL"),e[10]=t,e[11]=r):r=e[11];let a;e[12]!==n.workerUrl||e[13]!==r?(a={label:r,value:n.workerUrl},e[12]=n.workerUrl,e[13]=r,e[14]=a):a=e[14],i.push(a)}if(n.environment!==void 0){let r;e[15]!==t?(r=t("Environment"),e[15]=t,e[16]=r):r=e[16];let a;e[17]!==n.environment||e[18]!==r?(a={label:r,value:n.environment},e[17]=n.environment,e[18]=r,e[19]=a):a=e[19],i.push(a)}if(n.deploymentId!==void 0){let r;e[20]!==t?(r=t("Deployment"),e[20]=t,e[21]=r):r=e[21];let a;e[22]!==n.deploymentId||e[23]!==r?(a={label:r,value:n.deploymentId},e[22]=n.deploymentId,e[23]=r,e[24]=a):a=e[24],i.push(a)}if(n.versionTag!==void 0){let r;e[25]!==t?(r=t("Version"),e[25]=t,e[26]=r):r=e[26];let a;e[27]!==n.versionTag||e[28]!==r?(a={label:r,value:n.versionTag},e[27]=n.versionTag,e[28]=r,e[29]=a):a=e[29],i.push(a)}e[4]=n.deploymentId,e[5]=n.environment,e[6]=n.versionTag,e[7]=n.workerUrl,e[8]=t,e[9]=i}else i=e[9];R=i}const I=R;let T;e[30]!==U?.settings?(T=U?.settings??[],e[30]=U?.settings,e[31]=T):T=e[31];const d=T;let c;e[32]!==t?(c=t("Open in Cloudflare"),e[32]=t,e[33]=c):c=e[33];let p;e[34]!==c?(p=l("div",{className:"flex flex-wrap items-center gap-3",children:l("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:q,rel:"noreferrer",target:"_blank",children:c})}),e[34]=c,e[35]=p):p=e[35];let u;e[36]!==t?(u=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[36]=t,e[37]=u):u=e[37];let h;e[38]!==u?(h=l("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:u}),e[38]=u,e[39]=h):h=e[39];let f;e[40]!==m||e[41]!==E?(f=m!==null&&l(F,{error:E,testId:"set-error"}),e[40]=m,e[41]=E,e[42]=f):f=e[42];let g;e[43]!==I||e[44]!==t?(g=I.length>0&&s(D,{className:"py-0","data-testid":"set-deploy",children:[l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),l(K,{className:"py-3",children:l("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:I.map(H)})})]}),e[43]=I,e[44]=t,e[45]=g):g=e[45];let v;e[46]!==t?(v=t("Environment & bindings"),e[46]=t,e[47]=v):v=e[47];let x;e[48]!==v?(x=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[48]=v,e[49]=x):x=e[49];let y;e[50]!==m||e[51]!==$||e[52]!==d.length||e[53]!==t?(y=m===null&&!$&&d.length===0&&l("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[50]=m,e[51]=$,e[52]=d.length,e[53]=t,e[54]=y):y=e[54];let b;e[55]!==d||e[56]!==t?(b=d.length>0&&l(K,{className:"px-0 py-0",children:s(z,{"data-testid":"set-table",children:[l(G,{children:s(O,{children:[l(C,{children:t("name")}),l(C,{children:t("kind")}),l(C,{children:t("value")})]})}),l(J,{children:d.map(Q)})]})}),e[55]=d,e[56]=t,e[57]=b):b=e[57];let N;e[58]!==x||e[59]!==y||e[60]!==b?(N=s(D,{className:"py-0",children:[x,y,b]}),e[58]=x,e[59]=y,e[60]=b,e[61]=N):N=e[61];let _;return e[62]!==f||e[63]!==g||e[64]!==N||e[65]!==p||e[66]!==h?(_=s("div",{className:"flex flex-col gap-4","data-testid":"lunora-settings",children:[p,h,f,g,N]}),e[62]=f,e[63]=g,e[64]=N,e[65]=p,e[66]=h,e[67]=_):_=e[67],_};function H(o){return s("div",{className:"contents","data-testid":"set-deploy-row",children:[l("dt",{className:"text-muted-foreground",children:o.label}),l("dd",{className:"truncate font-mono text-xs",title:o.value,children:o.value})]},o.label)}function Q(o){return s(O,{"data-testid":"set-row",children:[l(L,{className:"font-mono text-xs font-medium",children:o.name}),l(L,{children:l(V,{variant:B[o.kind],children:o.bindingType??o.kind})}),l(L,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:o.value??l("span",{className:"text-muted-foreground",children:"—"})})]},o.name)}export{de as SettingsPanel};
1
+ import{c as O}from"react/compiler-runtime";import{E as A}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as K}from"../packem_shared/badge-BbuuAio7.js";import{c as I,u as L}from"../packem_shared/card-CIDGUN6K.js";import{n as j,d as F,m as C,p as T,f as V,u as U}from"../packem_shared/table-DdJBrClo.js";import{N as W}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-BnD4aovm.js";import{a as M}from"../packem_shared/cf-links-gbDy51nR.js";import{jsx as t,jsxs as m}from"react/jsx-runtime";const P={binding:"outline",secret:"destructive",var:"secondary"},B=(r,e)=>{if(r===void 0)return[];const c=[];return r.workerUrl!==void 0&&c.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&c.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&c.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&c.push({label:e("Version"),value:r.versionTag}),c},le=r=>{const e=O(52),{initialShardKey:c}=r,n=q();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const _=c??"";let $;e[1]!==_?($={shardKey:_},e[1]=_,e[2]=$):$=e[2];const{data:l,error:s,errorSource:k,isLoading:R}=W(z.getSettings,w,$);let a,p,u,d,o,i,h;if(e[3]!==s||e[4]!==k||e[5]!==l?.deploy||e[6]!==l?.settings||e[7]!==n){const D=B(l?.deploy,n);let S;e[15]!==l?.settings?(S=l?.settings??[],e[15]=l?.settings,e[16]=S):S=e[16],a=S,p="flex flex-col gap-4",u="lunora-settings";let N;e[17]!==n?(N=n("Open in Cloudflare"),e[17]=n,e[18]=N):N=e[18],e[19]!==N?(d=t("div",{className:"flex flex-wrap items-center gap-3",children:t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:M,rel:"noreferrer",target:"_blank",children:N})}),e[19]=N,e[20]=d):d=e[20];let b;e[21]!==n?(b=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=b):b=e[22],e[23]!==b?(o=t("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]!==s||e[26]!==k?(i=s!==null&&t(A,{error:k,testId:"set-error"}),e[25]=s,e[26]=k,e[27]=i):i=e[27],h=D.length>0&&m(I,{className:"py-0","data-testid":"set-deploy",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),t(L,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:D.map(G)})})]}),e[3]=s,e[4]=k,e[5]=l?.deploy,e[6]=l?.settings,e[7]=n,e[8]=a,e[9]=p,e[10]=u,e[11]=d,e[12]=o,e[13]=i,e[14]=h}else a=e[8],p=e[9],u=e[10],d=e[11],o=e[12],i=e[13],h=e[14];let f;e[28]!==n?(f=n("Environment & bindings"),e[28]=n,e[29]=f):f=e[29];let g;e[30]!==f?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f})}),e[30]=f,e[31]=g):g=e[31];let x;e[32]!==s||e[33]!==R||e[34]!==a.length||e[35]!==n?(x=s===null&&!R&&a.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[32]=s,e[33]=R,e[34]=a.length,e[35]=n,e[36]=x):x=e[36];let v;e[37]!==a||e[38]!==n?(v=a.length>0&&t(L,{className:"px-0 py-0",children:m(j,{"data-testid":"set-table",children:[t(F,{children:m(C,{children:[t(T,{children:n("name")}),t(T,{children:n("kind")}),t(T,{children:n("value")})]})}),t(V,{children:a.map(H)})]})}),e[37]=a,e[38]=n,e[39]=v):v=e[39];let y;e[40]!==g||e[41]!==x||e[42]!==v?(y=m(I,{className:"py-0",children:[g,x,v]}),e[40]=g,e[41]=x,e[42]=v,e[43]=y):y=e[43];let E;return e[44]!==y||e[45]!==p||e[46]!==u||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==h?(E=m("div",{className:p,"data-testid":u,children:[d,o,i,h,y]}),e[44]=y,e[45]=p,e[46]=u,e[47]=d,e[48]=o,e[49]=i,e[50]=h,e[51]=E):E=e[51],E};function G(r){return m("div",{className:"contents","data-testid":"set-deploy-row",children:[t("dt",{className:"text-muted-foreground",children:r.label}),t("dd",{className:"truncate font-mono text-xs",title:r.value,children:r.value})]},r.label)}function H(r){return m(C,{"data-testid":"set-row",children:[t(U,{className:"font-mono text-xs font-medium",children:r.name}),t(U,{children:t(K,{variant:P[r.kind],children:r.bindingType??r.kind})}),t(U,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:r.value??t("span",{className:"text-muted-foreground",children:"—"})})]},r.name)}export{le as SettingsPanel};