@lunora/studio 1.0.0-alpha.53 → 1.0.0-alpha.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +680 -780
- package/dist/index.js +8 -8
- package/dist/mount.d.ts +10 -10
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +2 -2
- package/dist/packem_chunks/ExportImportPanel.js +2 -2
- package/dist/packem_chunks/FileBrowser.js +3 -3
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +2 -2
- package/dist/packem_chunks/HealthPanel.js +2 -2
- package/dist/packem_chunks/InsightsPanel.js +2 -2
- package/dist/packem_chunks/LogsPanel.js +81 -53
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +392 -7
- package/dist/packem_chunks/MigrationsPanel.js +2 -2
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +2 -2
- package/dist/packem_chunks/SecurityAdvisorPanel.js +2 -2
- package/dist/packem_chunks/SettingsPanel.js +3 -3
- package/dist/packem_chunks/SqlEditorPanel.js +1 -1
- package/dist/packem_chunks/TableEditor.js +2 -2
- package/dist/packem_chunks/agents-panel.js +2 -2
- package/dist/packem_chunks/analytics-panel.js +1 -1
- package/dist/packem_chunks/auth-config-panel.js +1 -1
- package/dist/packem_chunks/auth-sessions-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +2 -2
- package/dist/packem_chunks/dashboards-panel.js +2 -2
- package/dist/packem_chunks/fanout-panel.js +2 -2
- package/dist/packem_chunks/flags-panel.js +2 -2
- package/dist/packem_chunks/issues-panel.js +2 -2
- package/dist/packem_chunks/kv-browser.js +2 -2
- package/dist/packem_chunks/log-drains-panel.js +2 -2
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +2 -2
- package/dist/packem_chunks/permissions-panel.js +2 -2
- package/dist/packem_chunks/queues-panel.js +2 -2
- package/dist/packem_chunks/rls-panel.js +2 -2
- package/dist/packem_chunks/schedule-panel.js +2 -2
- package/dist/packem_chunks/storage-rules-panel.js +2 -2
- package/dist/packem_chunks/subscriptions-panel.js +2 -2
- package/dist/packem_chunks/traces-panel.js +734 -0
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/vector-browser.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +2 -2
- package/dist/packem_shared/{ADMIN_FUNCTIONS-DNeyYtUN.js → ADMIN_FUNCTIONS-C6TEeUiJ.js} +2 -0
- package/dist/packem_shared/{ApiDocsPanel-_aEZxAMX.js → ApiDocsPanel-CcC6ucbp.js} +1 -1
- package/dist/packem_shared/{DataBrowser-C8hejnub.js → DataBrowser-BuFEPTiv.js} +1 -1
- package/dist/packem_shared/{GlobalDataBrowser-f5Ll2AQK.js → GlobalDataBrowser-D8h1fTL1.js} +1 -1
- package/dist/packem_shared/{HomePanel-Ye8PaqQL.js → HomePanel-2I1YZm0A.js} +3 -3
- package/dist/packem_shared/{ScheduledJobs-dHMgnJbx.js → ScheduledJobs-Cz5Tr-M6.js} +1 -1
- package/dist/packem_shared/{Studio-BNGjxLVo.js → Studio-CCJBI2wP.js} +2 -2
- package/dist/packem_shared/{StudioApp-K9dn1Q9d.js → StudioApp-Daeqxw2h.js} +1 -1
- package/dist/packem_shared/{advisor-view-Cx21PS_T.js → advisor-view-1RaDWED7.js} +1 -1
- package/dist/packem_shared/app.d-C-kxb-1T.d.ts +254 -0
- package/dist/packem_shared/{card-DURq3ElK.js → card-F2vH_aj2.js} +1 -1
- package/dist/packem_shared/{cf-links-BZfRdxSE.js → cf-links-SIbyi4Y1.js} +1 -1
- package/dist/packem_shared/{home-panel-D62G8108.js → home-panel-DHHUtnKU.js} +2 -2
- package/dist/packem_shared/log-fields-jEH83H2G.js +18 -0
- package/dist/packem_shared/{studio-Cd21fp4v.js → studio-0479nrrm.js} +551 -524
- package/dist/standalone/{chunk-SDQE2IUJ.js → chunk-3W4CSGDO.js} +1 -1
- package/dist/standalone/{chunk-FFVSSWU2.js → chunk-4AZYW2PI.js} +1 -1
- package/dist/standalone/{chunk-ZQQ3MFEQ.js → chunk-4F72YCTU.js} +1 -1
- package/dist/standalone/{chunk-IZN4TYMN.js → chunk-5IGHDPEP.js} +1 -1
- package/dist/standalone/{chunk-T7FHIJ2T.js → chunk-6LLFTVEI.js} +1 -1
- package/dist/standalone/{chunk-JPILGFXT.js → chunk-7YGTGBP7.js} +1 -1
- package/dist/standalone/{chunk-OETK333R.js → chunk-AE3AKGOW.js} +1 -1
- package/dist/standalone/{chunk-TO6D2PJC.js → chunk-CHNXZYAC.js} +1 -1
- package/dist/standalone/{chunk-R2MAZ2OH.js → chunk-CW7LZ4SR.js} +1 -1
- package/dist/standalone/{chunk-WUFVFVHJ.js → chunk-D73WYMRU.js} +1 -1
- package/dist/standalone/{chunk-YFZ27MEC.js → chunk-DVBY6YQK.js} +1 -1
- package/dist/standalone/chunk-EBTLTGG3.js +1 -0
- package/dist/standalone/chunk-EIZG4GOM.js +1 -0
- package/dist/standalone/{chunk-DMFVDMUJ.js → chunk-EPDC422O.js} +1 -1
- package/dist/standalone/{chunk-ISOUWAPB.js → chunk-FBGC3RSU.js} +1 -1
- package/dist/standalone/{chunk-LUP4YTBS.js → chunk-FDWXYXOM.js} +1 -1
- package/dist/standalone/{chunk-XXAW7V4T.js → chunk-FPKTXKPE.js} +1 -1
- package/dist/standalone/{chunk-AITOCPML.js → chunk-FQUNSQLG.js} +1 -1
- package/dist/standalone/{chunk-HRHG4HOZ.js → chunk-FXNS5NBY.js} +1 -1
- package/dist/standalone/{chunk-3GVA2ROQ.js → chunk-G4GGGHEV.js} +1 -1
- package/dist/standalone/{chunk-C4QK2DJN.js → chunk-G5CMK5GY.js} +1 -1
- package/dist/standalone/{chunk-GPQX3AEO.js → chunk-G5RC7USY.js} +1 -1
- package/dist/standalone/{chunk-PWKD5FTM.js → chunk-GVFODXW2.js} +1 -1
- package/dist/standalone/{chunk-MDTNVR3G.js → chunk-HNIDN3RX.js} +1 -1
- package/dist/standalone/{chunk-XXXNY3DK.js → chunk-IKVZUVHJ.js} +1 -1
- package/dist/standalone/{chunk-3C3CU2DS.js → chunk-JGCRBFFO.js} +1 -1
- package/dist/standalone/chunk-JHR3HKT5.js +3 -0
- package/dist/standalone/{chunk-WXUUGXDV.js → chunk-JQPHZL2A.js} +1 -1
- package/dist/standalone/{chunk-CRY26DNY.js → chunk-LJE6PGHD.js} +1 -1
- package/dist/standalone/{chunk-5JB7FDCA.js → chunk-LTCX3QOE.js} +1 -1
- package/dist/standalone/{chunk-ALL4U2C5.js → chunk-MWH5LBNF.js} +1 -1
- package/dist/standalone/{chunk-CZGILAZI.js → chunk-N5FMEYSL.js} +1 -1
- package/dist/standalone/chunk-N7SVJOHN.js +1 -0
- package/dist/standalone/{chunk-7KSXHCUD.js → chunk-NAFKYFBZ.js} +1 -1
- package/dist/standalone/{chunk-3XBP6RRG.js → chunk-OVSBLTAA.js} +1 -1
- package/dist/standalone/chunk-OXHHSUXO.js +1 -0
- package/dist/standalone/chunk-PIB7VUVM.js +1 -0
- package/dist/standalone/{chunk-IC7XYSER.js → chunk-Q3X7IMLF.js} +1 -1
- package/dist/standalone/{chunk-LAK5VSPI.js → chunk-QVIPA6UJ.js} +1 -1
- package/dist/standalone/{chunk-NXAKNU3L.js → chunk-RCSULEDU.js} +1 -1
- package/dist/standalone/{chunk-6TMEOFZC.js → chunk-RDA4VTHI.js} +1 -1
- package/dist/standalone/{chunk-VY6AI3RI.js → chunk-RG4HLPM2.js} +1 -1
- package/dist/standalone/{chunk-LOYE7OU2.js → chunk-S2G7OH5T.js} +1 -1
- package/dist/standalone/{chunk-7N5KFSSB.js → chunk-SP7GSPKX.js} +1 -1
- package/dist/standalone/{chunk-W6JKUZKD.js → chunk-SPACAIAR.js} +1 -1
- package/dist/standalone/{chunk-X4QFAAZ5.js → chunk-SWMBBYJU.js} +1 -1
- package/dist/standalone/{chunk-HZKFL2M7.js → chunk-TTEEPVCN.js} +1 -1
- package/dist/standalone/{chunk-SXAFEREK.js → chunk-VC2VDAUO.js} +1 -1
- package/dist/standalone/{chunk-USYCKPUK.js → chunk-VQ3YOUZB.js} +1 -1
- package/dist/standalone/chunk-VXM5H542.js +4 -0
- package/dist/standalone/{chunk-3MAQAOUA.js → chunk-W7ND56KZ.js} +1 -1
- package/dist/standalone/{chunk-43F677PE.js → chunk-WA3DGSC2.js} +1 -1
- package/dist/standalone/{chunk-75LPCQ77.js → chunk-WCLFE2ZB.js} +1 -1
- package/dist/standalone/{chunk-EEWKIQUE.js → chunk-WOYQG5AM.js} +1 -1
- package/dist/standalone/{chunk-JM7XBQVK.js → chunk-XCNYUUD6.js} +1 -1
- package/dist/standalone/{chunk-ZVT4GJEI.js → chunk-XG4TZSP4.js} +1 -1
- package/dist/standalone/{chunk-A3ZJACVT.js → chunk-XZWFP2GI.js} +1 -1
- package/dist/standalone/chunk-YNSFQKMM.js +1 -0
- package/dist/standalone/{chunk-CODD62OJ.js → chunk-YRE6TGXH.js} +1 -1
- package/dist/standalone/{chunk-S7RKDQPS.js → chunk-YS7NUMAN.js} +1 -1
- package/dist/standalone/{chunk-IEKK5GO6.js → chunk-ZUTFDG76.js} +1 -1
- package/dist/standalone/{chunk-22C6COGE.js → chunk-ZXLEXF4X.js} +2 -2
- package/dist/standalone/studio.js +1 -1
- package/dist/styles.css +2 -2
- package/package.json +8 -8
- package/dist/packem_shared/app.d-CGdOmLTm.d.ts +0 -300
- package/dist/standalone/chunk-G7ZBM54M.js +0 -1
- package/dist/standalone/chunk-I7Y7ST5Y.js +0 -1
- package/dist/standalone/chunk-KJJ3WM6H.js +0 -4
- package/dist/standalone/chunk-LT7IG26L.js +0 -1
- package/dist/standalone/chunk-TC4KPQJ7.js +0 -3
- package/dist/standalone/chunk-WI7GWFEG.js +0 -1
- /package/dist/standalone/{chunk-ITQKVEP7.js → chunk-5XO36X4C.js} +0 -0
- /package/dist/standalone/{chunk-TQ36RWOP.js → chunk-IYHPYY4A.js} +0 -0
- /package/dist/standalone/{chunk-SEU5V7I6.js → chunk-Y572GMZE.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as se}from"./chunk-SDQE2IUJ.js";import"./chunk-X4QFAAZ5.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as te}from"./chunk-XNJNSCLM.js";import{a as z,b as V,c as P,e as D}from"./chunk-SEU5V7I6.js";import{d as X,f as ee}from"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-G7ZBM54M.js";import{f as Q}from"./chunk-LOYE7OU2.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as U}from"./chunk-TAD43CG5.js";import{d as O,f as H,g as Y,h as G,l as Z}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(se,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),xe=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=X(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:ee("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{xe as default};
|
|
1
|
+
import{a as se}from"./chunk-3W4CSGDO.js";import"./chunk-SWMBBYJU.js";import"./chunk-BJGBHGK3.js";import"./chunk-ZIGWVHCS.js";import"./chunk-KEGAWN6Y.js";import{a as te}from"./chunk-XNJNSCLM.js";import{a as z,b as V,c as P,e as D}from"./chunk-Y572GMZE.js";import{d as X,f as ee}from"./chunk-2MLA6WFH.js";import"./chunk-HV7G6DFP.js";import{c as I}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-EBTLTGG3.js";import{f as Q}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as U}from"./chunk-TAD43CG5.js";import{d as O,f as H,g as Y,h as G,l as Z}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as k,e as j,f as ie,g as le,h as oe}from"./chunk-RRCPZMC2.js";var W=j(le(),1),T=j(ie(),1);var o=j(oe(),1);var de=H(J.runSql),ae=k(($,e)=>{let s=Q(),[f,t]=(0,T.useState)(void 0),[i,d]=(0,T.useState)(void 0),[l,c]=(0,T.useState)(!0),q=(0,T.useCallback)(async a=>{c(!0);try{let x=await s.query(de,{sql:$},Y(e));a.cancelled||(t(x),d(void 0))}catch(x){a.cancelled||(t(void 0),d(G(x)))}finally{a.cancelled||c(!1)}},[s,$,e]);return(0,T.useEffect)(()=>{let a={cancelled:!1};return Z(q(a)),()=>{a.cancelled=!0}},[q]),{error:i,loading:l,result:f}},"useRunSql"),re="lunora-studio-dashboards",B={shardKey:"",sql:"",title:""},ne=k($=>{let e=(0,W.c)(54),{onEdit:s,onRemove:f,widget:t}=$,i=O(),{error:d,loading:l,result:c}=ae(t.sql,t.shardKey??""),q;e[0]!==s||e[1]!==t.id?(q=k(()=>{s(t.id)},"t1"),e[0]=s,e[1]=t.id,e[2]=q):q=e[2];let a=q,x;e[3]!==f||e[4]!==t.id?(x=k(()=>{f(t.id)},"t2"),e[3]=f,e[4]=t.id,e[5]=x):x=e[5];let K=x,M=`dashboards-widget-${t.id}`,S;e[6]!==t.title?(S=(0,o.jsxDEV)(P,{className:"min-w-0 truncate",title:t.title,children:t.title},void 0,!1),e[6]=t.title,e[7]=S):S=e[7];let L;e[8]!==i?(L=i("Edit widget"),e[8]=i,e[9]=L):L=e[9];let R=`dashboards-widget-edit-${t.id}`,A;e[10]!==i?(A=i("Edit widget"),e[10]=i,e[11]=A):A=e[11];let w;e[12]===Symbol.for("react.memo_cache_sentinel")?(w=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"},void 0,!1)},void 0,!1),e[12]=w):w=e[12];let C;e[13]!==a||e[14]!==L||e[15]!==R||e[16]!==A?(C=(0,o.jsxDEV)(I,{"aria-label":L,"data-testid":R,onClick:a,size:"icon-xs",title:A,type:"button",variant:"ghost",children:w},void 0,!1),e[13]=a,e[14]=L,e[15]=R,e[16]=A,e[17]=C):C=e[17];let b;e[18]!==i?(b=i("Remove widget"),e[18]=i,e[19]=b):b=e[19];let E=`dashboards-widget-remove-${t.id}`,m;e[20]!==i?(m=i("Remove widget"),e[20]=i,e[21]=m):m=e[21];let p;e[22]===Symbol.for("react.memo_cache_sentinel")?(p=(0,o.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,o.jsxDEV)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"},void 0,!1)},void 0,!1),e[22]=p):p=e[22];let u;e[23]!==K||e[24]!==b||e[25]!==E||e[26]!==m?(u=(0,o.jsxDEV)(I,{"aria-label":b,"data-testid":E,onClick:K,size:"icon-xs",title:m,type:"button",variant:"ghost",children:p},void 0,!1),e[23]=K,e[24]=b,e[25]=E,e[26]=m,e[27]=u):u=e[27];let h;e[28]!==u||e[29]!==C?(h=(0,o.jsxDEV)("div",{className:"flex shrink-0 items-center gap-1",children:[C,u]},void 0,!0),e[28]=u,e[29]=C,e[30]=h):h=e[30];let v;e[31]!==h||e[32]!==S?(v=(0,o.jsxDEV)(V,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[S,h]},void 0,!0),e[31]=h,e[32]=S,e[33]=v):v=e[33];let g;e[34]!==d||e[35]!==t.id?(g=d!==void 0&&(0,o.jsxDEV)(te,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:d},void 0,!1),e[34]=d,e[35]=t.id,e[36]=g):g=e[36];let N;e[37]!==d||e[38]!==l||e[39]!==c||e[40]!==i||e[41]!==t.id?(N=d===void 0&&l&&c===void 0&&(0,o.jsxDEV)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:i("Running\u2026")},void 0,!1),e[37]=d,e[38]=l,e[39]=c,e[40]=i,e[41]=t.id,e[42]=N):N=e[42];let r;e[43]!==d||e[44]!==c?(r=d===void 0&&c!==void 0&&(0,o.jsxDEV)(se,{result:c},void 0,!1),e[43]=d,e[44]=c,e[45]=r):r=e[45];let n;e[46]!==g||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(D,{className:"min-h-32 py-2",children:[g,N,r]},void 0,!0),e[46]=g,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;return e[50]!==v||e[51]!==n||e[52]!==M?(y=(0,o.jsxDEV)(z,{"data-testid":M,children:[v,n]},void 0,!0),e[50]=v,e[51]=n,e[52]=M,e[53]=y):y=e[53],y},"WidgetCard"),ce=k($=>{let e=(0,W.c)(58),{draft:s,editing:f,onCancel:t,onChange:i,onSubmit:d}=$,l=O(),c;e[0]!==s||e[1]!==i?(c=k(_=>{i({...s,title:_.target.value})},"t1"),e[0]=s,e[1]=i,e[2]=c):c=e[2];let q=c,a;e[3]!==s||e[4]!==i?(a=k(_=>{i({...s,sql:_.target.value})},"t2"),e[3]=s,e[4]=i,e[5]=a):a=e[5];let x=a,K;e[6]!==s||e[7]!==i?(K=k(_=>{i({...s,shardKey:_.target.value})},"t3"),e[6]=s,e[7]=i,e[8]=K):K=e[8];let M=K,S;e[9]!==d?(S=k(()=>{d()},"t4"),e[9]=d,e[10]=S):S=e[10];let L=S,R;e[11]!==s.sql||e[12]!==s.title?(R=s.title.trim()!==""&&s.sql.trim()!=="",e[11]=s.sql,e[12]=s.title,e[13]=R):R=e[13];let A=R,w;e[14]!==l?(w=l("Widget title"),e[14]=l,e[15]=w):w=e[15];let C;e[16]!==l?(C=l("Widget title"),e[16]=l,e[17]=C):C=e[17];let b;e[18]!==s.title||e[19]!==q||e[20]!==w||e[21]!==C?(b=(0,o.jsxDEV)("input",{"aria-label":w,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:q,placeholder:C,type:"text",value:s.title},void 0,!1),e[18]=s.title,e[19]=q,e[20]=w,e[21]=C,e[22]=b):b=e[22];let E;e[23]!==l?(E=l("SQL query"),e[23]=l,e[24]=E):E=e[24];let m;e[25]!==s.sql||e[26]!==x||e[27]!==E?(m=(0,o.jsxDEV)("textarea",{"aria-label":E,className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:x,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:s.sql},void 0,!1),e[25]=s.sql,e[26]=x,e[27]=E,e[28]=m):m=e[28];let p;e[29]!==l?(p=l("Shard key (optional)"),e[29]=l,e[30]=p):p=e[30];let u;e[31]!==l?(u=l("Shard key (optional)"),e[31]=l,e[32]=u):u=e[32];let h;e[33]!==s.shardKey||e[34]!==M||e[35]!==p||e[36]!==u?(h=(0,o.jsxDEV)("input",{"aria-label":p,className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:M,placeholder:u,type:"text",value:s.shardKey},void 0,!1),e[33]=s.shardKey,e[34]=M,e[35]=p,e[36]=u,e[37]=h):h=e[37];let v;e[38]!==l?(v=l("Cancel"),e[38]=l,e[39]=v):v=e[39];let g;e[40]!==t||e[41]!==v?(g=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:v},void 0,!1),e[40]=t,e[41]=v,e[42]=g):g=e[42];let N=!A,r;e[43]!==f||e[44]!==l?(r=l(f?"Save widget":"Add widget"),e[43]=f,e[44]=l,e[45]=r):r=e[45];let n;e[46]!==L||e[47]!==N||e[48]!==r?(n=(0,o.jsxDEV)(I,{"data-testid":"dashboards-form-save",disabled:N,onClick:L,size:"sm",type:"button",children:r},void 0,!1),e[46]=L,e[47]=N,e[48]=r,e[49]=n):n=e[49];let y;e[50]!==g||e[51]!==n?(y=(0,o.jsxDEV)("div",{className:"flex items-center justify-end gap-2",children:[g,n]},void 0,!0),e[50]=g,e[51]=n,e[52]=y):y=e[52];let F;return e[53]!==m||e[54]!==h||e[55]!==y||e[56]!==b?(F=(0,o.jsxDEV)(z,{"data-testid":"dashboards-form",children:(0,o.jsxDEV)(D,{className:"flex flex-col gap-3 py-4",children:[b,m,h,y]},void 0,!0)},void 0,!1),e[53]=m,e[54]=h,e[55]=y,e[56]=b,e[57]=F):F=e[57],F},"WidgetForm"),xe=k($=>{let e=(0,W.c)(39),{initialShardKey:s}=$,f=O(),[t,i]=X(re),[d,l]=(0,T.useState)(B),[c,q]=(0,T.useState)(null),[a,x]=(0,T.useState)(!1),K;e[0]!==s?(K=k(()=>{q(null),l({...B,shardKey:s??""}),x(!0)},"t1"),e[0]=s,e[1]=K):K=e[1];let M=K,S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=k(()=>{x(!1),q(null),l(B)},"t2"),e[2]=S):S=e[2];let L=S,R;e[3]!==t?(R=k(r=>{let n=t.find(y=>y.id===r);n!==void 0&&(q(r),l({shardKey:n.shardKey??"",sql:n.sql,title:n.title}),x(!0))},"t3"),e[3]=t,e[4]=R):R=e[4];let A=R,w;e[5]!==i?(w=k(r=>{i(n=>n.filter(y=>y.id!==r))},"t4"),e[5]=i,e[6]=w):w=e[6];let C=w,b;e[7]!==d.shardKey||e[8]!==d.sql||e[9]!==d.title||e[10]!==c||e[11]!==i?(b=k(()=>{let r=d.title.trim(),n=d.sql.trim();if(r===""||n==="")return;let y=d.shardKey.trim();i(c===null?F=>[...F,{id:ee("w"),shardKey:y,sql:n,title:r}]:F=>F.map(_=>_.id===c?{..._,shardKey:y,sql:n,title:r}:_)),L()},"t5"),e[7]=d.shardKey,e[8]=d.sql,e[9]=d.title,e[10]=c,e[11]=i,e[12]=b):b=e[12];let E=b,m;e[13]!==f?(m=f("Chart widgets backed by saved read-only SQL queries."),e[13]=f,e[14]=m):m=e[14];let p;e[15]!==m?(p=(0,o.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[15]=m,e[16]=p):p=e[16];let u;e[17]!==a||e[18]!==M||e[19]!==f?(u=!a&&(0,o.jsxDEV)(I,{"data-testid":"dashboards-add",onClick:M,size:"sm",type:"button",children:f("Add widget")},void 0,!1),e[17]=a,e[18]=M,e[19]=f,e[20]=u):u=e[20];let h;e[21]!==p||e[22]!==u?(h=(0,o.jsxDEV)("div",{className:"flex items-center justify-between",children:[p,u]},void 0,!0),e[21]=p,e[22]=u,e[23]=h):h=e[23];let v;e[24]!==d||e[25]!==c||e[26]!==a||e[27]!==E?(v=a&&(0,o.jsxDEV)(ce,{draft:d,editing:c!==null,onCancel:L,onChange:l,onSubmit:E},void 0,!1),e[24]=d,e[25]=c,e[26]=a,e[27]=E,e[28]=v):v=e[28];let g;e[29]!==a||e[30]!==A||e[31]!==C||e[32]!==f||e[33]!==t?(g=t.length===0&&!a?(0,o.jsxDEV)(U,{description:f("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:f("No widgets yet")},void 0,!1):(0,o.jsxDEV)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(r=>(0,o.jsxDEV)(ne,{onEdit:A,onRemove:C,widget:r},r.id,!1))},void 0,!1),e[29]=a,e[30]=A,e[31]=C,e[32]=f,e[33]=t,e[34]=g):g=e[34];let N;return e[35]!==v||e[36]!==g||e[37]!==h?(N=(0,o.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[h,v,g]},void 0,!0),e[35]=v,e[36]=g,e[37]=h,e[38]=N):N=e[38],N},"DashboardsPanel");export{xe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as M,b as E,c as O,d as B,e as R,f as D,g as _,h as J}from"./chunk-V43BLH4J.js";import{a as q}from"./chunk-AHILM3ZP.js";import{a as U}from"./chunk-
|
|
1
|
+
import{a as M,b as E,c as O,d as B,e as R,f as D,g as _,h as J}from"./chunk-V43BLH4J.js";import{a as q}from"./chunk-AHILM3ZP.js";import{a as U}from"./chunk-WOYQG5AM.js";import{d as L,k as I,n as V}from"./chunk-5XO36X4C.js";import{a as C,e as j,f as z,g as K,h as P}from"./chunk-RRCPZMC2.js";var T=j(K(),1),H=j(z(),1);var a=j(P(),1);var $="inline-flex items-center gap-1 rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",W=/["\n,]/u,X=/^[=+\-@\t\r]/u,F=C(l=>{if(l==null)return"";let e;return typeof l=="string"?e=X.test(l)?` ${l}`:l:typeof l=="number"||typeof l=="boolean"||typeof l=="bigint"?e=String(l):e=JSON.stringify(l),W.test(e)?`"${e.replaceAll('"','""')}"`:e},"csvCell"),Y=C((l,e)=>{let o=l.map(n=>F(n)).join(","),s=e.map(n=>l.map(t=>F(n[t])).join(","));return[o,...s].join(`
|
|
2
2
|
`)},"toCsv"),Z=C(l=>JSON.stringify(l,null,2),"toJson"),G=500,Q=C(l=>`"${l.replaceAll('"','""')}"`,"sqlIdentifier"),ee=C(l=>l==null?"NULL":typeof l=="number"?Number.isFinite(l)?String(l):"NULL":typeof l=="bigint"?String(l):typeof l=="boolean"?l?"1":"0":`'${(typeof l=="string"?l:JSON.stringify(l)).replaceAll("'","''")}'`,"sqlLiteral"),te=C((l,e,o)=>{if(e.length===0||o.length===0)return"";let s=e.map(t=>Q(t)).join(", "),n=[];for(let t=0;t<o.length;t+=G){let r=o.slice(t,t+G).map(m=>` (${e.map(i=>ee(m[i])).join(", ")})`).join(`,
|
|
3
3
|
`);n.push(`INSERT INTO ${Q(l)} (${s}) VALUES
|
|
4
4
|
${r};`)}return n.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as be,b as ge,c as xe,d as Ne,e as Ce}from"./chunk-S5NTGHCG.js";import"./chunk-DWDILV2E.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{a as ue}from"./chunk-3GXGLNKW.js";import{g as me,h as ve,i as fe,j as pe}from"./chunk-TC4KPQJ7.js";import"./chunk-ZPUO7FNI.js";import"./chunk-WVTPZ6CM.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-ZIGWVHCS.js";import"./chunk-7TJJXVSE.js";import"./chunk-WI7GWFEG.js";import"./chunk-KEGAWN6Y.js";import"./chunk-ZQQ3MFEQ.js";import{a as de,b as ne,c as oe,d as q,e as Q,f as X}from"./chunk-GTM65MVX.js";import{a as re,e as se}from"./chunk-SEU5V7I6.js";import{a as ce}from"./chunk-VLXV72QE.js";import{a as W}from"./chunk-JSEXCW5Q.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as le}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as $}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as he}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-G7ZBM54M.js";import{f as Y}from"./chunk-LOYE7OU2.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ye}from"./chunk-TAD43CG5.js";import{d as U,h as z,l as R,n as ie,o as ke}from"./chunk-ITQKVEP7.js";import"./chunk-22C6COGE.js";import{a as n,e as ae,f as Me,g as Le,h as Be}from"./chunk-RRCPZMC2.js";var J=ae(Me(),1);var ee=ae(Le(),1);var l=ae(Be(),1);var De=n(r=>{let e=r.trim();if(e==="")return;let s=Number(e);return Number.isFinite(s)&&s>0?Math.floor(s):void 0},"parseTtl"),Oe=n(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"formatExpiration"),Ae=n(r=>new TextEncoder().encode(r).length,"byteLength"),Te=n(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"tryFormatJson"),Ee=n(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"isJsonOrEmpty"),Fe=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Se=n((r,e)=>{let s=r.trim();if(s==="")return"";let u=Number(s),d=Fe.find(f=>f.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*d)):s},"ttlToSeconds"),Ke=n(r=>{let e=r.trim();if(e==="")return!0;let s=Number(e);return Number.isInteger(s)&&s>=60},"isTtlValid"),Ve=n((r,e,s,u)=>{let d=De(r.ttl);return{expiration:d===void 0?u:void 0,expirationTtl:d,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:s,value:r.value}},"buildKvPutOptions"),Ie=n(r=>{let e=(0,ee.c)(60),{helper:s,id:u,invalid:d,onChange:f,testId:o}=r,t=U(),[a,p]=(0,J.useState)(""),[c,x]=(0,J.useState)("seconds"),b;e[0]!==f||e[1]!==c?(b=n(g=>{p(g.target.value),f(Se(g.target.value,c))},"t1"),e[0]=f,e[1]=c,e[2]=b):b=e[2];let M=b,V;e[3]!==a||e[4]!==f?(V=n(g=>{g!==null&&(x(g),f(Se(a,g)))},"t2"),e[3]=a,e[4]=f,e[5]=V):V=e[5];let L=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==y||e[17]!==N?(C={days:h,hours:v,minutes:y,seconds:N},e[14]=h,e[15]=v,e[16]=y,e[17]=N,e[18]=C):C=e[18];let S=C,k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==u||e[22]!==k?(w=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:u,children:k},void 0,!1),e[21]=u,e[22]=k,e[23]=w):w=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==a||e[27]!==u||e[28]!==d||e[29]!==M||e[30]!==E||e[31]!==o?(B=(0,l.jsxDEV)(le,{"aria-invalid":d,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:M,placeholder:E,value:a},void 0,!1),e[26]=a,e[27]=u,e[28]=d,e[29]=M,e[30]=E,e[31]=o,e[32]=B):B=e[32];let I;e[33]!==t?(I=t("TTL unit"),e[33]=t,e[34]=I):I=e[34];let O=`${o}-unit`,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=(0,l.jsxDEV)(ge,{},void 0,!1),e[35]=D):D=e[35];let i;e[36]!==I||e[37]!==O?(i=(0,l.jsxDEV)(xe,{"aria-label":I,className:"w-[7.5rem]","data-testid":O,children:D},void 0,!1),e[36]=I,e[37]=O,e[38]=i):i=e[38];let m;e[39]!==S?(m=Fe.map(g=>(0,l.jsxDEV)(Ce,{value:g.key,children:S[g.key]},g.key,!1)),e[39]=S,e[40]=m):m=e[40];let K;e[41]!==m?(K=(0,l.jsxDEV)(Ne,{children:m},void 0,!1),e[41]=m,e[42]=K):K=e[42];let T;e[43]!==L||e[44]!==i||e[45]!==K||e[46]!==c?(T=(0,l.jsxDEV)(be,{onValueChange:L,value:c,children:[i,K]},void 0,!0),e[43]=L,e[44]=i,e[45]=K,e[46]=c,e[47]=T):T=e[47];let _;e[48]!==B||e[49]!==T?(_=(0,l.jsxDEV)("div",{className:"flex gap-2",children:[B,T]},void 0,!0),e[48]=B,e[49]=T,e[50]=_):_=e[50];let F;e[51]!==s||e[52]!==d||e[53]!==t||e[54]!==o?(F=d?(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")},void 0,!1):s!==void 0&&(0,l.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:s},void 0,!1),e[51]=s,e[52]=d,e[53]=t,e[54]=o,e[55]=F):F=e[55];let A;return e[56]!==_||e[57]!==F||e[58]!==w?(A=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[w,_,F]},void 0,!0),e[56]=_,e[57]=F,e[58]=w,e[59]=A):A=e[59],A},"TtlField"),_e=n(r=>{let e=(0,ee.c)(36),{id:s,invalidTestId:u,onChange:d,testId:f,valid:o,value:t}=r,a=U(),p;e[0]!==t?(p=Te(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==a?(x=a("Metadata (JSON)"),e[2]=a,e[3]=x):x=e[3];let b;e[4]!==s||e[5]!==x?(b=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:s,children:x},void 0,!1),e[4]=s,e[5]=x,e[6]=b):b=e[6];let M=`${f}-format`,V=c===void 0,L;e[7]!==c||e[8]!==d?(L=n(()=>{c!==void 0&&d(c)},"t6"),e[7]=c,e[8]=d,e[9]=L):L=e[9];let h;e[10]!==a?(h=a("Format JSON"),e[10]=a,e[11]=h):h=e[11];let v;e[12]!==M||e[13]!==V||e[14]!==L||e[15]!==h?(v=(0,l.jsxDEV)($,{"data-testid":M,disabled:V,onClick:L,size:"sm",variant:"outline",children:h},void 0,!1),e[12]=M,e[13]=V,e[14]=L,e[15]=h,e[16]=v):v=e[16];let y;e[17]!==b||e[18]!==v?(y=(0,l.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[b,v]},void 0,!0),e[17]=b,e[18]=v,e[19]=y):y=e[19];let N=!o,C;e[20]!==d?(C=n(E=>{d(E.target.value)},"t11"),e[20]=d,e[21]=C):C=e[21];let S;e[22]!==s||e[23]!==N||e[24]!==C||e[25]!==f||e[26]!==t?(S=(0,l.jsxDEV)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":f,id:s,onChange:C,value:t},void 0,!1),e[22]=s,e[23]=N,e[24]=C,e[25]=f,e[26]=t,e[27]=S):S=e[27];let k;e[28]!==u||e[29]!==a||e[30]!==o?(k=!o&&(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":u,children:a("Metadata must be valid JSON.")},void 0,!1),e[28]=u,e[29]=a,e[30]=o,e[31]=k):k=e[31];let w;return e[32]!==S||e[33]!==k||e[34]!==y?(w=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[y,S,k]},void 0,!0),e[32]=S,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},"MetadataField"),Je={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Pe=n((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"createReducer"),$e=n(r=>{let e=(0,ee.c)(73),{namespace:s,onCancel:u,onCreated:d}=r,f=Y(),o=U(),[t,a]=(0,J.useReducer)(Pe,Je),p;e[0]!==t.metadata?(p=Ee(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ke(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,M;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(M=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=M):M=e[8];let V=M,L;e[9]!==V||e[10]!==f||e[11]!==s||e[12]!==d||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(L=n(()=>{V&&(a({type:"submitStart"}),R((async()=>{try{await f.putKvValue(Ve({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,s)),d()}catch(H){a({error:z(H),type:"submitFailed"})}})()))},"t4"),e[9]=V,e[10]=f,e[11]=s,e[12]=d,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=L):L=e[17];let h=L,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let y;e[20]!==v?(y=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-name",children:v},void 0,!1),e[20]=v,e[21]=y):y=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=n(H=>{a({field:"name",type:"setField",value:H.target.value})},"t7"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let S;e[25]!==t.name||e[26]!==C?(S=(0,l.jsxDEV)(le,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name},void 0,!1),e[25]=t.name,e[26]=C,e[27]=S):S=e[27];let k;e[28]!==y||e[29]!==S?(k=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[y,S]},void 0,!0),e[28]=y,e[29]=S,e[30]=k):k=e[30];let w;e[31]!==o?(w=o("Value"),e[31]=o,e[32]=w):w=e[32];let E;e[33]!==w?(E=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-value",children:w},void 0,!1),e[33]=w,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=n(H=>{a({field:"value",type:"setField",value:H.target.value})},"t13"),e[35]=B):B=e[35];let I;e[36]!==t.value?(I=(0,l.jsxDEV)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value},void 0,!1),e[36]=t.value,e[37]=I):I=e[37];let O;e[38]!==E||e[39]!==I?(O=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[E,I]},void 0,!0),e[38]=E,e[39]=I,e[40]=O):O=e[40];let D=!b,i;e[41]===Symbol.for("react.memo_cache_sentinel")?(i=n(H=>{a({field:"ttl",type:"setField",value:H})},"t17"),e[41]=i):i=e[41];let m;e[42]!==D?(m=(0,l.jsxDEV)(Ie,{id:"kv-create-ttl",invalid:D,onChange:i,testId:"kv-create-ttl"},void 0,!1),e[42]=D,e[43]=m):m=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n(H=>{a({field:"metadata",type:"setField",value:H})},"t19"),e[44]=K):K=e[44];let T;e[45]!==c||e[46]!==t.metadata?(T=(0,l.jsxDEV)(_e,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:K,testId:"kv-create-metadata",valid:c,value:t.metadata},void 0,!1),e[45]=c,e[46]=t.metadata,e[47]=T):T=e[47];let _=!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 A;e[51]!==h||e[52]!==_||e[53]!==F?(A=(0,l.jsxDEV)($,{"data-testid":"kv-create-submit",disabled:_,onClick:h,children:F},void 0,!1),e[51]=h,e[52]=_,e[53]=F,e[54]=A):A=e[54];let g=t.busy,P;e[55]!==o?(P=o("Cancel"),e[55]=o,e[56]=P):P=e[56];let j;e[57]!==u||e[58]!==t.busy||e[59]!==P?(j=(0,l.jsxDEV)($,{"data-testid":"kv-create-cancel",disabled:g,onClick:u,variant:"outline",children:P},void 0,!1),e[57]=u,e[58]=t.busy,e[59]=P,e[60]=j):j=e[60];let Z;e[61]!==A||e[62]!==j?(Z=(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[A,j]},void 0,!0),e[61]=A,e[62]=j,e[63]=Z):Z=e[63];let G;e[64]!==t.error?(G=t.error!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error},void 0,!1),e[64]=t.error,e[65]=G):G=e[65];let te;return e[66]!==k||e[67]!==O||e[68]!==m||e[69]!==T||e[70]!==Z||e[71]!==G?(te=(0,l.jsxDEV)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,O,m,T,Z,G]},void 0,!0),e[66]=k,e[67]=O,e[68]=m,e[69]=T,e[70]=Z,e[71]=G,e[72]=te):te=e[72],te},"KvCreateForm"),He={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Re=n((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"valueReducer"),je=n(r=>{let e=(0,ee.c)(67),{expiration:s,keyName:u,namespace:d,onDeleted:f}=r,o=Y(),t=U(),[a,p]=(0,J.useReducer)(Re,He),c,x;e[0]!==o||e[1]!==u||e[2]!==d?(c=n(()=>{let g={cancelled:!1};return R((async()=>{try{let P=await o.getKvValue({key:u,namespace:d});g.cancelled||p({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){let j=P;g.cancelled||p({error:z(j),type:"loadFailed"})}})()),()=>{g.cancelled=!0}},"t1"),x=[o,d,u],e[0]=o,e[1]=u,e[2]=d,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,J.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n(g=>{p({type:"editValue",value:g.target.value})},"t3"),e[5]=b):b=e[5];let M=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=n(g=>{p({type:"editMetadata",value:g})},"t4"),e[6]=V):V=e[6];let L=V,h;e[7]!==a.editedValue?(h=Te(a.editedValue),e[7]=a.editedValue,e[8]=h):h=e[8];let v=h,y;e[9]!==a.editedMetadata?(y=Ee(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];let N=y,C;e[11]!==a.editedTtl?(C=Ke(a.editedTtl),e[11]=a.editedTtl,e[12]=C):C=e[12];let S=C,k;e[13]!==v?(k=n(()=>{v!==void 0&&p({type:"editValue",value:v})},"t8"),e[13]=v,e[14]=k):k=e[14];let w=k,E;e[15]!==o||e[16]!==s||e[17]!==u||e[18]!==N||e[19]!==d||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(E=n(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),R((async()=>{try{await o.putKvValue(Ve({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},u,d,s)),p({type:"saveOk"})}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t9"),e[15]=o,e[16]=s,e[17]=u,e[18]=N,e[19]=d,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,I;e[25]!==o||e[26]!==u||e[27]!==d||e[28]!==f?(I=n(()=>{p({type:"deleteStart"}),R((async()=>{try{await o.deleteKvKey({key:u,namespace:d}),f(u)}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t10"),e[25]=o,e[26]=u,e[27]=d,e[28]=f,e[29]=I):I=e[29];let O=I,D;e[30]!==u?(D=n(()=>{ie(u)},"t11"),e[30]=u,e[31]=D):D=e[31];let i;e[32]!==t?(i=t("Copy key"),e[32]=t,e[33]=i):i=e[33];let m;e[34]!==D||e[35]!==i?(m=(0,l.jsxDEV)("div",{className:"mb-2 flex justify-end",children:(0,l.jsxDEV)($,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:i},void 0,!1)},void 0,!1),e[34]=D,e[35]=i,e[36]=m):m=e[36];let K;e[37]!==a.loadError?(K=a.loadError!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError},void 0,!1),e[37]=a.loadError,e[38]=K):K=e[38];let T;e[39]!==a.loading||e[40]!==t?(T=a.loading&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")},void 0,!1),e[39]=a.loading,e[40]=t,e[41]=T):T=e[41];let _;e[42]!==v||e[43]!==N||e[44]!==O||e[45]!==w||e[46]!==B||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==S?(_=!a.loading&&a.value!==null&&(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")},void 0,!1),v!==void 0&&(0,l.jsxDEV)(he,{variant:"secondary",children:t("JSON")},void 0,!1),(0,l.jsxDEV)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ke(Ae(a.editedValue))},void 0,!1)]},void 0,!0),(0,l.jsxDEV)("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:M,value:a.editedValue},void 0,!1),(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-copy-value-btn",onClick:n(()=>{ie(a.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(Ie,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!S,onChange:n(g=>{p({type:"editTtl",value:g})},"onChange"),testId:"kv-ttl-input"},void 0,!1),(0,l.jsxDEV)(_e,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:L,testId:"kv-metadata-editor",valid:N,value:a.editedMetadata},void 0,!1),(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!N||!S,onClick:B,children:a.busy==="saving"?t("Saving\u2026"):t("Save")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:O,variant:"destructive",children:a.busy==="deleting"?t("Deleting\u2026"):t("Delete")},void 0,!1)]},void 0,!0),a.writeError!==null&&(0,l.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError},void 0,!1)]},void 0,!0),e[42]=v,e[43]=N,e[44]=O,e[45]=w,e[46]=B,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=S,e[55]=_):_=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")},void 0,!1),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let A;return e[61]!==m||e[62]!==K||e[63]!==T||e[64]!==_||e[65]!==F?(A=(0,l.jsxDEV)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[m,K,T,_,F]},void 0,!0),e[61]=m,e[62]=K,e[63]=T,e[64]=_,e[65]=F,e[66]=A):A=e[66],A},"KvValueEditor"),we=100,ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Ue=n((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let s=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!s.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!s.has(u.name)),selectedKey:r.selectedKey!==null&&s.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(s=>s!==e.name),keys:r.keys===null?null:r.keys.filter(s=>s.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(s=>s!==e.name):[...r.bulk,e.name]};default:return r}},"keyListReducer"),Ze=n(({namespace:r})=>{let e=Y(),s=U(),[u,d]=(0,J.useReducer)(Ue,ze),{appliedPrefix:f,bulk:o,bulkBusy:t,bulkError:a,cursor:p,keys:c,listComplete:x,loadError:b,loading:M,prefixInput:V,reloadNonce:L,selectedKey:h}=u,[v,y]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let i={cancelled:!1};return R((async()=>{d({type:"loadStart"});try{let m=await e.listKvKeys({limit:we,namespace:r,prefix:f===""?void 0:f});i.cancelled||d({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){i.cancelled||d({error:z(m),type:"loadFailed"})}})()),()=>{i.cancelled=!0}},[e,r,f,L]);let N=n(i=>{d({type:"prefixInput",value:i.target.value})},"onPrefixChange"),C=n(()=>{d({type:"applyFilter"})},"onFilter"),S=n(i=>{d({name:i.currentTarget.dataset.key??null,type:"selectKey"})},"onSelectKey"),k=n(()=>{p!==null&&(d({type:"loadStart"}),R((async()=>{try{let i=await e.listKvKeys({cursor:p,limit:we,namespace:r,prefix:f===""?void 0:f});d({cursor:i.cursor??null,keys:i.keys,listComplete:i.listComplete,type:"appendPage"})}catch(i){d({error:z(i),type:"loadFailed"})}})()))},"onLoadMore"),w=n(i=>{d({name:i,type:"keyDeleted"})},"onKeyDeleted"),E=n(i=>{d({name:i,type:"toggleBulk"})},"onToggleBulk"),B=n(i=>{d({names:i&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"onToggleAll"),I=n(()=>{if(o.length===0)return;let i=[...o];d({type:"bulkDeleteStart"}),R((async()=>{let m=await Promise.allSettled(i.map(_=>e.deleteKvKey({key:_,namespace:r}))),K=i.filter((_,F)=>m[F]?.status==="fulfilled"),T=i.length-K.length;d({deleted:K,error:T>0?s("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},"onBulkDelete"),O=n(()=>{y(!1),d({type:"reload"})},"onCreated"),D=c!==null&&c.length>0&&o.length===c.length;return(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(le,{"aria-label":s("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:s("Filter by prefix\u2026"),value:V},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-filter-btn",disabled:M,onClick:C,children:s("Filter")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-new-key-btn",onClick:n(()=>{y(i=>!i)},"onClick"),variant:"outline",children:s("New key")},void 0,!1),o.length>0&&(0,l.jsxDEV)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:I,variant:"destructive",children:t?s("Deleting\u2026"):s("Delete {count}",{count:o.length})},void 0,!1)]},void 0,!0),a!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a},void 0,!1),b!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b},void 0,!1),c!==null&&c.length===0&&!M&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:s("No keys.")},void 0,!1),c!==null&&c.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-key-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:[(0,l.jsxDEV)(Q,{className:"w-10",children:(0,l.jsxDEV)(ue,{"aria-label":s("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:B},void 0,!1)},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Key")},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Expiration")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(oe,{children:c.map(i=>(0,l.jsxDEV)(q,{className:i.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":i.name,"data-testid":`kv-key-row-${i.name}`,onClick:S,children:[(0,l.jsxDEV)(X,{onClick:n(m=>{m.stopPropagation()},"onClick"),children:(0,l.jsxDEV)(ue,{"aria-label":s("Select {name}",{name:i.name}),checked:o.includes(i.name),"data-testid":`kv-select-${i.name}`,onCheckedChange:n(()=>{E(i.name)},"onCheckedChange")},void 0,!1)},void 0,!1),(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:i.name},void 0,!1),(0,l.jsxDEV)(X,{className:"tabular-nums text-xs",children:Oe(i.expiration)},void 0,!1)]},i.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),!x&&p!==null&&(0,l.jsxDEV)("div",{className:"mt-2",children:(0,l.jsxDEV)($,{"data-testid":"kv-load-more",disabled:M,onClick:k,variant:"outline",children:s(M?"Loading\u2026":"Load more")},void 0,!1)},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||y(!1)},"onOpenChange"),open:v,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{children:s("New key")},void 0,!1)},void 0,!1),(0,l.jsxDEV)($e,{namespace:r,onCancel:n(()=>{y(!1)},"onCancel"),onCreated:O},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||d({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{className:"truncate font-mono text-xs",children:h},void 0,!1)},void 0,!1),h!==null&&(0,l.jsxDEV)(je,{expiration:c?.find(i=>i.name===h)?.expiration,keyName:h,namespace:r,onDeleted:w},`${r}:${h}`,!1)]},void 0,!0)},void 0,!1)]},void 0,!0)},"KvKeyList"),ot=n(({loadNamespaces:r}={})=>{let e=Y(),s=U(),[u,d]=(0,J.useState)(null),[f,o]=(0,J.useState)(null),[t,a]=(0,J.useState)(null);(0,J.useEffect)(()=>{let c={cancelled:!1};return R((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(d(x),o(null),a(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(d(null),o(z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=n(c=>{a(c.currentTarget.dataset.ns??null)},"onSelectNs");return(0,l.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[f!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:f},void 0,!1),u!==null&&u.length===0&&(0,l.jsxDEV)(ye,{description:s("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,l.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"},void 0,!1)},void 0,!1),testId:"kv-empty",title:s("No KV namespaces.")},void 0,!1),u!==null&&u.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-namespace-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:(0,l.jsxDEV)(Q,{children:s("Namespace")},void 0,!1)},void 0,!1)},void 0,!1),(0,l.jsxDEV)(oe,{children:u.map(c=>(0,l.jsxDEV)(q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:c.binding},void 0,!1)},c.binding,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),t!==null&&(0,l.jsxDEV)(Ze,{namespace:t},t,!1)]},void 0,!0)},"KvBrowser");export{ot as KvBrowser};
|
|
1
|
+
import{a as be,b as ge,c as xe,d as Ne,e as Ce}from"./chunk-S5NTGHCG.js";import"./chunk-DWDILV2E.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{a as ue}from"./chunk-3GXGLNKW.js";import{g as me,h as ve,i as fe,j as pe}from"./chunk-JHR3HKT5.js";import"./chunk-ZPUO7FNI.js";import"./chunk-WVTPZ6CM.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import"./chunk-ZIGWVHCS.js";import"./chunk-7TJJXVSE.js";import"./chunk-OXHHSUXO.js";import"./chunk-KEGAWN6Y.js";import"./chunk-4F72YCTU.js";import{a as de,b as ne,c as oe,d as q,e as Q,f as X}from"./chunk-GTM65MVX.js";import{a as re,e as se}from"./chunk-Y572GMZE.js";import{a as ce}from"./chunk-VLXV72QE.js";import{a as W}from"./chunk-JSEXCW5Q.js";import"./chunk-KZ6INM5M.js";import"./chunk-4QHKBC77.js";import{R as le}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as $}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as he}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import"./chunk-EBTLTGG3.js";import{f as Y}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ye}from"./chunk-TAD43CG5.js";import{d as U,h as z,l as R,n as ie,o as ke}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as n,e as ae,f as Me,g as Le,h as Be}from"./chunk-RRCPZMC2.js";var J=ae(Me(),1);var ee=ae(Le(),1);var l=ae(Be(),1);var De=n(r=>{let e=r.trim();if(e==="")return;let s=Number(e);return Number.isFinite(s)&&s>0?Math.floor(s):void 0},"parseTtl"),Oe=n(r=>r===void 0?"\u2014":new Date(r*1e3).toISOString(),"formatExpiration"),Ae=n(r=>new TextEncoder().encode(r).length,"byteLength"),Te=n(r=>{if(r.trim()!=="")try{return JSON.stringify(JSON.parse(r),void 0,2)}catch{return}},"tryFormatJson"),Ee=n(r=>{if(r.trim()==="")return!0;try{return JSON.parse(r),!0}catch{return!1}},"isJsonOrEmpty"),Fe=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],Se=n((r,e)=>{let s=r.trim();if(s==="")return"";let u=Number(s),d=Fe.find(f=>f.key===e)?.seconds??1;return Number.isFinite(u)&&u>0?String(Math.round(u*d)):s},"ttlToSeconds"),Ke=n(r=>{let e=r.trim();if(e==="")return!0;let s=Number(e);return Number.isInteger(s)&&s>=60},"isTtlValid"),Ve=n((r,e,s,u)=>{let d=De(r.ttl);return{expiration:d===void 0?u:void 0,expirationTtl:d,key:e,metadata:r.metadata.trim()===""?void 0:JSON.parse(r.metadata),namespace:s,value:r.value}},"buildKvPutOptions"),Ie=n(r=>{let e=(0,ee.c)(60),{helper:s,id:u,invalid:d,onChange:f,testId:o}=r,t=U(),[a,p]=(0,J.useState)(""),[c,x]=(0,J.useState)("seconds"),b;e[0]!==f||e[1]!==c?(b=n(g=>{p(g.target.value),f(Se(g.target.value,c))},"t1"),e[0]=f,e[1]=c,e[2]=b):b=e[2];let M=b,V;e[3]!==a||e[4]!==f?(V=n(g=>{g!==null&&(x(g),f(Se(a,g)))},"t2"),e[3]=a,e[4]=f,e[5]=V):V=e[5];let L=V,h;e[6]!==t?(h=t("days"),e[6]=t,e[7]=h):h=e[7];let v;e[8]!==t?(v=t("hours"),e[8]=t,e[9]=v):v=e[9];let y;e[10]!==t?(y=t("minutes"),e[10]=t,e[11]=y):y=e[11];let N;e[12]!==t?(N=t("seconds"),e[12]=t,e[13]=N):N=e[13];let C;e[14]!==h||e[15]!==v||e[16]!==y||e[17]!==N?(C={days:h,hours:v,minutes:y,seconds:N},e[14]=h,e[15]=v,e[16]=y,e[17]=N,e[18]=C):C=e[18];let S=C,k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==u||e[22]!==k?(w=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:u,children:k},void 0,!1),e[21]=u,e[22]=k,e[23]=w):w=e[23];let E;e[24]!==t?(E=t("No expiration"),e[24]=t,e[25]=E):E=e[25];let B;e[26]!==a||e[27]!==u||e[28]!==d||e[29]!==M||e[30]!==E||e[31]!==o?(B=(0,l.jsxDEV)(le,{"aria-invalid":d,className:"flex-1","data-testid":o,id:u,inputMode:"numeric",onChange:M,placeholder:E,value:a},void 0,!1),e[26]=a,e[27]=u,e[28]=d,e[29]=M,e[30]=E,e[31]=o,e[32]=B):B=e[32];let I;e[33]!==t?(I=t("TTL unit"),e[33]=t,e[34]=I):I=e[34];let O=`${o}-unit`,D;e[35]===Symbol.for("react.memo_cache_sentinel")?(D=(0,l.jsxDEV)(ge,{},void 0,!1),e[35]=D):D=e[35];let i;e[36]!==I||e[37]!==O?(i=(0,l.jsxDEV)(xe,{"aria-label":I,className:"w-[7.5rem]","data-testid":O,children:D},void 0,!1),e[36]=I,e[37]=O,e[38]=i):i=e[38];let m;e[39]!==S?(m=Fe.map(g=>(0,l.jsxDEV)(Ce,{value:g.key,children:S[g.key]},g.key,!1)),e[39]=S,e[40]=m):m=e[40];let K;e[41]!==m?(K=(0,l.jsxDEV)(Ne,{children:m},void 0,!1),e[41]=m,e[42]=K):K=e[42];let T;e[43]!==L||e[44]!==i||e[45]!==K||e[46]!==c?(T=(0,l.jsxDEV)(be,{onValueChange:L,value:c,children:[i,K]},void 0,!0),e[43]=L,e[44]=i,e[45]=K,e[46]=c,e[47]=T):T=e[47];let _;e[48]!==B||e[49]!==T?(_=(0,l.jsxDEV)("div",{className:"flex gap-2",children:[B,T]},void 0,!0),e[48]=B,e[49]=T,e[50]=_):_=e[50];let F;e[51]!==s||e[52]!==d||e[53]!==t||e[54]!==o?(F=d?(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":`${o}-invalid`,children:t("TTL must be at least 60 seconds.")},void 0,!1):s!==void 0&&(0,l.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:s},void 0,!1),e[51]=s,e[52]=d,e[53]=t,e[54]=o,e[55]=F):F=e[55];let A;return e[56]!==_||e[57]!==F||e[58]!==w?(A=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[w,_,F]},void 0,!0),e[56]=_,e[57]=F,e[58]=w,e[59]=A):A=e[59],A},"TtlField"),_e=n(r=>{let e=(0,ee.c)(36),{id:s,invalidTestId:u,onChange:d,testId:f,valid:o,value:t}=r,a=U(),p;e[0]!==t?(p=Te(t),e[0]=t,e[1]=p):p=e[1];let c=p,x;e[2]!==a?(x=a("Metadata (JSON)"),e[2]=a,e[3]=x):x=e[3];let b;e[4]!==s||e[5]!==x?(b=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:s,children:x},void 0,!1),e[4]=s,e[5]=x,e[6]=b):b=e[6];let M=`${f}-format`,V=c===void 0,L;e[7]!==c||e[8]!==d?(L=n(()=>{c!==void 0&&d(c)},"t6"),e[7]=c,e[8]=d,e[9]=L):L=e[9];let h;e[10]!==a?(h=a("Format JSON"),e[10]=a,e[11]=h):h=e[11];let v;e[12]!==M||e[13]!==V||e[14]!==L||e[15]!==h?(v=(0,l.jsxDEV)($,{"data-testid":M,disabled:V,onClick:L,size:"sm",variant:"outline",children:h},void 0,!1),e[12]=M,e[13]=V,e[14]=L,e[15]=h,e[16]=v):v=e[16];let y;e[17]!==b||e[18]!==v?(y=(0,l.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[b,v]},void 0,!0),e[17]=b,e[18]=v,e[19]=y):y=e[19];let N=!o,C;e[20]!==d?(C=n(E=>{d(E.target.value)},"t11"),e[20]=d,e[21]=C):C=e[21];let S;e[22]!==s||e[23]!==N||e[24]!==C||e[25]!==f||e[26]!==t?(S=(0,l.jsxDEV)(ce,{"aria-invalid":N,className:"min-h-[4rem] font-mono text-xs","data-testid":f,id:s,onChange:C,value:t},void 0,!1),e[22]=s,e[23]=N,e[24]=C,e[25]=f,e[26]=t,e[27]=S):S=e[27];let k;e[28]!==u||e[29]!==a||e[30]!==o?(k=!o&&(0,l.jsxDEV)("p",{className:"text-xs text-destructive","data-testid":u,children:a("Metadata must be valid JSON.")},void 0,!1),e[28]=u,e[29]=a,e[30]=o,e[31]=k):k=e[31];let w;return e[32]!==S||e[33]!==k||e[34]!==y?(w=(0,l.jsxDEV)("div",{className:"mb-3 grid gap-1",children:[y,S,k]},void 0,!0),e[32]=S,e[33]=k,e[34]=y,e[35]=w):w=e[35],w},"MetadataField"),Je={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Pe=n((r,e)=>{switch(e.type){case"setField":return{...r,[e.field]:e.value};case"submitFailed":return{...r,busy:!1,error:e.error};case"submitStart":return{...r,busy:!0,error:null};default:return r}},"createReducer"),$e=n(r=>{let e=(0,ee.c)(73),{namespace:s,onCancel:u,onCreated:d}=r,f=Y(),o=U(),[t,a]=(0,J.useReducer)(Pe,Je),p;e[0]!==t.metadata?(p=Ee(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];let c=p,x;e[2]!==t.ttl?(x=Ke(t.ttl),e[2]=t.ttl,e[3]=x):x=e[3];let b=x,M;e[4]!==c||e[5]!==t.busy||e[6]!==t.name||e[7]!==b?(M=t.name.trim()!==""&&c&&b&&!t.busy,e[4]=c,e[5]=t.busy,e[6]=t.name,e[7]=b,e[8]=M):M=e[8];let V=M,L;e[9]!==V||e[10]!==f||e[11]!==s||e[12]!==d||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(L=n(()=>{V&&(a({type:"submitStart"}),R((async()=>{try{await f.putKvValue(Ve({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,s)),d()}catch(H){a({error:z(H),type:"submitFailed"})}})()))},"t4"),e[9]=V,e[10]=f,e[11]=s,e[12]=d,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=L):L=e[17];let h=L,v;e[18]!==o?(v=o("Key name"),e[18]=o,e[19]=v):v=e[19];let y;e[20]!==v?(y=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-name",children:v},void 0,!1),e[20]=v,e[21]=y):y=e[21];let N;e[22]===Symbol.for("react.memo_cache_sentinel")?(N=n(H=>{a({field:"name",type:"setField",value:H.target.value})},"t7"),e[22]=N):N=e[22];let C;e[23]!==o?(C=o("Key name"),e[23]=o,e[24]=C):C=e[24];let S;e[25]!==t.name||e[26]!==C?(S=(0,l.jsxDEV)(le,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:N,placeholder:C,value:t.name},void 0,!1),e[25]=t.name,e[26]=C,e[27]=S):S=e[27];let k;e[28]!==y||e[29]!==S?(k=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[y,S]},void 0,!0),e[28]=y,e[29]=S,e[30]=k):k=e[30];let w;e[31]!==o?(w=o("Value"),e[31]=o,e[32]=w):w=e[32];let E;e[33]!==w?(E=(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-create-value",children:w},void 0,!1),e[33]=w,e[34]=E):E=e[34];let B;e[35]===Symbol.for("react.memo_cache_sentinel")?(B=n(H=>{a({field:"value",type:"setField",value:H.target.value})},"t13"),e[35]=B):B=e[35];let I;e[36]!==t.value?(I=(0,l.jsxDEV)(ce,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:B,value:t.value},void 0,!1),e[36]=t.value,e[37]=I):I=e[37];let O;e[38]!==E||e[39]!==I?(O=(0,l.jsxDEV)("div",{className:"grid gap-1",children:[E,I]},void 0,!0),e[38]=E,e[39]=I,e[40]=O):O=e[40];let D=!b,i;e[41]===Symbol.for("react.memo_cache_sentinel")?(i=n(H=>{a({field:"ttl",type:"setField",value:H})},"t17"),e[41]=i):i=e[41];let m;e[42]!==D?(m=(0,l.jsxDEV)(Ie,{id:"kv-create-ttl",invalid:D,onChange:i,testId:"kv-create-ttl"},void 0,!1),e[42]=D,e[43]=m):m=e[43];let K;e[44]===Symbol.for("react.memo_cache_sentinel")?(K=n(H=>{a({field:"metadata",type:"setField",value:H})},"t19"),e[44]=K):K=e[44];let T;e[45]!==c||e[46]!==t.metadata?(T=(0,l.jsxDEV)(_e,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:K,testId:"kv-create-metadata",valid:c,value:t.metadata},void 0,!1),e[45]=c,e[46]=t.metadata,e[47]=T):T=e[47];let _=!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 A;e[51]!==h||e[52]!==_||e[53]!==F?(A=(0,l.jsxDEV)($,{"data-testid":"kv-create-submit",disabled:_,onClick:h,children:F},void 0,!1),e[51]=h,e[52]=_,e[53]=F,e[54]=A):A=e[54];let g=t.busy,P;e[55]!==o?(P=o("Cancel"),e[55]=o,e[56]=P):P=e[56];let j;e[57]!==u||e[58]!==t.busy||e[59]!==P?(j=(0,l.jsxDEV)($,{"data-testid":"kv-create-cancel",disabled:g,onClick:u,variant:"outline",children:P},void 0,!1),e[57]=u,e[58]=t.busy,e[59]=P,e[60]=j):j=e[60];let Z;e[61]!==A||e[62]!==j?(Z=(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[A,j]},void 0,!0),e[61]=A,e[62]=j,e[63]=Z):Z=e[63];let G;e[64]!==t.error?(G=t.error!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error},void 0,!1),e[64]=t.error,e[65]=G):G=e[65];let te;return e[66]!==k||e[67]!==O||e[68]!==m||e[69]!==T||e[70]!==Z||e[71]!==G?(te=(0,l.jsxDEV)("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,O,m,T,Z,G]},void 0,!0),e[66]=k,e[67]=O,e[68]=m,e[69]=T,e[70]=Z,e[71]=G,e[72]=te):te=e[72],te},"KvCreateForm"),He={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Re=n((r,e)=>{switch(e.type){case"deleteStart":return{...r,busy:"deleting",writeError:null};case"editMetadata":return{...r,editedMetadata:e.value};case"editTtl":return{...r,editedTtl:e.value};case"editValue":return{...r,editedValue:e.value};case"loaded":return{...r,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"saveOk":return{...r,busy:"",value:r.editedValue};case"saveStart":return{...r,busy:"saving",writeError:null};case"writeFailed":return{...r,busy:"",writeError:e.error};default:return r}},"valueReducer"),je=n(r=>{let e=(0,ee.c)(67),{expiration:s,keyName:u,namespace:d,onDeleted:f}=r,o=Y(),t=U(),[a,p]=(0,J.useReducer)(Re,He),c,x;e[0]!==o||e[1]!==u||e[2]!==d?(c=n(()=>{let g={cancelled:!1};return R((async()=>{try{let P=await o.getKvValue({key:u,namespace:d});g.cancelled||p({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){let j=P;g.cancelled||p({error:z(j),type:"loadFailed"})}})()),()=>{g.cancelled=!0}},"t1"),x=[o,d,u],e[0]=o,e[1]=u,e[2]=d,e[3]=c,e[4]=x):(c=e[3],x=e[4]),(0,J.useEffect)(c,x);let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=n(g=>{p({type:"editValue",value:g.target.value})},"t3"),e[5]=b):b=e[5];let M=b,V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=n(g=>{p({type:"editMetadata",value:g})},"t4"),e[6]=V):V=e[6];let L=V,h;e[7]!==a.editedValue?(h=Te(a.editedValue),e[7]=a.editedValue,e[8]=h):h=e[8];let v=h,y;e[9]!==a.editedMetadata?(y=Ee(a.editedMetadata),e[9]=a.editedMetadata,e[10]=y):y=e[10];let N=y,C;e[11]!==a.editedTtl?(C=Ke(a.editedTtl),e[11]=a.editedTtl,e[12]=C):C=e[12];let S=C,k;e[13]!==v?(k=n(()=>{v!==void 0&&p({type:"editValue",value:v})},"t8"),e[13]=v,e[14]=k):k=e[14];let w=k,E;e[15]!==o||e[16]!==s||e[17]!==u||e[18]!==N||e[19]!==d||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(E=n(()=>{if(!N){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),R((async()=>{try{await o.putKvValue(Ve({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},u,d,s)),p({type:"saveOk"})}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t9"),e[15]=o,e[16]=s,e[17]=u,e[18]=N,e[19]=d,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=E):E=e[24];let B=E,I;e[25]!==o||e[26]!==u||e[27]!==d||e[28]!==f?(I=n(()=>{p({type:"deleteStart"}),R((async()=>{try{await o.deleteKvKey({key:u,namespace:d}),f(u)}catch(g){p({error:z(g),type:"writeFailed"})}})())},"t10"),e[25]=o,e[26]=u,e[27]=d,e[28]=f,e[29]=I):I=e[29];let O=I,D;e[30]!==u?(D=n(()=>{ie(u)},"t11"),e[30]=u,e[31]=D):D=e[31];let i;e[32]!==t?(i=t("Copy key"),e[32]=t,e[33]=i):i=e[33];let m;e[34]!==D||e[35]!==i?(m=(0,l.jsxDEV)("div",{className:"mb-2 flex justify-end",children:(0,l.jsxDEV)($,{"data-testid":"kv-copy-key-btn",onClick:D,size:"sm",variant:"outline",children:i},void 0,!1)},void 0,!1),e[34]=D,e[35]=i,e[36]=m):m=e[36];let K;e[37]!==a.loadError?(K=a.loadError!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError},void 0,!1),e[37]=a.loadError,e[38]=K):K=e[38];let T;e[39]!==a.loading||e[40]!==t?(T=a.loading&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading\u2026")},void 0,!1),e[39]=a.loading,e[40]=t,e[41]=T):T=e[41];let _;e[42]!==v||e[43]!==N||e[44]!==O||e[45]!==w||e[46]!==B||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==S?(_=!a.loading&&a.value!==null&&(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(W,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")},void 0,!1),v!==void 0&&(0,l.jsxDEV)(he,{variant:"secondary",children:t("JSON")},void 0,!1),(0,l.jsxDEV)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:ke(Ae(a.editedValue))},void 0,!1)]},void 0,!0),(0,l.jsxDEV)("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:M,value:a.editedValue},void 0,!1),(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-format-btn",disabled:v===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-copy-value-btn",onClick:n(()=>{ie(a.editedValue)},"onClick"),size:"sm",variant:"outline",children:t("Copy value")},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(Ie,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!S,onChange:n(g=>{p({type:"editTtl",value:g})},"onChange"),testId:"kv-ttl-input"},void 0,!1),(0,l.jsxDEV)(_e,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:L,testId:"kv-metadata-editor",valid:N,value:a.editedMetadata},void 0,!1),(0,l.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,l.jsxDEV)($,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!N||!S,onClick:B,children:a.busy==="saving"?t("Saving\u2026"):t("Save")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:O,variant:"destructive",children:a.busy==="deleting"?t("Deleting\u2026"):t("Delete")},void 0,!1)]},void 0,!0),a.writeError!==null&&(0,l.jsxDEV)("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError},void 0,!1)]},void 0,!0),e[42]=v,e[43]=N,e[44]=O,e[45]=w,e[46]=B,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=S,e[55]=_):_=e[55];let F;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(F=!a.loading&&a.value===null&&a.loadError===null&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")},void 0,!1),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=F):F=e[60];let A;return e[61]!==m||e[62]!==K||e[63]!==T||e[64]!==_||e[65]!==F?(A=(0,l.jsxDEV)("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[m,K,T,_,F]},void 0,!0),e[61]=m,e[62]=K,e[63]=T,e[64]=_,e[65]=F,e[66]=A):A=e[66],A},"KvValueEditor"),we=100,ze={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Ue=n((r,e)=>{switch(e.type){case"appendPage":return{...r,cursor:e.cursor,keys:[...r.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...r,appliedPrefix:r.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{let s=new Set(e.deleted);return{...r,bulk:r.bulk.filter(u=>!s.has(u)),bulkBusy:!1,bulkError:e.error,keys:r.keys===null?null:r.keys.filter(u=>!s.has(u.name)),selectedKey:r.selectedKey!==null&&s.has(r.selectedKey)?null:r.selectedKey}}case"bulkDeleteStart":return{...r,bulkBusy:!0,bulkError:null};case"firstPage":return{...r,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...r,bulk:r.bulk.filter(s=>s!==e.name),keys:r.keys===null?null:r.keys.filter(s=>s.name!==e.name),selectedKey:null};case"loadFailed":return{...r,loadError:e.error,loading:!1};case"loadStart":return{...r,loadError:null,loading:!0};case"prefixInput":return{...r,prefixInput:e.value};case"reload":return{...r,bulk:[],bulkError:null,reloadNonce:r.reloadNonce+1,selectedKey:null};case"selectKey":return{...r,selectedKey:e.name};case"toggleAllBulk":return{...r,bulk:e.names};case"toggleBulk":return{...r,bulk:r.bulk.includes(e.name)?r.bulk.filter(s=>s!==e.name):[...r.bulk,e.name]};default:return r}},"keyListReducer"),Ze=n(({namespace:r})=>{let e=Y(),s=U(),[u,d]=(0,J.useReducer)(Ue,ze),{appliedPrefix:f,bulk:o,bulkBusy:t,bulkError:a,cursor:p,keys:c,listComplete:x,loadError:b,loading:M,prefixInput:V,reloadNonce:L,selectedKey:h}=u,[v,y]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let i={cancelled:!1};return R((async()=>{d({type:"loadStart"});try{let m=await e.listKvKeys({limit:we,namespace:r,prefix:f===""?void 0:f});i.cancelled||d({cursor:m.cursor??null,keys:m.keys,listComplete:m.listComplete,type:"firstPage"})}catch(m){i.cancelled||d({error:z(m),type:"loadFailed"})}})()),()=>{i.cancelled=!0}},[e,r,f,L]);let N=n(i=>{d({type:"prefixInput",value:i.target.value})},"onPrefixChange"),C=n(()=>{d({type:"applyFilter"})},"onFilter"),S=n(i=>{d({name:i.currentTarget.dataset.key??null,type:"selectKey"})},"onSelectKey"),k=n(()=>{p!==null&&(d({type:"loadStart"}),R((async()=>{try{let i=await e.listKvKeys({cursor:p,limit:we,namespace:r,prefix:f===""?void 0:f});d({cursor:i.cursor??null,keys:i.keys,listComplete:i.listComplete,type:"appendPage"})}catch(i){d({error:z(i),type:"loadFailed"})}})()))},"onLoadMore"),w=n(i=>{d({name:i,type:"keyDeleted"})},"onKeyDeleted"),E=n(i=>{d({name:i,type:"toggleBulk"})},"onToggleBulk"),B=n(i=>{d({names:i&&c!==null?c.map(m=>m.name):[],type:"toggleAllBulk"})},"onToggleAll"),I=n(()=>{if(o.length===0)return;let i=[...o];d({type:"bulkDeleteStart"}),R((async()=>{let m=await Promise.allSettled(i.map(_=>e.deleteKvKey({key:_,namespace:r}))),K=i.filter((_,F)=>m[F]?.status==="fulfilled"),T=i.length-K.length;d({deleted:K,error:T>0?s("Failed to delete {count} keys.",{count:T}):null,type:"bulkDeleted"})})())},"onBulkDelete"),O=n(()=>{y(!1),d({type:"reload"})},"onCreated"),D=c!==null&&c.length>0&&o.length===c.length;return(0,l.jsxDEV)(l.Fragment,{children:[(0,l.jsxDEV)("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[(0,l.jsxDEV)("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[(0,l.jsxDEV)(le,{"aria-label":s("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:N,placeholder:s("Filter by prefix\u2026"),value:V},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-filter-btn",disabled:M,onClick:C,children:s("Filter")},void 0,!1),(0,l.jsxDEV)($,{"data-testid":"kv-new-key-btn",onClick:n(()=>{y(i=>!i)},"onClick"),variant:"outline",children:s("New key")},void 0,!1),o.length>0&&(0,l.jsxDEV)($,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:I,variant:"destructive",children:t?s("Deleting\u2026"):s("Delete {count}",{count:o.length})},void 0,!1)]},void 0,!0),a!==null&&(0,l.jsxDEV)("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a},void 0,!1),b!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:b},void 0,!1),c!==null&&c.length===0&&!M&&(0,l.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:s("No keys.")},void 0,!1),c!==null&&c.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-key-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:[(0,l.jsxDEV)(Q,{className:"w-10",children:(0,l.jsxDEV)(ue,{"aria-label":s("Select all"),checked:D,"data-testid":"kv-select-all",onCheckedChange:B},void 0,!1)},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Key")},void 0,!1),(0,l.jsxDEV)(Q,{children:s("Expiration")},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(oe,{children:c.map(i=>(0,l.jsxDEV)(q,{className:i.name===h?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":i.name,"data-testid":`kv-key-row-${i.name}`,onClick:S,children:[(0,l.jsxDEV)(X,{onClick:n(m=>{m.stopPropagation()},"onClick"),children:(0,l.jsxDEV)(ue,{"aria-label":s("Select {name}",{name:i.name}),checked:o.includes(i.name),"data-testid":`kv-select-${i.name}`,onCheckedChange:n(()=>{E(i.name)},"onCheckedChange")},void 0,!1)},void 0,!1),(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:i.name},void 0,!1),(0,l.jsxDEV)(X,{className:"tabular-nums text-xs",children:Oe(i.expiration)},void 0,!1)]},i.name,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),!x&&p!==null&&(0,l.jsxDEV)("div",{className:"mt-2",children:(0,l.jsxDEV)($,{"data-testid":"kv-load-more",disabled:M,onClick:k,variant:"outline",children:s(M?"Loading\u2026":"Load more")},void 0,!1)},void 0,!1)]},void 0,!0),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||y(!1)},"onOpenChange"),open:v,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{children:s("New key")},void 0,!1)},void 0,!1),(0,l.jsxDEV)($e,{namespace:r,onCancel:n(()=>{y(!1)},"onCancel"),onCreated:O},void 0,!1)]},void 0,!0)},void 0,!1),(0,l.jsxDEV)(me,{onOpenChange:n(i=>{i||d({name:null,type:"selectKey"})},"onOpenChange"),open:h!==null,children:(0,l.jsxDEV)(ve,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[(0,l.jsxDEV)(fe,{children:(0,l.jsxDEV)(pe,{className:"truncate font-mono text-xs",children:h},void 0,!1)},void 0,!1),h!==null&&(0,l.jsxDEV)(je,{expiration:c?.find(i=>i.name===h)?.expiration,keyName:h,namespace:r,onDeleted:w},`${r}:${h}`,!1)]},void 0,!0)},void 0,!1)]},void 0,!0)},"KvKeyList"),ot=n(({loadNamespaces:r}={})=>{let e=Y(),s=U(),[u,d]=(0,J.useState)(null),[f,o]=(0,J.useState)(null),[t,a]=(0,J.useState)(null);(0,J.useEffect)(()=>{let c={cancelled:!1};return R((async()=>{try{let x=await(r??(()=>e.listKvNamespaces()))();c.cancelled||(d(x),o(null),a(b=>b??x[0]?.binding??null))}catch(x){c.cancelled||(d(null),o(z(x)))}})()),()=>{c.cancelled=!0}},[e,r]);let p=n(c=>{a(c.currentTarget.dataset.ns??null)},"onSelectNs");return(0,l.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[f!==null&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:f},void 0,!1),u!==null&&u.length===0&&(0,l.jsxDEV)(ye,{description:s("Add a kv_namespaces binding to wrangler.jsonc \u2014 it appears here automatically, no wiring needed."),icon:(0,l.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"},void 0,!1)},void 0,!1),testId:"kv-empty",title:s("No KV namespaces.")},void 0,!1),u!==null&&u.length>0&&(0,l.jsxDEV)(re,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(se,{className:"px-0",children:(0,l.jsxDEV)(de,{"data-testid":"kv-namespace-table",children:[(0,l.jsxDEV)(ne,{children:(0,l.jsxDEV)(q,{children:(0,l.jsxDEV)(Q,{children:s("Namespace")},void 0,!1)},void 0,!1)},void 0,!1),(0,l.jsxDEV)(oe,{children:u.map(c=>(0,l.jsxDEV)(q,{className:c.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":c.binding,"data-testid":`kv-ns-row-${c.binding}`,onClick:p,children:(0,l.jsxDEV)(X,{className:"font-mono text-xs",children:c.binding},void 0,!1)},c.binding,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),t!==null&&(0,l.jsxDEV)(Ze,{namespace:t},t,!1)]},void 0,!0)},"KvBrowser");export{ot as KvBrowser};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as V}from"./chunk-XNJNSCLM.js";import{h as w,i as A,j as E}from"./chunk-
|
|
1
|
+
import{a as V}from"./chunk-XNJNSCLM.js";import{h as w,i as A,j as E}from"./chunk-5XO36X4C.js";import{a as b}from"./chunk-ZXLEXF4X.js";import{a as x,e as N,g as D,h as H}from"./chunk-RRCPZMC2.js";var g=N(D(),1);var d=N(H(),1);var y=x(k=>{let e=(0,g.c)(26),{className:u,error:t,testId:h}=k,o,l,i,s,a,r,n;if(e[0]!==u||e[1]!==t||e[2]!==h){let v=A(t),p;e[10]!==t?(p=E(t),e[10]=t,e[11]=p):p=e[11],l=p,o=V,i=u,s=h,a="destructive";let m;e[12]!==t?(m=w(t),e[12]=t,e[13]=m):m=e[13],e[14]!==m?(r=(0,d.jsxDEV)("p",{className:"font-medium",children:m},void 0,!1),e[14]=m,e[15]=r):r=e[15],n=v===void 0?null:(0,d.jsxDEV)("p",{className:"mt-1 whitespace-pre-wrap text-xs opacity-90",children:b(v)},void 0,!1),e[0]=u,e[1]=t,e[2]=h,e[3]=o,e[4]=l,e[5]=i,e[6]=s,e[7]=a,e[8]=r,e[9]=n}else o=e[3],l=e[4],i=e[5],s=e[6],a=e[7],r=e[8],n=e[9];let c;e[16]!==l?(c=l===void 0?null:(0,d.jsxDEV)("a",{"aria-label":"View documentation for this error",className:"mt-1 inline-block text-xs underline",href:l,rel:"noreferrer",target:"_blank",children:"View error docs"},void 0,!1),e[16]=l,e[17]=c):c=e[17];let f;return e[18]!==o||e[19]!==i||e[20]!==s||e[21]!==a||e[22]!==r||e[23]!==n||e[24]!==c?(f=(0,d.jsxDEV)(o,{className:i,testId:s,variant:a,children:[r,n,c]},void 0,!0),e[18]=o,e[19]=i,e[20]=s,e[21]=a,e[22]=r,e[23]=n,e[24]=c,e[25]=f):f=e[25],f},"ErrorAlert");export{y as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk-
|
|
1
|
+
import{a as D}from"./chunk-FQUNSQLG.js";import{b as _}from"./chunk-4F72YCTU.js";import{a as O,b as $,c as k,d as T,e as r,f as o}from"./chunk-GTM65MVX.js";import{a as A,e as I}from"./chunk-Y572GMZE.js";import{b}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as L}from"./chunk-EBTLTGG3.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as S}from"./chunk-TAD43CG5.js";import{d as E}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as x,e as C,f as M,g as P,h as V}from"./chunk-RRCPZMC2.js";var B=C(P(),1),K=C(M(),1);var t=C(V(),1);var R="container:",F={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},H=x(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let s=e.slice(n+1).trim(),a=e.slice(0,n).trim();return s===""?{event:a}:{detail:s,event:a}},"parseContainerMessage"),W=x(e=>{let n=new Map;for(let s of e){let a=s.functionPath??"";if(!a.startsWith(R))continue;let i=a.slice(R.length);if(i==="")continue;let l=JSON.stringify([i,s.instance??""]),d=n.get(l);if(d!==void 0&&d.timestamp>=s.timestamp)continue;let{detail:N,event:c}=H(s.message);n.set(l,{detail:N,event:c,exitCode:s.exitCode,instance:s.instance,level:s.level,name:i,state:F[c]??"unknown",timestamp:s.timestamp})}return[...n.values()].toSorted((s,a)=>s.name.localeCompare(a.name)||(s.instance??"").localeCompare(a.instance??""))},"foldContainerInstances"),j={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},G=x(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"entriesOf"),ee=x(()=>{let e=(0,B.c)(23),n=E(),s,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},a={live:!0,shardKey:""},e[0]=s,e[1]=a):(s=e[0],a=e[1]);let{data:i,error:l,liveError:d}=_(L.getLogs,s,a),N=i!==void 0,c;e[2]!==i?(c=W(G(i)),e[2]=i,e[3]=c):c=e[3];let g=c,m;e[4]!==l?(m=l!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:l},void 0,!1),e[4]=l,e[5]=m):m=e[5];let f;e[6]!==n?(f=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[6]=n,e[7]=f):f=e[7];let u;e[8]!==f?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:f},void 0,!1),e[8]=f,e[9]=u):u=e[9];let p;e[10]!==d?(p=(0,t.jsxDEV)(D,{message:d,prefix:"containers"},void 0,!1),e[10]=d,e[11]=p):p=e[11];let v;e[12]!==u||e[13]!==p?(v=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,p]},void 0,!0),e[12]=u,e[13]=p,e[14]=v):v=e[14];let h;e[15]!==N||e[16]!==g||e[17]!==n?(h=N&&g.length===0?(0,t.jsxDEV)(S,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")},void 0,!1):(0,t.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(I,{className:"px-0",children:(0,t.jsxDEV)(O,{"data-testid":"containers-table",children:[(0,t.jsxDEV)($,{children:(0,t.jsxDEV)(T,{children:[(0,t.jsxDEV)(r,{children:n("Container")},void 0,!1),(0,t.jsxDEV)(r,{children:n("Instance")},void 0,!1),(0,t.jsxDEV)(r,{children:n("State")},void 0,!1),(0,t.jsxDEV)(r,{children:n("Last event")},void 0,!1),(0,t.jsxDEV)(r,{children:n("Detail")},void 0,!1),(0,t.jsxDEV)(r,{children:n("Exit")},void 0,!1),(0,t.jsxDEV)(r,{children:n("When")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(k,{children:g.map(J)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[15]=N,e[16]=g,e[17]=n,e[18]=h):h=e[18];let y;return e[19]!==m||e[20]!==v||e[21]!==h?(y=(0,t.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[m,v,h]},void 0,!0),e[19]=m,e[20]=v,e[21]=h,e[22]=y):y=e[22],y},"ContainersPanel");function J(e){return(0,t.jsxDEV)(T,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsxDEV)(o,{className:"font-mono text-xs",children:e.name},void 0,!1),(0,t.jsxDEV)(o,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"},void 0,!1),(0,t.jsxDEV)(o,{children:(0,t.jsxDEV)(b,{variant:j[e.state],children:e.state},void 0,!1)},void 0,!1),(0,t.jsxDEV)(o,{className:"font-mono text-xs text-muted-foreground",children:e.event},void 0,!1),(0,t.jsxDEV)(o,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"},void 0,!1),(0,t.jsxDEV)(o,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"},void 0,!1),(0,t.jsxDEV)(o,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()},void 0,!1)]},`${e.name}/${e.instance??""}`,!0)}x(J,"_temp");export{ee as ContainersPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _={clearCapturedMail:"__lunora_admin__:clearCapturedMail",clearQueueMessages:"__lunora_admin__:clearQueueMessages",clearTable:"__lunora_admin__:clearTable",createWorkflowInstance:"__lunora_admin__:createWorkflowInstance",deleteRows:"__lunora_admin__:deleteRows",describeTable:"__lunora_admin__:describeTable",describeTables:"__lunora_admin__:describeTables",exportShard:"__lunora_admin__:exportShard",facetColumn:"__lunora_admin__:facetColumn",getAdvisories:"__lunora_admin__:getAdvisories",getAuditLog:"__lunora_admin__:getAuditLog",getAuthMetrics:"__lunora_admin__:getAuthMetrics",getCapturedMail:"__lunora_admin__:getCapturedMail",getFanoutMetrics:"__lunora_admin__:getFanoutMetrics",getFunctionStats:"__lunora_admin__:getFunctionStats",getIssues:"__lunora_admin__:getIssues",listFlags:"__lunora_admin__:listFlags",listQueues:"__lunora_admin__:listQueues",listSubscriptions:"__lunora_admin__:listSubscriptions",listTableIndexes:"__lunora_admin__:listTableIndexes",listWorkflows:"__lunora_admin__:listWorkflows",getLogs:"__lunora_admin__:getLogs",getMetricSeries:"__lunora_admin__:getMetricSeries",getMetrics:"__lunora_admin__:getMetrics",getPitrBookmark:"__lunora_admin__:getPitrBookmark",getQueueMessages:"__lunora_admin__:getQueueMessages",getRequestLog:"__lunora_admin__:getRequestLog",getSecurityAudit:"__lunora_admin__:getSecurityAudit",getSettings:"__lunora_admin__:getSettings",getTraces:"__lunora_admin__:getTraces",getWorkflowInstanceStatus:"__lunora_admin__:getWorkflowInstanceStatus",importShard:"__lunora_admin__:importShard",listTables:"__lunora_admin__:listTables",maskPolicies:"__lunora_admin__:maskPolicies",migrationStatus:"__lunora_admin__:migrationStatus",pitrRestore:"__lunora_admin__:pitrRestore",readTablePage:"__lunora_admin__:readTablePage",replayQueueMessage:"__lunora_admin__:replayQueueMessage",rlsPolicies:"__lunora_admin__:rlsPolicies",runAs:"__lunora_admin__:runAs",runMigration:"__lunora_admin__:runMigration",runSql:"__lunora_admin__:runSql",sendQueueMessage:"__lunora_admin__:sendQueueMessage",sendTestMail:"__lunora_admin__:sendTestMail",storageOrphans:"__lunora_admin__:storageOrphans",storageReferences:"__lunora_admin__:storageReferences",storageRules:"__lunora_admin__:storageRules",studioFeatures:"__lunora_admin__:studioFeatures",writeRow:"__lunora_admin__:writeRow"};export{_ as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as le}from"./chunk-N7SVJOHN.js";import{a as oe}from"./chunk-FQUNSQLG.js";import{a as se}from"./chunk-2K47A3P6.js";import{a as ae}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as Z}from"./chunk-4F72YCTU.js";import{a as re}from"./chunk-FDWXYXOM.js";import{b as te}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as J}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import"./chunk-O3NAGRTR.js";import{b as G}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as ee}from"./chunk-EBTLTGG3.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as X}from"./chunk-TAD43CG5.js";import{d as Q,p as Y}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as S,e as q,f as de,g as ce,h as fe,j as z}from"./chunk-RRCPZMC2.js";var V=q(ce(),1),K=q(de(),1);var s=q(fe(),1);var me=.5,ne=S(o=>Math.min(100,Math.max(0,o)),"clampPercent"),ue=S((o,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let r=ne(o.offsetMs/e*100),a=o.durationMs/e*100,t=Math.max(me,Math.min(ne(a),100-r));return{leftPercent:r,widthPercent:t}},"spanBar"),he=S((o,e)=>{let r=e.trim().toLowerCase();return r===""?[...o]:o.filter(a=>a.rootName.toLowerCase().includes(r)||a.functionPath.toLowerCase().includes(r))},"filterTraces"),U=S(o=>Number.isFinite(o)?o>0&&o<1?`${o.toFixed(2)}ms`:`${String(Math.round(o))}ms`:"\u2014","formatSpanDuration"),pe=14,ge=S(o=>Array.isArray(o?.traces)?o.traces:[],"tracesOf"),ve=S(o=>{let e=(0,V.c)(50),{span:r,traceDurationMs:a}=o,t=Q(),f;e[0]!==r||e[1]!==a?(f=ue(r,a),e[0]=r,e[1]=a,e[2]=f):f=e[2];let{leftPercent:u,widthPercent:_}=f,k;e[3]!==r.attributes?(k=le(r.attributes),e[3]=r.attributes,e[4]=k):k=e[4];let T=k,M=r.depth*pe,h;e[5]!==M?(h={paddingLeft:M},e[5]=M,e[6]=h):h=e[6];let x=h,b=`${String(u)}%`,n=`${String(_)}%`,l;e[7]!==b||e[8]!==n?(l={left:b,width:n},e[7]=b,e[8]=n,e[9]=l):l=e[9];let p=l,I=r.depth,i;e[10]!==r.ok||e[11]!==t?(i=r.ok?null:(0,s.jsxDEV)("span",{"aria-label":t("Errored span"),className:"mr-1 text-destructive","data-testid":"tr-span-error",role:"img",children:"\u25CF"},void 0,!1),e[10]=r.ok,e[11]=t,e[12]=i):i=e[12];let w;e[13]!==x||e[14]!==r.name||e[15]!==i?(w=(0,s.jsxDEV)("span",{className:"w-56 shrink-0 truncate",role:"gridcell",style:x,title:r.name,children:[i,r.name]},void 0,!0),e[13]=x,e[14]=r.name,e[15]=i,e[16]=w):w=e[16];let d;e[17]!==r.durationMs||e[18]!==r.offsetMs||e[19]!==t?(d=t("starts {offset} in, runs {duration}",{duration:U(r.durationMs),offset:U(r.offsetMs)}),e[17]=r.durationMs,e[18]=r.offsetMs,e[19]=t,e[20]=d):d=e[20];let N=r.ok?"bg-primary/70":"bg-destructive",c;e[21]!==N?(c=z("absolute inset-y-0 rounded-sm",N),e[21]=N,e[22]=c):c=e[22];let g;e[23]!==p||e[24]!==u||e[25]!==c||e[26]!==_?(g=(0,s.jsxDEV)("span",{className:c,"data-left":u,"data-testid":"tr-span-bar","data-width":_,style:p},void 0,!1),e[23]=p,e[24]=u,e[25]=c,e[26]=_,e[27]=g):g=e[27];let y;e[28]!==d||e[29]!==g?(y=(0,s.jsxDEV)("span",{"aria-label":d,className:"relative h-3 flex-1 overflow-hidden rounded-sm bg-muted",role:"gridcell",children:g},void 0,!1),e[28]=d,e[29]=g,e[30]=y):y=e[30];let m;e[31]!==r.durationMs?(m=U(r.durationMs),e[31]=r.durationMs,e[32]=m):m=e[32];let v;e[33]!==m?(v=(0,s.jsxDEV)("span",{className:"w-16 shrink-0 text-right tabular-nums text-muted-foreground",role:"gridcell",children:m},void 0,!1),e[33]=m,e[34]=v):v=e[34];let E;e[35]!==r.error?(E=r.error===void 0?null:(0,s.jsxDEV)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:r.error.message,children:`${r.error.type}: ${r.error.message}`},void 0,!1),e[35]=r.error,e[36]=E):E=e[36];let P;e[37]!==E?(P=(0,s.jsxDEV)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:E},void 0,!1),e[37]=E,e[38]=P):P=e[38];let A;e[39]!==T?(A=T===""?null:(0,s.jsxDEV)("span",{"data-testid":"tr-span-attributes",title:T,children:T},void 0,!1),e[39]=T,e[40]=A):A=e[40];let C;e[41]!==A?(C=(0,s.jsxDEV)("span",{className:"w-64 shrink-0 truncate text-muted-foreground",role:"gridcell",children:A},void 0,!1),e[41]=A,e[42]=C):C=e[42];let $;return e[43]!==r.depth||e[44]!==w||e[45]!==y||e[46]!==v||e[47]!==P||e[48]!==C?($=(0,s.jsxDEV)("div",{className:"flex items-center gap-2 border-b border-border px-3 py-1.5 font-mono text-xs last:border-b-0 hover:bg-muted/50","data-depth":I,"data-testid":"tr-span-row",role:"row",children:[w,y,v,P,C]},void 0,!0),e[43]=r.depth,e[44]=w,e[45]=y,e[46]=v,e[47]=P,e[48]=C,e[49]=$):$=e[49],$},"SpanRow"),xe=S(o=>{let e=(0,V.c)(50),{expanded:r,onToggle:a,trace:t}=o,f=Q(),u;e[0]!==a||e[1]!==t.traceId?(u=S(()=>{a(t.traceId)},"t1"),e[0]=a,e[1]=t.traceId,e[2]=u):u=e[2];let _=u,k=`tr-row-${t.traceId}`,T=`tr-waterfall-${t.traceId}`,M=`tr-toggle-${t.traceId}`,h=r?"\u25BE":"\u25B8",x;e[3]!==h?(x=(0,s.jsxDEV)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:h},void 0,!1),e[3]=h,e[4]=x):x=e[4];let b;e[5]!==t.rootName?(b=(0,s.jsxDEV)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:t.rootName,children:t.rootName},void 0,!1),e[5]=t.rootName,e[6]=b):b=e[6];let n;e[7]!==t.functionPath?(n=(0,s.jsxDEV)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:t.functionPath,children:t.functionPath},void 0,!1),e[7]=t.functionPath,e[8]=n):n=e[8];let l;e[9]!==t.durationMs?(l=U(t.durationMs),e[9]=t.durationMs,e[10]=l):l=e[10];let p;e[11]!==l?(p=(0,s.jsxDEV)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:l},void 0,!1),e[11]=l,e[12]=p):p=e[12];let I;e[13]!==f||e[14]!==t.spans.length?(I=f("{count} spans",{count:t.spans.length}),e[13]=f,e[14]=t.spans.length,e[15]=I):I=e[15];let i;e[16]!==I?(i=(0,s.jsxDEV)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:I},void 0,!1),e[16]=I,e[17]=i):i=e[17];let w=t.ok?"secondary":"destructive",d;e[18]!==f||e[19]!==t.ok?(d=t.ok?f("ok"):f("error"),e[18]=f,e[19]=t.ok,e[20]=d):d=e[20];let N;e[21]!==w||e[22]!==d?(N=(0,s.jsxDEV)("span",{className:"shrink-0",children:(0,s.jsxDEV)(G,{variant:w,children:d},void 0,!1)},void 0,!1),e[21]=w,e[22]=d,e[23]=N):N=e[23];let c;e[24]!==t.startTs?(c=Y(t.startTs),e[24]=t.startTs,e[25]=c):c=e[25];let g;e[26]!==c?(g=(0,s.jsxDEV)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:c},void 0,!1),e[26]=c,e[27]=g):g=e[27];let y;e[28]!==r||e[29]!==_||e[30]!==p||e[31]!==i||e[32]!==N||e[33]!==g||e[34]!==T||e[35]!==M||e[36]!==x||e[37]!==b||e[38]!==n?(y=(0,s.jsxDEV)("button",{"aria-controls":T,"aria-expanded":r,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":M,onClick:_,type:"button",children:[x,b,n,p,i,N,g]},void 0,!0),e[28]=r,e[29]=_,e[30]=p,e[31]=i,e[32]=N,e[33]=g,e[34]=T,e[35]=M,e[36]=x,e[37]=b,e[38]=n,e[39]=y):y=e[39];let m;e[40]!==r||e[41]!==f||e[42]!==t.durationMs||e[43]!==t.spans||e[44]!==t.traceId?(m=r&&(0,s.jsxDEV)("div",{"aria-label":f("Trace waterfall"),className:"bg-muted/20","data-testid":`tr-waterfall-${t.traceId}`,id:`tr-waterfall-${t.traceId}`,role:"grid",children:t.spans.map(E=>(0,s.jsxDEV)(ve,{span:E,traceDurationMs:t.durationMs},E.spanId,!1))},void 0,!1),e[40]=r,e[41]=f,e[42]=t.durationMs,e[43]=t.spans,e[44]=t.traceId,e[45]=m):m=e[45];let v;return e[46]!==y||e[47]!==m||e[48]!==k?(v=(0,s.jsxDEV)("div",{className:"border-b border-border last:border-b-0","data-testid":k,children:[y,m]},void 0,!0),e[46]=y,e[47]=m,e[48]=k,e[49]=v):v=e[49],v},"TraceRow"),Ae=S(o=>{let e=(0,V.c)(43),{initialShardKey:r}=o,a=Q(),[t,f]=(0,K.useState)(r??""),[u,_]=(0,K.useState)(""),[k,T]=(0,K.useState)(be),M;e[0]!==t?(M=t.trim(),e[0]=t,e[1]=M):M=e[1];let h=se(M,400),x;e[2]===Symbol.for("react.memo_cache_sentinel")?(x={},e[2]=x):x=e[2];let b;e[3]!==h?(b={live:!0,shardKey:h},e[3]=h,e[4]=b):b=e[4];let{data:n,error:l,errorSource:p,isLoading:I,liveError:i}=Z(ee.getTraces,x,b),w,d;e[5]!==n||e[6]!==h?(w=S(()=>{n!==void 0&&te(h)},"t4"),d=[n,h],e[5]=n,e[6]=h,e[7]=w,e[8]=d):(w=e[7],d=e[8]),(0,K.useEffect)(w,d);let N;if(e[9]!==n||e[10]!==l||e[11]!==p||e[12]!==k||e[13]!==I||e[14]!==i||e[15]!==u||e[16]!==t||e[17]!==a){let c=ge(n),g=n?.total??c.length,y=g>c.length,m=he(c,u),v;e[19]===Symbol.for("react.memo_cache_sentinel")?(v=S(L=>{_(L.target.value)},"t7"),e[19]=v):v=e[19];let E=v,P;e[20]===Symbol.for("react.memo_cache_sentinel")?(P=S(L=>{T(ie=>{let H=new Set(ie);return H.has(L)?H.delete(L):H.add(L),H})},"t8"),e[20]=P):P=e[20];let A=P,C=l===null&&m.length===0&&!I,$;e[21]!==t?($=(0,s.jsxDEV)(re,{onChange:f,testId:"tr-shard-input",value:t},void 0,!1),e[21]=t,e[22]=$):$=e[22];let R;e[23]!==a?(R=a("Search traces"),e[23]=a,e[24]=R):R=e[24];let B;e[25]!==a?(B=a("search trace or function"),e[25]=a,e[26]=B):B=e[26];let D;e[27]!==u||e[28]!==R||e[29]!==B?(D=(0,s.jsxDEV)(J,{"aria-label":R,className:"h-8 w-56","data-testid":"tr-search",onChange:E,placeholder:B,value:u},void 0,!1),e[27]=u,e[28]=R,e[29]=B,e[30]=D):D=e[30];let F;e[31]!==i?(F=(0,s.jsxDEV)(oe,{message:i,prefix:"tr"},void 0,!1),e[31]=i,e[32]=F):F=e[32];let j;e[33]!==D||e[34]!==F||e[35]!==$?(j=(0,s.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[$,D,F]},void 0,!0),e[33]=D,e[34]=F,e[35]=$,e[36]=j):j=e[36];let O;e[37]!==l||e[38]!==p?(O=l!==null&&(0,s.jsxDEV)(ae,{error:p,testId:"tr-error"},void 0,!1),e[37]=l,e[38]=p,e[39]=O):O=e[39];let W;e[40]!==C||e[41]!==a?(W=C&&(0,s.jsxDEV)(X,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,s.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsxDEV)("path",{d:"M4 6h10M7 12h13M10 18h7"},void 0,!1)},void 0,!1),testId:"tr-empty",title:a("No traces")},void 0,!1),e[40]=C,e[41]=a,e[42]=W):W=e[42],N=(0,s.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[j,O,W,l===null&&y&&(0,s.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:c.length,total:g})},void 0,!1),l===null&&m.length>0&&(0,s.jsxDEV)("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:m.map(L=>(0,s.jsxDEV)(xe,{expanded:k.has(L.traceId),onToggle:A,trace:L},L.traceId,!1))},void 0,!1)]},void 0,!0),e[9]=n,e[10]=l,e[11]=p,e[12]=k,e[13]=I,e[14]=i,e[15]=u,e[16]=t,e[17]=a,e[18]=N}else N=e[18];return N},"TracesPanel");function be(){return new Set}S(be,"_temp");export{Ae as TracesPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as w}from"./chunk-
|
|
1
|
+
import{a as w}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as k}from"./chunk-4F72YCTU.js";import{a as C,b as $,c as A,d as v,e as n,f as c}from"./chunk-GTM65MVX.js";import{a as N,e as R}from"./chunk-Y572GMZE.js";import{b as y}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as S}from"./chunk-EBTLTGG3.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as T}from"./chunk-TAD43CG5.js";import{d as b}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as p,e as x,g as O,h as B}from"./chunk-RRCPZMC2.js";var I=x(O(),1);var t=x(B(),1);var D=p((e,r)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[r],"operationLabel"),E={delete:2,list:3,read:0,write:1},_=p(e=>[...e].toSorted((r,a)=>r.bucket.localeCompare(a.bucket)||E[r.on]-E[a.on]||(r.prefix??"").localeCompare(a.prefix??"")),"sortRules"),Q=p(()=>{let e=(0,I.c)(14),r=b(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:l,error:d,errorSource:i}=k(S.storageRules,a),h=l!==void 0,f;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==r){let g=_(Array.isArray(l?.rules)?l.rules:[]),m;e[7]!==d||e[8]!==i?(m=d!==null&&(0,t.jsxDEV)(w,{error:i,testId:"storage-rules-error"},void 0,!1),e[7]=d,e[8]=i,e[9]=m):m=e[9];let s;e[10]!==r?(s=r("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=r,e[11]=s):s=e[11];let u;e[12]!==s?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s},void 0,!1),e[12]=s,e[13]=u):u=e[13],f=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[m,u,h&&g.length===0?(0,t.jsxDEV)(T,{description:r("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:r("No storage rules defined")},void 0,!1):(0,t.jsxDEV)(N,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(R,{className:"px-0",children:(0,t.jsxDEV)(C,{"data-testid":"storage-rules-table",children:[(0,t.jsxDEV)($,{children:(0,t.jsxDEV)(v,{children:[(0,t.jsxDEV)(n,{children:r("Bucket")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Operation")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Key prefix")},void 0,!1),(0,t.jsxDEV)(n,{children:r("Guarded by")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(A,{children:g.map(o=>(0,t.jsxDEV)(v,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[(0,t.jsxDEV)(c,{className:"font-mono text-xs",children:o.bucket},void 0,!1),(0,t.jsxDEV)(c,{children:(0,t.jsxDEV)(y,{variant:"secondary",children:D(r,o.on)},void 0,!1)},void 0,!1),(0,t.jsxDEV)(c,{className:"font-mono text-xs",children:o.prefix??(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("(whole bucket)")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(c,{className:"font-mono text-xs text-muted-foreground",children:o.procedure},void 0,!1)]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=r,e[6]=f}else f=e[6];return f},"StorageRulesPanel");export{Q as StorageRulesPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Pe}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ae}from"./chunk-
|
|
1
|
+
import{a as Pe}from"./chunk-VLXV72QE.js";import{a as xe}from"./chunk-JSEXCW5Q.js";import{a as X}from"./chunk-KZ6INM5M.js";import{d as we,f as Oe,g as $e,k as ae}from"./chunk-4QHKBC77.js";import{a as Ae}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as ke}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as H}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as Se}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as Ce}from"./chunk-EBTLTGG3.js";import{f as G}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as W}from"./chunk-TAD43CG5.js";import{d as M,e as Ie,f as le,g as de,h as ce,l as Te,n as re}from"./chunk-5XO36X4C.js";import{b as Ne}from"./chunk-ZXLEXF4X.js";import{a as p,e as q,f as he,g as oe,h as ne,j as ge}from"./chunk-RRCPZMC2.js";var Ye=q(oe(),1),ye=q(he(),1);var ee=q(oe(),1);var Z=q(he(),1);var B=q(ne(),1);var Qe=le(Ce.listTables),Xe=["react","client","cli"],Ze=!1,et={action:"action",mutation:"mutation",query:"query"},Re=p(t=>{let e=t.indexOf(":");return e===-1?{file:"",fn:t}:{file:t.slice(0,e),fn:t.slice(e+1)}},"splitPath"),_e=p(({file:t,fn:e,kind:o})=>`await client.${et[o]}(api.${t}.${e}, { /* args */ });`,"buildClientSnippet"),tt=p(t=>{let e=`api.${t.file}.${t.fn}`;switch(t.kind){case"action":return _e(t);case"mutation":return`const ${t.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},"buildReactSnippet"),st=p(({file:t,fn:e})=>`lunora run ${t}:${e} --args '{ }'`,"buildCliSnippet"),ot=p(t=>["// Read rows",`const rows = await ctx.db.query("${t}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${t}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${t}">;`,`type RowId = Id<"${t}">;`].join(`
|
|
2
2
|
`),"buildTableSnippet"),nt=p((t,e)=>{switch(t){case"cli":return st(e);case"client":return _e(e);default:return tt(e)}},"snippetForTab"),je=p(t=>{let e=(0,ee.c)(19),{code:o,label:s,testId:n}=t,r=M(),l;e[0]!==o?(l=p(()=>{re(o)},"t1"),e[0]=o,e[1]=l):l=e[1];let i=l,d;e[2]!==s?(d=(0,B.jsxDEV)("span",{className:"text-xs font-medium text-muted-foreground",children:s},void 0,!1),e[2]=s,e[3]=d):d=e[3];let c=`${n}-copy`,m;e[4]!==r?(m=r("Copy"),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==c||e[8]!==m?(a=(0,B.jsxDEV)(H,{"data-testid":c,onClick:i,size:"xs",type:"button",variant:"ghost",children:m},void 0,!1),e[6]=i,e[7]=c,e[8]=m,e[9]=a):a=e[9];let u;e[10]!==d||e[11]!==a?(u=(0,B.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[d,a]},void 0,!0),e[10]=d,e[11]=a,e[12]=u):u=e[12];let v;e[13]!==o||e[14]!==n?(v=(0,B.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":n,children:o},void 0,!1),e[13]=o,e[14]=n,e[15]=v):v=e[15];let S;return e[16]!==u||e[17]!==v?(S=(0,B.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[u,v]},void 0,!0),e[16]=u,e[17]=v,e[18]=S):S=e[18],S},"SnippetBlock"),rt=p(t=>{let e=(0,ee.c)(50),{file:o,fn:s,kind:n}=t,r=M(),[l,i]=(0,Z.useState)("react"),d,c,m;if(e[0]!==o||e[1]!==s||e[2]!==n||e[3]!==r||e[4]!==l){let I={file:o,fn:s,kind:n},$;e[8]!==r?($=r("CLI"),e[8]=r,e[9]=$):$=e[9];let P;e[10]!==r?(P=r("Client"),e[10]=r,e[11]=P):P=e[11];let E;e[12]!==r?(E=r("React"),e[12]=r,e[13]=E):E=e[13];let j;e[14]!==$||e[15]!==P||e[16]!==E?(j={cli:$,client:P,react:E},e[14]=$,e[15]=P,e[16]=E,e[17]=j):j=e[17],m=j;let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=p(L=>{i(L.currentTarget.dataset.tab)},"t62"),e[18]=R):R=e[18],d=R,c=nt(l,I),e[0]=o,e[1]=s,e[2]=n,e[3]=r,e[4]=l,e[5]=d,e[6]=c,e[7]=m}else d=e[5],c=e[6],m=e[7];let a=c,u=n==="action"&&l==="react"&&!Ze,v=`api.${o}.${s}`,S;e[19]!==v?(S=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:v},void 0,!1),e[19]=v,e[20]=S):S=e[20];let O;e[21]!==n||e[22]!==r?(O=r("Call this {kind} from your app.",{kind:n}),e[21]=n,e[22]=r,e[23]=O):O=e[23];let h;e[24]!==O?(h=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:O},void 0,!1),e[24]=O,e[25]=h):h=e[25];let g;e[26]!==S||e[27]!==h?(g=(0,B.jsxDEV)("div",{children:[S,h]},void 0,!0),e[26]=S,e[27]=h,e[28]=g):g=e[28];let x;e[29]!==r?(x=r("Snippet flavour"),e[29]=r,e[30]=x):x=e[30];let b;e[31]!==d||e[32]!==l||e[33]!==m?(b=Xe.map(I=>(0,B.jsxDEV)(H,{"aria-selected":l===I,"data-tab":I,"data-testid":`api-tab-${I}`,onClick:d,role:"tab",size:"xs",type:"button",variant:l===I?"default":"outline",children:m[I]},I,!1)),e[31]=d,e[32]=l,e[33]=m,e[34]=b):b=e[34];let y;e[35]!==x||e[36]!==b?(y=(0,B.jsxDEV)("div",{"aria-label":x,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:b},void 0,!1),e[35]=x,e[36]=b,e[37]=y):y=e[37];let N=m[l],T=`api-snippet-${l}`,k;e[38]!==a||e[39]!==N||e[40]!==T?(k=(0,B.jsxDEV)(je,{code:a,label:N,testId:T},void 0,!1),e[38]=a,e[39]=N,e[40]=T,e[41]=k):k=e[41];let w;e[42]!==u||e[43]!==r?(w=u&&(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground","data-testid":"api-action-note",children:r("Actions have no React hook \u2014 call them through the client.")},void 0,!1),e[42]=u,e[43]=r,e[44]=w):w=e[44];let C;return e[45]!==k||e[46]!==w||e[47]!==g||e[48]!==y?(C=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[g,y,k,w]},void 0,!0),e[45]=k,e[46]=w,e[47]=g,e[48]=y,e[49]=C):C=e[49],C},"FunctionDoc"),it=p(t=>{let e=(0,ee.c)(19),{name:o}=t,s=M(),n;e[0]!==o?(n=ot(o),e[0]=o,e[1]=n):n=e[1];let r=n,l;e[2]!==o?(l=(0,B.jsxDEV)("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:o},void 0,!1),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==s?(i=s("Read and write this table through the typed data model."),e[4]=s,e[5]=i):i=e[5];let d;e[6]!==i?(d=(0,B.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:i},void 0,!1),e[6]=i,e[7]=d):d=e[7];let c;e[8]!==l||e[9]!==d?(c=(0,B.jsxDEV)("div",{children:[l,d]},void 0,!0),e[8]=l,e[9]=d,e[10]=c):c=e[10];let m;e[11]!==s?(m=s("Data model"),e[11]=s,e[12]=m):m=e[12];let a;e[13]!==r||e[14]!==m?(a=(0,B.jsxDEV)(je,{code:r,label:m,testId:"api-snippet-table"},void 0,!1),e[13]=r,e[14]=m,e[15]=a):a=e[15];let u;return e[16]!==c||e[17]!==a?(u=(0,B.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[c,a]},void 0,!0),e[16]=c,e[17]=a,e[18]=u):u=e[18],u},"TableDoc"),Ee=p(t=>{let e=(0,ee.c)(8),{active:o,label:s,onSelect:n,testId:r,value:l}=t,i;e[0]!==n||e[1]!==l?(i=p(()=>{n(l)},"t1"),e[0]=n,e[1]=l,e[2]=i):i=e[2];let d=i,c=o?"page":void 0,m;return e[3]!==s||e[4]!==d||e[5]!==c||e[6]!==r?(m=(0,B.jsxDEV)("button",{"aria-current":c,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":r,onClick:d,type:"button",children:s},void 0,!1),e[3]=s,e[4]=d,e[5]=c,e[6]=r,e[7]=m):m=e[7],m},"RailButton"),Le=p(t=>{let e=(0,ee.c)(67),{functions:o,initialShardKey:s}=t,n=M(),r=G(),[l,i]=(0,Z.useState)(null),[d,c]=(0,Z.useState)(null),m,a;e[0]!==r||e[1]!==s?(m=p(()=>{let _=!1;return r.query(Qe,{},de(s??"")).then(D=>(_||i(D),D)).catch(()=>{_||i([])}),()=>{_=!0}},"t1"),a=[r,s],e[0]=r,e[1]=s,e[2]=m,e[3]=a):(m=e[2],a=e[3]),(0,Z.useEffect)(m,a);let u;e[4]!==o?(u=o??[],e[4]=o,e[5]=u):u=e[5];let v=u,S;if(e[6]!==v){let _=new Map;for(let D of v){let{file:V,fn:U}=Re(D.path),ie=_.get(V)??[];ie.push({fn:U,kind:D.kind,path:D.path}),_.set(V,ie)}S=[..._.entries()].map(lt).toSorted(dt),e[6]=v,e[7]=S}else S=e[7];let O=S,h,g,x,b,y,N,T,k,w,C;if(e[8]!==v||e[9]!==O||e[10]!==d||e[11]!==n||e[12]!==l){let _=(l??[]).map(ct).toSorted(ft),D;e[23]===Symbol.for("react.memo_cache_sentinel")?(D=p(F=>{c({kind:"fn",path:F})},"t122"),e[23]=D):D=e[23];let V=D,U;e[24]===Symbol.for("react.memo_cache_sentinel")?(U=p(F=>{c({kind:"table",name:F})},"t132"),e[24]=U):U=e[24];let ie=U;if(g=d?.kind==="fn"?v.find(F=>F.path===d.path):void 0,h=v.length>0||_.length>0,x=g===void 0?void 0:Re(g.path),b="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",y="lunora-api-docs",e[25]!==n?(N=n("API resources"),e[25]=n,e[26]=N):N=e[26],T="flex flex-col gap-4 overflow-y-auto",k="api-rail",e[27]!==O||e[28]!==d||e[29]!==n){let F;e[31]!==d||e[32]!==n?(F=p(ve=>(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:ve.file||n("(root)")},void 0,!1),ve.items.map(se=>(0,B.jsxDEV)(Ee,{active:d?.kind==="fn"&&d.path===se.path,label:se.fn,onSelect:V,testId:`api-rail-fn-${se.path}`,value:se.path},se.path,!1))]},ve.file,!0),"t142"),e[31]=d,e[32]=n,e[33]=F):F=e[33],w=O.map(F),e[27]=O,e[28]=d,e[29]=n,e[30]=w}else w=e[30];C=_.length>0&&(0,B.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,B.jsxDEV)("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Tables")},void 0,!1),_.map(F=>(0,B.jsxDEV)(Ee,{active:d?.kind==="table"&&d.name===F,label:F,onSelect:ie,testId:`api-rail-table-${F}`,value:F},F,!1))]},void 0,!0),e[8]=v,e[9]=O,e[10]=d,e[11]=n,e[12]=l,e[13]=h,e[14]=g,e[15]=x,e[16]=b,e[17]=y,e[18]=N,e[19]=T,e[20]=k,e[21]=w,e[22]=C}else h=e[13],g=e[14],x=e[15],b=e[16],y=e[17],N=e[18],T=e[19],k=e[20],w=e[21],C=e[22];let I;e[34]!==h||e[35]!==n?(I=!h&&(0,B.jsxDEV)("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:n("No functions or tables to document yet.")},void 0,!1),e[34]=h,e[35]=n,e[36]=I):I=e[36];let $;e[37]!==I||e[38]!==N||e[39]!==T||e[40]!==k||e[41]!==w||e[42]!==C?($=(0,B.jsxDEV)("nav",{"aria-label":N,className:T,"data-testid":k,children:[w,C,I]},void 0,!0),e[37]=I,e[38]=N,e[39]=T,e[40]=k,e[41]=w,e[42]=C,e[43]=$):$=e[43];let P;e[44]!==d||e[45]!==n?(P=d===null&&(0,B.jsxDEV)(W,{description:n("Select a function or table to see how to call it from your app."),testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[44]=d,e[45]=n,e[46]=P):P=e[46];let E;e[47]!==d?.kind||e[48]!==g||e[49]!==x?(E=d?.kind==="fn"&&g!==void 0&&x!==void 0&&(0,B.jsxDEV)(rt,{file:x.file,fn:x.fn,kind:g.kind},g.path,!1),e[47]=d?.kind,e[48]=g,e[49]=x,e[50]=E):E=e[50];let j;e[51]!==d?.kind||e[52]!==g||e[53]!==n?(j=d?.kind==="fn"&&g===void 0&&(0,B.jsxDEV)(W,{testId:"api-empty",title:n("API usage snippets")},void 0,!1),e[51]=d?.kind,e[52]=g,e[53]=n,e[54]=j):j=e[54];let R;e[55]!==d?(R=d?.kind==="table"&&(0,B.jsxDEV)(it,{name:d.name},void 0,!1),e[55]=d,e[56]=R):R=e[56];let L;e[57]!==P||e[58]!==E||e[59]!==j||e[60]!==R?(L=(0,B.jsxDEV)("div",{className:"min-w-0",children:[P,E,j,R]},void 0,!0),e[57]=P,e[58]=E,e[59]=j,e[60]=R,e[61]=L):L=e[61];let A;return e[62]!==b||e[63]!==y||e[64]!==$||e[65]!==L?(A=(0,B.jsxDEV)("div",{className:b,"data-testid":y,children:[$,L]},void 0,!0),e[62]=b,e[63]=y,e[64]=$,e[65]=L,e[66]=A):A=e[66],A},"ApiDocsPanel");function at(t,e){return t.fn.localeCompare(e.fn)}p(at,"_temp");function lt(t){let[e,o]=t;return{file:e,items:o.toSorted(at)}}p(lt,"_temp2");function dt(t,e){return t.file.localeCompare(e.file)}p(dt,"_temp3");function ct(t){return t.name}p(ct,"_temp4");function ft(t,e){return t.localeCompare(e)}p(ft,"_temp5");var ze=q(oe(),1);var J=q(oe(),1),K=q(he(),1);var f=q(ne(),1);var ue=p(function(t,e,o){let s=(0,J.c)(10),n;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={kind:"loading"},s[0]=n):n=s[0];let[r,l]=(0,K.useState)(n),i,d;s[1]!==o||s[2]!==e||s[3]!==t?(i=p(()=>{if(t!==void 0)return;let m=!1;return e().then(a=>(m||l(o(a)),a)).catch(a=>{m||l({kind:"error",message:ce(a)})}),()=>{m=!0}},"t1"),d=[o,e,t],s[1]=o,s[2]=e,s[3]=t,s[4]=i,s[5]=d):(i=s[4],d=s[5]),(0,K.useEffect)(i,d);let c;return s[6]!==o||s[7]!==r||s[8]!==t?(c=t===void 0?r:o(t),s[6]=o,s[7]=r,s[8]=t,s[9]=c):c=s[9],c},"useAdminSpec"),pt=p(t=>typeof t=="number"?"number":typeof t=="boolean"?"boolean":"string","scalarOf"),Me=p(t=>{if(t.enum!==void 0&&t.enum.length>0)return t.enum;if(t.anyOf!==void 0&&t.anyOf.length>0&&t.anyOf.every(e=>e.const!==void 0))return t.anyOf.map(e=>e.const)},"enumValues"),pe=p(t=>t===void 0?"any":t.const!==void 0?JSON.stringify(t.const):t.enum!==void 0&&t.enum.length>0?t.enum.map(e=>JSON.stringify(e)).join(" | "):t.anyOf!==void 0&&t.anyOf.length>0?t.anyOf.map(e=>pe(e)).join(" | "):t.type==="array"?`array<${pe(t.items)}>`:t.type??"any","typeLabel"),ut=p(t=>{let e=Me(t);return e!==void 0?t.type??pt(e[0]):pe(t)},"fieldTypeLabel"),mt=p(t=>{let e=Me(t);return e===void 0?void 0:e.map(o=>JSON.stringify(o)).join(" | ")},"valueInText"),vt=p(t=>{let e=[];t.minimum!==void 0?e.push(`${String(t.minimum)} \u2264`):t.exclusiveMinimum!==void 0&&e.push(`${String(t.exclusiveMinimum)} <`);let o=e.length>0;e.push("value"),t.maximum!==void 0?e.push(`\u2264 ${String(t.maximum)}`):t.exclusiveMaximum!==void 0&&e.push(`< ${String(t.exclusiveMaximum)}`);let s=e.length>(o?2:1);return o||s?e.join(" "):void 0},"rangeText"),ht=p(t=>{if(t.type==="object"&&t.properties!==void 0)return t;if(t.type==="array"&&t.items?.type==="object"&&t.items.properties!==void 0)return t.items},"childObject"),te=p(t=>{if(t===void 0)return null;if(t.const!==void 0)return t.const;if(t.enum!==void 0&&t.enum.length>0)return t.enum[0];if(t.anyOf!==void 0&&t.anyOf.length>0)return te(t.anyOf[0]);switch(t.type){case"array":return[];case"boolean":return!1;case"number":return 0;case"object":{let e={};for(let[o,s]of Object.entries(t.properties??{}))e[o]=te(s);return e}case"string":return"";default:return null}},"exampleForSchema"),fe=p(t=>{let e=(0,J.c)(7),{label:o,value:s}=t,n;e[0]!==o?(n=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:o},void 0,!1),e[0]=o,e[1]=n):n=e[1];let r;e[2]!==s?(r=(0,f.jsxDEV)("span",{className:"text-foreground",children:s},void 0,!1),e[2]=s,e[3]=r):r=e[3];let l;return e[4]!==n||e[5]!==r?(l=(0,f.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 font-mono text-[10px]",children:[n,r]},void 0,!0),e[4]=n,e[5]=r,e[6]=l):l=e[6],l},"Badge"),gt=p(t=>{let e=(0,J.c)(40),{name:o,required:s,schema:n}=t,r=M(),l;e[0]!==n?(l=vt(n),e[0]=n,e[1]=l):l=e[1];let i=l,d;e[2]!==n?(d=mt(n),e[2]=n,e[3]=d):d=e[3];let c=d,m=n["x-lunora-table"],a=n.format!==void 0||i!==void 0||c!==void 0||m!==void 0,u;e[4]!==n?(u=ht(n),e[4]=n,e[5]=u):u=e[5];let v=u,S=s?"*":"?",O;e[6]!==S?(O=(0,f.jsxDEV)("span",{className:"text-muted-foreground",children:S},void 0,!1),e[6]=S,e[7]=O):O=e[7];let h;e[8]!==o||e[9]!==O?(h=(0,f.jsxDEV)("span",{className:"font-mono text-foreground",children:[o,O]},void 0,!0),e[8]=o,e[9]=O,e[10]=h):h=e[10];let g;e[11]!==n?(g=ut(n),e[11]=n,e[12]=g):g=e[12];let x;e[13]!==g?(x=(0,f.jsxDEV)("span",{className:"font-mono text-muted-foreground",children:g},void 0,!1),e[13]=g,e[14]=x):x=e[14];let b;e[15]!==h||e[16]!==x?(b=(0,f.jsxDEV)("div",{className:"flex items-baseline gap-2",children:[h,x]},void 0,!0),e[15]=h,e[16]=x,e[17]=b):b=e[17];let y;e[18]!==n.description?(y=n.description!==void 0&&(0,f.jsxDEV)("p",{className:"max-w-prose text-muted-foreground",children:n.description},void 0,!1),e[18]=n.description,e[19]=y):y=e[19];let N;e[20]!==a||e[21]!==i||e[22]!==m||e[23]!==n.format||e[24]!==r||e[25]!==c?(N=a&&(0,f.jsxDEV)("div",{className:"flex flex-wrap gap-1",children:[n.format!==void 0&&(0,f.jsxDEV)(fe,{label:r("Format"),value:n.format},void 0,!1),i!==void 0&&(0,f.jsxDEV)(fe,{label:r("Range"),value:i},void 0,!1),c!==void 0&&(0,f.jsxDEV)(fe,{label:r("Value in"),value:c},void 0,!1),m!==void 0&&(0,f.jsxDEV)(fe,{label:r("relation"),value:m},void 0,!1)]},void 0,!0),e[20]=a,e[21]=i,e[22]=m,e[23]=n.format,e[24]=r,e[25]=c,e[26]=N):N=e[26];let T;e[27]!==y||e[28]!==N||e[29]!==b?(T=(0,f.jsxDEV)("div",{className:"flex flex-col gap-1 py-2",children:[b,y,N]},void 0,!0),e[27]=y,e[28]=N,e[29]=b,e[30]=T):T=e[30];let k=T;if(v===void 0){let $;return e[31]!==k?($=(0,f.jsxDEV)("div",{className:"border-b border-border/50 last:border-b-0",children:k},void 0,!1),e[31]=k,e[32]=$):$=e[32],$}let w;e[33]!==k?(w=(0,f.jsxDEV)("summary",{className:"cursor-pointer marker:text-muted-foreground",children:k},void 0,!1),e[33]=k,e[34]=w):w=e[34];let C;e[35]!==v?(C=(0,f.jsxDEV)("div",{className:"mb-2 ml-2 border-l border-border pl-3",children:(0,f.jsxDEV)(Ke,{schema:v},void 0,!1)},void 0,!1),e[35]=v,e[36]=C):C=e[36];let I;return e[37]!==w||e[38]!==C?(I=(0,f.jsxDEV)("details",{className:"border-b border-border/50 last:border-b-0",children:[w,C]},void 0,!0),e[37]=w,e[38]=C,e[39]=I):I=e[39],I},"FieldRow"),Ke=p(t=>{let e=(0,J.c)(7),{schema:o}=t,s;e[0]!==o.required?(s=new Set(o.required),e[0]=o.required,e[1]=s):s=e[1];let n=s,r;e[2]!==o.properties?(r=Object.entries(o.properties??{}),e[2]=o.properties,e[3]=r):r=e[3];let l=r,i;return e[4]!==n||e[5]!==l?(i=(0,f.jsxDEV)("div",{className:"flex flex-col",children:l.map(d=>{let[c,m]=d;return(0,f.jsxDEV)(gt,{name:c,required:n.has(c),schema:m},c,!1)})},void 0,!1),e[4]=n,e[5]=l,e[6]=i):i=e[6],i},"SchemaFields"),Be=p(t=>{let e=(0,J.c)(10),{schema:o,testId:s}=t;if(o?.type!=="object"||Object.keys(o.properties??{}).length===0){let l;e[0]!==o?(l=pe(o),e[0]=o,e[1]=l):l=e[1];let i;return e[2]!==l||e[3]!==s?(i=(0,f.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":s,children:l},void 0,!1),e[2]=l,e[3]=s,e[4]=i):i=e[4],i}let n;e[5]!==o?(n=(0,f.jsxDEV)(Ke,{schema:o},void 0,!1),e[5]=o,e[6]=n):n=e[6];let r;return e[7]!==n||e[8]!==s?(r=(0,f.jsxDEV)("div",{className:"text-xs","data-testid":s,children:n},void 0,!1),e[7]=n,e[8]=s,e[9]=r):r=e[9],r},"SchemaTable"),xt=["curl","javascript","lunora"],bt={lunora:"Lunora",curl:"cURL",javascript:"JavaScript"},yt=p(t=>`api.${t.replaceAll(/[/:]/g,".")}`,"apiReferenceOf"),Nt=p(t=>{let e=te(t.argsSchema)??{};return t.functionPath===void 0?e:{args:e,functionPath:t.functionPath}},"requestBody"),St=p((t,e,o)=>{let s=`${o}${e.httpPath}`,n=JSON.stringify(Nt(e),void 0,2),r=JSON.stringify(te(e.argsSchema)??{},void 0,2);switch(t){case"curl":{let l=e.method!=="GET"&&e.method!=="HEAD",i=[`curl -X ${e.method} ${JSON.stringify(s)}`];return l&&i.push(' -H "Content-Type: application/json"',` -d '${n}'`),i.join(` \\
|
|
3
3
|
`)}case"lunora":return e.functionPath===void 0?`await fetch(${JSON.stringify(e.httpPath)}, { method: ${JSON.stringify(e.method)} });`:`import { useLunora } from "@lunora/react";
|
|
4
4
|
import { api } from "./_generated/api";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x}from"./chunk-4PC7IXNY.js";import{R as k}from"./chunk-VL23Y44O.js";import{d as b}from"./chunk-
|
|
1
|
+
import{a as x}from"./chunk-4PC7IXNY.js";import{R as k}from"./chunk-VL23Y44O.js";import{d as b}from"./chunk-5XO36X4C.js";import{a as c,e as C,f as $,g as j,h as w}from"./chunk-RRCPZMC2.js";var y=C(j(),1),u=C($(),1);var e=C(w(),1);var T=c(r=>{let t=(0,y.c)(21),{id:h,onChange:g,testId:o,value:v}=r,l=b(),f=(0,u.useId)(),[d]=(0,u.useState)(D),m;t[0]!==g?(m=c(_=>{g(_.target.value)},"t1"),t[0]=g,t[1]=m):m=t[1];let I=m,a;t[2]!==l?(a=l("Shard key"),t[2]=l,t[3]=a):a=t[3];let S=d.length>0?f:void 0,n;t[4]!==l?(n=l("shard key (optional)"),t[4]=l,t[5]=n):n=t[5];let s;t[6]!==h||t[7]!==I||t[8]!==a||t[9]!==S||t[10]!==n||t[11]!==o||t[12]!==v?(s=(0,e.jsxDEV)(k,{"aria-label":a,className:"h-8 w-48","data-testid":o,id:h,list:S,onChange:I,placeholder:n,value:v},void 0,!1),t[6]=h,t[7]=I,t[8]=a,t[9]=S,t[10]=n,t[11]=o,t[12]=v,t[13]=s):s=t[13];let i;t[14]!==f||t[15]!==d||t[16]!==o?(i=d.length>0&&(0,e.jsxDEV)("datalist",{"data-testid":`${o}-recents`,id:f,children:d.map(E)},void 0,!1),t[14]=f,t[15]=d,t[16]=o,t[17]=i):i=t[17];let p;return t[18]!==s||t[19]!==i?(p=(0,e.jsxDEV)(e.Fragment,{children:[s,i]},void 0,!0),t[18]=s,t[19]=i,t[20]=p):p=t[20],p},"ShardInput");function D(){return x()}c(D,"_temp");function E(r){return(0,e.jsxDEV)("option",{"aria-label":r,value:r},r,!1)}c(E,"_temp2");export{T as a};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{a as J}from"./chunk-
|
|
1
|
+
import{a as J}from"./chunk-WOYQG5AM.js";import{c as L}from"./chunk-4F72YCTU.js";import{a as v,e as y}from"./chunk-Y572GMZE.js";import{a as P}from"./chunk-VLXV72QE.js";import{a as B}from"./chunk-FDWXYXOM.js";import{b as j}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as D}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import"./chunk-CKSHCYGC.js";import{a as f}from"./chunk-EBTLTGG3.js";import{f as _}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as E,f as S,g as w,h as b,l as I}from"./chunk-5XO36X4C.js";import{b as N}from"./chunk-ZXLEXF4X.js";import{a as o,e as R,f as K,h as U}from"./chunk-RRCPZMC2.js";var c=R(K(),1);var e=R(U(),1);var V=S(f.exportShard),X=S(f.importShard),z=o(m=>m.map(a=>JSON.stringify(a)).join(`
|
|
2
2
|
`),"toNdjson"),G=o(m=>{let a=[],x=m.split(`
|
|
3
3
|
`);for(let[r,n]of x.entries()){let h=n.trim();if(h==="")continue;let l=JSON.parse(h);if(typeof l!="object"||l===null)throw new N("INTERNAL",`line ${(r+1).toString()}: expected a { table, doc } object`);let s=l;if(typeof s.table!="string"||typeof s.doc!="object"||s.doc===null||Array.isArray(s.doc))throw new N("INTERNAL",`line ${(r+1).toString()}: expected a { table, doc } object`);a.push(s)}return a},"parseNdjson"),ie=o(({initialShardKey:m})=>{let a=_(),x=L(),r=E(),[n,h]=(0,c.useState)(m??""),[l,s]=(0,c.useState)(""),[C,p]=(0,c.useState)(!1),[T,u]=(0,c.useState)(null),[i,g]=(0,c.useState)(null),[A,O]=(0,c.useState)(null),$=o(async()=>{p(!0),u(null),g(null);try{let t=await a.query(V,{},w(n));j(n),s(z(t.rows)),O(t.rows.length)}catch(t){u(b(t))}finally{p(!1)}},"exportShard"),k=o(async()=>{p(!0),u(null),g(null),O(null);let t;try{t=G(l)}catch(d){u(r("Invalid NDJSON: {message}",{message:b(d)})),p(!1);return}try{let d=await a.query(X,{rows:t},w(n));j(n),g(d),x(f.readTablePage),x(f.listTables)}catch(d){u(b(d))}finally{p(!1)}},"importShard"),M=i===null?0:Object.values(i.inserted).reduce((t,d)=>t+d,0),q=o(()=>{I($())},"runExport"),F=o(()=>{I(k())},"runImport"),H=o(t=>{s(t.target.value)},"onNdjsonChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-export-import",children:[(0,e.jsxDEV)(v,{className:"rounded-xl border border-border bg-card shadow-xs",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Export")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(y,{className:"flex flex-col gap-3 p-4",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(B,{onChange:h,testId:"ei-shard-input",value:n},void 0,!1),(0,e.jsxDEV)(D,{"data-testid":"ei-export",disabled:C,onClick:q,type:"button",children:r("Export")},void 0,!1)]},void 0,!0),A!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ei-export-result",children:r("Exported {count} rows.",{count:A})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)(v,{className:"rounded-xl border border-border bg-card shadow-xs",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Import")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(y,{className:"flex flex-col gap-3 p-4",children:[(0,e.jsxDEV)(P,{"aria-label":"NDJSON",className:"font-mono text-xs min-h-40 rounded-md","data-testid":"ei-ndjson",onChange:H,placeholder:'{"table":"messages","doc":{\u2026}}',value:l},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:(0,e.jsxDEV)(J,{confirmLabel:r("Import (writes rows)?"),disabled:C||l.trim()==="",onConfirm:F,testId:"ei-import",children:r("Import")},void 0,!1)},void 0,!1),i!==null&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ei-import-result",children:[(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:r("Inserted {inserted}, {conflicts} conflicts, {errors} errors.",{conflicts:i.conflicts,errors:i.errors.length,inserted:M})},void 0,!1),i.errors.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col gap-1","data-testid":"ei-import-errors",children:i.errors.map(t=>(0,e.jsxDEV)("li",{className:"text-xs text-destructive",children:r("line {line} ({table}): {message}",{line:t.line,message:t.message,table:t.table})},`${t.table}-${t.line.toString()}`,!1))},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),T!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ei-error",role:"alert",children:T},void 0,!1)]},void 0,!0)},"ExportImportPanel");export{ie as ExportImportPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n}from"./chunk-
|
|
1
|
+
import{d as n}from"./chunk-5XO36X4C.js";import{a as l,e as a,g as u,h as d}from"./chunk-RRCPZMC2.js";var c=a(u(),1);var v=a(d(),1);var x=l(f=>{let e=(0,c.c)(6),{message:r,prefix:m}=f,o=n();if(r===void 0)return null;let i=`${m}-live-error`,t;e[0]!==r||e[1]!==o?(t=o("Live unavailable: {liveError}",{liveError:r}),e[0]=r,e[1]=o,e[2]=t):t=e[2];let s;return e[3]!==i||e[4]!==t?(s=(0,v.jsxDEV)("span",{className:"text-xs text-destructive","data-testid":i,role:"status",children:t},void 0,!1),e[3]=i,e[4]=t,e[5]=s):s=e[5],s},"LiveError");export{x as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./chunk-
|
|
1
|
+
import{a as k}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as h}from"./chunk-4F72YCTU.js";import{a as C,b as w,c as I,d as u,e as o,f as n}from"./chunk-GTM65MVX.js";import{a as A,e as S}from"./chunk-Y572GMZE.js";import{c as T}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as N}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as g}from"./chunk-EBTLTGG3.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as E}from"./chunk-TAD43CG5.js";import{d as D,p as H}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as d,e as M,f as X,h as Y}from"./chunk-RRCPZMC2.js";var q=M(X(),1);var e=M(Y(),1);var G="agent_threads",Z="agent_messages",_=100,ee=250,te={},ae={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:G},l=d((r,t)=>{let a=r[t];return typeof a=="string"?a:void 0},"readString"),B=d((r,t)=>{let a=r[t];return typeof a=="number"?a:void 0},"readNumber"),P=d(r=>{let{usage:t}=r;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"readTotalTokens"),se=d(r=>{let{toolCalls:t}=r;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"readToolNames"),re=d(r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"threadStatusVariant"),oe=d(r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"approvalVariant"),ge=d(({initialShardKey:r=""})=>{let t=D(),[a,R]=(0,q.useState)(void 0),{data:p}=h(g.listTables,te,{live:!0,shardKey:r}),U=p!==void 0,m=Array.isArray(p)&&p.some(s=>s.name===G),{data:$,error:V,errorSource:z,liveError:O}=h(g.readTablePage,ae,{enabled:m,live:!0,shardKey:r}),F={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:ee,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:Z},{data:j,error:Q,errorSource:J}=h(g.readTablePage,F,{enabled:m&&a!==void 0,live:!0,shardKey:r}),x=Array.isArray($?.rows)?$.rows:[],K=Array.isArray(j?.rows)?j.rows:[],L=x.find(s=>l(s,"key")===a),f;return U&&!m?f=(0,e.jsxDEV)(E,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")},void 0,!1):m&&x.length===0?f=(0,e.jsxDEV)(E,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")},void 0,!1):f=(0,e.jsxDEV)("div",{className:"flex flex-col gap-6",children:[(0,e.jsxDEV)(A,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(S,{className:"px-0",children:(0,e.jsxDEV)(C,{"data-testid":"agents-threads-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Agent")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Key")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Status")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Messages")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tokens")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Updated")},void 0,!1),(0,e.jsxDEV)(o,{"aria-label":t("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:x.map(s=>{let i=l(s,"key")??"",c=l(s,"status"),v=P(s);return(0,e.jsxDEV)(u,{"data-active":i===a?"":void 0,"data-testid":`agents-thread-${i}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs",children:l(s,"agent")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs text-muted-foreground",children:i},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(N,{"data-testid":`agents-thread-status-${i}`,variant:re(c),children:c??"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums",children:B(s,"messageCount")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"tabular-nums text-muted-foreground",children:v??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:H(B(s,"updatedAt"),"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"text-right",children:(0,e.jsxDEV)(T,{"data-testid":`agents-thread-open-${i}`,onClick:d(()=>{R(i)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")},void 0,!1)},void 0,!1)]},i,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),Q!==null&&(0,e.jsxDEV)(k,{error:J,testId:"agents-messages-error"},void 0,!1),a!==void 0&&(0,e.jsxDEV)(A,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxDEV)(S,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,L!==void 0&&(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",P(L)??0," ",t("Tokens")]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)(T,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{R(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")},void 0,!1)]},void 0,!0),K.length===0?(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")},void 0,!1):(0,e.jsxDEV)(C,{"data-testid":"agents-messages-table",children:[(0,e.jsxDEV)(w,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(o,{children:t("Role")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Content")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Tool")},void 0,!1),(0,e.jsxDEV)(o,{children:t("Approval")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(I,{children:K.map((s,i)=>{let c=l(s,"role")??"\u2014",v=se(s),W=l(s,"toolName"),y=l(s,"status"),b=B(s,"seq")??i;return(0,e.jsxDEV)(u,{"data-testid":`agents-message-${String(b)}`,children:[(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:c},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:l(s,"content")??"\u2014"},void 0,!1),(0,e.jsxDEV)(n,{className:"font-mono text-xs align-top text-muted-foreground",children:W??(v.length>0?v.join(", "):"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{className:"align-top",children:y===void 0?(0,e.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:"\u2014"},void 0,!1):(0,e.jsxDEV)(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:oe(y),children:y},void 0,!1)},void 0,!1)]},l(s,"messageKey")??`${c}:${String(b)}`,!0)})},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&(0,e.jsxDEV)(k,{error:z,testId:"agents-error"},void 0,!1),(0,e.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")},void 0,!1),O!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")},void 0,!1),f]},void 0,!0)},"AgentsPanel");export{ge as AgentsPanel};
|