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

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 (66) hide show
  1. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  2. package/dist/standalone/{chunk-RJJRUUTE.js → chunk-24N5RZRI.js} +1 -1
  3. package/dist/standalone/{chunk-KIQ34774.js → chunk-2G7JHC6S.js} +1 -1
  4. package/dist/standalone/{chunk-OJR7BDKC.js → chunk-2QYMVMYR.js} +1 -1
  5. package/dist/standalone/{chunk-OWCTA7GY.js → chunk-3IGIBOCF.js} +1 -1
  6. package/dist/standalone/{chunk-L6VJTINV.js → chunk-3K56NZDT.js} +1 -1
  7. package/dist/standalone/{chunk-NFI2TNKU.js → chunk-4RII5S3H.js} +1 -1
  8. package/dist/standalone/{chunk-I6YVDNKQ.js → chunk-4YWFAODW.js} +1 -1
  9. package/dist/standalone/{chunk-ZP453BM4.js → chunk-4ZEERXMN.js} +1 -1
  10. package/dist/standalone/{chunk-LRUYEVHH.js → chunk-6C555TU5.js} +1 -1
  11. package/dist/standalone/{chunk-CO6R6GCX.js → chunk-73D52JHL.js} +1 -1
  12. package/dist/standalone/{chunk-HCK62XWB.js → chunk-7Z5MTBZB.js} +1 -1
  13. package/dist/standalone/{chunk-UFS6UP4Z.js → chunk-B3GOYA2R.js} +1 -1
  14. package/dist/standalone/{chunk-SGIEXE5J.js → chunk-BBJJJI7F.js} +1 -1
  15. package/dist/standalone/{chunk-2CDROYSG.js → chunk-BULGXI7X.js} +1 -1
  16. package/dist/standalone/chunk-C6FOSG2A.js +7 -0
  17. package/dist/standalone/{chunk-BU5VWXRR.js → chunk-CDJMXV45.js} +1 -1
  18. package/dist/standalone/{chunk-OQTMT64P.js → chunk-DRFBJBEN.js} +1 -1
  19. package/dist/standalone/{chunk-6K4F727K.js → chunk-E7QYOQWH.js} +1 -1
  20. package/dist/standalone/{chunk-CY45AO5T.js → chunk-EAYN3IGE.js} +1 -1
  21. package/dist/standalone/{chunk-AXDXIMCN.js → chunk-EGUFPKS4.js} +1 -1
  22. package/dist/standalone/{chunk-7ASIMMZY.js → chunk-EHU26D2V.js} +1 -1
  23. package/dist/standalone/{chunk-HJOXP6C3.js → chunk-FGHKL42J.js} +1 -1
  24. package/dist/standalone/{chunk-JZN3MNJX.js → chunk-FKF2BRRN.js} +1 -1
  25. package/dist/standalone/{chunk-AXB32N5O.js → chunk-FR22DHUN.js} +1 -1
  26. package/dist/standalone/{chunk-DZV6YFWZ.js → chunk-GERWUNAM.js} +1 -1
  27. package/dist/standalone/{chunk-BRPLE2Z6.js → chunk-GTJYJW4A.js} +1 -1
  28. package/dist/standalone/{chunk-QTWNCDLK.js → chunk-H54J65DJ.js} +1 -1
  29. package/dist/standalone/{chunk-U7NVTULW.js → chunk-HB6ABGZU.js} +1 -1
  30. package/dist/standalone/{chunk-ZADOHFZB.js → chunk-HQZ7B5EU.js} +1 -1
  31. package/dist/standalone/{chunk-BWBECJFT.js → chunk-I2XT2POX.js} +1 -1
  32. package/dist/standalone/chunk-IPDJJHZK.js +1 -0
  33. package/dist/standalone/{chunk-WEPANQGT.js → chunk-KRSQ6N4R.js} +1 -1
  34. package/dist/standalone/{chunk-V4B7ZPEG.js → chunk-KYZZGUIG.js} +1 -1
  35. package/dist/standalone/{chunk-Y2AKO63C.js → chunk-KZXAVLQ4.js} +1 -1
  36. package/dist/standalone/{chunk-PBXRUYD3.js → chunk-LIZUJ6AU.js} +1 -1
  37. package/dist/standalone/{chunk-KGQPMSNY.js → chunk-LQWEU5ZI.js} +1 -1
  38. package/dist/standalone/{chunk-EKXAE4PS.js → chunk-MAWEZEX6.js} +1 -1
  39. package/dist/standalone/{chunk-L7TFQUD7.js → chunk-MKH4V2DR.js} +1 -1
  40. package/dist/standalone/{chunk-2YDK4MZM.js → chunk-NMZ34D2Z.js} +1 -1
  41. package/dist/standalone/{chunk-4YVCKOYF.js → chunk-NNKVZBKP.js} +1 -1
  42. package/dist/standalone/{chunk-2M37OAK3.js → chunk-NTVQ4PWU.js} +1 -1
  43. package/dist/standalone/{chunk-HUL247LG.js → chunk-OG7AJWFV.js} +1 -1
  44. package/dist/standalone/{chunk-HLBZ7OAO.js → chunk-PPC2ESMI.js} +1 -1
  45. package/dist/standalone/{chunk-KZXSJF7K.js → chunk-PTL32GA6.js} +1 -1
  46. package/dist/standalone/{chunk-5EIGSLIK.js → chunk-Q6VRHDZJ.js} +1 -1
  47. package/dist/standalone/{chunk-3OVQC66W.js → chunk-QJFCK6J4.js} +1 -1
  48. package/dist/standalone/{chunk-ELPLRD4S.js → chunk-SKK6PGQ3.js} +1 -1
  49. package/dist/standalone/{chunk-3YCWRKSW.js → chunk-SKMAKUOG.js} +1 -1
  50. package/dist/standalone/{chunk-NP6CBOPK.js → chunk-SQ3M7JDP.js} +1 -1
  51. package/dist/standalone/{chunk-375GZTYC.js → chunk-TS4CMM2L.js} +1 -1
  52. package/dist/standalone/{chunk-CVJDEN5L.js → chunk-UYW53K2N.js} +1 -1
  53. package/dist/standalone/{chunk-LYWT6GTX.js → chunk-VJGP3BTD.js} +1 -1
  54. package/dist/standalone/{chunk-FYAUOSTX.js → chunk-W6UUGZH7.js} +1 -1
  55. package/dist/standalone/{chunk-P3ML7HGE.js → chunk-WLMTK3FN.js} +1 -1
  56. package/dist/standalone/{chunk-AQG5OGO4.js → chunk-WMKSIEJP.js} +1 -1
  57. package/dist/standalone/{chunk-CXXCVBMK.js → chunk-WODOEE2A.js} +1 -1
  58. package/dist/standalone/{chunk-U5UEDY4E.js → chunk-Y34WXKCA.js} +1 -1
  59. package/dist/standalone/{chunk-2OSZRVNW.js → chunk-YDFZA3T4.js} +1 -1
  60. package/dist/standalone/{chunk-IXCSVK2Z.js → chunk-Z3AINTU6.js} +1 -1
  61. package/dist/standalone/{chunk-ERUKFS3I.js → chunk-ZLAVM2NT.js} +1 -1
  62. package/dist/standalone/{chunk-4MFQ4XEJ.js → chunk-ZQ7KYIN6.js} +1 -1
  63. package/dist/standalone/studio.js +1 -1
  64. package/package.json +3 -3
  65. package/dist/standalone/chunk-K5W5C237.js +0 -1
  66. package/dist/standalone/chunk-QFN62JQJ.js +0 -7
