@lunora/studio 1.0.0-alpha.374 → 1.0.0-alpha.376

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 (93) hide show
  1. package/dist/index.d.mts +4 -3
  2. package/dist/index.d.ts +4 -3
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.mjs +1 -1
  5. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  6. package/dist/packem_chunks/MailPanel.mjs +1 -1
  7. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  8. package/dist/packem_chunks/TableEditor.mjs +1 -1
  9. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  10. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  11. package/dist/packem_chunks/kv-browser.mjs +1 -1
  12. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  13. package/dist/packem_chunks/payments-panel.mjs +1 -1
  14. package/dist/packem_chunks/queues-panel.mjs +1 -1
  15. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  16. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  17. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  18. package/dist/packem_chunks/users-panel.mjs +1 -1
  19. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs +1 -0
  20. package/dist/packem_shared/{DataBrowser-BrRWqnCr.mjs → DataBrowser-BR2nrvMW.mjs} +1 -1
  21. package/dist/packem_shared/GlobalDataBrowser-Df5S1NxG.mjs +1 -0
  22. package/dist/packem_shared/{ScheduledJobs-QCTRdugp.mjs → ScheduledJobs-Du8ZGL7v.mjs} +1 -1
  23. package/dist/packem_shared/{Studio-pDEG4JTx.mjs → Studio-JuMI1hpi.mjs} +1 -1
  24. package/dist/packem_shared/{StudioApp-C4IOJPR6.mjs → StudioApp-02dw_keu.mjs} +1 -1
  25. package/dist/packem_shared/{studio-DE7i2--m.mjs → studio-DtxNxSjs.mjs} +1 -1
  26. package/dist/packem_shared/{table-list-sidebar-DUnCjFL7.mjs → table-list-sidebar-C8qPvzGk.mjs} +1 -1
  27. package/dist/standalone/{chunk-4EQAUONF.js → chunk-2BQNNRAP.js} +1 -1
  28. package/dist/standalone/{chunk-USVLFLZL.js → chunk-3BQ6FMEA.js} +2 -2
  29. package/dist/standalone/{chunk-HCWB4UDT.js → chunk-3D2E7WXH.js} +1 -1
  30. package/dist/standalone/{chunk-QMULO5AP.js → chunk-4DIRNQHR.js} +1 -1
  31. package/dist/standalone/{chunk-QN66FO5B.js → chunk-64LU3VU6.js} +1 -1
  32. package/dist/standalone/{chunk-FK2S7VR4.js → chunk-6BH5TIGF.js} +1 -1
  33. package/dist/standalone/{chunk-ILSJ22BK.js → chunk-7LCGAQWG.js} +1 -1
  34. package/dist/standalone/{chunk-GH6CI2P2.js → chunk-AFVVESAA.js} +1 -1
  35. package/dist/standalone/{chunk-NGGTRLCC.js → chunk-ALNEZ5D2.js} +1 -1
  36. package/dist/standalone/chunk-AQ62YJJ5.js +1 -0
  37. package/dist/standalone/{chunk-TDJQ7HQM.js → chunk-B3TXCZUI.js} +1 -1
  38. package/dist/standalone/{chunk-PIOHOROI.js → chunk-B4PRNI7H.js} +1 -1
  39. package/dist/standalone/{chunk-52ULLZJX.js → chunk-BE3FD3E6.js} +1 -1
  40. package/dist/standalone/{chunk-OODTH4NA.js → chunk-BYUXIOPZ.js} +1 -1
  41. package/dist/standalone/{chunk-PIQ4A4BZ.js → chunk-CCETXQNF.js} +1 -1
  42. package/dist/standalone/{chunk-LR2FBYCC.js → chunk-CHIQ3CJZ.js} +1 -1
  43. package/dist/standalone/{chunk-TUFOWHEF.js → chunk-CLQKKJHL.js} +1 -1
  44. package/dist/standalone/{chunk-RKPVI2PI.js → chunk-CURIWKKC.js} +1 -1
  45. package/dist/standalone/{chunk-4B54WP4R.js → chunk-CZA2P2TU.js} +1 -1
  46. package/dist/standalone/{chunk-N7EIHD3H.js → chunk-EVJSGZXV.js} +1 -1
  47. package/dist/standalone/{chunk-RHYQB4RH.js → chunk-EYJX6GXU.js} +1 -1
  48. package/dist/standalone/{chunk-FGZ73BFG.js → chunk-EYMLYHWK.js} +1 -1
  49. package/dist/standalone/{chunk-XZHTVLDG.js → chunk-F4S2YEYW.js} +1 -1
  50. package/dist/standalone/{chunk-2CPMCEHD.js → chunk-FEHRNTIU.js} +1 -1
  51. package/dist/standalone/{chunk-FT3BWJVP.js → chunk-FERYOTLW.js} +1 -1
  52. package/dist/standalone/{chunk-WFXS3YRM.js → chunk-G6VBT4AU.js} +1 -1
  53. package/dist/standalone/{chunk-KYN4A72O.js → chunk-GMT66LBU.js} +1 -1
  54. package/dist/standalone/{chunk-ZCOMJH2I.js → chunk-HAK2T6YN.js} +1 -1
  55. package/dist/standalone/{chunk-SKZNH5QQ.js → chunk-HSI24FPH.js} +1 -1
  56. package/dist/standalone/{chunk-6VOBO5QL.js → chunk-JIBRGVA7.js} +1 -1
  57. package/dist/standalone/{chunk-XITLHKKR.js → chunk-JYCGHNPF.js} +1 -1
  58. package/dist/standalone/{chunk-JPCVFWR5.js → chunk-K3MVWN6E.js} +1 -1
  59. package/dist/standalone/{chunk-R52GVSS2.js → chunk-K46QTJR6.js} +1 -1
  60. package/dist/standalone/{chunk-MJWIIV2C.js → chunk-LKML3CX4.js} +1 -1
  61. package/dist/standalone/{chunk-LCIDEYA4.js → chunk-LQCF6SZW.js} +1 -1
  62. package/dist/standalone/{chunk-LFKKTGEF.js → chunk-N3FNOCHB.js} +1 -1
  63. package/dist/standalone/{chunk-EAPNLM2Q.js → chunk-OT2YNQPU.js} +1 -1
  64. package/dist/standalone/{chunk-4ADB7TWC.js → chunk-PEVNCIZQ.js} +1 -1
  65. package/dist/standalone/chunk-PFPJA2HR.js +7 -0
  66. package/dist/standalone/{chunk-RUQTILJN.js → chunk-PUU56AIE.js} +1 -1
  67. package/dist/standalone/{chunk-JB3DZ2PJ.js → chunk-PYQUCCUO.js} +1 -1
  68. package/dist/standalone/{chunk-QNY5EEBN.js → chunk-QAQ3KMY6.js} +1 -1
  69. package/dist/standalone/{chunk-WJA2IGZC.js → chunk-QGAWQTUE.js} +1 -1
  70. package/dist/standalone/{chunk-DDTWGWM4.js → chunk-QURCU2N2.js} +1 -1
  71. package/dist/standalone/{chunk-CBACG4XF.js → chunk-QXNMGPXW.js} +1 -1
  72. package/dist/standalone/{chunk-HZU4WF4X.js → chunk-R3P6KKUH.js} +1 -1
  73. package/dist/standalone/{chunk-2U6Z7A6C.js → chunk-RTE7SDRS.js} +1 -1
  74. package/dist/standalone/{chunk-PGJOTPWC.js → chunk-RWMOWRJX.js} +1 -1
  75. package/dist/standalone/{chunk-XWVFKYZV.js → chunk-SW52HGM4.js} +1 -1
  76. package/dist/standalone/{chunk-CGXIERYO.js → chunk-SWFSB4QT.js} +1 -1
  77. package/dist/standalone/{chunk-2IOS27FL.js → chunk-SZBLYYV6.js} +1 -1
  78. package/dist/standalone/{chunk-DHH7WHXQ.js → chunk-UBTKEHX6.js} +1 -1
  79. package/dist/standalone/{chunk-6IRGBPDN.js → chunk-UVNJG3UL.js} +1 -1
  80. package/dist/standalone/{chunk-VDSTHVWZ.js → chunk-W2FHSEQW.js} +1 -1
  81. package/dist/standalone/{chunk-LA76GGAT.js → chunk-WAIESA3E.js} +1 -1
  82. package/dist/standalone/{chunk-MTX62MQ7.js → chunk-WB6VGH7X.js} +1 -1
  83. package/dist/standalone/{chunk-3BQD5ITB.js → chunk-X45MVUVK.js} +1 -1
  84. package/dist/standalone/{chunk-IELLWQGA.js → chunk-X72A525Z.js} +1 -1
  85. package/dist/standalone/{chunk-G5REMLEG.js → chunk-YTPE33AO.js} +1 -1
  86. package/dist/standalone/{chunk-Z6WEYWT7.js → chunk-ZCXG3567.js} +1 -1
  87. package/dist/standalone/{chunk-RDS72J4I.js → chunk-ZFEDRJ7R.js} +1 -1
  88. package/dist/standalone/studio.js +1 -1
  89. package/package.json +4 -4
  90. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs +0 -1
  91. package/dist/packem_shared/GlobalDataBrowser-DB1B-WAN.mjs +0 -1
  92. package/dist/standalone/chunk-ACWAMBGT.js +0 -1
  93. package/dist/standalone/chunk-ODLNNVP2.js +0 -7
