@lunora/studio 1.0.0-alpha.362 → 1.0.0-alpha.363

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 (64) hide show
  1. package/dist/standalone/{chunk-J6XQKD2F.js → chunk-32V7XGNC.js} +1 -1
  2. package/dist/standalone/{chunk-Q2J73V2C.js → chunk-4L55URI5.js} +1 -1
  3. package/dist/standalone/{chunk-FBDIQ67D.js → chunk-4N76XUNG.js} +1 -1
  4. package/dist/standalone/{chunk-6KE7ILEZ.js → chunk-53XKGQEE.js} +1 -1
  5. package/dist/standalone/{chunk-7KJCRT4B.js → chunk-5QUTVSHM.js} +1 -1
  6. package/dist/standalone/{chunk-MJTVTUNI.js → chunk-5RX5CQSU.js} +1 -1
  7. package/dist/standalone/{chunk-ZG3IUVQ2.js → chunk-5Z2U4KBN.js} +1 -1
  8. package/dist/standalone/{chunk-ZKEYRU5C.js → chunk-75TRPM7O.js} +1 -1
  9. package/dist/standalone/{chunk-GC3GKGWD.js → chunk-7MLX5CGD.js} +1 -1
  10. package/dist/standalone/{chunk-BO5NNWMO.js → chunk-7TQ7BZ67.js} +1 -1
  11. package/dist/standalone/{chunk-H7BQUL7D.js → chunk-AD5J2ANS.js} +1 -1
  12. package/dist/standalone/{chunk-COLSZPCE.js → chunk-ALR4VAUE.js} +1 -1
  13. package/dist/standalone/{chunk-5EWIOOBI.js → chunk-AXE2SDRU.js} +1 -1
  14. package/dist/standalone/{chunk-JENPPZFV.js → chunk-BAEIW3YS.js} +1 -1
  15. package/dist/standalone/{chunk-BX7TFVCC.js → chunk-BBDTJG2K.js} +1 -1
  16. package/dist/standalone/{chunk-ZFQ253FX.js → chunk-BI6MZHZJ.js} +1 -1
  17. package/dist/standalone/{chunk-EE2COWFF.js → chunk-CP7QNLR4.js} +1 -1
  18. package/dist/standalone/{chunk-OP4QEV27.js → chunk-D57B4MFK.js} +1 -1
  19. package/dist/standalone/{chunk-53CGUTRT.js → chunk-DZFXH55R.js} +1 -1
  20. package/dist/standalone/{chunk-J3BZWYJQ.js → chunk-EPWCW2DF.js} +1 -1
  21. package/dist/standalone/{chunk-PAZKX7I6.js → chunk-FJLRSFTE.js} +1 -1
  22. package/dist/standalone/{chunk-L26RMC2W.js → chunk-FVCBNFQW.js} +1 -1
  23. package/dist/standalone/{chunk-UW6QNC74.js → chunk-GVQPNM3T.js} +1 -1
  24. package/dist/standalone/{chunk-7WV3EPE6.js → chunk-H3EIPYRZ.js} +1 -1
  25. package/dist/standalone/{chunk-HCCQTUHS.js → chunk-H5TMLWIS.js} +1 -1
  26. package/dist/standalone/{chunk-LPFUEJZ4.js → chunk-HBG6SSE2.js} +1 -1
  27. package/dist/standalone/{chunk-5O7ICPWV.js → chunk-HC2B7SXW.js} +1 -1
  28. package/dist/standalone/{chunk-IDZLHZIA.js → chunk-HGCOTYPV.js} +1 -1
  29. package/dist/standalone/{chunk-Q2KL457J.js → chunk-HLHMHCXS.js} +1 -1
  30. package/dist/standalone/{chunk-WADY55J2.js → chunk-HSF2DCJ2.js} +1 -1
  31. package/dist/standalone/{chunk-QEFLZBT7.js → chunk-I3SSF2T6.js} +1 -1
  32. package/dist/standalone/{chunk-ALQHMFOC.js → chunk-I5QX75DE.js} +1 -1
  33. package/dist/standalone/{chunk-JCRFMCNP.js → chunk-ICHZ2IBL.js} +1 -1
  34. package/dist/standalone/{chunk-E2FFHKGI.js → chunk-IG5VD7R7.js} +1 -1
  35. package/dist/standalone/{chunk-ABMHWBYA.js → chunk-KKMQUBYH.js} +1 -1
  36. package/dist/standalone/{chunk-AEU3EF4T.js → chunk-LDHJRHPZ.js} +1 -1
  37. package/dist/standalone/{chunk-X54WR7FF.js → chunk-MNYDT3RH.js} +1 -1
  38. package/dist/standalone/{chunk-OPIMGKWU.js → chunk-MT4ICMXJ.js} +1 -1
  39. package/dist/standalone/{chunk-N7WQJPOM.js → chunk-MXJTD2OX.js} +1 -1
  40. package/dist/standalone/{chunk-WCWP4EAW.js → chunk-OZAOWE7T.js} +1 -1
  41. package/dist/standalone/{chunk-GVZ3VFGG.js → chunk-Q3IA6HPX.js} +1 -1
  42. package/dist/standalone/{chunk-3RZD6VJ7.js → chunk-RBIVXSXT.js} +1 -1
  43. package/dist/standalone/{chunk-JHTL3QHW.js → chunk-SDDEOSQB.js} +1 -1
  44. package/dist/standalone/chunk-SHHGIT7M.js +7 -0
  45. package/dist/standalone/{chunk-Z57KMMOK.js → chunk-SVQWZPO4.js} +1 -1
  46. package/dist/standalone/{chunk-YX2N5PJW.js → chunk-TEMI7MVE.js} +1 -1
  47. package/dist/standalone/{chunk-VHPTPEZ4.js → chunk-U5MPNEM2.js} +1 -1
  48. package/dist/standalone/{chunk-5NIQHOPN.js → chunk-ULQNADMJ.js} +1 -1
  49. package/dist/standalone/{chunk-66LYVBXB.js → chunk-UPPNZ6MI.js} +1 -1
  50. package/dist/standalone/{chunk-ZSLKFLWE.js → chunk-UTQLJKHH.js} +1 -1
  51. package/dist/standalone/{chunk-FQEZUQ36.js → chunk-UVG3ZISC.js} +1 -1
  52. package/dist/standalone/{chunk-2FTGLXYA.js → chunk-VQDTA4P6.js} +1 -1
  53. package/dist/standalone/{chunk-7O5SGABV.js → chunk-WLHQ4FKC.js} +1 -1
  54. package/dist/standalone/{chunk-XWWQIAF6.js → chunk-XPFVUAPX.js} +1 -1
  55. package/dist/standalone/{chunk-NF2Q75WM.js → chunk-Y3IGTWUE.js} +1 -1
  56. package/dist/standalone/{chunk-J6FR2B77.js → chunk-Y64STA6O.js} +1 -1
  57. package/dist/standalone/{chunk-IUGNIG6L.js → chunk-YEXTJUKQ.js} +1 -1
  58. package/dist/standalone/{chunk-RE7GRXBM.js → chunk-YFTPHGS2.js} +1 -1
  59. package/dist/standalone/{chunk-EXFERMUT.js → chunk-Z64BZNPS.js} +1 -1
  60. package/dist/standalone/{chunk-TMWKF4XM.js → chunk-Z6VILGGP.js} +1 -1
  61. package/dist/standalone/{chunk-MQTI3STP.js → chunk-ZBOB33BA.js} +1 -1
  62. package/dist/standalone/studio.js +1 -1
  63. package/package.json +3 -3
  64. package/dist/standalone/chunk-FACXM2UB.js +0 -7