@@ -1 +1 @@
1
- import{a as qe}from"./chunk-5EIGSLIK.js";import{a as Je}from"./chunk-O66HDCZT.js";import{a as Ge}from"./chunk-APCHI5CD.js";import{a as Ze}from"./chunk-ATBPQT7F.js";import"./chunk-WXZ334CL.js";import{a as He}from"./chunk-UL5XVKGR.js";import{a as W}from"./chunk-MNN3YCKF.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-ERUKFS3I.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-HMMALUXM.js";import{b as X}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-ZJIYJZ6F.js";import{b as je}from"./chunk-LRUYEVHH.js";import{a as ie,e as ne}from"./chunk-XV2XEUUB.js";import{n as le}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.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},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((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"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");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)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((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}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.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},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=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:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{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]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));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)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"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)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,P])=>(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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{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.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
1
+ import{a as qe}from"./chunk-Q6VRHDZJ.js";import{a as Je}from"./chunk-O66HDCZT.js";import{a as Ge}from"./chunk-APCHI5CD.js";import{a as Ze}from"./chunk-ATBPQT7F.js";import"./chunk-WXZ334CL.js";import{a as He}from"./chunk-UL5XVKGR.js";import{a as W}from"./chunk-MNN3YCKF.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-ZLAVM2NT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-HMMALUXM.js";import{b as X}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-ZJIYJZ6F.js";import{b as je}from"./chunk-6C555TU5.js";import{a as ie,e as ne}from"./chunk-XV2XEUUB.js";import{n as le}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.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},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((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"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");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)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((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}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.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},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=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:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{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]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));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)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"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)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,P])=>(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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{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.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
@@ -1 +1 @@
1
- import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-JZN3MNJX.js";import"./chunk-EYSF4DHD.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-ZJIYJZ6F.js";import"./chunk-ELPLRD4S.js";import"./chunk-NFI2TNKU.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-LRUYEVHH.js";import{a as le,e as oe}from"./chunk-XV2XEUUB.js";import{n as Ae}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
1
+ import{b as Ke}from"./chunk-R6NJ4ER6.js";import{a as Ie,b as De,c as Oe}from"./chunk-AFLNQEZ5.js";import{a as Ee}from"./chunk-W5BTAOHO.js";import"./chunk-4KPATTV6.js";import{i as we}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as ke}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{b as _e}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as je}from"./chunk-FKF2BRRN.js";import"./chunk-EYSF4DHD.js";import{a as Se,b as Te,c as Ce,d as ie,e as M,f as W}from"./chunk-ZJIYJZ6F.js";import"./chunk-SKK6PGQ3.js";import"./chunk-4RII5S3H.js";import"./chunk-EOFWXI3T.js";import{a as ve}from"./chunk-LYVYUTQY.js";import{c as ye}from"./chunk-6C555TU5.js";import{a as le,e as oe}from"./chunk-XV2XEUUB.js";import{n as Ae}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as xe,j as pe,s as he,w as fe}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as ze}from"./chunk-A6TVTNKO.js";import{a as Ue,b as Pe}from"./chunk-ADABTCDI.js";import{a as b,d as Ne}from"./chunk-5PEAXTYQ.js";var ce=Ne(ze(),1);var I=Ne(Ue(),1);var a=Ne(Pe(),1);var Le=["disabled","schema","schema_and_log","schema_and_log_and_data"],$e={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},Be=864e5,qe=b(()=>{let t=(0,ce.c)(67),e=Ae(),r=xe(),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],t[0]=n):n=t[0];let g;t[1]!==e?(g={owner:e,tokens:n},t[1]=e,t[2]=g):g=t[2];let[h,N]=(0,I.useState)(g),x=h.owner===e?h.tokens:[],[c,m]=(0,I.useState)(null),[p,o]=(0,I.useState)(null);p!==null&&p.owner!==e&&o(null);let d=p?.owner===e?p.token:null,[l,i]=(0,I.useState)(""),[s,u]=(0,I.useState)(""),[_,k]=(0,I.useState)(null),D=_===e,v=(0,I.useRef)(0),w=(0,I.useRef)(e),O,j;t[3]!==e?(O=b(()=>{w.current=e},"D"),j=[e],t[3]=e,t[4]=O,t[5]=j):(O=t[4],j=t[5]),(0,I.useEffect)(O,j);let K;t[6]!==e?(K=b(async()=>{if(w.current!==e)return;v.current=v.current+1;let f=v.current;try{let E=await e.listAdminTokens();f===v.current&&(N({owner:e,tokens:E}),m(null))}catch(E){let de=E;f===v.current&&m(pe(de))}},"L"),t[6]=e,t[7]=K):K=t[7];let y=K,L,R;t[8]!==y?(L=b(()=>{he(y())},"O"),R=[y],t[8]=y,t[9]=L,t[10]=R):(L=t[9],R=t[10]),(0,I.useEffect)(L,R);let U;t[11]!==e||t[12]!==d||t[13]!==D||t[14]!==s||t[15]!==l||t[16]!==y?(U=b(f=>{if(f.preventDefault(),D||d!==null)return;k(e);let E=e,de=s===""?void 0:Date.now()+Number(s)*Be;he((async()=>{try{let se=await E.createAdminToken({expiresAt:de,name:l.trim()});w.current===E&&(o({owner:E,token:se}),i(""),u(""),await y())}catch(se){m(pe(se))}k(se=>se===E?null:se)})())},"K"),t[11]=e,t[12]=d,t[13]=D,t[14]=s,t[15]=l,t[16]=y,t[17]=U):U=t[17];let B=U,H=b(f=>{he((async()=>{try{await e.revokeAdminToken(f),o(E=>E?.token.name===f?null:E),await y()}catch(E){let de=E;await y(),w.current===e&&m(pe(de))}})())},"q"),q=le,G="py-0",J="set-admin-tokens",S;t[18]!==r?(S=r("Admin tokens"),t[18]=r,t[19]=S):S=t[19];let T;t[20]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),t[20]=S,t[21]=T):T=t[21];let F=oe,Q="flex flex-col gap-3 py-3",C;t[22]!==r?(C=r("Named tokens use the admin API but cannot manage tokens or open admin WebSockets. A revoked token is refused within 30 seconds."),t[22]=r,t[23]=C):C=t[23];let z;t[24]!==C?(z=(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:C}),t[24]=C,t[25]=z):z=t[25];let V;t[26]!==c?(V=c!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"set-admin-tokens-error",role:"alert",children:c}),t[26]=c,t[27]=V):V=t[27];let P;t[28]!==d||t[29]!==r?(P=d!==null&&(0,a.jsxs)("div",{className:"rounded-md border border-border p-3 text-xs","data-testid":"set-admin-token-created",role:"status",children:[(0,a.jsx)("p",{className:"pb-1 text-muted-foreground",children:r("Copy this token now. It is not shown again.")}),(0,a.jsx)("code",{className:"font-mono break-all select-all",children:d.token}),(0,a.jsx)("div",{className:"pt-2",children:(0,a.jsx)(ke,{"data-testid":"set-admin-token-dismiss",onClick:b(()=>{o(null)},"onClick"),size:"xs",variant:"outline",children:r("Dismiss")})})]}),t[28]=d,t[29]=r,t[30]=P):P=t[30];let A;t[31]!==r?(A=r("Token name"),t[31]=r,t[32]=A):A=t[32];let $;t[33]===Symbol.for("react.memo_cache_sentinel")?($=b(f=>{i(f.target.value)},"B"),t[33]=$):$=t[33];let X;t[34]!==l||t[35]!==A?(X=(0,a.jsx)(we,{"aria-label":A,className:"w-48","data-testid":"set-admin-token-name",onChange:$,pattern:"[a-z0-9][a-z0-9_\\-]{0,63}",placeholder:"ci-deploy",required:!0,value:l}),t[34]=l,t[35]=A,t[36]=X):X=t[36];let Y;t[37]!==r?(Y=r("Expires in days (optional)"),t[37]=r,t[38]=Y):Y=t[38];let me;t[39]===Symbol.for("react.memo_cache_sentinel")?(me=b(f=>{u(f.target.value)},"de"),t[39]=me):me=t[39];let Z;t[40]!==r?(Z=r("Expires in days (optional)"),t[40]=r,t[41]=Z):Z=t[41];let ee;t[42]!==s||t[43]!==Y||t[44]!==Z?(ee=(0,a.jsx)(we,{"aria-label":Y,className:"w-40",min:1,onChange:me,placeholder:Z,type:"number",value:s}),t[42]=s,t[43]=Y,t[44]=Z,t[45]=ee):ee=t[45];let be=D||d!==null,te;t[46]!==r?(te=r("Create token"),t[46]=r,t[47]=te):te=t[47];let ae;t[48]!==be||t[49]!==te?(ae=(0,a.jsx)(ke,{"data-testid":"set-admin-token-create",disabled:be,size:"sm",type:"submit",children:te}),t[48]=be,t[49]=te,t[50]=ae):ae=t[50];let ne;t[51]!==B||t[52]!==X||t[53]!==ee||t[54]!==ae?(ne=(0,a.jsxs)("form",{className:"flex flex-wrap items-end gap-2",onSubmit:B,children:[X,ee,ae]}),t[51]=B,t[52]=X,t[53]=ee,t[54]=ae,t[55]=ne):ne=t[55];let ge=x.length>0&&(0,a.jsxs)(Se,{"data-testid":"set-admin-tokens-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:r("name")}),(0,a.jsx)(M,{children:r("Created")}),(0,a.jsx)(M,{children:r("Last used")}),(0,a.jsx)(M,{children:r("Expires")}),(0,a.jsx)(M,{})]})}),(0,a.jsx)(Ce,{children:x.map(f=>(0,a.jsxs)(ie,{"data-testid":"set-admin-token-row",children:[(0,a.jsxs)(W,{className:"font-mono text-xs",children:[f.name,f.revoked===!0&&(0,a.jsx)("span",{className:"pl-2 text-destructive",children:r("Revoked")})]}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.createdAt)}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.lastUsedAt,"\u2014")}),(0,a.jsx)(W,{className:"text-xs",children:fe(f.expiresAt,r("Never"))}),(0,a.jsx)(W,{children:(0,a.jsx)(Ee,{onConfirm:b(()=>{H(f.name)},"onConfirm"),testId:`set-admin-token-revoke-${f.name}`,children:r("Revoke")})})]},f.name))})]}),re;t[56]!==F||t[57]!==z||t[58]!==V||t[59]!==P||t[60]!==ne||t[61]!==ge?(re=(0,a.jsxs)(F,{className:Q,children:[z,V,P,ne,ge]}),t[56]=F,t[57]=z,t[58]=V,t[59]=P,t[60]=ne,t[61]=ge,t[62]=re):re=t[62];let ue;return t[63]!==q||t[64]!==T||t[65]!==re?(ue=(0,a.jsxs)(q,{className:G,"data-testid":J,children:[T,re]}),t[63]=q,t[64]=T,t[65]=re,t[66]=ue):ue=t[66],ue},"Fe"),Fe={binding:"outline",secret:"destructive",var:"secondary"},Ve=b((t,e)=>{if(t===void 0)return[];let r=[];return t.workerUrl!==void 0&&r.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&r.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&r.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&r.push({label:e("Version"),value:t.versionTag}),r},"Pe"),Me={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},We=b(t=>{let e=[];for(let[r,n]of Object.entries($e))n===t&&e.push(r);return e},"qe"),He=b(()=>{let t=(0,ce.c)(29),e=xe(),r,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},n={shardKey:""},t[0]=r,t[1]=n):(r=t[0],n=t[1]);let{data:g}=ye(ve.aiAvailable,r,n),h=g?.level,N;t[2]!==h?(N=h===void 0?-1:Le.indexOf(h),t[2]=h,t[3]=N):N=t[3];let x=N,c;t[4]!==e?(c=e("AI assistant data sharing"),t[4]=e,t[5]=c):c=t[5];let m;t[6]!==c?(m=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c}),t[6]=c,t[7]=m):m=t[7];let p;t[8]!==h?(p=h!==void 0&&(0,a.jsx)(_e,{"data-testid":"set-ai-level",variant:h==="disabled"?"outline":"secondary",children:h}),t[8]=h,t[9]=p):p=t[9];let o;t[10]!==m||t[11]!==p?(o=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[m,p]}),t[10]=m,t[11]=p,t[12]=o):o=t[12];let d;t[13]!==x||t[14]!==h||t[15]!==e?(d=Le.map((k,D)=>{let v=x>=D,w=We(k);return(0,a.jsxs)("li",{className:v?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(v),"data-testid":`set-ai-tier-${k}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:k}),k===h&&(0,a.jsx)("span",{className:"text-[11px] text-primary",children:e("current")})]}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:e(Me[k])}),w.length>0&&(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:w.join(", ")})]},k)}),t[13]=x,t[14]=h,t[15]=e,t[16]=d):d=t[16];let l;t[17]!==d?(l=(0,a.jsx)("ul",{className:"flex flex-col gap-1.5 text-sm",children:d}),t[17]=d,t[18]=l):l=t[18];let i;t[19]!==e?(i=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=i):i=t[20];let s;t[21]!==i?(s=(0,a.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:i}),t[21]=i,t[22]=s):s=t[22];let u;t[23]!==s||t[24]!==l?(u=(0,a.jsxs)(oe,{className:"flex flex-col gap-3 py-3",children:[l,s]}),t[23]=s,t[24]=l,t[25]=u):u=t[25];let _;return t[26]!==u||t[27]!==o?(_=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-ai-sharing",children:[o,u]}),t[26]=u,t[27]=o,t[28]=_):_=t[28],_},"ze"),Re=b(t=>{let e=(0,ce.c)(18),{modifier:r,name:n,label:g}=t,h=Ie(),N;e[0]!==n?(N=b(u=>{if(!["Escape","Tab"].includes(u.key)){if(u.shiftKey){u.preventDefault();return}u.preventDefault(),De(n,u.key)}},"N"),e[0]=n,e[1]=N):N=e[1];let x=N,c=`set-shortcut-${n}`,m;e[2]!==g?(m=(0,a.jsx)("dt",{className:"text-muted-foreground",children:g}),e[2]=g,e[3]=m):m=e[3];let p;e[4]!==r?(p=(0,a.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:r}),e[4]=r,e[5]=p):p=e[5];let o=`set-shortcut-input-${n}`,d=h[n],l;e[6]!==g||e[7]!==x||e[8]!==o||e[9]!==d?(l=(0,a.jsx)("input",{"aria-label":g,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":o,onKeyDown:x,readOnly:!0,value:d}),e[6]=g,e[7]=x,e[8]=o,e[9]=d,e[10]=l):l=e[10];let i;e[11]!==p||e[12]!==l?(i=(0,a.jsxs)("dd",{className:"flex items-center gap-1.5",children:[p,l]}),e[11]=p,e[12]=l,e[13]=i):i=e[13];let s;return e[14]!==c||e[15]!==m||e[16]!==i?(s=(0,a.jsxs)("div",{className:"contents","data-testid":c,children:[m,i]}),e[14]=c,e[15]=m,e[16]=i,e[17]=s):s=e[17],s},"we"),ct=b(t=>{let e=(0,ce.c)(87),{initialShardKey:r}=t,n=xe(),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let h=r??"",N;e[1]!==h?(N={shardKey:h},e[1]=h,e[2]=N):N=e[2];let{data:x,error:c,errorSource:m,isLoading:p}=ye(ve.getSettings,g,N),o,d,l,i,s,u,_;if(e[3]!==c||e[4]!==m||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==n){let V=Ve(x?.deploy,n),P;e[15]!==x?.settings?(P=x?.settings??[],e[15]=x?.settings,e[16]=P):P=e[16],o=P,d="flex flex-col gap-4",l="lunora-settings";let A;e[17]!==n?(A=n("Open in Cloudflare"),e[17]=n,e[18]=A):A=e[18],e[19]!==A?(i=(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,a.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:Ke,rel:"noreferrer",target:"_blank",children:A})}),e[19]=A,e[20]=i):i=e[20];let $;e[21]!==n?($=n("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=$):$=e[22],e[23]!==$?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=s):s=e[24],e[25]!==c||e[26]!==m?(u=c!==null&&(0,a.jsx)(je,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=u):u=e[27],_=V.length>0&&(0,a.jsxs)(le,{className:"py-0","data-testid":"set-deploy",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),(0,a.jsx)(oe,{className:"py-3",children:(0,a.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:V.map(Ge)})})]}),e[3]=c,e[4]=m,e[5]=x?.deploy,e[6]=x?.settings,e[7]=n,e[8]=o,e[9]=d,e[10]=l,e[11]=i,e[12]=s,e[13]=u,e[14]=_}else o=e[8],d=e[9],l=e[10],i=e[11],s=e[12],u=e[13],_=e[14];let k,D;e[28]===Symbol.for("react.memo_cache_sentinel")?(k=(0,a.jsx)(He,{}),D=(0,a.jsx)(qe,{}),e[28]=k,e[29]=D):(k=e[28],D=e[29]);let v;e[30]!==n?(v=n("Keyboard shortcuts"),e[30]=n,e[31]=v):v=e[31];let w;e[32]!==v?(w=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[32]=v,e[33]=w):w=e[33];let O;e[34]!==n?(O=n("Reset"),e[34]=n,e[35]=O):O=e[35];let j;e[36]!==O?(j=(0,a.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:Oe,type:"button",children:O}),e[36]=O,e[37]=j):j=e[37];let K;e[38]!==w||e[39]!==j?(K=(0,a.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[w,j]}),e[38]=w,e[39]=j,e[40]=K):K=e[40];let y;e[41]!==n?(y=n("Command palette"),e[41]=n,e[42]=y):y=e[42];let L;e[43]!==y?(L=(0,a.jsx)(Re,{label:y,modifier:"\u2318/Ctrl",name:"palette"}),e[43]=y,e[44]=L):L=e[44];let R;e[45]!==n?(R=n("Operation console"),e[45]=n,e[46]=R):R=e[46];let U;e[47]!==R?(U=(0,a.jsx)(Re,{label:R,modifier:"Ctrl",name:"console"}),e[47]=R,e[48]=U):U=e[48];let B;e[49]!==L||e[50]!==U?(B=(0,a.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[L,U]}),e[49]=L,e[50]=U,e[51]=B):B=e[51];let H;e[52]!==n?(H=n("Stored in this browser. Focus a box and press a key to rebind it."),e[52]=n,e[53]=H):H=e[53];let q;e[54]!==H?(q=(0,a.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:H}),e[54]=H,e[55]=q):q=e[55];let G;e[56]!==B||e[57]!==q?(G=(0,a.jsxs)(oe,{className:"py-3",children:[B,q]}),e[56]=B,e[57]=q,e[58]=G):G=e[58];let J;e[59]!==K||e[60]!==G?(J=(0,a.jsxs)(le,{className:"py-0","data-testid":"set-preferences",children:[K,G]}),e[59]=K,e[60]=G,e[61]=J):J=e[61];let S;e[62]!==n?(S=n("Environment & bindings"),e[62]=n,e[63]=S):S=e[63];let T;e[64]!==S?(T=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S})}),e[64]=S,e[65]=T):T=e[65];let F;e[66]!==c||e[67]!==p||e[68]!==o.length||e[69]!==n?(F=c===null&&!p&&o.length===0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[66]=c,e[67]=p,e[68]=o.length,e[69]=n,e[70]=F):F=e[70];let Q;e[71]!==o||e[72]!==n?(Q=o.length>0&&(0,a.jsx)(oe,{className:"px-0 py-0",children:(0,a.jsxs)(Se,{"data-testid":"set-table",children:[(0,a.jsx)(Te,{children:(0,a.jsxs)(ie,{children:[(0,a.jsx)(M,{children:n("name")}),(0,a.jsx)(M,{children:n("kind")}),(0,a.jsx)(M,{children:n("value")})]})}),(0,a.jsx)(Ce,{children:o.map(Je)})]})}),e[71]=o,e[72]=n,e[73]=Q):Q=e[73];let C;e[74]!==T||e[75]!==F||e[76]!==Q?(C=(0,a.jsxs)(le,{className:"py-0",children:[T,F,Q]}),e[74]=T,e[75]=F,e[76]=Q,e[77]=C):C=e[77];let z;return e[78]!==J||e[79]!==C||e[80]!==d||e[81]!==l||e[82]!==i||e[83]!==s||e[84]!==u||e[85]!==_?(z=(0,a.jsxs)("div",{className:d,"data-testid":l,children:[i,s,u,_,k,D,J,C]}),e[78]=J,e[79]=C,e[80]=d,e[81]=l,e[82]=i,e[83]=s,e[84]=u,e[85]=_,e[86]=z):z=e[86],z},"ft");function Ge(t){return(0,a.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,a.jsx)("dt",{className:"text-muted-foreground",children:t.label}),(0,a.jsx)("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}b(Ge,"He");function Je(t){return(0,a.jsxs)(ie,{"data-testid":"set-row",children:[(0,a.jsx)(W,{className:"font-mono text-xs font-medium",children:t.name}),(0,a.jsx)(W,{children:(0,a.jsx)(_e,{variant:Fe[t.kind],children:t.bindingType??t.kind})}),(0,a.jsx)(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??(0,a.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},t.name)}b(Je,"We");export{ct as SettingsPanel};
@@ -1 +1 @@
1
- import{g as j,h as g,i as D,n as q}from"./chunk-QFN62JQJ.js";import{h as v,i as S,j as P,s as w}from"./chunk-2ZJJH4YN.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
1
+ import{g as j,h as g,i as D,n as q}from"./chunk-C6FOSG2A.js";import{h as v,i as S,j as P,s as w}from"./chunk-2ZJJH4YN.js";import{a as M}from"./chunk-A6TVTNKO.js";import{a as L}from"./chunk-ADABTCDI.js";import{a as i,d as A}from"./chunk-5PEAXTYQ.js";var E=A(M(),1);var p=A(L(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"c"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"u"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,O=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"E"),_=i((t,r)=>[...t,r],"g");function W(t,r,e={}){let s=q(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=_(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{w(o.refetch())},"refetch"),poll:i(async()=>{await o.refetch({throwOnError:!0})},"poll")}}i(W,"F");function Y(t,r,e={}){let s=q(),n=g(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=O(t,r,o),C=W(m,()=>s.query(v(t),r,S(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),Q=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),x=s.subscribe(v(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(_(m,s.clientIdentifier()),h)},{...S(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),x()}},[s,Q,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=g(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:O(s,n,a??"");w(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
@@ -1 +1 @@
1
- import{a as je}from"./chunk-O66HDCZT.js";import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-JQBVRWFN.js";import"./chunk-T7UKRA6J.js";import{a as qe}from"./chunk-NAGIOR23.js";import"./chunk-QF743FSL.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ze}from"./chunk-2KTN53PK.js";import{a as _e}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as le}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Ee}from"./chunk-HMMALUXM.js";import{b as me}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Re,c as Ve,d as pe,e as B,f as L}from"./chunk-ZJIYJZ6F.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as Ce}from"./chunk-LRUYEVHH.js";import{a as Ke,e as Te}from"./chunk-XV2XEUUB.js";import{n as be}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as ue,e as Se,f as $e,h as ie,i as Ne,j as ke,s as re,w as Me}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Ge}from"./chunk-A6TVTNKO.js";import{a as Oe,b as He}from"./chunk-ADABTCDI.js";import{a as d,d as ye}from"./chunk-5PEAXTYQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Ie="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=ie(U.resolveIssue),Xe=ie(U.ignoreIssue),Fe=ie(U.assignIssue),Ye=ie(U.setIssueSeverity),Ze=ie(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=be(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=je(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},S=await i.query(Ze,g,Ne($));o(S)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Se(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(le,{"data-testid":b,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=z,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let I;return e[41]!==c||e[42]!==E?(I=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=I):I=e[43],I},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Ie?null:ae;re(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let I=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let S;e[33]!==s.status||e[34]!==I||e[35]!==g?(S=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":I,variant:g,children:s.status})}),e[33]=s.status,e[34]=I,e[35]=g,e[36]=S):S=e[36];let V=s.severity??Ie,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,j;e[39]!==a?(j=a("\u2014"),e[39]=a,e[40]=j):j=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==j||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:j,children:N}),e[44]=j,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Ie,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==z||e[58]!==V||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(L,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:z,value:V,children:[q,D]})}),e[56]=u,e[57]=z,e[58]=V,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(Ae,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Me(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(le,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(le,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(le,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==S||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,S,F,H,J,Q,ee]}),e[103]=c,e[104]=S,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=be(),{queryShardKey:i,setShardKey:l,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ce(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,j)=>{z(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...j,hash:r},Ne(i))}catch(N){let C=ke(N);z(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"v"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let I;e[27]!==x?(I=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=I):I=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(le,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let S;e[32]!==g?(S=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=S):S=e[33];let V;e[34]!==S||e[35]!==c||e[36]!==I?(V=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,I,S]}),e[34]=S,e[35]=c,e[36]=I,e[37]=V):V=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,V,M&&y.length===0?(0,t.jsx)(Ee,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Ke,{className:"overflow-hidden py-0",children:(0,t.jsx)(Te,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Ve,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
1
+ import{a as je}from"./chunk-O66HDCZT.js";import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-JQBVRWFN.js";import"./chunk-T7UKRA6J.js";import{a as qe}from"./chunk-NAGIOR23.js";import"./chunk-QF743FSL.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{a as ze}from"./chunk-2KTN53PK.js";import{a as _e}from"./chunk-YLC2ZYCL.js";import"./chunk-EDL46BPM.js";import"./chunk-4KPATTV6.js";import"./chunk-N7FOBAV3.js";import{i as Ae}from"./chunk-2D4WBSDO.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as le}from"./chunk-CBTPJPCZ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Ee}from"./chunk-HMMALUXM.js";import{b as me}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as Le,b as Re,c as Ve,d as pe,e as B,f as L}from"./chunk-ZJIYJZ6F.js";import"./chunk-EOFWXI3T.js";import{a as U}from"./chunk-LYVYUTQY.js";import{c as Ce}from"./chunk-6C555TU5.js";import{a as Ke,e as Te}from"./chunk-XV2XEUUB.js";import{n as be}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as ue,e as Se,f as $e,h as ie,i as Ne,j as ke,s as re,w as Me}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as Ge}from"./chunk-A6TVTNKO.js";import{a as Oe,b as He}from"./chunk-ADABTCDI.js";import{a as d,d as ye}from"./chunk-5PEAXTYQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Ie="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=ie(U.resolveIssue),Xe=ie(U.ignoreIssue),Fe=ie(U.assignIssue),Ye=ie(U.setIssueSeverity),Ze=ie(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=be(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=je(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},S=await i.query(Ze,g,Ne($));o(S)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let z=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Se(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==z||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(le,{"data-testid":b,disabled:_,onClick:z,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=z,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(L,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let I;return e[41]!==c||e[42]!==E?(I=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=I):I=e[43],I},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Ie?null:ae;re(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let z=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();re(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(L,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let I=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let S;e[33]!==s.status||e[34]!==I||e[35]!==g?(S=(0,t.jsx)(L,{children:(0,t.jsx)(me,{"data-testid":I,variant:g,children:s.status})}),e[33]=s.status,e[34]=I,e[35]=g,e[36]=S):S=e[36];let V=s.severity??Ie,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,j;e[39]!==a?(j=a("\u2014"),e[39]=a,e[40]=j):j=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==j||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:j,children:N}),e[44]=j,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Ie,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==z||e[58]!==V||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(L,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:z,value:V,children:[q,D]})}),e[56]=u,e[57]=z,e[58]=V,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(L,{children:(0,t.jsx)(Ae,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Me(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(L,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(le,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(le,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(le,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{re(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(L,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==S||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,S,F,H,J,Q,ee]}),e[103]=c,e[104]=S,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=be(),{queryShardKey:i,setShardKey:l,shardKey:a}=ze(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,z]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ce(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,j)=>{z(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...j,hash:r},Ne(i))}catch(N){let C=ke(N);z(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"v"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let I;e[27]!==x?(I=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=I):I=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(le,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let S;e[32]!==g?(S=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=S):S=e[33];let V;e[34]!==S||e[35]!==c||e[36]!==I?(V=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,I,S]}),e[34]=S,e[35]=c,e[36]=I,e[37]=V):V=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,V,M&&y.length===0?(0,t.jsx)(Ee,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Ke,{className:"overflow-hidden py-0",children:(0,t.jsx)(Te,{className:"px-0",children:(0,t.jsxs)(Le,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(Ve,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-Y5QMX4YG.js";import{a as ne}from"./chunk-HMMALUXM.js";import{b as Z}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as O}from"./chunk-XV2XEUUB.js";import{i as se,n as X}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as re,w as le,x as Y}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as ce}from"./chunk-A6TVTNKO.js";import{b as me}from"./chunk-ADABTCDI.js";import{a as k,d as ae}from"./chunk-5PEAXTYQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Ie=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=re(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let _=oe?.ok??!1,G=_?"ok":"crit",j,H,I,x,N,v,S,V,b,P;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==_||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);H="flex flex-col gap-6",I="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let T;e[58]!==t?(T=t("Checked"),e[58]=t,e[59]=T):T=e[59];let $;e[60]!==T?($=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[60]=T,e[61]=$):$=e[61];let q;e[62]!==l.timestamp?(q=le(l.timestamp),e[62]=l.timestamp,e[63]=q):q=e[63];let B;e[64]!==q?(B=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:q}),e[64]=q,e[65]=B):B=e[65];let E;e[66]!==$||e[67]!==B?(E=(0,a.jsxs)("div",{className:"text-end",children:[$,B]}),e[66]=$,e[67]=B,e[68]=E):E=e[68],e[69]!==D||e[70]!==E?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,E]})}),e[69]=D,e[70]=E,e[71]=N):N=e[71];let L;e[72]!==t?(L=t("Liveness"),e[72]=t,e[73]=L):L=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==L?(R=(0,a.jsx)(ie,{label:L,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=L,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==_||e[81]!==t?(A=t(_?"Ready":"Not ready"),e[80]=_,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],j=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],P=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=_,e[34]=u,e[35]=t,e[36]=j,e[37]=H,e[38]=I,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=P}else j=e[36],H=e[37],I=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],P=e[45];let z;e[94]!==j||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==P?(z=(0,a.jsxs)(j,{className:S,"data-testid":V,children:[b,P]}),e[94]=j,e[95]=S,e[96]=V,e[97]=b,e[98]=P,e[99]=z):z=e[99];let M;return e[100]!==H||e[101]!==I||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[x,N,v,z]}),e[100]=H,e[101]=I,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"_e");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Ie as DeploymentHealthPanel};
1
+ import{a as ee}from"./chunk-Y5QMX4YG.js";import{a as ne}from"./chunk-HMMALUXM.js";import{b as Z}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as O}from"./chunk-XV2XEUUB.js";import{i as se,n as X}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as re,w as le,x as Y}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as ce}from"./chunk-A6TVTNKO.js";import{b as me}from"./chunk-ADABTCDI.js";import{a as k,d as ae}from"./chunk-5PEAXTYQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Ie=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=re(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(ne,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let _=oe?.ok??!1,G=_?"ok":"crit",j,H,I,x,N,v,S,V,b,P;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==_||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);H="flex flex-col gap-6",I="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let T;e[58]!==t?(T=t("Checked"),e[58]=t,e[59]=T):T=e[59];let $;e[60]!==T?($=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:T}),e[60]=T,e[61]=$):$=e[61];let q;e[62]!==l.timestamp?(q=le(l.timestamp),e[62]=l.timestamp,e[63]=q):q=e[63];let B;e[64]!==q?(B=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:q}),e[64]=q,e[65]=B):B=e[65];let E;e[66]!==$||e[67]!==B?(E=(0,a.jsxs)("div",{className:"text-end",children:[$,B]}),e[66]=$,e[67]=B,e[68]=E):E=e[68],e[69]!==D||e[70]!==E?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,E]})}),e[69]=D,e[70]=E,e[71]=N):N=e[71];let L;e[72]!==t?(L=t("Liveness"),e[72]=t,e[73]=L):L=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==L?(R=(0,a.jsx)(ie,{label:L,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=L,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==_||e[81]!==t?(A=t(_?"Ready":"Not ready"),e[80]=_,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],j=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],P=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=_,e[34]=u,e[35]=t,e[36]=j,e[37]=H,e[38]=I,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=P}else j=e[36],H=e[37],I=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],P=e[45];let z;e[94]!==j||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==P?(z=(0,a.jsxs)(j,{className:S,"data-testid":V,children:[b,P]}),e[94]=j,e[95]=S,e[96]=V,e[97]=b,e[98]=P,e[99]=z):z=e[99];let M;return e[100]!==H||e[101]!==I||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:H,"data-testid":I,children:[x,N,v,z]}),e[100]=H,e[101]=I,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"_e");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Ie as DeploymentHealthPanel};
@@ -1 +1 @@
1
- import{a as le,d as ae,e as ke,i as Ne,j as we,l as Se}from"./chunk-CP3LCFFM.js";import"./chunk-Y2YLTUMD.js";import"./chunk-CQDENTSP.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as ye}from"./chunk-FKAOFBS3.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import{a as ne}from"./chunk-Y5QMX4YG.js";import"./chunk-2NUCBQFU.js";import{i as ue}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as re}from"./chunk-HMMALUXM.js";import{b as oe}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-ZJIYJZ6F.js";import{a as pe,e as ge}from"./chunk-XV2XEUUB.js";import{n as fe}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as Y,s as me,x as he}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as qe}from"./chunk-A6TVTNKO.js";import{a as Ae,b as je}from"./chunk-ADABTCDI.js";import{a as c,d as te}from"./chunk-5PEAXTYQ.js";var z=te(qe(),1);var E=te(Ae(),1);var o=te(je(),1);var Le=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let a of r.nodes)(e===void 0||H(a)===e)&&t.add(a.id);if(e===void 0)return t;let l=new Set(t);for(let a of r.edges)d.has(a.kind)&&(t.has(a.from)&&l.add(a.to),t.has(a.to)&&l.add(a.from));return l},"Pe"),Ee=c((r,e,d,t)=>{let l=`lane:${r}`;return[{data:{label:e},id:l,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((a,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${a.detail??a.kind} \xB7 ${a.name}`,link:Pe(a)},extent:"parent",id:a.id,parentId:l,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let n of r.nodes)d.has(n.id)&&t.set(H(n),[...t.get(H(n))??[],n]);let l=[...r.modules.map(n=>({label:n.installed===!0?`${n.name} \xB7 ${e.componentLabel}`:n.name,lane:n.name})),{label:e.appLaneLabel,lane:Q}],a=[],i=0;for(let{label:n,lane:f}of l){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(a.push(...Ee(f,n,i,m)),i+=1)}let u=[];for(let n of r.edges)e.kinds.has(n.kind)&&d.has(n.from)&&d.has(n.to)&&u.push({animated:Me.has(n.kind),id:`${n.from}|${n.kind}|${n.to}`,label:n.kind,labelBgStyle:Fe,labelStyle:De,source:n.from,style:Be,target:n.to,type:"smoothstep"});return{edges:u,nodes:a}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),l;return e[0]!==t?(l=(0,o.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1],l},"qe"),Ie={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=ue(),{label:l,link:a}=d,i;e[0]!==a||e[1]!==t?(i=c(()=>{me(t(a))},"u"),e[0]=a,e[1]=t,e[2]=i):i=e[2];let u=i,n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(ae,{isConnectable:!1,position:le.Left,style:Ie,type:"target"}),e[3]=n):n=e[3];let f;e[4]!==l||e[5]!==u?(f=(0,o.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:l}),e[4]=l,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)(ae,{isConnectable:!1,position:le.Right,style:Ie,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,o.jsxs)(o.Fragment,{children:[n,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),l,a,i,u,n,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");n=j(Q),u=pe,p="overflow-hidden py-0",i=ge,s="px-0",a=be,m="architecture-catalog";let I;e[13]!==t?(I=t("Module"),e[13]=t,e[14]=I):I=e[14];let L;e[15]!==I?(L=(0,o.jsx)(T,{children:I}),e[15]=I,e[16]=L):L=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,o.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,o.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,o.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==L||e[32]!==q?(h=(0,o.jsx)(xe,{children:(0,o.jsxs)(J,{children:[L,q,y,N]})}),e[29]=y,e[30]=N,e[31]=L,e[32]=q,e[33]=h):h=e[33],l=ve,f=d.modules.map(g=>(0,o.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,o.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,o.jsx)(oe,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,o.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,o.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=l,e[4]=a,e[5]=i,e[6]=u,e[7]=n,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else l=e[3],a=e[4],i=e[5],u=e[6],n=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==n||e[35]!==t?(b=n>0&&(0,o.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,o.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs",children:n})]}),e[34]=n,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==l||e[38]!==f||e[39]!==b?(x=(0,o.jsxs)(l,{children:[f,b]}),e[37]=l,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==a||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,o.jsxs)(a,{"data-testid":m,children:[h,x]}),e[41]=a,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,o.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,o.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[l,a]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),n;e[0]!==d.edges?(n=c(w=>d.edges.some(X=>X.kind===w),"s"),e[0]=d.edges,e[1]=n):n=e[1];let f=Le.filter(n),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==l||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...l===ce?{}:{lane:l}}),e[6]=h,e[7]=p,e[8]=i,e[9]=l,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{a(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let I=j,L="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,o.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,o.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==l||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,o.jsxs)("select",{"aria-label":v,className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"architecture-module-filter",onChange:P,value:l,children:[k,N,M]}),e[26]=l,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,o.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,o.jsx)("button",{"aria-pressed":i.has(w),className:he("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{I(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,o.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,o.jsx)(Ne,{}),G=(0,o.jsx)(we,{showInteractive:!1}),K=(0,o.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,o.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,o.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,o.jsxs)("section",{className:L,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),l=fe(),a;e[0]!==l?(a=c(()=>l.fetchArchitecture(),"r"),e[0]=l,e[1]=a):a=e[1];let i=ye(d,a,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,o.jsx)(ne,{className:"h-8 w-48"}),(0,o.jsx)(ne,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,n,f;e[18]!==u?(n=(0,o.jsx)(We,{manifest:u}),f=(0,o.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=n,e[20]=f):(n=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,o.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,o.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,o.jsx)(oe,{variant:"outline",children:u.unresolved.length})]}),(0,o.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==n||e[25]!==f||e[26]!==m?(h=(0,o.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[n,f,m]}),e[24]=n,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Le)}c(Je,"We");function Qe(r){return(0,o.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,o.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
1
+ import{a as le,d as ae,e as ke,i as Ne,j as we,l as Se}from"./chunk-CP3LCFFM.js";import"./chunk-Y2YLTUMD.js";import"./chunk-CQDENTSP.js";import"./chunk-LMCBMC2V.js";import"./chunk-QF743FSL.js";import{a as ye}from"./chunk-FKAOFBS3.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import{a as ne}from"./chunk-Y5QMX4YG.js";import"./chunk-2NUCBQFU.js";import{i as ue}from"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as re}from"./chunk-HMMALUXM.js";import{b as oe}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-ZJIYJZ6F.js";import{a as pe,e as ge}from"./chunk-XV2XEUUB.js";import{n as fe}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as Y,s as me,x as he}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as qe}from"./chunk-A6TVTNKO.js";import{a as Ae,b as je}from"./chunk-ADABTCDI.js";import{a as c,d as te}from"./chunk-5PEAXTYQ.js";var z=te(qe(),1);var E=te(Ae(),1);var o=te(je(),1);var Le=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let a of r.nodes)(e===void 0||H(a)===e)&&t.add(a.id);if(e===void 0)return t;let l=new Set(t);for(let a of r.edges)d.has(a.kind)&&(t.has(a.from)&&l.add(a.to),t.has(a.to)&&l.add(a.from));return l},"Pe"),Ee=c((r,e,d,t)=>{let l=`lane:${r}`;return[{data:{label:e},id:l,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((a,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${a.detail??a.kind} \xB7 ${a.name}`,link:Pe(a)},extent:"parent",id:a.id,parentId:l,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let n of r.nodes)d.has(n.id)&&t.set(H(n),[...t.get(H(n))??[],n]);let l=[...r.modules.map(n=>({label:n.installed===!0?`${n.name} \xB7 ${e.componentLabel}`:n.name,lane:n.name})),{label:e.appLaneLabel,lane:Q}],a=[],i=0;for(let{label:n,lane:f}of l){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(a.push(...Ee(f,n,i,m)),i+=1)}let u=[];for(let n of r.edges)e.kinds.has(n.kind)&&d.has(n.from)&&d.has(n.to)&&u.push({animated:Me.has(n.kind),id:`${n.from}|${n.kind}|${n.to}`,label:n.kind,labelBgStyle:Fe,labelStyle:De,source:n.from,style:Be,target:n.to,type:"smoothstep"});return{edges:u,nodes:a}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),l;return e[0]!==t?(l=(0,o.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1],l},"qe"),Ie={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=ue(),{label:l,link:a}=d,i;e[0]!==a||e[1]!==t?(i=c(()=>{me(t(a))},"u"),e[0]=a,e[1]=t,e[2]=i):i=e[2];let u=i,n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n=(0,o.jsx)(ae,{isConnectable:!1,position:le.Left,style:Ie,type:"target"}),e[3]=n):n=e[3];let f;e[4]!==l||e[5]!==u?(f=(0,o.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:l}),e[4]=l,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,o.jsx)(ae,{isConnectable:!1,position:le.Right,style:Ie,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,o.jsxs)(o.Fragment,{children:[n,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),l,a,i,u,n,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");n=j(Q),u=pe,p="overflow-hidden py-0",i=ge,s="px-0",a=be,m="architecture-catalog";let I;e[13]!==t?(I=t("Module"),e[13]=t,e[14]=I):I=e[14];let L;e[15]!==I?(L=(0,o.jsx)(T,{children:I}),e[15]=I,e[16]=L):L=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,o.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,o.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,o.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==L||e[32]!==q?(h=(0,o.jsx)(xe,{children:(0,o.jsxs)(J,{children:[L,q,y,N]})}),e[29]=y,e[30]=N,e[31]=L,e[32]=q,e[33]=h):h=e[33],l=ve,f=d.modules.map(g=>(0,o.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,o.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,o.jsx)(oe,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,o.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,o.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=l,e[4]=a,e[5]=i,e[6]=u,e[7]=n,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else l=e[3],a=e[4],i=e[5],u=e[6],n=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==n||e[35]!==t?(b=n>0&&(0,o.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,o.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,o.jsx)(_,{className:"text-xs",children:n})]}),e[34]=n,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==l||e[38]!==f||e[39]!==b?(x=(0,o.jsxs)(l,{children:[f,b]}),e[37]=l,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==a||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,o.jsxs)(a,{"data-testid":m,children:[h,x]}),e[41]=a,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,o.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,o.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[l,a]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),n;e[0]!==d.edges?(n=c(w=>d.edges.some(X=>X.kind===w),"s"),e[0]=d.edges,e[1]=n):n=e[1];let f=Le.filter(n),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==l||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...l===ce?{}:{lane:l}}),e[6]=h,e[7]=p,e[8]=i,e[9]=l,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{a(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let I=j,L="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,o.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,o.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==l||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,o.jsxs)("select",{"aria-label":v,className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"architecture-module-filter",onChange:P,value:l,children:[k,N,M]}),e[26]=l,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,o.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,o.jsx)("button",{"aria-pressed":i.has(w),className:he("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{I(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,o.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,o.jsx)(Ne,{}),G=(0,o.jsx)(we,{showInteractive:!1}),K=(0,o.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,o.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,o.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,o.jsxs)("section",{className:L,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),l=fe(),a;e[0]!==l?(a=c(()=>l.fetchArchitecture(),"r"),e[0]=l,e[1]=a):a=e[1];let i=ye(d,a,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,o.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,o.jsx)(ne,{className:"h-8 w-48"}),(0,o.jsx)(ne,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,o.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,n,f;e[18]!==u?(n=(0,o.jsx)(We,{manifest:u}),f=(0,o.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=n,e[20]=f):(n=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,o.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,o.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,o.jsx)(oe,{variant:"outline",children:u.unresolved.length})]}),(0,o.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==n||e[25]!==f||e[26]!==m?(h=(0,o.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[n,f,m]}),e[24]=n,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Le)}c(Je,"We");function Qe(r){return(0,o.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,o.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
@@ -1 +1 @@
1
- import{b as h}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{b as I}from"./chunk-LRUYEVHH.js";import{a as y,e as S}from"./chunk-XV2XEUUB.js";import{n as k}from"./chunk-QFN62JQJ.js";import"./chunk-ZPQBVYNN.js";import{B as A}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as $}from"./chunk-A6TVTNKO.js";import{b as z}from"./chunk-ADABTCDI.js";import{a as u,d as w}from"./chunk-5PEAXTYQ.js";var N=w($(),1);var a=w(z(),1);var j=[{key:"accounts",label:"Accounts"},{key:"apiKey",label:"API keys"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let s;i[2]!==t?(s=(0,a.jsx)(S,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=u(()=>{let e=(0,N.c)(20),i=k(),t=A(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=I(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{let P=l.capabilities[r.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m(P)]},r.key)})})}),(0,a.jsx)(p,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(C)})}),(0,a.jsx)(p,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(p,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(p,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(p,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{M as default};
1
+ import{b as h}from"./chunk-BHUWAGFN.js";import"./chunk-L27FKJTG.js";import{b as I}from"./chunk-6C555TU5.js";import{a as y,e as S}from"./chunk-XV2XEUUB.js";import{n as k}from"./chunk-C6FOSG2A.js";import"./chunk-ZPQBVYNN.js";import{B as A}from"./chunk-2ZJJH4YN.js";import"./chunk-PDBW6GTJ.js";import{a as $}from"./chunk-A6TVTNKO.js";import{b as z}from"./chunk-ADABTCDI.js";import{a as u,d as w}from"./chunk-5PEAXTYQ.js";var N=w($(),1);var a=w(z(),1);var j=[{key:"accounts",label:"Accounts"},{key:"apiKey",label:"API keys"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let s;i[2]!==t?(s=(0,a.jsx)(S,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=u(()=>{let e=(0,N.c)(20),i=k(),t=A(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=I(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{let P=l.capabilities[r.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m(P)]},r.key)})})}),(0,a.jsx)(p,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(C)})}),(0,a.jsx)(p,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(p,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(p,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(p,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{M as default};