@lunora/studio 1.0.0-alpha.356 → 1.0.0-alpha.358

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/standalone/{chunk-Q5GY7D5H.js → chunk-2CPBNLFU.js} +1 -1
  2. package/dist/standalone/{chunk-YHK5UBXI.js → chunk-3HX723U6.js} +1 -1
  3. package/dist/standalone/{chunk-GNVWTK4S.js → chunk-4FZYH76L.js} +1 -1
  4. package/dist/standalone/{chunk-FIJVZCBO.js → chunk-5IGDDSST.js} +1 -1
  5. package/dist/standalone/{chunk-SL7LF2SO.js → chunk-5SYMAYUA.js} +1 -1
  6. package/dist/standalone/{chunk-SPPJFTWE.js → chunk-7KPRMBD6.js} +1 -1
  7. package/dist/standalone/{chunk-SOVH524I.js → chunk-AKGGWCWW.js} +1 -1
  8. package/dist/standalone/{chunk-Z3NZJ4C2.js → chunk-AN2L3XHC.js} +1 -1
  9. package/dist/standalone/{chunk-MQ3FFFP4.js → chunk-B4BK5Q5O.js} +1 -1
  10. package/dist/standalone/{chunk-TIQ3NI77.js → chunk-B6OTKSMY.js} +1 -1
  11. package/dist/standalone/{chunk-DN3HPAOA.js → chunk-BCP3MEB3.js} +1 -1
  12. package/dist/standalone/{chunk-F7GMBSJP.js → chunk-CVUNFP54.js} +1 -1
  13. package/dist/standalone/{chunk-S6OBDEAQ.js → chunk-CZACJYDC.js} +1 -1
  14. package/dist/standalone/{chunk-VO6GV6F2.js → chunk-DPESH5MT.js} +1 -1
  15. package/dist/standalone/{chunk-N5FOHLIG.js → chunk-EAZXULX6.js} +1 -1
  16. package/dist/standalone/{chunk-CDV6T5KM.js → chunk-F4VO76XV.js} +1 -1
  17. package/dist/standalone/{chunk-ILLDX6LU.js → chunk-FACE2CFY.js} +1 -1
  18. package/dist/standalone/{chunk-64S3IDR2.js → chunk-FCRSF54M.js} +1 -1
  19. package/dist/standalone/{chunk-XFTWGZKD.js → chunk-FHGTI6PR.js} +1 -1
  20. package/dist/standalone/{chunk-CHGMDVEQ.js → chunk-FMQ72AKG.js} +1 -1
  21. package/dist/standalone/{chunk-NQX6SAC6.js → chunk-FNUPPZKJ.js} +1 -1
  22. package/dist/standalone/{chunk-ESUUPILO.js → chunk-FRN6D6MP.js} +1 -1
  23. package/dist/standalone/{chunk-D5LY65EX.js → chunk-FSWWDMW2.js} +1 -1
  24. package/dist/standalone/{chunk-VPG46PCA.js → chunk-FYWZRJCT.js} +1 -1
  25. package/dist/standalone/{chunk-IMF6DJKL.js → chunk-GMO7IUXO.js} +1 -1
  26. package/dist/standalone/{chunk-OGKRWT6I.js → chunk-HGT4YHTI.js} +1 -1
  27. package/dist/standalone/{chunk-EEPCLLGE.js → chunk-HONLEKH5.js} +1 -1
  28. package/dist/standalone/{chunk-SV34MAIK.js → chunk-HSLO46OW.js} +1 -1
  29. package/dist/standalone/{chunk-UWAVY3IF.js → chunk-IIJXS3KP.js} +1 -1
  30. package/dist/standalone/{chunk-UHGLZ5RV.js → chunk-IWG2D7QS.js} +1 -1
  31. package/dist/standalone/{chunk-R66XCM3J.js → chunk-JYCRY3LM.js} +1 -1
  32. package/dist/standalone/{chunk-7DMOBHYC.js → chunk-KRDWV6YM.js} +1 -1
  33. package/dist/standalone/{chunk-RNHTOEL7.js → chunk-KRH6UDVU.js} +1 -1
  34. package/dist/standalone/{chunk-M3KSCNKR.js → chunk-LVNPLZDL.js} +1 -1
  35. package/dist/standalone/{chunk-ZXUEBA56.js → chunk-MC577GI5.js} +1 -1
  36. package/dist/standalone/{chunk-U2YFL6EA.js → chunk-MHJNM7VT.js} +1 -1
  37. package/dist/standalone/{chunk-3QGR4DC7.js → chunk-MI7DM536.js} +1 -1
  38. package/dist/standalone/{chunk-I2PP6Q6F.js → chunk-MY7ZGJOD.js} +1 -1
  39. package/dist/standalone/{chunk-E423VRTC.js → chunk-N4AWDORA.js} +1 -1
  40. package/dist/standalone/{chunk-O6XMGPGY.js → chunk-NEZRBBPI.js} +1 -1
  41. package/dist/standalone/{chunk-YJYXN3WQ.js → chunk-NSUOMZWM.js} +1 -1
  42. package/dist/standalone/{chunk-NXNUGQHB.js → chunk-OIBN6KMM.js} +1 -1
  43. package/dist/standalone/{chunk-R5ACA3OC.js → chunk-OSQYIZAV.js} +1 -1
  44. package/dist/standalone/{chunk-AZRUSOAH.js → chunk-OX7I5YHU.js} +1 -1
  45. package/dist/standalone/{chunk-QSNQXPIX.js → chunk-PBKTGB7B.js} +1 -1
  46. package/dist/standalone/{chunk-GZX5XABE.js → chunk-PCMV6S7K.js} +1 -1
  47. package/dist/standalone/{chunk-OT4KZ6Y6.js → chunk-PMGNJZYE.js} +1 -1
  48. package/dist/standalone/{chunk-BCIFRJ3Q.js → chunk-PTCC45P7.js} +1 -1
  49. package/dist/standalone/{chunk-AMLIZFTD.js → chunk-QXHMVPS3.js} +1 -1
  50. package/dist/standalone/{chunk-TNII7Q2L.js → chunk-SUOVLXY6.js} +1 -1
  51. package/dist/standalone/{chunk-DUQ7KXNS.js → chunk-TA3DCQUA.js} +1 -1
  52. package/dist/standalone/{chunk-5KD75VXP.js → chunk-UFPN44MP.js} +1 -1
  53. package/dist/standalone/{chunk-7W6WESSS.js → chunk-V6SVNLUM.js} +1 -1
  54. package/dist/standalone/{chunk-4SJDWMH3.js → chunk-W37HRJGQ.js} +1 -1
  55. package/dist/standalone/{chunk-ZZ5564FZ.js → chunk-WC5QFZYZ.js} +1 -1
  56. package/dist/standalone/{chunk-FXTT2XP3.js → chunk-WCWSMX3N.js} +1 -1
  57. package/dist/standalone/{chunk-OKSZWLJX.js → chunk-WOGVVXGF.js} +1 -1
  58. package/dist/standalone/{chunk-4BNWYVLP.js → chunk-XIVWJUD3.js} +1 -1
  59. package/dist/standalone/{chunk-2CWGRQ5L.js → chunk-XZ6B5XNN.js} +1 -1
  60. package/dist/standalone/{chunk-AQJXOPBW.js → chunk-XZKWGTLI.js} +1 -1
  61. package/dist/standalone/{chunk-TAGWTOFD.js → chunk-ZD53YB3L.js} +1 -1
  62. package/dist/standalone/{chunk-5IIX2STA.js → chunk-ZFFZWSDJ.js} +1 -1
  63. package/dist/standalone/{chunk-2PHY5V5E.js → chunk-ZQOPXQIT.js} +1 -1
  64. package/dist/standalone/studio.js +1 -1
  65. package/package.json +5 -5
  66. /package/dist/standalone/{chunk-FKM35PXF.js → chunk-SDSQIQJG.js} +0 -0
