@lunora/studio 1.0.0-alpha.150 → 1.0.0-alpha.151

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 (84) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/ApiTab.mjs +1 -1
  6. package/dist/packem_chunks/FileBrowser.mjs +4 -4
  7. package/dist/packem_chunks/TableEditor.mjs +1 -1
  8. package/dist/packem_chunks/kv-browser.mjs +1 -1
  9. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  10. package/dist/packem_shared/{ApiReferencePanel-B4i-KeOf.mjs → ApiReferencePanel-CigvHhCa.mjs} +1 -1
  11. package/dist/packem_shared/{DataBrowser-B0XdZT2Z.mjs → DataBrowser-O22nJCCN.mjs} +3 -3
  12. package/dist/packem_shared/{OpenRpcReferencePanel-BKJEX7we.mjs → OpenRpcReferencePanel-C6CM791D.mjs} +1 -1
  13. package/dist/packem_shared/{StudioApp-B5jLGbeH.mjs → StudioApp-fYFz6zZQ.mjs} +1 -1
  14. package/dist/packem_shared/reference-view-DiikOols.mjs +13 -0
  15. package/dist/standalone/{chunk-CBQTFTJC.js → chunk-23PYJYIE.js} +1 -1
  16. package/dist/standalone/{chunk-7DOPYCLK.js → chunk-2AQPSJ2A.js} +1 -1
  17. package/dist/standalone/{chunk-3ES7RN3O.js → chunk-2UYOGRM4.js} +1 -1
  18. package/dist/standalone/{chunk-RCDHVEJZ.js → chunk-32CGYBP7.js} +1 -1
  19. package/dist/standalone/{chunk-A4UOWQOI.js → chunk-3AP7VVQQ.js} +1 -1
  20. package/dist/standalone/{chunk-TCZ7ZOBB.js → chunk-4B2XXMFJ.js} +1 -1
  21. package/dist/standalone/{chunk-652ULANV.js → chunk-4ECJUS5H.js} +1 -1
  22. package/dist/standalone/{chunk-GZ525PHR.js → chunk-5BHA637G.js} +1 -1
  23. package/dist/standalone/{chunk-36KY3PTX.js → chunk-5OKOOE7F.js} +5 -5
  24. package/dist/standalone/{chunk-DDNGDORN.js → chunk-6KU6XZBN.js} +1 -1
  25. package/dist/standalone/chunk-74MH4UBQ.js +4 -0
  26. package/dist/standalone/{chunk-FIGP4KJN.js → chunk-A7FVAGCX.js} +1 -1
  27. package/dist/standalone/chunk-ACZ62CXX.js +1 -0
  28. package/dist/standalone/{chunk-G53FJKCM.js → chunk-ALDKIXZV.js} +1 -1
  29. package/dist/standalone/{chunk-PNDBXKC4.js → chunk-C37WBSYD.js} +1 -1
  30. package/dist/standalone/{chunk-LBRCRFC7.js → chunk-CIEJPCUW.js} +1 -1
  31. package/dist/standalone/{chunk-JRFMYRSK.js → chunk-CQMOOU7U.js} +1 -1
  32. package/dist/standalone/{chunk-JOQ7QICC.js → chunk-CY3TZEJJ.js} +1 -1
  33. package/dist/standalone/{chunk-Z7WIE3QU.js → chunk-EL76NZKP.js} +1 -1
  34. package/dist/standalone/{chunk-O3D7LAG3.js → chunk-EZ5WA3RT.js} +1 -1
  35. package/dist/standalone/chunk-FGSNEPHU.js +11 -0
  36. package/dist/standalone/{chunk-UAZ3QMWC.js → chunk-G4F3D3I7.js} +1 -1
  37. package/dist/standalone/{chunk-J5A6T372.js → chunk-G4Y2UUW4.js} +1 -1
  38. package/dist/standalone/{chunk-4A6H7VLZ.js → chunk-G6U7Z75E.js} +1 -1
  39. package/dist/standalone/{chunk-JAKYTDUH.js → chunk-GEITRXJJ.js} +1 -1
  40. package/dist/standalone/{chunk-TQEHSBYQ.js → chunk-GWV47763.js} +1 -1
  41. package/dist/standalone/{chunk-WPWHJRJ2.js → chunk-HB4BX7WR.js} +1 -1
  42. package/dist/standalone/{chunk-SCOUV4FW.js → chunk-HKOSEDH4.js} +1 -1
  43. package/dist/standalone/chunk-IAP6HECV.js +1 -0
  44. package/dist/standalone/{chunk-M3C4GMLC.js → chunk-IECKH2X5.js} +1 -1
  45. package/dist/standalone/{chunk-Y5JLYANQ.js → chunk-IHFI6CAR.js} +1 -1
  46. package/dist/standalone/{chunk-REDAHOJT.js → chunk-II7XZKMV.js} +1 -1
  47. package/dist/standalone/{chunk-QWHMIFOZ.js → chunk-ILD64B5N.js} +1 -1
  48. package/dist/standalone/{chunk-VYIK5F67.js → chunk-LX3GATRO.js} +1 -1
  49. package/dist/standalone/{chunk-MPMVG5EM.js → chunk-MDV7YLA4.js} +1 -1
  50. package/dist/standalone/{chunk-6NY2NC3H.js → chunk-NITR6C4Q.js} +1 -1
  51. package/dist/standalone/{chunk-PL664H45.js → chunk-NLCYWLK6.js} +1 -1
  52. package/dist/standalone/{chunk-TNQQCHK2.js → chunk-OEGOE365.js} +1 -1
  53. package/dist/standalone/{chunk-SUP63Z2J.js → chunk-P6P4OBT2.js} +1 -1
  54. package/dist/standalone/chunk-PHQZEAGF.js +1 -0
  55. package/dist/standalone/{chunk-HSQFTY37.js → chunk-PNHK6UE2.js} +2 -2
  56. package/dist/standalone/{chunk-T6S2F46N.js → chunk-Q7UGJSBF.js} +1 -1
  57. package/dist/standalone/{chunk-LJYUUOBB.js → chunk-R2IHJBT6.js} +1 -1
  58. package/dist/standalone/{chunk-PLQNPVGT.js → chunk-S26CQFMN.js} +1 -1
  59. package/dist/standalone/{chunk-WPBNZXI3.js → chunk-S35A5JDQ.js} +1 -1
  60. package/dist/standalone/{chunk-NL3S6OMD.js → chunk-S6WJJWE2.js} +1 -1
  61. package/dist/standalone/{chunk-OYMQJN7D.js → chunk-S7Z5HIXB.js} +1 -1
  62. package/dist/standalone/{chunk-SWDTL2C5.js → chunk-SWQC2USV.js} +1 -1
  63. package/dist/standalone/{chunk-2POTU437.js → chunk-SYJSEF4X.js} +1 -1
  64. package/dist/standalone/{chunk-IF2RWXTR.js → chunk-TLROCZPY.js} +1 -1
  65. package/dist/standalone/{chunk-AJURTLI3.js → chunk-TPPJQZRS.js} +1 -1
  66. package/dist/standalone/{chunk-WTFZV4A3.js → chunk-TWZTDUXT.js} +1 -1
  67. package/dist/standalone/{chunk-DYFJMRLR.js → chunk-TXH6IAVS.js} +1 -1
  68. package/dist/standalone/{chunk-I6SFPRHU.js → chunk-WXDJSSI3.js} +1 -1
  69. package/dist/standalone/{chunk-3TNEWUWJ.js → chunk-XJGHAQOK.js} +1 -1
  70. package/dist/standalone/{chunk-T6RCP25V.js → chunk-XNMDBPSX.js} +1 -1
  71. package/dist/standalone/{chunk-FNZC62LN.js → chunk-XUZKCNPR.js} +1 -1
  72. package/dist/standalone/{chunk-Z5ZA5WBK.js → chunk-YKS246NP.js} +1 -1
  73. package/dist/standalone/{chunk-2LN3T5HY.js → chunk-YUFHPV5Q.js} +2 -2
  74. package/dist/standalone/{chunk-DWSRRE2V.js → chunk-YWC6MTH4.js} +4 -4
  75. package/dist/standalone/{chunk-YWJSG462.js → chunk-Z4GCX456.js} +1 -1
  76. package/dist/standalone/{chunk-OG32J5CM.js → chunk-ZAU7W7ST.js} +1 -1
  77. package/dist/standalone/studio.js +2 -2
  78. package/package.json +6 -6
  79. package/dist/packem_shared/reference-view-AC9FgXSz.mjs +0 -13
  80. package/dist/standalone/chunk-6HCSE2X7.js +0 -4
  81. package/dist/standalone/chunk-LQQMVCEE.js +0 -1
  82. package/dist/standalone/chunk-MXL3RBMK.js +0 -1
  83. package/dist/standalone/chunk-MZDJBR3M.js +0 -11
  84. package/dist/standalone/chunk-Q443C75G.js +0 -1
