@lunora/studio 1.0.0-alpha.391 → 1.0.0-alpha.392

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 (107) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/packem_chunks/ai-knowledge.mjs +1 -1
  4. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  5. package/dist/standalone/{chunk-3IGIBOCF.js → chunk-22C2K5PS.js} +1 -1
  6. package/dist/standalone/{chunk-EMZ7RPR3.js → chunk-2CMHGYZ4.js} +1 -1
  7. package/dist/standalone/{chunk-Y5QMX4YG.js → chunk-2XAJCKRP.js} +1 -1
  8. package/dist/standalone/{chunk-WODOEE2A.js → chunk-34USSEJN.js} +1 -1
  9. package/dist/standalone/{chunk-ADS4BJ7K.js → chunk-3HVF5LKQ.js} +1 -1
  10. package/dist/standalone/{chunk-EAYN3IGE.js → chunk-3RCYH6UA.js} +1 -1
  11. package/dist/standalone/{chunk-OG7AJWFV.js → chunk-3YBXNEUY.js} +1 -1
  12. package/dist/standalone/{chunk-SKK6PGQ3.js → chunk-4YZAJTU5.js} +1 -1
  13. package/dist/standalone/{chunk-LQWEU5ZI.js → chunk-5D73GSOC.js} +1 -1
  14. package/dist/standalone/{chunk-K2LXQ3LS.js → chunk-5FFKYQHT.js} +1 -1
  15. package/dist/standalone/{chunk-TS4CMM2L.js → chunk-6HZDJA4T.js} +1 -1
  16. package/dist/standalone/{chunk-3K56NZDT.js → chunk-6IDVWVML.js} +1 -1
  17. package/dist/standalone/{chunk-LIZUJ6AU.js → chunk-6WTQL4W2.js} +1 -1
  18. package/dist/standalone/{chunk-PPC2ESMI.js → chunk-6YDEXJRE.js} +1 -1
  19. package/dist/standalone/{chunk-Y34WXKCA.js → chunk-725JLR43.js} +1 -1
  20. package/dist/standalone/{chunk-DRFBJBEN.js → chunk-7ELEYWJC.js} +1 -1
  21. package/dist/standalone/{chunk-ATBPQT7F.js → chunk-7ML357XR.js} +1 -1
  22. package/dist/standalone/{chunk-NNKVZBKP.js → chunk-7UPL6MQR.js} +1 -1
  23. package/dist/standalone/{chunk-V3DOKU22.js → chunk-7Z243YUE.js} +1 -1
  24. package/dist/standalone/{chunk-VQQEDEHH.js → chunk-ACCTEC6Y.js} +1 -1
  25. package/dist/standalone/{chunk-V5TGDG6U.js → chunk-AJFMXVR4.js} +1 -1
  26. package/dist/standalone/{chunk-NMZ34D2Z.js → chunk-ANHHDGNL.js} +1 -1
  27. package/dist/standalone/{chunk-4YWFAODW.js → chunk-ATYVKUH7.js} +1 -1
  28. package/dist/standalone/{chunk-3WYPRZY3.js → chunk-AZ6QNL6G.js} +1 -1
  29. package/dist/standalone/{chunk-ZQ7KYIN6.js → chunk-B34JDEEO.js} +1 -1
  30. package/dist/standalone/{chunk-4ZEERXMN.js → chunk-BFEX6HDU.js} +1 -1
  31. package/dist/standalone/{chunk-FR22DHUN.js → chunk-BKKE4QKE.js} +1 -1
  32. package/dist/standalone/{chunk-2ZJJH4YN.js → chunk-CDIV23I2.js} +2 -2
  33. package/dist/standalone/{chunk-Z3AINTU6.js → chunk-COMBKDVY.js} +1 -1
  34. package/dist/standalone/{chunk-CP3LCFFM.js → chunk-D63EYK5I.js} +1 -1
  35. package/dist/standalone/{chunk-Q6VRHDZJ.js → chunk-D7UOJY4N.js} +1 -1
  36. package/dist/standalone/{chunk-WMKSIEJP.js → chunk-DW5KLXPI.js} +1 -1
  37. package/dist/standalone/{chunk-EGUFPKS4.js → chunk-DYPC464U.js} +1 -1
  38. package/dist/standalone/{chunk-BBJJJI7F.js → chunk-E3IVOZVW.js} +1 -1
  39. package/dist/standalone/{chunk-CFQQHZYU.js → chunk-EFEAOMEB.js} +1 -1
  40. package/dist/standalone/{chunk-SKMAKUOG.js → chunk-EMNOVYZC.js} +1 -1
  41. package/dist/standalone/{chunk-KRSQ6N4R.js → chunk-EXHVWM27.js} +1 -1
  42. package/dist/standalone/{chunk-MNN3YCKF.js → chunk-EYBS3Q7O.js} +1 -1
  43. package/dist/standalone/{chunk-WXZ334CL.js → chunk-EZ5PVGPY.js} +1 -1
  44. package/dist/standalone/{chunk-PTL32GA6.js → chunk-FNBNPTCM.js} +1 -1
  45. package/dist/standalone/{chunk-EZMAQE3T.js → chunk-FT5WEK3S.js} +1 -1
  46. package/dist/standalone/{chunk-CQDENTSP.js → chunk-GVPVWT3Q.js} +1 -1
  47. package/dist/standalone/{chunk-HQZ7B5EU.js → chunk-H2HGJURT.js} +1 -1
  48. package/dist/standalone/{chunk-7Z5MTBZB.js → chunk-HWG2R642.js} +1 -1
  49. package/dist/standalone/{chunk-W6UUGZH7.js → chunk-HYAGF6A5.js} +1 -1
  50. package/dist/standalone/{chunk-B3GOYA2R.js → chunk-I37WFNA6.js} +1 -1
  51. package/dist/standalone/{chunk-LOEVTOKP.js → chunk-IFU5WQHZ.js} +1 -1
  52. package/dist/standalone/{chunk-APCHI5CD.js → chunk-INDH6PRB.js} +1 -1
  53. package/dist/standalone/{chunk-HB6ABGZU.js → chunk-JKTAHFTK.js} +1 -1
  54. package/dist/standalone/{chunk-23MMGFHI.js → chunk-JPL3WAVW.js} +1 -1
  55. package/dist/standalone/chunk-K2I3AGZR.js +1 -0
  56. package/dist/standalone/{chunk-24N5RZRI.js → chunk-KBPMT33Z.js} +1 -1
  57. package/dist/standalone/{chunk-ZJIYJZ6F.js → chunk-KMBE7RTC.js} +1 -1
  58. package/dist/standalone/{chunk-E7QYOQWH.js → chunk-KULAZ4W3.js} +1 -1
  59. package/dist/standalone/{chunk-KYZZGUIG.js → chunk-LEF32Q5K.js} +1 -1
  60. package/dist/standalone/{chunk-YLC2ZYCL.js → chunk-LFWS6VBU.js} +1 -1
  61. package/dist/standalone/{chunk-H54J65DJ.js → chunk-MA2KXG2L.js} +1 -1
  62. package/dist/standalone/{chunk-GERWUNAM.js → chunk-MPGM6L64.js} +1 -1
  63. package/dist/standalone/{chunk-MKH4V2DR.js → chunk-MVWMRJD5.js} +1 -1
  64. package/dist/standalone/{chunk-2QYMVMYR.js → chunk-N4P6WYRV.js} +1 -1
  65. package/dist/standalone/{chunk-6C555TU5.js → chunk-NP6H72XD.js} +1 -1
  66. package/dist/standalone/{chunk-XV2XEUUB.js → chunk-NPHGFVNE.js} +1 -1
  67. package/dist/standalone/{chunk-73D52JHL.js → chunk-NRWR25MB.js} +1 -1
  68. package/dist/standalone/{chunk-HMMALUXM.js → chunk-O46IV64X.js} +1 -1
  69. package/dist/standalone/{chunk-GTJYJW4A.js → chunk-O56AZXG6.js} +1 -1
  70. package/dist/standalone/{chunk-BHUWAGFN.js → chunk-OOPMRFI2.js} +1 -1
  71. package/dist/standalone/chunk-OZUPOUHR.js +1 -0
  72. package/dist/standalone/{chunk-O66HDCZT.js → chunk-PLDE5R5Y.js} +1 -1
  73. package/dist/standalone/{chunk-NAGIOR23.js → chunk-PRVBT5AJ.js} +1 -1
  74. package/dist/standalone/{chunk-FKF2BRRN.js → chunk-PUTERXSU.js} +1 -1
  75. package/dist/standalone/{chunk-NTVQ4PWU.js → chunk-PYG3TDLZ.js} +1 -1
  76. package/dist/standalone/{chunk-CBTPJPCZ.js → chunk-QHI77TGI.js} +1 -1
  77. package/dist/standalone/{chunk-SQ3M7JDP.js → chunk-QIROOZNJ.js} +1 -1
  78. package/dist/standalone/{chunk-KZXAVLQ4.js → chunk-QMZKJK53.js} +1 -1
  79. package/dist/standalone/{chunk-FGHKL42J.js → chunk-RIHWRGFS.js} +1 -1
  80. package/dist/standalone/{chunk-FKAOFBS3.js → chunk-RN32N6ZO.js} +1 -1
  81. package/dist/standalone/{chunk-ZLAVM2NT.js → chunk-RTD3B67U.js} +1 -1
  82. package/dist/standalone/{chunk-QJFCK6J4.js → chunk-RUCMNPTD.js} +1 -1
  83. package/dist/standalone/{chunk-CDJMXV45.js → chunk-RZJAZ5ED.js} +1 -1
  84. package/dist/standalone/{chunk-EHU26D2V.js → chunk-S64V5MAT.js} +1 -1
  85. package/dist/standalone/{chunk-MAWEZEX6.js → chunk-TFH347JK.js} +1 -1
  86. package/dist/standalone/{chunk-2G7JHC6S.js → chunk-TJ76NZTD.js} +1 -1
  87. package/dist/standalone/{chunk-UYW53K2N.js → chunk-TJV64AXT.js} +1 -1
  88. package/dist/standalone/{chunk-WLMTK3FN.js → chunk-TVDBLCXQ.js} +1 -1
  89. package/dist/standalone/{chunk-VJGP3BTD.js → chunk-TVJFKXX4.js} +1 -1
  90. package/dist/standalone/{chunk-4RII5S3H.js → chunk-UDKKUJHY.js} +1 -1
  91. package/dist/standalone/{chunk-W5BTAOHO.js → chunk-UEONVTOV.js} +1 -1
  92. package/dist/standalone/{chunk-JQBVRWFN.js → chunk-UNUSBFIC.js} +1 -1
  93. package/dist/standalone/{chunk-LLD7TMBV.js → chunk-UQ3WOVL2.js} +1 -1
  94. package/dist/standalone/{chunk-YDFZA3T4.js → chunk-UW34S35F.js} +1 -1
  95. package/dist/standalone/{chunk-UL5XVKGR.js → chunk-XHDCFSC6.js} +1 -1
  96. package/dist/standalone/{chunk-BULGXI7X.js → chunk-XKK5ABPC.js} +1 -1
  97. package/dist/standalone/{chunk-I2XT2POX.js → chunk-XYWMQVZ2.js} +1 -1
  98. package/dist/standalone/chunk-YESGXFAR.js +7 -0
  99. package/dist/standalone/{chunk-2D4WBSDO.js → chunk-Z6PYAG36.js} +1 -1
  100. package/dist/standalone/{chunk-BWHVY6L6.js → chunk-Z7ZRXPPE.js} +1 -1
  101. package/dist/standalone/{chunk-LLSK6QBX.js → chunk-ZHDO7DYM.js} +1 -1
  102. package/dist/standalone/{chunk-EYSF4DHD.js → chunk-ZIY53FID.js} +1 -1
  103. package/dist/standalone/studio.js +1 -1
  104. package/package.json +1 -1
  105. package/dist/standalone/chunk-C6FOSG2A.js +0 -7
  106. package/dist/standalone/chunk-IL64HWFW.js +0 -1
  107. package/dist/standalone/chunk-IPDJJHZK.js +0 -1
