@lunora/studio 1.0.0-alpha.350 → 1.0.0-alpha.351

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 (125) hide show
  1. package/dist/index.d.mts +4 -1
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  6. package/dist/packem_chunks/ApiTab.mjs +1 -1
  7. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  8. package/dist/packem_chunks/ExportImportPanel.mjs +8 -8
  9. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  10. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  11. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  12. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  13. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  14. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  15. package/dist/packem_chunks/MailPanel.mjs +1 -1
  16. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  17. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  18. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  19. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  20. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  21. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  22. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  23. package/dist/packem_chunks/TableEditor.mjs +1 -1
  24. package/dist/packem_chunks/agents-panel.mjs +1 -1
  25. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  26. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  27. package/dist/packem_chunks/containers-panel.mjs +1 -1
  28. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  29. package/dist/packem_chunks/evals-panel.mjs +1 -1
  30. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  31. package/dist/packem_chunks/flags-panel.mjs +1 -1
  32. package/dist/packem_chunks/issues-panel.mjs +1 -1
  33. package/dist/packem_chunks/kv-browser.mjs +1 -1
  34. package/dist/packem_chunks/migrations-route.mjs +1 -1
  35. package/dist/packem_chunks/payments-panel.mjs +1 -1
  36. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  37. package/dist/packem_chunks/queues-panel.mjs +1 -1
  38. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  39. package/dist/packem_chunks/rls-panel.mjs +1 -1
  40. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  41. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  42. package/dist/packem_chunks/traces-panel.mjs +1 -1
  43. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  44. package/dist/packem_shared/{ADMIN_FUNCTIONS-B8yyk5BX.mjs → ADMIN_FUNCTIONS-4aGsMs95.mjs} +1 -1
  45. package/dist/packem_shared/{ApiDocsPanel-B_RaW7Br.mjs → ApiDocsPanel-E4Vr-8zW.mjs} +1 -1
  46. package/dist/packem_shared/{DataBrowser-Cc1qZX-4.mjs → DataBrowser-C5HbI4TH.mjs} +1 -1
  47. package/dist/packem_shared/{GlobalDataBrowser-Hq6gTlkb.mjs → GlobalDataBrowser-D0H2yJSl.mjs} +1 -1
  48. package/dist/packem_shared/{HomePanel-DeyYLVxc.mjs → HomePanel-CcYkDlR-.mjs} +1 -1
  49. package/dist/packem_shared/{MigrationsPanel-CMZYYcQ5.mjs → MigrationsPanel-YyCO_T-3.mjs} +1 -1
  50. package/dist/packem_shared/{Studio-BhTqTeGb.mjs → Studio-4vJzwwNa.mjs} +1 -1
  51. package/dist/packem_shared/{StudioApp-B1d0beD4.mjs → StudioApp-px2FMPDS.mjs} +1 -1
  52. package/dist/packem_shared/{home-panel-0XMGe1hP.mjs → home-panel-DPiMVQZ2.mjs} +1 -1
  53. package/dist/packem_shared/{studio-CA3ZKwVK.mjs → studio-DIUgH7k0.mjs} +1 -1
  54. package/dist/packem_shared/{table-list-sidebar-nA7g7uSk.mjs → table-list-sidebar-CCRB_iYz.mjs} +1 -1
  55. package/dist/packem_shared/{use-sql-assistant-DXnqbBs-.mjs → use-sql-assistant-BMVlguKF.mjs} +1 -1
  56. package/dist/standalone/{chunk-WQGT24W6.js → chunk-22O2JDWR.js} +1 -1
  57. package/dist/standalone/{chunk-RXVXXRYD.js → chunk-2DV455PX.js} +1 -1
  58. package/dist/standalone/{chunk-B7MHW3A5.js → chunk-2EMNPL3B.js} +1 -1
  59. package/dist/standalone/{chunk-LOV52GLG.js → chunk-35BGGOWV.js} +1 -1
  60. package/dist/standalone/{chunk-BTRYFPZH.js → chunk-3MQ477EE.js} +1 -1
  61. package/dist/standalone/{chunk-XWEDIIIT.js → chunk-453GHHZ4.js} +1 -1
  62. package/dist/standalone/{chunk-QAQVT4FS.js → chunk-4CITH2NU.js} +1 -1
  63. package/dist/standalone/{chunk-E32FS6PE.js → chunk-4EDOPHLM.js} +1 -1
  64. package/dist/standalone/{chunk-EDGOSJXL.js → chunk-4QRVJDM4.js} +1 -1
  65. package/dist/standalone/{chunk-B3AXFXAD.js → chunk-4UWYDYM5.js} +1 -1
  66. package/dist/standalone/{chunk-SXD6JQXF.js → chunk-57ZNR6IA.js} +1 -1
  67. package/dist/standalone/{chunk-R3KLR5EP.js → chunk-6DYXTEU7.js} +1 -1
  68. package/dist/standalone/chunk-6GPEHYCG.js +1 -0
  69. package/dist/standalone/{chunk-E3VSRIQU.js → chunk-6GRI2HXU.js} +1 -1
  70. package/dist/standalone/{chunk-7F3S5OQT.js → chunk-6QBK3Z7A.js} +1 -1
  71. package/dist/standalone/{chunk-4ZEL6BYL.js → chunk-6UTZXEW3.js} +1 -1
  72. package/dist/standalone/{chunk-CGZVMM3P.js → chunk-7EAHHRJR.js} +1 -1
  73. package/dist/standalone/{chunk-HOPAJ5F6.js → chunk-ACNWZIAH.js} +1 -1
  74. package/dist/standalone/{chunk-5J32EGHF.js → chunk-ANACHJRU.js} +1 -1
  75. package/dist/standalone/chunk-BAGJYLSU.js +8 -0
  76. package/dist/standalone/{chunk-HLAAOW33.js → chunk-BCOOULSO.js} +1 -1
  77. package/dist/standalone/{chunk-ZMQ6PKLN.js → chunk-BKH2NALB.js} +1 -1
  78. package/dist/standalone/{chunk-ZBFWT34B.js → chunk-BTOOJXUL.js} +1 -1
  79. package/dist/standalone/{chunk-2EL4EMYZ.js → chunk-C6FNBKCO.js} +1 -1
  80. package/dist/standalone/{chunk-OECMBE6Q.js → chunk-DSTNWB4N.js} +1 -1
  81. package/dist/standalone/{chunk-WIET27J3.js → chunk-DTW4E5AB.js} +1 -1
  82. package/dist/standalone/{chunk-VB6YJKPA.js → chunk-FNWRS4VQ.js} +1 -1
  83. package/dist/standalone/{chunk-UTX6IBA3.js → chunk-FST24UXA.js} +1 -1
  84. package/dist/standalone/{chunk-ZTOXQK4V.js → chunk-FXGYX2V6.js} +1 -1
  85. package/dist/standalone/{chunk-MFNO5BFR.js → chunk-HWTX54JM.js} +1 -1
  86. package/dist/standalone/{chunk-26OKWFLO.js → chunk-HZCLLEWP.js} +1 -1
  87. package/dist/standalone/{chunk-7AZYREIY.js → chunk-IRCUXARN.js} +1 -1
  88. package/dist/standalone/{chunk-W7Z35E2E.js → chunk-IVQKQBKK.js} +1 -1
  89. package/dist/standalone/{chunk-W2XSKODB.js → chunk-K7FZTYAY.js} +1 -1
  90. package/dist/standalone/{chunk-5NZWQEEJ.js → chunk-KNX3KB7E.js} +1 -1
  91. package/dist/standalone/{chunk-MMJTKSHL.js → chunk-LYHEBMM6.js} +1 -1
  92. package/dist/standalone/{chunk-BVKQA5OL.js → chunk-M2RIGPGL.js} +1 -1
  93. package/dist/standalone/{chunk-EOR73TZZ.js → chunk-MKVZXGJQ.js} +1 -1
  94. package/dist/standalone/chunk-OIDFWEJX.js +21 -0
  95. package/dist/standalone/{chunk-CLINNLLE.js → chunk-OJG65AG4.js} +1 -1
  96. package/dist/standalone/{chunk-XMEVNOCA.js → chunk-Q4N3TJPV.js} +1 -1
  97. package/dist/standalone/{chunk-NVHHB5EV.js → chunk-QEVFVWGC.js} +1 -1
  98. package/dist/standalone/{chunk-JAHK7RRJ.js → chunk-RHOQJNDW.js} +1 -1
  99. package/dist/standalone/{chunk-7MN724WR.js → chunk-RQDSPVVH.js} +1 -1
  100. package/dist/standalone/{chunk-P5GAJKDW.js → chunk-S5S2YICJ.js} +1 -1
  101. package/dist/standalone/{chunk-ZZAJHNZ6.js → chunk-S6JFSLBK.js} +1 -1
  102. package/dist/standalone/{chunk-GMW2DYFU.js → chunk-SDTHCM5H.js} +1 -1
  103. package/dist/standalone/{chunk-JG2C7SS2.js → chunk-SM2IQWCJ.js} +1 -1
  104. package/dist/standalone/{chunk-GPOSJNMV.js → chunk-T2QAOXUO.js} +1 -1
  105. package/dist/standalone/{chunk-2WNL74MI.js → chunk-T4VAXHRL.js} +1 -1
  106. package/dist/standalone/{chunk-FPIUVV7Q.js → chunk-TBDJVYCB.js} +1 -1
  107. package/dist/standalone/{chunk-HFYFYNSX.js → chunk-TTD7BKB6.js} +1 -1
  108. package/dist/standalone/{chunk-KFNDET5D.js → chunk-UCK6ITED.js} +1 -1
  109. package/dist/standalone/{chunk-UZIBQZ2F.js → chunk-UKKZJRJT.js} +1 -1
  110. package/dist/standalone/{chunk-F5LTDUMB.js → chunk-V74BXQXC.js} +1 -1
  111. package/dist/standalone/{chunk-2ZO7XY3Z.js → chunk-VHMA6YPT.js} +1 -1
  112. package/dist/standalone/{chunk-SOO2HXV6.js → chunk-W4X4J7BU.js} +1 -1
  113. package/dist/standalone/{chunk-S7XAAH7U.js → chunk-W6ZKEW5M.js} +1 -1
  114. package/dist/standalone/{chunk-D7JK65OK.js → chunk-WIYDA4XT.js} +1 -1
  115. package/dist/standalone/{chunk-2X6O33OX.js → chunk-X7GSROPX.js} +1 -1
  116. package/dist/standalone/{chunk-O3FDK56W.js → chunk-Y7SN6CTX.js} +1 -1
  117. package/dist/standalone/{chunk-JGMQQ3S7.js → chunk-YRQHFMEY.js} +1 -1
  118. package/dist/standalone/{chunk-YJ2WHOGO.js → chunk-ZKPRORLI.js} +1 -1
  119. package/dist/standalone/{chunk-TWMS2TMF.js → chunk-ZLSNET6H.js} +1 -1
  120. package/dist/standalone/{chunk-CIVMATZK.js → chunk-ZM4K2ETZ.js} +1 -1
  121. package/dist/standalone/studio.js +1 -1
  122. package/package.json +5 -5
  123. package/dist/standalone/chunk-BHOLL76W.js +0 -8
  124. package/dist/standalone/chunk-GQYA5W5T.js +0 -1
  125. package/dist/standalone/chunk-U76DVXTR.js +0 -21
