@lunora/studio 1.0.0-alpha.381 → 1.0.0-alpha.383
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.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/mount.d.mts +1 -1
- package/dist/mount.d.ts +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
- package/dist/packem_chunks/analytics-panel.mjs +1 -1
- package/dist/packem_chunks/architecture-panel.mjs +1 -1
- package/dist/packem_chunks/assistant-panel.mjs +2 -2
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-config-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/log-drains-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/ApiDocsPanel-BZNuHTR8.mjs +2 -0
- package/dist/packem_shared/{ApiReferencePanel-CQxU1Ocx.mjs → ApiReferencePanel-DDvLw7c1.mjs} +1 -1
- package/dist/packem_shared/{CommandPalette-BZCHLpst.mjs → CommandPalette-BjHFgNA6.mjs} +1 -1
- package/dist/packem_shared/{DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs → DEFAULT_AUTO_REFRESH_MS-jK7srdI4.mjs} +1 -1
- package/dist/packem_shared/{DataBrowser-CkVOu6py.mjs → DataBrowser-Dp8ayK1S.mjs} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-l2ECwXCm.mjs → GlobalDataBrowser-VehUMwUK.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-c7as4tvl.mjs → HomePanel-D5-wWLAj.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-BQol4Un1.mjs → MigrationsPanel-CTd2YSSk.mjs} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-BFDG91tn.mjs → OpenRpcReferencePanel-dXFl95w8.mjs} +1 -1
- package/dist/packem_shared/{ScheduledJobs-Du8ZGL7v.mjs → ScheduledJobs-DPQHuiy6.mjs} +1 -1
- package/dist/packem_shared/Studio-CrfDOmdv.mjs +1 -0
- package/dist/packem_shared/{StudioApp-CsyDnrg2.mjs → StudioApp-DKBDIF7N.mjs} +1 -1
- package/dist/packem_shared/{advisor-view-gtf_DhUU.mjs → advisor-view-y9c2z5w1.mjs} +1 -1
- package/dist/packem_shared/{app.d-DpxFQ0qO.d.mts → app.d-QqDN78r1.d.mts} +1 -1
- package/dist/packem_shared/{app.d-DpxFQ0qO.d.ts → app.d-QqDN78r1.d.ts} +1 -1
- package/dist/packem_shared/{assistant-provider-Dw0roZh3.mjs → assistant-provider-b2GtJb5K.mjs} +1 -1
- package/dist/packem_shared/{data-grid-B5m1OosL.mjs → data-grid-GQLHcpMI.mjs} +1 -1
- package/dist/packem_shared/{diagram-export-panel-Vdt-DZnO.mjs → diagram-export-panel-miFPsocM.mjs} +1 -1
- package/dist/packem_shared/{error-alert-3AR_-s_s.mjs → error-alert-BxCd81tw.mjs} +1 -1
- package/dist/packem_shared/{grid-features-Drvfswwy.mjs → grid-features-Cdy2nWxA.mjs} +2 -2
- package/dist/packem_shared/{home-panel-TpxiaHgB.mjs → home-panel-BlvQ0xK2.mjs} +1 -1
- package/dist/packem_shared/{internal-hIuTpSbx.mjs → internal-BT5tH08j.mjs} +1 -1
- package/dist/packem_shared/{log-line-CYJQf6P-.mjs → log-line-BmYn49u1.mjs} +1 -1
- package/dist/packem_shared/{recording-client-z4CBi0y8.mjs → recording-client-D_-eNapT.mjs} +1 -1
- package/dist/packem_shared/{reference-view-DENugPcj.mjs → reference-view-CRtrtDMy.mjs} +3 -3
- package/dist/packem_shared/{schema-diagram-CtVPhOGj.mjs → schema-diagram-Dbs7-jSJ.mjs} +1 -1
- package/dist/packem_shared/{sql-result-table-DCwooMGW.mjs → sql-result-table-BuOHHoFG.mjs} +1 -1
- package/dist/packem_shared/{studio-DZlpp4Vx.mjs → studio-CwelGawN.mjs} +1 -1
- package/dist/packem_shared/{table-list-sidebar-Bfmg04MD.mjs → table-list-sidebar-Cw7ll9yK.mjs} +1 -1
- package/dist/packem_shared/{use-admin-query-CaOm4JS3.mjs → use-admin-query-DMnTt_hg.mjs} +1 -1
- package/dist/packem_shared/{use-admin-spec-CK7mk3Ui.mjs → use-admin-spec-Cokw73Ks.mjs} +1 -1
- package/dist/packem_shared/use-assistant-rpc-DLsuqTPB.mjs +1 -0
- package/dist/packem_shared/{use-async-submit-D0r7-m2J.mjs → use-async-submit-CBFJevkc.mjs} +1 -1
- package/dist/packem_shared/{use-auth-config-DameIc6y.mjs → use-auth-config-xzSMjhOV.mjs} +1 -1
- package/dist/packem_shared/{use-open-trace-BJKMJjeS.mjs → use-open-trace-trRfFb77.mjs} +1 -1
- package/dist/standalone/{chunk-QOK2UU3L.js → chunk-2IYIVCPN.js} +1 -1
- package/dist/standalone/{chunk-QCG2G6IF.js → chunk-2LKJSQKF.js} +1 -1
- package/dist/standalone/{chunk-5MIJ3KEK.js → chunk-4AGOKKRZ.js} +1 -1
- package/dist/standalone/{chunk-WDR3BJ2C.js → chunk-4KVCH3A4.js} +1 -1
- package/dist/standalone/{chunk-NDIEUO4N.js → chunk-54X7HWI6.js} +1 -1
- package/dist/standalone/{chunk-MNXXIISC.js → chunk-5CHKXJYN.js} +1 -1
- package/dist/standalone/{chunk-EVUVQB4Q.js → chunk-5IOQXXYH.js} +1 -1
- package/dist/standalone/chunk-5KQSRLQP.js +7 -0
- package/dist/standalone/{chunk-I626YY7T.js → chunk-5LJYJ5SF.js} +1 -1
- package/dist/standalone/chunk-6NZOJI3N.js +14 -0
- package/dist/standalone/chunk-6OIS24US.js +1 -0
- package/dist/standalone/{chunk-O4SDDSDL.js → chunk-76CCNRPQ.js} +1 -1
- package/dist/standalone/{chunk-OJO6ERJ4.js → chunk-7HIZZYHW.js} +1 -1
- package/dist/standalone/{chunk-Z4BLDRDD.js → chunk-7JIVSWQM.js} +1 -1
- package/dist/standalone/{chunk-NYLSD5LR.js → chunk-7O6F7GJ2.js} +1 -1
- package/dist/standalone/{chunk-DELDS72W.js → chunk-7OMB6F3L.js} +1 -1
- package/dist/standalone/{chunk-5QK3ZHNZ.js → chunk-7YHT6DLF.js} +1 -1
- package/dist/standalone/{chunk-K7GU4AIX.js → chunk-ABY6J4SX.js} +1 -1
- package/dist/standalone/{chunk-I7PUGF3D.js → chunk-APYV4J3H.js} +1 -1
- package/dist/standalone/{chunk-AY4DPAPO.js → chunk-B2QIV4WC.js} +1 -1
- package/dist/standalone/{chunk-X474JV2D.js → chunk-BCD7WQYW.js} +1 -1
- package/dist/standalone/{chunk-2VGEYQJ5.js → chunk-BIEYPLQZ.js} +1 -1
- package/dist/standalone/{chunk-UOFMFYZ7.js → chunk-BWS7JUQV.js} +2 -2
- package/dist/standalone/{chunk-UFFUDDK7.js → chunk-C6NIFA7C.js} +1 -1
- package/dist/standalone/{chunk-AWFFXR6S.js → chunk-CJ2V577P.js} +1 -1
- package/dist/standalone/{chunk-WONKLAKW.js → chunk-CNALVIPZ.js} +1 -1
- package/dist/standalone/{chunk-JQBZDS6X.js → chunk-D3MLU3PX.js} +1 -1
- package/dist/standalone/{chunk-2DKLUTH2.js → chunk-DKTTK2SX.js} +1 -1
- package/dist/standalone/{chunk-MTBY4GXM.js → chunk-DWNWEMQK.js} +1 -1
- package/dist/standalone/{chunk-NPZG7XK5.js → chunk-E52THCJJ.js} +1 -1
- package/dist/standalone/{chunk-ELWBGGS7.js → chunk-EU3IVSBQ.js} +1 -1
- package/dist/standalone/{chunk-YTLKHICM.js → chunk-FFECJKHB.js} +1 -1
- package/dist/standalone/{chunk-OVPS52RO.js → chunk-FKY2ID3J.js} +1 -1
- package/dist/standalone/{chunk-OR4RO6V4.js → chunk-FYSSF7AJ.js} +1 -1
- package/dist/standalone/{chunk-ZHZHI6KX.js → chunk-G7GMOSDG.js} +1 -1
- package/dist/standalone/{chunk-ZPQFM3A7.js → chunk-G7KYDZGL.js} +1 -1
- package/dist/standalone/{chunk-HBEZGCPB.js → chunk-GB7MHA6L.js} +1 -1
- package/dist/standalone/{chunk-KVQ2GMJR.js → chunk-HB2FLDDU.js} +1 -1
- package/dist/standalone/{chunk-3QNDJXLL.js → chunk-HFPX37U7.js} +1 -1
- package/dist/standalone/{chunk-WU2ST74V.js → chunk-HI3U4W6T.js} +1 -1
- package/dist/standalone/{chunk-MICDQTTJ.js → chunk-HPTF52JF.js} +1 -1
- package/dist/standalone/{chunk-VTTS5L36.js → chunk-I33WWIBV.js} +1 -1
- package/dist/standalone/{chunk-UUOEHNMP.js → chunk-IEOOQ2NW.js} +1 -1
- package/dist/standalone/{chunk-66IUCD6W.js → chunk-ILPLYMU4.js} +1 -1
- package/dist/standalone/{chunk-FKOAI6VV.js → chunk-IPRJMLLL.js} +1 -1
- package/dist/standalone/{chunk-DJPK4PZV.js → chunk-IW5TW36H.js} +1 -1
- package/dist/standalone/{chunk-4TGALJHR.js → chunk-J3ZEO3PJ.js} +1 -1
- package/dist/standalone/{chunk-4W7SB3SF.js → chunk-J5SYXVIK.js} +1 -1
- package/dist/standalone/{chunk-WVURFBJS.js → chunk-JPBTM43K.js} +1 -1
- package/dist/standalone/{chunk-SADHW6WJ.js → chunk-LFVPR2JB.js} +1 -1
- package/dist/standalone/{chunk-KXUK7CSR.js → chunk-MMRSSV2C.js} +1 -1
- package/dist/standalone/{chunk-MGYRQPAY.js → chunk-MT3K66QU.js} +1 -1
- package/dist/standalone/{chunk-A2LKDNNA.js → chunk-MVRBX7HB.js} +1 -1
- package/dist/standalone/{chunk-4E6DQHFK.js → chunk-N2XUTYZJ.js} +1 -1
- package/dist/standalone/{chunk-GCYQOJYI.js → chunk-NIIWN6ZY.js} +1 -1
- package/dist/standalone/{chunk-VGKDC2OQ.js → chunk-NVMQPIRS.js} +1 -1
- package/dist/standalone/{chunk-5NPU6VPX.js → chunk-OEHBCBV4.js} +1 -1
- package/dist/standalone/{chunk-V4JKKAAZ.js → chunk-OKZINWBB.js} +1 -1
- package/dist/standalone/{chunk-SBQT2ZSX.js → chunk-OVMZ7DXR.js} +1 -1
- package/dist/standalone/{chunk-RAJ327CY.js → chunk-PAFHBQFL.js} +1 -1
- package/dist/standalone/{chunk-AE3ABYCE.js → chunk-PAGLAE5H.js} +1 -1
- package/dist/standalone/{chunk-VJQP4ARP.js → chunk-PN7JHEYW.js} +1 -1
- package/dist/standalone/{chunk-JXUU3BD2.js → chunk-PQB2QX4Q.js} +1 -1
- package/dist/standalone/chunk-PUQ3LURH.js +1 -0
- package/dist/standalone/{chunk-LHQFTCOS.js → chunk-PXDQGWZR.js} +1 -1
- package/dist/standalone/{chunk-XSFGXEYO.js → chunk-Q4SE33KY.js} +1 -1
- package/dist/standalone/{chunk-O65QTRXU.js → chunk-Q6MWEK4M.js} +1 -1
- package/dist/standalone/{chunk-GDAZWXQW.js → chunk-QAETUNZX.js} +1 -1
- package/dist/standalone/{chunk-D2LGOQ32.js → chunk-QK4NIT57.js} +1 -1
- package/dist/standalone/{chunk-2KREOMPV.js → chunk-RAJO2KOX.js} +1 -1
- package/dist/standalone/{chunk-MULFKWTQ.js → chunk-RDYGUTWW.js} +1 -1
- package/dist/standalone/{chunk-NQ727GVM.js → chunk-S3TDGFRE.js} +1 -1
- package/dist/standalone/{chunk-4YEGXH2V.js → chunk-S7NFUY75.js} +1 -1
- package/dist/standalone/{chunk-ZBLG4UAV.js → chunk-SBJ4LWXW.js} +1 -1
- package/dist/standalone/{chunk-LYNQHGQ4.js → chunk-SFZ6IAL2.js} +1 -1
- package/dist/standalone/{chunk-XEIJUQ4B.js → chunk-SI5L5HDG.js} +1 -1
- package/dist/standalone/{chunk-IMM6HPPD.js → chunk-SNJ3ZOV2.js} +1 -1
- package/dist/standalone/{chunk-OOUGGYHQ.js → chunk-SRNRWSMY.js} +1 -1
- package/dist/standalone/{chunk-7MQQPZQC.js → chunk-THRRRMIZ.js} +1 -1
- package/dist/standalone/{chunk-ZZ6ZCOD4.js → chunk-TN4Z3P6S.js} +1 -1
- package/dist/standalone/{chunk-XOLTLG4I.js → chunk-TQH2BN2P.js} +1 -1
- package/dist/standalone/{chunk-JELTLAEP.js → chunk-U5YP7MSK.js} +1 -1
- package/dist/standalone/{chunk-DWKKQ75U.js → chunk-UDBPUH63.js} +1 -1
- package/dist/standalone/{chunk-RPRNYCFT.js → chunk-UHF224OV.js} +1 -1
- package/dist/standalone/{chunk-YL5ZAR3P.js → chunk-UN3QTZ6X.js} +1 -1
- package/dist/standalone/{chunk-F2DVDJV6.js → chunk-UV6GPH2E.js} +1 -1
- package/dist/standalone/{chunk-RK3HQKPW.js → chunk-V3A3775O.js} +1 -1
- package/dist/standalone/{chunk-Q7KRCKCE.js → chunk-VKX7HSAS.js} +1 -1
- package/dist/standalone/{chunk-274SZA4F.js → chunk-WDQDRE4G.js} +1 -1
- package/dist/standalone/{chunk-ML6YSDEQ.js → chunk-WEZRVKSV.js} +1 -1
- package/dist/standalone/{chunk-ZZA6VQDG.js → chunk-WKRUXQXB.js} +1 -1
- package/dist/standalone/{chunk-76D454G5.js → chunk-WSJTPPUQ.js} +1 -1
- package/dist/standalone/{chunk-3NYU3CCO.js → chunk-XUSA5BXI.js} +1 -1
- package/dist/standalone/{chunk-FPODRWDZ.js → chunk-YDDMKWPI.js} +1 -1
- package/dist/standalone/{chunk-XBHRAFJA.js → chunk-YNYH4P7E.js} +1 -1
- package/dist/standalone/{chunk-337EJGCU.js → chunk-ZO6OZV4D.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +3 -3
- package/dist/packem_shared/ApiDocsPanel-sEDqUNQq.mjs +0 -2
- package/dist/packem_shared/Studio-BmbkaUrx.mjs +0 -1
- package/dist/packem_shared/use-assistant-rpc-AKu8hvPm.mjs +0 -1
- package/dist/standalone/chunk-A4F3YMBV.js +0 -1
- package/dist/standalone/chunk-AQ6LY5RO.js +0 -14
- package/dist/standalone/chunk-KQVY73EU.js +0 -7
- package/dist/standalone/chunk-W3WGVJNJ.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as X}from"./chunk-CVSIFPI5.js";import{a as Q}from"./chunk-
|
|
1
|
+
import{a as X}from"./chunk-CVSIFPI5.js";import{a as Q}from"./chunk-N2XUTYZJ.js";import{d as O}from"./chunk-O5QATFN3.js";import{i as J}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as R}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import"./chunk-L27FKJTG.js";import"./chunk-LYVYUTQY.js";import"./chunk-UN3QTZ6X.js";import"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as H,s as Y,v as G}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as st}from"./chunk-A6TVTNKO.js";import{a as et,b as at}from"./chunk-ADABTCDI.js";import{a as u,d as V}from"./chunk-5PEAXTYQ.js";var B=V(st(),1);var d=V(at(),1);var z=V(et(),1);var nt=u(h=>{let t=(0,B.c)(28),{draft:e,onDraftChange:r,onSend:n,pending:a}=h,l=H(),s;t[0]!==l?(s=l("Ask about your data"),t[0]=l,t[1]=s):s=t[1];let o;t[2]!==r?(o=u(v=>{r(v.target.value)},"o"),t[2]=r,t[3]=o):o=t[3];let i;t[4]!==n?(i=u(v=>{v.key==="Enter"&&(v.preventDefault(),n())},"r"),t[4]=n,t[5]=i):i=t[5];let c;t[6]!==l?(c=l("Ask about your data"),t[6]=l,t[7]=c):c=t[7];let p;t[8]!==e||t[9]!==a||t[10]!==s||t[11]!==o||t[12]!==i||t[13]!==c?(p=(0,d.jsx)(J,{"aria-label":s,"data-testid":"assistant-input",disabled:a,onChange:o,onKeyDown:i,placeholder:c,value:e}),t[8]=e,t[9]=a,t[10]=s,t[11]=o,t[12]=i,t[13]=c,t[14]=p):p=t[14];let x;t[15]!==e||t[16]!==a?(x=a||e.trim()==="",t[15]=e,t[16]=a,t[17]=x):x=t[17];let m;t[18]!==a||t[19]!==l?(m=l(a?"Thinking\u2026":"Send"),t[18]=a,t[19]=l,t[20]=m):m=t[20];let f;t[21]!==n||t[22]!==x||t[23]!==m?(f=(0,d.jsx)(R,{"data-testid":"assistant-send",disabled:x,onClick:n,size:"xs",type:"button",children:m}),t[21]=n,t[22]=x,t[23]=m,t[24]=f):f=t[24];let g;return t[25]!==p||t[26]!==f?(g=(0,d.jsxs)("div",{className:"flex items-center gap-2 border-t border-border px-3 py-2",children:[p,f]}),t[25]=p,t[26]=f,t[27]=g):g=t[27],g},"nt"),lt=u(h=>{let t=(0,B.c)(17),{onClose:e}=h,r=H(),n;t[0]!==r?(n=r("Assistant"),t[0]=r,t[1]=n):n=t[1];let a;t[2]!==n?(a=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:n}),t[2]=n,t[3]=a):a=t[3];let l;t[4]!==r?(l=r("Answers are suggestions \u2014 nothing runs until you insert and run it."),t[4]=r,t[5]=l):l=t[5];let s;t[6]!==l?(s=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l}),t[6]=l,t[7]=s):s=t[7];let o;t[8]!==r?(o=r("Close assistant"),t[8]=r,t[9]=o):o=t[9];let i;t[10]!==e||t[11]!==o?(i=(0,d.jsx)(R,{"aria-label":o,className:"ms-auto","data-testid":"assistant-close",onClick:e,size:"xs",type:"button",variant:"ghost",children:"\xD7"}),t[10]=e,t[11]=o,t[12]=i):i=t[12];let c;return t[13]!==a||t[14]!==s||t[15]!==i?(c=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-3 py-1.5",children:[a,s,i]}),t[13]=a,t[14]=s,t[15]=i,t[16]=c):c=t[16],c},"lt"),ot={img:u(()=>null,"img")},Z=u(h=>{let t=(0,B.c)(2),{text:e}=h,r;return t[0]!==e?(r=(0,d.jsx)("div",{className:"prose-sm max-w-none text-xs","data-testid":"assistant-turn-body",children:(0,d.jsx)(O,{components:ot,children:e})}),t[0]=e,t[1]=r):r=t[1],r},"U"),_=u(h=>{let t=(0,B.c)(6),{children:e,label:r,testId:n}=h,a;t[0]!==r?(a=(0,d.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:r}),t[0]=r,t[1]=a):a=t[1];let l;return t[2]!==e||t[3]!==a||t[4]!==n?(l=(0,d.jsxs)("li",{className:"flex flex-col gap-1 border-b border-border px-3 py-2 last:border-b-0","data-testid":n,children:[a,e]}),t[2]=e,t[3]=a,t[4]=n,t[5]=l):l=t[5],l},"W"),rt=u(h=>{let t=(0,B.c)(7),{text:e}=h,r=H(),n;t[0]!==r?(n=r("Assistant"),t[0]=r,t[1]=n):n=t[1];let a;t[2]!==e?(a=(0,d.jsx)(Z,{text:e}),t[2]=e,t[3]=a):a=t[3];let l;return t[4]!==n||t[5]!==a?(l=(0,d.jsx)(_,{label:n,testId:"assistant-turn-live",children:a}),t[4]=n,t[5]=a,t[6]=l):l=t[6],l},"ot"),it=u(h=>{let t=(0,B.c)(20),{activeId:e,onDelete:r,onNew:n,onSelect:a,sessions:l}=h,s=H(),o;if(t[0]!==e||t[1]!==r||t[2]!==a||t[3]!==l||t[4]!==s){let x;t[6]!==e||t[7]!==r||t[8]!==a||t[9]!==l.length||t[10]!==s?(x=u(m=>(0,d.jsxs)("span",{className:"flex shrink-0 items-center",children:[(0,d.jsx)(R,{"data-testid":"assistant-session",onClick:u(()=>{a(m.id)},"onClick"),size:"xs",type:"button",variant:m.id===e?"secondary":"ghost",children:m.name}),l.length>1&&(0,d.jsx)(R,{"aria-label":s("Close chat"),"data-testid":"assistant-session-close",onClick:u(()=>{r(m.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:"\xD7"})]},m.id),"p"),t[6]=e,t[7]=r,t[8]=a,t[9]=l.length,t[10]=s,t[11]=x):x=t[11],o=l.map(x),t[0]=e,t[1]=r,t[2]=a,t[3]=l,t[4]=s,t[5]=o}else o=t[5];let i;t[12]!==s?(i=s("New chat"),t[12]=s,t[13]=i):i=t[13];let c;t[14]!==n||t[15]!==i?(c=(0,d.jsx)(R,{"aria-label":i,className:"shrink-0","data-testid":"assistant-session-new",onClick:n,size:"xs",type:"button",variant:"ghost",children:"+"}),t[14]=n,t[15]=i,t[16]=c):c=t[16];let p;return t[17]!==o||t[18]!==c?(p=(0,d.jsxs)("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border px-2 py-1","data-testid":"assistant-sessions",children:[o,c]}),t[17]=o,t[18]=c,t[19]=p):p=t[19],p},"at"),dt=u(h=>{let t=(0,B.c)(9),{reason:e,truncated:r}=h,n=H(),a;t[0]!==n||t[1]!==r?(a=r&&(0,d.jsx)("p",{className:"px-3 py-1 text-[11px] text-muted-foreground","data-testid":"assistant-truncated",children:n("Older turns were dropped to fit the context budget.")}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let l;t[3]!==e||t[4]!==n?(l=e!==void 0&&(0,d.jsx)("p",{className:"px-3 py-1 text-[11px] text-destructive","data-testid":"assistant-error",children:X(e,n)}),t[3]=e,t[4]=n,t[5]=l):l=t[5];let s;return t[6]!==a||t[7]!==l?(s=(0,d.jsxs)(d.Fragment,{children:[a,l]}),t[6]=a,t[7]=l,t[8]=s):s=t[8],s},"rt"),ct=u(h=>{let t=(0,B.c)(12),{onPick:e,suggestions:r}=h,n=H(),a;t[0]!==n?(a=n("Try asking"),t[0]=n,t[1]=a):a=t[1];let l;t[2]!==a?(l=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:a}),t[2]=a,t[3]=l):l=t[3];let s;if(t[4]!==e||t[5]!==r){let i;t[7]!==e?(i=u(c=>(0,d.jsx)("button",{className:"self-start rounded-md border border-border px-2 py-1 text-start text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"assistant-suggestion",onClick:u(()=>{e(c)},"onClick"),type:"button",children:c},c),"r"),t[7]=e,t[8]=i):i=t[8],s=r.map(i),t[4]=e,t[5]=r,t[6]=s}else s=t[6];let o;return t[9]!==l||t[10]!==s?(o=(0,d.jsxs)("div",{className:"flex flex-col gap-1 px-3 py-2","data-testid":"assistant-suggestions",children:[l,s]}),t[9]=l,t[10]=s,t[11]=o):o=t[11],o},"dt"),L="```",ut=u(h=>{if(h.startsWith(L))return h.slice(L.length).trim().toLowerCase()==="sql"?"sql":"foreign"},"ct"),pt=u(h=>{let t=[],e=h.split(`
|
|
2
2
|
`),r,n=!1;for(let a of e){let l=a.trim();if(n){n=l!==L;continue}if(r===void 0){let s=ut(l);s==="sql"?r=[]:s==="foreign"&&(n=!0);continue}if(l===L){let s=r.join(`
|
|
3
3
|
`).trim();s!==""&&t.push(s),r=void 0;continue}r.push(a)}return t},"ft"),mt=u(h=>{let t=(0,B.c)(29),{approval:e,onDecide:r}=h,n=H(),a;t[0]!==n?(a=n("The assistant wants to read rows before answering. Nothing runs until you allow it."),t[0]=n,t[1]=a):a=t[1];let l;t[2]!==a?(l=(0,d.jsx)("span",{className:"text-[11px] text-muted-foreground",children:a}),t[2]=a,t[3]=l):l=t[3];let s;t[4]!==e.sql?(s=(0,d.jsx)("pre",{className:"overflow-x-auto rounded bg-background p-1.5 font-mono text-[11px]","data-testid":"assistant-approval-sql",children:e.sql}),t[4]=e.sql,t[5]=s):s=t[5];let o;t[6]!==e||t[7]!==r?(o=u(()=>{r(!0,e)},"o"),t[6]=e,t[7]=r,t[8]=o):o=t[8];let i;t[9]!==n?(i=n("Allow"),t[9]=n,t[10]=i):i=t[10];let c;t[11]!==o||t[12]!==i?(c=(0,d.jsx)(R,{"data-testid":"assistant-approval-allow",onClick:o,size:"xs",type:"button",children:i}),t[11]=o,t[12]=i,t[13]=c):c=t[13];let p;t[14]!==e||t[15]!==r?(p=u(()=>{r(!1,e)},"f"),t[14]=e,t[15]=r,t[16]=p):p=t[16];let x;t[17]!==n?(x=n("Deny"),t[17]=n,t[18]=x):x=t[18];let m;t[19]!==p||t[20]!==x?(m=(0,d.jsx)(R,{"data-testid":"assistant-approval-deny",onClick:p,size:"xs",type:"button",variant:"secondary",children:x}),t[19]=p,t[20]=x,t[21]=m):m=t[21];let f;t[22]!==c||t[23]!==m?(f=(0,d.jsxs)("div",{className:"flex gap-2",children:[c,m]}),t[22]=c,t[23]=m,t[24]=f):f=t[24];let g;return t[25]!==f||t[26]!==l||t[27]!==s?(g=(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-muted/40 p-2","data-testid":"assistant-approval",children:[l,s,f]}),t[25]=f,t[26]=l,t[27]=s,t[28]=g):g=t[28],g},"ut"),xt=u(h=>{let t=(0,B.c)(15),{level:e,turn:r}=h,n=H(),a;t[0]!==r.toolCalls?(a=r.toolCalls??[],t[0]=r.toolCalls,t[1]=a):a=t[1];let l=a;if(l.length===0&&r.partial!==!0)return null;let s;if(t[2]!==l||t[3]!==e||t[4]!==n){let c;t[6]!==e||t[7]!==n?(c=u((p,x)=>(0,d.jsxs)("li",{children:[(0,d.jsx)("span",{className:"font-mono",children:p.name??n("(no such tool)")}),p.sql===void 0?null:(0,d.jsx)("span",{className:"ms-1 font-mono opacity-80",children:p.sql}),p.refused===void 0?null:(0,d.jsx)("span",{className:"ms-1 text-destructive",children:n("refused")}),p.needs===void 0?null:(0,d.jsx)("span",{className:"block text-muted-foreground","data-testid":"assistant-tool-needs",children:n("Needs the {needs} data-sharing level; this deployment is set to {level}. Change LUNORA_AI_OPT_IN in wrangler.jsonc.",{level:e??n("a lower level"),needs:p.needs})})]},`${String(x)}:${p.name??"?"}`),"d"),t[6]=e,t[7]=n,t[8]=c):c=t[8],s=l.map(c),t[2]=l,t[3]=e,t[4]=n,t[5]=s}else s=t[5];let o;t[9]!==n||t[10]!==r.partial?(o=r.partial===!0&&(0,d.jsx)("li",{"data-testid":"assistant-turn-partial",children:n("Stopped early \u2014 this answer is incomplete.")}),t[9]=n,t[10]=r.partial,t[11]=o):o=t[11];let i;return t[12]!==s||t[13]!==o?(i=(0,d.jsxs)("ul",{className:"flex flex-col gap-0.5 border-s border-border ps-2 text-[11px] text-muted-foreground","data-testid":"assistant-tool-calls",children:[s,o]}),t[12]=s,t[13]=o,t[14]=i):i=t[14],i},"pt"),ht=u(h=>{let t=(0,B.c)(60),{index:e,level:r,onBranch:n,onDecide:a,onInsert:l,onTruncate:s,turn:o}=h,i=H(),c,p,x,m,f;if(t[0]!==l||t[1]!==i||t[2]!==o.role||t[3]!==o.text){let $=o.role==="assistant"&&l!==void 0?pt(o.text):[];c=_,t[9]!==i||t[10]!==o.role?(p=o.role==="user"?i("You"):i("Assistant"),t[9]=i,t[10]=o.role,t[11]=p):p=t[11],x=`assistant-turn-${o.role}`,t[12]!==o.role||t[13]!==o.text?(m=o.role==="assistant"?(0,d.jsx)(Z,{text:o.text}):(0,d.jsx)("p",{className:"text-xs whitespace-pre-wrap","data-testid":"assistant-turn-body",children:o.text}),t[12]=o.role,t[13]=o.text,t[14]=m):m=t[14];let F;t[15]!==l||t[16]!==i?(F=u((T,j)=>(0,d.jsx)(R,{className:"self-start","data-testid":"assistant-insert",onClick:u(()=>{l?.(T)},"onClick"),size:"xs",type:"button",variant:"secondary",children:i("Insert into editor")},`${String(j)}:${T.slice(0,32)}`),"R"),t[15]=l,t[16]=i,t[17]=F):F=t[17],f=$.map(F),t[0]=l,t[1]=i,t[2]=o.role,t[3]=o.text,t[4]=c,t[5]=p,t[6]=x,t[7]=m,t[8]=f}else c=t[4],p=t[5],x=t[6],m=t[7],f=t[8];let g;t[18]!==a||t[19]!==o.pendingApproval?(g=o.pendingApproval!==void 0&&a!==void 0&&(0,d.jsx)(mt,{approval:o.pendingApproval,onDecide:a}),t[18]=a,t[19]=o.pendingApproval,t[20]=g):g=t[20];let v;t[21]!==r||t[22]!==o?(v=o.role==="assistant"&&(0,d.jsx)(xt,{level:r,turn:o}),t[21]=r,t[22]=o,t[23]=v):v=t[23];let S;t[24]!==o.text?(S=u(()=>{G(o.text)},"q"),t[24]=o.text,t[25]=S):S=t[25];let q;t[26]!==i?(q=i("Copy"),t[26]=i,t[27]=q):q=t[27];let k;t[28]!==S||t[29]!==q?(k=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-copy",onClick:S,type:"button",children:q}),t[28]=S,t[29]=q,t[30]=k):k=t[30];let y;t[31]!==e||t[32]!==n?(y=u(()=>{n(e)},"y"),t[31]=e,t[32]=n,t[33]=y):y=t[33];let b;t[34]!==i?(b=i("Branch from here"),t[34]=i,t[35]=b):b=t[35];let w;t[36]!==y||t[37]!==b?(w=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-branch",onClick:y,type:"button",children:b}),t[36]=y,t[37]=b,t[38]=w):w=t[38];let N;t[39]!==e||t[40]!==s?(N=u(()=>{s(e)},"k"),t[39]=e,t[40]=s,t[41]=N):N=t[41];let I;t[42]!==i?(I=i("Delete from here"),t[42]=i,t[43]=I):I=t[43];let A;t[44]!==N||t[45]!==I?(A=(0,d.jsx)("button",{className:"underline outline-none focus-visible:ring-1 focus-visible:ring-ring","data-testid":"assistant-truncate",onClick:N,type:"button",children:I}),t[44]=N,t[45]=I,t[46]=A):A=t[46];let C;t[47]!==w||t[48]!==A||t[49]!==k?(C=(0,d.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-muted-foreground",children:[k,w,A]}),t[47]=w,t[48]=A,t[49]=k,t[50]=C):C=t[50];let P;return t[51]!==c||t[52]!==p||t[53]!==C||t[54]!==x||t[55]!==m||t[56]!==f||t[57]!==g||t[58]!==v?(P=(0,d.jsxs)(c,{label:p,testId:x,children:[m,f,g,v,C]}),t[51]=c,t[52]=p,t[53]=C,t[54]=x,t[55]=m,t[56]=f,t[57]=g,t[58]=v,t[59]=P):P=t[59],P},"ht"),ft=u(({assistant:h,ops:t,session:e})=>{let[r,n]=(0,z.useState)(""),[a,l]=(0,z.useState)(e?.id);e?.id!==a&&(l(e?.id),n(""));let[s,o]=(0,z.useState)(void 0),[i,c]=(0,z.useState)(void 0),[p,x]=(0,z.useState)(void 0),[m,f]=(0,z.useState)(void 0),g=(0,z.useRef)(void 0);(0,z.useEffect)(()=>()=>{g.current?.abort()},[]);let v=t.pending("chat"),S=t.reason("chat"),{setTurns:q,takeAsk:k,unavailable:y}=h,b=e?.id,w=S==="ai-disabled"||S==="no-ai-binding"||p===b?S:void 0,N=u(T=>{b!==void 0&&h.branchFrom(b,T)},"k"),I=u(T=>{b!==void 0&&h.truncateFrom(b,T)},"A"),A=u((T,j,K)=>{if(T===""||v||g.current!==void 0||e===void 0)return;let E=new AbortController;g.current=E;let W={role:"user",text:T},tt=[...j,W];q(e.id,tt),o({sessionId:e.id,text:""}),x(e.id),Y(t.chat(T,j.map(D=>({role:D.role,text:D.text})),e.schema,K,D=>{o(M=>M?.sessionId===e.id?{sessionId:e.id,text:D.type==="delta"?`${M.text}${D.text}`:""}:M)},E.signal).then(D=>{if(D!==void 0&&!E.signal.aborted){c(D.truncated?e.id:void 0);let M={partial:D.partial,...D.pendingApproval===void 0?{}:{pendingApproval:D.pendingApproval},role:"assistant",text:D.reply,toolCalls:D.toolCalls};q(e.id,U=>U.at(-1)===W?[...U,M]:U)}return D}).finally(()=>{g.current=void 0,o(void 0)}))},"I"),C=u(T=>{let j=(T??r).trim();j===""||v||g.current!==void 0||e===void 0||(n(""),A(j,e.turns))},"C"),P=u((T,j)=>{if(e===void 0||v||g.current!==void 0)return;let K=e.turns.slice(0,-1),E=K.at(-1);E?.role==="user"&&A(E.text,K.slice(0,-1),{allow:T,sql:j.sql,ticket:j.ticket})},"F"),$=h.draft;$!==void 0&&$.id!==m&&(f($.id),n($.text));let F=h.pendingAsk;return(0,z.useEffect)(()=>{F===void 0||F.sessionId!==b||v||y||(k(F.id),queueMicrotask(()=>{C(F.text)}))},[F,b,k,v,y]),{branchHere:N,decide:P,draft:r,live:s,pending:v,reason:w,send:C,setDraft:n,truncatedFor:i,truncateHere:I}},"mt"),Zt=u(h=>{let t=(0,B.c)(39),{assistant:e}=h,r=H(),n;t[0]!==e.activeId?(n=u(C=>C.id===e.activeId,"l"),t[0]=e.activeId,t[1]=n):n=t[1];let a=e.sessions.find(n),l=Q(a?.shardKey??""),s=ft({assistant:e,ops:l,session:a});if(l.unavailable||a===void 0)return null;let{turns:o}=a,i;t[2]!==r?(i=r("Assistant"),t[2]=r,t[3]=i):i=t[3];let c="flex h-full w-96 min-w-0 shrink-0 flex-col border-s border-border bg-card",p="assistant-panel",x;t[4]!==e.close?(x=(0,d.jsx)(lt,{onClose:e.close}),t[4]=e.close,t[5]=x):x=t[5];let m;t[6]!==e||t[7]!==r?(m=u(()=>{e.newChat({title:r("New chat")})},"u"),t[6]=e,t[7]=r,t[8]=m):m=t[8];let f;t[9]!==e.activeId||t[10]!==e.deleteChat||t[11]!==e.selectChat||t[12]!==e.sessions||t[13]!==m?(f=(0,d.jsx)(it,{activeId:e.activeId,onDelete:e.deleteChat,onNew:m,onSelect:e.selectChat,sessions:e.sessions}),t[9]=e.activeId,t[10]=e.deleteChat,t[11]=e.selectChat,t[12]=e.sessions,t[13]=m,t[14]=f):f=t[14];let g=o.length===0&&a.suggestions.length>0&&(0,d.jsx)(ct,{onPick:u(C=>{s.send(C)},"onPick"),suggestions:a.suggestions}),v="min-h-0 flex-1 overflow-y-auto",S="assistant-turns",q=o.map((C,P)=>(0,d.jsx)(ht,{index:P,level:l.level,onBranch:s.branchHere,onDecide:P===o.length-1?s.decide:void 0,onInsert:e.hasEditor?e.requestInsert:void 0,onTruncate:s.truncateHere,turn:C},`${String(P)}:${C.role}`)),k;t[15]!==s.live||t[16]!==a.id?(k=s.live?.sessionId===a.id&&s.live.text!==""&&(0,d.jsx)(rt,{text:s.live.text}),t[15]=s.live,t[16]=a.id,t[17]=k):k=t[17];let y;t[18]!==q||t[19]!==k?(y=(0,d.jsxs)("ul",{className:v,"data-testid":S,children:[q,k]}),t[18]=q,t[19]=k,t[20]=y):y=t[20];let b=s.truncatedFor===a.id,w;t[21]!==s.reason||t[22]!==b?(w=(0,d.jsx)(dt,{reason:s.reason,truncated:b}),t[21]=s.reason,t[22]=b,t[23]=w):w=t[23];let N;t[24]!==s?(N=u(()=>{s.send()},"k"),t[24]=s,t[25]=N):N=t[25];let I;t[26]!==s.draft||t[27]!==s.pending||t[28]!==s.setDraft||t[29]!==N?(I=(0,d.jsx)(nt,{draft:s.draft,onDraftChange:s.setDraft,onSend:N,pending:s.pending}),t[26]=s.draft,t[27]=s.pending,t[28]=s.setDraft,t[29]=N,t[30]=I):I=t[30];let A;return t[31]!==y||t[32]!==w||t[33]!==I||t[34]!==i||t[35]!==x||t[36]!==f||t[37]!==g?(A=(0,d.jsxs)("section",{"aria-label":i,className:c,"data-testid":p,children:[x,f,g,y,w,I]}),t[31]=y,t[32]=w,t[33]=I,t[34]=i,t[35]=x,t[36]=f,t[37]=g,t[38]=A):A=t[38],A},"It");export{Zt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as L}from"./chunk-
|
|
1
|
+
import{a as L}from"./chunk-RAJO2KOX.js";import"./chunk-76CCNRPQ.js";import{a as z}from"./chunk-HPTF52JF.js";import{a as R}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as E}from"./chunk-S3TDGFRE.js";import"./chunk-L27FKJTG.js";import{a as O,b as F,c as H,d as k,e as r,f as n}from"./chunk-J3ZEO3PJ.js";import{b as j}from"./chunk-UN3QTZ6X.js";import{a as T,e as $}from"./chunk-TN4Z3P6S.js";import{n as I}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B,s as S,w as C}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as G}from"./chunk-A6TVTNKO.js";import{a as D,b as J}from"./chunk-ADABTCDI.js";import{a as f,d as y}from"./chunk-5PEAXTYQ.js";var P=y(G(),1),Q=y(D(),1);var s=y(J(),1);var w=200,se=f(()=>{let e=(0,P.c)(28),d=I(),a=B(),[l,q]=(0,Q.useState)(0),p;e[0]!==l?(p=["lunora-auth-sessions",w,l],e[0]=l,e[1]=p):p=e[1];let x;e[2]!==d||e[3]!==l?(x=f(()=>d.listAuthSessions({limit:w,offset:l}),"p"),e[2]=d,e[3]=l,e[4]=x):x=e[4];let o=j(p,x),{error:g}=o,t=o.data?.rows??null,N;e[5]!==o?(N=f(()=>o.poll(),"b"),e[5]=o,e[6]=N):N=e[6],z(N,!0);let v;e[7]!==d||e[8]!==o?(v=f(i=>{S((async()=>{await d.revokeAuthSession({sessionId:i}),o.refetch()})())},"g"),e[7]=d,e[8]=o,e[9]=v):v=e[9];let b=v,c;e[10]!==g?(c=g!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:g}),e[10]=g,e[11]=c):c=e[11];let m;e[12]!==t||e[13]!==a?(m=t!==null&&t.length===0&&(0,s.jsx)(E,{testId:"auth-sessions-empty",title:a("No active sessions.")}),e[12]=t,e[13]=a,e[14]=m):m=e[14];let h;e[15]!==b||e[16]!==t||e[17]!==a?(h=t!==null&&t.length>0&&(0,s.jsx)(T,{className:"overflow-hidden py-0",children:(0,s.jsx)($,{className:"px-0",children:(0,s.jsxs)(O,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)(F,{children:(0,s.jsxs)(k,{children:[(0,s.jsx)(r,{children:a("user")}),(0,s.jsx)(r,{children:a("expires")}),(0,s.jsx)(r,{children:a("ip")}),(0,s.jsx)(r,{children:a("user agent")}),(0,s.jsx)(r,{children:a("impersonated by")}),(0,s.jsx)(r,{"aria-label":a("Actions")})]})}),(0,s.jsx)(H,{children:t.map(i=>(0,s.jsxs)(k,{"data-testid":`auth-session-${i.id}`,children:[(0,s.jsx)(n,{className:"font-mono text-xs",children:i.userId}),(0,s.jsx)(n,{className:"text-muted-foreground tabular-nums",children:C(i.expiresAt)}),(0,s.jsx)(n,{children:i.ipAddress??""}),(0,s.jsx)(n,{className:"max-w-40 truncate",children:i.userAgent??""}),(0,s.jsx)(n,{className:"font-mono text-xs",children:i.impersonatedBy??""}),(0,s.jsx)(n,{children:(0,s.jsx)(R,{"data-testid":`auth-session-revoke-${i.id}`,onClick:f(()=>{b(i.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[15]=b,e[16]=t,e[17]=a,e[18]=h):h=e[18];let u;e[19]!==l||e[20]!==t||e[21]!==o.data?.total?(u=t!==null&&(0,s.jsx)(L,{count:t.length,offset:l,onOffsetChange:q,pageSize:w,prefix:"auth-sessions",total:o.data?.total}),e[19]=l,e[20]=t,e[21]=o.data?.total,e[22]=u):u=e[22];let A;return e[23]!==c||e[24]!==m||e[25]!==h||e[26]!==u?(A=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[c,m,h,u]}),e[23]=c,e[24]=m,e[25]=h,e[26]=u,e[27]=A):A=e[27],A},"ee");export{se as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as qe}from"./chunk-FKOAI6VV.js";import{a as Je}from"./chunk-ZPQFM3A7.js";import{a as Ge}from"./chunk-2KREOMPV.js";import{a as Ze}from"./chunk-KXUK7CSR.js";import"./chunk-O4SDDSDL.js";import{a as He}from"./chunk-IMM6HPPD.js";import{a as W}from"./chunk-AWFFXR6S.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-MICDQTTJ.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-V4JKKAAZ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-VGKDC2OQ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-NQ727GVM.js";import{b as X}from"./chunk-F2DVDJV6.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-4TGALJHR.js";import{b as je}from"./chunk-YL5ZAR3P.js";import{a as ie,e as ne}from"./chunk-ZZ6ZCOD4.js";import{n as le}from"./chunk-KQVY73EU.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-VJQP4ARP.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
|
|
1
|
+
import{a as qe}from"./chunk-IPRJMLLL.js";import{a as Je}from"./chunk-G7KYDZGL.js";import{a as Ge}from"./chunk-RAJO2KOX.js";import{a as Ze}from"./chunk-MMRSSV2C.js";import"./chunk-76CCNRPQ.js";import{a as He}from"./chunk-SNJ3ZOV2.js";import{a as W}from"./chunk-CJ2V577P.js";import{a as Xe}from"./chunk-DRHZZ7IN.js";import{a as We}from"./chunk-HPTF52JF.js";import"./chunk-QHVUXMRV.js";import"./chunk-2NUCBQFU.js";import{i as q}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as K}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as Me}from"./chunk-S3TDGFRE.js";import{b as X}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as Pe,b as Re,c as Be,d as Q,e as _,f as U}from"./chunk-J3ZEO3PJ.js";import{b as je}from"./chunk-UN3QTZ6X.js";import{a as ie,e as ne}from"./chunk-TN4Z3P6S.js";import{n as le}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as J,j as Ee,r as ee,s as te,u as Qe,w as ae}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as it}from"./chunk-A6TVTNKO.js";import{a as lt,b as nt}from"./chunk-ADABTCDI.js";import{a as r,d as Te}from"./chunk-5PEAXTYQ.js";var w=Te(lt(),1);var Z=Te(it(),1);var t=Te(nt(),1);var st=r(()=>{let h=(0,Z.c)(3),{config:e,ready:n}=qe(),l;return h[0]!==e.capabilities||h[1]!==n?(l={capabilities:e.capabilities,ready:n},h[0]=e.capabilities,h[1]=n,h[2]=l):l=h[2],l},"lt"),rt=r((h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending","it"),et=500,dt=r((h,e)=>{if(!URL.canParse(h.trim()))return null;let n=new URL(h.trim());return n.searchParams.set("email",e.email),n.searchParams.set("invite",e.token),n.toString()},"at"),ot=r(h=>{let e=(0,Z.c)(34),{issued:n,onSignUpPageChange:l,signUpPage:d}=h,a=J(),[u,i]=(0,w.useState)(null),s;e[0]!==n||e[1]!==d?(s=dt(d,n),e[0]=n,e[1]=d,e[2]=s):s=e[2];let c=s,f;e[3]!==c?(f=r(()=>{let L="navigator"in globalThis?globalThis.navigator.clipboard:void 0;c===null||L===void 0||te(L.writeText(c).then(()=>(i(c),!0)))},"p"),e[3]=c,e[4]=f):f=e[4];let N=f,b;e[5]!==a?(b=a("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=a,e[6]=b):b=e[6];let F;e[7]!==b?(F=(0,t.jsx)("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];let C=c===null,v;e[9]!==a?(v=a("Your app's sign-up page"),e[9]=a,e[10]=v):v=e[10];let m;e[11]!==l?(m=r(L=>{l(L.target.value)},"u"),e[11]=l,e[12]=m):m=e[12];let p;e[13]!==d||e[14]!==C||e[15]!==v||e[16]!==m?(p=(0,t.jsx)(q,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:m,value:d}),e[13]=d,e[14]=C,e[15]=v,e[16]=m,e[17]=p):p=e[17];let x=c??"",y;e[18]!==x?(y=(0,t.jsx)(q,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==u||e[21]!==c||e[22]!==a?(k=a(u!==null&&u===c?"Copied":"Copy"),e[20]=u,e[21]=c,e[22]=a,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=(0,t.jsx)(K,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=(0,t.jsxs)("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==p?(S=(0,t.jsx)(ie,{children:(0,t.jsxs)(ne,{className:"flex flex-col gap-2 p-4",children:[F,p,o]})}),e[30]=o,e[31]=F,e[32]=p,e[33]=S):S=e[33],S},"rt"),ct=r(()=>{let h=le(),e=J(),[n,l]=(0,w.useState)(""),[d,a]=(0,w.useState)(null),[u,i]=(0,w.useState)(null),[s,c]=(0,w.useState)(()=>`${Qe(h.url)}/sign-up`),f=je(["lunora-auth-sign-up-invitations",et],()=>h.listAuthSignUpInvitations({limit:et})),N=f.data?.rows??null,b=f.data?.total??0,F=r(()=>{let v=n.trim();v!==""&&(a(null),te((async()=>{try{let m=await h.createAuthSignUpInvitation({email:v}),p=typeof m.token=="string"?m.token:void 0;i(p===void 0?null:{email:v,token:p}),l(""),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})()))},"F"),C=r(v=>{a(null),te((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),f.refetch()}catch(m){a(m instanceof Error?m.message:String(m))}})())},"C");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed \u2014 send the invitee the one-time link yourself.")})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(q,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:r(v=>{l(v.target.value)},"onChange"),placeholder:e("ada@example.com"),type:"email",value:n}),(0,t.jsx)(K,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),u!==null&&(0,t.jsx)(ot,{issued:u,onSignUpPageChange:c,signUpPage:s},u.token),(d??f.error)!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:d??f.error}),N!==null&&N.length===0&&(0,t.jsx)(Me,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),N!==null&&N.length>0&&(0,t.jsx)(ie,{children:(0,t.jsx)(ne,{className:"p-0",children:(0,t.jsxs)(Pe,{children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:e("Email")}),(0,t.jsx)(_,{children:e("Status")}),(0,t.jsx)(_,{children:e("Expires")}),(0,t.jsx)(_,{children:e("Invited by")}),(0,t.jsx)(_,{})]})}),(0,t.jsx)(Be,{children:N.map(v=>{let m=rt(v,Date.now()),p=v.email??"";return(0,t.jsxs)(Q,{"data-testid":`sign-up-invitation-${p}`,children:[(0,t.jsx)(U,{children:p}),(0,t.jsxs)(U,{"data-testid":`sign-up-invitation-status-${p}`,children:[m==="spent"&&e("Accepted"),m==="expired"&&e("Expired"),m==="pending"&&e("Pending")]}),(0,t.jsx)(U,{children:typeof v.expiresAt=="number"?ae(v.expiresAt):"\u2014"}),(0,t.jsx)(U,{children:v.invitedBy??"\u2014"}),(0,t.jsx)(U,{className:"text-right",children:(0,t.jsx)(K,{onClick:r(()=>{C(p)},"onClick"),type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},"ot"),ut={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},mt=r((h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),"ct"),ht=r((h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;let n=typeof e=="string"?e.trim():"";if(n!==""){if(h.type==="number"){let l=Number(n);return Number.isNaN(l)?void 0:{value:l}}return{value:n}}},"ut"),pt=r(h=>{let e=(0,Z.c)(105),{onClose:n,onCreated:l}=h,d=le(),a=J(),{config:u}=qe(),{busy:i,error:s,run:c}=Je(),[f,N]=(0,w.useState)(""),[b,F]=(0,w.useState)(""),[C,v]=(0,w.useState)(""),[m,p]=(0,w.useState)(""),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let[y,k]=(0,w.useState)(x),g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=r(A=>{N(A.target.value)},"g"),e[1]=g):g=e[1];let o=g,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=r(A=>{F(A.target.value)},"S"),e[2]=S):S=e[2];let L=S,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(E=r(A=>{v(A.target.value)},"z"),e[3]=E):E=e[3];let H=E,j;e[4]===Symbol.for("react.memo_cache_sentinel")?(j=r(A=>{p(A.target.value)},"M"),e[4]=j):j=e[4];let Y=j,B;e[5]===Symbol.for("react.memo_cache_sentinel")?(B=r((A,M)=>{k(se=>({...se,[A]:M}))},"D"),e[5]=B):B=e[5];let O=B,T;e[6]!==y?(T=r(A=>y[A.name]??(A.type==="boolean"?!1:""),"O"),e[6]=y,e[7]=T):T=e[7];let z=T,$;if(e[8]!==u.userFields||e[9]!==z){let A;e[11]!==z?(A=r(M=>!M.required||mt(M,z(M)),"A"),e[11]=z,e[12]=A):A=e[12],$=u.userFields.every(A),e[8]=u.userFields,e[9]=z,e[10]=$}else $=e[10];let I=$,P;e[13]!==i||e[14]!==f||e[15]!==b||e[16]!==I?(P=!i&&f.trim()!==""&&b.trim()!==""&&I,e[13]=i,e[14]=f,e[15]=b,e[16]=I,e[17]=P):P=e[17];let V=P,G;e[18]!==u.userFields||e[19]!==z?(G=r(()=>{let A={};for(let M of u.userFields){let se=ht(M,z(M));se!==void 0&&(A[M.name]=se.value)}return Object.keys(A).length===0?void 0:A},"Q"),e[18]=u.userFields,e[19]=z,e[20]=G):G=e[20];let R=G,D;e[21]!==R||e[22]!==d||e[23]!==f||e[24]!==b||e[25]!==n||e[26]!==l||e[27]!==C||e[28]!==m||e[29]!==c?(D=r(()=>{c(async()=>{await d.createAuthUser({data:R(),email:f.trim(),name:b.trim(),password:C===""?void 0:C,role:m.trim()===""?void 0:m.trim()}),l(),n()})},"L"),e[21]=R,e[22]=d,e[23]=f,e[24]=b,e[25]=n,e[26]=l,e[27]=C,e[28]=m,e[29]=c,e[30]=D):D=e[30];let Oe=D,re;e[31]!==a?(re=a("Create user"),e[31]=a,e[32]=re):re=e[32];let de;e[33]!==a?(de=a("Create user"),e[33]=a,e[34]=de):de=e[34];let oe;e[35]!==de?(oe=(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:de}),e[35]=de,e[36]=oe):oe=e[36];let ce;e[37]!==a?(ce=a("email"),e[37]=a,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=(0,t.jsx)(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==f?(me=(0,t.jsx)(q,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:f}),e[41]=f,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let pe;e[46]!==a?(pe=a("name"),e[46]=a,e[47]=pe):pe=e[47];let fe;e[48]!==pe?(fe=(0,t.jsx)(W,{htmlFor:"uc-name",children:pe}),e[48]=pe,e[49]=fe):fe=e[49];let ve;e[50]!==b?(ve=(0,t.jsx)(q,{"data-testid":"uc-name",id:"uc-name",onChange:L,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==fe||e[53]!==ve?(ge=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[fe,ve]}),e[52]=fe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==a?(ye=a("Password (optional)"),e[55]=a,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=(0,t.jsx)(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=(0,t.jsx)(q,{"data-testid":"uc-password",id:"uc-password",onChange:H,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==a?(ke=a("Role (optional)"),e[64]=a,e[65]=ke):ke=e[65];let we;e[66]!==ke?(we=(0,t.jsx)(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=we):we=e[67];let Ce;e[68]!==m?(Ce=(0,t.jsx)(q,{"data-testid":"uc-role",id:"uc-role",onChange:Y,value:m}),e[68]=m,e[69]=Ce):Ce=e[69];let Ie;e[70]!==we||e[71]!==Ce?(Ie=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[we,Ce]}),e[70]=we,e[71]=Ce,e[72]=Ie):Ie=e[72];let Ae;e[73]!==u.userFields||e[74]!==z||e[75]!==a?(Ae=u.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")}),u.userFields.map(A=>{let M=`uc-field-${A.name}`,se=A.required?"":` (${a("optional")})`;if(A.type==="boolean"){let Le=z(A)===!0;return(0,t.jsxs)("label",{className:"flex items-center gap-2",htmlFor:M,children:[(0,t.jsx)(Ze,{checked:Le,"data-testid":M,id:M,onCheckedChange:r(at=>{O(A.name,at)},"onCheckedChange")}),(0,t.jsxs)("span",{className:"text-sm",children:[A.name,se]})]},A.name)}let Ve=z(A);return(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(W,{htmlFor:M,children:[A.name,se]}),(0,t.jsx)(q,{"data-testid":M,id:M,onChange:r(Le=>{O(A.name,Le.target.value)},"onChange"),type:ut[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=u.userFields,e[74]=z,e[75]=a,e[76]=Ae):Ae=e[76];let Se;e[77]!==s?(Se=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:s}),e[77]=s,e[78]=Se):Se=e[78];let Fe;e[79]!==a?(Fe=a("Cancel"),e[79]=a,e[80]=Fe):Fe=e[80];let Ue;e[81]!==n||e[82]!==Fe?(Ue=(0,t.jsx)(K,{"data-testid":"uc-cancel",onClick:n,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=n,e[82]=Fe,e[83]=Ue):Ue=e[83];let De=!V,ze;e[84]!==i||e[85]!==a?(ze=a(i?"Creating\u2026":"Create"),e[84]=i,e[85]=a,e[86]=ze):ze=e[86];let Ke;e[87]!==Oe||e[88]!==De||e[89]!==ze?(Ke=(0,t.jsx)(K,{"data-testid":"uc-submit",disabled:De,onClick:Oe,size:"sm",type:"button",children:ze}),e[87]=Oe,e[88]=De,e[89]=ze,e[90]=Ke):Ke=e[90];let _e;e[91]!==Ue||e[92]!==Ke?(_e=(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Ke]}),e[91]=Ue,e[92]=Ke,e[93]=_e):_e=e[93];let $e;return e[94]!==n||e[95]!==re||e[96]!==oe||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ie||e[101]!==Ae||e[102]!==Se||e[103]!==_e?($e=(0,t.jsxs)(He,{label:re,onClose:n,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[oe,he,ge,Ne,Ie,Ae,Se,_e]}),e[94]=n,e[95]=re,e[96]=oe,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ie,e[101]=Ae,e[102]=Se,e[103]=_e,e[104]=$e):$e=e[104],$e},"mt"),Ye=r(h=>{let e=(0,Z.c)(2),{children:n}=h,l;return e[0]!==n?(l=(0,t.jsx)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n}),e[0]=n,e[1]=l):l=e[1],l},"Me"),tt=r(h=>{let e=(0,Z.c)(15),{children:n,columns:l,testId:d}=h,a=J(),u;e[0]!==l?(u=l.map(yt),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==a?(i=a("Actions"),e[2]=a,e[3]=i):i=e[3];let s;e[4]!==i?(s=(0,t.jsx)(_,{"aria-label":i}),e[4]=i,e[5]=s):s=e[5];let c;e[6]!==u||e[7]!==s?(c=(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[u,s]})}),e[6]=u,e[7]=s,e[8]=c):c=e[8];let f;e[9]!==n?(f=(0,t.jsx)(Be,{children:n}),e[9]=n,e[10]=f):f=e[10];let N;return e[11]!==c||e[12]!==f||e[13]!==d?(N=(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":d,children:[c,f]})})}),e[11]=c,e[12]=f,e[13]=d,e[14]=N):N=e[14],N},"qe"),ft=r(h=>{let e=(0,Z.c)(29),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{let o=await u.listAuthSessions({limit:50,userId:d});c(o.rows)}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l?(C=r(o=>{l(()=>u.revokeAuthSession({sessionId:o}))},"C"),e[7]=u,e[8]=l,e[9]=C):C=e[9];let v=C,m;e[10]!==i?(m=i("Sessions"),e[10]=i,e[11]=m):m=e[11];let p;e[12]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[12]=m,e[13]=p):p=e[13];let x;e[14]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:f}),e[14]=f,e[15]=x):x=e[15];let y;e[16]!==s||e[17]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:i("No active sessions.")}),e[16]=s,e[17]=i,e[18]=y):y=e[18];let k;e[19]!==n||e[20]!==v||e[21]!==s||e[22]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-sessions-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("expires")}),(0,t.jsx)(_,{children:i("ip")}),(0,t.jsx)(_,{children:i("user agent")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>(0,t.jsxs)(Q,{"data-testid":`ud-session-${o.id}`,children:[(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.expiresAt)}),(0,t.jsx)(U,{children:o.ipAddress??""}),(0,t.jsx)(U,{className:"max-w-40 truncate",children:o.userAgent??""}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-${o.id}`,disabled:n,onClick:r(()=>{v(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Revoke")})})]},o.id))})]})})}),e[19]=n,e[20]=v,e[21]=s,e[22]=i,e[23]=k):k=e[23];let g;return e[24]!==p||e[25]!==x||e[26]!==y||e[27]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,y,k]}),e[24]=p,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},"ht"),vt=r(h=>{let e=(0,Z.c)(30),{busy:n,runAction:l,userId:d,version:a}=h,u=le(),i=J(),[s,c]=(0,w.useState)(null),[f,N]=(0,w.useState)(null),b;e[0]!==u||e[1]!==d?(b=r(()=>{te((async()=>{N(null);try{c(await u.listAuthAccounts({userId:d}))}catch(o){let S=o;c(null),N(Ee(S))}})())},"b"),e[0]=u,e[1]=d,e[2]=b):b=e[2];let F;e[3]!==u||e[4]!==d||e[5]!==a?(F=[u,d,a],e[3]=u,e[4]=d,e[5]=a,e[6]=F):F=e[6],(0,w.useEffect)(b,F);let C;e[7]!==u||e[8]!==l||e[9]!==d?(C=r(o=>{l(()=>u.unlinkAuthAccount({accountId:o,userId:d}))},"C"),e[7]=u,e[8]=l,e[9]=d,e[10]=C):C=e[10];let v=C,m;e[11]!==i?(m=i("Linked accounts"),e[11]=i,e[12]=m):m=e[12];let p;e[13]!==m?(p=(0,t.jsx)(Ye,{children:m}),e[13]=m,e[14]=p):p=e[14];let x;e[15]!==f?(x=f!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:f}),e[15]=f,e[16]=x):x=e[16];let y;e[17]!==s||e[18]!==i?(y=s!==null&&s.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:i("No linked accounts.")}),e[17]=s,e[18]=i,e[19]=y):y=e[19];let k;e[20]!==s||e[21]!==n||e[22]!==v||e[23]!==i?(k=s!==null&&s.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"ud-accounts-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:i("provider")}),(0,t.jsx)(_,{children:i("created")}),(0,t.jsx)(_,{"aria-label":i("Actions")})]})}),(0,t.jsx)(Be,{children:s.map(o=>{let S=ee(o.id);return(0,t.jsxs)(Q,{"data-testid":`ud-account-${S}`,children:[(0,t.jsx)(U,{children:ee(o.providerId)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-unlink-${S}`,disabled:n,onClick:r(()=>{v(S)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Unlink")})})]},S)})})]})})}),e[20]=s,e[21]=n,e[22]=v,e[23]=i,e[24]=k):k=e[24];let g;return e[25]!==p||e[26]!==x||e[27]!==y||e[28]!==k?(g=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,y,k]}),e[25]=p,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},"ft"),gt=r(h=>{let e=(0,Z.c)(71),{busy:n,capabilities:l,runAction:d,userId:a,version:u}=h,i=le(),s=J(),[c,f]=(0,w.useState)(null),[N,b]=(0,w.useState)(null),[F,C]=(0,w.useState)(null),[v,m]=(0,w.useState)(0),p;e[0]!==l.apiKey||e[1]!==i||e[2]!==a?(p=r(()=>{if(!l.apiKey)return;let R={live:!0};return te((async()=>{try{let D=await i.listAuthApiKeys({userId:a});R.live&&(b({rows:D,userId:a}),C(null))}catch{R.live&&C(a)}})()),()=>{R.live=!1}},"f"),e[0]=l.apiKey,e[1]=i,e[2]=a,e[3]=p):p=e[3];let x;e[4]!==v||e[5]!==l.apiKey||e[6]!==i||e[7]!==a||e[8]!==u?(x=[v,l.apiKey,i,a,u],e[4]=v,e[5]=l.apiKey,e[6]=i,e[7]=a,e[8]=u,e[9]=x):x=e[9],(0,w.useEffect)(p,x);let y=N?.userId===a?N.rows:null,k=F===a,g;e[10]!==l.passkey||e[11]!==i||e[12]!==a?(g=r(()=>{l.passkey&&te((async()=>{try{f(await i.listAuthPasskeys({userId:a}))}catch{f(null)}})())},"g"),e[10]=l.passkey,e[11]=i,e[12]=a,e[13]=g):g=e[13];let o;e[14]!==l.passkey||e[15]!==i||e[16]!==a||e[17]!==u?(o=[l.passkey,i,a,u],e[14]=l.passkey,e[15]=i,e[16]=a,e[17]=u,e[18]=o):o=e[18],(0,w.useEffect)(g,o);let S;e[19]!==i||e[20]!==d||e[21]!==a?(S=r(()=>{d(()=>i.disableAuthTwoFactor({userId:a}))},"S"),e[19]=i,e[20]=d,e[21]=a,e[22]=S):S=e[22];let L=S,E;e[23]!==i||e[24]!==d?(E=r(R=>{d(()=>i.deleteAuthPasskey({passkeyId:R}))},"z"),e[23]=i,e[24]=d,e[25]=E):E=e[25];let H=E,j;e[26]!==i||e[27]!==d?(j=r(R=>{d(()=>i.deleteAuthApiKey({apiKeyId:R}))},"M"),e[26]=i,e[27]=d,e[28]=j):j=e[28];let Y=j,B;e[29]!==s?(B=s("Security"),e[29]=s,e[30]=B):B=e[30];let O;e[31]!==B?(O=(0,t.jsx)(Ye,{children:B}),e[31]=B,e[32]=O):O=e[32];let T;e[33]!==n||e[34]!==l.twoFactor||e[35]!==L||e[36]!==s?(T=l.twoFactor&&(0,t.jsx)(K,{"data-testid":"ud-disable-2fa",disabled:n,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Disable two-factor")}),e[33]=n,e[34]=l.twoFactor,e[35]=L,e[36]=s,e[37]=T):T=e[37];let z;e[38]!==l.passkey||e[39]!==c||e[40]!==s?(z=l.passkey&&c!==null&&c.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No passkeys.")}),e[38]=l.passkey,e[39]=c,e[40]=s,e[41]=z):z=e[41];let $;e[42]!==n||e[43]!==l.passkey||e[44]!==H||e[45]!==c||e[46]!==s?($=l.passkey&&c!==null&&c.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("created")],testId:"ud-passkeys-table",children:c.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-passkey-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-delete-passkey-${D}`,disabled:n,onClick:r(()=>{H(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Delete")})})]},D)})}),e[42]=n,e[43]=l.passkey,e[44]=H,e[45]=c,e[46]=s,e[47]=$):$=e[47];let I;e[48]!==k||e[49]!==n||e[50]!==l.apiKey||e[51]!==s?(I=l.apiKey&&k&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("Could not load API keys.")}),(0,t.jsx)(K,{"data-testid":"ud-api-keys-retry",disabled:n,onClick:r(()=>{m(bt)},"onClick"),size:"xs",type:"button",variant:"outline",children:s("Retry")})]}),e[48]=k,e[49]=n,e[50]=l.apiKey,e[51]=s,e[52]=I):I=e[52];let P;e[53]!==l.apiKey||e[54]!==y||e[55]!==s?(P=l.apiKey&&y!==null&&y.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s("No API keys.")}),e[53]=l.apiKey,e[54]=y,e[55]=s,e[56]=P):P=e[56];let V;e[57]!==n||e[58]!==l.apiKey||e[59]!==y||e[60]!==Y||e[61]!==s?(V=l.apiKey&&y!==null&&y.length>0&&(0,t.jsx)(tt,{columns:[s("name"),s("Key"),s("created"),s("Expires")],testId:"ud-api-keys-table",children:y.map(R=>{let D=ee(R.id);return(0,t.jsxs)(Q,{"data-testid":`ud-api-key-${D}`,children:[(0,t.jsx)(U,{children:ee(R.name)||D}),(0,t.jsx)(U,{className:"font-mono text-muted-foreground",children:ee(R.start)||"\u2014"}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.createdAt)}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(R.expiresAt,s("Never"))}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`ud-revoke-api-key-${D}`,disabled:n,onClick:r(()=>{Y(D)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},D)})}),e[57]=n,e[58]=l.apiKey,e[59]=y,e[60]=Y,e[61]=s,e[62]=V):V=e[62];let G;return e[63]!==T||e[64]!==z||e[65]!==$||e[66]!==I||e[67]!==P||e[68]!==V||e[69]!==O?(G=(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[O,T,z,$,I,P,V]}),e[63]=T,e[64]=z,e[65]=$,e[66]=I,e[67]=P,e[68]=V,e[69]=O,e[70]=G):G=e[70],G},"pt");function yt(h){return(0,t.jsx)(_,{children:h},h)}r(yt,"vt");function bt(h){return h+1}r(bt,"gt");var xt=/(?:at|expires)$/iu,Nt=/^[1-9]\d*$/u,kt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),wt=r(h=>{let e=(0,Z.c)(51),{busy:n,onBan:l}=h,d=J(),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(""),[c,f]=(0,w.useState)(!1),N;e[0]!==i?(N=Nt.test(i.trim())&&Number.isSafeInteger(Number(i.trim())*86400)?Number(i.trim()):void 0,e[0]=i,e[1]=N):N=e[1];let b=N,F=c||b!==void 0,C;e[2]!==l||e[3]!==c||e[4]!==a||e[5]!==b?(C=r(()=>{l({expiresInSeconds:c||b===void 0?void 0:b*86400,reason:a.trim()===""?void 0:a.trim()})},"C"),e[2]=l,e[3]=c,e[4]=a,e[5]=b,e[6]=C):C=e[6];let v=C,m;e[7]!==d?(m=d("Ban reason (optional)"),e[7]=d,e[8]=m):m=e[8];let p;e[9]!==m?(p=(0,t.jsx)(W,{htmlFor:"ud-ban-reason",children:m}),e[9]=m,e[10]=p):p=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=r(P=>{u(P.target.value)},"x"),e[11]=x):x=e[11];let y;e[12]!==a?(y=(0,t.jsx)(q,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:a}),e[12]=a,e[13]=y):y=e[13];let k;e[14]!==p||e[15]!==y?(k=(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-1",children:[p,y]}),e[14]=p,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==d?(g=d("Days"),e[17]=d,e[18]=g):g=e[18];let o;e[19]!==g?(o=(0,t.jsx)(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==i||e[22]!==b?(S=i.trim()!==""&&b===void 0,e[21]=i,e[22]=b,e[23]=S):S=e[23];let L;e[24]===Symbol.for("react.memo_cache_sentinel")?(L=r(P=>{s(P.target.value)},"_"),e[24]=L):L=e[24];let E;e[25]!==i||e[26]!==c||e[27]!==S?(E=(0,t.jsx)(q,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:c,id:"ud-ban-days",min:1,onChange:L,step:1,type:"number",value:i}),e[25]=i,e[26]=c,e[27]=S,e[28]=E):E=e[28];let H;e[29]!==E||e[30]!==o?(H=(0,t.jsxs)("div",{className:"flex w-24 flex-col gap-1",children:[o,E]}),e[29]=E,e[30]=o,e[31]=H):H=e[31];let j;e[32]===Symbol.for("react.memo_cache_sentinel")?(j=r(P=>{f(P.target.checked)},"M"),e[32]=j):j=e[32];let Y;e[33]!==c?(Y=(0,t.jsx)("input",{checked:c,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:j,type:"checkbox"}),e[33]=c,e[34]=Y):Y=e[34];let B;e[35]!==d?(B=d("Permanent"),e[35]=d,e[36]=B):B=e[36];let O;e[37]!==Y||e[38]!==B?(O=(0,t.jsxs)(W,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[Y,B]}),e[37]=Y,e[38]=B,e[39]=O):O=e[39];let T=n||!F,z;e[40]!==d?(z=d("Ban user"),e[40]=d,e[41]=z):z=e[41];let $;e[42]!==v||e[43]!==T||e[44]!==z?($=(0,t.jsx)(K,{"data-testid":"ud-ban",disabled:T,onClick:v,size:"sm",type:"button",variant:"destructive",children:z}),e[42]=v,e[43]=T,e[44]=z,e[45]=$):$=e[45];let I;return e[46]!==H||e[47]!==O||e[48]!==$||e[49]!==k?(I=(0,t.jsxs)("div",{className:"flex items-end gap-2",children:[k,H,O,$]}),e[46]=H,e[47]=O,e[48]=$,e[49]=k,e[50]=I):I=e[50],I},"Nt"),Ct=r((h,e)=>typeof e=="number"&&xt.test(h)?ae(e):ee(e),"kt"),It=r(({capabilities:h,onChanged:e,onClose:n,user:l})=>{let d=le(),a=J(),u=l.banned===!0,[i,s]=(0,w.useState)(null),[c,f]=(0,w.useState)(!1),[N,b]=(0,w.useState)(0),[F,C]=(0,w.useState)(typeof l.role=="string"?l.role:""),[v,m]=(0,w.useState)(""),[p,x]=(0,w.useState)(null),[y,k]=(0,w.useState)(!1),g=r((I,P)=>{te((async()=>{f(!0),s(null);try{let V=await I();P?.refresh!==!1&&(b(G=>G+1),e()),P?.onResult?.(V)}catch(V){s(Ee(V))}f(!1)})())},"g"),o=r(I=>{C(I.target.value)},"o"),S=r(I=>{m(I.target.value)},"S"),L=r(()=>{let I=F.trim();I!==""&&g(async()=>{await d.setAuthUserRole({role:I,userId:l.id})})},"_"),E=r(I=>{g(async()=>{await d.banAuthUser({...I,userId:l.id})})},"z"),H=r(()=>{g(async()=>{await d.unbanAuthUser({userId:l.id})})},"q"),j=r(()=>{g(async()=>{await d.setAuthUserPassword({newPassword:v,userId:l.id}),m("")})},"M"),Y=r(()=>{g(()=>d.impersonateAuthUser({userId:l.id}),{onResult:r(I=>{x(I.token)},"onResult"),refresh:!1})},"H"),B=r(()=>{g(async()=>{await d.revokeAuthUserSessions({userId:l.id})})},"D"),O=r(()=>{g(async()=>{await d.removeAuthUser({userId:l.id}),n()})},"B"),T=r(()=>{k(!0)},"O"),z=r(()=>{k(!1)},"U"),$=Object.entries(l).filter(([I])=>!kt.has(I));return(0,t.jsxs)(He,{label:a("User details"),onClose:n,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:l.name??l.email??l.id}),(0,t.jsx)("p",{className:"font-mono text-xs text-muted-foreground",children:l.id}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof l.role=="string"&&l.role!==""&&(0,t.jsx)(X,{variant:"secondary",children:l.role}),u?(0,t.jsx)(X,{variant:"destructive",children:a("Banned")}):(0,t.jsx)(X,{variant:"outline",children:a("Active")}),l.emailVerified===!0?(0,t.jsx)(X,{variant:"secondary",children:a("verified")}):(0,t.jsx)(X,{variant:"outline",children:a("unverified")})]})]}),(0,t.jsx)(K,{"data-testid":"ud-close",onClick:n,size:"sm",type:"button",variant:"ghost",children:a("Close")})]}),i!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:i}),h.admin&&(0,t.jsxs)(ie,{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)(ne,{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)(W,{htmlFor:"ud-role",children:a("Role")}),(0,t.jsx)(q,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),(0,t.jsx)(K,{"data-testid":"ud-set-role",disabled:c||F.trim()==="",onClick:L,size:"sm",type:"button",variant:"outline",children:a("Set role")})]}),u?(0,t.jsx)(K,{"data-testid":"ud-unban",disabled:c,onClick:H,size:"sm",type:"button",variant:"outline",children:a("Unban")}):(0,t.jsx)(wt,{busy:c,onBan:E}),(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)(W,{htmlFor:"ud-password",children:a("New password")}),(0,t.jsx)(q,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),(0,t.jsx)(K,{"data-testid":"ud-set-password",disabled:c||v==="",onClick:j,size:"sm",type:"button",variant:"outline",children:a("Set password")})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsx)(K,{"data-testid":"ud-impersonate",disabled:c,onClick:Y,size:"sm",type:"button",variant:"outline",children:a("Impersonate")}),(0,t.jsx)(K,{"data-testid":"ud-revoke-all",disabled:c,onClick:B,size:"sm",type:"button",variant:"outline",children:a("Revoke all sessions")}),y?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K,{"data-testid":"ud-delete-confirm",disabled:c,onClick:O,size:"sm",type:"button",variant:"destructive",children:a("Confirm delete")}),(0,t.jsx)(K,{"data-testid":"ud-delete-cancel",onClick:z,size:"sm",type:"button",variant:"ghost",children:a("Cancel")})]}):(0,t.jsx)(K,{"data-testid":"ud-delete",disabled:c,onClick:T,size:"sm",type:"button",variant:"destructive",children:a("Delete user")})]}),p!==null&&(0,t.jsxs)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsx)(W,{htmlFor:"ud-token",children:a("Impersonation token")}),(0,t.jsx)(q,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:p})]})]})]}),(0,t.jsx)(ft,{busy:c,runAction:g,userId:l.id,version:N}),h.accounts&&(0,t.jsx)(vt,{busy:c,runAction:g,userId:l.id,version:N}),(h.twoFactor||h.passkey||h.apiKey)&&(0,t.jsx)(gt,{busy:c,capabilities:h,runAction:g,userId:l.id,version:N}),(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:$.map(([I,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:I}),(0,t.jsx)("dd",{className:"m-0 font-mono text-xs break-words",children:Ct(I,P)})]},I))})]})]})},"Ct"),At=50,Ht=r(({pageSize:h=At}={})=>{let e=le(),n=J(),[l,d]=(0,w.useState)(""),[a,u]=(0,w.useState)(""),[i,s]=(0,w.useState)(0),c=Xe(l),[f,N]=(0,w.useState)(null),[b,F]=(0,w.useState)(!1),{capabilities:C}=st(),v=c.trim(),m=a.trim(),p=je(["lunora-auth-users",v,m,h,i],()=>e.listAuthUsers({filterField:m===""?void 0:"role",filterValue:m===""?void 0:m,limit:h,offset:i,search:v===""?void 0:v}).then(o=>({...o,offset:i})),{keepPreviousData:!0}),x=p.data?.rows??null,y=p.error,k=r(()=>{p.refetch()},"k");We(()=>p.poll(),!0);let g=f===null?null:x?.find(o=>o.id===f)??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)(q,{"aria-label":n("Search users"),className:"w-56","data-testid":"us-search",onChange:r(o=>{d(o.target.value),s(0)},"onChange"),placeholder:n("Search by email or name\u2026"),value:l}),(0,t.jsx)(q,{"aria-label":n("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:r(o=>{u(o.target.value),s(0)},"onChange"),placeholder:n("Filter by role"),value:a}),(0,t.jsx)(K,{"data-testid":"us-new",onClick:r(()=>{F(!0)},"onClick"),size:"sm",type:"button",children:n("New user")})]}),y!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&(0,t.jsx)(Me,{description:n("Users who sign up to your app will appear here."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:n("No users.")}),x!==null&&x.length>0&&(0,t.jsx)(ie,{className:"overflow-hidden py-0",children:(0,t.jsx)(ne,{className:"px-0",children:(0,t.jsxs)(Pe,{"data-testid":"us-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(Q,{children:[(0,t.jsx)(_,{children:n("id")}),(0,t.jsx)(_,{children:n("email")}),(0,t.jsx)(_,{children:n("name")}),(0,t.jsx)(_,{children:n("role")}),(0,t.jsx)(_,{children:n("status")}),(0,t.jsx)(_,{children:n("verified")}),(0,t.jsx)(_,{children:n("created")}),(0,t.jsx)(_,{"aria-label":n("Actions")})]})}),(0,t.jsx)(Be,{children:x.map(o=>(0,t.jsxs)(Q,{"data-testid":`us-row-${o.id}`,children:[(0,t.jsx)(U,{className:"font-mono text-xs",children:o.id}),(0,t.jsx)(U,{children:o.email??""}),(0,t.jsx)(U,{children:o.name??""}),(0,t.jsx)(U,{children:typeof o.role=="string"&&o.role!==""?(0,t.jsx)(X,{variant:"secondary",children:o.role}):""}),(0,t.jsx)(U,{children:o.banned===!0?(0,t.jsx)(X,{variant:"destructive",children:n("Banned")}):(0,t.jsx)(X,{variant:"success",children:n("Active")})}),(0,t.jsx)(U,{children:o.emailVerified===!0?(0,t.jsx)(X,{variant:"success",children:n("yes")}):(0,t.jsx)(X,{variant:"outline",children:n("no")})}),(0,t.jsx)(U,{className:"text-muted-foreground tabular-nums",children:ae(o.createdAt)}),(0,t.jsx)(U,{children:(0,t.jsx)(K,{"data-testid":`us-manage-${o.id}`,onClick:r(()=>{N(o.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Manage")})})]},o.id))})]})})}),x!==null&&(0,t.jsx)(Ge,{count:x.length,offset:p.data?.offset??0,onOffsetChange:s,pageSize:h,prefix:"us",total:p.data?.total}),g!==null&&(0,t.jsx)(It,{capabilities:C,onChanged:k,onClose:r(()=>{N(null)},"onClose"),user:g}),b&&(0,t.jsx)(pt,{onClose:r(()=>{F(!1)},"onClose"),onCreated:k}),C.inviteOnly&&(0,t.jsx)(ct,{})]})},"Ht");export{Ht as UsersPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as u,s as f}from"./chunk-
|
|
1
|
+
import{j as u,s as f}from"./chunk-PN7JHEYW.js";import{a as S}from"./chunk-A6TVTNKO.js";import{a as h}from"./chunk-ADABTCDI.js";import{a as s,d as l}from"./chunk-5PEAXTYQ.js";var i=l(S(),1),c=l(h(),1);var g=s(()=>{let t=(0,i.c)(4),[a,n]=(0,c.useState)(!1),[e,m]=(0,c.useState)(null),r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=s(p=>{f((async()=>{n(!0),m(null);try{await p()}catch(b){m(u(b))}n(!1)})())},"e"),t[0]=r):r=t[0];let y=r,o;return t[1]!==a||t[2]!==e?(o={busy:a,error:e,run:y},t[1]=a,t[2]=e,t[3]=o):o=t[3],o},"g");export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as we}from"./chunk-5MIJ3KEK.js";import{a as ve}from"./chunk-MTBY4GXM.js";import{i as me}from"./chunk-V4JKKAAZ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as q}from"./chunk-VGKDC2OQ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ue}from"./chunk-NQ727GVM.js";import"./chunk-L27FKJTG.js";import{a as ae,b as re,c as ne,d as j,e as h,f as p}from"./chunk-4TGALJHR.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as Ne}from"./chunk-YL5ZAR3P.js";import{a as ee,e as te}from"./chunk-ZZ6ZCOD4.js";import{n as ce}from"./chunk-KQVY73EU.js";import"./chunk-ZPQBVYNN.js";import{B as Y,h as ie,i as de,j as z,p as pe,s as U}from"./chunk-VJQP4ARP.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{a as ke,b as Se}from"./chunk-ADABTCDI.js";import{a as s,d as he}from"./chunk-5PEAXTYQ.js";var xe=he(be(),1),i=he(ke(),1);var t=he(Se(),1);var Ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Oe=["pause","resume","restart","terminate"],Ie=s(l=>{let e=(0,xe.c)(7),{busy:w,id:x,onAct:N}=l,b=Y(),a;e[0]!==w||e[1]!==x||e[2]!==N||e[3]!==b?(a=Oe.map(m=>m==="restart"?(0,t.jsx)(ve,{confirmLabel:b("Restart?"),disabled:w,onConfirm:s(()=>{N(m)},"onConfirm"),testId:`workflow-instance-${m}-${x}`,children:b(m)},m):(0,t.jsx)(q,{"data-testid":`workflow-instance-${m}-${x}`,disabled:w,onClick:s(()=>{N(m)},"onClick"),size:"sm",type:"button",variant:"ghost",children:b(m)},m)),e[0]=w,e[1]=x,e[2]=N,e[3]=b,e[4]=a):a=e[4];let d;return e[5]!==a?(d=(0,t.jsx)(t.Fragment,{children:a}),e[5]=a,e[6]=d):d=e[6],d},"Ce"),$e="WORKFLOWS_NOT_CONFIGURED",We=s(l=>typeof l=="object"&&l!==null&&l.code===$e,"Oe"),Ae=s(l=>{let e=l.error??l.output;if(e===void 0)return"\u2014";try{return JSON.stringify(e,pe)}catch{return"(unserializable)"}},"Ee"),Te=s(({loadDetail:l,loadInstances:e,readOnly:w,runAction:x,workflowName:N})=>{let b=ce(),a=Y(),[d,m]=(0,i.useState)(null),[v,L]=(0,i.useState)(null),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(null),[F,W]=(0,i.useState)(!1),[_,R]=(0,i.useState)(null),g=(0,i.useRef)(0),y=(0,i.useRef)(0),k=(0,i.useRef)(0),A=l??(n=>b.getWorkflowInstance(n)),I=w?void 0:x??(e===void 0?n=>b.setWorkflowInstanceStatus(n):void 0),T=s(async()=>{y.current+=1;let n=y.current;O(null),W(!1);let u=S===""?void 0:S;try{if(e===void 0){let r=await b.listWorkflowInstances({name:N,status:u});if(n!==y.current)return;if(r.configured===!1){m(null),W(!0);return}m(r.instances);return}let f=await e({name:N,status:u});n===y.current&&m(f)}catch(f){if(n!==y.current)return;m(null),We(f)?W(!0):O(z(f))}},"E");(0,i.useEffect)(()=>{g.current+=1,k.current+=1,L(null),U(T())},[N,S]);let P=s(async n=>{k.current+=1;let u=k.current;O(null);try{let f=await A({id:n,name:N});u===k.current&&L(f)}catch(f){u===k.current&&O(z(f))}},"W"),E=s(()=>{k.current+=1,L(null)},"A"),J=s(async(n,u)=>{if(I===void 0)return;let f=g.current;R(n),O(null);try{await I({action:u,id:n,name:N}),f===g.current&&await T()}catch(r){O(z(r))}R(null)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:a("Instance history")}),(0,t.jsxs)("select",{"aria-label":a("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:s(n=>{B(n.target.value)},"onChange"),value:S,children:[(0,t.jsx)("option",{value:"",children:a("All statuses")}),Ce.map(n=>(0,t.jsx)("option",{value:n,children:n},n))]})]}),C!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),F&&(0,t.jsx)(ue,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!F&&d!==null&&d.length===0&&(0,t.jsx)(ue,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),d!==null&&d.length>0&&(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflow-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Instance id")}),(0,t.jsx)(h,{children:a("Status")}),(0,t.jsx)(h,{children:a("Created")}),(0,t.jsx)(h,{children:a("Ended")}),(0,t.jsx)(h,{"aria-label":a("Actions")})]})}),(0,t.jsx)(ne,{children:d.map(n=>(0,t.jsxs)(j,{"data-testid":`workflow-instance-${n.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:n.status}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"\u2014"}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,t.jsx)(q,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:s(()=>{U(P(n.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:a("Steps")}),I!==void 0&&(0,t.jsx)(Ie,{busy:_===n.id,id:n.id,onAct:s(u=>{U(J(n.id,u))},"onAct")},N)]})})]},n.id))})]})})}),v!==null&&(0,t.jsx)(ee,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,t.jsxs)(te,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:[a("Steps")," \xB7 ",v.id]}),(0,t.jsx)(q,{"data-testid":"workflow-instance-detail-close",onClick:E,size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),v.steps.length===0?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):(0,t.jsxs)(ae,{"data-testid":"workflow-instance-steps",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:a("Step")}),(0,t.jsx)(h,{children:a("Type")}),(0,t.jsx)(h,{children:a("Attempts")}),(0,t.jsx)(h,{children:a("Started")}),(0,t.jsx)(h,{children:a("Output")})]})}),(0,t.jsx)(ne,{children:v.steps.map((n,u)=>(0,t.jsxs)(j,{"data-testid":`workflow-step-${String(u)}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.name}),(0,t.jsx)(p,{className:"text-xs text-muted-foreground",children:n.type??"\u2014"}),(0,t.jsx)(p,{className:"tabular-nums",children:n.attempts??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.start??"\u2014"}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:Ae(n)})]},`${n.name}:${String(u)}`))})]})]})})]})},"_e"),_e=ie(X.createWorkflowInstance),Ee=ie(X.getWorkflowInstanceStatus),Je=ie(X.sendWorkflowEvent),De=s(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output,pe)}catch{return"(unserializable)"}},"$e"),ge=s(l=>{let e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},"ve"),Fe=s((l,e)=>l.some(w=>w.exportName===e)?e:l[0]?.exportName??"","Fe"),Pe=s(l=>{let e=(0,xe.c)(72),{eventTypes:w,exportName:x,onSent:N}=l,b=ce(),a=Y(),[d,m]=(0,i.useState)(""),[v,L]=(0,i.useState)(""),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(!1),[F,W]=(0,i.useState)(null),_;e[0]!==b||e[1]!==x||e[2]!==N||e[3]!==a||e[4]!==v?(_=s(async(D,oe)=>{try{await b.query(Je,{exportName:x,id:D,payload:oe,type:v},de(""))}catch(fe){W(z(fe));return}try{await N(x,D)}catch(fe){let ye=fe;W(`${a("Event sent, but refreshing the instance failed")}: ${z(ye)}`)}},"_"),e[0]=b,e[1]=x,e[2]=N,e[3]=a,e[4]=v,e[5]=_):_=e[5];let R=_,g;e[6]!==R||e[7]!==d||e[8]!==S||e[9]!==a?(g=s(async()=>{let D=d.trim(),oe=ge(S);if(oe===null){W(a("Payload must be valid JSON"));return}O(!0),W(null),await R(D,oe.value).finally(()=>{O(!1)})},"N"),e[6]=R,e[7]=d,e[8]=S,e[9]=a,e[10]=g):g=e[10];let y=g,k;e[11]!==a?(k=a("Send event"),e[11]=a,e[12]=k):k=e[12];let A;e[13]!==k?(A=(0,t.jsx)("h3",{className:"text-sm font-medium",children:k}),e[13]=k,e[14]=A):A=e[14];let I;e[15]!==F?(I=F!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:F}),e[15]=F,e[16]=I):I=e[16];let T;e[17]!==a?(T=a("Instance id"),e[17]=a,e[18]=T):T=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=s(D=>{m(D.target.value)},"O"),e[19]=P):P=e[19];let E;e[20]!==a?(E=a("Instance id"),e[20]=a,e[21]=E):E=e[21];let J;e[22]!==d||e[23]!==T||e[24]!==E?(J=(0,t.jsx)(me,{"aria-label":T,className:"max-w-48","data-testid":"workflows-event-id",onChange:P,placeholder:E,value:d}),e[22]=d,e[23]=T,e[24]=E,e[25]=J):J=e[25];let n;e[26]!==a?(n=a("Event type"),e[26]=a,e[27]=n):n=e[27];let u;e[28]===Symbol.for("react.memo_cache_sentinel")?(u=s(D=>{L(D.target.value)},"L"),e[28]=u):u=e[28];let f;e[29]!==a?(f=a("Event type"),e[29]=a,e[30]=f):f=e[30];let r;e[31]!==n||e[32]!==f||e[33]!==v?(r=(0,t.jsx)(me,{"aria-label":n,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:u,placeholder:f,value:v}),e[31]=n,e[32]=f,e[33]=v,e[34]=r):r=e[34];let c;e[35]!==w?(c=w.map(je),e[35]=w,e[36]=c):c=e[36];let o;e[37]!==c?(o=(0,t.jsx)("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:c}),e[37]=c,e[38]=o):o=e[38];let $;e[39]!==x||e[40]!==d||e[41]!==C||e[42]!==v?($=C||x===""||d.trim()===""||v.trim()==="",e[39]=x,e[40]=d,e[41]=C,e[42]=v,e[43]=$):$=e[43];let K;e[44]!==y?(K=s(()=>{U(y())},"z"),e[44]=y,e[45]=K):K=e[45];let G;e[46]!==C||e[47]!==a?(G=a(C?"Sending\u2026":"Send event"),e[46]=C,e[47]=a,e[48]=G):G=e[48];let M;e[49]!==$||e[50]!==K||e[51]!==G?(M=(0,t.jsx)(q,{"data-testid":"workflows-event-button",disabled:$,onClick:K,children:G}),e[49]=$,e[50]=K,e[51]=G,e[52]=M):M=e[52];let Z;e[53]!==r||e[54]!==o||e[55]!==M||e[56]!==J?(Z=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[J,r,o,M]}),e[53]=r,e[54]=o,e[55]=M,e[56]=J,e[57]=Z):Z=e[57];let H;e[58]!==a?(H=a("Payload (JSON)"),e[58]=a,e[59]=H):H=e[59];let se;e[60]===Symbol.for("react.memo_cache_sentinel")?(se=s(D=>{B(D.target.value)},"Y"),e[60]=se):se=e[60];let Q;e[61]!==a?(Q=a("Payload (JSON, optional)"),e[61]=a,e[62]=Q):Q=e[62];let V;e[63]!==S||e[64]!==H||e[65]!==Q?(V=(0,t.jsx)(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:se,placeholder:Q,value:S}),e[63]=S,e[64]=H,e[65]=Q,e[66]=V):V=e[66];let le;return e[67]!==Z||e[68]!==V||e[69]!==A||e[70]!==I?(le=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[A,I,Z,V]}),e[67]=Z,e[68]=V,e[69]=A,e[70]=I,e[71]=le):le=e[71],le},"Pe"),Ve=s(()=>{let l=ce(),e=Y(),{data:w,error:x}=Ne(X.listWorkflows,{}),[N,b]=(0,i.useState)(""),[a,d]=(0,i.useState)(""),[m,v]=(0,i.useState)(""),[L,S]=(0,i.useState)(!1),[B,C]=(0,i.useState)(null),[O,F]=(0,i.useState)([]),[W,_]=(0,i.useState)(null),R=w!==void 0,g=Array.isArray(w?.workflows)?[...w.workflows].toSorted((r,c)=>r.exportName.localeCompare(c.exportName)):[],y=Fe(g,N),k=g.find(r=>r.exportName===y),A=s(r=>{F(c=>{let o=c.filter($=>!($.exportName===r.exportName&&$.id===r.id));return[r,...o]})},"T"),I=s(async()=>{let r=y;if(r==="")return;let c=ge(m);if(c===null){C(e("Params must be valid JSON"));return}S(!0),C(null);try{let o=a.trim(),$=await l.query(_e,{exportName:r,id:o===""?void 0:o,params:c.value},de(""));A({exportName:r,id:$.id,status:$.status}),d("")}catch(o){C(z(o))}S(!1)},"F"),T=s(()=>{U(I())},"P"),P=s(async(r,c)=>{_(c);try{let o=await l.query(Ee,{exportName:r,id:c},de(""));A({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},"O"),E=s(async(r,c)=>{try{await P(r,c)}catch(o){C(z(o))}},"E"),J=s(r=>{b(r.target.value)},"W"),n=s(r=>{d(r.target.value)},"A"),u=s(r=>{v(r.target.value)},"L"),f=s(r=>{let{export:c,id:o}=r.currentTarget.dataset;c!==void 0&&o!==void 0&&U(E(c,o))},"n");return(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:x}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),R&&g.length===0?(0,t.jsx)(ue,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Export")}),(0,t.jsx)(h,{children:e("Name")}),(0,t.jsx)(h,{children:e("Class")})]})}),(0,t.jsx)(ne,{children:g.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-row-${r.exportName}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.name}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),g.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Start instance")}),B!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:B}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:J,value:y,children:g.map(r=>(0,t.jsx)("option",{value:r.exportName,children:r.exportName},r.exportName))}),(0,t.jsx)(me,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:n,placeholder:e("Instance id (optional)"),value:a}),(0,t.jsx)(q,{"data-testid":"workflows-start-button",disabled:L||y==="",onClick:T,children:e(L?"Starting\u2026":"Start instance")})]}),(0,t.jsx)(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:u,placeholder:e("Params (JSON, optional)"),value:m})]}),g.length>0&&(0,t.jsx)(Pe,{eventTypes:w?.eventTypes??[],exportName:y,onSent:P},y),O.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Instances")}),(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(j,{children:[(0,t.jsx)(h,{children:e("Workflow")}),(0,t.jsx)(h,{children:e("Instance id")}),(0,t.jsx)(h,{children:e("Status")}),(0,t.jsx)(h,{children:e("Output")}),(0,t.jsx)(h,{})]})}),(0,t.jsx)(ne,{children:O.map(r=>(0,t.jsxs)(j,{"data-testid":`workflows-instance-${r.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:r.status}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:De(r)}),(0,t.jsx)(p,{children:(0,t.jsx)(q,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:W===r.id,onClick:f,size:"xs",variant:"outline",children:W===r.id?e("Refreshing\u2026"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),k!==void 0&&(0,t.jsx)(Te,{workflowName:k.name})]})},"Ze");function je(l){return(0,t.jsx)("option",{value:l,children:l},l)}s(je,"De");export{Ve as default};
|
|
1
|
+
import{a as we}from"./chunk-4AGOKKRZ.js";import{a as ve}from"./chunk-DWNWEMQK.js";import{i as me}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as q}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as ue}from"./chunk-S3TDGFRE.js";import"./chunk-L27FKJTG.js";import{a as ae,b as re,c as ne,d as L,e as h,f as p}from"./chunk-J3ZEO3PJ.js";import{a as X}from"./chunk-LYVYUTQY.js";import{c as Ne}from"./chunk-UN3QTZ6X.js";import{a as ee,e as te}from"./chunk-TN4Z3P6S.js";import{n as ce}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as Y,h as ie,i as de,j as U,p as pe,s as z}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as be}from"./chunk-A6TVTNKO.js";import{a as ke,b as Se}from"./chunk-ADABTCDI.js";import{a as s,d as he}from"./chunk-5PEAXTYQ.js";var xe=he(be(),1),i=he(ke(),1);var t=he(Se(),1);var Ce=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Oe=["pause","resume","restart","terminate"],Ie=s(l=>{let e=(0,xe.c)(7),{busy:w,id:x,onAct:N}=l,b=Y(),a;e[0]!==w||e[1]!==x||e[2]!==N||e[3]!==b?(a=Oe.map(m=>m==="restart"?(0,t.jsx)(ve,{confirmLabel:b("Restart?"),disabled:w,onConfirm:s(()=>{N(m)},"onConfirm"),testId:`workflow-instance-${m}-${x}`,children:b(m)},m):(0,t.jsx)(q,{"data-testid":`workflow-instance-${m}-${x}`,disabled:w,onClick:s(()=>{N(m)},"onClick"),size:"sm",type:"button",variant:"ghost",children:b(m)},m)),e[0]=w,e[1]=x,e[2]=N,e[3]=b,e[4]=a):a=e[4];let d;return e[5]!==a?(d=(0,t.jsx)(t.Fragment,{children:a}),e[5]=a,e[6]=d):d=e[6],d},"Ce"),$e="WORKFLOWS_NOT_CONFIGURED",We=s(l=>typeof l=="object"&&l!==null&&l.code===$e,"Oe"),Ae=s(l=>{let e=l.error??l.output;if(e===void 0)return"\u2014";try{return JSON.stringify(e,pe)}catch{return"(unserializable)"}},"Ee"),Te=s(({loadDetail:l,loadInstances:e,readOnly:w,runAction:x,workflowName:N})=>{let b=ce(),a=Y(),[d,m]=(0,i.useState)(null),[v,R]=(0,i.useState)(null),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(null),[F,W]=(0,i.useState)(!1),[_,j]=(0,i.useState)(null),g=(0,i.useRef)(0),y=(0,i.useRef)(0),k=(0,i.useRef)(0),A=l??(n=>b.getWorkflowInstance(n)),I=w?void 0:x??(e===void 0?n=>b.setWorkflowInstanceStatus(n):void 0),T=s(async()=>{y.current+=1;let n=y.current;O(null),W(!1);let u=S===""?void 0:S;try{if(e===void 0){let r=await b.listWorkflowInstances({name:N,status:u});if(n!==y.current)return;if(r.configured===!1){m(null),W(!0);return}m(r.instances);return}let f=await e({name:N,status:u});n===y.current&&m(f)}catch(f){if(n!==y.current)return;m(null),We(f)?W(!0):O(U(f))}},"E");(0,i.useEffect)(()=>{g.current+=1,k.current+=1,R(null),z(T())},[N,S]);let P=s(async n=>{k.current+=1;let u=k.current;O(null);try{let f=await A({id:n,name:N});u===k.current&&R(f)}catch(f){u===k.current&&O(U(f))}},"W"),E=s(()=>{k.current+=1,R(null)},"A"),J=s(async(n,u)=>{if(I===void 0)return;let f=g.current;j(n),O(null);try{await I({action:u,id:n,name:N}),f===g.current&&await T()}catch(r){O(U(r))}j(null)},"L");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:a("Instance history")}),(0,t.jsxs)("select",{"aria-label":a("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:s(n=>{B(n.target.value)},"onChange"),value:S,children:[(0,t.jsx)("option",{value:"",children:a("All statuses")}),Ce.map(n=>(0,t.jsx)("option",{value:n,children:n},n))]})]}),C!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),F&&(0,t.jsx)(ue,{description:a("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:a("Workflow inspection not configured")}),!F&&d!==null&&d.length===0&&(0,t.jsx)(ue,{description:a("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:a("No instances")}),d!==null&&d.length>0&&(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflow-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(h,{children:a("Instance id")}),(0,t.jsx)(h,{children:a("Status")}),(0,t.jsx)(h,{children:a("Created")}),(0,t.jsx)(h,{children:a("Ended")}),(0,t.jsx)(h,{"aria-label":a("Actions")})]})}),(0,t.jsx)(ne,{children:d.map(n=>(0,t.jsxs)(L,{"data-testid":`workflow-instance-${n.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:n.status}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"\u2014"}),(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,t.jsx)(q,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:s(()=>{z(P(n.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:a("Steps")}),I!==void 0&&(0,t.jsx)(Ie,{busy:_===n.id,id:n.id,onAct:s(u=>{z(J(n.id,u))},"onAct")},N)]})})]},n.id))})]})})}),v!==null&&(0,t.jsx)(ee,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,t.jsxs)(te,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:[a("Steps")," \xB7 ",v.id]}),(0,t.jsx)(q,{"data-testid":"workflow-instance-detail-close",onClick:E,size:"xs",type:"button",variant:"ghost",children:a("Close")})]}),v.steps.length===0?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:a("This instance has no recorded steps yet.")}):(0,t.jsxs)(ae,{"data-testid":"workflow-instance-steps",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(h,{children:a("Step")}),(0,t.jsx)(h,{children:a("Type")}),(0,t.jsx)(h,{children:a("Attempts")}),(0,t.jsx)(h,{children:a("Started")}),(0,t.jsx)(h,{children:a("Output")})]})}),(0,t.jsx)(ne,{children:v.steps.map((n,u)=>(0,t.jsxs)(L,{"data-testid":`workflow-step-${String(u)}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:n.name}),(0,t.jsx)(p,{className:"text-xs text-muted-foreground",children:n.type??"\u2014"}),(0,t.jsx)(p,{className:"tabular-nums",children:n.attempts??"\u2014"}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:n.start??"\u2014"}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:Ae(n)})]},`${n.name}:${String(u)}`))})]})]})})]})},"_e"),_e=ie(X.createWorkflowInstance),Ee=ie(X.getWorkflowInstanceStatus),Je=ie(X.sendWorkflowEvent),De=s(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output,pe)}catch{return"(unserializable)"}},"$e"),ge=s(l=>{let e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},"ve"),Fe=s((l,e)=>l.some(w=>w.exportName===e)?e:l[0]?.exportName??"","Fe"),Pe=s(l=>{let e=(0,xe.c)(72),{eventTypes:w,exportName:x,onSent:N}=l,b=ce(),a=Y(),[d,m]=(0,i.useState)(""),[v,R]=(0,i.useState)(""),[S,B]=(0,i.useState)(""),[C,O]=(0,i.useState)(!1),[F,W]=(0,i.useState)(null),_;e[0]!==b||e[1]!==x||e[2]!==N||e[3]!==a||e[4]!==v?(_=s(async(D,oe)=>{try{await b.query(Je,{exportName:x,id:D,payload:oe,type:v},de(""))}catch(fe){W(U(fe));return}try{await N(x,D)}catch(fe){let ye=fe;W(`${a("Event sent, but refreshing the instance failed")}: ${U(ye)}`)}},"_"),e[0]=b,e[1]=x,e[2]=N,e[3]=a,e[4]=v,e[5]=_):_=e[5];let j=_,g;e[6]!==j||e[7]!==d||e[8]!==S||e[9]!==a?(g=s(async()=>{let D=d.trim(),oe=ge(S);if(oe===null){W(a("Payload must be valid JSON"));return}O(!0),W(null),await j(D,oe.value).finally(()=>{O(!1)})},"N"),e[6]=j,e[7]=d,e[8]=S,e[9]=a,e[10]=g):g=e[10];let y=g,k;e[11]!==a?(k=a("Send event"),e[11]=a,e[12]=k):k=e[12];let A;e[13]!==k?(A=(0,t.jsx)("h3",{className:"text-sm font-medium",children:k}),e[13]=k,e[14]=A):A=e[14];let I;e[15]!==F?(I=F!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:F}),e[15]=F,e[16]=I):I=e[16];let T;e[17]!==a?(T=a("Instance id"),e[17]=a,e[18]=T):T=e[18];let P;e[19]===Symbol.for("react.memo_cache_sentinel")?(P=s(D=>{m(D.target.value)},"O"),e[19]=P):P=e[19];let E;e[20]!==a?(E=a("Instance id"),e[20]=a,e[21]=E):E=e[21];let J;e[22]!==d||e[23]!==T||e[24]!==E?(J=(0,t.jsx)(me,{"aria-label":T,className:"max-w-48","data-testid":"workflows-event-id",onChange:P,placeholder:E,value:d}),e[22]=d,e[23]=T,e[24]=E,e[25]=J):J=e[25];let n;e[26]!==a?(n=a("Event type"),e[26]=a,e[27]=n):n=e[27];let u;e[28]===Symbol.for("react.memo_cache_sentinel")?(u=s(D=>{R(D.target.value)},"L"),e[28]=u):u=e[28];let f;e[29]!==a?(f=a("Event type"),e[29]=a,e[30]=f):f=e[30];let r;e[31]!==n||e[32]!==f||e[33]!==v?(r=(0,t.jsx)(me,{"aria-label":n,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:u,placeholder:f,value:v}),e[31]=n,e[32]=f,e[33]=v,e[34]=r):r=e[34];let c;e[35]!==w?(c=w.map(Le),e[35]=w,e[36]=c):c=e[36];let o;e[37]!==c?(o=(0,t.jsx)("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:c}),e[37]=c,e[38]=o):o=e[38];let $;e[39]!==x||e[40]!==d||e[41]!==C||e[42]!==v?($=C||x===""||d.trim()===""||v.trim()==="",e[39]=x,e[40]=d,e[41]=C,e[42]=v,e[43]=$):$=e[43];let K;e[44]!==y?(K=s(()=>{z(y())},"z"),e[44]=y,e[45]=K):K=e[45];let G;e[46]!==C||e[47]!==a?(G=a(C?"Sending\u2026":"Send event"),e[46]=C,e[47]=a,e[48]=G):G=e[48];let M;e[49]!==$||e[50]!==K||e[51]!==G?(M=(0,t.jsx)(q,{"data-testid":"workflows-event-button",disabled:$,onClick:K,children:G}),e[49]=$,e[50]=K,e[51]=G,e[52]=M):M=e[52];let Z;e[53]!==r||e[54]!==o||e[55]!==M||e[56]!==J?(Z=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[J,r,o,M]}),e[53]=r,e[54]=o,e[55]=M,e[56]=J,e[57]=Z):Z=e[57];let H;e[58]!==a?(H=a("Payload (JSON)"),e[58]=a,e[59]=H):H=e[59];let se;e[60]===Symbol.for("react.memo_cache_sentinel")?(se=s(D=>{B(D.target.value)},"Y"),e[60]=se):se=e[60];let Q;e[61]!==a?(Q=a("Payload (JSON, optional)"),e[61]=a,e[62]=Q):Q=e[62];let V;e[63]!==S||e[64]!==H||e[65]!==Q?(V=(0,t.jsx)(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:se,placeholder:Q,value:S}),e[63]=S,e[64]=H,e[65]=Q,e[66]=V):V=e[66];let le;return e[67]!==Z||e[68]!==V||e[69]!==A||e[70]!==I?(le=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[A,I,Z,V]}),e[67]=Z,e[68]=V,e[69]=A,e[70]=I,e[71]=le):le=e[71],le},"Pe"),Ve=s(()=>{let l=ce(),e=Y(),{data:w,error:x}=Ne(X.listWorkflows,{}),[N,b]=(0,i.useState)(""),[a,d]=(0,i.useState)(""),[m,v]=(0,i.useState)(""),[R,S]=(0,i.useState)(!1),[B,C]=(0,i.useState)(null),[O,F]=(0,i.useState)([]),[W,_]=(0,i.useState)(null),j=w!==void 0,g=Array.isArray(w?.workflows)?[...w.workflows].toSorted((r,c)=>r.exportName.localeCompare(c.exportName)):[],y=Fe(g,N),k=g.find(r=>r.exportName===y),A=s(r=>{F(c=>{let o=c.filter($=>!($.exportName===r.exportName&&$.id===r.id));return[r,...o]})},"T"),I=s(async()=>{let r=y;if(r==="")return;let c=ge(m);if(c===null){C(e("Params must be valid JSON"));return}S(!0),C(null);try{let o=a.trim(),$=await l.query(_e,{exportName:r,id:o===""?void 0:o,params:c.value},de(""));A({exportName:r,id:$.id,status:$.status}),d("")}catch(o){C(U(o))}S(!1)},"F"),T=s(()=>{z(I())},"P"),P=s(async(r,c)=>{_(c);try{let o=await l.query(Ee,{exportName:r,id:c},de(""));A({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},"O"),E=s(async(r,c)=>{try{await P(r,c)}catch(o){C(U(o))}},"E"),J=s(r=>{b(r.target.value)},"W"),n=s(r=>{d(r.target.value)},"A"),u=s(r=>{v(r.target.value)},"L"),f=s(r=>{let{export:c,id:o}=r.currentTarget.dataset;c!==void 0&&o!==void 0&&z(E(c,o))},"n");return(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[x!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:x}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),j&&g.length===0?(0,t.jsx)(ue,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(h,{children:e("Export")}),(0,t.jsx)(h,{children:e("Name")}),(0,t.jsx)(h,{children:e("Class")})]})}),(0,t.jsx)(ne,{children:g.map(r=>(0,t.jsxs)(L,{"data-testid":`workflows-row-${r.exportName}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.name}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),g.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Start instance")}),B!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:B}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:J,value:y,children:g.map(r=>(0,t.jsx)("option",{value:r.exportName,children:r.exportName},r.exportName))}),(0,t.jsx)(me,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:n,placeholder:e("Instance id (optional)"),value:a}),(0,t.jsx)(q,{"data-testid":"workflows-start-button",disabled:R||y==="",onClick:T,children:e(R?"Starting\u2026":"Start instance")})]}),(0,t.jsx)(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:u,placeholder:e("Params (JSON, optional)"),value:m})]}),g.length>0&&(0,t.jsx)(Pe,{eventTypes:w?.eventTypes??[],exportName:y,onSent:P},y),O.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,t.jsx)("h3",{className:"text-sm font-medium",children:e("Instances")}),(0,t.jsx)(ee,{className:"overflow-hidden py-0",children:(0,t.jsx)(te,{className:"px-0",children:(0,t.jsxs)(ae,{"data-testid":"workflows-instances-table",children:[(0,t.jsx)(re,{children:(0,t.jsxs)(L,{children:[(0,t.jsx)(h,{children:e("Workflow")}),(0,t.jsx)(h,{children:e("Instance id")}),(0,t.jsx)(h,{children:e("Status")}),(0,t.jsx)(h,{children:e("Output")}),(0,t.jsx)(h,{})]})}),(0,t.jsx)(ne,{children:O.map(r=>(0,t.jsxs)(L,{"data-testid":`workflows-instance-${r.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:r.exportName}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:r.id}),(0,t.jsx)(p,{className:"font-mono text-xs",children:r.status}),(0,t.jsx)(p,{className:"font-mono text-xs text-muted-foreground",children:De(r)}),(0,t.jsx)(p,{children:(0,t.jsx)(q,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:W===r.id,onClick:f,size:"xs",variant:"outline",children:W===r.id?e("Refreshing\u2026"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),k!==void 0&&(0,t.jsx)(Te,{workflowName:k.name})]})},"Ze");function Le(l){return(0,t.jsx)("option",{value:l,children:l},l)}s(Le,"De");export{Ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as i}from"./chunk-
|
|
1
|
+
import{x as i}from"./chunk-PN7JHEYW.js";import{a as d}from"./chunk-A6TVTNKO.js";import{b as p}from"./chunk-ADABTCDI.js";import{a as l,d as m}from"./chunk-5PEAXTYQ.js";var n=m(d(),1);var c=m(p(),1);function f(r){let t=(0,n.c)(8),e,s;t[0]!==r?({className:e,...s}=r,t[0]=r,t[1]=e,t[2]=s):(e=t[1],s=t[2]);let a;t[3]!==e?(a=i("animate-pulse rounded-md bg-muted",e),t[3]=e,t[4]=a):a=t[4];let o;return t[5]!==s||t[6]!==a?(o=(0,c.jsx)("div",{"data-slot":"skeleton",className:a,...s}),t[5]=s,t[6]=a,t[7]=o):o=t[7],o}l(f,"p");export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-TN4Z3P6S.js";import{a as h}from"./chunk-A6TVTNKO.js";import{b as N}from"./chunk-ADABTCDI.js";import{a as u,d as x}from"./chunk-5PEAXTYQ.js";var b=x(h(),1);var t=x(N(),1);var v=u(g=>{let e=(0,b.c)(16),{chart:c,footer:n,label:i,testId:m,value:p}=g,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=r):r=e[1];let a;e[2]!==m||e[3]!==p?(a=(0,t.jsx)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":m,children:p}),e[2]=m,e[3]=p,e[4]=a):a=e[4];let s;e[5]!==c||e[6]!==a?(s=(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[a,c]}),e[5]=c,e[6]=a,e[7]=s):s=e[7];let l;e[8]!==r||e[9]!==s?(l=(0,t.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[r,s]}),e[8]=r,e[9]=s,e[10]=l):l=e[10];let o;e[11]!==n?(o=n!=null&&(0,t.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:n}),e[11]=n,e[12]=o):o=e[12];let d;return e[13]!==l||e[14]!==o?(d=(0,t.jsxs)(f,{className:"justify-between gap-0 py-0",children:[l,o]}),e[13]=l,e[14]=o,e[15]=d):d=e[15],d},"j");export{v as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as we}from"./chunk-W7CLOQOU.js";import{b as xe,c as Ne}from"./chunk-MHZNDDGI.js";import{a as me}from"./chunk-KXUK7CSR.js";import{a as Se,b as Ce,c as Ee,d as Ke,e as Fe}from"./chunk-NDIEUO4N.js";import"./chunk-T7UKRA6J.js";import{a as ue}from"./chunk-5MIJ3KEK.js";import{a as Y}from"./chunk-AWFFXR6S.js";import"./chunk-QF743FSL.js";import{h as ve,i as pe,j as ye,k as he}from"./chunk-XSFGXEYO.js";import"./chunk-AFLNQEZ5.js";import"./chunk-WONKLAKW.js";import"./chunk-CL3JOU6F.js";import"./chunk-MICDQTTJ.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-KVQ2GMJR.js";import"./chunk-2NUCBQFU.js";import"./chunk-DA2CAFXI.js";import"./chunk-MTBY4GXM.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as ae}from"./chunk-V4JKKAAZ.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as R}from"./chunk-VGKDC2OQ.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as fe}from"./chunk-NQ727GVM.js";import{b as be}from"./chunk-F2DVDJV6.js";import"./chunk-L27FKJTG.js";import{a as ie,b as oe,c as ce,d as Q,e as U,f as X}from"./chunk-4TGALJHR.js";import"./chunk-MNXXIISC.js";import"./chunk-EOFWXI3T.js";import"./chunk-LYVYUTQY.js";import"./chunk-YL5ZAR3P.js";import{a as de,e as se}from"./chunk-ZZ6ZCOD4.js";import{n as G}from"./chunk-KQVY73EU.js";import"./chunk-ZPQBVYNN.js";import{B as H,j as W,o as ge,s as P,v as ne}from"./chunk-VJQP4ARP.js";import"./chunk-PDBW6GTJ.js";import{a as $e}from"./chunk-A6TVTNKO.js";import{a as Re,b as Ae}from"./chunk-ADABTCDI.js";import{a as d,d as re}from"./chunk-5PEAXTYQ.js";var _=re(Re(),1);var ee=re($e(),1);var a=re(Ae(),1);var Pe=d(l=>{let e=l.trim();if(e==="")return;let n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},"Je"),je=d(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"He"),We=d(l=>new TextEncoder().encode(l).length,"We"),Oe=d(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"Ce"),Ie=d(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"Ee"),Be=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Te=d((l,e)=>{let n=l.trim();if(n==="")return"";let s=Number(n),i=Be.find(y=>y.key===e)?.seconds??1;return Number.isFinite(s)&&s>0?String(Math.round(s*i)):n},"ve"),_e=d(l=>{let e=l.trim();if(e==="")return!0;let n=Number(e);return Number.isInteger(n)&&n>=60},"Te"),Le=d((l,e,n,s)=>{let i=Pe(l.ttl);return{expiration:i===void 0?s:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:n,value:l.value}},"Ke"),De=d(l=>{let e=(0,ee.c)(60),{helper:n,id:s,invalid:i,onChange:y,testId:o}=l,t=H(),[r,h]=(0,_.useState)(""),[m,x]=(0,_.useState)("seconds"),N;e[0]!==y||e[1]!==m?(N=d(C=>{h(C.target.value),y(Te(C.target.value,m))},"x"),e[0]=y,e[1]=m,e[2]=N):N=e[2];let T=N,V;e[3]!==r||e[4]!==y?(V=d(C=>{C!==null&&(x(C),y(Te(r,C)))},"F"),e[3]=r,e[4]=y,e[5]=V):V=e[5];let E=V,c;e[6]!==t?(c=t("days"),e[6]=t,e[7]=c):c=e[7];let u;e[8]!==t?(u=t("hours"),e[8]=t,e[9]=u):u=e[9];let p;e[10]!==t?(p=t("minutes"),e[10]=t,e[11]=p):p=e[11];let b;e[12]!==t?(b=t("seconds"),e[12]=t,e[13]=b):b=e[13];let f;e[14]!==c||e[15]!==u||e[16]!==p||e[17]!==b?(f={days:c,hours:u,minutes:p,seconds:b},e[14]=c,e[15]=u,e[16]=p,e[17]=b,e[18]=f):f=e[18];let w=f,g;e[19]!==t?(g=t("Expires after"),e[19]=t,e[20]=g):g=e[20];let S;e[21]!==s||e[22]!==g?(S=(0,a.jsx)(Y,{className:"text-xs",htmlFor:s,children:g}),e[21]=s,e[22]=g,e[23]=S):S=e[23];let M;e[24]!==t?(M=t("No expiration"),e[24]=t,e[25]=M):M=e[25];let D;e[26]!==r||e[27]!==s||e[28]!==i||e[29]!==T||e[30]!==M||e[31]!==o?(D=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:s,inputMode:"numeric",onChange:T,placeholder:M,value:r}),e[26]=r,e[27]=s,e[28]=i,e[29]=T,e[30]=M,e[31]=o,e[32]=D):D=e[32];let O;e[33]!==t?(O=t("TTL unit"),e[33]=t,e[34]=O):O=e[34];let J=`${o}-unit`,z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(Ce,{}),e[35]=z):z=e[35];let I;e[36]!==O||e[37]!==J?(I=(0,a.jsx)(Ee,{"aria-label":O,className:"w-[7.5rem]","data-testid":J,children:z}),e[36]=O,e[37]=J,e[38]=I):I=e[38];let v;e[39]!==w?(v=Be.map(C=>(0,a.jsx)(Fe,{value:C.key,children:w[C.key]},C.key)),e[39]=w,e[40]=v):v=e[40];let k;e[41]!==v?(k=(0,a.jsx)(Ke,{children:v}),e[41]=v,e[42]=k):k=e[42];let K;e[43]!==E||e[44]!==I||e[45]!==k||e[46]!==m?(K=(0,a.jsxs)(Se,{onValueChange:E,value:m,children:[I,k]}),e[43]=E,e[44]=I,e[45]=k,e[46]=m,e[47]=K):K=e[47];let B;e[48]!==D||e[49]!==K?(B=(0,a.jsxs)("div",{className:"flex gap-2",children:[D,K]}),e[48]=D,e[49]=K,e[50]=B):B=e[50];let F;e[51]!==n||e[52]!==i||e[53]!==t||e[54]!==o?(F=i?(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]=i,e[53]=t,e[54]=o,e[55]=F):F=e[55];let L;return e[56]!==B||e[57]!==F||e[58]!==S?(L=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,B,F]}),e[56]=B,e[57]=F,e[58]=S,e[59]=L):L=e[59],L},"_e"),ze=d(l=>{let e=(0,ee.c)(36),{id:n,invalidTestId:s,onChange:i,testId:y,valid:o,value:t}=l,r=H(),h;e[0]!==t?(h=Oe(t),e[0]=t,e[1]=h):h=e[1];let m=h,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let N;e[4]!==n||e[5]!==x?(N=(0,a.jsx)(Y,{className:"text-xs",htmlFor:n,children:x}),e[4]=n,e[5]=x,e[6]=N):N=e[6];let T=`${y}-format`,V=m===void 0,E;e[7]!==m||e[8]!==i?(E=d(()=>{m!==void 0&&i(m)},"w"),e[7]=m,e[8]=i,e[9]=E):E=e[9];let c;e[10]!==r?(c=r("Format JSON"),e[10]=r,e[11]=c):c=e[11];let u;e[12]!==T||e[13]!==V||e[14]!==E||e[15]!==c?(u=(0,a.jsx)(R,{"data-testid":T,disabled:V,onClick:E,size:"sm",variant:"outline",children:c}),e[12]=T,e[13]=V,e[14]=E,e[15]=c,e[16]=u):u=e[16];let p;e[17]!==N||e[18]!==u?(p=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[N,u]}),e[17]=N,e[18]=u,e[19]=p):p=e[19];let b=!o,f;e[20]!==i?(f=d(M=>{i(M.target.value)},"b"),e[20]=i,e[21]=f):f=e[21];let w;e[22]!==n||e[23]!==b||e[24]!==f||e[25]!==y||e[26]!==t?(w=(0,a.jsx)(ue,{"aria-invalid":b,className:"min-h-[4rem] font-mono text-xs","data-testid":y,id:n,onChange:f,value:t}),e[22]=n,e[23]=b,e[24]=f,e[25]=y,e[26]=t,e[27]=w):w=e[27];let g;e[28]!==s||e[29]!==r||e[30]!==o?(g=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":s,children:r("Metadata must be valid JSON.")}),e[28]=s,e[29]=r,e[30]=o,e[31]=g):g=e[31];let S;return e[32]!==w||e[33]!==g||e[34]!==p?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[p,w,g]}),e[32]=w,e[33]=g,e[34]=p,e[35]=S):S=e[35],S},"Fe"),He={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},qe=d((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Ue"),Ze=d(l=>{let e=(0,ee.c)(73),{namespace:n,onCancel:s,onCreated:i}=l,y=G(),o=H(),[t,r]=(0,_.useReducer)(qe,He),h;e[0]!==t.metadata?(h=Ie(t.metadata),e[0]=t.metadata,e[1]=h):h=e[1];let m=h,x;e[2]!==t.ttl?(x=_e(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let N=x,T;e[4]!==m||e[5]!==t.busy||e[6]!==t.name||e[7]!==N?(T=t.name.trim()!==""&&m&&N&&!t.busy,e[4]=m,e[5]=t.busy,e[6]=t.name,e[7]=N,e[8]=T):T=e[8];let V=T,E;e[9]!==V||e[10]!==y||e[11]!==n||e[12]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(E=d(()=>{V&&(r({type:"submitStart"}),P((async()=>{try{await y.putKvValue(Le({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),i()}catch(A){r({error:W(A),type:"submitFailed"})}})()))},"w"),e[9]=V,e[10]=y,e[11]=n,e[12]=i,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=E):E=e[17];let c=E,u;e[18]!==o?(u=o("Key name"),e[18]=o,e[19]=u):u=e[19];let p;e[20]!==u?(p=(0,a.jsx)(Y,{className:"text-xs",htmlFor:"kv-create-name",children:u}),e[20]=u,e[21]=p):p=e[21];let b;e[22]===Symbol.for("react.memo_cache_sentinel")?(b=d(A=>{r({field:"name",type:"setField",value:A.target.value})},"y"),e[22]=b):b=e[22];let f;e[23]!==o?(f=o("Key name"),e[23]=o,e[24]=f):f=e[24];let w;e[25]!==t.name||e[26]!==f?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:b,placeholder:f,value:t.name}),e[25]=t.name,e[26]=f,e[27]=w):w=e[27];let g;e[28]!==p||e[29]!==w?(g=(0,a.jsxs)("div",{className:"grid gap-1",children:[p,w]}),e[28]=p,e[29]=w,e[30]=g):g=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let M;e[33]!==S?(M=(0,a.jsx)(Y,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=M):M=e[34];let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=d(A=>{r({field:"value",type:"setField",value:A.target.value})},"B"),e[35]=D):D=e[35];let O;e[36]!==t.value?(O=(0,a.jsx)(ue,{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]=O):O=e[37];let J;e[38]!==M||e[39]!==O?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[M,O]}),e[38]=M,e[39]=O,e[40]=J):J=e[40];let z=!N,I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=d(A=>{r({field:"ttl",type:"setField",value:A})},"L"),e[41]=I):I=e[41];let v;e[42]!==z?(v=(0,a.jsx)(De,{id:"kv-create-ttl",invalid:z,onChange:I,testId:"kv-create-ttl"}),e[42]=z,e[43]=v):v=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=d(A=>{r({field:"metadata",type:"setField",value:A})},"h"),e[44]=k):k=e[44];let K;e[45]!==m||e[46]!==t.metadata?(K=(0,a.jsx)(ze,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:m,value:t.metadata}),e[45]=m,e[46]=t.metadata,e[47]=K):K=e[47];let B=!V,F;e[48]!==t.busy||e[49]!==o?(F=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=F):F=e[50];let L;e[51]!==c||e[52]!==B||e[53]!==F?(L=(0,a.jsx)(R,{"data-testid":"kv-create-submit",disabled:B,onClick:c,children:F}),e[51]=c,e[52]=B,e[53]=F,e[54]=L):L=e[54];let C=t.busy,$;e[55]!==o?($=o("Cancel"),e[55]=o,e[56]=$):$=e[56];let j;e[57]!==s||e[58]!==t.busy||e[59]!==$?(j=(0,a.jsx)(R,{"data-testid":"kv-create-cancel",disabled:C,onClick:s,variant:"outline",children:$}),e[57]=s,e[58]=t.busy,e[59]=$,e[60]=j):j=e[60];let q;e[61]!==L||e[62]!==j?(q=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,j]}),e[61]=L,e[62]=j,e[63]=q):q=e[63];let Z;e[64]!==t.error?(Z=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]=Z):Z=e[65];let te;return e[66]!==g||e[67]!==J||e[68]!==v||e[69]!==K||e[70]!==q||e[71]!==Z?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[g,J,v,K,q,Z]}),e[66]=g,e[67]=J,e[68]=v,e[69]=K,e[70]=q,e[71]=Z,e[72]=te):te=e[72],te},"Ze"),le=33,Ve=600,Ye=d(l=>{for(let e=l?.parentElement??null;e!==null;e=e.parentElement){let{overflowY:n}=getComputedStyle(e);if(n==="auto"||n==="scroll")return e}return document.scrollingElement},"qe"),Je=d((l,e,n)=>{if(l===null||typeof ResizeObserver>"u")return;let s=new ResizeObserver(n),i=[];for(let t=l;t!==null&&t!==e;t=t.parentElement)i.push(t);let y=d(()=>{s.disconnect();for(let t of i)for(let r=t.previousElementSibling;r!==null;r=r.previousElementSibling)s.observe(r)},"v");y();let o=typeof MutationObserver>"u"?void 0:new MutationObserver(()=>{y(),n()});for(let t of i)t.parentElement!==null&&o?.observe(t.parentElement,{childList:!0});return()=>{o?.disconnect(),s.disconnect()}},"Ve"),ke=d(l=>l.scrollElement===document.scrollingElement,"ae"),Ge=d((l,e,n)=>{let s=l.targetWindow;if(!s)return;let i=d(r=>{e(Math.max(0,-(n()?.getBoundingClientRect().top??0)),r)},"i"),y=d(()=>{i(!0)},"v"),o=d(()=>{i(!1)},"d");i(!1),s.addEventListener("scroll",y,{passive:!0}),s.addEventListener("scrollend",o);let t=Je(n(),null,o);return()=>{t?.(),s.removeEventListener("scroll",y),s.removeEventListener("scrollend",o)}},"Ge"),Qe=d((l,e)=>{let n=l.targetWindow;if(!n)return;let s=d(()=>{e({height:n.innerHeight,width:n.innerWidth})},"s");return s(),n.addEventListener("resize",s),()=>{n.removeEventListener("resize",s)}},"Ye"),Ue=d(({allSelected:l,bulkSelected:e,keys:n,onSelectKey:s,onToggleAll:i,onToggleBulk:y,selectedKey:o})=>{let t=H(),r=(0,_.useRef)(null),h=(0,_.useRef)(null),m=Ne({count:n.length,estimateSize:d(()=>le,"estimateSize"),getItemKey:d(c=>n[c]?.name??c,"getItemKey"),getScrollElement:d(()=>Ye(r.current),"getScrollElement"),initialRect:{height:Ve,width:800},observeElementOffset:d((c,u)=>{if(ke(c))return Ge(c,u,()=>r.current);let p=d(w=>{let g=c.scrollElement,S=r.current;u(g&&S?Math.max(0,g.getBoundingClientRect().top-S.getBoundingClientRect().top):0,w)},"f"),b=xe(c,(w,g)=>{p(g)}),f=Je(r.current,c.scrollElement,()=>{p(!1)});return()=>{f?.(),b?.()}},"observeElementOffset"),observeElementRect:d((c,u)=>ke(c)?Qe(c,u):we(c,u,Ve),"observeElementRect"),overscan:12}),x=m.getVirtualItems(),N=x[0]?.start??0,T=m.getTotalSize()-(x.at(-1)?.end??0),V=d(c=>{let u=c.key==="Tab"&&c.target instanceof Element?c.target.closest("[data-index]"):null;if(u===null)return;let p=c.shiftKey?-1:1,b=(h.current?.index??Number(u.dataset.index))+p,f=n[b];f===void 0||h.current===null&&u.parentElement?.querySelector(`[data-index="${String(b)}"]`)||(c.preventDefault(),h.current={index:b,name:f.name},ke(m)?m.targetWindow?.scrollBy(0,p*le):m.scrollElement?.scrollBy(0,p*le))},"F");(0,_.useEffect)(()=>{let c=h.current?.name,u=(c===void 0?void 0:[...r.current?.querySelectorAll("[data-key]")??[]].find(p=>p.dataset.key===c))?.querySelector('[data-testid^="kv-select-"]');u&&(h.current=null,u.focus())});let E=0;for(let c of n)E=Math.max(E,c.name.length);return(0,a.jsxs)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(oe,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(U,{className:"w-10",children:(0,a.jsx)(me,{"aria-label":t("Select all"),checked:l,"data-testid":"kv-select-all",onCheckedChange:i})}),(0,a.jsx)(U,{children:t("Key")}),(0,a.jsx)(U,{children:t("Expiration")})]})}),(0,a.jsxs)(ce,{onKeyDown:V,ref:r,children:[N>0&&(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:N}}),x.map(c=>{let u=n[c.index];return u===void 0?null:(0,a.jsxs)(Q,{className:u.name===o?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":c.index,"data-key":u.name,"data-testid":`kv-key-row-${u.name}`,onClick:s,style:{height:le},children:[(0,a.jsx)(X,{onClick:d(p=>{p.stopPropagation()},"onClick"),children:(0,a.jsx)(me,{"aria-label":t("Select {name}",{name:u.name}),checked:e.has(u.name),"data-testid":`kv-select-${u.name}`,onCheckedChange:d(()=>{y(u.name)},"onCheckedChange")})}),(0,a.jsx)(X,{className:"font-mono text-xs",style:{width:`${String(E)}ch`},children:u.name}),(0,a.jsx)(X,{className:"tabular-nums text-xs",children:je(u.expiration)})]},u.name)}),T>0&&(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:T}})]})]})},"Qe"),Xe={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},et=d((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,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{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"et"),tt=d(l=>{let e=(0,ee.c)(67),{expiration:n,keyName:s,namespace:i,onDeleted:y}=l,o=G(),t=H(),[r,h]=(0,_.useReducer)(et,Xe),m,x;e[0]!==o||e[1]!==s||e[2]!==i?(m=d(()=>{let C={cancelled:!1};return P((async()=>{try{let $=await o.getKvValue({key:s,namespace:i});C.cancelled||h({metadata:$.metadata,type:"loaded",value:$.value})}catch($){let j=$;C.cancelled||h({error:W(j),type:"loadFailed"})}})()),()=>{C.cancelled=!0}},"c"),x=[o,i,s],e[0]=o,e[1]=s,e[2]=i,e[3]=m,e[4]=x):(m=e[3],x=e[4]),(0,_.useEffect)(m,x);let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=d(C=>{h({type:"editValue",value:C.target.value})},"x"),e[5]=N):N=e[5];let T=N,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=d(C=>{h({type:"editMetadata",value:C})},"F"),e[6]=V):V=e[6];let E=V,c;e[7]!==r.editedValue?(c=Oe(r.editedValue),e[7]=r.editedValue,e[8]=c):c=e[8];let u=c,p;e[9]!==r.editedMetadata?(p=Ie(r.editedMetadata),e[9]=r.editedMetadata,e[10]=p):p=e[10];let b=p,f;e[11]!==r.editedTtl?(f=_e(r.editedTtl),e[11]=r.editedTtl,e[12]=f):f=e[12];let w=f,g;e[13]!==u?(g=d(()=>{u!==void 0&&h({type:"editValue",value:u})},"g"),e[13]=u,e[14]=g):g=e[14];let S=g,M;e[15]!==o||e[16]!==n||e[17]!==s||e[18]!==b||e[19]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(M=d(()=>{if(!b){h({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}h({type:"saveStart"}),P((async()=>{try{await o.putKvValue(Le({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},s,i,n)),h({type:"saveOk"})}catch(C){h({error:W(C),type:"writeFailed"})}})())},"V"),e[15]=o,e[16]=n,e[17]=s,e[18]=b,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=M):M=e[24];let D=M,O;e[25]!==o||e[26]!==s||e[27]!==i||e[28]!==y?(O=d(()=>{h({type:"deleteStart"}),P((async()=>{try{await o.deleteKvKey({key:s,namespace:i}),y(s)}catch(C){h({error:W(C),type:"writeFailed"})}})())},"I"),e[25]=o,e[26]=s,e[27]=i,e[28]=y,e[29]=O):O=e[29];let J=O,z;e[30]!==s?(z=d(()=>{ne(s)},"D"),e[30]=s,e[31]=z):z=e[31];let I;e[32]!==t?(I=t("Copy key"),e[32]=t,e[33]=I):I=e[33];let v;e[34]!==z||e[35]!==I?(v=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)(R,{"data-testid":"kv-copy-key-btn",onClick:z,size:"sm",variant:"outline",children:I})}),e[34]=z,e[35]=I,e[36]=v):v=e[36];let k;e[37]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let K;e[39]!==r.loading||e[40]!==t?(K=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=K):K=e[41];let B;e[42]!==u||e[43]!==b||e[44]!==J||e[45]!==S||e[46]!==D||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(B=!r.loading&&r.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)(Y,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),u!==void 0&&(0,a.jsx)(be,{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(We(r.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:T,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)(R,{"data-testid":"kv-format-btn",disabled:u===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)(R,{"data-testid":"kv-copy-value-btn",onClick:d(()=>{ne(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(De,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:d(C=>{h({type:"editTtl",value:C})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(ze,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:E,testId:"kv-metadata-editor",valid:b,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(R,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!b||!w,onClick:D,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)(R,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=u,e[43]=b,e[44]=J,e[45]=S,e[46]=D,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=B):B=e[55];let F;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(F=!r.loading&&r.value===null&&r.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]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=F):F=e[60];let L;return e[61]!==v||e[62]!==k||e[63]!==K||e[64]!==B||e[65]!==F?(L=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[v,k,K,B,F]}),e[61]=v,e[62]=k,e[63]=K,e[64]=B,e[65]=F,e[66]=L):L=e[66],L},"tt"),Me=100,at={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},lt=d((l,e)=>{switch(e.type){case"appendPage":return e.generation!==l.reloadNonce?l:{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let n=new Set(e.deleted);return{...l,bulk:l.bulk.filter(s=>!n.has(s)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(s=>!n.has(s.name)),selectedKey:l.selectedKey!==null&&n.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(n=>n!==e.name),keys:l.keys===null?null:l.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return e.generation!==void 0&&e.generation!==l.reloadNonce?l:{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(n=>n!==e.name):[...l.bulk,e.name]};default:return l}},"rt"),rt=d(({namespace:l})=>{let e=G(),n=H(),[s,i]=(0,_.useReducer)(lt,at),{appliedPrefix:y,bulk:o,bulkBusy:t,bulkError:r,cursor:h,keys:m,listComplete:x,loadError:N,loading:T,prefixInput:V,reloadNonce:E,selectedKey:c}=s,[u,p]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let v={cancelled:!1};return P((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Me,namespace:l,prefix:y===""?void 0:y});v.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){v.cancelled||i({error:W(k),type:"loadFailed"})}})()),()=>{v.cancelled=!0}},[e,l,y,E]);let b=d(v=>{i({type:"prefixInput",value:v.target.value})},"y"),f=d(()=>{i({type:"applyFilter"})},"b"),w=d(v=>{i({name:v.currentTarget.dataset.key??null,type:"selectKey"})},"N"),g=d(()=>{if(h===null)return;i({type:"loadStart"});let v=E;P((async()=>{try{let k=await e.listKvKeys({cursor:h,limit:Me,namespace:l,prefix:y===""?void 0:y});i({cursor:k.cursor??null,generation:v,keys:k.keys,listComplete:k.listComplete,type:"appendPage"})}catch(k){i({error:W(k),generation:v,type:"loadFailed"})}})())},"g"),S=d(v=>{i({name:v,type:"keyDeleted"})},"S"),M=d(v=>{i({name:v,type:"toggleBulk"})},"V"),D=d(v=>{i({names:v&&m!==null?m.map(k=>k.name):[],type:"toggleAllBulk"})},"B"),O=d(()=>{if(o.length===0)return;let v=[...o];i({type:"bulkDeleteStart"}),P((async()=>{let k=await Promise.allSettled(v.map(F=>e.deleteKvKey({key:F,namespace:l}))),K=v.filter((F,L)=>k[L]?.status==="fulfilled"),B=v.length-K.length;i({deleted:K,error:B>0?n("Failed to delete {count} keys.",{count:B}):null,type:"bulkDeleted"})})())},"I"),J=d(()=>{p(!1),i({type:"reload"})},"A"),z=m!==null&&m.length>0&&o.length===m.length,I=new Set(o);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:b,placeholder:n("Filter by prefix\u2026"),value:V}),(0,a.jsx)(R,{"data-testid":"kv-filter-btn",disabled:T,onClick:f,children:n("Filter")}),(0,a.jsx)(R,{"data-testid":"kv-new-key-btn",onClick:d(()=>{p(v=>!v)},"onClick"),variant:"outline",children:n("New key")}),o.length>0&&(0,a.jsx)(R,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:O,variant:"destructive",children:t?n("Deleting\u2026"):n("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),N!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:N}),m!==null&&m.length===0&&!T&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),m!==null&&m.length>0&&(0,a.jsx)(de,{className:"overflow-hidden py-0",children:(0,a.jsx)(se,{className:"px-0",children:(0,a.jsx)(Ue,{allSelected:z,bulkSelected:I,keys:m,onSelectKey:w,onToggleAll:D,onToggleBulk:M,selectedKey:c})})}),!x&&h!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(R,{"data-testid":"kv-load-more",disabled:T,onClick:g,variant:"outline",children:n(T?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(ve,{onOpenChange:d(v=>{v||p(!1)},"onOpenChange"),open:u,children:(0,a.jsxs)(pe,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(ye,{children:(0,a.jsx)(he,{children:n("New key")})}),(0,a.jsx)(Ze,{namespace:l,onCancel:d(()=>{p(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(ve,{onOpenChange:d(v=>{v||i({name:null,type:"selectKey"})},"onOpenChange"),open:c!==null,children:(0,a.jsxs)(pe,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(ye,{children:(0,a.jsx)(he,{className:"truncate font-mono text-xs",children:c})}),c!==null&&(0,a.jsx)(tt,{expiration:m?.find(v=>v.name===c)?.expiration,keyName:c,namespace:l,onDeleted:S},`${l}:${c}`)]})})]})},"at"),xt=d(({loadNamespaces:l}={})=>{let e=G(),n=H(),[s,i]=(0,_.useState)(null),[y,o]=(0,_.useState)(null),[t,r]=(0,_.useState)(null);(0,_.useEffect)(()=>{let m={cancelled:!1};return P((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();m.cancelled||(i(x),o(null),r(N=>N??x[0]?.binding??null))}catch(x){m.cancelled||(i(null),o(W(x)))}})()),()=>{m.cancelled=!0}},[e,l]);let h=d(m=>{r(m.currentTarget.dataset.ns??null)},"p");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[y!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:y}),s!==null&&s.length===0&&(0,a.jsx)(fe,{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.")}),s!==null&&s.length>0&&(0,a.jsx)(de,{className:"overflow-hidden py-0",children:(0,a.jsx)(se,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(oe,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(U,{children:n("Namespace")})})}),(0,a.jsx)(ce,{children:s.map(m=>(0,a.jsx)(Q,{className:m.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":m.binding,"data-testid":`kv-ns-row-${m.binding}`,onClick:h,children:(0,a.jsx)(X,{className:"font-mono text-xs",children:m.binding})},m.binding))})]})})}),t!==null&&(0,a.jsx)(rt,{namespace:t},t)]})},"Et");export{xt as KvBrowser};
|
|
1
|
+
import{a as we}from"./chunk-W7CLOQOU.js";import{b as xe,c as Ne}from"./chunk-MHZNDDGI.js";import{a as me}from"./chunk-MMRSSV2C.js";import{a as Se,b as Ce,c as Ee,d as Ke,e as Fe}from"./chunk-54X7HWI6.js";import"./chunk-T7UKRA6J.js";import{a as ue}from"./chunk-4AGOKKRZ.js";import{a as Y}from"./chunk-CJ2V577P.js";import"./chunk-QF743FSL.js";import{h as ve,i as pe,j as ye,k as he}from"./chunk-Q4SE33KY.js";import"./chunk-AFLNQEZ5.js";import"./chunk-CNALVIPZ.js";import"./chunk-CL3JOU6F.js";import"./chunk-HPTF52JF.js";import"./chunk-IQ5CIBXJ.js";import"./chunk-YNCZVYCO.js";import"./chunk-OWRWDDJT.js";import"./chunk-QHVUXMRV.js";import"./chunk-HB2FLDDU.js";import"./chunk-2NUCBQFU.js";import"./chunk-DA2CAFXI.js";import"./chunk-DWNWEMQK.js";import"./chunk-4KPATTV6.js";import"./chunk-7WGZSDRS.js";import"./chunk-N7FOBAV3.js";import{i as ae}from"./chunk-OKZINWBB.js";import"./chunk-4SY2N2RS.js";import"./chunk-4AG356VE.js";import{a as R}from"./chunk-NVMQPIRS.js";import"./chunk-SCTYLLJT.js";import"./chunk-OZID3UYF.js";import{a as fe}from"./chunk-S3TDGFRE.js";import{b as be}from"./chunk-UV6GPH2E.js";import"./chunk-L27FKJTG.js";import{a as ie,b as oe,c as ce,d as Q,e as U,f as X}from"./chunk-J3ZEO3PJ.js";import"./chunk-5CHKXJYN.js";import"./chunk-EOFWXI3T.js";import"./chunk-LYVYUTQY.js";import"./chunk-UN3QTZ6X.js";import{a as de,e as se}from"./chunk-TN4Z3P6S.js";import{n as G}from"./chunk-5KQSRLQP.js";import"./chunk-ZPQBVYNN.js";import{B as H,j as W,o as ge,s as P,v as ne}from"./chunk-PN7JHEYW.js";import"./chunk-PDBW6GTJ.js";import{a as $e}from"./chunk-A6TVTNKO.js";import{a as Re,b as Ae}from"./chunk-ADABTCDI.js";import{a as d,d as re}from"./chunk-5PEAXTYQ.js";var _=re(Re(),1);var ee=re($e(),1);var a=re(Ae(),1);var Pe=d(l=>{let e=l.trim();if(e==="")return;let n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},"Je"),je=d(l=>l===void 0?"\u2014":new Date(l*1e3).toISOString(),"He"),We=d(l=>new TextEncoder().encode(l).length,"We"),Oe=d(l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},"Ce"),Ie=d(l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},"Ee"),Be=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Te=d((l,e)=>{let n=l.trim();if(n==="")return"";let s=Number(n),i=Be.find(y=>y.key===e)?.seconds??1;return Number.isFinite(s)&&s>0?String(Math.round(s*i)):n},"ve"),_e=d(l=>{let e=l.trim();if(e==="")return!0;let n=Number(e);return Number.isInteger(n)&&n>=60},"Te"),Le=d((l,e,n,s)=>{let i=Pe(l.ttl);return{expiration:i===void 0?s:void 0,expirationTtl:i,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:n,value:l.value}},"Ke"),De=d(l=>{let e=(0,ee.c)(60),{helper:n,id:s,invalid:i,onChange:y,testId:o}=l,t=H(),[r,h]=(0,_.useState)(""),[m,x]=(0,_.useState)("seconds"),N;e[0]!==y||e[1]!==m?(N=d(C=>{h(C.target.value),y(Te(C.target.value,m))},"x"),e[0]=y,e[1]=m,e[2]=N):N=e[2];let T=N,V;e[3]!==r||e[4]!==y?(V=d(C=>{C!==null&&(x(C),y(Te(r,C)))},"F"),e[3]=r,e[4]=y,e[5]=V):V=e[5];let E=V,c;e[6]!==t?(c=t("days"),e[6]=t,e[7]=c):c=e[7];let u;e[8]!==t?(u=t("hours"),e[8]=t,e[9]=u):u=e[9];let p;e[10]!==t?(p=t("minutes"),e[10]=t,e[11]=p):p=e[11];let b;e[12]!==t?(b=t("seconds"),e[12]=t,e[13]=b):b=e[13];let f;e[14]!==c||e[15]!==u||e[16]!==p||e[17]!==b?(f={days:c,hours:u,minutes:p,seconds:b},e[14]=c,e[15]=u,e[16]=p,e[17]=b,e[18]=f):f=e[18];let w=f,g;e[19]!==t?(g=t("Expires after"),e[19]=t,e[20]=g):g=e[20];let S;e[21]!==s||e[22]!==g?(S=(0,a.jsx)(Y,{className:"text-xs",htmlFor:s,children:g}),e[21]=s,e[22]=g,e[23]=S):S=e[23];let M;e[24]!==t?(M=t("No expiration"),e[24]=t,e[25]=M):M=e[25];let D;e[26]!==r||e[27]!==s||e[28]!==i||e[29]!==T||e[30]!==M||e[31]!==o?(D=(0,a.jsx)(ae,{"aria-invalid":i,className:"flex-1","data-testid":o,id:s,inputMode:"numeric",onChange:T,placeholder:M,value:r}),e[26]=r,e[27]=s,e[28]=i,e[29]=T,e[30]=M,e[31]=o,e[32]=D):D=e[32];let O;e[33]!==t?(O=t("TTL unit"),e[33]=t,e[34]=O):O=e[34];let J=`${o}-unit`,z;e[35]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)(Ce,{}),e[35]=z):z=e[35];let I;e[36]!==O||e[37]!==J?(I=(0,a.jsx)(Ee,{"aria-label":O,className:"w-[7.5rem]","data-testid":J,children:z}),e[36]=O,e[37]=J,e[38]=I):I=e[38];let v;e[39]!==w?(v=Be.map(C=>(0,a.jsx)(Fe,{value:C.key,children:w[C.key]},C.key)),e[39]=w,e[40]=v):v=e[40];let k;e[41]!==v?(k=(0,a.jsx)(Ke,{children:v}),e[41]=v,e[42]=k):k=e[42];let K;e[43]!==E||e[44]!==I||e[45]!==k||e[46]!==m?(K=(0,a.jsxs)(Se,{onValueChange:E,value:m,children:[I,k]}),e[43]=E,e[44]=I,e[45]=k,e[46]=m,e[47]=K):K=e[47];let B;e[48]!==D||e[49]!==K?(B=(0,a.jsxs)("div",{className:"flex gap-2",children:[D,K]}),e[48]=D,e[49]=K,e[50]=B):B=e[50];let F;e[51]!==n||e[52]!==i||e[53]!==t||e[54]!==o?(F=i?(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]=i,e[53]=t,e[54]=o,e[55]=F):F=e[55];let L;return e[56]!==B||e[57]!==F||e[58]!==S?(L=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[S,B,F]}),e[56]=B,e[57]=F,e[58]=S,e[59]=L):L=e[59],L},"_e"),ze=d(l=>{let e=(0,ee.c)(36),{id:n,invalidTestId:s,onChange:i,testId:y,valid:o,value:t}=l,r=H(),h;e[0]!==t?(h=Oe(t),e[0]=t,e[1]=h):h=e[1];let m=h,x;e[2]!==r?(x=r("Metadata (JSON)"),e[2]=r,e[3]=x):x=e[3];let N;e[4]!==n||e[5]!==x?(N=(0,a.jsx)(Y,{className:"text-xs",htmlFor:n,children:x}),e[4]=n,e[5]=x,e[6]=N):N=e[6];let T=`${y}-format`,V=m===void 0,E;e[7]!==m||e[8]!==i?(E=d(()=>{m!==void 0&&i(m)},"w"),e[7]=m,e[8]=i,e[9]=E):E=e[9];let c;e[10]!==r?(c=r("Format JSON"),e[10]=r,e[11]=c):c=e[11];let u;e[12]!==T||e[13]!==V||e[14]!==E||e[15]!==c?(u=(0,a.jsx)(R,{"data-testid":T,disabled:V,onClick:E,size:"sm",variant:"outline",children:c}),e[12]=T,e[13]=V,e[14]=E,e[15]=c,e[16]=u):u=e[16];let p;e[17]!==N||e[18]!==u?(p=(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[N,u]}),e[17]=N,e[18]=u,e[19]=p):p=e[19];let b=!o,f;e[20]!==i?(f=d(M=>{i(M.target.value)},"b"),e[20]=i,e[21]=f):f=e[21];let w;e[22]!==n||e[23]!==b||e[24]!==f||e[25]!==y||e[26]!==t?(w=(0,a.jsx)(ue,{"aria-invalid":b,className:"min-h-[4rem] font-mono text-xs","data-testid":y,id:n,onChange:f,value:t}),e[22]=n,e[23]=b,e[24]=f,e[25]=y,e[26]=t,e[27]=w):w=e[27];let g;e[28]!==s||e[29]!==r||e[30]!==o?(g=!o&&(0,a.jsx)("p",{className:"text-xs text-destructive","data-testid":s,children:r("Metadata must be valid JSON.")}),e[28]=s,e[29]=r,e[30]=o,e[31]=g):g=e[31];let S;return e[32]!==w||e[33]!==g||e[34]!==p?(S=(0,a.jsxs)("div",{className:"mb-3 grid gap-1",children:[p,w,g]}),e[32]=w,e[33]=g,e[34]=p,e[35]=S):S=e[35],S},"Fe"),He={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},qe=d((l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},"Ue"),Ze=d(l=>{let e=(0,ee.c)(73),{namespace:n,onCancel:s,onCreated:i}=l,y=G(),o=H(),[t,r]=(0,_.useReducer)(qe,He),h;e[0]!==t.metadata?(h=Ie(t.metadata),e[0]=t.metadata,e[1]=h):h=e[1];let m=h,x;e[2]!==t.ttl?(x=_e(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let N=x,T;e[4]!==m||e[5]!==t.busy||e[6]!==t.name||e[7]!==N?(T=t.name.trim()!==""&&m&&N&&!t.busy,e[4]=m,e[5]=t.busy,e[6]=t.name,e[7]=N,e[8]=T):T=e[8];let V=T,E;e[9]!==V||e[10]!==y||e[11]!==n||e[12]!==i||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(E=d(()=>{V&&(r({type:"submitStart"}),P((async()=>{try{await y.putKvValue(Le({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),i()}catch(A){r({error:W(A),type:"submitFailed"})}})()))},"w"),e[9]=V,e[10]=y,e[11]=n,e[12]=i,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=E):E=e[17];let c=E,u;e[18]!==o?(u=o("Key name"),e[18]=o,e[19]=u):u=e[19];let p;e[20]!==u?(p=(0,a.jsx)(Y,{className:"text-xs",htmlFor:"kv-create-name",children:u}),e[20]=u,e[21]=p):p=e[21];let b;e[22]===Symbol.for("react.memo_cache_sentinel")?(b=d(A=>{r({field:"name",type:"setField",value:A.target.value})},"y"),e[22]=b):b=e[22];let f;e[23]!==o?(f=o("Key name"),e[23]=o,e[24]=f):f=e[24];let w;e[25]!==t.name||e[26]!==f?(w=(0,a.jsx)(ae,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:b,placeholder:f,value:t.name}),e[25]=t.name,e[26]=f,e[27]=w):w=e[27];let g;e[28]!==p||e[29]!==w?(g=(0,a.jsxs)("div",{className:"grid gap-1",children:[p,w]}),e[28]=p,e[29]=w,e[30]=g):g=e[30];let S;e[31]!==o?(S=o("Value"),e[31]=o,e[32]=S):S=e[32];let M;e[33]!==S?(M=(0,a.jsx)(Y,{className:"text-xs",htmlFor:"kv-create-value",children:S}),e[33]=S,e[34]=M):M=e[34];let D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=d(A=>{r({field:"value",type:"setField",value:A.target.value})},"B"),e[35]=D):D=e[35];let O;e[36]!==t.value?(O=(0,a.jsx)(ue,{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]=O):O=e[37];let J;e[38]!==M||e[39]!==O?(J=(0,a.jsxs)("div",{className:"grid gap-1",children:[M,O]}),e[38]=M,e[39]=O,e[40]=J):J=e[40];let z=!N,I;e[41]===Symbol.for("react.memo_cache_sentinel")?(I=d(A=>{r({field:"ttl",type:"setField",value:A})},"L"),e[41]=I):I=e[41];let v;e[42]!==z?(v=(0,a.jsx)(De,{id:"kv-create-ttl",invalid:z,onChange:I,testId:"kv-create-ttl"}),e[42]=z,e[43]=v):v=e[43];let k;e[44]===Symbol.for("react.memo_cache_sentinel")?(k=d(A=>{r({field:"metadata",type:"setField",value:A})},"h"),e[44]=k):k=e[44];let K;e[45]!==m||e[46]!==t.metadata?(K=(0,a.jsx)(ze,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:k,testId:"kv-create-metadata",valid:m,value:t.metadata}),e[45]=m,e[46]=t.metadata,e[47]=K):K=e[47];let B=!V,F;e[48]!==t.busy||e[49]!==o?(F=t.busy?o("Creating\u2026"):o("Create key"),e[48]=t.busy,e[49]=o,e[50]=F):F=e[50];let L;e[51]!==c||e[52]!==B||e[53]!==F?(L=(0,a.jsx)(R,{"data-testid":"kv-create-submit",disabled:B,onClick:c,children:F}),e[51]=c,e[52]=B,e[53]=F,e[54]=L):L=e[54];let C=t.busy,$;e[55]!==o?($=o("Cancel"),e[55]=o,e[56]=$):$=e[56];let j;e[57]!==s||e[58]!==t.busy||e[59]!==$?(j=(0,a.jsx)(R,{"data-testid":"kv-create-cancel",disabled:C,onClick:s,variant:"outline",children:$}),e[57]=s,e[58]=t.busy,e[59]=$,e[60]=j):j=e[60];let q;e[61]!==L||e[62]!==j?(q=(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[L,j]}),e[61]=L,e[62]=j,e[63]=q):q=e[63];let Z;e[64]!==t.error?(Z=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]=Z):Z=e[65];let te;return e[66]!==g||e[67]!==J||e[68]!==v||e[69]!==K||e[70]!==q||e[71]!==Z?(te=(0,a.jsxs)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[g,J,v,K,q,Z]}),e[66]=g,e[67]=J,e[68]=v,e[69]=K,e[70]=q,e[71]=Z,e[72]=te):te=e[72],te},"Ze"),le=33,Ve=600,Ye=d(l=>{for(let e=l?.parentElement??null;e!==null;e=e.parentElement){let{overflowY:n}=getComputedStyle(e);if(n==="auto"||n==="scroll")return e}return document.scrollingElement},"qe"),Je=d((l,e,n)=>{if(l===null||typeof ResizeObserver>"u")return;let s=new ResizeObserver(n),i=[];for(let t=l;t!==null&&t!==e;t=t.parentElement)i.push(t);let y=d(()=>{s.disconnect();for(let t of i)for(let r=t.previousElementSibling;r!==null;r=r.previousElementSibling)s.observe(r)},"v");y();let o=typeof MutationObserver>"u"?void 0:new MutationObserver(()=>{y(),n()});for(let t of i)t.parentElement!==null&&o?.observe(t.parentElement,{childList:!0});return()=>{o?.disconnect(),s.disconnect()}},"Ve"),ke=d(l=>l.scrollElement===document.scrollingElement,"ae"),Ge=d((l,e,n)=>{let s=l.targetWindow;if(!s)return;let i=d(r=>{e(Math.max(0,-(n()?.getBoundingClientRect().top??0)),r)},"i"),y=d(()=>{i(!0)},"v"),o=d(()=>{i(!1)},"d");i(!1),s.addEventListener("scroll",y,{passive:!0}),s.addEventListener("scrollend",o);let t=Je(n(),null,o);return()=>{t?.(),s.removeEventListener("scroll",y),s.removeEventListener("scrollend",o)}},"Ge"),Qe=d((l,e)=>{let n=l.targetWindow;if(!n)return;let s=d(()=>{e({height:n.innerHeight,width:n.innerWidth})},"s");return s(),n.addEventListener("resize",s),()=>{n.removeEventListener("resize",s)}},"Ye"),Ue=d(({allSelected:l,bulkSelected:e,keys:n,onSelectKey:s,onToggleAll:i,onToggleBulk:y,selectedKey:o})=>{let t=H(),r=(0,_.useRef)(null),h=(0,_.useRef)(null),m=Ne({count:n.length,estimateSize:d(()=>le,"estimateSize"),getItemKey:d(c=>n[c]?.name??c,"getItemKey"),getScrollElement:d(()=>Ye(r.current),"getScrollElement"),initialRect:{height:Ve,width:800},observeElementOffset:d((c,u)=>{if(ke(c))return Ge(c,u,()=>r.current);let p=d(w=>{let g=c.scrollElement,S=r.current;u(g&&S?Math.max(0,g.getBoundingClientRect().top-S.getBoundingClientRect().top):0,w)},"f"),b=xe(c,(w,g)=>{p(g)}),f=Je(r.current,c.scrollElement,()=>{p(!1)});return()=>{f?.(),b?.()}},"observeElementOffset"),observeElementRect:d((c,u)=>ke(c)?Qe(c,u):we(c,u,Ve),"observeElementRect"),overscan:12}),x=m.getVirtualItems(),N=x[0]?.start??0,T=m.getTotalSize()-(x.at(-1)?.end??0),V=d(c=>{let u=c.key==="Tab"&&c.target instanceof Element?c.target.closest("[data-index]"):null;if(u===null)return;let p=c.shiftKey?-1:1,b=(h.current?.index??Number(u.dataset.index))+p,f=n[b];f===void 0||h.current===null&&u.parentElement?.querySelector(`[data-index="${String(b)}"]`)||(c.preventDefault(),h.current={index:b,name:f.name},ke(m)?m.targetWindow?.scrollBy(0,p*le):m.scrollElement?.scrollBy(0,p*le))},"F");(0,_.useEffect)(()=>{let c=h.current?.name,u=(c===void 0?void 0:[...r.current?.querySelectorAll("[data-key]")??[]].find(p=>p.dataset.key===c))?.querySelector('[data-testid^="kv-select-"]');u&&(h.current=null,u.focus())});let E=0;for(let c of n)E=Math.max(E,c.name.length);return(0,a.jsxs)(ie,{"data-testid":"kv-key-table",children:[(0,a.jsx)(oe,{children:(0,a.jsxs)(Q,{children:[(0,a.jsx)(U,{className:"w-10",children:(0,a.jsx)(me,{"aria-label":t("Select all"),checked:l,"data-testid":"kv-select-all",onCheckedChange:i})}),(0,a.jsx)(U,{children:t("Key")}),(0,a.jsx)(U,{children:t("Expiration")})]})}),(0,a.jsxs)(ce,{onKeyDown:V,ref:r,children:[N>0&&(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:N}}),x.map(c=>{let u=n[c.index];return u===void 0?null:(0,a.jsxs)(Q,{className:u.name===o?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":c.index,"data-key":u.name,"data-testid":`kv-key-row-${u.name}`,onClick:s,style:{height:le},children:[(0,a.jsx)(X,{onClick:d(p=>{p.stopPropagation()},"onClick"),children:(0,a.jsx)(me,{"aria-label":t("Select {name}",{name:u.name}),checked:e.has(u.name),"data-testid":`kv-select-${u.name}`,onCheckedChange:d(()=>{y(u.name)},"onCheckedChange")})}),(0,a.jsx)(X,{className:"font-mono text-xs",style:{width:`${String(E)}ch`},children:u.name}),(0,a.jsx)(X,{className:"tabular-nums text-xs",children:je(u.expiration)})]},u.name)}),T>0&&(0,a.jsx)("tr",{"aria-hidden":"true",style:{height:T}})]})]})},"Qe"),Xe={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},et=d((l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,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{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},"et"),tt=d(l=>{let e=(0,ee.c)(67),{expiration:n,keyName:s,namespace:i,onDeleted:y}=l,o=G(),t=H(),[r,h]=(0,_.useReducer)(et,Xe),m,x;e[0]!==o||e[1]!==s||e[2]!==i?(m=d(()=>{let C={cancelled:!1};return P((async()=>{try{let $=await o.getKvValue({key:s,namespace:i});C.cancelled||h({metadata:$.metadata,type:"loaded",value:$.value})}catch($){let j=$;C.cancelled||h({error:W(j),type:"loadFailed"})}})()),()=>{C.cancelled=!0}},"c"),x=[o,i,s],e[0]=o,e[1]=s,e[2]=i,e[3]=m,e[4]=x):(m=e[3],x=e[4]),(0,_.useEffect)(m,x);let N;e[5]===Symbol.for("react.memo_cache_sentinel")?(N=d(C=>{h({type:"editValue",value:C.target.value})},"x"),e[5]=N):N=e[5];let T=N,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=d(C=>{h({type:"editMetadata",value:C})},"F"),e[6]=V):V=e[6];let E=V,c;e[7]!==r.editedValue?(c=Oe(r.editedValue),e[7]=r.editedValue,e[8]=c):c=e[8];let u=c,p;e[9]!==r.editedMetadata?(p=Ie(r.editedMetadata),e[9]=r.editedMetadata,e[10]=p):p=e[10];let b=p,f;e[11]!==r.editedTtl?(f=_e(r.editedTtl),e[11]=r.editedTtl,e[12]=f):f=e[12];let w=f,g;e[13]!==u?(g=d(()=>{u!==void 0&&h({type:"editValue",value:u})},"g"),e[13]=u,e[14]=g):g=e[14];let S=g,M;e[15]!==o||e[16]!==n||e[17]!==s||e[18]!==b||e[19]!==i||e[20]!==r.editedMetadata||e[21]!==r.editedTtl||e[22]!==r.editedValue||e[23]!==t?(M=d(()=>{if(!b){h({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}h({type:"saveStart"}),P((async()=>{try{await o.putKvValue(Le({metadata:r.editedMetadata,ttl:r.editedTtl,value:r.editedValue},s,i,n)),h({type:"saveOk"})}catch(C){h({error:W(C),type:"writeFailed"})}})())},"V"),e[15]=o,e[16]=n,e[17]=s,e[18]=b,e[19]=i,e[20]=r.editedMetadata,e[21]=r.editedTtl,e[22]=r.editedValue,e[23]=t,e[24]=M):M=e[24];let D=M,O;e[25]!==o||e[26]!==s||e[27]!==i||e[28]!==y?(O=d(()=>{h({type:"deleteStart"}),P((async()=>{try{await o.deleteKvKey({key:s,namespace:i}),y(s)}catch(C){h({error:W(C),type:"writeFailed"})}})())},"I"),e[25]=o,e[26]=s,e[27]=i,e[28]=y,e[29]=O):O=e[29];let J=O,z;e[30]!==s?(z=d(()=>{ne(s)},"D"),e[30]=s,e[31]=z):z=e[31];let I;e[32]!==t?(I=t("Copy key"),e[32]=t,e[33]=I):I=e[33];let v;e[34]!==z||e[35]!==I?(v=(0,a.jsx)("div",{className:"mb-2 flex justify-end",children:(0,a.jsx)(R,{"data-testid":"kv-copy-key-btn",onClick:z,size:"sm",variant:"outline",children:I})}),e[34]=z,e[35]=I,e[36]=v):v=e[36];let k;e[37]!==r.loadError?(k=r.loadError!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:r.loadError}),e[37]=r.loadError,e[38]=k):k=e[38];let K;e[39]!==r.loading||e[40]!==t?(K=r.loading&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")}),e[39]=r.loading,e[40]=t,e[41]=K):K=e[41];let B;e[42]!==u||e[43]!==b||e[44]!==J||e[45]!==S||e[46]!==D||e[47]!==r.busy||e[48]!==r.editedMetadata||e[49]!==r.editedValue||e[50]!==r.loading||e[51]!==r.value||e[52]!==r.writeError||e[53]!==t||e[54]!==w?(B=!r.loading&&r.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)(Y,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),u!==void 0&&(0,a.jsx)(be,{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(We(r.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:T,value:r.editedValue}),(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,a.jsx)(R,{"data-testid":"kv-format-btn",disabled:u===void 0,onClick:S,size:"sm",variant:"outline",children:t("Format JSON")}),(0,a.jsx)(R,{"data-testid":"kv-copy-value-btn",onClick:d(()=>{ne(r.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")})]}),(0,a.jsx)(De,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!w,onChange:d(C=>{h({type:"editTtl",value:C})},"onChange"),testId:"kv-ttl-input"}),(0,a.jsx)(ze,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:E,testId:"kv-metadata-editor",valid:b,value:r.editedMetadata}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,a.jsx)(R,{"data-testid":"kv-save-btn",disabled:r.busy!==""||!b||!w,onClick:D,children:r.busy==="saving"?t("Saving\u2026"):t("Save")}),(0,a.jsx)(R,{"data-testid":"kv-delete-btn",disabled:r.busy!=="",onClick:J,variant:"destructive",children:r.busy==="deleting"?t("Deleting\u2026"):t("Delete")})]}),r.writeError!==null&&(0,a.jsx)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:r.writeError})]}),e[42]=u,e[43]=b,e[44]=J,e[45]=S,e[46]=D,e[47]=r.busy,e[48]=r.editedMetadata,e[49]=r.editedValue,e[50]=r.loading,e[51]=r.value,e[52]=r.writeError,e[53]=t,e[54]=w,e[55]=B):B=e[55];let F;e[56]!==r.loadError||e[57]!==r.loading||e[58]!==r.value||e[59]!==t?(F=!r.loading&&r.value===null&&r.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]=r.loadError,e[57]=r.loading,e[58]=r.value,e[59]=t,e[60]=F):F=e[60];let L;return e[61]!==v||e[62]!==k||e[63]!==K||e[64]!==B||e[65]!==F?(L=(0,a.jsxs)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[v,k,K,B,F]}),e[61]=v,e[62]=k,e[63]=K,e[64]=B,e[65]=F,e[66]=L):L=e[66],L},"tt"),Me=100,at={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},lt=d((l,e)=>{switch(e.type){case"appendPage":return e.generation!==l.reloadNonce?l:{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,reloadNonce:l.reloadNonce+1,selectedKey:null};case"bulkDeleted":{let n=new Set(e.deleted);return{...l,bulk:l.bulk.filter(s=>!n.has(s)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(s=>!n.has(s.name)),selectedKey:l.selectedKey!==null&&n.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(n=>n!==e.name),keys:l.keys===null?null:l.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return e.generation!==void 0&&e.generation!==l.reloadNonce?l:{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(n=>n!==e.name):[...l.bulk,e.name]};default:return l}},"rt"),rt=d(({namespace:l})=>{let e=G(),n=H(),[s,i]=(0,_.useReducer)(lt,at),{appliedPrefix:y,bulk:o,bulkBusy:t,bulkError:r,cursor:h,keys:m,listComplete:x,loadError:N,loading:T,prefixInput:V,reloadNonce:E,selectedKey:c}=s,[u,p]=(0,_.useState)(!1);(0,_.useEffect)(()=>{let v={cancelled:!1};return P((async()=>{i({type:"loadStart"});try{let k=await e.listKvKeys({limit:Me,namespace:l,prefix:y===""?void 0:y});v.cancelled||i({cursor:k.cursor??null,keys:k.keys,listComplete:k.listComplete,type:"firstPage"})}catch(k){v.cancelled||i({error:W(k),type:"loadFailed"})}})()),()=>{v.cancelled=!0}},[e,l,y,E]);let b=d(v=>{i({type:"prefixInput",value:v.target.value})},"y"),f=d(()=>{i({type:"applyFilter"})},"b"),w=d(v=>{i({name:v.currentTarget.dataset.key??null,type:"selectKey"})},"N"),g=d(()=>{if(h===null)return;i({type:"loadStart"});let v=E;P((async()=>{try{let k=await e.listKvKeys({cursor:h,limit:Me,namespace:l,prefix:y===""?void 0:y});i({cursor:k.cursor??null,generation:v,keys:k.keys,listComplete:k.listComplete,type:"appendPage"})}catch(k){i({error:W(k),generation:v,type:"loadFailed"})}})())},"g"),S=d(v=>{i({name:v,type:"keyDeleted"})},"S"),M=d(v=>{i({name:v,type:"toggleBulk"})},"V"),D=d(v=>{i({names:v&&m!==null?m.map(k=>k.name):[],type:"toggleAllBulk"})},"B"),O=d(()=>{if(o.length===0)return;let v=[...o];i({type:"bulkDeleteStart"}),P((async()=>{let k=await Promise.allSettled(v.map(F=>e.deleteKvKey({key:F,namespace:l}))),K=v.filter((F,L)=>k[L]?.status==="fulfilled"),B=v.length-K.length;i({deleted:K,error:B>0?n("Failed to delete {count} keys.",{count:B}):null,type:"bulkDeleted"})})())},"I"),J=d(()=>{p(!1),i({type:"reload"})},"A"),z=m!==null&&m.length>0&&o.length===m.length,I=new Set(o);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:b,placeholder:n("Filter by prefix\u2026"),value:V}),(0,a.jsx)(R,{"data-testid":"kv-filter-btn",disabled:T,onClick:f,children:n("Filter")}),(0,a.jsx)(R,{"data-testid":"kv-new-key-btn",onClick:d(()=>{p(v=>!v)},"onClick"),variant:"outline",children:n("New key")}),o.length>0&&(0,a.jsx)(R,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:O,variant:"destructive",children:t?n("Deleting\u2026"):n("Delete {count}",{count:o.length})})]}),r!==null&&(0,a.jsx)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:r}),N!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:N}),m!==null&&m.length===0&&!T&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),m!==null&&m.length>0&&(0,a.jsx)(de,{className:"overflow-hidden py-0",children:(0,a.jsx)(se,{className:"px-0",children:(0,a.jsx)(Ue,{allSelected:z,bulkSelected:I,keys:m,onSelectKey:w,onToggleAll:D,onToggleBulk:M,selectedKey:c})})}),!x&&h!==null&&(0,a.jsx)("div",{className:"mt-2",children:(0,a.jsx)(R,{"data-testid":"kv-load-more",disabled:T,onClick:g,variant:"outline",children:n(T?"Loading\u2026":"Load more")})})]}),(0,a.jsx)(ve,{onOpenChange:d(v=>{v||p(!1)},"onOpenChange"),open:u,children:(0,a.jsxs)(pe,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,a.jsx)(ye,{children:(0,a.jsx)(he,{children:n("New key")})}),(0,a.jsx)(Ze,{namespace:l,onCancel:d(()=>{p(!1)},"onCancel"),onCreated:J})]})}),(0,a.jsx)(ve,{onOpenChange:d(v=>{v||i({name:null,type:"selectKey"})},"onOpenChange"),open:c!==null,children:(0,a.jsxs)(pe,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,a.jsx)(ye,{children:(0,a.jsx)(he,{className:"truncate font-mono text-xs",children:c})}),c!==null&&(0,a.jsx)(tt,{expiration:m?.find(v=>v.name===c)?.expiration,keyName:c,namespace:l,onDeleted:S},`${l}:${c}`)]})})]})},"at"),xt=d(({loadNamespaces:l}={})=>{let e=G(),n=H(),[s,i]=(0,_.useState)(null),[y,o]=(0,_.useState)(null),[t,r]=(0,_.useState)(null);(0,_.useEffect)(()=>{let m={cancelled:!1};return P((async()=>{try{let x=await(l??(()=>e.listKvNamespaces()))();m.cancelled||(i(x),o(null),r(N=>N??x[0]?.binding??null))}catch(x){m.cancelled||(i(null),o(W(x)))}})()),()=>{m.cancelled=!0}},[e,l]);let h=d(m=>{r(m.currentTarget.dataset.ns??null)},"p");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[y!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:y}),s!==null&&s.length===0&&(0,a.jsx)(fe,{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.")}),s!==null&&s.length>0&&(0,a.jsx)(de,{className:"overflow-hidden py-0",children:(0,a.jsx)(se,{className:"px-0",children:(0,a.jsxs)(ie,{"data-testid":"kv-namespace-table",children:[(0,a.jsx)(oe,{children:(0,a.jsx)(Q,{children:(0,a.jsx)(U,{children:n("Namespace")})})}),(0,a.jsx)(ce,{children:s.map(m=>(0,a.jsx)(Q,{className:m.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":m.binding,"data-testid":`kv-ns-row-${m.binding}`,onClick:h,children:(0,a.jsx)(X,{className:"font-mono text-xs",children:m.binding})},m.binding))})]})})}),t!==null&&(0,a.jsx)(rt,{namespace:t},t)]})},"Et");export{xt as KvBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as P}from"./chunk-
|
|
1
|
+
import{n as P}from"./chunk-5KQSRLQP.js";import{l as M}from"./chunk-PN7JHEYW.js";import{a as F}from"./chunk-A6TVTNKO.js";import{a as A}from"./chunk-ADABTCDI.js";import{a as o,d as v}from"./chunk-5PEAXTYQ.js";var S=v(F(),1),i=v(A(),1);var b=6e4,g=o(e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function","D"),w=5e3,U=o((e,r,s,h)=>{let t=(0,S.c)(10),n=s===void 0?w:s,d=P(),p=(0,i.useRef)(e),u;t[0]!==e?(u=o(()=>{p.current=e},"i"),t[0]=e,t[1]=u):u=t[1],(0,i.useEffect)(u);let f;t[2]!==r||t[3]!==n?(f=o(()=>{if(!r)return;let c=n,y=!1,T,m=o(()=>{y||(T=setTimeout(_,c))},"u"),E=o(()=>{c=n,m()},"_"),R=o(a=>{M(a)||(c=Math.max(n,Math.min(c*2,b)),m())},"M"),_=o(()=>{if(globalThis.document?.hidden===!0){m();return}let a;try{a=p.current()}catch(j){R(j);return}g(a)?Promise.resolve(a).then(E).catch(R):E()},"R");return m(),()=>{y=!0,clearTimeout(T)}},"n"),t[2]=r,t[3]=n,t[4]=f):f=t[4];let l;t[5]!==d||t[6]!==r||t[7]!==n||t[8]!==h?(l=[d,r,n,h],t[5]=d,t[6]=r,t[7]=n,t[8]=h,t[9]=l):l=t[9],(0,i.useEffect)(f,l)},"v"),B=o(async e=>{let r=(await Promise.allSettled(e)).find(s=>s.status==="rejected");if(r!==void 0)throw r.reason},"B");export{U as a,B as b};
|