@@ -0,0 +1,13 @@
1
+ import{c as P}from"react/compiler-runtime";import{useState as L,useEffectEvent as U,useEffect as ae,createContext as le,use as de}from"react";import{b as z,g as Y,f as ce,k as ue,c as fe,d as me}from"./internal-B6haJbiP.mjs";import{SentIcon as pe,Copy01Icon as he,Search01Icon as ge}from"@hugeicons/core-free-icons";import{HugeiconsIcon as W}from"@hugeicons/react";import{I as xe}from"./input-CXhxesPC.mjs";import{useT as J}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{B as q}from"./button-q0UYSmrn.mjs";import{jsx as i,jsxs as N,Fragment as be}from"react/jsx-runtime";import{B as ye}from"./badge-r_5B4LHP.mjs";import{ShardInput as ve}from"./ShardInput-C6mjgAh4.mjs";import{L as V}from"./label-DKFzyHq6.mjs";import{T as Ne}from"./textarea--40GKAyz.mjs";import{LunoraError as Se}from"@lunora/errors";import{useLunora as ke}from"@lunora/react";import{c as Q}from"./utils-bhneXptQ.mjs";const wt=function(t,e,s){const r=P(15);let n;r[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},r[0]=n):n=r[0];const[o,l]=L(n);let a;r[1]!==e?(a=async()=>e(),r[1]=e,r[2]=a):a=r[2];const g=U(a);let d;r[3]!==s?(d=f=>s(f),r[3]=s,r[4]=d):d=r[4];const c=U(d);let u;r[5]!==c||r[6]!==g||r[7]!==t?(u=()=>{if(t!==void 0)return;let f=!1;return g().then(m=>(f||l(c(m)),m)).catch(m=>{f||l({kind:"error",message:z(m)})}),()=>{f=!0}},r[5]=c,r[6]=g,r[7]=t,r[8]=u):u=r[8];let h;r[9]!==t?(h=[t],r[9]=t,r[10]=h):h=r[10],ae(u,h);let p;return r[11]!==s||r[12]!==o||r[13]!==t?(p=t===void 0?o:s(t),r[11]=s,r[12]=o,r[13]=t,r[14]=p):p=r[14],p},we=t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string",Z=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)},F=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=>F(e)).join(" | "):t.type==="array"?`array<${F(t.items)}>`:t.type??"any",Oe=t=>{const e=Z(t);return e!==void 0?t.type??we(e[0]):F(t)},$e=t=>{const e=Z(t);return e===void 0?void 0:e.map(s=>JSON.stringify(s)).join(" | ")},Te=t=>{const e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} ≤`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);const s=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`≤ ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);const r=e.length>(s?2:1);return s||r?e.join(" "):void 0},Ee=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},D=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 D(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{const e={};for(const[s,r]of Object.entries(t.properties??{}))e[s]=D(r);return e}case"string":return"";default:return null}},K=t=>{const e=P(7),{label:s,value:r}=t;let n;e[0]!==s?(n=i("span",{className:"text-muted-foreground",children:s}),e[0]=s,e[1]=n):n=e[1];let o;e[2]!==r?(o=i("span",{className:"text-foreground",children:r}),e[2]=r,e[3]=o):o=e[3];let l;return e[4]!==n||e[5]!==o?(l=N("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,o]}),e[4]=n,e[5]=o,e[6]=l):l=e[6],l},Ce=t=>{const e=P(40),{name:s,required:r,schema:n}=t,o=J();let l;e[0]!==n?(l=Te(n),e[0]=n,e[1]=l):l=e[1];const a=l;let g;e[2]!==n?(g=$e(n),e[2]=n,e[3]=g):g=e[3];const d=g,c=n["x-lunora-table"],u=n.format!==void 0||a!==void 0||d!==void 0||c!==void 0;let h;e[4]!==n?(h=Ee(n),e[4]=n,e[5]=h):h=e[5];const p=h,f=r?"*":"?";let m;e[6]!==f?(m=i("span",{className:"text-muted-foreground",children:f}),e[6]=f,e[7]=m):m=e[7];let v;e[8]!==s||e[9]!==m?(v=N("span",{className:"font-mono text-foreground",children:[s,m]}),e[8]=s,e[9]=m,e[10]=v):v=e[10];let k;e[11]!==n?(k=Oe(n),e[11]=n,e[12]=k):k=e[12];let x;e[13]!==k?(x=i("span",{className:"font-mono text-muted-foreground",children:k}),e[13]=k,e[14]=x):x=e[14];let b;e[15]!==v||e[16]!==x?(b=N("div",{className:"flex items-baseline gap-2",children:[v,x]}),e[15]=v,e[16]=x,e[17]=b):b=e[17];let y;e[18]!==n.description?(y=n.description!==void 0&&i("p",{className:"max-w-prose text-muted-foreground",children:n.description}),e[18]=n.description,e[19]=y):y=e[19];let S;e[20]!==u||e[21]!==a||e[22]!==c||e[23]!==n.format||e[24]!==o||e[25]!==d?(S=u&&N("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&i(K,{label:o("Format"),value:n.format}),a!==void 0&&i(K,{label:o("Range"),value:a}),d!==void 0&&i(K,{label:o("Value in"),value:d}),c!==void 0&&i(K,{label:o("relation"),value:c})]}),e[20]=u,e[21]=a,e[22]=c,e[23]=n.format,e[24]=o,e[25]=d,e[26]=S):S=e[26];let O;e[27]!==y||e[28]!==S||e[29]!==b?(O=N("div",{className:"flex flex-col gap-1 py-2",children:[b,y,S]}),e[27]=y,e[28]=S,e[29]=b,e[30]=O):O=e[30];const w=O;if(p===void 0){let $;return e[31]!==w?($=i("div",{className:"border-b border-border/50 last:border-b-0",children:w}),e[31]=w,e[32]=$):$=e[32],$}let T;e[33]!==w?(T=i("summary",{className:"cursor-pointer marker:text-muted-foreground",children:w}),e[33]=w,e[34]=T):T=e[34];let A;e[35]!==p?(A=i("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:i(ee,{schema:p})}),e[35]=p,e[36]=A):A=e[36];let E;return e[37]!==T||e[38]!==A?(E=N("details",{className:"border-b border-border/50 last:border-b-0",children:[T,A]}),e[37]=T,e[38]=A,e[39]=E):E=e[39],E},ee=t=>{const e=P(7),{schema:s}=t;let r;e[0]!==s.required?(r=new Set(s.required),e[0]=s.required,e[1]=r):r=e[1];const n=r;let o;e[2]!==s.properties?(o=Object.entries(s.properties??{}),e[2]=s.properties,e[3]=o):o=e[3];const l=o;let a;return e[4]!==n||e[5]!==l?(a=i("div",{className:"flex flex-col",children:l.map(g=>{const[d,c]=g;return i(Ce,{name:d,required:n.has(d),schema:c},d)})}),e[4]=n,e[5]=l,e[6]=a):a=e[6],a},G=t=>{const e=P(10),{schema:s,testId:r}=t;if(s?.type!=="object"||Object.keys(s.properties??{}).length===0){let l;e[0]!==s?(l=F(s),e[0]=s,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==r?(a=i("p",{className:"font-mono text-xs text-muted-foreground","data-testid":r,children:l}),e[2]=l,e[3]=r,e[4]=a):a=e[4],a}let n;e[5]!==s?(n=i(ee,{schema:s}),e[5]=s,e[6]=n):n=e[6];let o;return e[7]!==n||e[8]!==r?(o=i("div",{className:"text-xs","data-testid":r,children:n}),e[7]=n,e[8]=r,e[9]=o):o=e[9],o},Ae=["curl","javascript","lunora"],Ie={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},Re=t=>`api.${t.replaceAll(/[/:]/g,".")}`,je=t=>{const e=D(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},Pe=(t,e,s)=>{const r=`${s}${e.httpPath}`,n=JSON.stringify(je(e),void 0,2),o=JSON.stringify(D(e.argsSchema)??{},void 0,2);switch(t){case"curl":{const l=e.method!=="GET"&&e.method!=="HEAD",a=[`curl -X ${e.method} ${JSON.stringify(r)}`];return l&&a.push(' -H "Content-Type: application/json"',` -d '${n}'`),a.join(` \\
2
+ `)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
3
+ import { api } from "./_generated/api";
4
+
5
+ const client = useLunora();
6
+ await client.${e.kind??"query"}(${Re(e.functionPath)}, ${o});`;default:{const a=e.method!=="GET"&&e.method!=="HEAD"?`{
7
+ method: ${JSON.stringify(e.method)},
8
+ headers: { "Content-Type": "application/json" },
9
+ body: JSON.stringify(${n}),
10
+ }`:`{ method: ${JSON.stringify(e.method)} }`;return`const response = await fetch(${JSON.stringify(r)}, ${a});
11
+ const data = await response.json();`}}},Le=t=>{const e=P(24),{operation:s,server:r}=t,n=J(),[o,l]=L("curl");let a;e[0]!==s||e[1]!==o||e[2]!==r?(a=Pe(o,s,r),e[0]=s,e[1]=o,e[2]=r,e[3]=a):a=e[3];const g=a;let d;e[4]!==g?(d=()=>{Y(g)},e[4]=g,e[5]=d):d=e[5];const c=d;let u;e[6]===Symbol.for("react.memo_cache_sentinel")?(u=y=>{l(y.currentTarget.dataset.sample)},e[6]=u):u=e[6];const h=u;let p;e[7]!==o?(p=Ae.map(y=>i("button",{"aria-selected":o===y,className:"rounded px-2 py-0.5 text-xs text-muted-foreground transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium aria-selected:text-foreground","data-sample":y,"data-testid":`api-sample-${y}`,onClick:h,role:"tab",type:"button",children:Ie[y]},y)),e[7]=o,e[8]=p):p=e[8];let f;e[9]!==p?(f=i("div",{className:"flex gap-1",role:"tablist",children:p}),e[9]=p,e[10]=f):f=e[10];let m;e[11]!==n?(m=n("Copy"),e[11]=n,e[12]=m):m=e[12];let v;e[13]!==c||e[14]!==m?(v=i(q,{"data-testid":"api-sample-copy",onClick:c,size:"xs",type:"button",variant:"ghost",children:m}),e[13]=c,e[14]=m,e[15]=v):v=e[15];let k;e[16]!==f||e[17]!==v?(k=N("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[f,v]}),e[16]=f,e[17]=v,e[18]=k):k=e[18];let x;e[19]!==g?(x=i("pre",{className:"overflow-auto px-3 pb-3 font-mono text-xs","data-testid":"api-sample-source",children:g}),e[19]=g,e[20]=x):x=e[20];let b;return e[21]!==k||e[22]!==x?(b=N("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card","data-testid":"api-code-samples",children:[k,x]}),e[21]=k,e[22]=x,e[23]=b):b=e[23],b},_e={blue:"text-info",emerald:"text-success",neutral:"text-muted-foreground",orange:"text-warning",red:"text-destructive",violet:"text-royal-amethyst"},Be=t=>{switch(t.toUpperCase()){case"DELETE":return"red";case"GET":return"emerald";case"PATCH":return"orange";case"POST":return"blue";case"PUT":return"orange";default:return"neutral"}},Me=t=>{switch(t){case"action":return"violet";case"mutation":return"orange";case"query":return"emerald";default:return"neutral"}},H=t=>{const e=P(7),{kind:s,method:r,testId:n}=t;let o;e[0]!==s||e[1]!==r?(o=s??r.toUpperCase(),e[0]=s,e[1]=r,e[2]=o):o=e[2];const l=o,a=s===void 0?Be(r):Me(s),g=`${_e[a]} font-mono text-[10px] tracking-wide uppercase`;let d;return e[3]!==l||e[4]!==g||e[5]!==n?(d=i(ye,{className:g,"data-testid":n,variant:"ghost",children:l}),e[3]=l,e[4]=g,e[5]=n,e[6]=d):d=e[6],d},te=t=>t.startsWith("2")?"text-emerald-600 dark:text-emerald-400":t==="default"||t.startsWith("4")||t.startsWith("5")?"text-red-600 dark:text-red-400":"text-muted-foreground",re=t=>t.startsWith("2")?"bg-emerald-500":t==="default"||t.startsWith("4")||t.startsWith("5")?"bg-red-500":"bg-muted-foreground",Je=new Set([" ",`
12
+ `,"\r"]),X=" ",De=t=>{let e="";for(const n of t)Je.has(n)||(e+=n);let s=0,r=e.length;for(;s<r&&(e[s]??"")<=X;)s+=1;for(;r>s&&(e[r-1]??"")<=X;)r-=1;return e.slice(s,r)},Ke=/^(?:[a-z][\d+.a-z-]*:)?\/\//i,Fe=(t,e)=>{const s=globalThis.location?.origin??"",r=e===""?s:e,n=De(t);if(r===""){if(Ke.test(n))throw new Error(`restDispatch: refusing to send the admin token off-origin (${n} names its own host and there is no origin to check it against)`);return n}const o=new URL(n,r);if(o.origin!==new URL(r).origin)throw new Error(`restDispatch: refusing to send the admin token off-origin (${o.origin} is not ${r})`);return o.toString()},ze=async(t,e,s,r)=>{const n=t.method!=="GET"&&t.method!=="HEAD",o=Fe(t.httpPath,s),a=await(await fetch(o,{body:n?JSON.stringify(e):void 0,headers:{...n?{"content-type":"application/json"}:{},...r===null||r===""?{}:{authorization:`Bearer ${r}`}},method:t.method})).text();try{return JSON.parse(a)}catch{return a}},We=t=>JSON.stringify(D(t.argsSchema)??{},void 0,2),se=le(null),ne=()=>{const t=de(se);if(t===null)throw new Se("INTERNAL","useOperationRun must be used within an OperationRunProvider");return t},qe=({children:t,operation:e})=>{const s=J(),r=ke(),[n,o]=L(()=>We(e)),[l,a]=L(""),[g,d]=L("idle"),[c,u]=L(void 0),[h,p]=L(null),[f,m]=L(null),v=async()=>{let b;try{b=n.trim()===""?{}:JSON.parse(n)}catch(S){d("error"),u(void 0),m(null),p(s("Invalid JSON args: {message}",{message:z(S)}));return}d("running"),p(null);const y=performance.now();try{const S=await(e.functionPath===void 0?ze(e,b,r.url,r.getAuthToken()):ue(r,e.kind,fe(e.functionPath),b,me(l)));u(S),m(Math.round(performance.now()-y)),d("success")}catch(S){u(void 0),m(Math.round(performance.now()-y)),p(z(S)),d("error")}};return i(se,{value:{argsText:n,durationMs:f,error:h,operation:e,response:c,send:()=>{ce(v())},setArgsText:o,setShardKey:a,shardKey:l,status:g},children:t})},He=()=>{const t=P(48),e=J(),{argsText:s,operation:r,send:n,setArgsText:o,setShardKey:l,shardKey:a,status:g}=ne();let d;t[0]!==o?(d=C=>{o(C.target.value)},t[0]=o,t[1]=d):d=t[1];const c=d;let u;t[2]!==n?(u=C=>{C.key==="Enter"&&(C.metaKey||C.ctrlKey)&&(C.preventDefault(),n())},t[2]=n,t[3]=u):u=t[3];const h=u,p=g==="running";let f;t[4]!==r.kind||t[5]!==r.method?(f=i(H,{kind:r.kind,method:r.method,testId:"api-try-method"}),t[4]=r.kind,t[5]=r.method,t[6]=f):f=t[6];const m=r.functionPath??r.httpPath;let v;t[7]!==m?(v=i("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground",children:m}),t[7]=m,t[8]=v):v=t[8];const k=p?"animate-pulse":void 0;let x;t[9]!==k?(x=i(W,{className:k,icon:pe,strokeWidth:2}),t[9]=k,t[10]=x):x=t[10];let b;t[11]!==p||t[12]!==e?(b=e(p?"Sending…":"Send"),t[11]=p,t[12]=e,t[13]=b):b=t[13];let y;t[14]!==p||t[15]!==n||t[16]!==x||t[17]!==b?(y=N(q,{"data-testid":"api-try-send",disabled:p,onClick:n,size:"sm",type:"button",children:[x,b]}),t[14]=p,t[15]=n,t[16]=x,t[17]=b,t[18]=y):y=t[18];let S;t[19]!==f||t[20]!==v||t[21]!==y?(S=N("div",{className:"flex items-center gap-2 border-b border-border bg-muted px-3 py-2",children:[f,v,y]}),t[19]=f,t[20]=v,t[21]=y,t[22]=S):S=t[22];let O;t[23]!==e?(O=e("Arguments (JSON)"),t[23]=e,t[24]=O):O=t[24];let w;t[25]!==O?(w=i(V,{htmlFor:"api-try-args",children:O}),t[25]=O,t[26]=w):w=t[26];let T;t[27]!==s?(T=s.split(`
13
+ `),t[27]=s,t[28]=T):T=t[28];const A=Math.min(12,Math.max(3,T.length));let E;t[29]!==s||t[30]!==c||t[31]!==h||t[32]!==A?(E=i(Ne,{className:"font-mono text-xs","data-testid":"api-try-args",id:"api-try-args",onChange:c,onKeyDown:h,rows:A,spellCheck:!1,value:s}),t[29]=s,t[30]=c,t[31]=h,t[32]=A,t[33]=E):E=t[33];let $;t[34]!==w||t[35]!==E?($=N("div",{className:"flex flex-col gap-1.5",children:[w,E]}),t[34]=w,t[35]=E,t[36]=$):$=t[36];let I;t[37]!==r.functionPath||t[38]!==l||t[39]!==a||t[40]!==e?(I=r.functionPath!==void 0&&N("div",{className:"flex flex-col gap-1.5",children:[i(V,{htmlFor:"shard-input",children:e("Shard key (optional)")}),i(ve,{id:"shard-input",onChange:l,testId:"shard-input",value:a})]}),t[37]=r.functionPath,t[38]=l,t[39]=a,t[40]=e,t[41]=I):I=t[41];let R;t[42]!==$||t[43]!==I?(R=N("div",{className:"flex flex-col gap-3 p-3",children:[$,I]}),t[42]=$,t[43]=I,t[44]=R):R=t[44];let j;return t[45]!==R||t[46]!==S?(j=N("div",{className:"overflow-hidden rounded-xl border border-border bg-card","data-testid":"api-try-it",children:[S,R]}),t[45]=R,t[46]=S,t[47]=j):j=t[47],j},Ue=t=>{const e=P(51),{operation:s}=t,r=J(),n=`api-operation-${s.operationId}`,o=s.key;let l;e[0]!==s.kind||e[1]!==s.method?(l=i(H,{kind:s.kind,method:s.method,testId:"api-operation-method"}),e[0]=s.kind,e[1]=s.method,e[2]=l):l=e[2];const a=s.functionPath??s.httpPath;let g;e[3]!==a?(g=i("code",{className:"truncate font-mono text-xs text-muted-foreground",children:a}),e[3]=a,e[4]=g):g=e[4];let d;e[5]!==l||e[6]!==g?(d=N("div",{className:"flex items-center gap-2",children:[l,g]}),e[5]=l,e[6]=g,e[7]=d):d=e[7];let c;e[8]!==s.title?(c=i("h1",{className:"text-lg font-semibold text-foreground","data-testid":"api-operation-title",children:s.title}),e[8]=s.title,e[9]=c):c=e[9];let u;e[10]!==s.description?(u=s.description!==void 0&&i("p",{className:"text-sm text-muted-foreground",children:s.description}),e[10]=s.description,e[11]=u):u=e[11];let h;e[12]!==d||e[13]!==c||e[14]!==u?(h=N("header",{className:"sticky top-0 z-10 -mx-6 -mt-6 flex flex-col gap-2 border-b border-border bg-background px-6 pt-6 pb-3",children:[d,c,u]}),e[12]=d,e[13]=c,e[14]=u,e[15]=h):h=e[15];let p;e[16]!==r?(p=r("Try it"),e[16]=r,e[17]=p):p=e[17];let f;e[18]!==p?(f=i("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:p}),e[18]=p,e[19]=f):f=e[19];let m;e[20]===Symbol.for("react.memo_cache_sentinel")?(m=i(He,{}),e[20]=m):m=e[20];let v;e[21]!==f?(v=N("section",{className:"flex flex-col gap-2",children:[f,m]}),e[21]=f,e[22]=v):v=e[22];let k;e[23]!==r?(k=r("Request arguments"),e[23]=r,e[24]=k):k=e[24];let x;e[25]!==k?(x=i("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:k}),e[25]=k,e[26]=x):x=e[26];let b;e[27]!==s.argsSchema?(b=i(G,{schema:s.argsSchema,testId:"api-operation-args"}),e[27]=s.argsSchema,e[28]=b):b=e[28];let y;e[29]!==x||e[30]!==b?(y=N("section",{className:"flex flex-col gap-2",children:[x,b]}),e[29]=x,e[30]=b,e[31]=y):y=e[31];let S;e[32]!==r?(S=r("Response body"),e[32]=r,e[33]=S):S=e[33];let O;e[34]!==S?(O=i("h2",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),e[34]=S,e[35]=O):O=e[35];let w;if(e[36]!==s.responses||e[37]!==r){let E;e[39]!==r?(E=$=>N("div",{className:"flex flex-col gap-1.5 rounded-xl border border-border bg-card p-3",children:[N("div",{className:"flex items-center justify-between gap-2",children:[N("span",{className:`inline-flex items-center gap-1.5 font-mono text-xs font-semibold ${te($.status)}`,children:[i("span",{className:`size-1.5 rounded-full ${re($.status)}`}),$.status]}),$.schema!==void 0&&i("span",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:r("application/json")})]}),$.description!==void 0&&i("p",{className:"text-xs text-muted-foreground",children:$.description}),$.schema!==void 0&&i(G,{schema:$.schema,testId:`api-response-${$.status}`})]},$.status),e[39]=r,e[40]=E):E=e[40],w=s.responses.map(E),e[36]=s.responses,e[37]=r,e[38]=w}else w=e[38];let T;e[41]!==O||e[42]!==w?(T=N("section",{className:"flex flex-col gap-3",children:[O,w]}),e[41]=O,e[42]=w,e[43]=T):T=e[43];let A;return e[44]!==s.key||e[45]!==n||e[46]!==v||e[47]!==y||e[48]!==T||e[49]!==h?(A=N("div",{className:"flex flex-col gap-6 duration-200 animate-in fade-in-0 slide-in-from-bottom-1","data-testid":n,children:[h,v,y,T]},o),e[44]=s.key,e[45]=n,e[46]=v,e[47]=y,e[48]=T,e[49]=h,e[50]=A):A=e[50],A},Ve={boolean:"text-royal-amethyst",key:"text-sky-sapphire",number:"text-warning",plain:"",string:"text-success"},Ge=/"(?:[^"\\]|\\.)*"|\b(?:true|false|null)\b|-?\d+(?:\.\d+)?/g,Xe=/^\s*:/,Ye=(t,e,s)=>s.startsWith('"')?Xe.test(t.slice(e))?"key":"string":s==="true"||s==="false"||s==="null"?"boolean":"number",Qe=t=>{const e=[];let s=0;for(const r of t.matchAll(Ge)){const{index:n}=r,o=r[0],l=n+o.length;n>s&&e.push({kind:"plain",start:s,text:t.slice(s,n)}),e.push({kind:Ye(t,l,o),start:n,text:o}),s=l}return s<t.length&&e.push({kind:"plain",start:s,text:t.slice(s)}),e},Ze=t=>{const e=P(4),{code:s}=t;let r;e[0]!==s?(r=Qe(s).map(et),e[0]=s,e[1]=r):r=e[1];let n;return e[2]!==r?(n=i(be,{children:r}),e[2]=r,e[3]=n):n=e[3],n};function et(t){return i("span",{className:Ve[t.kind],children:t.text},t.start)}const oe="__live__",tt=t=>t.schema===void 0?"":JSON.stringify(D(t.schema),void 0,2),rt=(t,e,s)=>s?t??"":e===void 0?"":JSON.stringify(e,void 0,2),st=t=>{const e=P(18),{active:s,running:r,showError:n}=t,o=J();if(r){let u;e[0]!==o?(u=o("Sending…"),e[0]=o,e[1]=u):u=e[1];let h;return e[2]!==u?(h=i("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-running",children:u}),e[2]=u,e[3]=h):h=e[3],h}if(s===void 0||s.body===""){let u;e[4]!==s?.live||e[5]!==o?(u=s?.live===!0?o("Send a request to see the response."):o("No example for this response."),e[4]=s?.live,e[5]=o,e[6]=u):u=e[6];let h;return e[7]!==u?(h=i("p",{className:"px-3 py-3 text-xs text-muted-foreground","data-testid":"api-response-idle",children:u}),e[7]=u,e[8]=h):h=e[8],h}const l=n&&"text-destructive";let a;e[9]!==l?(a=Q("max-h-[28rem] overflow-auto px-3 py-3 font-mono text-xs",l),e[9]=l,e[10]=a):a=e[10];const g=n?"api-response-error":"api-response-body";let d;e[11]!==s.body||e[12]!==n?(d=n?s.body:i(Ze,{code:s.body}),e[11]=s.body,e[12]=n,e[13]=d):d=e[13];let c;return e[14]!==a||e[15]!==g||e[16]!==d?(c=i("pre",{className:a,"data-testid":g,children:d}),e[14]=a,e[15]=g,e[16]=d,e[17]=c):c=e[17],c},nt=({durationMs:t,error:e,failed:s,operation:r,ran:n,response:o,t:l})=>{const a=r.responses.map(d=>({body:tt(d),durationMs:null,id:d.status,label:d.status,live:!1,status:d.status}));return n?[{body:rt(e,o,s),durationMs:t,id:oe,label:l("Live"),live:!0,status:s?"error":"200"},...a]:a},ot=()=>{const t=P(19),e=J(),{durationMs:s,error:r,operation:n,response:o,status:l}=ne(),a=l==="running",g=l==="error",d=l==="success"||g,c=nt({durationMs:s,error:r,failed:g,operation:n,ran:d,response:o,t:e}),u=d?oe:c.find(it)?.id??c[0]?.id??"",[h,p]=L(null),f=c.find(C=>C.id===(h??u))??c[0];let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=C=>{const{id:_}=C.currentTarget.dataset;_!==void 0&&p(_)},t[0]=m):m=t[0];const v=m,k=()=>{f!==void 0&&Y(f.body)},x=f?.live===!0?f.durationMs:null,b=f?.live===!0&&f.status==="error",y="flex min-h-0 flex-col rounded-xl border border-border bg-card",S="api-response-panel";let O;t[1]!==e?(O=e("Response"),t[1]=e,t[2]=O):O=t[2];let w;t[3]!==O?(w=i("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:O}),t[3]=O,t[4]=w):w=t[4];const T=x!==null&&i("span",{className:"font-mono text-[10px] text-muted-foreground",children:e("{ms} ms",{ms:x})}),A=f!==void 0&&f.body!==""&&i(q,{"aria-label":e("Copy"),"data-testid":"api-response-copy",onClick:k,size:"icon-xs",type:"button",variant:"ghost",children:i(W,{icon:he,strokeWidth:2})});let E;t[5]!==T||t[6]!==A?(E=N("div",{className:"flex items-center gap-2",children:[T,A]}),t[5]=T,t[6]=A,t[7]=E):E=t[7];let $;t[8]!==w||t[9]!==E?($=N("div",{className:"flex items-center justify-between gap-2 border-b border-border px-3 py-2",children:[w,E]}),t[8]=w,t[9]=E,t[10]=$):$=t[10];const I=c.length>0&&i("div",{className:"flex gap-1 overflow-x-auto border-b border-border px-2 py-1.5",role:"tablist",children:c.map(C=>{const _=C.id===f?.id;return N("button",{"aria-selected":_,className:Q("inline-flex items-center gap-1.5 rounded px-2 py-0.5 font-mono text-xs transition-colors hover:text-foreground aria-selected:bg-muted aria-selected:font-medium",_?te(C.status):"text-muted-foreground"),"data-id":C.id,"data-testid":C.live?"api-response-tab-live":`api-response-tab-${C.status}`,onClick:v,role:"tab",type:"button",children:[i("span",{className:`size-1.5 rounded-full ${re(C.status)}`}),C.label]},C.id)})});let R;t[11]!==f||t[12]!==a||t[13]!==b?(R=i(st,{active:f,running:a,showError:b}),t[11]=f,t[12]=a,t[13]=b,t[14]=R):R=t[14];let j;return t[15]!==R||t[16]!==$||t[17]!==I?(j=N("div",{className:y,"data-testid":S,children:[$,I,R]}),t[15]=R,t[16]=$,t[17]=I,t[18]=j):j=t[18],j};function it(t){return t.status.startsWith("2")}const at=(t,e)=>{const s=e.trim().toLowerCase();return s===""?t:t.map(r=>({...r,operations:r.operations.filter(n=>`${n.summary} ${n.operationId}`.toLowerCase().includes(s))})).filter(r=>r.operations.length>0)},Ot=t=>{const e=P(53),{model:s}=t,r=J(),n=s.groups[0]?.operations[0]?.key??"",[o,l]=L(n),[a,g]=L("");let d;e[0]!==n||e[1]!==s.operationByKey||e[2]!==o?(d=s.operationByKey.get(o)??s.operationByKey.get(n),e[0]=n,e[1]=s.operationByKey,e[2]=o,e[3]=d):d=e[3];const c=d;let u,h,p,f,m,v,k,x,b,y;if(e[4]!==a||e[5]!==s.groups||e[6]!==s.server||e[7]!==c?.key||e[8]!==r){u=at(s.groups,a);let E;e[19]===Symbol.for("react.memo_cache_sentinel")?(E=M=>{const{key:B}=M.currentTarget.dataset;B!==void 0&&l(B)},e[19]=E):E=e[19];const $=E;let I;e[20]===Symbol.for("react.memo_cache_sentinel")?(I=M=>{g(M.target.value)},e[20]=I):I=e[20];const R=I;h=s.server??"",b="grid min-h-0 flex-1 grid-cols-1 overflow-hidden lg:grid-cols-[16rem_minmax(0,1fr)_22rem]",y="api-reference",e[21]!==r?(m=r("API operations"),e[21]=r,e[22]=m):m=e[22],v="flex min-h-0 flex-col overflow-y-auto border-r border-border",k="api-reference-nav";let j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=i(W,{className:"pointer-events-none absolute top-1/2 left-2 size-3.5 -translate-y-1/2 text-muted-foreground",icon:ge,strokeWidth:2}),e[23]=j):j=e[23];let C;e[24]!==r?(C=r("Filter operations"),e[24]=r,e[25]=C):C=e[25],e[26]!==a||e[27]!==C?(x=i("div",{className:"sticky top-0 z-10 border-b border-border bg-sidebar p-2",children:N("div",{className:"relative",children:[j,i(xe,{className:"h-7 pl-7","data-testid":"api-filter",onChange:R,placeholder:C,value:a})]})}),e[26]=a,e[27]=C,e[28]=x):x=e[28],p="flex flex-col gap-4 p-2";let _;e[29]!==c?.key||e[30]!==r?(_=M=>N("div",{className:"flex flex-col gap-1",children:[N("div",{className:"flex items-center justify-between px-2",children:[i("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:M.name||r("(root)")}),i("span",{className:"font-mono text-[10px] text-muted-foreground/70",children:M.operations.length})]}),M.operations.map(B=>{const ie=B.key===c?.key;return N("button",{"aria-current":ie?"page":void 0,className:"flex items-center justify-between gap-2 rounded-md border-l-2 border-transparent px-2 py-1 text-start text-xs text-muted-foreground transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground aria-[current=page]:border-primary aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-key":B.key,"data-testid":`api-nav-${B.operationId}`,onClick:$,type:"button",children:[i("span",{className:"truncate",children:B.summary}),i(H,{kind:B.kind,method:B.method})]},B.key)})]},M.name),e[29]=c?.key,e[30]=r,e[31]=_):_=e[31],f=u.map(_),e[4]=a,e[5]=s.groups,e[6]=s.server,e[7]=c?.key,e[8]=r,e[9]=u,e[10]=h,e[11]=p,e[12]=f,e[13]=m,e[14]=v,e[15]=k,e[16]=x,e[17]=b,e[18]=y}else u=e[9],h=e[10],p=e[11],f=e[12],m=e[13],v=e[14],k=e[15],x=e[16],b=e[17],y=e[18];let S;e[32]!==u.length||e[33]!==r?(S=u.length===0&&i("p",{className:"px-2 py-1 text-xs text-muted-foreground","data-testid":"api-nav-empty",children:r("No operations match your filter.")}),e[32]=u.length,e[33]=r,e[34]=S):S=e[34];let O;e[35]!==S||e[36]!==p||e[37]!==f?(O=N("div",{className:p,children:[f,S]}),e[35]=S,e[36]=p,e[37]=f,e[38]=O):O=e[38];let w;e[39]!==O||e[40]!==m||e[41]!==v||e[42]!==k||e[43]!==x?(w=N("nav",{"aria-label":m,className:v,"data-testid":k,children:[x,O]}),e[39]=O,e[40]=m,e[41]=v,e[42]=k,e[43]=x,e[44]=w):w=e[44];let T;e[45]!==c||e[46]!==h?(T=c===void 0?i("div",{className:"lg:col-span-2"}):N(qe,{operation:c,children:[i("div",{className:"min-w-0 overflow-y-auto p-6","data-testid":"api-reference-main",children:i(Ue,{operation:c})}),N("aside",{className:"flex min-w-0 flex-col gap-4 overflow-y-auto border-border p-4 lg:border-l","data-testid":"api-reference-aside",children:[i(Le,{operation:c,server:h}),i(ot,{})]})]},c.key),e[45]=c,e[46]=h,e[47]=T):T=e[47];let A;return e[48]!==w||e[49]!==T||e[50]!==b||e[51]!==y?(A=N("div",{className:b,"data-testid":y,children:[w,T]}),e[48]=w,e[49]=T,e[50]=b,e[51]=y,e[52]=A):A=e[52],A};export{Ot as R,wt as u};
@@ -1,2 +1,2 @@
1
- import{a as fe}from"./chunk-UDCVU3Z5.js";import"./chunk-I52I2DJG.js";import{a as ie}from"./chunk-WQYWA7U6.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-D27D4UUI.js";import{P as de}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as ne}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as he}from"./chunk-AJURTLI3.js";import"./chunk-ULIQFBZU.js";import"./chunk-PNDBXKC4.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-T6S2F46N.js";import{f as le}from"./chunk-MZDJBR3M.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as ce}from"./chunk-FKVZRPV5.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-FODLDLE2.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-YKXDMIHQ.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"we"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"ye"),Te=Z(H.clearCapturedMail),Le=Z(H.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(H.getCapturedMail,p),[k,f]=(0,N.useState)(null),[D,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,P]=(0,N.useState)(""),b=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let R=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let W=L,j;e[8]!==n?(j=i(()=>{n()},"L"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==R?(M=i(()=>{ae(R())},"A"),e[10]=R,e[11]=M):M=e[11];let U=M,_;e[12]!==W?(_=i(()=>{ae(W())},"E"),e[12]=W,e[13]=_):_=e[13];let G=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{P(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let J=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let K=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"j"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,D),d=Ce(O),I;e[17]!==d?(I=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=I):I=e[18];let V=I,B;e[19]!==d?(B=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=B):B=e[20];let X=B,E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=E):E=e[37],E},"Te"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Le"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:D,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:P}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:P.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:D,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
1
+ import{a as fe}from"./chunk-UDCVU3Z5.js";import"./chunk-I52I2DJG.js";import{a as ie}from"./chunk-WQYWA7U6.js";import{a as pe}from"./chunk-66UGPQVC.js";import"./chunk-D27D4UUI.js";import{P as de}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import{a as x}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as ne}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as he}from"./chunk-TPPJQZRS.js";import"./chunk-ULIQFBZU.js";import"./chunk-C37WBSYD.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-Q7UGJSBF.js";import{f as le}from"./chunk-FGSNEPHU.js";import"./chunk-FSRSK4LY.js";import"./chunk-YUFHPV5Q.js";import{a as ce}from"./chunk-FKVZRPV5.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-FODLDLE2.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-YKXDMIHQ.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"we"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"ye"),Te=Z(H.clearCapturedMail),Le=Z(H.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(H.getCapturedMail,p),[k,f]=(0,N.useState)(null),[D,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,P]=(0,N.useState)(""),b=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let R=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let W=L,j;e[8]!==n?(j=i(()=>{n()},"L"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==R?(M=i(()=>{ae(R())},"A"),e[10]=R,e[11]=M):M=e[11];let U=M,_;e[12]!==W?(_=i(()=>{ae(W())},"E"),e[12]=W,e[13]=_):_=e[13];let G=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{P(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let J=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let K=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"j"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,D),d=Ce(O),I;e[17]!==d?(I=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=I):I=e[18];let V=I,B;e[19]!==d?(B=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=B):B=e[20];let X=B,E;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(E={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=E):E=e[37],E},"Te"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Le"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:D,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:P}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:P.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:D,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
2
2
  `)}))]})]})]})]})},"We");export{Je as MailPanel};