@@ -1 +1 @@
1
- import{a as Ze}from"./chunk-YJWR6ZWC.js";import{a as qe}from"./chunk-WIET27J3.js";import{a as Ke}from"./chunk-4IEMXFUB.js";import{a as He}from"./chunk-NMVFSJM7.js";import{a as L}from"./chunk-OUFWXYEF.js";import{a as Je}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as We}from"./chunk-SOO2HXV6.js";import{a as Xe}from"./chunk-6QEXGYWH.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{i as T}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as _}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as D}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as De}from"./chunk-YJ2WHOGO.js";import{p as Z}from"./chunk-U76DVXTR.js";import"./chunk-WZTY3ZYI.js";import{a as Ve}from"./chunk-3Y5K3IQO.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-CW57Q264.js";import{a as J,e as K}from"./chunk-MD67S53Z.js";import{f as Q,j as Ee,r as Ue,s as X,u as Qe,w as te}from"./chunk-LPINY2IJ.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-OXFKZ4BM.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||X($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let A;return e[30]!==r||e[31]!==I||e[32]!==m?(A=(0,t.jsx)(J,{children:(0,t.jsxs)(K,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=A):A=e[33],A},"it"),ot=s(()=>{let h=Z(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),X((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),X((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(J,{children:(0,t.jsx)(K,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=Z(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(S=>{w(S.target.value)},"p"),e[1]=f):f=e[1];let r=f,A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=s(S=>{I(S.target.value)},"S"),e[2]=A):A=e[2];let $=A,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(S=>{v(S.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(S=>{m(S.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((S,R)=>{N(ee=>({...ee,[S]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(S=>x[S.name]??(S.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,O;if(e[8]!==p.userFields||e[9]!==P){let S;e[11]!==P?(S=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=S):S=e[12],O=p.userFields.every(S),e[8]=p.userFields,e[9]=P,e[10]=O}else O=e[10];let F=O,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let S={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(S[R.name]=ee.value)}return Object.keys(S).length===0?void 0:S},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(L,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(L,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(L,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(L,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(S=>{let R=`uc-field-${S.name}`,ee=S.required?"":` (${a("optional")})`;if(S.type==="boolean"){let Le=P(S)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(S.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[S.name,ee]})]},S.name)}let Ge=P(S);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(L,{htmlFor:R,children:[S.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Le=>{V(S.name,Le.target.value)},"onChange"),type:ct[S.type],value:typeof Ge=="string"?Ge:""})]},S.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Oe=!$e,Se;e[84]!==i||e[85]!==a?(Se=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Se):Se=e[86];let Ae;e[87]!==Be||e[88]!==Oe||e[89]!==Se?(Ae=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Oe,onClick:Be,size:"sm",type:"button",children:Se}),e[87]=Be,e[88]=Oe,e[89]=Se,e[90]=Ae):Ae=e[90];let Fe;e[91]!==Ie||e[92]!==Ae?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Ae]}),e[91]=Ie,e[92]=Ae,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=Z(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{X((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=Z(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{X((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let A=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${A}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${A}`,disabled:n,onClick:s(()=>{v(A)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},A)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=Z(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&X((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(A=>{o(()=>i.deleteAuthPasskey({passkeyId:A}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(A=>{let $=Ue(A.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(A.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(A.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(L,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(L,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let A;e[21]!==i||e[22]!==g?(A=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=A):A=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==A?(j=(0,t.jsx)(T,{"aria-invalid":A,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=A,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(L,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let O;e[42]!==v||e[43]!==G||e[44]!==P?(O=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=O):O=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==O||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,O]}),e[46]=H,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=Z(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{X((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),A=s(F=>{d(F.target.value)},"S"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),O=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(J,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(K,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:A,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(L,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:O.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=Z(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
1
+ import{a as Ze}from"./chunk-YJWR6ZWC.js";import{a as qe}from"./chunk-DTW4E5AB.js";import{a as Ke}from"./chunk-4IEMXFUB.js";import{a as He}from"./chunk-NMVFSJM7.js";import{a as L}from"./chunk-OUFWXYEF.js";import{a as Je}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as We}from"./chunk-W4X4J7BU.js";import{a as Xe}from"./chunk-6QEXGYWH.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import{i as T}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as _}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as D}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as De}from"./chunk-ZKPRORLI.js";import{p as Z}from"./chunk-OIDFWEJX.js";import"./chunk-WZTY3ZYI.js";import{a as Ve}from"./chunk-3Y5K3IQO.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-CW57Q264.js";import{a as J,e as K}from"./chunk-MD67S53Z.js";import{f as Q,j as Ee,r as Ue,s as X,u as Qe,w as te}from"./chunk-LPINY2IJ.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-OXFKZ4BM.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||X($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let A;return e[30]!==r||e[31]!==I||e[32]!==m?(A=(0,t.jsx)(J,{children:(0,t.jsxs)(K,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=A):A=e[33],A},"it"),ot=s(()=>{let h=Z(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),X((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),X((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(J,{children:(0,t.jsx)(K,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=Z(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(S=>{w(S.target.value)},"p"),e[1]=f):f=e[1];let r=f,A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A=s(S=>{I(S.target.value)},"S"),e[2]=A):A=e[2];let $=A,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(S=>{v(S.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(S=>{m(S.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((S,R)=>{N(ee=>({...ee,[S]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(S=>x[S.name]??(S.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,O;if(e[8]!==p.userFields||e[9]!==P){let S;e[11]!==P?(S=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=S):S=e[12],O=p.userFields.every(S),e[8]=p.userFields,e[9]=P,e[10]=O}else O=e[10];let F=O,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let S={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(S[R.name]=ee.value)}return Object.keys(S).length===0?void 0:S},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(L,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(L,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(L,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(L,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(S=>{let R=`uc-field-${S.name}`,ee=S.required?"":` (${a("optional")})`;if(S.type==="boolean"){let Le=P(S)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(S.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[S.name,ee]})]},S.name)}let Ge=P(S);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(L,{htmlFor:R,children:[S.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Le=>{V(S.name,Le.target.value)},"onChange"),type:ct[S.type],value:typeof Ge=="string"?Ge:""})]},S.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Oe=!$e,Se;e[84]!==i||e[85]!==a?(Se=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Se):Se=e[86];let Ae;e[87]!==Be||e[88]!==Oe||e[89]!==Se?(Ae=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Oe,onClick:Be,size:"sm",type:"button",children:Se}),e[87]=Be,e[88]=Oe,e[89]=Se,e[90]=Ae):Ae=e[90];let Fe;e[91]!==Ie||e[92]!==Ae?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Ae]}),e[91]=Ie,e[92]=Ae,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=Z(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{X((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=Z(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{X((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let A=r;c(null),w(Ee(A))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let A=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${A}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${A}`,disabled:n,onClick:s(()=>{v(A)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},A)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=Z(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&X((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(A=>{o(()=>i.deleteAuthPasskey({passkeyId:A}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(A=>{let $=Ue(A.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(A.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(A.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(L,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(L,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let A;e[21]!==i||e[22]!==g?(A=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=A):A=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==A?(j=(0,t.jsx)(T,{"aria-invalid":A,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=A,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(L,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let O;e[42]!==v||e[43]!==G||e[44]!==P?(O=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=O):O=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==O||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,O]}),e[46]=H,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&&gt.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=Z(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{X((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),A=s(F=>{d(F.target.value)},"S"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),O=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(J,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(K,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(L,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:A,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(L,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:O.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=Z(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(J,{className:"overflow-hidden py-0",children:(0,t.jsx)(K,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
@@ -1 +1 @@
1
- import{b as be}from"./chunk-TDVDZ7XQ.js";import{a as le}from"./chunk-XWEDIIIT.js";import"./chunk-ZBFWT34B.js";import"./chunk-SYGCASPT.js";import{a as ve}from"./chunk-XBZUJDHD.js";import"./chunk-ZGSL4DPP.js";import{a as xe}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-ZTOREMGH.js";import"./chunk-IBJVVHV5.js";import{b as ee}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import"./chunk-E26OT26O.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as ge}from"./chunk-YJ2WHOGO.js";import{o as he,p as fe}from"./chunk-U76DVXTR.js";import"./chunk-WZTY3ZYI.js";import{a as W}from"./chunk-MD67S53Z.js";import{b as $,f as B,h as X,i as ie,j as ce,s as se,w as pe}from"./chunk-LPINY2IJ.js";import{a as h,d as Z,e as Ae,f as ue,g as me}from"./chunk-OXFKZ4BM.js";var te=Z(ue(),1),x=Z(Ae(),1);var Ne=Z(ue(),1);var ae=Z(me(),1);var je={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},ye=h(()=>{let t=(0,Ne.c)(18),e=B(),n=he(),r;e:switch(n){case"connected":{let l;t[0]!==e?(l=e("Connected"),t[0]=e,t[1]=l):l=t[1],r=l;break e}case"connecting":{let l;t[2]!==e?(l=e("Connecting\u2026"),t[2]=e,t[3]=l):l=t[3],r=l;break e}case"idle":{let l;t[4]!==e?(l=e("Idle"),t[4]=e,t[5]=l):l=t[5],r=l;break e}case"offline":{let l;t[6]!==e?(l=e("Offline"),t[6]=e,t[7]=l):l=t[7],r=l;break e}case"polling":{let l;t[8]!==e?(l=e("Polling"),t[8]=e,t[9]=l):l=t[9],r=l;break e}default:r=n}let a=je[n],c;t[10]!==a?(c=$("size-2 rounded-full",a),t[10]=a,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,ae.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==n||t[15]!==i||t[16]!==r?(o=(0,ae.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":n,"data-testid":"dash-connection",role:"status",children:[i,r]}),t[14]=n,t[15]=i,t[16]=r,t[17]=o):o=t[17],o},"T");var s=Z(me(),1);var Te={crit:"destructive",ok:"secondary",warn:"default"},oe=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"re"),de=h((t,e,n)=>Number.isNaN(t)?"ok":t>=n?"crit":t>=e?"warn":"ok","oe"),Se=.01,Ee=.05,Ce=h(t=>{let e=(0,te.c)(36),{errorCount:n,logsError:r,topErrors:a,worstFunctions:c}=t,i=B(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=(0,s.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=l):l=e[3];let u;e[4]!==i||e[5]!==c?(u=c.length===0?(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,s.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,s.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,s.jsx)(ee,{variant:Te[de(y.errors/y.calls,Se,Ee)],children:oe(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==u?(f=(0,s.jsxs)(W,{className:"gap-0 py-0","data-testid":"hl-functions",children:[l,u]}),e[7]=l,e[8]=u,e[9]=f):f=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let m;e[12]!==v?(m=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=m):m=e[13];let d=n>0?"destructive":"outline",g;e[14]!==n||e[15]!==d?(g=(0,s.jsx)(ee,{"data-testid":"hl-error-count",variant:d,children:n}),e[14]=n,e[15]=d,e[16]=g):g=e[16];let p;e[17]!==m||e[18]!==g?(p=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[m,g]}),e[17]=m,e[18]=g,e[19]=p):p=e[19];let S;e[20]!==r?(S=r!==null&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:r}),e[20]=r,e[21]=S):S=e[21];let E;e[22]!==r||e[23]!==i||e[24]!==a.length?(E=r===null&&a.length===0&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=r,e[23]=i,e[24]=a.length,e[25]=E):E=e[25];let q;e[26]!==a?(q=a.length>0&&(0,s.jsx)("ul",{className:"divide-y divide-border",children:a.map(Ie)}),e[26]=a,e[27]=q):q=e[27];let w;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==p?(w=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[p,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=p,e[32]=w):w=e[32];let k;return e[33]!==w||e[34]!==f?(k=(0,s.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[f,w]}),e[33]=w,e[34]=f,e[35]=k):k=e[35],k},"_e");function Ie(t,e){return(0,s.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("time",{className:"shrink-0 text-muted-foreground",children:pe(t.timestamp)}),t.functionPath!==void 0&&(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,s.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ie,"Ae");var we={completed:0,failed:2,in_progress:1},De=h(t=>{let e=0,n=0,r=0,a=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){a+=1;continue}r+=1,e+=o.requests,n+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:n,failed:a,history:i,historyTruncated:c,reachable:r,requests:e}},"ke"),_e=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.path);if(a===void 0){e.set(r.path,{...r});continue}a.calls+=r.calls,a.errors+=r.errors,a.totalDurationMs+=r.totalDurationMs,a.scans=(a.scans??0)+(r.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,r.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,r.lastCalledAt),(r.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=r.lastErrorAt,a.lastErrorMessage=r.lastErrorMessage)}return[...e.values()]},"Re"),Pe=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.id);if(a===void 0){e.set(r.id,r);continue}let c=we[r.status]-we[a.status];(c>0||c===0&&(r.updatedAt??0)>(a.updatedAt??0))&&e.set(r.id,r)}return[...e.values()]},"Me"),Le=X(U.getAuthMetrics),Fe=X(U.getFunctionStats),Re=X(U.getLogs),Oe=X(U.getMetrics),ze=X(U.migrationStatus),$e=5,ke=2e3,Ke=5,Be=.1,Ue=.3,Ge=1,He=50,Qe=h((t,e,n)=>t>=n?"crit":t>=e?"warn":"ok","$e"),Je=h(t=>{let e=new Map;for(let r of t??[]){let a=e.get(r.bucketMs)??{calls:0,errors:0};a.calls+=r.calls,a.errors+=r.errors,e.set(r.bucketMs,a)}let n=[...e.entries()].toSorted((r,a)=>r[0]-a[0]);return{errors:n.map(([,r])=>r.errors),requests:n.map(([,r])=>r.calls)}},"Be"),Ve=h(t=>{let e=0,n=0;for(let a of t)a.status==="failed"?e+=1:a.status==="in_progress"&&(n+=1);let r="ok";return e>0?r="crit":n>0&&(r="warn"),{failed:e,level:r,running:n}},"Ve"),We=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),qe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Me={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Xe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Ye=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","ze"),ne=h(t=>{let e=(0,te.c)(19),{chart:n,label:r,level:a,testId:c,value:i}=t,o=qe[a],l;e[0]!==o?(l=$("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==l?(u=(0,s.jsx)("span",{"aria-hidden":"true",className:l}),e[2]=l,e[3]=u):u=e[3];let f;e[4]!==r||e[5]!==u?(f=(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[u,r]}),e[4]=r,e[5]=u,e[6]=f):f=e[6];let v=Me[a],m;e[7]!==v?(m=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=m):m=e[8];let d;e[9]!==m||e[10]!==c||e[11]!==i?(d=(0,s.jsx)("span",{className:m,"data-testid":c,children:i}),e[9]=m,e[10]=c,e[11]=i,e[12]=d):d=e[12];let g;e[13]!==n||e[14]!==d?(g=(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[d,n]}),e[13]=n,e[14]=d,e[15]=g):g=e[15];let p;return e[16]!==f||e[17]!==g?(p=(0,s.jsx)(W,{className:"gap-0 py-0",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[f,g]})}),e[16]=f,e[17]=g,e[18]=p):p=e[18],p},"ee"),Ze=h(async(t,e,n)=>{let r=await Promise.all(n.map(m=>{let d=ie(m);return Promise.allSettled([t.query(Oe,{},d),t.query(Fe,{},d),t.query(ze,{},d)])})),a=ie(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,l]=await Promise.allSettled([t.query(Re,{},a),t.query(Le,{},a),c]),u=r.map(([m,d,g])=>({functions:d.status==="fulfilled"?d.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),f=De(u),v=r[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:_e(u.map(m=>m.functions)),logsError:i.status==="rejected"?ce(i.reason):null,metricsError:f.reachable===0&&v?.status==="rejected"?ce(v.reason):null,migrations:Pe(u.map(m=>m.migrations)),scheduler:l.status==="fulfilled"?l.value:null,totals:f}},"Qe"),et=h(t=>{let e=t?.history??[];return{attempts:e.map(n=>n.attempts),failures:e.map(n=>n.failures)}},"We"),tt=h((t,e)=>t==="crit"?{description:e("One or more service levels are breached."),label:e("Critical")}:t==="warn"?{description:e("Some service levels need attention."),label:e("Degraded")}:{description:e("All service levels are within target."),label:e("All systems healthy")},"Xe"),rt=h(t=>{let e=(0,te.c)(75),{errorLevel:n,liveError:r,metricsError:a,overall:c,requestSeries:i,totals:o}=t,l=B(),u;e[0]!==c||e[1]!==l?(u=tt(c,l),e[0]=c,e[1]=l,e[2]=u):u=e[2];let{description:f,label:v}=u,m=Xe[c],d;e[3]!==m?(d=$("flex size-10 shrink-0 items-center justify-center rounded-full",m),e[3]=m,e[4]=d):d=e[4];let g=qe[c],p;e[5]!==g?(p=$("size-3 rounded-full",g),e[5]=g,e[6]=p):p=e[6];let S;e[7]!==p?(S=(0,s.jsx)("span",{className:p}),e[7]=p,e[8]=S):S=e[8];let E;e[9]!==d||e[10]!==S?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:d,children:S}),e[9]=d,e[10]=S,e[11]=E):E=e[11];let q;e[12]!==v?(q=(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:v}),e[12]=v,e[13]=q):q=e[13];let w;e[14]!==f?(w=(0,s.jsx)("span",{className:"text-[13px] text-muted-foreground",children:f}),e[14]=f,e[15]=w):w=e[15];let k;e[16]!==q||e[17]!==w?(k=(0,s.jsxs)("div",{className:"grid leading-tight",children:[q,w]}),e[16]=q,e[17]=w,e[18]=k):k=e[18];let y;e[19]!==k||e[20]!==E?(y=(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[E,k]}),e[19]=k,e[20]=E,e[21]=y):y=e[21];let j;e[22]!==l?(j=l("Requests"),e[22]=l,e[23]=j):j=e[23];let M;e[24]!==j?(M=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:j}),e[24]=j,e[25]=M):M=e[25];let A;e[26]!==i||e[27]!==l?(A=i.length>=2&&(0,s.jsx)(le,{ariaLabel:l("Requests over time"),className:"h-6 w-20 text-foreground",series:i,testId:"hl-spark-requests"}),e[26]=i,e[27]=l,e[28]=A):A=e[28];let F=o?.requests??0,R;e[29]!==F?(R=F.toString(),e[29]=F,e[30]=R):R=e[30];let D;e[31]!==R?(D=(0,s.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:R}),e[31]=R,e[32]=D):D=e[32];let O;e[33]!==A||e[34]!==D?(O=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[A,D]}),e[33]=A,e[34]=D,e[35]=O):O=e[35];let _;e[36]!==M||e[37]!==O?(_=(0,s.jsxs)("div",{className:"text-end",children:[M,O]}),e[36]=M,e[37]=O,e[38]=_):_=e[38];let G;e[39]===Symbol.for("react.memo_cache_sentinel")?(G=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[39]=G):G=e[39];let T;e[40]!==l?(T=l("Error rate"),e[40]=l,e[41]=T):T=e[41];let P;e[42]!==T?(P=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[42]=T,e[43]=P):P=e[43];let Y=Me[n],C;e[44]!==Y?(C=$("text-lg font-semibold tabular-nums",Y),e[44]=Y,e[45]=C):C=e[45];let z;e[46]!==o?(z=o===null?"\u2014":oe(o.errors,o.requests),e[46]=o,e[47]=z):z=e[47];let I;e[48]!==C||e[49]!==z?(I=(0,s.jsx)("div",{className:C,"data-testid":"hl-error-rate",children:z}),e[48]=C,e[49]=z,e[50]=I):I=e[50];let L;e[51]!==P||e[52]!==I?(L=(0,s.jsxs)("div",{className:"text-end",children:[P,I]}),e[51]=P,e[52]=I,e[53]=L):L=e[53];let K;e[54]===Symbol.for("react.memo_cache_sentinel")?(K=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[54]=K):K=e[54];let H;e[55]===Symbol.for("react.memo_cache_sentinel")?(H=(0,s.jsx)(ye,{}),e[55]=H):H=e[55];let b;e[56]!==r?(b=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[H,(0,s.jsx)(ve,{message:r,prefix:"hl"})]}),e[56]=r,e[57]=b):b=e[57];let N;e[58]!==_||e[59]!==L||e[60]!==b?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[_,G,L,K,b]}),e[58]=_,e[59]=L,e[60]=b,e[61]=N):N=e[61];let Q;e[62]!==y||e[63]!==N?(Q=(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[y,N]}),e[62]=y,e[63]=N,e[64]=Q):Q=e[64];let J;e[65]!==a?(J=a!==null&&(0,s.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:a}),e[65]=a,e[66]=J):J=e[66];let V;e[67]!==a||e[68]!==l||e[69]!==o?.historyTruncated?(V=a===null&&o?.historyTruncated===!0&&(0,s.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:l("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")}),e[67]=a,e[68]=l,e[69]=o?.historyTruncated,e[70]=V):V=e[70];let re;return e[71]!==Q||e[72]!==J||e[73]!==V?(re=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[Q,J,V]}),e[71]=Q,e[72]=J,e[73]=V,e[74]=re):re=e[74],re},"Je"),st=h(t=>{let e=(0,te.c)(14),{shards:n}=t,r=B(),a;e[0]!==r?(a=r("Shards seen"),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==a?(c=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[2]=a,e[3]=c):c=e[3];let i;e[4]!==n.length?(i=(0,s.jsx)(ee,{"data-testid":"hl-shard-count",variant:"outline",children:n.length}),e[4]=n.length,e[5]=i):i=e[5];let o;e[6]!==c||e[7]!==i?(o=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[c,i]}),e[6]=c,e[7]=i,e[8]=o):o=e[8];let l;e[9]!==n?(l=n.length>0&&(0,s.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:n.map(lt)}),e[9]=n,e[10]=l):l=e[10];let u;return e[11]!==o||e[12]!==l?(u=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[o,l]}),e[11]=o,e[12]=l,e[13]=u):u=e[13],u},"Ye"),kt=h(({initialShardKey:t})=>{let e=fe(),n=B(),[r,a]=(0,x.useState)([]),[c,i]=(0,x.useState)(null),[o,l]=(0,x.useState)(null),[u,f]=(0,x.useState)(null),[v,m]=(0,x.useState)([]),[d,g]=(0,x.useState)(null),[p,S]=(0,x.useState)(null),[E,q]=(0,x.useState)([]),[w]=(0,x.useState)(xe),k=(0,x.useRef)(!1),y=(0,x.useRef)(0),j=(0,x.useRef)(0),M=(0,x.useRef)(null),A=t??"",F=(0,x.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=y.current,N=await Ze(e,A,be(A,w));b===y.current&&(l(N.totals),f(N.metricsError),m(N.functions),q(N.migrations),a(N.entries),i(N.logsError),g(N.auth),S(N.scheduler),k.current=!1)},[e,w,A]);(0,x.useEffect)(()=>(se(F()),()=>{y.current+=1,k.current=!1,M.current!==null&&(clearTimeout(M.current),M.current=null)}),[F]);let R=h(()=>{let b=Date.now()-j.current;if(b>=ke){j.current=Date.now(),se(F());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,j.current=Date.now(),se(F())},ke-b))},"j"),{data:D,liveError:O}=ge(U.getMetrics,{},{live:!0,shardKey:A});(0,x.useEffect)(()=>{D!==void 0&&R()},[D]);let _=r.filter(b=>b.level==="error"),G=_.slice(0,$e),T=Je(o?.history),P=et(d),Y=v.filter(b=>b.calls>0).toSorted((b,N)=>N.errors/N.calls-b.errors/b.calls||N.calls-b.calls).slice(0,Ke),C=Ve(E),z=o===null||o.requests===0?0:o.errors/o.requests,I=de(z,Se,Ee),L=d===null?"ok":de(d.failureRate,Be,Ue),K=p===null?"ok":Qe(p.backlog,Ge,He),H=Ye([I,L,K,C.level]);return(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,s.jsx)(rt,{errorLevel:I,liveError:O,metricsError:u,overall:H,requestSeries:T.requests,totals:o}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,s.jsx)(ne,{chart:T.errors.length>=2?(0,s.jsx)(le,{ariaLabel:n("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:n("Error rate"),level:I,testId:"hl-slo-errorrate",value:o===null?"\u2014":oe(o.errors,o.requests)}),(0,s.jsx)(ne,{chart:P.failures.length>=2?(0,s.jsx)(le,{ariaLabel:n("Auth failures over time"),className:"h-7 w-20 text-destructive",series:P.failures,testId:"hl-spark-auth"}):void 0,label:n("Auth failures"),level:L,testId:"hl-slo-auth",value:d===null?"\u2014":oe(d.failures,d.attempts)}),(0,s.jsx)(ne,{label:n("Scheduler backlog"),level:K,testId:"hl-slo-backlog",value:p===null?"\u2014":p.backlog.toString()}),(0,s.jsx)(ne,{label:n("Migrations"),level:C.level,testId:"hl-slo-migrations",value:We(C,n)})]}),(0,s.jsx)(Ce,{errorCount:_.length,logsError:c,topErrors:G,worstFunctions:Y}),(0,s.jsx)(st,{shards:w})]})},"gt");function lt(t){return(0,s.jsx)("li",{"data-testid":"hl-shard",children:(0,s.jsx)(ee,{variant:"secondary",children:t})},t)}h(lt,"Ze");export{kt as HealthPanel};
1
+ import{b as be}from"./chunk-TDVDZ7XQ.js";import{a as le}from"./chunk-453GHHZ4.js";import"./chunk-BTOOJXUL.js";import"./chunk-SYGCASPT.js";import{a as ve}from"./chunk-XBZUJDHD.js";import"./chunk-ZGSL4DPP.js";import{a as xe}from"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import"./chunk-ZTOREMGH.js";import"./chunk-IBJVVHV5.js";import{b as ee}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import"./chunk-E26OT26O.js";import{a as U}from"./chunk-6UTZXEW3.js";import{c as ge}from"./chunk-ZKPRORLI.js";import{o as he,p as fe}from"./chunk-OIDFWEJX.js";import"./chunk-WZTY3ZYI.js";import{a as W}from"./chunk-MD67S53Z.js";import{b as $,f as B,h as X,i as ie,j as ce,s as se,w as pe}from"./chunk-LPINY2IJ.js";import{a as h,d as Z,e as Ae,f as ue,g as me}from"./chunk-OXFKZ4BM.js";var te=Z(ue(),1),x=Z(Ae(),1);var Ne=Z(ue(),1);var ae=Z(me(),1);var je={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},ye=h(()=>{let t=(0,Ne.c)(18),e=B(),n=he(),r;e:switch(n){case"connected":{let l;t[0]!==e?(l=e("Connected"),t[0]=e,t[1]=l):l=t[1],r=l;break e}case"connecting":{let l;t[2]!==e?(l=e("Connecting\u2026"),t[2]=e,t[3]=l):l=t[3],r=l;break e}case"idle":{let l;t[4]!==e?(l=e("Idle"),t[4]=e,t[5]=l):l=t[5],r=l;break e}case"offline":{let l;t[6]!==e?(l=e("Offline"),t[6]=e,t[7]=l):l=t[7],r=l;break e}case"polling":{let l;t[8]!==e?(l=e("Polling"),t[8]=e,t[9]=l):l=t[9],r=l;break e}default:r=n}let a=je[n],c;t[10]!==a?(c=$("size-2 rounded-full",a),t[10]=a,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,ae.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==n||t[15]!==i||t[16]!==r?(o=(0,ae.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":n,"data-testid":"dash-connection",role:"status",children:[i,r]}),t[14]=n,t[15]=i,t[16]=r,t[17]=o):o=t[17],o},"T");var s=Z(me(),1);var Te={crit:"destructive",ok:"secondary",warn:"default"},oe=h((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"re"),de=h((t,e,n)=>Number.isNaN(t)?"ok":t>=n?"crit":t>=e?"warn":"ok","oe"),Se=.01,Ee=.05,Ce=h(t=>{let e=(0,te.c)(36),{errorCount:n,logsError:r,topErrors:a,worstFunctions:c}=t,i=B(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let l;e[2]!==o?(l=(0,s.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=l):l=e[3];let u;e[4]!==i||e[5]!==c?(u=c.length===0?(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,s.jsx)("ul",{className:"divide-y divide-border",children:c.map(y=>(0,s.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:y.path}),(0,s.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,s.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:y.calls.toString()})}),(0,s.jsx)(ee,{variant:Te[de(y.errors/y.calls,Se,Ee)],children:oe(y.errors,y.calls)})]})]},y.path))}),e[4]=i,e[5]=c,e[6]=u):u=e[6];let f;e[7]!==l||e[8]!==u?(f=(0,s.jsxs)(W,{className:"gap-0 py-0","data-testid":"hl-functions",children:[l,u]}),e[7]=l,e[8]=u,e[9]=f):f=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let m;e[12]!==v?(m=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=m):m=e[13];let d=n>0?"destructive":"outline",g;e[14]!==n||e[15]!==d?(g=(0,s.jsx)(ee,{"data-testid":"hl-error-count",variant:d,children:n}),e[14]=n,e[15]=d,e[16]=g):g=e[16];let p;e[17]!==m||e[18]!==g?(p=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[m,g]}),e[17]=m,e[18]=g,e[19]=p):p=e[19];let S;e[20]!==r?(S=r!==null&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:r}),e[20]=r,e[21]=S):S=e[21];let E;e[22]!==r||e[23]!==i||e[24]!==a.length?(E=r===null&&a.length===0&&(0,s.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=r,e[23]=i,e[24]=a.length,e[25]=E):E=e[25];let q;e[26]!==a?(q=a.length>0&&(0,s.jsx)("ul",{className:"divide-y divide-border",children:a.map(Ie)}),e[26]=a,e[27]=q):q=e[27];let w;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==p?(w=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[p,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=p,e[32]=w):w=e[32];let k;return e[33]!==w||e[34]!==f?(k=(0,s.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[f,w]}),e[33]=w,e[34]=f,e[35]=k):k=e[35],k},"_e");function Ie(t,e){return(0,s.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,s.jsxs)("span",{className:"flex items-center gap-2",children:[(0,s.jsx)("time",{className:"shrink-0 text-muted-foreground",children:pe(t.timestamp)}),t.functionPath!==void 0&&(0,s.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,s.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}h(Ie,"Ae");var we={completed:0,failed:2,in_progress:1},De=h(t=>{let e=0,n=0,r=0,a=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){a+=1;continue}r+=1,e+=o.requests,n+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:n,failed:a,history:i,historyTruncated:c,reachable:r,requests:e}},"ke"),_e=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.path);if(a===void 0){e.set(r.path,{...r});continue}a.calls+=r.calls,a.errors+=r.errors,a.totalDurationMs+=r.totalDurationMs,a.scans=(a.scans??0)+(r.scans??0),a.maxDurationMs=Math.max(a.maxDurationMs,r.maxDurationMs),a.lastCalledAt=Math.max(a.lastCalledAt,r.lastCalledAt),(r.lastErrorAt??0)>(a.lastErrorAt??0)&&(a.lastErrorAt=r.lastErrorAt,a.lastErrorMessage=r.lastErrorMessage)}return[...e.values()]},"Re"),Pe=h(t=>{let e=new Map;for(let n of t)for(let r of n){let a=e.get(r.id);if(a===void 0){e.set(r.id,r);continue}let c=we[r.status]-we[a.status];(c>0||c===0&&(r.updatedAt??0)>(a.updatedAt??0))&&e.set(r.id,r)}return[...e.values()]},"Me"),Le=X(U.getAuthMetrics),Fe=X(U.getFunctionStats),Re=X(U.getLogs),Oe=X(U.getMetrics),ze=X(U.migrationStatus),$e=5,ke=2e3,Ke=5,Be=.1,Ue=.3,Ge=1,He=50,Qe=h((t,e,n)=>t>=n?"crit":t>=e?"warn":"ok","$e"),Je=h(t=>{let e=new Map;for(let r of t??[]){let a=e.get(r.bucketMs)??{calls:0,errors:0};a.calls+=r.calls,a.errors+=r.errors,e.set(r.bucketMs,a)}let n=[...e.entries()].toSorted((r,a)=>r[0]-a[0]);return{errors:n.map(([,r])=>r.errors),requests:n.map(([,r])=>r.calls)}},"Be"),Ve=h(t=>{let e=0,n=0;for(let a of t)a.status==="failed"?e+=1:a.status==="in_progress"&&(n+=1);let r="ok";return e>0?r="crit":n>0&&(r="warn"),{failed:e,level:r,running:n}},"Ve"),We=h((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"He"),qe={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Me={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Xe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},Ye=h(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","ze"),ne=h(t=>{let e=(0,te.c)(19),{chart:n,label:r,level:a,testId:c,value:i}=t,o=qe[a],l;e[0]!==o?(l=$("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=l):l=e[1];let u;e[2]!==l?(u=(0,s.jsx)("span",{"aria-hidden":"true",className:l}),e[2]=l,e[3]=u):u=e[3];let f;e[4]!==r||e[5]!==u?(f=(0,s.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[u,r]}),e[4]=r,e[5]=u,e[6]=f):f=e[6];let v=Me[a],m;e[7]!==v?(m=$("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=m):m=e[8];let d;e[9]!==m||e[10]!==c||e[11]!==i?(d=(0,s.jsx)("span",{className:m,"data-testid":c,children:i}),e[9]=m,e[10]=c,e[11]=i,e[12]=d):d=e[12];let g;e[13]!==n||e[14]!==d?(g=(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[d,n]}),e[13]=n,e[14]=d,e[15]=g):g=e[15];let p;return e[16]!==f||e[17]!==g?(p=(0,s.jsx)(W,{className:"gap-0 py-0",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[f,g]})}),e[16]=f,e[17]=g,e[18]=p):p=e[18],p},"ee"),Ze=h(async(t,e,n)=>{let r=await Promise.all(n.map(m=>{let d=ie(m);return Promise.allSettled([t.query(Oe,{},d),t.query(Fe,{},d),t.query(ze,{},d)])})),a=ie(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,l]=await Promise.allSettled([t.query(Re,{},a),t.query(Le,{},a),c]),u=r.map(([m,d,g])=>({functions:d.status==="fulfilled"?d.value.functions:[],metrics:m.status==="fulfilled"?m.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),f=De(u),v=r[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:_e(u.map(m=>m.functions)),logsError:i.status==="rejected"?ce(i.reason):null,metricsError:f.reachable===0&&v?.status==="rejected"?ce(v.reason):null,migrations:Pe(u.map(m=>m.migrations)),scheduler:l.status==="fulfilled"?l.value:null,totals:f}},"Qe"),et=h(t=>{let e=t?.history??[];return{attempts:e.map(n=>n.attempts),failures:e.map(n=>n.failures)}},"We"),tt=h((t,e)=>t==="crit"?{description:e("One or more service levels are breached."),label:e("Critical")}:t==="warn"?{description:e("Some service levels need attention."),label:e("Degraded")}:{description:e("All service levels are within target."),label:e("All systems healthy")},"Xe"),rt=h(t=>{let e=(0,te.c)(75),{errorLevel:n,liveError:r,metricsError:a,overall:c,requestSeries:i,totals:o}=t,l=B(),u;e[0]!==c||e[1]!==l?(u=tt(c,l),e[0]=c,e[1]=l,e[2]=u):u=e[2];let{description:f,label:v}=u,m=Xe[c],d;e[3]!==m?(d=$("flex size-10 shrink-0 items-center justify-center rounded-full",m),e[3]=m,e[4]=d):d=e[4];let g=qe[c],p;e[5]!==g?(p=$("size-3 rounded-full",g),e[5]=g,e[6]=p):p=e[6];let S;e[7]!==p?(S=(0,s.jsx)("span",{className:p}),e[7]=p,e[8]=S):S=e[8];let E;e[9]!==d||e[10]!==S?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:d,children:S}),e[9]=d,e[10]=S,e[11]=E):E=e[11];let q;e[12]!==v?(q=(0,s.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:v}),e[12]=v,e[13]=q):q=e[13];let w;e[14]!==f?(w=(0,s.jsx)("span",{className:"text-[13px] text-muted-foreground",children:f}),e[14]=f,e[15]=w):w=e[15];let k;e[16]!==q||e[17]!==w?(k=(0,s.jsxs)("div",{className:"grid leading-tight",children:[q,w]}),e[16]=q,e[17]=w,e[18]=k):k=e[18];let y;e[19]!==k||e[20]!==E?(y=(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[E,k]}),e[19]=k,e[20]=E,e[21]=y):y=e[21];let j;e[22]!==l?(j=l("Requests"),e[22]=l,e[23]=j):j=e[23];let M;e[24]!==j?(M=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:j}),e[24]=j,e[25]=M):M=e[25];let A;e[26]!==i||e[27]!==l?(A=i.length>=2&&(0,s.jsx)(le,{ariaLabel:l("Requests over time"),className:"h-6 w-20 text-foreground",series:i,testId:"hl-spark-requests"}),e[26]=i,e[27]=l,e[28]=A):A=e[28];let F=o?.requests??0,R;e[29]!==F?(R=F.toString(),e[29]=F,e[30]=R):R=e[30];let D;e[31]!==R?(D=(0,s.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:R}),e[31]=R,e[32]=D):D=e[32];let O;e[33]!==A||e[34]!==D?(O=(0,s.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[A,D]}),e[33]=A,e[34]=D,e[35]=O):O=e[35];let _;e[36]!==M||e[37]!==O?(_=(0,s.jsxs)("div",{className:"text-end",children:[M,O]}),e[36]=M,e[37]=O,e[38]=_):_=e[38];let G;e[39]===Symbol.for("react.memo_cache_sentinel")?(G=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[39]=G):G=e[39];let T;e[40]!==l?(T=l("Error rate"),e[40]=l,e[41]=T):T=e[41];let P;e[42]!==T?(P=(0,s.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[42]=T,e[43]=P):P=e[43];let Y=Me[n],C;e[44]!==Y?(C=$("text-lg font-semibold tabular-nums",Y),e[44]=Y,e[45]=C):C=e[45];let z;e[46]!==o?(z=o===null?"\u2014":oe(o.errors,o.requests),e[46]=o,e[47]=z):z=e[47];let I;e[48]!==C||e[49]!==z?(I=(0,s.jsx)("div",{className:C,"data-testid":"hl-error-rate",children:z}),e[48]=C,e[49]=z,e[50]=I):I=e[50];let L;e[51]!==P||e[52]!==I?(L=(0,s.jsxs)("div",{className:"text-end",children:[P,I]}),e[51]=P,e[52]=I,e[53]=L):L=e[53];let K;e[54]===Symbol.for("react.memo_cache_sentinel")?(K=(0,s.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),e[54]=K):K=e[54];let H;e[55]===Symbol.for("react.memo_cache_sentinel")?(H=(0,s.jsx)(ye,{}),e[55]=H):H=e[55];let b;e[56]!==r?(b=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[H,(0,s.jsx)(ve,{message:r,prefix:"hl"})]}),e[56]=r,e[57]=b):b=e[57];let N;e[58]!==_||e[59]!==L||e[60]!==b?(N=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[_,G,L,K,b]}),e[58]=_,e[59]=L,e[60]=b,e[61]=N):N=e[61];let Q;e[62]!==y||e[63]!==N?(Q=(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[y,N]}),e[62]=y,e[63]=N,e[64]=Q):Q=e[64];let J;e[65]!==a?(J=a!==null&&(0,s.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:a}),e[65]=a,e[66]=J):J=e[66];let V;e[67]!==a||e[68]!==l||e[69]!==o?.historyTruncated?(V=a===null&&o?.historyTruncated===!0&&(0,s.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:l("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")}),e[67]=a,e[68]=l,e[69]=o?.historyTruncated,e[70]=V):V=e[70];let re;return e[71]!==Q||e[72]!==J||e[73]!==V?(re=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[Q,J,V]}),e[71]=Q,e[72]=J,e[73]=V,e[74]=re):re=e[74],re},"Je"),st=h(t=>{let e=(0,te.c)(14),{shards:n}=t,r=B(),a;e[0]!==r?(a=r("Shards seen"),e[0]=r,e[1]=a):a=e[1];let c;e[2]!==a?(c=(0,s.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a}),e[2]=a,e[3]=c):c=e[3];let i;e[4]!==n.length?(i=(0,s.jsx)(ee,{"data-testid":"hl-shard-count",variant:"outline",children:n.length}),e[4]=n.length,e[5]=i):i=e[5];let o;e[6]!==c||e[7]!==i?(o=(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[c,i]}),e[6]=c,e[7]=i,e[8]=o):o=e[8];let l;e[9]!==n?(l=n.length>0&&(0,s.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:n.map(lt)}),e[9]=n,e[10]=l):l=e[10];let u;return e[11]!==o||e[12]!==l?(u=(0,s.jsxs)(W,{className:"gap-0 py-0",children:[o,l]}),e[11]=o,e[12]=l,e[13]=u):u=e[13],u},"Ye"),kt=h(({initialShardKey:t})=>{let e=fe(),n=B(),[r,a]=(0,x.useState)([]),[c,i]=(0,x.useState)(null),[o,l]=(0,x.useState)(null),[u,f]=(0,x.useState)(null),[v,m]=(0,x.useState)([]),[d,g]=(0,x.useState)(null),[p,S]=(0,x.useState)(null),[E,q]=(0,x.useState)([]),[w]=(0,x.useState)(xe),k=(0,x.useRef)(!1),y=(0,x.useRef)(0),j=(0,x.useRef)(0),M=(0,x.useRef)(null),A=t??"",F=(0,x.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=y.current,N=await Ze(e,A,be(A,w));b===y.current&&(l(N.totals),f(N.metricsError),m(N.functions),q(N.migrations),a(N.entries),i(N.logsError),g(N.auth),S(N.scheduler),k.current=!1)},[e,w,A]);(0,x.useEffect)(()=>(se(F()),()=>{y.current+=1,k.current=!1,M.current!==null&&(clearTimeout(M.current),M.current=null)}),[F]);let R=h(()=>{let b=Date.now()-j.current;if(b>=ke){j.current=Date.now(),se(F());return}M.current===null&&(M.current=setTimeout(()=>{M.current=null,j.current=Date.now(),se(F())},ke-b))},"j"),{data:D,liveError:O}=ge(U.getMetrics,{},{live:!0,shardKey:A});(0,x.useEffect)(()=>{D!==void 0&&R()},[D]);let _=r.filter(b=>b.level==="error"),G=_.slice(0,$e),T=Je(o?.history),P=et(d),Y=v.filter(b=>b.calls>0).toSorted((b,N)=>N.errors/N.calls-b.errors/b.calls||N.calls-b.calls).slice(0,Ke),C=Ve(E),z=o===null||o.requests===0?0:o.errors/o.requests,I=de(z,Se,Ee),L=d===null?"ok":de(d.failureRate,Be,Ue),K=p===null?"ok":Qe(p.backlog,Ge,He),H=Ye([I,L,K,C.level]);return(0,s.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,s.jsx)(rt,{errorLevel:I,liveError:O,metricsError:u,overall:H,requestSeries:T.requests,totals:o}),(0,s.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,s.jsx)(ne,{chart:T.errors.length>=2?(0,s.jsx)(le,{ariaLabel:n("Errors over time"),className:"h-7 w-20 text-destructive",series:T.errors,testId:"hl-spark-errors"}):void 0,label:n("Error rate"),level:I,testId:"hl-slo-errorrate",value:o===null?"\u2014":oe(o.errors,o.requests)}),(0,s.jsx)(ne,{chart:P.failures.length>=2?(0,s.jsx)(le,{ariaLabel:n("Auth failures over time"),className:"h-7 w-20 text-destructive",series:P.failures,testId:"hl-spark-auth"}):void 0,label:n("Auth failures"),level:L,testId:"hl-slo-auth",value:d===null?"\u2014":oe(d.failures,d.attempts)}),(0,s.jsx)(ne,{label:n("Scheduler backlog"),level:K,testId:"hl-slo-backlog",value:p===null?"\u2014":p.backlog.toString()}),(0,s.jsx)(ne,{label:n("Migrations"),level:C.level,testId:"hl-slo-migrations",value:We(C,n)})]}),(0,s.jsx)(Ce,{errorCount:_.length,logsError:c,topErrors:G,worstFunctions:Y}),(0,s.jsx)(st,{shards:w})]})},"gt");function lt(t){return(0,s.jsx)("li",{"data-testid":"hl-shard",children:(0,s.jsx)(ee,{variant:"secondary",children:t})},t)}h(lt,"Ze");export{kt as HealthPanel};