@lunora/studio 1.0.0-alpha.55 → 1.0.0-alpha.56

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.
Files changed (89) hide show
  1. package/dist/index.d.ts +5 -1
  2. package/dist/index.js +6 -6
  3. package/dist/mount.js +1 -1
  4. package/dist/packem_chunks/ApiTab.js +1 -1
  5. package/dist/packem_chunks/AuditPanel.js +1 -1
  6. package/dist/packem_chunks/ExportImportPanel.js +1 -1
  7. package/dist/packem_chunks/FileBrowser.js +1 -1
  8. package/dist/packem_chunks/FunctionRunner.js +1 -1
  9. package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
  10. package/dist/packem_chunks/HealthPanel.js +1 -1
  11. package/dist/packem_chunks/InsightsPanel.js +1 -1
  12. package/dist/packem_chunks/LogsPanel.js +1 -1
  13. package/dist/packem_chunks/MailPanel.js +1 -1
  14. package/dist/packem_chunks/MetricsPanel.js +2 -2
  15. package/dist/packem_chunks/MigrationsPanel.js +1 -1
  16. package/dist/packem_chunks/PitrPanel.js +1 -1
  17. package/dist/packem_chunks/SchemaViewer.js +1 -1
  18. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
  19. package/dist/packem_chunks/SettingsPanel.js +1 -1
  20. package/dist/packem_chunks/SqlEditorPanel.js +1 -1
  21. package/dist/packem_chunks/TableEditor.js +1 -1
  22. package/dist/packem_chunks/agents-panel.js +1 -1
  23. package/dist/packem_chunks/containers-panel.js +1 -1
  24. package/dist/packem_chunks/dashboards-panel.js +1 -1
  25. package/dist/packem_chunks/fanout-panel.js +1 -1
  26. package/dist/packem_chunks/flags-panel.js +1 -1
  27. package/dist/packem_chunks/issues-panel.js +320 -81
  28. package/dist/packem_chunks/kv-browser.js +2 -2
  29. package/dist/packem_chunks/payments-panel.js +1 -1
  30. package/dist/packem_chunks/permissions-panel.js +1 -1
  31. package/dist/packem_chunks/queues-panel.js +1 -1
  32. package/dist/packem_chunks/rls-panel.js +1 -1
  33. package/dist/packem_chunks/storage-rules-panel.js +1 -1
  34. package/dist/packem_chunks/subscriptions-panel.js +1 -1
  35. package/dist/packem_chunks/traces-panel.js +1 -1
  36. package/dist/packem_chunks/workflows-panel.js +1 -1
  37. package/dist/packem_shared/{ADMIN_FUNCTIONS-C6TEeUiJ.js → ADMIN_FUNCTIONS-C1LXrovV.js} +4 -0
  38. package/dist/packem_shared/{ApiDocsPanel-CcC6ucbp.js → ApiDocsPanel-cYkYKjK3.js} +1 -1
  39. package/dist/packem_shared/{DataBrowser-BuFEPTiv.js → DataBrowser-CowupumK.js} +1 -1
  40. package/dist/packem_shared/{HomePanel-2I1YZm0A.js → HomePanel-B12QgvIn.js} +2 -2
  41. package/dist/packem_shared/{Studio-CCJBI2wP.js → Studio-DV1PhCIl.js} +2 -2
  42. package/dist/packem_shared/{StudioApp-Daeqxw2h.js → StudioApp-BF2rK77z.js} +1 -1
  43. package/dist/packem_shared/{home-panel-DHHUtnKU.js → home-panel-DDo_fi19.js} +1 -1
  44. package/dist/packem_shared/{select-UkNYCT3s.js → select-D9OwHEch.js} +1 -1
  45. package/dist/packem_shared/{studio-0479nrrm.js → studio-CuNuEnSJ.js} +1 -1
  46. package/dist/standalone/{chunk-G5CMK5GY.js → chunk-25CDYYNE.js} +1 -1
  47. package/dist/standalone/{chunk-AE3AKGOW.js → chunk-2DCA6LV7.js} +1 -1
  48. package/dist/standalone/{chunk-EOE5NDMK.js → chunk-2TJVFKD2.js} +1 -1
  49. package/dist/standalone/{chunk-RG4HLPM2.js → chunk-2U3KE6IP.js} +1 -1
  50. package/dist/standalone/{chunk-DVBY6YQK.js → chunk-2XJ3WRKW.js} +1 -1
  51. package/dist/standalone/{chunk-4AZYW2PI.js → chunk-3BYY75EO.js} +1 -1
  52. package/dist/standalone/chunk-3HGNPZBN.js +1 -0
  53. package/dist/standalone/{chunk-VQ3YOUZB.js → chunk-4A7VE2UO.js} +1 -1
  54. package/dist/standalone/{chunk-TTEEPVCN.js → chunk-5SXQWGTH.js} +1 -1
  55. package/dist/standalone/{chunk-OVSBLTAA.js → chunk-6LQ3FXP2.js} +1 -1
  56. package/dist/standalone/{chunk-FPKTXKPE.js → chunk-6RW37KKD.js} +1 -1
  57. package/dist/standalone/{chunk-W7ND56KZ.js → chunk-6ZGXWDSY.js} +1 -1
  58. package/dist/standalone/{chunk-XG4TZSP4.js → chunk-AL5UKM6M.js} +1 -1
  59. package/dist/standalone/{chunk-N5FMEYSL.js → chunk-BZ5BHTVF.js} +1 -1
  60. package/dist/standalone/{chunk-RDA4VTHI.js → chunk-D54HL2MW.js} +1 -1
  61. package/dist/standalone/chunk-DBCP55V6.js +1 -0
  62. package/dist/standalone/{chunk-PIB7VUVM.js → chunk-DGWFJ3GW.js} +1 -1
  63. package/dist/standalone/{chunk-FBGC3RSU.js → chunk-DOLG4V3A.js} +1 -1
  64. package/dist/standalone/{chunk-MWH5LBNF.js → chunk-E5Z2TAAR.js} +1 -1
  65. package/dist/standalone/{chunk-CW7LZ4SR.js → chunk-EGANQQLW.js} +1 -1
  66. package/dist/standalone/{chunk-JHR3HKT5.js → chunk-ILGPO3PK.js} +2 -2
  67. package/dist/standalone/{chunk-JQPHZL2A.js → chunk-JWCCDDLY.js} +1 -1
  68. package/dist/standalone/{chunk-S5NTGHCG.js → chunk-JZLGLG4T.js} +1 -1
  69. package/dist/standalone/{chunk-ZUTFDG76.js → chunk-LJ3KEIPO.js} +1 -1
  70. package/dist/standalone/{chunk-Q3X7IMLF.js → chunk-LYAWJGSH.js} +1 -1
  71. package/dist/standalone/chunk-MHGJUKCZ.js +1 -0
  72. package/dist/standalone/{chunk-YNSFQKMM.js → chunk-N3V74RBP.js} +1 -1
  73. package/dist/standalone/{chunk-IKVZUVHJ.js → chunk-OBFYFJYZ.js} +1 -1
  74. package/dist/standalone/{chunk-YRE6TGXH.js → chunk-OEIBZ5AI.js} +1 -1
  75. package/dist/standalone/{chunk-FXNS5NBY.js → chunk-OOLK6C5I.js} +1 -1
  76. package/dist/standalone/{chunk-SP7GSPKX.js → chunk-RVVADT2N.js} +1 -1
  77. package/dist/standalone/{chunk-NAFKYFBZ.js → chunk-S7BCXJWD.js} +1 -1
  78. package/dist/standalone/{chunk-6LLFTVEI.js → chunk-ULOBAURC.js} +1 -1
  79. package/dist/standalone/{chunk-LTCX3QOE.js → chunk-VDOUWYIZ.js} +1 -1
  80. package/dist/standalone/{chunk-EIZG4GOM.js → chunk-VJABWVPW.js} +1 -1
  81. package/dist/standalone/{chunk-EPDC422O.js → chunk-WQC5IIF7.js} +1 -1
  82. package/dist/standalone/{chunk-WA3DGSC2.js → chunk-XFINDIAB.js} +1 -1
  83. package/dist/standalone/{chunk-JGCRBFFO.js → chunk-XTOCLVRS.js} +1 -1
  84. package/dist/standalone/studio.js +1 -1
  85. package/dist/styles.css +1 -1
  86. package/package.json +1 -1
  87. package/dist/standalone/chunk-DWDILV2E.js +0 -1
  88. package/dist/standalone/chunk-EBTLTGG3.js +0 -1
  89. package/dist/standalone/chunk-G5RC7USY.js +0 -1