@@ -1 +1 @@
1
- import{c as G}from"react/compiler-runtime";import{useState as P}from"react";import{B as L}from"../packem_shared/button-q0UYSmrn.mjs";import{a as _t,C as Tt}from"../packem_shared/card-By2O8ULa.mjs";import{E as Xe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as ce,a as $t,b as ht,e as fe,d as Mt,T as Rt}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Ve}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as Bt}from"../packem_shared/use-auth-config-CG7VvAvQ.mjs";import{useAutoRefresh as We,settlePolls as Qt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{l as A,f as kt,b as Jt,h as Ut}from"../packem_shared/internal-hIuTpSbx.mjs";import{u as Gt,A as Et}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{I as X}from"../packem_shared/input-CXhxesPC.mjs";import{L as Ht}from"../packem_shared/label-DKFzyHq6.mjs";import{M as Zt}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{T as Ft}from"../packem_shared/textarea--40GKAyz.mjs";import{u as me}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";import{jsx as s,jsxs as E,Fragment as bt}from"react/jsx-runtime";const Pt=t=>{const e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},qt=t=>{const e=Pt(t),l={};for(const[d,u]of Object.entries(e)){if(!Array.isArray(u)||u.some(n=>typeof n!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);l[d]=u}return l},jt=t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),W=t=>{const e=G(6),{children:l,htmlFor:d,label:u}=t;let n;e[0]!==d||e[1]!==u?(n=s(Ht,{htmlFor:d,children:u}),e[0]=d,e[1]=u,e[2]=n):n=e[2];let o;return e[3]!==l||e[4]!==n?(o=E("div",{className:"flex flex-col gap-1",children:[n,l]}),e[3]=l,e[4]=n,e[5]=o):o=e[5],o},de=({busy:t,canSubmit:e,children:l,destructive:d=!1,error:u,onClose:n,onSubmit:o,submitLabel:i,testId:r,title:m})=>{const a=q();return E(Zt,{label:m,onClose:n,panelTestId:`${r}-panel`,testId:`${r}-overlay`,variant:"dialog",children:[s("h2",{className:"text-sm font-semibold text-foreground",children:m}),l,u!==null&&s("p",{className:"text-sm text-destructive","data-testid":`${r}-error`,role:"alert",children:u}),E("div",{className:"flex justify-end gap-2 pt-1",children:[s(L,{"data-testid":`${r}-cancel`,onClick:n,size:"sm",type:"button",variant:"outline",children:a("Cancel")}),s(L,{"data-testid":`${r}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?a("Saving…"):i})]})]})},Dt=t=>{const e=G(79),{mode:l,onClose:d,onDone:u,org:n}=t,o=ae(),i=q(),{busy:r,error:m,run:a}=me();let h;e[0]!==n?(h=n?A(n.name):"",e[0]=n,e[1]=h):h=e[1];const[c,g]=P(h);let p;e[2]!==n?(p=n?A(n.slug):"",e[2]=n,e[3]=p):p=e[3];const[f,b]=P(p);let S;e[4]!==n?(S=n?A(n.logo):"",e[4]=n,e[5]=S):S=e[5];const[v,y]=P(S),[x,I]=P("");let C;e[6]!==l||e[7]!==n?.metadata?(C=l==="edit"?jt(n?.metadata):"",e[6]=l,e[7]=n?.metadata,e[8]=C):C=e[8];const[w,k]=P(C);let O;e[9]!==o||e[10]!==v||e[11]!==w||e[12]!==l||e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==n?.id||e[17]!==x||e[18]!==a||e[19]!==f?(O=()=>{a(async()=>{const D=w.trim()===""?void 0:Pt(w);l==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:D,name:c.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:D,name:c.trim()===""?void 0:c.trim(),organizationId:A(n?.id),slug:f.trim()===""?void 0:f.trim()}),u(),d()})},e[9]=o,e[10]=v,e[11]=w,e[12]=l,e[13]=c,e[14]=d,e[15]=u,e[16]=n?.id,e[17]=x,e[18]=a,e[19]=f,e[20]=O):O=e[20];const z=O;let N;e[21]!==l||e[22]!==c?(N=c.trim()!==""||l==="edit",e[21]=l,e[22]=c,e[23]=N):N=e[23];let _;e[24]!==l||e[25]!==i?(_=i(l==="create"?"Create":"Save"),e[24]=l,e[25]=i,e[26]=_):_=e[26];let T;e[27]!==l||e[28]!==i?(T=i(l==="create"?"New organization":"Edit organization"),e[27]=l,e[28]=i,e[29]=T):T=e[29];let R;e[30]!==i?(R=i("name"),e[30]=i,e[31]=R):R=e[31];let H;e[32]===Symbol.for("react.memo_cache_sentinel")?(H=D=>{g(D.target.value)},e[32]=H):H=e[32];let B;e[33]!==c?(B=s(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:H,value:c}),e[33]=c,e[34]=B):B=e[34];let U;e[35]!==B||e[36]!==R?(U=s(W,{htmlFor:"org-form-name",label:R,children:B}),e[35]=B,e[36]=R,e[37]=U):U=e[37];let Q;e[38]!==i?(Q=i("Slug (optional — derived from name)"),e[38]=i,e[39]=Q):Q=e[39];let F;e[40]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{b(D.target.value)},e[40]=F):F=e[40];let J;e[41]!==f?(J=s(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:F,value:f}),e[41]=f,e[42]=J):J=e[42];let j;e[43]!==Q||e[44]!==J?(j=s(W,{htmlFor:"org-form-slug",label:Q,children:J}),e[43]=Q,e[44]=J,e[45]=j):j=e[45];let Z;e[46]!==i?(Z=i("Logo URL (optional)"),e[46]=i,e[47]=Z):Z=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=D=>{y(D.target.value)},e[48]=M):M=e[48];let $;e[49]!==v?($=s(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:v}),e[49]=v,e[50]=$):$=e[50];let K;e[51]!==Z||e[52]!==$?(K=s(W,{htmlFor:"org-form-logo",label:Z,children:$}),e[51]=Z,e[52]=$,e[53]=K):K=e[53];let Y;e[54]!==l||e[55]!==x||e[56]!==i?(Y=l==="create"&&s(W,{htmlFor:"org-form-owner",label:i("Owner user id (optional)"),children:s(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:D=>{I(D.target.value)},value:x})}),e[54]=l,e[55]=x,e[56]=i,e[57]=Y):Y=e[57];let te;e[58]!==i?(te=i("Metadata (JSON, optional)"),e[58]=i,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=D=>{k(D.target.value)},e[60]=oe):oe=e[60];let le;e[61]!==w?(le=s(Ft,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:w}),e[61]=w,e[62]=le):le=e[62];let ee;e[63]!==te||e[64]!==le?(ee=s(W,{htmlFor:"org-form-metadata",label:te,children:le}),e[63]=te,e[64]=le,e[65]=ee):ee=e[65];let ie;return e[66]!==r||e[67]!==m||e[68]!==d||e[69]!==z||e[70]!==U||e[71]!==j||e[72]!==K||e[73]!==Y||e[74]!==ee||e[75]!==N||e[76]!==_||e[77]!==T?(ie=E(de,{busy:r,canSubmit:N,error:m,onClose:d,onSubmit:z,submitLabel:_,testId:"org-form",title:T,children:[U,j,K,Y,ee]}),e[66]=r,e[67]=m,e[68]=d,e[69]=z,e[70]=U,e[71]=j,e[72]=K,e[73]=Y,e[74]=ee,e[75]=N,e[76]=_,e[77]=T,e[78]=ie):ie=e[78],ie},Kt=t=>{const e=G(40),{onClose:l,onDone:d,organizationId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P(""),[c,g]=P("");let p;e[0]!==n||e[1]!==l||e[2]!==d||e[3]!==u||e[4]!==c||e[5]!==m||e[6]!==a?(p=()=>{m(async()=>{await n.addAuthOrgMember({organizationId:u,role:c.trim()===""?void 0:c.trim(),userId:a.trim()}),d(),l()})},e[0]=n,e[1]=l,e[2]=d,e[3]=u,e[4]=c,e[5]=m,e[6]=a,e[7]=p):p=e[7];const f=p;let b;e[8]!==a?(b=a.trim(),e[8]=a,e[9]=b):b=e[9];const S=b!=="";let v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=e[11];let y;e[12]!==o?(y=o("Add member"),e[12]=o,e[13]=y):y=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=T=>{h(T.target.value)},e[16]=I):I=e[16];let C;e[17]!==a?(C=s(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:I,value:a}),e[17]=a,e[18]=C):C=e[18];let w;e[19]!==x||e[20]!==C?(w=s(W,{htmlFor:"org-add-member-user",label:x,children:C}),e[19]=x,e[20]=C,e[21]=w):w=e[21];let k;e[22]!==o?(k=o("Role (optional)"),e[22]=o,e[23]=k):k=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{g(T.target.value)},e[24]=O):O=e[24];let z;e[25]!==c?(z=s(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:O,value:c}),e[25]=c,e[26]=z):z=e[26];let N;e[27]!==k||e[28]!==z?(N=s(W,{htmlFor:"org-add-member-role",label:k,children:z}),e[27]=k,e[28]=z,e[29]=N):N=e[29];let _;return e[30]!==i||e[31]!==r||e[32]!==l||e[33]!==f||e[34]!==N||e[35]!==S||e[36]!==v||e[37]!==y||e[38]!==w?(_=E(de,{busy:i,canSubmit:S,error:r,onClose:l,onSubmit:f,submitLabel:v,testId:"org-add-member",title:y,children:[w,N]}),e[30]=i,e[31]=r,e[32]=l,e[33]=f,e[34]=N,e[35]=S,e[36]=v,e[37]=y,e[38]=w,e[39]=_):_=e[39],_},Vt=t=>{const e=G(40),{onClose:l,onDone:d,organizationId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P(""),[c,g]=P("");let p;e[0]!==n||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==m?(p=()=>{m(async()=>{await n.inviteAuthOrgMember({email:a.trim(),organizationId:u,role:c.trim()===""?void 0:c.trim()}),d(),l()})},e[0]=n,e[1]=a,e[2]=l,e[3]=d,e[4]=u,e[5]=c,e[6]=m,e[7]=p):p=e[7];const f=p;let b;e[8]!==a?(b=a.trim(),e[8]=a,e[9]=b):b=e[9];const S=b!=="";let v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=e[11];let y;e[12]!==o?(y=o("Invite member"),e[12]=o,e[13]=y):y=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=T=>{h(T.target.value)},e[16]=I):I=e[16];let C;e[17]!==a?(C=s(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:I,type:"email",value:a}),e[17]=a,e[18]=C):C=e[18];let w;e[19]!==x||e[20]!==C?(w=s(W,{htmlFor:"org-invite-member-email",label:x,children:C}),e[19]=x,e[20]=C,e[21]=w):w=e[21];let k;e[22]!==o?(k=o("Role (optional)"),e[22]=o,e[23]=k):k=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{g(T.target.value)},e[24]=O):O=e[24];let z;e[25]!==c?(z=s(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:O,value:c}),e[25]=c,e[26]=z):z=e[26];let N;e[27]!==k||e[28]!==z?(N=s(W,{htmlFor:"org-invite-member-role",label:k,children:z}),e[27]=k,e[28]=z,e[29]=N):N=e[29];let _;return e[30]!==i||e[31]!==r||e[32]!==l||e[33]!==f||e[34]!==N||e[35]!==S||e[36]!==v||e[37]!==y||e[38]!==w?(_=E(de,{busy:i,canSubmit:S,error:r,onClose:l,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:y,children:[w,N]}),e[30]=i,e[31]=r,e[32]=l,e[33]=f,e[34]=N,e[35]=S,e[36]=v,e[37]=y,e[38]=w,e[39]=_):_=e[39],_},Wt=t=>{const e=G(32),{member:l,onClose:d,onDone:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me();let a;e[0]!==l.role?(a=()=>A(l.role),e[0]=l.role,e[1]=a):a=e[1];const[h,c]=P(a);let g;e[2]!==n||e[3]!==l.id||e[4]!==d||e[5]!==u||e[6]!==h||e[7]!==m?(g=()=>{m(async()=>{await n.setAuthOrgMemberRole({memberId:A(l.id),role:h.trim()}),u(),d()})},e[2]=n,e[3]=l.id,e[4]=d,e[5]=u,e[6]=h,e[7]=m,e[8]=g):g=e[8];const p=g;let f;e[9]!==h?(f=h.trim(),e[9]=h,e[10]=f):f=e[10];const b=f!=="";let S;e[11]!==o?(S=o("Save"),e[11]=o,e[12]=S):S=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=e[14];let y;e[15]!==o?(y=o("Role"),e[15]=o,e[16]=y):y=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=k=>{c(k.target.value)},e[17]=x):x=e[17];let I;e[18]!==h?(I=s(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:h}),e[18]=h,e[19]=I):I=e[19];let C;e[20]!==y||e[21]!==I?(C=s(W,{htmlFor:"org-member-role-value",label:y,children:I}),e[20]=y,e[21]=I,e[22]=C):C=e[22];let w;return e[23]!==i||e[24]!==r||e[25]!==d||e[26]!==p||e[27]!==C||e[28]!==b||e[29]!==S||e[30]!==v?(w=s(de,{busy:i,canSubmit:b,error:r,onClose:d,onSubmit:p,submitLabel:S,testId:"org-member-role",title:v,children:C}),e[23]=i,e[24]=r,e[25]=d,e[26]=p,e[27]=C,e[28]=b,e[29]=S,e[30]=v,e[31]=w):w=e[31],w},zt=t=>{const e=G(36),{mode:l,onClose:d,onDone:u,organizationId:n,team:o}=t,i=ae(),r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==o?(c=o?A(o.name):"",e[0]=o,e[1]=c):c=e[1];const[g,p]=P(c);let f;e[2]!==i||e[3]!==l||e[4]!==g||e[5]!==d||e[6]!==u||e[7]!==n||e[8]!==h||e[9]!==o?.id?(f=()=>{h(async()=>{await(l==="create"?i.createAuthOrgTeam({name:g.trim(),organizationId:n}):i.updateAuthOrgTeam({name:g.trim(),teamId:A(o?.id)})),u(),d()})},e[2]=i,e[3]=l,e[4]=g,e[5]=d,e[6]=u,e[7]=n,e[8]=h,e[9]=o?.id,e[10]=f):f=e[10];const b=f;let S;e[11]!==g?(S=g.trim(),e[11]=g,e[12]=S):S=e[12];const v=S!=="";let y;e[13]!==l||e[14]!==r?(y=r(l==="create"?"Create":"Save"),e[13]=l,e[14]=r,e[15]=y):y=e[15];let x;e[16]!==l||e[17]!==r?(x=r(l==="create"?"New team":"Rename team"),e[16]=l,e[17]=r,e[18]=x):x=e[18];let I;e[19]!==r?(I=r("name"),e[19]=r,e[20]=I):I=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=z=>{p(z.target.value)},e[21]=C):C=e[21];let w;e[22]!==g?(w=s(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:C,value:g}),e[22]=g,e[23]=w):w=e[23];let k;e[24]!==I||e[25]!==w?(k=s(W,{htmlFor:"org-team-form-name",label:I,children:w}),e[24]=I,e[25]=w,e[26]=k):k=e[26];let O;return e[27]!==m||e[28]!==a||e[29]!==d||e[30]!==b||e[31]!==k||e[32]!==v||e[33]!==y||e[34]!==x?(O=s(de,{busy:m,canSubmit:v,error:a,onClose:d,onSubmit:b,submitLabel:y,testId:"org-team-form",title:x,children:k}),e[27]=m,e[28]=a,e[29]=d,e[30]=b,e[31]=k,e[32]=v,e[33]=y,e[34]=x,e[35]=O):O=e[35],O},Xt=t=>{const e=G(30),{onClose:l,onDone:d,teamId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P("");let c;e[0]!==n||e[1]!==l||e[2]!==d||e[3]!==m||e[4]!==u||e[5]!==a?(c=()=>{m(async()=>{await n.addAuthOrgTeamMember({teamId:u,userId:a.trim()}),d(),l()})},e[0]=n,e[1]=l,e[2]=d,e[3]=m,e[4]=u,e[5]=a,e[6]=c):c=e[6];const g=c;let p;e[7]!==a?(p=a.trim(),e[7]=a,e[8]=p):p=e[8];const f=p!=="";let b;e[9]!==o?(b=o("Add member"),e[9]=o,e[10]=b):b=e[10];let S;e[11]!==o?(S=o("Add team member"),e[11]=o,e[12]=S):S=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=w=>{h(w.target.value)},e[15]=y):y=e[15];let x;e[16]!==a?(x=s(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:y,value:a}),e[16]=a,e[17]=x):x=e[17];let I;e[18]!==v||e[19]!==x?(I=s(W,{htmlFor:"org-team-add-member-user",label:v,children:x}),e[18]=v,e[19]=x,e[20]=I):I=e[20];let C;return e[21]!==i||e[22]!==r||e[23]!==l||e[24]!==g||e[25]!==f||e[26]!==b||e[27]!==S||e[28]!==I?(C=s(de,{busy:i,canSubmit:f,error:r,onClose:l,onSubmit:g,submitLabel:b,testId:"org-team-add-member",title:S,children:I}),e[21]=i,e[22]=r,e[23]=l,e[24]=g,e[25]=f,e[26]=b,e[27]=S,e[28]=I,e[29]=C):C=e[29],C},At=t=>{const e=G(47),{mode:l,onClose:d,onDone:u,organizationId:n,role:o}=t,i=ae(),r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==o?(c=o?A(o.role):"",e[0]=o,e[1]=c):c=e[1];const[g,p]=P(c);let f;e[2]!==l||e[3]!==o?.permission?(f=l==="edit"?jt(o?.permission):"",e[2]=l,e[3]=o?.permission,e[4]=f):f=e[4];const[b,S]=P(f);let v;e[5]!==i||e[6]!==l||e[7]!==g||e[8]!==d||e[9]!==u||e[10]!==n||e[11]!==b||e[12]!==o?.id||e[13]!==h?(v=()=>{h(async()=>{const T=qt(b);await(l==="create"?i.createAuthOrgRole({organizationId:n,permission:T,role:g.trim()}):i.updateAuthOrgRole({permission:T,roleId:A(o?.id)})),u(),d()})},e[5]=i,e[6]=l,e[7]=g,e[8]=d,e[9]=u,e[10]=n,e[11]=b,e[12]=o?.id,e[13]=h,e[14]=v):v=e[14];const y=v;let x;e[15]!==l||e[16]!==g||e[17]!==b?(x=b.trim()!==""&&(l==="edit"||g.trim()!==""),e[15]=l,e[16]=g,e[17]=b,e[18]=x):x=e[18];let I;e[19]!==l||e[20]!==r?(I=r(l==="create"?"Create":"Save"),e[19]=l,e[20]=r,e[21]=I):I=e[21];let C;e[22]!==l||e[23]!==r?(C=r(l==="create"?"New role":"Edit role"),e[22]=l,e[23]=r,e[24]=C):C=e[24];let w;e[25]!==l||e[26]!==g||e[27]!==r?(w=l==="create"&&s(W,{htmlFor:"org-role-form-name",label:r("Role name"),children:s(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:T=>{p(T.target.value)},value:g})}),e[25]=l,e[26]=g,e[27]=r,e[28]=w):w=e[28];let k;e[29]!==r?(k=r('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=r,e[30]=k):k=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{S(T.target.value)},e[31]=O):O=e[31];let z;e[32]!==b?(z=s(Ft,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:O,value:b}),e[32]=b,e[33]=z):z=e[33];let N;e[34]!==z||e[35]!==k?(N=s(W,{htmlFor:"org-role-form-permission",label:k,children:z}),e[34]=z,e[35]=k,e[36]=N):N=e[36];let _;return e[37]!==m||e[38]!==a||e[39]!==d||e[40]!==y||e[41]!==N||e[42]!==x||e[43]!==I||e[44]!==C||e[45]!==w?(_=E(de,{busy:m,canSubmit:x,error:a,onClose:d,onSubmit:y,submitLabel:I,testId:"org-role-form",title:C,children:[w,N]}),e[37]=m,e[38]=a,e[39]=d,e[40]=y,e[41]=N,e[42]=x,e[43]=I,e[44]=C,e[45]=w,e[46]=_):_=e[46],_},Lt=t=>{const e=G(18),{action:l,message:d,onClose:u,onDone:n,testId:o,title:i}=t,r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==l||e[1]!==u||e[2]!==n||e[3]!==h?(c=()=>{h(async()=>{await l(),n(),u()})},e[0]=l,e[1]=u,e[2]=n,e[3]=h,e[4]=c):c=e[4];const g=c;let p;e[5]!==r?(p=r("Delete"),e[5]=r,e[6]=p):p=e[6];let f;e[7]!==d?(f=s("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let b;return e[9]!==m||e[10]!==a||e[11]!==u||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==i?(b=s(de,{busy:m,canSubmit:!0,destructive:!0,error:a,onClose:u,onSubmit:g,submitLabel:p,testId:o,title:i,children:f}),e[9]=m,e[10]=a,e[11]=u,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=i,e[17]=b):b=e[17],b},Ye=t=>{const e=G(13),{action:l,children:d,heading:u,testId:n}=t;let o;e[0]!==u?(o=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=o):o=e[1];let i;e[2]!==l?(i=l!==void 0&&s("div",{className:"flex items-center gap-2",children:l}),e[2]=l,e[3]=i):i=e[3];let r;e[4]!==o||e[5]!==i?(r=E("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=r):r=e[6];let m;e[7]!==d?(m=s(_t,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let a;return e[9]!==r||e[10]!==m||e[11]!==n?(a=E(Tt,{className:"overflow-hidden py-0","data-testid":n,children:[r,m]}),e[9]=r,e[10]=m,e[11]=n,e[12]=a):a=e[12],a},et=t=>{const e=G(23),{columns:l,rowActions:d,rowPrefix:u,rows:n}=t,o=q();let i;e[0]!==l?(i=l.map(Yt),e[0]=l,e[1]=i):i=e[1];let r;e[2]!==o?(r=o("Actions"),e[2]=o,e[3]=r):r=e[3];let m;e[4]!==r?(m=s(ce,{"aria-label":r}),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==m?(a=s($t,{children:E(ht,{children:[i,m]})}),e[6]=i,e[7]=m,e[8]=a):a=e[8];let h;if(e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n){let p;e[14]!==l||e[15]!==d||e[16]!==u?(p=(f,b)=>{const S=A(f.id),v=S===""?`index-${b.toString()}`:S;return E(ht,{"data-testid":`${u}-${v}`,children:[l.map(y=>s(fe,{className:y.className,children:y.render(f)},y.head)),s(fe,{children:s("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},e[14]=l,e[15]=d,e[16]=u,e[17]=p):p=e[17],h=n.map(p),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=h}else h=e[13];let c;e[18]!==h?(c=s(Mt,{children:h}),e[18]=h,e[19]=c):c=e[19];let g;return e[20]!==a||e[21]!==c?(g=E(Rt,{children:[a,c]}),e[20]=a,e[21]=c,e[22]=g):g=e[22],g};function Yt(t){return s(ce,{children:t.head},t.head)}const el=t=>{const e=G(30),{actionBusy:l,onRemoveMember:d,memberColumns:u,members:n,onDialog:o}=t,i=q();let r;e[0]!==o?(r=()=>{o({kind:"add-member"})},e[0]=o,e[1]=r):r=e[1];let m;e[2]!==i?(m=i("Add member"),e[2]=i,e[3]=m):m=e[3];let a;e[4]!==r||e[5]!==m?(a=s(L,{"data-testid":"org-open-add-member",onClick:r,size:"xs",type:"button",variant:"outline",children:m}),e[4]=r,e[5]=m,e[6]=a):a=e[6];let h;e[7]!==o?(h=()=>{o({kind:"invite-member"})},e[7]=o,e[8]=h):h=e[8];let c;e[9]!==i?(c=i("Invite member"),e[9]=i,e[10]=c):c=e[10];let g;e[11]!==h||e[12]!==c?(g=s(L,{"data-testid":"org-open-invite-member",onClick:h,size:"xs",type:"button",variant:"outline",children:c}),e[11]=h,e[12]=c,e[13]=g):g=e[13];let p;e[14]!==a||e[15]!==g?(p=E(bt,{children:[a,g]}),e[14]=a,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==i?(f=i("Members"),e[17]=i,e[18]=f):f=e[18];let b;e[19]!==l||e[20]!==u||e[21]!==n||e[22]!==o||e[23]!==d||e[24]!==i?(b=n.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-members-empty",title:i("No members.")})}):s(et,{columns:u,rowActions:v=>E(bt,{children:[s(L,{"data-testid":`org-member-role-${A(v.id)}`,onClick:()=>{o({kind:"member-role",member:v})},size:"xs",type:"button",variant:"ghost",children:i("Change role")}),s(L,{"data-testid":`org-remove-member-${A(v.id)}`,disabled:l,onClick:()=>{d(A(v.id))},size:"xs",type:"button",variant:"ghost",children:i("Remove")})]}),rowPrefix:"org-member",rows:n}),e[19]=l,e[20]=u,e[21]=n,e[22]=o,e[23]=d,e[24]=i,e[25]=b):b=e[25];let S;return e[26]!==p||e[27]!==f||e[28]!==b?(S=s(Ye,{action:p,heading:f,testId:"org-members",children:b}),e[26]=p,e[27]=f,e[28]=b,e[29]=S):S=e[29],S},tl=t=>{const e=G(21),{onConfirmDeleteTeam:l,onDialog:d,onSelectTeam:u,selectedTeam:n,teamColumns:o,teams:i}=t,r=q();let m;e[0]!==d?(m=()=>{d({kind:"team-create"})},e[0]=d,e[1]=m):m=e[1];let a;e[2]!==r?(a=r("New team"),e[2]=r,e[3]=a):a=e[3];let h;e[4]!==m||e[5]!==a?(h=s(L,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:a}),e[4]=m,e[5]=a,e[6]=h):h=e[6];let c;e[7]!==r?(c=r("Teams"),e[7]=r,e[8]=c):c=e[8];let g;e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n||e[13]!==r||e[14]!==o||e[15]!==i?(g=i.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-teams-empty",title:r("No teams.")})}):s(et,{columns:o,rowActions:f=>E(bt,{children:[s(L,{"aria-pressed":n===A(f.id),"data-testid":`org-team-select-${A(f.id)}`,onClick:()=>{u(A(f.id))},size:"xs",type:"button",variant:"ghost",children:r("Members")}),s(L,{"data-testid":`org-team-rename-${A(f.id)}`,onClick:()=>{d({kind:"team-rename",team:f})},size:"xs",type:"button",variant:"ghost",children:r("Rename")}),s(L,{"data-testid":`org-team-delete-${A(f.id)}`,onClick:()=>{l(f)},size:"xs",type:"button",variant:"ghost",children:r("Delete")})]}),rowPrefix:"org-team",rows:i}),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=r,e[14]=o,e[15]=i,e[16]=g):g=e[16];let p;return e[17]!==h||e[18]!==c||e[19]!==g?(p=s(Ye,{action:h,heading:c,testId:"org-teams",children:g}),e[17]=h,e[18]=c,e[19]=g,e[20]=p):p=e[20],p},ll=t=>{const e=G(20),{actionBusy:l,onRemoveTeamMember:d,onDialog:u,selectedTeam:n,teamMemberColumns:o,teamMembers:i}=t,r=q();let m;e[0]!==u||e[1]!==n?(m=()=>{u({kind:"team-add-member",teamId:n})},e[0]=u,e[1]=n,e[2]=m):m=e[2];let a;e[3]!==r?(a=r("Add member"),e[3]=r,e[4]=a):a=e[4];let h;e[5]!==m||e[6]!==a?(h=s(L,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:a}),e[5]=m,e[6]=a,e[7]=h):h=e[7];let c;e[8]!==r?(c=r("Team members"),e[8]=r,e[9]=c):c=e[9];let g;e[10]!==l||e[11]!==d||e[12]!==r||e[13]!==o||e[14]!==i?(g=i.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-team-members-empty",title:r("No team members.")})}):s(et,{columns:o,rowActions:f=>s(L,{"data-testid":`org-team-remove-member-${A(f.id)}`,disabled:l,onClick:()=>{d(A(f.id))},size:"xs",type:"button",variant:"ghost",children:r("Remove")}),rowPrefix:"org-team-member",rows:i}),e[10]=l,e[11]=d,e[12]=r,e[13]=o,e[14]=i,e[15]=g):g=e[15];let p;return e[16]!==h||e[17]!==c||e[18]!==g?(p=s(Ye,{action:h,heading:c,testId:"org-team-members",children:g}),e[16]=h,e[17]=c,e[18]=g,e[19]=p):p=e[19],p},ol=t=>{const e=G(19),{onConfirmDeleteRole:l,onDialog:d,roleColumns:u,roles:n}=t,o=q();let i;e[0]!==d?(i=()=>{d({kind:"role-create"})},e[0]=d,e[1]=i):i=e[1];let r;e[2]!==o?(r=o("New role"),e[2]=o,e[3]=r):r=e[3];let m;e[4]!==i||e[5]!==r?(m=s(L,{"data-testid":"org-open-create-role",onClick:i,size:"xs",type:"button",variant:"outline",children:r}),e[4]=i,e[5]=r,e[6]=m):m=e[6];let a;e[7]!==o?(a=o("Roles"),e[7]=o,e[8]=a):a=e[8];let h;e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n||e[13]!==o?(h=n.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-roles-empty",title:o("No custom roles.")})}):s(et,{columns:u,rowActions:g=>E(bt,{children:[s(L,{"data-testid":`org-role-edit-${A(g.id)}`,onClick:()=>{d({kind:"role-edit",role:g})},size:"xs",type:"button",variant:"ghost",children:o("Edit")}),s(L,{"data-testid":`org-role-delete-${A(g.id)}`,onClick:()=>{l(A(g.id))},size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),rowPrefix:"org-role",rows:n}),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=o,e[14]=h):h=e[14];let c;return e[15]!==m||e[16]!==a||e[17]!==h?(c=s(Ye,{action:m,heading:a,testId:"org-roles",children:h}),e[15]=m,e[16]=a,e[17]=h,e[18]=c):c=e[18],c},Nt=200,il=t=>{const e=G(217),{organizationId:l,rolesEnabled:d,teamsEnabled:u}=t,n=ae(),o=q(),[i,r]=P(null),[m,a]=P(null),[h,c]=P(!1),[g,p]=P(null),[f,b]=Gt(l);let S;e[0]!==f||e[1]!==l?(S=["lunora-auth-org-members",l,f],e[0]=f,e[1]=l,e[2]=S):S=e[2];let v;e[3]!==n||e[4]!==f||e[5]!==l?(v=()=>n.listAuthOrgMembers({limit:Nt,offset:f,organizationId:l}),e[3]=n,e[4]=f,e[5]=l,e[6]=v):v=e[6];const y=Ve(S,v);let x;e[7]!==l?(x=["lunora-auth-org-invitations",l],e[7]=l,e[8]=x):x=e[8];let I;e[9]!==n||e[10]!==l?(I=()=>n.listAuthOrgInvitations({limit:200,organizationId:l}),e[9]=n,e[10]=l,e[11]=I):I=e[11];const C=Ve(x,I);let w;e[12]!==l?(w=["lunora-auth-org-teams",l],e[12]=l,e[13]=w):w=e[13];let k;e[14]!==n||e[15]!==l?(k=()=>n.listAuthOrgTeams({limit:200,organizationId:l}),e[14]=n,e[15]=l,e[16]=k):k=e[16];let O;e[17]!==u?(O={enabled:u},e[17]=u,e[18]=O):O=e[18];const z=Ve(w,k,O);let N;e[19]!==l?(N=["lunora-auth-org-roles",l],e[19]=l,e[20]=N):N=e[20];let _;e[21]!==n||e[22]!==l?(_=()=>n.listAuthOrgRoles({limit:200,organizationId:l}),e[21]=n,e[22]=l,e[23]=_):_=e[23];let T;e[24]!==d?(T={enabled:d},e[24]=d,e[25]=T):T=e[25];const R=Ve(N,_,T);let H;e[26]!==m?(H=["lunora-auth-org-team-members",m],e[26]=m,e[27]=H):H=e[27];let B;e[28]!==n||e[29]!==m?(B=()=>n.listAuthOrgTeamMembers({limit:200,teamId:m??""}),e[28]=n,e[29]=m,e[30]=B):B=e[30];const U=m!==null;let Q;e[31]!==U?(Q={enabled:U},e[31]=U,e[32]=Q):Q=e[32];const F=Ve(H,B,Q);let J;e[33]!==y.data?.rows?(J=y.data?.rows??[],e[33]=y.data?.rows,e[34]=J):J=e[34];const j=J;let Z;e[35]!==C.data?.rows?(Z=C.data?.rows??[],e[35]=C.data?.rows,e[36]=Z):Z=e[36];const M=Z;let $;e[37]!==z.data?.rows?($=z.data?.rows??[],e[37]=z.data?.rows,e[38]=$):$=e[38];const K=$;let Y;e[39]!==R.data?.rows?(Y=R.data?.rows??[],e[39]=R.data?.rows,e[40]=Y):Y=e[40];const te=Y;let oe;e[41]!==m||e[42]!==F.data?.rows?(oe=m===null?[]:F.data?.rows??[],e[41]=m,e[42]=F.data?.rows,e[43]=oe):oe=e[43];const le=oe,ee=y.error??C.error??z.error??R.error??F.error;let ie;if(e[44]!==C||e[45]!==y||e[46]!==d||e[47]!==R||e[48]!==m||e[49]!==F||e[50]!==u||e[51]!==z){const V=()=>{const ne=[y.poll(),C.poll()];return u&&ne.push(z.poll()),d&&ne.push(R.poll()),m!==null&&ne.push(F.poll()),Qt(ne)};ie=()=>{kt(V())},e[44]=C,e[45]=y,e[46]=d,e[47]=R,e[48]=m,e[49]=F,e[50]=u,e[51]=z,e[52]=ie}else ie=e[52];const D=ie;let tt;e[53]!==y?(tt=()=>y.poll(),e[53]=y,e[54]=tt):tt=e[54],We(tt,!0);let lt;e[55]!==C?(lt=()=>C.poll(),e[55]=C,e[56]=lt):lt=e[56],We(lt,!0);let ot;e[57]!==z?(ot=()=>z.poll(),e[57]=z,e[58]=ot):ot=e[58],We(ot,u);let it;e[59]!==R?(it=()=>R.poll(),e[59]=R,e[60]=it):it=e[60],We(it,d);let rt;e[61]!==F?(rt=()=>F.poll(),e[61]=F,e[62]=rt):rt=e[62],We(rt,m!==null);let st;e[63]===Symbol.for("react.memo_cache_sentinel")?(st=()=>{r(null)},e[63]=st):st=e[63];const re=st;let nt;e[64]!==D?(nt=V=>{kt((async()=>{c(!0),p(null);try{await V(),D(),c(!1)}catch(ne){p(Jt(ne)),c(!1)}})())},e[64]=D,e[65]=nt):nt=e[65];const se=nt;let at;e[66]!==n||e[67]!==o?(at=V=>{const ne=A(V.id);r({action:async()=>{await n.removeAuthOrgTeam({teamId:ne}),a(wt=>wt===ne?null:wt)},kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},e[66]=n,e[67]=o,e[68]=at):at=e[68];const pt=at;let ue;e[69]!==o?(ue=o("userId"),e[69]=o,e[70]=ue):ue=e[70];let ge;e[71]!==ue?(ge={head:ue,render:rl},e[71]=ue,e[72]=ge):ge=e[72];let he;e[73]!==o?(he=o("role"),e[73]=o,e[74]=he):he=e[74];let be;e[75]!==he?(be={head:he,render:sl},e[75]=he,e[76]=be):be=e[76];let mt;e[77]!==ge||e[78]!==be?(mt=[ge,be],e[77]=ge,e[78]=be,e[79]=mt):mt=e[79];const vt=mt;let pe;e[80]!==o?(pe=o("email"),e[80]=o,e[81]=pe):pe=e[81];let ve;e[82]!==pe?(ve={head:pe,render:nl},e[82]=pe,e[83]=ve):ve=e[83];let ye;e[84]!==o?(ye=o("role"),e[84]=o,e[85]=ye):ye=e[85];let Ce;e[86]!==ye?(Ce={head:ye,render:al},e[86]=ye,e[87]=Ce):Ce=e[87];let xe;e[88]!==o?(xe=o("status"),e[88]=o,e[89]=xe):xe=e[89];let Ie;e[90]!==xe?(Ie={head:xe,render:ml},e[90]=xe,e[91]=Ie):Ie=e[91];let dt;e[92]!==ve||e[93]!==Ce||e[94]!==Ie?(dt=[ve,Ce,Ie],e[92]=ve,e[93]=Ce,e[94]=Ie,e[95]=dt):dt=e[95];const yt=dt;let Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let we;e[98]!==Se?(we={className:"font-mono text-xs",head:Se,render:dl},e[98]=Se,e[99]=we):we=e[99];let ke;e[100]!==o?(ke=o("name"),e[100]=o,e[101]=ke):ke=e[101];let De;e[102]!==ke?(De={head:ke,render:cl},e[102]=ke,e[103]=De):De=e[103];let ct;e[104]!==we||e[105]!==De?(ct=[we,De],e[104]=we,e[105]=De,e[106]=ct):ct=e[106];const Ct=ct;let ze;e[107]!==o?(ze=o("userId"),e[107]=o,e[108]=ze):ze=e[108];let ft;e[109]!==ze?(ft=[{head:ze,render:fl}],e[109]=ze,e[110]=ft):ft=e[110];const xt=ft;let Ae;e[111]!==o?(Ae=o("role"),e[111]=o,e[112]=Ae):Ae=e[112];let Ne;e[113]!==Ae?(Ne={head:Ae,render:ul},e[113]=Ae,e[114]=Ne):Ne=e[114];let Oe;e[115]!==o?(Oe=o("Permission"),e[115]=o,e[116]=Oe):Oe=e[116];let _e;e[117]!==Oe?(_e={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:gl},e[117]=Oe,e[118]=_e):_e=e[118];let ut;e[119]!==Ne||e[120]!==_e?(ut=[Ne,_e],e[119]=Ne,e[120]=_e,e[121]=ut):ut=e[121];const It=ut;let Te;e[122]!==ee?(Te=ee!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Te):Te=e[123];let $e;e[124]!==g?($e=g!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[124]=g,e[125]=$e):$e=e[125];let Me;e[126]!==n||e[127]!==se?(Me=V=>{se(()=>n.removeAuthOrgMember({memberId:V}))},e[126]=n,e[127]=se,e[128]=Me):Me=e[128];let Re;e[129]!==h||e[130]!==vt||e[131]!==j||e[132]!==Me?(Re=s(el,{actionBusy:h,memberColumns:vt,members:j,onDialog:r,onRemoveMember:Me}),e[129]=h,e[130]=vt,e[131]=j,e[132]=Me,e[133]=Re):Re=e[133];const St=y.data?.total;let Ee;e[134]!==j.length||e[135]!==f||e[136]!==b||e[137]!==St?(Ee=s(Et,{count:j.length,offset:f,onOffsetChange:b,pageSize:Nt,prefix:"org-members",total:St}),e[134]=j.length,e[135]=f,e[136]=b,e[137]=St,e[138]=Ee):Ee=e[138];let Fe;e[139]!==h||e[140]!==n||e[141]!==yt||e[142]!==M||e[143]!==se||e[144]!==o?(Fe=M.length>0&&s(Ye,{heading:o("Invitations"),testId:"org-invitations",children:s(et,{columns:yt,rowActions:V=>s(L,{"data-testid":`org-cancel-invitation-${A(V.id)}`,disabled:h,onClick:()=>{se(()=>n.cancelAuthOrgInvitation({invitationId:A(V.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),rowPrefix:"org-invitation",rows:M})}),e[139]=h,e[140]=n,e[141]=yt,e[142]=M,e[143]=se,e[144]=o,e[145]=Fe):Fe=e[145];let Pe;e[146]!==pt||e[147]!==m||e[148]!==Ct||e[149]!==K||e[150]!==u?(Pe=u&&s(tl,{onConfirmDeleteTeam:pt,onDialog:r,onSelectTeam:a,selectedTeam:m,teamColumns:Ct,teams:K}),e[146]=pt,e[147]=m,e[148]=Ct,e[149]=K,e[150]=u,e[151]=Pe):Pe=e[151];let je;e[152]!==h||e[153]!==n||e[154]!==se||e[155]!==m||e[156]!==xt||e[157]!==le||e[158]!==u?(je=u&&m!==null&&s(ll,{actionBusy:h,onDialog:r,onRemoveTeamMember:V=>{se(()=>n.removeAuthOrgTeamMember({teamMemberId:V}))},selectedTeam:m,teamMemberColumns:xt,teamMembers:le}),e[152]=h,e[153]=n,e[154]=se,e[155]=m,e[156]=xt,e[157]=le,e[158]=u,e[159]=je):je=e[159];let Le;e[160]!==n||e[161]!==It||e[162]!==te||e[163]!==d||e[164]!==o?(Le=d&&s(ol,{onConfirmDeleteRole:V=>{r({action:()=>n.deleteAuthOrgRole({roleId:V}),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},onDialog:r,roleColumns:It,roles:te}),e[160]=n,e[161]=It,e[162]=te,e[163]=d,e[164]=o,e[165]=Le):Le=e[165];let Be;e[166]!==i?.kind||e[167]!==l||e[168]!==D?(Be=i?.kind==="add-member"&&s(Kt,{onClose:re,onDone:D,organizationId:l}),e[166]=i?.kind,e[167]=l,e[168]=D,e[169]=Be):Be=e[169];let Qe;e[170]!==i?.kind||e[171]!==l||e[172]!==D?(Qe=i?.kind==="invite-member"&&s(Vt,{onClose:re,onDone:D,organizationId:l}),e[170]=i?.kind,e[171]=l,e[172]=D,e[173]=Qe):Qe=e[173];let Je;e[174]!==i||e[175]!==D?(Je=i?.kind==="member-role"&&s(Wt,{member:i.member,onClose:re,onDone:D}),e[174]=i,e[175]=D,e[176]=Je):Je=e[176];let Ue;e[177]!==i?.kind||e[178]!==l||e[179]!==D?(Ue=i?.kind==="team-create"&&s(zt,{mode:"create",onClose:re,onDone:D,organizationId:l}),e[177]=i?.kind,e[178]=l,e[179]=D,e[180]=Ue):Ue=e[180];let Ge;e[181]!==i||e[182]!==l||e[183]!==D?(Ge=i?.kind==="team-rename"&&s(zt,{mode:"edit",onClose:re,onDone:D,organizationId:l,team:i.team}),e[181]=i,e[182]=l,e[183]=D,e[184]=Ge):Ge=e[184];let He;e[185]!==i||e[186]!==D?(He=i?.kind==="team-add-member"&&s(Xt,{onClose:re,onDone:D,teamId:i.teamId}),e[185]=i,e[186]=D,e[187]=He):He=e[187];let Ze;e[188]!==i?.kind||e[189]!==l||e[190]!==D?(Ze=i?.kind==="role-create"&&s(At,{mode:"create",onClose:re,onDone:D,organizationId:l}),e[188]=i?.kind,e[189]=l,e[190]=D,e[191]=Ze):Ze=e[191];let qe;e[192]!==i||e[193]!==l||e[194]!==D?(qe=i?.kind==="role-edit"&&s(At,{mode:"edit",onClose:re,onDone:D,organizationId:l,role:i.role}),e[192]=i,e[193]=l,e[194]=D,e[195]=qe):qe=e[195];let Ke;e[196]!==i||e[197]!==D?(Ke=i?.kind==="confirm"&&s(Lt,{action:i.action,message:i.message,onClose:re,onDone:D,testId:i.testId,title:i.title}),e[196]=i,e[197]=D,e[198]=Ke):Ke=e[198];let gt;return e[199]!==Te||e[200]!==$e||e[201]!==Re||e[202]!==Ee||e[203]!==Fe||e[204]!==Pe||e[205]!==je||e[206]!==Le||e[207]!==Be||e[208]!==Qe||e[209]!==Je||e[210]!==Ue||e[211]!==Ge||e[212]!==He||e[213]!==Ze||e[214]!==qe||e[215]!==Ke?(gt=E("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Te,$e,Re,Ee,Fe,Pe,je,Le,Be,Qe,Je,Ue,Ge,He,Ze,qe,Ke]}),e[199]=Te,e[200]=$e,e[201]=Re,e[202]=Ee,e[203]=Fe,e[204]=Pe,e[205]=je,e[206]=Le,e[207]=Be,e[208]=Qe,e[209]=Je,e[210]=Ue,e[211]=Ge,e[212]=He,e[213]=Ze,e[214]=qe,e[215]=Ke,e[216]=gt):gt=e[216],gt};function rl(t){return s("span",{className:"font-mono text-xs",children:A(t.userId)})}function sl(t){return A(t.role)}function nl(t){return A(t.email)}function al(t){return A(t.role)}function ml(t){return A(t.status)}function dl(t){return A(t.id)}function cl(t){return A(t.name)}function fl(t){return s("span",{className:"font-mono text-xs",children:A(t.userId)})}function ul(t){return A(t.role)}function gl(t){return A(t.permission)}const Ot=100,Ml=()=>{const t=G(69),e=ae(),l=q(),{config:d,ready:u}=Bt(),n=d.capabilities.organization,[o,i]=P(null),[r,m]=P(null),[a,h]=P(0);let c;t[0]!==a?(c=["lunora-auth-orgs",a],t[0]=a,t[1]=c):c=t[1];let g;t[2]!==e||t[3]!==a?(g=()=>e.listAuthOrganizations({limit:Ot,offset:a}),t[2]=e,t[3]=a,t[4]=g):g=t[4];let p;t[5]!==n?(p={enabled:n},t[5]=n,t[6]=p):p=t[6];const f=Ve(c,g,p),b=f.data?.rows??null;let S;t[7]!==f?(S=()=>f.poll(),t[7]=f,t[8]=S):S=t[8],We(S,n);let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(null)},t[9]=v):v=t[9];const y=v;let x;t[10]!==f?(x=()=>{f.refetch()},t[10]=f,t[11]=x):x=t[11];const I=x;let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=M=>{i(M)},t[12]=C):C=t[12];const w=C;if(u&&!n){let M;t[13]!==l?(M=l("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=l,t[14]=M):M=t[14];let $;t[15]!==l?($=l("Organizations are not enabled."),t[15]=l,t[16]=$):$=t[16];let K;return t[17]!==M||t[18]!==$?(K=s(Xe,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=K):K=t[19],K}let k;t[20]!==l?(k=l("Organizations"),t[20]=l,t[21]=k):k=t[21];let O;t[22]!==k?(O=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:k}),t[22]=k,t[23]=O):O=t[23];let z;t[24]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{m({kind:"create"})},t[24]=z):z=t[24];let N;t[25]!==l?(N=l("New organization"),t[25]=l,t[26]=N):N=t[26];let _;t[27]!==N?(_=s(L,{"data-testid":"org-new",onClick:z,size:"sm",type:"button",children:N}),t[27]=N,t[28]=_):_=t[28];let T;t[29]!==_||t[30]!==O?(T=E("div",{className:"flex items-center justify-between",children:[O,_]}),t[29]=_,t[30]=O,t[31]=T):T=t[31];let R;t[32]!==f.error?(R=f.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:f.error}),t[32]=f.error,t[33]=R):R=t[33];let H;t[34]!==b||t[35]!==l?(H=b!==null&&b.length===0&&s(Xe,{testId:"org-empty",title:l("No organizations.")}),t[34]=b,t[35]=l,t[36]=H):H=t[36];let B;t[37]!==b||t[38]!==o||t[39]!==l?(B=b!==null&&b.length>0&&s(Tt,{className:"overflow-hidden py-0",children:s(_t,{className:"px-0",children:E(Rt,{"data-testid":"org-table",children:[s($t,{children:E(ht,{children:[s(ce,{children:l("id")}),s(ce,{children:l("name")}),s(ce,{children:l("slug")}),s(ce,{children:l("created")}),s(ce,{"aria-label":l("Actions")})]})}),s(Mt,{children:b.map(M=>{const $=A(M.id);return E(ht,{"data-testid":`org-row-${$}`,children:[s(fe,{className:"font-mono text-xs",children:$}),s(fe,{children:A(M.name)}),s(fe,{children:A(M.slug)}),s(fe,{className:"text-muted-foreground tabular-nums",children:Ut(M.createdAt)}),s(fe,{children:E("div",{className:"flex justify-end gap-1",children:[s(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:()=>{w($)},size:"xs",type:"button",variant:"ghost",children:l("Manage")}),s(L,{"data-testid":`org-edit-${$}`,onClick:()=>{m({kind:"edit",org:M})},size:"xs",type:"button",variant:"ghost",children:l("Edit")}),s(L,{"data-testid":`org-delete-${$}`,onClick:()=>{m({kind:"delete",org:M})},size:"xs",type:"button",variant:"ghost",children:l("Delete")})]})})]},$)})})]})})}),t[37]=b,t[38]=o,t[39]=l,t[40]=B):B=t[40];let U;t[41]!==a||t[42]!==b||t[43]!==f.data?.total?(U=b!==null&&s(Et,{count:b.length,offset:a,onOffsetChange:h,pageSize:Ot,prefix:"org",total:f.data?.total}),t[41]=a,t[42]=b,t[43]=f.data?.total,t[44]=U):U=t[44];let Q;t[45]!==d.organization||t[46]!==o?(Q=o!==null&&s(il,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=Q):Q=t[47];let F;t[48]!==r?.kind||t[49]!==I?(F=r?.kind==="create"&&s(Dt,{mode:"create",onClose:y,onDone:I}),t[48]=r?.kind,t[49]=I,t[50]=F):F=t[50];let J;t[51]!==r||t[52]!==I?(J=r?.kind==="edit"&&s(Dt,{mode:"edit",onClose:y,onDone:I,org:r.org}),t[51]=r,t[52]=I,t[53]=J):J=t[53];let j;t[54]!==e||t[55]!==r||t[56]!==I||t[57]!==l?(j=r?.kind==="delete"&&s(Lt,{action:async()=>{const M=A(r.org.id);await e.deleteAuthOrganization({organizationId:M}),i($=>$===M?null:$)},message:l("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:y,onDone:I,testId:"org-delete",title:l("Delete organization")}),t[54]=e,t[55]=r,t[56]=I,t[57]=l,t[58]=j):j=t[58];let Z;return t[59]!==T||t[60]!==R||t[61]!==H||t[62]!==B||t[63]!==U||t[64]!==Q||t[65]!==F||t[66]!==J||t[67]!==j?(Z=E("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[T,R,H,B,U,Q,F,J,j]}),t[59]=T,t[60]=R,t[61]=H,t[62]=B,t[63]=U,t[64]=Q,t[65]=F,t[66]=J,t[67]=j,t[68]=Z):Z=t[68],Z};export{Ml as default};
1
+ import{c as G}from"react/compiler-runtime";import{useState as P}from"react";import{B as L}from"../packem_shared/button-q0UYSmrn.mjs";import{a as _t,C as Tt}from"../packem_shared/card-By2O8ULa.mjs";import{E as Xe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as ce,a as $t,b as ht,e as fe,d as Mt,T as Rt}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Ve}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as Bt}from"../packem_shared/use-auth-config-CG7VvAvQ.mjs";import{useAutoRefresh as We,settlePolls as Qt}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{l as A,f as kt,b as Jt,h as Ut}from"../packem_shared/internal-hIuTpSbx.mjs";import{u as Gt,A as Et}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{I as X}from"../packem_shared/input-CXhxesPC.mjs";import{L as Ht}from"../packem_shared/label-DKFzyHq6.mjs";import{M as Zt}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{T as Ft}from"../packem_shared/textarea--40GKAyz.mjs";import{u as me}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";import{jsx as s,jsxs as E,Fragment as bt}from"react/jsx-runtime";const Pt=t=>{const e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},qt=t=>{const e=Pt(t),l={};for(const[d,u]of Object.entries(e)){if(!Array.isArray(u)||u.some(n=>typeof n!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);l[d]=u}return l},jt=t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),W=t=>{const e=G(6),{children:l,htmlFor:d,label:u}=t;let n;e[0]!==d||e[1]!==u?(n=s(Ht,{htmlFor:d,children:u}),e[0]=d,e[1]=u,e[2]=n):n=e[2];let o;return e[3]!==l||e[4]!==n?(o=E("div",{className:"flex flex-col gap-1",children:[n,l]}),e[3]=l,e[4]=n,e[5]=o):o=e[5],o},de=({busy:t,canSubmit:e,children:l,destructive:d=!1,error:u,onClose:n,onSubmit:o,submitLabel:i,testId:r,title:m})=>{const a=q();return E(Zt,{label:m,onClose:n,panelTestId:`${r}-panel`,testId:`${r}-overlay`,variant:"dialog",children:[s("h2",{className:"text-sm font-semibold text-foreground",children:m}),l,u!==null&&s("p",{className:"text-sm text-destructive","data-testid":`${r}-error`,role:"alert",children:u}),E("div",{className:"flex justify-end gap-2 pt-1",children:[s(L,{"data-testid":`${r}-cancel`,onClick:n,size:"sm",type:"button",variant:"outline",children:a("Cancel")}),s(L,{"data-testid":`${r}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?a("Saving…"):i})]})]})},Dt=t=>{const e=G(79),{mode:l,onClose:d,onDone:u,org:n}=t,o=ae(),i=q(),{busy:r,error:m,run:a}=me();let h;e[0]!==n?(h=n?A(n.name):"",e[0]=n,e[1]=h):h=e[1];const[c,g]=P(h);let p;e[2]!==n?(p=n?A(n.slug):"",e[2]=n,e[3]=p):p=e[3];const[f,b]=P(p);let S;e[4]!==n?(S=n?A(n.logo):"",e[4]=n,e[5]=S):S=e[5];const[v,y]=P(S),[x,I]=P("");let C;e[6]!==l||e[7]!==n?.metadata?(C=l==="edit"?jt(n?.metadata):"",e[6]=l,e[7]=n?.metadata,e[8]=C):C=e[8];const[w,k]=P(C);let O;e[9]!==o||e[10]!==v||e[11]!==w||e[12]!==l||e[13]!==c||e[14]!==d||e[15]!==u||e[16]!==n?.id||e[17]!==x||e[18]!==a||e[19]!==f?(O=()=>{a(async()=>{const D=w.trim()===""?void 0:Pt(w);l==="create"?await o.createAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:D,name:c.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:f.trim()===""?void 0:f.trim()}):await o.updateAuthOrganization({logo:v.trim()===""?void 0:v.trim(),metadata:D,name:c.trim()===""?void 0:c.trim(),organizationId:A(n?.id),slug:f.trim()===""?void 0:f.trim()}),u(),d()})},e[9]=o,e[10]=v,e[11]=w,e[12]=l,e[13]=c,e[14]=d,e[15]=u,e[16]=n?.id,e[17]=x,e[18]=a,e[19]=f,e[20]=O):O=e[20];const z=O;let N;e[21]!==l||e[22]!==c?(N=c.trim()!==""||l==="edit",e[21]=l,e[22]=c,e[23]=N):N=e[23];let _;e[24]!==l||e[25]!==i?(_=i(l==="create"?"Create":"Save"),e[24]=l,e[25]=i,e[26]=_):_=e[26];let T;e[27]!==l||e[28]!==i?(T=i(l==="create"?"New organization":"Edit organization"),e[27]=l,e[28]=i,e[29]=T):T=e[29];let R;e[30]!==i?(R=i("name"),e[30]=i,e[31]=R):R=e[31];let H;e[32]===Symbol.for("react.memo_cache_sentinel")?(H=D=>{g(D.target.value)},e[32]=H):H=e[32];let B;e[33]!==c?(B=s(X,{"data-testid":"org-form-name",id:"org-form-name",onChange:H,value:c}),e[33]=c,e[34]=B):B=e[34];let U;e[35]!==B||e[36]!==R?(U=s(W,{htmlFor:"org-form-name",label:R,children:B}),e[35]=B,e[36]=R,e[37]=U):U=e[37];let Q;e[38]!==i?(Q=i("Slug (optional — derived from name)"),e[38]=i,e[39]=Q):Q=e[39];let F;e[40]===Symbol.for("react.memo_cache_sentinel")?(F=D=>{b(D.target.value)},e[40]=F):F=e[40];let J;e[41]!==f?(J=s(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:F,value:f}),e[41]=f,e[42]=J):J=e[42];let j;e[43]!==Q||e[44]!==J?(j=s(W,{htmlFor:"org-form-slug",label:Q,children:J}),e[43]=Q,e[44]=J,e[45]=j):j=e[45];let Z;e[46]!==i?(Z=i("Logo URL (optional)"),e[46]=i,e[47]=Z):Z=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=D=>{y(D.target.value)},e[48]=M):M=e[48];let $;e[49]!==v?($=s(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:v}),e[49]=v,e[50]=$):$=e[50];let K;e[51]!==Z||e[52]!==$?(K=s(W,{htmlFor:"org-form-logo",label:Z,children:$}),e[51]=Z,e[52]=$,e[53]=K):K=e[53];let Y;e[54]!==l||e[55]!==x||e[56]!==i?(Y=l==="create"&&s(W,{htmlFor:"org-form-owner",label:i("Owner user id (optional)"),children:s(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:D=>{I(D.target.value)},value:x})}),e[54]=l,e[55]=x,e[56]=i,e[57]=Y):Y=e[57];let te;e[58]!==i?(te=i("Metadata (JSON, optional)"),e[58]=i,e[59]=te):te=e[59];let oe;e[60]===Symbol.for("react.memo_cache_sentinel")?(oe=D=>{k(D.target.value)},e[60]=oe):oe=e[60];let le;e[61]!==w?(le=s(Ft,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:oe,value:w}),e[61]=w,e[62]=le):le=e[62];let ee;e[63]!==te||e[64]!==le?(ee=s(W,{htmlFor:"org-form-metadata",label:te,children:le}),e[63]=te,e[64]=le,e[65]=ee):ee=e[65];let ie;return e[66]!==r||e[67]!==m||e[68]!==d||e[69]!==z||e[70]!==U||e[71]!==j||e[72]!==K||e[73]!==Y||e[74]!==ee||e[75]!==N||e[76]!==_||e[77]!==T?(ie=E(de,{busy:r,canSubmit:N,error:m,onClose:d,onSubmit:z,submitLabel:_,testId:"org-form",title:T,children:[U,j,K,Y,ee]}),e[66]=r,e[67]=m,e[68]=d,e[69]=z,e[70]=U,e[71]=j,e[72]=K,e[73]=Y,e[74]=ee,e[75]=N,e[76]=_,e[77]=T,e[78]=ie):ie=e[78],ie},Kt=t=>{const e=G(40),{onClose:l,onDone:d,organizationId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P(""),[c,g]=P("");let p;e[0]!==n||e[1]!==l||e[2]!==d||e[3]!==u||e[4]!==c||e[5]!==m||e[6]!==a?(p=()=>{m(async()=>{await n.addAuthOrgMember({organizationId:u,role:c.trim()===""?void 0:c.trim(),userId:a.trim()}),d(),l()})},e[0]=n,e[1]=l,e[2]=d,e[3]=u,e[4]=c,e[5]=m,e[6]=a,e[7]=p):p=e[7];const f=p;let b;e[8]!==a?(b=a.trim(),e[8]=a,e[9]=b):b=e[9];const S=b!=="";let v;e[10]!==o?(v=o("Add member"),e[10]=o,e[11]=v):v=e[11];let y;e[12]!==o?(y=o("Add member"),e[12]=o,e[13]=y):y=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=T=>{h(T.target.value)},e[16]=I):I=e[16];let C;e[17]!==a?(C=s(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:I,value:a}),e[17]=a,e[18]=C):C=e[18];let w;e[19]!==x||e[20]!==C?(w=s(W,{htmlFor:"org-add-member-user",label:x,children:C}),e[19]=x,e[20]=C,e[21]=w):w=e[21];let k;e[22]!==o?(k=o("Role (optional)"),e[22]=o,e[23]=k):k=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{g(T.target.value)},e[24]=O):O=e[24];let z;e[25]!==c?(z=s(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:O,value:c}),e[25]=c,e[26]=z):z=e[26];let N;e[27]!==k||e[28]!==z?(N=s(W,{htmlFor:"org-add-member-role",label:k,children:z}),e[27]=k,e[28]=z,e[29]=N):N=e[29];let _;return e[30]!==i||e[31]!==r||e[32]!==l||e[33]!==f||e[34]!==N||e[35]!==S||e[36]!==v||e[37]!==y||e[38]!==w?(_=E(de,{busy:i,canSubmit:S,error:r,onClose:l,onSubmit:f,submitLabel:v,testId:"org-add-member",title:y,children:[w,N]}),e[30]=i,e[31]=r,e[32]=l,e[33]=f,e[34]=N,e[35]=S,e[36]=v,e[37]=y,e[38]=w,e[39]=_):_=e[39],_},Vt=t=>{const e=G(40),{onClose:l,onDone:d,organizationId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P(""),[c,g]=P("");let p;e[0]!==n||e[1]!==a||e[2]!==l||e[3]!==d||e[4]!==u||e[5]!==c||e[6]!==m?(p=()=>{m(async()=>{await n.inviteAuthOrgMember({email:a.trim(),organizationId:u,role:c.trim()===""?void 0:c.trim()}),d(),l()})},e[0]=n,e[1]=a,e[2]=l,e[3]=d,e[4]=u,e[5]=c,e[6]=m,e[7]=p):p=e[7];const f=p;let b;e[8]!==a?(b=a.trim(),e[8]=a,e[9]=b):b=e[9];const S=b!=="";let v;e[10]!==o?(v=o("Send invitation"),e[10]=o,e[11]=v):v=e[11];let y;e[12]!==o?(y=o("Invite member"),e[12]=o,e[13]=y):y=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let I;e[16]===Symbol.for("react.memo_cache_sentinel")?(I=T=>{h(T.target.value)},e[16]=I):I=e[16];let C;e[17]!==a?(C=s(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:I,type:"email",value:a}),e[17]=a,e[18]=C):C=e[18];let w;e[19]!==x||e[20]!==C?(w=s(W,{htmlFor:"org-invite-member-email",label:x,children:C}),e[19]=x,e[20]=C,e[21]=w):w=e[21];let k;e[22]!==o?(k=o("Role (optional)"),e[22]=o,e[23]=k):k=e[23];let O;e[24]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{g(T.target.value)},e[24]=O):O=e[24];let z;e[25]!==c?(z=s(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:O,value:c}),e[25]=c,e[26]=z):z=e[26];let N;e[27]!==k||e[28]!==z?(N=s(W,{htmlFor:"org-invite-member-role",label:k,children:z}),e[27]=k,e[28]=z,e[29]=N):N=e[29];let _;return e[30]!==i||e[31]!==r||e[32]!==l||e[33]!==f||e[34]!==N||e[35]!==S||e[36]!==v||e[37]!==y||e[38]!==w?(_=E(de,{busy:i,canSubmit:S,error:r,onClose:l,onSubmit:f,submitLabel:v,testId:"org-invite-member",title:y,children:[w,N]}),e[30]=i,e[31]=r,e[32]=l,e[33]=f,e[34]=N,e[35]=S,e[36]=v,e[37]=y,e[38]=w,e[39]=_):_=e[39],_},Wt=t=>{const e=G(32),{member:l,onClose:d,onDone:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me();let a;e[0]!==l.role?(a=()=>A(l.role),e[0]=l.role,e[1]=a):a=e[1];const[h,c]=P(a);let g;e[2]!==n||e[3]!==l.id||e[4]!==d||e[5]!==u||e[6]!==h||e[7]!==m?(g=()=>{m(async()=>{await n.setAuthOrgMemberRole({memberId:A(l.id),role:h.trim()}),u(),d()})},e[2]=n,e[3]=l.id,e[4]=d,e[5]=u,e[6]=h,e[7]=m,e[8]=g):g=e[8];const p=g;let f;e[9]!==h?(f=h.trim(),e[9]=h,e[10]=f):f=e[10];const b=f!=="";let S;e[11]!==o?(S=o("Save"),e[11]=o,e[12]=S):S=e[12];let v;e[13]!==o?(v=o("Change member role"),e[13]=o,e[14]=v):v=e[14];let y;e[15]!==o?(y=o("Role"),e[15]=o,e[16]=y):y=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=k=>{c(k.target.value)},e[17]=x):x=e[17];let I;e[18]!==h?(I=s(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:h}),e[18]=h,e[19]=I):I=e[19];let C;e[20]!==y||e[21]!==I?(C=s(W,{htmlFor:"org-member-role-value",label:y,children:I}),e[20]=y,e[21]=I,e[22]=C):C=e[22];let w;return e[23]!==i||e[24]!==r||e[25]!==d||e[26]!==p||e[27]!==C||e[28]!==b||e[29]!==S||e[30]!==v?(w=s(de,{busy:i,canSubmit:b,error:r,onClose:d,onSubmit:p,submitLabel:S,testId:"org-member-role",title:v,children:C}),e[23]=i,e[24]=r,e[25]=d,e[26]=p,e[27]=C,e[28]=b,e[29]=S,e[30]=v,e[31]=w):w=e[31],w},zt=t=>{const e=G(36),{mode:l,onClose:d,onDone:u,organizationId:n,team:o}=t,i=ae(),r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==o?(c=o?A(o.name):"",e[0]=o,e[1]=c):c=e[1];const[g,p]=P(c);let f;e[2]!==i||e[3]!==l||e[4]!==g||e[5]!==d||e[6]!==u||e[7]!==n||e[8]!==h||e[9]!==o?.id?(f=()=>{h(async()=>{await(l==="create"?i.createAuthOrgTeam({name:g.trim(),organizationId:n}):i.updateAuthOrgTeam({name:g.trim(),teamId:A(o?.id)})),u(),d()})},e[2]=i,e[3]=l,e[4]=g,e[5]=d,e[6]=u,e[7]=n,e[8]=h,e[9]=o?.id,e[10]=f):f=e[10];const b=f;let S;e[11]!==g?(S=g.trim(),e[11]=g,e[12]=S):S=e[12];const v=S!=="";let y;e[13]!==l||e[14]!==r?(y=r(l==="create"?"Create":"Save"),e[13]=l,e[14]=r,e[15]=y):y=e[15];let x;e[16]!==l||e[17]!==r?(x=r(l==="create"?"New team":"Rename team"),e[16]=l,e[17]=r,e[18]=x):x=e[18];let I;e[19]!==r?(I=r("name"),e[19]=r,e[20]=I):I=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=z=>{p(z.target.value)},e[21]=C):C=e[21];let w;e[22]!==g?(w=s(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:C,value:g}),e[22]=g,e[23]=w):w=e[23];let k;e[24]!==I||e[25]!==w?(k=s(W,{htmlFor:"org-team-form-name",label:I,children:w}),e[24]=I,e[25]=w,e[26]=k):k=e[26];let O;return e[27]!==m||e[28]!==a||e[29]!==d||e[30]!==b||e[31]!==k||e[32]!==v||e[33]!==y||e[34]!==x?(O=s(de,{busy:m,canSubmit:v,error:a,onClose:d,onSubmit:b,submitLabel:y,testId:"org-team-form",title:x,children:k}),e[27]=m,e[28]=a,e[29]=d,e[30]=b,e[31]=k,e[32]=v,e[33]=y,e[34]=x,e[35]=O):O=e[35],O},Xt=t=>{const e=G(30),{onClose:l,onDone:d,teamId:u}=t,n=ae(),o=q(),{busy:i,error:r,run:m}=me(),[a,h]=P("");let c;e[0]!==n||e[1]!==l||e[2]!==d||e[3]!==m||e[4]!==u||e[5]!==a?(c=()=>{m(async()=>{await n.addAuthOrgTeamMember({teamId:u,userId:a.trim()}),d(),l()})},e[0]=n,e[1]=l,e[2]=d,e[3]=m,e[4]=u,e[5]=a,e[6]=c):c=e[6];const g=c;let p;e[7]!==a?(p=a.trim(),e[7]=a,e[8]=p):p=e[8];const f=p!=="";let b;e[9]!==o?(b=o("Add member"),e[9]=o,e[10]=b):b=e[10];let S;e[11]!==o?(S=o("Add team member"),e[11]=o,e[12]=S):S=e[12];let v;e[13]!==o?(v=o("User id"),e[13]=o,e[14]=v):v=e[14];let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=w=>{h(w.target.value)},e[15]=y):y=e[15];let x;e[16]!==a?(x=s(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:y,value:a}),e[16]=a,e[17]=x):x=e[17];let I;e[18]!==v||e[19]!==x?(I=s(W,{htmlFor:"org-team-add-member-user",label:v,children:x}),e[18]=v,e[19]=x,e[20]=I):I=e[20];let C;return e[21]!==i||e[22]!==r||e[23]!==l||e[24]!==g||e[25]!==f||e[26]!==b||e[27]!==S||e[28]!==I?(C=s(de,{busy:i,canSubmit:f,error:r,onClose:l,onSubmit:g,submitLabel:b,testId:"org-team-add-member",title:S,children:I}),e[21]=i,e[22]=r,e[23]=l,e[24]=g,e[25]=f,e[26]=b,e[27]=S,e[28]=I,e[29]=C):C=e[29],C},At=t=>{const e=G(47),{mode:l,onClose:d,onDone:u,organizationId:n,role:o}=t,i=ae(),r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==o?(c=o?A(o.role):"",e[0]=o,e[1]=c):c=e[1];const[g,p]=P(c);let f;e[2]!==l||e[3]!==o?.permission?(f=l==="edit"?jt(o?.permission):"",e[2]=l,e[3]=o?.permission,e[4]=f):f=e[4];const[b,S]=P(f);let v;e[5]!==i||e[6]!==l||e[7]!==g||e[8]!==d||e[9]!==u||e[10]!==n||e[11]!==b||e[12]!==o?.id||e[13]!==h?(v=()=>{h(async()=>{const T=qt(b);await(l==="create"?i.createAuthOrgRole({organizationId:n,permission:T,role:g.trim()}):i.updateAuthOrgRole({permission:T,roleId:A(o?.id)})),u(),d()})},e[5]=i,e[6]=l,e[7]=g,e[8]=d,e[9]=u,e[10]=n,e[11]=b,e[12]=o?.id,e[13]=h,e[14]=v):v=e[14];const y=v;let x;e[15]!==l||e[16]!==g||e[17]!==b?(x=b.trim()!==""&&(l==="edit"||g.trim()!==""),e[15]=l,e[16]=g,e[17]=b,e[18]=x):x=e[18];let I;e[19]!==l||e[20]!==r?(I=r(l==="create"?"Create":"Save"),e[19]=l,e[20]=r,e[21]=I):I=e[21];let C;e[22]!==l||e[23]!==r?(C=r(l==="create"?"New role":"Edit role"),e[22]=l,e[23]=r,e[24]=C):C=e[24];let w;e[25]!==l||e[26]!==g||e[27]!==r?(w=l==="create"&&s(W,{htmlFor:"org-role-form-name",label:r("Role name"),children:s(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:T=>{p(T.target.value)},value:g})}),e[25]=l,e[26]=g,e[27]=r,e[28]=w):w=e[28];let k;e[29]!==r?(k=r('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=r,e[30]=k):k=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=T=>{S(T.target.value)},e[31]=O):O=e[31];let z;e[32]!==b?(z=s(Ft,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:O,value:b}),e[32]=b,e[33]=z):z=e[33];let N;e[34]!==z||e[35]!==k?(N=s(W,{htmlFor:"org-role-form-permission",label:k,children:z}),e[34]=z,e[35]=k,e[36]=N):N=e[36];let _;return e[37]!==m||e[38]!==a||e[39]!==d||e[40]!==y||e[41]!==N||e[42]!==x||e[43]!==I||e[44]!==C||e[45]!==w?(_=E(de,{busy:m,canSubmit:x,error:a,onClose:d,onSubmit:y,submitLabel:I,testId:"org-role-form",title:C,children:[w,N]}),e[37]=m,e[38]=a,e[39]=d,e[40]=y,e[41]=N,e[42]=x,e[43]=I,e[44]=C,e[45]=w,e[46]=_):_=e[46],_},Lt=t=>{const e=G(18),{action:l,message:d,onClose:u,onDone:n,testId:o,title:i}=t,r=q(),{busy:m,error:a,run:h}=me();let c;e[0]!==l||e[1]!==u||e[2]!==n||e[3]!==h?(c=()=>{h(async()=>{await l(),n(),u()})},e[0]=l,e[1]=u,e[2]=n,e[3]=h,e[4]=c):c=e[4];const g=c;let p;e[5]!==r?(p=r("Delete"),e[5]=r,e[6]=p):p=e[6];let f;e[7]!==d?(f=s("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=f):f=e[8];let b;return e[9]!==m||e[10]!==a||e[11]!==u||e[12]!==g||e[13]!==p||e[14]!==f||e[15]!==o||e[16]!==i?(b=s(de,{busy:m,canSubmit:!0,destructive:!0,error:a,onClose:u,onSubmit:g,submitLabel:p,testId:o,title:i,children:f}),e[9]=m,e[10]=a,e[11]=u,e[12]=g,e[13]=p,e[14]=f,e[15]=o,e[16]=i,e[17]=b):b=e[17],b},Ye=t=>{const e=G(13),{action:l,children:d,heading:u,testId:n}=t;let o;e[0]!==u?(o=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=o):o=e[1];let i;e[2]!==l?(i=l!==void 0&&s("div",{className:"flex items-center gap-2",children:l}),e[2]=l,e[3]=i):i=e[3];let r;e[4]!==o||e[5]!==i?(r=E("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,i]}),e[4]=o,e[5]=i,e[6]=r):r=e[6];let m;e[7]!==d?(m=s(_t,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let a;return e[9]!==r||e[10]!==m||e[11]!==n?(a=E(Tt,{className:"overflow-hidden py-0","data-testid":n,children:[r,m]}),e[9]=r,e[10]=m,e[11]=n,e[12]=a):a=e[12],a},et=t=>{const e=G(23),{columns:l,rowActions:d,rowPrefix:u,rows:n}=t,o=q();let i;e[0]!==l?(i=l.map(Yt),e[0]=l,e[1]=i):i=e[1];let r;e[2]!==o?(r=o("Actions"),e[2]=o,e[3]=r):r=e[3];let m;e[4]!==r?(m=s(ce,{"aria-label":r}),e[4]=r,e[5]=m):m=e[5];let a;e[6]!==i||e[7]!==m?(a=s($t,{children:E(ht,{children:[i,m]})}),e[6]=i,e[7]=m,e[8]=a):a=e[8];let h;if(e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n){let p;e[14]!==l||e[15]!==d||e[16]!==u?(p=(f,b)=>{const S=A(f.id),v=S===""?`index-${b.toString()}`:S;return E(ht,{"data-testid":`${u}-${v}`,children:[l.map(y=>s(fe,{className:y.className,children:y.render(f)},y.head)),s(fe,{children:s("div",{className:"flex justify-end gap-1",children:d(f)})})]},v)},e[14]=l,e[15]=d,e[16]=u,e[17]=p):p=e[17],h=n.map(p),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=h}else h=e[13];let c;e[18]!==h?(c=s(Mt,{children:h}),e[18]=h,e[19]=c):c=e[19];let g;return e[20]!==a||e[21]!==c?(g=E(Rt,{children:[a,c]}),e[20]=a,e[21]=c,e[22]=g):g=e[22],g};function Yt(t){return s(ce,{children:t.head},t.head)}const el=t=>{const e=G(30),{actionBusy:l,onRemoveMember:d,memberColumns:u,members:n,onDialog:o}=t,i=q();let r;e[0]!==o?(r=()=>{o({kind:"add-member"})},e[0]=o,e[1]=r):r=e[1];let m;e[2]!==i?(m=i("Add member"),e[2]=i,e[3]=m):m=e[3];let a;e[4]!==r||e[5]!==m?(a=s(L,{"data-testid":"org-open-add-member",onClick:r,size:"xs",type:"button",variant:"outline",children:m}),e[4]=r,e[5]=m,e[6]=a):a=e[6];let h;e[7]!==o?(h=()=>{o({kind:"invite-member"})},e[7]=o,e[8]=h):h=e[8];let c;e[9]!==i?(c=i("Invite member"),e[9]=i,e[10]=c):c=e[10];let g;e[11]!==h||e[12]!==c?(g=s(L,{"data-testid":"org-open-invite-member",onClick:h,size:"xs",type:"button",variant:"outline",children:c}),e[11]=h,e[12]=c,e[13]=g):g=e[13];let p;e[14]!==a||e[15]!==g?(p=E(bt,{children:[a,g]}),e[14]=a,e[15]=g,e[16]=p):p=e[16];let f;e[17]!==i?(f=i("Members"),e[17]=i,e[18]=f):f=e[18];let b;e[19]!==l||e[20]!==u||e[21]!==n||e[22]!==o||e[23]!==d||e[24]!==i?(b=n.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-members-empty",title:i("No members.")})}):s(et,{columns:u,rowActions:v=>E(bt,{children:[s(L,{"data-testid":`org-member-role-${A(v.id)}`,onClick:()=>{o({kind:"member-role",member:v})},size:"xs",type:"button",variant:"ghost",children:i("Change role")}),s(L,{"data-testid":`org-remove-member-${A(v.id)}`,disabled:l,onClick:()=>{d(A(v.id))},size:"xs",type:"button",variant:"ghost",children:i("Remove")})]}),rowPrefix:"org-member",rows:n}),e[19]=l,e[20]=u,e[21]=n,e[22]=o,e[23]=d,e[24]=i,e[25]=b):b=e[25];let S;return e[26]!==p||e[27]!==f||e[28]!==b?(S=s(Ye,{action:p,heading:f,testId:"org-members",children:b}),e[26]=p,e[27]=f,e[28]=b,e[29]=S):S=e[29],S},tl=t=>{const e=G(21),{onConfirmDeleteTeam:l,onDialog:d,onSelectTeam:u,selectedTeam:n,teamColumns:o,teams:i}=t,r=q();let m;e[0]!==d?(m=()=>{d({kind:"team-create"})},e[0]=d,e[1]=m):m=e[1];let a;e[2]!==r?(a=r("New team"),e[2]=r,e[3]=a):a=e[3];let h;e[4]!==m||e[5]!==a?(h=s(L,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:a}),e[4]=m,e[5]=a,e[6]=h):h=e[6];let c;e[7]!==r?(c=r("Teams"),e[7]=r,e[8]=c):c=e[8];let g;e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n||e[13]!==r||e[14]!==o||e[15]!==i?(g=i.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-teams-empty",title:r("No teams.")})}):s(et,{columns:o,rowActions:f=>E(bt,{children:[s(L,{"aria-pressed":n===A(f.id),"data-testid":`org-team-select-${A(f.id)}`,onClick:()=>{u(A(f.id))},size:"xs",type:"button",variant:"ghost",children:r("Members")}),s(L,{"data-testid":`org-team-rename-${A(f.id)}`,onClick:()=>{d({kind:"team-rename",team:f})},size:"xs",type:"button",variant:"ghost",children:r("Rename")}),s(L,{"data-testid":`org-team-delete-${A(f.id)}`,onClick:()=>{l(f)},size:"xs",type:"button",variant:"ghost",children:r("Delete")})]}),rowPrefix:"org-team",rows:i}),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=r,e[14]=o,e[15]=i,e[16]=g):g=e[16];let p;return e[17]!==h||e[18]!==c||e[19]!==g?(p=s(Ye,{action:h,heading:c,testId:"org-teams",children:g}),e[17]=h,e[18]=c,e[19]=g,e[20]=p):p=e[20],p},ll=t=>{const e=G(20),{actionBusy:l,onRemoveTeamMember:d,onDialog:u,selectedTeam:n,teamMemberColumns:o,teamMembers:i}=t,r=q();let m;e[0]!==u||e[1]!==n?(m=()=>{u({kind:"team-add-member",teamId:n})},e[0]=u,e[1]=n,e[2]=m):m=e[2];let a;e[3]!==r?(a=r("Add member"),e[3]=r,e[4]=a):a=e[4];let h;e[5]!==m||e[6]!==a?(h=s(L,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:a}),e[5]=m,e[6]=a,e[7]=h):h=e[7];let c;e[8]!==r?(c=r("Team members"),e[8]=r,e[9]=c):c=e[9];let g;e[10]!==l||e[11]!==d||e[12]!==r||e[13]!==o||e[14]!==i?(g=i.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-team-members-empty",title:r("No team members.")})}):s(et,{columns:o,rowActions:f=>s(L,{"data-testid":`org-team-remove-member-${A(f.id)}`,disabled:l,onClick:()=>{d(A(f.id))},size:"xs",type:"button",variant:"ghost",children:r("Remove")}),rowPrefix:"org-team-member",rows:i}),e[10]=l,e[11]=d,e[12]=r,e[13]=o,e[14]=i,e[15]=g):g=e[15];let p;return e[16]!==h||e[17]!==c||e[18]!==g?(p=s(Ye,{action:h,heading:c,testId:"org-team-members",children:g}),e[16]=h,e[17]=c,e[18]=g,e[19]=p):p=e[19],p},ol=t=>{const e=G(19),{onConfirmDeleteRole:l,onDialog:d,roleColumns:u,roles:n}=t,o=q();let i;e[0]!==d?(i=()=>{d({kind:"role-create"})},e[0]=d,e[1]=i):i=e[1];let r;e[2]!==o?(r=o("New role"),e[2]=o,e[3]=r):r=e[3];let m;e[4]!==i||e[5]!==r?(m=s(L,{"data-testid":"org-open-create-role",onClick:i,size:"xs",type:"button",variant:"outline",children:r}),e[4]=i,e[5]=r,e[6]=m):m=e[6];let a;e[7]!==o?(a=o("Roles"),e[7]=o,e[8]=a):a=e[8];let h;e[9]!==l||e[10]!==d||e[11]!==u||e[12]!==n||e[13]!==o?(h=n.length===0?s("div",{className:"p-3",children:s(Xe,{testId:"org-roles-empty",title:o("No custom roles.")})}):s(et,{columns:u,rowActions:g=>E(bt,{children:[s(L,{"data-testid":`org-role-edit-${A(g.id)}`,onClick:()=>{d({kind:"role-edit",role:g})},size:"xs",type:"button",variant:"ghost",children:o("Edit")}),s(L,{"data-testid":`org-role-delete-${A(g.id)}`,onClick:()=>{l(A(g.id))},size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),rowPrefix:"org-role",rows:n}),e[9]=l,e[10]=d,e[11]=u,e[12]=n,e[13]=o,e[14]=h):h=e[14];let c;return e[15]!==m||e[16]!==a||e[17]!==h?(c=s(Ye,{action:m,heading:a,testId:"org-roles",children:h}),e[15]=m,e[16]=a,e[17]=h,e[18]=c):c=e[18],c},Nt=200,il=t=>{const e=G(217),{organizationId:l,rolesEnabled:d,teamsEnabled:u}=t,n=ae(),o=q(),[i,r]=P(null),[m,a]=P(null),[h,c]=P(!1),[g,p]=P(null),[f,b]=Gt(l);let S;e[0]!==f||e[1]!==l?(S=["lunora-auth-org-members",l,f],e[0]=f,e[1]=l,e[2]=S):S=e[2];let v;e[3]!==n||e[4]!==f||e[5]!==l?(v=()=>n.listAuthOrgMembers({limit:Nt,offset:f,organizationId:l}),e[3]=n,e[4]=f,e[5]=l,e[6]=v):v=e[6];const y=Ve(S,v);let x;e[7]!==l?(x=["lunora-auth-org-invitations",l],e[7]=l,e[8]=x):x=e[8];let I;e[9]!==n||e[10]!==l?(I=()=>n.listAuthOrgInvitations({limit:200,organizationId:l}),e[9]=n,e[10]=l,e[11]=I):I=e[11];const C=Ve(x,I);let w;e[12]!==l?(w=["lunora-auth-org-teams",l],e[12]=l,e[13]=w):w=e[13];let k;e[14]!==n||e[15]!==l?(k=()=>n.listAuthOrgTeams({limit:200,organizationId:l}),e[14]=n,e[15]=l,e[16]=k):k=e[16];let O;e[17]!==u?(O={enabled:u},e[17]=u,e[18]=O):O=e[18];const z=Ve(w,k,O);let N;e[19]!==l?(N=["lunora-auth-org-roles",l],e[19]=l,e[20]=N):N=e[20];let _;e[21]!==n||e[22]!==l?(_=()=>n.listAuthOrgRoles({limit:200,organizationId:l}),e[21]=n,e[22]=l,e[23]=_):_=e[23];let T;e[24]!==d?(T={enabled:d},e[24]=d,e[25]=T):T=e[25];const R=Ve(N,_,T);let H;e[26]!==m?(H=["lunora-auth-org-team-members",m],e[26]=m,e[27]=H):H=e[27];let B;e[28]!==n||e[29]!==m?(B=()=>n.listAuthOrgTeamMembers({limit:200,teamId:m??""}),e[28]=n,e[29]=m,e[30]=B):B=e[30];const U=m!==null;let Q;e[31]!==U?(Q={enabled:U},e[31]=U,e[32]=Q):Q=e[32];const F=Ve(H,B,Q);let J;e[33]!==y.data?.rows?(J=y.data?.rows??[],e[33]=y.data?.rows,e[34]=J):J=e[34];const j=J;let Z;e[35]!==C.data?.rows?(Z=C.data?.rows??[],e[35]=C.data?.rows,e[36]=Z):Z=e[36];const M=Z;let $;e[37]!==z.data?.rows?($=z.data?.rows??[],e[37]=z.data?.rows,e[38]=$):$=e[38];const K=$;let Y;e[39]!==R.data?.rows?(Y=R.data?.rows??[],e[39]=R.data?.rows,e[40]=Y):Y=e[40];const te=Y;let oe;e[41]!==m||e[42]!==F.data?.rows?(oe=m===null?[]:F.data?.rows??[],e[41]=m,e[42]=F.data?.rows,e[43]=oe):oe=e[43];const le=oe,ee=y.error??C.error??z.error??R.error??F.error;let ie;if(e[44]!==C||e[45]!==y||e[46]!==d||e[47]!==R||e[48]!==m||e[49]!==F||e[50]!==u||e[51]!==z){const V=()=>{const ne=[y.poll(),C.poll()];return u&&ne.push(z.poll()),d&&ne.push(R.poll()),m!==null&&ne.push(F.poll()),Qt(ne)};ie=()=>{kt(V())},e[44]=C,e[45]=y,e[46]=d,e[47]=R,e[48]=m,e[49]=F,e[50]=u,e[51]=z,e[52]=ie}else ie=e[52];const D=ie;let tt;e[53]!==y?(tt=()=>y.poll(),e[53]=y,e[54]=tt):tt=e[54],We(tt,!0);let lt;e[55]!==C?(lt=()=>C.poll(),e[55]=C,e[56]=lt):lt=e[56],We(lt,!0);let ot;e[57]!==z?(ot=()=>z.poll(),e[57]=z,e[58]=ot):ot=e[58],We(ot,u);let it;e[59]!==R?(it=()=>R.poll(),e[59]=R,e[60]=it):it=e[60],We(it,d);let rt;e[61]!==F?(rt=()=>F.poll(),e[61]=F,e[62]=rt):rt=e[62],We(rt,m!==null);let st;e[63]===Symbol.for("react.memo_cache_sentinel")?(st=()=>{r(null)},e[63]=st):st=e[63];const re=st;let nt;e[64]!==D?(nt=V=>{kt((async()=>{c(!0),p(null);try{await V(),D(),c(!1)}catch(ne){p(Jt(ne)),c(!1)}})())},e[64]=D,e[65]=nt):nt=e[65];const se=nt;let at;e[66]!==n||e[67]!==o?(at=V=>{const ne=A(V.id);r({action:async()=>{await n.removeAuthOrgTeam({teamId:ne}),a(wt=>wt===ne?null:wt)},kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},e[66]=n,e[67]=o,e[68]=at):at=e[68];const pt=at;let ue;e[69]!==o?(ue=o("userId"),e[69]=o,e[70]=ue):ue=e[70];let ge;e[71]!==ue?(ge={head:ue,render:rl},e[71]=ue,e[72]=ge):ge=e[72];let he;e[73]!==o?(he=o("role"),e[73]=o,e[74]=he):he=e[74];let be;e[75]!==he?(be={head:he,render:sl},e[75]=he,e[76]=be):be=e[76];let mt;e[77]!==ge||e[78]!==be?(mt=[ge,be],e[77]=ge,e[78]=be,e[79]=mt):mt=e[79];const vt=mt;let pe;e[80]!==o?(pe=o("email"),e[80]=o,e[81]=pe):pe=e[81];let ve;e[82]!==pe?(ve={head:pe,render:nl},e[82]=pe,e[83]=ve):ve=e[83];let ye;e[84]!==o?(ye=o("role"),e[84]=o,e[85]=ye):ye=e[85];let Ce;e[86]!==ye?(Ce={head:ye,render:al},e[86]=ye,e[87]=Ce):Ce=e[87];let xe;e[88]!==o?(xe=o("status"),e[88]=o,e[89]=xe):xe=e[89];let Ie;e[90]!==xe?(Ie={head:xe,render:ml},e[90]=xe,e[91]=Ie):Ie=e[91];let dt;e[92]!==ve||e[93]!==Ce||e[94]!==Ie?(dt=[ve,Ce,Ie],e[92]=ve,e[93]=Ce,e[94]=Ie,e[95]=dt):dt=e[95];const yt=dt;let Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let we;e[98]!==Se?(we={className:"font-mono text-xs",head:Se,render:dl},e[98]=Se,e[99]=we):we=e[99];let ke;e[100]!==o?(ke=o("name"),e[100]=o,e[101]=ke):ke=e[101];let De;e[102]!==ke?(De={head:ke,render:cl},e[102]=ke,e[103]=De):De=e[103];let ct;e[104]!==we||e[105]!==De?(ct=[we,De],e[104]=we,e[105]=De,e[106]=ct):ct=e[106];const Ct=ct;let ze;e[107]!==o?(ze=o("userId"),e[107]=o,e[108]=ze):ze=e[108];let ft;e[109]!==ze?(ft=[{head:ze,render:fl}],e[109]=ze,e[110]=ft):ft=e[110];const xt=ft;let Ae;e[111]!==o?(Ae=o("role"),e[111]=o,e[112]=Ae):Ae=e[112];let Ne;e[113]!==Ae?(Ne={head:Ae,render:ul},e[113]=Ae,e[114]=Ne):Ne=e[114];let Oe;e[115]!==o?(Oe=o("Permission"),e[115]=o,e[116]=Oe):Oe=e[116];let _e;e[117]!==Oe?(_e={className:"font-mono text-xs whitespace-pre-wrap",head:Oe,render:gl},e[117]=Oe,e[118]=_e):_e=e[118];let ut;e[119]!==Ne||e[120]!==_e?(ut=[Ne,_e],e[119]=Ne,e[120]=_e,e[121]=ut):ut=e[121];const It=ut;let Te;e[122]!==ee?(Te=ee!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Te):Te=e[123];let $e;e[124]!==g?($e=g!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:g}),e[124]=g,e[125]=$e):$e=e[125];let Me;e[126]!==n||e[127]!==se?(Me=V=>{se(()=>n.removeAuthOrgMember({memberId:V}))},e[126]=n,e[127]=se,e[128]=Me):Me=e[128];let Re;e[129]!==h||e[130]!==vt||e[131]!==j||e[132]!==Me?(Re=s(el,{actionBusy:h,memberColumns:vt,members:j,onDialog:r,onRemoveMember:Me}),e[129]=h,e[130]=vt,e[131]=j,e[132]=Me,e[133]=Re):Re=e[133];const St=y.data?.total;let Ee;e[134]!==j.length||e[135]!==f||e[136]!==b||e[137]!==St?(Ee=s(Et,{count:j.length,offset:f,onOffsetChange:b,pageSize:Nt,prefix:"org-members",total:St}),e[134]=j.length,e[135]=f,e[136]=b,e[137]=St,e[138]=Ee):Ee=e[138];let Fe;e[139]!==h||e[140]!==n||e[141]!==yt||e[142]!==M||e[143]!==se||e[144]!==o?(Fe=M.length>0&&s(Ye,{heading:o("Invitations"),testId:"org-invitations",children:s(et,{columns:yt,rowActions:V=>s(L,{"data-testid":`org-cancel-invitation-${A(V.id)}`,disabled:h,onClick:()=>{se(()=>n.cancelAuthOrgInvitation({invitationId:A(V.id)}))},size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),rowPrefix:"org-invitation",rows:M})}),e[139]=h,e[140]=n,e[141]=yt,e[142]=M,e[143]=se,e[144]=o,e[145]=Fe):Fe=e[145];let Pe;e[146]!==pt||e[147]!==m||e[148]!==Ct||e[149]!==K||e[150]!==u?(Pe=u&&s(tl,{onConfirmDeleteTeam:pt,onDialog:r,onSelectTeam:a,selectedTeam:m,teamColumns:Ct,teams:K}),e[146]=pt,e[147]=m,e[148]=Ct,e[149]=K,e[150]=u,e[151]=Pe):Pe=e[151];let je;e[152]!==h||e[153]!==n||e[154]!==se||e[155]!==m||e[156]!==xt||e[157]!==le||e[158]!==u?(je=u&&m!==null&&s(ll,{actionBusy:h,onDialog:r,onRemoveTeamMember:V=>{se(()=>n.removeAuthOrgTeamMember({teamMemberId:V}))},selectedTeam:m,teamMemberColumns:xt,teamMembers:le}),e[152]=h,e[153]=n,e[154]=se,e[155]=m,e[156]=xt,e[157]=le,e[158]=u,e[159]=je):je=e[159];let Le;e[160]!==n||e[161]!==It||e[162]!==te||e[163]!==d||e[164]!==o?(Le=d&&s(ol,{onConfirmDeleteRole:V=>{r({action:()=>n.deleteAuthOrgRole({roleId:V}),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},onDialog:r,roleColumns:It,roles:te}),e[160]=n,e[161]=It,e[162]=te,e[163]=d,e[164]=o,e[165]=Le):Le=e[165];let Be;e[166]!==i?.kind||e[167]!==l||e[168]!==D?(Be=i?.kind==="add-member"&&s(Kt,{onClose:re,onDone:D,organizationId:l}),e[166]=i?.kind,e[167]=l,e[168]=D,e[169]=Be):Be=e[169];let Qe;e[170]!==i?.kind||e[171]!==l||e[172]!==D?(Qe=i?.kind==="invite-member"&&s(Vt,{onClose:re,onDone:D,organizationId:l}),e[170]=i?.kind,e[171]=l,e[172]=D,e[173]=Qe):Qe=e[173];let Je;e[174]!==i||e[175]!==D?(Je=i?.kind==="member-role"&&s(Wt,{member:i.member,onClose:re,onDone:D}),e[174]=i,e[175]=D,e[176]=Je):Je=e[176];let Ue;e[177]!==i?.kind||e[178]!==l||e[179]!==D?(Ue=i?.kind==="team-create"&&s(zt,{mode:"create",onClose:re,onDone:D,organizationId:l}),e[177]=i?.kind,e[178]=l,e[179]=D,e[180]=Ue):Ue=e[180];let Ge;e[181]!==i||e[182]!==l||e[183]!==D?(Ge=i?.kind==="team-rename"&&s(zt,{mode:"edit",onClose:re,onDone:D,organizationId:l,team:i.team}),e[181]=i,e[182]=l,e[183]=D,e[184]=Ge):Ge=e[184];let He;e[185]!==i||e[186]!==D?(He=i?.kind==="team-add-member"&&s(Xt,{onClose:re,onDone:D,teamId:i.teamId}),e[185]=i,e[186]=D,e[187]=He):He=e[187];let Ze;e[188]!==i?.kind||e[189]!==l||e[190]!==D?(Ze=i?.kind==="role-create"&&s(At,{mode:"create",onClose:re,onDone:D,organizationId:l}),e[188]=i?.kind,e[189]=l,e[190]=D,e[191]=Ze):Ze=e[191];let qe;e[192]!==i||e[193]!==l||e[194]!==D?(qe=i?.kind==="role-edit"&&s(At,{mode:"edit",onClose:re,onDone:D,organizationId:l,role:i.role}),e[192]=i,e[193]=l,e[194]=D,e[195]=qe):qe=e[195];let Ke;e[196]!==i||e[197]!==D?(Ke=i?.kind==="confirm"&&s(Lt,{action:i.action,message:i.message,onClose:re,onDone:D,testId:i.testId,title:i.title}),e[196]=i,e[197]=D,e[198]=Ke):Ke=e[198];let gt;return e[199]!==Te||e[200]!==$e||e[201]!==Re||e[202]!==Ee||e[203]!==Fe||e[204]!==Pe||e[205]!==je||e[206]!==Le||e[207]!==Be||e[208]!==Qe||e[209]!==Je||e[210]!==Ue||e[211]!==Ge||e[212]!==He||e[213]!==Ze||e[214]!==qe||e[215]!==Ke?(gt=E("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Te,$e,Re,Ee,Fe,Pe,je,Le,Be,Qe,Je,Ue,Ge,He,Ze,qe,Ke]}),e[199]=Te,e[200]=$e,e[201]=Re,e[202]=Ee,e[203]=Fe,e[204]=Pe,e[205]=je,e[206]=Le,e[207]=Be,e[208]=Qe,e[209]=Je,e[210]=Ue,e[211]=Ge,e[212]=He,e[213]=Ze,e[214]=qe,e[215]=Ke,e[216]=gt):gt=e[216],gt};function rl(t){return s("span",{className:"font-mono text-xs",children:A(t.userId)})}function sl(t){return A(t.role)}function nl(t){return A(t.email)}function al(t){return A(t.role)}function ml(t){return A(t.status)}function dl(t){return A(t.id)}function cl(t){return A(t.name)}function fl(t){return s("span",{className:"font-mono text-xs",children:A(t.userId)})}function ul(t){return A(t.role)}function gl(t){return A(t.permission)}const Ot=100,Ml=()=>{const t=G(69),e=ae(),l=q(),{config:d,ready:u}=Bt(),n=d.capabilities.organization,[o,i]=P(null),[r,m]=P(null),[a,h]=P(0);let c;t[0]!==a?(c=["lunora-auth-orgs",a],t[0]=a,t[1]=c):c=t[1];let g;t[2]!==e||t[3]!==a?(g=()=>e.listAuthOrganizations({limit:Ot,offset:a}),t[2]=e,t[3]=a,t[4]=g):g=t[4];let p;t[5]!==n?(p={enabled:n},t[5]=n,t[6]=p):p=t[6];const f=Ve(c,g,p),b=f.data?.rows??null;let S;t[7]!==f?(S=()=>f.poll(),t[7]=f,t[8]=S):S=t[8],We(S,n);let v;t[9]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{m(null)},t[9]=v):v=t[9];const y=v;let x;t[10]!==f?(x=()=>{f.refetch()},t[10]=f,t[11]=x):x=t[11];const I=x;let C;t[12]===Symbol.for("react.memo_cache_sentinel")?(C=M=>{i(M)},t[12]=C):C=t[12];const w=C;if(u&&!n){let M;t[13]!==l?(M=l("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=l,t[14]=M):M=t[14];let $;t[15]!==l?($=l("Organizations are not enabled."),t[15]=l,t[16]=$):$=t[16];let K;return t[17]!==M||t[18]!==$?(K=s(Xe,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=K):K=t[19],K}let k;t[20]!==l?(k=l("Organizations"),t[20]=l,t[21]=k):k=t[21];let O;t[22]!==k?(O=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:k}),t[22]=k,t[23]=O):O=t[23];let z;t[24]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{m({kind:"create"})},t[24]=z):z=t[24];let N;t[25]!==l?(N=l("New organization"),t[25]=l,t[26]=N):N=t[26];let _;t[27]!==N?(_=s(L,{"data-testid":"org-new",onClick:z,size:"sm",type:"button",children:N}),t[27]=N,t[28]=_):_=t[28];let T;t[29]!==_||t[30]!==O?(T=E("div",{className:"flex items-center justify-between",children:[O,_]}),t[29]=_,t[30]=O,t[31]=T):T=t[31];let R;t[32]!==f.error?(R=f.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:f.error}),t[32]=f.error,t[33]=R):R=t[33];let H;t[34]!==b||t[35]!==l?(H=b!==null&&b.length===0&&s(Xe,{testId:"org-empty",title:l("No organizations.")}),t[34]=b,t[35]=l,t[36]=H):H=t[36];let B;t[37]!==b||t[38]!==o||t[39]!==l?(B=b!==null&&b.length>0&&s(Tt,{className:"overflow-hidden py-0",children:s(_t,{className:"px-0",children:E(Rt,{"data-testid":"org-table",children:[s($t,{children:E(ht,{children:[s(ce,{children:l("id")}),s(ce,{children:l("name")}),s(ce,{children:l("slug")}),s(ce,{children:l("created")}),s(ce,{"aria-label":l("Actions")})]})}),s(Mt,{children:b.map(M=>{const $=A(M.id);return E(ht,{"data-testid":`org-row-${$}`,children:[s(fe,{className:"font-mono text-xs",children:$}),s(fe,{children:A(M.name)}),s(fe,{children:A(M.slug)}),s(fe,{className:"text-muted-foreground tabular-nums",children:Ut(M.createdAt)}),s(fe,{children:E("div",{className:"flex justify-end gap-1",children:[s(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:()=>{w($)},size:"xs",type:"button",variant:"ghost",children:l("Manage")}),s(L,{"data-testid":`org-edit-${$}`,onClick:()=>{m({kind:"edit",org:M})},size:"xs",type:"button",variant:"ghost",children:l("Edit")}),s(L,{"data-testid":`org-delete-${$}`,onClick:()=>{m({kind:"delete",org:M})},size:"xs",type:"button",variant:"ghost",children:l("Delete")})]})})]},$)})})]})})}),t[37]=b,t[38]=o,t[39]=l,t[40]=B):B=t[40];let U;t[41]!==a||t[42]!==b||t[43]!==f.data?.total?(U=b!==null&&s(Et,{count:b.length,offset:a,onOffsetChange:h,pageSize:Ot,prefix:"org",total:f.data?.total}),t[41]=a,t[42]=b,t[43]=f.data?.total,t[44]=U):U=t[44];let Q;t[45]!==d.organization||t[46]!==o?(Q=o!==null&&s(il,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=Q):Q=t[47];let F;t[48]!==r?.kind||t[49]!==I?(F=r?.kind==="create"&&s(Dt,{mode:"create",onClose:y,onDone:I}),t[48]=r?.kind,t[49]=I,t[50]=F):F=t[50];let J;t[51]!==r||t[52]!==I?(J=r?.kind==="edit"&&s(Dt,{mode:"edit",onClose:y,onDone:I,org:r.org}),t[51]=r,t[52]=I,t[53]=J):J=t[53];let j;t[54]!==e||t[55]!==r||t[56]!==I||t[57]!==l?(j=r?.kind==="delete"&&s(Lt,{action:async()=>{const M=A(r.org.id);await e.deleteAuthOrganization({organizationId:M}),i($=>$===M?null:$)},message:l("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:y,onDone:I,testId:"org-delete",title:l("Delete organization")}),t[54]=e,t[55]=r,t[56]=I,t[57]=l,t[58]=j):j=t[58];let Z;return t[59]!==T||t[60]!==R||t[61]!==H||t[62]!==B||t[63]!==U||t[64]!==Q||t[65]!==F||t[66]!==J||t[67]!==j?(Z=E("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[T,R,H,B,U,Q,F,J,j]}),t[59]=T,t[60]=R,t[61]=H,t[62]=B,t[63]=U,t[64]=Q,t[65]=F,t[66]=J,t[67]=j,t[68]=Z):Z=t[68],Z};export{Ml as default};
@@ -1 +1 @@
1
- import{decodeDocument as D}from"@lunora/wire";import{E as F}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as E}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as x,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as P,a as V,b as g,c as m,d as C,e as o}from"../packem_shared/table-D0SBiDu-.mjs";import{u as h}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as H}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as M}from"../packem_shared/home-panel-DTWHlX5S.mjs";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as b}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as B}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as e,jsxs as d}from"react/jsx-runtime";const T="payment_subscriptions",R="payment_events",k=[T,R],G={},N=new Set(["active","trialing"]),Y=new Set(["past_due","unpaid"]),a=(n,r)=>{if(n[r]!==void 0)return n[r];const p=n.__doc__;return typeof p=="string"?D(p)?.[r]:void 0},s=n=>typeof n=="string"?n:typeof n=="number"||typeof n=="bigint"||typeof n=="boolean"?String(n):"",q=n=>N.has(n)?"default":Y.has(n)?"destructive":"outline",oe=({limit:n=100})=>{const r=U(),p=M(),{data:y}=h(b.listTables,G,{live:!0}),_=y!==void 0,w=Array.isArray(y)&&k.every(t=>y.some(c=>c.name===t)),l=p.payments&&w,i=h(b.readTablePage,{filters:[],limit:n,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:T},{enabled:l}),u=h(b.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:R},{enabled:l}),v=h(b.facetColumn,{column:"state",table:T},{enabled:l});H(()=>{if(l)return Promise.all([i.poll(),u.poll(),v.poll()])},!0);const f=i.data?.rows??[],L=u.data?.rows??[],O=i.error??u.error,Q=i.error===null?u.errorSource:i.errorSource,j=i.data?.total??f.length,S=v.data?.values===void 0?f.filter(t=>N.has(s(a(t,"state")))).length:v.data.values.reduce((t,c)=>t+(N.has(s(c.value))?c.count:0),0);return _&&!l?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(I,{description:r("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:r("No payments configured")})}):d("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:d(x,{className:"justify-between gap-0 py-0",children:[d("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Subscriptions")}),d("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:S}),e(E,{variant:"default",children:r("{count} active",{count:S})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r("{total} total",{total:j})})]})}),O===null?void 0:e(F,{error:Q}),f.length===0&&!i.isLoading?e(I,{testId:"payments-empty",title:r("No subscriptions yet")}):e(x,{className:"overflow-hidden py-0",children:e(A,{className:"px-0",children:d(P,{children:[e(V,{children:d(g,{children:[e(m,{children:r("Provider")}),e(m,{children:r("Reference")}),e(m,{children:r("Plan")}),e(m,{children:r("State")}),e(m,{children:r("Renews")})]})}),e(C,{children:f.map(t=>{const c=s(a(t,"state"));return d(g,{"data-testid":"payment-subscription-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{children:s(a(t,"referenceId"))}),e(o,{children:s(a(t,"priceId"))}),e(o,{children:e(E,{variant:q(c),children:c})}),e(o,{children:B(a(t,"currentPeriodEnd"))})]},s(a(t,"providerSubscriptionId")))})})]})})}),d(x,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Recent webhook events")})}),e(A,{className:"px-0",children:e(P,{children:e(C,{children:L.map(t=>d(g,{"data-testid":"payment-event-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{className:"font-medium",children:s(a(t,"type"))}),e(o,{className:"text-muted-foreground",children:s(a(t,"providerEventId"))}),e(o,{children:B(a(t,"processedAt"))})]},s(a(t,"providerEventId"))))})})})]})]})};export{oe as PaymentsPanel};
1
+ import{decodeDocument as D}from"@lunora/wire";import{E as F}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as E}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as x,a as A}from"../packem_shared/card-By2O8ULa.mjs";import{E as I}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as P,a as V,b as g,c as m,d as C,e as o}from"../packem_shared/table-D0SBiDu-.mjs";import{u as h}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as H}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as M}from"../packem_shared/home-panel-DTWHlX5S.mjs";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as b}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as B}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as e,jsxs as d}from"react/jsx-runtime";const T="payment_subscriptions",R="payment_events",k=[T,R],G={},N=new Set(["active","trialing"]),Y=new Set(["past_due","unpaid"]),a=(n,r)=>{if(n[r]!==void 0)return n[r];const p=n.__doc__;return typeof p=="string"?D(p)?.[r]:void 0},s=n=>typeof n=="string"?n:typeof n=="number"||typeof n=="bigint"||typeof n=="boolean"?String(n):"",q=n=>N.has(n)?"default":Y.has(n)?"destructive":"outline",oe=({limit:n=100})=>{const r=U(),p=M(),{data:y}=h(b.listTables,G,{live:!0}),_=y!==void 0,w=Array.isArray(y)&&k.every(t=>y.some(c=>c.name===t)),l=p.payments&&w,i=h(b.readTablePage,{filters:[],limit:n,offset:0,orderBy:{column:"updatedAt",direction:"desc"},search:"",table:T},{enabled:l}),u=h(b.readTablePage,{filters:[],limit:25,offset:0,orderBy:{column:"processedAt",direction:"desc"},search:"",table:R},{enabled:l}),v=h(b.facetColumn,{column:"state",table:T},{enabled:l});H(()=>{if(l)return Promise.all([i.poll(),u.poll(),v.poll()])},!0);const f=i.data?.rows??[],L=u.data?.rows??[],O=i.error??u.error,Q=i.error===null?u.errorSource:i.errorSource,j=i.data?.total??f.length,S=v.data?.values===void 0?f.filter(t=>N.has(s(a(t,"state")))).length:v.data.values.reduce((t,c)=>t+(N.has(s(c.value))?c.count:0),0);return _&&!l?e("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:e(I,{description:r("No @lunora/payment tables found in this deployment. Add `.extend(paymentExtension)` to lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:r("No payments configured")})}):d("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[e("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:d(x,{className:"justify-between gap-0 py-0",children:[d("div",{className:"flex flex-col gap-2.5 p-4",children:[e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Subscriptions")}),d("div",{className:"flex items-center gap-2",children:[e("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:S}),e(E,{variant:"default",children:r("{count} active",{count:S})})]})]}),e("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r("{total} total",{total:j})})]})}),O===null?void 0:e(F,{error:Q}),f.length===0&&!i.isLoading?e(I,{testId:"payments-empty",title:r("No subscriptions yet")}):e(x,{className:"overflow-hidden py-0",children:e(A,{className:"px-0",children:d(P,{children:[e(V,{children:d(g,{children:[e(m,{children:r("Provider")}),e(m,{children:r("Reference")}),e(m,{children:r("Plan")}),e(m,{children:r("State")}),e(m,{children:r("Renews")})]})}),e(C,{children:f.map(t=>{const c=s(a(t,"state"));return d(g,{"data-testid":"payment-subscription-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{children:s(a(t,"referenceId"))}),e(o,{children:s(a(t,"priceId"))}),e(o,{children:e(E,{variant:q(c),children:c})}),e(o,{children:B(a(t,"currentPeriodEnd"))})]},s(a(t,"providerSubscriptionId")))})})]})})}),d(x,{className:"overflow-hidden py-0",children:[e("header",{className:"border-b border-border px-4 py-3",children:e("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Recent webhook events")})}),e(A,{className:"px-0",children:e(P,{children:e(C,{children:L.map(t=>d(g,{"data-testid":"payment-event-row",children:[e(o,{children:s(a(t,"provider"))}),e(o,{className:"font-medium",children:s(a(t,"type"))}),e(o,{className:"text-muted-foreground",children:s(a(t,"providerEventId"))}),e(o,{children:B(a(t,"processedAt"))})]},s(a(t,"providerEventId"))))})})})]})]})};export{oe as PaymentsPanel};
@@ -1 +1 @@
1
- import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("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[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("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:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("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:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
1
+ import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("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[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("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:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("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:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("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:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
@@ -1 +1 @@
1
- import{c as V}from"react/compiler-runtime";import{useState as G}from"react";import{D as we}from"../packem_shared/studio-DE7i2--m.mjs";import{B as le}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as j,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as ee,c as O,a as te,b as Q,d as se,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ne,u as xe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as re}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as ie,f as Z,j as ge,b as de,c as ve,d as ke}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as R}from"react/jsx-runtime";import{I as Se}from"../packem_shared/input-CXhxesPC.mjs";import{u as Ce}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{c as Te}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ae}from"@lunora/react";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{u as ye}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{ScheduledJobs as $e}from"../packem_shared/ScheduledJobs-QCTRdugp.mjs";const Ne={failed:"destructive",skipped:"warning",succeeded:"success"},Ie=25,Ee=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,Re=t=>{const e=V(39),{inFlight:i,last:n}=t,l=z();if(i!==void 0){let h;e[0]!==l?(h=l("running"),e[0]=l,e[1]=h):h=e[1];let g;e[2]!==h?(g=s(Y,{variant:"info",children:h}),e[2]=h,e[3]=g):g=e[3];let b;e[4]!==i.startedAt?(b=ie(i.startedAt,"—"),e[4]=i.startedAt,e[5]=b):b=e[5];let w;e[6]!==b?(w=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=w):w=e[7];let S;e[8]!==i.skipped||e[9]!==l?(S=i.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:l("{count} ticks skipped",{count:i.skipped})}),e[8]=i.skipped,e[9]=l,e[10]=S):S=e[10];let N;return e[11]!==g||e[12]!==w||e[13]!==S?(N=R("span",{className:"flex items-center gap-2",children:[g,w,S]}),e[11]=g,e[12]=w,e[13]=S,e[14]=N):N=e[14],N}if(n===void 0){let h;e[15]!==l?(h=l("never"),e[15]=l,e[16]=h):h=e[16];let g;return e[17]!==h?(g=s("span",{className:"text-xs text-muted-foreground",children:h}),e[17]=h,e[18]=g):g=e[18],g}let a;e[19]!==l?(a=l("failed"),e[19]=l,e[20]=a):a=e[20];let r;e[21]!==l?(r=l("skipped"),e[21]=l,e[22]=r):r=e[22];let o;e[23]!==l?(o=l("succeeded"),e[23]=l,e[24]=o):o=e[24];let u;e[25]!==a||e[26]!==r||e[27]!==o?(u={failed:a,skipped:r,succeeded:o},e[25]=a,e[26]=r,e[27]=o,e[28]=u):u=e[28];const v=u,f=Ne[n.status],c=v[n.status];let m;e[29]!==f||e[30]!==c?(m=s(Y,{variant:f,children:c}),e[29]=f,e[30]=c,e[31]=m):m=e[31];let y;e[32]!==n.startedAt?(y=ie(n.startedAt,"—"),e[32]=n.startedAt,e[33]=y):y=e[33];let p;e[34]!==y?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:y}),e[34]=y,e[35]=p):p=e[35];let d;return e[36]!==m||e[37]!==p?(d=R("span",{className:"flex items-center gap-2",children:[m,p]}),e[36]=m,e[37]=p,e[38]=d):d=e[38],d},Le=t=>{const e=V(80),{runs:i}=t,n=z();if(i.length===0)return;let l,a,r,o,u,v,f,c,m,y,p;if(e[0]!==i||e[1]!==n){const S=i.toSorted(Oe).slice(0,Ie);let N;e[13]!==n?(N=n("failed"),e[13]=n,e[14]=N):N=e[14];let T;e[15]!==n?(T=n("skipped"),e[15]=n,e[16]=T):T=e[16];let L;e[17]!==n?(L=n("succeeded"),e[17]=n,e[18]=L):L=e[18];let $;e[19]!==L||e[20]!==N||e[21]!==T?($={failed:N,skipped:T,succeeded:L},e[19]=L,e[20]=N,e[21]=T,e[22]=$):$=e[22];const A=$;m="flex flex-col gap-2",y="cron-run-history";let C;e[23]!==n?(C=n("Recent runs"),e[23]=n,e[24]=C):C=e[24],e[25]!==C?(p=s("h3",{className:"text-sm font-medium",children:C}),e[25]=C,e[26]=p):p=e[26],o=j,c="overflow-hidden py-0",r=X,f="px-0",a=ee;let k;e[27]!==n?(k=n("name"),e[27]=n,e[28]=k):k=e[28];let x;e[29]!==k?(x=s(O,{children:k}),e[29]=k,e[30]=x):x=e[30];let I;e[31]!==n?(I=n("status"),e[31]=n,e[32]=I):I=e[32];let D;e[33]!==I?(D=s(O,{children:I}),e[33]=I,e[34]=D):D=e[34];let E;e[35]!==n?(E=n("started"),e[35]=n,e[36]=E):E=e[36];let _;e[37]!==E?(_=s(O,{children:E}),e[37]=E,e[38]=_):_=e[38];let F;e[39]!==n?(F=n("duration"),e[39]=n,e[40]=F):F=e[40];let B;e[41]!==F?(B=s(O,{children:F}),e[41]=F,e[42]=B):B=e[42];let J;e[43]!==n?(J=n("skipped"),e[43]=n,e[44]=J):J=e[44];let U;e[45]!==J?(U=s(O,{children:J}),e[45]=J,e[46]=U):U=e[46];let P;e[47]!==n?(P=n("error"),e[47]=n,e[48]=P):P=e[48];let M;e[49]!==P?(M=s(O,{children:P}),e[49]=P,e[50]=M):M=e[50],e[51]!==x||e[52]!==D||e[53]!==_||e[54]!==B||e[55]!==U||e[56]!==M?(v=s(te,{children:R(Q,{children:[x,D,_,B,U,M]})}),e[51]=x,e[52]=D,e[53]=_,e[54]=B,e[55]=U,e[56]=M,e[57]=v):v=e[57],l=se;let W;e[58]!==A?(W=H=>R(Q,{"data-testid":`cron-run-row-${H.runId}`,children:[s(K,{children:H.name}),s(K,{children:s(Y,{variant:Ne[H.status],children:A[H.status]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(H.startedAt,"—")}),s(K,{className:"tabular-nums",children:H.status==="skipped"?"":Ee(H.durationMs)}),s(K,{className:"tabular-nums",children:H.skipped>0?H.skipped:""}),s(K,{className:"text-xs text-destructive",children:H.error??""})]},H.runId),e[58]=A,e[59]=W):W=e[59],u=S.map(W),e[0]=i,e[1]=n,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=v,e[8]=f,e[9]=c,e[10]=m,e[11]=y,e[12]=p}else l=e[2],a=e[3],r=e[4],o=e[5],u=e[6],v=e[7],f=e[8],c=e[9],m=e[10],y=e[11],p=e[12];let d;e[60]!==l||e[61]!==u?(d=s(l,{children:u}),e[60]=l,e[61]=u,e[62]=d):d=e[62];let h;e[63]!==a||e[64]!==v||e[65]!==d?(h=R(a,{children:[v,d]}),e[63]=a,e[64]=v,e[65]=d,e[66]=h):h=e[66];let g;e[67]!==r||e[68]!==f||e[69]!==h?(g=s(r,{className:f,children:h}),e[67]=r,e[68]=f,e[69]=h,e[70]=g):g=e[70];let b;e[71]!==o||e[72]!==g||e[73]!==c?(b=s(o,{className:c,children:g}),e[71]=o,e[72]=g,e[73]=c,e[74]=b):b=e[74];let w;return e[75]!==b||e[76]!==m||e[77]!==y||e[78]!==p?(w=R("div",{className:m,"data-testid":y,children:[p,b]}),e[75]=b,e[76]=m,e[77]=y,e[78]=p,e[79]=w):w=e[79],w};function Oe(t,e){return e.startedAt-t.startedAt}const Ke=()=>{const t=V(50),e=z(),i=Ce(""),[n,l]=G(""),[a,r]=G(void 0),[o,u]=G(!1);if(i.unavailable)return null;let v;t[0]!==i?(v=i.pending("cron"),t[0]=i,t[1]=v):v=t[1];const f=v;let c;t[2]!==i?(c=i.reason("cron"),t[2]=i,t[3]=c):c=t[3];const m=c;let y;t[4]!==n||t[5]!==i?(y=()=>{const E=n.trim();if(E==="")return;Z((async()=>{const F=await i.suggestCron(E);u(!1),r(F)})())},t[4]=n,t[5]=i,t[6]=y):y=t[6];const p=y;let d;t[7]!==a?(d=()=>{const E="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(E===void 0||a===void 0)return;Z((async()=>{try{await E.writeText(a),u(!0)}catch{u(!1)}})())},t[7]=a,t[8]=d):d=t[8];const h=d;let g;t[9]!==e?(g=e("Describe a schedule"),t[9]=e,t[10]=g):g=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{l(E.target.value)},t[11]=b):b=t[11];let w;t[12]!==p?(w=E=>{E.key==="Enter"&&(E.preventDefault(),p())},t[12]=p,t[13]=w):w=t[13];let S;t[14]!==e?(S=e("Describe a schedule"),t[14]=e,t[15]=S):S=t[15];let N;t[16]!==f||t[17]!==n||t[18]!==g||t[19]!==w||t[20]!==S?(N=s(Se,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:f,onChange:b,onKeyDown:w,placeholder:S,value:n}),t[16]=f,t[17]=n,t[18]=g,t[19]=w,t[20]=S,t[21]=N):N=t[21];const T=f&&"opacity-60";let L;t[22]!==T?(L=Te("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",T),t[22]=T,t[23]=L):L=t[23];let $;t[24]!==f||t[25]!==n?($=f||n.trim()==="",t[24]=f,t[25]=n,t[26]=$):$=t[26];let A;t[27]!==f||t[28]!==e?(A=e(f?"Thinking…":"Suggest schedule"),t[27]=f,t[28]=e,t[29]=A):A=t[29];let C;t[30]!==p||t[31]!==L||t[32]!==$||t[33]!==A?(C=s("button",{className:L,"data-testid":"cron-assistant-generate",disabled:$,onClick:p,type:"button",children:A}),t[30]=p,t[31]=L,t[32]=$,t[33]=A,t[34]=C):C=t[34];let k;t[35]!==C||t[36]!==N?(k=R("div",{className:"flex items-center gap-2",children:[N,C]}),t[35]=C,t[36]=N,t[37]=k):k=t[37];let x;t[38]!==o||t[39]!==h||t[40]!==a||t[41]!==e?(x=a!==void 0&&R("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:a}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:h,type:"button",children:e(o?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=o,t[39]=h,t[40]=a,t[41]=e,t[42]=x):x=t[42];let I;t[43]!==m||t[44]!==e?(I=m!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(m==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=m,t[44]=e,t[45]=I):I=t[45];let D;return t[46]!==k||t[47]!==x||t[48]!==I?(D=R("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[k,x,I]}),t[46]=k,t[47]=x,t[48]=I,t[49]=D):D=t[49],D},De={kind:"idle"},_e="SCHEDULER_NOT_CONFIGURED",ue={inFlight:[],runs:[]},Fe=(t,e,i)=>i!==void 0?i:e===void 0?n=>t.runCronJob(n):void 0,Je=({loadCronJobs:t,loadCronRuns:e,runCronJob:i}={})=>{const n=ae(),l=z(),[a,r]=G({}),o=ne(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>n.getCronJobs()))()),{data:u,error:v}=o,f=e??(t===void 0?()=>n.listCronRuns():void 0),c=ne(["lunora-cron-runs",e?"custom":"default"],async()=>f===void 0?ue:f().catch(d=>{if(ge(d)===_e)return ue;throw d})),m=c.data??ue;re(()=>c.poll(),f!==void 0);const y=Fe(n,t,i),p=async d=>{if(y!==void 0){r(h=>({...h,[d]:{kind:"running"}}));try{await y(d),r(h=>({...h,[d]:{kind:"ok"}})),o.refetch(),c.refetch()}catch(h){r(g=>({...g,[d]:{kind:"error",message:de(h)}}))}}};return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Ke,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:c.error}),u?.length===0&&s(oe,{description:l("Triggers declared with the cronJobs() builder appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:l("No cron triggers.")}),u!==void 0&&u.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"cron-table",children:[s(te,{children:R(Q,{children:[s(O,{children:l("name")}),s(O,{children:l("schedule")}),s(O,{children:l("target")}),s(O,{children:l("shard")}),s(O,{children:l("last run")}),y!==void 0&&s(O,{"aria-label":l("Actions")})]})}),s(se,{children:u.map(d=>{const h=a[d.name]??De;return R(Q,{"data-testid":`cron-row-${d.name}`,children:[s(K,{children:d.name}),s(K,{className:"font-mono text-xs tabular-nums",children:d.cron}),s(K,{children:R("span",{className:"flex items-center gap-2",children:[d.workflow===void 0?s(Y,{variant:"outline",children:l("function")}):s(Y,{variant:"secondary",children:l("workflow")}),s("span",{className:"font-mono text-xs",children:d.workflow??d.functionPath})]})}),s(K,{children:d.shardKey??""}),s(K,{"data-testid":`cron-last-run-${d.name}`,children:s(Re,{inFlight:m.inFlight.find(g=>g.name===d.name),last:m.runs.find(g=>g.name===d.name)})}),y!==void 0&&s(K,{className:"text-right",children:R("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${d.name}`,children:l("ran")}),h.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${d.name}`,role:"alert",children:h.message}),s(me,{confirmLabel:l("Run now?"),disabled:h.kind==="running",onConfirm:()=>{Z(p(d.name))},testId:`cron-run-${d.name}`,children:h.kind==="running"?l("Running…"):l("Run now")})]})})]},`${d.cron}:${d.name}`)})})]})})}),s(Le,{runs:m.runs})]})},Me=t=>Number.isFinite(t)?ie(t,"—"):"—",Pe=t=>{const e=V(34);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n,removeJob:l,retryJob:a}=i,r=ae(),o=z();let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-dead-jobs"],e[2]=u):u=e[2];let v;e[3]!==r||e[4]!==n?(v=async()=>(await(n??(()=>r.listDeadJobs()))()).toSorted(qe),e[3]=r,e[4]=n,e[5]=v):v=e[5];const f=ne(u,v),c=f.data,[m,y]=G(void 0),p=f.error??m,d=n===void 0;let h;e[6]!==r||e[7]!==d||e[8]!==a?(h=a??(d?x=>r.retryDeadJob(x):void 0),e[6]=r,e[7]=d,e[8]=a,e[9]=h):h=e[9];const g=h;let b;e[10]!==r||e[11]!==d||e[12]!==l?(b=l??(d?x=>r.removeDeadJob(x):void 0),e[10]=r,e[11]=d,e[12]=l,e[13]=b):b=e[13];const w=b;let S;e[14]!==f?(S=()=>f.poll(),e[14]=f,e[15]=S):S=e[15],re(S,!0);let N;e[16]!==f?(N=async x=>{y(void 0);try{await x,f.refetch()}catch(I){y(de(I))}},e[16]=f,e[17]=N):N=e[17];const T=N,L=g!==void 0||w!==void 0;let $;e[18]!==p?($=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=$):$=e[19];let A;e[20]!==c?.length||e[21]!==o?(A=c?.length===0&&s(oe,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=c?.length,e[21]=o,e[22]=A):A=e[22];let C;e[23]!==T||e[24]!==L||e[25]!==c||e[26]!==w||e[27]!==g||e[28]!==o?(C=c!==void 0&&c.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"dlq-table",children:[s(te,{children:R(Q,{children:[s(O,{children:o("function")}),s(O,{children:o("attempts")}),s(O,{children:o("last tried")}),s(O,{children:o("pool")}),s(O,{children:o("shard")}),s(O,{children:o("id")}),L&&s(O,{"aria-label":o("Actions")})]})}),s(se,{children:c.map(x=>R(Q,{"data-testid":`dlq-row-${x.id}`,children:[s(K,{className:"font-mono text-xs",children:x.workflow??x.functionPath}),s(K,{className:"tabular-nums",children:x.attempts??0}),s(K,{className:"text-muted-foreground tabular-nums",children:Me(x.scheduledFor)}),s(K,{className:"font-mono text-xs",children:x.pool??""}),s(K,{children:x.shardKey??""}),s(K,{className:"font-mono text-xs",children:x.id}),L&&s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&s(le,{"data-testid":`dlq-retry-${x.id}`,onClick:()=>{Z(T(g(x.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),w!==void 0&&s(me,{confirmLabel:o("Drop job?"),onConfirm:()=>{Z(T(w(x.id)))},testId:`dlq-remove-${x.id}`,children:o("Drop")})]})})]},x.id))})]})})}),e[23]=T,e[24]=L,e[25]=c,e[26]=w,e[27]=g,e[28]=o,e[29]=C):C=e[29];let k;return e[30]!==C||e[31]!==$||e[32]!==A?(k=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,A,C]}),e[30]=C,e[31]=$,e[32]=A,e[33]=k):k=e[33],k};function qe(t,e){return(e.attempts??0)-(t.attempts??0)}const Ue={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Be=t=>{const e=V(47);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n}=i,l=ae(),a=z();let r;e[2]!==l||e[3]!==n?(r=n??(async q=>l.listScheduledHistory(q===void 0?{}:{cursor:q})),e[2]=l,e[3]=n,e[4]=r):r=e[4];const o=r,u=n?"custom":"default";let v;e[5]!==u?(v=["lunora-job-history",u],e[5]=u,e[6]=v):v=e[6];let f;e[7]!==o?(f=async()=>o(),e[7]=o,e[8]=f):f=e[8];const c=ne(v,f),[m,y]=G(void 0),[p,d]=G(!1),[h,g]=G(void 0),b=c.data?.records;let w;e[9]!==b?(w=new Set(b?.map(He)),e[9]=b,e[10]=w):w=e[10];const S=w,N=b===void 0?void 0:[...b,...(m?.records??[]).filter(q=>!S.has(q.id))],T=m===void 0?c.data?.cursor:m.cursor;let L;e[11]!==o||e[12]!==T?(L=async()=>{d(!0),g(void 0);try{const q=await o(T);y(pe=>({cursor:q.cursor,records:[...pe?.records??[],...q.records]})),d(!1)}catch(q){g(de(q)),d(!1)}},e[11]=o,e[12]=T,e[13]=L):L=e[13];const $=L;let A;e[14]!==a?(A=a("canceled"),e[14]=a,e[15]=A):A=e[15];let C;e[16]!==a?(C=a("failed"),e[16]=a,e[17]=C):C=e[17];let k;e[18]!==a?(k=a("pending"),e[18]=a,e[19]=k):k=e[19];let x;e[20]!==a?(x=a("running"),e[20]=a,e[21]=x):x=e[21];let I;e[22]!==a?(I=a("succeeded"),e[22]=a,e[23]=I):I=e[23];let D;e[24]!==k||e[25]!==x||e[26]!==I||e[27]!==A||e[28]!==C?(D={canceled:A,failed:C,pending:k,running:x,succeeded:I},e[24]=k,e[25]=x,e[26]=I,e[27]=A,e[28]=C,e[29]=D):D=e[29];const E=D;let _;e[30]!==c?(_=()=>c.poll(),e[30]=c,e[31]=_):_=e[31],re(_,m===void 0);const F="flex flex-col gap-3",B="lunora-job-history";let J;e[32]!==c.error?(J=c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:c.error}),e[32]=c.error,e[33]=J):J=e[33];const U=N?.length===0&&s(oe,{description:a("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:a("No finished jobs.")}),P=N!==void 0&&N.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"job-history-table",children:[s(te,{children:R(Q,{children:[s(O,{children:a("function")}),s(O,{children:a("state")}),s(O,{children:a("finished")}),s(O,{children:a("error")}),s(O,{children:a("id")})]})}),s(se,{children:N.map(q=>R(Q,{"data-testid":`job-history-row-${q.id}`,children:[s(K,{className:"font-mono text-xs",children:q.workflow??q.functionPath}),s(K,{children:s(Y,{"data-testid":`job-history-state-${q.id}`,variant:Ue[q.state],children:E[q.state]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(q.completedAt,"—")}),s(K,{className:"text-xs text-destructive",children:q.error??""}),s(K,{className:"font-mono text-xs",children:q.id})]},q.id))})]})})});let M;e[34]!==h?(M=h!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:h}),e[34]=h,e[35]=M):M=e[35];let W;e[36]!==p||e[37]!==T||e[38]!==$||e[39]!==a?(W=T!==void 0&&s("div",{children:s(le,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{Z($())},variant:"outline",children:a(p?"Loading…":"Load more")})}),e[36]=p,e[37]=T,e[38]=$,e[39]=a,e[40]=W):W=e[40];let H;return e[41]!==J||e[42]!==U||e[43]!==P||e[44]!==M||e[45]!==W?(H=R("div",{className:F,"data-testid":B,children:[J,U,P,M,W]}),e[41]=J,e[42]=U,e[43]=P,e[44]=M,e[45]=W,e[46]=H):H=e[46],H};function He(t){return t.id}const Qe=ve(ce.dropOutboxEntry),Ve=ve(ce.retryOutboxEntry),ze=()=>{const t=V(8),e=z();let i;t[0]!==e?(i=e("Jobs whose mutation committed but that the scheduler has not accepted yet wait here."),t[0]=e,t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 4h16v12H4zM4 16l4 4h8l4-4"})}),t[2]=n):n=t[2];let l;t[3]!==e?(l=e("Nothing is waiting for the scheduler."),t[3]=e,t[4]=l):l=t[4];let a;return t[5]!==i||t[6]!==l?(a=s(oe,{description:i,icon:n,testId:"outbox-empty",title:l}),t[5]=i,t[6]=l,t[7]=a):a=t[7],a},We=t=>{const e=V(58),{entry:i,onAct:n}=t,l=z(),a=`outbox-row-${i.id}`;let r;e[0]!==i.target||e[1]!==l?(r=i.target??l("unreadable"),e[0]=i.target,e[1]=l,e[2]=r):r=e[2];let o;e[3]!==r?(o=s(K,{className:"font-mono text-xs",children:r}),e[3]=r,e[4]=o):o=e[4];const u=i.parked?"destructive":"secondary";let v;e[5]!==i.parked||e[6]!==l?(v=i.parked?l("parked"):l("retrying"),e[5]=i.parked,e[6]=l,e[7]=v):v=e[7];let f;e[8]!==u||e[9]!==v?(f=s(Y,{variant:u,children:v}),e[8]=u,e[9]=v,e[10]=f):f=e[10];let c;e[11]!==i.forever||e[12]!==l?(c=i.forever&&s(Y,{variant:"outline",children:l("forever")}),e[11]=i.forever,e[12]=l,e[13]=c):c=e[13];let m;e[14]!==f||e[15]!==c?(m=s(K,{children:R("div",{className:"flex gap-1",children:[f,c]})}),e[14]=f,e[15]=c,e[16]=m):m=e[16];let y;e[17]!==i.attempts?(y=s(K,{className:"tabular-nums",children:i.attempts}),e[17]=i.attempts,e[18]=y):y=e[18];let p;e[19]!==i.nextAttemptAt||e[20]!==i.parked?(p=i.parked?"—":ie(i.nextAttemptAt,"—"),e[19]=i.nextAttemptAt,e[20]=i.parked,e[21]=p):p=e[21];let d;e[22]!==p?(d=s(K,{className:"text-muted-foreground tabular-nums",children:p}),e[22]=p,e[23]=d):d=e[23];let h;e[24]!==i.id?(h=s(K,{className:"font-mono text-xs",children:i.id}),e[24]=i.id,e[25]=h):h=e[25];const g=`outbox-retry-${i.id}`;let b;e[26]!==i.id||e[27]!==n?(b=()=>{Z(n(Ve,i.id))},e[26]=i.id,e[27]=n,e[28]=b):b=e[28];let w;e[29]!==l?(w=l("Retry now"),e[29]=l,e[30]=w):w=e[30];let S;e[31]!==g||e[32]!==b||e[33]!==w?(S=s(le,{"data-testid":g,onClick:b,size:"sm",type:"button",variant:"outline",children:w}),e[31]=g,e[32]=b,e[33]=w,e[34]=S):S=e[34];let N;e[35]!==l?(N=l("Drop job?"),e[35]=l,e[36]=N):N=e[36];let T;e[37]!==i.id||e[38]!==n?(T=()=>{Z(n(Qe,i.id))},e[37]=i.id,e[38]=n,e[39]=T):T=e[39];const L=`outbox-drop-${i.id}`;let $;e[40]!==l?($=l("Drop"),e[40]=l,e[41]=$):$=e[41];let A;e[42]!==N||e[43]!==T||e[44]!==L||e[45]!==$?(A=s(me,{confirmLabel:N,onConfirm:T,testId:L,children:$}),e[42]=N,e[43]=T,e[44]=L,e[45]=$,e[46]=A):A=e[46];let C;e[47]!==S||e[48]!==A?(C=s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[S,A]})}),e[47]=S,e[48]=A,e[49]=C):C=e[49];let k;return e[50]!==a||e[51]!==d||e[52]!==h||e[53]!==C||e[54]!==o||e[55]!==m||e[56]!==y?(k=R(Q,{"data-testid":a,children:[o,m,y,d,h,C]}),e[50]=a,e[51]=d,e[52]=h,e[53]=C,e[54]=o,e[55]=m,e[56]=y,e[57]=k):k=e[57],k},Ge=t=>{const e=V(41),{entries:i,onAct:n}=t,l=z();let a;e[0]!==l?(a=l("function"),e[0]=l,e[1]=a):a=e[1];let r;e[2]!==a?(r=s(O,{children:a}),e[2]=a,e[3]=r):r=e[3];let o;e[4]!==l?(o=l("state"),e[4]=l,e[5]=o):o=e[5];let u;e[6]!==o?(u=s(O,{children:o}),e[6]=o,e[7]=u):u=e[7];let v;e[8]!==l?(v=l("attempts"),e[8]=l,e[9]=v):v=e[9];let f;e[10]!==v?(f=s(O,{children:v}),e[10]=v,e[11]=f):f=e[11];let c;e[12]!==l?(c=l("next attempt"),e[12]=l,e[13]=c):c=e[13];let m;e[14]!==c?(m=s(O,{children:c}),e[14]=c,e[15]=m):m=e[15];let y;e[16]!==l?(y=l("id"),e[16]=l,e[17]=y):y=e[17];let p;e[18]!==y?(p=s(O,{children:y}),e[18]=y,e[19]=p):p=e[19];let d;e[20]!==l?(d=l("Actions"),e[20]=l,e[21]=d):d=e[21];let h;e[22]!==d?(h=s(O,{"aria-label":d}),e[22]=d,e[23]=h):h=e[23];let g;e[24]!==p||e[25]!==h||e[26]!==r||e[27]!==u||e[28]!==f||e[29]!==m?(g=s(te,{children:R(Q,{children:[r,u,f,m,p,h]})}),e[24]=p,e[25]=h,e[26]=r,e[27]=u,e[28]=f,e[29]=m,e[30]=g):g=e[30];let b;if(e[31]!==i||e[32]!==n){let N;e[34]!==n?(N=T=>s(We,{entry:T,onAct:n},T.id),e[34]=n,e[35]=N):N=e[35],b=i.map(N),e[31]=i,e[32]=n,e[33]=b}else b=e[33];let w;e[36]!==b?(w=s(se,{children:b}),e[36]=b,e[37]=w):w=e[37];let S;return e[38]!==g||e[39]!==w?(S=s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"outbox-table",children:[g,w]})})}),e[38]=g,e[39]=w,e[40]=S):S=e[40],S},Ye=t=>{const e=V(11),{cursor:i,nextCursor:n,onFirst:l,onNext:a}=t,r=z();if(i===void 0&&n===void 0)return;let o;e[0]!==i||e[1]!==l||e[2]!==r?(o=i!==void 0&&s(le,{"data-testid":"outbox-first-page",onClick:l,size:"sm",type:"button",variant:"outline",children:r("First page")}),e[0]=i,e[1]=l,e[2]=r,e[3]=o):o=e[3];let u;e[4]!==n||e[5]!==a||e[6]!==r?(u=n!==void 0&&s(le,{"data-testid":"outbox-next-page",onClick:()=>{a(n)},size:"sm",type:"button",variant:"outline",children:r("Next page")}),e[4]=n,e[5]=a,e[6]=r,e[7]=u):u=e[7];let v;return e[8]!==o||e[9]!==u?(v=R("div",{className:"flex justify-end gap-1.5",children:[o,u]}),e[8]=o,e[9]=u,e[10]=v):v=e[10],v},je=t=>{const e=V(38);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n}=i,l=Ae(),a=z(),{queryShardKey:r,setShardKey:o,shardKey:u}=ye(n);let v;e[2]!==r?(v={cursor:void 0,shardKey:r},e[2]=r,e[3]=v):v=e[3];const[f,c]=G(v);f.shardKey!==r&&c({cursor:void 0,shardKey:r});const m=f.shardKey===r?f.cursor:void 0,y=u.trim()!==r;let p;e[4]!==m?(p=m===void 0?{}:{cursor:m},e[4]=m,e[5]=p):p=e[5];let d;e[6]!==r?(d={shardKey:r},e[6]=r,e[7]=d):d=e[7];const{data:h,error:g,poll:b,refetch:w}=xe(ce.getScheduleOutbox,p,d),S=y?void 0:h?.entries,N=y?void 0:h?.nextCursor,[T,L]=G(void 0),$=g??(T?.shardKey===r?T.message:void 0);re(b,!0);let A;e[8]!==l||e[9]!==r||e[10]!==w||e[11]!==a?(A=async(J,U)=>{L(void 0);try{(await l.query(J,{id:U},ke(r))).retried===!1&&L({message:a("That job is no longer in the outbox."),shardKey:r}),w()}catch(P){L({message:de(P),shardKey:r})}},e[8]=l,e[9]=r,e[10]=w,e[11]=a,e[12]=A):A=e[12];const C=A;let k;e[13]!==o||e[14]!==u?(k=s(be,{onChange:o,testId:"outbox-shard-input",value:u}),e[13]=o,e[14]=u,e[15]=k):k=e[15];let x;e[16]!==$?(x=$!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"outbox-error",role:"alert",children:$}),e[16]=$,e[17]=x):x=e[17];let I;e[18]!==m||e[19]!==S?.length?(I=S?.length===0&&m===void 0&&s(ze,{}),e[18]=m,e[19]=S?.length,e[20]=I):I=e[20];let D;e[21]!==C||e[22]!==S?(D=S!==void 0&&S.length>0&&s(Ge,{entries:S,onAct:C}),e[21]=C,e[22]=S,e[23]=D):D=e[23];let E,_;e[24]!==r?(E=()=>{c({cursor:void 0,shardKey:r})},_=J=>{c({cursor:J,shardKey:r})},e[24]=r,e[25]=E,e[26]=_):(E=e[25],_=e[26]);let F;e[27]!==m||e[28]!==N||e[29]!==E||e[30]!==_?(F=s(Ye,{cursor:m,nextCursor:N,onFirst:E,onNext:_}),e[27]=m,e[28]=N,e[29]=E,e[30]=_,e[31]=F):F=e[31];let B;return e[32]!==F||e[33]!==k||e[34]!==x||e[35]!==I||e[36]!==D?(B=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-schedule-outbox",children:[k,x,I,D,F]}),e[32]=F,e[33]=k,e[34]=x,e[35]=I,e[36]=D,e[37]=B):B=e[37],B},Xe="scheduler.lag_ms",he=t=>{const e=t.attributes?.function;return typeof e=="string"?e:t.functionPath},fe=t=>{const e=V(8),{label:i,testId:n,value:l}=t;let a;e[0]!==i?(a=s("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=a):a=e[1];let r;e[2]!==n||e[3]!==l?(r=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:l}),e[2]=n,e[3]=l,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=s(j,{className:"flex-1 py-0",children:R(X,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},Ze=t=>{const e=V(65);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadStatus:l}=i,a=ae(),r=z(),o=l===void 0;let u;e[2]!==o?(u=["lunora-scheduler-status",o],e[2]=o,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==l?(v=async()=>{const J=await(l??(()=>a.schedulerStatus()))();return{...J,pools:J.pools.toSorted(et)}},e[4]=a,e[5]=l,e[6]=v):v=e[6];const f=ne(u,v),{data:c,error:m}=f,{queryShardKey:y,setShardKey:p,shardKey:d}=ye(n);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h={},e[7]=h):h=e[7];let g;e[8]!==y?(g={shardKey:y},e[8]=y,e[9]=g):g=e[9];const b=xe(ce.getMetricSeries,h,g),{data:w,errorSource:S}=b;let N;e[10]!==S||e[11]!==b.error?(N=ge(S)==="FUNCTION_NOT_FOUND"?null:b.error,e[10]=S,e[11]=b.error,e[12]=N):N=e[12];const T=N;let L;e[13]!==f?(L=()=>f.poll(),e[13]=f,e[14]=L):L=e[14],re(L,!0);let $;e[15]!==b?($=()=>b.poll(),e[15]=b,e[16]=$):$=e[16],re($,!0);let A,C,k,x,I,D,E,_;if(e[17]!==m||e[18]!==w||e[19]!==T||e[20]!==p||e[21]!==d||e[22]!==c||e[23]!==r){const J=(Array.isArray(w?.series)?w.series:[]).filter(tt).toSorted(st);A="flex flex-col gap-3",C="lunora-scheduler-pools",e[32]!==m?(k=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:m}),e[32]=m,e[33]=k):k=e[33],e[34]!==c||e[35]!==r?(x=c!==void 0&&R("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(fe,{label:r("backlog"),testId:"pools-backlog",value:c.backlog}),s(fe,{label:r("in flight"),testId:"pools-inflight",value:c.inFlight}),s(fe,{label:r("pools"),testId:"pools-count",value:c.pools.length})]}),e[34]=c,e[35]=r,e[36]=x):x=e[36],e[37]!==c?.pools.length||e[38]!==r?(I=c?.pools.length===0&&s(oe,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[37]=c?.pools.length,e[38]=r,e[39]=I):I=e[39];let U;e[40]!==p||e[41]!==d?(U=s(be,{onChange:p,testId:"lag-shard-input",value:d}),e[40]=p,e[41]=d,e[42]=U):U=e[42];let P;e[43]!==r?(P=r("Start lag per job on this shard since it last woke; the series reset when the shard hibernates."),e[43]=r,e[44]=P):P=e[44];let M;e[45]!==P?(M=s("p",{className:"text-xs text-muted-foreground","data-testid":"lag-scope",children:P}),e[45]=P,e[46]=M):M=e[46],e[47]!==U||e[48]!==M?(D=R("div",{className:"flex flex-wrap items-center gap-3",children:[U,M]}),e[47]=U,e[48]=M,e[49]=D):D=e[49],e[50]!==T?(E=T!==null&&s("p",{className:"text-sm text-destructive","data-testid":"lag-error",role:"alert",children:T}),e[50]=T,e[51]=E):E=e[51],_=T===null&&J.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"lag-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("function")}),s(O,{children:r("runs")}),s(O,{children:r("mean lag (ms)")}),s(O,{children:r("max lag (ms)")}),s(O,{children:r("last lag (ms)")})]})}),s(se,{children:J.map(lt)})]})})}),e[17]=m,e[18]=w,e[19]=T,e[20]=p,e[21]=d,e[22]=c,e[23]=r,e[24]=A,e[25]=C,e[26]=k,e[27]=x,e[28]=I,e[29]=D,e[30]=E,e[31]=_}else A=e[24],C=e[25],k=e[26],x=e[27],I=e[28],D=e[29],E=e[30],_=e[31];let F;e[52]!==c||e[53]!==r?(F=c!==void 0&&c.pools.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"pools-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("pool")}),s(O,{children:r("queued")}),s(O,{children:r("in flight")}),s(O,{children:r("max concurrency")})]})}),s(se,{children:c.pools.map(rt)})]})})}),e[52]=c,e[53]=r,e[54]=F):F=e[54];let B;return e[55]!==A||e[56]!==C||e[57]!==k||e[58]!==x||e[59]!==I||e[60]!==D||e[61]!==E||e[62]!==_||e[63]!==F?(B=R("div",{className:A,"data-testid":C,children:[k,x,I,D,E,_,F]}),e[55]=A,e[56]=C,e[57]=k,e[58]=x,e[59]=I,e[60]=D,e[61]=E,e[62]=_,e[63]=F,e[64]=B):B=e[64],B};function et(t,e){return e.queued-t.queued}function tt(t){return t.name===Xe&&t.kind==="histogram"&&t.count>0}function st(t,e){return e.max-t.max}function lt(t){return R(Q,{"data-testid":`lag-row-${he(t)}`,children:[s(K,{className:"font-mono text-xs",children:he(t)}),s(K,{className:"tabular-nums",children:t.count}),s(K,{className:"tabular-nums",children:Math.round(t.sum/t.count)}),s(K,{className:"tabular-nums",children:t.max}),s(K,{className:"tabular-nums",children:t.last})]},he(t))}function rt(t){return R(Q,{"data-testid":`pools-row-${t.name}`,children:[s(K,{className:"font-mono text-xs",children:t.name}),s(K,{className:"tabular-nums",children:t.queued}),R(K,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(K,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const it=["jobs","outbox","history","dead","pools","cron"],It=t=>{const e=V(55);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadCronJobs:l,scheduledCancel:a,scheduledLoad:r}=i,o=z(),[u,v]=G("jobs");let f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let c;e[4]!==o?(c=o("Dead letter"),e[4]=o,e[5]=c):c=e[5];let m;e[6]!==o?(m=o("History"),e[6]=o,e[7]=m):m=e[7];let y;e[8]!==o?(y=o("Scheduled jobs"),e[8]=o,e[9]=y):y=e[9];let p;e[10]!==o?(p=o("Outbox"),e[10]=o,e[11]=p):p=e[11];let d;e[12]!==o?(d=o("Pools"),e[12]=o,e[13]=d):d=e[13];let h;e[14]!==f||e[15]!==c||e[16]!==m||e[17]!==y||e[18]!==p||e[19]!==d?(h={cron:f,dead:c,history:m,jobs:y,outbox:p,pools:d},e[14]=f,e[15]=c,e[16]=m,e[17]=y,e[18]=p,e[19]=d,e[20]=h):h=e[20];const g=h;let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{v(E.currentTarget.dataset.view)},e[21]=b):b=e[21];const w=b;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=s(we,{}),e[22]=S):S=e[22];let N;e[23]!==o?(N=o("Schedule view"),e[23]=o,e[24]=N):N=e[24];let T;e[25]!==u||e[26]!==g?(T=it.map(E=>s(le,{"aria-selected":u===E,"data-testid":`schedule-view-${E}`,"data-view":E,onClick:w,role:"tab",size:"sm",type:"button",variant:u===E?"default":"outline",children:g[E]},E)),e[25]=u,e[26]=g,e[27]=T):T=e[27];let L;e[28]!==N||e[29]!==T?(L=s("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:T}),e[28]=N,e[29]=T,e[30]=L):L=e[30];let $;e[31]!==a||e[32]!==r||e[33]!==u?($=u==="jobs"&&s($e,{cancelJob:a,loadJobs:r}),e[31]=a,e[32]=r,e[33]=u,e[34]=$):$=e[34];let A;e[35]!==u?(A=u==="outbox"&&s(je,{}),e[35]=u,e[36]=A):A=e[36];let C;e[37]!==u?(C=u==="history"&&s(Be,{}),e[37]=u,e[38]=C):C=e[38];let k;e[39]!==u?(k=u==="dead"&&s(Pe,{}),e[39]=u,e[40]=k):k=e[40];let x;e[41]!==n||e[42]!==u?(x=u==="pools"&&s(Ze,{initialShardKey:n}),e[41]=n,e[42]=u,e[43]=x):x=e[43];let I;e[44]!==l||e[45]!==u?(I=u==="cron"&&s(Je,{loadCronJobs:l}),e[44]=l,e[45]=u,e[46]=I):I=e[46];let D;return e[47]!==L||e[48]!==$||e[49]!==A||e[50]!==C||e[51]!==k||e[52]!==x||e[53]!==I?(D=R("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,L,$,A,C,k,x,I]}),e[47]=L,e[48]=$,e[49]=A,e[50]=C,e[51]=k,e[52]=x,e[53]=I,e[54]=D):D=e[54],D};export{It as SchedulePanel};
1
+ import{c as V}from"react/compiler-runtime";import{useState as G}from"react";import{D as we}from"../packem_shared/studio-DtxNxSjs.mjs";import{B as le}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as me}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Y}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as j,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as oe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as ee,c as O,a as te,b as Q,d as se,e as K}from"../packem_shared/table-D0SBiDu-.mjs";import{a as ne,u as xe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as re}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{h as ie,f as Z,j as ge,b as de,c as ve,d as ke}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as s,jsxs as R}from"react/jsx-runtime";import{I as Se}from"../packem_shared/input-CXhxesPC.mjs";import{u as Ce}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{c as Te}from"../packem_shared/utils-bhneXptQ.mjs";import{useLunora as Ae}from"@lunora/react";import{ShardInput as be}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{u as ye}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{ADMIN_FUNCTIONS as ce}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{ScheduledJobs as $e}from"../packem_shared/ScheduledJobs-Du8ZGL7v.mjs";const Ne={failed:"destructive",skipped:"warning",succeeded:"success"},Ie=25,Ee=t=>t<1e3?`${String(t)} ms`:`${(t/1e3).toFixed(1)} s`,Re=t=>{const e=V(39),{inFlight:i,last:n}=t,l=z();if(i!==void 0){let h;e[0]!==l?(h=l("running"),e[0]=l,e[1]=h):h=e[1];let g;e[2]!==h?(g=s(Y,{variant:"info",children:h}),e[2]=h,e[3]=g):g=e[3];let b;e[4]!==i.startedAt?(b=ie(i.startedAt,"—"),e[4]=i.startedAt,e[5]=b):b=e[5];let w;e[6]!==b?(w=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:b}),e[6]=b,e[7]=w):w=e[7];let S;e[8]!==i.skipped||e[9]!==l?(S=i.skipped>0&&s("span",{className:"text-xs text-muted-foreground",children:l("{count} ticks skipped",{count:i.skipped})}),e[8]=i.skipped,e[9]=l,e[10]=S):S=e[10];let N;return e[11]!==g||e[12]!==w||e[13]!==S?(N=R("span",{className:"flex items-center gap-2",children:[g,w,S]}),e[11]=g,e[12]=w,e[13]=S,e[14]=N):N=e[14],N}if(n===void 0){let h;e[15]!==l?(h=l("never"),e[15]=l,e[16]=h):h=e[16];let g;return e[17]!==h?(g=s("span",{className:"text-xs text-muted-foreground",children:h}),e[17]=h,e[18]=g):g=e[18],g}let a;e[19]!==l?(a=l("failed"),e[19]=l,e[20]=a):a=e[20];let r;e[21]!==l?(r=l("skipped"),e[21]=l,e[22]=r):r=e[22];let o;e[23]!==l?(o=l("succeeded"),e[23]=l,e[24]=o):o=e[24];let u;e[25]!==a||e[26]!==r||e[27]!==o?(u={failed:a,skipped:r,succeeded:o},e[25]=a,e[26]=r,e[27]=o,e[28]=u):u=e[28];const v=u,f=Ne[n.status],c=v[n.status];let m;e[29]!==f||e[30]!==c?(m=s(Y,{variant:f,children:c}),e[29]=f,e[30]=c,e[31]=m):m=e[31];let y;e[32]!==n.startedAt?(y=ie(n.startedAt,"—"),e[32]=n.startedAt,e[33]=y):y=e[33];let p;e[34]!==y?(p=s("span",{className:"text-xs text-muted-foreground tabular-nums",children:y}),e[34]=y,e[35]=p):p=e[35];let d;return e[36]!==m||e[37]!==p?(d=R("span",{className:"flex items-center gap-2",children:[m,p]}),e[36]=m,e[37]=p,e[38]=d):d=e[38],d},Le=t=>{const e=V(80),{runs:i}=t,n=z();if(i.length===0)return;let l,a,r,o,u,v,f,c,m,y,p;if(e[0]!==i||e[1]!==n){const S=i.toSorted(Oe).slice(0,Ie);let N;e[13]!==n?(N=n("failed"),e[13]=n,e[14]=N):N=e[14];let T;e[15]!==n?(T=n("skipped"),e[15]=n,e[16]=T):T=e[16];let L;e[17]!==n?(L=n("succeeded"),e[17]=n,e[18]=L):L=e[18];let $;e[19]!==L||e[20]!==N||e[21]!==T?($={failed:N,skipped:T,succeeded:L},e[19]=L,e[20]=N,e[21]=T,e[22]=$):$=e[22];const A=$;m="flex flex-col gap-2",y="cron-run-history";let C;e[23]!==n?(C=n("Recent runs"),e[23]=n,e[24]=C):C=e[24],e[25]!==C?(p=s("h3",{className:"text-sm font-medium",children:C}),e[25]=C,e[26]=p):p=e[26],o=j,c="overflow-hidden py-0",r=X,f="px-0",a=ee;let k;e[27]!==n?(k=n("name"),e[27]=n,e[28]=k):k=e[28];let x;e[29]!==k?(x=s(O,{children:k}),e[29]=k,e[30]=x):x=e[30];let I;e[31]!==n?(I=n("status"),e[31]=n,e[32]=I):I=e[32];let D;e[33]!==I?(D=s(O,{children:I}),e[33]=I,e[34]=D):D=e[34];let E;e[35]!==n?(E=n("started"),e[35]=n,e[36]=E):E=e[36];let _;e[37]!==E?(_=s(O,{children:E}),e[37]=E,e[38]=_):_=e[38];let F;e[39]!==n?(F=n("duration"),e[39]=n,e[40]=F):F=e[40];let B;e[41]!==F?(B=s(O,{children:F}),e[41]=F,e[42]=B):B=e[42];let J;e[43]!==n?(J=n("skipped"),e[43]=n,e[44]=J):J=e[44];let U;e[45]!==J?(U=s(O,{children:J}),e[45]=J,e[46]=U):U=e[46];let P;e[47]!==n?(P=n("error"),e[47]=n,e[48]=P):P=e[48];let M;e[49]!==P?(M=s(O,{children:P}),e[49]=P,e[50]=M):M=e[50],e[51]!==x||e[52]!==D||e[53]!==_||e[54]!==B||e[55]!==U||e[56]!==M?(v=s(te,{children:R(Q,{children:[x,D,_,B,U,M]})}),e[51]=x,e[52]=D,e[53]=_,e[54]=B,e[55]=U,e[56]=M,e[57]=v):v=e[57],l=se;let W;e[58]!==A?(W=H=>R(Q,{"data-testid":`cron-run-row-${H.runId}`,children:[s(K,{children:H.name}),s(K,{children:s(Y,{variant:Ne[H.status],children:A[H.status]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(H.startedAt,"—")}),s(K,{className:"tabular-nums",children:H.status==="skipped"?"":Ee(H.durationMs)}),s(K,{className:"tabular-nums",children:H.skipped>0?H.skipped:""}),s(K,{className:"text-xs text-destructive",children:H.error??""})]},H.runId),e[58]=A,e[59]=W):W=e[59],u=S.map(W),e[0]=i,e[1]=n,e[2]=l,e[3]=a,e[4]=r,e[5]=o,e[6]=u,e[7]=v,e[8]=f,e[9]=c,e[10]=m,e[11]=y,e[12]=p}else l=e[2],a=e[3],r=e[4],o=e[5],u=e[6],v=e[7],f=e[8],c=e[9],m=e[10],y=e[11],p=e[12];let d;e[60]!==l||e[61]!==u?(d=s(l,{children:u}),e[60]=l,e[61]=u,e[62]=d):d=e[62];let h;e[63]!==a||e[64]!==v||e[65]!==d?(h=R(a,{children:[v,d]}),e[63]=a,e[64]=v,e[65]=d,e[66]=h):h=e[66];let g;e[67]!==r||e[68]!==f||e[69]!==h?(g=s(r,{className:f,children:h}),e[67]=r,e[68]=f,e[69]=h,e[70]=g):g=e[70];let b;e[71]!==o||e[72]!==g||e[73]!==c?(b=s(o,{className:c,children:g}),e[71]=o,e[72]=g,e[73]=c,e[74]=b):b=e[74];let w;return e[75]!==b||e[76]!==m||e[77]!==y||e[78]!==p?(w=R("div",{className:m,"data-testid":y,children:[p,b]}),e[75]=b,e[76]=m,e[77]=y,e[78]=p,e[79]=w):w=e[79],w};function Oe(t,e){return e.startedAt-t.startedAt}const Ke=()=>{const t=V(50),e=z(),i=Ce(""),[n,l]=G(""),[a,r]=G(void 0),[o,u]=G(!1);if(i.unavailable)return null;let v;t[0]!==i?(v=i.pending("cron"),t[0]=i,t[1]=v):v=t[1];const f=v;let c;t[2]!==i?(c=i.reason("cron"),t[2]=i,t[3]=c):c=t[3];const m=c;let y;t[4]!==n||t[5]!==i?(y=()=>{const E=n.trim();if(E==="")return;Z((async()=>{const F=await i.suggestCron(E);u(!1),r(F)})())},t[4]=n,t[5]=i,t[6]=y):y=t[6];const p=y;let d;t[7]!==a?(d=()=>{const E="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if(E===void 0||a===void 0)return;Z((async()=>{try{await E.writeText(a),u(!0)}catch{u(!1)}})())},t[7]=a,t[8]=d):d=t[8];const h=d;let g;t[9]!==e?(g=e("Describe a schedule"),t[9]=e,t[10]=g):g=t[10];let b;t[11]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{l(E.target.value)},t[11]=b):b=t[11];let w;t[12]!==p?(w=E=>{E.key==="Enter"&&(E.preventDefault(),p())},t[12]=p,t[13]=w):w=t[13];let S;t[14]!==e?(S=e("Describe a schedule"),t[14]=e,t[15]=S):S=t[15];let N;t[16]!==f||t[17]!==n||t[18]!==g||t[19]!==w||t[20]!==S?(N=s(Se,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"cron-assistant-prompt",disabled:f,onChange:b,onKeyDown:w,placeholder:S,value:n}),t[16]=f,t[17]=n,t[18]=g,t[19]=w,t[20]=S,t[21]=N):N=t[21];const T=f&&"opacity-60";let L;t[22]!==T?(L=Te("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",T),t[22]=T,t[23]=L):L=t[23];let $;t[24]!==f||t[25]!==n?($=f||n.trim()==="",t[24]=f,t[25]=n,t[26]=$):$=t[26];let A;t[27]!==f||t[28]!==e?(A=e(f?"Thinking…":"Suggest schedule"),t[27]=f,t[28]=e,t[29]=A):A=t[29];let C;t[30]!==p||t[31]!==L||t[32]!==$||t[33]!==A?(C=s("button",{className:L,"data-testid":"cron-assistant-generate",disabled:$,onClick:p,type:"button",children:A}),t[30]=p,t[31]=L,t[32]=$,t[33]=A,t[34]=C):C=t[34];let k;t[35]!==C||t[36]!==N?(k=R("div",{className:"flex items-center gap-2",children:[N,C]}),t[35]=C,t[36]=N,t[37]=k):k=t[37];let x;t[38]!==o||t[39]!==h||t[40]!==a||t[41]!==e?(x=a!==void 0&&R("div",{className:"flex items-center gap-2",children:[s("code",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums","data-testid":"cron-assistant-result",children:a}),s("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cron-assistant-copy",onClick:h,type:"button",children:e(o?"Copied":"Copy")}),s("span",{className:"text-[11px] text-muted-foreground",children:e("Add it to lunora/crons.ts — triggers are compiled into the worker.")})]}),t[38]=o,t[39]=h,t[40]=a,t[41]=e,t[42]=x):x=t[42];let I;t[43]!==m||t[44]!==e?(I=m!==void 0&&s("p",{className:"text-[11px] text-muted-foreground","data-testid":"cron-assistant-reason",role:"status",children:e(m==="ai-error"?"The model could not be reached.":"The model did not return a schedule Cron Triggers accept.")}),t[43]=m,t[44]=e,t[45]=I):I=t[45];let D;return t[46]!==k||t[47]!==x||t[48]!==I?(D=R("div",{className:"flex flex-col gap-1.5","data-testid":"cron-assistant",children:[k,x,I]}),t[46]=k,t[47]=x,t[48]=I,t[49]=D):D=t[49],D},De={kind:"idle"},_e="SCHEDULER_NOT_CONFIGURED",ue={inFlight:[],runs:[]},Fe=(t,e,i)=>i!==void 0?i:e===void 0?n=>t.runCronJob(n):void 0,Je=({loadCronJobs:t,loadCronRuns:e,runCronJob:i}={})=>{const n=ae(),l=z(),[a,r]=G({}),o=ne(["lunora-cron-jobs",t?"custom":"default"],()=>(t??(()=>n.getCronJobs()))()),{data:u,error:v}=o,f=e??(t===void 0?()=>n.listCronRuns():void 0),c=ne(["lunora-cron-runs",e?"custom":"default"],async()=>f===void 0?ue:f().catch(d=>{if(ge(d)===_e)return ue;throw d})),m=c.data??ue;re(()=>c.poll(),f!==void 0);const y=Fe(n,t,i),p=async d=>{if(y!==void 0){r(h=>({...h,[d]:{kind:"running"}}));try{await y(d),r(h=>({...h,[d]:{kind:"ok"}})),o.refetch(),c.refetch()}catch(h){r(g=>({...g,[d]:{kind:"error",message:de(h)}}))}}};return R("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[s(Ke,{}),v!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:v}),c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"cron-runs-error",role:"alert",children:c.error}),u?.length===0&&s(oe,{description:l("Triggers declared with the cronJobs() builder appear here."),icon:R("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[s("circle",{cx:"12",cy:"12",r:"9"}),s("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:l("No cron triggers.")}),u!==void 0&&u.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"cron-table",children:[s(te,{children:R(Q,{children:[s(O,{children:l("name")}),s(O,{children:l("schedule")}),s(O,{children:l("target")}),s(O,{children:l("shard")}),s(O,{children:l("last run")}),y!==void 0&&s(O,{"aria-label":l("Actions")})]})}),s(se,{children:u.map(d=>{const h=a[d.name]??De;return R(Q,{"data-testid":`cron-row-${d.name}`,children:[s(K,{children:d.name}),s(K,{className:"font-mono text-xs tabular-nums",children:d.cron}),s(K,{children:R("span",{className:"flex items-center gap-2",children:[d.workflow===void 0?s(Y,{variant:"outline",children:l("function")}):s(Y,{variant:"secondary",children:l("workflow")}),s("span",{className:"font-mono text-xs",children:d.workflow??d.functionPath})]})}),s(K,{children:d.shardKey??""}),s(K,{"data-testid":`cron-last-run-${d.name}`,children:s(Re,{inFlight:m.inFlight.find(g=>g.name===d.name),last:m.runs.find(g=>g.name===d.name)})}),y!==void 0&&s(K,{className:"text-right",children:R("span",{className:"flex items-center justify-end gap-2",children:[h.kind==="ok"&&s("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${d.name}`,children:l("ran")}),h.kind==="error"&&s("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${d.name}`,role:"alert",children:h.message}),s(me,{confirmLabel:l("Run now?"),disabled:h.kind==="running",onConfirm:()=>{Z(p(d.name))},testId:`cron-run-${d.name}`,children:h.kind==="running"?l("Running…"):l("Run now")})]})})]},`${d.cron}:${d.name}`)})})]})})}),s(Le,{runs:m.runs})]})},Me=t=>Number.isFinite(t)?ie(t,"—"):"—",Pe=t=>{const e=V(34);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n,removeJob:l,retryJob:a}=i,r=ae(),o=z();let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-dead-jobs"],e[2]=u):u=e[2];let v;e[3]!==r||e[4]!==n?(v=async()=>(await(n??(()=>r.listDeadJobs()))()).toSorted(qe),e[3]=r,e[4]=n,e[5]=v):v=e[5];const f=ne(u,v),c=f.data,[m,y]=G(void 0),p=f.error??m,d=n===void 0;let h;e[6]!==r||e[7]!==d||e[8]!==a?(h=a??(d?x=>r.retryDeadJob(x):void 0),e[6]=r,e[7]=d,e[8]=a,e[9]=h):h=e[9];const g=h;let b;e[10]!==r||e[11]!==d||e[12]!==l?(b=l??(d?x=>r.removeDeadJob(x):void 0),e[10]=r,e[11]=d,e[12]=l,e[13]=b):b=e[13];const w=b;let S;e[14]!==f?(S=()=>f.poll(),e[14]=f,e[15]=S):S=e[15],re(S,!0);let N;e[16]!==f?(N=async x=>{y(void 0);try{await x,f.refetch()}catch(I){y(de(I))}},e[16]=f,e[17]=N):N=e[17];const T=N,L=g!==void 0||w!==void 0;let $;e[18]!==p?($=p!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:p}),e[18]=p,e[19]=$):$=e[19];let A;e[20]!==c?.length||e[21]!==o?(A=c?.length===0&&s(oe,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=c?.length,e[21]=o,e[22]=A):A=e[22];let C;e[23]!==T||e[24]!==L||e[25]!==c||e[26]!==w||e[27]!==g||e[28]!==o?(C=c!==void 0&&c.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"dlq-table",children:[s(te,{children:R(Q,{children:[s(O,{children:o("function")}),s(O,{children:o("attempts")}),s(O,{children:o("last tried")}),s(O,{children:o("pool")}),s(O,{children:o("shard")}),s(O,{children:o("id")}),L&&s(O,{"aria-label":o("Actions")})]})}),s(se,{children:c.map(x=>R(Q,{"data-testid":`dlq-row-${x.id}`,children:[s(K,{className:"font-mono text-xs",children:x.workflow??x.functionPath}),s(K,{className:"tabular-nums",children:x.attempts??0}),s(K,{className:"text-muted-foreground tabular-nums",children:Me(x.scheduledFor)}),s(K,{className:"font-mono text-xs",children:x.pool??""}),s(K,{children:x.shardKey??""}),s(K,{className:"font-mono text-xs",children:x.id}),L&&s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[g!==void 0&&s(le,{"data-testid":`dlq-retry-${x.id}`,onClick:()=>{Z(T(g(x.id)))},size:"sm",type:"button",variant:"outline",children:o("Retry")}),w!==void 0&&s(me,{confirmLabel:o("Drop job?"),onConfirm:()=>{Z(T(w(x.id)))},testId:`dlq-remove-${x.id}`,children:o("Drop")})]})})]},x.id))})]})})}),e[23]=T,e[24]=L,e[25]=c,e[26]=w,e[27]=g,e[28]=o,e[29]=C):C=e[29];let k;return e[30]!==C||e[31]!==$||e[32]!==A?(k=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,A,C]}),e[30]=C,e[31]=$,e[32]=A,e[33]=k):k=e[33],k};function qe(t,e){return(e.attempts??0)-(t.attempts??0)}const Ue={canceled:"secondary",failed:"destructive",pending:"outline",running:"info",succeeded:"success"},Be=t=>{const e=V(47);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{loadJobs:n}=i,l=ae(),a=z();let r;e[2]!==l||e[3]!==n?(r=n??(async q=>l.listScheduledHistory(q===void 0?{}:{cursor:q})),e[2]=l,e[3]=n,e[4]=r):r=e[4];const o=r,u=n?"custom":"default";let v;e[5]!==u?(v=["lunora-job-history",u],e[5]=u,e[6]=v):v=e[6];let f;e[7]!==o?(f=async()=>o(),e[7]=o,e[8]=f):f=e[8];const c=ne(v,f),[m,y]=G(void 0),[p,d]=G(!1),[h,g]=G(void 0),b=c.data?.records;let w;e[9]!==b?(w=new Set(b?.map(He)),e[9]=b,e[10]=w):w=e[10];const S=w,N=b===void 0?void 0:[...b,...(m?.records??[]).filter(q=>!S.has(q.id))],T=m===void 0?c.data?.cursor:m.cursor;let L;e[11]!==o||e[12]!==T?(L=async()=>{d(!0),g(void 0);try{const q=await o(T);y(pe=>({cursor:q.cursor,records:[...pe?.records??[],...q.records]})),d(!1)}catch(q){g(de(q)),d(!1)}},e[11]=o,e[12]=T,e[13]=L):L=e[13];const $=L;let A;e[14]!==a?(A=a("canceled"),e[14]=a,e[15]=A):A=e[15];let C;e[16]!==a?(C=a("failed"),e[16]=a,e[17]=C):C=e[17];let k;e[18]!==a?(k=a("pending"),e[18]=a,e[19]=k):k=e[19];let x;e[20]!==a?(x=a("running"),e[20]=a,e[21]=x):x=e[21];let I;e[22]!==a?(I=a("succeeded"),e[22]=a,e[23]=I):I=e[23];let D;e[24]!==k||e[25]!==x||e[26]!==I||e[27]!==A||e[28]!==C?(D={canceled:A,failed:C,pending:k,running:x,succeeded:I},e[24]=k,e[25]=x,e[26]=I,e[27]=A,e[28]=C,e[29]=D):D=e[29];const E=D;let _;e[30]!==c?(_=()=>c.poll(),e[30]=c,e[31]=_):_=e[31],re(_,m===void 0);const F="flex flex-col gap-3",B="lunora-job-history";let J;e[32]!==c.error?(J=c.error!==null&&s("p",{className:"text-sm text-destructive","data-testid":"job-history-error",role:"alert",children:c.error}),e[32]=c.error,e[33]=J):J=e[33];const U=N?.length===0&&s(oe,{description:a("Jobs that succeed, fail or are cancelled stay here for seven days."),testId:"job-history-empty",title:a("No finished jobs.")}),P=N!==void 0&&N.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"job-history-table",children:[s(te,{children:R(Q,{children:[s(O,{children:a("function")}),s(O,{children:a("state")}),s(O,{children:a("finished")}),s(O,{children:a("error")}),s(O,{children:a("id")})]})}),s(se,{children:N.map(q=>R(Q,{"data-testid":`job-history-row-${q.id}`,children:[s(K,{className:"font-mono text-xs",children:q.workflow??q.functionPath}),s(K,{children:s(Y,{"data-testid":`job-history-state-${q.id}`,variant:Ue[q.state],children:E[q.state]})}),s(K,{className:"text-muted-foreground tabular-nums",children:ie(q.completedAt,"—")}),s(K,{className:"text-xs text-destructive",children:q.error??""}),s(K,{className:"font-mono text-xs",children:q.id})]},q.id))})]})})});let M;e[34]!==h?(M=h!==void 0&&s("p",{className:"text-sm text-destructive",role:"alert",children:h}),e[34]=h,e[35]=M):M=e[35];let W;e[36]!==p||e[37]!==T||e[38]!==$||e[39]!==a?(W=T!==void 0&&s("div",{children:s(le,{"data-testid":"job-history-load-more",disabled:p,onClick:()=>{Z($())},variant:"outline",children:a(p?"Loading…":"Load more")})}),e[36]=p,e[37]=T,e[38]=$,e[39]=a,e[40]=W):W=e[40];let H;return e[41]!==J||e[42]!==U||e[43]!==P||e[44]!==M||e[45]!==W?(H=R("div",{className:F,"data-testid":B,children:[J,U,P,M,W]}),e[41]=J,e[42]=U,e[43]=P,e[44]=M,e[45]=W,e[46]=H):H=e[46],H};function He(t){return t.id}const Qe=ve(ce.dropOutboxEntry),Ve=ve(ce.retryOutboxEntry),ze=()=>{const t=V(8),e=z();let i;t[0]!==e?(i=e("Jobs whose mutation committed but that the scheduler has not accepted yet wait here."),t[0]=e,t[1]=i):i=t[1];let n;t[2]===Symbol.for("react.memo_cache_sentinel")?(n=s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 4h16v12H4zM4 16l4 4h8l4-4"})}),t[2]=n):n=t[2];let l;t[3]!==e?(l=e("Nothing is waiting for the scheduler."),t[3]=e,t[4]=l):l=t[4];let a;return t[5]!==i||t[6]!==l?(a=s(oe,{description:i,icon:n,testId:"outbox-empty",title:l}),t[5]=i,t[6]=l,t[7]=a):a=t[7],a},We=t=>{const e=V(58),{entry:i,onAct:n}=t,l=z(),a=`outbox-row-${i.id}`;let r;e[0]!==i.target||e[1]!==l?(r=i.target??l("unreadable"),e[0]=i.target,e[1]=l,e[2]=r):r=e[2];let o;e[3]!==r?(o=s(K,{className:"font-mono text-xs",children:r}),e[3]=r,e[4]=o):o=e[4];const u=i.parked?"destructive":"secondary";let v;e[5]!==i.parked||e[6]!==l?(v=i.parked?l("parked"):l("retrying"),e[5]=i.parked,e[6]=l,e[7]=v):v=e[7];let f;e[8]!==u||e[9]!==v?(f=s(Y,{variant:u,children:v}),e[8]=u,e[9]=v,e[10]=f):f=e[10];let c;e[11]!==i.forever||e[12]!==l?(c=i.forever&&s(Y,{variant:"outline",children:l("forever")}),e[11]=i.forever,e[12]=l,e[13]=c):c=e[13];let m;e[14]!==f||e[15]!==c?(m=s(K,{children:R("div",{className:"flex gap-1",children:[f,c]})}),e[14]=f,e[15]=c,e[16]=m):m=e[16];let y;e[17]!==i.attempts?(y=s(K,{className:"tabular-nums",children:i.attempts}),e[17]=i.attempts,e[18]=y):y=e[18];let p;e[19]!==i.nextAttemptAt||e[20]!==i.parked?(p=i.parked?"—":ie(i.nextAttemptAt,"—"),e[19]=i.nextAttemptAt,e[20]=i.parked,e[21]=p):p=e[21];let d;e[22]!==p?(d=s(K,{className:"text-muted-foreground tabular-nums",children:p}),e[22]=p,e[23]=d):d=e[23];let h;e[24]!==i.id?(h=s(K,{className:"font-mono text-xs",children:i.id}),e[24]=i.id,e[25]=h):h=e[25];const g=`outbox-retry-${i.id}`;let b;e[26]!==i.id||e[27]!==n?(b=()=>{Z(n(Ve,i.id))},e[26]=i.id,e[27]=n,e[28]=b):b=e[28];let w;e[29]!==l?(w=l("Retry now"),e[29]=l,e[30]=w):w=e[30];let S;e[31]!==g||e[32]!==b||e[33]!==w?(S=s(le,{"data-testid":g,onClick:b,size:"sm",type:"button",variant:"outline",children:w}),e[31]=g,e[32]=b,e[33]=w,e[34]=S):S=e[34];let N;e[35]!==l?(N=l("Drop job?"),e[35]=l,e[36]=N):N=e[36];let T;e[37]!==i.id||e[38]!==n?(T=()=>{Z(n(Qe,i.id))},e[37]=i.id,e[38]=n,e[39]=T):T=e[39];const L=`outbox-drop-${i.id}`;let $;e[40]!==l?($=l("Drop"),e[40]=l,e[41]=$):$=e[41];let A;e[42]!==N||e[43]!==T||e[44]!==L||e[45]!==$?(A=s(me,{confirmLabel:N,onConfirm:T,testId:L,children:$}),e[42]=N,e[43]=T,e[44]=L,e[45]=$,e[46]=A):A=e[46];let C;e[47]!==S||e[48]!==A?(C=s(K,{className:"text-right",children:R("div",{className:"flex justify-end gap-1.5",children:[S,A]})}),e[47]=S,e[48]=A,e[49]=C):C=e[49];let k;return e[50]!==a||e[51]!==d||e[52]!==h||e[53]!==C||e[54]!==o||e[55]!==m||e[56]!==y?(k=R(Q,{"data-testid":a,children:[o,m,y,d,h,C]}),e[50]=a,e[51]=d,e[52]=h,e[53]=C,e[54]=o,e[55]=m,e[56]=y,e[57]=k):k=e[57],k},Ge=t=>{const e=V(41),{entries:i,onAct:n}=t,l=z();let a;e[0]!==l?(a=l("function"),e[0]=l,e[1]=a):a=e[1];let r;e[2]!==a?(r=s(O,{children:a}),e[2]=a,e[3]=r):r=e[3];let o;e[4]!==l?(o=l("state"),e[4]=l,e[5]=o):o=e[5];let u;e[6]!==o?(u=s(O,{children:o}),e[6]=o,e[7]=u):u=e[7];let v;e[8]!==l?(v=l("attempts"),e[8]=l,e[9]=v):v=e[9];let f;e[10]!==v?(f=s(O,{children:v}),e[10]=v,e[11]=f):f=e[11];let c;e[12]!==l?(c=l("next attempt"),e[12]=l,e[13]=c):c=e[13];let m;e[14]!==c?(m=s(O,{children:c}),e[14]=c,e[15]=m):m=e[15];let y;e[16]!==l?(y=l("id"),e[16]=l,e[17]=y):y=e[17];let p;e[18]!==y?(p=s(O,{children:y}),e[18]=y,e[19]=p):p=e[19];let d;e[20]!==l?(d=l("Actions"),e[20]=l,e[21]=d):d=e[21];let h;e[22]!==d?(h=s(O,{"aria-label":d}),e[22]=d,e[23]=h):h=e[23];let g;e[24]!==p||e[25]!==h||e[26]!==r||e[27]!==u||e[28]!==f||e[29]!==m?(g=s(te,{children:R(Q,{children:[r,u,f,m,p,h]})}),e[24]=p,e[25]=h,e[26]=r,e[27]=u,e[28]=f,e[29]=m,e[30]=g):g=e[30];let b;if(e[31]!==i||e[32]!==n){let N;e[34]!==n?(N=T=>s(We,{entry:T,onAct:n},T.id),e[34]=n,e[35]=N):N=e[35],b=i.map(N),e[31]=i,e[32]=n,e[33]=b}else b=e[33];let w;e[36]!==b?(w=s(se,{children:b}),e[36]=b,e[37]=w):w=e[37];let S;return e[38]!==g||e[39]!==w?(S=s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"outbox-table",children:[g,w]})})}),e[38]=g,e[39]=w,e[40]=S):S=e[40],S},Ye=t=>{const e=V(11),{cursor:i,nextCursor:n,onFirst:l,onNext:a}=t,r=z();if(i===void 0&&n===void 0)return;let o;e[0]!==i||e[1]!==l||e[2]!==r?(o=i!==void 0&&s(le,{"data-testid":"outbox-first-page",onClick:l,size:"sm",type:"button",variant:"outline",children:r("First page")}),e[0]=i,e[1]=l,e[2]=r,e[3]=o):o=e[3];let u;e[4]!==n||e[5]!==a||e[6]!==r?(u=n!==void 0&&s(le,{"data-testid":"outbox-next-page",onClick:()=>{a(n)},size:"sm",type:"button",variant:"outline",children:r("Next page")}),e[4]=n,e[5]=a,e[6]=r,e[7]=u):u=e[7];let v;return e[8]!==o||e[9]!==u?(v=R("div",{className:"flex justify-end gap-1.5",children:[o,u]}),e[8]=o,e[9]=u,e[10]=v):v=e[10],v},je=t=>{const e=V(38);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n}=i,l=Ae(),a=z(),{queryShardKey:r,setShardKey:o,shardKey:u}=ye(n);let v;e[2]!==r?(v={cursor:void 0,shardKey:r},e[2]=r,e[3]=v):v=e[3];const[f,c]=G(v);f.shardKey!==r&&c({cursor:void 0,shardKey:r});const m=f.shardKey===r?f.cursor:void 0,y=u.trim()!==r;let p;e[4]!==m?(p=m===void 0?{}:{cursor:m},e[4]=m,e[5]=p):p=e[5];let d;e[6]!==r?(d={shardKey:r},e[6]=r,e[7]=d):d=e[7];const{data:h,error:g,poll:b,refetch:w}=xe(ce.getScheduleOutbox,p,d),S=y?void 0:h?.entries,N=y?void 0:h?.nextCursor,[T,L]=G(void 0),$=g??(T?.shardKey===r?T.message:void 0);re(b,!0);let A;e[8]!==l||e[9]!==r||e[10]!==w||e[11]!==a?(A=async(J,U)=>{L(void 0);try{(await l.query(J,{id:U},ke(r))).retried===!1&&L({message:a("That job is no longer in the outbox."),shardKey:r}),w()}catch(P){L({message:de(P),shardKey:r})}},e[8]=l,e[9]=r,e[10]=w,e[11]=a,e[12]=A):A=e[12];const C=A;let k;e[13]!==o||e[14]!==u?(k=s(be,{onChange:o,testId:"outbox-shard-input",value:u}),e[13]=o,e[14]=u,e[15]=k):k=e[15];let x;e[16]!==$?(x=$!==void 0&&s("p",{className:"text-sm text-destructive","data-testid":"outbox-error",role:"alert",children:$}),e[16]=$,e[17]=x):x=e[17];let I;e[18]!==m||e[19]!==S?.length?(I=S?.length===0&&m===void 0&&s(ze,{}),e[18]=m,e[19]=S?.length,e[20]=I):I=e[20];let D;e[21]!==C||e[22]!==S?(D=S!==void 0&&S.length>0&&s(Ge,{entries:S,onAct:C}),e[21]=C,e[22]=S,e[23]=D):D=e[23];let E,_;e[24]!==r?(E=()=>{c({cursor:void 0,shardKey:r})},_=J=>{c({cursor:J,shardKey:r})},e[24]=r,e[25]=E,e[26]=_):(E=e[25],_=e[26]);let F;e[27]!==m||e[28]!==N||e[29]!==E||e[30]!==_?(F=s(Ye,{cursor:m,nextCursor:N,onFirst:E,onNext:_}),e[27]=m,e[28]=N,e[29]=E,e[30]=_,e[31]=F):F=e[31];let B;return e[32]!==F||e[33]!==k||e[34]!==x||e[35]!==I||e[36]!==D?(B=R("div",{className:"flex flex-col gap-3","data-testid":"lunora-schedule-outbox",children:[k,x,I,D,F]}),e[32]=F,e[33]=k,e[34]=x,e[35]=I,e[36]=D,e[37]=B):B=e[37],B},Xe="scheduler.lag_ms",he=t=>{const e=t.attributes?.function;return typeof e=="string"?e:t.functionPath},fe=t=>{const e=V(8),{label:i,testId:n,value:l}=t;let a;e[0]!==i?(a=s("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=a):a=e[1];let r;e[2]!==n||e[3]!==l?(r=s("span",{className:"text-2xl font-semibold tabular-nums","data-testid":n,children:l}),e[2]=n,e[3]=l,e[4]=r):r=e[4];let o;return e[5]!==a||e[6]!==r?(o=s(j,{className:"flex-1 py-0",children:R(X,{className:"flex flex-col gap-1 p-4",children:[a,r]})}),e[5]=a,e[6]=r,e[7]=o):o=e[7],o},Ze=t=>{const e=V(65);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadStatus:l}=i,a=ae(),r=z(),o=l===void 0;let u;e[2]!==o?(u=["lunora-scheduler-status",o],e[2]=o,e[3]=u):u=e[3];let v;e[4]!==a||e[5]!==l?(v=async()=>{const J=await(l??(()=>a.schedulerStatus()))();return{...J,pools:J.pools.toSorted(et)}},e[4]=a,e[5]=l,e[6]=v):v=e[6];const f=ne(u,v),{data:c,error:m}=f,{queryShardKey:y,setShardKey:p,shardKey:d}=ye(n);let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h={},e[7]=h):h=e[7];let g;e[8]!==y?(g={shardKey:y},e[8]=y,e[9]=g):g=e[9];const b=xe(ce.getMetricSeries,h,g),{data:w,errorSource:S}=b;let N;e[10]!==S||e[11]!==b.error?(N=ge(S)==="FUNCTION_NOT_FOUND"?null:b.error,e[10]=S,e[11]=b.error,e[12]=N):N=e[12];const T=N;let L;e[13]!==f?(L=()=>f.poll(),e[13]=f,e[14]=L):L=e[14],re(L,!0);let $;e[15]!==b?($=()=>b.poll(),e[15]=b,e[16]=$):$=e[16],re($,!0);let A,C,k,x,I,D,E,_;if(e[17]!==m||e[18]!==w||e[19]!==T||e[20]!==p||e[21]!==d||e[22]!==c||e[23]!==r){const J=(Array.isArray(w?.series)?w.series:[]).filter(tt).toSorted(st);A="flex flex-col gap-3",C="lunora-scheduler-pools",e[32]!==m?(k=m!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:m}),e[32]=m,e[33]=k):k=e[33],e[34]!==c||e[35]!==r?(x=c!==void 0&&R("div",{className:"flex gap-3","data-testid":"pools-totals",children:[s(fe,{label:r("backlog"),testId:"pools-backlog",value:c.backlog}),s(fe,{label:r("in flight"),testId:"pools-inflight",value:c.inFlight}),s(fe,{label:r("pools"),testId:"pools-count",value:c.pools.length})]}),e[34]=c,e[35]=r,e[36]=x):x=e[36],e[37]!==c?.pools.length||e[38]!==r?(I=c?.pools.length===0&&s(oe,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[37]=c?.pools.length,e[38]=r,e[39]=I):I=e[39];let U;e[40]!==p||e[41]!==d?(U=s(be,{onChange:p,testId:"lag-shard-input",value:d}),e[40]=p,e[41]=d,e[42]=U):U=e[42];let P;e[43]!==r?(P=r("Start lag per job on this shard since it last woke; the series reset when the shard hibernates."),e[43]=r,e[44]=P):P=e[44];let M;e[45]!==P?(M=s("p",{className:"text-xs text-muted-foreground","data-testid":"lag-scope",children:P}),e[45]=P,e[46]=M):M=e[46],e[47]!==U||e[48]!==M?(D=R("div",{className:"flex flex-wrap items-center gap-3",children:[U,M]}),e[47]=U,e[48]=M,e[49]=D):D=e[49],e[50]!==T?(E=T!==null&&s("p",{className:"text-sm text-destructive","data-testid":"lag-error",role:"alert",children:T}),e[50]=T,e[51]=E):E=e[51],_=T===null&&J.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"lag-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("function")}),s(O,{children:r("runs")}),s(O,{children:r("mean lag (ms)")}),s(O,{children:r("max lag (ms)")}),s(O,{children:r("last lag (ms)")})]})}),s(se,{children:J.map(lt)})]})})}),e[17]=m,e[18]=w,e[19]=T,e[20]=p,e[21]=d,e[22]=c,e[23]=r,e[24]=A,e[25]=C,e[26]=k,e[27]=x,e[28]=I,e[29]=D,e[30]=E,e[31]=_}else A=e[24],C=e[25],k=e[26],x=e[27],I=e[28],D=e[29],E=e[30],_=e[31];let F;e[52]!==c||e[53]!==r?(F=c!==void 0&&c.pools.length>0&&s(j,{className:"overflow-hidden py-0",children:s(X,{className:"px-0",children:R(ee,{"data-testid":"pools-table",children:[s(te,{children:R(Q,{children:[s(O,{children:r("pool")}),s(O,{children:r("queued")}),s(O,{children:r("in flight")}),s(O,{children:r("max concurrency")})]})}),s(se,{children:c.pools.map(rt)})]})})}),e[52]=c,e[53]=r,e[54]=F):F=e[54];let B;return e[55]!==A||e[56]!==C||e[57]!==k||e[58]!==x||e[59]!==I||e[60]!==D||e[61]!==E||e[62]!==_||e[63]!==F?(B=R("div",{className:A,"data-testid":C,children:[k,x,I,D,E,_,F]}),e[55]=A,e[56]=C,e[57]=k,e[58]=x,e[59]=I,e[60]=D,e[61]=E,e[62]=_,e[63]=F,e[64]=B):B=e[64],B};function et(t,e){return e.queued-t.queued}function tt(t){return t.name===Xe&&t.kind==="histogram"&&t.count>0}function st(t,e){return e.max-t.max}function lt(t){return R(Q,{"data-testid":`lag-row-${he(t)}`,children:[s(K,{className:"font-mono text-xs",children:he(t)}),s(K,{className:"tabular-nums",children:t.count}),s(K,{className:"tabular-nums",children:Math.round(t.sum/t.count)}),s(K,{className:"tabular-nums",children:t.max}),s(K,{className:"tabular-nums",children:t.last})]},he(t))}function rt(t){return R(Q,{"data-testid":`pools-row-${t.name}`,children:[s(K,{className:"font-mono text-xs",children:t.name}),s(K,{className:"tabular-nums",children:t.queued}),R(K,{className:"tabular-nums",children:[t.inFlight," / ",t.maxConcurrency]}),s(K,{className:"tabular-nums",children:t.maxConcurrency})]},t.name)}const it=["jobs","outbox","history","dead","pools","cron"],It=t=>{const e=V(55);let i;e[0]!==t?(i=t===void 0?{}:t,e[0]=t,e[1]=i):i=e[1];const{initialShardKey:n,loadCronJobs:l,scheduledCancel:a,scheduledLoad:r}=i,o=z(),[u,v]=G("jobs");let f;e[2]!==o?(f=o("Cron triggers"),e[2]=o,e[3]=f):f=e[3];let c;e[4]!==o?(c=o("Dead letter"),e[4]=o,e[5]=c):c=e[5];let m;e[6]!==o?(m=o("History"),e[6]=o,e[7]=m):m=e[7];let y;e[8]!==o?(y=o("Scheduled jobs"),e[8]=o,e[9]=y):y=e[9];let p;e[10]!==o?(p=o("Outbox"),e[10]=o,e[11]=p):p=e[11];let d;e[12]!==o?(d=o("Pools"),e[12]=o,e[13]=d):d=e[13];let h;e[14]!==f||e[15]!==c||e[16]!==m||e[17]!==y||e[18]!==p||e[19]!==d?(h={cron:f,dead:c,history:m,jobs:y,outbox:p,pools:d},e[14]=f,e[15]=c,e[16]=m,e[17]=y,e[18]=p,e[19]=d,e[20]=h):h=e[20];const g=h;let b;e[21]===Symbol.for("react.memo_cache_sentinel")?(b=E=>{v(E.currentTarget.dataset.view)},e[21]=b):b=e[21];const w=b;let S;e[22]===Symbol.for("react.memo_cache_sentinel")?(S=s(we,{}),e[22]=S):S=e[22];let N;e[23]!==o?(N=o("Schedule view"),e[23]=o,e[24]=N):N=e[24];let T;e[25]!==u||e[26]!==g?(T=it.map(E=>s(le,{"aria-selected":u===E,"data-testid":`schedule-view-${E}`,"data-view":E,onClick:w,role:"tab",size:"sm",type:"button",variant:u===E?"default":"outline",children:g[E]},E)),e[25]=u,e[26]=g,e[27]=T):T=e[27];let L;e[28]!==N||e[29]!==T?(L=s("div",{"aria-label":N,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:T}),e[28]=N,e[29]=T,e[30]=L):L=e[30];let $;e[31]!==a||e[32]!==r||e[33]!==u?($=u==="jobs"&&s($e,{cancelJob:a,loadJobs:r}),e[31]=a,e[32]=r,e[33]=u,e[34]=$):$=e[34];let A;e[35]!==u?(A=u==="outbox"&&s(je,{}),e[35]=u,e[36]=A):A=e[36];let C;e[37]!==u?(C=u==="history"&&s(Be,{}),e[37]=u,e[38]=C):C=e[38];let k;e[39]!==u?(k=u==="dead"&&s(Pe,{}),e[39]=u,e[40]=k):k=e[40];let x;e[41]!==n||e[42]!==u?(x=u==="pools"&&s(Ze,{initialShardKey:n}),e[41]=n,e[42]=u,e[43]=x):x=e[43];let I;e[44]!==l||e[45]!==u?(I=u==="cron"&&s(Je,{loadCronJobs:l}),e[44]=l,e[45]=u,e[46]=I):I=e[46];let D;return e[47]!==L||e[48]!==$||e[49]!==A||e[50]!==C||e[51]!==k||e[52]!==x||e[53]!==I?(D=R("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,L,$,A,C,k,x,I]}),e[47]=L,e[48]=$,e[49]=A,e[50]=C,e[51]=k,e[52]=x,e[53]=I,e[54]=D):D=e[54],D};export{It as SchedulePanel};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as v,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as c,jsx as t}from"react/jsx-runtime";const w=80,G=l=>{if(l===void 0)return"";const e=JSON.stringify(l,q);return e.length>w?`${e.slice(0,w)}…`:e},J=l=>{const e=[];for(const r of l){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((s,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:s})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=l=>{const e=R(24),{initialShardKey:r}=l,n=O(),{queryShardKey:s,setShardKey:i,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==s?(f={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=f):f=e[2];const{data:o,error:a,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==a||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==i||e[8]!==m||e[9]!==n){const N=o===void 0?[]:J(o.connections);let d;e[11]!==i||e[12]!==m?(d=t(E,{onChange:i,testId:"subs-shard-input",value:m}),e[11]=i,e[12]=m,e[13]=d):d=e[13];let u;e[14]!==o||e[15]!==n?(u=o!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:o.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:o.totalSubscriptions})})]}),e[14]=o,e[15]=n,e[16]=u):u=e[16];let g;e[17]!==d||e[18]!==u?(g=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,u]}),e[17]=d,e[18]=u,e[19]=g):g=e[19];let x;e[20]!==a||e[21]!==h||e[22]!==s?(x=a!==null&&t(j,{error:h,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=h,e[22]=s,e[23]=x):x=e[23],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,a===null&&o!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),a===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:c(_,{"data-testid":"subs-table",children:[t(D,{children:c(T,{children:[t(v,{children:n("Connection")}),t(v,{children:n("Function path")}),t(v,{children:n("Table")}),t(v,{children:n("Arguments")})]})}),t(H,{children:N.map(y=>{const{subscription:k}=y,I=G(k?.args);return c(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},y.key)})})]})})})]}),e[3]=a,e[4]=h,e[5]=s,e[6]=o,e[7]=i,e[8]=m,e[9]=n,e[10]=b}else b=e[10];return b};export{ae as default};
1
+ import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as v,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as c,jsx as t}from"react/jsx-runtime";const w=80,G=l=>{if(l===void 0)return"";const e=JSON.stringify(l,q);return e.length>w?`${e.slice(0,w)}…`:e},J=l=>{const e=[];for(const r of l){const n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((s,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:s})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=l=>{const e=R(24),{initialShardKey:r}=l,n=O(),{queryShardKey:s,setShardKey:i,shardKey:m}=L(r);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==s?(f={keepPreviousData:!0,shardKey:s},e[1]=s,e[2]=f):f=e[2];const{data:o,error:a,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==a||e[4]!==h||e[5]!==s||e[6]!==o||e[7]!==i||e[8]!==m||e[9]!==n){const N=o===void 0?[]:J(o.connections);let d;e[11]!==i||e[12]!==m?(d=t(E,{onChange:i,testId:"subs-shard-input",value:m}),e[11]=i,e[12]=m,e[13]=d):d=e[13];let u;e[14]!==o||e[15]!==n?(u=o!==void 0&&c("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:o.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:o.totalSubscriptions})})]}),e[14]=o,e[15]=n,e[16]=u):u=e[16];let g;e[17]!==d||e[18]!==u?(g=c("div",{className:"flex flex-wrap items-center gap-2",children:[d,u]}),e[17]=d,e[18]=u,e[19]=g):g=e[19];let x;e[20]!==a||e[21]!==h||e[22]!==s?(x=a!==null&&t(j,{error:h,shardKey:s,testId:"subs-error"}),e[20]=a,e[21]=h,e[22]=s,e[23]=x):x=e[23],b=c("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,a===null&&o!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),a===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:c(_,{"data-testid":"subs-table",children:[t(D,{children:c(T,{children:[t(v,{children:n("Connection")}),t(v,{children:n("Function path")}),t(v,{children:n("Table")}),t(v,{children:n("Arguments")})]})}),t(H,{children:N.map(y=>{const{subscription:k}=y,I=G(k?.args);return c(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:c("span",{className:"inline-flex items-center gap-1.5",children:["#",y.connectionId,y.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},y.key)})})]})})})]}),e[3]=a,e[4]=h,e[5]=s,e[6]=o,e[7]=i,e[8]=m,e[9]=n,e[10]=b}else b=e[10];return b};export{ae as default};
@@ -1 +1 @@
1
- import{c as q}from"react/compiler-runtime";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as s}from"../packem_shared/table-D0SBiDu-.mjs";import{a as I}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as V}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as n,jsxs as r}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:g}=W,t=Y(),A=V();let T;e[0]!==A||e[1]!==g?(T=()=>Promise.resolve(g?g():A.debug()),e[0]=A,e[1]=g,e[2]=T):T=e[2];const M=T,E=g?"injected":"live";let x;e[3]!==E?(x=["lunora-studio","sync-client-debug",E],e[3]=E,e[4]=x):x=e[4];const{data:c,poll:O}=I(x,M);if(Q(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let S;e[7]!==t?(S=t("Sync client"),e[7]=t,e[8]=S):S=e[8];let k;return e[9]!==i||e[10]!==S?(k=n(R,{children:n(H,{children:n(P,{description:i,title:S})})}),e[9]=i,e[10]=S,e[11]=k):k=e[11],k}const{pendingWrites:C,shards:v,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const L=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==L?(d=n(_,{variant:L,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=L,e[18]=d):d=e[18];let h;e[19]!==C||e[20]!==t?(h=C>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:C})}):null,e[19]=C,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=r("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==v||e[31]!==t?(p=v.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:v.map(i=>r(w,{children:[n(s,{children:i.shardKey??t("(default)")}),n(s,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=v,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>r(w,{children:[n(s,{className:"font-mono text-xs",children:i.functionPath}),n(s,{children:i.kind}),n(s,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(s,{children:i.serverCursor??"—"}),n(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:r(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
1
+ import{c as q}from"react/compiler-runtime";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as s}from"../packem_shared/table-D0SBiDu-.mjs";import{a as I}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import{u as V}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as n,jsxs as r}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:g}=W,t=Y(),A=V();let T;e[0]!==A||e[1]!==g?(T=()=>Promise.resolve(g?g():A.debug()),e[0]=A,e[1]=g,e[2]=T):T=e[2];const M=T,E=g?"injected":"live";let x;e[3]!==E?(x=["lunora-studio","sync-client-debug",E],e[3]=E,e[4]=x):x=e[4];const{data:c,poll:O}=I(x,M);if(Q(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let S;e[7]!==t?(S=t("Sync client"),e[7]=t,e[8]=S):S=e[8];let k;return e[9]!==i||e[10]!==S?(k=n(R,{children:n(H,{children:n(P,{description:i,title:S})})}),e[9]=i,e[10]=S,e[11]=k):k=e[11],k}const{pendingWrites:C,shards:v,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const L=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==L?(d=n(_,{variant:L,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=L,e[18]=d):d=e[18];let h;e[19]!==C||e[20]!==t?(h=C>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:C})}):null,e[19]=C,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=r("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==v||e[31]!==t?(p=v.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:v.map(i=>r(w,{children:[n(s,{children:i.shardKey??t("(default)")}),n(s,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=v,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>r(w,{children:[n(s,{className:"font-mono text-xs",children:i.functionPath}),n(s,{children:i.kind}),n(s,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(s,{children:i.serverCursor??"—"}),n(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:r(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};