@@ -1 +1 @@
1
- import{b as be}from"./chunk-RIAOZECW.js";import{a as le}from"./chunk-DB6QX4X6.js";import"./chunk-5WNGRT7N.js";import{a as ve}from"./chunk-ELSQ4FVH.js";import"./chunk-Y2YLTUMD.js";import"./chunk-BG2CJOVS.js";import{a as xe}from"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-QRA7AKYO.js";import"./chunk-4EPW63HS.js";import{b as ee}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import"./chunk-4PI2OSSP.js";import{a as B}from"./chunk-2W4UO5BC.js";import{c as ge}from"./chunk-FBDIQ67D.js";import{a as X}from"./chunk-OK2QU2EV.js";import{l as he,m as fe}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B as U,h as W,i as ie,j as ce,s as se,w as pe,x as $}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ue}from"./chunk-GWNGVKLG.js";import{a as Ae,b as me}from"./chunk-6G3E4PJ2.js";import{a as h,d as Z}from"./chunk-5PEAXTYQ.js";var te=Z(ue(),1),x=Z(Ae(),1);var Ne=Z(ue(),1);var ae=Z(me(),1);var je={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},ye=h(()=>{let t=(0,Ne.c)(18),e=U(),n=he(),r;e:switch(n){case"connected":{let l;t[0]!==e?(l=e("Connected"),t[0]=e,t[1]=l):l=t[1],r=l;break e}case"connecting":{let l;t[2]!==e?(l=e("Connecting\u2026"),t[2]=e,t[3]=l):l=t[3],r=l;break e}case"idle":{let l;t[4]!==e?(l=e("Idle"),t[4]=e,t[5]=l):l=t[5],r=l;break e}case"offline":{let l;t[6]!==e?(l=e("Offline"),t[6]=e,t[7]=l):l=t[7],r=l;break e}case"polling":{let l;t[8]!==e?(l=e("Polling"),t[8]=e,t[9]=l):l=t[9],r=l;break e}default:r=n}let a=je[n],c;t[10]!==a?(c=$("size-2 rounded-full",a),t[10]=a,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,ae.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==n||t[15]!==i||t[16]!==r?(o=(0,ae.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":n,"data-testid":"dash-connection",role:"status",children:[i,r]}),t[14]=n,t[15]=i,t[16]=r,t[17]=o):o=t[17],o},"T");var s=Z(me(),1);var Te={crit:"destructive",ok:"secondary",warn:"default"},oe=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"re"),de=h((t,e,n)=>Number.isNaN(t)?"ok":t>=n?"crit":t>=e?"warn":"ok","oe"),Se=.01,Ee=.05,Ce=h(t=>{let e=(0,te.c)(36),{errorCount:n,logsError:r,topErrors:a,worstFunctions:c}=t,i=U(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=(0,s.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=l):l=e[3];let u;e[4]!==i||e[5]!==c?(u=c.length===0?(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,s.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,s.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,s.jsx)(ee,{variant:Te[de(y.errors/y.calls,Se,Ee)],children:oe(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==u?(f=(0,s.jsxs)(X,{className:"gap-0 py-0","data-testid":"hl-functions",children:[l,u]}),e[7]=l,e[8]=u,e[9]=f):f=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let m;e[12]!==v?(m=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=m):m=e[13];let d=n>0?"destructive":"outline",g;e[14]!==n||e[15]!==d?(g=(0,s.jsx)(ee,{"data-testid":"hl-error-count",variant:d,children:n}),e[14]=n,e[15]=d,e[16]=g):g=e[16];let p;e[17]!==m||e[18]!==g?(p=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[m,g]}),e[17]=m,e[18]=g,e[19]=p):p=e[19];let S;e[20]!==r?(S=r!==null&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:r}),e[20]=r,e[21]=S):S=e[21];let E;e[22]!==r||e[23]!==i||e[24]!==a.length?(E=r===null&&a.length===0&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=r,e[23]=i,e[24]=a.length,e[25]=E):E=e[25];let q;e[26]!==a?(q=a.length>0&&(0,s.jsx)("ul",{className:"divide-y divide-border",children:a.map(Ie)}),e[26]=a,e[27]=q):q=e[27];let w;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==p?(w=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[p,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=p,e[32]=w):w=e[32];let k;return e[33]!==w||e[34]!==f?(k=(0,s.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[f,w]}),e[33]=w,e[34]=f,e[35]=k):k=e[35],k},"_e");function Ie(t,e){return(0,s.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("time",{className:"shrink-0 text-muted-foreground",children:pe(t.timestamp)}),t.functionPath!==void 0&&(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,s.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ie,"Ae");var we={completed:0,failed:2,in_progress:1},De=h(t=>{let e=0,n=0,r=0,a=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){a+=1;continue}r+=1,e+=o.requests,n+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:n,failed:a,history:i,historyTruncated:c,reachable:r,requests:e}},"ke"),_e=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.path);if(a===void 0){e.set(r.path,{...r});continue}a.calls+=r.calls,a.errors+=r.errors,a.totalDurationMs+=r.totalDurationMs,a.scans=(a.scans??0)+(r.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,r.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,r.lastCalledAt),(r.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=r.lastErrorAt,a.lastErrorMessage=r.lastErrorMessage)}return[...e.values()]},"Re"),Pe=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.id);if(a===void 0){e.set(r.id,r);continue}let c=we[r.status]-we[a.status];(c>0||c===0&&(r.updatedAt??0)>(a.updatedAt??0))&&e.set(r.id,r)}return[...e.values()]},"Me"),Le=W(B.getAuthMetrics),Fe=W(B.getFunctionStats),Re=W(B.getLogs),Oe=W(B.getMetrics),ze=W(B.migrationStatus),$e=5,ke=2e3,Ke=5,Be=.1,Ue=.3,Ge=1,He=50,Qe=h((t,e,n)=>t>=n?"crit":t>=e?"warn":"ok","$e"),Je=h(t=>{let e=new Map;for(let r of t??[]){let a=e.get(r.bucketMs)??{calls:0,errors:0};a.calls+=r.calls,a.errors+=r.errors,e.set(r.bucketMs,a)}let n=[...e.entries()].toSorted((r,a)=>r[0]-a[0]);return{errors:n.map(([,r])=>r.errors),requests:n.map(([,r])=>r.calls)}},"Be"),Ve=h(t=>{let e=0,n=0;for(let a of t)a.status==="failed"?e+=1:a.status==="in_progress"&&(n+=1);let r="ok";return e>0?r="crit":n>0&&(r="warn"),{failed:e,level:r,running:n}},"Ve"),We=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),qe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Me={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Xe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Ye=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","ze"),ne=h(t=>{let e=(0,te.c)(19),{chart:n,label:r,level:a,testId:c,value:i}=t,o=qe[a],l;e[0]!==o?(l=$("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==l?(u=(0,s.jsx)("span",{"aria-hidden":"true",className:l}),e[2]=l,e[3]=u):u=e[3];let f;e[4]!==r||e[5]!==u?(f=(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[u,r]}),e[4]=r,e[5]=u,e[6]=f):f=e[6];let v=Me[a],m;e[7]!==v?(m=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=m):m=e[8];let d;e[9]!==m||e[10]!==c||e[11]!==i?(d=(0,s.jsx)("span",{className:m,"data-testid":c,children:i}),e[9]=m,e[10]=c,e[11]=i,e[12]=d):d=e[12];let g;e[13]!==n||e[14]!==d?(g=(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[d,n]}),e[13]=n,e[14]=d,e[15]=g):g=e[15];let p;return e[16]!==f||e[17]!==g?(p=(0,s.jsx)(X,{className:"gap-0 py-0",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[f,g]})}),e[16]=f,e[17]=g,e[18]=p):p=e[18],p},"ee"),Ze=h(async(t,e,n)=>{let r=await Promise.all(n.map(m=>{let d=ie(m);return Promise.allSettled([t.query(Oe,{},d),t.query(Fe,{},d),t.query(ze,{},d)])})),a=ie(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,l]=await Promise.allSettled([t.query(Re,{},a),t.query(Le,{},a),c]),u=r.map(([m,d,g])=>({functions:d.status==="fulfilled"?d.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),f=De(u),v=r[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:_e(u.map(m=>m.functions)),logsError:i.status==="rejected"?ce(i.reason):null,metricsError:f.reachable===0&&v?.status==="rejected"?ce(v.reason):null,migrations:Pe(u.map(m=>m.migrations)),scheduler:l.status==="fulfilled"?l.value:null,totals:f}},"Qe"),et=h(t=>{let e=t?.history??[];return{attempts:e.map(n=>n.attempts),failures:e.map(n=>n.failures)}},"We"),tt=h((t,e)=>t==="crit"?{description:e("One or more service levels are breached."),label:e("Critical")}:t==="warn"?{description:e("Some service levels need attention."),label:e("Degraded")}:{description:e("All service levels are within target."),label:e("All systems healthy")},"Xe"),rt=h(t=>{let e=(0,te.c)(75),{errorLevel:n,liveError:r,metricsError:a,overall:c,requestSeries:i,totals:o}=t,l=U(),u;e[0]!==c||e[1]!==l?(u=tt(c,l),e[0]=c,e[1]=l,e[2]=u):u=e[2];let{description:f,label:v}=u,m=Xe[c],d;e[3]!==m?(d=$("flex size-10 shrink-0 items-center justify-center rounded-full",m),e[3]=m,e[4]=d):d=e[4];let g=qe[c],p;e[5]!==g?(p=$("size-3 rounded-full",g),e[5]=g,e[6]=p):p=e[6];let S;e[7]!==p?(S=(0,s.jsx)("span",{className:p}),e[7]=p,e[8]=S):S=e[8];let E;e[9]!==d||e[10]!==S?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:d,children:S}),e[9]=d,e[10]=S,e[11]=E):E=e[11];let q;e[12]!==v?(q=(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:v}),e[12]=v,e[13]=q):q=e[13];let w;e[14]!==f?(w=(0,s.jsx)("span",{className:"text-[13px] text-muted-foreground",children:f}),e[14]=f,e[15]=w):w=e[15];let k;e[16]!==q||e[17]!==w?(k=(0,s.jsxs)("div",{className:"grid leading-tight",children:[q,w]}),e[16]=q,e[17]=w,e[18]=k):k=e[18];let y;e[19]!==k||e[20]!==E?(y=(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[E,k]}),e[19]=k,e[20]=E,e[21]=y):y=e[21];let j;e[22]!==l?(j=l("Requests"),e[22]=l,e[23]=j):j=e[23];let M;e[24]!==j?(M=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:j}),e[24]=j,e[25]=M):M=e[25];let A;e[26]!==i||e[27]!==l?(A=i.length>=2&&(0,s.jsx)(le,{ariaLabel:l("Requests over time"),className:"h-6 w-20 text-foreground",series:i,testId:"hl-spark-requests"}),e[26]=i,e[27]=l,e[28]=A):A=e[28];let F=o?.requests??0,R;e[29]!==F?(R=F.toString(),e[29]=F,e[30]=R):R=e[30];let D;e[31]!==R?(D=(0,s.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:R}),e[31]=R,e[32]=D):D=e[32];let O;e[33]!==A||e[34]!==D?(O=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[A,D]}),e[33]=A,e[34]=D,e[35]=O):O=e[35];let _;e[36]!==M||e[37]!==O?(_=(0,s.jsxs)("div",{className:"text-end",children:[M,O]}),e[36]=M,e[37]=O,e[38]=_):_=e[38];let G;e[39]===Symbol.for("react.memo_cache_sentinel")?(G=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[39]=G):G=e[39];let T;e[40]!==l?(T=l("Error rate"),e[40]=l,e[41]=T):T=e[41];let P;e[42]!==T?(P=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[42]=T,e[43]=P):P=e[43];let Y=Me[n],C;e[44]!==Y?(C=$("text-lg font-semibold tabular-nums",Y),e[44]=Y,e[45]=C):C=e[45];let z;e[46]!==o?(z=o===null?"\u2014":oe(o.errors,o.requests),e[46]=o,e[47]=z):z=e[47];let I;e[48]!==C||e[49]!==z?(I=(0,s.jsx)("div",{className:C,"data-testid":"hl-error-rate",children:z}),e[48]=C,e[49]=z,e[50]=I):I=e[50];let L;e[51]!==P||e[52]!==I?(L=(0,s.jsxs)("div",{className:"text-end",children:[P,I]}),e[51]=P,e[52]=I,e[53]=L):L=e[53];let K;e[54]===Symbol.for("react.memo_cache_sentinel")?(K=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[54]=K):K=e[54];let H;e[55]===Symbol.for("react.memo_cache_sentinel")?(H=(0,s.jsx)(ye,{}),e[55]=H):H=e[55];let b;e[56]!==r?(b=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[H,(0,s.jsx)(ve,{message:r,prefix:"hl"})]}),e[56]=r,e[57]=b):b=e[57];let N;e[58]!==_||e[59]!==L||e[60]!==b?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[_,G,L,K,b]}),e[58]=_,e[59]=L,e[60]=b,e[61]=N):N=e[61];let Q;e[62]!==y||e[63]!==N?(Q=(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[y,N]}),e[62]=y,e[63]=N,e[64]=Q):Q=e[64];let J;e[65]!==a?(J=a!==null&&(0,s.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:a}),e[65]=a,e[66]=J):J=e[66];let V;e[67]!==a||e[68]!==l||e[69]!==o?.historyTruncated?(V=a===null&&o?.historyTruncated===!0&&(0,s.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:l("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")}),e[67]=a,e[68]=l,e[69]=o?.historyTruncated,e[70]=V):V=e[70];let re;return e[71]!==Q||e[72]!==J||e[73]!==V?(re=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[Q,J,V]}),e[71]=Q,e[72]=J,e[73]=V,e[74]=re):re=e[74],re},"Je"),st=h(t=>{let e=(0,te.c)(14),{shards:n}=t,r=U(),a;e[0]!==r?(a=r("Shards seen"),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==a?(c=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[2]=a,e[3]=c):c=e[3];let i;e[4]!==n.length?(i=(0,s.jsx)(ee,{"data-testid":"hl-shard-count",variant:"outline",children:n.length}),e[4]=n.length,e[5]=i):i=e[5];let o;e[6]!==c||e[7]!==i?(o=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[c,i]}),e[6]=c,e[7]=i,e[8]=o):o=e[8];let l;e[9]!==n?(l=n.length>0&&(0,s.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:n.map(lt)}),e[9]=n,e[10]=l):l=e[10];let u;return e[11]!==o||e[12]!==l?(u=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[o,l]}),e[11]=o,e[12]=l,e[13]=u):u=e[13],u},"Ye"),kt=h(({initialShardKey:t})=>{let e=fe(),n=U(),[r,a]=(0,x.useState)([]),[c,i]=(0,x.useState)(null),[o,l]=(0,x.useState)(null),[u,f]=(0,x.useState)(null),[v,m]=(0,x.useState)([]),[d,g]=(0,x.useState)(null),[p,S]=(0,x.useState)(null),[E,q]=(0,x.useState)([]),[w]=(0,x.useState)(xe),k=(0,x.useRef)(!1),y=(0,x.useRef)(0),j=(0,x.useRef)(0),M=(0,x.useRef)(null),A=t??"",F=(0,x.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=y.current,N=await Ze(e,A,be(A,w));b===y.current&&(l(N.totals),f(N.metricsError),m(N.functions),q(N.migrations),a(N.entries),i(N.logsError),g(N.auth),S(N.scheduler),k.current=!1)},[e,w,A]);(0,x.useEffect)(()=>(se(F()),()=>{y.current+=1,k.current=!1,M.current!==null&&(clearTimeout(M.current),M.current=null)}),[F]);let R=h(()=>{let b=Date.now()-j.current;if(b>=ke){j.current=Date.now(),se(F());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,j.current=Date.now(),se(F())},ke-b))},"j"),{data:D,liveError:O}=ge(B.getMetrics,{},{live:!0,shardKey:A});(0,x.useEffect)(()=>{D!==void 0&&R()},[D]);let _=r.filter(b=>b.level==="error"),G=_.slice(0,$e),T=Je(o?.history),P=et(d),Y=v.filter(b=>b.calls>0).toSorted((b,N)=>N.errors/N.calls-b.errors/b.calls||N.calls-b.calls).slice(0,Ke),C=Ve(E),z=o===null||o.requests===0?0:o.errors/o.requests,I=de(z,Se,Ee),L=d===null?"ok":de(d.failureRate,Be,Ue),K=p===null?"ok":Qe(p.backlog,Ge,He),H=Ye([I,L,K,C.level]);return(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,s.jsx)(rt,{errorLevel:I,liveError:O,metricsError:u,overall:H,requestSeries:T.requests,totals:o}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,s.jsx)(ne,{chart:T.errors.length>=2?(0,s.jsx)(le,{ariaLabel:n("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:n("Error rate"),level:I,testId:"hl-slo-errorrate",value:o===null?"\u2014":oe(o.errors,o.requests)}),(0,s.jsx)(ne,{chart:P.failures.length>=2?(0,s.jsx)(le,{ariaLabel:n("Auth failures over time"),className:"h-7 w-20 text-destructive",series:P.failures,testId:"hl-spark-auth"}):void 0,label:n("Auth failures"),level:L,testId:"hl-slo-auth",value:d===null?"\u2014":oe(d.failures,d.attempts)}),(0,s.jsx)(ne,{label:n("Scheduler backlog"),level:K,testId:"hl-slo-backlog",value:p===null?"\u2014":p.backlog.toString()}),(0,s.jsx)(ne,{label:n("Migrations"),level:C.level,testId:"hl-slo-migrations",value:We(C,n)})]}),(0,s.jsx)(Ce,{errorCount:_.length,logsError:c,topErrors:G,worstFunctions:Y}),(0,s.jsx)(st,{shards:w})]})},"gt");function lt(t){return(0,s.jsx)("li",{"data-testid":"hl-shard",children:(0,s.jsx)(ee,{variant:"secondary",children:t})},t)}h(lt,"Ze");export{kt as HealthPanel};
1
+ import{b as be}from"./chunk-RIAOZECW.js";import{a as le}from"./chunk-DB6QX4X6.js";import"./chunk-5WNGRT7N.js";import{a as ve}from"./chunk-ELSQ4FVH.js";import"./chunk-Y2YLTUMD.js";import"./chunk-BG2CJOVS.js";import{a as xe}from"./chunk-3D67ZJRW.js";import"./chunk-ZSWW2UGP.js";import"./chunk-QRA7AKYO.js";import"./chunk-4EPW63HS.js";import{b as ee}from"./chunk-UQA2AJGI.js";import"./chunk-T3ZCW3RG.js";import"./chunk-4PI2OSSP.js";import{a as B}from"./chunk-2W4UO5BC.js";import{c as ge}from"./chunk-4N76XUNG.js";import{a as X}from"./chunk-OK2QU2EV.js";import{l as he,m as fe}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B as U,h as W,i as ie,j as ce,s as se,w as pe,x as $}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as ue}from"./chunk-GWNGVKLG.js";import{a as Ae,b as me}from"./chunk-6G3E4PJ2.js";import{a as h,d as Z}from"./chunk-5PEAXTYQ.js";var te=Z(ue(),1),x=Z(Ae(),1);var Ne=Z(ue(),1);var ae=Z(me(),1);var je={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},ye=h(()=>{let t=(0,Ne.c)(18),e=U(),n=he(),r;e:switch(n){case"connected":{let l;t[0]!==e?(l=e("Connected"),t[0]=e,t[1]=l):l=t[1],r=l;break e}case"connecting":{let l;t[2]!==e?(l=e("Connecting\u2026"),t[2]=e,t[3]=l):l=t[3],r=l;break e}case"idle":{let l;t[4]!==e?(l=e("Idle"),t[4]=e,t[5]=l):l=t[5],r=l;break e}case"offline":{let l;t[6]!==e?(l=e("Offline"),t[6]=e,t[7]=l):l=t[7],r=l;break e}case"polling":{let l;t[8]!==e?(l=e("Polling"),t[8]=e,t[9]=l):l=t[9],r=l;break e}default:r=n}let a=je[n],c;t[10]!==a?(c=$("size-2 rounded-full",a),t[10]=a,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,ae.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==n||t[15]!==i||t[16]!==r?(o=(0,ae.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":n,"data-testid":"dash-connection",role:"status",children:[i,r]}),t[14]=n,t[15]=i,t[16]=r,t[17]=o):o=t[17],o},"T");var s=Z(me(),1);var Te={crit:"destructive",ok:"secondary",warn:"default"},oe=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"re"),de=h((t,e,n)=>Number.isNaN(t)?"ok":t>=n?"crit":t>=e?"warn":"ok","oe"),Se=.01,Ee=.05,Ce=h(t=>{let e=(0,te.c)(36),{errorCount:n,logsError:r,topErrors:a,worstFunctions:c}=t,i=U(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=(0,s.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=l):l=e[3];let u;e[4]!==i||e[5]!==c?(u=c.length===0?(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,s.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,s.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,s.jsx)(ee,{variant:Te[de(y.errors/y.calls,Se,Ee)],children:oe(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==u?(f=(0,s.jsxs)(X,{className:"gap-0 py-0","data-testid":"hl-functions",children:[l,u]}),e[7]=l,e[8]=u,e[9]=f):f=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let m;e[12]!==v?(m=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=m):m=e[13];let d=n>0?"destructive":"outline",g;e[14]!==n||e[15]!==d?(g=(0,s.jsx)(ee,{"data-testid":"hl-error-count",variant:d,children:n}),e[14]=n,e[15]=d,e[16]=g):g=e[16];let p;e[17]!==m||e[18]!==g?(p=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[m,g]}),e[17]=m,e[18]=g,e[19]=p):p=e[19];let S;e[20]!==r?(S=r!==null&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:r}),e[20]=r,e[21]=S):S=e[21];let E;e[22]!==r||e[23]!==i||e[24]!==a.length?(E=r===null&&a.length===0&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=r,e[23]=i,e[24]=a.length,e[25]=E):E=e[25];let q;e[26]!==a?(q=a.length>0&&(0,s.jsx)("ul",{className:"divide-y divide-border",children:a.map(Ie)}),e[26]=a,e[27]=q):q=e[27];let w;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==p?(w=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[p,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=p,e[32]=w):w=e[32];let k;return e[33]!==w||e[34]!==f?(k=(0,s.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[f,w]}),e[33]=w,e[34]=f,e[35]=k):k=e[35],k},"_e");function Ie(t,e){return(0,s.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("time",{className:"shrink-0 text-muted-foreground",children:pe(t.timestamp)}),t.functionPath!==void 0&&(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,s.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ie,"Ae");var we={completed:0,failed:2,in_progress:1},De=h(t=>{let e=0,n=0,r=0,a=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){a+=1;continue}r+=1,e+=o.requests,n+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:n,failed:a,history:i,historyTruncated:c,reachable:r,requests:e}},"ke"),_e=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.path);if(a===void 0){e.set(r.path,{...r});continue}a.calls+=r.calls,a.errors+=r.errors,a.totalDurationMs+=r.totalDurationMs,a.scans=(a.scans??0)+(r.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,r.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,r.lastCalledAt),(r.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=r.lastErrorAt,a.lastErrorMessage=r.lastErrorMessage)}return[...e.values()]},"Re"),Pe=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.id);if(a===void 0){e.set(r.id,r);continue}let c=we[r.status]-we[a.status];(c>0||c===0&&(r.updatedAt??0)>(a.updatedAt??0))&&e.set(r.id,r)}return[...e.values()]},"Me"),Le=W(B.getAuthMetrics),Fe=W(B.getFunctionStats),Re=W(B.getLogs),Oe=W(B.getMetrics),ze=W(B.migrationStatus),$e=5,ke=2e3,Ke=5,Be=.1,Ue=.3,Ge=1,He=50,Qe=h((t,e,n)=>t>=n?"crit":t>=e?"warn":"ok","$e"),Je=h(t=>{let e=new Map;for(let r of t??[]){let a=e.get(r.bucketMs)??{calls:0,errors:0};a.calls+=r.calls,a.errors+=r.errors,e.set(r.bucketMs,a)}let n=[...e.entries()].toSorted((r,a)=>r[0]-a[0]);return{errors:n.map(([,r])=>r.errors),requests:n.map(([,r])=>r.calls)}},"Be"),Ve=h(t=>{let e=0,n=0;for(let a of t)a.status==="failed"?e+=1:a.status==="in_progress"&&(n+=1);let r="ok";return e>0?r="crit":n>0&&(r="warn"),{failed:e,level:r,running:n}},"Ve"),We=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),qe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Me={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Xe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Ye=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","ze"),ne=h(t=>{let e=(0,te.c)(19),{chart:n,label:r,level:a,testId:c,value:i}=t,o=qe[a],l;e[0]!==o?(l=$("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==l?(u=(0,s.jsx)("span",{"aria-hidden":"true",className:l}),e[2]=l,e[3]=u):u=e[3];let f;e[4]!==r||e[5]!==u?(f=(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[u,r]}),e[4]=r,e[5]=u,e[6]=f):f=e[6];let v=Me[a],m;e[7]!==v?(m=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=m):m=e[8];let d;e[9]!==m||e[10]!==c||e[11]!==i?(d=(0,s.jsx)("span",{className:m,"data-testid":c,children:i}),e[9]=m,e[10]=c,e[11]=i,e[12]=d):d=e[12];let g;e[13]!==n||e[14]!==d?(g=(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[d,n]}),e[13]=n,e[14]=d,e[15]=g):g=e[15];let p;return e[16]!==f||e[17]!==g?(p=(0,s.jsx)(X,{className:"gap-0 py-0",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[f,g]})}),e[16]=f,e[17]=g,e[18]=p):p=e[18],p},"ee"),Ze=h(async(t,e,n)=>{let r=await Promise.all(n.map(m=>{let d=ie(m);return Promise.allSettled([t.query(Oe,{},d),t.query(Fe,{},d),t.query(ze,{},d)])})),a=ie(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,l]=await Promise.allSettled([t.query(Re,{},a),t.query(Le,{},a),c]),u=r.map(([m,d,g])=>({functions:d.status==="fulfilled"?d.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),f=De(u),v=r[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:_e(u.map(m=>m.functions)),logsError:i.status==="rejected"?ce(i.reason):null,metricsError:f.reachable===0&&v?.status==="rejected"?ce(v.reason):null,migrations:Pe(u.map(m=>m.migrations)),scheduler:l.status==="fulfilled"?l.value:null,totals:f}},"Qe"),et=h(t=>{let e=t?.history??[];return{attempts:e.map(n=>n.attempts),failures:e.map(n=>n.failures)}},"We"),tt=h((t,e)=>t==="crit"?{description:e("One or more service levels are breached."),label:e("Critical")}:t==="warn"?{description:e("Some service levels need attention."),label:e("Degraded")}:{description:e("All service levels are within target."),label:e("All systems healthy")},"Xe"),rt=h(t=>{let e=(0,te.c)(75),{errorLevel:n,liveError:r,metricsError:a,overall:c,requestSeries:i,totals:o}=t,l=U(),u;e[0]!==c||e[1]!==l?(u=tt(c,l),e[0]=c,e[1]=l,e[2]=u):u=e[2];let{description:f,label:v}=u,m=Xe[c],d;e[3]!==m?(d=$("flex size-10 shrink-0 items-center justify-center rounded-full",m),e[3]=m,e[4]=d):d=e[4];let g=qe[c],p;e[5]!==g?(p=$("size-3 rounded-full",g),e[5]=g,e[6]=p):p=e[6];let S;e[7]!==p?(S=(0,s.jsx)("span",{className:p}),e[7]=p,e[8]=S):S=e[8];let E;e[9]!==d||e[10]!==S?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:d,children:S}),e[9]=d,e[10]=S,e[11]=E):E=e[11];let q;e[12]!==v?(q=(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:v}),e[12]=v,e[13]=q):q=e[13];let w;e[14]!==f?(w=(0,s.jsx)("span",{className:"text-[13px] text-muted-foreground",children:f}),e[14]=f,e[15]=w):w=e[15];let k;e[16]!==q||e[17]!==w?(k=(0,s.jsxs)("div",{className:"grid leading-tight",children:[q,w]}),e[16]=q,e[17]=w,e[18]=k):k=e[18];let y;e[19]!==k||e[20]!==E?(y=(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[E,k]}),e[19]=k,e[20]=E,e[21]=y):y=e[21];let j;e[22]!==l?(j=l("Requests"),e[22]=l,e[23]=j):j=e[23];let M;e[24]!==j?(M=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:j}),e[24]=j,e[25]=M):M=e[25];let A;e[26]!==i||e[27]!==l?(A=i.length>=2&&(0,s.jsx)(le,{ariaLabel:l("Requests over time"),className:"h-6 w-20 text-foreground",series:i,testId:"hl-spark-requests"}),e[26]=i,e[27]=l,e[28]=A):A=e[28];let F=o?.requests??0,R;e[29]!==F?(R=F.toString(),e[29]=F,e[30]=R):R=e[30];let D;e[31]!==R?(D=(0,s.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:R}),e[31]=R,e[32]=D):D=e[32];let O;e[33]!==A||e[34]!==D?(O=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[A,D]}),e[33]=A,e[34]=D,e[35]=O):O=e[35];let _;e[36]!==M||e[37]!==O?(_=(0,s.jsxs)("div",{className:"text-end",children:[M,O]}),e[36]=M,e[37]=O,e[38]=_):_=e[38];let G;e[39]===Symbol.for("react.memo_cache_sentinel")?(G=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[39]=G):G=e[39];let T;e[40]!==l?(T=l("Error rate"),e[40]=l,e[41]=T):T=e[41];let P;e[42]!==T?(P=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[42]=T,e[43]=P):P=e[43];let Y=Me[n],C;e[44]!==Y?(C=$("text-lg font-semibold tabular-nums",Y),e[44]=Y,e[45]=C):C=e[45];let z;e[46]!==o?(z=o===null?"\u2014":oe(o.errors,o.requests),e[46]=o,e[47]=z):z=e[47];let I;e[48]!==C||e[49]!==z?(I=(0,s.jsx)("div",{className:C,"data-testid":"hl-error-rate",children:z}),e[48]=C,e[49]=z,e[50]=I):I=e[50];let L;e[51]!==P||e[52]!==I?(L=(0,s.jsxs)("div",{className:"text-end",children:[P,I]}),e[51]=P,e[52]=I,e[53]=L):L=e[53];let K;e[54]===Symbol.for("react.memo_cache_sentinel")?(K=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[54]=K):K=e[54];let H;e[55]===Symbol.for("react.memo_cache_sentinel")?(H=(0,s.jsx)(ye,{}),e[55]=H):H=e[55];let b;e[56]!==r?(b=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[H,(0,s.jsx)(ve,{message:r,prefix:"hl"})]}),e[56]=r,e[57]=b):b=e[57];let N;e[58]!==_||e[59]!==L||e[60]!==b?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[_,G,L,K,b]}),e[58]=_,e[59]=L,e[60]=b,e[61]=N):N=e[61];let Q;e[62]!==y||e[63]!==N?(Q=(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[y,N]}),e[62]=y,e[63]=N,e[64]=Q):Q=e[64];let J;e[65]!==a?(J=a!==null&&(0,s.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:a}),e[65]=a,e[66]=J):J=e[66];let V;e[67]!==a||e[68]!==l||e[69]!==o?.historyTruncated?(V=a===null&&o?.historyTruncated===!0&&(0,s.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:l("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")}),e[67]=a,e[68]=l,e[69]=o?.historyTruncated,e[70]=V):V=e[70];let re;return e[71]!==Q||e[72]!==J||e[73]!==V?(re=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[Q,J,V]}),e[71]=Q,e[72]=J,e[73]=V,e[74]=re):re=e[74],re},"Je"),st=h(t=>{let e=(0,te.c)(14),{shards:n}=t,r=U(),a;e[0]!==r?(a=r("Shards seen"),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==a?(c=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[2]=a,e[3]=c):c=e[3];let i;e[4]!==n.length?(i=(0,s.jsx)(ee,{"data-testid":"hl-shard-count",variant:"outline",children:n.length}),e[4]=n.length,e[5]=i):i=e[5];let o;e[6]!==c||e[7]!==i?(o=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[c,i]}),e[6]=c,e[7]=i,e[8]=o):o=e[8];let l;e[9]!==n?(l=n.length>0&&(0,s.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:n.map(lt)}),e[9]=n,e[10]=l):l=e[10];let u;return e[11]!==o||e[12]!==l?(u=(0,s.jsxs)(X,{className:"gap-0 py-0",children:[o,l]}),e[11]=o,e[12]=l,e[13]=u):u=e[13],u},"Ye"),kt=h(({initialShardKey:t})=>{let e=fe(),n=U(),[r,a]=(0,x.useState)([]),[c,i]=(0,x.useState)(null),[o,l]=(0,x.useState)(null),[u,f]=(0,x.useState)(null),[v,m]=(0,x.useState)([]),[d,g]=(0,x.useState)(null),[p,S]=(0,x.useState)(null),[E,q]=(0,x.useState)([]),[w]=(0,x.useState)(xe),k=(0,x.useRef)(!1),y=(0,x.useRef)(0),j=(0,x.useRef)(0),M=(0,x.useRef)(null),A=t??"",F=(0,x.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=y.current,N=await Ze(e,A,be(A,w));b===y.current&&(l(N.totals),f(N.metricsError),m(N.functions),q(N.migrations),a(N.entries),i(N.logsError),g(N.auth),S(N.scheduler),k.current=!1)},[e,w,A]);(0,x.useEffect)(()=>(se(F()),()=>{y.current+=1,k.current=!1,M.current!==null&&(clearTimeout(M.current),M.current=null)}),[F]);let R=h(()=>{let b=Date.now()-j.current;if(b>=ke){j.current=Date.now(),se(F());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,j.current=Date.now(),se(F())},ke-b))},"j"),{data:D,liveError:O}=ge(B.getMetrics,{},{live:!0,shardKey:A});(0,x.useEffect)(()=>{D!==void 0&&R()},[D]);let _=r.filter(b=>b.level==="error"),G=_.slice(0,$e),T=Je(o?.history),P=et(d),Y=v.filter(b=>b.calls>0).toSorted((b,N)=>N.errors/N.calls-b.errors/b.calls||N.calls-b.calls).slice(0,Ke),C=Ve(E),z=o===null||o.requests===0?0:o.errors/o.requests,I=de(z,Se,Ee),L=d===null?"ok":de(d.failureRate,Be,Ue),K=p===null?"ok":Qe(p.backlog,Ge,He),H=Ye([I,L,K,C.level]);return(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,s.jsx)(rt,{errorLevel:I,liveError:O,metricsError:u,overall:H,requestSeries:T.requests,totals:o}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,s.jsx)(ne,{chart:T.errors.length>=2?(0,s.jsx)(le,{ariaLabel:n("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:n("Error rate"),level:I,testId:"hl-slo-errorrate",value:o===null?"\u2014":oe(o.errors,o.requests)}),(0,s.jsx)(ne,{chart:P.failures.length>=2?(0,s.jsx)(le,{ariaLabel:n("Auth failures over time"),className:"h-7 w-20 text-destructive",series:P.failures,testId:"hl-spark-auth"}):void 0,label:n("Auth failures"),level:L,testId:"hl-slo-auth",value:d===null?"\u2014":oe(d.failures,d.attempts)}),(0,s.jsx)(ne,{label:n("Scheduler backlog"),level:K,testId:"hl-slo-backlog",value:p===null?"\u2014":p.backlog.toString()}),(0,s.jsx)(ne,{label:n("Migrations"),level:C.level,testId:"hl-slo-migrations",value:We(C,n)})]}),(0,s.jsx)(Ce,{errorCount:_.length,logsError:c,topErrors:G,worstFunctions:Y}),(0,s.jsx)(st,{shards:w})]})},"gt");function lt(t){return(0,s.jsx)("li",{"data-testid":"hl-shard",children:(0,s.jsx)(ee,{variant:"secondary",children:t})},t)}h(lt,"Ze");export{kt as HealthPanel};
@@ -1 +1 @@
1
- import{i as G}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as H}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as J}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as Q,b as W,c as Z,d as V,e as C,f as S}from"./chunk-7QEZ2SFW.js";import{a as F,e as K}from"./chunk-OK2QU2EV.js";import{m as D}from"./chunk-FACXM2UB.js";import"./chunk-ZPQBVYNN.js";import{B,j as $,r as A,s as z}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as X}from"./chunk-GWNGVKLG.js";import{a as U,b as Y}from"./chunk-6G3E4PJ2.js";import{a as I,d as M}from"./chunk-5PEAXTYQ.js";var L=M(X(),1),g=M(U(),1);var t=M(Y(),1);var _=10,E=I(h=>{let e=(0,L.c)(7),{label:i,value:l}=h,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let a=l??"\u2014",n;e[2]!==a?(n=(0,t.jsx)("span",{className:"font-mono text-sm",children:a}),e[2]=a,e[3]=n):n=e[3];let s;return e[4]!==r||e[5]!==n?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,n]}),e[4]=r,e[5]=n,e[6]=s):s=e[6],s},"_"),ee=I(h=>{let e=(0,L.c)(38),{indexes:i,onSelect:l,selected:r}=h,a=B(),n;e[0]!==a?(n=a("name"),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==n?(s=(0,t.jsx)(C,{children:n}),e[2]=n,e[3]=s):s=e[3];let c;e[4]!==a?(c=a("table"),e[4]=a,e[5]=c):c=e[5];let o;e[6]!==c?(o=(0,t.jsx)(C,{children:c}),e[6]=c,e[7]=o):o=e[7];let d;e[8]!==a?(d=a("dimensions"),e[8]=a,e[9]=d):d=e[9];let x;e[10]!==d?(x=(0,t.jsx)(C,{children:d}),e[10]=d,e[11]=x):x=e[11];let m;e[12]!==a?(m=a("metric"),e[12]=a,e[13]=m):m=e[13];let p;e[14]!==m?(p=(0,t.jsx)(C,{children:m}),e[14]=m,e[15]=p):p=e[15];let u;e[16]!==a?(u=a("vectors"),e[16]=a,e[17]=u):u=e[17];let v;e[18]!==u?(v=(0,t.jsx)(C,{children:u}),e[18]=u,e[19]=v):v=e[19];let y;e[20]!==v||e[21]!==s||e[22]!==o||e[23]!==x||e[24]!==p?(y=(0,t.jsx)(W,{children:(0,t.jsxs)(V,{children:[s,o,x,p,v]})}),e[20]=v,e[21]=s,e[22]=o,e[23]=x,e[24]=p,e[25]=y):y=e[25];let k;if(e[26]!==i||e[27]!==l||e[28]!==r){let q;e[30]!==l||e[31]!==r?(q=I(w=>(0,t.jsxs)(V,{className:w.name===r?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":w.name,"data-testid":`vector-row-${w.name}`,onClick:l,children:[(0,t.jsx)(S,{className:"font-mono text-xs",children:w.name}),(0,t.jsx)(S,{className:"font-mono text-xs",children:w.table}),(0,t.jsx)(S,{className:"tabular-nums",children:w.dimensions??"\u2014"}),(0,t.jsx)(S,{children:w.metric??"\u2014"}),(0,t.jsx)(S,{className:"tabular-nums",children:w.vectorsCount??"\u2014"})]},w.name),"q"),e[30]=l,e[31]=r,e[32]=q):q=e[32],k=i.map(q),e[26]=i,e[27]=l,e[28]=r,e[29]=k}else k=e[29];let N;e[33]!==k?(N=(0,t.jsx)(Z,{children:k}),e[33]=k,e[34]=N):N=e[34];let f;return e[35]!==y||e[36]!==N?(f=(0,t.jsx)(F,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(Q,{"data-testid":"vector-table",children:[y,N]})})}),e[35]=y,e[36]=N,e[37]=f):f=e[37],f},"X"),te=I(h=>{let e=(0,L.c)(27),{matches:i}=h,l=B();if(i.length===0){let u;e[0]!==l?(u=l("No matches."),e[0]=l,e[1]=u):u=e[1];let v;return e[2]!==u?(v=(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:u}),e[2]=u,e[3]=v):v=e[3],v}let r;e[4]!==l?(r=l("id"),e[4]=l,e[5]=r):r=e[5];let a;e[6]!==r?(a=(0,t.jsx)(C,{children:r}),e[6]=r,e[7]=a):a=e[7];let n;e[8]!==l?(n=l("score"),e[8]=l,e[9]=n):n=e[9];let s;e[10]!==n?(s=(0,t.jsx)(C,{children:n}),e[10]=n,e[11]=s):s=e[11];let c;e[12]!==l?(c=l("metadata"),e[12]=l,e[13]=c):c=e[13];let o;e[14]!==c?(o=(0,t.jsx)(C,{children:c}),e[14]=c,e[15]=o):o=e[15];let d;e[16]!==a||e[17]!==s||e[18]!==o?(d=(0,t.jsx)(W,{children:(0,t.jsxs)(V,{children:[a,s,o]})}),e[16]=a,e[17]=s,e[18]=o,e[19]=d):d=e[19];let x;e[20]!==i?(x=i.map(le),e[20]=i,e[21]=x):x=e[21];let m;e[22]!==x?(m=(0,t.jsx)(Z,{children:x}),e[22]=x,e[23]=m):m=e[23];let p;return e[24]!==d||e[25]!==m?(p=(0,t.jsx)(F,{className:"mt-3 overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(Q,{"data-testid":"vector-matches",children:[d,m]})})}),e[24]=d,e[25]=m,e[26]=p):p=e[26],p},"Y"),me=I(({loadIndexes:h,runQuery:e}={})=>{let i=D(),l=B(),[r,a]=(0,g.useState)(null),[n,s]=(0,g.useState)(null),[c,o]=(0,g.useState)(null),[d,x]=(0,g.useState)(""),[m,p]=(0,g.useState)(null),[u,v]=(0,g.useState)(null),[y,k]=(0,g.useState)(!1),N=(0,g.useRef)(0);(0,g.useEffect)(()=>{let b={cancelled:!1};return z((async()=>{try{let j=await(h??(()=>i.listVectorIndexes()))();b.cancelled||(a(j),s(null),o(T=>T??j[0]?.name??null))}catch(j){b.cancelled||(a(null),s($(j)))}})()),()=>{b.cancelled=!0}},[i,h]);let f=r?.find(b=>b.name===c)??null,q=I(b=>{N.current+=1,o(b.currentTarget.dataset.index??null),p(null),v(null),k(!1)},"q"),w=I(b=>{x(b.target.value)},"y"),O=I(async()=>{let b=d.trim();if(c===null||b==="")return;N.current+=1;let j=N.current;k(!0),v(null);try{let T=await(e??(R=>i.queryVectorIndex(R)))({name:c,text:b,topK:_});if(j!==N.current)return;p(T)}catch(T){if(j!==N.current)return;p(null),v($(T))}k(!1)},"H"),P=I(()=>{z(O())},"K");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:n}),r!==null&&r.length===0&&(0,t.jsx)(J,{description:l("Indexes declared with .vectorize() or defineVectorIndex() appear here."),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 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:l("No vector indexes.")}),r!==null&&r.length>0&&(0,t.jsx)(ee,{indexes:r,onSelect:q,selected:c}),f!==null&&(0,t.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,t.jsx)(E,{label:l("field"),value:f.field}),(0,t.jsx)(E,{label:l("dimensions"),value:f.dimensions}),(0,t.jsx)(E,{label:l("metric"),value:f.metric}),(0,t.jsx)(E,{label:l("vectors"),value:f.vectorsCount})]}),f.metadata!==void 0&&f.metadata.length>0&&(0,t.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[l("metadata"),": ",(0,t.jsx)("span",{className:"font-mono",children:f.metadata.join(", ")})]}),(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,t.jsx)(G,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:w,placeholder:l("Search by similarity\u2026"),value:d}),(0,t.jsx)(H,{"data-testid":"vector-search",disabled:y||d.trim()==="",onClick:P,children:l(y?"Searching\u2026":"Search")})]}),u!==null&&(0,t.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:u}),m!==null&&(0,t.jsx)(te,{matches:m})]})]})},"ue");function le(h){return(0,t.jsxs)(V,{"data-testid":`vector-match-${h.id}`,children:[(0,t.jsx)(S,{className:"font-mono text-xs",children:h.id}),(0,t.jsx)(S,{className:"tabular-nums",children:h.score.toFixed(4)}),(0,t.jsx)(S,{className:"max-w-md truncate font-mono text-xs",children:h.metadata===void 0?"\u2014":A(h.metadata)})]},h.id)}I(le,"ee");export{me as VectorBrowser};
1
+ import{i as G}from"./chunk-IHGRWY3Y.js";import"./chunk-OWRKSQPE.js";import"./chunk-4EPW63HS.js";import{a as H}from"./chunk-V3BE427M.js";import"./chunk-CKEQX655.js";import"./chunk-UD5REVU2.js";import{a as J}from"./chunk-RCXNYW7P.js";import"./chunk-T3ZCW3RG.js";import{a as Q,b as W,c as Z,d as V,e as C,f as S}from"./chunk-7QEZ2SFW.js";import{a as F,e as K}from"./chunk-OK2QU2EV.js";import{m as D}from"./chunk-SHHGIT7M.js";import"./chunk-ZPQBVYNN.js";import{B,j as $,r as A,s as z}from"./chunk-GNI37YCV.js";import"./chunk-PDBW6GTJ.js";import{a as X}from"./chunk-GWNGVKLG.js";import{a as U,b as Y}from"./chunk-6G3E4PJ2.js";import{a as I,d as M}from"./chunk-5PEAXTYQ.js";var L=M(X(),1),g=M(U(),1);var t=M(Y(),1);var _=10,E=I(h=>{let e=(0,L.c)(7),{label:i,value:l}=h,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let a=l??"\u2014",n;e[2]!==a?(n=(0,t.jsx)("span",{className:"font-mono text-sm",children:a}),e[2]=a,e[3]=n):n=e[3];let s;return e[4]!==r||e[5]!==n?(s=(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[r,n]}),e[4]=r,e[5]=n,e[6]=s):s=e[6],s},"_"),ee=I(h=>{let e=(0,L.c)(38),{indexes:i,onSelect:l,selected:r}=h,a=B(),n;e[0]!==a?(n=a("name"),e[0]=a,e[1]=n):n=e[1];let s;e[2]!==n?(s=(0,t.jsx)(C,{children:n}),e[2]=n,e[3]=s):s=e[3];let c;e[4]!==a?(c=a("table"),e[4]=a,e[5]=c):c=e[5];let o;e[6]!==c?(o=(0,t.jsx)(C,{children:c}),e[6]=c,e[7]=o):o=e[7];let d;e[8]!==a?(d=a("dimensions"),e[8]=a,e[9]=d):d=e[9];let x;e[10]!==d?(x=(0,t.jsx)(C,{children:d}),e[10]=d,e[11]=x):x=e[11];let m;e[12]!==a?(m=a("metric"),e[12]=a,e[13]=m):m=e[13];let p;e[14]!==m?(p=(0,t.jsx)(C,{children:m}),e[14]=m,e[15]=p):p=e[15];let u;e[16]!==a?(u=a("vectors"),e[16]=a,e[17]=u):u=e[17];let v;e[18]!==u?(v=(0,t.jsx)(C,{children:u}),e[18]=u,e[19]=v):v=e[19];let y;e[20]!==v||e[21]!==s||e[22]!==o||e[23]!==x||e[24]!==p?(y=(0,t.jsx)(W,{children:(0,t.jsxs)(V,{children:[s,o,x,p,v]})}),e[20]=v,e[21]=s,e[22]=o,e[23]=x,e[24]=p,e[25]=y):y=e[25];let k;if(e[26]!==i||e[27]!==l||e[28]!==r){let q;e[30]!==l||e[31]!==r?(q=I(w=>(0,t.jsxs)(V,{className:w.name===r?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":w.name,"data-testid":`vector-row-${w.name}`,onClick:l,children:[(0,t.jsx)(S,{className:"font-mono text-xs",children:w.name}),(0,t.jsx)(S,{className:"font-mono text-xs",children:w.table}),(0,t.jsx)(S,{className:"tabular-nums",children:w.dimensions??"\u2014"}),(0,t.jsx)(S,{children:w.metric??"\u2014"}),(0,t.jsx)(S,{className:"tabular-nums",children:w.vectorsCount??"\u2014"})]},w.name),"q"),e[30]=l,e[31]=r,e[32]=q):q=e[32],k=i.map(q),e[26]=i,e[27]=l,e[28]=r,e[29]=k}else k=e[29];let N;e[33]!==k?(N=(0,t.jsx)(Z,{children:k}),e[33]=k,e[34]=N):N=e[34];let f;return e[35]!==y||e[36]!==N?(f=(0,t.jsx)(F,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(Q,{"data-testid":"vector-table",children:[y,N]})})}),e[35]=y,e[36]=N,e[37]=f):f=e[37],f},"X"),te=I(h=>{let e=(0,L.c)(27),{matches:i}=h,l=B();if(i.length===0){let u;e[0]!==l?(u=l("No matches."),e[0]=l,e[1]=u):u=e[1];let v;return e[2]!==u?(v=(0,t.jsx)("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:u}),e[2]=u,e[3]=v):v=e[3],v}let r;e[4]!==l?(r=l("id"),e[4]=l,e[5]=r):r=e[5];let a;e[6]!==r?(a=(0,t.jsx)(C,{children:r}),e[6]=r,e[7]=a):a=e[7];let n;e[8]!==l?(n=l("score"),e[8]=l,e[9]=n):n=e[9];let s;e[10]!==n?(s=(0,t.jsx)(C,{children:n}),e[10]=n,e[11]=s):s=e[11];let c;e[12]!==l?(c=l("metadata"),e[12]=l,e[13]=c):c=e[13];let o;e[14]!==c?(o=(0,t.jsx)(C,{children:c}),e[14]=c,e[15]=o):o=e[15];let d;e[16]!==a||e[17]!==s||e[18]!==o?(d=(0,t.jsx)(W,{children:(0,t.jsxs)(V,{children:[a,s,o]})}),e[16]=a,e[17]=s,e[18]=o,e[19]=d):d=e[19];let x;e[20]!==i?(x=i.map(le),e[20]=i,e[21]=x):x=e[21];let m;e[22]!==x?(m=(0,t.jsx)(Z,{children:x}),e[22]=x,e[23]=m):m=e[23];let p;return e[24]!==d||e[25]!==m?(p=(0,t.jsx)(F,{className:"mt-3 overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(Q,{"data-testid":"vector-matches",children:[d,m]})})}),e[24]=d,e[25]=m,e[26]=p):p=e[26],p},"Y"),me=I(({loadIndexes:h,runQuery:e}={})=>{let i=D(),l=B(),[r,a]=(0,g.useState)(null),[n,s]=(0,g.useState)(null),[c,o]=(0,g.useState)(null),[d,x]=(0,g.useState)(""),[m,p]=(0,g.useState)(null),[u,v]=(0,g.useState)(null),[y,k]=(0,g.useState)(!1),N=(0,g.useRef)(0);(0,g.useEffect)(()=>{let b={cancelled:!1};return z((async()=>{try{let j=await(h??(()=>i.listVectorIndexes()))();b.cancelled||(a(j),s(null),o(T=>T??j[0]?.name??null))}catch(j){b.cancelled||(a(null),s($(j)))}})()),()=>{b.cancelled=!0}},[i,h]);let f=r?.find(b=>b.name===c)??null,q=I(b=>{N.current+=1,o(b.currentTarget.dataset.index??null),p(null),v(null),k(!1)},"q"),w=I(b=>{x(b.target.value)},"y"),O=I(async()=>{let b=d.trim();if(c===null||b==="")return;N.current+=1;let j=N.current;k(!0),v(null);try{let T=await(e??(R=>i.queryVectorIndex(R)))({name:c,text:b,topK:_});if(j!==N.current)return;p(T)}catch(T){if(j!==N.current)return;p(null),v($(T))}k(!1)},"H"),P=I(()=>{z(O())},"K");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:n}),r!==null&&r.length===0&&(0,t.jsx)(J,{description:l("Indexes declared with .vectorize() or defineVectorIndex() appear here."),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 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:l("No vector indexes.")}),r!==null&&r.length>0&&(0,t.jsx)(ee,{indexes:r,onSelect:q,selected:c}),f!==null&&(0,t.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[(0,t.jsx)(E,{label:l("field"),value:f.field}),(0,t.jsx)(E,{label:l("dimensions"),value:f.dimensions}),(0,t.jsx)(E,{label:l("metric"),value:f.metric}),(0,t.jsx)(E,{label:l("vectors"),value:f.vectorsCount})]}),f.metadata!==void 0&&f.metadata.length>0&&(0,t.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[l("metadata"),": ",(0,t.jsx)("span",{className:"font-mono",children:f.metadata.join(", ")})]}),(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,t.jsx)(G,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:w,placeholder:l("Search by similarity\u2026"),value:d}),(0,t.jsx)(H,{"data-testid":"vector-search",disabled:y||d.trim()==="",onClick:P,children:l(y?"Searching\u2026":"Search")})]}),u!==null&&(0,t.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:u}),m!==null&&(0,t.jsx)(te,{matches:m})]})]})},"ue");function le(h){return(0,t.jsxs)(V,{"data-testid":`vector-match-${h.id}`,children:[(0,t.jsx)(S,{className:"font-mono text-xs",children:h.id}),(0,t.jsx)(S,{className:"tabular-nums",children:h.score.toFixed(4)}),(0,t.jsx)(S,{className:"max-w-md truncate font-mono text-xs",children:h.metadata===void 0?"\u2014":A(h.metadata)})]},h.id)}I(le,"ee");export{me as VectorBrowser};