@lunora/studio 1.0.0-alpha.105 → 1.0.0-alpha.106

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 (59) hide show
  1. package/dist/standalone/{chunk-L54MRHOE.js → chunk-25IDU7IW.js} +1 -1
  2. package/dist/standalone/{chunk-CV2ZHCSQ.js → chunk-2ZG23BA5.js} +1 -1
  3. package/dist/standalone/{chunk-DYH6W3L5.js → chunk-5MJ3G4DY.js} +1 -1
  4. package/dist/standalone/{chunk-MUSKZL5Y.js → chunk-5RIKPDDA.js} +1 -1
  5. package/dist/standalone/chunk-5UY7MLRC.js +1 -0
  6. package/dist/standalone/{chunk-KAVRYX7T.js → chunk-63D4ABMW.js} +1 -1
  7. package/dist/standalone/{chunk-744YTKHP.js → chunk-6KWKX3RH.js} +1 -1
  8. package/dist/standalone/{chunk-XDDXCDKW.js → chunk-6QBOXH2I.js} +1 -1
  9. package/dist/standalone/{chunk-U2DFU5HO.js → chunk-6WB63KTN.js} +1 -1
  10. package/dist/standalone/{chunk-AI62XFW6.js → chunk-7P7NURTD.js} +1 -1
  11. package/dist/standalone/{chunk-GRGQK4AX.js → chunk-7QOXFLZB.js} +1 -1
  12. package/dist/standalone/{chunk-NM6OOA4L.js → chunk-7UP7OQJG.js} +1 -1
  13. package/dist/standalone/{chunk-RGFVM2UG.js → chunk-BCOT3QRZ.js} +1 -1
  14. package/dist/standalone/chunk-BDHAGUAY.js +11 -0
  15. package/dist/standalone/{chunk-NXF4Z5ZP.js → chunk-BG5ELOW6.js} +1 -1
  16. package/dist/standalone/{chunk-3CXC27LL.js → chunk-BXJPPINU.js} +1 -1
  17. package/dist/standalone/{chunk-CMQJI7AJ.js → chunk-BZDIRP7L.js} +1 -1
  18. package/dist/standalone/{chunk-X3CR2UJK.js → chunk-C3YACIEE.js} +1 -1
  19. package/dist/standalone/{chunk-OKIEDUHL.js → chunk-CAOA5AM4.js} +1 -1
  20. package/dist/standalone/{chunk-MVUIIDB7.js → chunk-CKG2DTZ2.js} +1 -1
  21. package/dist/standalone/{chunk-3CSOMPVV.js → chunk-DNEIBTLL.js} +1 -1
  22. package/dist/standalone/{chunk-NGENUSFE.js → chunk-DRR3KV5L.js} +1 -1
  23. package/dist/standalone/{chunk-46ZHPP3M.js → chunk-EF5J67J3.js} +1 -1
  24. package/dist/standalone/{chunk-5MD62MWO.js → chunk-EJWTF334.js} +1 -1
  25. package/dist/standalone/{chunk-UEZXG35P.js → chunk-EP4JQH5X.js} +1 -1
  26. package/dist/standalone/{chunk-QT47YQFN.js → chunk-EXL35M7T.js} +1 -1
  27. package/dist/standalone/{chunk-UF6SDOXD.js → chunk-F2I4JLFR.js} +1 -1
  28. package/dist/standalone/{chunk-HFP4PBM5.js → chunk-F3J6ER2V.js} +1 -1
  29. package/dist/standalone/{chunk-UDOOZJO5.js → chunk-FZ2N52BV.js} +1 -1
  30. package/dist/standalone/{chunk-UPQGD6JY.js → chunk-HLENOQDN.js} +1 -1
  31. package/dist/standalone/{chunk-FCLMIH4N.js → chunk-HUF7RMS3.js} +1 -1
  32. package/dist/standalone/{chunk-HKRRKZPX.js → chunk-HX7IXD7I.js} +1 -1
  33. package/dist/standalone/{chunk-QOP32XAE.js → chunk-IBPWTHHW.js} +1 -1
  34. package/dist/standalone/{chunk-GXXEKXMR.js → chunk-KZRWBSYQ.js} +1 -1
  35. package/dist/standalone/{chunk-LCMKFBA4.js → chunk-LWE6NWQX.js} +1 -1
  36. package/dist/standalone/{chunk-JGTKRQVM.js → chunk-RFSPHFKM.js} +1 -1
  37. package/dist/standalone/{chunk-GLCJSRZU.js → chunk-RJS7UD5U.js} +1 -1
  38. package/dist/standalone/{chunk-NCD4PEEZ.js → chunk-S23KCFVU.js} +1 -1
  39. package/dist/standalone/{chunk-CGKML4NC.js → chunk-S4665UG5.js} +1 -1
  40. package/dist/standalone/{chunk-VU6IQL5Z.js → chunk-SY6ANTKE.js} +1 -1
  41. package/dist/standalone/{chunk-G4YBB2WW.js → chunk-TCV7MMYR.js} +1 -1
  42. package/dist/standalone/{chunk-246BLG4I.js → chunk-UFESYXCE.js} +1 -1
  43. package/dist/standalone/{chunk-V4XO5TAT.js → chunk-UKI2ZYB2.js} +1 -1
  44. package/dist/standalone/{chunk-JISQYNVU.js → chunk-UTK6JUTY.js} +1 -1
  45. package/dist/standalone/{chunk-IRNX35LY.js → chunk-VIJLMIC3.js} +1 -1
  46. package/dist/standalone/{chunk-VM4RE2MS.js → chunk-VOY5EALQ.js} +1 -1
  47. package/dist/standalone/{chunk-NQVE5YON.js → chunk-VR3OBMGZ.js} +1 -1
  48. package/dist/standalone/{chunk-CTR7LLJB.js → chunk-WJCKVELA.js} +1 -1
  49. package/dist/standalone/{chunk-LBORO43W.js → chunk-WZ65AZKA.js} +1 -1
  50. package/dist/standalone/{chunk-XCNNKMME.js → chunk-XEGWCG5S.js} +1 -1
  51. package/dist/standalone/{chunk-XJTTJ57C.js → chunk-XNSCEAHM.js} +1 -1
  52. package/dist/standalone/{chunk-4TLSANPE.js → chunk-XVD7HWY7.js} +1 -1
  53. package/dist/standalone/{chunk-MWLD5STA.js → chunk-XYV7TMYI.js} +1 -1
  54. package/dist/standalone/{chunk-PA7BSM5T.js → chunk-YJ25NVR2.js} +1 -1
  55. package/dist/standalone/{chunk-VU27DLBM.js → chunk-ZCNMXKF2.js} +1 -1
  56. package/dist/standalone/studio.js +1 -1
  57. package/package.json +4 -4
  58. package/dist/standalone/chunk-CJQ2534J.js +0 -1
  59. package/dist/standalone/chunk-UQV7Q5S4.js +0 -11