@@ -1 +1 @@
1
- import{b as c}from"./chunk-T6S2F46N.js";import{f as l}from"./chunk-MZDJBR3M.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=l(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"t"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=c(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"b");export{p as a,y as b};
1
+ import{b as c}from"./chunk-Q7UGJSBF.js";import{f as l}from"./chunk-FGSNEPHU.js";import{a as r,d as f,f as g}from"./chunk-YKXDMIHQ.js";var m=f(g(),1);var p={capabilities:{accounts:!0,admin:!0,organization:!1,passkey:!1,twoFactor:!1},emailAndPassword:!1,organization:{enabled:!1,roles:!1,teams:!1},plugins:[],rateLimit:{enabled:!1},session:{},socialProviders:[],userFields:[]},y=r(()=>{let o=(0,m.c)(6),t=l(),a;o[0]===Symbol.for("react.memo_cache_sentinel")?(a=["lunora-auth-config"],o[0]=a):a=o[0];let e;o[1]!==t?(e=r(()=>t.getAuthConfig(),"t"),o[1]=t,o[2]=e):e=o[2];let{data:u,isLoading:d}=c(a,e),i=u??p,n=!d,s;return o[3]!==i||o[4]!==n?(s={config:i,ready:n},o[3]=i,o[4]=n,o[5]=s):s=o[5],s},"b");export{p as a,y as b};
@@ -1 +1 @@
1
- import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-LJYUUOBB.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-JAKYTDUH.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-T6S2F46N.js";import{f as ne,g as oe}from"./chunk-MZDJBR3M.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as p,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=p(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.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,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.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,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.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]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=p(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(h.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=p(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),h!==null&&(0,r.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:h}),h===null&&n?.historyTruncated===!0&&(0,r.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:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
1
+ import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-R2IHJBT6.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-GEITRXJJ.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-Q7UGJSBF.js";import{f as ne,g as oe}from"./chunk-FGSNEPHU.js";import"./chunk-FSRSK4LY.js";import"./chunk-YUFHPV5Q.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as p,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=p(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.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,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.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,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.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]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=p(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(h.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=p(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),h!==null&&(0,r.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:h}),h===null&&n?.historyTruncated===!0&&(0,r.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:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
@@ -1 +1 @@
1
- import{a as x}from"./chunk-4ZEL6BYL.js";import{c as S}from"./chunk-T6S2F46N.js";import{f as q}from"./chunk-MZDJBR3M.js";import{d as _,f as g,g as y,n as C}from"./chunk-FODLDLE2.js";import{a as u,d as w,e as L,f as T,g as F}from"./chunk-YKXDMIHQ.js";var v=w(L(),1);var j={},A=g(x.aiGenerateSql),I=g(x.aiTableFilter),O=g(x.aiChartConfig),R=u(s=>{let e=q(),[i,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=S(x.aiAvailable,j,{shardKey:s}),[f,l]=(0,v.useState)(!1),b=f||a.data?.available===!1,p=u(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"i"),h=u((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&l(!0)},"a");return{generate:u(async(t,o)=>{p("sql");try{let{result:c}=await e.query(A,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:u(async t=>{p("chart");try{let{result:o}=await e.query(O,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:u(t=>i[t]===!0,"pending"),reason:u(t=>n[t],"reason"),suggestFilter:u(async(t,o)=>{p("filter");try{let{result:c}=await e.query(I,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"w");var N=w(T(),1);var m=w(F(),1);var G=u((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let i=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&i.push({match:!1,offset:r,text:s.slice(r,a)}),i.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&i.push({match:!1,offset:r,text:s.slice(r)}),i},"N"),U=u(s=>{let e=(0,N.c)(9),{highlight:i,value:d}=s;if(d==null){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=l):l=e[0],l}let n,r,a;if(e[1]!==i||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let l=C(d);if(i===void 0||i===""){a=(0,m.jsx)("span",{title:l,children:l});break e}n=l,r=G(l,i).map(z)}e[1]=i,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let f;return e[6]!==n||e[7]!==r?(f=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=f):f=e[8],f},"v"),Q=u(s=>{let e=(0,N.c)(22),{columns:i,rows:d}=s,n=_(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let f;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=u((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"c"),e[7]=n,e[8]=t):t=e[8],f=d.map(t),e[4]=d,e[5]=n,e[6]=f}else f=e[6];let l;e[9]!==a||e[10]!==f?(l=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,f]})}),e[9]=a,e[10]=f,e[11]=l):l=e[11];let b;if(e[12]!==i||e[13]!==d){let t;e[15]!==d?(t=u(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,k)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:c[o]})},k))]},o),"c"),e[15]=d,e[16]=t):t=e[16],b=i.map(t),e[12]=i,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==l||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[l,p]})}),e[19]=l,e[20]=p,e[21]=h):h=e[21],h},"T"),V=u(({children:s,layout:e="card",testId:i})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":i,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}u(z,"_");export{R as a,U as b,Q as c,V as d};
1
+ import{a as x}from"./chunk-4ZEL6BYL.js";import{c as S}from"./chunk-Q7UGJSBF.js";import{f as q}from"./chunk-FGSNEPHU.js";import{d as _,f as g,g as y,n as C}from"./chunk-FODLDLE2.js";import{a as u,d as w,e as L,f as T,g as F}from"./chunk-YKXDMIHQ.js";var v=w(L(),1);var j={},A=g(x.aiGenerateSql),I=g(x.aiTableFilter),O=g(x.aiChartConfig),R=u(s=>{let e=q(),[i,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=S(x.aiAvailable,j,{shardKey:s}),[f,l]=(0,v.useState)(!1),b=f||a.data?.available===!1,p=u(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"i"),h=u((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&l(!0)},"a");return{generate:u(async(t,o)=>{p("sql");try{let{result:c}=await e.query(A,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:u(async t=>{p("chart");try{let{result:o}=await e.query(O,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:u(t=>i[t]===!0,"pending"),reason:u(t=>n[t],"reason"),suggestFilter:u(async(t,o)=>{p("filter");try{let{result:c}=await e.query(I,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"w");var N=w(T(),1);var m=w(F(),1);var G=u((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let i=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&i.push({match:!1,offset:r,text:s.slice(r,a)}),i.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&i.push({match:!1,offset:r,text:s.slice(r)}),i},"N"),U=u(s=>{let e=(0,N.c)(9),{highlight:i,value:d}=s;if(d==null){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=l):l=e[0],l}let n,r,a;if(e[1]!==i||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let l=C(d);if(i===void 0||i===""){a=(0,m.jsx)("span",{title:l,children:l});break e}n=l,r=G(l,i).map(z)}e[1]=i,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let f;return e[6]!==n||e[7]!==r?(f=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=f):f=e[8],f},"v"),Q=u(s=>{let e=(0,N.c)(22),{columns:i,rows:d}=s,n=_(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let f;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=u((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"c"),e[7]=n,e[8]=t):t=e[8],f=d.map(t),e[4]=d,e[5]=n,e[6]=f}else f=e[6];let l;e[9]!==a||e[10]!==f?(l=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,f]})}),e[9]=a,e[10]=f,e[11]=l):l=e[11];let b;if(e[12]!==i||e[13]!==d){let t;e[15]!==d?(t=u(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,k)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:c[o]})},k))]},o),"c"),e[15]=d,e[16]=t):t=e[16],b=i.map(t),e[12]=i,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==l||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[l,p]})}),e[19]=l,e[20]=p,e[21]=h):h=e[21],h},"T"),V=u(({children:s,layout:e="card",testId:i})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":i,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}u(z,"_");export{R as a,U as b,Q as c,V as d};