@lunora/studio 1.0.0-alpha.63 → 1.0.0-alpha.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/standalone/{chunk-SM67QXQI.js → chunk-2F7G7IWQ.js} +1 -1
- package/dist/standalone/chunk-34UVAASH.js +1 -0
- package/dist/standalone/chunk-35II7U25.js +11 -0
- package/dist/standalone/{chunk-UVDPQU7J.js → chunk-3FUFEZ65.js} +1 -1
- package/dist/standalone/{chunk-VSS7NFZJ.js → chunk-3QRTYSSX.js} +1 -1
- package/dist/standalone/{chunk-PZPFWABF.js → chunk-4WLYA3XE.js} +1 -1
- package/dist/standalone/{chunk-TDE4AR5O.js → chunk-5OWIOACV.js} +1 -1
- package/dist/standalone/{chunk-ZSWWTXVW.js → chunk-5U2THBI7.js} +1 -1
- package/dist/standalone/{chunk-DY7CLL2H.js → chunk-65OTWFS3.js} +1 -1
- package/dist/standalone/chunk-6DWCIIHE.js +1 -0
- package/dist/standalone/{chunk-IJFCOWEQ.js → chunk-7J5N6DGQ.js} +1 -1
- package/dist/standalone/{chunk-M7QCL3ZP.js → chunk-B43FTQJ7.js} +1 -1
- package/dist/standalone/{chunk-TCQEDMAQ.js → chunk-BNUJ7QMG.js} +1 -1
- package/dist/standalone/{chunk-RLEENOIX.js → chunk-C43X4M5U.js} +1 -1
- package/dist/standalone/{chunk-JGY4NGFW.js → chunk-D7XXWV4E.js} +1 -1
- package/dist/standalone/{chunk-4MSKCWUL.js → chunk-DVOBKIUX.js} +1 -1
- package/dist/standalone/{chunk-K7M4SMQ7.js → chunk-EKRN4ZQM.js} +1 -1
- package/dist/standalone/{chunk-IGBEXNXY.js → chunk-EVN46TVV.js} +1 -1
- package/dist/standalone/{chunk-NPIULIRO.js → chunk-EXFBIISG.js} +1 -1
- package/dist/standalone/{chunk-OZGWNJXD.js → chunk-F5QWLENA.js} +1 -1
- package/dist/standalone/chunk-F6GOKFMU.js +3 -0
- package/dist/standalone/{chunk-PYXZLNG2.js → chunk-FGTK44LR.js} +1 -1
- package/dist/standalone/{chunk-XBGJVK32.js → chunk-GSPTEMYN.js} +1 -1
- package/dist/standalone/{chunk-XITDHIVL.js → chunk-HP2UCWND.js} +1 -1
- package/dist/standalone/{chunk-WQTUQZUM.js → chunk-IDNNI63H.js} +1 -1
- package/dist/standalone/{chunk-ZKEVSU66.js → chunk-KDOC2DP5.js} +1 -1
- package/dist/standalone/{chunk-P4J3Z3SA.js → chunk-L7N7F3DA.js} +1 -1
- package/dist/standalone/{chunk-IPHXIGYP.js → chunk-LJDP7NRB.js} +1 -1
- package/dist/standalone/{chunk-GBQHGYGH.js → chunk-OHKRN65U.js} +1 -1
- package/dist/standalone/{chunk-LA3HEESS.js → chunk-P24JBHEZ.js} +1 -1
- package/dist/standalone/chunk-PWWHP76O.js +1 -0
- package/dist/standalone/{chunk-IUW24D4X.js → chunk-QGKAJTQQ.js} +1 -1
- package/dist/standalone/{chunk-AX4PAEGP.js → chunk-QVEHPYA5.js} +1 -1
- package/dist/standalone/{chunk-7YAUSG6S.js → chunk-QWJ3NPE3.js} +1 -1
- package/dist/standalone/{chunk-H3V2QQ4K.js → chunk-RAA2RGG6.js} +1 -1
- package/dist/standalone/chunk-RBU52M5T.js +1 -0
- package/dist/standalone/{chunk-RWZKO2P6.js → chunk-SA3MDZC3.js} +1 -1
- package/dist/standalone/{chunk-66TS6K5F.js → chunk-T2JIUFOD.js} +1 -1
- package/dist/standalone/chunk-TJ2WZ5OP.js +1 -0
- package/dist/standalone/{chunk-37RIZFJ4.js → chunk-TLHJRWNK.js} +1 -1
- package/dist/standalone/{chunk-YQP2EYOC.js → chunk-UIS34ZPB.js} +1 -1
- package/dist/standalone/{chunk-P4DHFWH7.js → chunk-VPAXCQ2Y.js} +1 -1
- package/dist/standalone/{chunk-V4RWA7QI.js → chunk-XEDU5FO4.js} +1 -1
- package/dist/standalone/{chunk-M2B3MDFJ.js → chunk-XQBTNJUQ.js} +1 -1
- package/dist/standalone/{chunk-OWADN6BI.js → chunk-XSD4Y6SQ.js} +1 -1
- package/dist/standalone/{chunk-BY4QROKU.js → chunk-YD5NF6UT.js} +1 -1
- package/dist/standalone/{chunk-DCJKCERP.js → chunk-YI3WYUXK.js} +1 -1
- package/dist/standalone/{chunk-26TQSVUV.js → chunk-ZNNAGR6N.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +4 -4
- package/dist/standalone/chunk-3NHORZCK.js +0 -1
- package/dist/standalone/chunk-B5E7GQHG.js +0 -1
- package/dist/standalone/chunk-F6LUZVVI.js +0 -1
- package/dist/standalone/chunk-GHUPW2Y5.js +0 -1
- package/dist/standalone/chunk-LWECXQWP.js +0 -11
- package/dist/standalone/chunk-TRHTFGFW.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as ze}from"./chunk-7RXOPYR5.js";import{a as _e}from"./chunk-LLXFYRGQ.js";import{a as Ae}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as Le}from"./chunk-XXQUMVWH.js";import{a as Re,b as Te,c as Oe,d as xe,e as De,f as Me}from"./chunk-MIQTKZAR.js";import"./chunk-QBWRC5YX.js";import{a as Ee}from"./chunk-LFXFP4IF.js";import{b as Ie}from"./chunk-GRL5MG3Z.js";import{d as oe,e as he,f as fe}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as le}from"./chunk-GXZAXNZI.js";import{f as be}from"./chunk-
|
|
1
|
+
import{a as ze}from"./chunk-7RXOPYR5.js";import{a as _e}from"./chunk-LLXFYRGQ.js";import{a as Ae}from"./chunk-5RF4QDDA.js";import"./chunk-XQGANNLS.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-ESVP44Y3.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-PF7V3G2Z.js";import"./chunk-4UOFSGUS.js";import"./chunk-ILNELDFC.js";import"./chunk-7LQWFOEU.js";import"./chunk-T6VMSOBB.js";import{a as Le}from"./chunk-XXQUMVWH.js";import{a as Re,b as Te,c as Oe,d as xe,e as De,f as Me}from"./chunk-MIQTKZAR.js";import"./chunk-QBWRC5YX.js";import{a as Ee}from"./chunk-LFXFP4IF.js";import{b as Ie}from"./chunk-GRL5MG3Z.js";import{d as oe,e as he,f as fe}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as le}from"./chunk-GXZAXNZI.js";import{f as be}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{d as K,f as ne,g as re,h as Se,m as X}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as pe,f as Et,g as Lt,h as Rt,j as te}from"./chunk-3XIESWL4.js";var Y=pe(Lt(),1);var E=pe(Et(),1);var r=pe(Rt(),1);var Tt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Ot=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],se=String.fromCodePoint(0),Dt=new RegExp(`${se}${String.raw`(\d+)`}${se}`,"gu"),Mt=Tt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),_t=Ot.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
2
|
${l}`})),At=s(l=>{let e=[],t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${se}${(e.length-1).toString()}${se}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:n,replacement:o}of Mt)t=t.replaceAll(n,o);for(let{pattern:n,replacement:o}of _t)t=t.replaceAll(n,o);return t=t.replaceAll(Dt,(n,o)=>e[Number(o)]??""),t},"_t"),zt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Wt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),$t=/[\w$]/,Be=s(l=>l!==void 0&&$t.test(l),"Te"),je=s(l=>{let e=l.length;for(;e>0&&Be(l[e-1]);)e-=1;return l.slice(e)},"Le"),He=s((l,e)=>{let t=e;for(;t>0&&Be(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},"Re"),We=s((l,e)=>{let t=l.slice(0,e).trimEnd();return t.endsWith(".")||Wt.has(je(t).toUpperCase())},"Ce"),Bt=s((l,e)=>{let t=l.slice(0,e);if(!t.endsWith("."))return;let n=je(t.slice(0,-1));return n===""?void 0:n},"Bt"),Ne=s((l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),"ge"),$e=s((l,e,t,n)=>{let o=[];for(let a of l)if(Ne(a,e)&&(o.push(n(a)),o.length>=t))break;return o},"Se"),jt=s((l,e,t)=>{let n=new Map;for(let[o,a]of Object.entries(l.columns))for(let d of a)if(Ne(d,e)&&!n.has(d)&&(n.set(d,o),n.size>=t))return[...n].map(([p,c])=>({detail:c,kind:"column",label:p}));return[...n].map(([o,a])=>({detail:a,kind:"column",label:o}))},"Wt"),Ht=s((l,e,t)=>{let n=He(l,e),o=Bt(l,n.start);if(o!==void 0){let c=t.columns[o]??t.columns[o.toLowerCase()]??[];return $e(c,n.text,8,m=>({detail:o,kind:"column",label:m}))}if(n.text===""&&!We(l,n.start))return[];let a=$e(t.tables,n.text,8,c=>({kind:"table",label:c})),d=jt(t,n.text,8),p=zt.filter(c=>n.text!==""&&Ne(c,n.text)&&c.toLowerCase()!==n.text.toLowerCase()).map(c=>({kind:"keyword",label:c}));return(We(l,n.start)?[...d,...a,...p]:[...a,...d,...p]).slice(0,8)},"Ft"),Ft=s((l,e,t)=>{let n=He(l,e),o=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:o}},"Ht"),Pt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Jt=s((l,e)=>{let t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:o}=n;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let c of Pt)o[c]=t[c];n.textContent=l.value.slice(0,Math.max(0,e));let a=globalThis.document.createElement("span");a.textContent=l.value.slice(Math.max(0,e))||".",n.append(a),globalThis.document.body.append(n);let d=a.offsetLeft-l.scrollLeft,p=a.offsetTop-l.scrollTop;return n.remove(),{left:d,top:p}},"Ut"),Ut=s((l,e,t)=>{let n=(0,Y.c)(13),[o,a]=(0,E.useState)(null),d;n[0]!==l||n[1]!==e?(d=s((y,v)=>{let N=Ht(y,v,l);if(N.length===0){a(null);return}let f=e.current,{left:C,top:q}=f===null?{left:0,top:0}:Jt(f,v);a(L=>L!==null&&L.active===0&&L.left===C&&L.top===q&&L.suggestions.length===N.length&&L.suggestions.every((S,M)=>{let O=N.at(M);return S.kind===O?.kind&&S.label===O.label&&S.detail===O.detail})?L:{active:0,left:C,suggestions:N,top:q})},"c"),n[0]=l,n[1]=e,n[2]=d):d=n[2];let p=d,c;n[3]===Symbol.for("react.memo_cache_sentinel")?(c=s(()=>{a(null)},"i"),n[3]=c):c=n[3];let m=c,k;n[4]===Symbol.for("react.memo_cache_sentinel")?(k=s(y=>{a(v=>{if(v===null)return v;let N=v.suggestions.length,f=(v.active+y+N)%N;return{...v,active:f}})},"N"),n[4]=k):k=n[4];let g=k,x;n[5]!==t||n[6]!==o||n[7]!==e?(x=s(()=>{let y=e.current;if(o===null||y===null)return!1;let v=o.suggestions[o.active];if(v===void 0)return!1;let N=Ft(y.value,y.selectionStart,v);return t(N.value),a(null),requestAnimationFrame(()=>{let f=e.current;f!==null&&(f.focus(),f.setSelectionRange(N.caret,N.caret))}),!0},"h"),n[5]=t,n[6]=o,n[7]=e,n[8]=x):x=n[8];let b=x,u;return n[9]!==b||n[10]!==p||n[11]!==o?(u={close:m,commit:b,move:g,refresh:p,state:o},n[9]=b,n[10]=p,n[11]=o,n[12]=u):u=n[12],u},"Jt"),Yt={column:"column",keyword:"keyword",table:"table"},Kt=20,Gt=s(l=>{let e=(0,Y.c)(17),{listboxId:t,onPick:n,state:o}=l,a=K(),d;e[0]!==o?(d=o===null?void 0:{left:o.left,top:o.top+Kt},e[0]=o,e[1]=d):d=e[1];let p=d;if(o===null)return null;let c;if(e[2]!==t||e[3]!==n||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==a){let k;e[8]!==t||e[9]!==n||e[10]!==o.active||e[11]!==a?(k=s((g,x)=>(0,r.jsxs)("li",{"aria-selected":x===o.active,className:te("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",x===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${x.toString()}`,onMouseDown:s(b=>{b.preventDefault(),n(x)},"onMouseDown"),role:"option",children:[(0,r.jsx)("span",{className:"truncate font-mono",children:g.label}),g.detail!==void 0&&(0,r.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail}),(0,r.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:a(Yt[g.kind])})]},`${g.kind}:${g.label}`),"N"),e[8]=t,e[9]=n,e[10]=o.active,e[11]=a,e[12]=k):k=e[12],c=o.suggestions.map(k),e[2]=t,e[3]=n,e[4]=o.active,e[5]=o.suggestions,e[6]=a,e[7]=c}else c=e[7];let m;return e[13]!==t||e[14]!==p||e[15]!==c?(m=(0,r.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:p,children:c}),e[13]=t,e[14]=p,e[15]=c,e[16]=m):m=e[16],m},"Vt"),Fe=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Vt=s(l=>{let e=(0,Y.c)(29),{active:t,onDelete:n,onSelect:o,query:a}=l,d=K(),p;e[0]!==o||e[1]!==a.id?(p=s(()=>{o(a.id)},"m"),e[0]=o,e[1]=a.id,e[2]=p):p=e[2];let c=p,m;e[3]!==n||e[4]!==a.id?(m=s(S=>{S.stopPropagation(),n(a.id)},"u"),e[3]=n,e[4]=a.id,e[5]=m):m=e[5];let k=m,g=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",x;e[6]!==g?(x=te("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[6]=g,e[7]=x):x=e[7];let b=`sql-query-${a.id}`,u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=u):u=e[8];let y;e[9]!==a.name?(y=(0,r.jsx)("span",{className:"truncate",children:a.name}),e[9]=a.name,e[10]=y):y=e[10];let v;e[11]!==t||e[12]!==c||e[13]!==x||e[14]!==b||e[15]!==y?(v=(0,r.jsxs)("button",{"aria-pressed":t,className:x,"data-testid":b,onClick:c,type:"button",children:[u,y]}),e[11]=t,e[12]=c,e[13]=x,e[14]=b,e[15]=y,e[16]=v):v=e[16];let N;e[17]!==d?(N=d("Delete query"),e[17]=d,e[18]=N):N=e[18];let f;e[19]!==d?(f=d("Delete query"),e[19]=d,e[20]=f):f=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=C):C=e[21];let q;e[22]!==k||e[23]!==f||e[24]!==N?(q=(0,r.jsx)("button",{"aria-label":N,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:k,title:f,type:"button",children:C}),e[22]=k,e[23]=f,e[24]=N,e[25]=q):q=e[25];let L;return e[26]!==q||e[27]!==v?(L=(0,r.jsxs)("li",{className:"group/q flex items-center",children:[v,q]}),e[26]=q,e[27]=v,e[28]=L):L=e[28],L},"Gt"),Xt=s(l=>{let e=(0,Y.c)(58),{activeId:t,history:n,listRef:o,onClearHistory:a,onDelete:d,onLoadHistory:p,onLoadTemplate:c,onNew:m,onSearchChange:k,onSelect:g,queries:x,search:b}=l,u=K(),y;if(e[0]!==x||e[1]!==b){let I=b.trim().toLowerCase();y=I===""?[...x]:x.filter(T=>T.name.toLowerCase().includes(I)),e[0]=x,e[1]=b,e[2]=y}else y=e[2];let v=y,N;e[3]!==u?(N=u("Search queries\u2026"),e[3]=u,e[4]=N):N=e[4];let f;e[5]!==k||e[6]!==b||e[7]!==N?(f=(0,r.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:k,placeholder:N,type:"text",value:b}),e[5]=k,e[6]=b,e[7]=N,e[8]=f):f=e[8];let C;e[9]!==u?(C=u("New query"),e[9]=u,e[10]=C):C=e[10];let q;e[11]!==u?(q=u("New query"),e[11]=u,e[12]=q):q=e[12];let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[13]=L):L=e[13];let S;e[14]!==m||e[15]!==C||e[16]!==q?(S=(0,r.jsx)("button",{"aria-label":C,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:m,title:q,type:"button",children:L}),e[14]=m,e[15]=C,e[16]=q,e[17]=S):S=e[17];let M;e[18]!==f||e[19]!==S?(M=(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[f,S]}),e[18]=f,e[19]=S,e[20]=M):M=e[20];let O;e[21]!==u?(O=u("Private"),e[21]=u,e[22]=O):O=e[22];let _;e[23]!==O?(_=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:O}),e[23]=O,e[24]=_):_=e[24];let A;e[25]!==t||e[26]!==v||e[27]!==o||e[28]!==d||e[29]!==g||e[30]!==u?(A=v.length===0?(0,r.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:u("No saved queries yet \u2014 they save to this browser as you type.")}):(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:v.map(I=>(0,r.jsx)(Vt,{active:t===I.id,onDelete:d,onSelect:g,query:I},I.id))}),e[25]=t,e[26]=v,e[27]=o,e[28]=d,e[29]=g,e[30]=u,e[31]=A):A=e[31];let W;e[32]!==_||e[33]!==A?(W=(0,r.jsxs)("div",{children:[_,A]}),e[32]=_,e[33]=A,e[34]=W):W=e[34];let $;e[35]!==u?($=u("Reference"),e[35]=u,e[36]=$):$=e[36];let P;e[37]!==$?(P=(0,r.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=P):P=e[38];let H;e[39]!==c?(H=Fe.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,onClick:c,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),I.label]})},I.label)),e[39]=c,e[40]=H):H=e[40];let z;e[41]!==H?(z=(0,r.jsx)("ul",{className:"flex flex-col gap-px",children:H}),e[41]=H,e[42]=z):z=e[42];let R;e[43]!==P||e[44]!==z?(R=(0,r.jsxs)("div",{children:[P,z]}),e[43]=P,e[44]=z,e[45]=R):R=e[45];let D;e[46]!==n||e[47]!==a||e[48]!==p||e[49]!==u?(D=n.length>0&&(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,r.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u("History")}),(0,r.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:a,type:"button",children:u("Clear history")})]}),(0,r.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(I=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,"data-testid":"sql-history-item",onClick:p,title:I.sql,type:"button",children:[(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,r.jsx)("span",{className:"truncate font-mono",children:I.sql})]})},`${I.at.toString()}:${I.sql}`))})]}),e[46]=n,e[47]=a,e[48]=p,e[49]=u,e[50]=D):D=e[50];let B;e[51]!==W||e[52]!==R||e[53]!==D?(B=(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[W,R,D]}),e[51]=W,e[52]=R,e[53]=D,e[54]=B):B=e[54];let j;return e[55]!==B||e[56]!==M?(j=(0,r.jsxs)("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[M,B]}),e[55]=B,e[56]=M,e[57]=j):j=e[57],j},"Qt"),Qt=ne(le.listTables),Zt=ne(le.readTablePage),en=s(l=>{let e=(0,Y.c)(16),t=be(),n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let[o,a]=(0,E.useState)(n),d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={},e[1]=d):d=e[1];let[p,c]=(0,E.useState)(d),m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=new Set,e[2]=m):m=e[2];let k=(0,E.useRef)(m),g,x;e[3]!==t||e[4]!==l?(g=s(()=>{let f={cancelled:!1};return X((async()=>{try{let C=await t.query(Qt,{},re(l));f.cancelled||(a(C.map(nn)),c({}),k.current=new Set)}catch{f.cancelled||(a([]),c({}),k.current=new Set)}})()),()=>{f.cancelled=!0}},"x"),x=[t,l],e[3]=t,e[4]=l,e[5]=g,e[6]=x):(g=e[5],x=e[6]),(0,E.useEffect)(g,x);let b;e[7]!==t||e[8]!==l?(b=s(f=>{k.current.has(f)||(k.current.add(f),X((async()=>{try{let C=await t.query(Zt,{limit:1,offset:0,table:f},re(l));c(q=>({...q,[f]:C.columns}))}catch{k.current.delete(f)}})()))},"p"),e[7]=t,e[8]=l,e[9]=b):b=e[9];let u=b,y;e[10]!==p||e[11]!==o?(y={columns:p,tables:o},e[10]=p,e[11]=o,e[12]=y):y=e[12];let v=y,N;return e[13]!==u||e[14]!==v?(N={probe:u,schema:v},e[13]=u,e[14]=v,e[15]=N):N=e[15],N},"en"),ge=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,tn=s(l=>{let e=new Set;ge.lastIndex=0;let t=ge.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=ge.exec(l);return[...e]},"tn");function nn(l){return l.name}s(nn,"nn");var rn="lunora-studio-sql-tabs",ln="lunora-studio-sql-active-tab",ye=12,Q=s((l="",e="")=>({activeId:null,id:fe("tab"),name:e,sql:l}),"Q"),on=s(()=>he(ln,""),"on"),sn=s(l=>{let[e,t]=oe(rn),[n,o]=on(),a=(0,E.useRef)(null);e.length===0&&a.current===null&&(a.current=l()),(0,E.useEffect)(()=>{if(e.length===0&&a.current!==null){let p=a.current;t([p])}},[t,e.length]);let d=e.length===0&&a.current!==null?[a.current]:e;return{activeId:d.some(p=>p.id===n)?n:d[0]?.id??"",setActiveId:o,setTabs:t,tabs:d}},"sn"),Pe=s(l=>l.activeId===null&&l.sql.trim()!=="","De"),an=s((l,e)=>[...l,e].slice(-ye),"an"),cn=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};let o=l.filter(a=>a.id!==e);if(o.length===0){let a=t();return{activeId:a.id,tabs:[a]}}return{activeId:o[Math.min(n,o.length-1)].id,tabs:o}},"cn"),dn=s((l,e)=>{let t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},"dn"),un=s((l,e,t)=>{let n=l.findIndex(a=>a.id===e);if(n===-1)return{activeId:t,tabs:[...l]};let o=l.slice(0,n+1);return{activeId:o.some(a=>a.id===t)?t:e,tabs:o}},"un"),mn=s(l=>{let e=l();return{activeId:e.id,tabs:[e]}},"mn"),pn=s((l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){let n=e.findIndex(o=>o.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},"pn"),bn=s((l,e)=>l.trim()===""?e:(l.split(`
|
|
3
3
|
`)[0]??l).slice(0,24),"fn"),hn=s(l=>{let e=(0,Y.c)(14),{initial:t,onCancel:n,onCommit:o,placeholder:a,testId:d}=l,p=K(),c=gn,m;e[0]!==o?(m=s(y=>{o(y.currentTarget.value.trim())},"u"),e[0]=o,e[1]=m):m=e[1];let k=m,g;e[2]!==n||e[3]!==o?(g=s(y=>{y.key==="Enter"?o(y.currentTarget.value.trim()):y.key==="Escape"&&n()},"x"),e[2]=n,e[3]=o,e[4]=g):g=e[4];let x=g,b;e[5]!==p?(b=p("Tab title"),e[5]=p,e[6]=b):b=e[6];let u;return e[7]!==t||e[8]!==k||e[9]!==x||e[10]!==a||e[11]!==b||e[12]!==d?(u=(0,r.jsx)("input",{"aria-label":b,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":d,defaultValue:t,onBlur:k,onKeyDown:x,placeholder:a,ref:c,type:"text"}),e[7]=t,e[8]=k,e[9]=x,e[10]=a,e[11]=b,e[12]=d,e[13]=u):u=e[13],u},"bn"),fn=s(l=>{let e=(0,Y.c)(29),{idBase:t,onDiscard:n,onKeep:o}=l,a=K(),d=`sql-tab-close-prompt-${t}`,p;e[0]!==a?(p=a("Discard?"),e[0]=a,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let m;e[4]!==a?(m=a("Discard changes"),e[4]=a,e[5]=m):m=e[5];let k=`sql-tab-close-confirm-${t}`,g;e[6]!==a?(g=a("Discard changes"),e[6]=a,e[7]=g):g=e[7];let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=x):x=e[8];let b;e[9]!==n||e[10]!==m||e[11]!==k||e[12]!==g?(b=(0,r.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":k,onClick:n,title:g,type:"button",children:x}),e[9]=n,e[10]=m,e[11]=k,e[12]=g,e[13]=b):b=e[13];let u;e[14]!==a?(u=a("Keep editing"),e[14]=a,e[15]=u):u=e[15];let y=`sql-tab-close-cancel-${t}`,v;e[16]!==a?(v=a("Keep editing"),e[16]=a,e[17]=v):v=e[17];let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=N):N=e[18];let f;e[19]!==o||e[20]!==y||e[21]!==v||e[22]!==u?(f=(0,r.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":y,onClick:o,title:v,type:"button",children:N}),e[19]=o,e[20]=y,e[21]=v,e[22]=u,e[23]=f):f=e[23];let C;return e[24]!==d||e[25]!==f||e[26]!==c||e[27]!==b?(C=(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":d,role:"group",children:[c,b,f]}),e[24]=d,e[25]=f,e[26]=c,e[27]=b,e[28]=C):C=e[28],C},"hn"),xn=s(l=>{let e=(0,Y.c)(47),{active:t,canClose:n,onClose:o,onMenu:a,onRename:d,onSelect:p,tab:c}=l,m=K(),[k,g]=(0,E.useState)(!1),[x,b]=(0,E.useState)(!1),u;e[0]!==a||e[1]!==c.id?(u=s(F=>{a(c.id,F)},"d"),e[0]=a,e[1]=c.id,e[2]=u):u=e[2];let y=u,v;e[3]!==p||e[4]!==c.id?(v=s(()=>{p(c.id)},"g"),e[3]=p,e[4]=c.id,e[5]=v):v=e[5];let N=v,f;e[6]===Symbol.for("react.memo_cache_sentinel")?(f=s(()=>{g(!0)},"b"),e[6]=f):f=e[6];let C=f,q;e[7]!==o||e[8]!==c?(q=s(F=>{F.stopPropagation(),Pe(c)?b(!0):o(c.id)},"q"),e[7]=o,e[8]=c,e[9]=q):q=e[9];let L=q,S;e[10]!==o||e[11]!==c.id?(S=s(F=>{F.stopPropagation(),b(!1),o(c.id)},"S"),e[10]=o,e[11]=c.id,e[12]=S):S=e[12];let M=S,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=s(F=>{F.stopPropagation(),b(!1)},"L"),e[13]=O):O=e[13];let _=O,A;e[14]!==d||e[15]!==c.id?(A=s(F=>{d(c.id,F),g(!1)},"M"),e[14]=d,e[15]=c.id,e[16]=A):A=e[16];let W=A,$;e[17]===Symbol.for("react.memo_cache_sentinel")?($=s(()=>{g(!1)},"z"),e[17]=$):$=e[17];let P=$,H;e[18]!==c.name?(H=c.name.trim(),e[18]=c.name,e[19]=H):H=e[19];let z=H,R;e[20]!==m||e[21]!==c.sql?(R=bn(c.sql,m("Untitled")),e[20]=m,e[21]=c.sql,e[22]=R):R=e[22];let D=R,B=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",j;e[23]!==B?(j=te("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=j):j=e[24];let I=`sql-tab-${c.id}`,T;e[25]!==t||e[26]!==W||e[27]!==z||e[28]!==D||e[29]!==k||e[30]!==N||e[31]!==m||e[32]!==c.id?(T=k?(0,r.jsx)(hn,{initial:z,onCancel:P,onCommit:W,placeholder:D,testId:`sql-tab-rename-${c.id}`}):(0,r.jsx)("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:N,onDoubleClick:C,title:m("Double-click to rename"),type:"button",children:z===""?D:z}),e[25]=t,e[26]=W,e[27]=z,e[28]=D,e[29]=k,e[30]=N,e[31]=m,e[32]=c.id,e[33]=T):T=e[33];let J;e[34]!==n||e[35]!==M||e[36]!==x||e[37]!==L||e[38]!==m||e[39]!==c.id?(J=n&&(x?(0,r.jsx)(fn,{idBase:c.id,onDiscard:M,onKeep:_}):(0,r.jsx)("button",{"aria-label":m("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:L,title:m("Close tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=M,e[36]=x,e[37]=L,e[38]=m,e[39]=c.id,e[40]=J):J=e[40];let V;return e[41]!==y||e[42]!==j||e[43]!==I||e[44]!==T||e[45]!==J?(V=(0,r.jsxs)("div",{className:j,"data-testid":I,onContextMenu:y,children:[T,J]}),e[41]=y,e[42]=j,e[43]=I,e[44]=T,e[45]=J,e[46]=V):V=e[46],V},"xn");function gn(l){l?.focus(),l?.select()}s(gn,"gn");var vn=ne(le.runSql),yn="lunora-studio-sql-queries",Nn="lunora-studio-sql-history",kn="lunora-studio-sql-split-view",wn=25,qn={minWidth:"2.75rem",paddingInline:"0.5rem"},ve={error:null,pane:"results",result:null},Cn=s(l=>{let e=(0,Y.c)(16),{result:t}=l;if(t.columns.length===0){let c=t.rowCount===0?"0 rows":"",m;return e[0]!==c?(m=(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:c}),e[0]=c,e[1]=m):m=e[1],m}let n;e[2]!==t.columns?(n=t.columns.map(Sn),e[2]=t.columns,e[3]=n):n=e[3];let o;e[4]!==n?(o=(0,r.jsx)(Te,{className:"sticky top-0 z-10 bg-muted",children:(0,r.jsx)(xe,{children:n})}),e[4]=n,e[5]=o):o=e[5];let a;if(e[6]!==t.columns||e[7]!==t.rows){let c;e[9]!==t.columns?(c=s((m,k)=>(0,r.jsx)(xe,{"data-testid":"sql-row",children:t.columns.map(g=>(0,r.jsx)(Me,{className:"max-w-md truncate font-mono text-xs",children:(0,r.jsx)(_e,{value:m[g]})},g))},k),"i"),e[9]=t.columns,e[10]=c):c=e[10],a=t.rows.map(c),e[6]=t.columns,e[7]=t.rows,e[8]=a}else a=e[8];let d;e[11]!==a?(d=(0,r.jsx)(Oe,{children:a}),e[11]=a,e[12]=d):d=e[12];let p;return e[13]!==o||e[14]!==d?(p=(0,r.jsxs)(Re,{"data-testid":"sql-rows",children:[o,d]}),e[13]=o,e[14]=d,e[15]=p):p=e[15],p},"Cn"),Bn=s(({initialShardKey:l})=>{let e=be(),t=K(),[n,o]=oe(yn),[a,d]=oe(Nn),[p,c]=(0,E.useState)(""),m=s(()=>Q(Fe[0]?.sql??""),"u"),{activeId:k,setActiveId:g,setTabs:x,tabs:b}=sn(m),[u,y]=(0,E.useState)({}),[v,N]=(0,E.useState)(l??""),[f,C]=(0,E.useState)(!1),[q,L]=he(kn,!1),[S,M]=(0,E.useState)(null),[O,_]=(0,E.useState)(null),A=(0,E.useRef)(null),W=(0,E.useRef)(null),$=(0,E.useRef)(null),P=(0,E.useId)(),{probe:H,schema:z}=en(v),R=b.find(i=>i.id===k)??b[0]??Q(),D=R.sql,{activeId:B}=R,j=u[R.id]??ve,{error:I,result:T}=j,J=j.pane,V=s(i=>{x(h=>h.map(w=>w.id===R.id?{...w,...i}:w))},"G"),F=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{error:i.error,pane:i.pane??w.pane,result:i.result}}})},"F"),ke=s(i=>{y(h=>{let w=h[R.id]??ve;return{...h,[R.id]:{...w,pane:i}}})},"ve"),ie=s(i=>{V({sql:i}),B!==null&&o(h=>h.map(w=>w.id===B?{...w,sql:i}:w))},"re"),Je=Ut(z,W,ie),{close:ae,commit:we,move:ce,refresh:Z,state:G}=Je,Ue=s(i=>{ce(i-(G?.active??0)),we()},"_e");(0,E.useEffect)(()=>{let i=W.current;i!==null&&i===document.activeElement&&Z(i.value,i.selectionStart)},[Z,z]);let Ye=s(i=>{d(h=>h[0]?.sql===i?h:[{at:Date.now(),sql:i},...h.filter(w=>w.sql!==i)].slice(0,wn))},"Ae"),de=s(async i=>{if(D.trim()==="")return;C(!0);let h=i==="explain"?`EXPLAIN QUERY PLAN ${D}`:D;try{let w=await e.query(vn,{sql:h},re(v));F({error:null,pane:i,result:w}),Ie(v),Ye(h)}catch(w){F({error:Se(w),pane:i,result:null})}finally{C(!1)}},"se"),Ke=s(()=>{X(de("results"))},"ze"),Ge=s(i=>{let{selectionStart:h,value:w}=i.target;ie(w);for(let U of tn(w))H(U);Z(w,h)},"je"),Ve=s(i=>{let h=i.currentTarget;Z(h.value,h.selectionStart)},"Be"),Xe=s(i=>{if(G!==null){if(i.key==="ArrowDown"){i.preventDefault(),ce(1);return}if(i.key==="ArrowUp"){i.preventDefault(),ce(-1);return}if(i.key==="Escape"){i.preventDefault(),ae();return}if((i.key==="Enter"||i.key==="Tab")&&!i.metaKey&&!i.ctrlKey&&we()){i.preventDefault();return}}(i.metaKey||i.ctrlKey)&&i.key==="Enter"&&(i.preventDefault(),X(de(J)))},"We"),Qe=s(()=>{requestAnimationFrame(()=>{ae()})},"Fe"),Ze=s(i=>{A.current!==null&&(A.current.scrollTop=i.currentTarget.scrollTop)},"He"),ee=s((i,h)=>{x(w=>w.map(U=>U.id===R.id?{...U,activeId:h,sql:i}:U)),F({error:null,result:null})},"te"),et=s(()=>{let i={id:fe("q"),name:t("Untitled query"),sql:""};o(h=>[i,...h]),ee("",i.id)},"Pe"),tt=s(i=>{let h=n.find(w=>w.id===i);h!==void 0&&(ee(h.sql,i),$.current?.querySelector(`[data-testid="sql-query-${i}"]`)?.scrollIntoView({block:"nearest"}))},"Ue"),nt=s(i=>{o(h=>h.filter(w=>w.id!==i)),x(h=>h.map(w=>w.activeId===i?{...w,activeId:null}:w))},"Je"),rt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ke"),lt=s(i=>{ee(i.currentTarget.dataset.sql??"",null)},"Ye"),ot=s(()=>{d([])},"Ve"),st=s(()=>{ie(At(D))},"Ge"),it=s(()=>{if(b.length>=ye)return;let i=Q();x(h=>an(h,i)),g(i.id)},"Qe"),qe=s(i=>{M(null),_(null),x(i.tabs),g(i.activeId);let h=new Set(i.tabs.map(w=>w.id));y(w=>Object.fromEntries(Object.entries(w).filter(([U])=>h.has(U))))},"Ne"),at=s(i=>{qe(cn(b,i,Q))},"Xe"),Ce=s((i,h)=>{qe(i==="others"?dn(b,h):i==="right"?un(b,h,k):mn(Q))},"ke"),ue=s(i=>{S!==null&&(pn(i,b,S.id).some(h=>Pe(h))?_(i):Ce(i,S.id))},"ie"),ct=s((i,h)=>{h.preventDefault(),_(null),M({id:i,x:h.clientX,y:h.clientY})},"Ze"),dt=s(()=>{M(null),_(null)},"et"),ut=s(i=>{i.preventDefault(),M(null),_(null)},"tt"),mt=s(()=>{ue("others")},"nt"),pt=s(()=>{ue("right")},"rt"),bt=s(()=>{ue("all")},"lt"),ht=s(()=>{S!==null&&O!==null&&Ce(O,S.id),_(null)},"ot"),ft=s(()=>{_(null)},"st"),xt=S===null?void 0:{left:S.x,top:S.y},gt=s(i=>{ae(),g(i)},"at"),vt=s((i,h)=>{x(w=>w.map(U=>U.id===i?{...U,name:h}:U))},"ct"),yt=s(()=>{ke("results")},"dt"),Nt=s(()=>{X(de("explain"))},"ut"),kt=s(()=>{ke("chart")},"mt"),wt=s(()=>{L(!q)},"pt"),qt=D.split(`
|
|
4
4
|
`).length,Ct=s(i=>{c(i.target.value)},"bt"),me=s(i=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${i?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"ae"),St=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",It=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return(0,r.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[(0,r.jsx)(Xt,{activeId:B,history:a,listRef:$,onClearHistory:ot,onDelete:nt,onLoadHistory:lt,onLoadTemplate:rt,onNew:et,onSearchChange:Ct,onSelect:tt,queries:n,search:p}),(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[b.map(i=>(0,r.jsx)(xn,{active:i.id===R.id,canClose:b.length>1,onClose:at,onMenu:ct,onRename:vt,onSelect:gt,tab:i},i.id)),(0,r.jsx)("button",{"aria-label":t("New tab"),className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:b.length>=ye,onClick:it,title:t("New tab"),type:"button",children:(0,r.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),S!==null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:dt,onContextMenu:ut,role:"presentation"}),(0,r.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:xt,children:O===null?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:b.length<=1,onClick:mt,role:"menuitem",type:"button",children:t("Close other tabs")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:b.findIndex(i=>i.id===S.id)>=b.length-1,onClick:pt,role:"menuitem",type:"button",children:t("Close tabs to the right")}),(0,r.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:bt,role:"menuitem",type:"button",children:t("Close all tabs")})]}):(0,r.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,r.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:ht,type:"button",children:t("Discard")}),(0,r.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:ft,type:"button",children:t("Cancel")})]})]})})]}),(0,r.jsxs)("div",{className:St,children:[(0,r.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1",children:[(0,r.jsx)("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:A,style:qn,children:Array.from({length:qt},(i,h)=>(0,r.jsx)("div",{children:h+1},h))}),(0,r.jsxs)("div",{className:"relative min-w-0 flex-1",children:[(0,r.jsx)("textarea",{"aria-activedescendant":G===null?void 0:`${P}-opt-${G.active.toString()}`,"aria-autocomplete":"list","aria-controls":G===null?void 0:P,"aria-expanded":G!==null,"aria-label":t("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Qe,onChange:Ge,onKeyDown:Xe,onScroll:Ze,onSelect:Ve,placeholder:"SELECT * FROM \u2026",ref:W,role:"combobox",spellCheck:!1,value:D}),(0,r.jsx)(Gt,{listboxId:P,onPick:Ue,state:G})]})]}),(0,r.jsxs)("div",{className:It,children:[(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[(0,r.jsx)("button",{className:me(J==="results"),"data-testid":"sql-tab-results",onClick:yt,type:"button",children:t("Results")}),(0,r.jsx)("button",{className:me(J==="chart"),"data-testid":"sql-tab-chart",onClick:kt,type:"button",children:t("Chart")}),(0,r.jsx)("button",{className:me(J==="explain"),"data-testid":"sql-tab-explain",onClick:Nt,type:"button",children:t("Explain")}),(0,r.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[(0,r.jsx)("button",{"aria-label":t("Split editor and results"),"aria-pressed":q,className:`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${q?"bg-accent text-foreground":"text-muted-foreground"}`,"data-testid":"sql-split-toggle",onClick:wt,title:t("Split editor and results"),type:"button",children:(0,r.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,r.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,r.jsx)("path",{d:"M12 4v16"})]})}),T!==null&&T.columns.length>0&&(0,r.jsx)(Ae,{columns:T.columns,name:"query-result",rows:T.rows}),(0,r.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:f,onClick:st,type:"button",children:t("Format")}),(0,r.jsx)(Ee,{onChange:N,testId:"sql-shard-input",value:v}),(0,r.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:f,onClick:Ke,type:"button",children:[t(f?"Running\u2026":"Run"),(0,r.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"})]})]})]}),(0,r.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[I!==null&&(0,r.jsx)(Le,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:I}),I===null&&T===null&&(0,r.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")}),I===null&&T!==null&&(0,r.jsxs)("div",{"data-testid":"sql-result",children:[J==="chart"?(0,r.jsx)(ze,{result:T}):(0,r.jsx)(Cn,{result:T}),(0,r.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:T.truncated?t("Showing the first {max} of {count} rows.",{count:T.rowCount,max:T.rows.length}):t("{count} rows",{count:T.rowCount})})]})]})]})]})]})]})},"Hn");function Sn(l){return(0,r.jsx)(De,{children:l},l)}s(Sn,"Sn");export{Bn as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as R}from"./chunk-H7NIIBHH.js";import"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as h}from"./chunk-
|
|
1
|
+
import{b as R}from"./chunk-H7NIIBHH.js";import"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as h}from"./chunk-XSD4Y6SQ.js";import"./chunk-MIQTKZAR.js";import"./chunk-UZERI5YC.js";import{a as p}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{d as g}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as s,e as m,g as S,h as _}from"./chunk-3XIESWL4.js";var f=m(S(),1);var k=m(_(),1);var A=s((e,t)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[t.kind],"R"),w=s(e=>Array.isArray(e.findings)?e.findings:[],"k"),E=s(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),T=s((e,t)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:t.detail?.length,min:t.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:t.detail?.length,min:t.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[t.kind],"A"),O=s(()=>{let e=(0,f.c)(8),t=g(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];let{data:a,error:d,errorSource:c}=h(p.getSecurityAudit,r),n;if(e[1]!==a||e[2]!==t){let u=a===void 0?null:w(a);n=u===null?null:u.map(i=>({description:T(t,i),entity:E(i),issueType:A(t,i),key:i.kind,level:i.level})),e[1]=a,e[2]=t,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(R,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"N");export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as O}from"./chunk-X2FQ6B5V.js";import{a as q,b as B}from"./chunk-AVAC26HJ.js";import{a as z}from"./chunk-LFKCLLPT.js";import{a as A}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as R}from"./chunk-
|
|
1
|
+
import{a as O}from"./chunk-X2FQ6B5V.js";import{a as q,b as B}from"./chunk-AVAC26HJ.js";import{a as z}from"./chunk-LFKCLLPT.js";import{a as A}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as R}from"./chunk-XSD4Y6SQ.js";import{a as K,b as T,c as F,d as p,e as l,f as d}from"./chunk-MIQTKZAR.js";import{a as I,e as E}from"./chunk-UZERI5YC.js";import{a as j}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as C}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as V}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as k}from"./chunk-XQCVZAGU.js";import{d as L,q as M}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as o,e as b,f as ee,h as te}from"./chunk-3XIESWL4.js";var i=b(ee(),1);var e=b(te(),1);var D=80,re=o(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>D?`${t.slice(0,D)}\u2026`:t},"te"),ae=41,J=480,H=5,ie=o((s,t)=>q(s,n=>{t(n.height>0?n:{height:J,width:n.width})}),"ae"),Ne=o(({initialShardKey:s})=>{let t=L(),[n,P]=(0,i.useState)(s??""),[c,U]=(0,i.useState)(""),W=z(n.trim(),400),{data:f,error:g,errorSource:Z,isLoading:_,liveError:$}=R(V.getAuditLog,{},{live:!0,shardKey:W}),h=(0,i.useMemo)(()=>f?.entries??[],[f]),m=(0,i.useMemo)(()=>{let a=c.trim().toLowerCase();return a===""?h:h.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[h,c]),x=(0,i.useRef)(null),v=B({count:m.length,estimateSize:o(()=>ae,"estimateSize"),getScrollElement:o(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),G=v.getTotalSize(),N=u[0]?.start??0,w=G-(u.at(-1)?.end??0),Q={height:N},X={height:w},Y=o(a=>{U(a.target.value)},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(j,{onChange:P,testId:"au-shard-input",value:n}),(0,e.jsx)(O,{message:$,prefix:"au"}),(0,e.jsx)(C,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:c})]}),g!==null&&(0,e.jsx)(A,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(k,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(K,{"data-testid":"au-table",children:[(0,e.jsx)(T,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(l,{children:t("time")}),(0,e.jsx)(l,{children:t("op")}),(0,e.jsx)(l,{children:t("table")}),(0,e.jsx)(l,{children:t("id")}),(0,e.jsx)(l,{children:t("detail")})]})}),(0,e.jsxs)(F,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Q})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:M(r.ts,"\u2014")}),(0,e.jsx)(d,{children:(0,e.jsx)(y,{variant:"secondary",children:r.op})}),(0,e.jsx)(d,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(d,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})})]})]})})})]})},"we");export{Ne as AuditPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as D,c as f,d as E,f as I}from"./chunk-
|
|
1
|
+
import{b as D,c as f,d as E,f as I}from"./chunk-35II7U25.js";import{f as p,g as y,h as P,m as b}from"./chunk-4CGALXS3.js";import{a as s,e as T,f as Q,g as S}from"./chunk-3XIESWL4.js";var g=T(S(),1);var d=T(Q(),1);var h=s((e,r,o)=>["lunora-admin",e,r,o.trim()],"y");function L(e,r,o={}){let{enabled:t=!0,keepPreviousData:n=!1,staleTime:i=0}=o,a=E({enabled:t,queryFn:r,placeholderData:n?D:void 0,queryKey:e,staleTime:i});return{data:a.data,error:a.error?P(a.error):a.error,errorSource:a.error??void 0,isLoading:a.isLoading,liveError:void 0,refetch:s(()=>{b(a.refetch())},"refetch")}}s(L,"N");function O(e,r,o={}){let t=I(),n=f(),{enabled:i=!0,keepPreviousData:a=!1,live:u=!1,shardKey:l="",staleTime:k}=o,m=h(e,r,l),q=L(m,()=>t.query(p(e),r,y(l)),{enabled:i,keepPreviousData:a,staleTime:k??(u?Number.POSITIVE_INFINITY:0)}),[K,v]=(0,d.useState)(void 0),N=JSON.stringify(m);return(0,d.useEffect)(()=>{if(!(!i||!u))return v(void 0),t.subscribe(p(e),r,c=>{v(void 0),n.setQueryData(m,c)},{...y(l),onError:s(c=>{v(c.message)},"onError")})},[N,i,u]),{...q,liveError:i&&u?K:void 0}}s(O,"_");var C=s(()=>{let e=(0,g.c)(2),r=f(),o;return e[0]!==r?(o=s((t,n,i)=>{let a=n===void 0?["lunora-admin",t]:h(t,n,i??"");b(r.invalidateQueries({queryKey:a}))},"a"),e[0]=r,e[1]=o):o=e[1],o},"x");export{L as a,O as b,C as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as z}from"./chunk-54MMVNPT.js";import{a as B}from"./chunk-LFKCLLPT.js";import{a as H}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as E}from"./chunk-
|
|
1
|
+
import{a as z}from"./chunk-54MMVNPT.js";import{a as B}from"./chunk-LFKCLLPT.js";import{a as H}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as E}from"./chunk-XSD4Y6SQ.js";import{a as O,b as U,c as q,d as j,e as T,f as D}from"./chunk-MIQTKZAR.js";import{a as K}from"./chunk-UZERI5YC.js";import{a as W}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as M}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as A}from"./chunk-XQCVZAGU.js";import{d as _}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as S,e as F,f as X,g as Y,h as Q}from"./chunk-3XIESWL4.js";var P=F(Y(),1),V=F(X(),1);var t=F(Q(),1);var G=S(n=>`${n.toString()} ms`,"E"),Z=S(n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,"G"),w=S(n=>{let e=(0,P.c)(8),{label:r,testId:a,value:l}=n,o;e[0]!==r?(o=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=o):o=e[1];let i;e[2]!==a||e[3]!==l?(i=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":a,children:l}),e[2]=a,e[3]=l,e[4]=i):i=e[4];let h;return e[5]!==o||e[6]!==i?(h=(0,t.jsx)(K,{className:"gap-0 py-0",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[o,i]})}),e[5]=o,e[6]=i,e[7]=h):h=e[7],h},"R"),J=S(n=>{let e=(0,P.c)(48),{counters:r,includeTiming:a,prefix:l,t:o,title:i}=n,h=`${l}-section`,x;e[0]!==i?(x=(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:i}),e[0]=i,e[1]=x):x=e[1];let b=`${l}-stats`,s;e[2]!==o?(s=o("Passes"),e[2]=o,e[3]=s):s=e[3];let c=`${l}-passes`,k;e[4]!==r.passes||e[5]!==s||e[6]!==c?(k=(0,t.jsx)(w,{label:s,testId:c,value:r.passes}),e[4]=r.passes,e[5]=s,e[6]=c,e[7]=k):k=e[7];let N;e[8]!==o?(N=o("Sockets iterated"),e[8]=o,e[9]=N):N=e[9];let I=`${l}-iterated`,d;e[10]!==r.socketsIterated||e[11]!==N||e[12]!==I?(d=(0,t.jsx)(w,{label:N,testId:I,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=N,e[12]=I,e[13]=d):d=e[13];let m;e[14]!==o?(m=o("Delivered"),e[14]=o,e[15]=m):m=e[15];let v=`${l}-delivered`,u;e[16]!==r.socketsDelivered||e[17]!==m||e[18]!==v?(u=(0,t.jsx)(w,{label:m,testId:v,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=m,e[18]=v,e[19]=u):u=e[19];let p;e[20]!==o?(p=o("Peak width"),e[20]=o,e[21]=p):p=e[21];let y=`${l}-peak`,f;e[22]!==r.peakSocketsIterated||e[23]!==p||e[24]!==y?(f=(0,t.jsx)(w,{label:p,testId:y,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=p,e[24]=y,e[25]=f):f=e[25];let g;e[26]!==r.totalMs||e[27]!==a||e[28]!==l||e[29]!==o?(g=a&&(0,t.jsx)(w,{label:o("Total time"),testId:`${l}-total-ms`,value:G(r.totalMs)}),e[26]=r.totalMs,e[27]=a,e[28]=l,e[29]=o,e[30]=g):g=e[30];let C;e[31]!==r.maxMs||e[32]!==a||e[33]!==l||e[34]!==o?(C=a&&(0,t.jsx)(w,{label:o("Max time"),testId:`${l}-max-ms`,value:G(r.maxMs)}),e[31]=r.maxMs,e[32]=a,e[33]=l,e[34]=o,e[35]=C):C=e[35];let $;e[36]!==u||e[37]!==f||e[38]!==g||e[39]!==C||e[40]!==b||e[41]!==k||e[42]!==d?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":b,children:[k,d,u,f,g,C]}),e[36]=u,e[37]=f,e[38]=g,e[39]=C,e[40]=b,e[41]=k,e[42]=d,e[43]=$):$=e[43];let R;return e[44]!==h||e[45]!==$||e[46]!==x?(R=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":h,children:[x,$]}),e[44]=h,e[45]=$,e[46]=x,e[47]=R):R=e[47],R},"F"),ue=S(n=>{let e=(0,P.c)(32),{initialShardKey:r}=n,a=_(),[l,o]=(0,V.useState)(r??""),i;e[0]!==l?(i=l.trim(),e[0]=l,e[1]=i):i=e[1];let h=B(i,400),x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x={},e[2]=x):x=e[2];let b;e[3]!==h?(b={keepPreviousData:!0,shardKey:h},e[3]=h,e[4]=b):b=e[4];let{data:s,error:c,errorSource:k,refetch:N}=E(L.getFanoutMetrics,x,b);z(N,!0);let I;e[5]!==s?(I=s!==void 0&&Z(s),e[5]=s,e[6]=I):I=e[6];let d=I,m;e[7]!==l?(m=(0,t.jsx)(W,{onChange:o,testId:"fanout-shard-input",value:l}),e[7]=l,e[8]=m):m=e[8];let v;e[9]!==s||e[10]!==a?(v=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[s.promoted&&(0,t.jsx)(M,{"data-testid":"fanout-promoted",variant:s.relayCount>=s.maxRelays?"destructive":"default",children:s.relayCount>=s.maxRelays?a("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:s.maxRelays,relayCount:s.relayCount}):a("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:s.maxRelays,relayCount:s.relayCount})}),(0,t.jsx)(M,{variant:"secondary",children:a("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(M,{variant:"secondary",children:a("peak {count} subscribers",{count:s.peakSubscribers})})]}),e[9]=s,e[10]=a,e[11]=v):v=e[11];let u;e[12]!==m||e[13]!==v?(u=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[m,v]}),e[12]=m,e[13]=v,e[14]=u):u=e[14];let p;e[15]!==c||e[16]!==k?(p=c!==null&&(0,t.jsx)(H,{error:k,testId:"fanout-error"}),e[15]=c,e[16]=k,e[17]=p):p=e[17];let y;e[18]!==c||e[19]!==d||e[20]!==a?(y=c===null&&d&&(0,t.jsx)(A,{description:a("Realtime fan-out cost and per-topic subscriber counts for this shard."),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:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:a("No fan-out activity yet.")}),e[18]=c,e[19]=d,e[20]=a,e[21]=y):y=e[21];let f;e[22]!==c||e[23]!==d||e[24]!==s||e[25]!==a?(f=c===null&&s!==void 0&&!d&&(0,t.jsxs)(t.Fragment,{children:[s.topics.length>0&&(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[(0,t.jsx)("h3",{className:"text-sm font-medium text-foreground",children:a("Hot topics")}),(0,t.jsx)(K,{className:"overflow-hidden py-0",children:(0,t.jsxs)(O,{"data-testid":"fanout-topics-table",children:[(0,t.jsx)(U,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(T,{children:a("Topic")}),(0,t.jsx)(T,{children:a("Kind")}),(0,t.jsx)(T,{className:"text-right",children:a("Subscribers")})]})}),(0,t.jsx)(q,{children:s.topics.map(ee)})]})})]}),(0,t.jsxs)("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[(0,t.jsx)("h2",{className:"text-sm font-medium text-muted-foreground",children:a("Fan-out cost since this instance woke")}),(0,t.jsx)(J,{counters:s.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:a,title:a("Shape pokes")}),(0,t.jsx)(J,{counters:s.whisper,includeTiming:!1,prefix:"fanout-whisper",t:a,title:a("Whisper broadcasts")})]})]}),e[22]=c,e[23]=d,e[24]=s,e[25]=a,e[26]=f):f=e[26];let g;return e[27]!==f||e[28]!==u||e[29]!==p||e[30]!==y?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[u,p,y,f]}),e[27]=f,e[28]=u,e[29]=p,e[30]=y,e[31]=g):g=e[31],g},"ue");function ee(n){return(0,t.jsxs)(j,{"data-testid":"fanout-topic-row",children:[(0,t.jsx)(D,{className:"font-mono text-xs",children:n.topic}),(0,t.jsx)(D,{children:(0,t.jsx)(M,{variant:"outline",children:n.kind})}),(0,t.jsx)(D,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}S(ee,"J");export{ue as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Oe,b as Ke}from"./chunk-VSS7NFZJ.js";import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-54MMVNPT.js";import"./chunk-IVFHIQOT.js";import{a as He}from"./chunk-LFKCLLPT.js";import{a as Ge}from"./chunk-OWADN6BI.js";import{a as Ue,b as _e,c as $e,d as M,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{a as D}from"./chunk-5Y3QLNWX.js";import"./chunk-QBWRC5YX.js";import{R as T}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as B}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as E}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{d as W,h as Pe,l as Ae,m as ze,q as Ie}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as r,e as Me,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Me(Ye(),1);var Z=Me(et(),1);var t=Me(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Oe(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Oe(),{busy:i,error:n,run:m}=Ke(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let q=F,R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=r(p=>{I(p.target.value)},"_"),e[3]=R):R=e[3];let Te=R,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Be=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,$)=>{d(V=>({...V,[p]:$}))},"G"),e[5]=H):H=e[5];let Re=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r($=>!$.required||lt($,j($)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let $ of o.userFields){let V=rt($,j($));V!==void 0&&(p[$.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,P;e[31]!==a?(P=a("Create user"),e[31]=a,e[32]=P):P=e[32];let L;e[33]!==a?(L=a("Create user"),e[33]=a,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:L}),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:q,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:Te,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Be,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.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")}),o.userFields.map(p=>{let $=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let Le=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:$,children:[(0,t.jsx)(Qe,{checked:Le,"data-testid":$,id:$,onCheckedChange:r(Xe=>{Re(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:$,children:[p.name,V]}),(0,t.jsx)(T,{"data-testid":$,id:$,onChange:r(Le=>{Re(p.name,Le.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let qe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==qe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:qe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=qe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==P||e[96]!==O||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:P,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=P,e[96]=O,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Pe(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>(0,t.jsxs)(M,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Pe(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(M,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)($e,{children:m.map(F=>{let q=Ae(F.id);return(0,t.jsxs)(M,{"data-testid":`ud-passkey-${q}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||q}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${q}`,disabled:l,onClick:r(()=>{h(q)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},q)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,q]=(0,k.useState)(!1),R=r((N,P)=>{ze((async()=>{w(!0),n(null);try{let L=await N();P?.refresh!==!1&&(b(O=>O+1),e()),P?.onResult?.(L)}catch(L){n(Pe(L))}finally{w(!1)}})())},"_"),Te=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Be=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),Re=r(()=>{let N=C.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),P=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:P,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{R(async()=>{await c.unbanAuthUser({userId:s.id})})},"R"),K=r(()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{R(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{R(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{R(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{q(!0)},"W"),Se=r(()=>{q(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{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:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(B,{variant:"secondary",children:s.role}),o?(0,t.jsx)(B,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(B,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(B,{variant:"secondary",children:a("verified")}):(0,t.jsx)(B,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{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)(Ce,{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)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:Te,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:Re,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,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)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(T,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Be,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,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)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:R,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:R,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:R,userId:s.id,version:S}),(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:Y.map(([N,P])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,P)})]},N))})]})]})},"ut"),pt=50,_t=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=He(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");Je(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(T,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{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.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)($e,{children:h.map(d=>(0,t.jsxs)(M,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(B,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(B,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(B,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(B,{variant:"success",children:l("yes")}):(0,t.jsx)(B,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"Pt");export{_t as UsersPanel};
|
|
1
|
+
import{a as Oe,b as Ke}from"./chunk-3QRTYSSX.js";import{a as Qe}from"./chunk-JN2Y24PY.js";import{a as Ve}from"./chunk-ESVP44Y3.js";import{a as Je}from"./chunk-54MMVNPT.js";import"./chunk-IVFHIQOT.js";import{a as He}from"./chunk-LFKCLLPT.js";import{a as Ge}from"./chunk-XSD4Y6SQ.js";import{a as Ue,b as _e,c as $e,d as M,e as U,f as _}from"./chunk-MIQTKZAR.js";import{a as we,e as Ce}from"./chunk-UZERI5YC.js";import{a as D}from"./chunk-5Y3QLNWX.js";import"./chunk-QBWRC5YX.js";import{R as T}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as z}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as B}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{f as E}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as Ze}from"./chunk-XQCVZAGU.js";import{d as W,h as Pe,l as Ae,m as ze,q as Ie}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as r,e as Me,f as Ye,g as et,h as tt}from"./chunk-3XIESWL4.js";var k=Me(Ye(),1);var Z=Me(et(),1);var t=Me(tt(),1);var at=r(()=>{let u=(0,Z.c)(3),{config:e,ready:l}=Oe(),s;return u[0]!==e.capabilities||u[1]!==l?(s={capabilities:e.capabilities,ready:l},u[0]=e.capabilities,u[1]=l,u[2]=s):s=u[2],s},"et"),st={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},lt=r((u,e)=>u.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:u.type!=="number"||!Number.isNaN(Number(e.trim())),"at"),rt=r((u,e)=>{if(u.type==="boolean")return e===!0?{value:!0}:u.required?{value:!1}:void 0;let l=typeof e=="string"?e.trim():"";if(l!==""){if(u.type==="number"){let s=Number(l);return Number.isNaN(s)?void 0:{value:s}}return{value:l}}},"lt"),it=r(u=>{let e=(0,Z.c)(105),{onClose:l,onCreated:s}=u,c=E(),a=W(),{config:o}=Oe(),{busy:i,error:n,run:m}=Ke(),[w,S]=(0,k.useState)(""),[b,C]=(0,k.useState)(""),[y,I]=(0,k.useState)(""),[h,g]=(0,k.useState)(""),v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let[f,d]=(0,k.useState)(v),A;e[1]===Symbol.for("react.memo_cache_sentinel")?(A=r(p=>{S(p.target.value)},"C"),e[1]=A):A=e[1];let x=A,F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F=r(p=>{C(p.target.value)},"F"),e[2]=F):F=e[2];let q=F,R;e[3]===Symbol.for("react.memo_cache_sentinel")?(R=r(p=>{I(p.target.value)},"_"),e[3]=R):R=e[3];let Te=R,G;e[4]===Symbol.for("react.memo_cache_sentinel")?(G=r(p=>{g(p.target.value)},"O"),e[4]=G):G=e[4];let Be=G,H;e[5]===Symbol.for("react.memo_cache_sentinel")?(H=r((p,$)=>{d(V=>({...V,[p]:$}))},"G"),e[5]=H):H=e[5];let Re=H,J;e[6]!==f?(J=r(p=>f[p.name]??(p.type==="boolean"?!1:""),"H"),e[6]=f,e[7]=J):J=e[7];let j=J,K;if(e[8]!==o.userFields||e[9]!==j){let p;e[11]!==j?(p=r($=>!$.required||lt($,j($)),"p"),e[11]=j,e[12]=p):p=e[12],K=o.userFields.every(p),e[8]=o.userFields,e[9]=j,e[10]=K}else K=e[10];let Fe=K,Q;e[13]!==i||e[14]!==w||e[15]!==b||e[16]!==Fe?(Q=!i&&w.trim()!==""&&b.trim()!==""&&Fe,e[13]=i,e[14]=w,e[15]=b,e[16]=Fe,e[17]=Q):Q=e[17];let De=Q,X;e[18]!==o.userFields||e[19]!==j?(X=r(()=>{let p={};for(let $ of o.userFields){let V=rt($,j($));V!==void 0&&(p[$.name]=V.value)}return Object.keys(p).length===0?void 0:p},"W"),e[18]=o.userFields,e[19]=j,e[20]=X):X=e[20];let Se=X,Y;e[21]!==Se||e[22]!==c||e[23]!==w||e[24]!==b||e[25]!==l||e[26]!==s||e[27]!==y||e[28]!==h||e[29]!==m?(Y=r(()=>{m(async()=>{await c.createAuthUser({data:Se(),email:w.trim(),name:b.trim(),password:y===""?void 0:y,role:h.trim()===""?void 0:h.trim()}),s(),l()})},"Z"),e[21]=Se,e[22]=c,e[23]=w,e[24]=b,e[25]=l,e[26]=s,e[27]=y,e[28]=h,e[29]=m,e[30]=Y):Y=e[30];let N=Y,P;e[31]!==a?(P=a("Create user"),e[31]=a,e[32]=P):P=e[32];let L;e[33]!==a?(L=a("Create user"),e[33]=a,e[34]=L):L=e[34];let O;e[35]!==L?(O=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:L}),e[35]=L,e[36]=O):O=e[36];let ee;e[37]!==a?(ee=a("email"),e[37]=a,e[38]=ee):ee=e[38];let te;e[39]!==ee?(te=(0,t.jsx)(D,{htmlFor:"uc-email",children:ee}),e[39]=ee,e[40]=te):te=e[40];let ae;e[41]!==w?(ae=(0,t.jsx)(T,{"data-testid":"uc-email",id:"uc-email",onChange:x,type:"email",value:w}),e[41]=w,e[42]=ae):ae=e[42];let se;e[43]!==te||e[44]!==ae?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[te,ae]}),e[43]=te,e[44]=ae,e[45]=se):se=e[45];let le;e[46]!==a?(le=a("name"),e[46]=a,e[47]=le):le=e[47];let re;e[48]!==le?(re=(0,t.jsx)(D,{htmlFor:"uc-name",children:le}),e[48]=le,e[49]=re):re=e[49];let ie;e[50]!==b?(ie=(0,t.jsx)(T,{"data-testid":"uc-name",id:"uc-name",onChange:q,value:b}),e[50]=b,e[51]=ie):ie=e[51];let ne;e[52]!==re||e[53]!==ie?(ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[re,ie]}),e[52]=re,e[53]=ie,e[54]=ne):ne=e[54];let de;e[55]!==a?(de=a("Password (optional)"),e[55]=a,e[56]=de):de=e[56];let oe;e[57]!==de?(oe=(0,t.jsx)(D,{htmlFor:"uc-password",children:de}),e[57]=de,e[58]=oe):oe=e[58];let ce;e[59]!==y?(ce=(0,t.jsx)(T,{"data-testid":"uc-password",id:"uc-password",onChange:Te,type:"password",value:y}),e[59]=y,e[60]=ce):ce=e[60];let ue;e[61]!==oe||e[62]!==ce?(ue=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[oe,ce]}),e[61]=oe,e[62]=ce,e[63]=ue):ue=e[63];let me;e[64]!==a?(me=a("Role (optional)"),e[64]=a,e[65]=me):me=e[65];let he;e[66]!==me?(he=(0,t.jsx)(D,{htmlFor:"uc-role",children:me}),e[66]=me,e[67]=he):he=e[67];let pe;e[68]!==h?(pe=(0,t.jsx)(T,{"data-testid":"uc-role",id:"uc-role",onChange:Be,value:h}),e[68]=h,e[69]=pe):pe=e[69];let fe;e[70]!==he||e[71]!==pe?(fe=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[he,pe]}),e[70]=he,e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o.userFields||e[74]!==j||e[75]!==a?(ve=o.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")}),o.userFields.map(p=>{let $=`uc-field-${p.name}`,V=p.required?"":` (${a("optional")})`;if(p.type==="boolean"){let Le=j(p)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:$,children:[(0,t.jsx)(Qe,{checked:Le,"data-testid":$,id:$,onCheckedChange:r(Xe=>{Re(p.name,Xe)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[p.name,V]})]},p.name)}let We=j(p);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(D,{htmlFor:$,children:[p.name,V]}),(0,t.jsx)(T,{"data-testid":$,id:$,onChange:r(Le=>{Re(p.name,Le.target.value)},"onChange"),type:st[p.type],value:typeof We=="string"?We:""})]},p.name)})]}),e[73]=o.userFields,e[74]=j,e[75]=a,e[76]=ve):ve=e[76];let xe;e[77]!==n?(xe=n!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:n}),e[77]=n,e[78]=xe):xe=e[78];let be;e[79]!==a?(be=a("Cancel"),e[79]=a,e[80]=be):be=e[80];let ye;e[81]!==l||e[82]!==be?(ye=(0,t.jsx)(z,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:be}),e[81]=l,e[82]=be,e[83]=ye):ye=e[83];let qe=!De,ge;e[84]!==i||e[85]!==a?(ge=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ge):ge=e[86];let Ne;e[87]!==N||e[88]!==qe||e[89]!==ge?(Ne=(0,t.jsx)(z,{"data-testid":"uc-submit",disabled:qe,onClick:N,size:"sm",type:"button",children:ge}),e[87]=N,e[88]=qe,e[89]=ge,e[90]=Ne):Ne=e[90];let ke;e[91]!==ye||e[92]!==Ne?(ke=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[ye,Ne]}),e[91]=ye,e[92]=Ne,e[93]=ke):ke=e[93];let je;return e[94]!==l||e[95]!==P||e[96]!==O||e[97]!==se||e[98]!==ne||e[99]!==ue||e[100]!==fe||e[101]!==ve||e[102]!==xe||e[103]!==ke?(je=(0,t.jsxs)(Ve,{label:P,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[O,se,ne,ue,fe,ve,xe,ke]}),e[94]=l,e[95]=P,e[96]=O,e[97]=se,e[98]=ne,e[99]=ue,e[100]=fe,e[101]=ve,e[102]=xe,e[103]=ke,e[104]=je):je=e[104],je},"st"),Ee=r(u=>{let e=(0,Z.c)(2),{children:l}=u,s;return e[0]!==l?(s=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=s):s=e[1],s},"Le"),nt=r(u=>{let e=(0,Z.c)(29),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{let x=await o.listAuthSessions({limit:50,userId:c});m(x.rows)}catch(x){let F=x;m(null),S(Pe(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s?(y=r(x=>{s(()=>o.revokeAuthSession({sessionId:x}))},"y"),e[7]=o,e[8]=s,e[9]=y):y=e[9];let I=y,h;e[10]!==i?(h=i("Sessions"),e[10]=i,e[11]=h):h=e[11];let g;e[12]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[12]=h,e[13]=g):g=e[13];let v;e[14]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:w}),e[14]=w,e[15]=v):v=e[15];let f;e[16]!==n||e[17]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=n,e[17]=i,e[18]=f):f=e[18];let d;e[19]!==l||e[20]!==I||e[21]!==n||e[22]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:i("expires")}),(0,t.jsx)(U,{children:i("ip")}),(0,t.jsx)(U,{children:i("user agent")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>(0,t.jsxs)(M,{"data-testid":`ud-session-${x.id}`,children:[(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.expiresAt)}),(0,t.jsx)(_,{children:x.ipAddress??""}),(0,t.jsx)(_,{className:"max-w-40 truncate",children:x.userAgent??""}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-revoke-${x.id}`,disabled:l,onClick:r(()=>{I(x.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},x.id))})]})})}),e[19]=l,e[20]=I,e[21]=n,e[22]=i,e[23]=d):d=e[23];let A;return e[24]!==g||e[25]!==v||e[26]!==f||e[27]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[g,v,f,d]}),e[24]=g,e[25]=v,e[26]=f,e[27]=d,e[28]=A):A=e[28],A},"rt"),dt=r(u=>{let e=(0,Z.c)(30),{busy:l,runAction:s,userId:c,version:a}=u,o=E(),i=W(),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(null),b;e[0]!==o||e[1]!==c?(b=r(()=>{ze((async()=>{S(null);try{m(await o.listAuthAccounts({userId:c}))}catch(x){let F=x;m(null),S(Pe(F))}})())},"x"),e[0]=o,e[1]=c,e[2]=b):b=e[2];let C;e[3]!==o||e[4]!==c||e[5]!==a?(C=[o,c,a],e[3]=o,e[4]=c,e[5]=a,e[6]=C):C=e[6],(0,k.useEffect)(b,C);let y;e[7]!==o||e[8]!==s||e[9]!==c?(y=r(x=>{s(()=>o.unlinkAuthAccount({accountId:x,userId:c}))},"y"),e[7]=o,e[8]=s,e[9]=c,e[10]=y):y=e[10];let I=y,h;e[11]!==i?(h=i("Linked accounts"),e[11]=i,e[12]=h):h=e[12];let g;e[13]!==h?(g=(0,t.jsx)(Ee,{children:h}),e[13]=h,e[14]=g):g=e[14];let v;e[15]!==w?(v=w!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:w}),e[15]=w,e[16]=v):v=e[16];let f;e[17]!==n||e[18]!==i?(f=n!==null&&n.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=n,e[18]=i,e[19]=f):f=e[19];let d;e[20]!==n||e[21]!==l||e[22]!==I||e[23]!==i?(d=n!==null&&n.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:i("provider")}),(0,t.jsx)(U,{children:i("created")}),(0,t.jsx)(U,{"aria-label":i("Actions")})]})}),(0,t.jsx)($e,{children:n.map(x=>{let F=Ae(x.id);return(0,t.jsxs)(M,{"data-testid":`ud-account-${F}`,children:[(0,t.jsx)(_,{children:Ae(x.providerId)}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(x.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-unlink-${F}`,disabled:l,onClick:r(()=>{I(F)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},F)})})]})})}),e[20]=n,e[21]=l,e[22]=I,e[23]=i,e[24]=d):d=e[24];let A;return e[25]!==g||e[26]!==v||e[27]!==f||e[28]!==d?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[g,v,f,d]}),e[25]=g,e[26]=v,e[27]=f,e[28]=d,e[29]=A):A=e[29],A},"it"),ot=r(u=>{let e=(0,Z.c)(40),{busy:l,capabilities:s,runAction:c,userId:a,version:o}=u,i=E(),n=W(),[m,w]=(0,k.useState)(null),S;e[0]!==s.passkey||e[1]!==i||e[2]!==a?(S=r(()=>{s.passkey&&ze((async()=>{try{w(await i.listAuthPasskeys({userId:a}))}catch{w(null)}})())},"I"),e[0]=s.passkey,e[1]=i,e[2]=a,e[3]=S):S=e[3];let b;e[4]!==s.passkey||e[5]!==i||e[6]!==a||e[7]!==o?(b=[s.passkey,i,a,o],e[4]=s.passkey,e[5]=i,e[6]=a,e[7]=o,e[8]=b):b=e[8],(0,k.useEffect)(S,b);let C;e[9]!==i||e[10]!==c||e[11]!==a?(C=r(()=>{c(()=>i.disableAuthTwoFactor({userId:a}))},"w"),e[9]=i,e[10]=c,e[11]=a,e[12]=C):C=e[12];let y=C,I;e[13]!==i||e[14]!==c?(I=r(F=>{c(()=>i.deleteAuthPasskey({passkeyId:F}))},"A"),e[13]=i,e[14]=c,e[15]=I):I=e[15];let h=I,g;e[16]!==n?(g=n("Security"),e[16]=n,e[17]=g):g=e[17];let v;e[18]!==g?(v=(0,t.jsx)(Ee,{children:g}),e[18]=g,e[19]=v):v=e[19];let f;e[20]!==l||e[21]!==s.twoFactor||e[22]!==y||e[23]!==n?(f=s.twoFactor&&(0,t.jsx)(z,{"data-testid":"ud-disable-2fa",disabled:l,onClick:y,size:"sm",type:"button",variant:"outline",children:n("Disable two-factor")}),e[20]=l,e[21]=s.twoFactor,e[22]=y,e[23]=n,e[24]=f):f=e[24];let d;e[25]!==s.passkey||e[26]!==m||e[27]!==n?(d=s.passkey&&m!==null&&m.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:n("No passkeys.")}),e[25]=s.passkey,e[26]=m,e[27]=n,e[28]=d):d=e[28];let A;e[29]!==l||e[30]!==s.passkey||e[31]!==h||e[32]!==m||e[33]!==n?(A=s.passkey&&m!==null&&m.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"ud-passkeys-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:n("name")}),(0,t.jsx)(U,{children:n("created")}),(0,t.jsx)(U,{"aria-label":n("Actions")})]})}),(0,t.jsx)($e,{children:m.map(F=>{let q=Ae(F.id);return(0,t.jsxs)(M,{"data-testid":`ud-passkey-${q}`,children:[(0,t.jsx)(_,{children:Ae(F.name)||q}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(F.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`ud-delete-passkey-${q}`,disabled:l,onClick:r(()=>{h(q)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})})]},q)})})]})})}),e[29]=l,e[30]=s.passkey,e[31]=h,e[32]=m,e[33]=n,e[34]=A):A=e[34];let x;return e[35]!==v||e[36]!==f||e[37]!==d||e[38]!==A?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[v,f,d,A]}),e[35]=v,e[36]=f,e[37]=d,e[38]=A,e[39]=x):x=e[39],x},"nt"),ct=/(?:at|expires)$/iu,ut=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),mt=r((u,e)=>typeof e=="number"&&ct.test(u)?Ie(e):Ae(e),"ct"),ht=r(({capabilities:u,onChanged:e,onClose:l,user:s})=>{let c=E(),a=W(),o=s.banned===!0,[i,n]=(0,k.useState)(null),[m,w]=(0,k.useState)(!1),[S,b]=(0,k.useState)(0),[C,y]=(0,k.useState)(typeof s.role=="string"?s.role:""),[I,h]=(0,k.useState)(""),[g,v]=(0,k.useState)(""),[f,d]=(0,k.useState)(""),[A,x]=(0,k.useState)(null),[F,q]=(0,k.useState)(!1),R=r((N,P)=>{ze((async()=>{w(!0),n(null);try{let L=await N();P?.refresh!==!1&&(b(O=>O+1),e()),P?.onResult?.(L)}catch(L){n(Pe(L))}finally{w(!1)}})())},"_"),Te=r(N=>{y(N.target.value)},"De"),G=r(N=>{h(N.target.value)},"O"),Be=r(N=>{v(N.target.value)},"je"),H=r(N=>{d(N.target.value)},"G"),Re=r(()=>{let N=C.trim();N!==""&&R(async()=>{await c.setAuthUserRole({role:N,userId:s.id})})},"Se"),J=r(()=>{let N=Number.parseInt(g,10),P=Number.isFinite(N)&&N>0?N*86400:void 0;R(async()=>{await c.banAuthUser({expiresInSeconds:P,reason:I.trim()===""?void 0:I.trim(),userId:s.id})})},"H"),j=r(()=>{R(async()=>{await c.unbanAuthUser({userId:s.id})})},"R"),K=r(()=>{R(async()=>{await c.setAuthUserPassword({newPassword:f,userId:s.id}),d("")})},"J"),Fe=r(()=>{R(()=>c.impersonateAuthUser({userId:s.id}),{onResult:r(N=>{x(N.token)},"onResult"),refresh:!1})},"we"),Q=r(()=>{R(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"K"),De=r(()=>{R(async()=>{await c.removeAuthUser({userId:s.id}),l()})},"Te"),X=r(()=>{q(!0)},"W"),Se=r(()=>{q(!1)},"Ce"),Y=Object.entries(s).filter(([N])=>!ut.has(N));return(0,t.jsxs)(Ve,{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:s.name??s.email??s.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsx)(B,{variant:"secondary",children:s.role}),o?(0,t.jsx)(B,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(B,{variant:"outline",children:a("Active")}),s.emailVerified===!0?(0,t.jsx)(B,{variant:"secondary",children:a("verified")}):(0,t.jsx)(B,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(z,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),u.admin&&(0,t.jsxs)(we,{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)(Ce,{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)(D,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(T,{"data-testid":"ud-role-input",id:"ud-role",onChange:Te,value:C})]}),(0,t.jsx)(z,{"data-testid":"ud-set-role",disabled:m||C.trim()==="",onClick:Re,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),o?(0,t.jsx)(z,{"data-testid":"ud-unban",disabled:m,onClick:j,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)(D,{htmlFor:"ud-ban-reason",children:a("Ban reason (optional)")}),(0,t.jsx)(T,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:G,value:I})]}),(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsx)(D,{htmlFor:"ud-ban-days",children:a("Days")}),(0,t.jsx)(T,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:Be,type:"number",value:g})]}),(0,t.jsx)(z,{"data-testid":"ud-ban",disabled:m,onClick:J,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)(D,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(T,{"data-testid":"ud-password",id:"ud-password",onChange:H,type:"password",value:f})]}),(0,t.jsx)(z,{"data-testid":"ud-set-password",disabled:m||f==="",onClick:K,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(z,{"data-testid":"ud-impersonate",disabled:m,onClick:Fe,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(z,{"data-testid":"ud-revoke-all",disabled:m,onClick:Q,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),F?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(z,{"data-testid":"ud-delete-confirm",disabled:m,onClick:De,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(z,{"data-testid":"ud-delete-cancel",onClick:Se,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(z,{"data-testid":"ud-delete",disabled:m,onClick:X,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),A!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(D,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(T,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A})]})]})]}),(0,t.jsx)(nt,{busy:m,runAction:R,userId:s.id,version:S}),u.accounts&&(0,t.jsx)(dt,{busy:m,runAction:R,userId:s.id,version:S}),(u.twoFactor||u.passkey)&&(0,t.jsx)(ot,{busy:m,capabilities:u,runAction:R,userId:s.id,version:S}),(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:Y.map(([N,P])=>(0,t.jsxs)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsx)("dt",{className:"text-xs font-semibold text-muted-foreground",children:N}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:mt(N,P)})]},N))})]})]})},"ut"),pt=50,_t=r(({pageSize:u=pt}={})=>{let e=E(),l=W(),[s,c]=(0,k.useState)(""),[a,o]=(0,k.useState)(""),i=He(s),[n,m]=(0,k.useState)(null),[w,S]=(0,k.useState)(!1),{capabilities:b}=at(),C=i.trim(),y=a.trim(),I=Ge(["lunora-auth-users",C,y,u],()=>e.listAuthUsers({filterField:y===""?void 0:"role",filterValue:y===""?void 0:y,limit:u,search:C===""?void 0:C}),{keepPreviousData:!0}),h=I.data?.rows??null,g=I.error,v=r(()=>{I.refetch()},"v");Je(()=>{I.refetch()},!0);let f=n===null?null:h?.find(d=>d.id===n)??null;return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(T,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:r(d=>{c(d.target.value)},"onChange"),placeholder:l("Search by email or name\u2026"),value:s}),(0,t.jsx)(T,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(d=>{o(d.target.value)},"onChange"),placeholder:l("Filter by role"),value:a}),(0,t.jsx)(z,{"data-testid":"us-new",onClick:r(()=>{S(!0)},"onClick"),size:"sm",type:"button",children:l("New user")})]}),g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:g}),h!==null&&h.length===0&&(0,t.jsx)(Ze,{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.")}),h!==null&&h.length>0&&(0,t.jsx)(we,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(Ue,{"data-testid":"us-table",children:[(0,t.jsx)(_e,{children:(0,t.jsxs)(M,{children:[(0,t.jsx)(U,{children:l("id")}),(0,t.jsx)(U,{children:l("email")}),(0,t.jsx)(U,{children:l("name")}),(0,t.jsx)(U,{children:l("role")}),(0,t.jsx)(U,{children:l("status")}),(0,t.jsx)(U,{children:l("verified")}),(0,t.jsx)(U,{children:l("created")}),(0,t.jsx)(U,{"aria-label":l("Actions")})]})}),(0,t.jsx)($e,{children:h.map(d=>(0,t.jsxs)(M,{"data-testid":`us-row-${d.id}`,children:[(0,t.jsx)(_,{className:"font-mono text-xs",children:d.id}),(0,t.jsx)(_,{children:d.email??""}),(0,t.jsx)(_,{children:d.name??""}),(0,t.jsx)(_,{children:typeof d.role=="string"&&d.role!==""?(0,t.jsx)(B,{variant:"secondary",children:d.role}):""}),(0,t.jsx)(_,{children:d.banned===!0?(0,t.jsx)(B,{variant:"destructive",children:l("Banned")}):(0,t.jsx)(B,{variant:"success",children:l("Active")})}),(0,t.jsx)(_,{children:d.emailVerified===!0?(0,t.jsx)(B,{variant:"success",children:l("yes")}):(0,t.jsx)(B,{variant:"outline",children:l("no")})}),(0,t.jsx)(_,{className:"text-muted-foreground tabular-nums",children:Ie(d.createdAt)}),(0,t.jsx)(_,{children:(0,t.jsx)(z,{"data-testid":`us-manage-${d.id}`,onClick:r(()=>{m(d.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},d.id))})]})})}),f!==null&&(0,t.jsx)(ht,{capabilities:b,onChanged:v,onClose:r(()=>{m(null)},"onClose"),user:f}),w&&(0,t.jsx)(it,{onClose:r(()=>{S(!1)},"onClose"),onCreated:v})]})},"Pt");export{_t as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as B}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as q}from"./chunk-
|
|
1
|
+
import{a as B}from"./chunk-UNUU7CJJ.js";import"./chunk-XXQUMVWH.js";import{b as q}from"./chunk-XSD4Y6SQ.js";import{a as M,b as U,c as $,d as P,e as d,f as c}from"./chunk-MIQTKZAR.js";import{a as C,e as E}from"./chunk-UZERI5YC.js";import{b as T}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as z}from"./chunk-GXZAXNZI.js";import"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import{a as G}from"./chunk-XQCVZAGU.js";import{d as _}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as R,e as O,g as L,h as V}from"./chunk-3XIESWL4.js";var J=O(L(),1);var r=O(V(),1);var H=["read","insert","update","delete"],W=R((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"q"),Q=R(e=>{let s=new Map;for(let l of e){let t=s.get(l.table)??{operations:new Set,procedures:[],table:l.table};t.operations.add(l.on),t.procedures.includes(l.procedure)||t.procedures.push(l.procedure),s.set(l.table,t)}return[...s.values()].toSorted((l,t)=>l.table.localeCompare(t.table))},"B"),ie=R(()=>{let e=(0,J.c)(49),s=_(),l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let{data:t,error:S,errorSource:k}=q(z.rlsPolicies,l),p=t!==void 0,m,n,h,a,u,f,x,b,o;if(e[1]!==t||e[2]!==S||e[3]!==k||e[4]!==p||e[5]!==s){let F=Q(Array.isArray(t?.policies)?t.policies:[]),D;e[15]!==t?(D=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=D):D=e[16],n=D,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==S||e[18]!==k?(o=S!==null&&(0,r.jsx)(B,{error:k,testId:"rls-error"}),e[17]=S,e[18]=k,e[19]=o):o=e[19],f="flex flex-col gap-2",m=C,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(a=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=a):a=e[23],u=p&&F.length===0?(0,r.jsx)(G,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(E,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(U,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),H.map(i=>(0,r.jsx)(d,{children:W(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)($,{children:F.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),H.map(K=>(0,r.jsx)(c,{children:i.operations.has(K)?(0,r.jsx)(T,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},K)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:i.procedures.join(", ")})]},i.table))})]})}),e[1]=t,e[2]=S,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=a,e[10]=u,e[11]=f,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],a=e[9],u=e[10],f=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==a||e[27]!==u?(N=(0,r.jsxs)(m,{className:h,children:[a,u]}),e[24]=m,e[25]=h,e[26]=a,e[27]=u,e[28]=N):N=e[28];let g;e[29]!==f||e[30]!==N?(g=(0,r.jsx)("section",{className:f,children:N}),e[29]=f,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(G,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(E,{className:"px-0",children:(0,r.jsxs)(M,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(U,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)($,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(C,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let j;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(j=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=j):j=e[48],j},"ae");function X(e){return(0,r.jsx)(T,{variant:"outline",children:e},e)}R(X,"H");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}R(Y,"L");export{ie as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Bi,b as je,c as pi,d as Le,e as Ci,f as Ri,k as Zi}from"./chunk-
|
|
1
|
+
import{a as Bi,b as je,c as pi,d as Le,e as Ci,f as Ri,k as Zi}from"./chunk-RBU52M5T.js";import"./chunk-F6GOKFMU.js";import"./chunk-M536Y2KX.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-ILNELDFC.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import{a as Gi}from"./chunk-LFKCLLPT.js";import"./chunk-T6VMSOBB.js";import"./chunk-XSD4Y6SQ.js";import"./chunk-UZERI5YC.js";import"./chunk-HPFLBYRI.js";import"./chunk-QBWRC5YX.js";import{a as Ve}from"./chunk-7T7UOTYK.js";import{R as Yi}from"./chunk-CFPZYHPY.js";import{a as bd}from"./chunk-7QIFDWQV.js";import{c as Qi}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-GXZAXNZI.js";import{a as _i,e as Hi}from"./chunk-35II7U25.js";import"./chunk-XBDKZZ67.js";import"./chunk-XQCVZAGU.js";import{a as qi,d as xe,n as Xi}from"./chunk-4CGALXS3.js";import{b as Ui}from"./chunk-LE56LPNH.js";import{a as c,c as vn,e as cu,f as Di,g as sd,h as Ni,j as Ze}from"./chunk-3XIESWL4.js";var $i=vn(w=>{"use strict";function we(l,t){var a=l.length;l.push(t);l:for(;0<a;){var u=a-1>>>1,n=l[u];if(0<dn(n,t))l[u]=t,l[a]=n,a=u;else break l}}c(we,"push");function wl(l){return l.length===0?null:l[0]}c(wl,"peek");function hn(l){if(l.length===0)return null;var t=l[0],a=l.pop();if(a!==t){l[0]=a;l:for(var u=0,n=l.length,e=n>>>1;u<e;){var f=2*(u+1)-1,i=l[f],m=f+1,y=l[m];if(0>dn(i,a))m<n&&0>dn(y,i)?(l[u]=y,l[m]=a,u=m):(l[u]=i,l[f]=a,u=f);else if(m<n&&0>dn(y,a))l[u]=y,l[m]=a,u=m;else break l}}return t}c(hn,"pop");function dn(l,t){var a=l.sortIndex-t.sortIndex;return a!==0?a:l.id-t.id}c(dn,"compare");w.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(xi=performance,w.unstable_now=function(){return xi.now()}):(Ke=Date,ji=Ke.now(),w.unstable_now=function(){return Ke.now()-ji});var xi,Ke,ji,lt=[],Tt=[],zd=1,Ql=null,Sl=3,Fe=!1,fu=!1,iu=!1,$e=!1,Ki=typeof setTimeout=="function"?setTimeout:null,Ji=typeof clearTimeout=="function"?clearTimeout:null,Vi=typeof setImmediate<"u"?setImmediate:null;function yn(l){for(var t=wl(Tt);t!==null;){if(t.callback===null)hn(Tt);else if(t.startTime<=l)hn(Tt),t.sortIndex=t.expirationTime,we(lt,t);else break;t=wl(Tt)}}c(yn,"advanceTimers");function ke(l){if(iu=!1,yn(l),!fu)if(wl(lt)!==null)fu=!0,ga||(ga=!0,Sa());else{var t=wl(Tt);t!==null&&re(ke,t.startTime-l)}}c(ke,"handleTimeout");var ga=!1,mu=-1,Wi=5,wi=-1;function Fi(){return $e?!0:!(w.unstable_now()-wi<Wi)}c(Fi,"shouldYieldToHost");function Je(){if($e=!1,ga){var l=w.unstable_now();wi=l;var t=!0;try{l:{fu=!1,iu&&(iu=!1,Ji(mu),mu=-1),Fe=!0;var a=Sl;try{t:{for(yn(l),Ql=wl(lt);Ql!==null&&!(Ql.expirationTime>l&&Fi());){var u=Ql.callback;if(typeof u=="function"){Ql.callback=null,Sl=Ql.priorityLevel;var n=u(Ql.expirationTime<=l);if(l=w.unstable_now(),typeof n=="function"){Ql.callback=n,yn(l),t=!0;break t}Ql===wl(lt)&&hn(lt),yn(l)}else hn(lt);Ql=wl(lt)}if(Ql!==null)t=!0;else{var e=wl(Tt);e!==null&&re(ke,e.startTime-l),t=!1}}break l}finally{Ql=null,Sl=a,Fe=!1}t=void 0}}finally{t?Sa():ga=!1}}}c(Je,"performWorkUntilDeadline");var Sa;typeof Vi=="function"?Sa=c(function(){Vi(Je)},"schedulePerformWorkUntilDeadline"):typeof MessageChannel<"u"?(We=new MessageChannel,Li=We.port2,We.port1.onmessage=Je,Sa=c(function(){Li.postMessage(null)},"schedulePerformWorkUntilDeadline")):Sa=c(function(){Ki(Je,0)},"schedulePerformWorkUntilDeadline");var We,Li;function re(l,t){mu=Ki(function(){l(w.unstable_now())},t)}c(re,"requestHostTimeout");w.unstable_IdlePriority=5;w.unstable_ImmediatePriority=1;w.unstable_LowPriority=4;w.unstable_NormalPriority=3;w.unstable_Profiling=null;w.unstable_UserBlockingPriority=2;w.unstable_cancelCallback=function(l){l.callback=null};w.unstable_forceFrameRate=function(l){0>l||125<l?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Wi=0<l?Math.floor(1e3/l):5};w.unstable_getCurrentPriorityLevel=function(){return Sl};w.unstable_next=function(l){switch(Sl){case 1:case 2:case 3:var t=3;break;default:t=Sl}var a=Sl;Sl=t;try{return l()}finally{Sl=a}};w.unstable_requestPaint=function(){$e=!0};w.unstable_runWithPriority=function(l,t){switch(l){case 1:case 2:case 3:case 4:case 5:break;default:l=3}var a=Sl;Sl=l;try{return t()}finally{Sl=a}};w.unstable_scheduleCallback=function(l,t,a){var u=w.unstable_now();switch(typeof a=="object"&&a!==null?(a=a.delay,a=typeof a=="number"&&0<a?u+a:u):a=u,l){case 1:var n=-1;break;case 2:n=250;break;case 5:n=1073741823;break;case 4:n=1e4;break;default:n=5e3}return n=a+n,l={id:zd++,callback:t,priorityLevel:l,startTime:a,expirationTime:n,sortIndex:-1},a>u?(l.sortIndex=a,we(Tt,l),wl(lt)===null&&l===wl(Tt)&&(iu?(Ji(mu),mu=-1):iu=!0,re(ke,a-u))):(l.sortIndex=n,we(lt,l),fu||Fe||(fu=!0,ga||(ga=!0,Sa()))),l};w.unstable_shouldYield=Fi;w.unstable_wrapCallback=function(l){var t=Sl;return function(){var a=Sl;Sl=t;try{return l.apply(this,arguments)}finally{Sl=a}}}});var ri=vn((a2,ki)=>{"use strict";ki.exports=$i()});var md=vn(Re=>{"use strict";var el=ri(),M1=Di(),Ad=bd();function z(l){var t="https://react.dev/errors/"+l;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+l+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}c(z,"formatProdErrorMessage");function O1(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}c(O1,"isValidContainer");function $u(l){var t=l,a=l;if(l.alternate)for(;t.return;)t=t.return;else{l=t;do t=l,(t.flags&4098)!==0&&(a=t.return),l=t.return;while(l)}return t.tag===3?a:null}c($u,"getNearestMountedFiber");function U1(l){if(l.tag===13){var t=l.memoizedState;if(t===null&&(l=l.alternate,l!==null&&(t=l.memoizedState)),t!==null)return t.dehydrated}return null}c(U1,"getSuspenseInstanceFromFiber");function D1(l){if(l.tag===31){var t=l.memoizedState;if(t===null&&(l=l.alternate,l!==null&&(t=l.memoizedState)),t!==null)return t.dehydrated}return null}c(D1,"getActivityInstanceFromFiber");function Ii(l){if($u(l)!==l)throw Error(z(188))}c(Ii,"assertIsMounted");function Td(l){var t=l.alternate;if(!t){if(t=$u(l),t===null)throw Error(z(188));return t!==l?null:l}for(var a=l,u=t;;){var n=a.return;if(n===null)break;var e=n.alternate;if(e===null){if(u=n.return,u!==null){a=u;continue}break}if(n.child===e.child){for(e=n.child;e;){if(e===a)return Ii(n),l;if(e===u)return Ii(n),t;e=e.sibling}throw Error(z(188))}if(a.return!==u.return)a=n,u=e;else{for(var f=!1,i=n.child;i;){if(i===a){f=!0,a=n,u=e;break}if(i===u){f=!0,u=n,a=e;break}i=i.sibling}if(!f){for(i=e.child;i;){if(i===a){f=!0,a=e,u=n;break}if(i===u){f=!0,u=e,a=n;break}i=i.sibling}if(!f)throw Error(z(189))}}if(a.alternate!==u)throw Error(z(190))}if(a.tag!==3)throw Error(z(188));return a.stateNode.current===a?l:t}c(Td,"findCurrentFiberUsingSlowPath");function _1(l){var t=l.tag;if(t===5||t===26||t===27||t===6)return l;for(l=l.child;l!==null;){if(t=_1(l),t!==null)return t;l=l.sibling}return null}c(_1,"findCurrentHostFiberImpl");var W=Object.assign,Ed=Symbol.for("react.element"),Sn=Symbol.for("react.transitional.element"),bu=Symbol.for("react.portal"),Ta=Symbol.for("react.fragment"),N1=Symbol.for("react.strict_mode"),qc=Symbol.for("react.profiler"),H1=Symbol.for("react.consumer"),it=Symbol.for("react.context"),_f=Symbol.for("react.forward_ref"),Yc=Symbol.for("react.suspense"),Qc=Symbol.for("react.suspense_list"),Nf=Symbol.for("react.memo"),Et=Symbol.for("react.lazy"),Xc=Symbol.for("react.activity"),Md=Symbol.for("react.memo_cache_sentinel"),Pi=Symbol.iterator;function vu(l){return l===null||typeof l!="object"?null:(l=Pi&&l[Pi]||l["@@iterator"],typeof l=="function"?l:null)}c(vu,"getIteratorFn");var Od=Symbol.for("react.client.reference");function Gc(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===Od?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case Ta:return"Fragment";case qc:return"Profiler";case N1:return"StrictMode";case Yc:return"Suspense";case Qc:return"SuspenseList";case Xc:return"Activity"}if(typeof l=="object")switch(l.$$typeof){case bu:return"Portal";case it:return l.displayName||"Context";case H1:return(l._context.displayName||"Context")+".Consumer";case _f:var t=l.render;return l=l.displayName,l||(l=t.displayName||t.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case Nf:return t=l.displayName||null,t!==null?t:Gc(l.type)||"Memo";case Et:t=l._payload,l=l._init;try{return Gc(l(t))}catch{}}return null}c(Gc,"getComponentNameFromType");var su=Array.isArray,_=M1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,p=Ad.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Pt={pending:!1,data:null,method:null,action:null},pc=[],Ea=-1;function Il(l){return{current:l}}c(Il,"createCursor");function il(l){0>Ea||(l.current=pc[Ea],pc[Ea]=null,Ea--)}c(il,"pop");function L(l,t){Ea++,pc[Ea]=l.current,l.current=t}c(L,"push");var rl=Il(null),Gu=Il(null),Qt=Il(null),wn=Il(null);function Fn(l,t){switch(L(Qt,t),L(Gu,l),L(rl,null),t.nodeType){case 9:case 11:l=(l=t.documentElement)&&(l=l.namespaceURI)?c1(l):0;break;default:if(l=t.tagName,t=t.namespaceURI)t=c1(t),l=$v(t,l);else switch(l){case"svg":l=1;break;case"math":l=2;break;default:l=0}}il(rl),L(rl,l)}c(Fn,"pushHostContainer");function xa(){il(rl),il(Gu),il(Qt)}c(xa,"popHostContainer");function Cc(l){l.memoizedState!==null&&L(wn,l);var t=rl.current,a=$v(t,l.type);t!==a&&(L(Gu,l),L(rl,a))}c(Cc,"pushHostContext");function $n(l){Gu.current===l&&(il(rl),il(Gu)),wn.current===l&&(il(wn),Wu._currentValue=Pt)}c($n,"popHostContext");var Ie,l0;function $t(l){if(Ie===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);Ie=t&&t[1]||"",l0=-1<a.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
3
|
`+Ie+l+l0}c($t,"describeBuiltInComponentFrame");var Pe=!1;function lc(l,t){if(!l||Pe)return"";Pe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:c(function(){try{if(t){var b=c(function(){throw Error()},"Fake");if(Object.defineProperty(b.prototype,"props",{set:c(function(){throw Error()},"set")}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(g){var S=g}Reflect.construct(l,[],b)}else{try{b.call()}catch(g){S=g}l.call(b.prototype)}}else{try{throw Error()}catch(g){S=g}(b=l())&&typeof b.catch=="function"&&b.catch(function(){})}}catch(g){if(g&&S&&typeof g.stack=="string")return[g.stack,S.stack]}return[null,null]},"DetermineComponentFrameRoot")};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var n=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");n&&n.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var e=u.DetermineComponentFrameRoot(),f=e[0],i=e[1];if(f&&i){var m=f.split(`
|
|
4
4
|
`),y=i.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/studio",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.64",
|
|
4
4
|
"description": "The Lunora Studio: a local admin UI for your schema, data, logs, and advisors",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin-ui",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"@hugeicons/react": "^1.1.9",
|
|
59
59
|
"@lingui/core": "^6.6.0",
|
|
60
60
|
"@lingui/message-utils": "^6.6.0",
|
|
61
|
-
"@lunora/advisor": "1.0.0-alpha.
|
|
61
|
+
"@lunora/advisor": "1.0.0-alpha.39",
|
|
62
62
|
"@lunora/bindings": "1.0.0-alpha.11",
|
|
63
|
-
"@lunora/client": "1.0.0-alpha.
|
|
63
|
+
"@lunora/client": "1.0.0-alpha.31",
|
|
64
64
|
"@lunora/errors": "1.0.0-alpha.8",
|
|
65
|
-
"@lunora/react": "1.0.0-alpha.
|
|
65
|
+
"@lunora/react": "1.0.0-alpha.35",
|
|
66
66
|
"@tanstack/react-query": "^5.101.4",
|
|
67
67
|
"@tanstack/react-router": "^1.170.18",
|
|
68
68
|
"@tanstack/react-table": "^8.21.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ue,b as me,c as pe,d as ve,e as W}from"./chunk-3RTTXLMU.js";import"./chunk-2PJNAWB3.js";import{a as he}from"./chunk-X2FQ6B5V.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import{a as ne}from"./chunk-LFKCLLPT.js";import"./chunk-T6VMSOBB.js";import{b as re}from"./chunk-OWADN6BI.js";import{a as oe,b as de,c as ce,d as P,e as h,f as u}from"./chunk-MIQTKZAR.js";import{a as Z,e as ee}from"./chunk-UZERI5YC.js";import"./chunk-QBWRC5YX.js";import{a as le}from"./chunk-LFXFP4IF.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import{R as Y}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as S}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as V}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as I}from"./chunk-GXZAXNZI.js";import{f as J}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as se}from"./chunk-XQCVZAGU.js";import{d as Q,f as C,g as te,h as ae,m as N,q as ie}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as l,e as M,f as Se,g as Ce,h as $e}from"./chunk-3XIESWL4.js";var fe=M(Ce(),1);var $=M(Se(),1);var t=M($e(),1);var X="none",Ae=["all","open","resolved","ignored"],ke=["critical","high","medium","low"],Ee=C(I.resolveIssue),ze=C(I.ignoreIssue),ge=C(I.assignIssue),Ke=C(I.setIssueSeverity),Re=l(i=>Array.isArray(i?.issues)?i.issues:[],"Ee"),Te=l(i=>i==="resolved"?"success":i==="ignored"?"secondary":"warning","ke"),je=l(i=>i==="critical"?"destructive":i==="high"?"warning":i==="medium"?"info":"secondary","Re"),Qe=l(i=>{let e=(0,fe.c)(44),{initialShardKey:xe}=i,a=Q(),w=J(),[d,ye]=(0,$.useState)(xe??""),[n,Ne]=(0,$.useState)("all"),[_,B]=(0,$.useState)(null),[m,G]=(0,$.useState)(null),A;e[0]!==d?(A=d.trim(),e[0]=d,e[1]=A):A=e[1];let c=ne(A,400),k;e[2]!==n?(k=n==="all"?{}:{status:n},e[2]=n,e[3]=k):k=e[3];let E;e[4]!==c?(E={live:!0,shardKey:c},e[4]=c,e[5]=E):E=e[5];let{data:z,error:p,liveError:b}=re(I.getIssues,k,E),q=z!==void 0,K;if(e[6]!==m||e[7]!==_||e[8]!==w||e[9]!==z||e[10]!==c||e[11]!==p||e[12]!==b||e[13]!==q||e[14]!==d||e[15]!==n||e[16]!==a){let H=Re(z),R;e[18]!==w||e[19]!==c?(R=l(async(s,r,y)=>{G(null),B(s);try{await w.query(r,{...y,hash:s},te(c))}catch(be){G(ae(be))}B(null)},"k"),e[18]=w,e[19]=c,e[20]=R):R=e[20];let o=R,T;e[21]!==o?(T=l(s=>r=>{if(r.key!=="Enter")return;let y=r.currentTarget.value.trim();N(o(s.hash,ge,{assignee:y===""?null:y}))},"R"),e[21]=o,e[22]=T):T=e[22];let Ie=T,j;e[23]!==o?(j=l(s=>r=>{let y=r===null||r===X?null:r;N(o(s.hash,Ke,{severity:y}))},"T"),e[23]=o,e[24]=j):j=e[24];let we=j,L;e[25]!==a?(L=l(s=>a(s==="all"?"All":s==="open"?"Open":s==="resolved"?"Resolved":"Ignored"),"z"),e[25]=a,e[26]=L):L=e[26];let F=L,D;e[27]!==p?(D=p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:p}),e[27]=p,e[28]=D):D=e[28];let O;e[29]!==m?(O=m!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-action-error",role:"alert",children:m}),e[29]=m,e[30]=O):O=e[30];let v;e[31]!==d?(v=(0,t.jsx)(le,{onChange:ye,testId:"issues-shard-input",value:d}),e[31]=d,e[32]=v):v=e[32];let g;e[33]!==b?(g=(0,t.jsx)(he,{message:b,prefix:"issues"}),e[33]=b,e[34]=g):g=e[34];let f;e[35]!==n||e[36]!==F?(f=Ae.map(s=>(0,t.jsx)(S,{"data-active":n===s?"":void 0,"data-testid":`issues-filter-${s}`,onClick:l(()=>{Ne(s)},"onClick"),size:"xs",variant:n===s?"default":"outline",children:F(s)},s)),e[35]=n,e[36]=F,e[37]=f):f=e[37];let x;e[38]!==f?(x=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:f}),e[38]=f,e[39]=x):x=e[39];let U;e[40]!==v||e[41]!==g||e[42]!==x?(U=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[v,g,x]}),e[40]=v,e[41]=g,e[42]=x,e[43]=U):U=e[43],K=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[D,O,U,q&&H.length===0?(0,t.jsx)(se,{description:a("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:a("No issues")}):(0,t.jsx)(Z,{className:"overflow-hidden py-0",children:(0,t.jsx)(ee,{className:"px-0",children:(0,t.jsxs)(oe,{"data-testid":"issues-table",children:[(0,t.jsx)(de,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(h,{children:a("Issue")}),(0,t.jsx)(h,{children:a("Status")}),(0,t.jsx)(h,{children:a("Severity")}),(0,t.jsx)(h,{children:a("Assignee")}),(0,t.jsx)(h,{className:"text-right",children:a("Events")}),(0,t.jsx)(h,{children:a("Last seen")}),(0,t.jsx)(h,{className:"text-right",children:a("Actions")})]})}),(0,t.jsx)(ce,{children:H.map(s=>{let r=_===s.hash;return(0,t.jsxs)(P,{"data-testid":`issues-row-${s.hash}`,children:[(0,t.jsxs)(u,{className:"max-w-80",children:[(0,t.jsx)("div",{className:"truncate font-medium",title:s.title,children:s.title}),(0,t.jsx)("div",{className:"truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit})]}),(0,t.jsx)(u,{children:(0,t.jsx)(V,{"data-testid":`issues-status-${s.hash}`,variant:Te(s.status),children:s.status})}),(0,t.jsx)(u,{children:(0,t.jsxs)(ue,{disabled:r,onValueChange:we(s),value:s.severity??X,children:[(0,t.jsx)(pe,{"aria-label":a("Set severity"),className:"h-7 w-[110px]","data-testid":`issues-severity-${s.hash}`,children:(0,t.jsx)(me,{placeholder:a("\u2014"),children:s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(V,{variant:je(s.severity),children:s.severity})})}),(0,t.jsxs)(ve,{children:[ke.map(Le),(0,t.jsx)(W,{value:X,children:a("Clear")})]})]})}),(0,t.jsx)(u,{children:(0,t.jsx)(Y,{"aria-label":a("Assignee"),className:"h-7 w-32","data-testid":`issues-assignee-${s.hash}`,defaultValue:s.assignee??"",disabled:r,onKeyDown:Ie(s),placeholder:a("Unassigned")},s.assignee??"")}),(0,t.jsx)(u,{className:"text-right",children:(0,t.jsx)(V,{variant:"secondary",children:s.count})}),(0,t.jsx)(u,{className:"text-xs tabular-nums text-muted-foreground",children:ie(s.lastSeen)}),(0,t.jsx)(u,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[s.status!=="resolved"&&(0,t.jsx)(S,{"data-testid":`issues-resolve-${s.hash}`,disabled:r,onClick:l(()=>{N(o(s.hash,Ee,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),s.status!=="ignored"&&(0,t.jsx)(S,{"data-testid":`issues-ignore-${s.hash}`,disabled:r,onClick:l(()=>{N(o(s.hash,ze,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),s.status!=="open"&&(0,t.jsx)(S,{"data-testid":`issues-reopen-${s.hash}`,disabled:r,onClick:l(()=>{N(o(s.hash,ge,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")})]})})]},s.hash)})})]})})})]}),e[6]=m,e[7]=_,e[8]=w,e[9]=z,e[10]=c,e[11]=p,e[12]=b,e[13]=q,e[14]=d,e[15]=n,e[16]=a,e[17]=K}else K=e[17];return K},"Xe");function Le(i){return(0,t.jsx)(W,{value:i,children:i},i)}l(Le,"Te");export{Qe as IssuesPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as be,b as fe,c as xe,d as Ne,e as we}from"./chunk-3RTTXLMU.js";import"./chunk-2PJNAWB3.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as ue}from"./chunk-JN2Y24PY.js";import{g as me,h as ve,i as pe,j as ye}from"./chunk-TRHTFGFW.js";import"./chunk-M536Y2KX.js";import"./chunk-KYF2E5CJ.js";import"./chunk-7YEFOSPH.js";import"./chunk-BGBLQ563.js";import"./chunk-IVFHIQOT.js";import"./chunk-ILNELDFC.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-OWADN6BI.js";import{a as se,b as ie,c as oe,d as Q,e as X,f as Y}from"./chunk-MIQTKZAR.js";import{a as re,e as ne}from"./chunk-UZERI5YC.js";import{a as ce}from"./chunk-V53KNYRN.js";import{a as q}from"./chunk-5Y3QLNWX.js";import"./chunk-HPFLBYRI.js";import"./chunk-QBWRC5YX.js";import{R as ae}from"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import{c as $}from"./chunk-FXCBF4XT.js";import"./chunk-2OUPA2WJ.js";import{b as he}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import"./chunk-GXZAXNZI.js";import{f as G}from"./chunk-LWECXQWP.js";import"./chunk-XBDKZZ67.js";import{a as ke}from"./chunk-XQCVZAGU.js";import{d as R,h as Z,m as A,o as de,p as ge}from"./chunk-4CGALXS3.js";import"./chunk-LE56LPNH.js";import{a as i,e as le,f as Oe,g as _e,h as De}from"./chunk-3XIESWL4.js";var B=le(Oe(),1);var ee=le(_e(),1);var a=le(De(),1);var Je=i(r=>{let e=r.trim();if(e==="")return;let n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},"_e"),Le=i(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"Je"),Pe=i(r=>new TextEncoder().encode(r).length,"De"),Fe=i(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"ge"),Ee=i(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"xe"),Ke=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Ce=i((r,e)=>{let n=r.trim();if(n==="")return"";let u=Number(n),s=Ke.find(p=>p.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*s)):n},"ue"),Ve=i(r=>{let e=r.trim();if(e==="")return!0;let n=Number(e);return Number.isInteger(n)&&n>=60},"Ce"),Te=i((r,e,n,u)=>{let s=Je(r.ttl);return{expiration:s===void 0?u:void 0,expirationTtl:s,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:n,value:r.value}},"we"),Me=i(r=>{let e=(0,ee.c)(60),{helper:n,id:u,invalid:s,onChange:p,testId:o}=r,t=R(),[l,y]=(0,B.useState)(""),[c,x]=(0,B.useState)("seconds"),b;e[0]!==p||e[1]!==c?(b=i(f=>{y(f.target.value),p(Ce(f.target.value,c))},"f"),e[0]=p,e[1]=c,e[2]=b):b=e[2];let O=b,T;e[3]!==l||e[4]!==p?(T=i(f=>{f!==null&&(x(f),p(Ce(l,f)))},"V"),e[3]=l,e[4]=p,e[5]=T):T=e[5];let _=T,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let k;e[10]!==t?(k=t("minutes"),e[10]=t,e[11]=k):k=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let w;e[14]!==h||e[15]!==v||e[16]!==k||e[17]!==N?(w={days:h,hours:v,minutes:k,seconds:N},e[14]=h,e[15]=v,e[16]=k,e[17]=N,e[18]=w):w=e[18];let C=w,g;e[19]!==t?(g=t("Expires after"),e[19]=t,e[20]=g):g=e[20];let S;e[21]!==u||e[22]!==g?(S=(0,a.jsx)(q,{className:"text-xs",htmlFor:u,children:g}),e[21]=u,e[22]=g,e[23]=S):S=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let D;e[26]!==l||e[27]!==u||e[28]!==s||e[29]!==O||e[30]!==E||e[31]!==o?(D=(0,a.jsx)(ae,{"aria-invalid":s,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:O,placeholder:E,value:l}),e[26]=l,e[27]=u,e[28]=s,e[29]=O,e[30]=E,e[31]=o,e[32]=D):D=e[32];let M;e[33]!==t?(M=t("TTL unit"),e[33]=t,e[34]=M):M=e[34];let L=`${o}-unit`,J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=(0,a.jsx)(fe,{}),e[35]=J):J=e[35];let d;e[36]!==M||e[37]!==L?(d=(0,a.jsx)(xe,{"aria-label":M,className:"w-[7.5rem]","data-testid":L,children:J}),e[36]=M,e[37]=L,e[38]=d):d=e[38];let m;e[39]!==C?(m=Ke.map(f=>(0,a.jsx)(we,{value:f.key,children:C[f.key]},f.key)),e[39]=C,e[40]=m):m=e[40];let V;e[41]!==m?(V=(0,a.jsx)(Ne,{children:m}),e[41]=m,e[42]=V):V=e[42];let F;e[43]!==_||e[44]!==d||e[45]!==V||e[46]!==c?(F=(0,a.jsxs)(be,{onValueChange:_,value:c,children:[d,V]}),e[43]=_,e[44]=d,e[45]=V,e[46]=c,e[47]=F):F=e[47];let I;e[48]!==D||e[49]!==F?(I=(0,a.jsxs)("div",{className:"flex gap-2",children:[D,F]}),e[48]=D,e[49]=F,e[50]=I):I=e[50];let K;e[51]!==n||e[52]!==s||e[53]!==t||e[54]!==o?(K=s?(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")}):n!==void 0&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:n}),e[51]=n,e[52]=s,e[53]=t,e[54]=o,e[55]=K):K=e[55];let P;return e[56]!==I||e[57]!==K||e[58]!==S?(P=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,I,K]}),e[56]=I,e[57]=K,e[58]=S,e[59]=P):P=e[59],P},"$e"),Ie=i(r=>{let e=(0,ee.c)(36),{id:n,invalidTestId:u,onChange:s,testId:p,valid:o,value:t}=r,l=R(),y;e[0]!==t?(y=Fe(t),e[0]=t,e[1]=y):y=e[1];let c=y,x;e[2]!==l?(x=l("Metadata (JSON)"),e[2]=l,e[3]=x):x=e[3];let b;e[4]!==n||e[5]!==x?(b=(0,a.jsx)(q,{className:"text-xs",htmlFor:n,children:x}),e[4]=n,e[5]=x,e[6]=b):b=e[6];let O=`${p}-format`,T=c===void 0,_;e[7]!==c||e[8]!==s?(_=i(()=>{c!==void 0&&s(c)},"O"),e[7]=c,e[8]=s,e[9]=_):_=e[9];let h;e[10]!==l?(h=l("Format JSON"),e[10]=l,e[11]=h):h=e[11];let v;e[12]!==O||e[13]!==T||e[14]!==_||e[15]!==h?(v=(0,a.jsx)($,{"data-testid":O,disabled:T,onClick:_,size:"sm",variant:"outline",children:h}),e[12]=O,e[13]=T,e[14]=_,e[15]=h,e[16]=v):v=e[16];let k;e[17]!==b||e[18]!==v?(k=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[b,v]}),e[17]=b,e[18]=v,e[19]=k):k=e[19];let N=!o,w;e[20]!==s?(w=i(E=>{s(E.target.value)},"N"),e[20]=s,e[21]=w):w=e[21];let C;e[22]!==n||e[23]!==N||e[24]!==w||e[25]!==p||e[26]!==t?(C=(0,a.jsx)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":p,id:n,onChange:w,value:t}),e[22]=n,e[23]=N,e[24]=w,e[25]=p,e[26]=t,e[27]=C):C=e[27];let g;e[28]!==u||e[29]!==l||e[30]!==o?(g=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":u,children:l("Metadata must be valid JSON.")}),e[28]=u,e[29]=l,e[30]=o,e[31]=g):g=e[31];let S;return e[32]!==C||e[33]!==g||e[34]!==k?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[k,C,g]}),e[32]=C,e[33]=g,e[34]=k,e[35]=S):S=e[35],S},"Se"),Be={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},$e=i((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"Be"),je=i(r=>{let e=(0,ee.c)(73),{namespace:n,onCancel:u,onCreated:s}=r,p=G(),o=R(),[t,l]=(0,B.useReducer)($e,Be),y;e[0]!==t.metadata?(y=Ee(t.metadata),e[0]=t.metadata,e[1]=y):y=e[1];let c=y,x;e[2]!==t.ttl?(x=Ve(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,O;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(O=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=O):O=e[8];let T=O,_;e[9]!==T||e[10]!==p||e[11]!==n||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(_=i(()=>{T&&(l({type:"submitStart"}),A((async()=>{try{await p.putKvValue(Te({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),s()}catch(z){l({error:Z(z),type:"submitFailed"})}})()))},"O"),e[9]=T,e[10]=p,e[11]=n,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=_):_=e[17];let h=_,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let k;e[20]!==v?(k=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-name",children:v}),e[20]=v,e[21]=k):k=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=i(z=>{l({field:"name",type:"setField",value:z.target.value})},"x"),e[22]=N):N=e[22];let w;e[23]!==o?(w=o("Key name"),e[23]=o,e[24]=w):w=e[24];let C;e[25]!==t.name||e[26]!==w?(C=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:w,value:t.name}),e[25]=t.name,e[26]=w,e[27]=C):C=e[27];let g;e[28]!==k||e[29]!==C?(g=(0,a.jsxs)("div",{className:"grid gap-1",children:[k,C]}),e[28]=k,e[29]=C,e[30]=g):g=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let E;e[33]!==S?(E=(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=E):E=e[34];let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=i(z=>{l({field:"value",type:"setField",value:z.target.value})},"_"),e[35]=D):D=e[35];let M;e[36]!==t.value?(M=(0,a.jsx)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:D,value:t.value}),e[36]=t.value,e[37]=M):M=e[37];let L;e[38]!==E||e[39]!==M?(L=(0,a.jsxs)("div",{className:"grid gap-1",children:[E,M]}),e[38]=E,e[39]=M,e[40]=L):L=e[40];let J=!b,d;e[41]===Symbol.for("react.memo_cache_sentinel")?(d=i(z=>{l({field:"ttl",type:"setField",value:z})},"d"),e[41]=d):d=e[41];let m;e[42]!==J?(m=(0,a.jsx)(Me,{id:"kv-create-ttl",invalid:J,onChange:d,testId:"kv-create-ttl"}),e[42]=J,e[43]=m):m=e[43];let V;e[44]===Symbol.for("react.memo_cache_sentinel")?(V=i(z=>{l({field:"metadata",type:"setField",value:z})},"E"),e[44]=V):V=e[44];let F;e[45]!==c||e[46]!==t.metadata?(F=(0,a.jsx)(Ie,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:V,testId:"kv-create-metadata",valid:c,value:t.metadata}),e[45]=c,e[46]=t.metadata,e[47]=F):F=e[47];let I=!T,K;e[48]!==t.busy||e[49]!==o?(K=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=K):K=e[50];let P;e[51]!==h||e[52]!==I||e[53]!==K?(P=(0,a.jsx)($,{"data-testid":"kv-create-submit",disabled:I,onClick:h,children:K}),e[51]=h,e[52]=I,e[53]=K,e[54]=P):P=e[54];let f=t.busy,j;e[55]!==o?(j=o("Cancel"),e[55]=o,e[56]=j):j=e[56];let H;e[57]!==u||e[58]!==t.busy||e[59]!==j?(H=(0,a.jsx)($,{"data-testid":"kv-create-cancel",disabled:f,onClick:u,variant:"outline",children:j}),e[57]=u,e[58]=t.busy,e[59]=j,e[60]=H):H=e[60];let U;e[61]!==P||e[62]!==H?(U=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[P,H]}),e[61]=P,e[62]=H,e[63]=U):U=e[63];let W;e[64]!==t.error?(W=t.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=W):W=e[65];let te;return e[66]!==g||e[67]!==L||e[68]!==m||e[69]!==F||e[70]!==U||e[71]!==W?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[g,L,m,F,U,W]}),e[66]=g,e[67]=L,e[68]=m,e[69]=F,e[70]=U,e[71]=W,e[72]=te):te=e[72],te},"Pe"),ze={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=i((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"Ae"),He=i(r=>{let e=(0,ee.c)(67),{expiration:n,keyName:u,namespace:s,onDeleted:p}=r,o=G(),t=R(),[l,y]=(0,B.useReducer)(Ae,ze),c,x;e[0]!==o||e[1]!==u||e[2]!==s?(c=i(()=>{let f={cancelled:!1};return A((async()=>{try{let j=await o.getKvValue({key:u,namespace:s});f.cancelled||y({metadata:j.metadata,type:"loaded",value:j.value})}catch(j){let H=j;f.cancelled||y({error:Z(H),type:"loadFailed"})}})()),()=>{f.cancelled=!0}},"o"),x=[o,s,u],e[0]=o,e[1]=u,e[2]=s,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,B.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=i(f=>{y({type:"editValue",value:f.target.value})},"f"),e[5]=b):b=e[5];let O=b,T;e[6]===Symbol.for("react.memo_cache_sentinel")?(T=i(f=>{y({type:"editMetadata",value:f})},"V"),e[6]=T):T=e[6];let _=T,h;e[7]!==l.editedValue?(h=Fe(l.editedValue),e[7]=l.editedValue,e[8]=h):h=e[8];let v=h,k;e[9]!==l.editedMetadata?(k=Ee(l.editedMetadata),e[9]=l.editedMetadata,e[10]=k):k=e[10];let N=k,w;e[11]!==l.editedTtl?(w=Ve(l.editedTtl),e[11]=l.editedTtl,e[12]=w):w=e[12];let C=w,g;e[13]!==v?(g=i(()=>{v!==void 0&&y({type:"editValue",value:v})},"k"),e[13]=v,e[14]=g):g=e[14];let S=g,E;e[15]!==o||e[16]!==n||e[17]!==u||e[18]!==N||e[19]!==s||e[20]!==l.editedMetadata||e[21]!==l.editedTtl||e[22]!==l.editedValue||e[23]!==t?(E=i(()=>{if(!N){y({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}y({type:"saveStart"}),A((async()=>{try{await o.putKvValue(Te({metadata:l.editedMetadata,ttl:l.editedTtl,value:l.editedValue},u,s,n)),y({type:"saveOk"})}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"F"),e[15]=o,e[16]=n,e[17]=u,e[18]=N,e[19]=s,e[20]=l.editedMetadata,e[21]=l.editedTtl,e[22]=l.editedValue,e[23]=t,e[24]=E):E=e[24];let D=E,M;e[25]!==o||e[26]!==u||e[27]!==s||e[28]!==p?(M=i(()=>{y({type:"deleteStart"}),A((async()=>{try{await o.deleteKvKey({key:u,namespace:s}),p(u)}catch(f){y({error:Z(f),type:"writeFailed"})}})())},"M"),e[25]=o,e[26]=u,e[27]=s,e[28]=p,e[29]=M):M=e[29];let L=M,J;e[30]!==u?(J=i(()=>{de(u)},"J"),e[30]=u,e[31]=J):J=e[31];let d;e[32]!==t?(d=t("Copy key"),e[32]=t,e[33]=d):d=e[33];let m;e[34]!==J||e[35]!==d?(m=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)($,{"data-testid":"kv-copy-key-btn",onClick:J,size:"sm",variant:"outline",children:d})}),e[34]=J,e[35]=d,e[36]=m):m=e[36];let V;e[37]!==l.loadError?(V=l.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:l.loadError}),e[37]=l.loadError,e[38]=V):V=e[38];let F;e[39]!==l.loading||e[40]!==t?(F=l.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=l.loading,e[40]=t,e[41]=F):F=e[41];let I;e[42]!==v||e[43]!==N||e[44]!==L||e[45]!==S||e[46]!==D||e[47]!==l.busy||e[48]!==l.editedMetadata||e[49]!==l.editedValue||e[50]!==l.loading||e[51]!==l.value||e[52]!==l.writeError||e[53]!==t||e[54]!==C?(I=!l.loading&&l.value!==null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),v!==void 0&&(0,a.jsx)(he,{variant:"secondary",children:t("JSON")}),(0,a.jsx)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ge(Pe(l.editedValue))})]}),(0,a.jsx)("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:O,value:l.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)($,{"data-testid":"kv-copy-value-btn",onClick:i(()=>{de(l.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(Me,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:i(f=>{y({type:"editTtl",value:f})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(Ie,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:_,testId:"kv-metadata-editor",valid:N,value:l.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)($,{"data-testid":"kv-save-btn",disabled:l.busy!==""||!N||!C,onClick:D,children:l.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)($,{"data-testid":"kv-delete-btn",disabled:l.busy!=="",onClick:L,variant:"destructive",children:l.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),l.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:l.writeError})]}),e[42]=v,e[43]=N,e[44]=L,e[45]=S,e[46]=D,e[47]=l.busy,e[48]=l.editedMetadata,e[49]=l.editedValue,e[50]=l.loading,e[51]=l.value,e[52]=l.writeError,e[53]=t,e[54]=C,e[55]=I):I=e[55];let K;e[56]!==l.loadError||e[57]!==l.loading||e[58]!==l.value||e[59]!==t?(K=!l.loading&&l.value===null&&l.loadError===null&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=l.loadError,e[57]=l.loading,e[58]=l.value,e[59]=t,e[60]=K):K=e[60];let P;return e[61]!==m||e[62]!==V||e[63]!==F||e[64]!==I||e[65]!==K?(P=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[m,V,F,I,K]}),e[61]=m,e[62]=V,e[63]=F,e[64]=I,e[65]=K,e[66]=P):P=e[66],P},"ze"),Se=100,Ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=i((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let n=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!n.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!n.has(u.name)),selectedKey:r.selectedKey!==null&&n.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(n=>n!==e.name),keys:r.keys===null?null:r.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(n=>n!==e.name):[...r.bulk,e.name]};default:return r}},"Re"),Ue=i(({namespace:r})=>{let e=G(),n=R(),[u,s]=(0,B.useReducer)(Re,Ze),{appliedPrefix:p,bulk:o,bulkBusy:t,bulkError:l,cursor:y,keys:c,listComplete:x,loadError:b,loading:O,prefixInput:T,reloadNonce:_,selectedKey:h}=u,[v,k]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let d={cancelled:!1};return A((async()=>{s({type:"loadStart"});try{let m=await e.listKvKeys({limit:Se,namespace:r,prefix:p===""?void 0:p});d.cancelled||s({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){d.cancelled||s({error:Z(m),type:"loadFailed"})}})()),()=>{d.cancelled=!0}},[e,r,p,_]);let N=i(d=>{s({type:"prefixInput",value:d.target.value})},"x"),w=i(()=>{s({type:"applyFilter"})},"N"),C=i(d=>{s({name:d.currentTarget.dataset.key??null,type:"selectKey"})},"C"),g=i(()=>{y!==null&&(s({type:"loadStart"}),A((async()=>{try{let d=await e.listKvKeys({cursor:y,limit:Se,namespace:r,prefix:p===""?void 0:p});s({cursor:d.cursor??null,keys:d.keys,listComplete:d.listComplete,type:"appendPage"})}catch(d){s({error:Z(d),type:"loadFailed"})}})()))},"k"),S=i(d=>{s({name:d,type:"keyDeleted"})},"w"),E=i(d=>{s({name:d,type:"toggleBulk"})},"F"),D=i(d=>{s({names:d&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"_"),M=i(()=>{if(o.length===0)return;let d=[...o];s({type:"bulkDeleteStart"}),A((async()=>{let m=await Promise.allSettled(d.map(I=>e.deleteKvKey({key:I,namespace:r}))),V=d.filter((I,K)=>m[K]?.status==="fulfilled"),F=d.length-V.length;s({deleted:V,error:F>0?n("Failed to delete {count} keys.",{count:F}):null,type:"bulkDeleted"})})())},"M"),L=i(()=>{k(!1),s({type:"reload"})},"D"),J=c!==null&&c.length>0&&o.length===c.length;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,a.jsx)(ae,{"aria-label":n("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:n("Filter by prefix\u2026"),value:T}),(0,a.jsx)($,{"data-testid":"kv-filter-btn",disabled:O,onClick:w,children:n("Filter")}),(0,a.jsx)($,{"data-testid":"kv-new-key-btn",onClick:i(()=>{k(d=>!d)},"onClick"),variant:"outline",children:n("New key")}),o.length>0&&(0,a.jsx)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:M,variant:"destructive",children:t?n("Deleting\u2026"):n("Delete {count}",{count:o.length})})]}),l!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:l}),b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b}),c!==null&&c.length===0&&!O&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),c!==null&&c.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-key-table",children:[(0,a.jsx)(ie,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(X,{className:"w-10",children:(0,a.jsx)(ue,{"aria-label":n("Select all"),checked:J,"data-testid":"kv-select-all",onCheckedChange:D})}),(0,a.jsx)(X,{children:n("Key")}),(0,a.jsx)(X,{children:n("Expiration")})]})}),(0,a.jsx)(oe,{children:c.map(d=>(0,a.jsxs)(Q,{className:d.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":d.name,"data-testid":`kv-key-row-${d.name}`,onClick:C,children:[(0,a.jsx)(Y,{onClick:i(m=>{m.stopPropagation()},"onClick"),children:(0,a.jsx)(ue,{"aria-label":n("Select {name}",{name:d.name}),checked:o.includes(d.name),"data-testid":`kv-select-${d.name}`,onCheckedChange:i(()=>{E(d.name)},"onCheckedChange")})}),(0,a.jsx)(Y,{className:"font-mono text-xs",children:d.name}),(0,a.jsx)(Y,{className:"tabular-nums text-xs",children:Le(d.expiration)})]},d.name))})]})})}),!x&&y!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)($,{"data-testid":"kv-load-more",disabled:O,onClick:g,variant:"outline",children:n(O?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||k(!1)},"onOpenChange"),open:v,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{children:n("New key")})}),(0,a.jsx)(je,{namespace:r,onCancel:i(()=>{k(!1)},"onCancel"),onCreated:L})]})}),(0,a.jsx)(me,{onOpenChange:i(d=>{d||s({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,a.jsxs)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(pe,{children:(0,a.jsx)(ye,{className:"truncate font-mono text-xs",children:h})}),h!==null&&(0,a.jsx)(He,{expiration:c?.find(d=>d.name===h)?.expiration,keyName:h,namespace:r,onDeleted:S},`${r}:${h}`)]})})]})},"Ue"),it=i(({loadNamespaces:r}={})=>{let e=G(),n=R(),[u,s]=(0,B.useState)(null),[p,o]=(0,B.useState)(null),[t,l]=(0,B.useState)(null);(0,B.useEffect)(()=>{let c={cancelled:!1};return A((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(s(x),o(null),l(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(s(null),o(Z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let y=i(c=>{l(c.currentTarget.dataset.ns??null)},"p");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[p!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:p}),u!==null&&u.length===0&&(0,a.jsx)(ke,{description:n("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:n("No KV namespaces.")}),u!==null&&u.length>0&&(0,a.jsx)(re,{className:"overflow-hidden py-0",children:(0,a.jsx)(ne,{className:"px-0",children:(0,a.jsxs)(se,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(ie,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(X,{children:n("Namespace")})})}),(0,a.jsx)(oe,{children:u.map(c=>(0,a.jsx)(Q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:y,children:(0,a.jsx)(Y,{className:"font-mono text-xs",children:c.binding})},c.binding))})]})})}),t!==null&&(0,a.jsx)(Ue,{namespace:t},t)]})},"ct");export{it as KvBrowser};
|