@@ -1 +1 @@
1
- import{a as yt}from"./chunk-V53KNYRN.js";import{a as St}from"./chunk-3CSOMPVV.js";import{a as Nt}from"./chunk-ESVP44Y3.js";import{a as le}from"./chunk-3SCGCJYS.js";import{a as kt}from"./chunk-5Y3QLNWX.js";import{a as Ct}from"./chunk-54MMVNPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as L}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as ue}from"./chunk-UDOOZJO5.js";import{f as re}from"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{a as ft,b as pt,c as vt,d as Ze,e as se,f as me}from"./chunk-WJQLNYGX.js";import{a as ht,e as bt}from"./chunk-WQH3LT2P.js";import{d as q,h as wt,m as N,o as xt,r as zt}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as c,e as gt,f as Mt,g as Rt,h as Ft}from"./chunk-3XIESWL4.js";var U=gt(Rt(),1);var j=gt(Mt(),1);var n=gt(Ft(),1);var Ot=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"zt"),Et=c(t=>{let e=Ot(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Tt"),$t=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"St"),W=c(t=>{let e=(0,U.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,n.jsx)(kt,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"G"),de=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:l,title:s})=>{let m=q();return(0,n.jsxs)(Nt,{label:s,onClose:i,panelTestId:`${l}-panel`,testId:`${l}-overlay`,variant:"dialog",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s}),r,h!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":`${l}-error`,role:"alert",children:h}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,n.jsx)(L,{"data-testid":`${l}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:m("Cancel")}),(0,n.jsx)(L,{"data-testid":`${l}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?m("Saving\u2026"):a})]})]})},"se"),Dt=c(t=>{let e=(0,U.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=re(),a=q(),{busy:l,error:s,run:m}=le(),b;e[0]!==i?(b=i?N(i.name):"",e[0]=i,e[1]=b):b=e[1];let[u,g]=(0,j.useState)(b),p;e[2]!==i?(p=i?N(i.slug):"",e[2]=i,e[3]=p):p=e[3];let[f,y]=(0,j.useState)(p),z;e[4]!==i?(z=i?N(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[v,I]=(0,j.useState)(z),[C,k]=(0,j.useState)(""),w;e[6]!==r||e[7]!==i?.metadata?(w=r==="edit"?$t(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=w):w=e[8];let[x,S]=(0,j.useState)(w),O;e[9]!==o||e[10]!==v||e[11]!==x||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==m||e[19]!==f?(O=c(()=>{m(async()=>{let F=x.trim()===""?void 0:Ot(x);r==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim()===""?void 0:u.trim(),organizationId:N(i?.id),slug:f.trim()===""?void 0:f.trim()}),h(),d()})},"D"),e[9]=o,e[10]=v,e[11]=x,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=m,e[19]=f,e[20]=O):O=e[20];let A=O,D;e[21]!==r||e[22]!==u?(D=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=D):D=e[23];let $;e[24]!==r||e[25]!==a?($=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=$):$=e[26];let T;e[27]!==r||e[28]!==a?(T=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=T):T=e[29];let P;e[30]!==a?(P=a("name"),e[30]=a,e[31]=P):P=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=c(F=>{g(F.target.value)},"q"),e[32]=Q):Q=e[32];let J;e[33]!==u?(J=(0,n.jsx)(Z,{"data-testid":"org-form-name",id:"org-form-name",onChange:Q,value:u}),e[33]=u,e[34]=J):J=e[34];let E;e[35]!==J||e[36]!==P?(E=(0,n.jsx)(W,{htmlFor:"org-form-name",label:P,children:J}),e[35]=J,e[36]=P,e[37]=E):E=e[37];let B;e[38]!==a?(B=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=B):B=e[39];let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=c(F=>{y(F.target.value)},"Q"),e[40]=Y):Y=e[40];let M;e[41]!==f?(M=(0,n.jsx)(Z,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:Y,value:f}),e[41]=f,e[42]=M):M=e[42];let R;e[43]!==B||e[44]!==M?(R=(0,n.jsx)(W,{htmlFor:"org-form-slug",label:B,children:M}),e[43]=B,e[44]=M,e[45]=R):R=e[45];let H;e[46]!==a?(H=a("Logo URL (optional)"),e[46]=a,e[47]=H):H=e[47];let ie;e[48]===Symbol.for("react.memo_cache_sentinel")?(ie=c(F=>{I(F.target.value)},"le"),e[48]=ie):ie=e[48];let K;e[49]!==v?(K=(0,n.jsx)(Z,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:ie,value:v}),e[49]=v,e[50]=K):K=e[50];let ee;e[51]!==H||e[52]!==K?(ee=(0,n.jsx)(W,{htmlFor:"org-form-logo",label:H,children:K}),e[51]=H,e[52]=K,e[53]=ee):ee=e[53];let X;e[54]!==r||e[55]!==C||e[56]!==a?(X=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,n.jsx)(Z,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(F=>{k(F.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=a,e[57]=X):X=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=c(F=>{S(F.target.value)},"re"),e[60]=oe):oe=e[60];let V;e[61]!==x?(V=(0,n.jsx)(yt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:x}),e[61]=x,e[62]=V):V=e[62];let _;e[63]!==te||e[64]!==V?(_=(0,n.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:V}),e[63]=te,e[64]=V,e[65]=_):_=e[65];let ne;return e[66]!==l||e[67]!==s||e[68]!==d||e[69]!==A||e[70]!==E||e[71]!==R||e[72]!==ee||e[73]!==X||e[74]!==_||e[75]!==D||e[76]!==$||e[77]!==T?(ne=(0,n.jsxs)(de,{busy:l,canSubmit:D,error:s,onClose:d,onSubmit:A,submitLabel:$,testId:"org-form",title:T,children:[E,R,ee,X,_]}),e[66]=l,e[67]=s,e[68]=d,e[69]=A,e[70]=E,e[71]=R,e[72]=ee,e[73]=X,e[74]=_,e[75]=D,e[76]=$,e[77]=T,e[78]=ne):ne=e[78],ne},"bt"),Lt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==s||e[6]!==m?(p=c(()=>{s(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:m.trim()}),d(),r()})},"f"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=s,e[6]=m,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-add-member-user",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{g(T.target.value)},"D"),e[24]=O):O=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:O,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-add-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Mt"),jt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==m||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==s?(p=c(()=>{s(async()=>{await i.inviteAuthOrgMember({email:m.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"f"),e[0]=i,e[1]=m,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=s,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-invite-member-email",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{g(T.target.value)},"D"),e[24]=O):O=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:O,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Ft"),Pt=c(t=>{let e=(0,U.c)(32),{member:r,onClose:d,onDone:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),m;e[0]!==r.role?(m=c(()=>N(r.role),"m"),e[0]=r.role,e[1]=m):m=e[1];let[b,u]=(0,j.useState)(m),g;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==b||e[7]!==s?(g=c(()=>{s(async()=>{await i.setAuthOrgMemberRole({memberId:N(r.id),role:b.trim()}),h(),d()})},"u"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=b,e[7]=s,e[8]=g):g=e[8];let p=g,f;e[9]!==b?(f=b.trim(),e[9]=b,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(S=>{u(S.target.value)},"y"),e[17]=C):C=e[17];let k;e[18]!==b?(k=(0,n.jsx)(Z,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:b}),e[18]=b,e[19]=k):k=e[19];let w;e[20]!==I||e[21]!==k?(w=(0,n.jsx)(W,{htmlFor:"org-member-role-value",label:I,children:k}),e[20]=I,e[21]=k,e[22]=w):w=e[22];let x;return e[23]!==a||e[24]!==l||e[25]!==d||e[26]!==p||e[27]!==w||e[28]!==y||e[29]!==z||e[30]!==v?(x=(0,n.jsx)(de,{busy:a,canSubmit:y,error:l,onClose:d,onSubmit:p,submitLabel:z,testId:"org-member-role",title:v,children:w}),e[23]=a,e[24]=l,e[25]=d,e[26]=p,e[27]=w,e[28]=y,e[29]=z,e[30]=v,e[31]=x):x=e[31],x},"Et"),At=c(t=>{let e=(0,U.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.name):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==a||e[3]!==r||e[4]!==g||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==b||e[9]!==o?.id?(f=c(()=>{b(async()=>{await(r==="create"?a.createAuthOrgTeam({name:g.trim(),organizationId:i}):a.updateAuthOrgTeam({name:g.trim(),teamId:N(o?.id)})),h(),d()})},"b"),e[2]=a,e[3]=r,e[4]=g,e[5]=d,e[6]=h,e[7]=i,e[8]=b,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==g?(z=g.trim(),e[11]=g,e[12]=z):z=e[12];let v=z!=="",I;e[13]!==r||e[14]!==l?(I=l(r==="create"?"Create":"Save"),e[13]=r,e[14]=l,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==l?(C=l(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=l,e[18]=C):C=e[18];let k;e[19]!==l?(k=l("name"),e[19]=l,e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=c(A=>{p(A.target.value)},"$"),e[21]=w):w=e[21];let x;e[22]!==g?(x=(0,n.jsx)(Z,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:w,value:g}),e[22]=g,e[23]=x):x=e[23];let S;e[24]!==k||e[25]!==x?(S=(0,n.jsx)(W,{htmlFor:"org-team-form-name",label:k,children:x}),e[24]=k,e[25]=x,e[26]=S):S=e[26];let O;return e[27]!==s||e[28]!==m||e[29]!==d||e[30]!==y||e[31]!==S||e[32]!==v||e[33]!==I||e[34]!==C?(O=(0,n.jsx)(de,{busy:s,canSubmit:v,error:m,onClose:d,onSubmit:y,submitLabel:I,testId:"org-team-form",title:C,children:S}),e[27]=s,e[28]=m,e[29]=d,e[30]=y,e[31]=S,e[32]=v,e[33]=I,e[34]=C,e[35]=O):O=e[35],O},"ft"),Jt=c(t=>{let e=(0,U.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==s||e[4]!==h||e[5]!==m?(u=c(()=>{s(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:m.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=s,e[4]=h,e[5]=m,e[6]=u):u=e[6];let g=u,p;e[7]!==m?(p=m.trim(),e[7]=m,e[8]=p):p=e[8];let f=p!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(x=>{b(x.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==m?(C=(0,n.jsx)(Z,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:m}),e[16]=m,e[17]=C):C=e[17];let k;e[18]!==v||e[19]!==C?(k=(0,n.jsx)(W,{htmlFor:"org-team-add-member-user",label:v,children:C}),e[18]=v,e[19]=C,e[20]=k):k=e[20];let w;return e[21]!==a||e[22]!==l||e[23]!==r||e[24]!==g||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(w=(0,n.jsx)(de,{busy:a,canSubmit:f,error:l,onClose:r,onSubmit:g,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=a,e[22]=l,e[23]=r,e[24]=g,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=w):w=e[29],w},"Lt"),_t=c(t=>{let e=(0,U.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.role):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?$t(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,j.useState)(f),v;e[5]!==a||e[6]!==r||e[7]!==g||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==y||e[12]!==o?.id||e[13]!==b?(v=c(()=>{b(async()=>{let T=Et(y);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:T,role:g.trim()}):a.updateAuthOrgRole({permission:T,roleId:N(o?.id)})),h(),d()})},"p"),e[5]=a,e[6]=r,e[7]=g,e[8]=d,e[9]=h,e[10]=i,e[11]=y,e[12]=o?.id,e[13]=b,e[14]=v):v=e[14];let I=v,C;e[15]!==r||e[16]!==g||e[17]!==y?(C=y.trim()!==""&&(r==="edit"||g.trim()!==""),e[15]=r,e[16]=g,e[17]=y,e[18]=C):C=e[18];let k;e[19]!==r||e[20]!==l?(k=l(r==="create"?"Create":"Save"),e[19]=r,e[20]=l,e[21]=k):k=e[21];let w;e[22]!==r||e[23]!==l?(w=l(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=l,e[24]=w):w=e[24];let x;e[25]!==r||e[26]!==g||e[27]!==l?(x=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-role-form-name",label:l("Role name"),children:(0,n.jsx)(Z,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c(T=>{p(T.target.value)},"onChange"),value:g})}),e[25]=r,e[26]=g,e[27]=l,e[28]=x):x=e[28];let S;e[29]!==l?(S=l('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=l,e[30]=S):S=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{z(T.target.value)},"D"),e[31]=O):O=e[31];let A;e[32]!==y?(A=(0,n.jsx)(yt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:O,value:y}),e[32]=y,e[33]=A):A=e[33];let D;e[34]!==A||e[35]!==S?(D=(0,n.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=D):D=e[36];let $;return e[37]!==s||e[38]!==m||e[39]!==d||e[40]!==I||e[41]!==D||e[42]!==C||e[43]!==k||e[44]!==w||e[45]!==x?($=(0,n.jsxs)(de,{busy:s,canSubmit:C,error:m,onClose:d,onSubmit:I,submitLabel:k,testId:"org-role-form",title:w,children:[x,D]}),e[37]=s,e[38]=m,e[39]=d,e[40]=I,e[41]=D,e[42]=C,e[43]=k,e[44]=w,e[45]=x,e[46]=$):$=e[46],$},"pt"),Tt=c(t=>{let e=(0,U.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:a}=t,l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==b?(u=c(()=>{b(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=b,e[4]=u):u=e[4];let g=u,p;e[5]!==l?(p=l("Delete"),e[5]=l,e[6]=p):p=e[6];let f;e[7]!==d?(f=(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==s||e[10]!==m||e[11]!==h||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==a?(y=(0,n.jsx)(de,{busy:s,canSubmit:!0,destructive:!0,error:m,onClose:h,onSubmit:g,submitLabel:p,testId:o,title:a,children:f}),e[9]=s,e[10]=m,e[11]=h,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=a,e[17]=y):y=e[17],y},"kt"),Ge=c(t=>{let e=(0,U.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let a;e[2]!==r?(a=r!==void 0&&(0,n.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==a?(l=(0,n.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=l):l=e[6];let s;e[7]!==d?(s=(0,n.jsx)(bt,{className:"px-0",children:d}),e[7]=d,e[8]=s):s=e[8];let m;return e[9]!==l||e[10]!==s||e[11]!==i?(m=(0,n.jsxs)(ht,{className:"overflow-hidden py-0","data-testid":i,children:[l,s]}),e[9]=l,e[10]=s,e[11]=i,e[12]=m):m=e[12],m},"Ve"),Ke=c(t=>{let e=(0,U.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=q(),a;e[0]!==r?(a=r.map(Bt),e[0]=r,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("Actions"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==l?(s=(0,n.jsx)(se,{"aria-label":l}),e[4]=l,e[5]=s):s=e[5];let m;e[6]!==a||e[7]!==s?(m=(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[a,s]})}),e[6]=a,e[7]=s,e[8]=m):m=e[8];let b;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let p;e[14]!==r||e[15]!==d||e[16]!==h?(p=c((f,y)=>{let z=N(f.id),v=z===""?`index-${y.toString()}`:z;return(0,n.jsxs)(Ze,{"data-testid":`${h}-${v}`,children:[r.map(I=>(0,n.jsx)(me,{className:I.className,children:I.render(f)},I.head)),(0,n.jsx)(me,{children:(0,n.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},"f"),e[14]=r,e[15]=d,e[16]=h,e[17]=p):p=e[17],b=i.map(p),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=b}else b=e[13];let u;e[18]!==b?(u=(0,n.jsx)(vt,{children:b}),e[18]=b,e[19]=u):u=e[19];let g;return e[20]!==m||e[21]!==u?(g=(0,n.jsxs)(ft,{children:[m,u]}),e[20]=m,e[21]=u,e[22]=g):g=e[22],g},"Xe");function Bt(t){return(0,n.jsx)(se,{children:t.head},t.head)}c(Bt,"jt");var Ut=c(t=>{let e=(0,U.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,a=q(),l;e[0]!==o?(l=c(()=>{o({kind:"add-member"})},"a"),e[0]=o,e[1]=l):l=e[1];let s;e[2]!==a?(s=a("Add member"),e[2]=a,e[3]=s):s=e[3];let m;e[4]!==l||e[5]!==s?(m=(0,n.jsx)(L,{"data-testid":"org-open-add-member",onClick:l,size:"xs",type:"button",variant:"outline",children:s}),e[4]=l,e[5]=s,e[6]=m):m=e[6];let b;e[7]!==o?(b=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=b):b=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let g;e[11]!==b||e[12]!==u?(g=(0,n.jsx)(L,{"data-testid":"org-open-invite-member",onClick:b,size:"xs",type:"button",variant:"outline",children:u}),e[11]=b,e[12]=u,e[13]=g):g=e[13];let p;e[14]!==m||e[15]!==g?(p=(0,n.jsxs)(n.Fragment,{children:[m,g]}),e[14]=m,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==a?(f=a("Members"),e[17]=a,e[18]=f):f=e[18];let y;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==a?(y=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-members-empty",title:a("No members.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(v=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-member-role-${N(v.id)}`,onClick:c(()=>{o({kind:"member-role",member:v})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,n.jsx)(L,{"data-testid":`org-remove-member-${N(v.id)}`,disabled:r,onClick:c(()=>{d(N(v.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=a,e[25]=y):y=e[25];let z;return e[26]!==p||e[27]!==f||e[28]!==y?(z=(0,n.jsx)(Ge,{action:p,heading:f,testId:"org-members",children:y}),e[26]=p,e[27]=f,e[28]=y,e[29]=z):z=e[29],z},"Pt"),qt=c(t=>{let e=(0,U.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,l=q(),s;e[0]!==d?(s=c(()=>{d({kind:"team-create"})},"s"),e[0]=d,e[1]=s):s=e[1];let m;e[2]!==l?(m=l("New team"),e[2]=l,e[3]=m):m=e[3];let b;e[4]!==s||e[5]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-create-team",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[4]=s,e[5]=m,e[6]=b):b=e[6];let u;e[7]!==l?(u=l("Teams"),e[7]=l,e[8]=u):u=e[8];let g;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==l||e[14]!==o||e[15]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-teams-empty",title:l("No teams.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"aria-pressed":i===N(f.id),"data-testid":`org-team-select-${N(f.id)}`,onClick:c(()=>{h(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Members")}),(0,n.jsx)(L,{"data-testid":`org-team-rename-${N(f.id)}`,onClick:c(()=>{d({kind:"team-rename",team:f})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Rename")}),(0,n.jsx)(L,{"data-testid":`org-team-delete-${N(f.id)}`,onClick:c(()=>{r(f)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=l,e[14]=o,e[15]=a,e[16]=g):g=e[16];let p;return e[17]!==b||e[18]!==u||e[19]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-teams",children:g}),e[17]=b,e[18]=u,e[19]=g,e[20]=p):p=e[20],p},"Bt"),Ht=c(t=>{let e=(0,U.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,l=q(),s;e[0]!==h||e[1]!==i?(s=c(()=>{h({kind:"team-add-member",teamId:i})},"s"),e[0]=h,e[1]=i,e[2]=s):s=e[2];let m;e[3]!==l?(m=l("Add member"),e[3]=l,e[4]=m):m=e[4];let b;e[5]!==s||e[6]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[5]=s,e[6]=m,e[7]=b):b=e[7];let u;e[8]!==l?(u=l("Team members"),e[8]=l,e[9]=u):u=e[9];let g;e[10]!==r||e[11]!==d||e[12]!==l||e[13]!==o||e[14]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-team-members-empty",title:l("No team members.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsx)(L,{"data-testid":`org-team-remove-member-${N(f.id)}`,disabled:r,onClick:c(()=>{d(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=d,e[12]=l,e[13]=o,e[14]=a,e[15]=g):g=e[15];let p;return e[16]!==b||e[17]!==u||e[18]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-team-members",children:g}),e[16]=b,e[17]=u,e[18]=g,e[19]=p):p=e[19],p},"Jt"),Qt=c(t=>{let e=(0,U.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=q(),a;e[0]!==d?(a=c(()=>{d({kind:"role-create"})},"n"),e[0]=d,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("New role"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==a||e[5]!==l?(s=(0,n.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:l}),e[4]=a,e[5]=l,e[6]=s):s=e[6];let m;e[7]!==o?(m=o("Roles"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(b=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(g=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-role-edit-${N(g.id)}`,onClick:c(()=>{d({kind:"role-edit",role:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,n.jsx)(L,{"data-testid":`org-role-delete-${N(g.id)}`,onClick:c(()=>{r(N(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=b):b=e[14];let u;return e[15]!==s||e[16]!==m||e[17]!==b?(u=(0,n.jsx)(Ge,{action:s,heading:m,testId:"org-roles",children:b}),e[15]=s,e[16]=m,e[17]=b,e[18]=u):u=e[18],u},"Ut"),Wt=c(t=>{let e=(0,U.c)(199),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=re(),o=q(),[a,l]=(0,j.useState)(null),[s,m]=(0,j.useState)(null),[b,u]=(0,j.useState)(!1),[g,p]=(0,j.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==i||e[3]!==r?(y=c(()=>i.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=i,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),v;e[5]!==r?(v=["lunora-auth-org-invitations",r],e[5]=r,e[6]=v):v=e[6];let I;e[7]!==i||e[8]!==r?(I=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"C"),e[7]=i,e[8]=r,e[9]=I):I=e[9];let C=ue(v,I),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let w;e[12]!==i||e[13]!==r?(w=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"$"),e[12]=i,e[13]=r,e[14]=w):w=e[14];let x;e[15]!==h?(x={enabled:h},e[15]=h,e[16]=x):x=e[16];let S=ue(k,w,x),O;e[17]!==r?(O=["lunora-auth-org-roles",r],e[17]=r,e[18]=O):O=e[18];let A;e[19]!==i||e[20]!==r?(A=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"A"),e[19]=i,e[20]=r,e[21]=A):A=e[21];let D;e[22]!==d?(D={enabled:d},e[22]=d,e[23]=D):D=e[23];let $=ue(O,A,D),T;e[24]!==s?(T=["lunora-auth-org-team-members",s],e[24]=s,e[25]=T):T=e[25];let P;e[26]!==i||e[27]!==s?(P=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:s??""}),"P"),e[26]=i,e[27]=s,e[28]=P):P=e[28];let Q=s!==null,J;e[29]!==Q?(J={enabled:Q},e[29]=Q,e[30]=J):J=e[30];let E=ue(T,P,J),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let Y=B,M;e[33]!==C.data?.rows?(M=C.data?.rows??[],e[33]=C.data?.rows,e[34]=M):M=e[34];let R=M,H;e[35]!==S.data?.rows?(H=S.data?.rows??[],e[35]=S.data?.rows,e[36]=H):H=e[36];let ie=H,K;e[37]!==$.data?.rows?(K=$.data?.rows??[],e[37]=$.data?.rows,e[38]=K):K=e[38];let ee=K,X;e[39]!==s||e[40]!==E?(X=s===null?[]:E.data?.rows??[],e[39]=s,e[40]=E,e[41]=X):X=e[41];let te=X,oe=z.error??C.error??S.error??$.error??E.error,V;e[42]!==C||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==s||e[47]!==E||e[48]!==h||e[49]!==S?(V=c(()=>{z.refetch(),C.refetch(),h&&S.refetch(),d&&$.refetch(),s!==null&&E.refetch()},"W"),e[42]=C,e[43]=z,e[44]=d,e[45]=$,e[46]=s,e[47]=E,e[48]=h,e[49]=S,e[50]=V):V=e[50];let _=V;Ct(_,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=c(()=>{l(null)},"oe"),e[51]=ne):ne=e[51];let F=ne,Xe;e[52]!==_?(Xe=c(G=>{xt((async()=>{u(!0),p(null);try{await G(),_(),u(!1)}catch(lt){p(wt(lt)),u(!1)}})())},"Ye"),e[52]=_,e[53]=Xe):Xe=e[53];let ae=Xe,Ve;e[54]!==i||e[55]!==o?(Ve=c(G=>{let lt=N(G.id);l({action:c(async()=>{await i.removeAuthOrgTeam({teamId:lt}),m(It=>It===lt?null:It)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"Ze"),e[54]=i,e[55]=o,e[56]=Ve):Ve=e[56];let it=Ve,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Yt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Zt},e[63]=be,e[64]=fe):fe=e[64];let et;e[65]!==he||e[66]!==fe?(et=[he,fe],e[65]=he,e[66]=fe,e[67]=et):et=e[67];let st=et,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:Gt},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ce;e[74]!==ye?(Ce={head:ye,render:Kt},e[74]=ye,e[75]=Ce):Ce=e[75];let Ie;e[76]!==o?(Ie=o("status"),e[76]=o,e[77]=Ie):Ie=e[77];let we;e[78]!==Ie?(we={head:Ie,render:Xt},e[78]=Ie,e[79]=we):we=e[79];let tt;e[80]!==ve||e[81]!==Ce||e[82]!==we?(tt=[ve,Ce,we],e[80]=ve,e[81]=Ce,e[82]=we,e[83]=tt):tt=e[83];let mt=tt,xe;e[84]!==o?(xe=o("id"),e[84]=o,e[85]=xe):xe=e[85];let ze;e[86]!==xe?(ze={className:"font-mono text-xs",head:xe,render:Vt},e[86]=xe,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Se;e[90]!==ke?(Se={head:ke,render:er},e[90]=ke,e[91]=Se):Se=e[91];let rt;e[92]!==ze||e[93]!==Se?(rt=[ze,Se],e[92]=ze,e[93]=Se,e[94]=rt):rt=e[94];let dt=rt,Ne;e[95]!==o?(Ne=o("userId"),e[95]=o,e[96]=Ne):Ne=e[96];let ot;e[97]!==Ne?(ot=[{head:Ne,render:tr}],e[97]=Ne,e[98]=ot):ot=e[98];let ct=ot,De;e[99]!==o?(De=o("role"),e[99]=o,e[100]=De):De=e[100];let Ae;e[101]!==De?(Ae={head:De,render:rr},e[101]=De,e[102]=Ae):Ae=e[102];let _e;e[103]!==o?(_e=o("Permission"),e[103]=o,e[104]=_e):_e=e[104];let Oe;e[105]!==_e?(Oe={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:or},e[105]=_e,e[106]=Oe):Oe=e[106];let nt;e[107]!==Ae||e[108]!==Oe?(nt=[Ae,Oe],e[107]=Ae,e[108]=Oe,e[109]=nt):nt=e[109];let ut=nt,$e;e[110]!==oe?($e=oe!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:oe}),e[110]=oe,e[111]=$e):$e=e[111];let Te;e[112]!==g?(Te=g!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[112]=g,e[113]=Te):Te=e[113];let Me;e[114]!==i||e[115]!==ae?(Me=c(G=>{ae(()=>i.removeAuthOrgMember({memberId:G}))},"_e"),e[114]=i,e[115]=ae,e[116]=Me):Me=e[116];let Re;e[117]!==b||e[118]!==st||e[119]!==Y||e[120]!==Me?(Re=(0,n.jsx)(Ut,{actionBusy:b,memberColumns:st,members:Y,onDialog:l,onRemoveMember:Me}),e[117]=b,e[118]=st,e[119]=Y,e[120]=Me,e[121]=Re):Re=e[121];let Fe;e[122]!==b||e[123]!==i||e[124]!==mt||e[125]!==R||e[126]!==ae||e[127]!==o?(Fe=R.length>0&&(0,n.jsx)(Ge,{heading:o("Invitations"),testId:"org-invitations",children:(0,n.jsx)(Ke,{columns:mt,rowActions:c(G=>(0,n.jsx)(L,{"data-testid":`org-cancel-invitation-${N(G.id)}`,disabled:b,onClick:c(()=>{ae(()=>i.cancelAuthOrgInvitation({invitationId:N(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:R})}),e[122]=b,e[123]=i,e[124]=mt,e[125]=R,e[126]=ae,e[127]=o,e[128]=Fe):Fe=e[128];let Ee;e[129]!==it||e[130]!==s||e[131]!==dt||e[132]!==ie||e[133]!==h?(Ee=h&&(0,n.jsx)(qt,{onConfirmDeleteTeam:it,onDialog:l,onSelectTeam:m,selectedTeam:s,teamColumns:dt,teams:ie}),e[129]=it,e[130]=s,e[131]=dt,e[132]=ie,e[133]=h,e[134]=Ee):Ee=e[134];let Le;e[135]!==b||e[136]!==i||e[137]!==ae||e[138]!==s||e[139]!==ct||e[140]!==te||e[141]!==h?(Le=h&&s!==null&&(0,n.jsx)(Ht,{actionBusy:b,onDialog:l,onRemoveTeamMember:c(G=>{ae(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:s,teamMemberColumns:ct,teamMembers:te}),e[135]=b,e[136]=i,e[137]=ae,e[138]=s,e[139]=ct,e[140]=te,e[141]=h,e[142]=Le):Le=e[142];let je;e[143]!==i||e[144]!==ut||e[145]!==ee||e[146]!==d||e[147]!==o?(je=d&&(0,n.jsx)(Qt,{onConfirmDeleteRole:c(G=>{l({action:c(()=>i.deleteAuthOrgRole({roleId:G}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:l,roleColumns:ut,roles:ee}),e[143]=i,e[144]=ut,e[145]=ee,e[146]=d,e[147]=o,e[148]=je):je=e[148];let Pe;e[149]!==a?.kind||e[150]!==r||e[151]!==_?(Pe=a?.kind==="add-member"&&(0,n.jsx)(Lt,{onClose:F,onDone:_,organizationId:r}),e[149]=a?.kind,e[150]=r,e[151]=_,e[152]=Pe):Pe=e[152];let Je;e[153]!==a?.kind||e[154]!==r||e[155]!==_?(Je=a?.kind==="invite-member"&&(0,n.jsx)(jt,{onClose:F,onDone:_,organizationId:r}),e[153]=a?.kind,e[154]=r,e[155]=_,e[156]=Je):Je=e[156];let Be;e[157]!==a||e[158]!==_?(Be=a?.kind==="member-role"&&(0,n.jsx)(Pt,{member:a.member,onClose:F,onDone:_}),e[157]=a,e[158]=_,e[159]=Be):Be=e[159];let Ue;e[160]!==a?.kind||e[161]!==r||e[162]!==_?(Ue=a?.kind==="team-create"&&(0,n.jsx)(At,{mode:"create",onClose:F,onDone:_,organizationId:r}),e[160]=a?.kind,e[161]=r,e[162]=_,e[163]=Ue):Ue=e[163];let qe;e[164]!==a||e[165]!==r||e[166]!==_?(qe=a?.kind==="team-rename"&&(0,n.jsx)(At,{mode:"edit",onClose:F,onDone:_,organizationId:r,team:a.team}),e[164]=a,e[165]=r,e[166]=_,e[167]=qe):qe=e[167];let He;e[168]!==a||e[169]!==_?(He=a?.kind==="team-add-member"&&(0,n.jsx)(Jt,{onClose:F,onDone:_,teamId:a.teamId}),e[168]=a,e[169]=_,e[170]=He):He=e[170];let Qe;e[171]!==a?.kind||e[172]!==r||e[173]!==_?(Qe=a?.kind==="role-create"&&(0,n.jsx)(_t,{mode:"create",onClose:F,onDone:_,organizationId:r}),e[171]=a?.kind,e[172]=r,e[173]=_,e[174]=Qe):Qe=e[174];let We;e[175]!==a||e[176]!==r||e[177]!==_?(We=a?.kind==="role-edit"&&(0,n.jsx)(_t,{mode:"edit",onClose:F,onDone:_,organizationId:r,role:a.role}),e[175]=a,e[176]=r,e[177]=_,e[178]=We):We=e[178];let Ye;e[179]!==a||e[180]!==_?(Ye=a?.kind==="confirm"&&(0,n.jsx)(Tt,{action:a.action,message:a.message,onClose:F,onDone:_,testId:a.testId,title:a.title}),e[179]=a,e[180]=_,e[181]=Ye):Ye=e[181];let at;return e[182]!==$e||e[183]!==Te||e[184]!==Re||e[185]!==Fe||e[186]!==Ee||e[187]!==Le||e[188]!==je||e[189]!==Pe||e[190]!==Je||e[191]!==Be||e[192]!==Ue||e[193]!==qe||e[194]!==He||e[195]!==Qe||e[196]!==We||e[197]!==Ye?(at=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Te,Re,Fe,Ee,Le,je,Pe,Je,Be,Ue,qe,He,Qe,We,Ye]}),e[182]=$e,e[183]=Te,e[184]=Re,e[185]=Fe,e[186]=Ee,e[187]=Le,e[188]=je,e[189]=Pe,e[190]=Je,e[191]=Be,e[192]=Ue,e[193]=qe,e[194]=He,e[195]=Qe,e[196]=We,e[197]=Ye,e[198]=at):at=e[198],at},"Ht");function Yt(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(Yt,"Kt");function Zt(t){return N(t.role)}c(Zt,"qt");function Gt(t){return N(t.email)}c(Gt,"Gt");function Kt(t){return N(t.role)}c(Kt,"Qt");function Xt(t){return N(t.status)}c(Xt,"Vt");function Vt(t){return N(t.id)}c(Vt,"Xt");function er(t){return N(t.name)}c(er,"Yt");function tr(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(tr,"Zt");function rr(t){return N(t.role)}c(rr,"Wt");function or(t){return N(t.permission)}c(or,"er");var yr=c(()=>{let t=(0,U.c)(62),e=re(),r=q(),{config:d,ready:h}=St(),i=d.capabilities.organization,[o,a]=(0,j.useState)(null),[l,s]=(0,j.useState)(null),m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=["lunora-auth-orgs"],t[0]=m):m=t[0];let b;t[1]!==e?(b=c(()=>e.listAuthOrganizations({limit:100}),"h"),t[1]=e,t[2]=b):b=t[2];let u;t[3]!==i?(u={enabled:i},t[3]=i,t[4]=u):u=t[4];let g=ue(m,b,u),p=g.data?.rows??null,f;t[5]!==g?(f=c(()=>{g.refetch()},"b"),t[5]=g,t[6]=f):f=t[6],Ct(f,i);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{s(null)},"v"),t[7]=y):y=t[7];let z=y,v;t[8]!==g?(v=c(()=>{g.refetch()},"p"),t[8]=g,t[9]=v):v=t[9];let I=v,C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=c(M=>{a(M)},"y"),t[10]=C):C=t[10];let k=C;if(h&&!i){let M;t[11]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=M):M=t[12];let R;t[13]!==r?(R=r("Organizations are not enabled."),t[13]=r,t[14]=R):R=t[14];let H;return t[15]!==M||t[16]!==R?(H=(0,n.jsx)(ce,{description:M,testId:"org-disabled",title:R}),t[15]=M,t[16]=R,t[17]=H):H=t[17],H}let w;t[18]!==r?(w=r("Organizations"),t[18]=r,t[19]=w):w=t[19];let x;t[20]!==w?(x=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:w}),t[20]=w,t[21]=x):x=t[21];let S;t[22]===Symbol.for("react.memo_cache_sentinel")?(S=c(()=>{s({kind:"create"})},"z"),t[22]=S):S=t[22];let O;t[23]!==r?(O=r("New organization"),t[23]=r,t[24]=O):O=t[24];let A;t[25]!==O?(A=(0,n.jsx)(L,{"data-testid":"org-new",onClick:S,size:"sm",type:"button",children:O}),t[25]=O,t[26]=A):A=t[26];let D;t[27]!==A||t[28]!==x?(D=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[x,A]}),t[27]=A,t[28]=x,t[29]=D):D=t[29];let $;t[30]!==g.error?($=g.error!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[30]=g.error,t[31]=$):$=t[31];let T;t[32]!==p||t[33]!==r?(T=p!==null&&p.length===0&&(0,n.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=p,t[33]=r,t[34]=T):T=t[34];let P;t[35]!==p||t[36]!==o||t[37]!==r?(P=p!==null&&p.length>0&&(0,n.jsx)(ht,{className:"overflow-hidden py-0",children:(0,n.jsx)(bt,{className:"px-0",children:(0,n.jsxs)(ft,{"data-testid":"org-table",children:[(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[(0,n.jsx)(se,{children:r("id")}),(0,n.jsx)(se,{children:r("name")}),(0,n.jsx)(se,{children:r("slug")}),(0,n.jsx)(se,{children:r("created")}),(0,n.jsx)(se,{"aria-label":r("Actions")})]})}),(0,n.jsx)(vt,{children:p.map(M=>{let R=N(M.id);return(0,n.jsxs)(Ze,{"data-testid":`org-row-${R}`,children:[(0,n.jsx)(me,{className:"font-mono text-xs",children:R}),(0,n.jsx)(me,{children:N(M.name)}),(0,n.jsx)(me,{children:N(M.slug)}),(0,n.jsx)(me,{className:"text-muted-foreground tabular-nums",children:zt(M.createdAt)}),(0,n.jsx)(me,{children:(0,n.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,n.jsx)(L,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{k(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,n.jsx)(L,{"data-testid":`org-edit-${R}`,onClick:c(()=>{s({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,n.jsx)(L,{"data-testid":`org-delete-${R}`,onClick:c(()=>{s({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[35]=p,t[36]=o,t[37]=r,t[38]=P):P=t[38];let Q;t[39]!==d.organization||t[40]!==o?(Q=o!==null&&(0,n.jsx)(Wt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=Q):Q=t[41];let J;t[42]!==l?.kind||t[43]!==I?(J=l?.kind==="create"&&(0,n.jsx)(Dt,{mode:"create",onClose:z,onDone:I}),t[42]=l?.kind,t[43]=I,t[44]=J):J=t[44];let E;t[45]!==l||t[46]!==I?(E=l?.kind==="edit"&&(0,n.jsx)(Dt,{mode:"edit",onClose:z,onDone:I,org:l.org}),t[45]=l,t[46]=I,t[47]=E):E=t[47];let B;t[48]!==e||t[49]!==l||t[50]!==I||t[51]!==r?(B=l?.kind==="delete"&&(0,n.jsx)(Tt,{action:c(async()=>{let M=N(l.org.id);await e.deleteAuthOrganization({organizationId:M}),a(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:z,onDone:I,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=l,t[50]=I,t[51]=r,t[52]=B):B=t[52];let Y;return t[53]!==D||t[54]!==$||t[55]!==T||t[56]!==P||t[57]!==Q||t[58]!==J||t[59]!==E||t[60]!==B?(Y=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[D,$,T,P,Q,J,E,B]}),t[53]=D,t[54]=$,t[55]=T,t[56]=P,t[57]=Q,t[58]=J,t[59]=E,t[60]=B,t[61]=Y):Y=t[61],Y},"yr");export{yr as default};
1
+ import{a as yt}from"./chunk-V53KNYRN.js";import{a as St}from"./chunk-DNEIBTLL.js";import{a as Nt}from"./chunk-ESVP44Y3.js";import{a as le}from"./chunk-3SCGCJYS.js";import{a as kt}from"./chunk-5Y3QLNWX.js";import{a as Ct}from"./chunk-54MMVNPT.js";import{R as Z}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as L}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{b as ue}from"./chunk-FZ2N52BV.js";import{f as re}from"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{a as ft,b as pt,c as vt,d as Ze,e as se,f as me}from"./chunk-WJQLNYGX.js";import{a as ht,e as bt}from"./chunk-WQH3LT2P.js";import{d as q,h as wt,m as N,o as xt,r as zt}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as c,e as gt,f as Mt,g as Rt,h as Ft}from"./chunk-3XIESWL4.js";var U=gt(Rt(),1);var j=gt(Mt(),1);var n=gt(Ft(),1);var Ot=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"zt"),Et=c(t=>{let e=Ot(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Tt"),$t=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"St"),W=c(t=>{let e=(0,U.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,n.jsx)(kt,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,n.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"G"),de=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:l,title:s})=>{let m=q();return(0,n.jsxs)(Nt,{label:s,onClose:i,panelTestId:`${l}-panel`,testId:`${l}-overlay`,variant:"dialog",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:s}),r,h!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":`${l}-error`,role:"alert",children:h}),(0,n.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,n.jsx)(L,{"data-testid":`${l}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:m("Cancel")}),(0,n.jsx)(L,{"data-testid":`${l}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?m("Saving\u2026"):a})]})]})},"se"),Dt=c(t=>{let e=(0,U.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=re(),a=q(),{busy:l,error:s,run:m}=le(),b;e[0]!==i?(b=i?N(i.name):"",e[0]=i,e[1]=b):b=e[1];let[u,g]=(0,j.useState)(b),p;e[2]!==i?(p=i?N(i.slug):"",e[2]=i,e[3]=p):p=e[3];let[f,y]=(0,j.useState)(p),z;e[4]!==i?(z=i?N(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[v,I]=(0,j.useState)(z),[C,k]=(0,j.useState)(""),w;e[6]!==r||e[7]!==i?.metadata?(w=r==="edit"?$t(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=w):w=e[8];let[x,S]=(0,j.useState)(w),O;e[9]!==o||e[10]!==v||e[11]!==x||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==m||e[19]!==f?(O=c(()=>{m(async()=>{let F=x.trim()===""?void 0:Ot(x);r==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:F,name:u.trim()===""?void 0:u.trim(),organizationId:N(i?.id),slug:f.trim()===""?void 0:f.trim()}),h(),d()})},"D"),e[9]=o,e[10]=v,e[11]=x,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=m,e[19]=f,e[20]=O):O=e[20];let A=O,D;e[21]!==r||e[22]!==u?(D=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=D):D=e[23];let $;e[24]!==r||e[25]!==a?($=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=$):$=e[26];let T;e[27]!==r||e[28]!==a?(T=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=T):T=e[29];let P;e[30]!==a?(P=a("name"),e[30]=a,e[31]=P):P=e[31];let Q;e[32]===Symbol.for("react.memo_cache_sentinel")?(Q=c(F=>{g(F.target.value)},"q"),e[32]=Q):Q=e[32];let J;e[33]!==u?(J=(0,n.jsx)(Z,{"data-testid":"org-form-name",id:"org-form-name",onChange:Q,value:u}),e[33]=u,e[34]=J):J=e[34];let E;e[35]!==J||e[36]!==P?(E=(0,n.jsx)(W,{htmlFor:"org-form-name",label:P,children:J}),e[35]=J,e[36]=P,e[37]=E):E=e[37];let B;e[38]!==a?(B=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=B):B=e[39];let Y;e[40]===Symbol.for("react.memo_cache_sentinel")?(Y=c(F=>{y(F.target.value)},"Q"),e[40]=Y):Y=e[40];let M;e[41]!==f?(M=(0,n.jsx)(Z,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:Y,value:f}),e[41]=f,e[42]=M):M=e[42];let R;e[43]!==B||e[44]!==M?(R=(0,n.jsx)(W,{htmlFor:"org-form-slug",label:B,children:M}),e[43]=B,e[44]=M,e[45]=R):R=e[45];let H;e[46]!==a?(H=a("Logo URL (optional)"),e[46]=a,e[47]=H):H=e[47];let ie;e[48]===Symbol.for("react.memo_cache_sentinel")?(ie=c(F=>{I(F.target.value)},"le"),e[48]=ie):ie=e[48];let K;e[49]!==v?(K=(0,n.jsx)(Z,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:ie,value:v}),e[49]=v,e[50]=K):K=e[50];let ee;e[51]!==H||e[52]!==K?(ee=(0,n.jsx)(W,{htmlFor:"org-form-logo",label:H,children:K}),e[51]=H,e[52]=K,e[53]=ee):ee=e[53];let X;e[54]!==r||e[55]!==C||e[56]!==a?(X=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,n.jsx)(Z,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(F=>{k(F.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=a,e[57]=X):X=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=c(F=>{S(F.target.value)},"re"),e[60]=oe):oe=e[60];let V;e[61]!==x?(V=(0,n.jsx)(yt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:x}),e[61]=x,e[62]=V):V=e[62];let _;e[63]!==te||e[64]!==V?(_=(0,n.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:V}),e[63]=te,e[64]=V,e[65]=_):_=e[65];let ne;return e[66]!==l||e[67]!==s||e[68]!==d||e[69]!==A||e[70]!==E||e[71]!==R||e[72]!==ee||e[73]!==X||e[74]!==_||e[75]!==D||e[76]!==$||e[77]!==T?(ne=(0,n.jsxs)(de,{busy:l,canSubmit:D,error:s,onClose:d,onSubmit:A,submitLabel:$,testId:"org-form",title:T,children:[E,R,ee,X,_]}),e[66]=l,e[67]=s,e[68]=d,e[69]=A,e[70]=E,e[71]=R,e[72]=ee,e[73]=X,e[74]=_,e[75]=D,e[76]=$,e[77]=T,e[78]=ne):ne=e[78],ne},"bt"),Lt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==s||e[6]!==m?(p=c(()=>{s(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:m.trim()}),d(),r()})},"f"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=s,e[6]=m,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:k,value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-add-member-user",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{g(T.target.value)},"D"),e[24]=O):O=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:O,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-add-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Mt"),jt=c(t=>{let e=(0,U.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),[u,g]=(0,j.useState)(""),p;e[0]!==i||e[1]!==m||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==s?(p=c(()=>{s(async()=>{await i.inviteAuthOrgMember({email:m.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"f"),e[0]=i,e[1]=m,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=s,e[7]=p):p=e[7];let f=p,y;e[8]!==m?(y=m.trim(),e[8]=m,e[9]=y):y=e[9];let z=y!=="",v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=c(T=>{b(T.target.value)},"x"),e[16]=k):k=e[16];let w;e[17]!==m?(w=(0,n.jsx)(Z,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:k,type:"email",value:m}),e[17]=m,e[18]=w):w=e[18];let x;e[19]!==C||e[20]!==w?(x=(0,n.jsx)(W,{htmlFor:"org-invite-member-email",label:C,children:w}),e[19]=C,e[20]=w,e[21]=x):x=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{g(T.target.value)},"D"),e[24]=O):O=e[24];let A;e[25]!==u?(A=(0,n.jsx)(Z,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:O,value:u}),e[25]=u,e[26]=A):A=e[26];let D;e[27]!==S||e[28]!==A?(D=(0,n.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=D):D=e[29];let $;return e[30]!==a||e[31]!==l||e[32]!==r||e[33]!==f||e[34]!==D||e[35]!==z||e[36]!==v||e[37]!==I||e[38]!==x?($=(0,n.jsxs)(de,{busy:a,canSubmit:z,error:l,onClose:r,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:I,children:[x,D]}),e[30]=a,e[31]=l,e[32]=r,e[33]=f,e[34]=D,e[35]=z,e[36]=v,e[37]=I,e[38]=x,e[39]=$):$=e[39],$},"Ft"),Pt=c(t=>{let e=(0,U.c)(32),{member:r,onClose:d,onDone:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),m;e[0]!==r.role?(m=c(()=>N(r.role),"m"),e[0]=r.role,e[1]=m):m=e[1];let[b,u]=(0,j.useState)(m),g;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==b||e[7]!==s?(g=c(()=>{s(async()=>{await i.setAuthOrgMemberRole({memberId:N(r.id),role:b.trim()}),h(),d()})},"u"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=b,e[7]=s,e[8]=g):g=e[8];let p=g,f;e[9]!==b?(f=b.trim(),e[9]=b,e[10]=f):f=e[10];let y=f!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(S=>{u(S.target.value)},"y"),e[17]=C):C=e[17];let k;e[18]!==b?(k=(0,n.jsx)(Z,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:b}),e[18]=b,e[19]=k):k=e[19];let w;e[20]!==I||e[21]!==k?(w=(0,n.jsx)(W,{htmlFor:"org-member-role-value",label:I,children:k}),e[20]=I,e[21]=k,e[22]=w):w=e[22];let x;return e[23]!==a||e[24]!==l||e[25]!==d||e[26]!==p||e[27]!==w||e[28]!==y||e[29]!==z||e[30]!==v?(x=(0,n.jsx)(de,{busy:a,canSubmit:y,error:l,onClose:d,onSubmit:p,submitLabel:z,testId:"org-member-role",title:v,children:w}),e[23]=a,e[24]=l,e[25]=d,e[26]=p,e[27]=w,e[28]=y,e[29]=z,e[30]=v,e[31]=x):x=e[31],x},"Et"),At=c(t=>{let e=(0,U.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.name):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==a||e[3]!==r||e[4]!==g||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==b||e[9]!==o?.id?(f=c(()=>{b(async()=>{await(r==="create"?a.createAuthOrgTeam({name:g.trim(),organizationId:i}):a.updateAuthOrgTeam({name:g.trim(),teamId:N(o?.id)})),h(),d()})},"b"),e[2]=a,e[3]=r,e[4]=g,e[5]=d,e[6]=h,e[7]=i,e[8]=b,e[9]=o?.id,e[10]=f):f=e[10];let y=f,z;e[11]!==g?(z=g.trim(),e[11]=g,e[12]=z):z=e[12];let v=z!=="",I;e[13]!==r||e[14]!==l?(I=l(r==="create"?"Create":"Save"),e[13]=r,e[14]=l,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==l?(C=l(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=l,e[18]=C):C=e[18];let k;e[19]!==l?(k=l("name"),e[19]=l,e[20]=k):k=e[20];let w;e[21]===Symbol.for("react.memo_cache_sentinel")?(w=c(A=>{p(A.target.value)},"$"),e[21]=w):w=e[21];let x;e[22]!==g?(x=(0,n.jsx)(Z,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:w,value:g}),e[22]=g,e[23]=x):x=e[23];let S;e[24]!==k||e[25]!==x?(S=(0,n.jsx)(W,{htmlFor:"org-team-form-name",label:k,children:x}),e[24]=k,e[25]=x,e[26]=S):S=e[26];let O;return e[27]!==s||e[28]!==m||e[29]!==d||e[30]!==y||e[31]!==S||e[32]!==v||e[33]!==I||e[34]!==C?(O=(0,n.jsx)(de,{busy:s,canSubmit:v,error:m,onClose:d,onSubmit:y,submitLabel:I,testId:"org-team-form",title:C,children:S}),e[27]=s,e[28]=m,e[29]=d,e[30]=y,e[31]=S,e[32]=v,e[33]=I,e[34]=C,e[35]=O):O=e[35],O},"ft"),Jt=c(t=>{let e=(0,U.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=re(),o=q(),{busy:a,error:l,run:s}=le(),[m,b]=(0,j.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==s||e[4]!==h||e[5]!==m?(u=c(()=>{s(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:m.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=s,e[4]=h,e[5]=m,e[6]=u):u=e[6];let g=u,p;e[7]!==m?(p=m.trim(),e[7]=m,e[8]=p):p=e[8];let f=p!=="",y;e[9]!==o?(y=o("Add member"),e[9]=o,e[10]=y):y=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(x=>{b(x.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==m?(C=(0,n.jsx)(Z,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:m}),e[16]=m,e[17]=C):C=e[17];let k;e[18]!==v||e[19]!==C?(k=(0,n.jsx)(W,{htmlFor:"org-team-add-member-user",label:v,children:C}),e[18]=v,e[19]=C,e[20]=k):k=e[20];let w;return e[21]!==a||e[22]!==l||e[23]!==r||e[24]!==g||e[25]!==f||e[26]!==y||e[27]!==z||e[28]!==k?(w=(0,n.jsx)(de,{busy:a,canSubmit:f,error:l,onClose:r,onSubmit:g,submitLabel:y,testId:"org-team-add-member",title:z,children:k}),e[21]=a,e[22]=l,e[23]=r,e[24]=g,e[25]=f,e[26]=y,e[27]=z,e[28]=k,e[29]=w):w=e[29],w},"Lt"),_t=c(t=>{let e=(0,U.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,a=re(),l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==o?(u=o?N(o.role):"",e[0]=o,e[1]=u):u=e[1];let[g,p]=(0,j.useState)(u),f;e[2]!==r||e[3]!==o?.permission?(f=r==="edit"?$t(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=f):f=e[4];let[y,z]=(0,j.useState)(f),v;e[5]!==a||e[6]!==r||e[7]!==g||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==y||e[12]!==o?.id||e[13]!==b?(v=c(()=>{b(async()=>{let T=Et(y);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:T,role:g.trim()}):a.updateAuthOrgRole({permission:T,roleId:N(o?.id)})),h(),d()})},"p"),e[5]=a,e[6]=r,e[7]=g,e[8]=d,e[9]=h,e[10]=i,e[11]=y,e[12]=o?.id,e[13]=b,e[14]=v):v=e[14];let I=v,C;e[15]!==r||e[16]!==g||e[17]!==y?(C=y.trim()!==""&&(r==="edit"||g.trim()!==""),e[15]=r,e[16]=g,e[17]=y,e[18]=C):C=e[18];let k;e[19]!==r||e[20]!==l?(k=l(r==="create"?"Create":"Save"),e[19]=r,e[20]=l,e[21]=k):k=e[21];let w;e[22]!==r||e[23]!==l?(w=l(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=l,e[24]=w):w=e[24];let x;e[25]!==r||e[26]!==g||e[27]!==l?(x=r==="create"&&(0,n.jsx)(W,{htmlFor:"org-role-form-name",label:l("Role name"),children:(0,n.jsx)(Z,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c(T=>{p(T.target.value)},"onChange"),value:g})}),e[25]=r,e[26]=g,e[27]=l,e[28]=x):x=e[28];let S;e[29]!==l?(S=l('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=l,e[30]=S):S=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=c(T=>{z(T.target.value)},"D"),e[31]=O):O=e[31];let A;e[32]!==y?(A=(0,n.jsx)(yt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:O,value:y}),e[32]=y,e[33]=A):A=e[33];let D;e[34]!==A||e[35]!==S?(D=(0,n.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=D):D=e[36];let $;return e[37]!==s||e[38]!==m||e[39]!==d||e[40]!==I||e[41]!==D||e[42]!==C||e[43]!==k||e[44]!==w||e[45]!==x?($=(0,n.jsxs)(de,{busy:s,canSubmit:C,error:m,onClose:d,onSubmit:I,submitLabel:k,testId:"org-role-form",title:w,children:[x,D]}),e[37]=s,e[38]=m,e[39]=d,e[40]=I,e[41]=D,e[42]=C,e[43]=k,e[44]=w,e[45]=x,e[46]=$):$=e[46],$},"pt"),Tt=c(t=>{let e=(0,U.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:a}=t,l=q(),{busy:s,error:m,run:b}=le(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==b?(u=c(()=>{b(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=b,e[4]=u):u=e[4];let g=u,p;e[5]!==l?(p=l("Delete"),e[5]=l,e[6]=p):p=e[6];let f;e[7]!==d?(f=(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let y;return e[9]!==s||e[10]!==m||e[11]!==h||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==a?(y=(0,n.jsx)(de,{busy:s,canSubmit:!0,destructive:!0,error:m,onClose:h,onSubmit:g,submitLabel:p,testId:o,title:a,children:f}),e[9]=s,e[10]=m,e[11]=h,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=a,e[17]=y):y=e[17],y},"kt"),Ge=c(t=>{let e=(0,U.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let a;e[2]!==r?(a=r!==void 0&&(0,n.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let l;e[4]!==o||e[5]!==a?(l=(0,n.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=l):l=e[6];let s;e[7]!==d?(s=(0,n.jsx)(bt,{className:"px-0",children:d}),e[7]=d,e[8]=s):s=e[8];let m;return e[9]!==l||e[10]!==s||e[11]!==i?(m=(0,n.jsxs)(ht,{className:"overflow-hidden py-0","data-testid":i,children:[l,s]}),e[9]=l,e[10]=s,e[11]=i,e[12]=m):m=e[12],m},"Ve"),Ke=c(t=>{let e=(0,U.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=q(),a;e[0]!==r?(a=r.map(Bt),e[0]=r,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("Actions"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==l?(s=(0,n.jsx)(se,{"aria-label":l}),e[4]=l,e[5]=s):s=e[5];let m;e[6]!==a||e[7]!==s?(m=(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[a,s]})}),e[6]=a,e[7]=s,e[8]=m):m=e[8];let b;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let p;e[14]!==r||e[15]!==d||e[16]!==h?(p=c((f,y)=>{let z=N(f.id),v=z===""?`index-${y.toString()}`:z;return(0,n.jsxs)(Ze,{"data-testid":`${h}-${v}`,children:[r.map(I=>(0,n.jsx)(me,{className:I.className,children:I.render(f)},I.head)),(0,n.jsx)(me,{children:(0,n.jsx)("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},"f"),e[14]=r,e[15]=d,e[16]=h,e[17]=p):p=e[17],b=i.map(p),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=b}else b=e[13];let u;e[18]!==b?(u=(0,n.jsx)(vt,{children:b}),e[18]=b,e[19]=u):u=e[19];let g;return e[20]!==m||e[21]!==u?(g=(0,n.jsxs)(ft,{children:[m,u]}),e[20]=m,e[21]=u,e[22]=g):g=e[22],g},"Xe");function Bt(t){return(0,n.jsx)(se,{children:t.head},t.head)}c(Bt,"jt");var Ut=c(t=>{let e=(0,U.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,a=q(),l;e[0]!==o?(l=c(()=>{o({kind:"add-member"})},"a"),e[0]=o,e[1]=l):l=e[1];let s;e[2]!==a?(s=a("Add member"),e[2]=a,e[3]=s):s=e[3];let m;e[4]!==l||e[5]!==s?(m=(0,n.jsx)(L,{"data-testid":"org-open-add-member",onClick:l,size:"xs",type:"button",variant:"outline",children:s}),e[4]=l,e[5]=s,e[6]=m):m=e[6];let b;e[7]!==o?(b=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=b):b=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let g;e[11]!==b||e[12]!==u?(g=(0,n.jsx)(L,{"data-testid":"org-open-invite-member",onClick:b,size:"xs",type:"button",variant:"outline",children:u}),e[11]=b,e[12]=u,e[13]=g):g=e[13];let p;e[14]!==m||e[15]!==g?(p=(0,n.jsxs)(n.Fragment,{children:[m,g]}),e[14]=m,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==a?(f=a("Members"),e[17]=a,e[18]=f):f=e[18];let y;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==a?(y=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-members-empty",title:a("No members.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(v=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-member-role-${N(v.id)}`,onClick:c(()=>{o({kind:"member-role",member:v})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,n.jsx)(L,{"data-testid":`org-remove-member-${N(v.id)}`,disabled:r,onClick:c(()=>{d(N(v.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=a,e[25]=y):y=e[25];let z;return e[26]!==p||e[27]!==f||e[28]!==y?(z=(0,n.jsx)(Ge,{action:p,heading:f,testId:"org-members",children:y}),e[26]=p,e[27]=f,e[28]=y,e[29]=z):z=e[29],z},"Pt"),qt=c(t=>{let e=(0,U.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,l=q(),s;e[0]!==d?(s=c(()=>{d({kind:"team-create"})},"s"),e[0]=d,e[1]=s):s=e[1];let m;e[2]!==l?(m=l("New team"),e[2]=l,e[3]=m):m=e[3];let b;e[4]!==s||e[5]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-create-team",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[4]=s,e[5]=m,e[6]=b):b=e[6];let u;e[7]!==l?(u=l("Teams"),e[7]=l,e[8]=u):u=e[8];let g;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==l||e[14]!==o||e[15]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-teams-empty",title:l("No teams.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"aria-pressed":i===N(f.id),"data-testid":`org-team-select-${N(f.id)}`,onClick:c(()=>{h(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Members")}),(0,n.jsx)(L,{"data-testid":`org-team-rename-${N(f.id)}`,onClick:c(()=>{d({kind:"team-rename",team:f})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Rename")}),(0,n.jsx)(L,{"data-testid":`org-team-delete-${N(f.id)}`,onClick:c(()=>{r(f)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=l,e[14]=o,e[15]=a,e[16]=g):g=e[16];let p;return e[17]!==b||e[18]!==u||e[19]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-teams",children:g}),e[17]=b,e[18]=u,e[19]=g,e[20]=p):p=e[20],p},"Bt"),Ht=c(t=>{let e=(0,U.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,l=q(),s;e[0]!==h||e[1]!==i?(s=c(()=>{h({kind:"team-add-member",teamId:i})},"s"),e[0]=h,e[1]=i,e[2]=s):s=e[2];let m;e[3]!==l?(m=l("Add member"),e[3]=l,e[4]=m):m=e[4];let b;e[5]!==s||e[6]!==m?(b=(0,n.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:s,size:"xs",type:"button",variant:"outline",children:m}),e[5]=s,e[6]=m,e[7]=b):b=e[7];let u;e[8]!==l?(u=l("Team members"),e[8]=l,e[9]=u):u=e[9];let g;e[10]!==r||e[11]!==d||e[12]!==l||e[13]!==o||e[14]!==a?(g=a.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-team-members-empty",title:l("No team members.")})}):(0,n.jsx)(Ke,{columns:o,rowActions:c(f=>(0,n.jsx)(L,{"data-testid":`org-team-remove-member-${N(f.id)}`,disabled:r,onClick:c(()=>{d(N(f.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=d,e[12]=l,e[13]=o,e[14]=a,e[15]=g):g=e[15];let p;return e[16]!==b||e[17]!==u||e[18]!==g?(p=(0,n.jsx)(Ge,{action:b,heading:u,testId:"org-team-members",children:g}),e[16]=b,e[17]=u,e[18]=g,e[19]=p):p=e[19],p},"Jt"),Qt=c(t=>{let e=(0,U.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=q(),a;e[0]!==d?(a=c(()=>{d({kind:"role-create"})},"n"),e[0]=d,e[1]=a):a=e[1];let l;e[2]!==o?(l=o("New role"),e[2]=o,e[3]=l):l=e[3];let s;e[4]!==a||e[5]!==l?(s=(0,n.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:l}),e[4]=a,e[5]=l,e[6]=s):s=e[6];let m;e[7]!==o?(m=o("Roles"),e[7]=o,e[8]=m):m=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(b=i.length===0?(0,n.jsx)("div",{className:"p-3",children:(0,n.jsx)(ce,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,n.jsx)(Ke,{columns:h,rowActions:c(g=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(L,{"data-testid":`org-role-edit-${N(g.id)}`,onClick:c(()=>{d({kind:"role-edit",role:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,n.jsx)(L,{"data-testid":`org-role-delete-${N(g.id)}`,onClick:c(()=>{r(N(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=b):b=e[14];let u;return e[15]!==s||e[16]!==m||e[17]!==b?(u=(0,n.jsx)(Ge,{action:s,heading:m,testId:"org-roles",children:b}),e[15]=s,e[16]=m,e[17]=b,e[18]=u):u=e[18],u},"Ut"),Wt=c(t=>{let e=(0,U.c)(199),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=re(),o=q(),[a,l]=(0,j.useState)(null),[s,m]=(0,j.useState)(null),[b,u]=(0,j.useState)(!1),[g,p]=(0,j.useState)(null),f;e[0]!==r?(f=["lunora-auth-org-members",r],e[0]=r,e[1]=f):f=e[1];let y;e[2]!==i||e[3]!==r?(y=c(()=>i.listAuthOrgMembers({limit:200,organizationId:r}),"v"),e[2]=i,e[3]=r,e[4]=y):y=e[4];let z=ue(f,y),v;e[5]!==r?(v=["lunora-auth-org-invitations",r],e[5]=r,e[6]=v):v=e[6];let I;e[7]!==i||e[8]!==r?(I=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"C"),e[7]=i,e[8]=r,e[9]=I):I=e[9];let C=ue(v,I),k;e[10]!==r?(k=["lunora-auth-org-teams",r],e[10]=r,e[11]=k):k=e[11];let w;e[12]!==i||e[13]!==r?(w=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"$"),e[12]=i,e[13]=r,e[14]=w):w=e[14];let x;e[15]!==h?(x={enabled:h},e[15]=h,e[16]=x):x=e[16];let S=ue(k,w,x),O;e[17]!==r?(O=["lunora-auth-org-roles",r],e[17]=r,e[18]=O):O=e[18];let A;e[19]!==i||e[20]!==r?(A=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"A"),e[19]=i,e[20]=r,e[21]=A):A=e[21];let D;e[22]!==d?(D={enabled:d},e[22]=d,e[23]=D):D=e[23];let $=ue(O,A,D),T;e[24]!==s?(T=["lunora-auth-org-team-members",s],e[24]=s,e[25]=T):T=e[25];let P;e[26]!==i||e[27]!==s?(P=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:s??""}),"P"),e[26]=i,e[27]=s,e[28]=P):P=e[28];let Q=s!==null,J;e[29]!==Q?(J={enabled:Q},e[29]=Q,e[30]=J):J=e[30];let E=ue(T,P,J),B;e[31]!==z.data?.rows?(B=z.data?.rows??[],e[31]=z.data?.rows,e[32]=B):B=e[32];let Y=B,M;e[33]!==C.data?.rows?(M=C.data?.rows??[],e[33]=C.data?.rows,e[34]=M):M=e[34];let R=M,H;e[35]!==S.data?.rows?(H=S.data?.rows??[],e[35]=S.data?.rows,e[36]=H):H=e[36];let ie=H,K;e[37]!==$.data?.rows?(K=$.data?.rows??[],e[37]=$.data?.rows,e[38]=K):K=e[38];let ee=K,X;e[39]!==s||e[40]!==E?(X=s===null?[]:E.data?.rows??[],e[39]=s,e[40]=E,e[41]=X):X=e[41];let te=X,oe=z.error??C.error??S.error??$.error??E.error,V;e[42]!==C||e[43]!==z||e[44]!==d||e[45]!==$||e[46]!==s||e[47]!==E||e[48]!==h||e[49]!==S?(V=c(()=>{z.refetch(),C.refetch(),h&&S.refetch(),d&&$.refetch(),s!==null&&E.refetch()},"W"),e[42]=C,e[43]=z,e[44]=d,e[45]=$,e[46]=s,e[47]=E,e[48]=h,e[49]=S,e[50]=V):V=e[50];let _=V;Ct(_,!0);let ne;e[51]===Symbol.for("react.memo_cache_sentinel")?(ne=c(()=>{l(null)},"oe"),e[51]=ne):ne=e[51];let F=ne,Xe;e[52]!==_?(Xe=c(G=>{xt((async()=>{u(!0),p(null);try{await G(),_(),u(!1)}catch(lt){p(wt(lt)),u(!1)}})())},"Ye"),e[52]=_,e[53]=Xe):Xe=e[53];let ae=Xe,Ve;e[54]!==i||e[55]!==o?(Ve=c(G=>{let lt=N(G.id);l({action:c(async()=>{await i.removeAuthOrgTeam({teamId:lt}),m(It=>It===lt?null:It)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"Ze"),e[54]=i,e[55]=o,e[56]=Ve):Ve=e[56];let it=Ve,ge;e[57]!==o?(ge=o("userId"),e[57]=o,e[58]=ge):ge=e[58];let he;e[59]!==ge?(he={head:ge,render:Yt},e[59]=ge,e[60]=he):he=e[60];let be;e[61]!==o?(be=o("role"),e[61]=o,e[62]=be):be=e[62];let fe;e[63]!==be?(fe={head:be,render:Zt},e[63]=be,e[64]=fe):fe=e[64];let et;e[65]!==he||e[66]!==fe?(et=[he,fe],e[65]=he,e[66]=fe,e[67]=et):et=e[67];let st=et,pe;e[68]!==o?(pe=o("email"),e[68]=o,e[69]=pe):pe=e[69];let ve;e[70]!==pe?(ve={head:pe,render:Gt},e[70]=pe,e[71]=ve):ve=e[71];let ye;e[72]!==o?(ye=o("role"),e[72]=o,e[73]=ye):ye=e[73];let Ce;e[74]!==ye?(Ce={head:ye,render:Kt},e[74]=ye,e[75]=Ce):Ce=e[75];let Ie;e[76]!==o?(Ie=o("status"),e[76]=o,e[77]=Ie):Ie=e[77];let we;e[78]!==Ie?(we={head:Ie,render:Xt},e[78]=Ie,e[79]=we):we=e[79];let tt;e[80]!==ve||e[81]!==Ce||e[82]!==we?(tt=[ve,Ce,we],e[80]=ve,e[81]=Ce,e[82]=we,e[83]=tt):tt=e[83];let mt=tt,xe;e[84]!==o?(xe=o("id"),e[84]=o,e[85]=xe):xe=e[85];let ze;e[86]!==xe?(ze={className:"font-mono text-xs",head:xe,render:Vt},e[86]=xe,e[87]=ze):ze=e[87];let ke;e[88]!==o?(ke=o("name"),e[88]=o,e[89]=ke):ke=e[89];let Se;e[90]!==ke?(Se={head:ke,render:er},e[90]=ke,e[91]=Se):Se=e[91];let rt;e[92]!==ze||e[93]!==Se?(rt=[ze,Se],e[92]=ze,e[93]=Se,e[94]=rt):rt=e[94];let dt=rt,Ne;e[95]!==o?(Ne=o("userId"),e[95]=o,e[96]=Ne):Ne=e[96];let ot;e[97]!==Ne?(ot=[{head:Ne,render:tr}],e[97]=Ne,e[98]=ot):ot=e[98];let ct=ot,De;e[99]!==o?(De=o("role"),e[99]=o,e[100]=De):De=e[100];let Ae;e[101]!==De?(Ae={head:De,render:rr},e[101]=De,e[102]=Ae):Ae=e[102];let _e;e[103]!==o?(_e=o("Permission"),e[103]=o,e[104]=_e):_e=e[104];let Oe;e[105]!==_e?(Oe={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:or},e[105]=_e,e[106]=Oe):Oe=e[106];let nt;e[107]!==Ae||e[108]!==Oe?(nt=[Ae,Oe],e[107]=Ae,e[108]=Oe,e[109]=nt):nt=e[109];let ut=nt,$e;e[110]!==oe?($e=oe!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:oe}),e[110]=oe,e[111]=$e):$e=e[111];let Te;e[112]!==g?(Te=g!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[112]=g,e[113]=Te):Te=e[113];let Me;e[114]!==i||e[115]!==ae?(Me=c(G=>{ae(()=>i.removeAuthOrgMember({memberId:G}))},"_e"),e[114]=i,e[115]=ae,e[116]=Me):Me=e[116];let Re;e[117]!==b||e[118]!==st||e[119]!==Y||e[120]!==Me?(Re=(0,n.jsx)(Ut,{actionBusy:b,memberColumns:st,members:Y,onDialog:l,onRemoveMember:Me}),e[117]=b,e[118]=st,e[119]=Y,e[120]=Me,e[121]=Re):Re=e[121];let Fe;e[122]!==b||e[123]!==i||e[124]!==mt||e[125]!==R||e[126]!==ae||e[127]!==o?(Fe=R.length>0&&(0,n.jsx)(Ge,{heading:o("Invitations"),testId:"org-invitations",children:(0,n.jsx)(Ke,{columns:mt,rowActions:c(G=>(0,n.jsx)(L,{"data-testid":`org-cancel-invitation-${N(G.id)}`,disabled:b,onClick:c(()=>{ae(()=>i.cancelAuthOrgInvitation({invitationId:N(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:R})}),e[122]=b,e[123]=i,e[124]=mt,e[125]=R,e[126]=ae,e[127]=o,e[128]=Fe):Fe=e[128];let Ee;e[129]!==it||e[130]!==s||e[131]!==dt||e[132]!==ie||e[133]!==h?(Ee=h&&(0,n.jsx)(qt,{onConfirmDeleteTeam:it,onDialog:l,onSelectTeam:m,selectedTeam:s,teamColumns:dt,teams:ie}),e[129]=it,e[130]=s,e[131]=dt,e[132]=ie,e[133]=h,e[134]=Ee):Ee=e[134];let Le;e[135]!==b||e[136]!==i||e[137]!==ae||e[138]!==s||e[139]!==ct||e[140]!==te||e[141]!==h?(Le=h&&s!==null&&(0,n.jsx)(Ht,{actionBusy:b,onDialog:l,onRemoveTeamMember:c(G=>{ae(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:s,teamMemberColumns:ct,teamMembers:te}),e[135]=b,e[136]=i,e[137]=ae,e[138]=s,e[139]=ct,e[140]=te,e[141]=h,e[142]=Le):Le=e[142];let je;e[143]!==i||e[144]!==ut||e[145]!==ee||e[146]!==d||e[147]!==o?(je=d&&(0,n.jsx)(Qt,{onConfirmDeleteRole:c(G=>{l({action:c(()=>i.deleteAuthOrgRole({roleId:G}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:l,roleColumns:ut,roles:ee}),e[143]=i,e[144]=ut,e[145]=ee,e[146]=d,e[147]=o,e[148]=je):je=e[148];let Pe;e[149]!==a?.kind||e[150]!==r||e[151]!==_?(Pe=a?.kind==="add-member"&&(0,n.jsx)(Lt,{onClose:F,onDone:_,organizationId:r}),e[149]=a?.kind,e[150]=r,e[151]=_,e[152]=Pe):Pe=e[152];let Je;e[153]!==a?.kind||e[154]!==r||e[155]!==_?(Je=a?.kind==="invite-member"&&(0,n.jsx)(jt,{onClose:F,onDone:_,organizationId:r}),e[153]=a?.kind,e[154]=r,e[155]=_,e[156]=Je):Je=e[156];let Be;e[157]!==a||e[158]!==_?(Be=a?.kind==="member-role"&&(0,n.jsx)(Pt,{member:a.member,onClose:F,onDone:_}),e[157]=a,e[158]=_,e[159]=Be):Be=e[159];let Ue;e[160]!==a?.kind||e[161]!==r||e[162]!==_?(Ue=a?.kind==="team-create"&&(0,n.jsx)(At,{mode:"create",onClose:F,onDone:_,organizationId:r}),e[160]=a?.kind,e[161]=r,e[162]=_,e[163]=Ue):Ue=e[163];let qe;e[164]!==a||e[165]!==r||e[166]!==_?(qe=a?.kind==="team-rename"&&(0,n.jsx)(At,{mode:"edit",onClose:F,onDone:_,organizationId:r,team:a.team}),e[164]=a,e[165]=r,e[166]=_,e[167]=qe):qe=e[167];let He;e[168]!==a||e[169]!==_?(He=a?.kind==="team-add-member"&&(0,n.jsx)(Jt,{onClose:F,onDone:_,teamId:a.teamId}),e[168]=a,e[169]=_,e[170]=He):He=e[170];let Qe;e[171]!==a?.kind||e[172]!==r||e[173]!==_?(Qe=a?.kind==="role-create"&&(0,n.jsx)(_t,{mode:"create",onClose:F,onDone:_,organizationId:r}),e[171]=a?.kind,e[172]=r,e[173]=_,e[174]=Qe):Qe=e[174];let We;e[175]!==a||e[176]!==r||e[177]!==_?(We=a?.kind==="role-edit"&&(0,n.jsx)(_t,{mode:"edit",onClose:F,onDone:_,organizationId:r,role:a.role}),e[175]=a,e[176]=r,e[177]=_,e[178]=We):We=e[178];let Ye;e[179]!==a||e[180]!==_?(Ye=a?.kind==="confirm"&&(0,n.jsx)(Tt,{action:a.action,message:a.message,onClose:F,onDone:_,testId:a.testId,title:a.title}),e[179]=a,e[180]=_,e[181]=Ye):Ye=e[181];let at;return e[182]!==$e||e[183]!==Te||e[184]!==Re||e[185]!==Fe||e[186]!==Ee||e[187]!==Le||e[188]!==je||e[189]!==Pe||e[190]!==Je||e[191]!==Be||e[192]!==Ue||e[193]!==qe||e[194]!==He||e[195]!==Qe||e[196]!==We||e[197]!==Ye?(at=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Te,Re,Fe,Ee,Le,je,Pe,Je,Be,Ue,qe,He,Qe,We,Ye]}),e[182]=$e,e[183]=Te,e[184]=Re,e[185]=Fe,e[186]=Ee,e[187]=Le,e[188]=je,e[189]=Pe,e[190]=Je,e[191]=Be,e[192]=Ue,e[193]=qe,e[194]=He,e[195]=Qe,e[196]=We,e[197]=Ye,e[198]=at):at=e[198],at},"Ht");function Yt(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(Yt,"Kt");function Zt(t){return N(t.role)}c(Zt,"qt");function Gt(t){return N(t.email)}c(Gt,"Gt");function Kt(t){return N(t.role)}c(Kt,"Qt");function Xt(t){return N(t.status)}c(Xt,"Vt");function Vt(t){return N(t.id)}c(Vt,"Xt");function er(t){return N(t.name)}c(er,"Yt");function tr(t){return(0,n.jsx)("span",{className:"font-mono text-xs",children:N(t.userId)})}c(tr,"Zt");function rr(t){return N(t.role)}c(rr,"Wt");function or(t){return N(t.permission)}c(or,"er");var yr=c(()=>{let t=(0,U.c)(62),e=re(),r=q(),{config:d,ready:h}=St(),i=d.capabilities.organization,[o,a]=(0,j.useState)(null),[l,s]=(0,j.useState)(null),m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=["lunora-auth-orgs"],t[0]=m):m=t[0];let b;t[1]!==e?(b=c(()=>e.listAuthOrganizations({limit:100}),"h"),t[1]=e,t[2]=b):b=t[2];let u;t[3]!==i?(u={enabled:i},t[3]=i,t[4]=u):u=t[4];let g=ue(m,b,u),p=g.data?.rows??null,f;t[5]!==g?(f=c(()=>{g.refetch()},"b"),t[5]=g,t[6]=f):f=t[6],Ct(f,i);let y;t[7]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{s(null)},"v"),t[7]=y):y=t[7];let z=y,v;t[8]!==g?(v=c(()=>{g.refetch()},"p"),t[8]=g,t[9]=v):v=t[9];let I=v,C;t[10]===Symbol.for("react.memo_cache_sentinel")?(C=c(M=>{a(M)},"y"),t[10]=C):C=t[10];let k=C;if(h&&!i){let M;t[11]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[11]=r,t[12]=M):M=t[12];let R;t[13]!==r?(R=r("Organizations are not enabled."),t[13]=r,t[14]=R):R=t[14];let H;return t[15]!==M||t[16]!==R?(H=(0,n.jsx)(ce,{description:M,testId:"org-disabled",title:R}),t[15]=M,t[16]=R,t[17]=H):H=t[17],H}let w;t[18]!==r?(w=r("Organizations"),t[18]=r,t[19]=w):w=t[19];let x;t[20]!==w?(x=(0,n.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:w}),t[20]=w,t[21]=x):x=t[21];let S;t[22]===Symbol.for("react.memo_cache_sentinel")?(S=c(()=>{s({kind:"create"})},"z"),t[22]=S):S=t[22];let O;t[23]!==r?(O=r("New organization"),t[23]=r,t[24]=O):O=t[24];let A;t[25]!==O?(A=(0,n.jsx)(L,{"data-testid":"org-new",onClick:S,size:"sm",type:"button",children:O}),t[25]=O,t[26]=A):A=t[26];let D;t[27]!==A||t[28]!==x?(D=(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[x,A]}),t[27]=A,t[28]=x,t[29]=D):D=t[29];let $;t[30]!==g.error?($=g.error!==null&&(0,n.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[30]=g.error,t[31]=$):$=t[31];let T;t[32]!==p||t[33]!==r?(T=p!==null&&p.length===0&&(0,n.jsx)(ce,{testId:"org-empty",title:r("No organizations.")}),t[32]=p,t[33]=r,t[34]=T):T=t[34];let P;t[35]!==p||t[36]!==o||t[37]!==r?(P=p!==null&&p.length>0&&(0,n.jsx)(ht,{className:"overflow-hidden py-0",children:(0,n.jsx)(bt,{className:"px-0",children:(0,n.jsxs)(ft,{"data-testid":"org-table",children:[(0,n.jsx)(pt,{children:(0,n.jsxs)(Ze,{children:[(0,n.jsx)(se,{children:r("id")}),(0,n.jsx)(se,{children:r("name")}),(0,n.jsx)(se,{children:r("slug")}),(0,n.jsx)(se,{children:r("created")}),(0,n.jsx)(se,{"aria-label":r("Actions")})]})}),(0,n.jsx)(vt,{children:p.map(M=>{let R=N(M.id);return(0,n.jsxs)(Ze,{"data-testid":`org-row-${R}`,children:[(0,n.jsx)(me,{className:"font-mono text-xs",children:R}),(0,n.jsx)(me,{children:N(M.name)}),(0,n.jsx)(me,{children:N(M.slug)}),(0,n.jsx)(me,{className:"text-muted-foreground tabular-nums",children:zt(M.createdAt)}),(0,n.jsx)(me,{children:(0,n.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,n.jsx)(L,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{k(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,n.jsx)(L,{"data-testid":`org-edit-${R}`,onClick:c(()=>{s({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,n.jsx)(L,{"data-testid":`org-delete-${R}`,onClick:c(()=>{s({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[35]=p,t[36]=o,t[37]=r,t[38]=P):P=t[38];let Q;t[39]!==d.organization||t[40]!==o?(Q=o!==null&&(0,n.jsx)(Wt,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[39]=d.organization,t[40]=o,t[41]=Q):Q=t[41];let J;t[42]!==l?.kind||t[43]!==I?(J=l?.kind==="create"&&(0,n.jsx)(Dt,{mode:"create",onClose:z,onDone:I}),t[42]=l?.kind,t[43]=I,t[44]=J):J=t[44];let E;t[45]!==l||t[46]!==I?(E=l?.kind==="edit"&&(0,n.jsx)(Dt,{mode:"edit",onClose:z,onDone:I,org:l.org}),t[45]=l,t[46]=I,t[47]=E):E=t[47];let B;t[48]!==e||t[49]!==l||t[50]!==I||t[51]!==r?(B=l?.kind==="delete"&&(0,n.jsx)(Tt,{action:c(async()=>{let M=N(l.org.id);await e.deleteAuthOrganization({organizationId:M}),a(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:z,onDone:I,testId:"org-delete",title:r("Delete organization")}),t[48]=e,t[49]=l,t[50]=I,t[51]=r,t[52]=B):B=t[52];let Y;return t[53]!==D||t[54]!==$||t[55]!==T||t[56]!==P||t[57]!==Q||t[58]!==J||t[59]!==E||t[60]!==B?(Y=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[D,$,T,P,Q,J,E,B]}),t[53]=D,t[54]=$,t[55]=T,t[56]=P,t[57]=Q,t[58]=J,t[59]=E,t[60]=B,t[61]=Y):Y=t[61],Y},"yr");export{yr as default};
@@ -1 +1 @@
1
- import{a as x}from"./chunk-VDW32UET.js";import{c as C}from"./chunk-UDOOZJO5.js";import{f as q}from"./chunk-UQV7Q5S4.js";import{d as k,f as g,g as y,m as S}from"./chunk-IUYFXK4X.js";import{a as f,e as w,f as L,g as F,h as O}from"./chunk-3XIESWL4.js";var v=w(L(),1);var j={},I=g(x.aiGenerateSql),T=g(x.aiTableFilter),A=g(x.aiChartConfig),R=f(s=>{let e=q(),[l,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=C(x.aiAvailable,j,{shardKey:s}),[u,i]=(0,v.useState)(!1),b=u||a.data?.available===!1,p=f(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"n"),h=f((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&i(!0)},"t");return{generate:f(async(t,o)=>{p("sql");try{let{result:c}=await e.query(I,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:f(async t=>{p("chart");try{let{result:o}=await e.query(A,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:f(t=>l[t]===!0,"pending"),reason:f(t=>n[t],"reason"),suggestFilter:f(async(t,o)=>{p("filter");try{let{result:c}=await e.query(T,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"k");var N=w(F(),1);var m=w(O(),1);var U=f((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&l.push({match:!1,offset:r,text:s.slice(r,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&l.push({match:!1,offset:r,text:s.slice(r)}),l},"N"),z=f(s=>{let e=(0,N.c)(9),{highlight:l,value:d}=s;if(d==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=i):i=e[0],i}let n,r,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let i=S(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:i,children:i});break e}n=i,r=U(i,l).map(D)}e[1]=l,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==r?(u=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=u):u=e[8],u},"v"),Q=f(s=>{let e=(0,N.c)(22),{columns:l,rows:d}=s,n=k(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=f((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"i"),e[7]=n,e[8]=t):t=e[8],u=d.map(t),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let i;e[9]!==a||e[10]!==u?(i=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=i):i=e[11];let b;if(e[12]!==l||e[13]!==d){let t;e[15]!==d?(t=f(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,_)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(z,{value:c[o]})},_))]},o),"i"),e[15]=d,e[16]=t):t=e[16],b=l.map(t),e[12]=l,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==i||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[i,p]})}),e[19]=i,e[20]=p,e[21]=h):h=e[21],h},"j"),V=f(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"O");function D(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}f(D,"k");export{R as a,z as b,Q as c,V as d};
1
+ import{a as x}from"./chunk-VDW32UET.js";import{c as C}from"./chunk-FZ2N52BV.js";import{f as q}from"./chunk-BDHAGUAY.js";import{d as k,f as g,g as y,m as S}from"./chunk-IUYFXK4X.js";import{a as f,e as w,f as L,g as F,h as O}from"./chunk-3XIESWL4.js";var v=w(L(),1);var j={},I=g(x.aiGenerateSql),T=g(x.aiTableFilter),A=g(x.aiChartConfig),R=f(s=>{let e=q(),[l,d]=(0,v.useState)({}),[n,r]=(0,v.useState)({}),a=C(x.aiAvailable,j,{shardKey:s}),[u,i]=(0,v.useState)(!1),b=u||a.data?.available===!1,p=f(t=>{d(o=>({...o,[t]:!0})),r(o=>({...o,[t]:void 0}))},"n"),h=f((t,o)=>{d(c=>({...c,[t]:!1})),o!==void 0&&r(c=>({...c,[t]:o})),o==="no-ai-binding"&&i(!0)},"t");return{generate:f(async(t,o)=>{p("sql");try{let{result:c}=await e.query(I,{failedError:o?.error,failedSql:o?.sql,prompt:t},y(s));return h("sql",c.degraded?c.reason:void 0),c.degraded?void 0:c.sql}catch{h("sql","ai-error");return}},"generate"),inferChart:f(async t=>{p("chart");try{let{result:o}=await e.query(A,t,y(s));return h("chart",o.degraded?o.reason:void 0),o.degraded?void 0:o.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:f(t=>l[t]===!0,"pending"),reason:f(t=>n[t],"reason"),suggestFilter:f(async(t,o)=>{p("filter");try{let{result:c}=await e.query(T,{prompt:t,table:o},y(s));return h("filter",c.degraded?c.reason:void 0),c.degraded?void 0:c.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:b}},"k");var N=w(F(),1);var m=w(O(),1);var U=f((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),r=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,r))a>r&&l.push({match:!1,offset:r,text:s.slice(r,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),r=a+e.length;return r<s.length&&l.push({match:!1,offset:r,text:s.slice(r)}),l},"N"),z=f(s=>{let e=(0,N.c)(9),{highlight:l,value:d}=s;if(d==null){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=i):i=e[0],i}let n,r,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let i=S(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:i,children:i});break e}n=i,r=U(i,l).map(D)}e[1]=l,e[2]=d,e[3]=n,e[4]=r,e[5]=a}else n=e[3],r=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==r?(u=(0,m.jsx)("span",{title:n,children:r}),e[6]=n,e[7]=r,e[8]=u):u=e[8],u},"v"),Q=f(s=>{let e=(0,N.c)(22),{columns:l,rows:d}=s,n=k(),r;e[0]!==n?(r=n("Field"),e[0]=n,e[1]=r):r=e[1];let a;e[2]!==r?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r}),e[2]=r,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let t;e[7]!==n?(t=f((o,c)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:c+1})},c),"i"),e[7]=n,e[8]=t):t=e[8],u=d.map(t),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let i;e[9]!==a||e[10]!==u?(i=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=i):i=e[11];let b;if(e[12]!==l||e[13]!==d){let t;e[15]!==d?(t=f(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((c,_)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(z,{value:c[o]})},_))]},o),"i"),e[15]=d,e[16]=t):t=e[16],b=l.map(t),e[12]=l,e[13]=d,e[14]=b}else b=e[14];let p;e[17]!==b?(p=(0,m.jsx)("tbody",{children:b}),e[17]=b,e[18]=p):p=e[18];let h;return e[19]!==i||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[i,p]})}),e[19]=i,e[20]=p,e[21]=h):h=e[21],h},"j"),V=f(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"O");function D(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}f(D,"k");export{R as a,z as b,Q as c,V as d};
@@ -1 +1 @@
1
- import{b as R}from"./chunk-QOP32XAE.js";import"./chunk-OKIEDUHL.js";import"./chunk-XXQUMVWH.js";import"./chunk-NQVE5YON.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-UDOOZJO5.js";import"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as g}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
1
+ import{b as R}from"./chunk-IBPWTHHW.js";import"./chunk-CAOA5AM4.js";import"./chunk-XXQUMVWH.js";import"./chunk-VR3OBMGZ.js";import"./chunk-QLQADHFE.js";import{a as p}from"./chunk-VDW32UET.js";import{c as h}from"./chunk-FZ2N52BV.js";import"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as g}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
@@ -1 +1 @@
1
- import{a as N}from"./chunk-OKIEDUHL.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-WJQLNYGX.js";import{a as x,e as b}from"./chunk-WQH3LT2P.js";import{d as h}from"./chunk-IUYFXK4X.js";import{a as s,e as p,f as R,h as T,j as g}from"./chunk-3XIESWL4.js";var $=p(R(),1);var e=p(T(),1);var S={ERROR:"error",INFO:"info",WARN:"warning"},B=s(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:S[r.level]}},"U"),j=["error","warning","info"],A={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=s((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"A"),U=s((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"O"),W=s((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"S"),q=s(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"j"),G=s(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let a=h(),[m,k]=(0,$.useState)("error"),I=q(o),u=(o??[]).filter(t=>t.level===m),E=s(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:j.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",A[t])}),O(a,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:U(a,t,I[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:a("Issue type")}),(0,e.jsx)(c,{children:a("Entity/item")}),(0,e.jsx)(c,{children:a("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:W(a,m)}),(0,e.jsx)("span",{className:"block text-sm",children:a("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"q");export{B as a,G as b};
1
+ import{a as N}from"./chunk-CAOA5AM4.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-WJQLNYGX.js";import{a as x,e as b}from"./chunk-WQH3LT2P.js";import{d as h}from"./chunk-IUYFXK4X.js";import{a as s,e as p,f as R,h as T,j as g}from"./chunk-3XIESWL4.js";var $=p(R(),1);var e=p(T(),1);var S={ERROR:"error",INFO:"info",WARN:"warning"},B=s(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:S[r.level]}},"U"),j=["error","warning","info"],A={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},O=s((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"A"),U=s((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"O"),W=s((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"S"),q=s(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"j"),G=s(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let a=h(),[m,k]=(0,$.useState)("error"),I=q(o),u=(o??[]).filter(t=>t.level===m),E=s(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:j.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",A[t])}),O(a,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:U(a,t,I[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:a("Issue type")}),(0,e.jsx)(c,{children:a("Entity/item")}),(0,e.jsx)(c,{children:a("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:W(a,m)}),(0,e.jsx)("span",{className:"block text-sm",children:a("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"q");export{B as a,G as b};
@@ -1 +1 @@
1
- import{a as Y}from"./chunk-Y32QIKBS.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-CJQ2534J.js";import{a as _,b as W}from"./chunk-QOP32XAE.js";import{a as U}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-OKIEDUHL.js";import"./chunk-XXQUMVWH.js";import"./chunk-NQVE5YON.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-UDOOZJO5.js";import{f as B}from"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
1
+ import{a as Y}from"./chunk-Y32QIKBS.js";import{a as V}from"./chunk-3CWGJYBB.js";import{a as G}from"./chunk-RMN2JN4S.js";import{b as Q}from"./chunk-GRL5MG3Z.js";import{a as z}from"./chunk-SFDOII3B.js";import{e as P}from"./chunk-SMIESS7P.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import{b as Z,c as ee}from"./chunk-5UY7MLRC.js";import{a as _,b as W}from"./chunk-IBPWTHHW.js";import{a as U}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import"./chunk-CAOA5AM4.js";import"./chunk-XXQUMVWH.js";import"./chunk-VR3OBMGZ.js";import"./chunk-QLQADHFE.js";import{a as I}from"./chunk-VDW32UET.js";import{c as M}from"./chunk-FZ2N52BV.js";import{f as B}from"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import"./chunk-WJQLNYGX.js";import"./chunk-WQH3LT2P.js";import{d as A,f as H,g as K,o as k}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as l,e as L,f as fe,g as he,h as me}from"./chunk-3XIESWL4.js";var j=L(he(),1);var u=L(fe(),1);var $=L(me(),1);var pe=l(t=>{let{suggestedIndex:e,table:r}=t;return!(typeof r!="string"||r.length===0||typeof e!="object"||e===null||!Array.isArray(e.fields)||e.fields.length===0)},"pe"),be=l((t,e,r)=>{let a=`"${t}"`,n=`"${e}"`,o=r.map(c=>`"${c}"`).join(", ");return`CREATE INDEX IF NOT EXISTS ${n} ON ${a} (${o});`},"ge"),ge=l(t=>{let e=(0,j.c)(19),{fields:r,indexName:a,table:n,testId:o}=t,c=A(),[T,p]=(0,u.useState)(!1),f;e[0]!==r||e[1]!==a||e[2]!==n?(f=l(()=>{let S="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(S===void 0)return;let y=be(n,a,r);k(S.writeText(y)),p(!0)},"d"),e[0]=r,e[1]=a,e[2]=n,e[3]=f):f=e[3];let v=f;if(T){let S=`${o}-applied`,y;e[4]!==c?(y=c("CREATE INDEX SQL copied to clipboard."),e[4]=c,e[5]=y):y=e[5];let E;return e[6]!==S||e[7]!==y?(E=(0,$.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":S,children:y}),e[6]=S,e[7]=y,e[8]=E):E=e[8],E}let w;e[9]!==c?(w=c("Apply?"),e[9]=c,e[10]=w):w=e[10];let h;e[11]!==c||e[12]!==n?(h=c("Apply index on {table}",{table:n}),e[11]=c,e[12]=n,e[13]=h):h=e[13];let x;return e[14]!==v||e[15]!==w||e[16]!==h||e[17]!==o?(x=(0,$.jsx)(Y,{confirmLabel:w,onConfirm:v,testId:o,children:h}),e[14]=v,e[15]=w,e[16]=h,e[17]=o,e[18]=x):x=e[18],x},"be"),ve=l((t,e)=>{let r=new Map;for(let a of e){let n=`${a.table} ${a.index}`;r.set(n,(r.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:r.get(`${a.table} ${a.index}`)??0,table:a.table}))},"xe"),xe=l(t=>{let e=new Map;for(let r of t)for(let a of r.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([r,a])=>({scans:a,table:r}))},"ye"),te=l((t,e)=>e.map(r=>({index:r.name,table:t})),"X"),ye=l(t=>{let e=ve(t.declaredIndexes??[],t.indexHits??[]),r=xe(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,o=n&&n.indexHits.length>0?n.indexHits:e,c=n&&n.tableScans.length>0?n.tableScans:r,T=n&&n.shardTraffic.length>0?n.shardTraffic:a,p=ee({indexHits:o,schema:{tables:[]},shardTraffic:T,tableScans:c},{lints:Z,source:"runtime"}),f=t.suppressHotScanTables;return(f===void 0?p:p.filter(v=>!(v.metadata.kind==="hot_scan"&&typeof v.metadata.table=="string"&&f.has(v.metadata.table)))).map(v=>_(v))},"ve"),we=H(I.listTables),Se=H(I.listTableIndexes),Te=H(I.listTablesIndexes),q=l(t=>`${(t*100).toFixed(1)}%`,"K"),ae=l(t=>`${(t/1e3).toFixed(2)}s`,"B"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Te"),Ie=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function")})[e.kind],"Ie"),ne=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:q(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:q(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:q(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:ae(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:ae(e.value)})})[e.kind],"J"),Ee=l(t=>{let e=(0,j.c)(10),{onJump:r,table:a}=t,n=A(),o;e[0]!==r||e[1]!==a?(o=l(()=>{r(a)},"o"),e[0]=r,e[1]=a,e[2]=o):o=e[2];let c=o,T=`in-add-index-${a}`,p;e[3]!==n||e[4]!==a?(p=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=p):p=e[5];let f;return e[6]!==c||e[7]!==T||e[8]!==p?(f=(0,$.jsx)(U,{"data-testid":T,onClick:c,size:"sm",type:"button",variant:"outline",children:p}),e[6]=c,e[7]=T,e[8]=p,e[9]=f):f=e[9],f},"Ee"),De=l(({initialShardKey:t,loadShardTraffic:e})=>{let r=B(),a=P(),n=A(),{queryShardKey:o,setShardKey:c,shardKey:T}=V(t),[p,f]=(0,u.useState)(null),[v,w]=(0,u.useState)(null),h=(0,u.useRef)(""),x=M(I.getMetrics,{},{live:!0,shardKey:o}),S=M(I.getFunctionStats,{},{live:!0,shardKey:o}),y=M(I.getAdvisories,{},{live:!0,shardKey:o}),E=x.data??null,F=S.data?.functions??null,O=y.data?.advisories??null,re=x.data?.indexHits??null,R=x.error!==null&&S.error!==null?x.error:null,se=e??(s=>r.shardTraffic(s)),ie=l(async(s,b)=>{let i=s[0];if(i===void 0||i===""){h.current===b&&w(null);return}try{let m=await se(i);if(h.current!==b)return;let d=new Map;for(let g of m.shards)d.has(g.shardKey)||d.set(g.shardKey,{requests:g.requests,shardKey:g.shardKey});w([...d.values()])}catch{h.current===b&&w(null)}},"V"),oe=l(async(s,b)=>{let i=await Promise.allSettled(s.map(async d=>[d,await r.query(Se,{table:d},K(b))])),m=[];for(let d of i)if(d.status==="fulfilled"){let[g,N]=d.value;m.push(...te(g,N.indexes))}return m},"G"),D=(0,u.useEffectEvent)(async s=>{h.current=s;let b=[];try{let i=await r.query(we,{},K(s));if(h.current!==s)return;Q(s),b=i.map(d=>d.name);let m=[];if(b.length>0)try{let d=await r.query(Te,{tables:b},K(s));if(h.current!==s)return;for(let[g,N]of Object.entries(d.indexesByTable))m.push(...te(g,N))}catch{if(m=await oe(b,s),h.current!==s)return}f(m)}catch{h.current===s&&f(null)}await ie(b,s)});(0,u.useEffect)(()=>{k(D(o))},[o]);let le=(0,u.useEffectEvent)(()=>{x.refetch(),S.refetch(),y.refetch(),k(D(o))});(0,u.useEffect)(()=>{let s=l(()=>{document.visibilityState==="visible"&&le()},"i");return document.addEventListener("visibilitychange",s),()=>{document.removeEventListener("visibilitychange",s)}},[]);let J=(0,u.useCallback)(s=>{k(a({search:{table:s},to:"/schema"}))},[a]),C=z(E,F),ce=new Set(C.filter(s=>s.kind==="missing-index").flatMap(s=>s.tables??[])),X=ye({declaredIndexes:p??[],functions:F,indexHits:re,shardTraffic:v,suppressHotScanTables:ce}),de=(0,u.useMemo)(()=>{let s=C.map(i=>{let m=i.kind==="missing-index"?i.tables??[]:[];return{action:m.length>0?m.map(d=>(0,$.jsx)(Ee,{onJump:J,table:d},d)):void 0,description:i.message===void 0?ne(n,i):`${ne(n,i)} \u2014 ${i.message}`,entity:i.fn,issueType:Ie(n,i),key:`${i.kind}:${i.fn??""}`,level:i.severity}}),b=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(O??[]).map(i=>{let m=_(i);if(b.has(i.name)&&pe(i.metadata)){let{table:d,suggestedIndex:g}=i.metadata,N=`in-apply-index-${d}-${g.name}`;return{...m,action:(0,$.jsx)(ge,{fields:g.fields,indexName:g.name,table:d,testId:N})}}return m}),...X,...s]},[O,C,J,X,n]),ue=(0,$.jsx)(G,{onChange:c,testId:"in-shard-input",value:T});return(0,$.jsx)(W,{error:R,errorSource:R===null?void 0:x.errorSource,rows:de,testId:"lunora-insights",toolbar:ue})},"Je");export{De as InsightsPanel};
@@ -1,2 +1,2 @@
1
- import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as x}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-OKIEDUHL.js";import"./chunk-XXQUMVWH.js";import"./chunk-NQVE5YON.js";import"./chunk-QLQADHFE.js";import{a as P}from"./chunk-VDW32UET.js";import{c as ue}from"./chunk-UDOOZJO5.js";import{f as le}from"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as i,e as Y,f as ge,g as ve,h as Ne,j as se}from"./chunk-3XIESWL4.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"xe");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"ae"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"ye"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"we"),Te=Z(P.clearCapturedMail),Le=Z(P.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:D,error:w,errorSource:C,isLoading:g,refetch:n}=ue(P.getCapturedMail,p),[k,f]=(0,N.useState)(null),[E,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,U]=(0,N.useState)(""),b=D?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"S"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let W=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"$"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let B=L,j;e[8]!==n?(j=i(()=>{n()},"T"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==W?(M=i(()=>{ae(W())},"L"),e[10]=W,e[11]=M):M=e[11];let R=M,_;e[12]!==B?(_=i(()=>{ae(B())},"j"),e[12]=B,e[13]=_):_=e[13];let G=_,$;e[14]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{U(m.currentTarget.value)},"M"),e[14]=$):$=e[14];let J=$,z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"_"),e[15]=z):z=e[15];let K=z,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"z"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,E),d=Ce(O),q;e[17]!==d?(q=i(()=>{d!==void 0&&me(d)},"O"),e[17]=d,e[18]=q):q=e[18];let V=q,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"I"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==R||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(I={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:R,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=R,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=I):I=e[37],I},"Se"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Te"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:D,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:E,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:U}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:D}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:U.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:E,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
1
+ import{a as fe}from"./chunk-LEDWUPXM.js";import"./chunk-2PJNAWB3.js";import{a as ie}from"./chunk-IC4L6G56.js";import{a as pe}from"./chunk-54MMVNPT.js";import"./chunk-BGBLQ563.js";import{R as de}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{a as x}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as ne}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as he}from"./chunk-CAOA5AM4.js";import"./chunk-XXQUMVWH.js";import"./chunk-VR3OBMGZ.js";import"./chunk-QLQADHFE.js";import{a as P}from"./chunk-VDW32UET.js";import{c as ue}from"./chunk-FZ2N52BV.js";import{f as le}from"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import{a as ce}from"./chunk-XQCVZAGU.js";import{d as oe,f as Z,g as ee,h as te,o as ae,q as me,r as re}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as i,e as Y,f as ge,g as ve,h as Ne,j as se}from"./chunk-3XIESWL4.js";var t=Y(Ne(),1);var xe=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"xe");var we=/https?:\/\/[^\s"'<>)]+/i,be=i(a=>a===void 0?void 0:we.exec(a)?.[0],"ae"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=i(a=>{if(a!==void 0)return be(a.html)??be(a.text)},"Ne"),ke=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"ye"),Se=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"we"),Te=Z(P.clearCapturedMail),Le=Z(P.sendTestMail),je=i(a=>{let e=(0,xe.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:D,error:w,errorSource:C,isLoading:g,refetch:n}=ue(P.getCapturedMail,p),[k,f]=(0,N.useState)(null),[E,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,U]=(0,N.useState)(""),b=D?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(Te,{},ee("")),S(null),n()}catch(m){f(te(m))}},"S"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let W=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Le,{},ee("")),n()}catch(m){f(te(m))}},"$"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let B=L,j;e[8]!==n?(j=i(()=>{n()},"T"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==W?(M=i(()=>{ae(W())},"L"),e[10]=W,e[11]=M):M=e[11];let R=M,_;e[12]!==B?(_=i(()=>{ae(B())},"j"),e[12]=B,e[13]=_):_=e[13];let G=_,$;e[14]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{U(m.currentTarget.value)},"M"),e[14]=$):$=e[14];let J=$,z;e[15]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"_"),e[15]=z):z=e[15];let K=z,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"z"),e[16]=A):A=e[16];let Q=A,F=ke(b,c),O=Se(F,E),d=Ce(O),q;e[17]!==d?(q=i(()=>{d!==void 0&&me(d)},"O"),e[17]=d,e[18]=q):q=e[18];let V=q,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"I"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==b||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==R||e[28]!==V||e[29]!==J||e[30]!==X||e[31]!==K||e[32]!==Q||e[33]!==G||e[34]!==O||e[35]!==v||e[36]!==F?(I={entries:b,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:R,onCopyLink:V,onFilterChange:J,onOpenLink:X,onSelectMessage:K,onSelectTab:Q,onSendTest:G,selected:O,tab:v,visible:F},e[21]=b,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=R,e[28]=V,e[29]=J,e[30]=X,e[31]=K,e[32]=Q,e[33]=G,e[34]=O,e[35]=v,e[36]=F,e[37]=I):I=e[37],I},"Se"),Me=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,_e=i(a=>`${Me}${a}`,"Te"),Je=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:D,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:E,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:U}=je({limit:a}),b=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"b");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(x,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(x,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:D}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:U.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:E,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(x,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(x,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(x,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:b(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:_e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
2
2
  `)}))]})]})]})]})},"We");export{Je as MailPanel};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-IGCNMZSB.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-UDOOZJO5.js";import"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import{a as I}from"./chunk-XQCVZAGU.js";import{a as k,b as A,c as D,d as g,e as c,f as l}from"./chunk-WJQLNYGX.js";import{a as b,e as S}from"./chunk-WQH3LT2P.js";import{d as w}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as p,e as y,g as j,h as E}from"./chunk-3XIESWL4.js";var _=y(j(),1);var t=y(E(),1);var T="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},W=p(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"_"),B=p(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(T))continue;let i=a.slice(T.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:u,event:d}=W(r.message);n.set(s,{detail:u,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"j"),F={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},H=p(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"W"),V=p(()=>{let e=(0,_.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),u=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==u||e[6]!==n){let N=B(H(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let h;e[14]!==o?(h=(0,t.jsx)(O,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==f||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[f,h]}),e[16]=f,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(k,{"data-testid":"containers-table",children:[(0,t.jsx)(A,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(D,{children:N.map(J)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=u,e[6]=n,e[7]=d}else d=e[7];return d},"H");function J(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:F[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}p(J,"B");export{V as default};
1
+ import{a as O}from"./chunk-IGCNMZSB.js";import{b as C}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-QLQADHFE.js";import{a as L}from"./chunk-VDW32UET.js";import{c as $}from"./chunk-FZ2N52BV.js";import"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import{a as I}from"./chunk-XQCVZAGU.js";import{a as k,b as A,c as D,d as g,e as c,f as l}from"./chunk-WJQLNYGX.js";import{a as b,e as S}from"./chunk-WQH3LT2P.js";import{d as w}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as p,e as y,g as j,h as E}from"./chunk-3XIESWL4.js";var _=y(j(),1);var t=y(E(),1);var T="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},W=p(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"_"),B=p(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(T))continue;let i=a.slice(T.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:u,event:d}=W(r.message);n.set(s,{detail:u,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"j"),F={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},H=p(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"W"),V=p(()=>{let e=(0,_.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),u=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==u||e[6]!==n){let N=B(H(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let f;e[12]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let h;e[14]!==o?(h=(0,t.jsx)(O,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==f||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[f,h]}),e[16]=f,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(k,{"data-testid":"containers-table",children:[(0,t.jsx)(A,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(D,{children:N.map(J)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=u,e[6]=n,e[7]=d}else d=e[7];return d},"H");function J(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:F[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}p(J,"B");export{V as default};
@@ -1 +1 @@
1
- import{a as w}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as C}from"./chunk-OKIEDUHL.js";import"./chunk-XXQUMVWH.js";import"./chunk-NQVE5YON.js";import"./chunk-QLQADHFE.js";import{a as h}from"./chunk-VDW32UET.js";import{c as u}from"./chunk-UDOOZJO5.js";import"./chunk-UQV7Q5S4.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as S,b as K,c as $,d as g,e as i,f as o}from"./chunk-WJQLNYGX.js";import{a as A,e as k}from"./chunk-WQH3LT2P.js";import{d as M,r as D}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as d,e as z,f as ae,h as re}from"./chunk-3XIESWL4.js";var O=z(ae(),1);var e=z(re(),1);var Q="agent_threads",se="agent_messages",F="agent_run_queue",R=100,ne=250,ie={},oe={filters:[],limit:R,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},l=d((s,t)=>{let r=s[t];return typeof r=="string"?r:void 0},"l"),j=d((s,t)=>{let r=s[t];return typeof r=="number"?r:void 0},"w"),L=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:r}=t;return typeof r=="number"?r:void 0},"M"),de=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(r=>r!==null&&typeof r=="object"?r.name:void 0).filter(r=>typeof r=="string"):[]},"ne"),le=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"ie"),ce=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"oe"),be=d(({initialShardKey:s=""})=>{let t=M(),[r,I]=(0,O.useState)(void 0),{data:c}=u(h.listTables,ie,{live:!0,shardKey:s}),G=c!==void 0,p=Array.isArray(c)&&c.some(a=>a.name===Q),H=Array.isArray(c)&&c.some(a=>a.name===F),{data:_,error:J,errorSource:V,liveError:W}=u(h.readTablePage,oe,{enabled:p,live:!0,shardKey:s}),X={filters:[{column:"threadKey",operator:"eq",value:r??""}],limit:ne,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:se},{data:q}=u(h.readTablePage,{limit:R,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:F},{enabled:H,live:!0,shardKey:s}),{data:U,error:Y,errorSource:Z}=u(h.readTablePage,X,{enabled:p&&r!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],ee=Array.isArray(q?.rows)?q.rows:[],B=d(a=>ee.filter(n=>l(n,"threadKey")===a).length,"S"),E=Array.isArray(U?.rows)?U.rows:[],P=v.find(a=>l(a,"key")===r),f;return G&&!p?f=(0,e.jsx)(T,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):p&&v.length===0?f=(0,e.jsx)(T,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):f=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(S,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(i,{children:t("Agent")}),(0,e.jsx)(i,{children:t("Key")}),(0,e.jsx)(i,{children:t("Status")}),(0,e.jsx)(i,{children:t("Queued")}),(0,e.jsx)(i,{children:t("Messages")}),(0,e.jsx)(i,{children:t("Tokens")}),(0,e.jsx)(i,{children:t("Updated")}),(0,e.jsx)(i,{"aria-label":t("Actions")})]})}),(0,e.jsx)($,{children:v.map(a=>{let n=l(a,"key")??"",m=l(a,"status"),x=L(a);return(0,e.jsxs)(g,{"data-active":n===r?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(a,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(o,{children:(0,e.jsx)(y,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:B(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:B(n)})}),(0,e.jsx)(o,{className:"tabular-nums",children:j(a,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:x??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:D(j(a,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{I(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),Y!==null&&(0,e.jsx)(C,{error:Z,testId:"agents-messages-error"}),r!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",r,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",L(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{I(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(S,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(i,{children:t("Role")}),(0,e.jsx)(i,{children:t("Content")}),(0,e.jsx)(i,{children:t("Tool")}),(0,e.jsx)(i,{children:t("Approval")})]})}),(0,e.jsx)($,{children:E.map((a,n)=>{let m=l(a,"role")??"\u2014",x=de(a),te=l(a,"toolName"),N=l(a,"status"),b=j(a,"seq")??n;return(0,e.jsxs)(g,{"data-testid":`agents-message-${String(b)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(a,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:te??(x.length>0?x.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:N===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-message-approval-${String(b)}`,variant:ce(N),children:N})})]},l(a,"messageKey")??`${m}:${String(b)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[J!==null&&(0,e.jsx)(C,{error:V,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),W!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),f]})},"Ne");export{be as default};
1
+ import{a as w}from"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as C}from"./chunk-CAOA5AM4.js";import"./chunk-XXQUMVWH.js";import"./chunk-VR3OBMGZ.js";import"./chunk-QLQADHFE.js";import{a as h}from"./chunk-VDW32UET.js";import{c as u}from"./chunk-FZ2N52BV.js";import"./chunk-BDHAGUAY.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as S,b as K,c as $,d as g,e as i,f as o}from"./chunk-WJQLNYGX.js";import{a as A,e as k}from"./chunk-WQH3LT2P.js";import{d as M,r as D}from"./chunk-IUYFXK4X.js";import"./chunk-5DVJR52Z.js";import{a as d,e as z,f as ae,h as re}from"./chunk-3XIESWL4.js";var O=z(ae(),1);var e=z(re(),1);var Q="agent_threads",se="agent_messages",F="agent_run_queue",R=100,ne=250,ie={},oe={filters:[],limit:R,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},l=d((s,t)=>{let r=s[t];return typeof r=="string"?r:void 0},"l"),j=d((s,t)=>{let r=s[t];return typeof r=="number"?r:void 0},"w"),L=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:r}=t;return typeof r=="number"?r:void 0},"M"),de=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(r=>r!==null&&typeof r=="object"?r.name:void 0).filter(r=>typeof r=="string"):[]},"ne"),le=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"ie"),ce=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"oe"),be=d(({initialShardKey:s=""})=>{let t=M(),[r,I]=(0,O.useState)(void 0),{data:c}=u(h.listTables,ie,{live:!0,shardKey:s}),G=c!==void 0,p=Array.isArray(c)&&c.some(a=>a.name===Q),H=Array.isArray(c)&&c.some(a=>a.name===F),{data:_,error:J,errorSource:V,liveError:W}=u(h.readTablePage,oe,{enabled:p,live:!0,shardKey:s}),X={filters:[{column:"threadKey",operator:"eq",value:r??""}],limit:ne,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:se},{data:q}=u(h.readTablePage,{limit:R,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:F},{enabled:H,live:!0,shardKey:s}),{data:U,error:Y,errorSource:Z}=u(h.readTablePage,X,{enabled:p&&r!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],ee=Array.isArray(q?.rows)?q.rows:[],B=d(a=>ee.filter(n=>l(n,"threadKey")===a).length,"S"),E=Array.isArray(U?.rows)?U.rows:[],P=v.find(a=>l(a,"key")===r),f;return G&&!p?f=(0,e.jsx)(T,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):p&&v.length===0?f=(0,e.jsx)(T,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):f=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(S,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(i,{children:t("Agent")}),(0,e.jsx)(i,{children:t("Key")}),(0,e.jsx)(i,{children:t("Status")}),(0,e.jsx)(i,{children:t("Queued")}),(0,e.jsx)(i,{children:t("Messages")}),(0,e.jsx)(i,{children:t("Tokens")}),(0,e.jsx)(i,{children:t("Updated")}),(0,e.jsx)(i,{"aria-label":t("Actions")})]})}),(0,e.jsx)($,{children:v.map(a=>{let n=l(a,"key")??"",m=l(a,"status"),x=L(a);return(0,e.jsxs)(g,{"data-active":n===r?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs",children:l(a,"agent")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(o,{children:(0,e.jsx)(y,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"\u2014"})}),(0,e.jsx)(o,{className:"tabular-nums",children:B(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:B(n)})}),(0,e.jsx)(o,{className:"tabular-nums",children:j(a,"messageCount")??"\u2014"}),(0,e.jsx)(o,{className:"tabular-nums text-muted-foreground",children:x??"\u2014"}),(0,e.jsx)(o,{className:"text-muted-foreground tabular-nums",children:D(j(a,"updatedAt"),"\u2014")}),(0,e.jsx)(o,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{I(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),Y!==null&&(0,e.jsx)(C,{error:Z,testId:"agents-messages-error"}),r!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",r,P!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",L(P)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{I(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),E.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(S,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(i,{children:t("Role")}),(0,e.jsx)(i,{children:t("Content")}),(0,e.jsx)(i,{children:t("Tool")}),(0,e.jsx)(i,{children:t("Approval")})]})}),(0,e.jsx)($,{children:E.map((a,n)=>{let m=l(a,"role")??"\u2014",x=de(a),te=l(a,"toolName"),N=l(a,"status"),b=j(a,"seq")??n;return(0,e.jsxs)(g,{"data-testid":`agents-message-${String(b)}`,children:[(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),(0,e.jsx)(o,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(a,"content")??"\u2014"}),(0,e.jsx)(o,{className:"font-mono text-xs align-top text-muted-foreground",children:te??(x.length>0?x.join(", "):"\u2014")}),(0,e.jsx)(o,{className:"align-top",children:N===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-message-approval-${String(b)}`,variant:ce(N),children:N})})]},l(a,"messageKey")??`${m}:${String(b)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[J!==null&&(0,e.jsx)(C,{error:V,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),W!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),f]})},"Ne");export{be as default};