@lunora/studio 1.0.0-alpha.88 → 1.0.0-alpha.89

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 (56) hide show
  1. package/dist/standalone/{chunk-4JIOFDMR.js → chunk-24JLZ2Z5.js} +1 -1
  2. package/dist/standalone/{chunk-EWDLYYJM.js → chunk-3AV5CV6K.js} +1 -1
  3. package/dist/standalone/{chunk-XZN645UJ.js → chunk-4COKHD2C.js} +1 -1
  4. package/dist/standalone/{chunk-T2Q7I3V2.js → chunk-53KJRSHE.js} +1 -1
  5. package/dist/standalone/{chunk-UNVK2VZP.js → chunk-5ZXDB6LB.js} +1 -1
  6. package/dist/standalone/{chunk-LYRAWNV7.js → chunk-62EKHKTS.js} +1 -1
  7. package/dist/standalone/{chunk-B5S6GSUC.js → chunk-67DKQC23.js} +1 -1
  8. package/dist/standalone/{chunk-PDMZITZZ.js → chunk-6MKDYZ7A.js} +1 -1
  9. package/dist/standalone/{chunk-TVGKSIIW.js → chunk-6VTLIGVX.js} +1 -1
  10. package/dist/standalone/{chunk-EAIUBZA5.js → chunk-AQX2QFCN.js} +1 -1
  11. package/dist/standalone/{chunk-HYCMT2V5.js → chunk-ARP36PTE.js} +1 -1
  12. package/dist/standalone/{chunk-7DNDRUMZ.js → chunk-AUQKJYHL.js} +1 -1
  13. package/dist/standalone/{chunk-CLNB7I3O.js → chunk-AZAGCJVI.js} +1 -1
  14. package/dist/standalone/{chunk-SMEW3ZTU.js → chunk-BL6NO3U3.js} +1 -1
  15. package/dist/standalone/{chunk-L4RW5BFD.js → chunk-BRQMMGOS.js} +1 -1
  16. package/dist/standalone/{chunk-NMLCYY4H.js → chunk-BUTBQGUU.js} +1 -1
  17. package/dist/standalone/{chunk-OOWHAURL.js → chunk-C3HXK3A5.js} +1 -1
  18. package/dist/standalone/{chunk-NBUBAW3V.js → chunk-CT6ZDXLL.js} +1 -1
  19. package/dist/standalone/{chunk-EVTCXQ5D.js → chunk-D3HXVA33.js} +1 -1
  20. package/dist/standalone/{chunk-SJZQPIZB.js → chunk-DG7YINFM.js} +1 -1
  21. package/dist/standalone/{chunk-BDNDSBYM.js → chunk-DMCYISRF.js} +1 -1
  22. package/dist/standalone/{chunk-KJIBL5D4.js → chunk-E7TB4USI.js} +1 -1
  23. package/dist/standalone/{chunk-QJTGO4JG.js → chunk-GKSRVABT.js} +1 -1
  24. package/dist/standalone/{chunk-2VWWXVWK.js → chunk-GSKOAKQ2.js} +1 -1
  25. package/dist/standalone/{chunk-QXDMHM2V.js → chunk-IC64YIX5.js} +1 -1
  26. package/dist/standalone/{chunk-NCWUTRZB.js → chunk-JFW3YNVQ.js} +1 -1
  27. package/dist/standalone/{chunk-D3JTCLSF.js → chunk-LAHYLAT4.js} +1 -1
  28. package/dist/standalone/{chunk-YRYEZHOJ.js → chunk-LJIFMW67.js} +1 -1
  29. package/dist/standalone/{chunk-DABW4OOI.js → chunk-LJISXTZJ.js} +1 -1
  30. package/dist/standalone/{chunk-YFJXQUPW.js → chunk-LQAKPCFX.js} +1 -1
  31. package/dist/standalone/{chunk-6MGI5IN6.js → chunk-MHAXZQVO.js} +1 -1
  32. package/dist/standalone/{chunk-S2CXYDNT.js → chunk-OG2AMGOC.js} +1 -1
  33. package/dist/standalone/{chunk-EJ2CHD4G.js → chunk-PB7FNRDB.js} +1 -1
  34. package/dist/standalone/{chunk-5KRD6F67.js → chunk-PGC523I2.js} +1 -1
  35. package/dist/standalone/{chunk-F7NVC7YK.js → chunk-PM37X2V3.js} +1 -1
  36. package/dist/standalone/{chunk-WPUINKEO.js → chunk-QV6KV4SD.js} +1 -1
  37. package/dist/standalone/{chunk-PNAVAJAF.js → chunk-QWBRD6PX.js} +1 -1
  38. package/dist/standalone/{chunk-5X4OZ7OD.js → chunk-QYIOW7CD.js} +1 -1
  39. package/dist/standalone/{chunk-B5UFGO4E.js → chunk-SF4MF2FT.js} +1 -1
  40. package/dist/standalone/{chunk-TS6346VY.js → chunk-SHMNA6UL.js} +1 -1
  41. package/dist/standalone/{chunk-OUCGTB3Y.js → chunk-SP5SBO2W.js} +1 -1
  42. package/dist/standalone/{chunk-ORVR33FM.js → chunk-T6OAYQTX.js} +1 -1
  43. package/dist/standalone/{chunk-GZS3ORGS.js → chunk-TBBJPPZ3.js} +1 -1
  44. package/dist/standalone/{chunk-VQK34A2H.js → chunk-ULCZDGWQ.js} +1 -1
  45. package/dist/standalone/chunk-V2U5CL3S.js +11 -0
  46. package/dist/standalone/{chunk-IVCIG5J7.js → chunk-VFQDHG7I.js} +1 -1
  47. package/dist/standalone/{chunk-T3CGXSXO.js → chunk-WB5IUUUU.js} +1 -1
  48. package/dist/standalone/{chunk-GE5WTIWX.js → chunk-XZSGE5ST.js} +1 -1
  49. package/dist/standalone/{chunk-YKAO3JNJ.js → chunk-Y7JXGNXD.js} +1 -1
  50. package/dist/standalone/{chunk-UR3X4K4T.js → chunk-YOUKADZH.js} +1 -1
  51. package/dist/standalone/{chunk-SNK7TOOO.js → chunk-YU5CI2FD.js} +1 -1
  52. package/dist/standalone/{chunk-ZCFDQW4U.js → chunk-Z7G74IH4.js} +1 -1
  53. package/dist/standalone/{chunk-7FO57AZY.js → chunk-ZPLWCC4I.js} +1 -1
  54. package/dist/standalone/studio.js +1 -1
  55. package/package.json +4 -4
  56. package/dist/standalone/chunk-MIFLRBVS.js +0 -11
