@lunora/studio 1.0.0-alpha.184 → 1.0.0-alpha.185
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/standalone/{chunk-JP6RVFCJ.js → chunk-2254YC77.js} +1 -1
- package/dist/standalone/{chunk-5TV5EBCO.js → chunk-22EHJEFE.js} +1 -1
- package/dist/standalone/{chunk-GKUDJ3RC.js → chunk-2PYJCU6C.js} +1 -1
- package/dist/standalone/{chunk-JYVJ2OWH.js → chunk-2TAFAGWH.js} +1 -1
- package/dist/standalone/{chunk-M3ANC2JI.js → chunk-2VGRBZVS.js} +1 -1
- package/dist/standalone/{chunk-56XCNBO4.js → chunk-3PUGTMHP.js} +1 -1
- package/dist/standalone/{chunk-7TRN7FQ4.js → chunk-5G2MAI3G.js} +1 -1
- package/dist/standalone/{chunk-FAFNOIJX.js → chunk-6DGK6352.js} +1 -1
- package/dist/standalone/{chunk-724ZBLVZ.js → chunk-6MMHVZID.js} +1 -1
- package/dist/standalone/{chunk-NRZ5MBPS.js → chunk-77UI3GTT.js} +1 -1
- package/dist/standalone/{chunk-4P4DE3XL.js → chunk-7F5LVCXA.js} +1 -1
- package/dist/standalone/{chunk-2KM4MU7U.js → chunk-AMPB3H6K.js} +1 -1
- package/dist/standalone/{chunk-GETL6R4M.js → chunk-CEA2QYAI.js} +1 -1
- package/dist/standalone/{chunk-HATH336U.js → chunk-EKMKNRYI.js} +1 -1
- package/dist/standalone/{chunk-ZWJGQACG.js → chunk-EMUTRNK5.js} +1 -1
- package/dist/standalone/{chunk-3GJKDNXE.js → chunk-FGEBPY6M.js} +1 -1
- package/dist/standalone/{chunk-IYUIJLIW.js → chunk-FHW7T5NC.js} +1 -1
- package/dist/standalone/{chunk-7MF5C3Z6.js → chunk-GLTOTU4J.js} +1 -1
- package/dist/standalone/{chunk-MKRJGSYF.js → chunk-GQQPTCCH.js} +1 -1
- package/dist/standalone/{chunk-QZHPUFML.js → chunk-GXSHHAYL.js} +1 -1
- package/dist/standalone/{chunk-WDJ4CHIO.js → chunk-H7UQ7W6L.js} +1 -1
- package/dist/standalone/{chunk-AO5ROTB4.js → chunk-HB2AVFM7.js} +1 -1
- package/dist/standalone/{chunk-ETHN2RZR.js → chunk-HEIGV6KL.js} +1 -1
- package/dist/standalone/{chunk-O337Z6XI.js → chunk-HQWKWSY4.js} +1 -1
- package/dist/standalone/{chunk-PVAE535J.js → chunk-IOPBEKDK.js} +1 -1
- package/dist/standalone/{chunk-5AQVGRDR.js → chunk-J6ESSV7B.js} +1 -1
- package/dist/standalone/{chunk-N6LSV246.js → chunk-JA7FUFCP.js} +1 -1
- package/dist/standalone/{chunk-VCOPIBKL.js → chunk-K5ZNTNAC.js} +1 -1
- package/dist/standalone/{chunk-FZ45WJQK.js → chunk-L3AFRJE2.js} +1 -1
- package/dist/standalone/{chunk-XBKABVCJ.js → chunk-METTWXRR.js} +1 -1
- package/dist/standalone/{chunk-VG34EBBT.js → chunk-MH73AR4R.js} +1 -1
- package/dist/standalone/{chunk-VICAUTXQ.js → chunk-MRI7UILC.js} +1 -1
- package/dist/standalone/{chunk-LP7ELDUL.js → chunk-MVJL6J4Y.js} +1 -1
- package/dist/standalone/{chunk-55K64SUB.js → chunk-NGEP4H3Q.js} +1 -1
- package/dist/standalone/{chunk-T57JAZCX.js → chunk-NSYGYSMJ.js} +1 -1
- package/dist/standalone/{chunk-CZIPGHIR.js → chunk-OGEHSNF7.js} +1 -1
- package/dist/standalone/{chunk-UZHJM2CX.js → chunk-OUKLYU72.js} +1 -1
- package/dist/standalone/{chunk-7E4PCEOO.js → chunk-P52AMBNB.js} +1 -1
- package/dist/standalone/{chunk-FRMJ5VVM.js → chunk-PAWM6IP3.js} +1 -1
- package/dist/standalone/{chunk-JM6U3CQE.js → chunk-PCQP4NHL.js} +1 -1
- package/dist/standalone/{chunk-Y6SKU4M7.js → chunk-Q5R67CRQ.js} +1 -1
- package/dist/standalone/{chunk-MWSNVNHE.js → chunk-QAIEAIIE.js} +1 -1
- package/dist/standalone/{chunk-26L63KFY.js → chunk-QMFQGVTQ.js} +1 -1
- package/dist/standalone/{chunk-6VNVVY4F.js → chunk-QZJVCXWS.js} +1 -1
- package/dist/standalone/{chunk-ZGMGMEFM.js → chunk-RBAMNKW7.js} +1 -1
- package/dist/standalone/{chunk-CLELTQYS.js → chunk-RJZI2ZRF.js} +1 -1
- package/dist/standalone/{chunk-YBZYUPAG.js → chunk-RY2LZULX.js} +1 -1
- package/dist/standalone/{chunk-4PLYQWKJ.js → chunk-SMMYONB7.js} +1 -1
- package/dist/standalone/{chunk-EAQZEXBX.js → chunk-SZSHO6RE.js} +1 -1
- package/dist/standalone/{chunk-BMVSHGFK.js → chunk-TLFNAWL6.js} +1 -1
- package/dist/standalone/{chunk-SDBOAPOT.js → chunk-U5EMA2D7.js} +1 -1
- package/dist/standalone/{chunk-Z2CLSELV.js → chunk-UCYK6YWD.js} +1 -1
- package/dist/standalone/{chunk-FDB7QVEC.js → chunk-UD47ZOIF.js} +1 -1
- package/dist/standalone/{chunk-37CLUREK.js → chunk-UREV5NIX.js} +1 -1
- package/dist/standalone/{chunk-75OWNJEY.js → chunk-VWLX4CH4.js} +2 -2
- package/dist/standalone/{chunk-DVXDMRWA.js → chunk-XRR2R2H5.js} +1 -1
- package/dist/standalone/{chunk-4X5HAX5N.js → chunk-XXB357HN.js} +1 -1
- package/dist/standalone/{chunk-FGMA2GGM.js → chunk-YAMJRRT2.js} +1 -1
- package/dist/standalone/{chunk-J6JOGFVB.js → chunk-Z4FYPU4Q.js} +1 -1
- package/dist/standalone/{chunk-SGL3ZV4P.js → chunk-ZEZ5FW7V.js} +1 -1
- package/dist/standalone/{chunk-PVV6LALL.js → chunk-ZVMUTCUE.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Qe}from"./chunk-56XCNBO4.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as Qe}from"./chunk-3PUGTMHP.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as C}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as y}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as C}from"./chunk-UD47ZOIF.js";import"./chunk-ULIQFBZU.js";import"./chunk-AMPB3H6K.js";import"./chunk-35DM4JJG.js";import{a as h}from"./chunk-4ZEL6BYL.js";import{c as u}from"./chunk-5G2MAI3G.js";import"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as T}from"./chunk-FKVZRPV5.js";import{a as S,b as K,c as $,d as g,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as A,e as k}from"./chunk-WUWBZPUK.js";import{d as M,r as D}from"./chunk-FODLDLE2.js";import{a as d,d as z,e as ae,g as re}from"./chunk-YKXDMIHQ.js";var O=z(ae(),1);var e=z(re(),1);var Q="agent_threads",se="agent_messages",F="agent_run_queue",R=100,ne=250,oe={},ie={filters:[],limit:R,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},l=d((s,t)=>{let r=s[t];return typeof r=="string"?r:void 0},"i"),j=d((s,t)=>{let r=s[t];return typeof r=="number"?r:void 0},"A"),L=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:r}=t;return typeof r=="number"?r:void 0},"U"),de=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(r=>r!==null&&typeof r=="object"?r.name:void 0).filter(r=>typeof r=="string"):[]},"ne"),le=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"oe"),ce=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"de"),Ne=d(({initialShardKey:s=""})=>{let t=M(),[r,I]=(0,O.useState)(void 0),{data:c}=u(h.listTables,oe,{live:!0,shardKey:s}),G=c!==void 0,p=Array.isArray(c)&&c.some(a=>a.name===Q),H=Array.isArray(c)&&c.some(a=>a.name===F),{data:_,error:J,errorSource:V,liveError:W}=u(h.readTablePage,ie,{enabled:p,live:!0,shardKey:s}),X={filters:[{column:"threadKey",operator:"eq",value:r??""}],limit:ne,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:se},{data:q}=u(h.readTablePage,{limit:R,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:F},{enabled:H,live:!0,shardKey:s}),{data:B,error:Y,errorSource:Z}=u(h.readTablePage,X,{enabled:p&&r!==void 0,live:!0,shardKey:s}),v=Array.isArray(_?.rows)?_.rows:[],ee=Array.isArray(q?.rows)?q.rows:[],E=d(a=>ee.filter(n=>l(n,"threadKey")===a).length,"w"),P=Array.isArray(B?.rows)?B.rows:[],U=v.find(a=>l(a,"key")===r),f;return G&&!p?f=(0,e.jsx)(T,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):p&&v.length===0?f=(0,e.jsx)(T,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):f=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(A,{className:"overflow-hidden py-0",children:(0,e.jsx)(k,{className:"px-0",children:(0,e.jsxs)(S,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)($,{children:v.map(a=>{let n=l(a,"key")??"",m=l(a,"status"),x=L(a);return(0,e.jsxs)(g,{"data-active":n===r?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:l(a,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(y,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:E(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:E(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:j(a,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:x??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:D(j(a,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(w,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{I(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),Y!==null&&(0,e.jsx)(C,{error:Z,testId:"agents-messages-error"}),r!==void 0&&(0,e.jsx)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(k,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",r,U!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",L(U)??0," ",t("Tokens")]})]}),(0,e.jsx)(w,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{I(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),P.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(S,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(K,{children:(0,e.jsxs)(g,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)($,{children:P.map((a,n)=>{let m=l(a,"role")??"\u2014",x=de(a),te=l(a,"toolName"),b=l(a,"status"),N=j(a,"seq")??n;return(0,e.jsxs)(g,{"data-testid":`agents-message-${String(N)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(a,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:te??(x.length>0?x.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:b===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(y,{"data-testid":`agents-message-approval-${String(N)}`,variant:ce(b),children:b})})]},l(a,"messageKey")??`${m}:${String(N)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[J!==null&&(0,e.jsx)(C,{error:V,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),W!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),f]})},"be");export{Ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N}from"./chunk-
|
|
1
|
+
import{a as N}from"./chunk-UD47ZOIF.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-HEAQVSNS.js";import{a as x,e as b}from"./chunk-WUWBZPUK.js";import{d as h}from"./chunk-FODLDLE2.js";import{a,d as p,e as I,g as R,i as g}from"./chunk-YKXDMIHQ.js";var $=p(I(),1);var e=p(R(),1);var A={ERROR:"error",INFO:"info",WARN:"warning"},q=a(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:A[r.level]}},"z"),C=["error","warning","info"],O={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},S=a((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"$"),j=a((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"k"),z=a((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"V"),F=a(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"O"),B=a(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let s=h(),[m,k]=(0,$.useState)("error"),T=F(o),u=(o??[]).filter(t=>t.level===m),E=a(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:C.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",O[t])}),S(s,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:j(s,t,T[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:s("Issue type")}),(0,e.jsx)(c,{children:s("Entity/item")}),(0,e.jsx)(c,{children:s("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:z(s,m)}),(0,e.jsx)("span",{className:"block text-sm",children:s("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"F");export{q as a,B as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as Ve}from"./chunk-TIUMFAN2.js";import{a as qe}from"./chunk-BOTGXX4H.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as Le}from"./chunk-S3CRZLGS.js";import{a as _e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ke}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ie}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as me}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-7TRN7FQ4.js";import{f as Ne}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import{b as Ie,c as $e}from"./chunk-GETL6R4M.js";import{a as Ae}from"./chunk-FKVZRPV5.js";import{a as ze,b as Re,c as je,d as pe,e as B,f as z}from"./chunk-HEAQVSNS.js";import{a as Me,e as Ce}from"./chunk-WUWBZPUK.js";import{d as ue,f as re,g as be,h as Ke,o as le,r as Te}from"./chunk-FODLDLE2.js";import{a as d,d as ye,e as Oe,f as Ge,g as He}from"./chunk-YKXDMIHQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Se="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=re(U.resolveIssue),Xe=re(U.ignoreIssue),Fe=re(U.assignIssue),Ye=re(U.setIssueSeverity),Ze=re(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=Ve(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,be($));o(I)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let L=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==L||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":b,disabled:_,onClick:L,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=L,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(z,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==E?(S=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=S):S=e[43],S},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;le(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let L=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();le(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(z,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(z,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let j=s.severity??Se,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==V||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:V,children:N}),e[44]=V,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Se,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==L||e[58]!==j||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(z,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:L,value:j,children:[q,D]})}),e[56]=u,e[57]=L,e[58]=j,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(z,{children:(0,t.jsx)(ke,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(z,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,I,F,H,J,Q,ee]}),e[103]=c,e[104]=I,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:l,shardKey:a}=Le(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,L]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ee(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,V)=>{L(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...V,hash:r},be(i))}catch(N){let C=Ke(N);L(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"S"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(ie,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let j;e[34]!==I||e[35]!==c||e[36]!==S?(j=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=j):j=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,j,M&&y.length===0?(0,t.jsx)(Ae,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(je,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
|
|
1
|
+
import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as Ve}from"./chunk-TIUMFAN2.js";import{a as qe}from"./chunk-BOTGXX4H.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as Le}from"./chunk-S3CRZLGS.js";import{a as _e}from"./chunk-2DX5MROH.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ke}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ie}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as me}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-5G2MAI3G.js";import{f as Ne}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import{b as Ie,c as $e}from"./chunk-CEA2QYAI.js";import{a as Ae}from"./chunk-FKVZRPV5.js";import{a as ze,b as Re,c as je,d as pe,e as B,f as z}from"./chunk-HEAQVSNS.js";import{a as Me,e as Ce}from"./chunk-WUWBZPUK.js";import{d as ue,f as re,g as be,h as Ke,o as le,r as Te}from"./chunk-FODLDLE2.js";import{a as d,d as ye,e as Oe,f as Ge,g as He}from"./chunk-YKXDMIHQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Se="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=re(U.resolveIssue),Xe=re(U.ignoreIssue),Fe=re(U.assignIssue),Ye=re(U.setIssueSeverity),Ze=re(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=Ve(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,be($));o(I)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let L=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==L||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":b,disabled:_,onClick:L,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=L,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(z,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==E?(S=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=S):S=e[43],S},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;le(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let L=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();le(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(z,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(z,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let j=s.severity??Se,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==V||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:V,children:N}),e[44]=V,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Se,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==L||e[58]!==j||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(z,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:L,value:j,children:[q,D]})}),e[56]=u,e[57]=L,e[58]=j,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(z,{children:(0,t.jsx)(ke,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(z,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,I,F,H,J,Q,ee]}),e[103]=c,e[104]=I,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:l,shardKey:a}=Le(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,L]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ee(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,V)=>{L(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...V,hash:r},be(i))}catch(N){let C=Ke(N);L(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"S"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(ie,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let j;e[34]!==I||e[35]!==c||e[36]!==S?(j=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=j):j=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,j,M&&y.length===0?(0,t.jsx)(Ae,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(je,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-2DX5MROH.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as O}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{d as K,e as _,f as z,h as B,o as P,r as q}from"./chunk-FODLDLE2.js";import{a as s,d as J,e as ie,g as oe}from"./chunk-YKXDMIHQ.js";var i=J(ie(),1);var e=J(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"oe"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"ie"),ce=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ue=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ce(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(E.runAs),fe=10,he=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),g=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,h]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(B(d))}),()=>{t=!0}},[u,r]);let A=I===""?g[0]?.path??"":I,n=g.find(t=>t.path===A),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){h("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=c.trim()===""?{}:{shardKey:c.trim()},j=o?f.trim():"",L=s(l=>{Y(T=>[{argsText:m,at:Date.now(),id:(T[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...T].slice(0,fe))},"$");h("running"),N(null);try{let l=j===""?await _(u,n.kind,d,t,R):await u.query(me,{args:t,functionPath:n.path,userId:j},R);M(c),y(l),h("success"),L("success")}catch(l){y(void 0),N(l.message),h("error"),L("error")}},"J"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"M"),te=s(t=>{S(t.target.value)},"P"),re=s(t=>{b(t.target.value)},"z"),ae=s(t=>{W(t.target.value)},"q"),se=s(()=>{P(Z())},"H"),ne=s(()=>{b(ue(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:A,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(p,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(U,{onChange:F,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(p,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:q(t.at)})," ",(0,e.jsx)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ae");export{Fe as FunctionRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as R}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as q}from"./chunk-
|
|
1
|
+
import{W as R}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as B}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as S}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as q}from"./chunk-UD47ZOIF.js";import"./chunk-ULIQFBZU.js";import"./chunk-AMPB3H6K.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as O}from"./chunk-5G2MAI3G.js";import"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as D}from"./chunk-FKVZRPV5.js";import{a as G,b as J,c as K,d as F,e as s,f as o}from"./chunk-HEAQVSNS.js";import{a as V,e as W}from"./chunk-WUWBZPUK.js";import{d as P,r as H}from"./chunk-FODLDLE2.js";import{a as n,d as j,e as re,f as ae,g as ie}from"./chunk-YKXDMIHQ.js";var X=j(ae(),1),M=j(re(),1);var t=j(ie(),1);var ne=n(e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary","te"),Q=n(e=>e.endpoint??e.id,"M"),ve=n(()=>{let e=(0,X.c)(38),r=P(),[i,Y]=(0,M.useState)("all"),[l,Z]=(0,M.useState)(""),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];let{data:I,error:d,errorSource:x,isLoading:_,refetch:v}=O(U.listPushSubscriptions,g),N;if(e[1]!==I?.subscriptions||e[2]!==d||e[3]!==x||e[4]!==_||e[5]!==i||e[6]!==v||e[7]!==l||e[8]!==r){let L=I?.subscriptions??[],T=l.trim().toLowerCase(),A=L.filter(a=>i!=="all"&&a.kind!==i?!1:T===""?!0:`${Q(a)} ${a.userId??""}`.toLowerCase().includes(T)),b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=n(a=>{Z(a.target.value)},"w"),e[10]=b):b=e[10];let ee=b,w;e[11]!==v?(w=n(()=>{v()},"y"),e[11]=v,e[12]=w):w=e[12];let E=w,k;e[13]===Symbol.for("react.memo_cache_sentinel")?(k=["all","web-push","fcm"],e[13]=k):k=e[13];let te=k,c;e[14]!==i||e[15]!==r?(c=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:te.map(a=>(0,t.jsx)(B,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:n(()=>{Y(a)},"onClick"),role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=c):c=e[16];let m;e[17]!==r?(m=r("Filter devices"),e[17]=r,e[18]=m):m=e[18];let h;e[19]!==r?(h=r("filter endpoint, user"),e[19]=r,e[20]=h):h=e[20];let u;e[21]!==l||e[22]!==m||e[23]!==h?(u=(0,t.jsx)(R,{"aria-label":m,className:"h-8 w-56","data-testid":"nt-search",onChange:ee,placeholder:h,value:l}),e[21]=l,e[22]=m,e[23]=h,e[24]=u):u=e[24];let f;e[25]!==r?(f=r("Refresh"),e[25]=r,e[26]=f):f=e[26];let p;e[27]!==E||e[28]!==f?(p=(0,t.jsx)(B,{className:"ml-auto","data-testid":"nt-refresh",onClick:E,size:"sm",type:"button",variant:"outline",children:f}),e[27]=E,e[28]=f,e[29]=p):p=e[29];let $=L.length>0&&(0,t.jsx)(S,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:L.length})}),y;e[30]!==p||e[31]!==$||e[32]!==c||e[33]!==u?(y=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p,$]}),e[30]=p,e[31]=$,e[32]=c,e[33]=u,e[34]=y):y=e[34];let C;e[35]!==d||e[36]!==x?(C=d!==null&&(0,t.jsx)(q,{error:x,testId:"nt-error"}),e[35]=d,e[36]=x,e[37]=C):C=e[37],N=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[y,C,d===null&&!_&&A.length===0&&(0,t.jsx)(D,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),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:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&(0,t.jsx)(V,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"nt-table",children:[(0,t.jsx)(J,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(s,{children:r("kind")}),(0,t.jsx)(s,{children:r("endpoint")}),(0,t.jsx)(s,{children:r("user")}),(0,t.jsx)(s,{children:r("last seen")}),(0,t.jsx)(s,{children:r("status")}),(0,t.jsx)(s,{children:r("error")})]})}),(0,t.jsx)(K,{children:A.map(a=>{let z=Q(a);return(0,t.jsxs)(F,{"data-testid":"nt-row",children:[(0,t.jsx)(o,{children:(0,t.jsx)(S,{variant:"outline",children:a.kind})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs",title:z,children:z}),(0,t.jsx)(o,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(o,{className:"text-muted-foreground tabular-nums",children:H(a.lastSeenAt,"\u2014")}),(0,t.jsx)(o,{children:(0,t.jsx)(S,{"data-testid":`nt-status-${a.id}`,variant:ne(a.lastStatus),children:a.lastStatus??r("n/a")})}),(0,t.jsx)(o,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.id)})})]})})})]}),e[1]=I?.subscriptions,e[2]=d,e[3]=x,e[4]=_,e[5]=i,e[6]=v,e[7]=l,e[8]=r,e[9]=N}else N=e[9];return N},"ge");export{ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-FZ45WJQK.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-7TRN7FQ4.js";import{f as V}from"./chunk-EAQZEXBX.js";import"./chunk-FSRSK4LY.js";import"./chunk-GETL6R4M.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,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:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(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)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(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)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(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:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("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:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
|
|
1
|
+
import{a as Ge}from"./chunk-3FBLWUXD.js";import{a as Qe,b as qe}from"./chunk-L3AFRJE2.js";import{a as Xe}from"./chunk-TIUMFAN2.js";import{a as He}from"./chunk-XZMOZFE6.js";import{a as j}from"./chunk-IMOHEGMV.js";import{a as Ke}from"./chunk-66UGPQVC.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{W as E}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as D}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as Ve}from"./chunk-5G2MAI3G.js";import{f as V}from"./chunk-SZSHO6RE.js";import"./chunk-FSRSK4LY.js";import"./chunk-CEA2QYAI.js";import{a as Me}from"./chunk-FKVZRPV5.js";import{a as Se,b as ze,c as Ue,d as T,e as S,f as z}from"./chunk-HEAQVSNS.js";import{a as H,e as W}from"./chunk-WUWBZPUK.js";import{d as q,h as Pe,n as Fe,o as J,r as Q}from"./chunk-FODLDLE2.js";import{a as s,d as Oe,e as tt,f as at,g as it}from"./chunk-YKXDMIHQ.js";var x=Oe(tt(),1);var X=Oe(at(),1);var t=Oe(it(),1);Qe.capabilities;var lt=s(()=>{let h=(0,X.c)(3),{config:e,ready:l}=qe(),i;return h[0]!==e.capabilities||h[1]!==l?(i={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=i):i=h[2],i},"st"),st=s((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","nt"),Ye=500,nt=s(()=>{let h=V(),e=q(),[l,i]=(0,x.useState)(""),[m,a]=(0,x.useState)(null),[c,n]=(0,x.useState)(null),[d,v]=(0,x.useState)(!1),f=Ve(["lunora-auth-sign-up-invitations",Ye],()=>h.listAuthSignUpInvitations({limit:Ye})),C=f.data?.rows??null,y=f.data?.total??0,A=s(()=>{let r=l.trim();r!==""&&(a(null),J((async()=>{try{let u=await h.createAuthSignUpInvitation({email:r}),p=typeof u.token=="string"?u.token:void 0;n(p===void 0?null:`${globalThis.location.origin}/sign-up?email=${encodeURIComponent(r)}&invite=${encodeURIComponent(p)}`),v(!1),i(""),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})()))},"A"),N=s(()=>{let r="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||r===void 0||J(r.writeText(c).then(()=>(v(!0),!0)))},"y"),I=s(r=>{a(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:r}),f.refetch()}catch(u){a(u instanceof Error?u.message:String(u))}})())},"I");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)(E,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:s(r=>{i(r.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:l}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-submit",onClick:A,type:"button",children:e("Invite")})]}),c!==null&&(0,t.jsx)(H,{children:(0,t.jsxs)(W,{className:"flex flex-col gap-2 p-4",children:[(0,t.jsx)("p",{className:"text-sm",children:e("Send this link to the invitee. It is shown once and cannot be recovered.")}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(E,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:c}),(0,t.jsx)(U,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:e(d?"Copied":"Copy")})]})]})}),(m??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:m??f.error}),C!==null&&C.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&y>C.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.")}),C!==null&&C.length>0&&(0,t.jsx)(H,{children:(0,t.jsx)(W,{className:"p-0",children:(0,t.jsxs)(Se,{children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:e("Email")}),(0,t.jsx)(S,{children:e("Status")}),(0,t.jsx)(S,{children:e("Expires")}),(0,t.jsx)(S,{children:e("Invited by")}),(0,t.jsx)(S,{})]})}),(0,t.jsx)(Ue,{children:C.map(r=>{let u=st(r,Date.now()),p=r.email??"";return(0,t.jsxs)(T,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(z,{children:p}),(0,t.jsxs)(z,{"data-testid":`sign-up-invitation-status-${p}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),(0,t.jsx)(z,{children:typeof r.expiresAt=="number"?Q(r.expiresAt):"\u2014"}),(0,t.jsx)(z,{children:r.invitedBy??"\u2014"}),(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(U,{onClick:s(()=>{I(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},r.id)})})]})})})]})},"lt"),rt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=s((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"it"),ot=s((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){let i=Number(l);return Number.isNaN(i)?void 0:{value:i}}return{value:l}}},"rt"),ct=s(h=>{let e=(0,X.c)(105),{onClose:l,onCreated:i}=h,m=V(),a=q(),{config:c}=qe(),{busy:n,error:d,run:v}=Xe(),[f,C]=(0,x.useState)(""),[y,A]=(0,x.useState)(""),[N,I]=(0,x.useState)(""),[r,u]=(0,x.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let[g,o]=(0,x.useState)(p),F;e[1]===Symbol.for("react.memo_cache_sentinel")?(F=s(b=>{C(b.target.value)},"F"),e[1]=F):F=e[1];let k=F,$;e[2]===Symbol.for("react.memo_cache_sentinel")?($=s(b=>{A(b.target.value)},"E"),e[2]=$):$=e[2];let L=$,_;e[3]===Symbol.for("react.memo_cache_sentinel")?(_=s(b=>{I(b.target.value)},"D"),e[3]=_):_=e[3];let Be=_,Z;e[4]===Symbol.for("react.memo_cache_sentinel")?(Z=s(b=>{u(b.target.value)},"Z"),e[4]=Z):Z=e[4];let De=Z,G;e[5]===Symbol.for("react.memo_cache_sentinel")?(G=s((b,R)=>{o(K=>({...K,[b]:R}))},"W"),e[5]=G):G=e[5];let _e=G,Y;e[6]!==g?(Y=s(b=>g[b.name]??(b.type==="boolean"?!1:""),"J"),e[6]=g,e[7]=Y):Y=e[7];let P=Y,ee;if(e[8]!==c.userFields||e[9]!==P){let b;e[11]!==P?(b=s(R=>!R.required||dt(R,P(R)),"g"),e[11]=P,e[12]=b):b=e[12],ee=c.userFields.every(b),e[8]=c.userFields,e[9]=P,e[10]=ee}else ee=e[10];let $e=ee,te;e[13]!==n||e[14]!==f||e[15]!==y||e[16]!==$e?(te=!n&&f.trim()!==""&&y.trim()!==""&&$e,e[13]=n,e[14]=f,e[15]=y,e[16]=$e,e[17]=te):te=e[17];let Te=te,ae;e[18]!==c.userFields||e[19]!==P?(ae=s(()=>{let b={};for(let R of c.userFields){let K=ot(R,P(R));K!==void 0&&(b[R.name]=K.value)}return Object.keys(b).length===0?void 0:b},"ee"),e[18]=c.userFields,e[19]=P,e[20]=ae):ae=e[20];let Re=ae,ie;e[21]!==Re||e[22]!==m||e[23]!==f||e[24]!==y||e[25]!==l||e[26]!==i||e[27]!==N||e[28]!==r||e[29]!==v?(ie=s(()=>{v(async()=>{await m.createAuthUser({data:Re(),email:f.trim(),name:y.trim(),password:N===""?void 0:N,role:r.trim()===""?void 0:r.trim()}),i(),l()})},"te"),e[21]=Re,e[22]=m,e[23]=f,e[24]=y,e[25]=l,e[26]=i,e[27]=N,e[28]=r,e[29]=v,e[30]=ie):ie=e[30];let w=ie,B;e[31]!==a?(B=a("Create user"),e[31]=a,e[32]=B):B=e[32];let O;e[33]!==a?(O=a("Create user"),e[33]=a,e[34]=O):O=e[34];let M;e[35]!==O?(M=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:O}),e[35]=O,e[36]=M):M=e[36];let le;e[37]!==a?(le=a("email"),e[37]=a,e[38]=le):le=e[38];let se;e[39]!==le?(se=(0,t.jsx)(j,{htmlFor:"uc-email",children:le}),e[39]=le,e[40]=se):se=e[40];let ne;e[41]!==f?(ne=(0,t.jsx)(E,{"data-testid":"uc-email",id:"uc-email",onChange:k,type:"email",value:f}),e[41]=f,e[42]=ne):ne=e[42];let re;e[43]!==se||e[44]!==ne?(re=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[se,ne]}),e[43]=se,e[44]=ne,e[45]=re):re=e[45];let de;e[46]!==a?(de=a("name"),e[46]=a,e[47]=de):de=e[47];let oe;e[48]!==de?(oe=(0,t.jsx)(j,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=oe):oe=e[49];let ce;e[50]!==y?(ce=(0,t.jsx)(E,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:y}),e[50]=y,e[51]=ce):ce=e[51];let ue;e[52]!==oe||e[53]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[52]=oe,e[53]=ce,e[54]=ue):ue=e[54];let he;e[55]!==a?(he=a("Password (optional)"),e[55]=a,e[56]=he):he=e[56];let me;e[57]!==he?(me=(0,t.jsx)(j,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=me):me=e[58];let pe;e[59]!==N?(pe=(0,t.jsx)(E,{"data-testid":"uc-password",id:"uc-password",onChange:Be,type:"password",value:N}),e[59]=N,e[60]=pe):pe=e[60];let ve;e[61]!==me||e[62]!==pe?(ve=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[me,pe]}),e[61]=me,e[62]=pe,e[63]=ve):ve=e[63];let fe;e[64]!==a?(fe=a("Role (optional)"),e[64]=a,e[65]=fe):fe=e[65];let be;e[66]!==fe?(be=(0,t.jsx)(j,{htmlFor:"uc-role",children:fe}),e[66]=fe,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=(0,t.jsx)(E,{"data-testid":"uc-role",id:"uc-role",onChange:De,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let ge;e[73]!==c.userFields||e[74]!==P||e[75]!==a?(ge=c.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")}),c.userFields.map(b=>{let R=`uc-field-${b.name}`,K=b.required?"":` (${a("optional")})`;if(b.type==="boolean"){let Le=P(b)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:R,children:[(0,t.jsx)(Ge,{checked:Le,"data-testid":R,id:R,onCheckedChange:s(et=>{_e(b.name,et)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[b.name,K]})]},b.name)}let Je=P(b);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(j,{htmlFor:R,children:[b.name,K]}),(0,t.jsx)(E,{"data-testid":R,id:R,onChange:s(Le=>{_e(b.name,Le.target.value)},"onChange"),type:rt[b.type],value:typeof Je=="string"?Je:""})]},b.name)})]}),e[73]=c.userFields,e[74]=P,e[75]=a,e[76]=ge):ge=e[76];let Ne;e[77]!==d?(Ne=d!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:d}),e[77]=d,e[78]=Ne):Ne=e[78];let ke;e[79]!==a?(ke=a("Cancel"),e[79]=a,e[80]=ke):ke=e[80];let we;e[81]!==l||e[82]!==ke?(we=(0,t.jsx)(U,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:ke}),e[81]=l,e[82]=ke,e[83]=we):we=e[83];let je=!Te,Ce;e[84]!==n||e[85]!==a?(Ce=a(n?"Creating\u2026":"Create"),e[84]=n,e[85]=a,e[86]=Ce):Ce=e[86];let Ae;e[87]!==w||e[88]!==je||e[89]!==Ce?(Ae=(0,t.jsx)(U,{"data-testid":"uc-submit",disabled:je,onClick:w,size:"sm",type:"button",children:Ce}),e[87]=w,e[88]=je,e[89]=Ce,e[90]=Ae):Ae=e[90];let Ie;e[91]!==we||e[92]!==Ae?(Ie=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[we,Ae]}),e[91]=we,e[92]=Ae,e[93]=Ie):Ie=e[93];let Ee;return e[94]!==l||e[95]!==B||e[96]!==M||e[97]!==re||e[98]!==ue||e[99]!==ve||e[100]!==ye||e[101]!==ge||e[102]!==Ne||e[103]!==Ie?(Ee=(0,t.jsxs)(He,{label:B,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[M,re,ue,ve,ye,ge,Ne,Ie]}),e[94]=l,e[95]=B,e[96]=M,e[97]=re,e[98]=ue,e[99]=ve,e[100]=ye,e[101]=ge,e[102]=Ne,e[103]=Ie,e[104]=Ee):Ee=e[104],Ee},"ot"),We=s(h=>{let e=(0,X.c)(2),{children:l}=h,i;return e[0]!==l?(i=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=i):i=e[1],i},"je"),ut=s(h=>{let e=(0,X.c)(29),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{let k=await c.listAuthSessions({limit:50,userId:m});v(k.rows)}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i?(N=s(k=>{i(()=>c.revokeAuthSession({sessionId:k}))},"y"),e[7]=c,e[8]=i,e[9]=N):N=e[9];let I=N,r;e[10]!==n?(r=n("Sessions"),e[10]=n,e[11]=r):r=e[11];let u;e[12]!==r?(u=(0,t.jsx)(We,{children:r}),e[12]=r,e[13]=u):u=e[13];let p;e[14]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=p):p=e[15];let g;e[16]!==d||e[17]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:n("No active sessions.")}),e[16]=d,e[17]=n,e[18]=g):g=e[18];let o;e[19]!==l||e[20]!==I||e[21]!==d||e[22]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("expires")}),(0,t.jsx)(S,{children:n("ip")}),(0,t.jsx)(S,{children:n("user agent")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>(0,t.jsxs)(T,{"data-testid":`ud-session-${k.id}`,children:[(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.expiresAt)}),(0,t.jsx)(z,{children:k.ipAddress??""}),(0,t.jsx)(z,{className:"max-w-40 truncate",children:k.userAgent??""}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-revoke-${k.id}`,disabled:l,onClick:s(()=>{I(k.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Revoke")})})]},k.id))})]})})}),e[19]=l,e[20]=I,e[21]=d,e[22]=n,e[23]=o):o=e[23];let F;return e[24]!==u||e[25]!==p||e[26]!==g||e[27]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[u,p,g,o]}),e[24]=u,e[25]=p,e[26]=g,e[27]=o,e[28]=F):F=e[28],F},"dt"),ht=s(h=>{let e=(0,X.c)(30),{busy:l,runAction:i,userId:m,version:a}=h,c=V(),n=q(),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(null),y;e[0]!==c||e[1]!==m?(y=s(()=>{J((async()=>{C(null);try{v(await c.listAuthAccounts({userId:m}))}catch(k){let $=k;v(null),C(Pe($))}})())},"b"),e[0]=c,e[1]=m,e[2]=y):y=e[2];let A;e[3]!==c||e[4]!==m||e[5]!==a?(A=[c,m,a],e[3]=c,e[4]=m,e[5]=a,e[6]=A):A=e[6],(0,x.useEffect)(y,A);let N;e[7]!==c||e[8]!==i||e[9]!==m?(N=s(k=>{i(()=>c.unlinkAuthAccount({accountId:k,userId:m}))},"y"),e[7]=c,e[8]=i,e[9]=m,e[10]=N):N=e[10];let I=N,r;e[11]!==n?(r=n("Linked accounts"),e[11]=n,e[12]=r):r=e[12];let u;e[13]!==r?(u=(0,t.jsx)(We,{children:r}),e[13]=r,e[14]=u):u=e[14];let p;e[15]!==f?(p=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=p):p=e[16];let g;e[17]!==d||e[18]!==n?(g=d!==null&&d.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No linked accounts.")}),e[17]=d,e[18]=n,e[19]=g):g=e[19];let o;e[20]!==d||e[21]!==l||e[22]!==I||e[23]!==n?(o=d!==null&&d.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:n("provider")}),(0,t.jsx)(S,{children:n("created")}),(0,t.jsx)(S,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Ue,{children:d.map(k=>{let $=Fe(k.id);return(0,t.jsxs)(T,{"data-testid":`ud-account-${$}`,children:[(0,t.jsx)(z,{children:Fe(k.providerId)}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(k.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-unlink-${$}`,disabled:l,onClick:s(()=>{I($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Unlink")})})]},$)})})]})})}),e[20]=d,e[21]=l,e[22]=I,e[23]=n,e[24]=o):o=e[24];let F;return e[25]!==u||e[26]!==p||e[27]!==g||e[28]!==o?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[u,p,g,o]}),e[25]=u,e[26]=p,e[27]=g,e[28]=o,e[29]=F):F=e[29],F},"ct"),mt=s(h=>{let e=(0,X.c)(40),{busy:l,capabilities:i,runAction:m,userId:a,version:c}=h,n=V(),d=q(),[v,f]=(0,x.useState)(null),C;e[0]!==i.passkey||e[1]!==n||e[2]!==a?(C=s(()=>{i.passkey&&J((async()=>{try{f(await n.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"C"),e[0]=i.passkey,e[1]=n,e[2]=a,e[3]=C):C=e[3];let y;e[4]!==i.passkey||e[5]!==n||e[6]!==a||e[7]!==c?(y=[i.passkey,n,a,c],e[4]=i.passkey,e[5]=n,e[6]=a,e[7]=c,e[8]=y):y=e[8],(0,x.useEffect)(C,y);let A;e[9]!==n||e[10]!==m||e[11]!==a?(A=s(()=>{m(()=>n.disableAuthTwoFactor({userId:a}))},"A"),e[9]=n,e[10]=m,e[11]=a,e[12]=A):A=e[12];let N=A,I;e[13]!==n||e[14]!==m?(I=s($=>{m(()=>n.deleteAuthPasskey({passkeyId:$}))},"I"),e[13]=n,e[14]=m,e[15]=I):I=e[15];let r=I,u;e[16]!==d?(u=d("Security"),e[16]=d,e[17]=u):u=e[17];let p;e[18]!==u?(p=(0,t.jsx)(We,{children:u}),e[18]=u,e[19]=p):p=e[19];let g;e[20]!==l||e[21]!==i.twoFactor||e[22]!==N||e[23]!==d?(g=i.twoFactor&&(0,t.jsx)(U,{"data-testid":"ud-disable-2fa",disabled:l,onClick:N,size:"sm",type:"button",variant:"outline",children:d("Disable two-factor")}),e[20]=l,e[21]=i.twoFactor,e[22]=N,e[23]=d,e[24]=g):g=e[24];let o;e[25]!==i.passkey||e[26]!==v||e[27]!==d?(o=i.passkey&&v!==null&&v.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:d("No passkeys.")}),e[25]=i.passkey,e[26]=v,e[27]=d,e[28]=o):o=e[28];let F;e[29]!==l||e[30]!==i.passkey||e[31]!==r||e[32]!==v||e[33]!==d?(F=i.passkey&&v!==null&&v.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:d("name")}),(0,t.jsx)(S,{children:d("created")}),(0,t.jsx)(S,{"aria-label":d("Actions")})]})}),(0,t.jsx)(Ue,{children:v.map($=>{let L=Fe($.id);return(0,t.jsxs)(T,{"data-testid":`ud-passkey-${L}`,children:[(0,t.jsx)(z,{children:Fe($.name)||L}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q($.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`ud-delete-passkey-${L}`,disabled:l,onClick:s(()=>{r(L)},"onClick"),size:"xs",type:"button",variant:"ghost",children:d("Delete")})})]},L)})})]})})}),e[29]=l,e[30]=i.passkey,e[31]=r,e[32]=v,e[33]=d,e[34]=F):F=e[34];let k;return e[35]!==p||e[36]!==g||e[37]!==o||e[38]!==F?(k=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[p,g,o,F]}),e[35]=p,e[36]=g,e[37]=o,e[38]=F,e[39]=k):k=e[39],k},"ut"),pt=/(?:at|expires)$/iu,vt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),ft=s((h,e)=>typeof e=="number"&&pt.test(h)?Q(e):Fe(e),"pt"),bt=s(({capabilities:h,onChanged:e,onClose:l,user:i})=>{let m=V(),a=q(),c=i.banned===!0,[n,d]=(0,x.useState)(null),[v,f]=(0,x.useState)(!1),[C,y]=(0,x.useState)(0),[A,N]=(0,x.useState)(typeof i.role=="string"?i.role:""),[I,r]=(0,x.useState)(""),[u,p]=(0,x.useState)(""),[g,o]=(0,x.useState)(""),[F,k]=(0,x.useState)(null),[$,L]=(0,x.useState)(!1),_=s((w,B)=>{J((async()=>{f(!0),d(null);try{let O=await w();B?.refresh!==!1&&(y(M=>M+1),e()),B?.onResult?.(O)}catch(O){d(Pe(O))}f(!1)})())},"D"),Be=s(w=>{N(w.target.value)},"$e"),Z=s(w=>{r(w.target.value)},"Z"),De=s(w=>{p(w.target.value)},"Be"),G=s(w=>{o(w.target.value)},"W"),_e=s(()=>{let w=A.trim();w!==""&&_(async()=>{await m.setAuthUserRole({role:w,userId:i.id})})},"De"),Y=s(()=>{let w=Number.parseInt(u,10),B=Number.isFinite(w)&&w>0?w*86400:void 0;_(async()=>{await m.banAuthUser({expiresInSeconds:B,reason:I.trim()===""?void 0:I.trim(),userId:i.id})})},"J"),P=s(()=>{_(async()=>{await m.unbanAuthUser({userId:i.id})})},"P"),ee=s(()=>{_(async()=>{await m.setAuthUserPassword({newPassword:g,userId:i.id}),o("")})},"K"),$e=s(()=>{_(()=>m.impersonateAuthUser({userId:i.id}),{onResult:s(w=>{k(w.token)},"onResult"),refresh:!1})},"Fe"),te=s(()=>{_(async()=>{await m.revokeAuthUserSessions({userId:i.id})})},"X"),Te=s(()=>{_(async()=>{await m.removeAuthUser({userId:i.id}),l()})},"ze"),ae=s(()=>{L(!0)},"ee"),Re=s(()=>{L(!1)},"Se"),ie=Object.entries(i).filter(([w])=>!vt.has(w));return(0,t.jsxs)(He,{label:a("User details"),onClose:l,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:i.name??i.email??i.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:i.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof i.role=="string"&&i.role!==""&&(0,t.jsx)(D,{variant:"secondary",children:i.role}),c?(0,t.jsx)(D,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(D,{variant:"outline",children:a("Active")}),i.emailVerified===!0?(0,t.jsx)(D,{variant:"secondary",children:a("verified")}):(0,t.jsx)(D,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(U,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:n}),h.admin&&(0,t.jsxs)(H,{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)(W,{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)(j,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(E,{"data-testid":"ud-role-input",id:"ud-role",onChange:Be,value:A})]}),(0,t.jsx)(U,{"data-testid":"ud-set-role",disabled:v||A.trim()==="",onClick:_e,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),c?(0,t.jsx)(U,{"data-testid":"ud-unban",disabled:v,onClick:P,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(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)(j,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(E,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:Z,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(j,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(E,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:De,type:"number",value:u})]}),(0,t.jsx)(U,{"data-testid":"ud-ban",disabled:v,onClick:Y,size:"sm",type:"button",variant:"destructive",children:a("Ban user")})]}),(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)(j,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(E,{"data-testid":"ud-password",id:"ud-password",onChange:G,type:"password",value:g})]}),(0,t.jsx)(U,{"data-testid":"ud-set-password",disabled:v||g==="",onClick:ee,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(U,{"data-testid":"ud-impersonate",disabled:v,onClick:$e,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(U,{"data-testid":"ud-revoke-all",disabled:v,onClick:te,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),$?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(U,{"data-testid":"ud-delete-confirm",disabled:v,onClick:Te,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(U,{"data-testid":"ud-delete-cancel",onClick:Re,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(U,{"data-testid":"ud-delete",disabled:v,onClick:ae,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),F!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(j,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(E,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:F})]})]})]}),(0,t.jsx)(ut,{busy:v,runAction:_,userId:i.id,version:C}),h.accounts&&(0,t.jsx)(ht,{busy:v,runAction:_,userId:i.id,version:C}),(h.twoFactor||h.passkey)&&(0,t.jsx)(mt,{busy:v,capabilities:h,runAction:_,userId:i.id,version:C}),(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:ie.map(([w,B])=>(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:w}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:ft(w,B)})]},w))})]})]})},"ft"),xt=50,Bt=s(({pageSize:h=xt}={})=>{let e=V(),l=q(),[i,m]=(0,x.useState)(""),[a,c]=(0,x.useState)(""),n=Ze(i),[d,v]=(0,x.useState)(null),[f,C]=(0,x.useState)(!1),{capabilities:y}=lt(),A=n.trim(),N=a.trim(),I=Ve(["lunora-auth-users",A,N,h],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:h,search:A===""?void 0:A}),{keepPreviousData:!0}),r=I.data?.rows??null,u=I.error,p=s(()=>{I.refetch()},"p");Ke(()=>{I.refetch()},!0);let g=d===null?null:r?.find(o=>o.id===d)??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)(E,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:s(o=>{m(o.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:i}),(0,t.jsx)(E,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:s(o=>{c(o.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(U,{"data-testid":"us-new",onClick:s(()=>{C(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),u!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:u}),r!==null&&r.length===0&&(0,t.jsx)(Me,{description:l("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:l("No users.")}),r!==null&&r.length>0&&(0,t.jsx)(H,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Se,{"data-testid":"us-table",children:[(0,t.jsx)(ze,{children:(0,t.jsxs)(T,{children:[(0,t.jsx)(S,{children:l("id")}),(0,t.jsx)(S,{children:l("email")}),(0,t.jsx)(S,{children:l("name")}),(0,t.jsx)(S,{children:l("role")}),(0,t.jsx)(S,{children:l("status")}),(0,t.jsx)(S,{children:l("verified")}),(0,t.jsx)(S,{children:l("created")}),(0,t.jsx)(S,{"aria-label":l("Actions")})]})}),(0,t.jsx)(Ue,{children:r.map(o=>(0,t.jsxs)(T,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(z,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(z,{children:o.email??""}),(0,t.jsx)(z,{children:o.name??""}),(0,t.jsx)(z,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(D,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(z,{children:o.banned===!0?(0,t.jsx)(D,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(D,{variant:"success",children:l("Active")})}),(0,t.jsx)(z,{children:o.emailVerified===!0?(0,t.jsx)(D,{variant:"success",children:l("yes")}):(0,t.jsx)(D,{variant:"outline",children:l("no")})}),(0,t.jsx)(z,{className:"text-muted-foreground tabular-nums",children:Q(o.createdAt)}),(0,t.jsx)(z,{children:(0,t.jsx)(U,{"data-testid":`us-manage-${o.id}`,onClick:s(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},o.id))})]})})}),g!==null&&(0,t.jsx)(bt,{capabilities:y,onChanged:p,onClose:s(()=>{v(null)},"onClose"),user:g}),f&&(0,t.jsx)(ct,{onClose:s(()=>{C(!1)},"onClose"),onCreated:p}),y.inviteOnly&&(0,t.jsx)(nt,{})]})},"zt");export{Bt as UsersPanel};
|