@lunora/studio 1.0.0-alpha.337 → 1.0.0-alpha.338
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.
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs +1 -0
- package/dist/standalone/{chunk-VQH2F33R.js → chunk-2JD6VLW7.js} +1 -1
- package/dist/standalone/{chunk-6K7ZB6M6.js → chunk-2OOWQRI5.js} +1 -1
- package/dist/standalone/{chunk-3EFAEGID.js → chunk-3DNOCE5K.js} +1 -1
- package/dist/standalone/{chunk-7XBIOLIW.js → chunk-3FRBAQI7.js} +1 -1
- package/dist/standalone/chunk-3JVXNEBO.js +7 -0
- package/dist/standalone/{chunk-KT4UNIZB.js → chunk-4KMJQGIN.js} +1 -1
- package/dist/standalone/{chunk-EA2RNGEE.js → chunk-4ZISAQ2B.js} +1 -1
- package/dist/standalone/{chunk-JNW2ARJO.js → chunk-5B4SQYIP.js} +1 -1
- package/dist/standalone/{chunk-AWGYECJN.js → chunk-5NCDYUAL.js} +1 -1
- package/dist/standalone/{chunk-4KVOF3BE.js → chunk-6LNSHLOB.js} +1 -1
- package/dist/standalone/{chunk-IIIYLX6U.js → chunk-7LPVTOAF.js} +1 -1
- package/dist/standalone/{chunk-TKMI2XAK.js → chunk-7VF6QXGR.js} +1 -1
- package/dist/standalone/{chunk-V5FLSZT6.js → chunk-7WWDCRLQ.js} +1 -1
- package/dist/standalone/{chunk-SL7YMFRX.js → chunk-AHQIBM3C.js} +1 -1
- package/dist/standalone/{chunk-NRAAYZ4C.js → chunk-BAWEGZ7T.js} +3 -3
- package/dist/standalone/{chunk-EOCVVABQ.js → chunk-BCGCD4CO.js} +1 -1
- package/dist/standalone/{chunk-2OSBOZSF.js → chunk-CG7AWLQB.js} +1 -1
- package/dist/standalone/{chunk-35LRTD6L.js → chunk-CHYVUB6Y.js} +1 -1
- package/dist/standalone/{chunk-ZFW3QEVE.js → chunk-CMVOO3MU.js} +1 -1
- package/dist/standalone/{chunk-HFR5DYKT.js → chunk-DW67E5WI.js} +1 -1
- package/dist/standalone/{chunk-T4Y5DPRN.js → chunk-DXC6YGNT.js} +1 -1
- package/dist/standalone/{chunk-FKS6EUNJ.js → chunk-EFT6JH6H.js} +1 -1
- package/dist/standalone/{chunk-T6J6Q5Q2.js → chunk-EJ7YAEPM.js} +1 -1
- package/dist/standalone/{chunk-FYW6TV4Q.js → chunk-G2YF7RNG.js} +1 -1
- package/dist/standalone/{chunk-CS7K5PAU.js → chunk-G5DO7HSE.js} +1 -1
- package/dist/standalone/{chunk-HD2IF5L4.js → chunk-GABRCO5N.js} +1 -1
- package/dist/standalone/{chunk-R36PEHB2.js → chunk-GDD7FNZA.js} +1 -1
- package/dist/standalone/{chunk-SHCUZSRI.js → chunk-GNX7VKQY.js} +1 -1
- package/dist/standalone/{chunk-KVEG7CIS.js → chunk-H4BEW5RF.js} +1 -1
- package/dist/standalone/{chunk-Z643LPA5.js → chunk-H6MI6GGH.js} +1 -1
- package/dist/standalone/{chunk-3VI2EZN2.js → chunk-HC6E6BIJ.js} +1 -1
- package/dist/standalone/{chunk-VOLGQ2EF.js → chunk-JIWDKEGI.js} +1 -1
- package/dist/standalone/{chunk-LTQGGU4V.js → chunk-KRSOII6O.js} +1 -1
- package/dist/standalone/{chunk-BOUF5HG7.js → chunk-LQM7KUEA.js} +1 -1
- package/dist/standalone/{chunk-AX2GEOKC.js → chunk-LVNRJL4S.js} +1 -1
- package/dist/standalone/{chunk-5AXRIRHW.js → chunk-LXQGF74P.js} +1 -1
- package/dist/standalone/{chunk-XC2LTW44.js → chunk-M27YVZWM.js} +1 -1
- package/dist/standalone/{chunk-4FUDGFY7.js → chunk-MFUYHLXW.js} +1 -1
- package/dist/standalone/{chunk-MC44447W.js → chunk-NQZ5IJWF.js} +1 -1
- package/dist/standalone/{chunk-YSPQIRER.js → chunk-NWWMHMGA.js} +1 -1
- package/dist/standalone/{chunk-3DRBFZ2R.js → chunk-O75FH2VA.js} +1 -1
- package/dist/standalone/{chunk-7COKTU5I.js → chunk-OPXOPRI2.js} +1 -1
- package/dist/standalone/{chunk-ZRFRFHRU.js → chunk-OYDOFRRB.js} +1 -1
- package/dist/standalone/{chunk-5UDEPHRK.js → chunk-Q5CSRWLU.js} +1 -1
- package/dist/standalone/{chunk-7FTJLXZH.js → chunk-QYLNHUWI.js} +1 -1
- package/dist/standalone/{chunk-ZPYEW5ZL.js → chunk-QZFWP5PG.js} +1 -1
- package/dist/standalone/{chunk-AUUB5SEX.js → chunk-ROX3SLF7.js} +1 -1
- package/dist/standalone/{chunk-LVKT5NQQ.js → chunk-RZAWVHB7.js} +1 -1
- package/dist/standalone/{chunk-VHL2HNC5.js → chunk-SKTCA3PL.js} +1 -1
- package/dist/standalone/{chunk-XN2YDTTH.js → chunk-STF2OPKL.js} +1 -1
- package/dist/standalone/{chunk-BPDWF4EX.js → chunk-TNXRQCSI.js} +1 -1
- package/dist/standalone/{chunk-3SSDUHUE.js → chunk-UEHILSMN.js} +1 -1
- package/dist/standalone/{chunk-L5UNLRGK.js → chunk-UQJRKAQX.js} +1 -1
- package/dist/standalone/{chunk-N4KRZI7P.js → chunk-V65TMRRH.js} +1 -1
- package/dist/standalone/{chunk-P7I3HBJN.js → chunk-VTLEHQAN.js} +1 -1
- package/dist/standalone/{chunk-YHTANVUO.js → chunk-VVB3GENM.js} +2 -2
- package/dist/standalone/{chunk-BUH67LRI.js → chunk-VVGQZR53.js} +1 -1
- package/dist/standalone/{chunk-L3NY3CEL.js → chunk-VVRT5OAX.js} +1 -1
- package/dist/standalone/{chunk-5OGXAO7S.js → chunk-W77PDXGW.js} +1 -1
- package/dist/standalone/{chunk-Q5KTZWZ2.js → chunk-WYP2Z35M.js} +6 -6
- package/dist/standalone/{chunk-W4CQMJH3.js → chunk-XSW4R2MI.js} +1 -1
- package/dist/standalone/{chunk-3LD7PBIC.js → chunk-YGV4V7VT.js} +1 -1
- package/dist/standalone/{chunk-6XRGQ3ND.js → chunk-YI7WVSMX.js} +1 -1
- package/dist/standalone/{chunk-H3MO4VSS.js → chunk-YJ5SU2PD.js} +1 -1
- package/dist/standalone/{chunk-6RYVH5BG.js → chunk-YXW7GATV.js} +1 -1
- package/dist/standalone/{chunk-MW6W7DGV.js → chunk-Z277L2BQ.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/OpenRpcReferencePanel-CPIr-u-J.mjs +0 -1
- package/dist/standalone/chunk-EQRZJZD4.js +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-5UDEPHRK.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-ZRFRFHRU.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-YSPQIRER.js";import{l as J}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&>.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(K,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(X,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:L.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
|
|
1
|
+
import{a as Ze}from"./chunk-7RKB5KS7.js";import{a as qe}from"./chunk-Q5CSRWLU.js";import{a as Ke}from"./chunk-WVWCUB4S.js";import{a as He}from"./chunk-QJLHH3ET.js";import{a as O}from"./chunk-37WYCOQ2.js";import{a as Je}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as We}from"./chunk-OYDOFRRB.js";import{a as Xe}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{i as T}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as _}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as D}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as De}from"./chunk-NWWMHMGA.js";import{l as J}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as Ve}from"./chunk-RWVIV3U7.js";import{a as ze,b as _e,c as Pe,d as q,e as U,f as z}from"./chunk-HCTJKP5J.js";import{a as K,e as X}from"./chunk-2IKDEUCX.js";import{d as Q,h as Ee,p as Ue,q as Z,s as Qe,u as te}from"./chunk-74IYYDDI.js";import{a as s,d as Me,e as at,f as lt,g as nt}from"./chunk-I26MS5PJ.js";var C=Me(at(),1);var W=Me(lt(),1);var t=Me(nt(),1);var it=s(()=>{let h=(0,W.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"nt"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","lt"),et=500,rt=s((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),dt=s(h=>{let e=(0,W.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:o}=h,a=Q(),[p,i]=(0,C.useState)(null),u;e[0]!==n||e[1]!==o?(u=rt(o,n),e[0]=n,e[1]=o,e[2]=u):u=e[2];let c=u,y;e[3]!==c?(y=s(()=>{let $="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||$===void 0||Z($.writeText(c).then(()=>(i(c),!0)))},"y"),e[3]=c,e[4]=y):y=e[4];let w=y,g;e[5]!==a?(g=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=g):g=e[6];let I;e[7]!==g?(I=(0,t.jsx)("p",{className:"text-sm",children:g}),e[7]=g,e[8]=I):I=e[8];let k=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let d;e[11]!==l?(d=s($=>{l($.target.value)},"r"),e[11]=l,e[12]=d):d=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==d?(m=(0,t.jsx)(T,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:d,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=d,e[17]=m):m=e[17];let b=c??"",x;e[18]!==b?(x=(0,t.jsx)(T,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==p||e[21]!==c||e[22]!==a?(N=a(p!==null&&p===c?"Copied":"Copy"),e[20]=p,e[21]=c,e[22]=a,e[23]=N):N=e[23];let f;e[24]!==w||e[25]!==N?(f=(0,t.jsx)(_,{"data-testid":"sign-up-invitation-copy",onClick:w,type:"button",children:N}),e[24]=w,e[25]=N,e[26]=f):f=e[26];let r;e[27]!==x||e[28]!==f?(r=(0,t.jsxs)("div",{className:"flex gap-2",children:[x,f]}),e[27]=x,e[28]=f,e[29]=r):r=e[29];let S;return e[30]!==r||e[31]!==I||e[32]!==m?(S=(0,t.jsx)(K,{children:(0,t.jsxs)(X,{className:"flex flex-col gap-2 p-4",children:[I,m,r]})}),e[30]=r,e[31]=I,e[32]=m,e[33]=S):S=e[33],S},"it"),ot=s(()=>{let h=J(),e=Q(),[n,l]=(0,C.useState)(""),[o,a]=(0,C.useState)(null),[p,i]=(0,C.useState)(null),[u,c]=(0,C.useState)(()=>`${Qe(h.url)}/sign-up`),y=De(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),w=y.data?.rows??null,g=y.data?.total??0,I=s(()=>{let v=n.trim();v!==""&&(a(null),Z((async()=>{try{let d=await h.createAuthSignUpInvitation({email:v}),m=typeof d.token=="string"?d.token:void 0;i(m===void 0?null:{email:v,token:m}),l(""),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})()))},"w"),k=s(v=>{a(null),Z((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(d){a(d instanceof Error?d.message:String(d))}})())},"k");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(T,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(_,{"data-testid":"sign-up-invitation-submit",onClick:I,type:"button",children:e("Invite")})]}),p!==null&&(0,t.jsx)(dt,{issued:p,onSignUpPageChange:c,signUpPage:u},p.token),(o??y.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),w!==null&&w.length===0&&(0,t.jsx)(Ve,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),w!==null&&g>w.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),w!==null&&w.length>0&&(0,t.jsx)(K,{children:(0,t.jsx)(X,{className:"p-0",children:(0,t.jsxs)(ze,{children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:e("Email")}),(0,t.jsx)(U,{children:e("Status")}),(0,t.jsx)(U,{children:e("Expires")}),(0,t.jsx)(U,{children:e("Invited by")}),(0,t.jsx)(U,{})]})}),(0,t.jsx)(Pe,{children:w.map(v=>{let d=st(v,Date.now()),m=v.email??"";return(0,t.jsxs)(q,{"data-testid":`sign-up-invitation-${m}`,children:[(0,t.jsx)(z,{children:m}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${m}`,children:[d==="spent"&&e("Accepted"),d==="expired"&&e("Expired"),d==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(_,{onClick:s(()=>{k(m)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"rt"),ct={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ut=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"dt"),mt=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ct"),ht=s(h=>{let e=(0,W.c)(105),{onClose:n,onCreated:l}=h,o=J(),a=Q(),{config:p}=qe(),{busy:i,error:u,run:c}=Ke(),[y,w]=(0,C.useState)(""),[g,I]=(0,C.useState)(""),[k,v]=(0,C.useState)(""),[d,m]=(0,C.useState)(""),b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];let[x,N]=(0,C.useState)(b),f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s(A=>{w(A.target.value)},"p"),e[1]=f):f=e[1];let r=f,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=s(A=>{I(A.target.value)},"I"),e[2]=S):S=e[2];let $=S,j;e[3]===Symbol.for("react.memo_cache_sentinel")?(j=s(A=>{v(A.target.value)},"z"),e[3]=j):j=e[3];let H=j,M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=s(A=>{m(A.target.value)},"M"),e[4]=M):M=e[4];let Y=M,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=s((A,R)=>{N(ee=>({...ee,[A]:R}))},"L"),e[5]=B):B=e[5];let V=B,G;e[6]!==x?(G=s(A=>x[A.name]??(A.type==="boolean"?!1:""),"Y"),e[6]=x,e[7]=G):G=e[7];let P=G,L;if(e[8]!==p.userFields||e[9]!==P){let A;e[11]!==P?(A=s(R=>!R.required||ut(R,P(R)),"A"),e[11]=P,e[12]=A):A=e[12],L=p.userFields.every(A),e[8]=p.userFields,e[9]=P,e[10]=L}else L=e[10];let F=L,E;e[13]!==i||e[14]!==y||e[15]!==g||e[16]!==F?(E=!i&&y.trim()!==""&&g.trim()!==""&&F,e[13]=i,e[14]=y,e[15]=g,e[16]=F,e[17]=E):E=e[17];let $e=E,ae;e[18]!==p.userFields||e[19]!==P?(ae=s(()=>{let A={};for(let R of p.userFields){let ee=mt(R,P(R));ee!==void 0&&(A[R.name]=ee.value)}return Object.keys(A).length===0?void 0:A},"te"),e[18]=p.userFields,e[19]=P,e[20]=ae):ae=e[20];let je=ae,Re;e[21]!==je||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==n||e[26]!==l||e[27]!==k||e[28]!==d||e[29]!==c?(Re=s(()=>{c(async()=>{await o.createAuthUser({data:je(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:d.trim()===""?void 0:d.trim()}),l(),n()})},"De"),e[21]=je,e[22]=o,e[23]=y,e[24]=g,e[25]=n,e[26]=l,e[27]=k,e[28]=d,e[29]=c,e[30]=Re):Re=e[30];let Be=Re,le;e[31]!==a?(le=a("Create user"),e[31]=a,e[32]=le):le=e[32];let ne;e[33]!==a?(ne=a("Create user"),e[33]=a,e[34]=ne):ne=e[34];let ie;e[35]!==ne?(ie=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=ie):ie=e[36];let se;e[37]!==a?(se=a("email"),e[37]=a,e[38]=se):se=e[38];let re;e[39]!==se?(re=(0,t.jsx)(O,{htmlFor:"uc-email",children:se}),e[39]=se,e[40]=re):re=e[40];let de;e[41]!==y?(de=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:r,type:"email",value:y}),e[41]=y,e[42]=de):de=e[42];let oe;e[43]!==re||e[44]!==de?(oe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,de]}),e[43]=re,e[44]=de,e[45]=oe):oe=e[45];let ce;e[46]!==a?(ce=a("name"),e[46]=a,e[47]=ce):ce=e[47];let ue;e[48]!==ce?(ue=(0,t.jsx)(O,{htmlFor:"uc-name",children:ce}),e[48]=ce,e[49]=ue):ue=e[49];let me;e[50]!==g?(me=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:$,value:g}),e[50]=g,e[51]=me):me=e[51];let he;e[52]!==ue||e[53]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[52]=ue,e[53]=me,e[54]=he):he=e[54];let pe;e[55]!==a?(pe=a("Password (optional)"),e[55]=a,e[56]=pe):pe=e[56];let fe;e[57]!==pe?(fe=(0,t.jsx)(O,{htmlFor:"uc-password",children:pe}),e[57]=pe,e[58]=fe):fe=e[58];let ve;e[59]!==k?(ve=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:k}),e[59]=k,e[60]=ve):ve=e[60];let ge;e[61]!==fe||e[62]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[61]=fe,e[62]=ve,e[63]=ge):ge=e[63];let be;e[64]!==a?(be=a("Role (optional)"),e[64]=a,e[65]=be):be=e[65];let xe;e[66]!==be?(xe=(0,t.jsx)(O,{htmlFor:"uc-role",children:be}),e[66]=be,e[67]=xe):xe=e[67];let ye;e[68]!==d?(ye=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:d}),e[68]=d,e[69]=ye):ye=e[69];let Ne;e[70]!==xe||e[71]!==ye?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[xe,ye]}),e[70]=xe,e[71]=ye,e[72]=Ne):Ne=e[72];let ke;e[73]!==p.userFields||e[74]!==P||e[75]!==a?(ke=p.userFields.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Plugin fields")}),p.userFields.map(A=>{let R=`uc-field-${A.name}`,ee=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Oe=P(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ze,{checked:Oe,"data-testid":R,id:R,onCheckedChange:s(tt=>{V(A.name,tt)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,ee]})]},A.name)}let Ge=P(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(O,{htmlFor:R,children:[A.name,ee]}),(0,t.jsx)(T,{"data-testid":R,id:R,onChange:s(Oe=>{V(A.name,Oe.target.value)},"onChange"),type:ct[A.type],value:typeof Ge=="string"?Ge:""})]},A.name)})]}),e[73]=p.userFields,e[74]=P,e[75]=a,e[76]=ke):ke=e[76];let we;e[77]!==u?(we=u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:u}),e[77]=u,e[78]=we):we=e[78];let Ce;e[79]!==a?(Ce=a("Cancel"),e[79]=a,e[80]=Ce):Ce=e[80];let Ie;e[81]!==n||e[82]!==Ce?(Ie=(0,t.jsx)(_,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=n,e[82]=Ce,e[83]=Ie):Ie=e[83];let Le=!$e,Ae;e[84]!==i||e[85]!==a?(Ae=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=Ae):Ae=e[86];let Se;e[87]!==Be||e[88]!==Le||e[89]!==Ae?(Se=(0,t.jsx)(_,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Ae}),e[87]=Be,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Fe;e[91]!==Ie||e[92]!==Se?(Fe=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ie,Se]}),e[91]=Ie,e[92]=Se,e[93]=Fe):Fe=e[93];let Te;return e[94]!==n||e[95]!==le||e[96]!==ie||e[97]!==oe||e[98]!==he||e[99]!==ge||e[100]!==Ne||e[101]!==ke||e[102]!==we||e[103]!==Fe?(Te=(0,t.jsxs)(He,{label:le,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[ie,oe,he,ge,Ne,ke,we,Fe]}),e[94]=n,e[95]=le,e[96]=ie,e[97]=oe,e[98]=he,e[99]=ge,e[100]=Ne,e[101]=ke,e[102]=we,e[103]=Fe,e[104]=Te):Te=e[104],Te},"ut"),Ye=s(h=>{let e=(0,W.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"_e"),pt=s(h=>{let e=(0,W.c)(29),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{let r=await p.listAuthSessions({limit:50,userId:o});c(r.rows)}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l?(k=s(r=>{l(()=>p.revokeAuthSession({sessionId:r}))},"k"),e[7]=p,e[8]=l,e[9]=k):k=e[9];let v=k,d;e[10]!==i?(d=i("Sessions"),e[10]=i,e[11]=d):d=e[11];let m;e[12]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[12]=d,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==u||e[17]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=u,e[17]=i,e[18]=x):x=e[18];let N;e[19]!==n||e[20]!==v||e[21]!==u||e[22]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>(0,t.jsxs)(q,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.expiresAt)}),(0,t.jsx)(z,{children:r.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-revoke-${r.id}`,disabled:n,onClick:s(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},r.id))})]})})}),e[19]=n,e[20]=v,e[21]=u,e[22]=i,e[23]=N):N=e[23];let f;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=f):f=e[28],f},"mt"),ft=s(h=>{let e=(0,W.c)(30),{busy:n,runAction:l,userId:o,version:a}=h,p=J(),i=Q(),[u,c]=(0,C.useState)(null),[y,w]=(0,C.useState)(null),g;e[0]!==p||e[1]!==o?(g=s(()=>{Z((async()=>{w(null);try{c(await p.listAuthAccounts({userId:o}))}catch(r){let S=r;c(null),w(Ee(S))}})())},"g"),e[0]=p,e[1]=o,e[2]=g):g=e[2];let I;e[3]!==p||e[4]!==o||e[5]!==a?(I=[p,o,a],e[3]=p,e[4]=o,e[5]=a,e[6]=I):I=e[6],(0,C.useEffect)(g,I);let k;e[7]!==p||e[8]!==l||e[9]!==o?(k=s(r=>{l(()=>p.unlinkAuthAccount({accountId:r,userId:o}))},"k"),e[7]=p,e[8]=l,e[9]=o,e[10]=k):k=e[10];let v=k,d;e[11]!==i?(d=i("Linked accounts"),e[11]=i,e[12]=d):d=e[12];let m;e[13]!==d?(m=(0,t.jsx)(Ye,{children:d}),e[13]=d,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==u||e[18]!==i?(x=u!==null&&u.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=u,e[18]=i,e[19]=x):x=e[19];let N;e[20]!==u||e[21]!==n||e[22]!==v||e[23]!==i?(N=u!==null&&u.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Pe,{children:u.map(r=>{let S=Ue(r.id);return(0,t.jsxs)(q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(z,{children:Ue(r.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:s(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=u,e[21]=n,e[22]=v,e[23]=i,e[24]=N):N=e[24];let f;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(f=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=f):f=e[29],f},"ht"),vt=s(h=>{let e=(0,W.c)(40),{busy:n,capabilities:l,runAction:o,userId:a,version:p}=h,i=J(),u=Q(),[c,y]=(0,C.useState)(null),w;e[0]!==l.passkey||e[1]!==i||e[2]!==a?(w=s(()=>{l.passkey&&Z((async()=>{try{y(await i.listAuthPasskeys({userId:a}))}catch{y(null)}})())},"C"),e[0]=l.passkey,e[1]=i,e[2]=a,e[3]=w):w=e[3];let g;e[4]!==l.passkey||e[5]!==i||e[6]!==a||e[7]!==p?(g=[l.passkey,i,a,p],e[4]=l.passkey,e[5]=i,e[6]=a,e[7]=p,e[8]=g):g=e[8],(0,C.useEffect)(w,g);let I;e[9]!==i||e[10]!==o||e[11]!==a?(I=s(()=>{o(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=o,e[11]=a,e[12]=I):I=e[12];let k=I,v;e[13]!==i||e[14]!==o?(v=s(S=>{o(()=>i.deleteAuthPasskey({passkeyId:S}))},"v"),e[13]=i,e[14]=o,e[15]=v):v=e[15];let d=v,m;e[16]!==u?(m=u("Security"),e[16]=u,e[17]=m):m=e[17];let b;e[18]!==m?(b=(0,t.jsx)(Ye,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==n||e[21]!==l.twoFactor||e[22]!==k||e[23]!==u?(x=l.twoFactor&&(0,t.jsx)(_,{"data-testid":"ud-disable-2fa",disabled:n,onClick:k,size:"sm",type:"button",variant:"outline",children:u("Disable two-factor")}),e[20]=n,e[21]=l.twoFactor,e[22]=k,e[23]=u,e[24]=x):x=e[24];let N;e[25]!==l.passkey||e[26]!==c||e[27]!==u?(N=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:u("No passkeys.")}),e[25]=l.passkey,e[26]=c,e[27]=u,e[28]=N):N=e[28];let f;e[29]!==n||e[30]!==l.passkey||e[31]!==d||e[32]!==c||e[33]!==u?(f=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:u("name")}),(0,t.jsx)(U,{children:u("created")}),(0,t.jsx)(U,{"aria-label":u("Actions")})]})}),(0,t.jsx)(Pe,{children:c.map(S=>{let $=Ue(S.id);return(0,t.jsxs)(q,{"data-testid":`ud-passkey-${$}`,children:[(0,t.jsx)(z,{children:Ue(S.name)||$}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(S.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`ud-delete-passkey-${$}`,disabled:n,onClick:s(()=>{d($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:u("Delete")})})]},$)})})]})})}),e[29]=n,e[30]=l.passkey,e[31]=d,e[32]=c,e[33]=u,e[34]=f):f=e[34];let r;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==f?(r=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,f]}),e[35]=b,e[36]=x,e[37]=N,e[38]=f,e[39]=r):r=e[39],r},"ft"),gt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),yt=s(h=>{let e=(0,W.c)(51),{busy:n,onBan:l}=h,o=Q(),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(""),[c,y]=(0,C.useState)(!1),w;e[0]!==i?(w=bt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=w):w=e[1];let g=w,I=c||g!==void 0,k;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==g?(k=s(()=>{l({expiresInSeconds:c||g===void 0?void 0:g*86400,reason:a.trim()===""?void 0:a.trim()})},"k"),e[2]=l,e[3]=c,e[4]=a,e[5]=g,e[6]=k):k=e[6];let v=k,d;e[7]!==o?(d=o("Ban reason (optional)"),e[7]=o,e[8]=d):d=e[8];let m;e[9]!==d?(m=(0,t.jsx)(O,{htmlFor:"ud-ban-reason",children:d}),e[9]=d,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=s(E=>{p(E.target.value)},"b"),e[11]=b):b=e[11];let x;e[12]!==a?(x=(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:a}),e[12]=a,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let f;e[17]!==o?(f=o("Days"),e[17]=o,e[18]=f):f=e[18];let r;e[19]!==f?(r=(0,t.jsx)(O,{htmlFor:"ud-ban-days",children:f}),e[19]=f,e[20]=r):r=e[20];let S;e[21]!==i||e[22]!==g?(S=i.trim()!==""&&g===void 0,e[21]=i,e[22]=g,e[23]=S):S=e[23];let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=s(E=>{u(E.target.value)},"T"),e[24]=$):$=e[24];let j;e[25]!==i||e[26]!==c||e[27]!==S?(j=(0,t.jsx)(T,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:$,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=j):j=e[28];let H;e[29]!==j||e[30]!==r?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[r,j]}),e[29]=j,e[30]=r,e[31]=H):H=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=s(E=>{y(E.target.checked)},"M"),e[32]=M):M=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==o?(B=o("Permanent"),e[35]=o,e[36]=B):B=e[36];let V;e[37]!==Y||e[38]!==B?(V=(0,t.jsxs)(O,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=V):V=e[39];let G=n||!I,P;e[40]!==o?(P=o("Ban user"),e[40]=o,e[41]=P):P=e[41];let L;e[42]!==v||e[43]!==G||e[44]!==P?(L=(0,t.jsx)(_,{"data-testid":"ud-ban",disabled:G,onClick:v,size:"sm",type:"button",variant:"destructive",children:P}),e[42]=v,e[43]=G,e[44]=P,e[45]=L):L=e[45];let F;return e[46]!==H||e[47]!==V||e[48]!==L||e[49]!==N?(F=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[N,H,V,L]}),e[46]=H,e[47]=V,e[48]=L,e[49]=N,e[50]=F):F=e[50],F},"bt"),Nt=s((h,e)=>typeof e=="number"&>.test(h)?te(e):Ue(e),"xt"),kt=s(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let o=J(),a=Q(),p=l.banned===!0,[i,u]=(0,C.useState)(null),[c,y]=(0,C.useState)(!1),[w,g]=(0,C.useState)(0),[I,k]=(0,C.useState)(typeof l.role=="string"?l.role:""),[v,d]=(0,C.useState)(""),[m,b]=(0,C.useState)(null),[x,N]=(0,C.useState)(!1),f=s((F,E)=>{Z((async()=>{y(!0),u(null);try{let $e=await F();E?.refresh!==!1&&(g(ae=>ae+1),e()),E?.onResult?.($e)}catch($e){u(Ee($e))}y(!1)})())},"p"),r=s(F=>{k(F.target.value)},"i"),S=s(F=>{d(F.target.value)},"I"),$=s(()=>{let F=I.trim();F!==""&&f(async()=>{await o.setAuthUserRole({role:F,userId:l.id})})},"T"),j=s(F=>{f(async()=>{await o.banAuthUser({...F,userId:l.id})})},"z"),H=s(()=>{f(async()=>{await o.unbanAuthUser({userId:l.id})})},"j"),M=s(()=>{f(async()=>{await o.setAuthUserPassword({newPassword:v,userId:l.id}),d("")})},"M"),Y=s(()=>{f(()=>o.impersonateAuthUser({userId:l.id}),{onResult:s(F=>{b(F.token)},"onResult"),refresh:!1})},"H"),B=s(()=>{f(async()=>{await o.revokeAuthUserSessions({userId:l.id})})},"L"),V=s(()=>{f(async()=>{await o.removeAuthUser({userId:l.id}),n()})},"V"),G=s(()=>{N(!0)},"Y"),P=s(()=>{N(!1)},"E"),L=Object.entries(l).filter(([F])=>!xt.has(F));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:l.role}),p?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(_,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(K,{className:"gap-0 py-0",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Actions")})}),(0,t.jsxs)(X,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:r,value:I})]}),(0,t.jsx)(_,{"data-testid":"ud-set-role",disabled:c||I.trim()==="",onClick:$,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),p?(0,t.jsx)(_,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(yt,{busy:c,onBan:j}),(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsx)(O,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(_,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(_,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(_,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(_,{"data-testid":"ud-delete-confirm",disabled:c,onClick:V,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(_,{"data-testid":"ud-delete-cancel",onClick:P,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(_,{"data-testid":"ud-delete",disabled:c,onClick:G,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),m!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(O,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),(0,t.jsx)(pt,{busy:c,runAction:f,userId:l.id,version:w}),h.accounts&&(0,t.jsx)(ft,{busy:c,runAction:f,userId:l.id,version:w}),(h.twoFactor||h.passkey)&&(0,t.jsx)(vt,{busy:c,capabilities:h,runAction:f,userId:l.id,version:w}),(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Fields")}),(0,t.jsx)("dl",{className:"flex flex-col",children:L.map(([F,E])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Nt(F,E)})]},F))})]})]})},"yt"),wt=50,Vt=s(({pageSize:h=wt}={})=>{let e=J(),n=Q(),[l,o]=(0,C.useState)(""),[a,p]=(0,C.useState)(""),[i,u]=(0,C.useState)(0),c=Xe(l),[y,w]=(0,C.useState)(null),[g,I]=(0,C.useState)(!1),{capabilities:k}=it(),v=c.trim(),d=a.trim(),m=De(["lunora-auth-users",v,d,h,i],()=>e.listAuthUsers({filterField:d===""?void 0:"role",filterValue:d===""?void 0:d,limit:h,offset:i,search:v===""?void 0:v}).then(r=>({...r,offset:i})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=s(()=>{m.refetch()},"N");We(()=>m.poll(),!0);let f=y===null?null:b?.find(r=>r.id===y)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:s(r=>{o(r.target.value),u(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(T,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(r=>{p(r.target.value),u(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(_,{"data-testid":"us-new",onClick:s(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&(0,t.jsx)(Ve,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),b!==null&&b.length>0&&(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsx)(X,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(q,{children:[(0,t.jsx)(U,{children:n("id")}),(0,t.jsx)(U,{children:n("email")}),(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("role")}),(0,t.jsx)(U,{children:n("status")}),(0,t.jsx)(U,{children:n("verified")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Pe,{children:b.map(r=>(0,t.jsxs)(q,{"data-testid":`us-row-${r.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:r.id}),(0,t.jsx)(z,{children:r.email??""}),(0,t.jsx)(z,{children:r.name??""}),(0,t.jsx)(z,{children:typeof r.role=="string"&&r.role!==""?(0,t.jsx)(D,{variant:"secondary",children:r.role}):""}),(0,t.jsx)(z,{children:r.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(D,{variant:"success",children:n("Active")})}),(0,t.jsx)(z,{children:r.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:n("yes")}):(0,t.jsx)(D,{variant:"outline",children:n("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:te(r.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(_,{"data-testid":`us-manage-${r.id}`,onClick:s(()=>{w(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},r.id))})]})})}),b!==null&&(0,t.jsx)(Je,{count:b.length,offset:m.data?.offset??0,onOffsetChange:u,pageSize:h,prefix:"us",total:m.data?.total}),f!==null&&(0,t.jsx)(kt,{capabilities:k,onChanged:N,onClose:s(()=>{w(null)},"onClose"),user:f}),g&&(0,t.jsx)(ht,{onClose:s(()=>{I(!1)},"onClose"),onCreated:N}),k.inviteOnly&&(0,t.jsx)(ot,{})]})},"jt");export{Vt as UsersPanel};
|
|
@@ -8,8 +8,8 @@ import{a}from"./chunk-I26MS5PJ.js";var r="https://developers.cloudflare.com/supp
|
|
|
8
8
|
`),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
|
|
9
9
|
`),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
|
|
10
10
|
`),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
|
|
11
|
-
`),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],
|
|
12
|
-
`),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),E=a(e=>{if(!O.test(e))return;let t=e.toLowerCase(),o=t.includes("error"),i=t.includes("cloudflare");if(o){for(let s of
|
|
11
|
+
`),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:r,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:r,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:r,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:r,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:r,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:r,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:r,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=a(e=>e!==void 0&&e>="0"&&e<="9","l"),g=a((e,t)=>{for(let o=e.indexOf(t);o!==-1;o=e.indexOf(t,o+t.length))if(!u(e[o-1])&&!u(e[o+t.length]))return!0;return!1},"_"),A=a((e,t)=>{for(let o of[`error ${t}`,`error: ${t}`])for(let i=e.indexOf(o);i!==-1;i=e.indexOf(o,i+o.length))if(!u(e[i+o.length]))return!0;return!1},"E"),O=/error|cloudflare/iu,p=a(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
|
|
12
|
+
`),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),E=a(e=>{if(!O.test(e))return;let t=e.toLowerCase(),o=t.includes("error"),i=t.includes("cloudflare");if(o){for(let s of d)if(A(t,s.code))return p(s)}if(i){for(let s of d)if(g(t,s.code))return p(s)}},"T"),R=a(e=>(typeof e=="string"?e:e.join(`
|
|
13
13
|
`)).split(`
|
|
14
14
|
`).filter(t=>!t.startsWith("```")).join(`
|
|
15
|
-
`).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"A"),_=a(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"u"),y=a(e=>_(e)??E(e),"O");var f=Symbol.for("@lunora/errors/LunoraError"),h=class e extends Error{static{a(this,"s")}static[Symbol.hasInstance](t){return this!==e?Function.prototype[Symbol.hasInstance].call(this,t):typeof t=="object"&&t!==null&&t[f]===!0}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;why;constructor(t,o,i={}){let s=c(t);super(o??t,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??s?.hint,this.title=i.title??s?.title,this.loc=i.location,this.code=t,this.status=i.status??s?.status??500,this.docsUrl=i.docsUrl??s?.docsUrl,this.data=i.data,this.why=i.why,Object.defineProperty(this,f,{value:!0}),i.internal!==void 0&&Object.defineProperty(this,"internal",{value:i.internal})}};export{l as a,R as b,y as c,h as d};
|
|
15
|
+
`).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"A"),_=a(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"u"),y=a(e=>_(e)??E(e),"O");var f=Symbol.for("@lunora/errors/LunoraError"),h=class e extends Error{static{a(this,"s")}static[Symbol.hasInstance](t){return this!==e?Function.prototype[Symbol.hasInstance].call(this,t):typeof t=="object"&&t!==null&&t[f]===!0}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;why;constructor(t,o,i={}){let s=c(t);super(o??t,i.cause===void 0?void 0:{cause:i.cause}),this.name=i.name??"LunoraError",this.hint=i.hint??s?.hint,this.title=i.title??s?.title,this.loc=i.location,this.code=t,this.status=i.status??s?.status??500,this.docsUrl=i.docsUrl??s?.docsUrl,this.data=i.data,this.why=i.why,Object.defineProperty(this,f,{value:!0}),i.internal!==void 0&&Object.defineProperty(this,"internal",{value:i.internal}),i.headers!==void 0&&Object.defineProperty(this,"headers",{value:i.headers})}};export{l as a,R as b,y as c,h as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as J}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as J}from"./chunk-M27YVZWM.js";import"./chunk-NCPW7WHO.js";import"./chunk-LXQGF74P.js";import"./chunk-55UGUCQ6.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-NWWMHMGA.js";import"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as E}from"./chunk-RWVIV3U7.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HCTJKP5J.js";import{a as D,e as _}from"./chunk-2IKDEUCX.js";import{d as q}from"./chunk-74IYYDDI.js";import{a as S,d as O,f as Q,g as V}from"./chunk-I26MS5PJ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./chunk-
|
|
1
|
+
import{a as H}from"./chunk-OYDOFRRB.js";import{b as x}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as z}from"./chunk-NWWMHMGA.js";import{l as O}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HCTJKP5J.js";import{a as A,e as L}from"./chunk-2IKDEUCX.js";import{d as W}from"./chunk-74IYYDDI.js";import{a as R,d as M,f as $,g as D}from"./chunk-I26MS5PJ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,poll:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,l;e[12]!==t?(l=t("This Studio session's sync client"),e[12]=t,e[13]=l):l=e[13];let a;e[14]!==l?(a=(0,n.jsx)("span",{className:"text-sm font-medium",children:l}),e[14]=l,e[15]=a):a=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==a||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[a,o,d]}),e[22]=a,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ae,d as le,e as ke,i as Ne,j as we,l as Se}from"./chunk-ZFW3QEVE.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ye}from"./chunk-VDC6JP4A.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as oe}from"./chunk-SA2OGF3F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{i as me}from"./chunk-OQ6I6OXT.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ne}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{l as ue}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as re}from"./chunk-RWVIV3U7.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-HCTJKP5J.js";import{a as he,e as pe}from"./chunk-2IKDEUCX.js";import{d as Y,q as ge}from"./chunk-74IYYDDI.js";import{a as c,d as te,e as Ae,f as qe,g as je,i as fe}from"./chunk-I26MS5PJ.js";var z=te(qe(),1);var E=te(Ae(),1);var n=te(je(),1);var Ie=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let l of r.nodes)(e===void 0||H(l)===e)&&t.add(l.id);if(e===void 0)return t;let a=new Set(t);for(let l of r.edges)d.has(l.kind)&&(t.has(l.from)&&a.add(l.to),t.has(l.to)&&a.add(l.from));return a},"Pe"),Ee=c((r,e,d,t)=>{let a=`lane:${r}`;return[{data:{label:e},id:a,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((l,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${l.detail??l.kind} \xB7 ${l.name}`,link:Pe(l)},extent:"parent",id:l.id,parentId:a,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let o of r.nodes)d.has(o.id)&&t.set(H(o),[...t.get(H(o))??[],o]);let a=[...r.modules.map(o=>({label:o.installed===!0?`${o.name} \xB7 ${e.componentLabel}`:o.name,lane:o.name})),{label:e.appLaneLabel,lane:Q}],l=[],i=0;for(let{label:o,lane:f}of a){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(l.push(...Ee(f,o,i,m)),i+=1)}let u=[];for(let o of r.edges)e.kinds.has(o.kind)&&d.has(o.from)&&d.has(o.to)&&u.push({animated:Me.has(o.kind),id:`${o.from}|${o.kind}|${o.to}`,label:o.kind,labelBgStyle:Fe,labelStyle:De,source:o.from,style:Be,target:o.to,type:"smoothstep"});return{edges:u,nodes:l}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),a;return e[0]!==t?(a=(0,n.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=a):a=e[1],a},"qe"),Le={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=me(),{label:a,link:l}=d,i;e[0]!==l||e[1]!==t?(i=c(()=>{ge(t(l))},"u"),e[0]=l,e[1]=t,e[2]=i):i=e[2];let u=i,o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(le,{isConnectable:!1,position:ae.Left,style:Le,type:"target"}),e[3]=o):o=e[3];let f;e[4]!==a||e[5]!==u?(f=(0,n.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:a}),e[4]=a,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,n.jsx)(le,{isConnectable:!1,position:ae.Right,style:Le,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,n.jsxs)(n.Fragment,{children:[o,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),a,l,i,u,o,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");o=j(Q),u=he,p="overflow-hidden py-0",i=pe,s="px-0",l=be,m="architecture-catalog";let L;e[13]!==t?(L=t("Module"),e[13]=t,e[14]=L):L=e[14];let I;e[15]!==L?(I=(0,n.jsx)(T,{children:L}),e[15]=L,e[16]=I):I=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,n.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,n.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,n.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==I||e[32]!==q?(h=(0,n.jsx)(xe,{children:(0,n.jsxs)(J,{children:[I,q,y,N]})}),e[29]=y,e[30]=N,e[31]=I,e[32]=q,e[33]=h):h=e[33],a=ve,f=d.modules.map(g=>(0,n.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,n.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,n.jsx)(ne,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,n.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,n.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=a,e[4]=l,e[5]=i,e[6]=u,e[7]=o,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else a=e[3],l=e[4],i=e[5],u=e[6],o=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==o||e[35]!==t?(b=o>0&&(0,n.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,n.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,n.jsx)(_,{className:"text-xs",children:o})]}),e[34]=o,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==a||e[38]!==f||e[39]!==b?(x=(0,n.jsxs)(a,{children:[f,b]}),e[37]=a,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==l||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,n.jsxs)(l,{"data-testid":m,children:[h,x]}),e[41]=l,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,n.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,n.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[a,l]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),o;e[0]!==d.edges?(o=c(w=>d.edges.some(X=>X.kind===w),"n"),e[0]=d.edges,e[1]=o):o=e[1];let f=Ie.filter(o),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==a||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...a===ce?{}:{lane:a}}),e[6]=h,e[7]=p,e[8]=i,e[9]=a,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{l(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let L=j,I="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,n.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,n.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==a||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,n.jsxs)("select",{"aria-label":v,className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"architecture-module-filter",onChange:P,value:a,children:[k,N,M]}),e[26]=a,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,n.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,n.jsx)("button",{"aria-pressed":i.has(w),className:fe("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{L(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,n.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,n.jsx)(Ne,{}),G=(0,n.jsx)(we,{showInteractive:!1}),K=(0,n.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,n.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,n.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,n.jsxs)("section",{className:I,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),a=ue(),l;e[0]!==a?(l=c(()=>a.fetchArchitecture(),"r"),e[0]=a,e[1]=l):l=e[1];let i=ye(d,l,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,n.jsx)(oe,{className:"h-8 w-48"}),(0,n.jsx)(oe,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,n.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,n.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,o,f;e[18]!==u?(o=(0,n.jsx)(We,{manifest:u}),f=(0,n.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=o,e[20]=f):(o=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,n.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,n.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,n.jsx)(ne,{variant:"outline",children:u.unresolved.length})]}),(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==o||e[25]!==f||e[26]!==m?(h=(0,n.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[o,f,m]}),e[24]=o,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Ie)}c(Je,"We");function Qe(r){return(0,n.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,n.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
|
|
1
|
+
import{a as ae,d as le,e as ke,i as Ne,j as we,l as Se}from"./chunk-CMVOO3MU.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as ye}from"./chunk-VDC6JP4A.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as oe}from"./chunk-SA2OGF3F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{i as me}from"./chunk-OQ6I6OXT.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ne}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{l as ue}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as re}from"./chunk-RWVIV3U7.js";import{a as be,b as xe,c as ve,d as J,e as T,f as _}from"./chunk-HCTJKP5J.js";import{a as he,e as pe}from"./chunk-2IKDEUCX.js";import{d as Y,q as ge}from"./chunk-74IYYDDI.js";import{a as c,d as te,e as Ae,f as qe,g as je,i as fe}from"./chunk-I26MS5PJ.js";var z=te(qe(),1);var E=te(Ae(),1);var n=te(je(),1);var Ie=["call","schedule","read","write","enqueue","publish","subscribe","start","trigger","invoke"],Me=new Set(["enqueue","publish","schedule","start","subscribe","trigger"]),$e={cron:1,function:2,http:0,queue:4,service:7,table:6,topic:3,workflow:5},Be={stroke:"var(--muted-foreground)"},De={fill:"var(--muted-foreground)",fontSize:10},Fe={fill:"var(--background)"},Q="",se=260,Oe=120,Ce=44,de=40,_e=12,ie=16,Re=c(r=>{if(typeof r!="object"||r===null)return;let e=r;return["edges","nodes","modules","unresolved"].every(d=>Array.isArray(e[d]))?e:void 0},"Ge"),ze={cron:c(()=>({to:"/schedule"}),"cron"),function:c(()=>({to:"/functions"}),"function"),http:c(()=>({to:"/api"}),"http"),queue:c(()=>({to:"/queues"}),"queue"),service:c(()=>({to:"/functions"}),"service"),table:c(r=>({search:{table:r.name},to:"/data"}),"table"),topic:c(()=>({to:"/queues"}),"topic"),workflow:c(()=>({to:"/workflows"}),"workflow")},Pe=c(r=>ze[r.kind](r),"Me"),H=c(r=>r.module??Q,"R"),Te=c((r,e,d)=>{let t=new Set;for(let l of r.nodes)(e===void 0||H(l)===e)&&t.add(l.id);if(e===void 0)return t;let a=new Set(t);for(let l of r.edges)d.has(l.kind)&&(t.has(l.from)&&a.add(l.to),t.has(l.to)&&a.add(l.from));return a},"Pe"),Ee=c((r,e,d,t)=>{let a=`lane:${r}`;return[{data:{label:e},id:a,position:{x:d*(se+Oe),y:0},selectable:!1,style:{height:Ce+t.length*(de+_e)+ie,width:se},type:"lane"},...t.map((l,i)=>({className:"flex cursor-pointer items-center truncate rounded-md border border-border bg-card px-2 text-xs text-foreground hover:border-ring",data:{label:`${l.detail??l.kind} \xB7 ${l.name}`,link:Pe(l)},extent:"parent",id:l.id,parentId:a,position:{x:ie,y:Ce+i*(de+_e)},style:{height:de,width:se-ie*2},type:"member"}))]},"Re"),He=c((r,e)=>{let d=Te(r,e.lane,e.kinds),t=new Map;for(let o of r.nodes)d.has(o.id)&&t.set(H(o),[...t.get(H(o))??[],o]);let a=[...r.modules.map(o=>({label:o.installed===!0?`${o.name} \xB7 ${e.componentLabel}`:o.name,lane:o.name})),{label:e.appLaneLabel,lane:Q}],l=[],i=0;for(let{label:o,lane:f}of a){let m=(t.get(f)??[]).toSorted((h,s)=>$e[h.kind]-$e[s.kind]||h.name.localeCompare(s.name));m.length>0&&(l.push(...Ee(f,o,i,m)),i+=1)}let u=[];for(let o of r.edges)e.kinds.has(o.kind)&&d.has(o.from)&&d.has(o.to)&&u.push({animated:Me.has(o.kind),id:`${o.from}|${o.kind}|${o.to}`,label:o.kind,labelBgStyle:Fe,labelStyle:De,source:o.from,style:Be,target:o.to,type:"smoothstep"});return{edges:u,nodes:l}},"Fe"),ce="*",Ve=c(r=>{let e=(0,z.c)(2),{data:d}=r,t=String(d.label),a;return e[0]!==t?(a=(0,n.jsx)("div",{className:"size-full rounded-lg border border-dashed border-border bg-background/60 px-3 py-2 text-xs font-medium text-muted-foreground",children:t}),e[0]=t,e[1]=a):a=e[1],a},"qe"),Le={opacity:0},Ze=c(r=>{let e=(0,z.c)(10),{data:d}=r,t=me(),{label:a,link:l}=d,i;e[0]!==l||e[1]!==t?(i=c(()=>{ge(t(l))},"u"),e[0]=l,e[1]=t,e[2]=i):i=e[2];let u=i,o;e[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(le,{isConnectable:!1,position:ae.Left,style:Le,type:"target"}),e[3]=o):o=e[3];let f;e[4]!==a||e[5]!==u?(f=(0,n.jsx)("button",{className:"size-full cursor-pointer truncate rounded-md text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",onClick:u,type:"button",children:a}),e[4]=a,e[5]=u,e[6]=f):f=e[6];let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=(0,n.jsx)(le,{isConnectable:!1,position:ae.Right,style:Le,type:"source"}),e[7]=m):m=e[7];let h;return e[8]!==f?(h=(0,n.jsxs)(n.Fragment,{children:[o,f,m]}),e[8]=f,e[9]=h):h=e[9],h},"je"),Ge={lane:Ve,member:Ze},Ke=c(r=>{let e=Re(r);return e===void 0?{kind:"error",message:"the response is not an architecture manifest"}:e.modules.length===0?{kind:"empty"}:{kind:"ready",spec:e}},"ze"),We=c(r=>{let e=(0,z.c)(54),{manifest:d}=r,t=Y(),a,l,i,u,o,f,m,h,s,p;if(e[0]!==d.modules||e[1]!==d.nodes||e[2]!==t){let P=new Map;for(let g of d.nodes)g.kind==="function"&&P.set(H(g),(P.get(H(g))??0)+1);let j=c(g=>P.get(g)??0,"I");o=j(Q),u=he,p="overflow-hidden py-0",i=pe,s="px-0",l=be,m="architecture-catalog";let L;e[13]!==t?(L=t("Module"),e[13]=t,e[14]=L):L=e[14];let I;e[15]!==L?(I=(0,n.jsx)(T,{children:L}),e[15]=L,e[16]=I):I=e[16];let A;e[17]!==t?(A=t("Description"),e[17]=t,e[18]=A):A=e[18];let q;e[19]!==A?(q=(0,n.jsx)(T,{children:A}),e[19]=A,e[20]=q):q=e[20];let v;e[21]!==t?(v=t("Owned tables"),e[21]=t,e[22]=v):v=e[22];let y;e[23]!==v?(y=(0,n.jsx)(T,{children:v}),e[23]=v,e[24]=y):y=e[24];let k;e[25]!==t?(k=t("Functions"),e[25]=t,e[26]=k):k=e[26];let N;e[27]!==k?(N=(0,n.jsx)(T,{children:k}),e[27]=k,e[28]=N):N=e[28],e[29]!==y||e[30]!==N||e[31]!==I||e[32]!==q?(h=(0,n.jsx)(xe,{children:(0,n.jsxs)(J,{children:[I,q,y,N]})}),e[29]=y,e[30]=N,e[31]=I,e[32]=q,e[33]=h):h=e[33],a=ve,f=d.modules.map(g=>(0,n.jsxs)(J,{"data-testid":`architecture-module-${g.name}`,children:[(0,n.jsxs)(_,{className:"font-mono text-xs",children:[g.name,g.installed===!0&&(0,n.jsx)(ne,{className:"ml-2","data-testid":`architecture-component-${g.name}`,variant:"outline",children:t("Component")})]}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:g.description??(g.installed===!0?t("Installed component"):"\u2014")}),(0,n.jsx)(_,{className:"font-mono text-xs text-muted-foreground",children:g.tables.length===0?"\u2014":g.tables.join(", ")}),(0,n.jsx)(_,{className:"text-xs",children:j(g.name)})]},g.name)),e[0]=d.modules,e[1]=d.nodes,e[2]=t,e[3]=a,e[4]=l,e[5]=i,e[6]=u,e[7]=o,e[8]=f,e[9]=m,e[10]=h,e[11]=s,e[12]=p}else a=e[3],l=e[4],i=e[5],u=e[6],o=e[7],f=e[8],m=e[9],h=e[10],s=e[11],p=e[12];let b;e[34]!==o||e[35]!==t?(b=o>0&&(0,n.jsxs)(J,{"data-testid":"architecture-module-app",children:[(0,n.jsx)(_,{className:"text-xs italic text-muted-foreground",children:t("Outside any module")}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,n.jsx)(_,{className:"text-xs text-muted-foreground",children:"\u2014"}),(0,n.jsx)(_,{className:"text-xs",children:o})]}),e[34]=o,e[35]=t,e[36]=b):b=e[36];let x;e[37]!==a||e[38]!==f||e[39]!==b?(x=(0,n.jsxs)(a,{children:[f,b]}),e[37]=a,e[38]=f,e[39]=b,e[40]=x):x=e[40];let S;e[41]!==l||e[42]!==m||e[43]!==h||e[44]!==x?(S=(0,n.jsxs)(l,{"data-testid":m,children:[h,x]}),e[41]=l,e[42]=m,e[43]=h,e[44]=x,e[45]=S):S=e[45];let $;e[46]!==i||e[47]!==s||e[48]!==S?($=(0,n.jsx)(i,{className:s,children:S}),e[46]=i,e[47]=s,e[48]=S,e[49]=$):$=e[49];let C;return e[50]!==u||e[51]!==p||e[52]!==$?(C=(0,n.jsx)(u,{className:p,children:$}),e[50]=u,e[51]=p,e[52]=$,e[53]=C):C=e[53],C},"Ye"),Ye=c(r=>{let e=(0,z.c)(52),{manifest:d}=r,t=Y(),[a,l]=(0,E.useState)(ce),[i,u]=(0,E.useState)(Je),o;e[0]!==d.edges?(o=c(w=>d.edges.some(X=>X.kind===w),"n"),e[0]=d.edges,e[1]=o):o=e[1];let f=Ie.filter(o),m;e[2]!==t?(m=t("Outside any module"),e[2]=t,e[3]=m):m=e[3];let h=m,s;e[4]!==t?(s=t("Component"),e[4]=t,e[5]=s):s=e[5];let p=s,b;e[6]!==h||e[7]!==p||e[8]!==i||e[9]!==a||e[10]!==d?(b=He(d,{appLaneLabel:h,componentLabel:p,kinds:i,...a===ce?{}:{lane:a}}),e[6]=h,e[7]=p,e[8]=i,e[9]=a,e[10]=d,e[11]=b):b=e[11];let{edges:x,nodes:S}=b,$=(0,E.useRef)(null),C;e[12]===Symbol.for("react.memo_cache_sentinel")?(C=c(w=>{l(w.target.value)},"_"),e[12]=C):C=e[12];let P=C,j;e[13]===Symbol.for("react.memo_cache_sentinel")?(j=c(w=>{u(X=>{let ee=new Set(X);return ee.delete(w)||ee.add(w),ee})},"I"),e[13]=j):j=e[13];let L=j,I="flex flex-col gap-2",A="architecture-diagram",q="flex flex-wrap items-center gap-2",v;e[14]!==t?(v=t("Module"),e[14]=t,e[15]=v):v=e[15];let y;e[16]!==t?(y=t("All modules"),e[16]=t,e[17]=y):y=e[17];let k;e[18]!==y?(k=(0,n.jsx)("option",{value:ce,children:y}),e[18]=y,e[19]=k):k=e[19];let N;e[20]!==d.modules?(N=d.modules.map(Qe),e[20]=d.modules,e[21]=N):N=e[21];let g;e[22]!==t?(g=t("Outside any module"),e[22]=t,e[23]=g):g=e[23];let M;e[24]!==g?(M=(0,n.jsx)("option",{value:Q,children:g}),e[24]=g,e[25]=M):M=e[25];let B;e[26]!==a||e[27]!==v||e[28]!==k||e[29]!==N||e[30]!==M?(B=(0,n.jsxs)("select",{"aria-label":v,className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"architecture-module-filter",onChange:P,value:a,children:[k,N,M]}),e[26]=a,e[27]=v,e[28]=k,e[29]=N,e[30]=M,e[31]=B):B=e[31];let D;e[32]!==x.length||e[33]!==t?(D=t("{count} edges shown",{count:x.length}),e[32]=x.length,e[33]=t,e[34]=D):D=e[34];let F;e[35]!==D?(F=(0,n.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"architecture-edge-count",children:D}),e[35]=D,e[36]=F):F=e[36];let V;e[37]!==i?(V=c(w=>(0,n.jsx)("button",{"aria-pressed":i.has(w),className:fe("rounded-full border border-border px-2.5 py-0.5 text-xs",i.has(w)?"bg-muted":"text-muted-foreground line-through"),"data-testid":`architecture-kind-${w}`,onClick:c(()=>{L(w)},"onClick"),type:"button",children:w},w),"q"),e[37]=i,e[38]=V):V=e[38];let U=f.map(V),O;e[39]!==B||e[40]!==F||e[41]!==U?(O=(0,n.jsxs)("div",{className:q,children:[B,F,U]}),e[39]=B,e[40]=F,e[41]=U,e[42]=O):O=e[42];let Z,G,K;e[43]===Symbol.for("react.memo_cache_sentinel")?(Z=(0,n.jsx)(Ne,{}),G=(0,n.jsx)(we,{showInteractive:!1}),K=(0,n.jsx)(Se,{containerRef:$,filenameBase:"architecture",testIdPrefix:"architecture"}),e[43]=Z,e[44]=G,e[45]=K):(Z=e[43],G=e[44],K=e[45]);let R;e[46]!==x||e[47]!==S?(R=(0,n.jsx)("div",{className:"h-[600px] w-full overflow-hidden border border-border bg-muted/20","data-testid":"architecture-canvas",ref:$,children:(0,n.jsxs)(ke,{edges:x,edgesFocusable:!1,fitView:!0,minZoom:.1,nodes:S,nodesConnectable:!1,nodesDraggable:!1,nodeTypes:Ge,children:[Z,G,K]})}),e[46]=x,e[47]=S,e[48]=R):R=e[48];let W;return e[49]!==O||e[50]!==R?(W=(0,n.jsxs)("section",{className:I,"data-testid":A,children:[O,R]}),e[49]=O,e[50]=R,e[51]=W):W=e[51],W},"Ve"),mt=c(r=>{let e=(0,z.c)(28),{manifest:d}=r,t=Y(),a=ue(),l;e[0]!==a?(l=c(()=>a.fetchArchitecture(),"r"),e[0]=a,e[1]=l):l=e[1];let i=ye(d,l,Ke);if(i.kind==="loading"){let s;return e[2]===Symbol.for("react.memo_cache_sentinel")?(s=(0,n.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"architecture-loading",children:[(0,n.jsx)(oe,{className:"h-8 w-48"}),(0,n.jsx)(oe,{className:"h-64 w-full"})]}),e[2]=s):s=e[2],s}if(i.kind==="error"){let s;e[3]!==i.message||e[4]!==t?(s=t("Couldn't load the architecture manifest: {message}",{message:i.message}),e[3]=i.message,e[4]=t,e[5]=s):s=e[5];let p;e[6]!==t?(p=t("Architecture unavailable"),e[6]=t,e[7]=p):p=e[7];let b;return e[8]!==s||e[9]!==p?(b=(0,n.jsx)(re,{description:s,testId:"architecture-error",title:p}),e[8]=s,e[9]=p,e[10]=b):b=e[10],b}if(i.kind==="empty"){let s;e[11]!==t?(s=t("Add a lunora/<folder>/module.ts that default-exports defineModule(...) and run lunora codegen to map your modules here. Installed components join the map once you declare one."),e[11]=t,e[12]=s):s=e[12];let p;e[13]!==t?(p=t("No modules declared"),e[13]=t,e[14]=p):p=e[14];let b;return e[15]!==s||e[16]!==p?(b=(0,n.jsx)(re,{description:s,testId:"architecture-empty",title:p}),e[15]=s,e[16]=p,e[17]=b):b=e[17],b}let{spec:u}=i,o,f;e[18]!==u?(o=(0,n.jsx)(We,{manifest:u}),f=(0,n.jsx)(Ye,{manifest:u}),e[18]=u,e[19]=o,e[20]=f):(o=e[19],f=e[20]);let m;e[21]!==u.unresolved||e[22]!==t?(m=u.unresolved.length>0&&(0,n.jsxs)("details",{className:"text-sm","data-testid":"architecture-unresolved",children:[(0,n.jsxs)("summary",{className:"cursor-pointer text-muted-foreground",children:[t("{count} call sites could not be drawn",{count:u.unresolved.length})," ",(0,n.jsx)(ne,{variant:"outline",children:u.unresolved.length})]}),(0,n.jsx)("ul",{className:"mt-2 flex flex-col gap-1 font-mono text-xs",children:u.unresolved.map(Ue)})]}),e[21]=u.unresolved,e[22]=t,e[23]=m):m=e[23];let h;return e[24]!==o||e[25]!==f||e[26]!==m?(h=(0,n.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"architecture-panel",children:[o,f,m]}),e[24]=o,e[25]=f,e[26]=m,e[27]=h):h=e[27],h},"mt");function Je(){return new Set(Ie)}c(Je,"We");function Qe(r){return(0,n.jsx)("option",{value:r.name,children:r.name},r.name)}c(Qe,"Ze");function Ue(r){return(0,n.jsxs)("li",{children:[r.file,":",r.line," \xB7 ",r.kind," \xB7 ",r.reason]},`${r.file}:${String(r.line)}:${r.kind}:${r.reason}`)}c(Ue,"Je");export{mt as default};
|