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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/index.d.ts +3 -3
  2. package/dist/index.js +10 -10
  3. package/dist/mount.d.ts +1 -1
  4. package/dist/mount.js +3 -2
  5. package/dist/packem_chunks/ApiTab.js +3 -3
  6. package/dist/packem_chunks/AuditPanel.js +7 -7
  7. package/dist/packem_chunks/ExportImportPanel.js +5 -4
  8. package/dist/packem_chunks/FileBrowser.js +2 -2
  9. package/dist/packem_chunks/FunctionRunner.js +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.js +72 -70
  11. package/dist/packem_chunks/HealthPanel.js +3 -3
  12. package/dist/packem_chunks/InsightsPanel.js +4 -3
  13. package/dist/packem_chunks/LogsPanel.js +6 -6
  14. package/dist/packem_chunks/MailPanel.js +8 -7
  15. package/dist/packem_chunks/MetricsPanel.js +3 -3
  16. package/dist/packem_chunks/MigrationsPanel.js +7 -7
  17. package/dist/packem_chunks/PitrPanel.js +1 -1
  18. package/dist/packem_chunks/SchemaViewer.js +3 -2
  19. package/dist/packem_chunks/SecurityAdvisorPanel.js +11 -8
  20. package/dist/packem_chunks/SettingsPanel.js +50 -49
  21. package/dist/packem_chunks/SqlEditorPanel.js +5 -4
  22. package/dist/packem_chunks/TableEditor.js +3 -3
  23. package/dist/packem_chunks/analytics-panel.js +1 -1
  24. package/dist/packem_chunks/auth-config-panel.js +1 -1
  25. package/dist/packem_chunks/auth-sessions-panel.js +2 -2
  26. package/dist/packem_chunks/containers-panel.js +247 -0
  27. package/dist/packem_chunks/dashboards-panel.js +3 -2
  28. package/dist/packem_chunks/fanout-panel.js +31 -30
  29. package/dist/packem_chunks/flags-panel.js +6 -6
  30. package/dist/packem_chunks/kv-browser.js +2 -2
  31. package/dist/packem_chunks/log-drains-panel.js +1 -1
  32. package/dist/packem_chunks/organizations-panel.js +3 -3
  33. package/dist/packem_chunks/payments-panel.js +6 -5
  34. package/dist/packem_chunks/permissions-panel.js +12 -11
  35. package/dist/packem_chunks/queues-panel.js +32 -31
  36. package/dist/packem_chunks/rls-panel.js +86 -84
  37. package/dist/packem_chunks/schedule-panel.js +3 -3
  38. package/dist/packem_chunks/sparkline.js +1 -1
  39. package/dist/packem_chunks/storage-rules-panel.js +27 -25
  40. package/dist/packem_chunks/subscriptions-panel.js +33 -31
  41. package/dist/packem_chunks/users-panel.js +3 -3
  42. package/dist/packem_chunks/vector-browser.js +1 -1
  43. package/dist/packem_chunks/workflows-panel.js +2 -2
  44. package/dist/packem_shared/{ApiDocsPanel-B6u_wnz-.js → ApiDocsPanel-Cu6mD4u7.js} +1 -1
  45. package/dist/packem_shared/{ApiReferencePanel-Drz4UO0a.js → ApiReferencePanel-Co_wpRF2.js} +1 -1
  46. package/dist/packem_shared/{CommandPalette-B5BertvU.js → CommandPalette-BUPpbpMc.js} +1 -1
  47. package/dist/packem_shared/{DataBrowser-ANTHLWWh.js → DataBrowser-DSNK1tPg.js} +5 -5
  48. package/dist/packem_shared/{GlobalDataBrowser-CjgTG_wa.js → GlobalDataBrowser-ErfvIs1S.js} +3 -3
  49. package/dist/packem_shared/{HomePanel-c2FodE9t.js → HomePanel-DQk3P8xX.js} +3 -3
  50. package/dist/packem_shared/{OpenRpcReferencePanel-CspFdbUT.js → OpenRpcReferencePanel-DLWzrIx9.js} +1 -1
  51. package/dist/packem_shared/{ScheduledJobs-BEJXtsBn.js → ScheduledJobs-ClaNpZsg.js} +2 -2
  52. package/dist/packem_shared/{Studio-CVTtA_sB.js → Studio-CFTYGEUt.js} +4 -4
  53. package/dist/packem_shared/{StudioApp-BSYV2fz6.js → StudioApp-Cy9vUwVl.js} +1 -1
  54. package/dist/packem_shared/{advisor-view-DzqyvUU3.js → advisor-view-D3-U4kRR.js} +5 -5
  55. package/dist/packem_shared/alert-CdAET2K_.js +68 -0
  56. package/dist/packem_shared/{app.d-B6MyY_al.d.ts → app.d-CNLRTrWw.d.ts} +1 -1
  57. package/dist/packem_shared/{bar-chart-Bb__F5-u.js → bar-chart-DSwcWIRy.js} +4 -3
  58. package/dist/packem_shared/{browser-storage-d03UsV7v.js → browser-storage-tLOxkIHd.js} +3 -67
  59. package/dist/packem_shared/{data-grid-Dsg6nRjo.js → data-grid-Jz8FqQ2C.js} +1 -1
  60. package/dist/packem_shared/error-alert-BBT6D22d.js +114 -0
  61. package/dist/packem_shared/{grid-features-D7nNzBYm.js → grid-features-CUr8Z1_O.js} +1 -1
  62. package/dist/packem_shared/{home-panel-aOR_drVv.js → home-panel-Bo-Mgrkn.js} +4 -2
  63. package/dist/packem_shared/{internal-FcNZ3beb.js → internal-DTsYVn-g.js} +30 -1
  64. package/dist/packem_shared/{reference-view-Doy1XlQq.js → reference-view-CSKyUyPl.js} +3 -2
  65. package/dist/packem_shared/{sparkline-KgMPHS4u.js → sparkline-BnA1kC9X.js} +1 -1
  66. package/dist/packem_shared/{studio-dMTJ-kRR.js → studio-Dg2e-dsR.js} +587 -560
  67. package/dist/packem_shared/{table-list-sidebar-VMo0ftxD.js → table-list-sidebar-B5psdSV1.js} +1 -1
  68. package/dist/packem_shared/{use-admin-query-BViPA3US.js → use-admin-query-BHPKmPuj.js} +2 -1
  69. package/dist/packem_shared/{use-auth-capabilities-BHkoBnbZ.js → use-auth-capabilities-C-VH0oJJ.js} +1 -1
  70. package/dist/standalone/{chunk-N4JI6VQD.js → chunk-25VHPD2I.js} +1 -1
  71. package/dist/standalone/chunk-2GGMGPEP.js +1 -0
  72. package/dist/standalone/{chunk-BHTPZS7L.js → chunk-3CJW6NWG.js} +1 -1
  73. package/dist/standalone/chunk-4H2OJBXO.js +1 -0
  74. package/dist/standalone/chunk-4MLAVZP4.js +1 -0
  75. package/dist/standalone/chunk-55YA7ZZI.js +76 -0
  76. package/dist/standalone/chunk-5OH3VPZF.js +1 -0
  77. package/dist/standalone/chunk-6GFEVKJP.js +1 -0
  78. package/dist/standalone/{chunk-ITLLHEVG.js → chunk-764T6X6X.js} +1 -1
  79. package/dist/standalone/chunk-7M3F6U4L.js +1 -0
  80. package/dist/standalone/{chunk-KGS7KM4A.js → chunk-7VF3IAAW.js} +1 -1
  81. package/dist/standalone/chunk-AJIUI7DD.js +1 -0
  82. package/dist/standalone/{chunk-5NSZVXCS.js → chunk-BACPICH6.js} +1 -1
  83. package/dist/standalone/chunk-BET2625I.js +1 -0
  84. package/dist/standalone/chunk-BQUQS7QN.js +1 -0
  85. package/dist/standalone/chunk-CKSHCYGC.js +2 -0
  86. package/dist/standalone/chunk-DCECRP45.js +1 -0
  87. package/dist/standalone/chunk-DFP2DADO.js +1 -0
  88. package/dist/standalone/chunk-DORBUITF.js +1 -0
  89. package/dist/standalone/chunk-DVKPRFIJ.js +1 -0
  90. package/dist/standalone/chunk-E6WUCLSI.js +1 -0
  91. package/dist/standalone/chunk-E7WLF6IU.js +1 -0
  92. package/dist/standalone/chunk-EVPLBWUT.js +8 -0
  93. package/dist/standalone/chunk-FCSPAJW4.js +1 -0
  94. package/dist/standalone/chunk-G2ICR3DL.js +1 -0
  95. package/dist/standalone/{chunk-2DS7JLWL.js → chunk-GJ6PGSES.js} +5 -5
  96. package/dist/standalone/chunk-GMSGZDDH.js +13 -0
  97. package/dist/standalone/chunk-GVRM4U6W.js +2 -0
  98. package/dist/standalone/chunk-GZDWDDXN.js +1 -0
  99. package/dist/standalone/chunk-ISJAJWYI.js +1 -0
  100. package/dist/standalone/{chunk-G2TFEWEQ.js → chunk-JIDZFLTB.js} +1 -1
  101. package/dist/standalone/{chunk-RMYA7NAH.js → chunk-K3GNLVYK.js} +1 -1
  102. package/dist/standalone/chunk-K4ZDRTQM.js +1 -0
  103. package/dist/standalone/{chunk-ASLGNHAX.js → chunk-LI43EKM6.js} +1 -1
  104. package/dist/standalone/chunk-MFPTVCJ6.js +1 -0
  105. package/dist/standalone/chunk-MPYFGAOW.js +1 -0
  106. package/dist/standalone/{chunk-TICVNLPM.js → chunk-O3NAGRTR.js} +1 -1
  107. package/dist/standalone/chunk-OV2WFAJX.js +1 -0
  108. package/dist/standalone/chunk-PA3LN4XJ.js +1 -0
  109. package/dist/standalone/chunk-PD6WPVYU.js +1 -0
  110. package/dist/standalone/{chunk-7PBZKXYA.js → chunk-PN5NCZDX.js} +1 -1
  111. package/dist/standalone/{chunk-YJGANMU7.js → chunk-PVZI3CXP.js} +10 -9
  112. package/dist/standalone/chunk-PZ7HD5T2.js +1 -0
  113. package/dist/standalone/{chunk-UGMRUEBU.js → chunk-QAFAJBAW.js} +1 -1
  114. package/dist/standalone/{chunk-6VTGE3WJ.js → chunk-QBAT52GB.js} +1 -1
  115. package/dist/standalone/chunk-QHIIRFG7.js +1 -0
  116. package/dist/standalone/chunk-RSEEHNFI.js +1 -0
  117. package/dist/standalone/chunk-SFJ5F4DX.js +1 -0
  118. package/dist/standalone/{chunk-3BP4BTLR.js → chunk-SGDQIWAR.js} +3 -3
  119. package/dist/standalone/chunk-SYEIXTEU.js +1 -0
  120. package/dist/standalone/chunk-T5HRXUSY.js +1 -0
  121. package/dist/standalone/{chunk-OD2POGPJ.js → chunk-TDL7NEWA.js} +1 -1
  122. package/dist/standalone/chunk-TM7CMA7X.js +1 -0
  123. package/dist/standalone/chunk-U4OAQPBT.js +1 -0
  124. package/dist/standalone/chunk-UDSVXA42.js +1 -0
  125. package/dist/standalone/chunk-UK64ZSUW.js +1 -0
  126. package/dist/standalone/chunk-VEZO7G5Q.js +3 -0
  127. package/dist/standalone/chunk-VSHUSN6T.js +1 -0
  128. package/dist/standalone/chunk-VYMCCC6O.js +1 -0
  129. package/dist/standalone/{chunk-7RYIQKZA.js → chunk-WXPWVBIY.js} +1 -1
  130. package/dist/standalone/chunk-X72PYOEW.js +1 -0
  131. package/dist/standalone/chunk-X7MMBSNW.js +1 -0
  132. package/dist/standalone/{chunk-6RC6L33K.js → chunk-XIGIWZLO.js} +3 -3
  133. package/dist/standalone/chunk-XNJNSCLM.js +1 -0
  134. package/dist/standalone/{chunk-NNISYDNI.js → chunk-XUGSA2NG.js} +1 -1
  135. package/dist/standalone/{chunk-VXBZQIGY.js → chunk-Y2ZPNDL7.js} +1 -1
  136. package/dist/standalone/chunk-YM6BBZDN.js +1 -0
  137. package/dist/standalone/chunk-ZHVTQ37P.js +1 -0
  138. package/dist/standalone/chunk-ZPP2KOR4.js +1 -0
  139. package/dist/standalone/studio.js +30 -30
  140. package/dist/styles.css +1 -1
  141. package/package.json +6 -5
  142. package/dist/standalone/chunk-2PDQ4KZ6.js +0 -1
  143. package/dist/standalone/chunk-57LYXHXH.js +0 -1
  144. package/dist/standalone/chunk-63XKJQTQ.js +0 -1
  145. package/dist/standalone/chunk-7POIIWC5.js +0 -3
  146. package/dist/standalone/chunk-AB6QGMBF.js +0 -1
  147. package/dist/standalone/chunk-D7HKX4DI.js +0 -1
  148. package/dist/standalone/chunk-DGWTR4G7.js +0 -1
  149. package/dist/standalone/chunk-DSX53PBM.js +0 -1
  150. package/dist/standalone/chunk-DV2MNASX.js +0 -1
  151. package/dist/standalone/chunk-E7AVZZKO.js +0 -1
  152. package/dist/standalone/chunk-EGJX34WM.js +0 -1
  153. package/dist/standalone/chunk-FCR3HKFV.js +0 -1
  154. package/dist/standalone/chunk-FQKNJSRA.js +0 -76
  155. package/dist/standalone/chunk-GABMIICA.js +0 -1
  156. package/dist/standalone/chunk-GZXPPJVK.js +0 -1
  157. package/dist/standalone/chunk-HFBRE65A.js +0 -1
  158. package/dist/standalone/chunk-HFMQNUBC.js +0 -1
  159. package/dist/standalone/chunk-HG7Q5B3H.js +0 -1
  160. package/dist/standalone/chunk-HTQL7AXU.js +0 -1
  161. package/dist/standalone/chunk-KG3QTFWE.js +0 -1
  162. package/dist/standalone/chunk-KODWGUAB.js +0 -1
  163. package/dist/standalone/chunk-MGFEVTRI.js +0 -1
  164. package/dist/standalone/chunk-N2QDG3MW.js +0 -1
  165. package/dist/standalone/chunk-O4PXDNR3.js +0 -1
  166. package/dist/standalone/chunk-OXCK3ZUG.js +0 -1
  167. package/dist/standalone/chunk-P7DSVO4U.js +0 -1
  168. package/dist/standalone/chunk-PKAM3N5C.js +0 -1
  169. package/dist/standalone/chunk-QGXGBHQO.js +0 -1
  170. package/dist/standalone/chunk-QHA3TAEJ.js +0 -1
  171. package/dist/standalone/chunk-QQWC62X7.js +0 -1
  172. package/dist/standalone/chunk-S53RUBW5.js +0 -1
  173. package/dist/standalone/chunk-SB4GT6PK.js +0 -1
  174. package/dist/standalone/chunk-SHIOUDOT.js +0 -1
  175. package/dist/standalone/chunk-SIDRSX7Y.js +0 -1
  176. package/dist/standalone/chunk-VJPQUBN6.js +0 -8
  177. package/dist/standalone/chunk-VMJKJWG6.js +0 -1
  178. package/dist/standalone/chunk-VPDPN5RR.js +0 -2
  179. package/dist/standalone/chunk-VSEGZA3J.js +0 -1
  180. package/dist/standalone/chunk-W7PCVQTE.js +0 -1
  181. package/dist/standalone/chunk-XLILSHPE.js +0 -1
  182. package/dist/standalone/chunk-XURNGQSS.js +0 -1
  183. package/dist/standalone/chunk-YQQJ4N6U.js +0 -1
  184. package/dist/standalone/chunk-ZH7UES4T.js +0 -2
  185. package/dist/standalone/chunk-ZQCVDXDL.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as k,b as N,c as O,d as x,e as q,f as D}from"./chunk-GTM65MVX.js";import{a as C}from"./chunk-TAD43CG5.js";import{a as g}from"./chunk-SEU5V7I6.js";import{d as T,g as I,j as _,k as w}from"./chunk-PVZI3CXP.js";import{b as L}from"./chunk-GMSGZDDH.js";import{a as d,e as b,f as U,g as Y,h as F}from"./chunk-RRCPZMC2.js";var M=b(Y(),1);var H="https://api.cloudflare.com/client/v4/accounts",E=class extends L{static{d(this,"AnalyticsSqlError")}constructor(e,f){super("ANALYTICS_SQL_ERROR",`Analytics Engine SQL API returned ${String(e)}: ${f}`,{name:"AnalyticsSqlError",status:e})}},v=d(t=>{let e=t.fetch??globalThis.fetch,f=`${H}/${encodeURIComponent(t.accountId)}/analytics_engine/sql`;return{query:d(async s=>{let l=await e(f,{body:s,headers:{Authorization:`Bearer ${t.apiToken}`,"Content-Type":"text/plain"},method:"POST"});if(!l.ok)throw new E(l.status,await l.text());let n;try{n=await l.json()}catch{throw new E(l.status,"Analytics Engine SQL API returned a non-JSON body.")}let o=n,a=o.data??[];return{columns:o.meta??[],rowCount:o.rows??a.length,rows:a}},"query")}},"createAnalyticsSqlClient");var m=b(U(),1);var r=b(F(),1);var W="ANALYTICS",P=[{key:"volume",sql:d(t=>`SELECT blob2 AS fn, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,"sql"),title:"Request volume per function"},{key:"latency",sql:d(t=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${t} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,"sql"),title:"Latency p50 / p95 per function"},{key:"hotShards",sql:d(t=>`SELECT blob3 AS shard, count() AS calls FROM ${t} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,"sql"),title:"Hot shards"}],j={error:null,loading:!0,result:null},G=d(t=>{let e=(0,M.c)(27),{state:f,title:p}=t,s=T(),{error:l,loading:n,result:o}=f,a=`analytics-panel-${p}`,i;e[0]!==s||e[1]!==p?(i=s(p),e[0]=s,e[1]=p,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1)},void 0,!1),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==n||e[6]!==s?(u=n&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:s("Loading\u2026")},void 0,!1),e[5]=n,e[6]=s,e[7]=u):u=e[7];let y;e[8]!==l||e[9]!==n?(y=!n&&l!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:l},void 0,!1),e[8]=l,e[9]=n,e[10]=y):y=e[10];let h;e[11]!==l||e[12]!==n||e[13]!==o||e[14]!==s?(h=!n&&l===null&&o!==null&&o.rows.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:s("No data points yet.")},void 0,!1),e[11]=l,e[12]=n,e[13]=o,e[14]=s,e[15]=h):h=e[15];let A;e[16]!==l||e[17]!==n||e[18]!==o?(A=!n&&l===null&&o!==null&&o.rows.length>0&&(0,r.jsxDEV)(k,{children:[(0,r.jsxDEV)(N,{children:(0,r.jsxDEV)(x,{children:o.columns.map(Q)},void 0,!1)},void 0,!1),(0,r.jsxDEV)(O,{children:o.rows.map((B,$)=>(0,r.jsxDEV)(x,{children:o.columns.map(R=>(0,r.jsxDEV)(D,{className:"font-mono text-xs",children:_(B[R.name])},R.name,!1))},$,!1))},void 0,!1)]},void 0,!0),e[16]=l,e[17]=n,e[18]=o,e[19]=A):A=e[19];let S;return e[20]!==a||e[21]!==c||e[22]!==u||e[23]!==y||e[24]!==h||e[25]!==A?(S=(0,r.jsxDEV)(g,{className:"gap-0 py-0","data-testid":a,children:[c,u,y,h,A]},void 0,!0),e[20]=a,e[21]=c,e[22]=u,e[23]=y,e[24]=h,e[25]=A,e[26]=S):S=e[26],S},"PanelResult"),re=d(({config:t,dataset:e=W,runQuery:f}={})=>{let p=T(),[s,l]=(0,m.useState)({}),n=(0,m.useMemo)(()=>{if(f!==void 0)return f;if(t===void 0)return null;let a=v({accountId:t.accountId,apiToken:t.apiToken});return i=>a.query(i)},[t,f]),o=(0,m.useCallback)(async a=>{if(n!==null)for(let i of P){if(a.cancelled)return;l(c=>({...c,[i.key]:{error:null,loading:!0,result:null}}));try{let c=await n(i.sql(e));a.cancelled||l(u=>({...u,[i.key]:{error:null,loading:!1,result:c}}))}catch(c){a.cancelled||l(u=>({...u,[i.key]:{error:I(c),loading:!1,result:null}}))}}},[n,e]);return(0,m.useEffect)(()=>{let a={cancelled:!1};return w(o(a)),()=>{a.cancelled=!0}},[o]),n===null?(0,r.jsxDEV)(C,{description:p("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:(0,r.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsxDEV)("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"},void 0,!1)},void 0,!1),testId:"analytics-not-configured",title:p("Analytics is not configured.")},void 0,!1):(0,r.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:P.map(a=>(0,r.jsxDEV)(G,{state:s[a.key]??j,title:a.title},a.key,!1))},void 0,!1)},"AnalyticsPanel");function Q(t){return(0,r.jsxDEV)(q,{children:t.name},t.name,!1)}d(Q,"_temp");export{re as AnalyticsPanel};
@@ -0,0 +1 @@
1
+ import{a as V}from"./chunk-VLXV72QE.js";import{a as g}from"./chunk-JSEXCW5Q.js";import{a as z}from"./chunk-K3GNLVYK.js";import{b as q}from"./chunk-TBMYIZIO.js";import{R as j}from"./chunk-3CJW6NWG.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as P}from"./chunk-AQGOX5DK.js";import{b as w}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as L}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as U,e as B,g as J,k as K,n as M}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a,e as D,f as oe,h as ne}from"./chunk-RRCPZMC2.js";var n=D(oe(),1);var t=D(ne(),1);var ie=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),de=a(r=>r===void 0||r.length===0?"()":`(${r.map(l=>`${l.name}${l.optional?"?":""}: ${ie(l)}`).join(", ")})`,"formatSignature"),le=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ce=a(r=>{let l={};for(let s of r??[])s.optional||(l[s.name]=le(s.kind));return JSON.stringify(l,void 0,2)},"argumentsTemplate"),ue=B(P.runAs),fe=10,me=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ie=a(({functions:r,runAsIdentity:l=!1}={})=>{let s=U(),c=L(),[H,X]=(0,n.useState)(null),[k,Y]=(0,n.useState)(null),x=r??H??[],[R,I]=(0,n.useState)(""),[f,b]=(0,n.useState)("{}"),[u,A]=(0,n.useState)(""),[m,G]=(0,n.useState)(""),[N,h]=(0,n.useState)("idle"),[Q,y]=(0,n.useState)(void 0),[C,S]=(0,n.useState)(null),[T,W]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let e=!1;return c.listFunctions().then(i=>(e||X(i),i)).catch(i=>{e||Y(J(i))}),()=>{e=!0}},[c,r]);let F=R===""?x[0]?.path??"":R,o=x.find(e=>e.path===F),Z=a(async()=>{if(!o)return;let e;try{e=f.trim()===""?{}:JSON.parse(f)}catch(d){h("error"),y(void 0),S(s("Invalid JSON args: {message}",{message:d.message}));return}let i={__lunoraRef:o.path},v=u.trim()===""?{}:{shardKey:u.trim()},$=l?m.trim():"",E=a(d=>{W(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:u,status:d},...O].slice(0,fe))},"record");h("running"),S(null);try{let d;if($==="")switch(o.kind){case"action":{d=await c.action(i,e,v);break}case"mutation":{d=await c.mutation(i,e,v);break}default:d=await c.query(i,e,v)}else d=await c.query(ue,{args:e,functionPath:o.path,userId:$},v);q(u),y(d),h("success"),E("success")}catch(d){y(void 0),S(d.message),h("error"),E("error")}},"run"),_=a(e=>{I(e.path),b(e.argsText),A(e.shardKey)},"loadRun"),ee=a(e=>{I(e.target.value)},"onSelectChange"),te=a(e=>{b(e.target.value)},"onArgsChange"),re=a(e=>{G(e.target.value)},"onRunAsChange"),se=a(()=>{K(Z())},"runOnce"),ae=a(()=>{b(ce(o?.args))},"prefillArgs");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)(g,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,t.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ee,value:F,children:x.map(e=>(0,t.jsxDEV)("option",{value:e.path,children:[e.path," (",e.kind,")"]},e.path,!0))},void 0,!1),o!==void 0&&(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,t.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,t.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:de(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxDEV)(g,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,t.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:ae,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(V,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:te,value:f},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(z,{onChange:A,testId:"shard-input",value:u},void 0,!1),l&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,t.jsxDEV)(g,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,t.jsxDEV)(j,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:re,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,t.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(p,{"data-testid":"run-button",disabled:N==="running"||o===void 0,onClick:se,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,t.jsxDEV)(w,{variant:"outline",children:o.kind},void 0,!1),l&&m.trim()!==""&&(0,t.jsxDEV)(w,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),N==="error"&&C!==null&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C},void 0,!1),N==="success"&&(0,t.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:me(Q)},void 0,!1),T.length>0&&(0,t.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:T.map((e,i)=>(0,t.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,t.jsxDEV)("span",{className:e.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${i.toString()}`,children:e.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,t.jsxDEV)("span",{className:"font-mono text-xs",children:[e.path," (",e.kind,")"]},void 0,!0)," ",(0,t.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:M(e.at)},void 0,!1)," ",(0,t.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${i.toString()}`,onClick:a(()=>{_(e)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},e.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ie as FunctionRunner};
@@ -1,13 +1,13 @@
1
- import{a as Ce}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as ke,f as we,g as Oe,k as ae}from"./chunk-4QHKBC77.js";import{a as Te}from"./chunk-RMYA7NAH.js";import"./chunk-TBMYIZIO.js";import{R as Se}from"./chunk-BHTPZS7L.js";import{c as H}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as Ie}from"./chunk-AQGOX5DK.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Ne}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import{f as G}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,i as $e,j as re}from"./chunk-YJGANMU7.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ge=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var L=q(ne(),1);var Ue=le(Ie.listTables),Ye=["react","client","cli"],Qe=!1,Xe={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Re=p(({file:t,fn:e,kind:o})=>`await client.${Xe[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),Ze=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Re(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),et=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),tt=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
- `),"buildTableSnippet"),st=p((t,e)=>{switch(t){case"cli":return et(e);case"client":return Re(e);default:return Ze(e)}},"snippetForTab"),Ee=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,L.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,L.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,L.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,L.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let k;return e[16]!==u||e[17]!==v?(k=(0,L.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=k):k=e[18],k},"SnippetBlock"),ot=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=e[9];let A;e[10]!==r?(A=r("Client"),e[10]=r,e[11]=A):A=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==I||e[15]!==A||e[16]!==E?(j={cli:I,client:A,react:E},e[14]=I,e[15]=A,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(B=>{i(B.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=st(l,T),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Qe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(0,L.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=k):k=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==k||e[27]!==h?(g=(0,L.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Ye.map(T=>(0,L.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(0,L.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,L.jsxDEV)(Ee,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,L.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),nt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=tt(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,L.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,L.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,L.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,L.jsxDEV)(Ee,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,L.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Ae=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,L.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),_e=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Ue,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(it).toSorted(at),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(lt).toSorted(dt),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,L.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,L.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,L.jsxDEV)(Ae,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,L.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,L.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,L.jsxDEV)(Ae,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!h&&(0,L.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,L.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=e[43];let A;e[44]!==d||e[45]!==n?(A=d===null&&(0,L.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=A):A=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,L.jsxDEV)(ot,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,L.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,L.jsxDEV)(nt,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let B;e[57]!==A||e[58]!==E||e[59]!==j||e[60]!==R?(B=(0,L.jsxDEV)("div",{className:"min-w-0",children:[A,E,j,R]},void 0,!0),e[57]=A,e[58]=E,e[59]=j,e[60]=R,e[61]=B):B=e[61];let P;return e[62]!==b||e[63]!==S||e[64]!==I||e[65]!==B?(P=(0,L.jsxDEV)("div",{className:b,"data-testid":S,children:[I,B]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=B,e[66]=P):P=e[66],P},"ApiDocsPanel");function rt(t,e){return t.fn.localeCompare(e.fn)}p(rt,"_temp");function it(t){let[e,o]=t;return{file:e,items:o.toSorted(rt)}}p(it,"_temp2");function at(t,e){return t.file.localeCompare(e.file)}p(at,"_temp3");function lt(t){return t.name}p(lt,"_temp4");function dt(t,e){return t.localeCompare(e)}p(dt,"_temp5");var qe=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),ct=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),Le=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),ft=p(t=>{let e=Le(t);return e!==void 0?t.type??ct(e[0]):pe(t)},"fieldTypeLabel"),pt=p(t=>{let e=Le(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),ut=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),mt=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),vt=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=ut(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=pt(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=mt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=ft(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==n.description?(S=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(De,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=T):T=e[39],T},"FieldRow"),De=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(vt,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),je=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(De,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),ht=["curl","javascript","lunora"],gt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),bt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),yt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(bt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
1
+ import{a as Ae}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ce}from"./chunk-K3GNLVYK.js";import"./chunk-TBMYIZIO.js";import{R as ke}from"./chunk-3CJW6NWG.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Te}from"./chunk-AQGOX5DK.js";import{a as W}from"./chunk-TAD43CG5.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as G}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as M,e as le,f as de,g as ce,k as Ie,l as re}from"./chunk-PVZI3CXP.js";import{b as Ne}from"./chunk-GMSGZDDH.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ue=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Ye=le(Te.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},Pe=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),Ee=p(({file:t,fn:e,kind:o})=>`await client.${Ze[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),et=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ee(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),tt=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),st=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
+ `),"buildTableSnippet"),ot=p((t,e)=>{switch(t){case"cli":return tt(e);case"client":return Ee(e);default:return et(e)}},"snippetForTab"),_e=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,B.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,B.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,B.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,B.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let k;return e[16]!==u||e[17]!==v?(k=(0,B.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=k):k=e[18],k},"SnippetBlock"),nt=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let T={file:o,fn:s,kind:n},I;e[8]!==r?(I=r("CLI"),e[8]=r,e[9]=I):I=e[9];let P;e[10]!==r?(P=r("Client"),e[10]=r,e[11]=P):P=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==I||e[15]!==P||e[16]!==E?(j={cli:I,client:P,react:E},e[14]=I,e[15]=P,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(L=>{i(L.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=ot(l,T),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Xe,v=`api.${o}.${s}`,k;e[19]!==v?(k=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=k):k=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==k||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[k,h]},void 0,!0),e[26]=k,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Qe.map(T=>(0,B.jsxDEV)(H,{"aria-selected":l===T,"data-tab":T,"data-testid":`api-tab-${T}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===T?"default":"outline",children:m[T]},T,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let S;e[35]!==x||e[36]!==b?(S=(0,B.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=S):S=e[37];let y=m[l],$=`api-snippet-${l}`,N;e[38]!==a||e[39]!==y||e[40]!==$?(N=(0,B.jsxDEV)(_e,{code:a,label:y,testId:$},void 0,!1),e[38]=a,e[39]=y,e[40]=$,e[41]=N):N=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==N||e[46]!==w||e[47]!==g||e[48]!==S?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,S,N,w]},void 0,!0),e[45]=N,e[46]=w,e[47]=g,e[48]=S,e[49]=C):C=e[49],C},"FunctionDoc"),rt=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=st(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,B.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,B.jsxDEV)(_e,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Re=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,B.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),je=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Ye,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,k;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Pe(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}k=[..._.entries()].map(at).toSorted(lt),e[6]=v,e[7]=k}else k=e[7];let O=k,h,g,x,b,S,y,$,N,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(dt).toSorted(ct),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Pe(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",S="lunora-api-docs",e[25]!==n?(y=n("API resources"),e[25]=n,e[26]=y):y=e[26],$="flex flex-col gap-4 overflow-y-auto",N="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,B.jsxDEV)(Re,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,B.jsxDEV)(Re,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=S,e[18]=y,e[19]=$,e[20]=N,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],S=e[17],y=e[18],$=e[19],N=e[20],w=e[21],C=e[22];let T;e[34]!==h||e[35]!==n?(T=!h&&(0,B.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=T):T=e[36];let I;e[37]!==T||e[38]!==y||e[39]!==$||e[40]!==N||e[41]!==w||e[42]!==C?(I=(0,B.jsxDEV)("nav",{"aria-label":y,className:$,"data-testid":N,children:[w,C,T]},void 0,!0),e[37]=T,e[38]=y,e[39]=$,e[40]=N,e[41]=w,e[42]=C,e[43]=I):I=e[43];let P;e[44]!==d||e[45]!==n?(P=d===null&&(0,B.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=P):P=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,B.jsxDEV)(nt,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,B.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,B.jsxDEV)(rt,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let L;e[57]!==P||e[58]!==E||e[59]!==j||e[60]!==R?(L=(0,B.jsxDEV)("div",{className:"min-w-0",children:[P,E,j,R]},void 0,!0),e[57]=P,e[58]=E,e[59]=j,e[60]=R,e[61]=L):L=e[61];let A;return e[62]!==b||e[63]!==S||e[64]!==I||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":S,children:[I,L]},void 0,!0),e[62]=b,e[63]=S,e[64]=I,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function it(t,e){return t.fn.localeCompare(e.fn)}p(it,"_temp");function at(t){let[e,o]=t;return{file:e,items:o.toSorted(it)}}p(at,"_temp2");function lt(t,e){return t.file.localeCompare(e.file)}p(lt,"_temp3");function dt(t){return t.name}p(dt,"_temp4");function ct(t,e){return t.localeCompare(e)}p(ct,"_temp5");var Ve=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),ft=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),De=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),pt=p(t=>{let e=De(t);return e!==void 0?t.type??ft(e[0]):pe(t)},"fieldTypeLabel"),ut=p(t=>{let e=De(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),mt=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),vt=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),ht=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=mt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=ut(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=vt(n),e[4]=n,e[5]=u):u=e[5];let v=u,k=s?"*":"?",O;e[6]!==k?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:k},void 0,!1),e[6]=k,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=pt(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let S;e[18]!==n.description?(S=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=S):S=e[19];let y;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(y=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=y):y=e[26];let $;e[27]!==S||e[28]!==y||e[29]!==b?($=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,S,y]},void 0,!0),e[27]=S,e[28]=y,e[29]=b,e[30]=$):$=e[30];let N=$;if(v===void 0){let I;return e[31]!==N?(I=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:N},void 0,!1),e[31]=N,e[32]=I):I=e[32],I}let w;e[33]!==N?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:N},void 0,!1),e[33]=N,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(Me,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let T;return e[37]!==w||e[38]!==C?(T=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=T):T=e[39],T},"FieldRow"),Me=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(ht,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),Le=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(Me,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),gt=["curl","javascript","lunora"],xt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},bt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),yt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),Nt=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(yt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
5
5
 
6
6
  const client = useLunora();
7
- await client.${e.kind??"query"}(${xt(e.functionPath)}, ${r});`;default:{let i=e.method!=="GET"&&e.method!=="HEAD"?`{
7
+ await client.${e.kind??"query"}(${bt(e.functionPath)}, ${r});`;default:{let i=e.method!=="GET"&&e.method!=="HEAD"?`{
8
8
  method: ${JSON.stringify(e.method)},
9
9
  headers: { "Content-Type": "application/json" },
10
10
  body: JSON.stringify(${n}),
11
11
  }`:`{ method: ${JSON.stringify(e.method)} }`;return`const response = await fetch(${JSON.stringify(s)}, ${i});
12
- const data = await response.json();`}}},"sampleSource"),Nt=p(t=>{let e=(0,J.c)(24),{operation:o,server:s}=t,n=M(),[r,l]=(0,K.useState)("curl"),i;e[0]!==o||e[1]!==r||e[2]!==s?(i=yt(r,o,s),e[0]=o,e[1]=r,e[2]=s,e[3]=i):i=e[3];let d=i,c;e[4]!==d?(c=p(()=>{re(d)},"t2"),e[4]=d,e[5]=c):c=e[5];let m=c,a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=p(S=>{l(S.currentTarget.dataset.sample)},"t3"),e[6]=a):a=e[6];let u=a,v;e[7]!==r?(v=ht.map(S=>(0,f.jsxDEV)("button",{"aria-selected":r===S,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":S,"data-testid":`api-sample-${S}`,onClick:u,role:"tab",type:"button",children:gt[S]},S,!1)),e[7]=r,e[8]=v):v=e[8];let k;e[9]!==v?(k=(0,f.jsxDEV)("div",{className:"flex gap-1",role:"tablist",children:v},void 0,!1),e[9]=v,e[10]=k):k=e[10];let O;e[11]!==n?(O=n("Copy"),e[11]=n,e[12]=O):O=e[12];let h;e[13]!==m||e[14]!==O?(h=(0,f.jsxDEV)(H,{"data-testid":"api-sample-copy",onClick:m,size:"xs",type:"button",variant:"ghost",children:O},void 0,!1),e[13]=m,e[14]=O,e[15]=h):h=e[15];let g;e[16]!==k||e[17]!==h?(g=(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[k,h]},void 0,!0),e[16]=k,e[17]=h,e[18]=g):g=e[18];let x;e[19]!==d?(x=(0,f.jsxDEV)("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:d},void 0,!1),e[19]=d,e[20]=x):x=e[20];let b;return e[21]!==g||e[22]!==x?(b=(0,f.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[g,x]},void 0,!0),e[21]=g,e[22]=x,e[23]=b):b=e[23],b},"CodeSamples"),St={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},kt=p(t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},"methodTone"),wt=p(t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},"kindTone"),be=p(t=>{let e=(0,J.c)(7),{kind:o,method:s,testId:n}=t,r;e[0]!==o||e[1]!==s?(r=o??s.toUpperCase(),e[0]=o,e[1]=s,e[2]=r):r=e[2];let l=r,i=o===void 0?kt(s):wt(o),d=`${St[i]} font-mono text-[10px] tracking-wide uppercase`,c;return e[3]!==l||e[4]!==d||e[5]!==n?(c=(0,f.jsxDEV)(Ne,{className:d,"data-testid":n,variant:"ghost",children:l},void 0,!1),e[3]=l,e[4]=d,e[5]=n,e[6]=c):c=e[6],c},"MethodBadge"),Me=p(t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground","statusToneClass"),Ke=p(t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground","statusDotClass"),Ot=p(t=>JSON.stringify(te(t.argsSchema)??{},void 0,2),"seedArgs"),Fe=(0,K.createContext)(null),Je=p(()=>{let t=(0,K.use)(Fe);if(t===null)throw new Error("useOperationRun must be used within an OperationRunProvider");return t},"useOperationRun"),$t=p(({children:t,operation:e})=>{let o=M(),s=G(),[n,r]=(0,K.useState)(()=>Ot(e)),[l,i]=(0,K.useState)(""),[d,c]=(0,K.useState)("idle"),[m,a]=(0,K.useState)(void 0),[u,v]=(0,K.useState)(null),[k,O]=(0,K.useState)(null),h=p(async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(y){c("error"),a(void 0),O(null),v(o("Invalid JSON args: {message}",{message:ce(y)}));return}c("running"),v(null);let S=performance.now();try{let y;if(e.functionPath===void 0){let $=e.method!=="GET"&&e.method!=="HEAD",w=await(await fetch(e.httpPath,{body:$?JSON.stringify(b):void 0,headers:$?{"content-type":"application/json"}:void 0,method:e.method})).text();try{y=JSON.parse(w)}catch{y=w}}else{let $=le(e.functionPath),N=de(l);switch(e.kind){case"action":{y=await s.action($,b,N);break}case"mutation":{y=await s.mutation($,b,N);break}default:y=await s.query($,b,N)}}a(y),O(Math.round(performance.now()-S)),c("success")}catch(y){a(void 0),O(Math.round(performance.now()-S)),v(ce(y)),c("error")}},"send");return(0,f.jsxDEV)(Fe,{value:{argsText:n,durationMs:k,error:u,operation:e,response:m,send:p(()=>{$e(h())},"onSend"),setArgsText:r,setShardKey:i,shardKey:l,status:d},children:t},void 0,!1)},"OperationRunProvider"),It=p(()=>{let t=(0,J.c)(48),e=M(),{argsText:o,operation:s,send:n,setArgsText:r,setShardKey:l,shardKey:i,status:d}=Je(),c;t[0]!==r?(c=p(R=>{r(R.target.value)},"t0"),t[0]=r,t[1]=c):c=t[1];let m=c,a;t[2]!==n?(a=p(R=>{R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),n())},"t1"),t[2]=n,t[3]=a):a=t[3];let u=a,v=d==="running",k;t[4]!==s.kind||t[5]!==s.method?(k=(0,f.jsxDEV)(be,{kind:s.kind,method:s.method,testId:"api-try-method"},void 0,!1),t[4]=s.kind,t[5]=s.method,t[6]=k):k=t[6];let O=s.functionPath??s.httpPath,h;t[7]!==O?(h=(0,f.jsxDEV)("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:O},void 0,!1),t[7]=O,t[8]=h):h=t[8];let g=v?"animate-pulse":void 0,x;t[9]!==g?(x=(0,f.jsxDEV)(ae,{className:g,icon:Oe,strokeWidth:2},void 0,!1),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==v||t[12]!==e?(b=e(v?"Sending\u2026":"Send"),t[11]=v,t[12]=e,t[13]=b):b=t[13];let S;t[14]!==v||t[15]!==n||t[16]!==x||t[17]!==b?(S=(0,f.jsxDEV)(H,{"data-testid":"api-try-send",disabled:v,onClick:n,size:"sm",type:"button",children:[x,b]},void 0,!0),t[14]=v,t[15]=n,t[16]=x,t[17]=b,t[18]=S):S=t[18];let y;t[19]!==k||t[20]!==h||t[21]!==S?(y=(0,f.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[k,h,S]},void 0,!0),t[19]=k,t[20]=h,t[21]=S,t[22]=y):y=t[22];let $;t[23]!==e?($=e("Arguments (JSON)"),t[23]=e,t[24]=$):$=t[24];let N;t[25]!==$?(N=(0,f.jsxDEV)(xe,{htmlFor:"api-try-args",children:$},void 0,!1),t[25]=$,t[26]=N):N=t[26];let w;t[27]!==o?(w=o.split(`
13
- `),t[27]=o,t[28]=w):w=t[28];let C=Math.min(12,Math.max(3,w.length)),T;t[29]!==o||t[30]!==m||t[31]!==u||t[32]!==C?(T=(0,f.jsxDEV)(Ce,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:m,onKeyDown:u,rows:C,spellCheck:!1,value:o},void 0,!1),t[29]=o,t[30]=m,t[31]=u,t[32]=C,t[33]=T):T=t[33];let I;t[34]!==N||t[35]!==T?(I=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[N,T]},void 0,!0),t[34]=N,t[35]=T,t[36]=I):I=t[36];let A;t[37]!==s.functionPath||t[38]!==l||t[39]!==i||t[40]!==e?(A=s.functionPath!==void 0&&(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,f.jsxDEV)(xe,{htmlFor:"shard-input",children:e("Shard key (optional)")},void 0,!1),(0,f.jsxDEV)(Te,{id:"shard-input",onChange:l,testId:"shard-input",value:i},void 0,!1)]},void 0,!0),t[37]=s.functionPath,t[38]=l,t[39]=i,t[40]=e,t[41]=A):A=t[41];let E;t[42]!==I||t[43]!==A?(E=(0,f.jsxDEV)("div",{className:"flex flex-col gap-3 p-3",children:[I,A]},void 0,!0),t[42]=I,t[43]=A,t[44]=E):E=t[44];let j;return t[45]!==E||t[46]!==y?(j=(0,f.jsxDEV)("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[y,E]},void 0,!0),t[45]=E,t[46]=y,t[47]=j):j=t[47],j},"TryIt"),Tt=p(t=>{let e=(0,J.c)(51),{operation:o}=t,s=M(),n=`api-operation-${o.operationId}`,r=o.key,l;e[0]!==o.kind||e[1]!==o.method?(l=(0,f.jsxDEV)(be,{kind:o.kind,method:o.method,testId:"api-operation-method"},void 0,!1),e[0]=o.kind,e[1]=o.method,e[2]=l):l=e[2];let i=o.functionPath??o.httpPath,d;e[3]!==i?(d=(0,f.jsxDEV)("code",{className:"truncate font-mono text-xs text-muted-foreground",children:i},void 0,!1),e[3]=i,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=(0,f.jsxDEV)("div",{className:"flex items-center gap-2",children:[l,d]},void 0,!0),e[5]=l,e[6]=d,e[7]=c):c=e[7];let m;e[8]!==o.title?(m=(0,f.jsxDEV)("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:o.title},void 0,!1),e[8]=o.title,e[9]=m):m=e[9];let a;e[10]!==o.description?(a=o.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[10]=o.description,e[11]=a):a=e[11];let u;e[12]!==c||e[13]!==m||e[14]!==a?(u=(0,f.jsxDEV)("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[c,m,a]},void 0,!0),e[12]=c,e[13]=m,e[14]=a,e[15]=u):u=e[15];let v;e[16]!==s?(v=s("Try it"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==v?(k=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v},void 0,!1),e[18]=v,e[19]=k):k=e[19];let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=(0,f.jsxDEV)(It,{},void 0,!1),e[20]=O):O=e[20];let h;e[21]!==k?(h=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[k,O]},void 0,!0),e[21]=k,e[22]=h):h=e[22];let g;e[23]!==s?(g=s("Request arguments"),e[23]=s,e[24]=g):g=e[24];let x;e[25]!==g?(x=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1),e[25]=g,e[26]=x):x=e[26];let b;e[27]!==o.argsSchema?(b=(0,f.jsxDEV)(je,{schema:o.argsSchema,testId:"api-operation-args"},void 0,!1),e[27]=o.argsSchema,e[28]=b):b=e[28];let S;e[29]!==x||e[30]!==b?(S=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[x,b]},void 0,!0),e[29]=x,e[30]=b,e[31]=S):S=e[31];let y;e[32]!==s?(y=s("Response body"),e[32]=s,e[33]=y):y=e[33];let $;e[34]!==y?($=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1),e[34]=y,e[35]=$):$=e[35];let N;if(e[36]!==o.responses||e[37]!==s){let T;e[39]!==s?(T=p(I=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,f.jsxDEV)("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${Me(I.status)}`,children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Ke(I.status)}`},void 0,!1),I.status]},void 0,!0),I.schema!==void 0&&(0,f.jsxDEV)("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s("application/json")},void 0,!1)]},void 0,!0),I.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:I.description},void 0,!1),I.schema!==void 0&&(0,f.jsxDEV)(je,{schema:I.schema,testId:`api-response-${I.status}`},void 0,!1)]},I.status,!0),"t212"),e[39]=s,e[40]=T):T=e[40],N=o.responses.map(T),e[36]=o.responses,e[37]=s,e[38]=N}else N=e[38];let w;e[41]!==$||e[42]!==N?(w=(0,f.jsxDEV)("section",{className:"flex flex-col gap-3",children:[$,N]},void 0,!0),e[41]=$,e[42]=N,e[43]=w):w=e[43];let C;return e[44]!==o.key||e[45]!==n||e[46]!==h||e[47]!==S||e[48]!==w||e[49]!==u?(C=(0,f.jsxDEV)("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[u,h,S,w]},r,!0),e[44]=o.key,e[45]=n,e[46]=h,e[47]=S,e[48]=w,e[49]=u,e[50]=C):C=e[50],C},"OperationView"),Ct={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Pt=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,At=/^\s*:/,Rt=p((t,e,o)=>o.startsWith('"')?At.test(t.slice(e))?"key":"string":o==="true"||o==="false"||o==="null"?"boolean":"number","classify"),Et=p(t=>{let e=[],o=0;for(let s of t.matchAll(Pt)){let{index:n}=s,r=s[0],l=n+r.length;n>o&&e.push({kind:"plain",start:o,text:t.slice(o,n)}),e.push({kind:Rt(t,l,r),start:n,text:r}),o=l}return o<t.length&&e.push({kind:"plain",start:o,text:t.slice(o)}),e},"tokenize"),_t=p(t=>{let e=(0,J.c)(4),{code:o}=t,s;e[0]!==o?(s=Et(o).map(jt),e[0]=o,e[1]=s):s=e[1];let n;return e[2]!==s?(n=(0,f.jsxDEV)(f.Fragment,{children:s},void 0,!1),e[2]=s,e[3]=n):n=e[3],n},"JsonHighlight");function jt(t){return(0,f.jsxDEV)("span",{className:Ct[t.kind],children:t.text},t.start,!1)}p(jt,"_temp$1");var Be="__live__",Bt=p(t=>t.schema===void 0?"":JSON.stringify(te(t.schema),void 0,2),"exampleBody"),Lt=p((t,e,o)=>o?t??"":e===void 0?"":JSON.stringify(e,void 0,2),"liveBody"),Dt=p(t=>{let e=(0,J.c)(18),{active:o,running:s,showError:n}=t,r=M();if(s){let a;e[0]!==r?(a=r("Sending\u2026"),e[0]=r,e[1]=a):a=e[1];let u;return e[2]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:a},void 0,!1),e[2]=a,e[3]=u):u=e[3],u}if(o===void 0||o.body===""){let a;e[4]!==o?.live||e[5]!==r?(a=o?.live===!0?r("Send a request to see the response."):r("No example for this response."),e[4]=o?.live,e[5]=r,e[6]=a):a=e[6];let u;return e[7]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:a},void 0,!1),e[7]=a,e[8]=u):u=e[8],u}let l=n&&"text-destructive",i;e[9]!==l?(i=ge("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=i):i=e[10];let d=n?"api-response-error":"api-response-body",c;e[11]!==o.body||e[12]!==n?(c=n?o.body:(0,f.jsxDEV)(_t,{code:o.body},void 0,!1),e[11]=o.body,e[12]=n,e[13]=c):c=e[13];let m;return e[14]!==i||e[15]!==d||e[16]!==c?(m=(0,f.jsxDEV)("pre",{className:i,"data-testid":d,children:c},void 0,!1),e[14]=i,e[15]=d,e[16]=c,e[17]=m):m=e[17],m},"ResponseBody"),Mt=p(()=>{let t=(0,J.c)(67),e=M(),{durationMs:o,error:s,operation:n,response:r,status:l}=Je(),i=l==="running",d=l==="error",c=l==="success"||d,m;if(t[0]!==o||t[1]!==s||t[2]!==d||t[3]!==n.responses||t[4]!==c||t[5]!==r||t[6]!==e){e:{let B=n.responses.map(Kt);if(!c){m=B;break e}let P;t[8]!==s||t[9]!==d||t[10]!==r?(P=Lt(s,r,d),t[8]=s,t[9]=d,t[10]=r,t[11]=P):P=t[11];let _;t[12]!==e?(_=e("Live"),t[12]=e,t[13]=_):_=t[13];let D=d?"error":"200",V;t[14]!==o||t[15]!==P||t[16]!==_||t[17]!==D?(V={body:P,durationMs:o,id:Be,label:_,live:!0,status:D},t[14]=o,t[15]=P,t[16]=_,t[17]=D,t[18]=V):V=t[18],m=[V,...B]}t[0]=o,t[1]=s,t[2]=d,t[3]=n.responses,t[4]=c,t[5]=r,t[6]=e,t[7]=m}else m=t[7];let a=m,u;t[19]!==c||t[20]!==a?(u=c?Be:a.find(Ft)?.id??a[0]?.id??"",t[19]=c,t[20]=a,t[21]=u):u=t[21];let v=u,[k,O]=(0,K.useState)(null),h,g,x,b,S,y,$,N,w,C;if(t[22]!==v||t[23]!==k||t[24]!==e||t[25]!==a){h=a.find(D=>D.id===(k??v))??a[0];let B;t[36]===Symbol.for("react.memo_cache_sentinel")?(B=p(D=>{let{id:V}=D.currentTarget.dataset;V!==void 0&&O(V)},"t82"),t[36]=B):B=t[36],x=B,g=p(()=>{h!==void 0&&re(h.body)},"onCopy");let P=h?.live===!0?h.durationMs:null;b=h?.live===!0&&h.status==="error",w="flex min-h-0 flex-col rounded-xl border border-border bg-card",C="api-response-panel",$="flex items-center justify-between gap-2 border-b border-border px-3 py-2";let _;t[37]!==e?(_=e("Response"),t[37]=e,t[38]=_):_=t[38],t[39]!==_?(N=(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),t[39]=_,t[40]=N):N=t[40],S="flex items-center gap-2",y=P!==null&&(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:P})},void 0,!1),t[22]=v,t[23]=k,t[24]=e,t[25]=a,t[26]=h,t[27]=g,t[28]=x,t[29]=b,t[30]=S,t[31]=y,t[32]=$,t[33]=N,t[34]=w,t[35]=C}else h=t[26],g=t[27],x=t[28],b=t[29],S=t[30],y=t[31],$=t[32],N=t[33],w=t[34],C=t[35];let T;t[41]!==h||t[42]!==g||t[43]!==e?(T=h!==void 0&&h.body!==""&&(0,f.jsxDEV)(H,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:g,size:"icon-xs",type:"button",variant:"ghost",children:(0,f.jsxDEV)(ae,{icon:ke,strokeWidth:2},void 0,!1)},void 0,!1),t[41]=h,t[42]=g,t[43]=e,t[44]=T):T=t[44];let I;t[45]!==S||t[46]!==y||t[47]!==T?(I=(0,f.jsxDEV)("div",{className:S,children:[y,T]},void 0,!0),t[45]=S,t[46]=y,t[47]=T,t[48]=I):I=t[48];let A;t[49]!==$||t[50]!==N||t[51]!==I?(A=(0,f.jsxDEV)("div",{className:$,children:[N,I]},void 0,!0),t[49]=$,t[50]=N,t[51]=I,t[52]=A):A=t[52];let E;t[53]!==h?.id||t[54]!==x||t[55]!==a?(E=a.length>0&&(0,f.jsxDEV)("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:a.map(B=>{let P=B.id===h?.id;return(0,f.jsxDEV)("button",{"aria-selected":P,className:ge("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",P?Me(B.status):"text-muted-foreground"),"data-id":B.id,"data-testid":B.live?"api-response-tab-live":`api-response-tab-${B.status}`,onClick:x,role:"tab",type:"button",children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Ke(B.status)}`},void 0,!1),B.label]},B.id,!0)})},void 0,!1),t[53]=h?.id,t[54]=x,t[55]=a,t[56]=E):E=t[56];let j;t[57]!==h||t[58]!==i||t[59]!==b?(j=(0,f.jsxDEV)(Dt,{active:h,running:i,showError:b},void 0,!1),t[57]=h,t[58]=i,t[59]=b,t[60]=j):j=t[60];let R;return t[61]!==A||t[62]!==E||t[63]!==j||t[64]!==w||t[65]!==C?(R=(0,f.jsxDEV)("div",{className:w,"data-testid":C,children:[A,E,j]},void 0,!0),t[61]=A,t[62]=E,t[63]=j,t[64]=w,t[65]=C,t[66]=R):R=t[66],R},"ResponsePanel");function Kt(t){return{body:Bt(t),durationMs:null,id:t.status,label:t.status,live:!1,status:t.status}}p(Kt,"_temp");function Ft(t){return t.status.startsWith("2")}p(Ft,"_temp2");var Jt=p((t,e)=>{let o=e.trim().toLowerCase();return o===""?t:t.map(s=>({...s,operations:s.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(o))})).filter(s=>s.operations.length>0)},"filterGroups"),me=p(t=>{let e=(0,J.c)(53),{model:o}=t,s=M(),n=o.groups[0]?.operations[0]?.key??"",[r,l]=(0,K.useState)(n),[i,d]=(0,K.useState)(""),c;e[0]!==n||e[1]!==o.operationByKey||e[2]!==r?(c=o.operationByKey.get(r)??o.operationByKey.get(n),e[0]=n,e[1]=o.operationByKey,e[2]=r,e[3]=c):c=e[3];let m=c,a,u,v,k,O,h,g,x,b,S;if(e[4]!==i||e[5]!==o.groups||e[6]!==o.server||e[7]!==m?.key||e[8]!==s){a=Jt(o.groups,i);let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p(P=>{let{key:_}=P.currentTarget.dataset;_!==void 0&&l(_)},"t102"),e[19]=T):T=e[19];let I=T,A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=p(P=>{d(P.target.value)},"t112"),e[20]=A):A=e[20];let E=A;u=o.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",S="api-reference",e[21]!==s?(O=s("API operations"),e[21]=s,e[22]=O):O=e[22],h="flex min-h-0 flex-col overflow-y-auto border-r border-border",g="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=(0,f.jsxDEV)(ae,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:we,strokeWidth:2},void 0,!1),e[23]=j):j=e[23];let R;e[24]!==s?(R=s("Filter operations"),e[24]=s,e[25]=R):R=e[25],e[26]!==i||e[27]!==R?(x=(0,f.jsxDEV)("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:(0,f.jsxDEV)("div",{className:"relative",children:[j,(0,f.jsxDEV)(Se,{className:"h-7 pl-7","data-testid":"api-filter",onChange:E,placeholder:R,value:i},void 0,!1)]},void 0,!0)},void 0,!1),e[26]=i,e[27]=R,e[28]=x):x=e[28],v="flex flex-col gap-4 p-2";let B;e[29]!==m?.key||e[30]!==s?(B=p(P=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between px-2",children:[(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:P.name||s("(root)")},void 0,!1),(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:P.operations.length},void 0,!1)]},void 0,!0),P.operations.map(_=>{let D=_.key===m?.key;return(0,f.jsxDEV)("button",{"aria-current":D?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":_.key,"data-testid":`api-nav-${_.operationId}`,onClick:I,type:"button",children:[(0,f.jsxDEV)("span",{className:"truncate",children:_.summary},void 0,!1),(0,f.jsxDEV)(be,{kind:_.kind,method:_.method},void 0,!1)]},_.key,!0)})]},P.name,!0),"t142"),e[29]=m?.key,e[30]=s,e[31]=B):B=e[31],k=a.map(B),e[4]=i,e[5]=o.groups,e[6]=o.server,e[7]=m?.key,e[8]=s,e[9]=a,e[10]=u,e[11]=v,e[12]=k,e[13]=O,e[14]=h,e[15]=g,e[16]=x,e[17]=b,e[18]=S}else a=e[9],u=e[10],v=e[11],k=e[12],O=e[13],h=e[14],g=e[15],x=e[16],b=e[17],S=e[18];let y;e[32]!==a.length||e[33]!==s?(y=a.length===0&&(0,f.jsxDEV)("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:s("No operations match your filter.")},void 0,!1),e[32]=a.length,e[33]=s,e[34]=y):y=e[34];let $;e[35]!==y||e[36]!==v||e[37]!==k?($=(0,f.jsxDEV)("div",{className:v,children:[k,y]},void 0,!0),e[35]=y,e[36]=v,e[37]=k,e[38]=$):$=e[38];let N;e[39]!==$||e[40]!==O||e[41]!==h||e[42]!==g||e[43]!==x?(N=(0,f.jsxDEV)("nav",{"aria-label":O,className:h,"data-testid":g,children:[x,$]},void 0,!0),e[39]=$,e[40]=O,e[41]=h,e[42]=g,e[43]=x,e[44]=N):N=e[44];let w;e[45]!==m||e[46]!==u?(w=m===void 0?(0,f.jsxDEV)("div",{className:"lg:col-span-2"},void 0,!1):(0,f.jsxDEV)($t,{operation:m,children:[(0,f.jsxDEV)("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:(0,f.jsxDEV)(Tt,{operation:m},void 0,!1)},void 0,!1),(0,f.jsxDEV)("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[(0,f.jsxDEV)(Nt,{operation:m,server:u},void 0,!1),(0,f.jsxDEV)(Mt,{},void 0,!1)]},void 0,!0)]},m.key,!0),e[45]=m,e[46]=u,e[47]=w):w=e[47];let C;return e[48]!==N||e[49]!==w||e[50]!==b||e[51]!==S?(C=(0,f.jsxDEV)("div",{className:b,"data-testid":S,children:[N,w]},void 0,!0),e[48]=N,e[49]=w,e[50]=b,e[51]=S,e[52]=C):C=e[52],C},"ReferenceView");var Y=q(ne(),1);var qt=["get","post","put","patch","delete","head","options","trace"],Ve=p(t=>t?.content?.["application/json"]?.schema,"jsonSchemaOf"),Vt=p((t,e)=>Object.entries(t.responses??{}).map(([o,s])=>{let n=s.$ref?.replace("#/components/responses/",""),r=n===void 0?s:e.components?.responses?.[n]??s;return{description:r.description,schema:Ve(r),status:o}}),"buildResponses"),zt=p((t,e,o,s,n)=>{let r=Ve(s.requestBody),l=r?.properties?.functionPath?.const,i=typeof l=="string"?l:void 0,d=i===void 0?r:r?.properties?.args,c=s.operationId??`${o} ${e}`;return{argsSchema:d,description:s.description,functionPath:i,httpPath:e,key:t,kind:s["x-lunora-function-kind"],method:o.toUpperCase(),operationId:c,requestSchema:r,responses:Vt(s,n),summary:s.summary??c,tags:s.tags??[],title:s.summary??c}},"flattenOperation"),Ht=p(t=>{let e=[];for(let[o,s]of Object.entries(t.paths??{})){let n=o.includes("#")?o.slice(0,o.indexOf("#")):o;for(let r of qt){let l=s[r];l!==void 0&&e.push(zt(o,n,r,l,t))}}return e},"collectOperations"),Wt=p(t=>{let e=t??{},o=Ht(e),s=new Map((e.tags??[]).map(i=>[i.name,i.description])),n=new Set,r=[],l=p(i=>{if(n.has(i))return;n.add(i);let d=o.filter(c=>(c.tags[0]??"")===i);d.length>0&&r.push({description:s.get(i),name:i,operations:d})},"pushGroup");for(let i of e.tags??[])l(i.name);for(let i of o)l(i.tags[0]??"");return{groups:r,operationByKey:new Map(o.map(i=>[i.key,i])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenApi"),Gt=p(t=>{let{paths:e}=t;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},"isEmptySpec"),Ut=p(t=>{let e=t;return Gt(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifySpec"),ze=p(t=>{let e=(0,qe.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenApi(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,Ut),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Wt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Y.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[(0,Y.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Y.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenAPI spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenAPI spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Y.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"ApiReferencePanel");var He=q(oe(),1);var Q=q(ne(),1);var Yt=p(t=>(t.params??[]).find(e=>e.name==="args")??(t.params??[])[0],"argsParameterOf"),Qt=p(t=>t["x-tags"]?.[0]?.name??(t.name.includes(":")?t.name.slice(0,t.name.indexOf(":")):""),"namespaceOf"),Xt=p(t=>{let e=Yt(t)?.schema;return{argsSchema:e,description:t.description,functionPath:t.name,httpPath:"/_lunora/rpc",key:t.name,kind:t["x-lunora-function-kind"],method:"POST",operationId:t.name,requestSchema:e,responses:[{description:t.result?.name,schema:t.result?.schema,status:"200"}],summary:t.summary??t.name,tags:[Qt(t)],title:t.summary??t.name}},"toOperation"),Zt=p(t=>{let e=t??{},o=(e.methods??[]).map(r=>Xt(r)),s=new Map;for(let r of o){let l=r.tags[0]??"",i=s.get(l)??[];i.push(r),s.set(l,i)}return{groups:[...s.entries()].map(([r,l])=>({name:r,operations:l.toSorted((i,d)=>i.operationId.localeCompare(d.operationId))})).toSorted((r,l)=>r.name.localeCompare(l.name)),operationByKey:new Map(o.map(r=>[r.key,r])),title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenRpc"),es=p(t=>t.methods===void 0||t.methods.length===0,"isEmptyDocument"),ts=p(t=>{let e=t;return es(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifyDocument"),We=p(t=>{let e=(0,He.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenRpc(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,ts),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Zt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Q.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"openrpc-reference-loading",children:[(0,Q.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Q.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenRPC spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenRPC spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Q.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"OpenRpcReferencePanel");var z=q(ne(),1);var ss=["reference","snippets"],os=["openapi","openrpc"],zs=p(t=>{let e=(0,Ge.c)(51),{functions:o,initialShardKey:s,openApiSpec:n,openRpcSpec:r}=t,l=M(),[i,d]=(0,ye.useState)("reference"),[c,m]=(0,ye.useState)("openapi"),a;e[0]!==l?(a=l("Reference"),e[0]=l,e[1]=a):a=e[1];let u;e[2]!==l?(u=l("Snippets"),e[2]=l,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==u?(v={reference:a,snippets:u},e[4]=a,e[5]=u,e[6]=v):v=e[6];let k=v,O;e[7]!==l?(O=l("OpenAPI"),e[7]=l,e[8]=O):O=e[8];let h;e[9]!==l?(h=l("OpenRPC"),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==O||e[12]!==h?(g={openapi:O,openrpc:h},e[11]=O,e[12]=h,e[13]=g):g=e[13];let x=g,b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=p(P=>{d(P.currentTarget.dataset.view)},"t7"),e[14]=b):b=e[14];let S=b,y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=p(P=>{m(P.currentTarget.dataset.format)},"t8"),e[15]=y):y=e[15];let $=y,N;e[16]!==l?(N=l("API view"),e[16]=l,e[17]=N):N=e[17];let w;e[18]!==i||e[19]!==k?(w=ss.map(P=>(0,z.jsxDEV)(H,{"aria-selected":i===P,"data-testid":`api-view-${P}`,"data-view":P,onClick:S,role:"tab",size:"sm",type:"button",variant:i===P?"default":"outline",children:k[P]},P,!1)),e[18]=i,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==w||e[22]!==N?(C=(0,z.jsxDEV)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:w},void 0,!1),e[21]=w,e[22]=N,e[23]=C):C=e[23];let T;e[24]!==c||e[25]!==x||e[26]!==l||e[27]!==i?(T=i==="reference"&&(0,z.jsxDEV)("div",{"aria-label":l("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:os.map(P=>(0,z.jsxDEV)(H,{"aria-selected":c===P,"data-format":P,"data-testid":`api-format-${P}`,onClick:$,role:"tab",size:"sm",type:"button",variant:c===P?"default":"outline",children:x[P]},P,!1))},void 0,!1),e[24]=c,e[25]=x,e[26]=l,e[27]=i,e[28]=T):T=e[28];let I;e[29]!==C||e[30]!==T?(I=(0,z.jsxDEV)("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[C,T]},void 0,!0),e[29]=C,e[30]=T,e[31]=I):I=e[31];let A;e[32]!==o||e[33]!==s||e[34]!==i?(A=i==="snippets"&&(0,z.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,z.jsxDEV)(_e,{functions:o,initialShardKey:s},void 0,!1)},void 0,!1),e[32]=o,e[33]=s,e[34]=i,e[35]=A):A=e[35];let E;e[36]!==c||e[37]!==n||e[38]!==i?(E=i==="reference"&&c==="openapi"&&(0,z.jsxDEV)(ze,{spec:n},void 0,!1),e[36]=c,e[37]=n,e[38]=i,e[39]=E):E=e[39];let j;e[40]!==c||e[41]!==r||e[42]!==i?(j=i==="reference"&&c==="openrpc"&&(0,z.jsxDEV)(We,{spec:r},void 0,!1),e[40]=c,e[41]=r,e[42]=i,e[43]=j):j=e[43];let R;e[44]!==A||e[45]!==E||e[46]!==j?(R=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[A,E,j]},void 0,!0),e[44]=A,e[45]=E,e[46]=j,e[47]=R):R=e[47];let B;return e[48]!==I||e[49]!==R?(B=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[I,R]},void 0,!0),e[48]=I,e[49]=R,e[50]=B):B=e[50],B},"ApiTab");export{zs as default};
12
+ const data = await response.json();`}}},"sampleSource"),St=p(t=>{let e=(0,J.c)(24),{operation:o,server:s}=t,n=M(),[r,l]=(0,K.useState)("curl"),i;e[0]!==o||e[1]!==r||e[2]!==s?(i=Nt(r,o,s),e[0]=o,e[1]=r,e[2]=s,e[3]=i):i=e[3];let d=i,c;e[4]!==d?(c=p(()=>{re(d)},"t2"),e[4]=d,e[5]=c):c=e[5];let m=c,a;e[6]===Symbol.for("react.memo_cache_sentinel")?(a=p(S=>{l(S.currentTarget.dataset.sample)},"t3"),e[6]=a):a=e[6];let u=a,v;e[7]!==r?(v=gt.map(S=>(0,f.jsxDEV)("button",{"aria-selected":r===S,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":S,"data-testid":`api-sample-${S}`,onClick:u,role:"tab",type:"button",children:xt[S]},S,!1)),e[7]=r,e[8]=v):v=e[8];let k;e[9]!==v?(k=(0,f.jsxDEV)("div",{className:"flex gap-1",role:"tablist",children:v},void 0,!1),e[9]=v,e[10]=k):k=e[10];let O;e[11]!==n?(O=n("Copy"),e[11]=n,e[12]=O):O=e[12];let h;e[13]!==m||e[14]!==O?(h=(0,f.jsxDEV)(H,{"data-testid":"api-sample-copy",onClick:m,size:"xs",type:"button",variant:"ghost",children:O},void 0,!1),e[13]=m,e[14]=O,e[15]=h):h=e[15];let g;e[16]!==k||e[17]!==h?(g=(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[k,h]},void 0,!0),e[16]=k,e[17]=h,e[18]=g):g=e[18];let x;e[19]!==d?(x=(0,f.jsxDEV)("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:d},void 0,!1),e[19]=d,e[20]=x):x=e[20];let b;return e[21]!==g||e[22]!==x?(b=(0,f.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[g,x]},void 0,!0),e[21]=g,e[22]=x,e[23]=b):b=e[23],b},"CodeSamples"),kt={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},wt=p(t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},"methodTone"),Ot=p(t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},"kindTone"),be=p(t=>{let e=(0,J.c)(7),{kind:o,method:s,testId:n}=t,r;e[0]!==o||e[1]!==s?(r=o??s.toUpperCase(),e[0]=o,e[1]=s,e[2]=r):r=e[2];let l=r,i=o===void 0?wt(s):Ot(o),d=`${kt[i]} font-mono text-[10px] tracking-wide uppercase`,c;return e[3]!==l||e[4]!==d||e[5]!==n?(c=(0,f.jsxDEV)(Se,{className:d,"data-testid":n,variant:"ghost",children:l},void 0,!1),e[3]=l,e[4]=d,e[5]=n,e[6]=c):c=e[6],c},"MethodBadge"),Ke=p(t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground","statusToneClass"),Fe=p(t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground","statusDotClass"),$t=p(t=>JSON.stringify(te(t.argsSchema)??{},void 0,2),"seedArgs"),Je=(0,K.createContext)(null),qe=p(()=>{let t=(0,K.use)(Je);if(t===null)throw new Ne("INTERNAL","useOperationRun must be used within an OperationRunProvider");return t},"useOperationRun"),It=p(({children:t,operation:e})=>{let o=M(),s=G(),[n,r]=(0,K.useState)(()=>$t(e)),[l,i]=(0,K.useState)(""),[d,c]=(0,K.useState)("idle"),[m,a]=(0,K.useState)(void 0),[u,v]=(0,K.useState)(null),[k,O]=(0,K.useState)(null),h=p(async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(y){c("error"),a(void 0),O(null),v(o("Invalid JSON args: {message}",{message:ce(y)}));return}c("running"),v(null);let S=performance.now();try{let y;if(e.functionPath===void 0){let $=e.method!=="GET"&&e.method!=="HEAD",w=await(await fetch(e.httpPath,{body:$?JSON.stringify(b):void 0,headers:$?{"content-type":"application/json"}:void 0,method:e.method})).text();try{y=JSON.parse(w)}catch{y=w}}else{let $=le(e.functionPath),N=de(l);switch(e.kind){case"action":{y=await s.action($,b,N);break}case"mutation":{y=await s.mutation($,b,N);break}default:y=await s.query($,b,N)}}a(y),O(Math.round(performance.now()-S)),c("success")}catch(y){a(void 0),O(Math.round(performance.now()-S)),v(ce(y)),c("error")}},"send");return(0,f.jsxDEV)(Je,{value:{argsText:n,durationMs:k,error:u,operation:e,response:m,send:p(()=>{Ie(h())},"onSend"),setArgsText:r,setShardKey:i,shardKey:l,status:d},children:t},void 0,!1)},"OperationRunProvider"),Tt=p(()=>{let t=(0,J.c)(48),e=M(),{argsText:o,operation:s,send:n,setArgsText:r,setShardKey:l,shardKey:i,status:d}=qe(),c;t[0]!==r?(c=p(R=>{r(R.target.value)},"t0"),t[0]=r,t[1]=c):c=t[1];let m=c,a;t[2]!==n?(a=p(R=>{R.key==="Enter"&&(R.metaKey||R.ctrlKey)&&(R.preventDefault(),n())},"t1"),t[2]=n,t[3]=a):a=t[3];let u=a,v=d==="running",k;t[4]!==s.kind||t[5]!==s.method?(k=(0,f.jsxDEV)(be,{kind:s.kind,method:s.method,testId:"api-try-method"},void 0,!1),t[4]=s.kind,t[5]=s.method,t[6]=k):k=t[6];let O=s.functionPath??s.httpPath,h;t[7]!==O?(h=(0,f.jsxDEV)("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:O},void 0,!1),t[7]=O,t[8]=h):h=t[8];let g=v?"animate-pulse":void 0,x;t[9]!==g?(x=(0,f.jsxDEV)(ae,{className:g,icon:$e,strokeWidth:2},void 0,!1),t[9]=g,t[10]=x):x=t[10];let b;t[11]!==v||t[12]!==e?(b=e(v?"Sending\u2026":"Send"),t[11]=v,t[12]=e,t[13]=b):b=t[13];let S;t[14]!==v||t[15]!==n||t[16]!==x||t[17]!==b?(S=(0,f.jsxDEV)(H,{"data-testid":"api-try-send",disabled:v,onClick:n,size:"sm",type:"button",children:[x,b]},void 0,!0),t[14]=v,t[15]=n,t[16]=x,t[17]=b,t[18]=S):S=t[18];let y;t[19]!==k||t[20]!==h||t[21]!==S?(y=(0,f.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[k,h,S]},void 0,!0),t[19]=k,t[20]=h,t[21]=S,t[22]=y):y=t[22];let $;t[23]!==e?($=e("Arguments (JSON)"),t[23]=e,t[24]=$):$=t[24];let N;t[25]!==$?(N=(0,f.jsxDEV)(xe,{htmlFor:"api-try-args",children:$},void 0,!1),t[25]=$,t[26]=N):N=t[26];let w;t[27]!==o?(w=o.split(`
13
+ `),t[27]=o,t[28]=w):w=t[28];let C=Math.min(12,Math.max(3,w.length)),T;t[29]!==o||t[30]!==m||t[31]!==u||t[32]!==C?(T=(0,f.jsxDEV)(Ae,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:m,onKeyDown:u,rows:C,spellCheck:!1,value:o},void 0,!1),t[29]=o,t[30]=m,t[31]=u,t[32]=C,t[33]=T):T=t[33];let I;t[34]!==N||t[35]!==T?(I=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[N,T]},void 0,!0),t[34]=N,t[35]=T,t[36]=I):I=t[36];let P;t[37]!==s.functionPath||t[38]!==l||t[39]!==i||t[40]!==e?(P=s.functionPath!==void 0&&(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,f.jsxDEV)(xe,{htmlFor:"shard-input",children:e("Shard key (optional)")},void 0,!1),(0,f.jsxDEV)(Ce,{id:"shard-input",onChange:l,testId:"shard-input",value:i},void 0,!1)]},void 0,!0),t[37]=s.functionPath,t[38]=l,t[39]=i,t[40]=e,t[41]=P):P=t[41];let E;t[42]!==I||t[43]!==P?(E=(0,f.jsxDEV)("div",{className:"flex flex-col gap-3 p-3",children:[I,P]},void 0,!0),t[42]=I,t[43]=P,t[44]=E):E=t[44];let j;return t[45]!==E||t[46]!==y?(j=(0,f.jsxDEV)("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[y,E]},void 0,!0),t[45]=E,t[46]=y,t[47]=j):j=t[47],j},"TryIt"),Ct=p(t=>{let e=(0,J.c)(51),{operation:o}=t,s=M(),n=`api-operation-${o.operationId}`,r=o.key,l;e[0]!==o.kind||e[1]!==o.method?(l=(0,f.jsxDEV)(be,{kind:o.kind,method:o.method,testId:"api-operation-method"},void 0,!1),e[0]=o.kind,e[1]=o.method,e[2]=l):l=e[2];let i=o.functionPath??o.httpPath,d;e[3]!==i?(d=(0,f.jsxDEV)("code",{className:"truncate font-mono text-xs text-muted-foreground",children:i},void 0,!1),e[3]=i,e[4]=d):d=e[4];let c;e[5]!==l||e[6]!==d?(c=(0,f.jsxDEV)("div",{className:"flex items-center gap-2",children:[l,d]},void 0,!0),e[5]=l,e[6]=d,e[7]=c):c=e[7];let m;e[8]!==o.title?(m=(0,f.jsxDEV)("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:o.title},void 0,!1),e[8]=o.title,e[9]=m):m=e[9];let a;e[10]!==o.description?(a=o.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o.description},void 0,!1),e[10]=o.description,e[11]=a):a=e[11];let u;e[12]!==c||e[13]!==m||e[14]!==a?(u=(0,f.jsxDEV)("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[c,m,a]},void 0,!0),e[12]=c,e[13]=m,e[14]=a,e[15]=u):u=e[15];let v;e[16]!==s?(v=s("Try it"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==v?(k=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v},void 0,!1),e[18]=v,e[19]=k):k=e[19];let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=(0,f.jsxDEV)(Tt,{},void 0,!1),e[20]=O):O=e[20];let h;e[21]!==k?(h=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[k,O]},void 0,!0),e[21]=k,e[22]=h):h=e[22];let g;e[23]!==s?(g=s("Request arguments"),e[23]=s,e[24]=g):g=e[24];let x;e[25]!==g?(x=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g},void 0,!1),e[25]=g,e[26]=x):x=e[26];let b;e[27]!==o.argsSchema?(b=(0,f.jsxDEV)(Le,{schema:o.argsSchema,testId:"api-operation-args"},void 0,!1),e[27]=o.argsSchema,e[28]=b):b=e[28];let S;e[29]!==x||e[30]!==b?(S=(0,f.jsxDEV)("section",{className:"flex flex-col gap-2",children:[x,b]},void 0,!0),e[29]=x,e[30]=b,e[31]=S):S=e[31];let y;e[32]!==s?(y=s("Response body"),e[32]=s,e[33]=y):y=e[33];let $;e[34]!==y?($=(0,f.jsxDEV)("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y},void 0,!1),e[34]=y,e[35]=$):$=e[35];let N;if(e[36]!==o.responses||e[37]!==s){let T;e[39]!==s?(T=p(I=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,f.jsxDEV)("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${Ke(I.status)}`,children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(I.status)}`},void 0,!1),I.status]},void 0,!0),I.schema!==void 0&&(0,f.jsxDEV)("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:s("application/json")},void 0,!1)]},void 0,!0),I.description!==void 0&&(0,f.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:I.description},void 0,!1),I.schema!==void 0&&(0,f.jsxDEV)(Le,{schema:I.schema,testId:`api-response-${I.status}`},void 0,!1)]},I.status,!0),"t212"),e[39]=s,e[40]=T):T=e[40],N=o.responses.map(T),e[36]=o.responses,e[37]=s,e[38]=N}else N=e[38];let w;e[41]!==$||e[42]!==N?(w=(0,f.jsxDEV)("section",{className:"flex flex-col gap-3",children:[$,N]},void 0,!0),e[41]=$,e[42]=N,e[43]=w):w=e[43];let C;return e[44]!==o.key||e[45]!==n||e[46]!==h||e[47]!==S||e[48]!==w||e[49]!==u?(C=(0,f.jsxDEV)("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[u,h,S,w]},r,!0),e[44]=o.key,e[45]=n,e[46]=h,e[47]=S,e[48]=w,e[49]=u,e[50]=C):C=e[50],C},"OperationView"),At={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Pt=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,Rt=/^\s*:/,Et=p((t,e,o)=>o.startsWith('"')?Rt.test(t.slice(e))?"key":"string":o==="true"||o==="false"||o==="null"?"boolean":"number","classify"),_t=p(t=>{let e=[],o=0;for(let s of t.matchAll(Pt)){let{index:n}=s,r=s[0],l=n+r.length;n>o&&e.push({kind:"plain",start:o,text:t.slice(o,n)}),e.push({kind:Et(t,l,r),start:n,text:r}),o=l}return o<t.length&&e.push({kind:"plain",start:o,text:t.slice(o)}),e},"tokenize"),jt=p(t=>{let e=(0,J.c)(4),{code:o}=t,s;e[0]!==o?(s=_t(o).map(Lt),e[0]=o,e[1]=s):s=e[1];let n;return e[2]!==s?(n=(0,f.jsxDEV)(f.Fragment,{children:s},void 0,!1),e[2]=s,e[3]=n):n=e[3],n},"JsonHighlight");function Lt(t){return(0,f.jsxDEV)("span",{className:At[t.kind],children:t.text},t.start,!1)}p(Lt,"_temp$1");var Be="__live__",Bt=p(t=>t.schema===void 0?"":JSON.stringify(te(t.schema),void 0,2),"exampleBody"),Dt=p((t,e,o)=>o?t??"":e===void 0?"":JSON.stringify(e,void 0,2),"liveBody"),Mt=p(t=>{let e=(0,J.c)(18),{active:o,running:s,showError:n}=t,r=M();if(s){let a;e[0]!==r?(a=r("Sending\u2026"),e[0]=r,e[1]=a):a=e[1];let u;return e[2]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:a},void 0,!1),e[2]=a,e[3]=u):u=e[3],u}if(o===void 0||o.body===""){let a;e[4]!==o?.live||e[5]!==r?(a=o?.live===!0?r("Send a request to see the response."):r("No example for this response."),e[4]=o?.live,e[5]=r,e[6]=a):a=e[6];let u;return e[7]!==a?(u=(0,f.jsxDEV)("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:a},void 0,!1),e[7]=a,e[8]=u):u=e[8],u}let l=n&&"text-destructive",i;e[9]!==l?(i=ge("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=i):i=e[10];let d=n?"api-response-error":"api-response-body",c;e[11]!==o.body||e[12]!==n?(c=n?o.body:(0,f.jsxDEV)(jt,{code:o.body},void 0,!1),e[11]=o.body,e[12]=n,e[13]=c):c=e[13];let m;return e[14]!==i||e[15]!==d||e[16]!==c?(m=(0,f.jsxDEV)("pre",{className:i,"data-testid":d,children:c},void 0,!1),e[14]=i,e[15]=d,e[16]=c,e[17]=m):m=e[17],m},"ResponseBody"),Kt=p(()=>{let t=(0,J.c)(67),e=M(),{durationMs:o,error:s,operation:n,response:r,status:l}=qe(),i=l==="running",d=l==="error",c=l==="success"||d,m;if(t[0]!==o||t[1]!==s||t[2]!==d||t[3]!==n.responses||t[4]!==c||t[5]!==r||t[6]!==e){e:{let L=n.responses.map(Ft);if(!c){m=L;break e}let A;t[8]!==s||t[9]!==d||t[10]!==r?(A=Dt(s,r,d),t[8]=s,t[9]=d,t[10]=r,t[11]=A):A=t[11];let _;t[12]!==e?(_=e("Live"),t[12]=e,t[13]=_):_=t[13];let D=d?"error":"200",V;t[14]!==o||t[15]!==A||t[16]!==_||t[17]!==D?(V={body:A,durationMs:o,id:Be,label:_,live:!0,status:D},t[14]=o,t[15]=A,t[16]=_,t[17]=D,t[18]=V):V=t[18],m=[V,...L]}t[0]=o,t[1]=s,t[2]=d,t[3]=n.responses,t[4]=c,t[5]=r,t[6]=e,t[7]=m}else m=t[7];let a=m,u;t[19]!==c||t[20]!==a?(u=c?Be:a.find(Jt)?.id??a[0]?.id??"",t[19]=c,t[20]=a,t[21]=u):u=t[21];let v=u,[k,O]=(0,K.useState)(null),h,g,x,b,S,y,$,N,w,C;if(t[22]!==v||t[23]!==k||t[24]!==e||t[25]!==a){h=a.find(D=>D.id===(k??v))??a[0];let L;t[36]===Symbol.for("react.memo_cache_sentinel")?(L=p(D=>{let{id:V}=D.currentTarget.dataset;V!==void 0&&O(V)},"t82"),t[36]=L):L=t[36],x=L,g=p(()=>{h!==void 0&&re(h.body)},"onCopy");let A=h?.live===!0?h.durationMs:null;b=h?.live===!0&&h.status==="error",w="flex min-h-0 flex-col rounded-xl border border-border bg-card",C="api-response-panel",$="flex items-center justify-between gap-2 border-b border-border px-3 py-2";let _;t[37]!==e?(_=e("Response"),t[37]=e,t[38]=_):_=t[38],t[39]!==_?(N=(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:_},void 0,!1),t[39]=_,t[40]=N):N=t[40],S="flex items-center gap-2",y=A!==null&&(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:A})},void 0,!1),t[22]=v,t[23]=k,t[24]=e,t[25]=a,t[26]=h,t[27]=g,t[28]=x,t[29]=b,t[30]=S,t[31]=y,t[32]=$,t[33]=N,t[34]=w,t[35]=C}else h=t[26],g=t[27],x=t[28],b=t[29],S=t[30],y=t[31],$=t[32],N=t[33],w=t[34],C=t[35];let T;t[41]!==h||t[42]!==g||t[43]!==e?(T=h!==void 0&&h.body!==""&&(0,f.jsxDEV)(H,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:g,size:"icon-xs",type:"button",variant:"ghost",children:(0,f.jsxDEV)(ae,{icon:we,strokeWidth:2},void 0,!1)},void 0,!1),t[41]=h,t[42]=g,t[43]=e,t[44]=T):T=t[44];let I;t[45]!==S||t[46]!==y||t[47]!==T?(I=(0,f.jsxDEV)("div",{className:S,children:[y,T]},void 0,!0),t[45]=S,t[46]=y,t[47]=T,t[48]=I):I=t[48];let P;t[49]!==$||t[50]!==N||t[51]!==I?(P=(0,f.jsxDEV)("div",{className:$,children:[N,I]},void 0,!0),t[49]=$,t[50]=N,t[51]=I,t[52]=P):P=t[52];let E;t[53]!==h?.id||t[54]!==x||t[55]!==a?(E=a.length>0&&(0,f.jsxDEV)("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:a.map(L=>{let A=L.id===h?.id;return(0,f.jsxDEV)("button",{"aria-selected":A,className:ge("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",A?Ke(L.status):"text-muted-foreground"),"data-id":L.id,"data-testid":L.live?"api-response-tab-live":`api-response-tab-${L.status}`,onClick:x,role:"tab",type:"button",children:[(0,f.jsxDEV)("span",{className:`size-1.5 rounded-full ${Fe(L.status)}`},void 0,!1),L.label]},L.id,!0)})},void 0,!1),t[53]=h?.id,t[54]=x,t[55]=a,t[56]=E):E=t[56];let j;t[57]!==h||t[58]!==i||t[59]!==b?(j=(0,f.jsxDEV)(Mt,{active:h,running:i,showError:b},void 0,!1),t[57]=h,t[58]=i,t[59]=b,t[60]=j):j=t[60];let R;return t[61]!==P||t[62]!==E||t[63]!==j||t[64]!==w||t[65]!==C?(R=(0,f.jsxDEV)("div",{className:w,"data-testid":C,children:[P,E,j]},void 0,!0),t[61]=P,t[62]=E,t[63]=j,t[64]=w,t[65]=C,t[66]=R):R=t[66],R},"ResponsePanel");function Ft(t){return{body:Bt(t),durationMs:null,id:t.status,label:t.status,live:!1,status:t.status}}p(Ft,"_temp");function Jt(t){return t.status.startsWith("2")}p(Jt,"_temp2");var qt=p((t,e)=>{let o=e.trim().toLowerCase();return o===""?t:t.map(s=>({...s,operations:s.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(o))})).filter(s=>s.operations.length>0)},"filterGroups"),me=p(t=>{let e=(0,J.c)(53),{model:o}=t,s=M(),n=o.groups[0]?.operations[0]?.key??"",[r,l]=(0,K.useState)(n),[i,d]=(0,K.useState)(""),c;e[0]!==n||e[1]!==o.operationByKey||e[2]!==r?(c=o.operationByKey.get(r)??o.operationByKey.get(n),e[0]=n,e[1]=o.operationByKey,e[2]=r,e[3]=c):c=e[3];let m=c,a,u,v,k,O,h,g,x,b,S;if(e[4]!==i||e[5]!==o.groups||e[6]!==o.server||e[7]!==m?.key||e[8]!==s){a=qt(o.groups,i);let T;e[19]===Symbol.for("react.memo_cache_sentinel")?(T=p(A=>{let{key:_}=A.currentTarget.dataset;_!==void 0&&l(_)},"t102"),e[19]=T):T=e[19];let I=T,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=p(A=>{d(A.target.value)},"t112"),e[20]=P):P=e[20];let E=P;u=o.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",S="api-reference",e[21]!==s?(O=s("API operations"),e[21]=s,e[22]=O):O=e[22],h="flex min-h-0 flex-col overflow-y-auto border-r border-border",g="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=(0,f.jsxDEV)(ae,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:Oe,strokeWidth:2},void 0,!1),e[23]=j):j=e[23];let R;e[24]!==s?(R=s("Filter operations"),e[24]=s,e[25]=R):R=e[25],e[26]!==i||e[27]!==R?(x=(0,f.jsxDEV)("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:(0,f.jsxDEV)("div",{className:"relative",children:[j,(0,f.jsxDEV)(ke,{className:"h-7 pl-7","data-testid":"api-filter",onChange:E,placeholder:R,value:i},void 0,!1)]},void 0,!0)},void 0,!1),e[26]=i,e[27]=R,e[28]=x):x=e[28],v="flex flex-col gap-4 p-2";let L;e[29]!==m?.key||e[30]!==s?(L=p(A=>(0,f.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,f.jsxDEV)("div",{className:"flex items-center justify-between px-2",children:[(0,f.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A.name||s("(root)")},void 0,!1),(0,f.jsxDEV)("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:A.operations.length},void 0,!1)]},void 0,!0),A.operations.map(_=>{let D=_.key===m?.key;return(0,f.jsxDEV)("button",{"aria-current":D?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":_.key,"data-testid":`api-nav-${_.operationId}`,onClick:I,type:"button",children:[(0,f.jsxDEV)("span",{className:"truncate",children:_.summary},void 0,!1),(0,f.jsxDEV)(be,{kind:_.kind,method:_.method},void 0,!1)]},_.key,!0)})]},A.name,!0),"t142"),e[29]=m?.key,e[30]=s,e[31]=L):L=e[31],k=a.map(L),e[4]=i,e[5]=o.groups,e[6]=o.server,e[7]=m?.key,e[8]=s,e[9]=a,e[10]=u,e[11]=v,e[12]=k,e[13]=O,e[14]=h,e[15]=g,e[16]=x,e[17]=b,e[18]=S}else a=e[9],u=e[10],v=e[11],k=e[12],O=e[13],h=e[14],g=e[15],x=e[16],b=e[17],S=e[18];let y;e[32]!==a.length||e[33]!==s?(y=a.length===0&&(0,f.jsxDEV)("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:s("No operations match your filter.")},void 0,!1),e[32]=a.length,e[33]=s,e[34]=y):y=e[34];let $;e[35]!==y||e[36]!==v||e[37]!==k?($=(0,f.jsxDEV)("div",{className:v,children:[k,y]},void 0,!0),e[35]=y,e[36]=v,e[37]=k,e[38]=$):$=e[38];let N;e[39]!==$||e[40]!==O||e[41]!==h||e[42]!==g||e[43]!==x?(N=(0,f.jsxDEV)("nav",{"aria-label":O,className:h,"data-testid":g,children:[x,$]},void 0,!0),e[39]=$,e[40]=O,e[41]=h,e[42]=g,e[43]=x,e[44]=N):N=e[44];let w;e[45]!==m||e[46]!==u?(w=m===void 0?(0,f.jsxDEV)("div",{className:"lg:col-span-2"},void 0,!1):(0,f.jsxDEV)(It,{operation:m,children:[(0,f.jsxDEV)("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:(0,f.jsxDEV)(Ct,{operation:m},void 0,!1)},void 0,!1),(0,f.jsxDEV)("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[(0,f.jsxDEV)(St,{operation:m,server:u},void 0,!1),(0,f.jsxDEV)(Kt,{},void 0,!1)]},void 0,!0)]},m.key,!0),e[45]=m,e[46]=u,e[47]=w):w=e[47];let C;return e[48]!==N||e[49]!==w||e[50]!==b||e[51]!==S?(C=(0,f.jsxDEV)("div",{className:b,"data-testid":S,children:[N,w]},void 0,!0),e[48]=N,e[49]=w,e[50]=b,e[51]=S,e[52]=C):C=e[52],C},"ReferenceView");var Y=q(ne(),1);var Vt=["get","post","put","patch","delete","head","options","trace"],ze=p(t=>t?.content?.["application/json"]?.schema,"jsonSchemaOf"),zt=p((t,e)=>Object.entries(t.responses??{}).map(([o,s])=>{let n=s.$ref?.replace("#/components/responses/",""),r=n===void 0?s:e.components?.responses?.[n]??s;return{description:r.description,schema:ze(r),status:o}}),"buildResponses"),Ht=p((t,e,o,s,n)=>{let r=ze(s.requestBody),l=r?.properties?.functionPath?.const,i=typeof l=="string"?l:void 0,d=i===void 0?r:r?.properties?.args,c=s.operationId??`${o} ${e}`;return{argsSchema:d,description:s.description,functionPath:i,httpPath:e,key:t,kind:s["x-lunora-function-kind"],method:o.toUpperCase(),operationId:c,requestSchema:r,responses:zt(s,n),summary:s.summary??c,tags:s.tags??[],title:s.summary??c}},"flattenOperation"),Wt=p(t=>{let e=[];for(let[o,s]of Object.entries(t.paths??{})){let n=o.includes("#")?o.slice(0,o.indexOf("#")):o;for(let r of Vt){let l=s[r];l!==void 0&&e.push(Ht(o,n,r,l,t))}}return e},"collectOperations"),Gt=p(t=>{let e=t??{},o=Wt(e),s=new Map((e.tags??[]).map(i=>[i.name,i.description])),n=new Set,r=[],l=p(i=>{if(n.has(i))return;n.add(i);let d=o.filter(c=>(c.tags[0]??"")===i);d.length>0&&r.push({description:s.get(i),name:i,operations:d})},"pushGroup");for(let i of e.tags??[])l(i.name);for(let i of o)l(i.tags[0]??"");return{groups:r,operationByKey:new Map(o.map(i=>[i.key,i])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenApi"),Ut=p(t=>{let{paths:e}=t;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},"isEmptySpec"),Yt=p(t=>{let e=t;return Ut(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifySpec"),He=p(t=>{let e=(0,Ve.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenApi(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,Yt),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?Gt(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Y.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[(0,Y.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Y.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenAPI spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenAPI spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Y.jsxDEV)(W,{description:a,testId:"api-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Y.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"ApiReferencePanel");var We=q(oe(),1);var Q=q(ne(),1);var Qt=p(t=>(t.params??[]).find(e=>e.name==="args")??(t.params??[])[0],"argsParameterOf"),Xt=p(t=>t["x-tags"]?.[0]?.name??(t.name.includes(":")?t.name.slice(0,t.name.indexOf(":")):""),"namespaceOf"),Zt=p(t=>{let e=Qt(t)?.schema;return{argsSchema:e,description:t.description,functionPath:t.name,httpPath:"/_lunora/rpc",key:t.name,kind:t["x-lunora-function-kind"],method:"POST",operationId:t.name,requestSchema:e,responses:[{description:t.result?.name,schema:t.result?.schema,status:"200"}],summary:t.summary??t.name,tags:[Xt(t)],title:t.summary??t.name}},"toOperation"),es=p(t=>{let e=t??{},o=(e.methods??[]).map(r=>Zt(r)),s=new Map;for(let r of o){let l=r.tags[0]??"",i=s.get(l)??[];i.push(r),s.set(l,i)}return{groups:[...s.entries()].map(([r,l])=>({name:r,operations:l.toSorted((i,d)=>i.operationId.localeCompare(d.operationId))})).toSorted((r,l)=>r.name.localeCompare(l.name)),operationByKey:new Map(o.map(r=>[r.key,r])),title:e.info?.title??"API reference",version:e.info?.version}},"parseOpenRpc"),ts=p(t=>t.methods===void 0||t.methods.length===0,"isEmptyDocument"),ss=p(t=>{let e=t;return ts(e)?{kind:"empty"}:{kind:"ready",spec:e}},"classifyDocument"),Ge=p(t=>{let e=(0,We.c)(23),{spec:o}=t,s=M(),n=G(),r;e[0]!==n?(r=p(()=>n.fetchOpenRpc(),"t1"),e[0]=n,e[1]=r):r=e[1];let i=ue(o,r,ss),d;e[2]!==i.kind||e[3]!==i.spec?(d=i.kind==="ready"?es(i.spec):void 0,e[2]=i.kind,e[3]=i.spec,e[4]=d):d=e[4];let c=d;if(i.kind==="loading"){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=(0,Q.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"openrpc-reference-loading",children:[(0,Q.jsxDEV)(X,{className:"h-8 w-48"},void 0,!1),(0,Q.jsxDEV)(X,{className:"h-64 w-full"},void 0,!1)]},void 0,!0),e[5]=a):a=e[5],a}if(i.kind==="error"){let a;e[6]!==i.message||e[7]!==s?(a=s("Couldn't load the OpenRPC spec: {message}",{message:i.message}),e[6]=i.message,e[7]=s,e[8]=a):a=e[8];let u;e[9]!==s?(u=s("API reference unavailable"),e[9]=s,e[10]=u):u=e[10];let v;return e[11]!==a||e[12]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-error",title:u},void 0,!1),e[11]=a,e[12]=u,e[13]=v):v=e[13],v}if(i.kind==="empty"||c===void 0){let a;e[14]!==s?(a=s("Run `lunora codegen --api-spec openrpc` and wire `_generated/openrpc.json` to the worker to render the OpenRPC reference here."),e[14]=s,e[15]=a):a=e[15];let u;e[16]!==s?(u=s("No OpenRPC spec configured"),e[16]=s,e[17]=u):u=e[17];let v;return e[18]!==a||e[19]!==u?(v=(0,Q.jsxDEV)(W,{description:a,testId:"openrpc-reference-empty",title:u},void 0,!1),e[18]=a,e[19]=u,e[20]=v):v=e[20],v}let m;return e[21]!==c?(m=(0,Q.jsxDEV)(me,{model:c},void 0,!1),e[21]=c,e[22]=m):m=e[22],m},"OpenRpcReferencePanel");var z=q(ne(),1);var os=["reference","snippets"],ns=["openapi","openrpc"],Ws=p(t=>{let e=(0,Ue.c)(51),{functions:o,initialShardKey:s,openApiSpec:n,openRpcSpec:r}=t,l=M(),[i,d]=(0,ye.useState)("reference"),[c,m]=(0,ye.useState)("openapi"),a;e[0]!==l?(a=l("Reference"),e[0]=l,e[1]=a):a=e[1];let u;e[2]!==l?(u=l("Snippets"),e[2]=l,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==u?(v={reference:a,snippets:u},e[4]=a,e[5]=u,e[6]=v):v=e[6];let k=v,O;e[7]!==l?(O=l("OpenAPI"),e[7]=l,e[8]=O):O=e[8];let h;e[9]!==l?(h=l("OpenRPC"),e[9]=l,e[10]=h):h=e[10];let g;e[11]!==O||e[12]!==h?(g={openapi:O,openrpc:h},e[11]=O,e[12]=h,e[13]=g):g=e[13];let x=g,b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=p(A=>{d(A.currentTarget.dataset.view)},"t7"),e[14]=b):b=e[14];let S=b,y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=p(A=>{m(A.currentTarget.dataset.format)},"t8"),e[15]=y):y=e[15];let $=y,N;e[16]!==l?(N=l("API view"),e[16]=l,e[17]=N):N=e[17];let w;e[18]!==i||e[19]!==k?(w=os.map(A=>(0,z.jsxDEV)(H,{"aria-selected":i===A,"data-testid":`api-view-${A}`,"data-view":A,onClick:S,role:"tab",size:"sm",type:"button",variant:i===A?"default":"outline",children:k[A]},A,!1)),e[18]=i,e[19]=k,e[20]=w):w=e[20];let C;e[21]!==w||e[22]!==N?(C=(0,z.jsxDEV)("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"api-view-toggle",role:"tablist",children:w},void 0,!1),e[21]=w,e[22]=N,e[23]=C):C=e[23];let T;e[24]!==c||e[25]!==x||e[26]!==l||e[27]!==i?(T=i==="reference"&&(0,z.jsxDEV)("div",{"aria-label":l("API spec format"),className:"flex gap-1.5","data-testid":"api-format-toggle",role:"tablist",children:ns.map(A=>(0,z.jsxDEV)(H,{"aria-selected":c===A,"data-format":A,"data-testid":`api-format-${A}`,onClick:$,role:"tab",size:"sm",type:"button",variant:c===A?"default":"outline",children:x[A]},A,!1))},void 0,!1),e[24]=c,e[25]=x,e[26]=l,e[27]=i,e[28]=T):T=e[28];let I;e[29]!==C||e[30]!==T?(I=(0,z.jsxDEV)("div",{className:"flex shrink-0 flex-wrap items-center gap-3 border-b border-border px-6 py-3",children:[C,T]},void 0,!0),e[29]=C,e[30]=T,e[31]=I):I=e[31];let P;e[32]!==o||e[33]!==s||e[34]!==i?(P=i==="snippets"&&(0,z.jsxDEV)("div",{className:"min-h-0 flex-1 overflow-y-auto p-6",children:(0,z.jsxDEV)(je,{functions:o,initialShardKey:s},void 0,!1)},void 0,!1),e[32]=o,e[33]=s,e[34]=i,e[35]=P):P=e[35];let E;e[36]!==c||e[37]!==n||e[38]!==i?(E=i==="reference"&&c==="openapi"&&(0,z.jsxDEV)(He,{spec:n},void 0,!1),e[36]=c,e[37]=n,e[38]=i,e[39]=E):E=e[39];let j;e[40]!==c||e[41]!==r||e[42]!==i?(j=i==="reference"&&c==="openrpc"&&(0,z.jsxDEV)(Ge,{spec:r},void 0,!1),e[40]=c,e[41]=r,e[42]=i,e[43]=j):j=e[43];let R;e[44]!==P||e[45]!==E||e[46]!==j?(R=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[P,E,j]},void 0,!0),e[44]=P,e[45]=E,e[46]=j,e[47]=R):R=e[47];let L;return e[48]!==I||e[49]!==R?(L=(0,z.jsxDEV)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"lunora-api-tab",children:[I,R]},void 0,!0),e[48]=I,e[49]=R,e[50]=L):L=e[50],L},"ApiTab");export{Ws as default};
@@ -0,0 +1,13 @@
1
+ import{a as t}from"./chunk-RRCPZMC2.js";var a={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`],status:400,title:"Unique constraint violation"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{status:500,title:"Auth headers missing"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"}};var l=[{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
2
+ `),header:"No Lunora schema found",id:"lunora-schema-missing",test:t(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
3
+ `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:t(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
4
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:t(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
5
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:t(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
6
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:t(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
7
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:t(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
8
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:t(e=>e.includes("not exported by your worker entry"),"test")},{body:a.NOT_UNIQUE.hint.join(`
9
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:t(e=>e.includes("unique constraint violation on"),"test")},{body:a.CONFLICT.hint.join(`
10
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:t(e=>e.includes("optimistic concurrency conflict"),"test")}],d=t(e=>(Array.isArray(e)?e.join(`
11
+ `):e).split(`
12
+ `).filter(n=>!n.startsWith("```")).join(`
13
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"flattenHint");var o=class extends Error{static{t(this,"LunoraError")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(n,s,i={}){let r=a[n];super(s??n,{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??r?.hint,this.title=i.title??r?.title,this.loc=i.location,this.code=n,this.status=i.status??r?.status??500,this.docsUrl=i.docsUrl??r?.docsUrl,this.data=i.data}};export{d as a,o as b};
@@ -0,0 +1,2 @@
1
+ "use client";import{a as Ue,b as Vt,c as Ce,f as ut}from"./chunk-DWDILV2E.js";import{a as ft}from"./chunk-QAFAJBAW.js";import{a as Lt}from"./chunk-J6J54MBP.js";import{a as Ht,b as $e}from"./chunk-5OIBXYZM.js";import{a as zt}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{C as ye,R as Xt,e as Tt,i as Mt,p as De,q as Yt}from"./chunk-3CJW6NWG.js";import{c as Ne}from"./chunk-UK64ZSUW.js";import{a as ve,c as xe}from"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as Fe}from"./chunk-AQGOX5DK.js";import{a as Pt}from"./chunk-TAD43CG5.js";import{b as It}from"./chunk-DVKPRFIJ.js";import{b as Ot}from"./chunk-ZPP2KOR4.js";import{j as Z}from"./chunk-CKSHCYGC.js";import{f as Ct}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import{a as lt}from"./chunk-3OA7PECS.js";import{d as At,e as st,f as at,g as it,k as ct,l as Wt,n as dt}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as r,d as tr,e as L,f as ee,g as rr,h as or,j as ke}from"./chunk-RRCPZMC2.js";var se=L(ee(),1);var Gt=L(rr(),1);var fe={};tr(fe,{Content:()=>xt,Corner:()=>St,Root:()=>ht,Scrollbar:()=>vt,Thumb:()=>gt,Viewport:()=>pt});var d=L(ee(),1);var je=L(ee(),1);var Be=je.createContext(void 0);Be.displayName="ScrollAreaRootContext";function te(){let e=je.useContext(Be);if(e===void 0)throw new Error("Base UI: ScrollAreaRootContext is missing. ScrollArea parts must be placed within <ScrollArea.Root>.");return e}r(te,"useScrollAreaRootContext");var Ae=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});function V(e,t,n){if(!e)return 0;let N=getComputedStyle(e),A=n==="x"?"Inline":"Block";return n==="x"&&t==="margin"?parseFloat(N[`${t}InlineStart`])*2:parseFloat(N[`${t}${A}Start`])+parseFloat(N[`${t}${A}End`])}r(V,"getOffset");var _t=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var ge=(function(e){return e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var ce={hasOverflowX:r(e=>e?{[ge.hasOverflowX]:""}:null,"hasOverflowX"),hasOverflowY:r(e=>e?{[ge.hasOverflowY]:""}:null,"hasOverflowY"),overflowXStart:r(e=>e?{[ge.overflowXStart]:""}:null,"overflowXStart"),overflowXEnd:r(e=>e?{[ge.overflowXEnd]:""}:null,"overflowXEnd"),overflowYStart:r(e=>e?{[ge.overflowYStart]:""}:null,"overflowYStart"),overflowYEnd:r(e=>e?{[ge.overflowYEnd]:""}:null,"overflowYEnd"),cornerHidden:r(()=>null,"cornerHidden")};var Dt=L(lt(),1);var nr={x:0,y:0},kt={width:0,height:0},lr={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},sr={x:!0,y:!0,corner:!0},ht=d.forwardRef(r(function(t,n){let{render:N,className:A,overflowEdgeThreshold:f,style:E,...c}=t,{xStart:w,xEnd:S,yStart:T,yEnd:D}=ar(f),C=Tt(),M=ye(),b=ye(),{nonce:W,disableStyleElements:u}=Vt(),[y,g]=d.useState(!1),[$,_]=d.useState(!1),[I,F]=d.useState(!1),[U,k]=d.useState(!1),[re,G]=d.useState(!1),[X,p]=d.useState(kt),[H,ue]=d.useState(kt),[z,l]=d.useState(lr),[s,oe]=d.useState(sr),Q=d.useRef(null),x=d.useRef(null),O=d.useRef(null),a=d.useRef(null),m=d.useRef(null),h=d.useRef(null),R=d.useRef(null),Y=d.useRef(!1),B=d.useRef(0),q=d.useRef(0),P=d.useRef(0),ae=d.useRef(0),j=d.useRef("vertical"),Se=d.useRef(nr),be=xe(i=>{let ne=i.x-Se.current.x,Xe=i.y-Se.current.y;Se.current=i,Xe!==0&&(F(!0),M.start(500,()=>{F(!1)})),ne!==0&&(_(!0),b.start(500,()=>{_(!1)}))}),ie=xe(i=>{i.button===0&&(Y.current=!0,B.current=i.clientY,q.current=i.clientX,j.current=i.currentTarget.getAttribute(_t.orientation),x.current&&(P.current=x.current.scrollTop,ae.current=x.current.scrollLeft),m.current&&j.current==="vertical"&&m.current.setPointerCapture(i.pointerId),h.current&&j.current==="horizontal"&&h.current.setPointerCapture(i.pointerId))}),Le=xe(i=>{if(!Y.current)return;let ne=i.clientY-B.current,Xe=i.clientX-q.current;if(x.current){let He=x.current.scrollHeight,Ve=x.current.clientHeight,et=x.current.scrollWidth,tt=x.current.clientWidth;if(m.current&&O.current&&j.current==="vertical"){let me=V(O.current,"padding","y"),he=V(m.current,"margin","y"),Ee=m.current.offsetHeight,Pe=O.current.offsetHeight-Ee-me-he,We=ne/Pe;x.current.scrollTop=P.current+We*(He-Ve),i.preventDefault(),F(!0),M.start(500,()=>{F(!1)})}if(h.current&&a.current&&j.current==="horizontal"){let me=V(a.current,"padding","x"),he=V(h.current,"margin","x"),Ee=h.current.offsetWidth,Pe=a.current.offsetWidth-Ee-me-he,We=Xe/Pe;x.current.scrollLeft=ae.current+We*(et-tt),i.preventDefault(),_(!0),b.start(500,()=>{_(!1)})}}}),we=xe(i=>{Y.current=!1,m.current&&j.current==="vertical"&&m.current.hasPointerCapture(i.pointerId)&&m.current.releasePointerCapture(i.pointerId),h.current&&j.current==="horizontal"&&h.current.hasPointerCapture(i.pointerId)&&h.current.releasePointerCapture(i.pointerId)});function K(i){k(i.pointerType==="touch")}r(K,"handleTouchModalityChange");function J(i){if(K(i),i.pointerType!=="touch"){let ne=De(Q.current,i.target);g(ne)}}r(J,"handlePointerEnterOrMove");let Me=d.useMemo(()=>({scrolling:$||I,hasOverflowX:!s.x,hasOverflowY:!s.y,overflowXStart:z.xStart,overflowXEnd:z.xEnd,overflowYStart:z.yStart,overflowYEnd:z.yEnd,cornerHidden:s.corner}),[$,I,s.x,s.y,s.corner,z]),Je={role:"presentation",onPointerEnter:J,onPointerMove:J,onPointerDown:K,onPointerLeave(){g(!1)},style:{position:"relative",[Ae.scrollAreaCornerHeight]:`${X.height}px`,[Ae.scrollAreaCornerWidth]:`${X.width}px`}},Re=Z("div",t,{state:Me,ref:[n,Q],props:[Je,c],stateAttributesMapping:ce}),Ye=d.useMemo(()=>({handlePointerDown:ie,handlePointerMove:Le,handlePointerUp:we,handleScroll:be,cornerSize:X,setCornerSize:p,thumbSize:H,setThumbSize:ue,hasMeasuredScrollbar:re,setHasMeasuredScrollbar:G,touchModality:U,cornerRef:R,scrollingX:$,setScrollingX:_,scrollingY:I,setScrollingY:F,hovering:y,setHovering:g,viewportRef:x,rootRef:Q,scrollbarYRef:O,scrollbarXRef:a,thumbYRef:m,thumbXRef:h,rootId:C,hiddenState:s,setHiddenState:oe,overflowEdges:z,setOverflowEdges:l,viewportState:Me,overflowEdgeThreshold:{xStart:w,xEnd:S,yStart:T,yEnd:D}}),[ie,Le,we,be,X,H,re,U,$,_,I,F,y,g,C,s,z,Me,w,S,T,D]);return(0,Dt.jsxs)(Be.Provider,{value:Ye,children:[!u&&Ue.getElement(W),Re]})},"ScrollAreaRoot"));ht.displayName="ScrollAreaRoot";function ar(e){if(typeof e=="number"){let t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}r(ar,"normalizeOverflowEdgeThreshold");var de=L(ee(),1);var qe=L(ee(),1);var Ke=qe.createContext(void 0);Ke.displayName="ScrollAreaViewportContext";function $t(){let e=qe.useContext(Ke);if(e===void 0)throw new Error("Base UI: ScrollAreaViewportContext missing. ScrollAreaViewport parts must be placed within <ScrollArea.Viewport>.");return e}r($t,"useScrollAreaViewportContext");var le=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({});var Ut=L(lt(),1);var Ft=!1;function cr(){Ft||Mt.engine.webkit||(typeof CSS<"u"&&"registerProperty"in CSS&&[le.scrollAreaOverflowXStart,le.scrollAreaOverflowXEnd,le.scrollAreaOverflowYStart,le.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ft=!0)}r(cr,"removeCSSVariableInheritance");var pt=de.forwardRef(r(function(t,n){let{render:N,className:A,style:f,...E}=t,{viewportRef:c,scrollbarYRef:w,scrollbarXRef:S,thumbYRef:T,thumbXRef:D,cornerRef:C,cornerSize:M,setCornerSize:b,setThumbSize:W,rootId:u,setHiddenState:y,hiddenState:g,setHasMeasuredScrollbar:$,handleScroll:_,setHovering:I,setOverflowEdges:F,overflowEdges:U,overflowEdgeThreshold:k,scrollingX:re,scrollingY:G}=te(),X=$e(),p=de.useRef(!0),H=de.useRef([NaN,NaN,NaN,NaN]),ue=ye(),z=ye(),l=xe(()=>{let a=c.current,m=w.current,h=S.current,R=T.current,Y=D.current,B=C.current;if(!a)return;let q=a.scrollHeight,P=a.scrollWidth,ae=a.clientHeight,j=a.clientWidth,Se=a.scrollTop,be=a.scrollLeft,ie=H.current,Le=Number.isNaN(ie[0]);if(ie[0]=ae,ie[1]=q,ie[2]=j,ie[3]=P,Le&&$(!0),q===0||P===0)return;let we=dr(a),K=we.y,J=we.x,Me=j/P,Je=ae/q,Re=Math.max(0,P-j),Ye=Math.max(0,q-ae),i=0,ne=0;if(!J){let v=0;X==="rtl"?v=Ce(-be,0,Re):v=Ce(be,0,Re),i=ut(v,Re),ne=Re-i}let Xe=K?0:Ce(Se,0,Ye),He=K?0:ut(Xe,Ye),Ve=K?0:Ye-He,et=J?0:j,tt=K?0:ae,me=0,he=0;!J&&!K&&(me=m?.offsetWidth||0,he=h?.offsetHeight||0);let Ee=M.width===0&&M.height===0,Pe=Ee?me:0,We=Ee?he:0,bt=V(h,"padding","x"),wt=V(m,"padding","y"),Rt=V(Y,"margin","x"),Et=V(R,"margin","y"),yt=et-bt-Rt,Nt=tt-wt-Et,Qt=h?Math.min(h.offsetWidth-Pe,yt):yt,Jt=m?Math.min(m.offsetHeight-We,Nt):Nt,rt=Math.max(16,Qt*Me),ot=Math.max(16,Jt*Je);if(W(v=>v.height===ot&&v.width===rt?v:{width:rt,height:ot}),m&&R){let v=m.offsetHeight-ot-wt-Et,pe=q-ae,_e=pe===0?0:Se/pe,nt=Math.min(v,Math.max(0,_e*v));R.style.transform=`translate3d(0,${nt}px,0)`}if(h&&Y){let v=h.offsetWidth-rt-bt-Rt,pe=P-j,_e=pe===0?0:be/pe,nt=X==="rtl"?Ce(_e*v,-v,0):Ce(_e*v,0,v);Y.style.transform=`translate3d(${nt}px,0,0)`}let er=[[le.scrollAreaOverflowXStart,i],[le.scrollAreaOverflowXEnd,ne],[le.scrollAreaOverflowYStart,He],[le.scrollAreaOverflowYEnd,Ve]];for(let[v,pe]of er)a.style.setProperty(v,`${pe}px`);B&&(J||K?b({width:0,height:0}):!J&&!K&&b({width:me,height:he})),y(v=>fr(v,we));let Ie={xStart:!J&&i>k.xStart,xEnd:!J&&ne>k.xEnd,yStart:!K&&He>k.yStart,yEnd:!K&&Ve>k.yEnd};F(v=>v.xStart===Ie.xStart&&v.xEnd===Ie.xEnd&&v.yStart===Ie.yStart&&v.yEnd===Ie.yEnd?v:Ie)});ve(()=>{c.current&&cr()},[c]),ve(()=>{queueMicrotask(l)},[l,g,X,k.xStart,k.xEnd,k.yStart,k.yEnd]),ve(()=>{c.current?.matches(":hover")&&I(!0)},[c,I]),ve(()=>{let a=c.current;if(typeof ResizeObserver>"u"||!a)return;let m=!1,h=new ResizeObserver(()=>{if(!m){m=!0;let R=H.current;if(R[0]===a.clientHeight&&R[1]===a.scrollHeight&&R[2]===a.clientWidth&&R[3]===a.scrollWidth)return}l()});return h.observe(a),z.start(0,()=>{let R=a.getAnimations({subtree:!0});R.length!==0&&Promise.allSettled(R.map(Y=>Y.finished)).then(l).catch(()=>{})}),()=>{h.disconnect(),z.clear()}},[l,c,z]);function s(){p.current=!1}r(s,"handleUserInteraction");let oe={role:"presentation",...u&&{"data-id":`${u}-viewport`},tabIndex:g.x&&g.y?-1:0,className:Ue.className,style:{overflow:"scroll"},onScroll(){c.current&&(l(),p.current||_({x:c.current.scrollLeft,y:c.current.scrollTop}),ue.start(100,()=>{p.current=!0}))},onWheel:s,onTouchMove:s,onPointerMove:s,onPointerEnter:s,onKeyDown:s},Q=de.useMemo(()=>({scrolling:re||G,hasOverflowX:!g.x,hasOverflowY:!g.y,overflowXStart:U.xStart,overflowXEnd:U.xEnd,overflowYStart:U.yStart,overflowYEnd:U.yEnd,cornerHidden:g.corner}),[re,G,g.x,g.y,g.corner,U]),x=Z("div",t,{ref:[n,c],state:Q,props:[oe,E],stateAttributesMapping:ce}),O=de.useMemo(()=>({computeThumbPosition:l}),[l]);return(0,Ut.jsx)(Ke.Provider,{value:O,children:x})},"ScrollAreaViewport"));pt.displayName="ScrollAreaViewport";function dr(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}r(dr,"getHiddenState");function fr(e,t){return e.y===t.y&&e.x===t.x&&e.corner===t.corner?e:t}r(fr,"mergeHiddenState");var Te=L(ee(),1);var Ze=L(ee(),1);var Ge=Ze.createContext(void 0);Ge.displayName="ScrollAreaScrollbarContext";function jt(){let e=Ze.useContext(Ge);if(e===void 0)throw new Error("Base UI: ScrollAreaScrollbarContext is missing. ScrollAreaScrollbar parts must be placed within <ScrollArea.Scrollbar>.");return e}r(jt,"useScrollAreaScrollbarContext");var Oe=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});var Bt=L(lt(),1);var vt=Te.forwardRef(r(function(t,n){let{render:N,className:A,orientation:f="vertical",keepMounted:E=!1,style:c,...w}=t,{hovering:S,scrollingX:T,scrollingY:D,hiddenState:C,overflowEdges:M,scrollbarYRef:b,scrollbarXRef:W,viewportRef:u,thumbYRef:y,thumbXRef:g,handlePointerDown:$,handlePointerUp:_,handleScroll:I,rootId:F,thumbSize:U,hasMeasuredScrollbar:k}=te(),re={hovering:S,scrolling:{horizontal:T,vertical:D}[f],orientation:f,hasOverflowX:!C.x,hasOverflowY:!C.y,overflowXStart:M.xStart,overflowXEnd:M.xEnd,overflowYStart:M.yStart,overflowYEnd:M.yEnd,cornerHidden:C.corner},G=$e(),X=!k&&!E,p=f==="vertical"?C.y:C.x,H=E||!p;Te.useEffect(()=>{if(!H)return;let s=u.current,oe=f==="vertical"?b.current:W.current;if(!oe)return;function Q(x){if(!s||!oe||x.ctrlKey)return;let O=f==="horizontal",a=O?"scrollLeft":"scrollTop",m=O?x.deltaX:x.deltaY;if(m===0)return;let h=O?s.scrollWidth-s.clientWidth:s.scrollHeight-s.clientHeight,R=O&&G==="rtl"?-h:0,Y=O&&G==="rtl"?0:h,B=s[a];B<=R&&m<0||B>=Y&&m>0||(x.preventDefault(),s[a]=Math.min(Y,Math.max(R,B+m)),I({x:s.scrollLeft,y:s.scrollTop}))}return r(Q,"handleWheel"),Ht(oe,"wheel",Q,{passive:!1})},[G,I,f,W,b,H,u]);let ue={...F&&{"data-id":`${F}-scrollbar`},onPointerDown(s){if(s.button!==0)return;let oe=Yt(s.nativeEvent),Q=f==="vertical"?y.current:g.current;if(!(Q&&De(Q,oe))&&u.current){if(y.current&&b.current&&f==="vertical"){let x=V(y.current,"margin","y"),O=V(b.current,"padding","y"),a=y.current.offsetHeight,m=b.current.getBoundingClientRect(),h=s.clientY-m.top-a/2-O+x/2,R=u.current.scrollHeight,Y=u.current.clientHeight,B=b.current.offsetHeight-a-O-x,P=h/B*(R-Y);u.current.scrollTop=P}if(g.current&&W.current&&f==="horizontal"){let x=V(g.current,"margin","x"),O=V(W.current,"padding","x"),a=g.current.offsetWidth,m=W.current.getBoundingClientRect(),h=s.clientX-m.left-a/2-O+x/2,R=u.current.scrollWidth,Y=u.current.clientWidth,B=W.current.offsetWidth-a-O-x,q=h/B,P;G==="rtl"?(P=(1-q)*(R-Y),u.current.scrollLeft<=0&&(P=-P)):P=q*(R-Y),u.current.scrollLeft=P}I({x:u.current.scrollLeft,y:u.current.scrollTop}),$(s)}},onPointerUp:_,onPointerCancel:_,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:X?"hidden":void 0,...f==="vertical"&&{top:0,bottom:`var(${Ae.scrollAreaCornerHeight})`,insetInlineEnd:0,[Oe.scrollAreaThumbHeight]:`${U.height}px`},...f==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${Ae.scrollAreaCornerWidth})`,bottom:0,[Oe.scrollAreaThumbWidth]:`${U.width}px`}}},z=Z("div",t,{ref:[n,f==="vertical"?b:W],state:re,props:[ue,w],stateAttributesMapping:ce}),l=Te.useMemo(()=>({orientation:f}),[f]);return H?(0,Bt.jsx)(Ge.Provider,{value:l,children:z}):null},"ScrollAreaScrollbar"));vt.displayName="ScrollAreaScrollbar";var ze=L(ee(),1);var xt=ze.forwardRef(r(function(t,n){let{render:N,className:A,style:f,...E}=t,{computeThumbPosition:c}=$t(),{hasMeasuredScrollbar:w,viewportState:S}=te(),T=ze.useRef(null),D=ze.useRef(w);return ve(()=>{if(typeof ResizeObserver>"u")return;let M=!1,b=new ResizeObserver(()=>{!M&&(M=!0,!D.current)||c()});return T.current&&b.observe(T.current),()=>{b.disconnect()}},[c]),Z("div",t,{ref:[n,T],state:S,stateAttributesMapping:ce,props:[{role:"presentation",style:{minWidth:"fit-content"}},E]})},"ScrollAreaContent"));xt.displayName="ScrollAreaContent";var qt=L(ee(),1);var gt=qt.forwardRef(r(function(t,n){let{render:N,className:A,style:f,...E}=t,{thumbYRef:c,thumbXRef:w,handlePointerDown:S,handlePointerMove:T,handlePointerUp:D,setScrollingX:C,setScrollingY:M,scrollingX:b,scrollingY:W,hasMeasuredScrollbar:u}=te(),{orientation:y}=jt(),g={scrolling:y==="horizontal"?b:W,orientation:y};function $(I){y==="vertical"&&M(!1),y==="horizontal"&&C(!1),D(I)}return r($,"endDrag"),Z("div",t,{ref:[n,y==="vertical"?c:w],state:g,props:[{onPointerDown:S,onPointerMove:T,onPointerUp:$,onPointerCancel:$,style:{visibility:u?void 0:"hidden",...y==="vertical"&&{height:`var(${Oe.scrollAreaThumbHeight})`},...y==="horizontal"&&{width:`var(${Oe.scrollAreaThumbWidth})`}}},E]})},"ScrollAreaThumb"));gt.displayName="ScrollAreaThumb";var Kt=L(ee(),1);var St=Kt.forwardRef(r(function(t,n){let{render:N,className:A,style:f,...E}=t,{cornerRef:c,cornerSize:w,hiddenState:S}=te(),T=Z("div",t,{ref:[n,c],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:w.width,height:w.height}},E]});return S.corner?null:T},"ScrollAreaCorner"));St.displayName="ScrollAreaCorner";var o=L(or(),1);function ur({className:e,orientation:t="horizontal",...n}){return(0,o.jsxDEV)(ft,{"data-slot":"separator",orientation:t,className:ke("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...n},void 0,!1)}r(ur,"Separator");function mr(e){let t=(0,Gt.c)(14),n,N,A;t[0]!==e?({className:N,children:n,...A}=e,t[0]=e,t[1]=n,t[2]=N,t[3]=A):(n=t[1],N=t[2],A=t[3]);let f;t[4]!==N?(f=ke("relative",N),t[4]=N,t[5]=f):f=t[5];let E;t[6]!==n?(E=(0,o.jsxDEV)(fe.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:n},void 0,!1),t[6]=n,t[7]=E):E=t[7];let c,w;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,o.jsxDEV)(hr,{},void 0,!1),w=(0,o.jsxDEV)(fe.Corner,{},void 0,!1),t[8]=c,t[9]=w):(c=t[8],w=t[9]);let S;return t[10]!==A||t[11]!==f||t[12]!==E?(S=(0,o.jsxDEV)(fe.Root,{"data-slot":"scroll-area",className:f,...A,children:[E,c,w]},void 0,!0),t[10]=A,t[11]=f,t[12]=E,t[13]=S):S=t[13],S}r(mr,"ScrollArea");function hr({className:e,orientation:t="vertical",...n}){return(0,o.jsxDEV)(fe.Scrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:ke("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-s data-vertical:border-s-transparent",e),...n,children:(0,o.jsxDEV)(fe.Thumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-md bg-border"},void 0,!1)},void 0,!1)}r(hr,"ScrollBar");var pr=st(Fe.clearCapturedMail),vr=st(Fe.sendTestMail),xr=/https?:\/\/[^\s"'<>)]+/i,Zt=r(e=>e===void 0?void 0:xr.exec(e)?.[0],"firstLink"),gr=r(e=>{if(e!==void 0)return Zt(e.html)??Zt(e.text)},"selectedLink"),Sr=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,br=r(e=>`${Sr}${e}`,"withPreviewCsp"),Qe=r(e=>e===void 0?"":Array.isArray(e)?e.join(", "):e,"recipientText"),mn=r(({limit:e=100})=>{let t=Ct(),n=At(),{data:N,error:A,errorSource:f,isLoading:E,refetch:c}=It(Fe.getCapturedMail,{limit:e}),[w,S]=(0,se.useState)(null),[T,D]=(0,se.useState)(null),[C,M]=(0,se.useState)("html"),[b,W]=(0,se.useState)(""),u=(0,se.useMemo)(()=>N?.entries??[],[N]),y=A??w,g=A===null?w:f,$=r(async()=>{S(null);try{await t.query(pr,{},at("")),D(null),c()}catch(l){S(it(l))}},"clearInbox"),_=r(async()=>{S(null);try{await t.query(vr,{},at("")),c()}catch(l){S(it(l))}},"sendTest");Lt(()=>{c()},!0);let I=r(()=>{ct($())},"onClear"),F=r(()=>{ct(_())},"onSendTest"),U=r(l=>{W(l.currentTarget.value)},"onFilterChange"),k=r(l=>{let{id:s}=l.currentTarget.dataset;s!==void 0&&D(s)},"onSelectMessage"),re=r(l=>{let s=l.currentTarget.dataset.tab;(s==="headers"||s==="html"||s==="text")&&M(s)},"onSelectTab"),G=r(l=>n(l==="html"?"HTML":l==="text"?"Plain text":"Headers"),"tabTitle"),X=(0,se.useMemo)(()=>{let l=b.trim().toLowerCase();return l===""?u:u.filter(s=>`${s.subject} ${Qe(s.to)}`.toLowerCase().includes(l))},[u,b]),p=(0,se.useMemo)(()=>{if(X.length!==0)return X.find(l=>l.id===T)??X[0]},[X,T]),H=gr(p),ue=r(()=>{H!==void 0&&Wt(H)},"onCopyLink"),z=r(()=>{H!==void 0&&"window"in globalThis&&globalThis.window.open(H,"_blank","noopener")},"onOpenLink");return(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,o.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,o.jsxDEV)(Ne,{"data-testid":"mail-send-test",onClick:F,size:"sm",type:"button",variant:"outline",children:n("Send test")},void 0,!1),(0,o.jsxDEV)(Ne,{"data-testid":"mail-clear",disabled:u.length===0,onClick:I,size:"sm",type:"button",variant:"outline",children:n("Clear inbox")},void 0,!1),u.length>0&&(0,o.jsxDEV)(Ot,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:n("{count} messages",{count:u.length})},void 0,!1)]},void 0,!0),y!==null&&(0,o.jsxDEV)(zt,{error:g,testId:"mail-error"},void 0,!1),y===null&&!E&&u.length===0&&(0,o.jsxDEV)(Pt,{description:n("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,o.jsxDEV)("path",{d:"M4 5h16v14H4z"},void 0,!1),(0,o.jsxDEV)("path",{d:"m4 6 8 6 8-6"},void 0,!1)]},void 0,!0),testId:"mail-empty",title:n("No captured email.")},void 0,!1),u.length>0&&(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,o.jsxDEV)("div",{className:"flex flex-col gap-2",children:[(0,o.jsxDEV)(Xt,{"aria-label":n("Search messages"),"data-testid":"mail-search",onChange:U,placeholder:n("Filter messages"),type:"search",value:b},void 0,!1),(0,o.jsxDEV)(mr,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,o.jsxDEV)("ul",{className:"divide-y",children:X.map(l=>{let s=l.id===p?.id;return(0,o.jsxDEV)("li",{children:(0,o.jsxDEV)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${s?"bg-muted":""}`,"data-active":s,"data-id":l.id,"data-testid":"mail-list-item",onClick:k,type:"button",children:[(0,o.jsxDEV)("span",{className:"w-full truncate font-medium",children:l.subject||n("(no subject)")},void 0,!1),(0,o.jsxDEV)("span",{className:"w-full truncate text-xs text-muted-foreground",children:Qe(l.to)},void 0,!1),(0,o.jsxDEV)("span",{className:"text-xs text-muted-foreground tabular-nums",children:dt(l.capturedAt,"\u2014")},void 0,!1)]},void 0,!0)},l.id,!1)})},void 0,!1)},void 0,!1)]},void 0,!0),p!==void 0&&(0,o.jsxDEV)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,o.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,o.jsxDEV)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:p.subject||n("(no subject)")},void 0,!1),(0,o.jsxDEV)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,o.jsxDEV)("dt",{children:n("From")},void 0,!1),(0,o.jsxDEV)("dd",{className:"truncate font-mono",children:p.from??"\u2014"},void 0,!1),(0,o.jsxDEV)("dt",{children:n("To")},void 0,!1),(0,o.jsxDEV)("dd",{className:"truncate font-mono",children:Qe(p.to)},void 0,!1),p.cc!==void 0&&p.cc.length>0&&(0,o.jsxDEV)(o.Fragment,{children:[(0,o.jsxDEV)("dt",{children:n("Cc")},void 0,!1),(0,o.jsxDEV)("dd",{className:"truncate font-mono",children:Qe(p.cc)},void 0,!1)]},void 0,!0),(0,o.jsxDEV)("dt",{children:n("Sent")},void 0,!1),(0,o.jsxDEV)("dd",{className:"tabular-nums",children:dt(p.capturedAt,"\u2014")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,o.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,o.jsxDEV)(Ne,{"data-testid":"mail-copy-link",disabled:H===void 0,onClick:ue,size:"sm",type:"button",variant:"outline",children:n("Copy link")},void 0,!1),(0,o.jsxDEV)(Ne,{"data-testid":"mail-open-link",disabled:H===void 0,onClick:z,size:"sm",type:"button",variant:"outline",children:n("Open in new tab")},void 0,!1)]},void 0,!0),(0,o.jsxDEV)(ur,{},void 0,!1),(0,o.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(l=>(0,o.jsxDEV)(Ne,{"aria-selected":C===l,"data-tab":l,"data-testid":`mail-tab-${l}`,onClick:re,role:"tab",size:"sm",type:"button",variant:C===l?"secondary":"ghost",children:G(l)},l,!1))},void 0,!1),(0,o.jsxDEV)("div",{className:"min-h-[12rem]",children:[C==="html"&&(p.html===void 0?(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No HTML body.")},void 0,!1):(0,o.jsxDEV)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:br(p.html),title:n("Email preview")},void 0,!1)),C==="text"&&(p.text===void 0?(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No text body.")},void 0,!1):(0,o.jsxDEV)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:p.text},void 0,!1)),C==="headers"&&(p.headers===void 0||Object.keys(p.headers).length===0?(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:n("No headers.")},void 0,!1):(0,o.jsxDEV)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(p.headers).map(([l,s])=>`${l}: ${s}`).join(`
2
+ `)},void 0,!1))]},void 0,!0)]},void 0,!0)]},void 0,!0)]},void 0,!0)},"MailPanel");export{mn as MailPanel};
@@ -0,0 +1 @@
1
+ import{b as de,e as j}from"./chunk-25VHPD2I.js";import{a as ce}from"./chunk-WXPWVBIY.js";import"./chunk-55YA7ZZI.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import"./chunk-KEGAWN6Y.js";import{a as ie}from"./chunk-TBMYIZIO.js";import"./chunk-HV7G6DFP.js";import{a as E}from"./chunk-AQGOX5DK.js";import{b as ne}from"./chunk-DVKPRFIJ.js";import{a as S}from"./chunk-SEU5V7I6.js";import{b as A}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as ae,g as le}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as D,e as T,f as H,g as Q,k as F,n as oe}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as h,e as k,f as ke,g as re,h as se,j as w}from"./chunk-RRCPZMC2.js";var ve=k(re(),1);var c=k(ke(),1);var ue=k(re(),1);var W=k(se(),1);var Ae={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},fe=h(()=>{let t=(0,ue.c)(16),e=D(),a=le(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}default:s=a}let l=Ae[a],d;t[8]!==l?(d=w("size-2 rounded-full",l),t[8]=l,t[9]=d):d=t[9];let u;t[10]!==d?(u=(0,W.jsxDEV)("span",{"aria-hidden":"true",className:d},void 0,!1),t[10]=d,t[11]=u):u=t[11];let i;return t[12]!==a||t[13]!==u||t[14]!==s?(i=(0,W.jsxDEV)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[u,s]},void 0,!0),t[12]=a,t[13]=u,t[14]=s,t[15]=i):i=t[15],i},"ConnectionBadge");var r=k(se(),1);var me={completed:0,failed:2,in_progress:1},Re=h(t=>{let e=0,a=0,s=0,l=0,d=[];for(let{metrics:u}of t){if(u===null){l+=1;continue}s+=1,e+=u.requests,a+=u.errors,d.push(...u.history??[])}return{errors:a,failed:l,history:d,reachable:s,requests:e}},"sumShardMetrics"),Me=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"mergeFunctionStats"),_e=h(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let d=me[s.status]-me[l.status];(d>0||d===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"dedupeMigrations"),Ie=T(E.getAuthMetrics),Le=T(E.getFunctionStats),Ce=T(E.getLogs),Oe=T(E.getMetrics),qe=T(E.migrationStatus),De=5,he=2e3,Fe=5,pe=.01,ge=.05,je=.1,Ue=.3,Pe=1,Ge=50,X=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","rateLevel"),Ve=h((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","countLevel"),Be={crit:"destructive",ok:"secondary",warn:"default"},U=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"ratePercent"),Ke=h(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"requestErrorSeries"),$e=h(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"migrationSummary"),ze=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"migrationTileValue"),xe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},He={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Qe=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","worstLevel"),P=h(t=>{let e=(0,ve.c)(19),{chart:a,label:s,level:l,testId:d,value:u}=t,i=xe[l],n;e[0]!==i?(n=w("size-1.5 shrink-0 rounded-full",i),e[0]=i,e[1]=n):n=e[1];let p;e[2]!==n?(p=(0,r.jsxDEV)("span",{"aria-hidden":"true",className:n},void 0,!1),e[2]=n,e[3]=p):p=e[3];let g;e[4]!==s||e[5]!==p?(g=(0,r.jsxDEV)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[p,s]},void 0,!0),e[4]=s,e[5]=p,e[6]=g):g=e[6];let b=Ne[l],m;e[7]!==b?(m=w("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=m):m=e[8];let f;e[9]!==m||e[10]!==d||e[11]!==u?(f=(0,r.jsxDEV)("span",{className:m,"data-testid":d,children:u},void 0,!1),e[9]=m,e[10]=d,e[11]=u,e[12]=f):f=e[12];let v;e[13]!==a||e[14]!==f?(v=(0,r.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[f,a]},void 0,!0),e[13]=a,e[14]=f,e[15]=v):v=e[15];let x;return e[16]!==g||e[17]!==v?(x=(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:(0,r.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,v]},void 0,!0)},void 0,!1),e[16]=g,e[17]=v,e[18]=x):x=e[18],x},"SloCard"),We=h(async(t,e,a)=>{let s=await Promise.all(a.map(m=>{let f=H(m);return Promise.allSettled([t.query(Oe,{},f),t.query(Le,{},f),t.query(qe,{},f)])})),l=H(e),d=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[u,i,n]=await Promise.allSettled([t.query(Ce,{},l),t.query(Ie,{},l),d]),p=s.map(([m,f,v])=>({functions:f.status==="fulfilled"?f.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:v.status==="fulfilled"?v.value.migrations:[]})),g=Re(p),b=s[0]?.[0];return{auth:i.status==="fulfilled"?i.value:null,entries:u.status==="fulfilled"?u.value.entries:[],functions:Me(p.map(m=>m.functions)),logsError:u.status==="rejected"?Q(u.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?Q(b.reason):null,migrations:_e(p.map(m=>m.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:g}},"loadSloData"),ht=h(({initialShardKey:t})=>{let e=ae(),a=D(),[s,l]=(0,c.useState)([]),[d,u]=(0,c.useState)(null),[i,n]=(0,c.useState)(null),[p,g]=(0,c.useState)(null),[b,m]=(0,c.useState)([]),[f,v]=(0,c.useState)(null),[x,be]=(0,c.useState)(null),[we,Ee]=(0,c.useState)([]),[y]=(0,c.useState)(ie),R=(0,c.useRef)(!1),G=(0,c.useRef)(!0);(0,c.useEffect)(()=>(G.current=!0,()=>{G.current=!1}),[]);let M=t??"",_=(0,c.useCallback)(async()=>{if(R.current)return;R.current=!0;let o=await We(e,M,de(M,y));if(!G.current){R.current=!1;return}n(o.totals),g(o.metricsError),m(o.functions),Ee(o.migrations),l(o.entries),u(o.logsError),v(o.auth),be(o.scheduler),R.current=!1},[e,y,M]);(0,c.useEffect)(()=>{F(_())},[_]);let V=(0,c.useRef)(0),I=(0,c.useRef)(null),Se=h(()=>{let o=Date.now()-V.current;if(o>=he){V.current=Date.now(),F(_());return}I.current??=setTimeout(()=>{I.current=null,V.current=Date.now(),F(_())},he-o)},"scheduleFanOut");(0,c.useEffect)(()=>()=>{I.current!==null&&clearTimeout(I.current)},[]);let{data:J,liveError:Te}=ne(E.getMetrics,{},{live:!0,shardKey:M});(0,c.useEffect)(()=>{J!==void 0&&Se()},[J]);let B=s.filter(o=>o.level==="error"),K=B.slice(0,De),L=Ke(i?.history),Y=(0,c.useMemo)(()=>{let o=f?.history??[];return{attempts:o.map(N=>N.attempts),failures:o.map(N=>N.failures)}},[f?.history]),Z=b.filter(o=>o.calls>0).toSorted((o,N)=>N.errors/N.calls-o.errors/o.calls||N.calls-o.calls).slice(0,Fe),$=$e(we),ye=i===null||i.requests===0?0:i.errors/i.requests,z=X(ye,pe,ge),ee=f===null?"ok":X(f.failureRate,je,Ue),te=x===null?"ok":Ve(x.backlog,Pe,Ge),C=Qe([z,ee,te,$.level]),O,q;return C==="crit"?(O=a("Critical"),q=a("One or more service levels are breached.")):C==="warn"?(O=a("Degraded"),q=a("Some service levels need attention.")):(O=a("All systems healthy"),q=a("All service levels are within target.")),(0,r.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxDEV)("div",{className:"flex items-center gap-3",children:[(0,r.jsxDEV)("span",{"aria-hidden":"true",className:w("flex size-10 shrink-0 items-center justify-center rounded-full",He[C]),children:(0,r.jsxDEV)("span",{className:w("size-3 rounded-full",xe[C])},void 0,!1)},void 0,!1),(0,r.jsxDEV)("div",{className:"grid leading-tight",children:[(0,r.jsxDEV)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O},void 0,!1),(0,r.jsxDEV)("span",{className:"text-[13px] text-muted-foreground",children:q},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsxDEV)(j,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"},void 0,!1),(0,r.jsxDEV)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(i?.requests??0).toString()},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"text-end",children:[(0,r.jsxDEV)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")},void 0,!1),(0,r.jsxDEV)("div",{className:w("text-lg font-semibold tabular-nums",Ne[z]),"data-testid":"hl-error-rate",children:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"},void 0,!1),(0,r.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)(fe,{},void 0,!1),(0,r.jsxDEV)(ce,{message:Te,prefix:"hl"},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),p!==null&&(0,r.jsxDEV)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:p},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsxDEV)(P,{chart:L.errors.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"},void 0,!1):void 0,label:a("Error rate"),level:z,testId:"hl-slo-errorrate",value:i===null?"\u2014":U(i.errors,i.requests)},void 0,!1),(0,r.jsxDEV)(P,{chart:Y.failures.length>=2?(0,r.jsxDEV)(j,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:Y.failures,testId:"hl-spark-auth"},void 0,!1):void 0,label:a("Auth failures"),level:ee,testId:"hl-slo-auth",value:f===null?"\u2014":U(f.failures,f.attempts)},void 0,!1),(0,r.jsxDEV)(P,{label:a("Scheduler backlog"),level:te,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()},void 0,!1),(0,r.jsxDEV)(P,{label:a("Migrations"),level:$.level,testId:"hl-slo-migrations",value:ze($,a)},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("div",{className:"grid gap-3 lg:grid-cols-2",children:[(0,r.jsxDEV)(S,{className:"gap-0 py-0","data-testid":"hl-functions",children:[(0,r.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Functions by error rate")},void 0,!1)},void 0,!1),Z.length===0?(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:a("No function activity yet.")},void 0,!1):(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:Z.map(o=>(0,r.jsxDEV)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.path},void 0,!1),(0,r.jsxDEV)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsxDEV)("span",{className:"tabular-nums text-muted-foreground",children:a("{count} calls",{count:o.calls.toString()})},void 0,!1),(0,r.jsxDEV)(A,{variant:Be[X(o.errors/o.calls,pe,ge)],children:U(o.errors,o.calls)},void 0,!1)]},void 0,!0)]},o.path,!0))},void 0,!1)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Recent errors")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-error-count",variant:B.length>0?"destructive":"outline",children:B.length},void 0,!1)]},void 0,!0),d!==null&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:d},void 0,!1),d===null&&K.length===0&&(0,r.jsxDEV)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:a("No recent errors.")},void 0,!1),K.length>0&&(0,r.jsxDEV)("ul",{className:"divide-y divide-border",children:K.map((o,N)=>(0,r.jsxDEV)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxDEV)("span",{className:"flex items-center gap-2",children:[(0,r.jsxDEV)("time",{className:"shrink-0 text-muted-foreground",children:oe(o.timestamp)},void 0,!1),o.functionPath!==void 0&&(0,r.jsxDEV)("span",{className:"truncate font-mono text-foreground",children:o.functionPath},void 0,!1)]},void 0,!0),(0,r.jsxDEV)("span",{className:"text-destructive",children:o.message},void 0,!1)]},`${o.timestamp.toString()}-${N.toString()}`,!0))},void 0,!1)]},void 0,!0)]},void 0,!0),(0,r.jsxDEV)(S,{className:"gap-0 py-0",children:[(0,r.jsxDEV)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")},void 0,!1),(0,r.jsxDEV)(A,{"data-testid":"hl-shard-count",variant:"outline",children:y.length},void 0,!1)]},void 0,!0),y.length>0&&(0,r.jsxDEV)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:y.map(o=>(0,r.jsxDEV)("li",{"data-testid":"hl-shard",children:(0,r.jsxDEV)(A,{variant:"secondary",children:o},void 0,!1)},o,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)},"HealthPanel");export{ht as HealthPanel};
@@ -0,0 +1 @@
1
+ import{a as $}from"./chunk-WXPWVBIY.js";import{a as W}from"./chunk-TDL7NEWA.js";import{a as _}from"./chunk-2K47A3P6.js";import{a as q}from"./chunk-AJIUI7DD.js";import"./chunk-XNJNSCLM.js";import{a as G,b as P,c as V,d as b,e as i,f as o}from"./chunk-GTM65MVX.js";import{a as y}from"./chunk-JSEXCW5Q.js";import{a as U}from"./chunk-K3GNLVYK.js";import{b as Q}from"./chunk-TBMYIZIO.js";import{R as w}from"./chunk-3CJW6NWG.js";import{c as L}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-HV7G6DFP.js";import{a as g}from"./chunk-AQGOX5DK.js";import{a as A}from"./chunk-TAD43CG5.js";import{b as H}from"./chunk-DVKPRFIJ.js";import{a as k,e as B}from"./chunk-SEU5V7I6.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{f as M}from"./chunk-X7MMBSNW.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as S,e as F,f as K,g as O,k as j,n as z}from"./chunk-PVZI3CXP.js";import"./chunk-GMSGZDDH.js";import{a as n,e as D,f as le,h as ce}from"./chunk-RRCPZMC2.js";var a=D(le(),1);var e=D(ce(),1);var ue=F(g.runMigration),we=n(({initialShardKey:J})=>{let X=M(),r=S(),[c,Y]=(0,a.useState)(J??""),[x,Z]=(0,a.useState)(""),[R,ee]=(0,a.useState)("up"),[f,re]=(0,a.useState)(!0),[u,N]=(0,a.useState)(!1),[d,h]=(0,a.useState)(null),[C,p]=(0,a.useState)(null),m=_(c.trim(),400),I=c.trim()===m,s=H(g.migrationStatus,{},{live:!0,shardKey:m}),l=s.data?.migrations??null,te=s.error,{errorSource:ae,liveError:ie}=s;(0,a.useEffect)(()=>{s.data!==void 0&&Q(m)},[s.data,m]);let oe=n(async()=>{let t=x.trim();if(t===""){p(r("Enter a migration id")),h(null);return}N(!0),p(null);try{let v=await X.query(ue,{direction:R,dryRun:f,id:t},K(c));h(v),s.refetch()}catch(v){h(null),p(O(v))}finally{N(!1)}},"run"),E=n(()=>{j(oe())},"runMigration"),ne=n(t=>{Z(t.target.value)},"onIdChange"),se=n(t=>{ee(t.target.value==="down"?"down":"up")},"onDirectionChange"),de=n(t=>{re(t.target.checked)},"onDryRunChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-migrations",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(U,{onChange:Y,testId:"mg-shard-input",value:c},void 0,!1),(0,e.jsxDEV)($,{message:ie,prefix:"mg"},void 0,!1)]},void 0,!0),te!==null&&(0,e.jsxDEV)(q,{error:ae,testId:"mg-status-error"},void 0,!1),l!==null&&l.length===0&&(0,e.jsxDEV)(A,{description:r("Data migrations you run against this shard will be tracked here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"},void 0,!1)},void 0,!1),testId:"mg-empty",title:r("No migrations have run on this shard.")},void 0,!1),l!==null&&l.length>0&&(0,e.jsxDEV)(k,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(B,{className:"px-0",children:(0,e.jsxDEV)(G,{"data-testid":"mg-table",children:[(0,e.jsxDEV)(P,{children:(0,e.jsxDEV)(b,{children:[(0,e.jsxDEV)(i,{children:r("id")},void 0,!1),(0,e.jsxDEV)(i,{children:r("direction")},void 0,!1),(0,e.jsxDEV)(i,{children:r("status")},void 0,!1),(0,e.jsxDEV)(i,{children:r("processed")},void 0,!1),(0,e.jsxDEV)(i,{children:r("changed")},void 0,!1),(0,e.jsxDEV)(i,{children:r("updated")},void 0,!1),(0,e.jsxDEV)(i,{children:r("error")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(V,{children:l.map(t=>(0,e.jsxDEV)(b,{"data-testid":`mg-row-${t.id}`,children:[(0,e.jsxDEV)(o,{children:t.id},void 0,!1),(0,e.jsxDEV)(o,{children:t.direction},void 0,!1),(0,e.jsxDEV)(o,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:t.status},void 0,!1)},void 0,!1),(0,e.jsxDEV)(o,{children:t.processed},void 0,!1),(0,e.jsxDEV)(o,{children:t.changed},void 0,!1),(0,e.jsxDEV)(o,{children:z(t.updatedAt)},void 0,!1),(0,e.jsxDEV)(o,{children:t.error??""},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsxDEV)(y,{children:r("Run migration")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(w,{"aria-label":r("Migration id"),className:"w-auto","data-testid":"mg-id-input",onChange:ne,placeholder:r("migration id"),value:x},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":r("Direction"),className:"flex h-9 rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"mg-direction",onChange:se,value:R,children:[(0,e.jsxDEV)("option",{value:"up",children:r("up")},void 0,!1),(0,e.jsxDEV)("option",{value:"down",children:r("down")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(y,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[(0,e.jsxDEV)("input",{checked:f,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:de,type:"checkbox"},void 0,!1),r("Dry run")]},void 0,!0),f?(0,e.jsxDEV)(L,{"data-testid":"mg-run",disabled:u||!I,onClick:E,size:"sm",type:"button",children:r(u?"Running\u2026":"Run")},void 0,!1):(0,e.jsxDEV)(W,{confirmLabel:r(u?"Running\u2026":"Run migration?"),disabled:u||!I,onConfirm:E,testId:"mg-run",children:r("Run")},void 0,!1)]},void 0,!0)]},void 0,!0),C!==null&&(0,e.jsxDEV)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:C},void 0,!1),d!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[d.dryRun?r("Dry run: "):"",r("{status} \u2014 processed",{status:d.status}),d.processed,r(", changed"),d.changed]},void 0,!0)]},void 0,!0)},"MigrationsPanel");export{we as MigrationsPanel};