@@ -1 +1 @@
1
- import{a as f}from"./chunk-5Y3QLNWX.js";import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-QXXIJAD5.js";import{R as v}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-VDW32UET.js";import{f as P}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{d as q,f as y,g as c,h,m as p}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=y(w.getPitrBookmark),V=y(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}d(!1)},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}d(!1)})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let N=await m.mutation(V,t,c(i));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};
1
+ import{a as f}from"./chunk-5Y3QLNWX.js";import{a as U}from"./chunk-54MMVNPT.js";import{a as C}from"./chunk-QXXIJAD5.js";import{R as v}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as O}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as L}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as w}from"./chunk-VDW32UET.js";import{f as P}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{d as q,f as y,g as c,h,m as p}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as o,e as T,f as W,h as $}from"./chunk-3XIESWL4.js";var a=T(W(),1);var e=T($(),1);var R=y(w.getPitrBookmark),V=y(w.pitrRestore),ne=o(({initialShardKey:j})=>{let m=P(),r=q(),i=j??"",[z,x]=(0,a.useState)(null),[l,A]=(0,a.useState)(""),[B,I]=(0,a.useState)(null),[u,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[s,K]=(0,a.useState)(null),[F,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let t=await m.query(R,{},c(i));x(t.current)}catch(t){n(h(t))}d(!1)},[m,i]);(0,a.useEffect)(()=>{p(g())},[g]),U(()=>{p((async()=>{try{let t=await m.query(R,{},c(i));x(t.current)}catch{}})())},!0);let M=o(t=>{A(t.target.value)},"U"),Z=o(t=>{D(t.target.value)},"j"),_=o(t=>{E(t.target.checked)},"M"),G=o(()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{let t=await m.query(R,{time:l.trim()},c(i));I(t.forTime??null),x(t.current)}catch(t){I(null),n(h(t))}d(!1)})())},"z"),S=o(t=>{p((async()=>{d(!0),n(null);try{let N=await m.mutation(V,t,c(i));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"R"),H=u.trim()!==""||l.trim()!=="",J=o(()=>{let t=k?{restart:!0}:{};u.trim()===""?t.time=l.trim():t.bookmark=u.trim(),S(t)},"$"),Q=o(()=>{s!==null&&S(k?{bookmark:s.undoBookmark,restart:!0}:{bookmark:s.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[r("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:i===""?r("root"):i})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:r("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),F!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:F}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:r("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:z??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:r("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(O,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:r("Preview")})]}),B!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[r("Bookmark for that time"),": ",B]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:r("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:r("bookmark string"),value:u})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),r("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm restore"),disabled:b||!H,onConfirm:J,testId:"pitr-restore",children:r("Restore")})})]}),s!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:r("Restore armed")}),(0,e.jsx)(L,{variant:s.restarted?"destructive":"secondary",children:s.restarted?r("restarted now"):r("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[r("Restored to"),": ",s.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[r("Undo bookmark"),": ",s.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:r("Confirm undo"),disabled:b,onConfirm:Q,testId:"pitr-undo",children:r("Undo restore")})})]})]})},"de");export{ne as PitrPanel};
@@ -1 +1 @@
1
- import{a as $}from"./chunk-FW75RYZU.js";import{a as b}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as u}from"./chunk-VDW32UET.js";import{c as p}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as y,b as w,c as j,d as h,e as i,f as m}from"./chunk-MIQTKZAR.js";import{a as l,e as c}from"./chunk-UZERI5YC.js";import{d as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as o,e as S,h as E,j as x}from"./chunk-3XIESWL4.js";var e=S(E(),1);var n={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},P=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"S"),T=o(r=>r.toSorted((a,d)=>a.coverage==="clean"&&d.coverage!=="clean"?1:d.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-d.score),"E"),_=o(({testId:r="advisor-health"})=>{let a=k(),d=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=d.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??d.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(l,{children:(0,e.jsx)(c,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let I=T(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(l,{children:(0,e.jsxs)(c,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:n.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:n.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:n.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:n.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(l,{children:(0,e.jsxs)(c,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(l,{children:(0,e.jsx)(c,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(i,{className:"w-20",children:a("Score")}),(0,e.jsx)(i,{children:a("Procedure")}),(0,e.jsx)(i,{className:"w-32",children:a("Kind")}),(0,e.jsx)(i,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:I.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(m,{className:x("tabular-nums font-medium",n[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(m,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(m,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(m,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?P(s,a("no reason given")):s.checks.map(R=>R.name).join(", ")})]},s.id))})]})})})]})},"U");export{_ as default};
1
+ import{a as $}from"./chunk-FW75RYZU.js";import{a as b}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as u}from"./chunk-VDW32UET.js";import{c as p}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as y,b as w,c as j,d as h,e as i,f as m}from"./chunk-MIQTKZAR.js";import{a as l,e as c}from"./chunk-UZERI5YC.js";import{d as k}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as o,e as S,h as E,j as x}from"./chunk-3XIESWL4.js";var e=S(E(),1);var n={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},P=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"S"),T=o(r=>r.toSorted((a,d)=>a.coverage==="clean"&&d.coverage!=="clean"?1:d.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-d.score),"E"),_=o(({testId:r="advisor-health"})=>{let a=k(),d=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=d.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??d.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(l,{children:(0,e.jsx)(c,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let I=T(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(l,{children:(0,e.jsxs)(c,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:n.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:n.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:n.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:n.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(l,{children:(0,e.jsxs)(c,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(l,{children:(0,e.jsx)(c,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(i,{className:"w-20",children:a("Score")}),(0,e.jsx)(i,{children:a("Procedure")}),(0,e.jsx)(i,{className:"w-32",children:a("Kind")}),(0,e.jsx)(i,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:I.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(m,{className:x("tabular-nums font-medium",n[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(m,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(m,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(m,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?P(s,a("no reason given")):s.checks.map(R=>R.name).join(", ")})]},s.id))})]})})})]})},"U");export{_ as default};
@@ -1 +1 @@
1
- import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-OUCGTB3Y.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as j,c as I,d as g,e as c,f as a}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as _,q as S}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as m,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],L={},k=new Set(["active","trialing"]),U=new Set(["past_due","unpaid"]),n=m((s,t)=>{if(s[t]!==void 0)return s[t];let p=s.__doc__;if(typeof p=="string")try{let o=JSON.parse(p);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[t]}catch{}},"s"),i=m(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","i"),$=m(s=>k.has(s)?"default":U.has(s)?"destructive":"outline","J"),te=m(({limit:s=100})=>{let t=_(),p=E(),{data:o}=b(v.listTables,L,{live:!0}),D=o!==void 0,O=Array.isArray(o)&&H.every(r=>o.some(l=>l.name===r)),f=p.payments&&O,d=b(v.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),h=b(v.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});R(()=>{f&&(d.refetch(),h.refetch())},!0);let u=d.data?.rows??[],B=h.data?.rows??[],C=d.error??h.error,F=d.error===null?h.errorSource:d.errorSource,P=u.filter(r=>k.has(i(n(r,"state")))).length,J=B.toSorted((r,l)=>Number(n(l,"processedAt")??0)-Number(n(r,"processedAt")??0));return D&&!f?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(y,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),C===null?void 0:(0,e.jsx)(T,{error:F}),u.length===0&&!d.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(j,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(c,{children:t("Provider")}),(0,e.jsx)(c,{children:t("Reference")}),(0,e.jsx)(c,{children:t("Plan")}),(0,e.jsx)(c,{children:t("State")}),(0,e.jsx)(c,{children:t("Renews")})]})}),(0,e.jsx)(I,{children:u.map(r=>{let l=i(n(r,"state"));return(0,e.jsxs)(g,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{children:i(n(r,"referenceId"))}),(0,e.jsx)(a,{children:i(n(r,"priceId"))}),(0,e.jsx)(a,{children:(0,e.jsx)(x,{variant:$(l),children:l})}),(0,e.jsx)(a,{children:S(n(r,"currentPeriodEnd"))})]},i(n(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(y,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(I,{children:J.map(r=>(0,e.jsxs)(g,{"data-testid":"payment-event-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{className:"font-medium",children:i(n(r,"type"))}),(0,e.jsx)(a,{className:"text-muted-foreground",children:i(n(r,"providerEventId"))}),(0,e.jsx)(a,{children:S(n(r,"processedAt"))})]},i(n(r,"providerEventId"))))})})})]})]})},"re");export{te as PaymentsPanel};
1
+ import{a as R}from"./chunk-54MMVNPT.js";import{a as E}from"./chunk-SP5SBO2W.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as T}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as v}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as A,b as j,c as I,d as g,e as c,f as a}from"./chunk-MIQTKZAR.js";import{a as y,e as N}from"./chunk-UZERI5YC.js";import{d as _,q as S}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as m,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],L={},k=new Set(["active","trialing"]),U=new Set(["past_due","unpaid"]),n=m((s,t)=>{if(s[t]!==void 0)return s[t];let p=s.__doc__;if(typeof p=="string")try{let o=JSON.parse(p);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[t]}catch{}},"s"),i=m(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","i"),$=m(s=>k.has(s)?"default":U.has(s)?"destructive":"outline","J"),te=m(({limit:s=100})=>{let t=_(),p=E(),{data:o}=b(v.listTables,L,{live:!0}),D=o!==void 0,O=Array.isArray(o)&&H.every(r=>o.some(l=>l.name===r)),f=p.payments&&O,d=b(v.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:f}),h=b(v.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:f});R(()=>{f&&(d.refetch(),h.refetch())},!0);let u=d.data?.rows??[],B=h.data?.rows??[],C=d.error??h.error,F=d.error===null?h.errorSource:d.errorSource,P=u.filter(r=>k.has(i(n(r,"state")))).length,J=B.toSorted((r,l)=>Number(n(l,"processedAt")??0)-Number(n(r,"processedAt")??0));return D&&!f?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(y,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:u.length})})]})}),C===null?void 0:(0,e.jsx)(T,{error:F}),u.length===0&&!d.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(y,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(A,{children:[(0,e.jsx)(j,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(c,{children:t("Provider")}),(0,e.jsx)(c,{children:t("Reference")}),(0,e.jsx)(c,{children:t("Plan")}),(0,e.jsx)(c,{children:t("State")}),(0,e.jsx)(c,{children:t("Renews")})]})}),(0,e.jsx)(I,{children:u.map(r=>{let l=i(n(r,"state"));return(0,e.jsxs)(g,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{children:i(n(r,"referenceId"))}),(0,e.jsx)(a,{children:i(n(r,"priceId"))}),(0,e.jsx)(a,{children:(0,e.jsx)(x,{variant:$(l),children:l})}),(0,e.jsx)(a,{children:S(n(r,"currentPeriodEnd"))})]},i(n(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(y,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(A,{children:(0,e.jsx)(I,{children:J.map(r=>(0,e.jsxs)(g,{"data-testid":"payment-event-row",children:[(0,e.jsx)(a,{children:i(n(r,"provider"))}),(0,e.jsx)(a,{className:"font-medium",children:i(n(r,"type"))}),(0,e.jsx)(a,{className:"text-muted-foreground",children:i(n(r,"providerEventId"))}),(0,e.jsx)(a,{children:S(n(r,"processedAt"))})]},i(n(r,"providerEventId"))))})})})]})]})},"re");export{te as PaymentsPanel};
@@ -1 +1 @@
1
- import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as me}from"./chunk-XQCVZAGU.js";import{a as ae}from"./chunk-UZERI5YC.js";import{d as ce,q as pe}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as k,e as ie,g as xe,h as ge,j as Z}from"./chunk-3XIESWL4.js";var ne=ie(xe(),1);var a=ie(ge(),1);var ye="/_lunora/health",Ne="/_lunora/health/ready",ve=k((n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,"xe"),be=k(()=>{let n=oe();return async e=>{let w=e==="ready"?Ne:ye,t=n.getAuthToken(),_=ve(n.url,w);try{let l=await fetch(_,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),d=null;try{d=await l.json()}catch{d=null}return{body:d,ok:l.ok,status:l.status}}catch(l){return{body:null,error:l instanceof Error?l.message:String(l),ok:!1,status:0}}}},"Ne"),he={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},we=k(n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok","ye"),ue=k(n=>{let e=(0,ne.c)(13),{label:w,level:t,testId:_,value:l}=n,d=he[t],o;e[0]!==d?(o=Z("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=o):o=e[1];let c;e[2]!==o?(c=(0,a.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=c):c=e[3];let x;e[4]!==w||e[5]!==c?(x=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[c,w]}),e[4]=w,e[5]=c,e[6]=x):x=e[6];let g;e[7]!==_||e[8]!==l?(g=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":_,children:l}),e[7]=_,e[8]=l,e[9]=g):g=e[9];let u;return e[10]!==x||e[11]!==g?(u=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[x,g]})}),e[10]=x,e[11]=g,e[12]=u):u=e[12],u},"ne"),De=k(n=>{let e=(0,ne.c)(115),{probe:w}=n,t=ce(),_=be(),l=w??_,d;e[0]!==l?(d=k(async()=>{let[s,i]=await Promise.all([l("live"),l("ready")]);return{live:s,ready:i}},"d"),e[0]=l,e[1]=d):d=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=["deployment-health"],e[2]=o):o=e[2];let c;e[3]!==d?(c={queryFn:d,queryKey:o},e[3]=d,e[4]=c):c=e[4];let{data:x,isPending:g}=de(c),u=x?.live??null,fe=x?.ready??null;if(g){let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(le,{className:"h-16 w-full"}),(0,a.jsx)(le,{className:"h-40 w-full"})]}),e[5]=s):s=e[5],s}let r=u?.body??null;if(r===null){let s=u?.status===403,i;e[6]!==s||e[7]!==u?.error||e[8]!==t?(i=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=s,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let h;e[10]!==t?(h=t("Health endpoint unavailable"),e[10]=t,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==h?(p=(0,a.jsx)(me,{description:i,testId:"deployment-health-error",title:h}),e[12]=i,e[13]=h,e[14]=p):p=e[14],p}let ee;e[15]!==r.status?(ee=we(r.status),e[15]=r.status,e[16]=ee):ee=e[16];let j=ee,m;if(r.status==="unhealthy"){let s;e[17]!==t?(s=t("Unhealthy"),e[17]=t,e[18]=s):s=e[18],m=s}else if(r.status==="degraded"){let s;e[19]!==t?(s=t("Degraded"),e[19]=t,e[20]=s):s=e[20],m=s}else{let s;e[21]!==t?(s=t("Healthy"),e[21]=t,e[22]=s):s=e[22],m=s}let C=fe?.ok??!1,Y=C?"ok":"crit",z,I,y,N,v,S,V,b,$,H;if(e[23]!==r.appName||e[24]!==r.appVersion||e[25]!==r.checks||e[26]!==r.timestamp||e[27]!==j||e[28]!==Y||e[29]!==C||e[30]!==m||e[31]!==t){let s=[...r.checks].toSorted(_e);H="flex flex-col gap-6",I="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(y=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=y):y=e[45];let h=ke[j],p;e[46]!==h?(p=Z("flex size-10 shrink-0 items-center justify-center rounded-full",h),e[46]=h,e[47]=p):p=e[47];let se=he[j],D;e[48]!==se?(D=Z("size-3 rounded-full",se),e[48]=se,e[49]=D):D=e[49];let L;e[50]!==D?(L=(0,a.jsx)("span",{className:D}),e[50]=D,e[51]=L):L=e[51];let T;e[52]!==p||e[53]!==L?(T=(0,a.jsx)("span",{"aria-hidden":"true",className:p,children:L}),e[52]=p,e[53]=L,e[54]=T):T=e[54];let q;e[55]!==m?(q=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:m}),e[55]=m,e[56]=q):q=e[56];let E;e[57]!==r.appName||e[58]!==r.appVersion?(E=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[r.appName," \xB7 ",r.appVersion]}),e[57]=r.appName,e[58]=r.appVersion,e[59]=E):E=e[59];let R;e[60]!==q||e[61]!==E?(R=(0,a.jsxs)("div",{className:"grid leading-tight",children:[q,E]}),e[60]=q,e[61]=E,e[62]=R):R=e[62];let U;e[63]!==T||e[64]!==R?(U=(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[T,R]}),e[63]=T,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==r.timestamp?(F=pe(r.timestamp),e[70]=r.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=(0,a.jsxs)("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(N=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=N):N=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==j||e[83]!==m||e[84]!==W?(G=(0,a.jsx)(ue,{label:W,level:j,testId:"dh-liveness",value:m}),e[82]=j,e[83]=m,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==C||e[89]!==t?(M=t(C?"Ready":"Not ready"),e[88]=C,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=(0,a.jsx)(ue,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=v):v=e[97],z=ae,S="gap-0 py-0",V="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=b):b=e[101],$=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(f=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${f.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Z("size-1.5 shrink-0 rounded-full",f.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:f.name}),f.critical&&(0,a.jsx)(re,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[f.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:f.message}),(0,a.jsx)(re,{"data-testid":`dh-check-status-${f.name}`,variant:f.status==="up"?"secondary":"destructive",children:f.status==="up"?t("Up"):t("Down")})]})]},f.name))}),e[23]=r.appName,e[24]=r.appVersion,e[25]=r.checks,e[26]=r.timestamp,e[27]=j,e[28]=Y,e[29]=C,e[30]=m,e[31]=t,e[32]=z,e[33]=I,e[34]=y,e[35]=N,e[36]=v,e[37]=S,e[38]=V,e[39]=b,e[40]=$,e[41]=H}else z=e[32],I=e[33],y=e[34],N=e[35],v=e[36],S=e[37],V=e[38],b=e[39],$=e[40],H=e[41];let P;e[102]!==z||e[103]!==S||e[104]!==V||e[105]!==b||e[106]!==$?(P=(0,a.jsxs)(z,{className:S,"data-testid":V,children:[b,$]}),e[102]=z,e[103]=S,e[104]=V,e[105]=b,e[106]=$,e[107]=P):P=e[107];let te;return e[108]!==I||e[109]!==y||e[110]!==N||e[111]!==v||e[112]!==P||e[113]!==H?(te=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[y,N,v,P]}),e[108]=I,e[109]=y,e[110]=N,e[111]=v,e[112]=P,e[113]=H,e[114]=te):te=e[114],te},"Ie");function _e(n,e){return n.name.localeCompare(e.name)}k(_e,"be");export{De as DeploymentHealthPanel};
1
+ import{a as le}from"./chunk-HPFLBYRI.js";import{b as re}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{d as de,f as oe}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as me}from"./chunk-XQCVZAGU.js";import{a as ae}from"./chunk-UZERI5YC.js";import{d as ce,q as pe}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as k,e as ie,g as xe,h as ge,j as Z}from"./chunk-3XIESWL4.js";var ne=ie(xe(),1);var a=ie(ge(),1);var ye="/_lunora/health",Ne="/_lunora/health/ready",ve=k((n,e)=>(n.endsWith("/")?n.slice(0,-1):n)+e,"xe"),be=k(()=>{let n=oe();return async e=>{let w=e==="ready"?Ne:ye,t=n.getAuthToken(),_=ve(n.url,w);try{let l=await fetch(_,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),d=null;try{d=await l.json()}catch{d=null}return{body:d,ok:l.ok,status:l.status}}catch(l){return{body:null,error:l instanceof Error?l.message:String(l),ok:!1,status:0}}}},"Ne"),he={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ke={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},we=k(n=>n==="unhealthy"?"crit":n==="degraded"?"warn":"ok","ye"),ue=k(n=>{let e=(0,ne.c)(13),{label:w,level:t,testId:_,value:l}=n,d=he[t],o;e[0]!==d?(o=Z("size-1.5 shrink-0 rounded-full",d),e[0]=d,e[1]=o):o=e[1];let c;e[2]!==o?(c=(0,a.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=c):c=e[3];let x;e[4]!==w||e[5]!==c?(x=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[c,w]}),e[4]=w,e[5]=c,e[6]=x):x=e[6];let g;e[7]!==_||e[8]!==l?(g=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":_,children:l}),e[7]=_,e[8]=l,e[9]=g):g=e[9];let u;return e[10]!==x||e[11]!==g?(u=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[x,g]})}),e[10]=x,e[11]=g,e[12]=u):u=e[12],u},"ne"),De=k(n=>{let e=(0,ne.c)(115),{probe:w}=n,t=ce(),_=be(),l=w??_,d;e[0]!==l?(d=k(async()=>{let[s,i]=await Promise.all([l("live"),l("ready")]);return{live:s,ready:i}},"d"),e[0]=l,e[1]=d):d=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=["deployment-health"],e[2]=o):o=e[2];let c;e[3]!==d?(c={queryFn:d,queryKey:o},e[3]=d,e[4]=c):c=e[4];let{data:x,isPending:g}=de(c),u=x?.live??null,fe=x?.ready??null;if(g){let s;return e[5]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(le,{className:"h-16 w-full"}),(0,a.jsx)(le,{className:"h-40 w-full"})]}),e[5]=s):s=e[5],s}let r=u?.body??null;if(r===null){let s=u?.status===403,i;e[6]!==s||e[7]!==u?.error||e[8]!==t?(i=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:u?.error??t("no response")}),e[6]=s,e[7]=u?.error,e[8]=t,e[9]=i):i=e[9];let h;e[10]!==t?(h=t("Health endpoint unavailable"),e[10]=t,e[11]=h):h=e[11];let p;return e[12]!==i||e[13]!==h?(p=(0,a.jsx)(me,{description:i,testId:"deployment-health-error",title:h}),e[12]=i,e[13]=h,e[14]=p):p=e[14],p}let ee;e[15]!==r.status?(ee=we(r.status),e[15]=r.status,e[16]=ee):ee=e[16];let j=ee,m;if(r.status==="unhealthy"){let s;e[17]!==t?(s=t("Unhealthy"),e[17]=t,e[18]=s):s=e[18],m=s}else if(r.status==="degraded"){let s;e[19]!==t?(s=t("Degraded"),e[19]=t,e[20]=s):s=e[20],m=s}else{let s;e[21]!==t?(s=t("Healthy"),e[21]=t,e[22]=s):s=e[22],m=s}let C=fe?.ok??!1,Y=C?"ok":"crit",z,I,y,N,v,S,V,b,$,H;if(e[23]!==r.appName||e[24]!==r.appVersion||e[25]!==r.checks||e[26]!==r.timestamp||e[27]!==j||e[28]!==Y||e[29]!==C||e[30]!==m||e[31]!==t){let s=[...r.checks].toSorted(_e);H="flex flex-col gap-6",I="deployment-health";let i;e[42]!==t?(i=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[42]=t,e[43]=i):i=e[43],e[44]!==i?(y=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:i}),e[44]=i,e[45]=y):y=e[45];let h=ke[j],p;e[46]!==h?(p=Z("flex size-10 shrink-0 items-center justify-center rounded-full",h),e[46]=h,e[47]=p):p=e[47];let se=he[j],D;e[48]!==se?(D=Z("size-3 rounded-full",se),e[48]=se,e[49]=D):D=e[49];let L;e[50]!==D?(L=(0,a.jsx)("span",{className:D}),e[50]=D,e[51]=L):L=e[51];let T;e[52]!==p||e[53]!==L?(T=(0,a.jsx)("span",{"aria-hidden":"true",className:p,children:L}),e[52]=p,e[53]=L,e[54]=T):T=e[54];let q;e[55]!==m?(q=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:m}),e[55]=m,e[56]=q):q=e[56];let E;e[57]!==r.appName||e[58]!==r.appVersion?(E=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[r.appName," \xB7 ",r.appVersion]}),e[57]=r.appName,e[58]=r.appVersion,e[59]=E):E=e[59];let R;e[60]!==q||e[61]!==E?(R=(0,a.jsxs)("div",{className:"grid leading-tight",children:[q,E]}),e[60]=q,e[61]=E,e[62]=R):R=e[62];let U;e[63]!==T||e[64]!==R?(U=(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[T,R]}),e[63]=T,e[64]=R,e[65]=U):U=e[65];let A;e[66]!==t?(A=t("Checked"),e[66]=t,e[67]=A):A=e[67];let B;e[68]!==A?(B=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:A}),e[68]=A,e[69]=B):B=e[69];let F;e[70]!==r.timestamp?(F=pe(r.timestamp),e[70]=r.timestamp,e[71]=F):F=e[71];let K;e[72]!==F?(K=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:F}),e[72]=F,e[73]=K):K=e[73];let Q;e[74]!==B||e[75]!==K?(Q=(0,a.jsxs)("div",{className:"text-end",children:[B,K]}),e[74]=B,e[75]=K,e[76]=Q):Q=e[76],e[77]!==U||e[78]!==Q?(N=(0,a.jsx)(ae,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[U,Q]})}),e[77]=U,e[78]=Q,e[79]=N):N=e[79];let W;e[80]!==t?(W=t("Liveness"),e[80]=t,e[81]=W):W=e[81];let G;e[82]!==j||e[83]!==m||e[84]!==W?(G=(0,a.jsx)(ue,{label:W,level:j,testId:"dh-liveness",value:m}),e[82]=j,e[83]=m,e[84]=W,e[85]=G):G=e[85];let J;e[86]!==t?(J=t("Readiness"),e[86]=t,e[87]=J):J=e[87];let M;e[88]!==C||e[89]!==t?(M=t(C?"Ready":"Not ready"),e[88]=C,e[89]=t,e[90]=M):M=e[90];let O;e[91]!==Y||e[92]!==J||e[93]!==M?(O=(0,a.jsx)(ue,{label:J,level:Y,testId:"dh-readiness",value:M}),e[91]=Y,e[92]=J,e[93]=M,e[94]=O):O=e[94],e[95]!==G||e[96]!==O?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[G,O]}),e[95]=G,e[96]=O,e[97]=v):v=e[97],z=ae,S="gap-0 py-0",V="dh-checks";let X;e[98]!==t?(X=t("Subsystem checks"),e[98]=t,e[99]=X):X=e[99],e[100]!==X?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:X})}),e[100]=X,e[101]=b):b=e[101],$=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(f=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${f.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Z("size-1.5 shrink-0 rounded-full",f.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:f.name}),f.critical&&(0,a.jsx)(re,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[f.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:f.message}),(0,a.jsx)(re,{"data-testid":`dh-check-status-${f.name}`,variant:f.status==="up"?"secondary":"destructive",children:f.status==="up"?t("Up"):t("Down")})]})]},f.name))}),e[23]=r.appName,e[24]=r.appVersion,e[25]=r.checks,e[26]=r.timestamp,e[27]=j,e[28]=Y,e[29]=C,e[30]=m,e[31]=t,e[32]=z,e[33]=I,e[34]=y,e[35]=N,e[36]=v,e[37]=S,e[38]=V,e[39]=b,e[40]=$,e[41]=H}else z=e[32],I=e[33],y=e[34],N=e[35],v=e[36],S=e[37],V=e[38],b=e[39],$=e[40],H=e[41];let P;e[102]!==z||e[103]!==S||e[104]!==V||e[105]!==b||e[106]!==$?(P=(0,a.jsxs)(z,{className:S,"data-testid":V,children:[b,$]}),e[102]=z,e[103]=S,e[104]=V,e[105]=b,e[106]=$,e[107]=P):P=e[107];let te;return e[108]!==I||e[109]!==y||e[110]!==N||e[111]!==v||e[112]!==P||e[113]!==H?(te=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[y,N,v,P]}),e[108]=I,e[109]=y,e[110]=N,e[111]=v,e[112]=P,e[113]=H,e[114]=te):te=e[114],te},"Ie");function _e(n,e){return n.name.localeCompare(e.name)}k(_e,"be");export{De as DeploymentHealthPanel};
@@ -1,4 +1,4 @@
1
- import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-VDW32UET.js";import{f as H}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as B}from"./chunk-XQCVZAGU.js";import{d as E,e as Se,f as se,g as ie,h as le,m as $e,o as ae}from"./chunk-OG4N2XHD.js";import{c as be}from"./chunk-XNGYYOLS.js";import{a as u,e as K,f as ue,g as te,h as re,j as fe}from"./chunk-3XIESWL4.js";var Fe=K(te(),1),ge=K(ue(),1);var Z=K(te(),1);var X=K(ue(),1);var T=K(re(),1);var Ve=se(Ie.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"J"),Ce=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"U"),Ye=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ce(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"re"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"se"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
1
+ import{a as Pe}from"./chunk-V53KNYRN.js";import{a as he}from"./chunk-5Y3QLNWX.js";import{d as Ne,f as ke,g as we,k as oe}from"./chunk-QBWRC5YX.js";import{a as Q}from"./chunk-HPFLBYRI.js";import{a as Oe}from"./chunk-X665E2HU.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as ye}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as U}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as ve}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as Ie}from"./chunk-VDW32UET.js";import{f as H}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as B}from"./chunk-XQCVZAGU.js";import{d as E,e as Se,f as se,g as ie,h as le,m as $e,o as ae}from"./chunk-OG4N2XHD.js";import{c as be}from"./chunk-XNGYYOLS.js";import{a as u,e as K,f as ue,g as te,h as re,j as fe}from"./chunk-3XIESWL4.js";var Fe=K(te(),1),ge=K(ue(),1);var Z=K(te(),1);var X=K(ue(),1);var T=K(re(),1);var Ve=se(Ie.listTables),Qe=["react","client","cli"],Xe=!1,Ze={action:"action",mutation:"mutation",query:"query"},_e=u(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"J"),Ce=u(({file:t,fn:e,kind:a})=>`await client.${Ze[a]}(api.${t}.${e}, { /* args */ });`,"U"),Ye=u(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return Ce(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"re"),et=u(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"se"),tt=u(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
2
2
  `),"de"),rt=u((t,e)=>{switch(t){case"cli":return et(e);case"client":return Ce(e);default:return Ye(e)}},"ce"),Te=u(t=>{let e=(0,Z.c)(19),{code:a,label:r,testId:n}=t,s=E(),o;e[0]!==a?(o=u(()=>{ae(a)},"s"),e[0]=a,e[1]=o):o=e[1];let i=o,d;e[2]!==r?(d=(0,T.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:r}),e[2]=r,e[3]=d):d=e[3];let m=`${n}-copy`,l;e[4]!==s?(l=s("Copy"),e[4]=s,e[5]=l):l=e[5];let c;e[6]!==i||e[7]!==m||e[8]!==l?(c=(0,T.jsx)(U,{"data-testid":m,onClick:i,size:"xs",type:"button",variant:"ghost",children:l}),e[6]=i,e[7]=m,e[8]=l,e[9]=c):c=e[9];let f;e[10]!==d||e[11]!==c?(f=(0,T.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[d,c]}),e[10]=d,e[11]=c,e[12]=f):f=e[12];let x;e[13]!==a||e[14]!==n?(x=(0,T.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:a}),e[13]=a,e[14]=n,e[15]=x):x=e[15];let h;return e[16]!==f||e[17]!==x?(h=(0,T.jsxs)("div",{className:"flex flex-col gap-1.5",children:[f,x]}),e[16]=f,e[17]=x,e[18]=h):h=e[18],h},"V"),at=u(t=>{let e=(0,Z.c)(50),{file:a,fn:r,kind:n}=t,s=E(),[o,i]=(0,X.useState)("react"),d,m,l;if(e[0]!==a||e[1]!==r||e[2]!==n||e[3]!==s||e[4]!==o){let $={file:a,fn:r,kind:n},S;e[8]!==s?(S=s("CLI"),e[8]=s,e[9]=S):S=e[9];let C;e[10]!==s?(C=s("Client"),e[10]=s,e[11]=C):C=e[11];let A;e[12]!==s?(A=s("React"),e[12]=s,e[13]=A):A=e[13];let M;e[14]!==S||e[15]!==C||e[16]!==A?(M={cli:S,client:C,react:A},e[14]=S,e[15]=C,e[16]=A,e[17]=M):M=e[17],l=M;let _;e[18]===Symbol.for("react.memo_cache_sentinel")?(_=u(J=>{i(J.currentTarget.dataset.tab)},"D"),e[18]=_):_=e[18],d=_,m=rt(o,$),e[0]=a,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=d,e[6]=m,e[7]=l}else d=e[5],m=e[6],l=e[7];let c=m,f=n==="action"&&o==="react"&&!Xe,x=`api.${a}.${r}`,h;e[19]!==x?(h=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:x}),e[19]=x,e[20]=h):h=e[20];let b;e[21]!==n||e[22]!==s?(b=s("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=s,e[23]=b):b=e[23];let y;e[24]!==b?(y=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=y):y=e[25];let N;e[26]!==h||e[27]!==y?(N=(0,T.jsxs)("div",{children:[h,y]}),e[26]=h,e[27]=y,e[28]=N):N=e[28];let v;e[29]!==s?(v=s("Snippet flavour"),e[29]=s,e[30]=v):v=e[30];let g;e[31]!==d||e[32]!==o||e[33]!==l?(g=Qe.map($=>(0,T.jsx)(U,{"aria-selected":o===$,"data-tab":$,"data-testid":`api-tab-${$}`,onClick:d,role:"tab",size:"xs",type:"button",variant:o===$?"default":"outline",children:l[$]},$)),e[31]=d,e[32]=o,e[33]=l,e[34]=g):g=e[34];let k;e[35]!==v||e[36]!==g?(k=(0,T.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:g}),e[35]=v,e[36]=g,e[37]=k):k=e[37];let O=l[o],P=`api-snippet-${o}`,w;e[38]!==c||e[39]!==O||e[40]!==P?(w=(0,T.jsx)(Te,{code:c,label:O,testId:P}),e[38]=c,e[39]=O,e[40]=P,e[41]=w):w=e[41];let I;e[42]!==f||e[43]!==s?(I=f&&(0,T.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:s("Actions have no React hook \u2014 call them through the client.")}),e[42]=f,e[43]=s,e[44]=I):I=e[44];let j;return e[45]!==w||e[46]!==I||e[47]!==N||e[48]!==k?(j=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[N,k,w,I]}),e[45]=w,e[46]=I,e[47]=N,e[48]=k,e[49]=j):j=e[49],j},"pe"),nt=u(t=>{let e=(0,Z.c)(19),{name:a}=t,r=E(),n;e[0]!==a?(n=tt(a),e[0]=a,e[1]=n):n=e[1];let s=n,o;e[2]!==a?(o=(0,T.jsx)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=o):o=e[3];let i;e[4]!==r?(i=r("Read and write this table through the typed data model."),e[4]=r,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,T.jsx)("p",{className:"text-xs text-muted-foreground",children:i}),e[6]=i,e[7]=d):d=e[7];let m;e[8]!==o||e[9]!==d?(m=(0,T.jsxs)("div",{children:[o,d]}),e[8]=o,e[9]=d,e[10]=m):m=e[10];let l;e[11]!==r?(l=r("Data model"),e[11]=r,e[12]=l):l=e[12];let c;e[13]!==s||e[14]!==l?(c=(0,T.jsx)(Te,{code:s,label:l,testId:"api-snippet-table"}),e[13]=s,e[14]=l,e[15]=c):c=e[15];let f;return e[16]!==m||e[17]!==c?(f=(0,T.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[m,c]}),e[16]=m,e[17]=c,e[18]=f):f=e[18],f},"fe"),je=u(t=>{let e=(0,Z.c)(8),{active:a,label:r,onSelect:n,testId:s,value:o}=t,i;e[0]!==n||e[1]!==o?(i=u(()=>{n(o)},"u"),e[0]=n,e[1]=o,e[2]=i):i=e[2];let d=i,m=a?"page":void 0,l;return e[3]!==r||e[4]!==d||e[5]!==m||e[6]!==s?(l=(0,T.jsx)("button",{"aria-current":m,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":s,onClick:d,type:"button",children:r}),e[3]=r,e[4]=d,e[5]=m,e[6]=s,e[7]=l):l=e[7],l},"G"),ot=u(t=>{let e=new Map;for(let a of t){let{file:r,fn:n}=_e(a.path),s=e.get(r)??[];s.push({fn:n,kind:a.kind,path:a.path}),e.set(r,s)}return[...e.entries()].map(([a,r])=>({file:a,items:r.toSorted((n,s)=>n.fn.localeCompare(s.fn))})).toSorted((a,r)=>a.file.localeCompare(r.file))},"me"),Ae=u(t=>{let e=(0,Z.c)(58),{functions:a,initialShardKey:r}=t,n=E(),s=H(),[o,i]=(0,X.useState)(null),[d,m]=(0,X.useState)(null),l,c;e[0]!==s||e[1]!==r?(l=u(()=>{let M=!1;return s.query(Ve,{},ie(r??"")).then(_=>(M||i(_),_)).catch(()=>{M||i([])}),()=>{M=!0}},"r"),c=[s,r],e[0]=s,e[1]=r,e[2]=l,e[3]=c):(l=e[2],c=e[3]),(0,X.useEffect)(l,c);let f,x,h,b,y,N,v,g,k,O;if(e[4]!==a||e[5]!==d||e[6]!==n||e[7]!==o){let M=a??[],_=ot(M),J=(o??[]).map(st).toSorted(it),R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=u(z=>{m({kind:"fn",path:z})},"F"),e[18]=R):R=e[18];let D=R,V;e[19]===Symbol.for("react.memo_cache_sentinel")?(V=u(z=>{m({kind:"table",name:z})},"H"),e[19]=V):V=e[19];let Ge=V;x=d?.kind==="fn"?M.find(z=>z.path===d.path):void 0,f=M.length>0||J.length>0,h=x===void 0?void 0:_e(x.path),k="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",O="lunora-api-docs",e[20]!==n?(b=n("API resources"),e[20]=n,e[21]=b):b=e[21],y="flex flex-col gap-4 overflow-y-auto",N="api-rail";let ne;e[22]!==d||e[23]!==n?(ne=u(z=>(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:z.file||n("(root)")}),z.items.map(ee=>(0,T.jsx)(je,{active:d?.kind==="fn"&&d.path===ee.path,label:ee.fn,onSelect:D,testId:`api-rail-fn-${ee.path}`,value:ee.path},ee.path))]},z.file),"K"),e[22]=d,e[23]=n,e[24]=ne):ne=e[24],v=_.map(ne),g=J.length>0&&(0,T.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,T.jsx)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")}),J.map(z=>(0,T.jsx)(je,{active:d?.kind==="table"&&d.name===z,label:z,onSelect:Ge,testId:`api-rail-table-${z}`,value:z},z))]}),e[4]=a,e[5]=d,e[6]=n,e[7]=o,e[8]=f,e[9]=x,e[10]=h,e[11]=b,e[12]=y,e[13]=N,e[14]=v,e[15]=g,e[16]=k,e[17]=O}else f=e[8],x=e[9],h=e[10],b=e[11],y=e[12],N=e[13],v=e[14],g=e[15],k=e[16],O=e[17];let P;e[25]!==f||e[26]!==n?(P=!f&&(0,T.jsx)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")}),e[25]=f,e[26]=n,e[27]=P):P=e[27];let w;e[28]!==P||e[29]!==b||e[30]!==y||e[31]!==N||e[32]!==v||e[33]!==g?(w=(0,T.jsxs)("nav",{"aria-label":b,className:y,"data-testid":N,children:[v,g,P]}),e[28]=P,e[29]=b,e[30]=y,e[31]=N,e[32]=v,e[33]=g,e[34]=w):w=e[34];let I;e[35]!==d||e[36]!==n?(I=d===null&&(0,T.jsx)(B,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")}),e[35]=d,e[36]=n,e[37]=I):I=e[37];let j;e[38]!==d?.kind||e[39]!==x||e[40]!==h?(j=d?.kind==="fn"&&x!==void 0&&h!==void 0&&(0,T.jsx)(at,{file:h.file,fn:h.fn,kind:x.kind},x.path),e[38]=d?.kind,e[39]=x,e[40]=h,e[41]=j):j=e[41];let $;e[42]!==d?.kind||e[43]!==x||e[44]!==n?($=d?.kind==="fn"&&x===void 0&&(0,T.jsx)(B,{testId:"api-empty",title:n("API usage snippets")}),e[42]=d?.kind,e[43]=x,e[44]=n,e[45]=$):$=e[45];let S;e[46]!==d?(S=d?.kind==="table"&&(0,T.jsx)(nt,{name:d.name}),e[46]=d,e[47]=S):S=e[47];let C;e[48]!==I||e[49]!==j||e[50]!==$||e[51]!==S?(C=(0,T.jsxs)("div",{className:"min-w-0",children:[I,j,$,S]}),e[48]=I,e[49]=j,e[50]=$,e[51]=S,e[52]=C):C=e[52];let A;return e[53]!==w||e[54]!==C||e[55]!==k||e[56]!==O?(A=(0,T.jsxs)("div",{className:k,"data-testid":O,children:[w,C]}),e[53]=w,e[54]=C,e[55]=k,e[56]=O,e[57]=A):A=e[57],A},"Se");function st(t){return t.name}u(st,"ue");function it(t,e){return t.localeCompare(e)}u(it,"he");var We=K(te(),1);var q=K(te(),1),L=K(ue(),1);var p=K(re(),1);var pe=u(function(t,e,a){let r=(0,q.c)(10),n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];let[s,o]=(0,L.useState)(n),i,d;r[1]!==a||r[2]!==e||r[3]!==t?(i=u(()=>{if(t!==void 0)return;let l=!1;return e().then(c=>(l||o(a(c)),c)).catch(c=>{l||o({kind:"error",message:le(c)})}),()=>{l=!0}},"l"),d=[a,e,t],r[1]=a,r[2]=e,r[3]=t,r[4]=i,r[5]=d):(i=r[4],d=r[5]),(0,L.useEffect)(i,d);let m;return r[6]!==a||r[7]!==s||r[8]!==t?(m=t===void 0?s:a(t),r[6]=a,r[7]=s,r[8]=t,r[9]=m):m=r[9],m},"gt"),lt=u(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","$e"),Re=u(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"X"),ce=u(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>ce(e)).join(" | "):t.type==="array"?`array<${ce(t.items)}>`:t.type??"any","B"),dt=u(t=>{let e=Re(t);return e!==void 0?t.type??lt(e[0]):ce(t)},"ke"),ct=u(t=>{let e=Re(t);return e===void 0?void 0:e.map(a=>JSON.stringify(a)).join(" | ")},"Se"),pt=u(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let a=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let r=e.length>(a?2:1);return a||r?e.join(" "):void 0},"we"),mt=u(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"Oe"),Y=u(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return Y(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[a,r]of Object.entries(t.properties??{}))e[a]=Y(r);return e}case"string":return"";default:return null}},"q"),de=u(t=>{let e=(0,q.c)(7),{label:a,value:r}=t,n;e[0]!==a?(n=(0,p.jsx)("span",{className:"text-muted-foreground",children:a}),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==r?(s=(0,p.jsx)("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=s):s=e[3];let o;return e[4]!==n||e[5]!==s?(o=(0,p.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,s]}),e[4]=n,e[5]=s,e[6]=o):o=e[6],o},"W"),ut=u(t=>{let e=(0,q.c)(40),{name:a,required:r,schema:n}=t,s=E(),o;e[0]!==n?(o=pt(n),e[0]=n,e[1]=o):o=e[1];let i=o,d;e[2]!==n?(d=ct(n),e[2]=n,e[3]=d):d=e[3];let m=d,l=n["x-lunora-table"],c=n.format!==void 0||i!==void 0||m!==void 0||l!==void 0,f;e[4]!==n?(f=mt(n),e[4]=n,e[5]=f):f=e[5];let x=f,h=r?"*":"?",b;e[6]!==h?(b=(0,p.jsx)("span",{className:"text-muted-foreground",children:h}),e[6]=h,e[7]=b):b=e[7];let y;e[8]!==a||e[9]!==b?(y=(0,p.jsxs)("span",{className:"font-mono text-foreground",children:[a,b]}),e[8]=a,e[9]=b,e[10]=y):y=e[10];let N;e[11]!==n?(N=dt(n),e[11]=n,e[12]=N):N=e[12];let v;e[13]!==N?(v=(0,p.jsx)("span",{className:"font-mono text-muted-foreground",children:N}),e[13]=N,e[14]=v):v=e[14];let g;e[15]!==y||e[16]!==v?(g=(0,p.jsxs)("div",{className:"flex items-baseline gap-2",children:[y,v]}),e[15]=y,e[16]=v,e[17]=g):g=e[17];let k;e[18]!==n.description?(k=n.description!==void 0&&(0,p.jsx)("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=k):k=e[19];let O;e[20]!==c||e[21]!==i||e[22]!==l||e[23]!==n.format||e[24]!==s||e[25]!==m?(O=c&&(0,p.jsxs)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,p.jsx)(de,{label:s("Format"),value:n.format}),i!==void 0&&(0,p.jsx)(de,{label:s("Range"),value:i}),m!==void 0&&(0,p.jsx)(de,{label:s("Value in"),value:m}),l!==void 0&&(0,p.jsx)(de,{label:s("relation"),value:l})]}),e[20]=c,e[21]=i,e[22]=l,e[23]=n.format,e[24]=s,e[25]=m,e[26]=O):O=e[26];let P;e[27]!==k||e[28]!==O||e[29]!==g?(P=(0,p.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[g,k,O]}),e[27]=k,e[28]=O,e[29]=g,e[30]=P):P=e[30];let w=P;if(x===void 0){let S;return e[31]!==w?(S=(0,p.jsx)("div",{className:"border-b border-border/50 last:border-b-0",children:w}),e[31]=w,e[32]=S):S=e[32],S}let I;e[33]!==w?(I=(0,p.jsx)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:w}),e[33]=w,e[34]=I):I=e[34];let j;e[35]!==x?(j=(0,p.jsx)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,p.jsx)(Je,{schema:x})}),e[35]=x,e[36]=j):j=e[36];let $;return e[37]!==I||e[38]!==j?($=(0,p.jsxs)("details",{className:"border-b border-border/50 last:border-b-0",children:[I,j]}),e[37]=I,e[38]=j,e[39]=$):$=e[39],$},"je"),Je=u(t=>{let e=(0,q.c)(7),{schema:a}=t,r;e[0]!==a.required?(r=new Set(a.required),e[0]=a.required,e[1]=r):r=e[1];let n=r,s;e[2]!==a.properties?(s=Object.entries(a.properties??{}),e[2]=a.properties,e[3]=s):s=e[3];let o=s,i;return e[4]!==n||e[5]!==o?(i=(0,p.jsx)("div",{className:"flex flex-col",children:o.map(d=>{let[m,l]=d;return(0,p.jsx)(ut,{name:m,required:n.has(m),schema:l},m)})}),e[4]=n,e[5]=o,e[6]=i):i=e[6],i},"Y"),Me=u(t=>{let e=(0,q.c)(10),{schema:a,testId:r}=t;if(a?.type!=="object"||Object.keys(a.properties??{}).length===0){let o;e[0]!==a?(o=ce(a),e[0]=a,e[1]=o):o=e[1];let i;return e[2]!==o||e[3]!==r?(i=(0,p.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:o}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i}let n;e[5]!==a?(n=(0,p.jsx)(Je,{schema:a}),e[5]=a,e[6]=n):n=e[6];let s;return e[7]!==n||e[8]!==r?(s=(0,p.jsx)("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=s):s=e[9],s},"G"),ft=["curl","javascript","lunora"],ht={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},xt=u(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"Pe"),gt=u(t=>{let e=Y(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"Te"),bt=u((t,e,a)=>{let r=`${a}${e.httpPath}`,n=JSON.stringify(gt(e),void 0,2),s=JSON.stringify(Y(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let o=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(r)}`];return o&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
3
3
  `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
4
4
  import { api } from "./_generated/api";
@@ -1 +1 @@
1
- import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-TS6346VY.js";import{f as O}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{d as z}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
1
+ import{a as D}from"./chunk-54MMVNPT.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as B}from"./chunk-SHMNA6UL.js";import{f as O}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as j}from"./chunk-XQCVZAGU.js";import{a as W,b as q,c as E,d as S,e as r,f as s}from"./chunk-MIQTKZAR.js";import{a as A,e as L}from"./chunk-UZERI5YC.js";import{d as z}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as T,e as M,g as $,h as I}from"./chunk-3XIESWL4.js";var F=M($(),1);var n=M(I(),1);var J=2e3,Q=new Set(["open"]),re=T(G=>{let e=(0,F.c)(41),{read:y}=G,t=z(),K=O(),v;e[0]!==K||e[1]!==y?(v=T(()=>Promise.resolve(y?y():K.debug()),"S"),e[0]=K,e[1]=y,e[2]=v):v=e[2];let H=v,P=y?"injected":"live",b;e[3]!==P?(b=["lunora-studio","sync-client-debug",P],e[3]=P,e[4]=b):b=e[4];let{data:c,refetch:Y}=B(b,H);if(D(Y,!0,J),!c){let i;e[5]!==t?(i=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let _;return e[9]!==i||e[10]!==g?(_=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(j,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=_):_=e[11],_}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let R=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==R?(o=(0,n.jsx)(x,{variant:R,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=R,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(j,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Shard")}),(0,n.jsx)(r,{children:t("Socket")}),(0,n.jsx)(r,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:i.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:Q.has(i.wsState)?"default":"secondary",children:i.wsState})}),(0,n.jsx)(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(j,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(W,{children:[(0,n.jsx)(q,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(r,{children:t("Subscription")}),(0,n.jsx)(r,{children:t("Kind")}),(0,n.jsx)(r,{children:t("Acked")}),(0,n.jsx)(r,{children:t("Cursor")}),(0,n.jsx)(r,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(i=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:i.functionPath}),(0,n.jsx)(s,{children:i.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:i.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"re");export{re as default};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-CTNB2KIA.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as I}from"./chunk-XQCVZAGU.js";import{a as k,b as A,c as D,d as g,e as c,f as l}from"./chunk-MIQTKZAR.js";import{a as S,e as b}from"./chunk-UZERI5YC.js";import{d as w}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as u,e as y,g as j,h as E}from"./chunk-3XIESWL4.js";var _=y(j(),1);var t=y(E(),1);var T="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},P=u(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"_"),W=u(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(T))continue;let i=a.slice(T.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:f,event:m}=P(r.message);n.set(s,{detail:f,event:m,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[m]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"j"),F={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},H=u(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=u(()=>{let e=(0,_.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),f=i!==void 0,m;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==f||e[6]!==n){let N=W(H(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let d;e[10]!==n?(d=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=d):d=e[11];let h;e[12]!==d?(h=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[12]=d,e[13]=h):h=e[13];let p;e[14]!==o?(p=(0,t.jsx)(O,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==h||e[17]!==p?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[h,p]}),e[16]=h,e[17]=p,e[18]=v):v=e[18],m=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,f&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(S,{className:"overflow-hidden py-0",children:(0,t.jsx)(b,{className:"px-0",children:(0,t.jsxs)(k,{"data-testid":"containers-table",children:[(0,t.jsx)(A,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(D,{children:N.map(J)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=f,e[6]=n,e[7]=m}else m=e[7];return m},"H");function J(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:F[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}u(J,"W");export{V as ContainersPanel};
1
+ import{a as O}from"./chunk-CTNB2KIA.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as I}from"./chunk-XQCVZAGU.js";import{a as k,b as A,c as D,d as g,e as c,f as l}from"./chunk-MIQTKZAR.js";import{a as S,e as b}from"./chunk-UZERI5YC.js";import{d as w}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as u,e as y,g as j,h as E}from"./chunk-3XIESWL4.js";var _=y(j(),1);var t=y(E(),1);var T="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},P=u(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"_"),W=u(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(T))continue;let i=a.slice(T.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:f,event:m}=P(r.message);n.set(s,{detail:f,event:m,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[m]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"j"),F={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},H=u(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=u(()=>{let e=(0,_.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),f=i!==void 0,m;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==f||e[6]!==n){let N=W(H(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let d;e[10]!==n?(d=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=d):d=e[11];let h;e[12]!==d?(h=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[12]=d,e[13]=h):h=e[13];let p;e[14]!==o?(p=(0,t.jsx)(O,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==h||e[17]!==p?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[h,p]}),e[16]=h,e[17]=p,e[18]=v):v=e[18],m=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,f&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(S,{className:"overflow-hidden py-0",children:(0,t.jsx)(b,{className:"px-0",children:(0,t.jsxs)(k,{"data-testid":"containers-table",children:[(0,t.jsx)(A,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(D,{children:N.map(J)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=f,e[6]=n,e[7]=m}else m=e[7];return m},"H");function J(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:F[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}u(J,"W");export{V as ContainersPanel};
@@ -1 +1 @@
1
- import{a as Ze}from"./chunk-IAKPXGTQ.js";import"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Ie}from"./chunk-5Y3QLNWX.js";import{a as Ye}from"./chunk-CTNB2KIA.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as Xe}from"./chunk-QXXIJAD5.js";import{a as ze}from"./chunk-3CWGJYBB.js";import{a as We}from"./chunk-X665E2HU.js";import{b as Ve}from"./chunk-GRL5MG3Z.js";import{d as De,e as Fe}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{R as Ee}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Ae}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as _e}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as we}from"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as C}from"./chunk-VDW32UET.js";import{c as de}from"./chunk-TS6346VY.js";import{f as Te}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as ye}from"./chunk-XQCVZAGU.js";import{a as Ge,b as He,c as Qe,d as Me,e as O,f as M}from"./chunk-MIQTKZAR.js";import{a as Le,e as Je}from"./chunk-UZERI5YC.js";import{d as oe,f as Pe,g as Be,h as Ue,m as ke,q as Ne}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as m,e as ie,f as qe,g as Ce,h as Ke,j as ne}from"./chunk-3XIESWL4.js";var me=ie(Ce(),1),ce=ie(qe(),1);var et=ie(Ce(),1);var j=ie(qe(),1);var l=ie(Ke(),1);var ct=Pe(C.runMigration),tt=m(a=>{let e=(0,et.c)(98),{initialShardKey:r}=a,s=Te(),t=oe(),{queryShardKey:d,setShardKey:i,shardKey:n}=ze(r),[u,b]=(0,j.useState)(""),[h,v]=(0,j.useState)("up"),[p,g]=(0,j.useState)(!0),[f,y]=(0,j.useState)(!1),[x,c]=(0,j.useState)(null),[N,k]=(0,j.useState)(null),K;e[0]!==n?(K=n.trim(),e[0]=n,e[1]=K):K=e[1];let I=K===d,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S={},e[2]=S):S=e[2];let R;e[3]!==d?(R={live:!0,shardKey:d},e[3]=d,e[4]=R):R=e[4];let w=de(C.migrationStatus,S,R),$=w.data?.migrations??null,$e=w.error,{errorSource:je,liveError:Se}=w,ue,he;e[5]!==d||e[6]!==w.data?(ue=m(()=>{w.data!==void 0&&Ve(d)},"Q"),he=[w.data,d],e[5]=d,e[6]=w.data,e[7]=ue,e[8]=he):(ue=e[7],he=e[8]),(0,j.useEffect)(ue,he);let pe;if(e[9]!==s||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==n||e[14]!==w||e[15]!==t){let q=m(async()=>{let Re=u.trim();if(Re===""){k(t("Enter a migration id")),c(null);return}y(!0),k(null);try{let Oe=await s.query(ct,{direction:h,dryRun:p,id:Re},Be(n));c(Oe),w.refetch()}catch(Oe){let lt=Oe;c(null),k(Ue(lt))}y(!1)},"m");pe=m(()=>{ke(q())},"X"),e[9]=s,e[10]=h,e[11]=p,e[12]=u,e[13]=n,e[14]=w,e[15]=t,e[16]=pe}else pe=e[16];let fe=pe,ge;e[17]===Symbol.for("react.memo_cache_sentinel")?(ge=m(q=>{b(q.target.value)},"Z"),e[17]=ge):ge=e[17];let nt=ge,be;e[18]===Symbol.for("react.memo_cache_sentinel")?(be=m(q=>{v(q.target.value==="down"?"down":"up")},"H"),e[18]=be):be=e[18];let ot=be,ve;e[19]===Symbol.for("react.memo_cache_sentinel")?(ve=m(q=>{g(q.target.checked)},"ee"),e[19]=ve):ve=e[19];let dt=ve,T;e[20]!==i||e[21]!==n?(T=(0,l.jsx)(We,{onChange:i,testId:"mg-shard-input",value:n}),e[20]=i,e[21]=n,e[22]=T):T=e[22];let D;e[23]!==Se?(D=(0,l.jsx)(Ye,{message:Se,prefix:"mg"}),e[23]=Se,e[24]=D):D=e[24];let F;e[25]!==T||e[26]!==D?(F=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[T,D]}),e[25]=T,e[26]=D,e[27]=F):F=e[27];let _;e[28]!==$e||e[29]!==je?(_=$e!==null&&(0,l.jsx)(we,{error:je,testId:"mg-status-error"}),e[28]=$e,e[29]=je,e[30]=_):_=e[30];let E;e[31]!==$||e[32]!==t?(E=$!==null&&$.length===0&&(0,l.jsx)(ye,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:t("No migrations have run on this shard.")}),e[31]=$,e[32]=t,e[33]=E):E=e[33];let A;e[34]!==$||e[35]!==t?(A=$!==null&&$.length>0&&(0,l.jsx)(Le,{className:"overflow-hidden py-0",children:(0,l.jsx)(Je,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(He,{children:(0,l.jsxs)(Me,{children:[(0,l.jsx)(O,{children:t("id")}),(0,l.jsx)(O,{children:t("direction")}),(0,l.jsx)(O,{children:t("status")}),(0,l.jsx)(O,{children:t("processed")}),(0,l.jsx)(O,{children:t("changed")}),(0,l.jsx)(O,{children:t("updated")}),(0,l.jsx)(O,{children:t("error")})]})}),(0,l.jsx)(Qe,{children:$.map(mt)})]})})}),e[34]=$,e[35]=t,e[36]=A):A=e[36];let L;e[37]!==t?(L=t("Run migration"),e[37]=t,e[38]=L):L=e[38];let J;e[39]!==L?(J=(0,l.jsx)(Ie,{children:L}),e[39]=L,e[40]=J):J=e[40];let P;e[41]!==t?(P=t("Migration id"),e[41]=t,e[42]=P):P=e[42];let B;e[43]!==t?(B=t("migration id"),e[43]=t,e[44]=B):B=e[44];let U;e[45]!==u||e[46]!==P||e[47]!==B?(U=(0,l.jsx)(Ee,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:nt,placeholder:B,value:u}),e[45]=u,e[46]=P,e[47]=B,e[48]=U):U=e[48];let V;e[49]!==t?(V=t("Direction"),e[49]=t,e[50]=V):V=e[50];let W;e[51]!==t?(W=t("up"),e[51]=t,e[52]=W):W=e[52];let z;e[53]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[53]=W,e[54]=z):z=e[54];let G;e[55]!==t?(G=t("down"),e[55]=t,e[56]=G):G=e[56];let H;e[57]!==G?(H=(0,l.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=H):H=e[58];let Q;e[59]!==h||e[60]!==V||e[61]!==z||e[62]!==H?(Q=(0,l.jsxs)("select",{"aria-label":V,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:ot,value:h,children:[z,H]}),e[59]=h,e[60]=V,e[61]=z,e[62]=H,e[63]=Q):Q=e[63];let X;e[64]!==p?(X=(0,l.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:dt,type:"checkbox"}),e[64]=p,e[65]=X):X=e[65];let Y;e[66]!==t?(Y=t("Dry run"),e[66]=t,e[67]=Y):Y=e[67];let Z;e[68]!==X||e[69]!==Y?(Z=(0,l.jsxs)(Ie,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[68]=X,e[69]=Y,e[70]=Z):Z=e[70];let ee;e[71]!==p||e[72]!==fe||e[73]!==f||e[74]!==I||e[75]!==t?(ee=p?(0,l.jsx)(Ae,{"data-testid":"mg-run",disabled:f||!I,onClick:fe,type:"button",children:t(f?"Running\u2026":"Run")}):(0,l.jsx)(Xe,{confirmLabel:t(f?"Running\u2026":"Run migration?"),disabled:f||!I,onConfirm:fe,testId:"mg-run",children:t("Run")}),e[71]=p,e[72]=fe,e[73]=f,e[74]=I,e[75]=t,e[76]=ee):ee=e[76];let te;e[77]!==U||e[78]!==Q||e[79]!==Z||e[80]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[77]=U,e[78]=Q,e[79]=Z,e[80]=ee,e[81]=te):te=e[81];let ae;e[82]!==J||e[83]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[82]=J,e[83]=te,e[84]=ae):ae=e[84];let re;e[85]!==N?(re=N!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:N}),e[85]=N,e[86]=re):re=e[86];let se;e[87]!==x||e[88]!==t?(se=x!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[x.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:x.status}),x.processed,t(", changed"),x.changed]}),e[87]=x,e[88]=t,e[89]=se):se=e[89];let xe;return e[90]!==F||e[91]!==_||e[92]!==E||e[93]!==A||e[94]!==ae||e[95]!==re||e[96]!==se?(xe=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[F,_,E,A,ae,re,se]}),e[90]=F,e[91]=_,e[92]=E,e[93]=A,e[94]=ae,e[95]=re,e[96]=se,e[97]=xe):xe=e[97],xe},"yr");function mt(a){return(0,l.jsxs)(Me,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(M,{children:a.id}),(0,l.jsx)(M,{children:a.direction}),(0,l.jsx)(M,{children:(0,l.jsx)(_e,{variant:"secondary",children:a.status})}),(0,l.jsx)(M,{children:a.processed}),(0,l.jsx)(M,{children:a.changed}),(0,l.jsx)(M,{children:Ne(a.updatedAt)}),(0,l.jsx)(M,{children:a.error??""})]},a.id)}m(mt,"Ve");var o=ie(Ke(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ut=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),ht=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,s]of Object.entries(e.tables))if(!ut(s))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},"B"),pt=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,s)=>r===e.fields[s]),"L"),ft=m((a,e,r,s)=>{let t=[];return r.kind!==s.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${s.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!s.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&s.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),gt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),bt=m((a,e,r,s)=>{for(let[t,d]of Object.entries(r.fields)){let i=e.fields[t];i===void 0?s.push(gt(a,t,d)):s.push(...ft(a,t,i,d))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&s.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),vt=m((a,e,r,s)=>{for(let[t,d]of Object.entries(r.indexes)){let i=e.indexes[t];if(i===void 0){s.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}pt(i,d)||s.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&s.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),xt=m((a,e,r,s)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&s.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&s.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),yt=m((a,e,r,s)=>{e.shardMode!==r.shardMode&&s.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),bt(a,e,r,s),vt(a,e,r,s),xt(a,e,r,s)},"ee"),kt=m((a,e)=>{let r=[],s=a?.tables??{};for(let[t,d]of Object.entries(e.tables)){let i=s[t];if(i===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}yt(t,i,d,r)}for(let t of Object.keys(s))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",d=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${d} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"te"),at=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(s=>s.field===e&&s.kind==="one")?.table,type:r.kind})),"T"),rt=m((a,e)=>{let r={},s=a?.fields??{},t=e?.fields??{};for(let[d,i]of Object.entries(t)){let n=s[d];n===void 0?r[d]=a===void 0?"unchanged":"added":r[d]=n.kind===i.kind&&n.optional===i.optional?"unchanged":"changed"}for(let d of Object.keys(s))t[d]===void 0&&(r[d]="removed");return r},"F"),Nt=m((a,e)=>{let{changes:r}=kt(a,e),s=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),t=[],d=m((i,n)=>i?"added":s.has(n)?"changed":"context","o");for(let[i,n]of Object.entries(e.tables)){let u=a?.tables[i],b=d(u===void 0,i);t.push({columns:at(n),fieldStatus:rt(u,n),name:i,shardMode:n.shardMode,status:b})}for(let[i,n]of Object.entries(a?.tables??{}))e.tables[i]===void 0&&t.push({columns:at(n),fieldStatus:rt(n,void 0),name:i,shardMode:n.shardMode,status:"removed"});return t.sort((i,n)=>i.name.localeCompare(n.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:t}},"ae"),st=m(a=>{let e=ht(a);return e.status==="ok"?e.snapshot:void 0},"A"),wt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},$t=m(a=>a==="global"?"global":"shard","se"),jt=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:s,onSelect:t,selected:d,seq:i}=a,n=d?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==n?(u=ne("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",n),e[0]=n,e[1]=u):u=e[1];let b=`sh-version-${s}`,h;e[2]!==s||e[3]!==t?(h=m(()=>{t(s)},"m"),e[2]=s,e[3]=t,e[4]=h):h=e[4];let v;e[5]!==i?(v=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=v):v=e[6];let p;e[7]!==s?(p=s.slice(0,7),e[7]=s,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==v||e[12]!==g?(f=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[v,g]}),e[11]=v,e[12]=g,e[13]=f):f=e[13];let y;e[14]!==r?(y=Ne(r),e[14]=r,e[15]=y):y=e[15];let x;e[16]!==y?(x=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:y}),e[16]=y,e[17]=x):x=e[17];let c;return e[18]!==x||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,x]})}),e[18]=x,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=c):c=e[23],c},"ie"),St=m(a=>{let e=(0,me.c)(26),{breaking:r,count:s,first:t}=a,d=oe();if(t){let g;e[0]!==s?(g=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:s}),e[0]=s,e[1]=g):g=e[1];let f;e[2]!==d?(f=d("tables"),e[2]=d,e[3]=f):f=e[3];let y;e[4]!==f?(y=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=y):y=e[5];let x;return e[6]!==g||e[7]!==y?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,y]}),e[6]=g,e[7]=y,e[8]=x):x=e[8],x}let i=r>0&&"text-destructive",n;e[9]!==i?(n=ne("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=n):n=e[10];let u;e[11]!==s||e[12]!==n?(u=(0,o.jsx)("span",{className:n,children:s}),e[11]=s,e[12]=n,e[13]=u):u=e[13];let b;e[14]!==s||e[15]!==d?(b=d(s===1?"change":"changes"),e[14]=s,e[15]=d,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let v;e[19]!==r||e[20]!==d?(v=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",d("{count} breaking",{count:r})]}),e[19]=r,e[20]=d,e[21]=v):v=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==v?(p=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,v]}),e[22]=u,e[23]=h,e[24]=v,e[25]=p):p=e[25],p},"re"),it={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Ot=m((a,e)=>{let r=`${it[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),Mt=m(a=>{let e=new Map;for(let s of a){let t=s.table??"",d=e.get(t);d===void 0?e.set(t,[s]):d.push(s)}let r=[...e].map(([s,t])=>({changes:t,table:s}));return[...r.filter(s=>s.table!==""),...r.filter(s=>s.table==="")]},"de"),It=m(a=>{let e=(0,me.c)(2),{children:r}=a,s;return e[0]!==r?(s=(0,o.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=s):s=e[1],s},"le"),Rt=m(({pane:a,shardKey:e=""})=>{let r=oe(),s=Fe(),t=De({strict:!1}).version,d=m(c=>{ke(s({search:{version:c},to:"/migrations"}))},"o"),i=de(C.schemaHistory,{},{shardKey:e}),n=i.data?.versions??[],u=t!==void 0&&n.some(c=>c.hash===t)?t:n[0]?.hash,b=n.findIndex(c=>c.hash===u),h=b===-1?void 0:n[b+1]?.hash,v=de(C.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=de(C.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ce.useMemo)(()=>{let c=st(v.data?.version?.snapshotJson);if(c!==void 0)return Nt(st(p.data?.version?.snapshotJson),c)},[v.data,p.data]),f=(0,ce.useMemo)(()=>(g?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:$t(c.shardMode)})),[g]),y=(0,ce.useMemo)(()=>{let c={};for(let N of g?.tables??[])c[N.name]=wt[N.status];return c},[g]);if(i.error!==null)return(0,o.jsx)(we,{error:i.errorSource,testId:"sh-error"});if(n.length===0)return(0,o.jsx)(ye,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let x=g?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(It,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:n.map(c=>(0,o.jsx)(jt,{appliedAt:c.appliedAt,hash:c.hash,onSelect:d,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(St,{breaking:g?.breakingCount??0,count:h===void 0?f.length:x.length,first:h===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(Ze,{fill:!0,nodeClasses:y,tables:f,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Mt(x).map(c=>{let N=(g?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),N!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:N.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:K,kind:I}=it[k.type],S=k.severity==="breaking",R=Ot(k,I);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:ne("-ms-3 h-3 w-0.5 shrink-0 self-center",S?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(K)," ",I]}),R!==c.table&&(0,o.jsx)("span",{className:ne("min-w-0 font-mono text-[13px]",S?"text-destructive":"text-foreground"),children:R}),S&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),qt=m(a=>ne("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),da=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,s=oe(),[t,d]=(0,ce.useState)("diagram"),i;e[0]!==t?(i=m((v,p,g,f)=>(0,o.jsxs)("button",{"aria-selected":t===v,className:qt(t===v),"data-testid":g,onClick:m(()=>{d(v)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"i"),e[0]=t,e[1]=i):i=e[1];let n=i,u;e[2]!==s||e[3]!==n?(u=(0,o.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[n("diagram",s("Diagram"),"mg-pane-diagram"),n("changes",s("Changes"),"mg-pane-changes"),n("data",s("Data migrations"),"mg-pane-data")]}),e[2]=s,e[3]=n,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==t?(b=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(tt,{initialShardKey:r})}):(0,o.jsx)(Rt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"je");export{da as MigrationsRoutePanel};
1
+ import{a as Ze}from"./chunk-IAKPXGTQ.js";import"./chunk-GMR677FL.js";import"./chunk-7H7LZRLP.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as Ie}from"./chunk-5Y3QLNWX.js";import{a as Ye}from"./chunk-CTNB2KIA.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import"./chunk-4UOFSGUS.js";import{a as Xe}from"./chunk-QXXIJAD5.js";import{a as ze}from"./chunk-3CWGJYBB.js";import{a as We}from"./chunk-X665E2HU.js";import{b as Ve}from"./chunk-GRL5MG3Z.js";import{d as De,e as Fe}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import{R as Ee}from"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{c as Ae}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as _e}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as we}from"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as C}from"./chunk-VDW32UET.js";import{c as de}from"./chunk-SHMNA6UL.js";import{f as Te}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as ye}from"./chunk-XQCVZAGU.js";import{a as Ge,b as He,c as Qe,d as Me,e as O,f as M}from"./chunk-MIQTKZAR.js";import{a as Le,e as Je}from"./chunk-UZERI5YC.js";import{d as oe,f as Pe,g as Be,h as Ue,m as ke,q as Ne}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as m,e as ie,f as qe,g as Ce,h as Ke,j as ne}from"./chunk-3XIESWL4.js";var me=ie(Ce(),1),ce=ie(qe(),1);var et=ie(Ce(),1);var j=ie(qe(),1);var l=ie(Ke(),1);var ct=Pe(C.runMigration),tt=m(a=>{let e=(0,et.c)(98),{initialShardKey:r}=a,s=Te(),t=oe(),{queryShardKey:d,setShardKey:i,shardKey:n}=ze(r),[u,b]=(0,j.useState)(""),[h,v]=(0,j.useState)("up"),[p,g]=(0,j.useState)(!0),[f,y]=(0,j.useState)(!1),[x,c]=(0,j.useState)(null),[N,k]=(0,j.useState)(null),K;e[0]!==n?(K=n.trim(),e[0]=n,e[1]=K):K=e[1];let I=K===d,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S={},e[2]=S):S=e[2];let R;e[3]!==d?(R={live:!0,shardKey:d},e[3]=d,e[4]=R):R=e[4];let w=de(C.migrationStatus,S,R),$=w.data?.migrations??null,$e=w.error,{errorSource:je,liveError:Se}=w,ue,he;e[5]!==d||e[6]!==w.data?(ue=m(()=>{w.data!==void 0&&Ve(d)},"Q"),he=[w.data,d],e[5]=d,e[6]=w.data,e[7]=ue,e[8]=he):(ue=e[7],he=e[8]),(0,j.useEffect)(ue,he);let pe;if(e[9]!==s||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==n||e[14]!==w||e[15]!==t){let q=m(async()=>{let Re=u.trim();if(Re===""){k(t("Enter a migration id")),c(null);return}y(!0),k(null);try{let Oe=await s.query(ct,{direction:h,dryRun:p,id:Re},Be(n));c(Oe),w.refetch()}catch(Oe){let lt=Oe;c(null),k(Ue(lt))}y(!1)},"m");pe=m(()=>{ke(q())},"X"),e[9]=s,e[10]=h,e[11]=p,e[12]=u,e[13]=n,e[14]=w,e[15]=t,e[16]=pe}else pe=e[16];let fe=pe,ge;e[17]===Symbol.for("react.memo_cache_sentinel")?(ge=m(q=>{b(q.target.value)},"Z"),e[17]=ge):ge=e[17];let nt=ge,be;e[18]===Symbol.for("react.memo_cache_sentinel")?(be=m(q=>{v(q.target.value==="down"?"down":"up")},"H"),e[18]=be):be=e[18];let ot=be,ve;e[19]===Symbol.for("react.memo_cache_sentinel")?(ve=m(q=>{g(q.target.checked)},"ee"),e[19]=ve):ve=e[19];let dt=ve,T;e[20]!==i||e[21]!==n?(T=(0,l.jsx)(We,{onChange:i,testId:"mg-shard-input",value:n}),e[20]=i,e[21]=n,e[22]=T):T=e[22];let D;e[23]!==Se?(D=(0,l.jsx)(Ye,{message:Se,prefix:"mg"}),e[23]=Se,e[24]=D):D=e[24];let F;e[25]!==T||e[26]!==D?(F=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[T,D]}),e[25]=T,e[26]=D,e[27]=F):F=e[27];let _;e[28]!==$e||e[29]!==je?(_=$e!==null&&(0,l.jsx)(we,{error:je,testId:"mg-status-error"}),e[28]=$e,e[29]=je,e[30]=_):_=e[30];let E;e[31]!==$||e[32]!==t?(E=$!==null&&$.length===0&&(0,l.jsx)(ye,{description:t("Data migrations you run against this shard will be tracked here."),icon:(0,l.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:t("No migrations have run on this shard.")}),e[31]=$,e[32]=t,e[33]=E):E=e[33];let A;e[34]!==$||e[35]!==t?(A=$!==null&&$.length>0&&(0,l.jsx)(Le,{className:"overflow-hidden py-0",children:(0,l.jsx)(Je,{className:"px-0",children:(0,l.jsxs)(Ge,{"data-testid":"mg-table",children:[(0,l.jsx)(He,{children:(0,l.jsxs)(Me,{children:[(0,l.jsx)(O,{children:t("id")}),(0,l.jsx)(O,{children:t("direction")}),(0,l.jsx)(O,{children:t("status")}),(0,l.jsx)(O,{children:t("processed")}),(0,l.jsx)(O,{children:t("changed")}),(0,l.jsx)(O,{children:t("updated")}),(0,l.jsx)(O,{children:t("error")})]})}),(0,l.jsx)(Qe,{children:$.map(mt)})]})})}),e[34]=$,e[35]=t,e[36]=A):A=e[36];let L;e[37]!==t?(L=t("Run migration"),e[37]=t,e[38]=L):L=e[38];let J;e[39]!==L?(J=(0,l.jsx)(Ie,{children:L}),e[39]=L,e[40]=J):J=e[40];let P;e[41]!==t?(P=t("Migration id"),e[41]=t,e[42]=P):P=e[42];let B;e[43]!==t?(B=t("migration id"),e[43]=t,e[44]=B):B=e[44];let U;e[45]!==u||e[46]!==P||e[47]!==B?(U=(0,l.jsx)(Ee,{"aria-label":P,className:"w-auto","data-testid":"mg-id-input",onChange:nt,placeholder:B,value:u}),e[45]=u,e[46]=P,e[47]=B,e[48]=U):U=e[48];let V;e[49]!==t?(V=t("Direction"),e[49]=t,e[50]=V):V=e[50];let W;e[51]!==t?(W=t("up"),e[51]=t,e[52]=W):W=e[52];let z;e[53]!==W?(z=(0,l.jsx)("option",{value:"up",children:W}),e[53]=W,e[54]=z):z=e[54];let G;e[55]!==t?(G=t("down"),e[55]=t,e[56]=G):G=e[56];let H;e[57]!==G?(H=(0,l.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=H):H=e[58];let Q;e[59]!==h||e[60]!==V||e[61]!==z||e[62]!==H?(Q=(0,l.jsxs)("select",{"aria-label":V,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:ot,value:h,children:[z,H]}),e[59]=h,e[60]=V,e[61]=z,e[62]=H,e[63]=Q):Q=e[63];let X;e[64]!==p?(X=(0,l.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:dt,type:"checkbox"}),e[64]=p,e[65]=X):X=e[65];let Y;e[66]!==t?(Y=t("Dry run"),e[66]=t,e[67]=Y):Y=e[67];let Z;e[68]!==X||e[69]!==Y?(Z=(0,l.jsxs)(Ie,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[X,Y]}),e[68]=X,e[69]=Y,e[70]=Z):Z=e[70];let ee;e[71]!==p||e[72]!==fe||e[73]!==f||e[74]!==I||e[75]!==t?(ee=p?(0,l.jsx)(Ae,{"data-testid":"mg-run",disabled:f||!I,onClick:fe,type:"button",children:t(f?"Running\u2026":"Run")}):(0,l.jsx)(Xe,{confirmLabel:t(f?"Running\u2026":"Run migration?"),disabled:f||!I,onConfirm:fe,testId:"mg-run",children:t("Run")}),e[71]=p,e[72]=fe,e[73]=f,e[74]=I,e[75]=t,e[76]=ee):ee=e[76];let te;e[77]!==U||e[78]!==Q||e[79]!==Z||e[80]!==ee?(te=(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[U,Q,Z,ee]}),e[77]=U,e[78]=Q,e[79]=Z,e[80]=ee,e[81]=te):te=e[81];let ae;e[82]!==J||e[83]!==te?(ae=(0,l.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[J,te]}),e[82]=J,e[83]=te,e[84]=ae):ae=e[84];let re;e[85]!==N?(re=N!==null&&(0,l.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:N}),e[85]=N,e[86]=re):re=e[86];let se;e[87]!==x||e[88]!==t?(se=x!==null&&(0,l.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[x.dryRun?t("Dry run: "):"",t("{status} \u2014 processed",{status:x.status}),x.processed,t(", changed"),x.changed]}),e[87]=x,e[88]=t,e[89]=se):se=e[89];let xe;return e[90]!==F||e[91]!==_||e[92]!==E||e[93]!==A||e[94]!==ae||e[95]!==re||e[96]!==se?(xe=(0,l.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[F,_,E,A,ae,re,se]}),e[90]=F,e[91]=_,e[92]=E,e[93]=A,e[94]=ae,e[95]=re,e[96]=se,e[97]=xe):xe=e[97],xe},"yr");function mt(a){return(0,l.jsxs)(Me,{"data-testid":`mg-row-${a.id}`,children:[(0,l.jsx)(M,{children:a.id}),(0,l.jsx)(M,{children:a.direction}),(0,l.jsx)(M,{children:(0,l.jsx)(_e,{variant:"secondary",children:a.status})}),(0,l.jsx)(M,{children:a.processed}),(0,l.jsx)(M,{children:a.changed}),(0,l.jsx)(M,{children:Ne(a.updatedAt)}),(0,l.jsx)(M,{children:a.error??""})]},a.id)}m(mt,"Ve");var o=ie(Ke(),1);var le=m(a=>typeof a=="object"&&a!==null,"k"),ut=m(a=>le(a)&&le(a.fields)&&le(a.indexes)&&le(a.relations)&&typeof a.shardMode=="string","z"),ht=m(a=>{if(a===void 0||a.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(a)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!le(e)||e.version!==1||!le(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(1)})`,status:"invalid"};for(let[r,s]of Object.entries(e.tables))if(!ut(s))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:1},status:"ok"}},"B"),pt=m((a,e)=>a.unique===e.unique&&a.fields.length===e.fields.length&&a.fields.every((r,s)=>r===e.fields[s]),"L"),ft=m((a,e,r,s)=>{let t=[];return r.kind!==s.kind&&t.push({severity:"breaking",summary:`field ${a}.${e} changed type: ${r.kind} \u2192 ${s.kind} \u2014 add a data migration to convert existing values`,table:a,scope:"table",type:"changedFieldKind"}),r.optional&&!s.optional?t.push({severity:"breaking",summary:`field ${a}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:a,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&s.optional&&t.push({scope:"table",severity:"safe",summary:`field ${a}.${e} became optional`,table:a,type:"fieldRequiredToOptional"}),t},"Q"),gt=m((a,e,r)=>r.optional?{scope:"table",severity:"safe",summary:`added optional field ${a}.${e}`,table:a,type:"addedOptionalField"}:{severity:"breaking",summary:`added required field ${a}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:a,scope:"table",type:"addedRequiredField"},"G"),bt=m((a,e,r,s)=>{for(let[t,d]of Object.entries(r.fields)){let i=e.fields[t];i===void 0?s.push(gt(a,t,d)):s.push(...ft(a,t,i,d))}for(let t of Object.keys(e.fields))r.fields[t]===void 0&&s.push({severity:"breaking",summary:`removed field ${a}.${t} \u2014 add a data migration if stored data must be cleaned up`,table:a,scope:"table",type:"removedField"})},"X"),vt=m((a,e,r,s)=>{for(let[t,d]of Object.entries(r.indexes)){let i=e.indexes[t];if(i===void 0){s.push({scope:"table",severity:"safe",summary:`added index ${t} on ${a}`,table:a,type:"addedIndex"});continue}pt(i,d)||s.push({severity:"breaking",summary:`index ${t} on ${a} changed shape \u2014 a query may have relied on the old index`,table:a,scope:"table",type:"changedIndex"})}for(let t of Object.keys(e.indexes))r.indexes[t]===void 0&&s.push({severity:"breaking",summary:`removed index ${t} on ${a} \u2014 a query that used \`.withIndex("${t}")\` would break`,table:a,scope:"table",type:"removedIndex"})},"Y"),xt=m((a,e,r,s)=>{for(let t of Object.keys(r.relations))e.relations[t]===void 0&&s.push({scope:"schema",severity:"safe",summary:`added relation ${a}.${t}`,table:a,type:"addedRelation"});for(let t of Object.keys(e.relations))r.relations[t]===void 0&&s.push({scope:"schema",severity:"breaking",summary:`removed relation ${a}.${t}`,table:a,type:"removedRelation"})},"Z"),yt=m((a,e,r,s)=>{e.shardMode!==r.shardMode&&s.push({severity:"breaking",summary:`table ${a} changed shard mode: ${e.shardMode} \u2192 ${r.shardMode} \u2014 its physical storage moves; add a data migration / re-shard plan`,table:a,scope:"table",type:"changedShardMode"}),bt(a,e,r,s),vt(a,e,r,s),xt(a,e,r,s)},"ee"),kt=m((a,e)=>{let r=[],s=a?.tables??{};for(let[t,d]of Object.entries(e.tables)){let i=s[t];if(i===void 0){r.push({scope:"table",severity:"safe",summary:`added table ${t}`,table:t,type:"addedTable"});continue}yt(t,i,d,r)}for(let t of Object.keys(s))e.tables[t]===void 0&&r.push({scope:"table",severity:"breaking",summary:`removed table ${t} \u2014 add a data migration if its data must be archived/cleaned up`,table:t,type:"removedTable"});if(a!==void 0&&a.jurisdiction!==e.jurisdiction){let t=a.jurisdiction??"(none)",d=e.jurisdiction??"(none)";r.push({scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${t} to ${d} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"te"),at=m(a=>Object.entries(a.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(a.relations).find(s=>s.field===e&&s.kind==="one")?.table,type:r.kind})),"T"),rt=m((a,e)=>{let r={},s=a?.fields??{},t=e?.fields??{};for(let[d,i]of Object.entries(t)){let n=s[d];n===void 0?r[d]=a===void 0?"unchanged":"added":r[d]=n.kind===i.kind&&n.optional===i.optional?"unchanged":"changed"}for(let d of Object.keys(s))t[d]===void 0&&(r[d]="removed");return r},"F"),Nt=m((a,e)=>{let{changes:r}=kt(a,e),s=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),t=[],d=m((i,n)=>i?"added":s.has(n)?"changed":"context","o");for(let[i,n]of Object.entries(e.tables)){let u=a?.tables[i],b=d(u===void 0,i);t.push({columns:at(n),fieldStatus:rt(u,n),name:i,shardMode:n.shardMode,status:b})}for(let[i,n]of Object.entries(a?.tables??{}))e.tables[i]===void 0&&t.push({columns:at(n),fieldStatus:rt(n,void 0),name:i,shardMode:n.shardMode,status:"removed"});return t.sort((i,n)=>i.name.localeCompare(n.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:t}},"ae"),st=m(a=>{let e=ht(a);return e.status==="ok"?e.snapshot:void 0},"A"),wt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},$t=m(a=>a==="global"?"global":"shard","se"),jt=m(a=>{let e=(0,me.c)(24),{appliedAt:r,hash:s,onSelect:t,selected:d,seq:i}=a,n=d?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==n?(u=ne("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",n),e[0]=n,e[1]=u):u=e[1];let b=`sh-version-${s}`,h;e[2]!==s||e[3]!==t?(h=m(()=>{t(s)},"m"),e[2]=s,e[3]=t,e[4]=h):h=e[4];let v;e[5]!==i?(v=(0,o.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=v):v=e[6];let p;e[7]!==s?(p=s.slice(0,7),e[7]=s,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==v||e[12]!==g?(f=(0,o.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[v,g]}),e[11]=v,e[12]=g,e[13]=f):f=e[13];let y;e[14]!==r?(y=Ne(r),e[14]=r,e[15]=y):y=e[15];let x;e[16]!==y?(x=(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:y}),e[16]=y,e[17]=x):x=e[17];let c;return e[18]!==x||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(c=(0,o.jsx)("li",{children:(0,o.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,x]})}),e[18]=x,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=c):c=e[23],c},"ie"),St=m(a=>{let e=(0,me.c)(26),{breaking:r,count:s,first:t}=a,d=oe();if(t){let g;e[0]!==s?(g=(0,o.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:s}),e[0]=s,e[1]=g):g=e[1];let f;e[2]!==d?(f=d("tables"),e[2]=d,e[3]=f):f=e[3];let y;e[4]!==f?(y=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=y):y=e[5];let x;return e[6]!==g||e[7]!==y?(x=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,y]}),e[6]=g,e[7]=y,e[8]=x):x=e[8],x}let i=r>0&&"text-destructive",n;e[9]!==i?(n=ne("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=n):n=e[10];let u;e[11]!==s||e[12]!==n?(u=(0,o.jsx)("span",{className:n,children:s}),e[11]=s,e[12]=n,e[13]=u):u=e[13];let b;e[14]!==s||e[15]!==d?(b=d(s===1?"change":"changes"),e[14]=s,e[15]=d,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,o.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let v;e[19]!==r||e[20]!==d?(v=r>0&&(0,o.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",d("{count} breaking",{count:r})]}),e[19]=r,e[20]=d,e[21]=v):v=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==v?(p=(0,o.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,v]}),e[22]=u,e[23]=h,e[24]=v,e[25]=p):p=e[25],p},"re"),it={addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedFieldKind:{action:"changed",kind:"field kind"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedShardMode:{action:"changed",kind:"shard mode"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"}},Ot=m((a,e)=>{let r=`${it[a.type].action} ${e} `;return a.summary.startsWith(r)?a.summary.slice(r.length):a.summary},"oe"),Mt=m(a=>{let e=new Map;for(let s of a){let t=s.table??"",d=e.get(t);d===void 0?e.set(t,[s]):d.push(s)}let r=[...e].map(([s,t])=>({changes:t,table:s}));return[...r.filter(s=>s.table!==""),...r.filter(s=>s.table==="")]},"de"),It=m(a=>{let e=(0,me.c)(2),{children:r}=a,s;return e[0]!==r?(s=(0,o.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=s):s=e[1],s},"le"),Rt=m(({pane:a,shardKey:e=""})=>{let r=oe(),s=Fe(),t=De({strict:!1}).version,d=m(c=>{ke(s({search:{version:c},to:"/migrations"}))},"o"),i=de(C.schemaHistory,{},{shardKey:e}),n=i.data?.versions??[],u=t!==void 0&&n.some(c=>c.hash===t)?t:n[0]?.hash,b=n.findIndex(c=>c.hash===u),h=b===-1?void 0:n[b+1]?.hash,v=de(C.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=de(C.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ce.useMemo)(()=>{let c=st(v.data?.version?.snapshotJson);if(c!==void 0)return Nt(st(p.data?.version?.snapshotJson),c)},[v.data,p.data]),f=(0,ce.useMemo)(()=>(g?.tables??[]).map(c=>({columns:c.columns,name:c.name,tier:$t(c.shardMode)})),[g]),y=(0,ce.useMemo)(()=>{let c={};for(let N of g?.tables??[])c[N.name]=wt[N.status];return c},[g]);if(i.error!==null)return(0,o.jsx)(we,{error:i.errorSource,testId:"sh-error"});if(n.length===0)return(0,o.jsx)(ye,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let x=g?.changes??[];return(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,o.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,o.jsx)(It,{children:r("Schema versions")}),(0,o.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:n.map(c=>(0,o.jsx)(jt,{appliedAt:c.appliedAt,hash:c.hash,onSelect:d,selected:c.hash===u,seq:c.seq},c.hash))})]}),(0,o.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,o.jsx)(St,{breaking:g?.breakingCount??0,count:h===void 0?f.length:x.length,first:h===void 0}),a==="diagram"?(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,o.jsx)(Ze,{fill:!0,nodeClasses:y,tables:f,testIdPrefix:"sh"})}):(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Mt(x).map(c=>{let N=(g?.tables??[]).find(k=>k.name===c.table);return(0,o.jsxs)("section",{className:"mb-6",children:[(0,o.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,o.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:c.table===""?r("schema"):c.table}),N!==void 0&&(0,o.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:N.columns.length})}),c.changes.length>1&&(0,o.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:c.changes.length})]}),(0,o.jsx)("ul",{children:c.changes.map(k=>{let{action:K,kind:I}=it[k.type],S=k.severity==="breaking",R=Ot(k,I);return(0,o.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,o.jsx)("span",{"aria-hidden":"true",className:ne("-ms-3 h-3 w-0.5 shrink-0 self-center",S?"bg-destructive":"bg-transparent")}),(0,o.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(K)," ",I]}),R!==c.table&&(0,o.jsx)("span",{className:ne("min-w-0 font-mono text-[13px]",S?"text-destructive":"text-foreground"),children:R}),S&&(0,o.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},c.table)})})]})]})},"ce"),qt=m(a=>ne("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",a?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"me"),da=m(a=>{let e=(0,me.c)(11),{initialShardKey:r}=a,s=oe(),[t,d]=(0,ce.useState)("diagram"),i;e[0]!==t?(i=m((v,p,g,f)=>(0,o.jsxs)("button",{"aria-selected":t===v,className:qt(t===v),"data-testid":g,onClick:m(()=>{d(v)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,o.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"i"),e[0]=t,e[1]=i):i=e[1];let n=i,u;e[2]!==s||e[3]!==n?(u=(0,o.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[n("diagram",s("Diagram"),"mg-pane-diagram"),n("changes",s("Changes"),"mg-pane-changes"),n("data",s("Data migrations"),"mg-pane-data")]}),e[2]=s,e[3]=n,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==t?(b=(0,o.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:t==="data"?(0,o.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,o.jsx)(tt,{initialShardKey:r})}):(0,o.jsx)(Rt,{pane:t,shardKey:r})}),e[5]=r,e[6]=t,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,o.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"je");export{da as MigrationsRoutePanel};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-TS6346VY.js";import{f as _}from"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),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)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("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 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("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:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
1
+ import{a as H}from"./chunk-54MMVNPT.js";import{a as G}from"./chunk-QXXIJAD5.js";import{c as ee}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as Z}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{b as E}from"./chunk-SHMNA6UL.js";import{f as _}from"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import{a as W}from"./chunk-XQCVZAGU.js";import{a as K,b as V,c as z,d as M,e as u,f}from"./chunk-MIQTKZAR.js";import{a as B,e as D}from"./chunk-UZERI5YC.js";import{d as A,h as O,m as T,q as X}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as c,e as R,f as oe,g as re,h as ae}from"./chunk-3XIESWL4.js";var U=R(re(),1),Y=R(oe(),1);var t=R(ae(),1);var se=R(re(),1);var Q=R(oe(),1);var h=R(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","Q"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"A"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"U"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,p=_(),r=A(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let g=await(d??(()=>p.listScheduledJobs()))();return le(g)}),[b,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),k,w;e[1]!==p||e[2]!==l?(k=c(()=>{if(l)return p.subscribeScheduledJobs(g=>{m(void 0),n(le(g))})},"v"),w=[l,p],e[1]=p,e[2]=l,e[3]=k,e[4]=w):(k=e[3],w=e[4]),(0,Q.useEffect)(k,w);let x;e[5]!==N?(x=c(()=>{N.refetch()},"j"),e[5]=N,e[6]=x):x=e[6],H(x,!l);let J=ce(p,i,d),v=b??N.data,j=s??N.error,q=c(async g=>{if(J!==void 0){m(void 0);try{await J(g),l||N.refetch()}catch(P){m(O(P))}}},"k"),I="flex flex-col gap-3",F="lunora-scheduled-jobs",C;e[7]!==j?(C=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=C):C=e[8];let S;e[9]!==v?.length||e[10]!==r?(S=v?.length===0&&(0,h.jsx)(W,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=v?.length,e[10]=r,e[11]=S):S=e[11];let $=v!==void 0&&v.length>0&&(0,h.jsx)(B,{className:"overflow-hidden py-0",children:(0,h.jsx)(D,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(M,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:v.map(g=>(0,h.jsxs)(M,{"data-testid":`sj-row-${g.id}`,children:[(0,h.jsx)(f,{className:"font-mono text-xs",children:g.functionPath}),(0,h.jsx)(f,{className:"text-muted-foreground tabular-nums",children:ie(g.scheduledFor)}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.pool??""}),(0,h.jsx)(f,{className:"tabular-nums",children:g.attempts??0}),(0,h.jsx)(f,{children:g.shardKey??""}),(0,h.jsx)(f,{className:"font-mono text-xs",children:g.id}),J!==void 0&&(0,h.jsx)(f,{className:"text-right",children:(0,h.jsx)(G,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{T(q(g.id))},"onConfirm"),testId:`sj-cancel-${g.id}`,children:r("Cancel")})})]},g.id))})]})})}),y;return e[12]!==$||e[13]!==C||e[14]!==S?(y=(0,h.jsxs)("div",{className:I,"data-testid":F,children:[C,S,$]}),e[12]=$,e[13]=C,e[14]=S,e[15]=y):y=e[15],y},"me");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"oe"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=_(),d=A(),[p,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,b=me(i,a,e),n=c(async s=>{if(b!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await b(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(k=>({...k,[s]:{kind:"error",message:O(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(W,{description:d("Triggers declared with the cronJobs() builder appear here."),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)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),b!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=p[s.name]??he;return(0,t.jsxs)(M,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(f,{children:s.name}),(0,t.jsx)(f,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(f,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(f,{children:s.shardKey??""}),b!==void 0&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(G,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{T(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),fe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","re"),pe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:p,retryJob:r}=i,l=_(),o=A(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let b;e[3]!==l||e[4]!==d?(b=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(ve),"h"),e[3]=l,e[4]=d,e[5]=b):b=e[5];let n=E(N,b),s=n.data,[m,k]=(0,Y.useState)(void 0),w=n.error??m,x=d===void 0,J;e[6]!==l||e[7]!==x||e[8]!==r?(J=r??(x?L=>l.retryDeadJob(L):void 0),e[6]=l,e[7]=x,e[8]=r,e[9]=J):J=e[9];let v=J,j;e[10]!==l||e[11]!==x||e[12]!==p?(j=p??(x?L=>l.removeDeadJob(L):void 0),e[10]=l,e[11]=x,e[12]=p,e[13]=j):j=e[13];let q=j,I;e[14]!==n?(I=c(()=>{n.refetch()},"J"),e[14]=n,e[15]=I):I=e[15],H(I,!0);let F;e[16]!==n?(F=c(async L=>{k(void 0);try{await L,n.refetch()}catch(ne){k(O(ne))}},"j"),e[16]=n,e[17]=F):F=e[17];let C=F,S=v!==void 0||q!==void 0,$;e[18]!==w?($=w!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:w}),e[18]=w,e[19]=$):$=e[19];let y;e[20]!==s?.length||e[21]!==o?(y=s?.length===0&&(0,t.jsx)(W,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("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 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=y):y=e[22];let g;e[23]!==C||e[24]!==S||e[25]!==s||e[26]!==q||e[27]!==v||e[28]!==o?(g=s!==void 0&&s.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),S&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(L=>(0,t.jsxs)(M,{"data-testid":`dlq-row-${L.id}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:L.functionPath}),(0,t.jsx)(f,{className:"tabular-nums",children:L.attempts??0}),(0,t.jsx)(f,{className:"text-muted-foreground tabular-nums",children:fe(L.scheduledFor)}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.pool??""}),(0,t.jsx)(f,{children:L.shardKey??""}),(0,t.jsx)(f,{className:"font-mono text-xs",children:L.id}),S&&(0,t.jsx)(f,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${L.id}`,onClick:c(()=>{T(C(v(L.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),q!==void 0&&(0,t.jsx)(G,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{T(C(q(L.id)))},"onConfirm"),testId:`dlq-remove-${L.id}`,children:o("Drop")})]})})]},L.id))})]})})}),e[23]=C,e[24]=S,e[25]=s,e[26]=q,e[27]=v,e[28]=o,e[29]=g):g=e[29];let P;return e[30]!==g||e[31]!==$||e[32]!==y?(P=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,y,g]}),e[30]=g,e[31]=$,e[32]=y,e[33]=P):P=e[33],P},"ne");function ve(a,e){return(e.attempts??0)-(a.attempts??0)}c(ve,"ae");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:p}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==p?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:p}),e[2]=d,e[3]=p,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(B,{className:"flex-1 py-0",children:(0,t.jsxs)(D,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"F"),be=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,p=_(),r=A(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==p||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>p.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"k"),e[4]=p,e[5]=d,e[6]=N):N=e[6];let b=E(o,N),{data:n,error:s}=b,m;e[7]!==b?(m=c(()=>{b.refetch()},"s"),e[7]=b,e[8]=m):m=e[8],H(m,!0);let k;e[9]!==s?(k=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=k):k=e[10];let w;e[11]!==n||e[12]!==r?(w=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=w):w=e[13];let x;e[14]!==n?.pools.length||e[15]!==r?(x=n?.pools.length===0&&(0,t.jsx)(W,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("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:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=x):x=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(B,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let v;return e[20]!==k||e[21]!==w||e[22]!==x||e[23]!==J?(v=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[k,w,x,J]}),e[20]=k,e[21]=w,e[22]=x,e[23]=J,e[24]=v):v=e[24],v},"de");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(M,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(f,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(f,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(f,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(f,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"se");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:p,scheduledLoad:r}=i,l=A(),[o,N]=(0,Y.useState)("jobs"),b;e[2]!==l?(b=l("Cron triggers"),e[2]=l,e[3]=b):b=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let k;e[10]!==b||e[11]!==n||e[12]!==s||e[13]!==m?(k={cron:b,dead:n,jobs:s,pools:m},e[10]=b,e[11]=n,e[12]=s,e[13]=m,e[14]=k):k=e[14];let w=k,x;e[15]===Symbol.for("react.memo_cache_sentinel")?(x=c(y=>{N(y.currentTarget.dataset.view)},"u"),e[15]=x):x=e[15];let J=x,v;e[16]!==l?(v=l("Schedule view"),e[16]=l,e[17]=v):v=e[17];let j;e[18]!==o||e[19]!==w?(j=Ne.map(y=>(0,t.jsx)(ee,{"aria-selected":o===y,"data-testid":`schedule-view-${y}`,"data-view":y,onClick:J,role:"tab",size:"sm",type:"button",variant:o===y?"default":"outline",children:w[y]},y)),e[18]=o,e[19]=w,e[20]=j):j=e[20];let q;e[21]!==v||e[22]!==j?(q=(0,t.jsx)("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=v,e[22]=j,e[23]=q):q=e[23];let I;e[24]!==p||e[25]!==r||e[26]!==o?(I=o==="jobs"&&(0,t.jsx)(de,{cancelJob:p,loadJobs:r}),e[24]=p,e[25]=r,e[26]=o,e[27]=I):I=e[27];let F;e[28]!==o?(F=o==="dead"&&(0,t.jsx)(pe,{}),e[28]=o,e[29]=F):F=e[29];let C;e[30]!==o?(C=o==="pools"&&(0,t.jsx)(be,{}),e[30]=o,e[31]=C):C=e[31];let S;e[32]!==d||e[33]!==o?(S=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=S):S=e[34];let $;return e[35]!==q||e[36]!==I||e[37]!==F||e[38]!==C||e[39]!==S?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[q,I,F,C,S]}),e[35]=q,e[36]=I,e[37]=F,e[38]=C,e[39]=S,e[40]=$):$=e[40],$},"Je");export{Ve as SchedulePanel};
@@ -1 +1 @@
1
- import{b as R}from"./chunk-UR3X4K4T.js";import"./chunk-YRYEZHOJ.js";import"./chunk-XXQUMVWH.js";import"./chunk-PNAVAJAF.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-TS6346VY.js";import"./chunk-MIFLRBVS.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as g}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
1
+ import{b as R}from"./chunk-YOUKADZH.js";import"./chunk-LJIFMW67.js";import"./chunk-XXQUMVWH.js";import"./chunk-QWBRD6PX.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-SHMNA6UL.js";import"./chunk-V2U5CL3S.js";import"./chunk-XBDKZZ67.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{d as g}from"./chunk-OG4N2XHD.js";import"./chunk-XNGYYOLS.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};