@@ -1 +1 @@
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
+ 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-MHGJUKCZ.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 +1 @@
1
- import{a as De,b as gt,c as Ee,f as rt}from"./chunk-DWDILV2E.js";import{a as wt,b as Le}from"./chunk-5OIBXYZM.js";import{C as be,e as St,i as xt,p as _e,q as vt}from"./chunk-VL23Y44O.js";import{a as me,c as he}from"./chunk-O3NAGRTR.js";import{j as $}from"./chunk-CKSHCYGC.js";import{a as et}from"./chunk-3OA7PECS.js";import{a as r,d as Pt,e as N,f as te,g as Vt,h as zt,j as tt}from"./chunk-RRCPZMC2.js";var Tt=N(Vt(),1);var ce={};Pt(ce,{Content:()=>ct,Corner:()=>it,Root:()=>nt,Scrollbar:()=>st,Thumb:()=>at,Viewport:()=>lt});var s=N(te(),1);var $e=N(te(),1);var Ue=$e.createContext(void 0);Ue.displayName="ScrollAreaRootContext";function q(){let e=$e.useContext(Ue);if(e===void 0)throw new Error("Base UI: ScrollAreaRootContext is missing. ScrollArea parts must be placed within <ScrollArea.Root>.");return e}r(q,"useScrollAreaRootContext");var ye=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});function Y(e,t,i){if(!e)return 0;let y=getComputedStyle(e),A=i==="x"?"Inline":"Block";return i==="x"&&t==="margin"?parseFloat(y[`${t}InlineStart`])*2:parseFloat(y[`${t}${A}Start`])+parseFloat(y[`${t}${A}End`])}r(Y,"getOffset");var Rt=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var pe=(function(e){return e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var le={hasOverflowX:r(e=>e?{[pe.hasOverflowX]:""}:null,"hasOverflowX"),hasOverflowY:r(e=>e?{[pe.hasOverflowY]:""}:null,"hasOverflowY"),overflowXStart:r(e=>e?{[pe.overflowXStart]:""}:null,"overflowXStart"),overflowXEnd:r(e=>e?{[pe.overflowXEnd]:""}:null,"overflowXEnd"),overflowYStart:r(e=>e?{[pe.overflowYStart]:""}:null,"overflowYStart"),overflowYEnd:r(e=>e?{[pe.overflowYEnd]:""}:null,"overflowYEnd"),cornerHidden:r(()=>null,"cornerHidden")};var Et=N(et(),1);var It={x:0,y:0},bt={width:0,height:0},_t={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Lt={x:!0,y:!0,corner:!0},nt=s.forwardRef(r(function(t,i){let{render:y,className:A,overflowEdgeThreshold:a,style:x,...f}=t,{xStart:v,xEnd:R,yStart:X,yEnd:B}=Dt(a),T=St(),C=be(),w=be(),{nonce:M,disableStyleElements:S}=gt(),[b,h]=s.useState(!1),[U,V]=s.useState(!1),[H,F]=s.useState(!1),[k,z]=s.useState(!1),[ae,G]=s.useState(!1),[j,ie]=s.useState(bt),[J,Ce]=s.useState(bt),[W,I]=s.useState(_t),[l,Q]=s.useState(Lt),K=s.useRef(null),m=s.useRef(null),g=s.useRef(null),o=s.useRef(null),c=s.useRef(null),u=s.useRef(null),p=s.useRef(null),E=s.useRef(!1),_=s.useRef(0),L=s.useRef(0),O=s.useRef(0),oe=s.useRef(0),P=s.useRef("vertical"),xe=s.useRef(It),ve=he(n=>{let ee=n.x-xe.current.x,Ne=n.y-xe.current.y;xe.current=n,Ne!==0&&(F(!0),C.start(500,()=>{F(!1)})),ee!==0&&(V(!0),w.start(500,()=>{V(!1)}))}),ne=he(n=>{n.button===0&&(E.current=!0,_.current=n.clientY,L.current=n.clientX,P.current=n.currentTarget.getAttribute(Rt.orientation),m.current&&(O.current=m.current.scrollTop,oe.current=m.current.scrollLeft),c.current&&P.current==="vertical"&&c.current.setPointerCapture(n.pointerId),u.current&&P.current==="horizontal"&&u.current.setPointerCapture(n.pointerId))}),Ve=he(n=>{if(!E.current)return;let ee=n.clientY-_.current,Ne=n.clientX-L.current;if(m.current){let Te=m.current.scrollHeight,ze=m.current.clientHeight,Ze=m.current.scrollWidth,qe=m.current.clientWidth;if(c.current&&g.current&&P.current==="vertical"){let fe=Y(g.current,"padding","y"),ue=Y(c.current,"margin","y"),Re=c.current.offsetHeight,Me=g.current.offsetHeight-Re-fe-ue,He=ee/Me;m.current.scrollTop=O.current+He*(Te-ze),n.preventDefault(),F(!0),C.start(500,()=>{F(!1)})}if(u.current&&o.current&&P.current==="horizontal"){let fe=Y(o.current,"padding","x"),ue=Y(u.current,"margin","x"),Re=u.current.offsetWidth,Me=o.current.offsetWidth-Re-fe-ue,He=Ne/Me;m.current.scrollLeft=oe.current+He*(Ze-qe),n.preventDefault(),V(!0),w.start(500,()=>{V(!1)})}}}),we=he(n=>{E.current=!1,c.current&&P.current==="vertical"&&c.current.hasPointerCapture(n.pointerId)&&c.current.releasePointerCapture(n.pointerId),u.current&&P.current==="horizontal"&&u.current.hasPointerCapture(n.pointerId)&&u.current.releasePointerCapture(n.pointerId)});function D(n){z(n.pointerType==="touch")}r(D,"handleTouchModalityChange");function Z(n){if(D(n),n.pointerType!=="touch"){let ee=_e(K.current,n.target);h(ee)}}r(Z,"handlePointerEnterOrMove");let Ye=s.useMemo(()=>({scrolling:U||H,hasOverflowX:!l.x,hasOverflowY:!l.y,overflowXStart:W.xStart,overflowXEnd:W.xEnd,overflowYStart:W.yStart,overflowYEnd:W.yEnd,cornerHidden:l.corner}),[U,H,l.x,l.y,l.corner,W]),Ke={role:"presentation",onPointerEnter:Z,onPointerMove:Z,onPointerDown:D,onPointerLeave(){h(!1)},style:{position:"relative",[ye.scrollAreaCornerHeight]:`${j.height}px`,[ye.scrollAreaCornerWidth]:`${j.width}px`}},ge=$("div",t,{state:Ye,ref:[i,K],props:[Ke,f],stateAttributesMapping:le}),Xe=s.useMemo(()=>({handlePointerDown:ne,handlePointerMove:Ve,handlePointerUp:we,handleScroll:ve,cornerSize:j,setCornerSize:ie,thumbSize:J,setThumbSize:Ce,hasMeasuredScrollbar:ae,setHasMeasuredScrollbar:G,touchModality:k,cornerRef:p,scrollingX:U,setScrollingX:V,scrollingY:H,setScrollingY:F,hovering:b,setHovering:h,viewportRef:m,rootRef:K,scrollbarYRef:g,scrollbarXRef:o,thumbYRef:c,thumbXRef:u,rootId:T,hiddenState:l,setHiddenState:Q,overflowEdges:W,setOverflowEdges:I,viewportState:Ye,overflowEdgeThreshold:{xStart:v,xEnd:R,yStart:X,yEnd:B}}),[ne,Ve,we,ve,j,J,ae,k,U,V,H,F,b,h,T,l,W,Ye,v,R,X,B]);return(0,Et.jsxs)(Ue.Provider,{value:Xe,children:[!S&&De.getElement(M),ge]})},"ScrollAreaRoot"));nt.displayName="ScrollAreaRoot";function Dt(e){if(typeof e=="number"){let t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}r(Dt,"normalizeOverflowEdgeThreshold");var se=N(te(),1);var Fe=N(te(),1);var ke=Fe.createContext(void 0);ke.displayName="ScrollAreaViewportContext";function yt(){let e=Fe.useContext(ke);if(e===void 0)throw new Error("Base UI: ScrollAreaViewportContext missing. ScrollAreaViewport parts must be placed within <ScrollArea.Viewport>.");return e}r(yt,"useScrollAreaViewportContext");var re=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({});var At=N(et(),1);var Ot=!1;function Ut(){Ot||xt.engine.webkit||(typeof CSS<"u"&&"registerProperty"in CSS&&[re.scrollAreaOverflowXStart,re.scrollAreaOverflowXEnd,re.scrollAreaOverflowYStart,re.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ot=!0)}r(Ut,"removeCSSVariableInheritance");var lt=se.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{viewportRef:f,scrollbarYRef:v,scrollbarXRef:R,thumbYRef:X,thumbXRef:B,cornerRef:T,cornerSize:C,setCornerSize:w,setThumbSize:M,rootId:S,setHiddenState:b,hiddenState:h,setHasMeasuredScrollbar:U,handleScroll:V,setHovering:H,setOverflowEdges:F,overflowEdges:k,overflowEdgeThreshold:z,scrollingX:ae,scrollingY:G}=q(),j=Le(),ie=se.useRef(!0),J=se.useRef([NaN,NaN,NaN,NaN]),Ce=be(),W=be(),I=he(()=>{let o=f.current,c=v.current,u=R.current,p=X.current,E=B.current,_=T.current;if(!o)return;let L=o.scrollHeight,O=o.scrollWidth,oe=o.clientHeight,P=o.clientWidth,xe=o.scrollTop,ve=o.scrollLeft,ne=J.current,Ve=Number.isNaN(ne[0]);if(ne[0]=oe,ne[1]=L,ne[2]=P,ne[3]=O,Ve&&U(!0),L===0||O===0)return;let we=Ft(o),D=we.y,Z=we.x,Ye=P/O,Ke=oe/L,ge=Math.max(0,O-P),Xe=Math.max(0,L-oe),n=0,ee=0;if(!Z){let d=0;j==="rtl"?d=Ee(-ve,0,ge):d=Ee(ve,0,ge),n=rt(d,ge),ee=ge-n}let Ne=D?0:Ee(xe,0,Xe),Te=D?0:rt(Ne,Xe),ze=D?0:Xe-Te,Ze=Z?0:P,qe=D?0:oe,fe=0,ue=0;!Z&&!D&&(fe=c?.offsetWidth||0,ue=u?.offsetHeight||0);let Re=C.width===0&&C.height===0,Me=Re?fe:0,He=Re?ue:0,ft=Y(u,"padding","x"),ut=Y(c,"padding","y"),dt=Y(E,"margin","x"),mt=Y(p,"margin","y"),ht=Ze-ft-dt,pt=qe-ut-mt,Mt=u?Math.min(u.offsetWidth-Me,ht):ht,Ht=c?Math.min(c.offsetHeight-He,pt):pt,Ge=Math.max(16,Mt*Ye),Je=Math.max(16,Ht*Ke);if(M(d=>d.height===Je&&d.width===Ge?d:{width:Ge,height:Je}),c&&p){let d=c.offsetHeight-Je-ut-mt,de=L-oe,Ie=de===0?0:xe/de,Qe=Math.min(d,Math.max(0,Ie*d));p.style.transform=`translate3d(0,${Qe}px,0)`}if(u&&E){let d=u.offsetWidth-Ge-ft-dt,de=O-P,Ie=de===0?0:ve/de,Qe=j==="rtl"?Ee(Ie*d,-d,0):Ee(Ie*d,0,d);E.style.transform=`translate3d(${Qe}px,0,0)`}let Wt=[[re.scrollAreaOverflowXStart,n],[re.scrollAreaOverflowXEnd,ee],[re.scrollAreaOverflowYStart,Te],[re.scrollAreaOverflowYEnd,ze]];for(let[d,de]of Wt)o.style.setProperty(d,`${de}px`);_&&(Z||D?w({width:0,height:0}):!Z&&!D&&w({width:fe,height:ue})),b(d=>kt(d,we));let We={xStart:!Z&&n>z.xStart,xEnd:!Z&&ee>z.xEnd,yStart:!D&&Te>z.yStart,yEnd:!D&&ze>z.yEnd};F(d=>d.xStart===We.xStart&&d.xEnd===We.xEnd&&d.yStart===We.yStart&&d.yEnd===We.yEnd?d:We)});me(()=>{f.current&&Ut()},[f]),me(()=>{queueMicrotask(I)},[I,h,j,z.xStart,z.xEnd,z.yStart,z.yEnd]),me(()=>{f.current?.matches(":hover")&&H(!0)},[f,H]),me(()=>{let o=f.current;if(typeof ResizeObserver>"u"||!o)return;let c=!1,u=new ResizeObserver(()=>{if(!c){c=!0;let p=J.current;if(p[0]===o.clientHeight&&p[1]===o.scrollHeight&&p[2]===o.clientWidth&&p[3]===o.scrollWidth)return}I()});return u.observe(o),W.start(0,()=>{let p=o.getAnimations({subtree:!0});p.length!==0&&Promise.allSettled(p.map(E=>E.finished)).then(I).catch(()=>{})}),()=>{u.disconnect(),W.clear()}},[I,f,W]);function l(){ie.current=!1}r(l,"handleUserInteraction");let Q={role:"presentation",...S&&{"data-id":`${S}-viewport`},tabIndex:h.x&&h.y?-1:0,className:De.className,style:{overflow:"scroll"},onScroll(){f.current&&(I(),ie.current||V({x:f.current.scrollLeft,y:f.current.scrollTop}),Ce.start(100,()=>{ie.current=!0}))},onWheel:l,onTouchMove:l,onPointerMove:l,onPointerEnter:l,onKeyDown:l},K=se.useMemo(()=>({scrolling:ae||G,hasOverflowX:!h.x,hasOverflowY:!h.y,overflowXStart:k.xStart,overflowXEnd:k.xEnd,overflowYStart:k.yStart,overflowYEnd:k.yEnd,cornerHidden:h.corner}),[ae,G,h.x,h.y,h.corner,k]),m=$("div",t,{ref:[i,f],state:K,props:[Q,x],stateAttributesMapping:le}),g=se.useMemo(()=>({computeThumbPosition:I}),[I]);return(0,At.jsx)(ke.Provider,{value:g,children:m})},"ScrollAreaViewport"));lt.displayName="ScrollAreaViewport";function Ft(e){let t=e.clientHeight>=e.scrollHeight,i=e.clientWidth>=e.scrollWidth;return{y:t,x:i,corner:t||i}}r(Ft,"getHiddenState");function kt(e,t){return e.y===t.y&&e.x===t.x&&e.corner===t.corner?e:t}r(kt,"mergeHiddenState");var Ae=N(te(),1);var Be=N(te(),1);var je=Be.createContext(void 0);je.displayName="ScrollAreaScrollbarContext";function Ct(){let e=Be.useContext(je);if(e===void 0)throw new Error("Base UI: ScrollAreaScrollbarContext is missing. ScrollAreaScrollbar parts must be placed within <ScrollArea.Scrollbar>.");return e}r(Ct,"useScrollAreaScrollbarContext");var Oe=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});var Yt=N(et(),1);var st=Ae.forwardRef(r(function(t,i){let{render:y,className:A,orientation:a="vertical",keepMounted:x=!1,style:f,...v}=t,{hovering:R,scrollingX:X,scrollingY:B,hiddenState:T,overflowEdges:C,scrollbarYRef:w,scrollbarXRef:M,viewportRef:S,thumbYRef:b,thumbXRef:h,handlePointerDown:U,handlePointerUp:V,handleScroll:H,rootId:F,thumbSize:k,hasMeasuredScrollbar:z}=q(),ae={hovering:R,scrolling:{horizontal:X,vertical:B}[a],orientation:a,hasOverflowX:!T.x,hasOverflowY:!T.y,overflowXStart:C.xStart,overflowXEnd:C.xEnd,overflowYStart:C.yStart,overflowYEnd:C.yEnd,cornerHidden:T.corner},G=Le(),j=!z&&!x,ie=a==="vertical"?T.y:T.x,J=x||!ie;Ae.useEffect(()=>{if(!J)return;let l=S.current,Q=a==="vertical"?w.current:M.current;if(!Q)return;function K(m){if(!l||!Q||m.ctrlKey)return;let g=a==="horizontal",o=g?"scrollLeft":"scrollTop",c=g?m.deltaX:m.deltaY;if(c===0)return;let u=g?l.scrollWidth-l.clientWidth:l.scrollHeight-l.clientHeight,p=g&&G==="rtl"?-u:0,E=g&&G==="rtl"?0:u,_=l[o];_<=p&&c<0||_>=E&&c>0||(m.preventDefault(),l[o]=Math.min(E,Math.max(p,_+c)),H({x:l.scrollLeft,y:l.scrollTop}))}return r(K,"handleWheel"),wt(Q,"wheel",K,{passive:!1})},[G,H,a,M,w,J,S]);let Ce={...F&&{"data-id":`${F}-scrollbar`},onPointerDown(l){if(l.button!==0)return;let Q=vt(l.nativeEvent),K=a==="vertical"?b.current:h.current;if(!(K&&_e(K,Q))&&S.current){if(b.current&&w.current&&a==="vertical"){let m=Y(b.current,"margin","y"),g=Y(w.current,"padding","y"),o=b.current.offsetHeight,c=w.current.getBoundingClientRect(),u=l.clientY-c.top-o/2-g+m/2,p=S.current.scrollHeight,E=S.current.clientHeight,_=w.current.offsetHeight-o-g-m,O=u/_*(p-E);S.current.scrollTop=O}if(h.current&&M.current&&a==="horizontal"){let m=Y(h.current,"margin","x"),g=Y(M.current,"padding","x"),o=h.current.offsetWidth,c=M.current.getBoundingClientRect(),u=l.clientX-c.left-o/2-g+m/2,p=S.current.scrollWidth,E=S.current.clientWidth,_=M.current.offsetWidth-o-g-m,L=u/_,O;G==="rtl"?(O=(1-L)*(p-E),S.current.scrollLeft<=0&&(O=-O)):O=L*(p-E),S.current.scrollLeft=O}H({x:S.current.scrollLeft,y:S.current.scrollTop}),U(l)}},onPointerUp:V,onPointerCancel:V,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:j?"hidden":void 0,...a==="vertical"&&{top:0,bottom:`var(${ye.scrollAreaCornerHeight})`,insetInlineEnd:0,[Oe.scrollAreaThumbHeight]:`${k.height}px`},...a==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${ye.scrollAreaCornerWidth})`,bottom:0,[Oe.scrollAreaThumbWidth]:`${k.width}px`}}},W=$("div",t,{ref:[i,a==="vertical"?w:M],state:ae,props:[Ce,v],stateAttributesMapping:le}),I=Ae.useMemo(()=>({orientation:a}),[a]);return J?(0,Yt.jsx)(je.Provider,{value:I,children:W}):null},"ScrollAreaScrollbar"));st.displayName="ScrollAreaScrollbar";var Pe=N(te(),1);var ct=Pe.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{computeThumbPosition:f}=yt(),{hasMeasuredScrollbar:v,viewportState:R}=q(),X=Pe.useRef(null),B=Pe.useRef(v);return me(()=>{if(typeof ResizeObserver>"u")return;let C=!1,w=new ResizeObserver(()=>{!C&&(C=!0,!B.current)||f()});return X.current&&w.observe(X.current),()=>{w.disconnect()}},[f]),$("div",t,{ref:[i,X],state:R,stateAttributesMapping:le,props:[{role:"presentation",style:{minWidth:"fit-content"}},x]})},"ScrollAreaContent"));ct.displayName="ScrollAreaContent";var Xt=N(te(),1);var at=Xt.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{thumbYRef:f,thumbXRef:v,handlePointerDown:R,handlePointerMove:X,handlePointerUp:B,setScrollingX:T,setScrollingY:C,scrollingX:w,scrollingY:M,hasMeasuredScrollbar:S}=q(),{orientation:b}=Ct(),h={scrolling:b==="horizontal"?w:M,orientation:b};function U(H){b==="vertical"&&C(!1),b==="horizontal"&&T(!1),B(H)}return r(U,"endDrag"),$("div",t,{ref:[i,b==="vertical"?f:v],state:h,props:[{onPointerDown:R,onPointerMove:X,onPointerUp:U,onPointerCancel:U,style:{visibility:S?void 0:"hidden",...b==="vertical"&&{height:`var(${Oe.scrollAreaThumbHeight})`},...b==="horizontal"&&{width:`var(${Oe.scrollAreaThumbWidth})`}}},x]})},"ScrollAreaThumb"));at.displayName="ScrollAreaThumb";var Nt=N(te(),1);var it=Nt.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{cornerRef:f,cornerSize:v,hiddenState:R}=q(),X=$("div",t,{ref:[i,f],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:v.width,height:v.height}},x]});return R.corner?null:X},"ScrollAreaCorner"));it.displayName="ScrollAreaCorner";var Se=N(zt(),1);function yo(e){let t=(0,Tt.c)(14),i,y,A;t[0]!==e?({className:y,children:i,...A}=e,t[0]=e,t[1]=i,t[2]=y,t[3]=A):(i=t[1],y=t[2],A=t[3]);let a;t[4]!==y?(a=tt("relative",y),t[4]=y,t[5]=a):a=t[5];let x;t[6]!==i?(x=(0,Se.jsxDEV)(ce.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:i},void 0,!1),t[6]=i,t[7]=x):x=t[7];let f,v;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,Se.jsxDEV)(Bt,{},void 0,!1),v=(0,Se.jsxDEV)(ce.Corner,{},void 0,!1),t[8]=f,t[9]=v):(f=t[8],v=t[9]);let R;return t[10]!==A||t[11]!==a||t[12]!==x?(R=(0,Se.jsxDEV)(ce.Root,{"data-slot":"scroll-area",className:a,...A,children:[x,f,v]},void 0,!0),t[10]=A,t[11]=a,t[12]=x,t[13]=R):R=t[13],R}r(yo,"ScrollArea");function Bt({className:e,orientation:t="vertical",...i}){return(0,Se.jsxDEV)(ce.Scrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:tt("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-s data-vertical:border-s-transparent",e),...i,children:(0,Se.jsxDEV)(ce.Thumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-md bg-border"},void 0,!1)},void 0,!1)}r(Bt,"ScrollBar");export{yo as a};
1
+ import{a as Ee,d as rt,e as De,f as gt}from"./chunk-3HGNPZBN.js";import{a as wt,b as Le}from"./chunk-5OIBXYZM.js";import{C as be,e as St,i as xt,p as _e,q as vt}from"./chunk-VL23Y44O.js";import{a as me,c as he}from"./chunk-O3NAGRTR.js";import{j as $}from"./chunk-CKSHCYGC.js";import{a as et}from"./chunk-3OA7PECS.js";import{a as r,d as Pt,e as N,f as te,g as Vt,h as zt,j as tt}from"./chunk-RRCPZMC2.js";var Tt=N(Vt(),1);var ce={};Pt(ce,{Content:()=>ct,Corner:()=>it,Root:()=>nt,Scrollbar:()=>st,Thumb:()=>at,Viewport:()=>lt});var s=N(te(),1);var $e=N(te(),1);var Ue=$e.createContext(void 0);Ue.displayName="ScrollAreaRootContext";function q(){let e=$e.useContext(Ue);if(e===void 0)throw new Error("Base UI: ScrollAreaRootContext is missing. ScrollArea parts must be placed within <ScrollArea.Root>.");return e}r(q,"useScrollAreaRootContext");var ye=(function(e){return e.scrollAreaCornerHeight="--scroll-area-corner-height",e.scrollAreaCornerWidth="--scroll-area-corner-width",e})({});function Y(e,t,i){if(!e)return 0;let y=getComputedStyle(e),A=i==="x"?"Inline":"Block";return i==="x"&&t==="margin"?parseFloat(y[`${t}InlineStart`])*2:parseFloat(y[`${t}${A}Start`])+parseFloat(y[`${t}${A}End`])}r(Y,"getOffset");var Rt=(function(e){return e.orientation="data-orientation",e.hovering="data-hovering",e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var pe=(function(e){return e.scrolling="data-scrolling",e.hasOverflowX="data-has-overflow-x",e.hasOverflowY="data-has-overflow-y",e.overflowXStart="data-overflow-x-start",e.overflowXEnd="data-overflow-x-end",e.overflowYStart="data-overflow-y-start",e.overflowYEnd="data-overflow-y-end",e})({});var le={hasOverflowX:r(e=>e?{[pe.hasOverflowX]:""}:null,"hasOverflowX"),hasOverflowY:r(e=>e?{[pe.hasOverflowY]:""}:null,"hasOverflowY"),overflowXStart:r(e=>e?{[pe.overflowXStart]:""}:null,"overflowXStart"),overflowXEnd:r(e=>e?{[pe.overflowXEnd]:""}:null,"overflowXEnd"),overflowYStart:r(e=>e?{[pe.overflowYStart]:""}:null,"overflowYStart"),overflowYEnd:r(e=>e?{[pe.overflowYEnd]:""}:null,"overflowYEnd"),cornerHidden:r(()=>null,"cornerHidden")};var Et=N(et(),1);var It={x:0,y:0},bt={width:0,height:0},_t={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},Lt={x:!0,y:!0,corner:!0},nt=s.forwardRef(r(function(t,i){let{render:y,className:A,overflowEdgeThreshold:a,style:x,...f}=t,{xStart:v,xEnd:R,yStart:X,yEnd:B}=Dt(a),T=St(),C=be(),w=be(),{nonce:M,disableStyleElements:S}=gt(),[b,h]=s.useState(!1),[U,V]=s.useState(!1),[H,F]=s.useState(!1),[k,z]=s.useState(!1),[ae,G]=s.useState(!1),[j,ie]=s.useState(bt),[J,Ce]=s.useState(bt),[W,I]=s.useState(_t),[l,Q]=s.useState(Lt),K=s.useRef(null),m=s.useRef(null),g=s.useRef(null),o=s.useRef(null),c=s.useRef(null),u=s.useRef(null),p=s.useRef(null),E=s.useRef(!1),_=s.useRef(0),L=s.useRef(0),O=s.useRef(0),oe=s.useRef(0),P=s.useRef("vertical"),xe=s.useRef(It),ve=he(n=>{let ee=n.x-xe.current.x,Ne=n.y-xe.current.y;xe.current=n,Ne!==0&&(F(!0),C.start(500,()=>{F(!1)})),ee!==0&&(V(!0),w.start(500,()=>{V(!1)}))}),ne=he(n=>{n.button===0&&(E.current=!0,_.current=n.clientY,L.current=n.clientX,P.current=n.currentTarget.getAttribute(Rt.orientation),m.current&&(O.current=m.current.scrollTop,oe.current=m.current.scrollLeft),c.current&&P.current==="vertical"&&c.current.setPointerCapture(n.pointerId),u.current&&P.current==="horizontal"&&u.current.setPointerCapture(n.pointerId))}),Ve=he(n=>{if(!E.current)return;let ee=n.clientY-_.current,Ne=n.clientX-L.current;if(m.current){let Te=m.current.scrollHeight,ze=m.current.clientHeight,Ze=m.current.scrollWidth,qe=m.current.clientWidth;if(c.current&&g.current&&P.current==="vertical"){let fe=Y(g.current,"padding","y"),ue=Y(c.current,"margin","y"),Re=c.current.offsetHeight,Me=g.current.offsetHeight-Re-fe-ue,He=ee/Me;m.current.scrollTop=O.current+He*(Te-ze),n.preventDefault(),F(!0),C.start(500,()=>{F(!1)})}if(u.current&&o.current&&P.current==="horizontal"){let fe=Y(o.current,"padding","x"),ue=Y(u.current,"margin","x"),Re=u.current.offsetWidth,Me=o.current.offsetWidth-Re-fe-ue,He=Ne/Me;m.current.scrollLeft=oe.current+He*(Ze-qe),n.preventDefault(),V(!0),w.start(500,()=>{V(!1)})}}}),we=he(n=>{E.current=!1,c.current&&P.current==="vertical"&&c.current.hasPointerCapture(n.pointerId)&&c.current.releasePointerCapture(n.pointerId),u.current&&P.current==="horizontal"&&u.current.hasPointerCapture(n.pointerId)&&u.current.releasePointerCapture(n.pointerId)});function D(n){z(n.pointerType==="touch")}r(D,"handleTouchModalityChange");function Z(n){if(D(n),n.pointerType!=="touch"){let ee=_e(K.current,n.target);h(ee)}}r(Z,"handlePointerEnterOrMove");let Ye=s.useMemo(()=>({scrolling:U||H,hasOverflowX:!l.x,hasOverflowY:!l.y,overflowXStart:W.xStart,overflowXEnd:W.xEnd,overflowYStart:W.yStart,overflowYEnd:W.yEnd,cornerHidden:l.corner}),[U,H,l.x,l.y,l.corner,W]),Ke={role:"presentation",onPointerEnter:Z,onPointerMove:Z,onPointerDown:D,onPointerLeave(){h(!1)},style:{position:"relative",[ye.scrollAreaCornerHeight]:`${j.height}px`,[ye.scrollAreaCornerWidth]:`${j.width}px`}},ge=$("div",t,{state:Ye,ref:[i,K],props:[Ke,f],stateAttributesMapping:le}),Xe=s.useMemo(()=>({handlePointerDown:ne,handlePointerMove:Ve,handlePointerUp:we,handleScroll:ve,cornerSize:j,setCornerSize:ie,thumbSize:J,setThumbSize:Ce,hasMeasuredScrollbar:ae,setHasMeasuredScrollbar:G,touchModality:k,cornerRef:p,scrollingX:U,setScrollingX:V,scrollingY:H,setScrollingY:F,hovering:b,setHovering:h,viewportRef:m,rootRef:K,scrollbarYRef:g,scrollbarXRef:o,thumbYRef:c,thumbXRef:u,rootId:T,hiddenState:l,setHiddenState:Q,overflowEdges:W,setOverflowEdges:I,viewportState:Ye,overflowEdgeThreshold:{xStart:v,xEnd:R,yStart:X,yEnd:B}}),[ne,Ve,we,ve,j,J,ae,k,U,V,H,F,b,h,T,l,W,Ye,v,R,X,B]);return(0,Et.jsxs)(Ue.Provider,{value:Xe,children:[!S&&De.getElement(M),ge]})},"ScrollAreaRoot"));nt.displayName="ScrollAreaRoot";function Dt(e){if(typeof e=="number"){let t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}r(Dt,"normalizeOverflowEdgeThreshold");var se=N(te(),1);var Fe=N(te(),1);var ke=Fe.createContext(void 0);ke.displayName="ScrollAreaViewportContext";function yt(){let e=Fe.useContext(ke);if(e===void 0)throw new Error("Base UI: ScrollAreaViewportContext missing. ScrollAreaViewport parts must be placed within <ScrollArea.Viewport>.");return e}r(yt,"useScrollAreaViewportContext");var re=(function(e){return e.scrollAreaOverflowXStart="--scroll-area-overflow-x-start",e.scrollAreaOverflowXEnd="--scroll-area-overflow-x-end",e.scrollAreaOverflowYStart="--scroll-area-overflow-y-start",e.scrollAreaOverflowYEnd="--scroll-area-overflow-y-end",e})({});var At=N(et(),1);var Ot=!1;function Ut(){Ot||xt.engine.webkit||(typeof CSS<"u"&&"registerProperty"in CSS&&[re.scrollAreaOverflowXStart,re.scrollAreaOverflowXEnd,re.scrollAreaOverflowYStart,re.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),Ot=!0)}r(Ut,"removeCSSVariableInheritance");var lt=se.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{viewportRef:f,scrollbarYRef:v,scrollbarXRef:R,thumbYRef:X,thumbXRef:B,cornerRef:T,cornerSize:C,setCornerSize:w,setThumbSize:M,rootId:S,setHiddenState:b,hiddenState:h,setHasMeasuredScrollbar:U,handleScroll:V,setHovering:H,setOverflowEdges:F,overflowEdges:k,overflowEdgeThreshold:z,scrollingX:ae,scrollingY:G}=q(),j=Le(),ie=se.useRef(!0),J=se.useRef([NaN,NaN,NaN,NaN]),Ce=be(),W=be(),I=he(()=>{let o=f.current,c=v.current,u=R.current,p=X.current,E=B.current,_=T.current;if(!o)return;let L=o.scrollHeight,O=o.scrollWidth,oe=o.clientHeight,P=o.clientWidth,xe=o.scrollTop,ve=o.scrollLeft,ne=J.current,Ve=Number.isNaN(ne[0]);if(ne[0]=oe,ne[1]=L,ne[2]=P,ne[3]=O,Ve&&U(!0),L===0||O===0)return;let we=Ft(o),D=we.y,Z=we.x,Ye=P/O,Ke=oe/L,ge=Math.max(0,O-P),Xe=Math.max(0,L-oe),n=0,ee=0;if(!Z){let d=0;j==="rtl"?d=Ee(-ve,0,ge):d=Ee(ve,0,ge),n=rt(d,ge),ee=ge-n}let Ne=D?0:Ee(xe,0,Xe),Te=D?0:rt(Ne,Xe),ze=D?0:Xe-Te,Ze=Z?0:P,qe=D?0:oe,fe=0,ue=0;!Z&&!D&&(fe=c?.offsetWidth||0,ue=u?.offsetHeight||0);let Re=C.width===0&&C.height===0,Me=Re?fe:0,He=Re?ue:0,ft=Y(u,"padding","x"),ut=Y(c,"padding","y"),dt=Y(E,"margin","x"),mt=Y(p,"margin","y"),ht=Ze-ft-dt,pt=qe-ut-mt,Mt=u?Math.min(u.offsetWidth-Me,ht):ht,Ht=c?Math.min(c.offsetHeight-He,pt):pt,Ge=Math.max(16,Mt*Ye),Je=Math.max(16,Ht*Ke);if(M(d=>d.height===Je&&d.width===Ge?d:{width:Ge,height:Je}),c&&p){let d=c.offsetHeight-Je-ut-mt,de=L-oe,Ie=de===0?0:xe/de,Qe=Math.min(d,Math.max(0,Ie*d));p.style.transform=`translate3d(0,${Qe}px,0)`}if(u&&E){let d=u.offsetWidth-Ge-ft-dt,de=O-P,Ie=de===0?0:ve/de,Qe=j==="rtl"?Ee(Ie*d,-d,0):Ee(Ie*d,0,d);E.style.transform=`translate3d(${Qe}px,0,0)`}let Wt=[[re.scrollAreaOverflowXStart,n],[re.scrollAreaOverflowXEnd,ee],[re.scrollAreaOverflowYStart,Te],[re.scrollAreaOverflowYEnd,ze]];for(let[d,de]of Wt)o.style.setProperty(d,`${de}px`);_&&(Z||D?w({width:0,height:0}):!Z&&!D&&w({width:fe,height:ue})),b(d=>kt(d,we));let We={xStart:!Z&&n>z.xStart,xEnd:!Z&&ee>z.xEnd,yStart:!D&&Te>z.yStart,yEnd:!D&&ze>z.yEnd};F(d=>d.xStart===We.xStart&&d.xEnd===We.xEnd&&d.yStart===We.yStart&&d.yEnd===We.yEnd?d:We)});me(()=>{f.current&&Ut()},[f]),me(()=>{queueMicrotask(I)},[I,h,j,z.xStart,z.xEnd,z.yStart,z.yEnd]),me(()=>{f.current?.matches(":hover")&&H(!0)},[f,H]),me(()=>{let o=f.current;if(typeof ResizeObserver>"u"||!o)return;let c=!1,u=new ResizeObserver(()=>{if(!c){c=!0;let p=J.current;if(p[0]===o.clientHeight&&p[1]===o.scrollHeight&&p[2]===o.clientWidth&&p[3]===o.scrollWidth)return}I()});return u.observe(o),W.start(0,()=>{let p=o.getAnimations({subtree:!0});p.length!==0&&Promise.allSettled(p.map(E=>E.finished)).then(I).catch(()=>{})}),()=>{u.disconnect(),W.clear()}},[I,f,W]);function l(){ie.current=!1}r(l,"handleUserInteraction");let Q={role:"presentation",...S&&{"data-id":`${S}-viewport`},tabIndex:h.x&&h.y?-1:0,className:De.className,style:{overflow:"scroll"},onScroll(){f.current&&(I(),ie.current||V({x:f.current.scrollLeft,y:f.current.scrollTop}),Ce.start(100,()=>{ie.current=!0}))},onWheel:l,onTouchMove:l,onPointerMove:l,onPointerEnter:l,onKeyDown:l},K=se.useMemo(()=>({scrolling:ae||G,hasOverflowX:!h.x,hasOverflowY:!h.y,overflowXStart:k.xStart,overflowXEnd:k.xEnd,overflowYStart:k.yStart,overflowYEnd:k.yEnd,cornerHidden:h.corner}),[ae,G,h.x,h.y,h.corner,k]),m=$("div",t,{ref:[i,f],state:K,props:[Q,x],stateAttributesMapping:le}),g=se.useMemo(()=>({computeThumbPosition:I}),[I]);return(0,At.jsx)(ke.Provider,{value:g,children:m})},"ScrollAreaViewport"));lt.displayName="ScrollAreaViewport";function Ft(e){let t=e.clientHeight>=e.scrollHeight,i=e.clientWidth>=e.scrollWidth;return{y:t,x:i,corner:t||i}}r(Ft,"getHiddenState");function kt(e,t){return e.y===t.y&&e.x===t.x&&e.corner===t.corner?e:t}r(kt,"mergeHiddenState");var Ae=N(te(),1);var Be=N(te(),1);var je=Be.createContext(void 0);je.displayName="ScrollAreaScrollbarContext";function Ct(){let e=Be.useContext(je);if(e===void 0)throw new Error("Base UI: ScrollAreaScrollbarContext is missing. ScrollAreaScrollbar parts must be placed within <ScrollArea.Scrollbar>.");return e}r(Ct,"useScrollAreaScrollbarContext");var Oe=(function(e){return e.scrollAreaThumbHeight="--scroll-area-thumb-height",e.scrollAreaThumbWidth="--scroll-area-thumb-width",e})({});var Yt=N(et(),1);var st=Ae.forwardRef(r(function(t,i){let{render:y,className:A,orientation:a="vertical",keepMounted:x=!1,style:f,...v}=t,{hovering:R,scrollingX:X,scrollingY:B,hiddenState:T,overflowEdges:C,scrollbarYRef:w,scrollbarXRef:M,viewportRef:S,thumbYRef:b,thumbXRef:h,handlePointerDown:U,handlePointerUp:V,handleScroll:H,rootId:F,thumbSize:k,hasMeasuredScrollbar:z}=q(),ae={hovering:R,scrolling:{horizontal:X,vertical:B}[a],orientation:a,hasOverflowX:!T.x,hasOverflowY:!T.y,overflowXStart:C.xStart,overflowXEnd:C.xEnd,overflowYStart:C.yStart,overflowYEnd:C.yEnd,cornerHidden:T.corner},G=Le(),j=!z&&!x,ie=a==="vertical"?T.y:T.x,J=x||!ie;Ae.useEffect(()=>{if(!J)return;let l=S.current,Q=a==="vertical"?w.current:M.current;if(!Q)return;function K(m){if(!l||!Q||m.ctrlKey)return;let g=a==="horizontal",o=g?"scrollLeft":"scrollTop",c=g?m.deltaX:m.deltaY;if(c===0)return;let u=g?l.scrollWidth-l.clientWidth:l.scrollHeight-l.clientHeight,p=g&&G==="rtl"?-u:0,E=g&&G==="rtl"?0:u,_=l[o];_<=p&&c<0||_>=E&&c>0||(m.preventDefault(),l[o]=Math.min(E,Math.max(p,_+c)),H({x:l.scrollLeft,y:l.scrollTop}))}return r(K,"handleWheel"),wt(Q,"wheel",K,{passive:!1})},[G,H,a,M,w,J,S]);let Ce={...F&&{"data-id":`${F}-scrollbar`},onPointerDown(l){if(l.button!==0)return;let Q=vt(l.nativeEvent),K=a==="vertical"?b.current:h.current;if(!(K&&_e(K,Q))&&S.current){if(b.current&&w.current&&a==="vertical"){let m=Y(b.current,"margin","y"),g=Y(w.current,"padding","y"),o=b.current.offsetHeight,c=w.current.getBoundingClientRect(),u=l.clientY-c.top-o/2-g+m/2,p=S.current.scrollHeight,E=S.current.clientHeight,_=w.current.offsetHeight-o-g-m,O=u/_*(p-E);S.current.scrollTop=O}if(h.current&&M.current&&a==="horizontal"){let m=Y(h.current,"margin","x"),g=Y(M.current,"padding","x"),o=h.current.offsetWidth,c=M.current.getBoundingClientRect(),u=l.clientX-c.left-o/2-g+m/2,p=S.current.scrollWidth,E=S.current.clientWidth,_=M.current.offsetWidth-o-g-m,L=u/_,O;G==="rtl"?(O=(1-L)*(p-E),S.current.scrollLeft<=0&&(O=-O)):O=L*(p-E),S.current.scrollLeft=O}H({x:S.current.scrollLeft,y:S.current.scrollTop}),U(l)}},onPointerUp:V,onPointerCancel:V,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:j?"hidden":void 0,...a==="vertical"&&{top:0,bottom:`var(${ye.scrollAreaCornerHeight})`,insetInlineEnd:0,[Oe.scrollAreaThumbHeight]:`${k.height}px`},...a==="horizontal"&&{insetInlineStart:0,insetInlineEnd:`var(${ye.scrollAreaCornerWidth})`,bottom:0,[Oe.scrollAreaThumbWidth]:`${k.width}px`}}},W=$("div",t,{ref:[i,a==="vertical"?w:M],state:ae,props:[Ce,v],stateAttributesMapping:le}),I=Ae.useMemo(()=>({orientation:a}),[a]);return J?(0,Yt.jsx)(je.Provider,{value:I,children:W}):null},"ScrollAreaScrollbar"));st.displayName="ScrollAreaScrollbar";var Pe=N(te(),1);var ct=Pe.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{computeThumbPosition:f}=yt(),{hasMeasuredScrollbar:v,viewportState:R}=q(),X=Pe.useRef(null),B=Pe.useRef(v);return me(()=>{if(typeof ResizeObserver>"u")return;let C=!1,w=new ResizeObserver(()=>{!C&&(C=!0,!B.current)||f()});return X.current&&w.observe(X.current),()=>{w.disconnect()}},[f]),$("div",t,{ref:[i,X],state:R,stateAttributesMapping:le,props:[{role:"presentation",style:{minWidth:"fit-content"}},x]})},"ScrollAreaContent"));ct.displayName="ScrollAreaContent";var Xt=N(te(),1);var at=Xt.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{thumbYRef:f,thumbXRef:v,handlePointerDown:R,handlePointerMove:X,handlePointerUp:B,setScrollingX:T,setScrollingY:C,scrollingX:w,scrollingY:M,hasMeasuredScrollbar:S}=q(),{orientation:b}=Ct(),h={scrolling:b==="horizontal"?w:M,orientation:b};function U(H){b==="vertical"&&C(!1),b==="horizontal"&&T(!1),B(H)}return r(U,"endDrag"),$("div",t,{ref:[i,b==="vertical"?f:v],state:h,props:[{onPointerDown:R,onPointerMove:X,onPointerUp:U,onPointerCancel:U,style:{visibility:S?void 0:"hidden",...b==="vertical"&&{height:`var(${Oe.scrollAreaThumbHeight})`},...b==="horizontal"&&{width:`var(${Oe.scrollAreaThumbWidth})`}}},x]})},"ScrollAreaThumb"));at.displayName="ScrollAreaThumb";var Nt=N(te(),1);var it=Nt.forwardRef(r(function(t,i){let{render:y,className:A,style:a,...x}=t,{cornerRef:f,cornerSize:v,hiddenState:R}=q(),X=$("div",t,{ref:[i,f],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:v.width,height:v.height}},x]});return R.corner?null:X},"ScrollAreaCorner"));it.displayName="ScrollAreaCorner";var Se=N(zt(),1);function yo(e){let t=(0,Tt.c)(14),i,y,A;t[0]!==e?({className:y,children:i,...A}=e,t[0]=e,t[1]=i,t[2]=y,t[3]=A):(i=t[1],y=t[2],A=t[3]);let a;t[4]!==y?(a=tt("relative",y),t[4]=y,t[5]=a):a=t[5];let x;t[6]!==i?(x=(0,Se.jsxDEV)(ce.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:i},void 0,!1),t[6]=i,t[7]=x):x=t[7];let f,v;t[8]===Symbol.for("react.memo_cache_sentinel")?(f=(0,Se.jsxDEV)(Bt,{},void 0,!1),v=(0,Se.jsxDEV)(ce.Corner,{},void 0,!1),t[8]=f,t[9]=v):(f=t[8],v=t[9]);let R;return t[10]!==A||t[11]!==a||t[12]!==x?(R=(0,Se.jsxDEV)(ce.Root,{"data-slot":"scroll-area",className:a,...A,children:[x,f,v]},void 0,!0),t[10]=A,t[11]=a,t[12]=x,t[13]=R):R=t[13],R}r(yo,"ScrollArea");function Bt({className:e,orientation:t="vertical",...i}){return(0,Se.jsxDEV)(ce.Scrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:tt("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-s data-vertical:border-s-transparent",e),...i,children:(0,Se.jsxDEV)(ce.Thumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-md bg-border"},void 0,!1)},void 0,!1)}r(Bt,"ScrollBar");export{yo as a};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-VLXV72QE.js";import{a as v}from"./chunk-JSEXCW5Q.js";import{a as q}from"./chunk-FDWXYXOM.js";import{b as V}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as B}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as S}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as z}from"./chunk-EBTLTGG3.js";import{f as L}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as j,e as K,f as U,h as J,l as M,p as P}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a,e as D,f as ne,h as ie}from"./chunk-RRCPZMC2.js";var n=D(ne(),1);var e=D(ie(),1);var de=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),le=a(r=>r===void 0||r.length===0?"()":`(${r.map(i=>`${i.name}${i.optional?"?":""}: ${de(i)}`).join(", ")})`,"formatSignature"),ce=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ue=a(r=>{let i={};for(let s of r??[])s.optional||(i[s.name]=ce(s.kind));return JSON.stringify(i,void 0,2)},"argumentsTemplate"),fe=U(z.runAs),me=10,he=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ae=a(({functions:r,runAsIdentity:i=!1}={})=>{let s=j(),u=L(),[X,Y]=(0,n.useState)(null),[w,G]=(0,n.useState)(null),g=r??X??[],[R,I]=(0,n.useState)(""),[f,x]=(0,n.useState)("{}"),[c,k]=(0,n.useState)(""),[m,Q]=(0,n.useState)(""),[b,h]=(0,n.useState)("idle"),[W,N]=(0,n.useState)(void 0),[A,y]=(0,n.useState)(null),[C,Z]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Y(d),d)).catch(d=>{t||G(J(d))}),()=>{t=!0}},[u,r]);let T=R===""?g[0]?.path??"":R,o=g.find(t=>t.path===T),_=a(async()=>{if(!o)return;let t;try{t=f.trim()===""?{}:JSON.parse(f)}catch(l){h("error"),N(void 0),y(s("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:o.path},F=c.trim()===""?{}:{shardKey:c.trim()},$=i?m.trim():"",E=a(l=>{Z(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:c,status:l},...O].slice(0,me))},"record");h("running"),y(null);try{let l=$===""?await K(u,o.kind,d,t,F):await u.query(fe,{args:t,functionPath:o.path,userId:$},F);V(c),N(l),h("success"),E("success")}catch(l){N(void 0),y(l.message),h("error"),E("error")}},"run"),ee=a(t=>{I(t.path),x(t.argsText),k(t.shardKey)},"loadRun"),te=a(t=>{I(t.target.value)},"onSelectChange"),re=a(t=>{x(t.target.value)},"onArgsChange"),se=a(t=>{Q(t.target.value)},"onRunAsChange"),ae=a(()=>{M(_())},"runOnce"),oe=a(()=>{x(ue(o?.args))},"prefillArgs");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:w},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(v,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:T,children:g.map(t=>(0,e.jsxDEV)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path,!0))},void 0,!1),o!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,e.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:le(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)(v,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:oe,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(H,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:f},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{onChange:k,testId:"shard-input",value:c},void 0,!1),i&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsxDEV)(v,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,e.jsxDEV)(B,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:se,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,e.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(p,{"data-testid":"run-button",disabled:b==="running"||o===void 0,onClick:ae,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,e.jsxDEV)(S,{variant:"outline",children:o.kind},void 0,!1),i&&m.trim()!==""&&(0,e.jsxDEV)(S,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),b==="error"&&A!==null&&(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:A},void 0,!1),b==="success"&&(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(W)},void 0,!1),C.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:C.map((t,d)=>(0,e.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsxDEV)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]},void 0,!0)," ",(0,e.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:P(t.at)},void 0,!1)," ",(0,e.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:a(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ae as FunctionRunner};
1
+ import{a as H}from"./chunk-VLXV72QE.js";import{a as v}from"./chunk-JSEXCW5Q.js";import{a as q}from"./chunk-FDWXYXOM.js";import{b as V}from"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as B}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as p}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as S}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as z}from"./chunk-MHGJUKCZ.js";import{f as L}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{d as j,e as K,f as U,h as J,l as M,p as P}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a,e as D,f as ne,h as ie}from"./chunk-RRCPZMC2.js";var n=D(ne(),1);var e=D(ie(),1);var de=a(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"argumentType"),le=a(r=>r===void 0||r.length===0?"()":`(${r.map(i=>`${i.name}${i.optional?"?":""}: ${de(i)}`).join(", ")})`,"formatSignature"),ce=a(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"placeholderValue"),ue=a(r=>{let i={};for(let s of r??[])s.optional||(i[s.name]=ce(s.kind));return JSON.stringify(i,void 0,2)},"argumentsTemplate"),fe=U(z.runAs),me=10,he=a(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"formatResult"),Ae=a(({functions:r,runAsIdentity:i=!1}={})=>{let s=j(),u=L(),[X,Y]=(0,n.useState)(null),[w,G]=(0,n.useState)(null),g=r??X??[],[R,I]=(0,n.useState)(""),[f,x]=(0,n.useState)("{}"),[c,k]=(0,n.useState)(""),[m,Q]=(0,n.useState)(""),[b,h]=(0,n.useState)("idle"),[W,N]=(0,n.useState)(void 0),[A,y]=(0,n.useState)(null),[C,Z]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Y(d),d)).catch(d=>{t||G(J(d))}),()=>{t=!0}},[u,r]);let T=R===""?g[0]?.path??"":R,o=g.find(t=>t.path===T),_=a(async()=>{if(!o)return;let t;try{t=f.trim()===""?{}:JSON.parse(f)}catch(l){h("error"),N(void 0),y(s("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:o.path},F=c.trim()===""?{}:{shardKey:c.trim()},$=i?m.trim():"",E=a(l=>{Z(O=>[{argsText:f,at:Date.now(),id:(O[0]?.id??0)+1,kind:o.kind,path:o.path,shardKey:c,status:l},...O].slice(0,me))},"record");h("running"),y(null);try{let l=$===""?await K(u,o.kind,d,t,F):await u.query(fe,{args:t,functionPath:o.path,userId:$},F);V(c),N(l),h("success"),E("success")}catch(l){N(void 0),y(l.message),h("error"),E("error")}},"run"),ee=a(t=>{I(t.path),x(t.argsText),k(t.shardKey)},"loadRun"),te=a(t=>{I(t.target.value)},"onSelectChange"),re=a(t=>{x(t.target.value)},"onArgsChange"),se=a(t=>{Q(t.target.value)},"onRunAsChange"),ae=a(()=>{M(_())},"runOnce"),oe=a(()=>{x(ue(o?.args))},"prefillArgs");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[w!==null&&(0,e.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:w},void 0,!1),(0,e.jsxDEV)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)(v,{htmlFor:"function-select",children:s("Function")},void 0,!1),(0,e.jsxDEV)("select",{"aria-label":s("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:T,children:g.map(t=>(0,e.jsxDEV)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path,!0))},void 0,!1),o!==void 0&&(0,e.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsxDEV)("span",{className:"mr-1.5 font-medium",children:s("Signature")},void 0,!1),(0,e.jsxDEV)("code",{className:"font-mono","data-testid":"function-signature",children:le(o.args)},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxDEV)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxDEV)(v,{htmlFor:"args-input",children:s("Arguments")},void 0,!1),(0,e.jsxDEV)(p,{"data-testid":"prefill-button",disabled:o===void 0,onClick:oe,size:"xs",type:"button",variant:"ghost",children:s("Prefill")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(H,{"aria-label":s("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:f},void 0,!1)]},void 0,!0),(0,e.jsxDEV)(q,{onChange:k,testId:"shard-input",value:c},void 0,!1),i&&(0,e.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsxDEV)(v,{htmlFor:"run-as-input",children:s("Run as identity (userId)")},void 0,!1),(0,e.jsxDEV)(B,{"aria-label":s("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:se,placeholder:s("Leave empty to run as admin"),value:m},void 0,!1),(0,e.jsxDEV)("p",{className:"text-[11px] text-muted-foreground",children:s("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")},void 0,!1)]},void 0,!0),(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(p,{"data-testid":"run-button",disabled:b==="running"||o===void 0,onClick:ae,type:"button",children:s("Run")},void 0,!1),o!==void 0&&(0,e.jsxDEV)(S,{variant:"outline",children:o.kind},void 0,!1),i&&m.trim()!==""&&(0,e.jsxDEV)(S,{"data-testid":"run-as-badge",variant:"secondary",children:s("as {userId}",{userId:m.trim()})},void 0,!1)]},void 0,!0)]},void 0,!0),b==="error"&&A!==null&&(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:A},void 0,!1),b==="success"&&(0,e.jsxDEV)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(W)},void 0,!1),C.length>0&&(0,e.jsxDEV)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:C.map((t,d)=>(0,e.jsxDEV)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsxDEV)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"},void 0,!1)," ",(0,e.jsxDEV)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]},void 0,!0)," ",(0,e.jsxDEV)("time",{className:"text-xs text-muted-foreground",children:P(t.at)},void 0,!1)," ",(0,e.jsxDEV)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:a(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Load")},void 0,!1)]},t.id,!0))},void 0,!1)]},void 0,!0)},"FunctionRunner");export{Ae as FunctionRunner};
@@ -1 +1 @@
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};
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-MHGJUKCZ.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};
@@ -1,4 +1,4 @@
1
- import{b as Le}from"./chunk-CHNXZYAC.js";import"./chunk-V43BLH4J.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{c as Be}from"./chunk-IYHPYY4A.js";import{a as ye}from"./chunk-3GXGLNKW.js";import"./chunk-AHILM3ZP.js";import{a as Ke}from"./chunk-J6J54MBP.js";import"./chunk-WVTPZ6CM.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import{a as ze}from"./chunk-WOYQG5AM.js";import"./chunk-KEGAWN6Y.js";import{a as Fe,b as De,c as Re,d as de,e as le,f as ee}from"./chunk-GTM65MVX.js";import{a as Te,e as _e}from"./chunk-Y572GMZE.js";import"./chunk-4QHKBC77.js";import{a as $e}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as Ne}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as se}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as ie}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as be}from"./chunk-EBTLTGG3.js";import{f as we}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as me}from"./chunk-TAD43CG5.js";import{d as Ce,f as ge,g as pe,h as Q,l as H,n as Ee,o as ve}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as g,e as he,f as gt,g as pt,h as vt}from"./chunk-RRCPZMC2.js";var j=he(pt(),1),_=he(gt(),1);var l=he(vt(),1);var je=g((c,e,s)=>{let t=(0,j.c)(21),{onCopy:n,onDelete:o,onDownload:u,onToggleSelect:a}=s,r;t[0]!==c.key||t[1]!==n?(r=g(()=>{n(c.key)},"t0"),t[0]=c.key,t[1]=n,t[2]=r):r=t[2];let d=r,h;t[3]!==c.key||t[4]!==u?(h=g(()=>{u(c.key)},"t1"),t[3]=c.key,t[4]=u,t[5]=h):h=t[5];let f=h,m;t[6]!==c.key||t[7]!==o?(m=g(()=>{o(c.key)},"t2"),t[6]=c.key,t[7]=o,t[8]=m):m=t[8];let S=m,i;t[9]!==c.key||t[10]!==a?(i=g(()=>{a(c.key)},"t3"),t[9]=c.key,t[10]=a,t[11]=i):i=t[11];let x=i,y;t[12]!==c.key||t[13]!==e.length?(y=c.key.slice(e.length),t[12]=c.key,t[13]=e.length,t[14]=y):y=t[14];let v;return t[15]!==d||t[16]!==f||t[17]!==S||t[18]!==y||t[19]!==x?(v={copy:d,download:f,name:y,remove:S,toggle:x},t[15]=d,t[16]=f,t[17]=S,t[18]=y,t[19]=x,t[20]=v):v=t[20],v},"useFileItem"),Ue=g(c=>{let e=(0,j.c)(31),{busy:s,buttonClassName:t,copied:n,objectKey:o,onCopy:u,onDelete:a,onDownload:r,t:d}=c,h=`storage-copy-${o}`,f;e[0]!==n||e[1]!==d?(f=d(n?"Copied":"Copy URL"),e[0]=n,e[1]=d,e[2]=f):f=e[2];let m;e[3]!==s||e[4]!==t||e[5]!==u||e[6]!==h||e[7]!==f?(m=(0,l.jsxDEV)(se,{className:t,"data-testid":h,disabled:s,onClick:u,size:"sm",type:"button",variant:"ghost",children:f},void 0,!1),e[3]=s,e[4]=t,e[5]=u,e[6]=h,e[7]=f,e[8]=m):m=e[8];let S=`storage-download-${o}`,i;e[9]!==d?(i=d("Download"),e[9]=d,e[10]=i):i=e[10];let x;e[11]!==s||e[12]!==t||e[13]!==r||e[14]!==S||e[15]!==i?(x=(0,l.jsxDEV)(se,{className:t,"data-testid":S,disabled:s,onClick:r,size:"sm",type:"button",variant:"ghost",children:i},void 0,!1),e[11]=s,e[12]=t,e[13]=r,e[14]=S,e[15]=i,e[16]=x):x=e[16];let y;e[17]!==d?(y=d("Delete object?"),e[17]=d,e[18]=y):y=e[18];let v=`storage-delete-${o}`,b;e[19]!==d?(b=d("Delete"),e[19]=d,e[20]=b):b=e[20];let k;e[21]!==s||e[22]!==a||e[23]!==y||e[24]!==v||e[25]!==b?(k=(0,l.jsxDEV)(ze,{confirmLabel:y,disabled:s,onConfirm:a,testId:v,children:b},void 0,!1),e[21]=s,e[22]=a,e[23]=y,e[24]=v,e[25]=b,e[26]=k):k=e[26];let w;return e[27]!==k||e[28]!==m||e[29]!==x?(w=(0,l.jsxDEV)(l.Fragment,{children:[m,x,k]},void 0,!0),e[27]=k,e[28]=m,e[29]=x,e[30]=w):w=e[30],w},"FileActions"),Me=g(c=>{let e=(0,j.c)(14),{objectKey:s,references:t,t:n}=c;if(t===void 0)return null;if(t.length===0){let h=`storage-orphan-${s}`,f;e[0]!==n?(f=n("Orphan"),e[0]=n,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=(0,l.jsxDEV)(ie,{"data-testid":h,variant:"warning",children:f},void 0,!1),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let o;e[5]!==t?(o=t.map(bt).join(`
1
+ import{b as Le}from"./chunk-CHNXZYAC.js";import"./chunk-V43BLH4J.js";import"./chunk-APSSZB6Z.js";import"./chunk-QAFAJBAW.js";import{c as Be}from"./chunk-IYHPYY4A.js";import{a as ye}from"./chunk-3GXGLNKW.js";import"./chunk-AHILM3ZP.js";import{a as Ke}from"./chunk-J6J54MBP.js";import"./chunk-WVTPZ6CM.js";import"./chunk-SHERR7ZP.js";import"./chunk-5OIBXYZM.js";import"./chunk-L7SK4ZZD.js";import{a as ze}from"./chunk-WOYQG5AM.js";import"./chunk-KEGAWN6Y.js";import{a as Fe,b as De,c as Re,d as de,e as le,f as ee}from"./chunk-GTM65MVX.js";import{a as Te,e as _e}from"./chunk-Y572GMZE.js";import"./chunk-4QHKBC77.js";import{a as $e}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as Ne}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as se}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as ie}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as be}from"./chunk-MHGJUKCZ.js";import{f as we}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as me}from"./chunk-TAD43CG5.js";import{d as Ce,f as ge,g as pe,h as Q,l as H,n as Ee,o as ve}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as g,e as he,f as gt,g as pt,h as vt}from"./chunk-RRCPZMC2.js";var j=he(pt(),1),_=he(gt(),1);var l=he(vt(),1);var je=g((c,e,s)=>{let t=(0,j.c)(21),{onCopy:n,onDelete:o,onDownload:u,onToggleSelect:a}=s,r;t[0]!==c.key||t[1]!==n?(r=g(()=>{n(c.key)},"t0"),t[0]=c.key,t[1]=n,t[2]=r):r=t[2];let d=r,h;t[3]!==c.key||t[4]!==u?(h=g(()=>{u(c.key)},"t1"),t[3]=c.key,t[4]=u,t[5]=h):h=t[5];let f=h,m;t[6]!==c.key||t[7]!==o?(m=g(()=>{o(c.key)},"t2"),t[6]=c.key,t[7]=o,t[8]=m):m=t[8];let S=m,i;t[9]!==c.key||t[10]!==a?(i=g(()=>{a(c.key)},"t3"),t[9]=c.key,t[10]=a,t[11]=i):i=t[11];let x=i,y;t[12]!==c.key||t[13]!==e.length?(y=c.key.slice(e.length),t[12]=c.key,t[13]=e.length,t[14]=y):y=t[14];let v;return t[15]!==d||t[16]!==f||t[17]!==S||t[18]!==y||t[19]!==x?(v={copy:d,download:f,name:y,remove:S,toggle:x},t[15]=d,t[16]=f,t[17]=S,t[18]=y,t[19]=x,t[20]=v):v=t[20],v},"useFileItem"),Ue=g(c=>{let e=(0,j.c)(31),{busy:s,buttonClassName:t,copied:n,objectKey:o,onCopy:u,onDelete:a,onDownload:r,t:d}=c,h=`storage-copy-${o}`,f;e[0]!==n||e[1]!==d?(f=d(n?"Copied":"Copy URL"),e[0]=n,e[1]=d,e[2]=f):f=e[2];let m;e[3]!==s||e[4]!==t||e[5]!==u||e[6]!==h||e[7]!==f?(m=(0,l.jsxDEV)(se,{className:t,"data-testid":h,disabled:s,onClick:u,size:"sm",type:"button",variant:"ghost",children:f},void 0,!1),e[3]=s,e[4]=t,e[5]=u,e[6]=h,e[7]=f,e[8]=m):m=e[8];let S=`storage-download-${o}`,i;e[9]!==d?(i=d("Download"),e[9]=d,e[10]=i):i=e[10];let x;e[11]!==s||e[12]!==t||e[13]!==r||e[14]!==S||e[15]!==i?(x=(0,l.jsxDEV)(se,{className:t,"data-testid":S,disabled:s,onClick:r,size:"sm",type:"button",variant:"ghost",children:i},void 0,!1),e[11]=s,e[12]=t,e[13]=r,e[14]=S,e[15]=i,e[16]=x):x=e[16];let y;e[17]!==d?(y=d("Delete object?"),e[17]=d,e[18]=y):y=e[18];let v=`storage-delete-${o}`,b;e[19]!==d?(b=d("Delete"),e[19]=d,e[20]=b):b=e[20];let k;e[21]!==s||e[22]!==a||e[23]!==y||e[24]!==v||e[25]!==b?(k=(0,l.jsxDEV)(ze,{confirmLabel:y,disabled:s,onConfirm:a,testId:v,children:b},void 0,!1),e[21]=s,e[22]=a,e[23]=y,e[24]=v,e[25]=b,e[26]=k):k=e[26];let w;return e[27]!==k||e[28]!==m||e[29]!==x?(w=(0,l.jsxDEV)(l.Fragment,{children:[m,x,k]},void 0,!0),e[27]=k,e[28]=m,e[29]=x,e[30]=w):w=e[30],w},"FileActions"),Me=g(c=>{let e=(0,j.c)(14),{objectKey:s,references:t,t:n}=c;if(t===void 0)return null;if(t.length===0){let h=`storage-orphan-${s}`,f;e[0]!==n?(f=n("Orphan"),e[0]=n,e[1]=f):f=e[1];let m;return e[2]!==h||e[3]!==f?(m=(0,l.jsxDEV)(ie,{"data-testid":h,variant:"warning",children:f},void 0,!1),e[2]=h,e[3]=f,e[4]=m):m=e[4],m}let o;e[5]!==t?(o=t.map(bt).join(`
2
2
  `),e[5]=t,e[6]=o):o=e[6];let u=o,a=`storage-refs-${s}`,r;e[7]!==t.length||e[8]!==n?(r=t.length===1?n("1 record"):n("{count} records",{count:t.length}),e[7]=t.length,e[8]=n,e[9]=r):r=e[9];let d;return e[10]!==u||e[11]!==a||e[12]!==r?(d=(0,l.jsxDEV)(ie,{"data-testid":a,title:u,variant:"secondary",children:r},void 0,!1),e[10]=u,e[11]=a,e[12]=r,e[13]=d):d=e[13],d},"FileReferences"),Ge=g(c=>{let e=(0,j.c)(7),{objectKey:s,onToggle:t,selected:n,t:o}=c,u;e[0]!==o?(u=o("Select row"),e[0]=o,e[1]=u):u=e[1];let a=`storage-select-${s}`,r;return e[2]!==t||e[3]!==n||e[4]!==u||e[5]!==a?(r=(0,l.jsxDEV)(ye,{"aria-label":u,checked:n,"data-testid":a,onCheckedChange:t},void 0,!1),e[2]=t,e[3]=n,e[4]=u,e[5]=a,e[6]=r):r=e[6],r},"FileSelect");function bt(c){return`${c.table}\xB7${c.id}`}g(bt,"_temp$2");var yt=g(c=>{let e=(0,j.c)(10),{colSpan:s,name:t,onEnter:n}=c,o;e[0]!==t||e[1]!==n?(o=g(()=>{n(t)},"t1"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let u=o,a;e[3]===Symbol.for("react.memo_cache_sentinel")?(a=(0,l.jsxDEV)("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"},void 0,!1)},void 0,!1),e[3]=a):a=e[3];let r;e[4]!==u||e[5]!==t?(r=(0,l.jsxDEV)("button",{className:"inline-flex items-center gap-2 font-mono text-xs outline-none hover:text-foreground focus-visible:text-foreground","data-testid":"fb-folder",onClick:u,type:"button",children:[a,t]},void 0,!0),e[4]=u,e[5]=t,e[6]=r):r=e[6];let d;return e[7]!==s||e[8]!==r?(d=(0,l.jsxDEV)(de,{children:(0,l.jsxDEV)(ee,{colSpan:s,children:r},void 0,!1)},void 0,!1),e[7]=s,e[8]=r,e[9]=d):d=e[9],d},"FolderRow"),xt=g(c=>{let e=(0,j.c)(33),{busy:s,copiedKey:t,handlers:n,object:o,prefix:u,references:a,selected:r,showReferences:d,t:h}=c,{copy:f,download:m,name:S,remove:i,toggle:x}=je(o,u,n),y;e[0]!==o.key||e[1]!==r||e[2]!==h||e[3]!==x?(y=(0,l.jsxDEV)(ee,{className:"w-8",children:(0,l.jsxDEV)(Ge,{objectKey:o.key,onToggle:x,selected:r,t:h},void 0,!1)},void 0,!1),e[0]=o.key,e[1]=r,e[2]=h,e[3]=x,e[4]=y):y=e[4];let v;e[5]!==S?(v=(0,l.jsxDEV)(ee,{className:"font-mono text-xs",children:S},void 0,!1),e[5]=S,e[6]=v):v=e[6];let b;e[7]!==o.size?(b=ve(o.size),e[7]=o.size,e[8]=b):b=e[8];let k;e[9]!==b?(k=(0,l.jsxDEV)(ee,{className:"tabular-nums text-muted-foreground",children:b},void 0,!1),e[9]=b,e[10]=k):k=e[10];let w=o.httpMetadata?.contentType??"",T;e[11]!==w?(T=(0,l.jsxDEV)(ee,{children:w},void 0,!1),e[11]=w,e[12]=T):T=e[12];let C;e[13]!==o.key||e[14]!==a||e[15]!==d||e[16]!==h?(C=d&&(0,l.jsxDEV)(ee,{children:(0,l.jsxDEV)(Me,{objectKey:o.key,references:a,t:h},void 0,!1)},void 0,!1),e[13]=o.key,e[14]=a,e[15]=d,e[16]=h,e[17]=C):C=e[17];let N=t===o.key,E;e[18]!==s||e[19]!==f||e[20]!==m||e[21]!==o.key||e[22]!==i||e[23]!==h||e[24]!==N?(E=(0,l.jsxDEV)(ee,{className:"text-right",children:(0,l.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:(0,l.jsxDEV)(Ue,{busy:s,copied:N,objectKey:o.key,onCopy:f,onDelete:i,onDownload:m,t:h},void 0,!1)},void 0,!1)},void 0,!1),e[18]=s,e[19]=f,e[20]=m,e[21]=o.key,e[22]=i,e[23]=h,e[24]=N,e[25]=E):E=e[25];let F;return e[26]!==y||e[27]!==v||e[28]!==k||e[29]!==T||e[30]!==C||e[31]!==E?(F=(0,l.jsxDEV)(de,{"data-testid":"fb-row",children:[y,v,k,T,C,E]},void 0,!0),e[26]=y,e[27]=v,e[28]=k,e[29]=T,e[30]=C,e[31]=E,e[32]=F):F=e[32],F},"FileRow"),kt=g(c=>{let e=(0,j.c)(65),{allSelected:s,busy:t,copiedKey:n,files:o,folders:u,handlers:a,onEnterFolder:r,prefix:d,references:h,selected:f,showReferences:m,someSelected:S,t:i,toggleSelectAll:x}=c,y;e[0]!==i?(y=i("Select all rows"),e[0]=i,e[1]=y):y=e[1];let v;e[2]!==s||e[3]!==S||e[4]!==y||e[5]!==x?(v=(0,l.jsxDEV)(le,{className:"w-8",children:(0,l.jsxDEV)(ye,{"aria-label":y,checked:s,"data-testid":"storage-select-all",indeterminate:S,onCheckedChange:x},void 0,!1)},void 0,!1),e[2]=s,e[3]=S,e[4]=y,e[5]=x,e[6]=v):v=e[6];let b;e[7]!==i?(b=i("key"),e[7]=i,e[8]=b):b=e[8];let k;e[9]!==b?(k=(0,l.jsxDEV)(le,{children:b},void 0,!1),e[9]=b,e[10]=k):k=e[10];let w;e[11]!==i?(w=i("size"),e[11]=i,e[12]=w):w=e[12];let T;e[13]!==w?(T=(0,l.jsxDEV)(le,{children:w},void 0,!1),e[13]=w,e[14]=T):T=e[14];let C;e[15]!==i?(C=i("content-type"),e[15]=i,e[16]=C):C=e[16];let N;e[17]!==C?(N=(0,l.jsxDEV)(le,{children:C},void 0,!1),e[17]=C,e[18]=N):N=e[18];let E;e[19]!==m||e[20]!==i?(E=m&&(0,l.jsxDEV)(le,{children:i("used by")},void 0,!1),e[19]=m,e[20]=i,e[21]=E):E=e[21];let F;e[22]!==i?(F=i("Actions"),e[22]=i,e[23]=F):F=e[23];let R;e[24]!==F?(R=(0,l.jsxDEV)(le,{"aria-label":F},void 0,!1),e[24]=F,e[25]=R):R=e[25];let D;e[26]!==R||e[27]!==v||e[28]!==k||e[29]!==T||e[30]!==N||e[31]!==E?(D=(0,l.jsxDEV)(De,{children:(0,l.jsxDEV)(de,{children:[v,k,T,N,E,R]},void 0,!0)},void 0,!1),e[26]=R,e[27]=v,e[28]=k,e[29]=T,e[30]=N,e[31]=E,e[32]=D):D=e[32];let B;if(e[33]!==u||e[34]!==r||e[35]!==m){let z;e[37]!==r||e[38]!==m?(z=g(L=>(0,l.jsxDEV)(yt,{colSpan:m?6:5,name:L,onEnter:r},L,!1),"t142"),e[37]=r,e[38]=m,e[39]=z):z=e[39],B=u.map(z),e[33]=u,e[34]=r,e[35]=m,e[36]=B}else B=e[36];let I;if(e[40]!==t||e[41]!==n||e[42]!==o||e[43]!==a||e[44]!==d||e[45]!==h||e[46]!==f||e[47]!==m||e[48]!==i){let z;e[50]!==t||e[51]!==n||e[52]!==a||e[53]!==d||e[54]!==h||e[55]!==f||e[56]!==m||e[57]!==i?(z=g(L=>(0,l.jsxDEV)(xt,{busy:t,copiedKey:n,handlers:a,object:L,prefix:d,references:h[L.key],selected:f.has(L.key),showReferences:m,t:i},L.key,!1),"t152"),e[50]=t,e[51]=n,e[52]=a,e[53]=d,e[54]=h,e[55]=f,e[56]=m,e[57]=i,e[58]=z):z=e[58],I=o.map(z),e[40]=t,e[41]=n,e[42]=o,e[43]=a,e[44]=d,e[45]=h,e[46]=f,e[47]=m,e[48]=i,e[49]=I}else I=e[49];let K;e[59]!==B||e[60]!==I?(K=(0,l.jsxDEV)(Re,{children:[B,I]},void 0,!0),e[59]=B,e[60]=I,e[61]=K):K=e[61];let A;return e[62]!==D||e[63]!==K?(A=(0,l.jsxDEV)(Te,{className:"overflow-hidden py-0",children:(0,l.jsxDEV)(_e,{className:"px-0",children:(0,l.jsxDEV)(Fe,{"data-testid":"fb-table",children:[D,K]},void 0,!0)},void 0,!1)},void 0,!1),e[62]=D,e[63]=K,e[64]=A):A=e[64],A},"FileBrowserList"),St=[{label:"15m",seconds:900},{label:"1h",seconds:3600},{label:"24h",seconds:86400},{label:"7d",seconds:604800}],wt=3600,Ie=g((c,e)=>{if(e==="size")return c.size;if(e==="type")return c.httpMetadata?.contentType??"";if(e==="date"){if(c.uploaded===void 0)return 0;let s=new Date(c.uploaded).getTime();return Number.isNaN(s)?0:s}return e.startsWith("tag:")?c.customMetadata?.[e.slice(4)]??"":c.key},"fileSortValue"),Ct=g((c,e,s)=>{let t=s==="desc"?-1:1;return c.toSorted((n,o)=>{let u=Ie(n,e),a=Ie(o,e);return(typeof u=="number"&&typeof a=="number"?u-a:String(u).localeCompare(String(a)))*t})},"sortFiles"),Nt=g((c,e)=>{let s=new Set,t=[];for(let n of c){let o=n.key.slice(e.length),u=o.indexOf("/");u===-1?t.push(n):s.add(o.slice(0,u+1))}return{files:t,folders:[...s].toSorted((n,o)=>n.localeCompare(o))}},"deriveEntries"),Tt=g(c=>{let e=(0,j.c)(59),{bucket:s,buckets:t,busy:n,draftPrefix:o,expiry:u,fileInputRef:a,onBucketChange:r,onExpiryChange:d,onFileChange:h,onList:f,onPrefixChange:m,onUploadClick:S,t:i}=c,x;e[0]!==m?(x=g(G=>{m(G.target.value)},"t1"),e[0]=m,e[1]=x):x=e[1];let y=x,v;e[2]!==r?(v=g(G=>{r(G.target.value)},"t2"),e[2]=r,e[3]=v):v=e[3];let b=v,k;e[4]!==d?(k=g(G=>{d(Number.parseInt(G.target.value,10))},"t3"),e[4]=d,e[5]=k):k=e[5];let w=k,T;e[6]!==s||e[7]!==t||e[8]!==b||e[9]!==i?(T=t.length>0&&(0,l.jsxDEV)("select",{"aria-label":i("Bucket"),className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-bucket",onChange:b,value:s,children:t.map(Et)},void 0,!1),e[6]=s,e[7]=t,e[8]=b,e[9]=i,e[10]=T):T=e[10];let C;e[11]!==i?(C=i("Key prefix"),e[11]=i,e[12]=C):C=e[12];let N;e[13]!==i?(N=i("key prefix (optional)"),e[13]=i,e[14]=N):N=e[14];let E;e[15]!==o||e[16]!==y||e[17]!==C||e[18]!==N?(E=(0,l.jsxDEV)(Ne,{"aria-label":C,className:"h-8 w-64 max-w-full","data-testid":"fb-prefix-input",onChange:y,placeholder:N,value:o},void 0,!1),e[15]=o,e[16]=y,e[17]=C,e[18]=N,e[19]=E):E=e[19];let F;e[20]!==i?(F=i("List"),e[20]=i,e[21]=F):F=e[21];let R;e[22]!==n||e[23]!==f||e[24]!==F?(R=(0,l.jsxDEV)(se,{"data-testid":"fb-list",disabled:n,onClick:f,size:"sm",type:"button",children:F},void 0,!1),e[22]=n,e[23]=f,e[24]=F,e[25]=R):R=e[25];let D;e[26]!==n||e[27]!==i?(D=i(n?"Uploading\u2026":"Upload"),e[26]=n,e[27]=i,e[28]=D):D=e[28];let B;e[29]!==n||e[30]!==S||e[31]!==D?(B=(0,l.jsxDEV)(se,{"data-testid":"storage-upload",disabled:n,onClick:S,size:"sm",type:"button",variant:"outline",children:D},void 0,!1),e[29]=n,e[30]=S,e[31]=D,e[32]=B):B=e[32];let I;e[33]!==a||e[34]!==h?(I=(0,l.jsxDEV)("input",{className:"hidden","data-testid":"storage-file-input",onChange:h,ref:a,type:"file"},void 0,!1),e[33]=a,e[34]=h,e[35]=I):I=e[35];let K;e[36]!==i?(K=i("Link expiry"),e[36]=i,e[37]=K):K=e[37];let A;e[38]!==i?(A=St.map(G=>(0,l.jsxDEV)("option",{value:G.seconds,children:i(G.label)},G.seconds,!1)),e[38]=i,e[39]=A):A=e[39];let z;e[40]!==u||e[41]!==w||e[42]!==A?(z=(0,l.jsxDEV)("select",{className:"h-8 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":"storage-expiry",id:"storage-expiry",onChange:w,value:u,children:A},void 0,!1),e[40]=u,e[41]=w,e[42]=A,e[43]=z):z=e[43];let L;e[44]!==K||e[45]!==z?(L=(0,l.jsxDEV)("label",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"storage-expiry",children:[K,z]},void 0,!0),e[44]=K,e[45]=z,e[46]=L):L=e[46];let U;e[47]!==i?(U=i("Open in Cloudflare"),e[47]=i,e[48]=U):U=e[48];let M;e[49]!==U?(M=(0,l.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"fb-cf-link",href:Be,rel:"noreferrer",target:"_blank",children:U},void 0,!1),e[49]=U,e[50]=M):M=e[50];let P;return e[51]!==B||e[52]!==I||e[53]!==L||e[54]!==M||e[55]!==T||e[56]!==E||e[57]!==R?(P=(0,l.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[T,E,R,B,I,L,M]},void 0,!0),e[51]=B,e[52]=I,e[53]=L,e[54]=M,e[55]=T,e[56]=E,e[57]=R,e[58]=P):P=e[58],P},"FileBrowserToolbar"),_t=g(c=>{let e=(0,j.c)(66),{onSortKeyChange:s,onThumbSizeChange:t,showGrid:n,showList:o,sortDirection:u,sortKey:a,t:r,tagKeys:d,thumbSize:h,toggleSortDirection:f,view:m}=c,S;e[0]!==s?(S=g(W=>{s(W.target.value)},"t1"),e[0]=s,e[1]=S):S=e[1];let i=S,x;e[2]!==t?(x=g(W=>{t(Number.parseInt(W.target.value,10))},"t2"),e[2]=t,e[3]=x):x=e[3];let y=x,v=m==="list",b;e[4]!==r?(b=r("List"),e[4]=r,e[5]=b):b=e[5];let k;e[6]!==o||e[7]!==v||e[8]!==b?(k=(0,l.jsxDEV)("button",{"aria-pressed":v,className:"px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-list",onClick:o,type:"button",children:b},void 0,!1),e[6]=o,e[7]=v,e[8]=b,e[9]=k):k=e[9];let w=m==="grid",T;e[10]!==r?(T=r("Grid"),e[10]=r,e[11]=T):T=e[11];let C;e[12]!==n||e[13]!==w||e[14]!==T?(C=(0,l.jsxDEV)("button",{"aria-pressed":w,className:"border-s border-border px-2 py-1 outline-none transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-testid":"fb-view-grid",onClick:n,type:"button",children:T},void 0,!1),e[12]=n,e[13]=w,e[14]=T,e[15]=C):C=e[15];let N;e[16]!==k||e[17]!==C?(N=(0,l.jsxDEV)("div",{className:"inline-flex overflow-hidden rounded-md border border-border",children:[k,C]},void 0,!0),e[16]=k,e[17]=C,e[18]=N):N=e[18];let E;e[19]!==r?(E=r("Sort"),e[19]=r,e[20]=E):E=e[20];let F;e[21]!==r?(F=r("Name"),e[21]=r,e[22]=F):F=e[22];let R;e[23]!==F?(R=(0,l.jsxDEV)("option",{value:"name",children:F},void 0,!1),e[23]=F,e[24]=R):R=e[24];let D;e[25]!==r?(D=r("size"),e[25]=r,e[26]=D):D=e[26];let B;e[27]!==D?(B=(0,l.jsxDEV)("option",{value:"size",children:D},void 0,!1),e[27]=D,e[28]=B):B=e[28];let I;e[29]!==r?(I=r("Type"),e[29]=r,e[30]=I):I=e[30];let K;e[31]!==I?(K=(0,l.jsxDEV)("option",{value:"type",children:I},void 0,!1),e[31]=I,e[32]=K):K=e[32];let A;e[33]!==r?(A=r("Modified"),e[33]=r,e[34]=A):A=e[34];let z;e[35]!==A?(z=(0,l.jsxDEV)("option",{value:"date",children:A},void 0,!1),e[35]=A,e[36]=z):z=e[36];let L;e[37]!==d?(L=d.map($t),e[37]=d,e[38]=L):L=e[38];let U;e[39]!==i||e[40]!==a||e[41]!==R||e[42]!==B||e[43]!==K||e[44]!==z||e[45]!==L?(U=(0,l.jsxDEV)("select",{className:"h-8 rounded-md border border-border bg-background px-1 outline-none focus-visible:border-ring","data-testid":"fb-sort",id:"fb-sort",onChange:i,value:a,children:[R,B,K,z,L]},void 0,!0),e[39]=i,e[40]=a,e[41]=R,e[42]=B,e[43]=K,e[44]=z,e[45]=L,e[46]=U):U=e[46];let M;e[47]!==E||e[48]!==U?(M=(0,l.jsxDEV)("label",{className:"flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-sort",children:[E,U]},void 0,!0),e[47]=E,e[48]=U,e[49]=M):M=e[49];let P;e[50]!==r?(P=r("Toggle sort direction"),e[50]=r,e[51]=P):P=e[51];let G=u==="asc"?"\u2191":"\u2193",q;e[52]!==P||e[53]!==G||e[54]!==f?(q=(0,l.jsxDEV)("button",{"aria-label":P,className:"flex size-8 items-center justify-center rounded-md border border-border tabular-nums outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"fb-sort-dir",onClick:f,type:"button",children:G},void 0,!1),e[52]=P,e[53]=G,e[54]=f,e[55]=q):q=e[55];let Y;e[56]!==y||e[57]!==r||e[58]!==h||e[59]!==m?(Y=m==="grid"&&(0,l.jsxDEV)("label",{className:"ml-auto flex items-center gap-1.5 text-muted-foreground",htmlFor:"fb-thumb-size",children:[r("Thumbnail size"),(0,l.jsxDEV)("input",{className:"accent-primary","data-testid":"fb-thumb-size",id:"fb-thumb-size",max:240,min:80,onChange:y,step:8,type:"range",value:h},void 0,!1)]},void 0,!0),e[56]=y,e[57]=r,e[58]=h,e[59]=m,e[60]=Y):Y=e[60];let oe;return e[61]!==M||e[62]!==q||e[63]!==Y||e[64]!==N?(oe=(0,l.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2 text-xs","data-testid":"fb-controls",children:[N,M,q,Y]},void 0,!0),e[61]=M,e[62]=q,e[63]=Y,e[64]=N,e[65]=oe):oe=e[65],oe},"FileBrowserControls");function Et(c){return(0,l.jsxDEV)("option",{value:c,children:c},c,!1)}g(Et,"_temp$1");function $t(c){return(0,l.jsxDEV)("option",{value:`tag:${c}`,children:c},c,!1)}g($t,"_temp2");var Ft=/\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/iu,Dt=g(c=>(c.httpMetadata?.contentType??"").startsWith("image/")||Ft.test(c.key),"isImage"),Rt=g(()=>{let c=(0,j.c)(1),e;return c[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,l.jsxDEV)("svg",{"aria-hidden":"true",className:"size-8 text-muted-foreground/60",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M7 3h7l5 5v13a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Zm7 0v5h5"},void 0,!1)},void 0,!1),c[0]=e):e=c[0],e},"FileGlyph"),zt=g(c=>{let e=(0,j.c)(13),{object:s,resolveUrl:t}=c,[n,o]=(0,_.useState)(null),[u,a]=(0,_.useState)(!1),r;e[0]!==s?(r=Dt(s),e[0]=s,e[1]=r):r=e[1];let d=r,h,f;e[2]!==d||e[3]!==s.key||e[4]!==t?(h=g(()=>{if(!d)return;let x={cancelled:!1};return H((async()=>{try{let y=await t(s.key);x.cancelled||o(y)}catch{x.cancelled||a(!0)}})()),()=>{x.cancelled=!0}},"t2"),f=[d,s.key,t],e[2]=d,e[3]=s.key,e[4]=t,e[5]=h,e[6]=f):(h=e[5],f=e[6]),(0,_.useEffect)(h,f);let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=g(()=>{a(!0)},"t4"),e[7]=m):m=e[7];let S=m,i;return e[8]!==u||e[9]!==d||e[10]!==s.key||e[11]!==n?(i=(0,l.jsxDEV)("div",{className:"flex aspect-square w-full items-center justify-center overflow-hidden rounded-md border border-border bg-muted/30",children:d&&n!==null&&!u?(0,l.jsxDEV)("img",{alt:s.key,className:"size-full object-cover",loading:"lazy",onError:S,src:n},void 0,!1):(0,l.jsxDEV)(Rt,{},void 0,!1)},void 0,!1),e[8]=u,e[9]=d,e[10]=s.key,e[11]=n,e[12]=i):i=e[12],i},"Thumbnail"),Kt=g(c=>{let e=(0,j.c)(38),{busy:s,copiedKey:t,handlers:n,object:o,prefix:u,references:a,resolveUrl:r,selected:d,showReferences:h,t:f}=c,{copy:m,download:S,name:i,remove:x,toggle:y}=je(o,u,n),v;e[0]!==o||e[1]!==r?(v=(0,l.jsxDEV)(zt,{object:o,resolveUrl:r},void 0,!1),e[0]=o,e[1]=r,e[2]=v):v=e[2];let b;e[3]!==o.key||e[4]!==d||e[5]!==f||e[6]!==y?(b=(0,l.jsxDEV)("span",{className:"absolute left-1.5 top-1.5 rounded bg-background/80 p-0.5",children:(0,l.jsxDEV)(Ge,{objectKey:o.key,onToggle:y,selected:d,t:f},void 0,!1)},void 0,!1),e[3]=o.key,e[4]=d,e[5]=f,e[6]=y,e[7]=b):b=e[7];let k;e[8]!==v||e[9]!==b?(k=(0,l.jsxDEV)("div",{className:"relative",children:[v,b]},void 0,!0),e[8]=v,e[9]=b,e[10]=k):k=e[10];let w;e[11]!==i?(w=(0,l.jsxDEV)("p",{className:"truncate font-mono text-xs",title:i,children:i},void 0,!1),e[11]=i,e[12]=w):w=e[12];let T;e[13]!==o.size?(T=ve(o.size),e[13]=o.size,e[14]=T):T=e[14];let C;e[15]!==T?(C=(0,l.jsxDEV)("p",{className:"text-[11px] tabular-nums text-muted-foreground",children:T},void 0,!1),e[15]=T,e[16]=C):C=e[16];let N;e[17]!==o.key||e[18]!==a||e[19]!==h||e[20]!==f?(N=h&&(0,l.jsxDEV)("div",{className:"mt-1",children:(0,l.jsxDEV)(Me,{objectKey:o.key,references:a,t:f},void 0,!1)},void 0,!1),e[17]=o.key,e[18]=a,e[19]=h,e[20]=f,e[21]=N):N=e[21];let E;e[22]!==w||e[23]!==C||e[24]!==N?(E=(0,l.jsxDEV)("div",{className:"min-w-0",children:[w,C,N]},void 0,!0),e[22]=w,e[23]=C,e[24]=N,e[25]=E):E=e[25];let F=t===o.key,R;e[26]!==s||e[27]!==m||e[28]!==S||e[29]!==o.key||e[30]!==x||e[31]!==f||e[32]!==F?(R=(0,l.jsxDEV)("div",{className:"flex items-center gap-1",children:(0,l.jsxDEV)(Ue,{busy:s,buttonClassName:"h-7 px-2 text-xs",copied:F,objectKey:o.key,onCopy:m,onDelete:x,onDownload:S,t:f},void 0,!1)},void 0,!1),e[26]=s,e[27]=m,e[28]=S,e[29]=o.key,e[30]=x,e[31]=f,e[32]=F,e[33]=R):R=e[33];let D;return e[34]!==R||e[35]!==k||e[36]!==E?(D=(0,l.jsxDEV)("div",{className:"flex flex-col gap-1.5","data-testid":"fb-tile",children:[k,E,R]},void 0,!0),e[34]=R,e[35]=k,e[36]=E,e[37]=D):D=e[37],D},"GalleryTile"),Lt=g(c=>{let e=(0,j.c)(9),{name:s,onEnter:t}=c,n;e[0]!==s||e[1]!==t?(n=g(()=>{t(s)},"t1"),e[0]=s,e[1]=t,e[2]=n):n=e[2];let o=n,u;e[3]===Symbol.for("react.memo_cache_sentinel")?(u=(0,l.jsxDEV)("span",{className:"flex aspect-square w-full items-center justify-center rounded-md border border-border bg-muted/30 transition-colors hover:bg-accent",children:(0,l.jsxDEV)("svg",{"aria-hidden":"true",className:"size-10 text-muted-foreground",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.4,viewBox:"0 0 24 24",children:(0,l.jsxDEV)("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"},void 0,!1)},void 0,!1)},void 0,!1),e[3]=u):u=e[3];let a;e[4]!==s?(a=(0,l.jsxDEV)("span",{className:"truncate font-mono text-xs",title:s,children:s},void 0,!1),e[4]=s,e[5]=a):a=e[5];let r;return e[6]!==o||e[7]!==a?(r=(0,l.jsxDEV)("button",{className:"flex flex-col gap-1.5 text-left outline-none","data-testid":"fb-folder",onClick:o,type:"button",children:[u,a]},void 0,!0),e[6]=o,e[7]=a,e[8]=r):r=e[8],r},"FolderTile"),Bt=g(c=>{let e=(0,j.c)(34),{busy:s,copiedKey:t,files:n,folders:o,handlers:u,onEnterFolder:a,prefix:r,references:d,resolveUrl:h,selected:f,showReferences:m,size:S,t:i}=c,x;e[0]!==S?(x=S.toString(),e[0]=S,e[1]=x):x=e[1];let y=`repeat(auto-fill, minmax(${x}px, 1fr))`,v;e[2]!==y?(v={gridTemplateColumns:y},e[2]=y,e[3]=v):v=e[3];let b=v,k;if(e[4]!==o||e[5]!==a){let C;e[7]!==a?(C=g(N=>(0,l.jsxDEV)(Lt,{name:N,onEnter:a},N,!1),"t52"),e[7]=a,e[8]=C):C=e[8],k=o.map(C),e[4]=o,e[5]=a,e[6]=k}else k=e[6];let w;if(e[9]!==s||e[10]!==t||e[11]!==n||e[12]!==u||e[13]!==r||e[14]!==d||e[15]!==h||e[16]!==f||e[17]!==m||e[18]!==i){let C;e[20]!==s||e[21]!==t||e[22]!==u||e[23]!==r||e[24]!==d||e[25]!==h||e[26]!==f||e[27]!==m||e[28]!==i?(C=g(N=>(0,l.jsxDEV)(Kt,{busy:s,copiedKey:t,handlers:u,object:N,prefix:r,references:d[N.key],resolveUrl:h,selected:f.has(N.key),showReferences:m,t:i},N.key,!1),"t62"),e[20]=s,e[21]=t,e[22]=u,e[23]=r,e[24]=d,e[25]=h,e[26]=f,e[27]=m,e[28]=i,e[29]=C):C=e[29],w=n.map(C),e[9]=s,e[10]=t,e[11]=n,e[12]=u,e[13]=r,e[14]=d,e[15]=h,e[16]=f,e[17]=m,e[18]=i,e[19]=w}else w=e[19];let T;return e[30]!==b||e[31]!==k||e[32]!==w?(T=(0,l.jsxDEV)("div",{className:"grid gap-4","data-testid":"fb-gallery",style:b,children:[k,w]},void 0,!0),e[30]=b,e[31]=k,e[32]=w,e[33]=T):T=e[33],T},"FileGallery"),It=g(c=>{let e=(0,j.c)(23),{reference:s,t}=c,n=`fb-dangling-${s.table}-${s.id}-${s.column}`,o=`${s.table}\xB7${s.id}`,u;e[0]!==o?(u=(0,l.jsxDEV)(ie,{variant:"secondary",children:o},void 0,!1),e[0]=o,e[1]=u):u=e[1];let a;e[2]!==s.column?(a=(0,l.jsxDEV)("span",{className:"text-muted-foreground",children:s.column},void 0,!1),e[2]=s.column,e[3]=a):a=e[3];let r;e[4]!==t?(r=t("\u2192"),e[4]=t,e[5]=r):r=e[5];let d;e[6]!==r?(d=(0,l.jsxDEV)("span",{className:"text-muted-foreground/60",children:r},void 0,!1),e[6]=r,e[7]=d):d=e[7];let h;e[8]!==s.key?(h=(0,l.jsxDEV)("code",{className:"rounded bg-muted px-1 py-0.5 font-mono text-foreground",children:s.key},void 0,!1),e[8]=s.key,e[9]=h):h=e[9];let f;e[10]!==u||e[11]!==a||e[12]!==d||e[13]!==h?(f=(0,l.jsxDEV)("span",{className:"flex flex-wrap items-center gap-1.5",children:[u,a,d,h]},void 0,!0),e[10]=u,e[11]=a,e[12]=d,e[13]=h,e[14]=f):f=e[14];let m;e[15]!==t?(m=t("Missing object"),e[15]=t,e[16]=m):m=e[16];let S;e[17]!==m?(S=(0,l.jsxDEV)(ie,{className:"border-destructive/40 text-destructive",variant:"outline",children:m},void 0,!1),e[17]=m,e[18]=S):S=e[18];let i;return e[19]!==n||e[20]!==S||e[21]!==f?(i=(0,l.jsxDEV)("li",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-border/60 px-3 py-2 text-xs","data-testid":n,children:[f,S]},void 0,!0),e[19]=n,e[20]=S,e[21]=f,e[22]=i):i=e[22],i},"DanglingRow"),Ot=g(c=>{let e=(0,j.c)(37),{busy:s,onCheck:t,references:n,t:o,truncated:u}=c,a;e[0]!==o?(a=o("Integrity"),e[0]=o,e[1]=a):a=e[1];let r;e[2]!==a?(r=(0,l.jsxDEV)("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=r):r=e[3];let d;e[4]!==o?(d=o("Orphaned objects"),e[4]=o,e[5]=d):d=e[5];let h;e[6]!==d?(h=(0,l.jsxDEV)("span",{className:"text-sm font-medium text-foreground",children:d},void 0,!1),e[6]=d,e[7]=h):h=e[7];let f;e[8]!==o?(f=o("Find records whose file reference points at an object the bucket no longer has."),e[8]=o,e[9]=f):f=e[9];let m;e[10]!==f?(m=(0,l.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:f},void 0,!1),e[10]=f,e[11]=m):m=e[11];let S;e[12]!==r||e[13]!==h||e[14]!==m?(S=(0,l.jsxDEV)("div",{className:"flex flex-col gap-1",children:[r,h,m]},void 0,!0),e[12]=r,e[13]=h,e[14]=m,e[15]=S):S=e[15];let i;e[16]!==s||e[17]!==o?(i=o(s?"Checking\u2026":"Check for orphans"),e[16]=s,e[17]=o,e[18]=i):i=e[18];let x;e[19]!==s||e[20]!==t||e[21]!==i?(x=(0,l.jsxDEV)(se,{"data-testid":"fb-orphans-check",disabled:s,onClick:t,size:"sm",type:"button",variant:"outline",children:i},void 0,!1),e[19]=s,e[20]=t,e[21]=i,e[22]=x):x=e[22];let y;e[23]!==S||e[24]!==x?(y=(0,l.jsxDEV)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[S,x]},void 0,!0),e[23]=S,e[24]=x,e[25]=y):y=e[25];let v;e[26]!==n?.length||e[27]!==o?(v=n?.length===0&&(0,l.jsxDEV)(me,{description:o("Every record's file reference points at an object that exists in the bucket."),testId:"fb-orphans-empty",title:o("No dangling references.")},void 0,!1),e[26]=n?.length,e[27]=o,e[28]=v):v=e[28];let b;e[29]!==n||e[30]!==o||e[31]!==u?(b=n!==void 0&&n.length>0&&(0,l.jsxDEV)(l.Fragment,{children:[u&&(0,l.jsxDEV)("p",{className:"text-xs text-warning","data-testid":"fb-orphans-truncated",children:o("Showing the first {count} dangling references \u2014 the scan was truncated.",{count:n.length})},void 0,!1),(0,l.jsxDEV)("ul",{className:"flex flex-col gap-1.5","data-testid":"fb-orphans-list",children:n.map(w=>(0,l.jsxDEV)(It,{reference:w,t:o},`${w.table}\xB7${w.id}\xB7${w.column}`,!1))},void 0,!1)]},void 0,!0),e[29]=n,e[30]=o,e[31]=u,e[32]=b):b=e[32];let k;return e[33]!==y||e[34]!==v||e[35]!==b?(k=(0,l.jsxDEV)("section",{className:"flex flex-col gap-2 rounded-lg border border-border/60 p-3","data-testid":"fb-orphans",children:[y,v,b]},void 0,!0),e[33]=y,e[34]=v,e[35]=b,e[36]=k):k=e[36],k},"OrphanedObjectsSection"),At=g(function(c,e){let s=(0,j.c)(18),t;s[0]===Symbol.for("react.memo_cache_sentinel")?(t=new Set,s[0]=t):t=s[0];let[n,o]=(0,_.useState)(t),u;s[1]===Symbol.for("react.memo_cache_sentinel")?(u=g(v=>{o(b=>{let k=new Set(b);return k.has(v)?k.delete(v):k.add(v),k})},"t1"),s[1]=u):u=s[1];let a=u,r;s[2]===Symbol.for("react.memo_cache_sentinel")?(r=g(()=>{o(new Set)},"t2"),s[2]=r):r=s[2];let d=r,h,f,m;if(s[3]!==c||s[4]!==e||s[5]!==n){let v;s[9]!==e?(v=g(b=>e(b),"t42"),s[9]=e,s[10]=v):v=s[10],f=c.map(v),h=f.length>0&&f.every(b=>n.has(b)),m=!h&&f.some(b=>n.has(b)),s[3]=c,s[4]=e,s[5]=n,s[6]=h,s[7]=f,s[8]=m}else h=s[6],f=s[7],m=s[8];let S=m,i;s[11]!==f?(i=g(()=>{o(v=>f.every(b=>v.has(b))?new Set:new Set(f))},"t4"),s[11]=f,s[12]=i):i=s[12];let x=i,y;return s[13]!==h||s[14]!==n||s[15]!==S||s[16]!==x?(y={allSelected:h,clear:d,selected:n,someSelected:S,toggle:a,toggleAll:x},s[13]=h,s[14]=n,s[15]=S,s[16]=x,s[17]=y):y=s[17],y},"useKeySelection"),jt=ge(be.storageReferences),Ut=ge(be.storageOrphans),Oe=1e4,Mt=1e3,Gt=3600,Ht=g((c,e)=>{if(!("document"in globalThis))return;let s=globalThis.document.createElement("a");s.href=c,s.download=e,s.rel="noopener",globalThis.document.body.append(s),s.click(),s.remove()},"triggerDownload"),Pt=g(({initialPrefix:c,pageSize:e})=>{let s=we(),[t,n]=(0,_.useState)(c??""),[o,u]=(0,_.useState)(c??""),[a,r]=(0,_.useState)(wt),[d,h]=(0,_.useState)("list"),[f,m]=(0,_.useState)(128),[S,i]=(0,_.useState)("name"),[x,y]=(0,_.useState)("asc"),[v,b]=(0,_.useState)(void 0),[k,w]=(0,_.useState)(void 0),[T,C]=(0,_.useState)(!1),[N,E]=(0,_.useState)(void 0),[F,R]=(0,_.useState)(void 0),[D,B]=(0,_.useState)(""),[I,K]=(0,_.useState)({}),[A,z]=(0,_.useState)(!1),[L,U]=(0,_.useState)(void 0),[M,P]=(0,_.useState)(!1),[G,q]=(0,_.useState)(!1),[Y,oe]=(0,_.useState)([]),[W,xe]=(0,_.useState)(""),re=(0,_.useRef)(0),J=(0,_.useRef)(0);(0,_.useEffect)(()=>{let p={cancelled:!1};return H((async()=>{try{let $=await s.listStorageBuckets();if(!p.cancelled){oe($);let[O]=$;O!==void 0&&xe(te=>te===""?O:te)}}catch{}})()),()=>{p.cancelled=!0}},[s]);let Z=(0,_.useMemo)(()=>({list:g(p=>s.listStorageObjects({...p,bucket:W}),"list"),remove:g(p=>s.deleteStorageObject(p,{bucket:W}),"remove"),signedUrl:g((p,$)=>s.signedStorageUrl(p,{...$,bucket:W}),"signedUrl"),upload:g(p=>s.uploadStorageObject({...p,bucket:W}),"upload")}),[W,s]),X=(0,_.useCallback)(async(p,$,O)=>{re.current+=1;let te=re.current;w(void 0),C(!0);try{let V=await Z.list({cursor:$,limit:e,prefix:p});if(te!==re.current)return;b(ce=>O&&ce!==void 0?[...ce,...V.objects]:V.objects),R(V.cursor)}catch(V){if(te!==re.current)return;O||b(void 0),w(Q(V))}finally{te===re.current&&C(!1)}},[e,Z]);(0,_.useEffect)(()=>{H(X(c??"",void 0,!1))},[X,c]);let He=(v?.length??0)<=e;Ke(()=>{H(X(t,void 0,!1))},He);let{files:fe,folders:Pe}=Nt(v??[],t),qe=(0,_.useMemo)(()=>{let p=new Set;for(let $ of fe)for(let O of Object.keys($.customMetadata??{}))p.add(O);return[...p].toSorted(($,O)=>$.localeCompare(O))},[fe]),ae=Ct(fe,S,x),ue=(0,_.useMemo)(()=>[...new Set(ae.map(p=>p.key))].toSorted((p,$)=>p.localeCompare($)).join(`
3
3
  `),[ae]);(0,_.useEffect)(()=>{let p=ue===""?[]:ue.split(`
4
4
  `);if(p.length===0){K({});return}let $={current:!0};return H((async()=>{try{let O=await s.query(jt,{keys:p},pe(D));$.current&&(K(O.references??{}),z(Object.keys(O.storageColumns??{}).length>0))}catch{$.current&&(K({}),z(!1))}})()),()=>{$.current=!1}},[s,ue,D]);let Ve=g(p=>p.key,"keyOf"),{allSelected:We,clear:ne,selected:ke,someSelected:Ze,toggle:Xe,toggleAll:Ye}=At(ae,Ve),Je=g(()=>{n(o),ne(),H(X(o,void 0,!1))},"listFirst"),Qe=g(()=>{H(X(t,F,!0))},"loadMore"),Se=g(p=>{n(p),u(p),ne(),H(X(p,void 0,!1))},"navigate"),et=g(p=>{Se(`${t}${p}`)},"enterFolder"),tt=g(p=>Z.signedUrl(p,{expiresInSeconds:Gt}),"resolveUrl"),st=g(()=>{h("list")},"showList"),lt=g(()=>{h("grid")},"showGrid"),ot=g(p=>{i(p)},"onSortKeyChange"),rt=g(()=>{y(p=>p==="asc"?"desc":"asc")},"toggleSortDirection"),nt=g(p=>{m(p)},"onThumbSizeChange"),it=g(p=>{r(p)},"onExpiryChange"),at=g(()=>{w(void 0),C(!0),H((async()=>{try{for(let p of ke)await Z.remove(p);await X(t,void 0,!1),ne()}catch(p){w(Q(p))}finally{C(!1)}})())},"bulkDelete"),ct=g(p=>{w(void 0),H((async()=>{try{let $=await Z.signedUrl(p,{expiresInSeconds:a});Ee($)&&E(p)}catch($){w(Q($))}})())},"onCopy"),dt=g(p=>{w(void 0),H((async()=>{try{let $=await Z.signedUrl(p,{expiresInSeconds:a}),O=p.slice(p.lastIndexOf("/")+1)||p;Ht($,O)}catch($){w(Q($))}})())},"onDownload");(0,_.useEffect)(()=>{if(N===void 0)return;let p=globalThis.setTimeout(()=>{E(void 0)},2e3);return()=>{globalThis.clearTimeout(p)}},[N]);let ft=g(p=>{w(void 0),C(!0),H((async()=>{try{await Z.remove(p),await X(t,void 0,!1)}catch($){w(Q($))}finally{C(!1)}})())},"onDelete"),ut=g(p=>{let $=`${t}${p.name}`;w(void 0),C(!0),H((async()=>{try{let O=await p.arrayBuffer();await Z.upload({body:O,contentType:p.type===""?void 0:p.type,key:$}),await X(t,void 0,!1)}catch(O){w(Q(O))}finally{C(!1)}})())},"onFile");(0,_.useEffect)(()=>{J.current+=1,U(void 0),q(!1)},[D]);let ht=g(()=>{J.current+=1;let p=J.current;w(void 0),P(!0),H((async()=>{try{let $=[],O;do{let V=await Z.list({cursor:O,limit:Mt});for(let ce of V.objects)$.push(ce.key);O=$.length>=Oe?void 0:V.cursor}while(O!==void 0);if($.length>=Oe)p===J.current&&(U([]),q(!0));else{let V=await s.query(Ut,{liveKeys:$},pe(D));p===J.current&&(U(V.references??[]),q(V.truncated===!0))}}catch($){p===J.current&&(U([]),q(!1),w(Q($)))}finally{p===J.current&&P(!1)}})())},"checkOrphans"),mt=g(p=>{re.current+=1,J.current+=1,xe(p),n(c??""),u(c??""),b(void 0),U(void 0),q(!1),ne()},"selectBucket");return{allSelected:We,bucket:W,buckets:Y,bulkDelete:at,busy:T,checkOrphans:ht,clearSelection:ne,copiedKey:N,danglingBusy:M,danglingReferences:L,danglingTruncated:G,draftPrefix:o,enterFolder:et,error:k,expiry:a,files:ae,folders:Pe,hasObjects:v!==void 0&&v.length>0,hasStorageColumns:A,listFirst:Je,loaded:v!==void 0,loadMore:Qe,navigate:Se,nextCursor:F,onCopy:ct,onDelete:ft,onDownload:dt,onExpiryChange:it,onFile:ut,onSortKeyChange:ot,onThumbSizeChange:nt,prefix:t,referenceShard:D,references:I,resolveUrl:tt,selectBucket:mt,selected:ke,setDraftPrefix:u,setReferenceShard:B,showGrid:lt,showList:st,someSelected:Ze,sortDirection:x,sortKey:S,tagKeys:qe,thumbSize:f,toggleSelect:Xe,toggleSelectAll:Ye,toggleSortDirection:rt,view:d}},"useFileBrowser"),qt=100,Ae=g(c=>{let e=(0,j.c)(6),{label:s,onNavigate:t,target:n}=c,o;e[0]!==t||e[1]!==n?(o=g(()=>{t(n)},"t1"),e[0]=t,e[1]=n,e[2]=o):o=e[2];let u=o,a;return e[3]!==u||e[4]!==s?(a=(0,l.jsxDEV)("button",{className:"rounded px-1 text-muted-foreground outline-none hover:text-foreground focus-visible:text-foreground",onClick:u,type:"button",children:s},void 0,!1),e[3]=u,e[4]=s,e[5]=a):a=e[5],a},"Crumb"),Vt=g(c=>{let e=(0,j.c)(11),{onNavigate:s,prefix:t,t:n}=c,o;if(e[0]!==s||e[1]!==t||e[2]!==n){let u=t.split("/").filter(Wt),a;e[4]!==n?(a=n("Folder path"),e[4]=n,e[5]=a):a=e[5];let r;e[6]!==n?(r=n("root"),e[6]=n,e[7]=r):r=e[7];let d;e[8]!==s||e[9]!==r?(d=(0,l.jsxDEV)(Ae,{label:r,onNavigate:s,target:""},void 0,!1),e[8]=s,e[9]=r,e[10]=d):d=e[10],o=(0,l.jsxDEV)("nav",{"aria-label":a,className:"flex flex-wrap items-center gap-0.5 text-xs","data-testid":"fb-breadcrumbs",children:[d,u.map((h,f)=>(0,l.jsxDEV)("span",{className:"flex items-center gap-0.5",children:[(0,l.jsxDEV)("span",{className:"text-muted-foreground/50",children:"/"},void 0,!1),(0,l.jsxDEV)(Ae,{label:h,onNavigate:s,target:`${u.slice(0,f+1).join("/")}/`},void 0,!1)]},`${h}-${f.toString()}`,!0))]},void 0,!0),e[0]=s,e[1]=t,e[2]=n,e[3]=o}else o=e[3];return o},"Breadcrumbs"),fs=g(({initialPrefix:c,pageSize:e=qt})=>{let s=Ce(),t=Pt({initialPrefix:c,pageSize:e}),n=(0,_.useRef)(null),{onCopy:o,onDelete:u,onDownload:a,onFile:r,toggleSelect:d}=t,h={onCopy:o,onDelete:u,onDownload:a,onToggleSelect:d},f=g(()=>{n.current?.click()},"onUploadClick"),m=g(i=>{let x=i.target,y=x.files?.[0];x.value="",y&&r(y)},"onFileChange"),S=t.loaded&&!t.hasObjects;return(0,l.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"lunora-file-browser",children:[(0,l.jsxDEV)(Tt,{bucket:t.bucket,buckets:t.buckets,busy:t.busy,draftPrefix:t.draftPrefix,expiry:t.expiry,fileInputRef:n,onBucketChange:t.selectBucket,onExpiryChange:t.onExpiryChange,onFileChange:m,onList:t.listFirst,onPrefixChange:t.setDraftPrefix,onUploadClick:f,t:s},void 0,!1),t.loaded&&(0,l.jsxDEV)(Vt,{onNavigate:t.navigate,prefix:t.prefix,t:s},void 0,!1),t.hasObjects&&(0,l.jsxDEV)(_t,{onSortKeyChange:t.onSortKeyChange,onThumbSizeChange:t.onThumbSizeChange,showGrid:t.showGrid,showList:t.showList,sortDirection:t.sortDirection,sortKey:t.sortKey,t:s,tagKeys:t.tagKeys,thumbSize:t.thumbSize,toggleSortDirection:t.toggleSortDirection,view:t.view},void 0,!1),t.hasStorageColumns&&(0,l.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"fb-references-shard",children:[(0,l.jsxDEV)("label",{className:"text-xs text-muted-foreground",htmlFor:"fb-reference-shard-input",children:s("References shard")},void 0,!1),(0,l.jsxDEV)($e,{id:"fb-reference-shard-input",onChange:t.setReferenceShard,testId:"fb-reference-shard-input",value:t.referenceShard},void 0,!1),(0,l.jsxDEV)("span",{className:"text-xs text-muted-foreground",children:s("Which shard's records are checked for references to these files. Empty = root shard.")},void 0,!1)]},void 0,!0),t.hasStorageColumns&&(0,l.jsxDEV)(Ot,{busy:t.danglingBusy,onCheck:t.checkOrphans,references:t.danglingReferences,t:s,truncated:t.danglingTruncated},void 0,!1),t.selected.size>0&&(0,l.jsxDEV)(Le,{count:t.selected.size,editable:!0,onClear:t.clearSelection,onDelete:t.bulkDelete},void 0,!1),t.error!==void 0&&(0,l.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"storage-error",role:"alert",children:t.error},void 0,!1),S&&(0,l.jsxDEV)(me,{description:s("Objects you upload to your R2 buckets will appear here."),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:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Z"},void 0,!1),(0,l.jsxDEV)("path",{d:"M12 11v5m-2.5-2.5h5"},void 0,!1)]},void 0,!0),testId:"fb-empty",title:s("No objects.")},void 0,!1),t.hasObjects&&t.view==="list"&&(0,l.jsxDEV)(kt,{allSelected:t.allSelected,busy:t.busy,copiedKey:t.copiedKey,files:t.files,folders:t.folders,handlers:h,onEnterFolder:t.enterFolder,prefix:t.prefix,references:t.references,selected:t.selected,showReferences:t.hasStorageColumns,someSelected:t.someSelected,t:s,toggleSelectAll:t.toggleSelectAll},void 0,!1),t.hasObjects&&t.view==="grid"&&(0,l.jsxDEV)(Bt,{busy:t.busy,copiedKey:t.copiedKey,files:t.files,folders:t.folders,handlers:h,onEnterFolder:t.enterFolder,prefix:t.prefix,references:t.references,resolveUrl:t.resolveUrl,selected:t.selected,showReferences:t.hasStorageColumns,size:t.thumbSize,t:s},void 0,!1),t.nextCursor!==void 0&&(0,l.jsxDEV)("div",{children:(0,l.jsxDEV)(se,{"data-testid":"fb-next",disabled:t.busy,onClick:t.loadMore,size:"sm",type:"button",variant:"outline",children:s("Load more")},void 0,!1)},void 0,!1)]},void 0,!0)},"FileBrowser");function Wt(c){return c!==""}g(Wt,"_temp");export{fs as FileBrowser};
@@ -0,0 +1 @@
1
+ import{a as _}from"./chunk-3OA7PECS.js";import{a as n,e as E,f as S}from"./chunk-RRCPZMC2.js";function u(t,e=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,r))}n(u,"clamp");var p=1;function A(t,e){return Math.max(0,t-e)}n(A,"getMaxScrollOffset");function D(t,e){if(e<=0)return 0;let r=u(t,0,e),c=r,l=e-r,a=c<=p,i=l<=p;return a&&i?c<=l?0:e:a?0:i?e:r}n(D,"normalizeScrollOffset");var f=E(_(),1),o="base-ui-disable-scrollbar",d={className:o,getElement(t){return(0,f.jsx)("style",{nonce:t,href:o,precedence:"base-ui:low",children:`.${o}{scrollbar-width:none}.${o}::-webkit-scrollbar{display:none}`})}};d.getElement.displayName="styleDisableScrollbar.getElement";var s=E(S(),1);var m=s.createContext(void 0);m.displayName="CSPContext";var N={disableStyleElements:!1};function O(){return s.useContext(m)??N}n(O,"useCSPContext");export{u as a,p as b,A as c,D as d,d as e,O as f};
@@ -1 +1 @@
1
- import{a as k,b as j}from"./chunk-VXM5H542.js";import{a as D}from"./chunk-FQUNSQLG.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as A}from"./chunk-4F72YCTU.js";import{a as _,b as z,c as B,d as f,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as y,e as E}from"./chunk-Y572GMZE.js";import{a as M}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as L}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import"./chunk-O3NAGRTR.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as H}from"./chunk-EBTLTGG3.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as I}from"./chunk-TAD43CG5.js";import{d as C,p as R}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as i,e as w,f as ee,h as te}from"./chunk-RRCPZMC2.js";var o=w(ee(),1);var e=w(te(),1);var K=80,ae=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>K?`${t.slice(0,K)}\u2026`:t},"formatDetail"),re=41,F=480,U=5,oe=i((s,t)=>k(s,d=>{t(d.height>0?d:{height:F,width:d.width})}),"observeViewportRect"),Se=i(({initialShardKey:s})=>{let t=C(),[d,G]=(0,o.useState)(s??""),[m,W]=(0,o.useState)(""),q=O(d.trim(),400),{data:v,error:p,errorSource:J,isLoading:P,liveError:Q}=A(H.getAuditLog,{},{live:!0,shardKey:q}),u=(0,o.useMemo)(()=>v?.entries??[],[v]),c=(0,o.useMemo)(()=>{let r=m.trim().toLowerCase();return r===""?u:u.filter(a=>a.op.toLowerCase().includes(r)||(a.table??"").toLowerCase().includes(r)||(a.id??"").toLowerCase().includes(r))},[u,m]),g=(0,o.useRef)(null),x=j({count:c.length,estimateSize:i(()=>re,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:F,width:800},observeElementRect:oe,overscan:8}),h=x.getVirtualItems(),X=x.getTotalSize(),S=h[0]?.start??0,b=X-(h.at(-1)?.end??0),Z={height:S},$={height:b},Y=i(r=>{W(r.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:G,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(D,{message:Q,prefix:"au"},void 0,!1),(0,e.jsxDEV)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:m},void 0,!1)]},void 0,!0),p!==null&&(0,e.jsxDEV)(V,{error:J,testId:"au-error"},void 0,!1),p===null&&!P&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(_,{"data-testid":"au-table",children:[(0,e.jsxDEV)(z,{children:(0,e.jsxDEV)(f,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(B,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:Z},void 0,!1)},void 0,!1),h.map(r=>{let a=c[r.index],N=ae(a.detail);return(0,e.jsxDEV)(f,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:$},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{Se as AuditPanel};
1
+ import{a as k,b as j}from"./chunk-VXM5H542.js";import{a as D}from"./chunk-FQUNSQLG.js";import{a as O}from"./chunk-2K47A3P6.js";import{a as V}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as A}from"./chunk-4F72YCTU.js";import{a as _,b as z,c as B,d as f,e as l,f as n}from"./chunk-GTM65MVX.js";import{a as y,e as E}from"./chunk-Y572GMZE.js";import{a as M}from"./chunk-FDWXYXOM.js";import"./chunk-4PC7IXNY.js";import"./chunk-2MLA6WFH.js";import{R as L}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import"./chunk-O3NAGRTR.js";import{b as T}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as H}from"./chunk-MHGJUKCZ.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as I}from"./chunk-TAD43CG5.js";import{d as C,p as R}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as i,e as w,f as ee,h as te}from"./chunk-RRCPZMC2.js";var o=w(ee(),1);var e=w(te(),1);var K=80,ae=i(s=>{if(s===void 0)return"";let t=JSON.stringify(s);return t.length>K?`${t.slice(0,K)}\u2026`:t},"formatDetail"),re=41,F=480,U=5,oe=i((s,t)=>k(s,d=>{t(d.height>0?d:{height:F,width:d.width})}),"observeViewportRect"),Se=i(({initialShardKey:s})=>{let t=C(),[d,G]=(0,o.useState)(s??""),[m,W]=(0,o.useState)(""),q=O(d.trim(),400),{data:v,error:p,errorSource:J,isLoading:P,liveError:Q}=A(H.getAuditLog,{},{live:!0,shardKey:q}),u=(0,o.useMemo)(()=>v?.entries??[],[v]),c=(0,o.useMemo)(()=>{let r=m.trim().toLowerCase();return r===""?u:u.filter(a=>a.op.toLowerCase().includes(r)||(a.table??"").toLowerCase().includes(r)||(a.id??"").toLowerCase().includes(r))},[u,m]),g=(0,o.useRef)(null),x=j({count:c.length,estimateSize:i(()=>re,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:F,width:800},observeElementRect:oe,overscan:8}),h=x.getVirtualItems(),X=x.getTotalSize(),S=h[0]?.start??0,b=X-(h.at(-1)?.end??0),Z={height:S},$={height:b},Y=i(r=>{W(r.target.value)},"onSearchChange");return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxDEV)(M,{onChange:G,testId:"au-shard-input",value:d},void 0,!1),(0,e.jsxDEV)(D,{message:Q,prefix:"au"},void 0,!1),(0,e.jsxDEV)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:Y,placeholder:t("filter op, table, id"),value:m},void 0,!1)]},void 0,!0),p!==null&&(0,e.jsxDEV)(V,{error:J,testId:"au-error"},void 0,!1),p===null&&!P&&c.length===0&&(0,e.jsxDEV)(I,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsxDEV)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"},void 0,!1)},void 0,!1),testId:"au-empty",title:t("No audit entries.")},void 0,!1),c.length>0&&(0,e.jsxDEV)(y,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:g,children:(0,e.jsxDEV)(_,{"data-testid":"au-table",children:[(0,e.jsxDEV)(z,{children:(0,e.jsxDEV)(f,{children:[(0,e.jsxDEV)(l,{children:t("time")},void 0,!1),(0,e.jsxDEV)(l,{children:t("op")},void 0,!1),(0,e.jsxDEV)(l,{children:t("table")},void 0,!1),(0,e.jsxDEV)(l,{children:t("id")},void 0,!1),(0,e.jsxDEV)(l,{children:t("detail")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(B,{children:[S>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:Z},void 0,!1)},void 0,!1),h.map(r=>{let a=c[r.index],N=ae(a.detail);return(0,e.jsxDEV)(f,{"data-testid":"au-row",children:[(0,e.jsxDEV)(n,{className:"text-muted-foreground tabular-nums",children:R(a.ts,"\u2014")},void 0,!1),(0,e.jsxDEV)(n,{children:(0,e.jsxDEV)(T,{variant:"secondary",children:a.op},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"font-medium",children:a.table??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:a.id??(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1),(0,e.jsxDEV)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:N||void 0,children:N||(0,e.jsxDEV)("span",{className:"text-muted-foreground",children:"\u2014"},void 0,!1)},void 0,!1)]},a.seq,!0)}),b>0&&(0,e.jsxDEV)("tr",{"aria-hidden":"true",children:(0,e.jsxDEV)("td",{colSpan:U,style:$},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)},"AuditPanel");export{Se as AuditPanel};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-J6J54MBP.js";import{a as E}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as y}from"./chunk-4F72YCTU.js";import{a as x,b as I,c as N,d as u,e as l,f as o}from"./chunk-GTM65MVX.js";import{a as m,e as h}from"./chunk-Y572GMZE.js";import{b as v}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 A}from"./chunk-TAD43CG5.js";import{d as S,p as b}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as c,e as Q,h as V}from"./chunk-RRCPZMC2.js";var e=Q(V(),1);var P=new Set(["active","trialing"]),D=new Set(["past_due","unpaid"]),a=c((t,s)=>{if(t[s]!==void 0)return t[s];let d=t.__doc__;if(typeof d=="string")try{let n=JSON.parse(d);if(n!==null&&typeof n=="object"&&!Array.isArray(n))return n[s]}catch{}},"readField"),i=c(t=>typeof t=="string"?t:typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"?String(t):"","text"),F=c(t=>P.has(t)?"default":D.has(t)?"destructive":"outline","badgeVariant"),K=c(({limit:t=100})=>{let s=S(),d=y(g.readTablePage,{filters:[],limit:t,offset:0,orderBy:[],search:"",table:"subscriptions"}),n=y(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"});C(()=>{d.refetch(),n.refetch()},!0);let f=d.data?.rows??[],R=n.data?.rows??[],B=d.error??n.error,w=d.error===null?n.errorSource:d.errorSource,T=f.filter(r=>P.has(i(a(r,"state")))).length,j=R.toSorted((r,p)=>Number(a(p,"processedAt")??0)-Number(a(r,"processedAt")??0));return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxDEV)(m,{className:"justify-between gap-0 py-0",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Subscriptions")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T},void 0,!1),(0,e.jsxDEV)(v,{variant:"default",children:s("{count} active",{count:T})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:s("{total} total",{total:f.length})},void 0,!1)]},void 0,!0)},void 0,!1),B===null?void 0:(0,e.jsxDEV)(E,{error:w},void 0,!1),f.length===0&&!d.isLoading?(0,e.jsxDEV)(A,{testId:"payments-empty",title:s("No subscriptions yet")},void 0,!1):(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:[(0,e.jsxDEV)(I,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(l,{children:s("Provider")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Reference")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Plan")},void 0,!1),(0,e.jsxDEV)(l,{children:s("State")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Renews")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(N,{children:f.map(r=>{let p=i(a(r,"state"));return(0,e.jsxDEV)(u,{"data-testid":"payment-subscription-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"referenceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"priceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:(0,e.jsxDEV)(v,{variant:F(p),children:p},void 0,!1)},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"currentPeriodEnd"))},void 0,!1)]},i(a(r,"providerSubscriptionId")),!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",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:s("Recent webhook events")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:(0,e.jsxDEV)(N,{children:j.map(r=>(0,e.jsxDEV)(u,{"data-testid":"payment-event-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{className:"font-medium",children:i(a(r,"type"))},void 0,!1),(0,e.jsxDEV)(o,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"processedAt"))},void 0,!1)]},i(a(r,"providerEventId")),!0))},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PaymentsPanel");export{K as PaymentsPanel};
1
+ import{a as C}from"./chunk-J6J54MBP.js";import{a as E}from"./chunk-D73WYMRU.js";import"./chunk-XNJNSCLM.js";import{b as y}from"./chunk-4F72YCTU.js";import{a as x,b as I,c as N,d as u,e as l,f as o}from"./chunk-GTM65MVX.js";import{a as m,e as h}from"./chunk-Y572GMZE.js";import{b as v}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as g}from"./chunk-MHGJUKCZ.js";import"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as A}from"./chunk-TAD43CG5.js";import{d as S,p as b}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as c,e as Q,h as V}from"./chunk-RRCPZMC2.js";var e=Q(V(),1);var P=new Set(["active","trialing"]),D=new Set(["past_due","unpaid"]),a=c((t,s)=>{if(t[s]!==void 0)return t[s];let d=t.__doc__;if(typeof d=="string")try{let n=JSON.parse(d);if(n!==null&&typeof n=="object"&&!Array.isArray(n))return n[s]}catch{}},"readField"),i=c(t=>typeof t=="string"?t:typeof t=="number"||typeof t=="bigint"||typeof t=="boolean"?String(t):"","text"),F=c(t=>P.has(t)?"default":D.has(t)?"destructive":"outline","badgeVariant"),K=c(({limit:t=100})=>{let s=S(),d=y(g.readTablePage,{filters:[],limit:t,offset:0,orderBy:[],search:"",table:"subscriptions"}),n=y(g.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"});C(()=>{d.refetch(),n.refetch()},!0);let f=d.data?.rows??[],R=n.data?.rows??[],B=d.error??n.error,w=d.error===null?n.errorSource:d.errorSource,T=f.filter(r=>P.has(i(a(r,"state")))).length,j=R.toSorted((r,p)=>Number(a(p,"processedAt")??0)-Number(a(r,"processedAt")??0));return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxDEV)(m,{className:"justify-between gap-0 py-0",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Subscriptions")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:T},void 0,!1),(0,e.jsxDEV)(v,{variant:"default",children:s("{count} active",{count:T})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:s("{total} total",{total:f.length})},void 0,!1)]},void 0,!0)},void 0,!1),B===null?void 0:(0,e.jsxDEV)(E,{error:w},void 0,!1),f.length===0&&!d.isLoading?(0,e.jsxDEV)(A,{testId:"payments-empty",title:s("No subscriptions yet")},void 0,!1):(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:[(0,e.jsxDEV)(I,{children:(0,e.jsxDEV)(u,{children:[(0,e.jsxDEV)(l,{children:s("Provider")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Reference")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Plan")},void 0,!1),(0,e.jsxDEV)(l,{children:s("State")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Renews")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(N,{children:f.map(r=>{let p=i(a(r,"state"));return(0,e.jsxDEV)(u,{"data-testid":"payment-subscription-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"referenceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:i(a(r,"priceId"))},void 0,!1),(0,e.jsxDEV)(o,{children:(0,e.jsxDEV)(v,{variant:F(p),children:p},void 0,!1)},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"currentPeriodEnd"))},void 0,!1)]},i(a(r,"providerSubscriptionId")),!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",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:s("Recent webhook events")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(x,{children:(0,e.jsxDEV)(N,{children:j.map(r=>(0,e.jsxDEV)(u,{"data-testid":"payment-event-row",children:[(0,e.jsxDEV)(o,{children:i(a(r,"provider"))},void 0,!1),(0,e.jsxDEV)(o,{className:"font-medium",children:i(a(r,"type"))},void 0,!1),(0,e.jsxDEV)(o,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))},void 0,!1),(0,e.jsxDEV)(o,{children:b(a(r,"processedAt"))},void 0,!1)]},i(a(r,"providerEventId")),!0))},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PaymentsPanel");export{K as PaymentsPanel};
@@ -1 +1 @@
1
- import{a as He}from"./chunk-EOE5NDMK.js";import"./chunk-DWDILV2E.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-D73WYMRU.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{b as De}from"./chunk-4F72YCTU.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Le,e as Me}from"./chunk-Y572GMZE.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-EBTLTGG3.js";import{f as Fe}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ie}from"./chunk-TAD43CG5.js";import{d as U,f as ce,g as ue,h as me,l as fe,p as ze}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
1
+ import{a as He}from"./chunk-2TJVFKD2.js";import"./chunk-3HGNPZBN.js";import{a as je}from"./chunk-J6J54MBP.js";import"./chunk-5OIBXYZM.js";import{a as Pe}from"./chunk-D73WYMRU.js";import{a as Ge}from"./chunk-XNJNSCLM.js";import{b as De}from"./chunk-4F72YCTU.js";import{a as Be,b as Re,c as $e,d as j,e as E,f as _}from"./chunk-GTM65MVX.js";import{a as Le,e as Me}from"./chunk-Y572GMZE.js";import{a as Ve}from"./chunk-VLXV72QE.js";import{R as We}from"./chunk-VL23Y44O.js";import"./chunk-HV7G6DFP.js";import{c as V}from"./chunk-UK64ZSUW.js";import"./chunk-O3NAGRTR.js";import{b as de}from"./chunk-ZPP2KOR4.js";import"./chunk-CKSHCYGC.js";import{a as J}from"./chunk-MHGJUKCZ.js";import{f as Fe}from"./chunk-S2G7OH5T.js";import"./chunk-ZHVTQ37P.js";import"./chunk-3OA7PECS.js";import{a as ie}from"./chunk-TAD43CG5.js";import{d as U,f as ce,g as ue,h as me,l as fe,p as ze}from"./chunk-5XO36X4C.js";import"./chunk-ZXLEXF4X.js";import{a as f,e as Ie,f as at,g as ot,h as rt}from"./chunk-RRCPZMC2.js";var F=Ie(ot(),1);var w=Ie(at(),1);var t=Ie(rt(),1);var lt=f((o,e)=>{let s=new Set(o.map(a=>a.deadLetterQueue).filter(a=>typeof a=="string"&&a!=="")),i=o.filter(a=>(a.deadLetterQueue===void 0||a.deadLetterQueue==="")&&!s.has(a.name)),n=e.filter(a=>a.deadLettered).length;return{deadLetteredCount:n,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||n>0}},"computeQueueReliability"),nt=200,dt=ce(J.sendQueueMessage),it=ce(J.replayQueueMessage),ct=ce(J.clearQueueMessages),Ye=96,ut=f(o=>{if(o===void 0)return"\u2014";try{return JSON.stringify(o)}catch{return"[unserializable]"}},"formatBody"),mt=f(o=>o.length>Ye?`${o.slice(0,Ye)}\u2026`:o,"truncate"),ft=f(o=>o==="error"?"destructive":o==="retry"?"outline":"secondary","outcomeVariant"),ht=f((o,e)=>e(o==="messages"?"Messages":o==="send"?"Send":"Declared"),"tabLabel"),pt=f(o=>{let e=(0,F.c)(11),{loaded:s,queues:i}=o,n=U(),a;e[0]!==n?(a=n("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=n,e[1]=a):a=e[1];let l;e[2]!==a?(l=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:a},void 0,!1),e[2]=a,e[3]=l):l=e[3];let r;e[4]!==s||e[5]!==i||e[6]!==n?(r=s&&i.length===0?(0,t.jsxDEV)(ie,{description:n("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:n("No queues defined")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:n("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Queue")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Mode")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Binding")},void 0,!1),(0,t.jsxDEV)(E,{children:n("Dead-letter")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(yt)},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[4]=s,e[5]=i,e[6]=n,e[7]=r):r=e[7];let h;return e[8]!==l||e[9]!==r?(h=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[l,r]},void 0,!0),e[8]=l,e[9]=r,e[10]=h):h=e[10],h},"QueuesDeclaredTab"),gt=f(o=>{let e=(0,F.c)(67),{message:s,onReplay:i,replayingId:n}=o,a=U(),l,r,h,u,y,p,x,d,m,g;if(e[0]!==s.attempts||e[1]!==s.body||e[2]!==s.deadLettered||e[3]!==s.exportName||e[4]!==s.id||e[5]!==s.messageId||e[6]!==s.outcome||e[7]!==s.queue||e[8]!==a){let W=ut(s.body);r=j,p=`queues-message-${s.id}`;let z=s.exportName??s.queue;e[19]!==z?(x=(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:z},void 0,!1),e[19]=z,e[20]=x):x=e[20],e[21]!==s.messageId?(d=(0,t.jsxDEV)(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:s.messageId,children:s.messageId},void 0,!1),e[21]=s.messageId,e[22]=d):d=e[22],e[23]!==s.attempts?(m=(0,t.jsxDEV)(_,{className:"font-mono text-xs tabular-nums",children:s.attempts},void 0,!1),e[23]=s.attempts,e[24]=m):m=e[24];let I=`queues-outcome-${s.id}`,L;e[25]!==s.outcome?(L=ft(s.outcome),e[25]=s.outcome,e[26]=L):L=e[26];let T;e[27]!==s.outcome||e[28]!==I||e[29]!==L?(T=(0,t.jsxDEV)(de,{"data-testid":I,variant:L,children:s.outcome},void 0,!1),e[27]=s.outcome,e[28]=I,e[29]=L,e[30]=T):T=e[30];let M;e[31]!==s.deadLettered||e[32]!==s.id||e[33]!==a?(M=s.deadLettered&&(0,t.jsxDEV)(de,{"data-testid":`queues-dlq-${s.id}`,variant:"destructive",children:a("DLQ")},void 0,!1),e[31]=s.deadLettered,e[32]=s.id,e[33]=a,e[34]=M):M=e[34],e[35]!==T||e[36]!==M?(g=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1",children:[T,M]},void 0,!0)},void 0,!1),e[35]=T,e[36]=M,e[37]=g):g=e[37],l=_,h="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",u=W,y=mt(W),e[0]=s.attempts,e[1]=s.body,e[2]=s.deadLettered,e[3]=s.exportName,e[4]=s.id,e[5]=s.messageId,e[6]=s.outcome,e[7]=s.queue,e[8]=a,e[9]=l,e[10]=r,e[11]=h,e[12]=u,e[13]=y,e[14]=p,e[15]=x,e[16]=d,e[17]=m,e[18]=g}else l=e[9],r=e[10],h=e[11],u=e[12],y=e[13],p=e[14],x=e[15],d=e[16],m=e[17],g=e[18];let v;e[38]!==l||e[39]!==h||e[40]!==u||e[41]!==y?(v=(0,t.jsxDEV)(l,{className:h,title:u,children:y},void 0,!1),e[38]=l,e[39]=h,e[40]=u,e[41]=y,e[42]=v):v=e[42];let N;e[43]!==s.capturedAt?(N=ze(s.capturedAt,"\u2014"),e[43]=s.capturedAt,e[44]=N):N=e[44];let b;e[45]!==N?(b=(0,t.jsxDEV)(_,{className:"text-xs text-muted-foreground tabular-nums",children:N},void 0,!1),e[45]=N,e[46]=b):b=e[46];let S=`queues-replay-${s.id}`,A=n!==null,C;e[47]!==s.id||e[48]!==n||e[49]!==a?(C=n===s.id?a("Replaying\u2026"):a("Replay"),e[47]=s.id,e[48]=n,e[49]=a,e[50]=C):C=e[50];let Q;e[51]!==s.id||e[52]!==i||e[53]!==S||e[54]!==A||e[55]!==C?(Q=(0,t.jsxDEV)(_,{children:(0,t.jsxDEV)(V,{"data-id":s.id,"data-testid":S,disabled:A,onClick:i,size:"xs",type:"button",variant:"outline",children:C},void 0,!1)},void 0,!1),e[51]=s.id,e[52]=i,e[53]=S,e[54]=A,e[55]=C,e[56]=Q):Q=e[56];let D;return e[57]!==r||e[58]!==b||e[59]!==Q||e[60]!==p||e[61]!==x||e[62]!==d||e[63]!==m||e[64]!==g||e[65]!==v?(D=(0,t.jsxDEV)(r,{"data-testid":p,children:[x,d,m,g,v,b,Q]},void 0,!0),e[57]=r,e[58]=b,e[59]=Q,e[60]=p,e[61]=x,e[62]=d,e[63]=m,e[64]=g,e[65]=v,e[66]=D):D=e[66],D},"QueueLogRow"),vt=f(o=>{let e=(0,F.c)(26),{hasError:s,messages:i,onClear:n,onReplay:a,replayingId:l}=o,r=U(),h;e[0]!==r?(h=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=h):h=e[1];let u;e[2]!==h?(u=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:h},void 0,!1),e[2]=h,e[3]=u):u=e[3];let y=i.length===0,p;e[4]!==r?(p=r("Clear log"),e[4]=r,e[5]=p):p=e[5];let x;e[6]!==n||e[7]!==y||e[8]!==p?(x=(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-clear",disabled:y,onClick:n,size:"sm",type:"button",variant:"outline",children:p},void 0,!1),e[6]=n,e[7]=y,e[8]=p,e[9]=x):x=e[9];let d;e[10]!==i.length||e[11]!==r?(d=i.length>0&&(0,t.jsxDEV)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})},void 0,!1),e[10]=i.length,e[11]=r,e[12]=d):d=e[12];let m;e[13]!==u||e[14]!==x||e[15]!==d?(m=(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[u,x,d]},void 0,!0),e[13]=u,e[14]=x,e[15]=d,e[16]=m):m=e[16];let g;e[17]!==s||e[18]!==i||e[19]!==a||e[20]!==l||e[21]!==r?(g=!s&&i.length===0?(0,t.jsxDEV)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")},void 0,!1):(0,t.jsxDEV)(Le,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(Me,{className:"px-0",children:(0,t.jsxDEV)(He,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxDEV)(Be,{"data-testid":"queues-messages-table",children:[(0,t.jsxDEV)(Re,{children:(0,t.jsxDEV)(j,{children:[(0,t.jsxDEV)(E,{children:r("Export")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Message")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Attempts")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Outcome")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Body")},void 0,!1),(0,t.jsxDEV)(E,{children:r("Captured")},void 0,!1),(0,t.jsxDEV)(E,{},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)($e,{children:i.map(N=>(0,t.jsxDEV)(gt,{message:N,onReplay:a,replayingId:l},N.id,!1))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)},void 0,!1),e[17]=s,e[18]=i,e[19]=a,e[20]=l,e[21]=r,e[22]=g):g=e[22];let v;return e[23]!==m||e[24]!==g?(v=(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[m,g]},void 0,!0),e[23]=m,e[24]=g,e[25]=v):v=e[25],v},"QueuesMessagesTab"),xt=f(o=>{let e=(0,F.c)(20),{batchMode:s,bodyText:i,delayText:n,onBatchModeChange:a,onBodyChange:l,onDelayChange:r,onSelectExport:h,onSend:u,queues:y,selectedExportName:p,sending:x}=o,d=U(),m;e[0]!==d?(m=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=m):m=e[1];let g;e[2]!==m?(g=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:m},void 0,!1),e[2]=m,e[3]=g):g=e[3];let v;e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==h||e[11]!==u||e[12]!==y||e[13]!==p||e[14]!==x||e[15]!==d?(v=y.length===0?(0,t.jsxDEV)(ie,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:h,value:p,children:y.map(bt)},void 0,!1),(0,t.jsxDEV)(We,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:d("Delay (s)"),type:"number",value:n},void 0,!1),(0,t.jsxDEV)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsxDEV)("input",{checked:s,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:a,type:"checkbox"},void 0,!1),d("Send as batch (JSON array)")]},void 0,!0),(0,t.jsxDEV)(V,{className:"ml-auto","data-testid":"queues-send-button",disabled:x||p==="",onClick:u,type:"button",children:d(x?"Sending\u2026":"Send message")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(Ve,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:l,placeholder:s?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i},void 0,!1)]},void 0,!0),e[4]=s,e[5]=i,e[6]=n,e[7]=a,e[8]=l,e[9]=r,e[10]=h,e[11]=u,e[12]=y,e[13]=p,e[14]=x,e[15]=d,e[16]=v):v=e[16];let N;return e[17]!==g||e[18]!==v?(N=(0,t.jsxDEV)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[g,v]},void 0,!0),e[17]=g,e[18]=v,e[19]=N):N=e[19],N},"QueuesSendTab"),Ut=f(o=>{let e=(0,F.c)(59),{limit:s}=o,i=s??nt,n=Fe(),a=U(),[l,r]=(0,w.useState)("declared"),[h,u]=(0,w.useState)(null),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:p,error:x,errorSource:d}=De(J.listQueues,y),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:g,error:v,errorSource:N,refetch:b}=De(J.getQueueMessages,m),S=Array.isArray(p?.queues)?[...p.queues].toSorted(Nt):[],A=g?.entries??[],{deadLetteredCount:C,queuesWithoutDlq:Q,showReliabilityWarning:D}=lt(S,A),[W,z]=(0,w.useState)(""),[I,L]=(0,w.useState)(""),[T,M]=(0,w.useState)(""),[G,Xe]=(0,w.useState)(!1),[he,Oe]=(0,w.useState)(!1),[pe,ke]=(0,w.useState)(null),H=S.some(c=>c.exportName===W)?W:S[0]?.exportName??"",Ue=l==="messages"?v:x,Ke=l==="messages"?N:d,ge=Ue??h,ve=Ue===null?h:Ke,Y;e[3]!==b?(Y=f(()=>{b()},"t3"),e[3]=b,e[4]=Y):Y=e[4],je(Y,l==="messages");let xe=f(async()=>{u(null);let c=H;if(c==="")return;let q=null,we=I.trim();if(we!=="")try{q=JSON.parse(we)}catch{u(a("Body must be valid JSON."));return}let Ae,Je=T.trim();if(Je!==""){let P=Number(Je);if(!Number.isFinite(P)||P<0){u(a("Delay must be a non-negative number of seconds."));return}Ae=P}if(G&&!Array.isArray(q)){u(a("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let st=G?{batch:q,delaySeconds:Ae,exportName:c}:{body:q,delaySeconds:Ae,exportName:c};try{await n.query(dt,st,ue("")),b()}catch(P){u(me(P))}Oe(!1)},"send"),X;e[5]!==n||e[6]!==b?(X=f(async c=>{u(null),ke(c);try{await n.query(it,{id:c},ue("")),b()}catch(q){u(me(q))}ke(null)},"t5"),e[5]=n,e[6]=b,e[7]=X):X=e[7];let ye=X,K;e[8]!==n||e[9]!==b?(K=f(async()=>{u(null);try{await n.query(ct,{},ue("")),b()}catch(c){u(me(c))}},"t6"),e[8]=n,e[9]=b,e[10]=K):K=e[10];let be=K,Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f(c=>{let q=c.currentTarget.dataset.tab;(q==="declared"||q==="messages"||q==="send")&&r(q)},"t7"),e[11]=Z):Z=e[11];let Ze=Z,ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f(c=>{z(c.currentTarget.value)},"t8"),e[12]=ee):ee=e[12];let Ne=ee,te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f(c=>{L(c.currentTarget.value)},"t9"),e[13]=te):te=e[13];let qe=te,se;e[14]===Symbol.for("react.memo_cache_sentinel")?(se=f(c=>{M(c.currentTarget.value)},"t10"),e[14]=se):se=e[14];let Se=se,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=f(c=>{Xe(c.currentTarget.checked)},"t11"),e[15]=ae):ae=e[15];let Ee=ae,oe;e[16]!==xe?(oe=f(()=>{fe(xe())},"t12"),e[16]=xe,e[17]=oe):oe=e[17];let _e=oe,re;e[18]!==ye?(re=f(c=>{let{id:q}=c.currentTarget.dataset;q!==void 0&&fe(ye(q))},"t13"),e[18]=ye,e[19]=re):re=e[19];let Te=re,le;e[20]!==be?(le=f(()=>{fe(be())},"t14"),e[20]=be,e[21]=le):le=e[21];let Ce=le,et="flex flex-col gap-6",tt="lunora-queues-panel",B;e[22]!==a||e[23]!==l?(B=(0,t.jsxDEV)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(c=>(0,t.jsxDEV)(V,{"aria-selected":l===c,"data-tab":c,"data-testid":`queues-tab-${c}`,onClick:Ze,role:"tab",size:"sm",type:"button",variant:l===c?"secondary":"ghost",children:ht(c,a)},c,!1))},void 0,!1),e[22]=a,e[23]=l,e[24]=B):B=e[24];let R;e[25]!==ge||e[26]!==ve?(R=ge!==null&&(0,t.jsxDEV)(Pe,{error:ve,testId:"queues-error"},void 0,!1),e[25]=ge,e[26]=ve,e[27]=R):R=e[27];let Qe=D&&(0,t.jsxDEV)(Ge,{icon:(0,t.jsxDEV)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"},void 0,!1),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[Q.length>0&&(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("p",{className:"font-medium",children:a("No dead-letter queue on {queues}.",{queues:Q.map(qt).join(", ")})},void 0,!1),(0,t.jsxDEV)("p",{className:"text-muted-foreground",children:a("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")},void 0,!1)]},void 0,!0),C>0&&(0,t.jsxDEV)("p",{className:Q.length>0?"text-muted-foreground":"font-medium",children:C===1?a("1 message was recently dead-lettered."):a("{count} messages were recently dead-lettered.",{count:C})},void 0,!1)]},void 0,!0)},void 0,!1),$;e[28]!==S||e[29]!==p||e[30]!==l?($=l==="declared"&&(0,t.jsxDEV)(pt,{loaded:p!==void 0,queues:S},void 0,!1),e[28]=S,e[29]=p,e[30]=l,e[31]=$):$=e[31];let O;e[32]!==A||e[33]!==v||e[34]!==Ce||e[35]!==Te||e[36]!==pe||e[37]!==l?(O=l==="messages"&&(0,t.jsxDEV)(vt,{hasError:v!==null,messages:A,onClear:Ce,onReplay:Te,replayingId:pe},void 0,!1),e[32]=A,e[33]=v,e[34]=Ce,e[35]=Te,e[36]=pe,e[37]=l,e[38]=O):O=e[38];let k;e[39]!==G||e[40]!==I||e[41]!==T||e[42]!==Ee||e[43]!==qe||e[44]!==Se||e[45]!==Ne||e[46]!==_e||e[47]!==S||e[48]!==H||e[49]!==he||e[50]!==l?(k=l==="send"&&(0,t.jsxDEV)(xt,{batchMode:G,bodyText:I,delayText:T,onBatchModeChange:Ee,onBodyChange:qe,onDelayChange:Se,onSelectExport:Ne,onSend:_e,queues:S,selectedExportName:H,sending:he},void 0,!1),e[39]=G,e[40]=I,e[41]=T,e[42]=Ee,e[43]=qe,e[44]=Se,e[45]=Ne,e[46]=_e,e[47]=S,e[48]=H,e[49]=he,e[50]=l,e[51]=k):k=e[51];let ne;return e[52]!==B||e[53]!==R||e[54]!==Qe||e[55]!==$||e[56]!==O||e[57]!==k?(ne=(0,t.jsxDEV)("div",{className:et,"data-testid":tt,children:[B,R,Qe,$,O,k]},void 0,!0),e[52]=B,e[53]=R,e[54]=Qe,e[55]=$,e[56]=O,e[57]=k,e[58]=ne):ne=e[58],ne},"QueuesPanel");function yt(o){return(0,t.jsxDEV)(j,{"data-testid":`queues-row-${o.exportName}`,children:[(0,t.jsxDEV)(_,{className:"font-mono text-xs",children:o.exportName},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.name},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.mode},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.binding},void 0,!1),(0,t.jsxDEV)(_,{className:"font-mono text-xs text-muted-foreground",children:o.deadLetterQueue??"\u2014"},void 0,!1)]},o.exportName,!0)}f(yt,"_temp");function bt(o){return(0,t.jsxDEV)("option",{value:o.exportName,children:o.exportName},o.exportName,!1)}f(bt,"_temp2");function Nt(o,e){return o.exportName.localeCompare(e.exportName)}f(Nt,"_temp3");function qt(o){return o.name}f(qt,"_temp4");export{Ut as default};
@@ -1,3 +1,3 @@
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(`
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-MHGJUKCZ.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};