@@ -1 +1 @@
1
- import{x as d}from"./chunk-2ZJJH4YN.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
1
+ import{x as d}from"./chunk-CDIV23I2.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as i}from"./chunk-ADABTCDI.js";import{a as c,d as b}from"./chunk-5PEAXTYQ.js";var n=b(m(),1);var o=b(i(),1);function p(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("w-full caption-bottom text-xs",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto overflow-y-clip",children:(0,o.jsx)("table",{"data-slot":"table",className:l,...a})}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(p,"f");function f(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("bg-muted/50 [&_tr]:border-b",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("thead",{"data-slot":"table-header",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(f,"p");function h(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("[&_tr:last-child]:border-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tbody",{"data-slot":"table-body",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(h,"m");function x(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("tr",{"data-slot":"table-row",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(x,"u");function N(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("h-9 border-e border-border px-3 text-start align-middle font-mono text-[11px] font-medium tracking-wide whitespace-nowrap text-muted-foreground uppercase last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("th",{"data-slot":"table-head",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(N,"h");function w(r){let e=(0,n.c)(8),t,a;e[0]!==r?({className:t,...a}=r,e[0]=r,e[1]=t,e[2]=a):(t=e[1],a=e[2]);let l;e[3]!==t?(l=d("border-e border-border px-3 py-1.5 align-middle whitespace-nowrap last:border-e-0 [&:has([role=checkbox])]:pe-0",t),e[3]=t,e[4]=l):l=e[4];let s;return e[5]!==a||e[6]!==l?(s=(0,o.jsx)("td",{"data-slot":"table-cell",className:l,...a}),e[5]=a,e[6]=l,e[7]=s):s=e[7],s}c(w,"x");export{p as a,f as b,h as c,x as d,N as e,w as f};
@@ -1 +1 @@
1
- import{a as N}from"./chunk-HMMALUXM.js";import{b as x}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as y}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-6C555TU5.js";import{a as g,e as v}from"./chunk-XV2XEUUB.js";import"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as f}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{b as T}from"./chunk-ADABTCDI.js";import{a as n,d as R}from"./chunk-5PEAXTYQ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),K=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=f(),{data:l,error:E,errorSource:A,liveError:I}=p(u.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(N,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(g,{className:"overflow-hidden py-0",children:(0,e.jsx)(v,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=K(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(x,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,shardKey:a,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
1
+ import{a as N}from"./chunk-O46IV64X.js";import{b as x}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as y}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as w,b,c as S,d as c,e as s,f as o}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as u}from"./chunk-LYVYUTQY.js";import{c as p}from"./chunk-NP6H72XD.js";import{a as g,e as v}from"./chunk-NPHGFVNE.js";import"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as f}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import"./chunk-A6TVTNKO.js";import{b as T}from"./chunk-ADABTCDI.js";import{a as n,d as R}from"./chunk-5PEAXTYQ.js";var e=R(T(),1);var $={active:"default",failing:"destructive",idle:"secondary"},j=n(a=>a===void 0?"\u2014":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,"I"),K=n(a=>{let t=a.runs+a.suppressed;return t===0?void 0:Math.round(a.suppressed/t*100)},"$"),F=n(({initialShardKey:a=""})=>{let t=f(),{data:l,error:E,errorSource:A,liveError:I}=p(u.listReactors,{},{live:!0,shardKey:a}),C=l!==void 0,i=Array.isArray(l?.reactors)?l.reactors:[],d;C&&i.length===0?d=(0,e.jsx)(N,{description:t("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:t("No reactors declared")}):d=(0,e.jsx)(g,{className:"overflow-hidden py-0",children:(0,e.jsx)(v,{className:"px-0",children:(0,e.jsxs)(w,{"data-testid":"reactors-table",children:[(0,e.jsx)(b,{children:(0,e.jsxs)(c,{children:[(0,e.jsx)(s,{children:t("Reactor")}),(0,e.jsx)(s,{children:t("State")}),(0,e.jsx)(s,{children:t("Ran")}),(0,e.jsx)(s,{children:t("Suppressed")}),(0,e.jsx)(s,{children:t("Errors")}),(0,e.jsx)(s,{children:t("Watches")}),(0,e.jsx)(s,{children:t("Last dispatch")})]})}),(0,e.jsx)(S,{children:i.map(r=>{let m=K(r);return(0,e.jsxs)(c,{"data-testid":`reactors-row-${r.path}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:r.path}),(0,e.jsx)(o,{children:(0,e.jsx)(x,{"data-testid":`reactors-state-${r.path}`,variant:$[r.state],children:r.state})}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.runs}),(0,e.jsxs)(o,{className:"font-mono text-xs text-muted-foreground",children:[r.suppressed,m===void 0?"":` (${String(m)}%)`]}),(0,e.jsx)(o,{className:"font-mono text-xs",children:r.errors===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"0"}):(0,e.jsx)("span",{className:"text-destructive",children:r.errors})}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:r.tables===void 0||r.tables.length===0?"\u2014":r.tables.join(", ")}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:j(r.lastRanAt)})]},r.path)})})]})})});let h=i.filter(r=>r.state==="failing");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[E!==null&&(0,e.jsx)(y,{error:A,shardKey:a,testId:"reactors-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("A reactor runs after a write flush, but only when the result of the query it watches actually changed \u2014 a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),h.length>0&&(0,e.jsx)("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:h.map(r=>(0,e.jsxs)("p",{className:"text-xs text-destructive",role:"alert",children:[(0,e.jsx)("span",{className:"font-mono",children:r.path}),": ",r.lastError??t("last dispatch failed")]},r.path))}),I!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:t("Live updates unavailable; showing the last reading.")}),d]})},"U");export{F as default};
@@ -1 +1 @@
1
- import{a as re}from"./chunk-NAGIOR23.js";import{a as X}from"./chunk-2KTN53PK.js";import{a as V}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as W}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Q}from"./chunk-HMMALUXM.js";import{b as G}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Y}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as Z,b as ee,c as te,d as P,e as n,f as o}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as R}from"./chunk-LYVYUTQY.js";import{c as O}from"./chunk-6C555TU5.js";import{a as H,e as J}from"./chunk-XV2XEUUB.js";import"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as U,w as z,x as L}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as de,b as he}from"./chunk-ADABTCDI.js";import{a as l,d as B}from"./chunk-5PEAXTYQ.js";var se=B(me(),1),le=B(de(),1);var t=B(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},ae=l(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"q"),fe=l(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=l(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:l((r,e)=>e.calls-r.calls,"calls"),recent:l((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:l((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},De=l(r=>{let e=(0,se.c)(49),{functions:_,initialShardKey:ne}=r,s=U(),{queryShardKey:i,setShardKey:v,shardKey:S}=X(ne),[c,oe]=(0,le.useState)("recent"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C={},e[0]=C):C=e[0];let $;e[1]!==i?($={live:!0,shardKey:i},e[1]=i,e[2]=$):$=e[2];let{data:ie,error:d,errorSource:b,liveError:k}=O(R.getFunctionStats,C,$),M=ie?.functions??null,F;e[3]!==_?(F=new Map((_??[]).map(ge)),e[3]=_,e[4]=F):F=e[4];let T=F,I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=l(w=>{oe(w.currentTarget.dataset.sort)},"E"),e[5]=I):I=e[5];let ce=I,K;if(e[6]!==d||e[7]!==b||e[8]!==T||e[9]!==k||e[10]!==i||e[11]!==v||e[12]!==S||e[13]!==c||e[14]!==M||e[15]!==s){let w=M===null?[]:M.toSorted(xe[c]),m;e[17]!==s?(m=s("Recent"),e[17]=s,e[18]=m):m=e[18];let h;e[19]!==m?(h={key:"recent",label:m},e[19]=m,e[20]=h):h=e[20];let u;e[21]!==s?(u=s("Most called"),e[21]=s,e[22]=u):u=e[22];let f;e[23]!==u?(f={key:"calls",label:u},e[23]=u,e[24]=f):f=e[24];let p;e[25]!==s?(p=s("Slowest"),e[25]=s,e[26]=p):p=e[26];let x;e[27]!==p?(x={key:"slowest",label:p},e[27]=p,e[28]=x):x=e[28];let A;e[29]!==x||e[30]!==h||e[31]!==f?(A=[h,f,x],e[29]=x,e[30]=h,e[31]=f,e[32]=A):A=e[32];let j=A,g;e[33]!==v||e[34]!==S?(g=(0,t.jsx)(V,{onChange:v,testId:"fs-shard-input",value:S}),e[33]=v,e[34]=S,e[35]=g):g=e[35];let y;e[36]!==k?(y=(0,t.jsx)(re,{message:k,prefix:"fs"}),e[36]=k,e[37]=y):y=e[37];let N;e[38]!==j||e[39]!==c?(N=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:j.map(a=>(0,t.jsx)(W,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:ce,size:"sm",type:"button",variant:c===a.key?"secondary":"ghost",children:a.label},a.key))}),e[38]=j,e[39]=c,e[40]=N):N=e[40];let D;e[41]!==g||e[42]!==y||e[43]!==N?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,y,N]}),e[41]=g,e[42]=y,e[43]=N,e[44]=D):D=e[44];let E;e[45]!==d||e[46]!==b||e[47]!==i?(E=d!==null&&(0,t.jsx)(Y,{error:b,shardKey:i,testId:"fs-error"}),e[45]=d,e[46]=b,e[47]=i,e[48]=E):E=e[48],K=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,M!==null&&w.length===0&&d===null&&(0,t.jsx)(Q,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),w.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(J,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(n,{children:s("function")}),(0,t.jsx)(n,{children:s("kind")}),(0,t.jsx)(n,{className:"text-right",children:s("calls")}),(0,t.jsx)(n,{className:"text-right",children:s("errors")}),(0,t.jsx)(n,{className:"text-right",children:s("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:s("avg")}),(0,t.jsx)(n,{className:"text-right",children:s("max")}),(0,t.jsx)(n,{children:s("last run")}),(0,t.jsx)(n,{children:s("last error")})]})}),(0,t.jsx)(te,{children:w.map(a=>{let q=T.get(a.path);return(0,t.jsxs)(P,{"data-testid":`fs-row-${a.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:a.path}),(0,t.jsx)(o,{children:q===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(G,{variant:ue[q],children:q})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls}),(0,t.jsx)(o,{className:L("text-right tabular-nums",a.errors>0&&"text-destructive"),children:fe(a)}),(0,t.jsx)(o,{className:L("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:pe(a)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.totalDurationMs/a.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:z(a.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.path)})})]})})})]}),e[6]=d,e[7]=b,e[8]=T,e[9]=k,e[10]=i,e[11]=v,e[12]=S,e[13]=c,e[14]=M,e[15]=s,e[16]=K}else K=e[16];return K},"Ae");function ge(r){return[r.path,r.kind]}l(ge,"fe");export{De as FunctionStatsPanel};
1
+ import{a as re}from"./chunk-PRVBT5AJ.js";import{a as X}from"./chunk-2KTN53PK.js";import{a as V}from"./chunk-LFWS6VBU.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as W}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Q}from"./chunk-O46IV64X.js";import{b as G}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as Y}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as Z,b as ee,c as te,d as P,e as n,f as o}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as R}from"./chunk-LYVYUTQY.js";import{c as O}from"./chunk-NP6H72XD.js";import{a as H,e as J}from"./chunk-NPHGFVNE.js";import"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as U,w as z,x as L}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as de,b as he}from"./chunk-ADABTCDI.js";import{a as l,d as B}from"./chunk-5PEAXTYQ.js";var se=B(me(),1),le=B(de(),1);var t=B(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},ae=l(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"q"),fe=l(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=l(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:l((r,e)=>e.calls-r.calls,"calls"),recent:l((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:l((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},De=l(r=>{let e=(0,se.c)(49),{functions:_,initialShardKey:ne}=r,s=U(),{queryShardKey:i,setShardKey:v,shardKey:S}=X(ne),[c,oe]=(0,le.useState)("recent"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C={},e[0]=C):C=e[0];let $;e[1]!==i?($={live:!0,shardKey:i},e[1]=i,e[2]=$):$=e[2];let{data:ie,error:d,errorSource:b,liveError:k}=O(R.getFunctionStats,C,$),M=ie?.functions??null,F;e[3]!==_?(F=new Map((_??[]).map(ge)),e[3]=_,e[4]=F):F=e[4];let T=F,I;e[5]===Symbol.for("react.memo_cache_sentinel")?(I=l(w=>{oe(w.currentTarget.dataset.sort)},"E"),e[5]=I):I=e[5];let ce=I,K;if(e[6]!==d||e[7]!==b||e[8]!==T||e[9]!==k||e[10]!==i||e[11]!==v||e[12]!==S||e[13]!==c||e[14]!==M||e[15]!==s){let w=M===null?[]:M.toSorted(xe[c]),m;e[17]!==s?(m=s("Recent"),e[17]=s,e[18]=m):m=e[18];let h;e[19]!==m?(h={key:"recent",label:m},e[19]=m,e[20]=h):h=e[20];let u;e[21]!==s?(u=s("Most called"),e[21]=s,e[22]=u):u=e[22];let f;e[23]!==u?(f={key:"calls",label:u},e[23]=u,e[24]=f):f=e[24];let p;e[25]!==s?(p=s("Slowest"),e[25]=s,e[26]=p):p=e[26];let x;e[27]!==p?(x={key:"slowest",label:p},e[27]=p,e[28]=x):x=e[28];let A;e[29]!==x||e[30]!==h||e[31]!==f?(A=[h,f,x],e[29]=x,e[30]=h,e[31]=f,e[32]=A):A=e[32];let j=A,g;e[33]!==v||e[34]!==S?(g=(0,t.jsx)(V,{onChange:v,testId:"fs-shard-input",value:S}),e[33]=v,e[34]=S,e[35]=g):g=e[35];let y;e[36]!==k?(y=(0,t.jsx)(re,{message:k,prefix:"fs"}),e[36]=k,e[37]=y):y=e[37];let N;e[38]!==j||e[39]!==c?(N=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:j.map(a=>(0,t.jsx)(W,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:ce,size:"sm",type:"button",variant:c===a.key?"secondary":"ghost",children:a.label},a.key))}),e[38]=j,e[39]=c,e[40]=N):N=e[40];let D;e[41]!==g||e[42]!==y||e[43]!==N?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,y,N]}),e[41]=g,e[42]=y,e[43]=N,e[44]=D):D=e[44];let E;e[45]!==d||e[46]!==b||e[47]!==i?(E=d!==null&&(0,t.jsx)(Y,{error:b,shardKey:i,testId:"fs-error"}),e[45]=d,e[46]=b,e[47]=i,e[48]=E):E=e[48],K=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,M!==null&&w.length===0&&d===null&&(0,t.jsx)(Q,{description:s("Per-function call counts, error rates, and latency land here after your first request."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),w.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(J,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(n,{children:s("function")}),(0,t.jsx)(n,{children:s("kind")}),(0,t.jsx)(n,{className:"text-right",children:s("calls")}),(0,t.jsx)(n,{className:"text-right",children:s("errors")}),(0,t.jsx)(n,{className:"text-right",children:s("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:s("avg")}),(0,t.jsx)(n,{className:"text-right",children:s("max")}),(0,t.jsx)(n,{children:s("last run")}),(0,t.jsx)(n,{children:s("last error")})]})}),(0,t.jsx)(te,{children:w.map(a=>{let q=T.get(a.path);return(0,t.jsxs)(P,{"data-testid":`fs-row-${a.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:a.path}),(0,t.jsx)(o,{children:q===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(G,{variant:ue[q],children:q})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls}),(0,t.jsx)(o,{className:L("text-right tabular-nums",a.errors>0&&"text-destructive"),children:fe(a)}),(0,t.jsx)(o,{className:L("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:pe(a)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.totalDurationMs/a.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:z(a.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.path)})})]})})})]}),e[6]=d,e[7]=b,e[8]=T,e[9]=k,e[10]=i,e[11]=v,e[12]=S,e[13]=c,e[14]=M,e[15]=s,e[16]=K}else K=e[16];return K},"Ae");function ge(r){return[r.path,r.kind]}l(ge,"fe");export{De as FunctionStatsPanel};
@@ -1 +1 @@
1
- import{a as k}from"./chunk-EDL46BPM.js";import{i as j}from"./chunk-2D4WBSDO.js";import{B as b}from"./chunk-2ZJJH4YN.js";import{a as $}from"./chunk-A6TVTNKO.js";import{a as w,b as A}from"./chunk-ADABTCDI.js";import{a as m,d as S}from"./chunk-5PEAXTYQ.js";var y=S($(),1),h=S(w(),1);var a=S(A(),1);var z=m(i=>{let t=(0,y.c)(21),{id:f,onChange:g,testId:e,value:v}=i,s=b(),u=(0,h.useId)(),[d]=(0,h.useState)(F),c;t[0]!==g?(c=m(C=>{g(C.target.value)},"d"),t[0]=g,t[1]=c):c=t[1];let I=c,o;t[2]!==s?(o=s("Shard key"),t[2]=s,t[3]=o):o=t[3];let x=d.length>0?u:void 0,r;t[4]!==s?(r=s("shard key (optional)"),t[4]=s,t[5]=r):r=t[5];let l;t[6]!==f||t[7]!==I||t[8]!==o||t[9]!==x||t[10]!==r||t[11]!==e||t[12]!==v?(l=(0,a.jsx)(j,{"aria-label":o,className:"h-8 w-48","data-testid":e,id:f,list:x,onChange:I,placeholder:r,value:v}),t[6]=f,t[7]=I,t[8]=o,t[9]=x,t[10]=r,t[11]=e,t[12]=v,t[13]=l):l=t[13];let n;t[14]!==u||t[15]!==d||t[16]!==e?(n=d.length>0&&(0,a.jsx)("datalist",{"data-testid":`${e}-recents`,id:u,children:d.map(N)}),t[14]=u,t[15]=d,t[16]=e,t[17]=n):n=t[17];let p;return t[18]!==l||t[19]!==n?(p=(0,a.jsxs)(a.Fragment,{children:[l,n]}),t[18]=l,t[19]=n,t[20]=p):p=t[20],p},"A");function F(){return k()}m(F,"$");function N(i){return(0,a.jsx)("option",{"aria-label":i,value:i},i)}m(N,"w");export{z as a};
1
+ import{a as k}from"./chunk-EDL46BPM.js";import{i as j}from"./chunk-Z6PYAG36.js";import{B as b}from"./chunk-CDIV23I2.js";import{a as $}from"./chunk-A6TVTNKO.js";import{a as w,b as A}from"./chunk-ADABTCDI.js";import{a as m,d as S}from"./chunk-5PEAXTYQ.js";var y=S($(),1),h=S(w(),1);var a=S(A(),1);var z=m(i=>{let t=(0,y.c)(21),{id:f,onChange:g,testId:e,value:v}=i,s=b(),u=(0,h.useId)(),[d]=(0,h.useState)(F),c;t[0]!==g?(c=m(C=>{g(C.target.value)},"d"),t[0]=g,t[1]=c):c=t[1];let I=c,o;t[2]!==s?(o=s("Shard key"),t[2]=s,t[3]=o):o=t[3];let x=d.length>0?u:void 0,r;t[4]!==s?(r=s("shard key (optional)"),t[4]=s,t[5]=r):r=t[5];let l;t[6]!==f||t[7]!==I||t[8]!==o||t[9]!==x||t[10]!==r||t[11]!==e||t[12]!==v?(l=(0,a.jsx)(j,{"aria-label":o,className:"h-8 w-48","data-testid":e,id:f,list:x,onChange:I,placeholder:r,value:v}),t[6]=f,t[7]=I,t[8]=o,t[9]=x,t[10]=r,t[11]=e,t[12]=v,t[13]=l):l=t[13];let n;t[14]!==u||t[15]!==d||t[16]!==e?(n=d.length>0&&(0,a.jsx)("datalist",{"data-testid":`${e}-recents`,id:u,children:d.map(N)}),t[14]=u,t[15]=d,t[16]=e,t[17]=n):n=t[17];let p;return t[18]!==l||t[19]!==n?(p=(0,a.jsxs)(a.Fragment,{children:[l,n]}),t[18]=l,t[19]=n,t[20]=p):p=t[20],p},"A");function F(){return k()}m(F,"$");function N(i){return(0,a.jsx)("option",{"aria-label":i,value:i},i)}m(N,"w");export{z as a};
@@ -1 +1 @@
1
- import{d as E,e as _}from"./chunk-FWM5Z6CH.js";import{a as $}from"./chunk-3WYPRZY3.js";import{a as de}from"./chunk-K2LXQ3LS.js";import"./chunk-EZMAQE3T.js";import{a as ce}from"./chunk-V3DOKU22.js";import"./chunk-QLZGKBOW.js";import"./chunk-Y2YLTUMD.js";import"./chunk-R3RIZDUS.js";import{a as le}from"./chunk-2KTN53PK.js";import{a as re}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as ae}from"./chunk-HMMALUXM.js";import{b as K}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as ie}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as R,b as W,c as Z,d as A,e as M,f as S}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as D}from"./chunk-6C555TU5.js";import{a as q,b as H,c as J,e as ne}from"./chunk-XV2XEUUB.js";import"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as F,w as oe}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{b as ge}from"./chunk-ADABTCDI.js";import{a as p,d as se}from"./chunk-5PEAXTYQ.js";var O=se(be(),1);var o=se(ge(),1);var G="gen_ai.usage.input_tokens",Q="gen_ai.usage.output_tokens",V="gen_ai.usage.cost",fe="gen_ai.request.model",Te="lunora.usage.cost.source",xe=new Set(["ai.embed","ai.generate","ai.stream"]),ue=6e4,Ce=1440,ve="unknown",X=p(()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),"q"),Y=p((n,e)=>{let s=n?.[e];return typeof s=="string"&&s!==""?s:void 0},"J"),z=p((n,e)=>{let s=n?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},"L"),ee=p(n=>Y(n,Te)==="provider"?"provider":"estimated","Q"),me=p((n,e)=>n.reduce((s,a)=>s+e(a),0),"Y"),B=p(n=>n.providerCost+n.estimatedCost,"F"),ke=p(n=>n.estimatedCost>0?n.providerCost>0?"mixed":"estimated":n.providerCost>0?"provider":"none","ae"),ye=p((n,e)=>({calls:n.calls+e.calls,estimatedCost:n.estimatedCost+e.estimatedCost,inputTokens:n.inputTokens+e.inputTokens,outputTokens:n.outputTokens+e.outputTokens,providerCost:n.providerCost+e.providerCost}),"ce"),Ie=p(n=>{let e=X(),s=0,a=0,t=0;for(let c of n){let l=me(c.points,i=>i.sum),r=me(c.points,i=>i.count);c.name===G?(e.inputTokens+=l,s+=r):c.name===Q?(e.outputTokens+=l,a+=r):(t+=r,ee(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,a,t),e},"ge"),Ne=p((n,e)=>B(e)-B(n)||e.inputTokens+e.outputTokens-(n.inputTokens+n.outputTokens)||n.key.localeCompare(e.key),"Ne"),pe=p((n,e)=>{let s=new Map;for(let a of n){let t=e(a);s.set(t,{key:t,...ye(s.get(t)??X(),a)})}return[...s.values()].toSorted(Ne)},"Z"),we=p(n=>(n?.series??[]).filter(e=>e.name===G||e.name===Q||e.name===V),"xe"),Me=p(n=>Y(n.attributes,fe)??ve,"Se"),Se=p(n=>{let e=new Map;for(let s of n){let a=Me(s),t=JSON.stringify([s.functionPath,a]),c=e.get(t)??{functionPath:s.functionPath,model:a,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:a,series:t})=>({functionPath:s,model:a,...Ie(t)}))},"Ie"),_e=p(n=>{let e=new Map;for(let r of n){if(r.name!==V)continue;let i=ee(r.attributes)==="provider";for(let u of r.points){let m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};i?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}let s=[...e.keys()].toSorted((r,i)=>r-i),a=s[0],t=s.at(-1);if(a===void 0||t===void 0)return[];let c=Math.max(a,t-(Ce-1)*ue),l=[];for(let r=c;r<=t;r+=ue)l.push(e.get(r)??{bucketMs:r,estimatedCost:0,providerCost:0});return l},"_e"),Pe=p(n=>{let e=[];for(let s of n)for(let a of s.spans){if(!xe.has(a.name))continue;let{attributes:t}=a,c=z(t,V),l=z(t,G),r=z(t,Q);e.push({...c===void 0?{}:{cost:c,costSource:ee(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:Y(t,fe)??ve,ok:a.ok,...r===void 0?{}:{outputTokens:r},startTs:s.startTs+a.offsetMs,streaming:a.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,a)=>a.startTs-s.startTs)},"Me"),Fe=p(n=>n.map(e=>{let s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),"Oe"),Oe=p((n,e)=>{let s=we(n),a=Pe(e),t=s.length>0,c=t?Se(s):Fe(a),l=X(),r="none";for(let i of c)l=ye(l,i);return t?r="history":a.length>0&&(r="live"),{byFunction:pe(c,i=>i.functionPath),byModel:pe(c,i=>i.model),calls:a,source:r,totals:l,trend:t?_e(s):[]}},"Ae"),Ke=p(n=>Array.isArray(n?.traces)?n.traces:[],"Ee"),Ae=25,te=p(n=>{let e=(0,O.c)(16),{provenance:s,value:a}=n,t=F();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==a?(c=s==="provider"?E(a):`~${E(a)}`,e[1]=s,e[2]=a,e[3]=c):c=e[3];let l;e[4]!==c?(l=(0,o.jsx)("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let r;e[6]!==s||e[7]!==t?(r=s==="estimated"?(0,o.jsx)(K,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=r):r=e[8];let i;e[9]!==s||e[10]!==t?(i=s==="mixed"?(0,o.jsx)(K,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=i):i=e[11];let u;return e[12]!==l||e[13]!==r||e[14]!==i?(u=(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[l,r,i]}),e[12]=l,e[13]=r,e[14]=i,e[15]=u):u=e[15],u},"V"),he=p(n=>{let e=(0,O.c)(40),{keyLabel:s,rows:a,testId:t,title:c}=n,l=F(),r;e[0]!==c?(r=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[0]=c,e[1]=r):r=e[1];let i;e[2]!==s?(i=(0,o.jsx)(M,{children:s}),e[2]=s,e[3]=i):i=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)(M,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let k;e[8]!==l?(k=l("Input tokens"),e[8]=l,e[9]=k):k=e[9];let y;e[10]!==k?(y=(0,o.jsx)(M,{className:"text-end",children:k}),e[10]=k,e[11]=y):y=e[11];let b;e[12]!==l?(b=l("Output tokens"),e[12]=l,e[13]=b):b=e[13];let T;e[14]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[14]=b,e[15]=T):T=e[15];let g;e[16]!==l?(g=l("Cost"),e[16]=l,e[17]=g):g=e[17];let d;e[18]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[18]=g,e[19]=d):d=e[19];let x;e[20]!==d||e[21]!==i||e[22]!==m||e[23]!==y||e[24]!==T?(x=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d]})}),e[20]=d,e[21]=i,e[22]=m,e[23]=y,e[24]=T,e[25]=x):x=e[25];let h;if(e[26]!==a||e[27]!==t){let N;e[29]!==t?(N=p(w=>(0,o.jsxs)(A,{"data-testid":`${t}-row`,children:[(0,o.jsx)(S,{className:"max-w-[280px] truncate font-mono",title:w.key,children:w.key}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.calls)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:ke(w),value:B(w)})})]},w.key),"x"),e[29]=t,e[30]=N):N=e[30],h=a.map(N),e[26]=a,e[27]=t,e[28]=h}else h=e[28];let f;e[31]!==h?(f=(0,o.jsx)(Z,{children:h}),e[31]=h,e[32]=f):f=e[32];let v;e[33]!==x||e[34]!==f?(v=(0,o.jsxs)(R,{children:[x,f]}),e[33]=x,e[34]=f,e[35]=v):v=e[35];let C;return e[36]!==r||e[37]!==v||e[38]!==t?(C=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":t,children:[r,v]}),e[36]=r,e[37]=v,e[38]=t,e[39]=C):C=e[39],C},"ee"),$e=p(n=>{let e=(0,O.c)(55),{calls:s,onOpenTrace:a}=n,t=F(),c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[2]=c,e[3]=l):l=e[3];let r;e[4]!==t?(r=t("When"),e[4]=t,e[5]=r):r=e[5];let i;e[6]!==r?(i=(0,o.jsx)(M,{children:r}),e[6]=r,e[7]=i):i=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=(0,o.jsx)(M,{children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==t?(k=t("Model"),e[12]=t,e[13]=k):k=e[13];let y;e[14]!==k?(y=(0,o.jsx)(M,{children:k}),e[14]=k,e[15]=y):y=e[15];let b;e[16]!==t?(b=t("Input tokens"),e[16]=t,e[17]=b):b=e[17];let T;e[18]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[18]=b,e[19]=T):T=e[19];let g;e[20]!==t?(g=t("Output tokens"),e[20]=t,e[21]=g):g=e[21];let d;e[22]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[22]=g,e[23]=d):d=e[23];let x;e[24]!==t?(x=t("Cost"),e[24]=t,e[25]=x):x=e[25];let h;e[26]!==x?(h=(0,o.jsx)(M,{className:"text-end",children:x}),e[26]=x,e[27]=h):h=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let v;e[30]!==f?(v=(0,o.jsx)(M,{children:f}),e[30]=f,e[31]=v):v=e[31];let C;e[32]!==T||e[33]!==d||e[34]!==h||e[35]!==v||e[36]!==i||e[37]!==m||e[38]!==y?(C=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d,h,v]})}),e[32]=T,e[33]=d,e[34]=h,e[35]=v,e[36]=i,e[37]=m,e[38]=y,e[39]=C):C=e[39];let N;if(e[40]!==s||e[41]!==a||e[42]!==t){let j;e[44]!==a||e[45]!==t?(j=p(I=>(0,o.jsxs)(A,{"data-testid":"ai-call",children:[(0,o.jsx)(S,{className:"font-mono text-muted-foreground",children:oe(I.startTs)}),(0,o.jsx)(S,{className:"font-mono",children:(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[I.functionPath,I.streaming?(0,o.jsx)(K,{variant:"outline",children:t("stream")}):null,I.ok?null:(0,o.jsx)(K,{variant:"destructive",children:t("failed")})]})}),(0,o.jsx)(S,{className:"max-w-[240px] truncate font-mono",title:I.model,children:I.model}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.inputTokens===void 0?"\u2014":_(I.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.outputTokens===void 0?"\u2014":_(I.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:I.cost===void 0?"none":I.costSource??"estimated",value:I.cost??0})}),(0,o.jsx)(S,{children:(0,o.jsx)("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:p(()=>{a(I.traceId)},"onClick"),title:t("Open the trace {trace}",{trace:I.traceId}),type:"button",children:I.traceId.slice(0,8)})})]},`${I.traceId}:${I.startTs.toString()}:${I.model}`),"K"),e[44]=a,e[45]=t,e[46]=j):j=e[46],N=s.slice(0,Ae).map(j),e[40]=s,e[41]=a,e[42]=t,e[43]=N}else N=e[43];let w;e[47]!==N?(w=(0,o.jsx)(Z,{children:N}),e[47]=N,e[48]=w):w=e[48];let P;e[49]!==C||e[50]!==w?(P=(0,o.jsxs)(R,{children:[C,w]}),e[49]=C,e[50]=w,e[51]=P):P=e[51];let L;return e[52]!==l||e[53]!==P?(L=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,P]}),e[52]=l,e[53]=P,e[54]=L):L=e[54],L},"Pe"),Ee=p(n=>{let e=(0,O.c)(48),{totals:s,trend:a}=n,t=F(),c;e[0]!==s?(c=ke(s),e[0]=s,e[1]=c):c=e[1];let l=c,r;e[2]!==t||e[3]!==a?(r=a.length>=2?(0,o.jsx)(de,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:a,testId:"ai-trend"}):void 0,e[2]=t,e[3]=a,e[4]=r):r=e[4];let i;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(i=l==="none"?t("No cost reported"):(0,o.jsx)("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported \xB7 {estimated} estimated",{estimated:E(s.estimatedCost),provider:E(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=i):i=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=B(s),e[12]=s,e[13]=m):m=e[13];let k;e[14]!==l||e[15]!==m?(k=(0,o.jsx)(te,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=k):k=e[16];let y;e[17]!==r||e[18]!==i||e[19]!==u||e[20]!==k?(y=(0,o.jsx)($,{chart:r,footer:i,label:u,testId:"ai-total-cost",value:k}),e[17]=r,e[18]=i,e[19]=u,e[20]=k,e[21]=y):y=e[21];let b;e[22]!==t?(b=t("Input tokens"),e[22]=t,e[23]=b):b=e[23];let T;e[24]!==s.inputTokens?(T=_(s.inputTokens),e[24]=s.inputTokens,e[25]=T):T=e[25];let g;e[26]!==b||e[27]!==T?(g=(0,o.jsx)($,{label:b,testId:"ai-input-tokens",value:T}),e[26]=b,e[27]=T,e[28]=g):g=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let x;e[31]!==s.outputTokens?(x=_(s.outputTokens),e[31]=s.outputTokens,e[32]=x):x=e[32];let h;e[33]!==d||e[34]!==x?(h=(0,o.jsx)($,{label:d,testId:"ai-output-tokens",value:x}),e[33]=d,e[34]=x,e[35]=h):h=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let v;e[38]!==s.calls?(v=_(s.calls),e[38]=s.calls,e[39]=v):v=e[39];let C;e[40]!==f||e[41]!==v?(C=(0,o.jsx)($,{label:f,testId:"ai-calls-total",value:v}),e[40]=f,e[41]=v,e[42]=C):C=e[42];let N;return e[43]!==g||e[44]!==h||e[45]!==C||e[46]!==y?(N=(0,o.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[y,g,h,C]}),e[43]=g,e[44]=h,e[45]=C,e[46]=y,e[47]=N):N=e[47],N},"Ke"),Ye=p(n=>{let e=(0,O.c)(29),{initialShardKey:s}=n,a=F(),{queryShardKey:t,setShardKey:c,shardKey:l}=le(s),r=ce(t),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];let{data:m,error:k}=D(U.getTraces,i,u),y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={},e[3]=y):y=e[3];let b;e[4]!==t?(b={live:!0,shardKey:t},e[4]=t,e[5]=b):b=e[5];let{data:T}=D(U.getMetricHistory,y,b),g,d;e[6]!==m||e[7]!==T?(d=Oe(T,Ke(m)),g=d.trend.map(Le),e[6]=m,e[7]=T,e[8]=g,e[9]=d):(g=e[8],d=e[9]);let x=g,h;e[10]!==c||e[11]!==l?(h=(0,o.jsx)(re,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=h):h=e[12];let f;e[13]!==k||e[14]!==t?(f=k===null?null:(0,o.jsx)(ie,{error:k,shardKey:t,testId:"ai-error"}),e[13]=k,e[14]=t,e[15]=f):f=e[15];let v;e[16]!==r||e[17]!==a||e[18]!==x||e[19]!==d.byFunction||e[20]!==d.byModel||e[21]!==d.calls||e[22]!==d.source||e[23]!==d.totals?(v=d.source==="none"?(0,o.jsx)(ae,{description:a("Spend shows up here once an action calls ctx.ai.model(...) \u2014 tokens and cost per function and per model."),testId:"ai-empty",title:a("No AI usage recorded")}):(0,o.jsxs)(o.Fragment,{children:[d.source==="live"?(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:a("No durable history yet \u2014 these totals come from the live trace ring and reset when the shard hibernates.")}):(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:a("Totals cover the retained metric history (up to the last 24 hours).")}),(0,o.jsx)(Ee,{totals:d.totals,trend:x}),(0,o.jsxs)("div",{className:"grid gap-3 xl:grid-cols-2",children:[(0,o.jsx)(he,{keyLabel:a("Function"),rows:d.byFunction,testId:"ai-by-function",title:a("By function")}),(0,o.jsx)(he,{keyLabel:a("Model"),rows:d.byModel,testId:"ai-by-model",title:a("By model")})]}),d.calls.length===0?(0,o.jsx)(q,{children:(0,o.jsx)(ne,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:a("No recent calls in the live trace ring \u2014 it empties when the shard hibernates.")})}):(0,o.jsx)($e,{calls:d.calls,onOpenTrace:r})]}),e[16]=r,e[17]=a,e[18]=x,e[19]=d.byFunction,e[20]=d.byModel,e[21]=d.calls,e[22]=d.source,e[23]=d.totals,e[24]=v):v=e[24];let C;return e[25]!==h||e[26]!==f||e[27]!==v?(C=(0,o.jsxs)("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[h,f,v]}),e[25]=h,e[26]=f,e[27]=v,e[28]=C):C=e[28],C},"Ze");function Le(n){return n.providerCost+n.estimatedCost}p(Le,"Ue");export{Ye as default};
1
+ import{d as E,e as _}from"./chunk-FWM5Z6CH.js";import{a as $}from"./chunk-AZ6QNL6G.js";import{a as de}from"./chunk-5FFKYQHT.js";import"./chunk-FT5WEK3S.js";import{a as ce}from"./chunk-7Z243YUE.js";import"./chunk-QLZGKBOW.js";import"./chunk-Y2YLTUMD.js";import"./chunk-R3RIZDUS.js";import{a as le}from"./chunk-2KTN53PK.js";import{a as re}from"./chunk-LFWS6VBU.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-OZID3UYF.js";import{a as ae}from"./chunk-O46IV64X.js";import{b as K}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as ie}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as R,b as W,c as Z,d as A,e as M,f as S}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as D}from"./chunk-NP6H72XD.js";import{a as q,b as H,c as J,e as ne}from"./chunk-NPHGFVNE.js";import"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as F,w as oe}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{b as ge}from"./chunk-ADABTCDI.js";import{a as p,d as se}from"./chunk-5PEAXTYQ.js";var O=se(be(),1);var o=se(ge(),1);var G="gen_ai.usage.input_tokens",Q="gen_ai.usage.output_tokens",V="gen_ai.usage.cost",fe="gen_ai.request.model",Te="lunora.usage.cost.source",xe=new Set(["ai.embed","ai.generate","ai.stream"]),ue=6e4,Ce=1440,ve="unknown",X=p(()=>({calls:0,estimatedCost:0,inputTokens:0,outputTokens:0,providerCost:0}),"q"),Y=p((n,e)=>{let s=n?.[e];return typeof s=="string"&&s!==""?s:void 0},"J"),z=p((n,e)=>{let s=n?.[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},"L"),ee=p(n=>Y(n,Te)==="provider"?"provider":"estimated","Q"),me=p((n,e)=>n.reduce((s,a)=>s+e(a),0),"Y"),B=p(n=>n.providerCost+n.estimatedCost,"F"),ke=p(n=>n.estimatedCost>0?n.providerCost>0?"mixed":"estimated":n.providerCost>0?"provider":"none","ae"),ye=p((n,e)=>({calls:n.calls+e.calls,estimatedCost:n.estimatedCost+e.estimatedCost,inputTokens:n.inputTokens+e.inputTokens,outputTokens:n.outputTokens+e.outputTokens,providerCost:n.providerCost+e.providerCost}),"ce"),Ie=p(n=>{let e=X(),s=0,a=0,t=0;for(let c of n){let l=me(c.points,i=>i.sum),r=me(c.points,i=>i.count);c.name===G?(e.inputTokens+=l,s+=r):c.name===Q?(e.outputTokens+=l,a+=r):(t+=r,ee(c.attributes)==="provider"?e.providerCost+=l:e.estimatedCost+=l)}return e.calls=Math.max(s,a,t),e},"ge"),Ne=p((n,e)=>B(e)-B(n)||e.inputTokens+e.outputTokens-(n.inputTokens+n.outputTokens)||n.key.localeCompare(e.key),"Ne"),pe=p((n,e)=>{let s=new Map;for(let a of n){let t=e(a);s.set(t,{key:t,...ye(s.get(t)??X(),a)})}return[...s.values()].toSorted(Ne)},"Z"),we=p(n=>(n?.series??[]).filter(e=>e.name===G||e.name===Q||e.name===V),"xe"),Me=p(n=>Y(n.attributes,fe)??ve,"Se"),Se=p(n=>{let e=new Map;for(let s of n){let a=Me(s),t=JSON.stringify([s.functionPath,a]),c=e.get(t)??{functionPath:s.functionPath,model:a,series:[]};c.series.push(s),e.set(t,c)}return[...e.values()].map(({functionPath:s,model:a,series:t})=>({functionPath:s,model:a,...Ie(t)}))},"Ie"),_e=p(n=>{let e=new Map;for(let r of n){if(r.name!==V)continue;let i=ee(r.attributes)==="provider";for(let u of r.points){let m=e.get(u.bucketMs)??{bucketMs:u.bucketMs,estimatedCost:0,providerCost:0};i?m.providerCost+=u.sum:m.estimatedCost+=u.sum,e.set(u.bucketMs,m)}}let s=[...e.keys()].toSorted((r,i)=>r-i),a=s[0],t=s.at(-1);if(a===void 0||t===void 0)return[];let c=Math.max(a,t-(Ce-1)*ue),l=[];for(let r=c;r<=t;r+=ue)l.push(e.get(r)??{bucketMs:r,estimatedCost:0,providerCost:0});return l},"_e"),Pe=p(n=>{let e=[];for(let s of n)for(let a of s.spans){if(!xe.has(a.name))continue;let{attributes:t}=a,c=z(t,V),l=z(t,G),r=z(t,Q);e.push({...c===void 0?{}:{cost:c,costSource:ee(t)},functionPath:s.functionPath,...l===void 0?{}:{inputTokens:l},model:Y(t,fe)??ve,ok:a.ok,...r===void 0?{}:{outputTokens:r},startTs:s.startTs+a.offsetMs,streaming:a.name==="ai.stream",traceId:s.traceId})}return e.toSorted((s,a)=>a.startTs-s.startTs)},"Me"),Fe=p(n=>n.map(e=>{let s=e.cost??0;return{calls:1,estimatedCost:e.costSource==="provider"?0:s,functionPath:e.functionPath,inputTokens:e.inputTokens??0,model:e.model,outputTokens:e.outputTokens??0,providerCost:e.costSource==="provider"?s:0}}),"Oe"),Oe=p((n,e)=>{let s=we(n),a=Pe(e),t=s.length>0,c=t?Se(s):Fe(a),l=X(),r="none";for(let i of c)l=ye(l,i);return t?r="history":a.length>0&&(r="live"),{byFunction:pe(c,i=>i.functionPath),byModel:pe(c,i=>i.model),calls:a,source:r,totals:l,trend:t?_e(s):[]}},"Ae"),Ke=p(n=>Array.isArray(n?.traces)?n.traces:[],"Ee"),Ae=25,te=p(n=>{let e=(0,O.c)(16),{provenance:s,value:a}=n,t=F();if(s==="none"){let m;return e[0]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=m):m=e[0],m}let c;e[1]!==s||e[2]!==a?(c=s==="provider"?E(a):`~${E(a)}`,e[1]=s,e[2]=a,e[3]=c):c=e[3];let l;e[4]!==c?(l=(0,o.jsx)("span",{className:"tabular-nums",children:c}),e[4]=c,e[5]=l):l=e[5];let r;e[6]!==s||e[7]!==t?(r=s==="estimated"?(0,o.jsx)(K,{title:t("Derived from a price table, not reported by the provider."),variant:"warning",children:t("Estimated")}):null,e[6]=s,e[7]=t,e[8]=r):r=e[8];let i;e[9]!==s||e[10]!==t?(i=s==="mixed"?(0,o.jsx)(K,{title:t("Includes cost derived from a price table, not reported by the provider."),variant:"warning",children:t("Partly estimated")}):null,e[9]=s,e[10]=t,e[11]=i):i=e[11];let u;return e[12]!==l||e[13]!==r||e[14]!==i?(u=(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[l,r,i]}),e[12]=l,e[13]=r,e[14]=i,e[15]=u):u=e[15],u},"V"),he=p(n=>{let e=(0,O.c)(40),{keyLabel:s,rows:a,testId:t,title:c}=n,l=F(),r;e[0]!==c?(r=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[0]=c,e[1]=r):r=e[1];let i;e[2]!==s?(i=(0,o.jsx)(M,{children:s}),e[2]=s,e[3]=i):i=e[3];let u;e[4]!==l?(u=l("Calls"),e[4]=l,e[5]=u):u=e[5];let m;e[6]!==u?(m=(0,o.jsx)(M,{className:"text-end",children:u}),e[6]=u,e[7]=m):m=e[7];let k;e[8]!==l?(k=l("Input tokens"),e[8]=l,e[9]=k):k=e[9];let y;e[10]!==k?(y=(0,o.jsx)(M,{className:"text-end",children:k}),e[10]=k,e[11]=y):y=e[11];let b;e[12]!==l?(b=l("Output tokens"),e[12]=l,e[13]=b):b=e[13];let T;e[14]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[14]=b,e[15]=T):T=e[15];let g;e[16]!==l?(g=l("Cost"),e[16]=l,e[17]=g):g=e[17];let d;e[18]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[18]=g,e[19]=d):d=e[19];let x;e[20]!==d||e[21]!==i||e[22]!==m||e[23]!==y||e[24]!==T?(x=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d]})}),e[20]=d,e[21]=i,e[22]=m,e[23]=y,e[24]=T,e[25]=x):x=e[25];let h;if(e[26]!==a||e[27]!==t){let N;e[29]!==t?(N=p(w=>(0,o.jsxs)(A,{"data-testid":`${t}-row`,children:[(0,o.jsx)(S,{className:"max-w-[280px] truncate font-mono",title:w.key,children:w.key}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.calls)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:_(w.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:ke(w),value:B(w)})})]},w.key),"x"),e[29]=t,e[30]=N):N=e[30],h=a.map(N),e[26]=a,e[27]=t,e[28]=h}else h=e[28];let f;e[31]!==h?(f=(0,o.jsx)(Z,{children:h}),e[31]=h,e[32]=f):f=e[32];let v;e[33]!==x||e[34]!==f?(v=(0,o.jsxs)(R,{children:[x,f]}),e[33]=x,e[34]=f,e[35]=v):v=e[35];let C;return e[36]!==r||e[37]!==v||e[38]!==t?(C=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":t,children:[r,v]}),e[36]=r,e[37]=v,e[38]=t,e[39]=C):C=e[39],C},"ee"),$e=p(n=>{let e=(0,O.c)(55),{calls:s,onOpenTrace:a}=n,t=F(),c;e[0]!==t?(c=t("Recent calls"),e[0]=t,e[1]=c):c=e[1];let l;e[2]!==c?(l=(0,o.jsx)(H,{className:"px-4 py-3",children:(0,o.jsx)(J,{children:c})}),e[2]=c,e[3]=l):l=e[3];let r;e[4]!==t?(r=t("When"),e[4]=t,e[5]=r):r=e[5];let i;e[6]!==r?(i=(0,o.jsx)(M,{children:r}),e[6]=r,e[7]=i):i=e[7];let u;e[8]!==t?(u=t("Function"),e[8]=t,e[9]=u):u=e[9];let m;e[10]!==u?(m=(0,o.jsx)(M,{children:u}),e[10]=u,e[11]=m):m=e[11];let k;e[12]!==t?(k=t("Model"),e[12]=t,e[13]=k):k=e[13];let y;e[14]!==k?(y=(0,o.jsx)(M,{children:k}),e[14]=k,e[15]=y):y=e[15];let b;e[16]!==t?(b=t("Input tokens"),e[16]=t,e[17]=b):b=e[17];let T;e[18]!==b?(T=(0,o.jsx)(M,{className:"text-end",children:b}),e[18]=b,e[19]=T):T=e[19];let g;e[20]!==t?(g=t("Output tokens"),e[20]=t,e[21]=g):g=e[21];let d;e[22]!==g?(d=(0,o.jsx)(M,{className:"text-end",children:g}),e[22]=g,e[23]=d):d=e[23];let x;e[24]!==t?(x=t("Cost"),e[24]=t,e[25]=x):x=e[25];let h;e[26]!==x?(h=(0,o.jsx)(M,{className:"text-end",children:x}),e[26]=x,e[27]=h):h=e[27];let f;e[28]!==t?(f=t("Trace"),e[28]=t,e[29]=f):f=e[29];let v;e[30]!==f?(v=(0,o.jsx)(M,{children:f}),e[30]=f,e[31]=v):v=e[31];let C;e[32]!==T||e[33]!==d||e[34]!==h||e[35]!==v||e[36]!==i||e[37]!==m||e[38]!==y?(C=(0,o.jsx)(W,{children:(0,o.jsxs)(A,{children:[i,m,y,T,d,h,v]})}),e[32]=T,e[33]=d,e[34]=h,e[35]=v,e[36]=i,e[37]=m,e[38]=y,e[39]=C):C=e[39];let N;if(e[40]!==s||e[41]!==a||e[42]!==t){let j;e[44]!==a||e[45]!==t?(j=p(I=>(0,o.jsxs)(A,{"data-testid":"ai-call",children:[(0,o.jsx)(S,{className:"font-mono text-muted-foreground",children:oe(I.startTs)}),(0,o.jsx)(S,{className:"font-mono",children:(0,o.jsxs)("span",{className:"inline-flex items-center gap-2",children:[I.functionPath,I.streaming?(0,o.jsx)(K,{variant:"outline",children:t("stream")}):null,I.ok?null:(0,o.jsx)(K,{variant:"destructive",children:t("failed")})]})}),(0,o.jsx)(S,{className:"max-w-[240px] truncate font-mono",title:I.model,children:I.model}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.inputTokens===void 0?"\u2014":_(I.inputTokens)}),(0,o.jsx)(S,{className:"text-end tabular-nums",children:I.outputTokens===void 0?"\u2014":_(I.outputTokens)}),(0,o.jsx)(S,{className:"text-end",children:(0,o.jsx)(te,{provenance:I.cost===void 0?"none":I.costSource??"estimated",value:I.cost??0})}),(0,o.jsx)(S,{children:(0,o.jsx)("button",{className:"font-mono text-muted-foreground underline-offset-2 hover:underline",onClick:p(()=>{a(I.traceId)},"onClick"),title:t("Open the trace {trace}",{trace:I.traceId}),type:"button",children:I.traceId.slice(0,8)})})]},`${I.traceId}:${I.startTs.toString()}:${I.model}`),"K"),e[44]=a,e[45]=t,e[46]=j):j=e[46],N=s.slice(0,Ae).map(j),e[40]=s,e[41]=a,e[42]=t,e[43]=N}else N=e[43];let w;e[47]!==N?(w=(0,o.jsx)(Z,{children:N}),e[47]=N,e[48]=w):w=e[48];let P;e[49]!==C||e[50]!==w?(P=(0,o.jsxs)(R,{children:[C,w]}),e[49]=C,e[50]=w,e[51]=P):P=e[51];let L;return e[52]!==l||e[53]!==P?(L=(0,o.jsxs)(q,{className:"gap-0 py-0","data-testid":"ai-calls",children:[l,P]}),e[52]=l,e[53]=P,e[54]=L):L=e[54],L},"Pe"),Ee=p(n=>{let e=(0,O.c)(48),{totals:s,trend:a}=n,t=F(),c;e[0]!==s?(c=ke(s),e[0]=s,e[1]=c):c=e[1];let l=c,r;e[2]!==t||e[3]!==a?(r=a.length>=2?(0,o.jsx)(de,{ariaLabel:t("Cost per minute"),className:"h-7 w-24",series:a,testId:"ai-trend"}):void 0,e[2]=t,e[3]=a,e[4]=r):r=e[4];let i;e[5]!==l||e[6]!==t||e[7]!==s.estimatedCost||e[8]!==s.providerCost?(i=l==="none"?t("No cost reported"):(0,o.jsx)("span",{"data-testid":"ai-cost-split",children:t("{provider} provider-reported \xB7 {estimated} estimated",{estimated:E(s.estimatedCost),provider:E(s.providerCost)})}),e[5]=l,e[6]=t,e[7]=s.estimatedCost,e[8]=s.providerCost,e[9]=i):i=e[9];let u;e[10]!==t?(u=t("Total cost"),e[10]=t,e[11]=u):u=e[11];let m;e[12]!==s?(m=B(s),e[12]=s,e[13]=m):m=e[13];let k;e[14]!==l||e[15]!==m?(k=(0,o.jsx)(te,{provenance:l,value:m}),e[14]=l,e[15]=m,e[16]=k):k=e[16];let y;e[17]!==r||e[18]!==i||e[19]!==u||e[20]!==k?(y=(0,o.jsx)($,{chart:r,footer:i,label:u,testId:"ai-total-cost",value:k}),e[17]=r,e[18]=i,e[19]=u,e[20]=k,e[21]=y):y=e[21];let b;e[22]!==t?(b=t("Input tokens"),e[22]=t,e[23]=b):b=e[23];let T;e[24]!==s.inputTokens?(T=_(s.inputTokens),e[24]=s.inputTokens,e[25]=T):T=e[25];let g;e[26]!==b||e[27]!==T?(g=(0,o.jsx)($,{label:b,testId:"ai-input-tokens",value:T}),e[26]=b,e[27]=T,e[28]=g):g=e[28];let d;e[29]!==t?(d=t("Output tokens"),e[29]=t,e[30]=d):d=e[30];let x;e[31]!==s.outputTokens?(x=_(s.outputTokens),e[31]=s.outputTokens,e[32]=x):x=e[32];let h;e[33]!==d||e[34]!==x?(h=(0,o.jsx)($,{label:d,testId:"ai-output-tokens",value:x}),e[33]=d,e[34]=x,e[35]=h):h=e[35];let f;e[36]!==t?(f=t("Calls"),e[36]=t,e[37]=f):f=e[37];let v;e[38]!==s.calls?(v=_(s.calls),e[38]=s.calls,e[39]=v):v=e[39];let C;e[40]!==f||e[41]!==v?(C=(0,o.jsx)($,{label:f,testId:"ai-calls-total",value:v}),e[40]=f,e[41]=v,e[42]=C):C=e[42];let N;return e[43]!==g||e[44]!==h||e[45]!==C||e[46]!==y?(N=(0,o.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"ai-totals",children:[y,g,h,C]}),e[43]=g,e[44]=h,e[45]=C,e[46]=y,e[47]=N):N=e[47],N},"Ke"),Ye=p(n=>{let e=(0,O.c)(29),{initialShardKey:s}=n,a=F(),{queryShardKey:t,setShardKey:c,shardKey:l}=le(s),r=ce(t),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let u;e[1]!==t?(u={live:!0,shardKey:t},e[1]=t,e[2]=u):u=e[2];let{data:m,error:k}=D(U.getTraces,i,u),y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y={},e[3]=y):y=e[3];let b;e[4]!==t?(b={live:!0,shardKey:t},e[4]=t,e[5]=b):b=e[5];let{data:T}=D(U.getMetricHistory,y,b),g,d;e[6]!==m||e[7]!==T?(d=Oe(T,Ke(m)),g=d.trend.map(Le),e[6]=m,e[7]=T,e[8]=g,e[9]=d):(g=e[8],d=e[9]);let x=g,h;e[10]!==c||e[11]!==l?(h=(0,o.jsx)(re,{onChange:c,testId:"ai-shard-input",value:l}),e[10]=c,e[11]=l,e[12]=h):h=e[12];let f;e[13]!==k||e[14]!==t?(f=k===null?null:(0,o.jsx)(ie,{error:k,shardKey:t,testId:"ai-error"}),e[13]=k,e[14]=t,e[15]=f):f=e[15];let v;e[16]!==r||e[17]!==a||e[18]!==x||e[19]!==d.byFunction||e[20]!==d.byModel||e[21]!==d.calls||e[22]!==d.source||e[23]!==d.totals?(v=d.source==="none"?(0,o.jsx)(ae,{description:a("Spend shows up here once an action calls ctx.ai.model(...) \u2014 tokens and cost per function and per model."),testId:"ai-empty",title:a("No AI usage recorded")}):(0,o.jsxs)(o.Fragment,{children:[d.source==="live"?(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-live-only",children:a("No durable history yet \u2014 these totals come from the live trace ring and reset when the shard hibernates.")}):(0,o.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"ai-window",children:a("Totals cover the retained metric history (up to the last 24 hours).")}),(0,o.jsx)(Ee,{totals:d.totals,trend:x}),(0,o.jsxs)("div",{className:"grid gap-3 xl:grid-cols-2",children:[(0,o.jsx)(he,{keyLabel:a("Function"),rows:d.byFunction,testId:"ai-by-function",title:a("By function")}),(0,o.jsx)(he,{keyLabel:a("Model"),rows:d.byModel,testId:"ai-by-model",title:a("By model")})]}),d.calls.length===0?(0,o.jsx)(q,{children:(0,o.jsx)(ne,{className:"p-4 text-xs text-muted-foreground","data-testid":"ai-no-calls",children:a("No recent calls in the live trace ring \u2014 it empties when the shard hibernates.")})}):(0,o.jsx)($e,{calls:d.calls,onOpenTrace:r})]}),e[16]=r,e[17]=a,e[18]=x,e[19]=d.byFunction,e[20]=d.byModel,e[21]=d.calls,e[22]=d.source,e[23]=d.totals,e[24]=v):v=e[24];let C;return e[25]!==h||e[26]!==f||e[27]!==v?(C=(0,o.jsxs)("section",{className:"flex flex-col gap-4","data-testid":"ai-panel",children:[h,f,v]}),e[25]=h,e[26]=f,e[27]=v,e[28]=C):C=e[28],C},"Ze");function Le(n){return n.providerCost+n.estimatedCost}p(Le,"Ue");export{Ye as default};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-LYVYUTQY.js";import{c as f}from"./chunk-6C555TU5.js";import{n as q}from"./chunk-C6FOSG2A.js";import{h as s,i as l}from"./chunk-2ZJJH4YN.js";import{a as U}from"./chunk-ADABTCDI.js";import{a as e,d as R}from"./chunk-5PEAXTYQ.js";var p=R(U(),1);var _=e(async i=>{try{let{knowledgeExcerpts:d}=await import("./chunk-IL64HWFW.js");return d(i)}catch{return[]}},"x"),B={},H=s(n.aiGenerateSql),L=s(n.aiTableFilter),O=s(n.aiChartConfig),P=s(n.aiChat),V=s(n.aiNameQuery),j=s(n.aiCronExpression),Y=e(i=>{let d=q(),[w,g]=(0,p.useState)({}),[b,m]=(0,p.useState)({}),y=f(n.aiAvailable,B,{shardKey:i}),[C,S]=(0,p.useState)(!1),N=C||y.data?.available===!1,c=e(a=>{g(r=>({...r,[a]:!0})),m(r=>({...r,[a]:void 0}))},"i"),t=e((a,r)=>{g(o=>({...o,[a]:!1})),r!==void 0&&m(o=>({...o,[a]:r})),(r==="ai-disabled"||r==="no-ai-binding")&&S(!0)},"e"),h=e(async a=>{c("sql");try{let r=await d.query(H,a,l(i));return t("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{t("sql","ai-error");return}},"p"),x=e(async(a,r)=>h({failedError:r?.error,failedSql:r?.sql,prompt:a}),"E"),E=e(async(a,r)=>h({editSql:r,prompt:a}),"w"),F=e(async(a,r,o,G,K,v)=>{c("chat");try{let u=await d.streamRpc(P,{approval:G,knowledge:await _(a),prompt:a,schema:o,shardKey:i,transcript:r},{onFrame:e(M=>{K?.(M)},"onFrame"),...v===void 0?{}:{signal:v}});return t("chat",u.degraded?u.reason:void 0),u.degraded?void 0:u}catch{t("chat","ai-error");return}},"C"),A=e(async(a,r)=>{c("filter");try{let o=await d.query(L,{prompt:a,table:r},l(i));return t("filter",o.degraded?o.reason:void 0),o.degraded?void 0:o.clauses}catch{t("filter","ai-error");return}},"I"),I=e(async a=>{c("chart");try{let r=await d.query(O,a,l(i));return t("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{t("chart","ai-error");return}},"R"),Q=e(async a=>{c("name");try{let r=await d.query(V,{sql:a},l(i));return t("name",r.degraded?r.reason:void 0),r.degraded?void 0:{description:r.description,title:r.title}}catch{t("name","ai-error");return}},"S"),T=e(async a=>{c("cron");try{let r=await d.query(j,{prompt:a},l(i));return t("cron",r.degraded?r.reason:void 0),r.degraded?void 0:r.cron}catch{t("cron","ai-error");return}},"T"),k=e(a=>w[a]===!0,"N"),D=e(a=>b[a],"b");return{chat:F,generate:x,inferChart:I,level:y.data?.level,nameQuery:Q,pending:k,reason:D,rewrite:E,suggestCron:T,suggestFilter:A,unavailable:N}},"V");export{Y as a};
1
+ import{a as n}from"./chunk-LYVYUTQY.js";import{c as f}from"./chunk-NP6H72XD.js";import{n as q}from"./chunk-YESGXFAR.js";import{h as s,i as l}from"./chunk-CDIV23I2.js";import{a as U}from"./chunk-ADABTCDI.js";import{a as e,d as R}from"./chunk-5PEAXTYQ.js";var p=R(U(),1);var _=e(async i=>{try{let{knowledgeExcerpts:d}=await import("./chunk-OZUPOUHR.js");return d(i)}catch{return[]}},"x"),B={},H=s(n.aiGenerateSql),L=s(n.aiTableFilter),O=s(n.aiChartConfig),P=s(n.aiChat),V=s(n.aiNameQuery),j=s(n.aiCronExpression),Y=e(i=>{let d=q(),[w,g]=(0,p.useState)({}),[b,m]=(0,p.useState)({}),y=f(n.aiAvailable,B,{shardKey:i}),[C,S]=(0,p.useState)(!1),N=C||y.data?.available===!1,c=e(a=>{g(r=>({...r,[a]:!0})),m(r=>({...r,[a]:void 0}))},"i"),t=e((a,r)=>{g(o=>({...o,[a]:!1})),r!==void 0&&m(o=>({...o,[a]:r})),(r==="ai-disabled"||r==="no-ai-binding")&&S(!0)},"e"),h=e(async a=>{c("sql");try{let r=await d.query(H,a,l(i));return t("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{t("sql","ai-error");return}},"p"),x=e(async(a,r)=>h({failedError:r?.error,failedSql:r?.sql,prompt:a}),"E"),E=e(async(a,r)=>h({editSql:r,prompt:a}),"w"),F=e(async(a,r,o,G,K,v)=>{c("chat");try{let u=await d.streamRpc(P,{approval:G,knowledge:await _(a),prompt:a,schema:o,shardKey:i,transcript:r},{onFrame:e(M=>{K?.(M)},"onFrame"),...v===void 0?{}:{signal:v}});return t("chat",u.degraded?u.reason:void 0),u.degraded?void 0:u}catch{t("chat","ai-error");return}},"C"),A=e(async(a,r)=>{c("filter");try{let o=await d.query(L,{prompt:a,table:r},l(i));return t("filter",o.degraded?o.reason:void 0),o.degraded?void 0:o.clauses}catch{t("filter","ai-error");return}},"I"),I=e(async a=>{c("chart");try{let r=await d.query(O,a,l(i));return t("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{t("chart","ai-error");return}},"R"),Q=e(async a=>{c("name");try{let r=await d.query(V,{sql:a},l(i));return t("name",r.degraded?r.reason:void 0),r.degraded?void 0:{description:r.description,title:r.title}}catch{t("name","ai-error");return}},"S"),T=e(async a=>{c("cron");try{let r=await d.query(j,{prompt:a},l(i));return t("cron",r.degraded?r.reason:void 0),r.degraded?void 0:r.cron}catch{t("cron","ai-error");return}},"T"),k=e(a=>w[a]===!0,"N"),D=e(a=>b[a],"b");return{chat:F,generate:x,inferChart:I,level:y.data?.level,nameQuery:Q,pending:k,reason:D,rewrite:E,suggestCron:T,suggestFilter:A,unavailable:N}},"V");export{Y as a};
@@ -1 +1 @@
1
- import{a as Re,b as Pe,c as qe}from"./chunk-V5TGDG6U.js";import{b as Ie,c as Te}from"./chunk-LJLNIVUA.js";import{a as Se}from"./chunk-V3DOKU22.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-NAGIOR23.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-YLC2ZYCL.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as D}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-HMMALUXM.js";import{b as ne}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as ye,b as we,c as Ne,d as se,e as j,f as B}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-6C555TU5.js";import{n as ge}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as he,s as ae,x as W}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as ze}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(ze(),1);var ue=["trace","debug","log","info","warn","error","fatal"],De="LOG_ARCHIVE_NOT_CONFIGURED",je={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=z(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,je),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===De?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(D,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(D,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=z(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=z(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=z(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
1
+ import{a as Re,b as Pe,c as qe}from"./chunk-AJFMXVR4.js";import{b as Ie,c as Te}from"./chunk-LJLNIVUA.js";import{a as Se}from"./chunk-7Z243YUE.js";import"./chunk-QLZGKBOW.js";import{a as de}from"./chunk-R6NJ4ER6.js";import{a as Le}from"./chunk-W7CLOQOU.js";import{c as ke}from"./chunk-MHZNDDGI.js";import{a as Ce}from"./chunk-PRVBT5AJ.js";import{a as ie}from"./chunk-DRHZZ7IN.js";import{a as be}from"./chunk-2KTN53PK.js";import{a as ve}from"./chunk-LFWS6VBU.js";import{b as fe}from"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as D}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as pe}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as J}from"./chunk-O46IV64X.js";import{b as ne}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as xe}from"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import{a as ye,b as we,c as Ne,d as se,e as j,f as B}from"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as oe}from"./chunk-LYVYUTQY.js";import{c as le}from"./chunk-NP6H72XD.js";import{n as ge}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as z,j as re,k as he,s as ae,x as W}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as Ue}from"./chunk-A6TVTNKO.js";import{a as $e,b as ze}from"./chunk-ADABTCDI.js";import{a as v,d as te}from"./chunk-5PEAXTYQ.js";var K=te(Ue(),1);var q=te($e(),1);var r=te(ze(),1);var ue=["trace","debug","log","info","warn","error","fatal"],De="LOG_ARCHIVE_NOT_CONFIGURED",je={cursor:void 0,error:null,generation:0,loading:!1,notConfigured:!1,rows:null},Be=v((i,e)=>{switch(e.type){case"append":return{...i,cursor:e.cursor,error:null,loading:!1,rows:[...i.rows??[],...e.rows]};case"failed":return{...i,cursor:void 0,error:e.message,loading:!1,notConfigured:!1,rows:null};case"loaded":return{cursor:e.cursor,error:null,generation:i.generation+1,loading:!1,notConfigured:!1,rows:e.rows};case"loading":return{...i,error:null,loading:!0,notConfigured:!1};case"notConfigured":return{...i,cursor:void 0,error:null,loading:!1,notConfigured:!0,rows:null};case"pageFailed":return{...i,error:e.message,loading:!1};default:return i}},"ze"),We=v(i=>{let e=(0,K.c)(36),{row:t}=i,s;e[0]!==t.fields?(s=Ie(t.fields),e[0]=t.fields,e[1]=s):s=e[1];let n=s,o=`lg-archive-row-${String(t.ts)}`,c;e[2]!==t.ts?(c=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=c):c=e[3];let p;e[4]!==c?(p=(0,r.jsx)(B,{className:"tabular-nums whitespace-nowrap text-xs text-muted-foreground",children:c}),e[4]=c,e[5]=p):p=e[5];let m=Re[t.level],d;e[6]!==t.level||e[7]!==m?(d=(0,r.jsx)(B,{children:(0,r.jsx)(ne,{variant:m,children:t.level})}),e[6]=t.level,e[7]=m,e[8]=d):d=e[8];let a;e[9]!==t.functionPath?(a=(0,r.jsx)(B,{className:"font-mono text-xs",children:t.functionPath}),e[9]=t.functionPath,e[10]=a):a=e[10];let h;e[11]!==t.message?(h=(0,r.jsx)("div",{className:"truncate",title:t.message,children:t.message}),e[11]=t.message,e[12]=h):h=e[12];let l;e[13]!==n.text?(l=n.text!==""&&(0,r.jsx)("div",{className:"truncate font-mono text-[11px] text-muted-foreground",title:n.text,children:n.text}),e[13]=n.text,e[14]=l):l=e[14];let g;e[15]!==n.errors?(g=n.errors.length>0&&(0,r.jsx)(Pe,{errors:n.errors}),e[15]=n.errors,e[16]=g):g=e[16];let u;e[17]!==g||e[18]!==h||e[19]!==l?(u=(0,r.jsxs)(B,{className:"max-w-md",children:[h,l,g]}),e[17]=g,e[18]=h,e[19]=l,e[20]=u):u=e[20];let x=t.traceId??"\u2014",f;e[21]!==x?(f=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:x}),e[21]=x,e[22]=f):f=e[22];let C=t.shardKey??"\u2014",y;e[23]!==C?(y=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:C}),e[23]=C,e[24]=y):y=e[24];let w=t.userId??"\u2014",k;e[25]!==w?(k=(0,r.jsx)(B,{className:"font-mono text-[11px] text-muted-foreground",children:w}),e[25]=w,e[26]=k):k=e[26];let L;return e[27]!==u||e[28]!==f||e[29]!==y||e[30]!==k||e[31]!==o||e[32]!==p||e[33]!==d||e[34]!==a?(L=(0,r.jsxs)(se,{"data-testid":o,children:[p,d,a,u,f,y,k]}),e[27]=u,e[28]=f,e[29]=y,e[30]=k,e[31]=o,e[32]=p,e[33]=d,e[34]=a,e[35]=L):L=e[35],L},"Ge"),Ve=v(({shardKey:i})=>{let e=ge(),t=z(),[s,n]=(0,q.useState)(""),[o,c]=(0,q.useState)(""),[p,m]=(0,q.useState)(""),[{cursor:d,error:a,generation:h,loading:l,notConfigured:g,rows:u},x]=(0,q.useReducer)(Be,je),f=ie(s.trim(),400),C=ie(o.trim(),400),y={...f===""?{}:{functionPathPrefix:f},...p===""?{}:{minLevel:p},...i===""?{}:{shardKey:i},...C===""?{}:{userId:C}},w=JSON.stringify(y),k=(0,q.useRef)(w);(0,q.useEffect)(()=>{let b={cancelled:!1};return k.current=w,ae((async()=>{x({type:"loading"});try{let N=await e.queryLogArchive(y);b.cancelled||x({cursor:N.nextCursor,rows:N.rows,type:"loaded"})}catch(N){b.cancelled||x(he(N)===De?{type:"notConfigured"}:{message:re(N),type:"failed"})}})()),()=>{b.cancelled=!0}},[e,w]);let L=v(async()=>{if(d===void 0)return;let b=w;x({type:"loading"});try{let N=await e.queryLogArchive({...y,cursor:d});k.current===b&&x({cursor:N.nextCursor,rows:N.rows,type:"append"})}catch(N){k.current===b&&x({message:re(N),type:"pageFailed"})}},"N"),S=v(b=>{n(b.target.value)},"I"),T=v(b=>{c(b.target.value)},"T"),R=v(b=>{m(b.target.value)},"R"),P=v(()=>{ae(L())},"k");return g?(0,r.jsx)(J,{action:(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline",href:de,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")}),description:t("Wire pipelineLogSink to a Cloudflare Pipeline \u2192 R2 Data Catalog table and set R2_SQL_ACCOUNT_ID, R2_SQL_TOKEN, R2_SQL_BUCKET to browse the durable log archive here."),testId:"lg-archive-not-configured",title:t("Log archive not configured")}):(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lg-archive",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)(D,{"aria-label":t("Function path prefix"),className:"h-8 w-48","data-testid":"lg-archive-path",onChange:S,placeholder:t("function path\u2026"),value:s}),(0,r.jsx)(D,{"aria-label":t("User id"),className:"h-8 w-40","data-testid":"lg-archive-user",onChange:T,placeholder:t("user id\u2026"),value:o}),(0,r.jsxs)("select",{"aria-label":t("Minimum level"),className:"h-8 rounded-md border border-border bg-background px-2 text-sm","data-testid":"lg-archive-min-level",onChange:R,value:p,children:[(0,r.jsx)("option",{value:"",children:t("min level")}),ue.map(b=>(0,r.jsx)("option",{value:b,children:b},b))]})]}),a!==null&&(0,r.jsx)("p",{className:"text-sm text-destructive","data-testid":"lg-archive-error",role:"alert",children:a}),l&&u===null&&a===null&&(0,r.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"lg-archive-loading",children:t("Loading\u2026")}),u!==null&&u.length===0&&(0,r.jsx)(J,{description:t("No archived logs match these filters. The durable archive fills as pipelineLogSink flushes records to R2."),testId:"lg-archive-empty",title:t("No archived logs.")}),u!==null&&u.length>0&&(0,r.jsx)("div",{className:"overflow-hidden rounded-xl border border-border shadow-xs",children:(0,r.jsxs)(ye,{"data-testid":"lg-archive-table",children:[(0,r.jsx)(we,{children:(0,r.jsxs)(se,{children:[(0,r.jsx)(j,{children:t("Time")}),(0,r.jsx)(j,{children:t("Level")}),(0,r.jsx)(j,{children:t("Function")}),(0,r.jsx)(j,{children:t("Message")}),(0,r.jsx)(j,{children:t("Trace")}),(0,r.jsx)(j,{children:t("Shard")}),(0,r.jsx)(j,{children:t("User")})]})}),(0,r.jsx)(Ne,{children:u.map((b,N)=>(0,r.jsx)(We,{row:b},`${String(h)}:${String(b.ts)}-${String(N)}`))})]})}),d!==void 0&&(0,r.jsx)("div",{children:(0,r.jsx)(pe,{"data-testid":"lg-archive-more",disabled:l,onClick:P,size:"sm",variant:"outline",children:t(l?"Loading\u2026":"Load more")})})]})},"He"),Qe=v(i=>{let e=(0,K.c)(11),{level:t,onToggle:s,selected:n}=i,o;e[0]!==t||e[1]!==s?(o=v(()=>{s(t)},"o"),e[0]=t,e[1]=s,e[2]=o):o=e[2];let c=o,p=n?"border-border bg-muted font-medium":"border-input text-muted-foreground",m;e[3]!==p?(m=W("rounded-md border px-2 py-1 text-xs",p),e[3]=p,e[4]=m):m=e[4];let d=`logs-level-${t}`,a;return e[5]!==t||e[6]!==c||e[7]!==n||e[8]!==m||e[9]!==d?(a=(0,r.jsx)("button",{"aria-pressed":n,className:m,"data-testid":d,onClick:c,type:"button",children:t}),e[5]=t,e[6]=c,e[7]=n,e[8]=m,e[9]=d,e[10]=a):a=e[10],a},"We"),Ye=v(i=>{let e=(0,K.c)(68),{levelFilter:t,onLogPathChange:s,onSearchChange:n,onTimeRangeChange:o,onToggleLevel:c,onToggleSummary:p,pathFilter:m,search:d,showSummary:a,timeRange:h}=i,l=z(),g;e[0]!==l?(g=l("Search messages"),e[0]=l,e[1]=g):g=e[1];let u;e[2]!==l?(u=l("search message"),e[2]=l,e[3]=u):u=e[3];let x;e[4]!==n||e[5]!==d||e[6]!==g||e[7]!==u?(x=(0,r.jsx)(D,{"aria-label":g,className:"h-8 w-48","data-testid":"lg-search",onChange:n,placeholder:u,value:d}),e[4]=n,e[5]=d,e[6]=g,e[7]=u,e[8]=x):x=e[8];let f;e[9]!==l?(f=l("Function path"),e[9]=l,e[10]=f):f=e[10];let C;e[11]!==l?(C=l("filter path"),e[11]=l,e[12]=C):C=e[12];let y;e[13]!==s||e[14]!==m||e[15]!==f||e[16]!==C?(y=(0,r.jsx)(D,{"aria-label":f,className:"h-8 w-40","data-testid":"logs-path-filter",onChange:s,placeholder:C,value:m}),e[13]=s,e[14]=m,e[15]=f,e[16]=C,e[17]=y):y=e[17];let w;e[18]!==l?(w=l("Level filter"),e[18]=l,e[19]=w):w=e[19];let k;e[20]!==t||e[21]!==c?(k=ue.map(Q=>(0,r.jsx)(Qe,{level:Q,onToggle:c,selected:t.has(Q)},Q)),e[20]=t,e[21]=c,e[22]=k):k=e[22];let L;e[23]!==w||e[24]!==k?(L=(0,r.jsx)("div",{"aria-label":w,className:"inline-flex items-center gap-1","data-testid":"logs-level-filter",role:"group",children:k}),e[23]=w,e[24]=k,e[25]=L):L=e[25];let S;e[26]!==l?(S=l("Time range"),e[26]=l,e[27]=S):S=e[27];let T;e[28]!==l?(T=l("All time"),e[28]=l,e[29]=T):T=e[29];let R;e[30]!==T?(R=(0,r.jsx)("option",{value:"all",children:T}),e[30]=T,e[31]=R):R=e[31];let P;e[32]!==l?(P=l("Last 5m"),e[32]=l,e[33]=P):P=e[33];let b;e[34]!==P?(b=(0,r.jsx)("option",{value:"5m",children:P}),e[34]=P,e[35]=b):b=e[35];let N;e[36]!==l?(N=l("Last 15m"),e[36]=l,e[37]=N):N=e[37];let F;e[38]!==N?(F=(0,r.jsx)("option",{value:"15m",children:N}),e[38]=N,e[39]=F):F=e[39];let E;e[40]!==l?(E=l("Last hour"),e[40]=l,e[41]=E):E=e[41];let O;e[42]!==E?(O=(0,r.jsx)("option",{value:"1h",children:E}),e[42]=E,e[43]=O):O=e[43];let M;e[44]!==o||e[45]!==S||e[46]!==R||e[47]!==b||e[48]!==F||e[49]!==O||e[50]!==h?(M=(0,r.jsxs)("select",{"aria-label":S,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"logs-time-range",onChange:o,value:h,children:[R,b,F,O]}),e[44]=o,e[45]=S,e[46]=R,e[47]=b,e[48]=F,e[49]=O,e[50]=h,e[51]=M):M=e[51];let V=a?"border-border bg-muted font-medium":"border-input text-muted-foreground",_;e[52]!==V?(_=W("h-8 rounded-md border px-3 text-sm",V),e[52]=V,e[53]=_):_=e[53];let U;e[54]!==a||e[55]!==l?(U=l(a?"List":"Summary"),e[54]=a,e[55]=l,e[56]=U):U=e[56];let A;e[57]!==p||e[58]!==a||e[59]!==_||e[60]!==U?(A=(0,r.jsx)("button",{"aria-pressed":a,className:_,"data-testid":"logs-summary-toggle",onClick:p,type:"button",children:U}),e[57]=p,e[58]=a,e[59]=_,e[60]=U,e[61]=A):A=e[61];let $;return e[62]!==M||e[63]!==A||e[64]!==x||e[65]!==y||e[66]!==L?($=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,y,L,M,A]}),e[62]=M,e[63]=A,e[64]=x,e[65]=y,e[66]=L,e[67]=$):$=e[67],$},"Ye"),Ge=v(i=>{let e=(0,K.c)(53),{onOutcomeChange:t,onPathChange:s,onTableChange:n,onUserChange:o,outcomeFilter:c,pathPrefix:p,tableFilter:m,userIdFilter:d}=i,a=z(),h;e[0]!==a?(h=a("Function path"),e[0]=a,e[1]=h):h=e[1];let l;e[2]!==a?(l=a("file:function"),e[2]=a,e[3]=l):l=e[3];let g;e[4]!==s||e[5]!==p||e[6]!==h||e[7]!==l?(g=(0,r.jsx)(D,{"aria-label":h,className:"h-8 w-44","data-testid":"lg-req-path",onChange:s,placeholder:l,value:p}),e[4]=s,e[5]=p,e[6]=h,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==a?(u=a("User id"),e[9]=a,e[10]=u):u=e[10];let x;e[11]!==a?(x=a("userId"),e[11]=a,e[12]=x):x=e[12];let f;e[13]!==o||e[14]!==u||e[15]!==x||e[16]!==d?(f=(0,r.jsx)(D,{"aria-label":u,className:"h-8 w-32","data-testid":"lg-req-user",onChange:o,placeholder:x,value:d}),e[13]=o,e[14]=u,e[15]=x,e[16]=d,e[17]=f):f=e[17];let C;e[18]!==a?(C=a("Table touched"),e[18]=a,e[19]=C):C=e[19];let y;e[20]!==a?(y=a("table"),e[20]=a,e[21]=y):y=e[21];let w;e[22]!==n||e[23]!==C||e[24]!==y||e[25]!==m?(w=(0,r.jsx)(D,{"aria-label":C,className:"h-8 w-32","data-testid":"lg-req-table",onChange:n,placeholder:y,value:m}),e[22]=n,e[23]=C,e[24]=y,e[25]=m,e[26]=w):w=e[26];let k;e[27]!==a?(k=a("Outcome filter"),e[27]=a,e[28]=k):k=e[28];let L;e[29]!==a?(L=a("all"),e[29]=a,e[30]=L):L=e[30];let S;e[31]!==L?(S=(0,r.jsx)("option",{value:"all",children:L}),e[31]=L,e[32]=S):S=e[32];let T;e[33]!==a?(T=a("ok"),e[33]=a,e[34]=T):T=e[34];let R;e[35]!==T?(R=(0,r.jsx)("option",{value:"ok",children:T}),e[35]=T,e[36]=R):R=e[36];let P;e[37]!==a?(P=a("error"),e[37]=a,e[38]=P):P=e[38];let b;e[39]!==P?(b=(0,r.jsx)("option",{value:"error",children:P}),e[39]=P,e[40]=b):b=e[40];let N;e[41]!==t||e[42]!==c||e[43]!==k||e[44]!==S||e[45]!==R||e[46]!==b?(N=(0,r.jsxs)("select",{"aria-label":k,className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm shadow-xs focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none","data-testid":"lg-req-outcome",onChange:t,value:c,children:[S,R,b]}),e[41]=t,e[42]=c,e[43]=k,e[44]=S,e[45]=R,e[46]=b,e[47]=N):N=e[47];let F;return e[48]!==N||e[49]!==g||e[50]!==f||e[51]!==w?(F=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[g,f,w,N]}),e[48]=N,e[49]=g,e[50]=f,e[51]=w,e[52]=F):F=e[52],F},"je"),Oe=v(i=>{let e=(0,K.c)(7),{bucket:t}=i,s;e[0]!==t.key?(s=(0,r.jsx)("span",{className:"truncate text-muted-foreground",role:"gridcell",children:t.key}),e[0]=t.key,e[1]=s):s=e[1];let n;e[2]!==t.count?(n=(0,r.jsx)("span",{className:"shrink-0 tabular-nums",role:"gridcell",children:t.count}),e[2]=t.count,e[3]=n):n=e[3];let o;return e[4]!==s||e[5]!==n?(o=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 px-3 py-1 font-mono text-xs","data-testid":"logs-summary-row",role:"row",children:[s,n]}),e[4]=s,e[5]=n,e[6]=o):o=e[6],o},"pe"),He=v(i=>{let e=(0,K.c)(31),{summary:t}=i,s=z(),n;e[0]!==t.total||e[1]!==s?(n=s("{count} entries",{count:t.total}),e[0]=t.total,e[1]=s,e[2]=n):n=e[2];let o;e[3]!==n?(o=(0,r.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"logs-summary-total",children:n}),e[3]=n,e[4]=o):o=e[4];let c;e[5]!==s?(c=s("By level"),e[5]=s,e[6]=c):c=e[6];let p;e[7]!==c?(p=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),e[7]=c,e[8]=p):p=e[8];let m;e[9]!==t.byLevel?(m=t.byLevel.map(Je),e[9]=t.byLevel,e[10]=m):m=e[10];let d;e[11]!==m?(d=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-levels",role:"grid",children:m}),e[11]=m,e[12]=d):d=e[12];let a;e[13]!==p||e[14]!==d?(a=(0,r.jsxs)("div",{children:[p,d]}),e[13]=p,e[14]=d,e[15]=a):a=e[15];let h;e[16]!==s?(h=s("By function"),e[16]=s,e[17]=h):h=e[17];let l;e[18]!==h?(l=(0,r.jsx)("h4",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[18]=h,e[19]=l):l=e[19];let g;e[20]!==t.byPath?(g=t.byPath.map(Xe),e[20]=t.byPath,e[21]=g):g=e[21];let u;e[22]!==g?(u=(0,r.jsx)("div",{className:"overflow-hidden rounded-lg border border-border","data-testid":"logs-summary-paths",role:"grid",children:g}),e[22]=g,e[23]=u):u=e[23];let x;e[24]!==u||e[25]!==l?(x=(0,r.jsxs)("div",{children:[l,u]}),e[24]=u,e[25]=l,e[26]=x):x=e[26];let f;return e[27]!==x||e[28]!==o||e[29]!==a?(f=(0,r.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"logs-summary",children:[o,a,x]}),e[27]=x,e[28]=o,e[29]=a,e[30]=f):f=e[30],f},"Je");function Je(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Je,"Xe");function Xe(i){return(0,r.jsx)(Oe,{bucket:i},i.key)}v(Xe,"Ze");var Ze=v(i=>{let e=(0,K.c)(46),{liveError:t,onShardKeyChange:s,onShowArchive:n,onShowErrors:o,onShowRequests:c,shardKey:p,view:m}=i,d=z(),a=m==="requests",h=m==="requests"?"bg-muted font-medium":"text-muted-foreground",l;e[0]!==h?(l=W("px-3 py-1 text-sm",h),e[0]=h,e[1]=l):l=e[1];let g;e[2]!==d?(g=d("Requests"),e[2]=d,e[3]=g):g=e[3];let u;e[4]!==c||e[5]!==a||e[6]!==l||e[7]!==g?(u=(0,r.jsx)("button",{"aria-selected":a,className:l,"data-testid":"lg-view-requests",onClick:c,role:"tab",type:"button",children:g}),e[4]=c,e[5]=a,e[6]=l,e[7]=g,e[8]=u):u=e[8];let x=m==="errors",f=m==="errors"?"bg-muted font-medium":"text-muted-foreground",C;e[9]!==f?(C=W("px-3 py-1 text-sm",f),e[9]=f,e[10]=C):C=e[10];let y;e[11]!==d?(y=d("Errors"),e[11]=d,e[12]=y):y=e[12];let w;e[13]!==o||e[14]!==x||e[15]!==C||e[16]!==y?(w=(0,r.jsx)("button",{"aria-selected":x,className:C,"data-testid":"lg-view-errors",onClick:o,role:"tab",type:"button",children:y}),e[13]=o,e[14]=x,e[15]=C,e[16]=y,e[17]=w):w=e[17];let k=m==="archive",L=m==="archive"?"bg-muted font-medium":"text-muted-foreground",S;e[18]!==L?(S=W("px-3 py-1 text-sm",L),e[18]=L,e[19]=S):S=e[19];let T;e[20]!==d?(T=d("Archive"),e[20]=d,e[21]=T):T=e[21];let R;e[22]!==n||e[23]!==k||e[24]!==S||e[25]!==T?(R=(0,r.jsx)("button",{"aria-selected":k,className:S,"data-testid":"lg-view-archive",onClick:n,role:"tab",type:"button",children:T}),e[22]=n,e[23]=k,e[24]=S,e[25]=T,e[26]=R):R=e[26];let P;e[27]!==w||e[28]!==R||e[29]!==u?(P=(0,r.jsxs)("div",{className:"inline-flex overflow-hidden rounded-lg border border-border",role:"tablist",children:[u,w,R]}),e[27]=w,e[28]=R,e[29]=u,e[30]=P):P=e[30];let b;e[31]!==s||e[32]!==p?(b=(0,r.jsx)(ve,{onChange:s,testId:"lg-shard-input",value:p}),e[31]=s,e[32]=p,e[33]=b):b=e[33];let N;e[34]!==t||e[35]!==m?(N=m!=="archive"&&(0,r.jsx)(Ce,{message:t,prefix:"lg"}),e[34]=t,e[35]=m,e[36]=N):N=e[36];let F;e[37]!==d?(F=d("Open in Cloudflare"),e[37]=d,e[38]=F):F=e[38];let E;e[39]!==F?(E=(0,r.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"lg-cf-link",href:de,rel:"noreferrer",target:"_blank",children:F}),e[39]=F,e[40]=E):E=e[40];let O;return e[41]!==P||e[42]!==b||e[43]!==N||e[44]!==E?(O=(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[P,b,N,E]}),e[41]=P,e[42]=b,e[43]=N,e[44]=E,e[45]=O):O=e[45],O},"et"),ce=400,et=36,tt={height:ce,overflow:"auto"},Ke={left:0,position:"absolute",top:0,width:"100%"},rt={error:"destructive",ok:"secondary"},Me=v(i=>{let e=(0,K.c)(6),{onOpenTrace:t,traceId:s}=i,n=z(),o;e[0]!==t||e[1]!==n||e[2]!==s?(o=s===void 0?null:(0,r.jsx)("button",{className:"text-primary underline-offset-2 hover:underline","data-testid":"lg-trace-link",onClick:v(()=>{t(s)},"onClick"),type:"button",children:n("Trace")}),e[0]=t,e[1]=n,e[2]=s,e[3]=o):o=e[3];let c;return e[4]!==o?(c=(0,r.jsx)("span",{className:"w-16 shrink-0 text-right",role:"gridcell",children:o}),e[4]=o,e[5]=c):c=e[5],c},"be"),at=v(i=>{let e=(0,K.c)(13),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t?(a=(0,r.jsx)(qe,{entry:t}),e[2]=t,e[3]=a):a=e[3];let h;e[4]!==t.traceId||e[5]!==o?(h=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[4]=t.traceId,e[5]=o,e[6]=h):h=e[6];let l;return e[7]!==s||e[8]!==n||e[9]!==d||e[10]!==a||e[11]!==h?(l=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-row",ref:n,role:"row",style:d,children:[a,h]}),e[7]=s,e[8]=n,e[9]=d,e[10]=a,e[11]=h,e[12]=l):l=e[12],l},"lt"),Fe=v(i=>i.length===0?"\u2014":i.join(", "),"ce"),lt=v(i=>{let e=(0,K.c)(41),{entry:t,index:s,measureRef:n,onOpenTrace:o,start:c}=i,p=`translateY(${String(c)}px)`,m;e[0]!==p?(m={...Ke,transform:p},e[0]=p,e[1]=m):m=e[1];let d=m,a;e[2]!==t.ts?(a=new Date(t.ts).toLocaleString(),e[2]=t.ts,e[3]=a):a=e[3];let h;e[4]!==a?(h=(0,r.jsx)("span",{className:"w-40 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:a}),e[4]=a,e[5]=h):h=e[5];let l=rt[t.outcome],g;e[6]!==t.outcome||e[7]!==l?(g=(0,r.jsx)("span",{className:"w-16 shrink-0",role:"gridcell",children:(0,r.jsx)(ne,{variant:l,children:t.outcome})}),e[6]=t.outcome,e[7]=l,e[8]=g):g=e[8];let u;e[9]!==t.functionPath?(u=(0,r.jsx)("span",{className:"w-44 shrink-0 truncate",role:"gridcell",title:t.functionPath,children:t.functionPath}),e[9]=t.functionPath,e[10]=u):u=e[10];let x=t.shardKey??"\u2014",f;e[11]!==x?(f=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:x}),e[11]=x,e[12]=f):f=e[12];let C=t.userId??"\u2014",y;e[13]!==C?(y=(0,r.jsx)("span",{className:"w-24 shrink-0 truncate text-muted-foreground",role:"gridcell",children:C}),e[13]=C,e[14]=y):y=e[14];let w;e[15]!==t.durationMs?(w=Math.round(t.durationMs),e[15]=t.durationMs,e[16]=w):w=e[16];let k=`${String(w)}ms`,L;e[17]!==k?(L=(0,r.jsx)("span",{className:"w-16 shrink-0 tabular-nums text-muted-foreground",role:"gridcell",children:k}),e[17]=k,e[18]=L):L=e[18];let S;e[19]!==t.errorMessage||e[20]!==t.outcome||e[21]!==t.tablesRead||e[22]!==t.tablesWritten?(S=t.outcome==="error"&&t.errorMessage!==void 0?t.errorMessage:`r:${Fe(t.tablesRead)} \xB7 w:${Fe(t.tablesWritten)}`,e[19]=t.errorMessage,e[20]=t.outcome,e[21]=t.tablesRead,e[22]=t.tablesWritten,e[23]=S):S=e[23];let T;e[24]!==S?(T=(0,r.jsx)("span",{className:"flex-1 truncate text-muted-foreground",role:"gridcell",children:S}),e[24]=S,e[25]=T):T=e[25];let R;e[26]!==t.traceId||e[27]!==o?(R=(0,r.jsx)(Me,{onOpenTrace:o,traceId:t.traceId}),e[26]=t.traceId,e[27]=o,e[28]=R):R=e[28];let P;return e[29]!==s||e[30]!==n||e[31]!==d||e[32]!==y||e[33]!==L||e[34]!==T||e[35]!==R||e[36]!==h||e[37]!==g||e[38]!==u||e[39]!==f?(P=(0,r.jsxs)("div",{className:"flex items-center border-b border-border px-3 py-1.5 font-mono text-xs hover:bg-muted/50","data-index":s,"data-testid":"lg-req-row",ref:n,role:"row",style:d,children:[h,g,u,f,y,L,T,R]}),e[29]=s,e[30]=n,e[31]=d,e[32]=y,e[33]=L,e[34]=T,e[35]=R,e[36]=h,e[37]=g,e[38]=u,e[39]=f,e[40]=P):P=e[40],P},"ot"),Ee=v(i=>{let{entries:e}=i??{};return Array.isArray(e)?e:[]},"de"),ot=v(i=>{let e={};return i.functionPathPrefix.trim()!==""&&(e.functionPathPrefix=i.functionPathPrefix.trim()),i.userId.trim()!==""&&(e.userId=i.userId.trim()),i.tableTouched.trim()!==""&&(e.tableTouched=i.tableTouched.trim()),(i.outcome==="ok"||i.outcome==="error")&&(e.outcome=i.outcome),e},"nt"),nt={"5m":300*1e3,"15m":900*1e3,"1h":3600*1e3},st=v((i,e)=>{let t=e.search.trim().toLowerCase(),s=e.path.trim().toLowerCase(),n=e.range==="all"?Number.NEGATIVE_INFINITY:e.now-nt[e.range];return i.filter(o=>e.levels.size>0&&!e.levels.has(o.level)||o.timestamp<n||s!==""&&!(o.functionPath??"").toLowerCase().includes(s)?!1:t===""||o.message.toLowerCase().includes(t)||Te(o.fields).toLowerCase().includes(t))},"it"),it="\u2014",dt=v(i=>{let e=new Map,t=new Map;for(let o of i){e.set(o.level,(e.get(o.level)??0)+1);let c=o.functionPath??it;t.set(c,(t.get(c)??0)+1)}let s=ue.filter(o=>e.has(o)).map(o=>({count:e.get(o)??0,key:o})),n=[...t.entries()].map(([o,c])=>({count:c,key:o})).toSorted((o,c)=>c.count===o.count?o.key.localeCompare(c.key):c.count-o.count);return{byLevel:s,byPath:n,total:i.length}},"dt"),Et=v(({initialShardKey:i})=>{let e=z(),[t,s]=(0,q.useState)("requests"),{queryShardKey:n,setShardKey:o,shardKey:c}=be(i),[p,m]=(0,q.useState)(""),[d,a]=(0,q.useState)(()=>new Set),[h,l]=(0,q.useState)(""),[g,u]=(0,q.useState)("all"),[x,f]=(0,q.useState)(!1),[C,y]=(0,q.useState)(""),[w,k]=(0,q.useState)(""),[L,S]=(0,q.useState)(""),[T,R]=(0,q.useState)("all"),P=ot({functionPathPrefix:C,outcome:T,tableTouched:L,userId:w}),b=le(oe.getRequestLog,P,{enabled:t==="requests",live:!0,shardKey:n}),N=le(oe.getLogs,{},{enabled:t==="errors",live:!0,shardKey:n}),F=t==="requests"?b:N,{error:E,errorSource:O,isLoading:M,liveError:V}=F,_=Se(n),U=Ee(N.data),A=Ee(b.data);(0,q.useEffect)(()=>{F.data!==void 0&&fe(n)},[F.data,n]);let $=st(U,{levels:d,now:Date.now(),path:h,range:g,search:p}),Q=dt($),X=t==="requests"?A.length:$.length,Z=t==="errors"&&x,Y=(0,q.useMemo)(()=>E!==null?"error":X===0?M?Z?"summary":"list":"empty":Z?"summary":"list",[X,M,E,Z]),me=(0,q.useRef)(null),G=ke({count:X,estimateSize:v(()=>et,"estimateSize"),getItemKey:v(I=>t==="errors"?$[I]?.id??I:I,"getItemKey"),getScrollElement:v(()=>me.current,"getScrollElement"),initialRect:{height:ce,width:800},observeElementRect:v((I,ee)=>Le(I,ee,ce),"observeElementRect"),overscan:8}),_e=G.getVirtualItems(),Ae={height:G.getTotalSize(),position:"relative",width:"100%"};return(0,r.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-logs",children:[(0,r.jsx)(Ze,{liveError:V,onShardKeyChange:o,onShowArchive:v(()=>{s("archive"),f(!1)},"onShowArchive"),onShowErrors:v(()=>{s("errors"),f(!1)},"onShowErrors"),onShowRequests:v(()=>{s("requests"),f(!1)},"onShowRequests"),shardKey:c,view:t}),t==="errors"&&(0,r.jsx)(Ye,{levelFilter:d,onLogPathChange:v(I=>{l(I.target.value)},"onLogPathChange"),onSearchChange:v(I=>{m(I.target.value)},"onSearchChange"),onTimeRangeChange:v(I=>{u(I.target.value)},"onTimeRangeChange"),onToggleLevel:v(I=>{a(ee=>{let H=new Set(ee);return H.has(I)?H.delete(I):H.add(I),H})},"onToggleLevel"),onToggleSummary:v(()=>{f(I=>!I)},"onToggleSummary"),pathFilter:h,search:p,showSummary:x,timeRange:g}),t==="requests"&&(0,r.jsx)(Ge,{onOutcomeChange:v(I=>{R(I.target.value)},"onOutcomeChange"),onPathChange:v(I=>{y(I.target.value)},"onPathChange"),onTableChange:v(I=>{S(I.target.value)},"onTableChange"),onUserChange:v(I=>{k(I.target.value)},"onUserChange"),outcomeFilter:T,pathPrefix:C,tableFilter:L,userIdFilter:w}),t==="archive"?(0,r.jsx)(Ve,{shardKey:n}):(0,r.jsxs)(r.Fragment,{children:[Y==="error"&&(0,r.jsx)(xe,{error:O,shardKey:n,testId:"lg-error"}),Y==="empty"&&(0,r.jsx)(J,{description:e("Function and request logs for this shard show up here as your app handles traffic."),icon:(0,r.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 5h16M4 12h16M4 19h10"})}),testId:"lg-empty",title:e("No logs.")}),Y==="summary"&&(0,r.jsx)(He,{summary:Q}),Y==="list"&&(0,r.jsx)("div",{className:"rounded-xl border border-border shadow-xs","data-testid":"lg-scroll",ref:me,style:tt,children:(0,r.jsx)("div",{"aria-label":e("Recent logs"),"data-testid":"lg-table",role:"grid",style:Ae,children:_e.map(I=>t==="requests"?(0,r.jsx)(lt,{entry:A[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key):(0,r.jsx)(at,{entry:$[I.index],index:I.index,measureRef:G.measureElement,onOpenTrace:_,start:I.start},I.key))})})]})]})},"jt");export{Et as LogsPanel,st as filterLogs,dt as summarizeLogs};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-YLC2ZYCL.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-LLD7TMBV.js";import{a as j,b as te}from"./chunk-WMKSIEJP.js";import{a as V}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-6C555TU5.js";import"./chunk-XV2XEUUB.js";import{n as Q}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
1
+ import{a as ee}from"./chunk-2KTN53PK.js";import{a as Z}from"./chunk-LFWS6VBU.js";import{b as Y}from"./chunk-EDL46BPM.js";import{a as X}from"./chunk-DA2CAFXI.js";import{a as W}from"./chunk-UEONVTOV.js";import"./chunk-4KPATTV6.js";import{i as D}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{b as ae,c as ne}from"./chunk-UQ3WOVL2.js";import{a as j,b as te}from"./chunk-DW5KLXPI.js";import{a as V}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import"./chunk-PUTERXSU.js";import"./chunk-ZIY53FID.js";import"./chunk-KMBE7RTC.js";import"./chunk-4YZAJTU5.js";import"./chunk-UDKKUJHY.js";import"./chunk-EOFWXI3T.js";import{a as I}from"./chunk-LYVYUTQY.js";import{c as A}from"./chunk-NP6H72XD.js";import"./chunk-NPHGFVNE.js";import{n as Q}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as q,h as M,i as C,o as G,s as N}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as me}from"./chunk-A6TVTNKO.js";import{a as he,b as pe}from"./chunk-ADABTCDI.js";import{a as l,d as _}from"./chunk-5PEAXTYQ.js";var E=_(me(),1);var c=_(he(),1);var S=_(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:n}=t;if(typeof n!="string"||n.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:r}=e;return!Array.isArray(a)||a.length===0||a.some(i=>typeof i!="string"||i.length===0)?!1:typeof r=="string"&&r.length>0},"xe"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(n=>JSON.stringify(n)).join(", ")}])`,"ge"),xe=l(t=>{let e=(0,E.c)(19),{fields:n,indexName:a,table:r,testId:i}=t,u=q(),[h,f]=(0,c.useState)(null),m;e[0]!==n||e[1]!==a?(m=l(()=>{let b=be(a,n),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=n,e[1]=a,e[2]=m):m=e[2];let y=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==r||e[7]!==i?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${i}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:r})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${i}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:r}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=r,e[7]=i,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==r?(p=u("Copy index declaration for {table}",{table:r}),e[11]=u,e[12]=r,e[13]=p):p=e[13];let w;return e[14]!==y||e[15]!==T||e[16]!==p||e[17]!==i?(w=(0,S.jsx)(W,{confirmLabel:T,onConfirm:y,testId:i,children:p}),e[14]=y,e[15]=T,e[16]=p,e[17]=i,e[18]=w):w=e[18],w},"ve"),ye=l((t,e)=>{let n=new Map;for(let a of e){let r=`${a.table} ${a.index}`;n.set(r,(n.get(r)??0)+a.reads)}return t.map(a=>({index:a.index,reads:n.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let n of t)for(let a of n.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([n,a])=>({scans:a,table:n}))},"Te"),re=l((t,e)=>e.filter(n=>n.type!=="vector"&&n.unique!==!0).map(n=>({index:n.name,table:t})),"P"),we=l(t=>{let e=ye(t.declaredIndexes??[],t.indexHits??[]),n=ve(t.functions??[]),a=t.shardTraffic??[],r=t.analyticsMetrics,i=r&&r.indexHits.length>0?r.indexHits:e,u=r&&r.tableScans.length>0?r.tableScans:n,h=r&&r.shardTraffic.length>0?r.shardTraffic:a,f=ne({indexHits:i,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(y=>!(y.metadata.kind==="hot_scan"&&typeof y.metadata.table=="string"&&m.has(y.metadata.table)))).map(y=>j(y))},"we"),Se=M(I.listTables),Te=M(I.listTableIndexes),Ie=M(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"H"),se=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),ie=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:se(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:se(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:G(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:n,table:a}=t,r=q(),i;e[0]!==n||e[1]!==a?(i=l(()=>{n(a)},"o"),e[0]=n,e[1]=a,e[2]=i):i=e[2];let u=i,h=`in-add-index-${a}`,f;e[3]!==r||e[4]!==a?(f=r("Add index on {table}",{table:a}),e[3]=r,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(V,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let n=Q(),a=D(),r=q(),{queryShardKey:i,setShardKey:u,shardKey:h}=ee(t),[f,m]=(0,c.useState)(null),[y,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=A(I.getMetrics,{},{live:!0,shardKey:i}),b=A(I.getFunctionStats,{},{live:!0,shardKey:i}),$=A(I.getAdvisories,{},{live:!0,shardKey:i}),L=w.data??null,K=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(s=>n.shardTraffic(s)),le=l(async(s,x)=>{let o=s[0];if(o===void 0||o===""){p.current===x&&T(null);return}try{let g=await oe(o);if(p.current!==x)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===x&&T(null)}},"Y"),de=l(async(s,x)=>{let o=await Promise.allSettled(s.map(async d=>[d,await n.query(Te,{table:d},C(x))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...re(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async s=>{p.current=s;let x=[];try{let o=await n.query(Se,{},C(s));if(p.current!==s)return;Y(s),x=o.map(d=>d.name);let g=[];if(x.length>0)try{let d=await n.query(Ie,{tables:x},C(s));if(p.current!==s)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...re(v,k))}catch{if(g=await de(x,s),p.current!==s)return}m(g)}catch{p.current===s&&m(null)}await le(x,s)});(0,c.useEffect)(()=>{N(z(i))},[i]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(i))});(0,c.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let U=(0,c.useCallback)(s=>{N(a({search:{table:s},to:"/schema"}))},[a]),H=(0,c.useMemo)(()=>X(L,K),[K,L]),P=(0,c.useMemo)(()=>new Set(H.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),[H]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:K,indexHits:J,shardTraffic:y,suppressHotScanTables:P}),[f,K,J,P,y]),ue=(0,c.useMemo)(()=>{let s=H.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?ie(r,o):`${ie(r,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(r,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),x=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=j(o);if(x.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(xe,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...s]},[F,H,U,R,r]),fe=(0,S.jsx)(Z,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(te,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,shardKey:i,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
@@ -1 +1 @@
1
- import{g as j,h as g,i as D,n as q}from"./chunk-C6FOSG2A.js";import{h as v,i as S,j as P,s as w}from"./chunk-2ZJJH4YN.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
1
+ import{g as j,h as g,i as D,n as q}from"./chunk-YESGXFAR.js";import{h as v,i as S,j as P,s as w}from"./chunk-CDIV23I2.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
@@ -1 +1 @@
1
- import{x as c}from"./chunk-2ZJJH4YN.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as u}from"./chunk-ADABTCDI.js";import{a as o,d as n}from"./chunk-5PEAXTYQ.js";var l=n(m(),1);var i=n(u(),1);function f({className:d,size:a="default",...t}){return(0,i.jsx)("div",{"data-slot":"card","data-size":a,className:c("group/card flex flex-col gap-4 overflow-hidden rounded-xl border border-border bg-card py-4 text-xs/relaxed text-card-foreground shadow-xs has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-md *:[img:last-child]:rounded-md",d),...t})}o(f,"p");function x(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-md px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-header",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(x,"f");function g(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("font-heading text-sm font-medium group-data-[size=sm]/card:text-sm",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-title",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(g,"u");function h(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("text-xs/relaxed text-muted-foreground",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-description",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(h,"x");function b(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("px-4 group-data-[size=sm]/card:px-3",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-content",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(b,"g");export{f as a,x as b,g as c,h as d,b as e};
1
+ import{x as c}from"./chunk-CDIV23I2.js";import{a as m}from"./chunk-A6TVTNKO.js";import{b as u}from"./chunk-ADABTCDI.js";import{a as o,d as n}from"./chunk-5PEAXTYQ.js";var l=n(m(),1);var i=n(u(),1);function f({className:d,size:a="default",...t}){return(0,i.jsx)("div",{"data-slot":"card","data-size":a,className:c("group/card flex flex-col gap-4 overflow-hidden rounded-xl border border-border bg-card py-4 text-xs/relaxed text-card-foreground shadow-xs has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-2 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-md *:[img:last-child]:rounded-md",d),...t})}o(f,"p");function x(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-md px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-header",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(x,"f");function g(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("font-heading text-sm font-medium group-data-[size=sm]/card:text-sm",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-title",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(g,"u");function h(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("text-xs/relaxed text-muted-foreground",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-description",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(h,"x");function b(d){let a=(0,l.c)(8),t,e;a[0]!==d?({className:t,...e}=d,a[0]=d,a[1]=t,a[2]=e):(t=a[1],e=a[2]);let r;a[3]!==t?(r=c("px-4 group-data-[size=sm]/card:px-3",t),a[3]=t,a[4]=r):r=a[4];let s;return a[5]!==e||a[6]!==r?(s=(0,i.jsx)("div",{"data-slot":"card-content",className:r,...e}),a[5]=e,a[6]=r,a[7]=s):s=a[7],s}o(b,"g");export{f as a,x as b,g as c,h as d,b as e};
@@ -1 +1 @@
1
- import{a as je}from"./chunk-O66HDCZT.js";import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-JQBVRWFN.js";import"./chunk-T7UKRA6J.js";import{a as qe}from"./chunk-NAGIOR23.js";import"./chunk-QF743FSL.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ze}from"./chunk-2KTN53PK.js";import{a as _e}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as le}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Ee}from"./chunk-HMMALUXM.js";import{b as me}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Re,c as Ve,d as pe,e as B,f as L}from"./chunk-ZJIYJZ6F.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as Ce}from"./chunk-6C555TU5.js";import{a as Ke,e as Te}from"./chunk-XV2XEUUB.js";import{n as be}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as ue,e as Se,f as $e,h as ie,i as Ne,j as ke,s as re,w as Me}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Ge}from"./chunk-A6TVTNKO.js";import{a as Oe,b as He}from"./chunk-ADABTCDI.js";import{a as d,d as ye}from"./chunk-5PEAXTYQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Ie="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=ie(U.resolveIssue),Xe=ie(U.ignoreIssue),Fe=ie(U.assignIssue),Ye=ie(U.setIssueSeverity),Ze=ie(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=be(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=je(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},S=await i.query(Ze,g,Ne($));o(S)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Se(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(le,{"data-testid":b,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=z,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let I;return e[41]!==c||e[42]!==E?(I=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=I):I=e[43],I},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Ie?null:ae;re(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let I=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let S;e[33]!==s.status||e[34]!==I||e[35]!==g?(S=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":I,variant:g,children:s.status})}),e[33]=s.status,e[34]=I,e[35]=g,e[36]=S):S=e[36];let V=s.severity??Ie,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,j;e[39]!==a?(j=a("\u2014"),e[39]=a,e[40]=j):j=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==j||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:j,children:N}),e[44]=j,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Ie,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==z||e[58]!==V||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(L,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:z,value:V,children:[q,D]})}),e[56]=u,e[57]=z,e[58]=V,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(Ae,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Me(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(le,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(le,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(le,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==S||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,S,F,H,J,Q,ee]}),e[103]=c,e[104]=S,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=be(),{queryShardKey:i,setShardKey:l,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ce(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,j)=>{z(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...j,hash:r},Ne(i))}catch(N){let C=ke(N);z(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"v"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let I;e[27]!==x?(I=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=I):I=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(le,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let S;e[32]!==g?(S=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=S):S=e[33];let V;e[34]!==S||e[35]!==c||e[36]!==I?(V=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,I,S]}),e[34]=S,e[35]=c,e[36]=I,e[37]=V):V=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,V,M&&y.length===0?(0,t.jsx)(Ee,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Ke,{className:"overflow-hidden py-0",children:(0,t.jsx)(Te,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Ve,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
1
+ import{a as je}from"./chunk-PLDE5R5Y.js";import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-UNUSBFIC.js";import"./chunk-T7UKRA6J.js";import{a as qe}from"./chunk-PRVBT5AJ.js";import"./chunk-QF743FSL.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ze}from"./chunk-2KTN53PK.js";import{a as _e}from"./chunk-LFWS6VBU.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-Z6PYAG36.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as le}from"./chunk-QHI77TGI.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Ee}from"./chunk-O46IV64X.js";import{b as me}from"./chunk-OOPMRFI2.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Re,c as Ve,d as pe,e as B,f as L}from"./chunk-KMBE7RTC.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as Ce}from"./chunk-NP6H72XD.js";import{a as Ke,e as Te}from"./chunk-NPHGFVNE.js";import{n as be}from"./chunk-YESGXFAR.js";import"./chunk-ZPQBVYNN.js";import{B as ue,e as Se,f as $e,h as ie,i as Ne,j as ke,s as re,w as Me}from"./chunk-CDIV23I2.js";import"./chunk-PDBW6GTJ.js";import{a as Ge}from"./chunk-A6TVTNKO.js";import{a as Oe,b as He}from"./chunk-ADABTCDI.js";import{a as d,d as ye}from"./chunk-5PEAXTYQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Ie="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=ie(U.resolveIssue),Xe=ie(U.ignoreIssue),Fe=ie(U.assignIssue),Ye=ie(U.setIssueSeverity),Ze=ie(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=be(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=je(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},S=await i.query(Ze,g,Ne($));o(S)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Se(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(le,{"data-testid":b,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=z,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let I;return e[41]!==c||e[42]!==E?(I=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=I):I=e[43],I},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Ie?null:ae;re(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let I=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let S;e[33]!==s.status||e[34]!==I||e[35]!==g?(S=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":I,variant:g,children:s.status})}),e[33]=s.status,e[34]=I,e[35]=g,e[36]=S):S=e[36];let V=s.severity??Ie,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,j;e[39]!==a?(j=a("\u2014"),e[39]=a,e[40]=j):j=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==j||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:j,children:N}),e[44]=j,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Ie,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==z||e[58]!==V||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(L,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:z,value:V,children:[q,D]})}),e[56]=u,e[57]=z,e[58]=V,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(Ae,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Me(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(le,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(le,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(le,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==S||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,S,F,H,J,Q,ee]}),e[103]=c,e[104]=S,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=be(),{queryShardKey:i,setShardKey:l,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ce(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,j)=>{z(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...j,hash:r},Ne(i))}catch(N){let C=ke(N);z(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"v"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let I;e[27]!==x?(I=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=I):I=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(le,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let S;e[32]!==g?(S=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=S):S=e[33];let V;e[34]!==S||e[35]!==c||e[36]!==I?(V=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,I,S]}),e[34]=S,e[35]=c,e[36]=I,e[37]=V):V=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,V,M&&y.length===0?(0,t.jsx)(Ee,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Ke,{className:"overflow-hidden py-0",children:(0,t.jsx)(Te,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Ve,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
@@ -1 +1 @@
1
- import{x as h}from"./chunk-2ZJJH4YN.js";import{a as b}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as u,d as g}from"./chunk-5PEAXTYQ.js";var v=g(b(),1);var t=g(j(),1);var z=u(N=>{let e=(0,v.c)(19),{action:a,className:x,description:c,icon:m,testId:f,title:p}=N,s;e[0]!==x?(s=h("flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border px-6 py-14 text-center",x),e[0]=x,e[1]=s):s=e[1];let r;e[2]!==m?(r=m!==void 0&&(0,t.jsx)("span",{className:"flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-5",children:m}),e[2]=m,e[3]=r):r=e[3];let d;e[4]!==p?(d=(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:p}),e[4]=p,e[5]=d):d=e[5];let l;e[6]!==c?(l=c!==void 0&&(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:c}),e[6]=c,e[7]=l):l=e[7];let o;e[8]!==d||e[9]!==l?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[d,l]}),e[8]=d,e[9]=l,e[10]=o):o=e[10];let i;e[11]!==a?(i=a!==void 0&&(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2",children:a}),e[11]=a,e[12]=i):i=e[12];let n;return e[13]!==s||e[14]!==r||e[15]!==o||e[16]!==i||e[17]!==f?(n=(0,t.jsxs)("div",{className:s,"data-testid":f,children:[r,o,i]}),e[13]=s,e[14]=r,e[15]=o,e[16]=i,e[17]=f,e[18]=n):n=e[18],n},"y");export{z as a};
1
+ import{x as h}from"./chunk-CDIV23I2.js";import{a as b}from"./chunk-A6TVTNKO.js";import{b as j}from"./chunk-ADABTCDI.js";import{a as u,d as g}from"./chunk-5PEAXTYQ.js";var v=g(b(),1);var t=g(j(),1);var z=u(N=>{let e=(0,v.c)(19),{action:a,className:x,description:c,icon:m,testId:f,title:p}=N,s;e[0]!==x?(s=h("flex flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border px-6 py-14 text-center",x),e[0]=x,e[1]=s):s=e[1];let r;e[2]!==m?(r=m!==void 0&&(0,t.jsx)("span",{className:"flex size-10 items-center justify-center rounded-lg bg-muted text-muted-foreground [&_svg]:size-5",children:m}),e[2]=m,e[3]=r):r=e[3];let d;e[4]!==p?(d=(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:p}),e[4]=p,e[5]=d):d=e[5];let l;e[6]!==c?(l=c!==void 0&&(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:c}),e[6]=c,e[7]=l):l=e[7];let o;e[8]!==d||e[9]!==l?(o=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[d,l]}),e[8]=d,e[9]=l,e[10]=o):o=e[10];let i;e[11]!==a?(i=a!==void 0&&(0,t.jsx)("div",{className:"mt-1 flex items-center gap-2",children:a}),e[11]=a,e[12]=i):i=e[12];let n;return e[13]!==s||e[14]!==r||e[15]!==o||e[16]!==i||e[17]!==f?(n=(0,t.jsxs)("div",{className:s,"data-testid":f,children:[r,o,i]}),e[13]=s,e[14]=r,e[15]=o,e[16]=i,e[17]=f,e[18]=n):n=e[18],n},"y");export{z as a};