@@ -1 +1 @@
1
- import{a as Ot}from"./chunk-P6L6ABWO.js";import{a as Et}from"./chunk-DUQ7KXNS.js";import{a as me}from"./chunk-4IEMXFUB.js";import{a as Lt}from"./chunk-NMVFSJM7.js";import{a as Mt}from"./chunk-OUFWXYEF.js";import{a as _t,b as jt}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as be,b as Ft}from"./chunk-ILLDX6LU.js";import{i as X}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as L}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import"./chunk-4C4THJUD.js";import{b as he}from"./chunk-4SJDWMH3.js";import{p as oe}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as ge}from"./chunk-3Y5K3IQO.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-CW57Q264.js";import{a as zt,e as kt}from"./chunk-MD67S53Z.js";import{f as Q,j as Rt,r as D,s as St,w as $t}from"./chunk-LPINY2IJ.js";import{a as m,d as wt,e as Yt,f as qt,g as Gt}from"./chunk-OXFKZ4BM.js";var H=wt(qt(),1),E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Mt,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.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,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.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]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(kt,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(zt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.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]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=he(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=he(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=he(k,S,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=he(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=he(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Ft(se)},"V");ae=m(()=>{St(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],be(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],be(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],be(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],be(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],be(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{St((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>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:n,roleColumns:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=m(()=>e.listAuthOrganizations({limit:Ht,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=he(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],be(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(ge,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(ge,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(zt,{className:"overflow-hidden py-0",children:(0,l.jsx)(kt,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
1
+ import{a as Ot}from"./chunk-P6L6ABWO.js";import{a as Et}from"./chunk-TA3DCQUA.js";import{a as me}from"./chunk-4IEMXFUB.js";import{a as Lt}from"./chunk-NMVFSJM7.js";import{a as Mt}from"./chunk-OUFWXYEF.js";import{a as _t,b as jt}from"./chunk-LKCO3E2B.js";import"./chunk-HKPDPKXD.js";import{a as be,b as Ft}from"./chunk-FACE2CFY.js";import{i as X}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as L}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import"./chunk-4C4THJUD.js";import{b as he}from"./chunk-W37HRJGQ.js";import{p as oe}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as ge}from"./chunk-3Y5K3IQO.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-CW57Q264.js";import{a as zt,e as kt}from"./chunk-MD67S53Z.js";import{f as Q,j as Rt,r as D,s as St,w as $t}from"./chunk-LPINY2IJ.js";import{a as m,d as wt,e as Yt,f as qt,g as Gt}from"./chunk-OXFKZ4BM.js";var H=wt(qt(),1),E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Mt,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.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,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.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]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(kt,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(zt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.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]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=he(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=he(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=he(k,S,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=he(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=he(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Ft(se)},"V");ae=m(()=>{St(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],be(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],be(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],be(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],be(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],be(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{St((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>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:n,roleColumns:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=m(()=>e.listAuthOrganizations({limit:Ht,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=he(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],be(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(ge,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(ge,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(zt,{className:"overflow-hidden py-0",children:(0,l.jsx)(kt,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as v}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as j}from"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as g}from"./chunk-6UTZXEW3.js";import{c as h}from"./chunk-4SJDWMH3.js";import"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as $}from"./chunk-3Y5K3IQO.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-CW57Q264.js";import{a as S,e as K}from"./chunk-MD67S53Z.js";import{f as T,w as F}from"./chunk-LPINY2IJ.js";import{a as d,d as k,e as ne,f as oe,g as ie}from"./chunk-OXFKZ4BM.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{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")}):f&&b.length===0?x=(0,e.jsx)($,{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")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(S,{className:"overflow-hidden py-0",children:(0,e.jsx)(K,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(S,{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 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,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.")}),Z!==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.")}),x]})},"Ee");export{Te as default};
1
+ import{a as C}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as v}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as j}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as g}from"./chunk-6UTZXEW3.js";import{c as h}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as $}from"./chunk-3Y5K3IQO.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-CW57Q264.js";import{a as S,e as K}from"./chunk-MD67S53Z.js";import{f as T,w as F}from"./chunk-LPINY2IJ.js";import{a as d,d as k,e as ne,f as oe,g as ie}from"./chunk-OXFKZ4BM.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{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")}):f&&b.length===0?x=(0,e.jsx)($,{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")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(S,{className:"overflow-hidden py-0",children:(0,e.jsx)(K,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(S,{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 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,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.")}),Z!==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.")}),x]})},"Ee");export{Te as default};
@@ -1 +1 @@
1
- import{a as O,c as D}from"./chunk-4SQBAPY6.js";import{a as F}from"./chunk-XBZUJDHD.js";import{a as j}from"./chunk-5DNGK3NT.js";import{a as V}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as L}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-ZBON5T5A.js";import{b as C}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as z}from"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as T}from"./chunk-6UTZXEW3.js";import{c as R}from"./chunk-4SJDWMH3.js";import"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as k}from"./chunk-3Y5K3IQO.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-CW57Q264.js";import{a as I,e as E}from"./chunk-MD67S53Z.js";import{f as b,p as K,w as M}from"./chunk-LPINY2IJ.js";import{a as i,d as y,e as ee,g as te}from"./chunk-OXFKZ4BM.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,K),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=R(T.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
1
+ import{a as O,c as D}from"./chunk-4SQBAPY6.js";import{a as F}from"./chunk-XBZUJDHD.js";import{a as j}from"./chunk-5DNGK3NT.js";import{a as V}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as L}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-ZBON5T5A.js";import{b as C}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as z}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as T}from"./chunk-6UTZXEW3.js";import{c as R}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as k}from"./chunk-3Y5K3IQO.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-CW57Q264.js";import{a as I,e as E}from"./chunk-MD67S53Z.js";import{f as b,p as K,w as M}from"./chunk-LPINY2IJ.js";import{a as i,d as y,e as ee,g as te}from"./chunk-OXFKZ4BM.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,K),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=j(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=R(T.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(V,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
@@ -1 +1 @@
1
- import{b as h}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as A}from"./chunk-4SJDWMH3.js";import{p as S}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as y,e as I}from"./chunk-MD67S53Z.js";import{f as k}from"./chunk-LPINY2IJ.js";import{a as u,d as w,f as z,g as P}from"./chunk-OXFKZ4BM.js";var N=w(z(),1);var a=w(P(),1);var j=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let s;i[2]!==t?(s=(0,a.jsx)(I,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=u(()=>{let e=(0,N.c)(20),i=S(),t=k(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=A(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{let $=l.capabilities[r.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m($)]},r.key)})})}),(0,a.jsx)(p,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(C)})}),(0,a.jsx)(p,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(p,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(p,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(p,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{M as default};
1
+ import{b as h}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{b as A}from"./chunk-W37HRJGQ.js";import{p as S}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as y,e as I}from"./chunk-MD67S53Z.js";import{f as k}from"./chunk-LPINY2IJ.js";import{a as u,d as w,f as z,g as P}from"./chunk-OXFKZ4BM.js";var N=w(z(),1);var a=w(P(),1);var j=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=u(e=>{if(e===void 0)return"\u2014";let i=[[86400,"d"],[3600,"h"],[60,"m"]];for(let[t,d]of i)if(e>=t&&e%t===0)return`${String(e/t)}${d}`;return`${String(e)}s`},"v"),p=u(e=>{let i=(0,N.c)(8),{children:t,heading:d,testId:n}=e,l;i[0]!==d?(l=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let s;i[2]!==t?(s=(0,a.jsx)(I,{className:"p-3",children:t}),i[2]=t,i[3]=s):s=i[3];let c;return i[4]!==l||i[5]!==s||i[6]!==n?(c=(0,a.jsxs)(y,{className:"gap-0 py-0","data-testid":n,children:[l,s]}),i[4]=l,i[5]=s,i[6]=n,i[7]=c):c=i[7],c},"h"),o=u(e=>{let i=(0,N.c)(7),{label:t,value:d}=e,n;i[0]!==t?(n=(0,a.jsx)("span",{className:"text-sm",children:t}),i[0]=t,i[1]=n):n=i[1];let l;i[2]!==d?(l=(0,a.jsx)("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let s;return i[4]!==n||i[5]!==l?(s=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[n,l]}),i[4]=n,i[5]=l,i[6]=s):s=i[6],s},"c"),M=u(()=>{let e=(0,N.c)(20),i=S(),t=k(),d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let n;e[1]!==i?(n=u(()=>i.getAuthConfig(),"r"),e[1]=i,e[2]=n):n=e[2];let{data:l,error:s}=A(d,n),c;e[3]!==t?(c=u(r=>(0,a.jsx)(h,{variant:r?"success":"outline",children:t(r?"Enabled":"Disabled")}),"u"),e[3]=t,e[4]=c):c=e[4];let m=c,g;e[5]!==s?(g=s!==null&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=g):g=e[6];let f;e[7]!==l||e[8]!==s||e[9]!==t?(f=s===null&&l===void 0&&(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:t("Loading auth configuration\u2026")}),e[7]=l,e[8]=s,e[9]=t,e[10]=f):f=e[10];let x;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==t?(x=s===null&&l!==void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p,{heading:t("Enabled capabilities"),testId:"auth-config-capabilities",children:(0,a.jsx)("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{let $=l.capabilities[r.key];return(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[(0,a.jsx)("span",{className:"text-sm",children:t(r.label)}),m($)]},r.key)})})}),(0,a.jsx)(p,{heading:t("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:t("No plugins enabled.")}):(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(C)})}),(0,a.jsx)(p,{heading:t("Sign-in methods"),testId:"auth-config-signin",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Email & password"),value:m(l.emailAndPassword)}),(0,a.jsx)(o,{label:t("Social providers"),value:l.socialProviders.length===0?t("None"):(0,a.jsx)("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(q)})})]})}),l.organization.enabled&&(0,a.jsx)(p,{heading:t("Organizations"),testId:"auth-config-org",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Teams"),value:m(l.organization.teams)}),(0,a.jsx)(o,{label:t("Custom roles"),value:m(l.organization.roles)})]})}),(0,a.jsx)(p,{heading:t("Session policy"),testId:"auth-config-session",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Expires in"),value:v(l.session.expiresIn)}),(0,a.jsx)(o,{label:t("Refresh after"),value:v(l.session.updateAge)}),(0,a.jsx)(o,{label:t("Fresh window"),value:v(l.session.freshAge)}),(0,a.jsx)(o,{label:t("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),(0,a.jsx)(p,{heading:t("Rate limit"),testId:"auth-config-ratelimit",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,a.jsx)(o,{label:t("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o,{label:t("Max requests"),value:l.rateLimit.max??"\u2014"}),(0,a.jsx)(o,{label:t("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&(0,a.jsx)(p,{heading:t("Plugin user fields"),testId:"auth-config-user-fields",children:(0,a.jsx)("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>(0,a.jsxs)("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[(0,a.jsxs)("span",{className:"flex flex-col",children:[(0,a.jsx)("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&(0,a.jsx)("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(h,{variant:"outline",children:r.type}),r.required&&(0,a.jsx)(h,{variant:"secondary",children:t("required")}),r.unique&&(0,a.jsx)(h,{variant:"secondary",children:t("unique")})]})]},r.name))})}),(0,a.jsx)(y,{className:"gap-0 py-0",children:(0,a.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:t("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=t,e[15]=x):x=e[15];let b;return e[16]!==g||e[17]!==f||e[18]!==x?(b=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,f,x]}),e[16]=g,e[17]=f,e[18]=x,e[19]=b):b=e[19],b},"O");function C(e){return(0,a.jsx)(h,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}u(C,"P");function q(e){return(0,a.jsx)(h,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}u(q,"z");export{M as default};
@@ -1 +1 @@
1
- import{a as $}from"./chunk-WS36BO4R.js";import{a as b}from"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as u}from"./chunk-6UTZXEW3.js";import{c as p}from"./chunk-4SJDWMH3.js";import"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-CW57Q264.js";import{a as d,e as l}from"./chunk-MD67S53Z.js";import{b as x,f as k}from"./chunk-LPINY2IJ.js";import{a as o,d as I,g as T}from"./chunk-OXFKZ4BM.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
1
+ import{a as $}from"./chunk-WS36BO4R.js";import{a as b}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as u}from"./chunk-6UTZXEW3.js";import{c as p}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-CW57Q264.js";import{a as d,e as l}from"./chunk-MD67S53Z.js";import{b as x,f as k}from"./chunk-LPINY2IJ.js";import{a as o,d as I,g as T}from"./chunk-OXFKZ4BM.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
@@ -1,4 +1,4 @@
1
- import{a as Fe,b as Ke}from"./chunk-DN3HPAOA.js";import"./chunk-5IIX2STA.js";import{a as We}from"./chunk-N5FOHLIG.js";import{d as He}from"./chunk-DS7HZKZ2.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import"./chunk-NMVFSJM7.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import{a as ze}from"./chunk-6QEXGYWH.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import"./chunk-ZGSL4DPP.js";import"./chunk-ZWDORIZY.js";import{a as Pe}from"./chunk-KYONGQQ4.js";import{b as Oe}from"./chunk-SLIDAWNX.js";import{c as $e,d as pe,e as ve,f as ye,g as Ee}from"./chunk-6M7FLLMT.js";import"./chunk-ZTOREMGH.js";import{i as qe}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import"./chunk-4C4THJUD.js";import{a as je}from"./chunk-OSJ7HV7B.js";import{a as he}from"./chunk-6UTZXEW3.js";import"./chunk-4SJDWMH3.js";import{p as xe}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import"./chunk-CW57Q264.js";import{b as ie,f as se,h as me,i as fe,j as Ae,s as ae}from"./chunk-LPINY2IJ.js";import{a as i,d as ke,e as ct,f as dt,g as ut}from"./chunk-OXFKZ4BM.js";var X=ke(dt(),1),j=ke(ct(),1);var u=ke(ut(),1);var be=class{static{i(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),d=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(d,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=i(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),d=n.length,a=e.length,c=1,m=d+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,v=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(v[0],n,e,0,t);if(v[0].oldPos+1>=a&&g+1>=d)return l(this.buildValues(v[0].lastComponent,n,e));let E=-1/0,x=1/0,y=i(()=>{for(let h=Math.max(E,-c);h<=Math.min(x,c);h+=2){let S,w=v[h-1],C=v[h+1];w&&(v[h-1]=void 0);let b=!1;if(C){let N=C.oldPos-h;b=C&&0<=N&&N<d}let k=w&&w.oldPos+1<a;if(!b&&!k){v[h]=void 0;continue}if(!k||b&&w.oldPos<C.oldPos?S=this.addToPath(C,!0,!1,0,t):S=this.addToPath(w,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=d)return l(this.buildValues(S.lastComponent,n,e))||!0;v[h]=S,S.oldPos+1>=a&&(x=Math.min(x,h-1)),g+1>=d&&(E=Math.max(E,h+1))}c++},"execEditLength");if(o)i(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);y()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=y();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,d=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<d&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,d=0,a=0,c=0;for(;d<l;d++){let m=o[d];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,v){let g=t[c+v];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var Te=class extends be{static{i(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=mt}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
1
+ import{a as Fe,b as Ke}from"./chunk-BCP3MEB3.js";import"./chunk-ZFFZWSDJ.js";import{a as We}from"./chunk-EAZXULX6.js";import{d as He}from"./chunk-DS7HZKZ2.js";import"./chunk-SYGCASPT.js";import"./chunk-CTE6RPXC.js";import"./chunk-LIGOLZND.js";import"./chunk-3GXPALXG.js";import"./chunk-NMVFSJM7.js";import"./chunk-AP4PC2M4.js";import"./chunk-KRPXOSBL.js";import"./chunk-W2BCSK5S.js";import{a as ze}from"./chunk-6QEXGYWH.js";import"./chunk-NGVP66OH.js";import"./chunk-XYR5NST4.js";import"./chunk-ZGSL4DPP.js";import"./chunk-ZWDORIZY.js";import{a as Pe}from"./chunk-KYONGQQ4.js";import{b as Oe}from"./chunk-SLIDAWNX.js";import{c as $e,d as pe,e as ve,f as ye,g as Ee}from"./chunk-6M7FLLMT.js";import"./chunk-ZTOREMGH.js";import{i as qe}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import"./chunk-4C4THJUD.js";import{a as je}from"./chunk-OSJ7HV7B.js";import{a as he}from"./chunk-6UTZXEW3.js";import"./chunk-W37HRJGQ.js";import{p as xe}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import"./chunk-CW57Q264.js";import{b as ie,f as se,h as me,i as fe,j as Ae,s as ae}from"./chunk-LPINY2IJ.js";import{a as i,d as ke,e as ct,f as dt,g as ut}from"./chunk-OXFKZ4BM.js";var X=ke(dt(),1),j=ke(ct(),1);var u=ke(ut(),1);var be=class{static{i(this,"Diff")}diff(e,n,t={}){let o;typeof t=="function"?(o=t,t={}):"callback"in t&&(o=t.callback);let r=this.castInput(e,t),l=this.castInput(n,t),d=this.removeEmpty(this.tokenize(r,t)),a=this.removeEmpty(this.tokenize(l,t));return this.diffWithOptionsObj(d,a,t,o)}diffWithOptionsObj(e,n,t,o){var r;let l=i(h=>{if(h=this.postProcess(h,t),o){setTimeout(function(){o(h)},0);return}else return h},"done"),d=n.length,a=e.length,c=1,m=d+a;t.maxEditLength!=null&&(m=Math.min(m,t.maxEditLength));let p=(r=t.timeout)!==null&&r!==void 0?r:1/0,f=Date.now()+p,v=[{oldPos:-1,lastComponent:void 0}],g=this.extractCommon(v[0],n,e,0,t);if(v[0].oldPos+1>=a&&g+1>=d)return l(this.buildValues(v[0].lastComponent,n,e));let E=-1/0,x=1/0,y=i(()=>{for(let h=Math.max(E,-c);h<=Math.min(x,c);h+=2){let S,w=v[h-1],C=v[h+1];w&&(v[h-1]=void 0);let b=!1;if(C){let N=C.oldPos-h;b=C&&0<=N&&N<d}let k=w&&w.oldPos+1<a;if(!b&&!k){v[h]=void 0;continue}if(!k||b&&w.oldPos<C.oldPos?S=this.addToPath(C,!0,!1,0,t):S=this.addToPath(w,!1,!0,1,t),g=this.extractCommon(S,n,e,h,t),S.oldPos+1>=a&&g+1>=d)return l(this.buildValues(S.lastComponent,n,e))||!0;v[h]=S,S.oldPos+1>=a&&(x=Math.min(x,h-1)),g+1>=d&&(E=Math.max(E,h+1))}c++},"execEditLength");if(o)i(function h(){setTimeout(function(){if(c>m||Date.now()>f)return o(void 0);y()||h()},0)},"exec")();else for(;c<=m&&Date.now()<=f;){let h=y();if(h)return h}}addToPath(e,n,t,o,r){let l=e.lastComponent;return l&&!r.oneChangePerToken&&l.added===n&&l.removed===t?{oldPos:e.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:t,previousComponent:l.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:n,removed:t,previousComponent:l}}}extractCommon(e,n,t,o,r){let l=n.length,d=t.length,a=e.oldPos,c=a-o,m=0;for(;c+1<l&&a+1<d&&this.equals(t[a+1],n[c+1],r);)c++,a++,m++,r.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!r.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,c}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let o=[],r;for(;e;)o.push(e),r=e.previousComponent,delete e.previousComponent,e=r;o.reverse();let l=o.length,d=0,a=0,c=0;for(;d<l;d++){let m=o[d];if(m.removed)m.value=this.join(t.slice(c,c+m.count)),c+=m.count;else{if(!m.added&&this.useLongestToken){let p=n.slice(a,a+m.count);p=p.map(function(f,v){let g=t[c+v];return g.length>f.length?g:f}),m.value=this.join(p)}else m.value=this.join(n.slice(a,a+m.count));a+=m.count,m.added||(c+=m.count)}}return o}};var Te=class extends be{static{i(this,"LineDiff")}constructor(){super(...arguments),this.tokenize=mt}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
2
2
  `))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
3
3
  `))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
4
4
  `)&&(e=e.slice(0,-1)),n.endsWith(`
@@ -1 +1 @@
1
- import{b as g}from"./chunk-NXNUGQHB.js";import"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as f}from"./chunk-6UTZXEW3.js";import{c as m}from"./chunk-4SJDWMH3.js";import"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import"./chunk-CW57Q264.js";import"./chunk-MD67S53Z.js";import{f as p}from"./chunk-LPINY2IJ.js";import{a as r,d as h,f as S,g as A}from"./chunk-OXFKZ4BM.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"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("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(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"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.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:s.detail?.length,min:s.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: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,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)(g,{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},"T");export{O as default};
1
+ import{b as g}from"./chunk-OIBN6KMM.js";import"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as f}from"./chunk-6UTZXEW3.js";import{c as m}from"./chunk-W37HRJGQ.js";import"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import"./chunk-CW57Q264.js";import"./chunk-MD67S53Z.js";import{f as p}from"./chunk-LPINY2IJ.js";import{a as r,d as h,f as S,g as A}from"./chunk-OXFKZ4BM.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"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("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(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"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.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:s.detail?.length,min:s.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: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,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)(g,{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},"T");export{O as default};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-OSJ7HV7B.js";import{a as T}from"./chunk-SL7LF2SO.js";import{b as E}from"./chunk-E26OT26O.js";import{b as A}from"./chunk-FKM35PXF.js";import{f as H,j as I,m as O,n as S}from"./chunk-LPINY2IJ.js";import{a as C,d as q,f as _,g as z}from"./chunk-OXFKZ4BM.js";var K=q(_(),1);var l=q(z(),1);var P=C(U=>{let e=(0,K.c)(42),{className:y,error:t,testId:g}=U,k=H(),r=E(),n,i,a,c,m,p,o,s,d;if(e[0]!==y||e[1]!==t||e[2]!==r||e[3]!==g){let V=O(t),b;e[13]!==t?(b=S(t),e[13]=t,e[14]=b):b=e[14],i=b;let v;e[15]!==t?(v=T(t),e[15]=t,e[16]=v):v=e[16];let j=v,w=t?.why,N;e[17]!==r||e[18]!==j?(N=C(()=>{r?.openConsole({errorsOnly:!0,seq:j})},"y"),e[17]=r,e[18]=j,e[19]=N):N=e[19],a=N,n=D,c=y,m=g,p="destructive";let h;e[20]!==t?(h=I(t),e[20]=t,e[21]=h):h=e[21],e[22]!==h?(o=(0,l.jsx)("p",{className:"font-medium",children:h}),e[22]=h,e[23]=o):o=e[23],e[24]!==w?(s=typeof w=="string"?(0,l.jsx)("p",{className:"mt-1 text-xs opacity-90",children:w}):null,e[24]=w,e[25]=s):s=e[25],d=V===void 0?null:(0,l.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:A(V)}),e[0]=y,e[1]=t,e[2]=r,e[3]=g,e[4]=n,e[5]=i,e[6]=a,e[7]=c,e[8]=m,e[9]=p,e[10]=o,e[11]=s,e[12]=d}else n=e[4],i=e[5],a=e[6],c=e[7],m=e[8],p=e[9],o=e[10],s=e[11],d=e[12];let f;e[26]!==i?(f=i===void 0?null:(0,l.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:i,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[26]=i,e[27]=f):f=e[27];let u;e[28]!==r||e[29]!==a||e[30]!==k?(u=r===void 0?null:(0,l.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:a,type:"button",children:k("Show in console")}),e[28]=r,e[29]=a,e[30]=k,e[31]=u):u=e[31];let x;return e[32]!==n||e[33]!==c||e[34]!==m||e[35]!==p||e[36]!==o||e[37]!==s||e[38]!==d||e[39]!==f||e[40]!==u?(x=(0,l.jsxs)(n,{className:c,testId:m,variant:p,children:[o,s,d,f,u]}),e[32]=n,e[33]=c,e[34]=m,e[35]=p,e[36]=o,e[37]=s,e[38]=d,e[39]=f,e[40]=u,e[41]=x):x=e[41],x},"K");export{P as a};
1
+ import{a as D}from"./chunk-OSJ7HV7B.js";import{a as T}from"./chunk-5SYMAYUA.js";import{b as E}from"./chunk-E26OT26O.js";import{b as A}from"./chunk-SDSQIQJG.js";import{f as H,j as I,m as O,n as S}from"./chunk-LPINY2IJ.js";import{a as C,d as q,f as _,g as z}from"./chunk-OXFKZ4BM.js";var K=q(_(),1);var l=q(z(),1);var P=C(U=>{let e=(0,K.c)(42),{className:y,error:t,testId:g}=U,k=H(),r=E(),n,i,a,c,m,p,o,s,d;if(e[0]!==y||e[1]!==t||e[2]!==r||e[3]!==g){let V=O(t),b;e[13]!==t?(b=S(t),e[13]=t,e[14]=b):b=e[14],i=b;let v;e[15]!==t?(v=T(t),e[15]=t,e[16]=v):v=e[16];let j=v,w=t?.why,N;e[17]!==r||e[18]!==j?(N=C(()=>{r?.openConsole({errorsOnly:!0,seq:j})},"y"),e[17]=r,e[18]=j,e[19]=N):N=e[19],a=N,n=D,c=y,m=g,p="destructive";let h;e[20]!==t?(h=I(t),e[20]=t,e[21]=h):h=e[21],e[22]!==h?(o=(0,l.jsx)("p",{className:"font-medium",children:h}),e[22]=h,e[23]=o):o=e[23],e[24]!==w?(s=typeof w=="string"?(0,l.jsx)("p",{className:"mt-1 text-xs opacity-90",children:w}):null,e[24]=w,e[25]=s):s=e[25],d=V===void 0?null:(0,l.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:A(V)}),e[0]=y,e[1]=t,e[2]=r,e[3]=g,e[4]=n,e[5]=i,e[6]=a,e[7]=c,e[8]=m,e[9]=p,e[10]=o,e[11]=s,e[12]=d}else n=e[4],i=e[5],a=e[6],c=e[7],m=e[8],p=e[9],o=e[10],s=e[11],d=e[12];let f;e[26]!==i?(f=i===void 0?null:(0,l.jsx)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:i,rel:"noreferrer",target:"_blank",children:"View error docs"}),e[26]=i,e[27]=f):f=e[27];let u;e[28]!==r||e[29]!==a||e[30]!==k?(u=r===void 0?null:(0,l.jsx)("button",{className:"mt-1 block text-xs underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"error-show-in-console",onClick:a,type:"button",children:k("Show in console")}),e[28]=r,e[29]=a,e[30]=k,e[31]=u):u=e[31];let x;return e[32]!==n||e[33]!==c||e[34]!==m||e[35]!==p||e[36]!==o||e[37]!==s||e[38]!==d||e[39]!==f||e[40]!==u?(x=(0,l.jsxs)(n,{className:c,testId:m,variant:p,children:[o,s,d,f,u]}),e[32]=n,e[33]=c,e[34]=m,e[35]=p,e[36]=o,e[37]=s,e[38]=d,e[39]=f,e[40]=u,e[41]=x):x=e[41],x},"K");export{P as a};
@@ -1 +1 @@
1
- import{a as Se}from"./chunk-P6L6ABWO.js";import{a as _}from"./chunk-OUFWXYEF.js";import{a as Ie}from"./chunk-XBZUJDHD.js";import{a as Ce}from"./chunk-ZWDORIZY.js";import{a as ve}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as V}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as z}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as E}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Ne}from"./chunk-IMF6DJKL.js";import"./chunk-OSJ7HV7B.js";import"./chunk-SL7LF2SO.js";import"./chunk-E26OT26O.js";import{a as X}from"./chunk-6UTZXEW3.js";import{c as re}from"./chunk-4SJDWMH3.js";import{g as pe,p as ce}from"./chunk-FKM35PXF.js";import"./chunk-WZTY3ZYI.js";import{a as de}from"./chunk-3Y5K3IQO.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-CW57Q264.js";import{a as se,b as ue,c as fe,d as he,e as ne}from"./chunk-MD67S53Z.js";import{f as K,h as xe,i as ge,j as ye,p as be,s as ae}from"./chunk-LPINY2IJ.js";import{a as f,d as oe,e as Fe,f as Te,g as Ee}from"./chunk-OXFKZ4BM.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(de,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=xe(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=ce();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},ge(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,be,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=ce(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(ye(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(de,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(fe,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(he,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ue,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(ne,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(se,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(ne,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
1
+ import{a as Se}from"./chunk-P6L6ABWO.js";import{a as _}from"./chunk-OUFWXYEF.js";import{a as Ie}from"./chunk-XBZUJDHD.js";import{a as Ce}from"./chunk-ZWDORIZY.js";import{a as ve}from"./chunk-KYONGQQ4.js";import"./chunk-SLIDAWNX.js";import"./chunk-6M7FLLMT.js";import{i as V}from"./chunk-SDQH4HR6.js";import"./chunk-W7MRISE3.js";import"./chunk-IBJVVHV5.js";import{a as z}from"./chunk-2O6KKVH2.js";import"./chunk-JTGGWF7R.js";import"./chunk-ZBON5T5A.js";import{b as E}from"./chunk-6I42AM75.js";import"./chunk-4C4THJUD.js";import{a as Ne}from"./chunk-GMO7IUXO.js";import"./chunk-OSJ7HV7B.js";import"./chunk-5SYMAYUA.js";import"./chunk-E26OT26O.js";import{a as X}from"./chunk-6UTZXEW3.js";import{c as re}from"./chunk-W37HRJGQ.js";import{g as pe,p as ce}from"./chunk-SDSQIQJG.js";import"./chunk-WZTY3ZYI.js";import{a as de}from"./chunk-3Y5K3IQO.js";import{a as ke,b as we,c as Pe,d as me,e as le,f as ie}from"./chunk-CW57Q264.js";import{a as se,b as ue,c as fe,d as he,e as ne}from"./chunk-MD67S53Z.js";import{f as K,h as xe,i as ge,j as ye,p as be,s as ae}from"./chunk-LPINY2IJ.js";import{a as f,d as oe,e as Fe,f as Te,g as Ee}from"./chunk-OXFKZ4BM.js";var y=oe(Fe(),1);var ee=oe(Te(),1);var a=oe(Ee(),1);var _e=["read","insert","update","delete"],ze=f((t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],"_e"),$e=f(t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,"Fe"),De=f(t=>{let e=new Set;for(let l of t?.advisories??[])if(l.name==="rls_uncovered_table"){let{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},"Oe"),Le=f((t,e,l)=>{let o=new Map,i=f(n=>{let s=o.get(n);if(s!==void 0)return s;let p={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,p),p},"r");for(let n of t)i(n.table).cells[n.on]={path:$e(n),procedure:n.procedure};for(let n of e)i(n.table).maskedColumns.add(n.column);for(let n of l)i(n);return[...o.values()].toSorted((n,s)=>n.table.localeCompare(s.table))},"De"),Oe=f(t=>{let e=(0,ee.c)(17),l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];let{onProbe:o}=l,i=K(),n,s;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},s={live:!0},e[2]=n,e[3]=s):(n=e[2],s=e[3]);let p=re(X.rlsPolicies,n,s),r;e[4]===Symbol.for("react.memo_cache_sentinel")?(r={},e[4]=r):r=e[4];let m=re(X.maskPolicies,r),d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d={},e[5]=d):d=e[5];let c=re(X.getAdvisories,d),h;if(e[6]!==c.data||e[7]!==m.data||e[8]!==o||e[9]!==p||e[10]!==i){let g=null;p.data!==void 0&&(g=Array.isArray(p.data.policies)?p.data.policies:[]);let $=Array.isArray(m.data?.columns)?m.data.columns:[],H=c.data??null,{error:C,errorSource:w,liveError:S}=p,A=g===null?[]:Le(g,$,De(H)),k;e[12]!==S?(k=(0,a.jsx)("div",{className:"flex items-center justify-end",children:(0,a.jsx)(Ie,{message:S,prefix:"pm"})}),e[12]=S,e[13]=k):k=e[13];let R;e[14]!==C||e[15]!==w?(R=C!==null&&(0,a.jsx)(Ne,{error:w,testId:"pm-error"}),e[14]=C,e[15]=w,e[16]=R):R=e[16],h=(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,R,g!==null&&A.length===0?(0,a.jsx)(de,{description:i("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:i("No policy")}):(0,a.jsxs)(ke,{"data-testid":"pm-table",children:[(0,a.jsx)(we,{children:(0,a.jsxs)(me,{children:[(0,a.jsx)(le,{children:i("Table")}),_e.map(x=>(0,a.jsx)(le,{children:ze(i,x)},x)),(0,a.jsx)(le,{children:i("Masked columns")})]})}),(0,a.jsx)(Pe,{children:A.map(x=>(0,a.jsxs)(me,{"data-testid":`pm-row-${x.table}`,children:[(0,a.jsx)(ie,{className:"font-mono text-xs",children:(0,a.jsxs)("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&(0,a.jsx)(E,{"data-testid":`pm-uncovered-${x.table}`,title:i("Uncovered \u2014 reachable without a policy"),variant:"destructive",children:i("Uncovered \u2014 reachable without a policy")})]})}),_e.map(I=>{let v=x.cells[I];return(0,a.jsx)(ie,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:i("No policy")}):(0,a.jsxs)("span",{className:"flex flex-col gap-1",children:[(0,a.jsx)(E,{variant:"secondary",children:i("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&(0,a.jsx)(z,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:f(()=>{o(x.table,I,v.path??"")},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Probe this")})]})},I)}),(0,a.jsx)(ie,{children:x.maskedColumns.size===0?(0,a.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,a.jsx)("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map(qe)})})]},x.table))})]})]}),e[6]=c.data,e[7]=m.data,e[8]=o,e[9]=p,e[10]=i,e[11]=h}else h=e[11];return h},"Le");function qe(t){return(0,a.jsx)(E,{variant:"outline",children:t},t)}f(qe,"$e");var Ue=xe(X.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),je=f(t=>{let e=t?.code;return typeof e=="string"?e:void 0},"Me"),Be=f(()=>{let t=ce();return async({args:e,functionPath:l,shardKey:o="",userId:i})=>{if(i.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};let n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:i},ge(o))}}catch(s){let p=s instanceof Error?s.message:String(s),r=je(s);return r!==void 0&&We.has(r)?{kind:"denied",message:p}:{kind:"errored",message:p}}}},"ze"),Me=f(t=>t===void 0?"undefined":JSON.stringify(t,be,2),"qe"),Je=f(t=>{let e=(0,ee.c)(43),{outcome:l}=t,o=K();if(l.kind==="allowed"){let r;e[0]!==o?(r=o("Allowed"),e[0]=o,e[1]=r):r=e[1];let m;e[2]!==r?(m=(0,a.jsx)(E,{variant:"secondary",children:r}),e[2]=r,e[3]=m):m=e[3];let d;e[4]!==l.value?(d=Me(l.value),e[4]=l.value,e[5]=d):d=e[5];let c;e[6]!==d?(c=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:d}),e[6]=d,e[7]=c):c=e[7];let h;return e[8]!==m||e[9]!==c?(h=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[m,c]}),e[8]=m,e[9]=c,e[10]=h):h=e[10],h}if(l.kind==="denied"){let r;e[11]!==o?(r=o("Denied"),e[11]=o,e[12]=r):r=e[12];let m;e[13]!==r?(m=(0,a.jsx)(E,{variant:"destructive",children:r}),e[13]=r,e[14]=m):m=e[14];let d;e[15]!==l.message?(d=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:l.message}),e[15]=l.message,e[16]=d):d=e[16];let c;return e[17]!==m||e[18]!==d?(c=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[m,d]}),e[17]=m,e[18]=d,e[19]=c):c=e[19],c}if(l.kind==="errored"){let r;e[20]!==o?(r=o("Errored"),e[20]=o,e[21]=r):r=e[21];let m;e[22]!==r?(m=(0,a.jsx)(E,{variant:"outline",children:r}),e[22]=r,e[23]=m):m=e[23];let d;e[24]!==o?(d=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=d):d=e[25];let c;e[26]!==d?(c=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[26]=d,e[27]=c):c=e[27];let h;e[28]!==l.message?(h=(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==m||e[31]!==c||e[32]!==h?(g=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[m,c,h]}),e[30]=m,e[31]=c,e[32]=h,e[33]=g):g=e[33],g}let i;e[34]!==o?(i=o("Not run"),e[34]=o,e[35]=i):i=e[35];let n;e[36]!==i?(n=(0,a.jsx)(E,{variant:"outline",children:i}),e[36]=i,e[37]=n):n=e[37];let s;e[38]!==l.message?(s=(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=s):s=e[39];let p;return e[40]!==n||e[41]!==s?(p=(0,a.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,s]}),e[40]=n,e[41]=s,e[42]=p):p=e[42],p},"Be"),He=f(t=>{let e=(0,ee.c)(17),{disabled:l,executesWrites:o,functionPath:i,onRun:n,running:s,userId:p}=t,r=K(),m;e[0]!==s||e[1]!==r?(m=r(s?"Probing\u2026":"Run probe"),e[0]=s,e[1]=r,e[2]=m):m=e[2];let d=m,c;e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==d||e[7]!==n||e[8]!==r||e[9]!==p?(c=o?(0,a.jsx)(Ce,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:i,userId:p}),disabled:l,onConfirm:n,testId:"pp-run",children:d}):(0,a.jsx)(z,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:d}),e[3]=l,e[4]=o,e[5]=i,e[6]=d,e[7]=n,e[8]=r,e[9]=p,e[10]=c):c=e[10];let h;e[11]!==r||e[12]!==p?(h=p!==""&&(0,a.jsx)(E,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:p})}),e[11]=r,e[12]=p,e[13]=h):h=e[13];let g;return e[14]!==c||e[15]!==h?(g=(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[c,h]}),e[14]=c,e[15]=h,e[16]=g):g=e[16],g},"je"),Ke=f(({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{let o=ce(),i=K(),n=Be(),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(null),d=t??s??[],[c,h]=(0,y.useState)(""),[g,$]=(0,y.useState)("{}"),[H,C]=(0,y.useState)(""),[w,S]=(0,y.useState)(""),[A,k]=(0,y.useState)(!1),[R,x]=(0,y.useState)(null),[I,v]=(0,y.useState)(null),[F,D]=(0,y.useState)(!1),T=(0,y.useRef)(-1),P=(0,y.useRef)(0);(0,y.useEffect)(()=>{if(t!==void 0)return;let u=!1;return o.listFunctions().then(N=>(u||p(N),N)).catch(N=>{u||m(ye(N))}),()=>{u=!0}},[o,t]),(0,y.useEffect)(()=>{if(e===void 0||T.current===e.nonce)return;T.current=e.nonce,P.current+=1;let u=e.functionPath;queueMicrotask(()=>{h(u),x(null)})},[e]);let Q=F?d:d.filter(u=>u.kind==="query"||u.path===c),b=c===""?Q[0]?.path??"":c,L=d.find(u=>u.path===b),Z=b!==""&&L?.kind!=="query",O=f(async()=>{if(b==="")return;let u;try{u=g.trim()===""?{}:pe(JSON.parse(g))}catch(J){v(i("Invalid JSON args: {message}",{message:J.message})),x(null);return}P.current+=1;let N=P.current;v(null),k(!0);try{let J=await n({args:u,functionPath:b,shardKey:H.trim(),userId:w.trim()});N===P.current&&x(J)}finally{k(!1)}},"L"),q=f(()=>{ae(O())},"$"),U=f(u=>{h(u.target.value)},"U"),W=f(u=>{$(u.target.value)},"W"),j=f(u=>{S(u.target.value)},"M"),B=f(u=>{D(u.target.checked),!u.target.checked&&Z&&h("")},"z"),M=!l||A||b==="";return(0,a.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[r!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:r}),!l&&(0,a.jsx)(de,{description:i("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:i("Set `runAsIdentity` to forge an identity and probe access.")}),(0,a.jsxs)("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-function",children:i("Function")}),(0,a.jsx)("select",{"aria-label":i("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:U,value:b,children:Q.map(u=>(0,a.jsxs)("option",{value:u.path,children:[u.path," (",u.kind,")"]},u.path))}),(0,a.jsxs)(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[(0,a.jsx)("input",{checked:F,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:B,type:"checkbox"}),i("Include mutations and actions")]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-args",children:i("Arguments")}),(0,a.jsx)(Se,{"aria-label":i("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),(0,a.jsx)(ve,{onChange:C,testId:"pp-shard",value:H}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(_,{htmlFor:"pp-user",children:i("Run as (userId)")}),(0,a.jsx)(V,{"aria-label":i("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:j,placeholder:i("Required \u2014 the identity to probe as"),value:w})]}),(0,a.jsx)(He,{disabled:M,executesWrites:Z,functionPath:b,onRun:q,running:A,userId:w.trim()})]}),I!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),R!==null&&(0,a.jsx)(Je,{outcome:R})]})},"Qe"),Ve="/__lunora/policy-scaffold",Qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists \u2014 pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({\u2026}) form \u2014 convert it to the builder form (c.use(\u2026).query(\u2026)) before wiring RLS."},Ze=f(async t=>{let e=await fetch(Ve,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};let o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Qe[o]??o}},"Ke"),Ae={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ye=f(()=>{let t=(0,ee.c)(69),e=K(),[l,o]=(0,y.useState)(null),[i,n]=(0,y.useState)(!1),[s,p]=(0,y.useState)(null),[r,m]=(0,y.useState)(Ae),d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=f(te=>{let Y=te.target.name,{value:G}=te.target;m(Re=>({...Re,[Y]:G}))},"c"),t[0]=d):d=t[0];let c=d,h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=f(()=>{o(null),m(Ae)},"h"),t[1]=h):h=t[1];let g=h,$;t[2]===Symbol.for("react.memo_cache_sentinel")?($=f(async te=>{n(!0),p(null);try{let Y=await Ze(te);p(Y),Y.kind==="ok"&&g()}catch(Y){let G=Y;p({kind:"error",message:G instanceof Error?G.message:String(G)})}n(!1)},"F"),t[2]=$):$=t[2];let H=$,C;t[3]!==r.policyName||t[4]!==r.tableName?(C=f(()=>{ae(H({kind:"scaffoldPolicy",name:r.policyName.trim(),table:r.tableName.trim()}))},"w"),t[3]=r.policyName,t[4]=r.tableName,t[5]=C):C=t[5];let w=C,S;t[6]!==r.exportName||t[7]!==r.filePath||t[8]!==r.policies?(S=f(()=>{ae(H({exportName:r.exportName.trim(),filePath:r.filePath.trim(),kind:"wireRls",policies:r.policies.trim()}))},"P"),t[6]=r.exportName,t[7]=r.filePath,t[8]=r.policies,t[9]=S):S=t[9];let A=S,k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=f(()=>{p(null),o("scaffold")},"k"),t[10]=k):k=t[10];let R=k,x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=f(()=>{p(null),o("wire")},"x"),t[11]=x):x=t[11];let I=x,v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let F;t[14]!==v?(F=(0,a.jsx)(fe,{children:v}),t[14]=v,t[15]=F):F=t[15];let D;t[16]!==e?(D=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=D):D=t[17];let T;t[18]!==D?(T=(0,a.jsx)(he,{children:D}),t[18]=D,t[19]=T):T=t[19];let P;t[20]!==T||t[21]!==F?(P=(0,a.jsxs)(ue,{children:[F,T]}),t[20]=T,t[21]=F,t[22]=P):P=t[22];let Q=l==="scaffold"?"default":"outline",b;t[23]!==e?(b=e("New policy file"),t[23]=e,t[24]=b):b=t[24];let L;t[25]!==Q||t[26]!==b?(L=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-new",onClick:R,size:"xs",type:"button",variant:Q,children:b}),t[25]=Q,t[26]=b,t[27]=L):L=t[27];let Z=l==="wire"?"default":"outline",O;t[28]!==e?(O=e("Wire into a procedure"),t[28]=e,t[29]=O):O=t[29];let q;t[30]!==Z||t[31]!==O?(q=(0,a.jsx)(z,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:Z,children:O}),t[30]=Z,t[31]=O,t[32]=q):q=t[32];let U;t[33]!==L||t[34]!==q?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,q]}),t[33]=L,t[34]=q,t[35]=U):U=t[35];let W;t[36]!==i||t[37]!==r.policyName||t[38]!==r.tableName||t[39]!==l||t[40]!==w||t[41]!==e?(W=l==="scaffold"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:c,value:r.policyName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:c,value:r.tableName})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-create",disabled:i||r.policyName.trim()===""||r.tableName.trim()==="",onClick:w,size:"xs",type:"button",children:e(i?"Creating\u2026":"Create policy file")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=i,t[37]=r.policyName,t[38]=r.tableName,t[39]=l,t[40]=w,t[41]=e,t[42]=W):W=t[42];let j;t[43]!==i||t[44]!==r.exportName||t[45]!==r.filePath||t[46]!==r.policies||t[47]!==l||t[48]!==A||t[49]!==e?(j=l==="wire"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:c,value:r.filePath})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:c,value:r.exportName})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,a.jsx)(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),(0,a.jsx)(V,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:c,value:r.policies})]}),(0,a.jsx)(z,{"data-testid":"policy-scaffolder-apply",disabled:i||r.filePath.trim()===""||r.exportName.trim()===""||r.policies.trim()==="",onClick:A,size:"xs",type:"button",children:e(i?"Wiring\u2026":"Wire RLS")}),(0,a.jsx)(z,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=i,t[44]=r.exportName,t[45]=r.filePath,t[46]=r.policies,t[47]=l,t[48]=A,t[49]=e,t[50]=j):j=t[50];let B;t[51]!==s?(B=s?.kind==="error"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:s.message}),t[51]=s,t[52]=B):B=t[52];let M;t[53]!==s?.kind||t[54]!==e?(M=s?.kind==="needs-manual-edit"&&(0,a.jsx)("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand \u2014 the scaffolder only adds new, deny-by-default rules.")}),t[53]=s?.kind,t[54]=e,t[55]=M):M=t[55];let u;t[56]!==s||t[57]!==e?(u=s?.kind==="ok"&&(0,a.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[(0,a.jsx)("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:s.label})}),s.diagnostics.length>0&&(0,a.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:s.diagnostics.map(Ge)})]}),t[56]=s,t[57]=e,t[58]=u):u=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==j||t[62]!==B||t[63]!==M||t[64]!==u?(N=(0,a.jsxs)(ne,{children:[U,W,j,B,M,u]}),t[59]=U,t[60]=W,t[61]=j,t[62]=B,t[63]=M,t[64]=u,t[65]=N):N=t[65];let J;return t[66]!==P||t[67]!==N?(J=(0,a.jsxs)(se,{"data-testid":"policy-scaffolder",size:"sm",children:[P,N]}),t[66]=P,t[67]=N,t[68]=J):J=t[68],J},"Ve");function Ge(t){return(0,a.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}f(Ge,"Ye");var gt=f(({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{let o=K(),[i,n]=(0,y.useState)(void 0),s=f((p,r,m)=>{m!==""&&n(d=>({functionPath:m,nonce:(d?.nonce??0)+1}))},"i");return(0,a.jsxs)("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[(0,a.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),(0,a.jsx)(Oe,{onProbe:s})]}),(0,a.jsx)("section",{className:"flex flex-col gap-3",children:(0,a.jsxs)(se,{className:"gap-0 py-0",children:[(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),(0,a.jsxs)(ne,{className:"px-4 py-4",children:[(0,a.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),(0,a.jsx)(Ke,{functions:t,prefill:i,runAsIdentity:e})]})]})}),l&&(0,a.jsx)("section",{className:"flex flex-col gap-2",children:(0,a.jsx)(Ye,{})})]})},"bt");export{gt as PermissionsPanel};
@@ -1 +1 @@
1
- import{m as h,n as v}from"./chunk-5IIX2STA.js";import{b as g}from"./chunk-LPINY2IJ.js";import{a as u,d as p,f as x,g as y}from"./chunk-OXFKZ4BM.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};
1
+ import{m as h,n as v}from"./chunk-ZFFZWSDJ.js";import{b as g}from"./chunk-LPINY2IJ.js";import{a as u,d as p,f as x,g as y}from"./chunk-OXFKZ4BM.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};