@lunora/studio 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (174) hide show
  1. package/__assets__/package-og.svg +1 -1
  2. package/dist/index.d.ts +29 -18
  3. package/dist/index.js +29 -29
  4. package/dist/mount.d.ts +1 -1
  5. package/dist/mount.js +1 -1
  6. package/dist/{packem_shared/ApiTab-W3no0KOj.js → packem_chunks/ApiTab.js} +5 -5
  7. package/dist/{packem_shared/AuditPanel-Bq4o_IqT.js → packem_chunks/AuditPanel.js} +24 -36
  8. package/dist/{packem_shared/ExportImportPanel-dxY56TDF.js → packem_chunks/ExportImportPanel.js} +13 -9
  9. package/dist/{packem_shared/FileBrowser-Dhy4zES8.js → packem_chunks/FileBrowser.js} +15 -15
  10. package/dist/{packem_shared/FunctionRunner--fQJRPAD.js → packem_chunks/FunctionRunner.js} +10 -10
  11. package/dist/{packem_shared/FunctionStatsPanel-BjRUA_G3.js → packem_chunks/FunctionStatsPanel.js} +147 -204
  12. package/dist/{packem_shared/HealthPanel-PxclMWmA.js → packem_chunks/HealthPanel.js} +37 -29
  13. package/dist/{packem_shared/InsightsPanel-CWS_C-xW.js → packem_chunks/InsightsPanel.js} +107 -69
  14. package/dist/{packem_shared/LogsPanel-CTW8CFcM.js → packem_chunks/LogsPanel.js} +41 -53
  15. package/dist/{packem_shared/MailPanel-BwkvfIHF.js → packem_chunks/MailPanel.js} +37 -44
  16. package/dist/{packem_shared/MetricsPanel-BLuOhZQ4.js → packem_chunks/MetricsPanel.js} +41 -322
  17. package/dist/{packem_shared/MigrationsPanel-DT3lnwHF.js → packem_chunks/MigrationsPanel.js} +39 -46
  18. package/dist/{packem_shared/PitrPanel-CdErL7EJ.js → packem_chunks/PitrPanel.js} +9 -9
  19. package/dist/{packem_shared/SchemaViewer-LJDcmNIO.js → packem_chunks/SchemaViewer.js} +15 -15
  20. package/dist/{packem_shared/SecurityAdvisorPanel-C_ETsPih.js → packem_chunks/SecurityAdvisorPanel.js} +44 -31
  21. package/dist/packem_chunks/SettingsPanel.js +390 -0
  22. package/dist/{packem_shared/sql-editor-panel-BFRpzj6r.js → packem_chunks/SqlEditorPanel.js} +12 -252
  23. package/dist/{packem_shared/TableEditor-ChfUOZec.js → packem_chunks/TableEditor.js} +10 -68
  24. package/dist/packem_chunks/analytics-panel.js +261 -0
  25. package/dist/packem_chunks/auth-config-panel.js +179 -0
  26. package/dist/packem_chunks/auth-sessions-panel.js +175 -0
  27. package/dist/packem_chunks/dashboards-panel.js +779 -0
  28. package/dist/packem_chunks/fanout-panel.js +481 -0
  29. package/dist/packem_chunks/flags-panel.js +176 -0
  30. package/dist/packem_chunks/kv-browser.js +1896 -0
  31. package/dist/packem_chunks/log-drains-panel.js +273 -0
  32. package/dist/packem_chunks/organizations-panel.js +670 -0
  33. package/dist/packem_chunks/payments-panel.js +185 -0
  34. package/dist/packem_chunks/permissions-panel.js +804 -0
  35. package/dist/packem_chunks/queues-panel.js +147 -0
  36. package/dist/packem_chunks/rls-panel.js +313 -0
  37. package/dist/packem_chunks/schedule-panel.js +831 -0
  38. package/dist/packem_chunks/sparkline.js +79 -0
  39. package/dist/packem_chunks/storage-rules-panel.js +138 -0
  40. package/dist/packem_chunks/subscriptions-panel.js +236 -0
  41. package/dist/packem_chunks/users-panel.js +1265 -0
  42. package/dist/packem_chunks/vector-browser.js +281 -0
  43. package/dist/packem_chunks/workflows-panel.js +562 -0
  44. package/dist/packem_shared/{ADMIN_FUNCTIONS-DmBqMZ-z.js → ADMIN_FUNCTIONS-CdaxLGkE.js} +3 -0
  45. package/dist/packem_shared/{ApiDocsPanel-C5-yJ1p7.js → ApiDocsPanel-B6u_wnz-.js} +2 -2
  46. package/dist/packem_shared/{ApiReferencePanel-1vubqG5s.js → ApiReferencePanel-Drz4UO0a.js} +2 -1
  47. package/dist/packem_shared/{CommandPalette-BtgkBzZI.js → CommandPalette-B5BertvU.js} +1 -1
  48. package/dist/packem_shared/{DataBrowser-CtBe1So9.js → DataBrowser-ANTHLWWh.js} +198 -247
  49. package/dist/packem_shared/{GlobalDataBrowser-BTEmGrph.js → GlobalDataBrowser-CjgTG_wa.js} +37 -66
  50. package/dist/packem_shared/HomePanel-c2FodE9t.js +14 -0
  51. package/dist/packem_shared/{OpenRpcReferencePanel-vbcYbv3V.js → OpenRpcReferencePanel-CspFdbUT.js} +2 -1
  52. package/dist/packem_shared/{ScheduledJobs-CabfKbyM.js → ScheduledJobs-BEJXtsBn.js} +163 -60
  53. package/dist/packem_shared/Studio-CVTtA_sB.js +16 -0
  54. package/dist/packem_shared/{StudioApp-CHOZA-z-.js → StudioApp-BSYV2fz6.js} +277 -3
  55. package/dist/packem_shared/{advisor-view-CGcfMiPq.js → advisor-view-DzqyvUU3.js} +1 -1
  56. package/dist/packem_shared/{app.d-CCmwDEVs.d.ts → app.d-B6MyY_al.d.ts} +1 -1
  57. package/dist/packem_shared/{bar-chart-CzJAgqkp.js → bar-chart-Bb__F5-u.js} +1 -1
  58. package/dist/packem_shared/browser-storage-d03UsV7v.js +249 -0
  59. package/dist/packem_shared/{cf-links-2cktDedA.js → cf-links-BZfRdxSE.js} +1 -1
  60. package/dist/packem_shared/{data-grid-B5CaV3wS.js → data-grid-Dsg6nRjo.js} +1 -1
  61. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +96 -0
  62. package/dist/packem_shared/{grid-features-CzUfqgsM.js → grid-features-D7nNzBYm.js} +4 -99
  63. package/dist/packem_shared/{HomePanel-Cw16stjq.js → home-panel-aOR_drVv.js} +833 -469
  64. package/dist/packem_shared/{internal-rXJEAhXS.js → internal-FcNZ3beb.js} +1 -1
  65. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +100 -0
  66. package/dist/packem_shared/{reference-view-B4E49Lip.js → reference-view-Doy1XlQq.js} +4 -44
  67. package/dist/packem_shared/select-UkNYCT3s.js +273 -0
  68. package/dist/packem_shared/skeleton-CGhL0p20.js +45 -0
  69. package/dist/packem_shared/{sparkline-10dG-_f0.js → sparkline-KgMPHS4u.js} +1 -1
  70. package/dist/packem_shared/studio-dMTJ-kRR.js +3987 -0
  71. package/dist/packem_shared/{table-_RzNvy3R.js → table-DsCa9Qp9.js} +1 -1
  72. package/dist/packem_shared/{table-list-sidebar-Bg7uzbvC.js → table-list-sidebar-VMo0ftxD.js} +1 -1
  73. package/dist/packem_shared/use-admin-query-BViPA3US.js +105 -0
  74. package/dist/packem_shared/use-auth-capabilities-BHkoBnbZ.js +32 -0
  75. package/dist/standalone/chunk-2DS7JLWL.js +13 -0
  76. package/dist/standalone/chunk-2K47A3P6.js +1 -0
  77. package/dist/standalone/chunk-2NGUNNGW.js +1 -0
  78. package/dist/standalone/chunk-2PDQ4KZ6.js +1 -0
  79. package/dist/standalone/chunk-3BP4BTLR.js +4 -0
  80. package/dist/standalone/chunk-3OA7PECS.js +6 -0
  81. package/dist/standalone/chunk-4QHKBC77.js +1 -0
  82. package/dist/standalone/chunk-57LYXHXH.js +1 -0
  83. package/dist/standalone/chunk-5NSZVXCS.js +1 -0
  84. package/dist/standalone/chunk-5OIBXYZM.js +1 -0
  85. package/dist/standalone/chunk-63XKJQTQ.js +1 -0
  86. package/dist/standalone/chunk-6RC6L33K.js +4 -0
  87. package/dist/standalone/chunk-6VTGE3WJ.js +1 -0
  88. package/dist/standalone/chunk-7PBZKXYA.js +1 -0
  89. package/dist/standalone/chunk-7POIIWC5.js +3 -0
  90. package/dist/standalone/chunk-7RYIQKZA.js +1 -0
  91. package/dist/standalone/chunk-7TJJXVSE.js +1 -0
  92. package/dist/standalone/chunk-AB6QGMBF.js +1 -0
  93. package/dist/standalone/chunk-AHILM3ZP.js +1 -0
  94. package/dist/standalone/chunk-AQGOX5DK.js +1 -0
  95. package/dist/standalone/chunk-ASLGNHAX.js +1 -0
  96. package/dist/standalone/chunk-BHTPZS7L.js +4 -0
  97. package/dist/standalone/chunk-BJGBHGK3.js +1 -0
  98. package/dist/standalone/chunk-D7HKX4DI.js +1 -0
  99. package/dist/standalone/chunk-DGWTR4G7.js +1 -0
  100. package/dist/standalone/chunk-DSX53PBM.js +1 -0
  101. package/dist/standalone/chunk-DV2MNASX.js +1 -0
  102. package/dist/standalone/chunk-DWDILV2E.js +1 -0
  103. package/dist/standalone/chunk-E7AVZZKO.js +1 -0
  104. package/dist/standalone/chunk-EGJX34WM.js +1 -0
  105. package/dist/standalone/chunk-FCR3HKFV.js +1 -0
  106. package/dist/standalone/chunk-FKO3HO6I.js +4 -0
  107. package/dist/standalone/chunk-FQKNJSRA.js +76 -0
  108. package/dist/standalone/chunk-G2TFEWEQ.js +4 -0
  109. package/dist/standalone/chunk-GABMIICA.js +1 -0
  110. package/dist/standalone/chunk-GTM65MVX.js +1 -0
  111. package/dist/standalone/chunk-GZXPPJVK.js +1 -0
  112. package/dist/standalone/chunk-HFBRE65A.js +1 -0
  113. package/dist/standalone/chunk-HFMQNUBC.js +1 -0
  114. package/dist/standalone/chunk-HG7Q5B3H.js +1 -0
  115. package/dist/standalone/chunk-HTQL7AXU.js +1 -0
  116. package/dist/standalone/chunk-HV7G6DFP.js +5 -0
  117. package/dist/standalone/chunk-ITLLHEVG.js +1 -0
  118. package/dist/standalone/chunk-J6J54MBP.js +1 -0
  119. package/dist/standalone/chunk-JSEXCW5Q.js +1 -0
  120. package/dist/standalone/chunk-KEGAWN6Y.js +1 -0
  121. package/dist/standalone/chunk-KG3QTFWE.js +1 -0
  122. package/dist/standalone/chunk-KGS7KM4A.js +2 -0
  123. package/dist/standalone/chunk-KODWGUAB.js +1 -0
  124. package/dist/standalone/chunk-KZ6INM5M.js +1 -0
  125. package/dist/standalone/chunk-MGFEVTRI.js +1 -0
  126. package/dist/standalone/chunk-N2QDG3MW.js +1 -0
  127. package/dist/standalone/chunk-N4JI6VQD.js +1 -0
  128. package/dist/standalone/chunk-NNISYDNI.js +1 -0
  129. package/dist/standalone/chunk-O4PXDNR3.js +1 -0
  130. package/dist/standalone/chunk-O77VNUFD.js +1 -0
  131. package/dist/standalone/chunk-OD2POGPJ.js +1 -0
  132. package/dist/standalone/chunk-OXCK3ZUG.js +1 -0
  133. package/dist/standalone/chunk-P7DSVO4U.js +1 -0
  134. package/dist/standalone/chunk-PKAM3N5C.js +1 -0
  135. package/dist/standalone/chunk-QGXGBHQO.js +1 -0
  136. package/dist/standalone/chunk-QHA3TAEJ.js +1 -0
  137. package/dist/standalone/chunk-QQWC62X7.js +1 -0
  138. package/dist/standalone/chunk-RMYA7NAH.js +1 -0
  139. package/dist/standalone/chunk-RRCPZMC2.js +22 -0
  140. package/dist/standalone/chunk-S53RUBW5.js +1 -0
  141. package/dist/standalone/chunk-SB4GT6PK.js +1 -0
  142. package/dist/standalone/chunk-SEU5V7I6.js +1 -0
  143. package/dist/standalone/chunk-SHIOUDOT.js +1 -0
  144. package/dist/standalone/chunk-SIDRSX7Y.js +1 -0
  145. package/dist/standalone/chunk-SVR644RF.js +1 -0
  146. package/dist/standalone/chunk-TAD43CG5.js +1 -0
  147. package/dist/standalone/chunk-TBMYIZIO.js +1 -0
  148. package/dist/standalone/chunk-TICVNLPM.js +1 -0
  149. package/dist/standalone/chunk-TQ36RWOP.js +1 -0
  150. package/dist/standalone/chunk-UGMRUEBU.js +1 -0
  151. package/dist/standalone/chunk-UII66UVF.js +1 -0
  152. package/dist/standalone/chunk-VJPQUBN6.js +8 -0
  153. package/dist/standalone/chunk-VLXV72QE.js +1 -0
  154. package/dist/standalone/chunk-VMJKJWG6.js +1 -0
  155. package/dist/standalone/chunk-VPDPN5RR.js +2 -0
  156. package/dist/standalone/chunk-VSEGZA3J.js +1 -0
  157. package/dist/standalone/chunk-VXBZQIGY.js +4 -0
  158. package/dist/standalone/chunk-W7PCVQTE.js +1 -0
  159. package/dist/standalone/chunk-XLILSHPE.js +1 -0
  160. package/dist/standalone/chunk-XURNGQSS.js +1 -0
  161. package/dist/standalone/chunk-YJGANMU7.js +18 -0
  162. package/dist/standalone/chunk-YQQJ4N6U.js +1 -0
  163. package/dist/standalone/chunk-ZH7UES4T.js +2 -0
  164. package/dist/standalone/chunk-ZPUO7FNI.js +1 -0
  165. package/dist/standalone/chunk-ZQCVDXDL.js +1 -0
  166. package/dist/standalone/studio.js +104 -246
  167. package/dist/styles.css +1 -1
  168. package/package.json +13 -12
  169. package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
  170. package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
  171. package/dist/packem_shared/Studio-DFWAlcuf.js +0 -33
  172. package/dist/packem_shared/studio-Bj8psK1c.js +0 -10303
  173. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  174. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
@@ -0,0 +1 @@
1
+ import{a as le}from"./chunk-P7DSVO4U.js";import{a as X}from"./chunk-AHILM3ZP.js";import{a as ae}from"./chunk-J6J54MBP.js";import{a as se}from"./chunk-2K47A3P6.js";import{a as G,b as W,c as Y,d as B,e as F,f as U}from"./chunk-GTM65MVX.js";import{a as z}from"./chunk-JSEXCW5Q.js";import{R as D}from"./chunk-BHTPZS7L.js";import{c as S}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as ee}from"./chunk-TAD43CG5.js";import{a as te}from"./chunk-FCR3HKFV.js";import{a as V,e as j}from"./chunk-SEU5V7I6.js";import{b as E}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import{f as $}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as M,g as Z,h as H,i as O,l as Q}from"./chunk-YJGANMU7.js";import{a,e as K,f as ge,g as Ne,h as we}from"./chunk-RRCPZMC2.js";var m=K(ge(),1);var t=K(we(),1),q=K(Ne(),1);var ke=a(({onClose:w,onCreated:e})=>{let i=$(),s=M(),[c,d]=(0,m.useState)(""),[u,l]=(0,m.useState)(""),[o,f]=(0,m.useState)(""),[k,I]=(0,m.useState)(""),[C,b]=(0,m.useState)(!1),[N,y]=(0,m.useState)(null),h=a(r=>{d(r.target.value)},"onEmailChange"),p=a(r=>{l(r.target.value)},"onNameChange"),x=a(r=>{f(r.target.value)},"onPasswordChange"),v=a(r=>{I(r.target.value)},"onRoleChange"),n=a(async()=>{b(!0),y(null);try{await i.createAuthUser({email:c.trim(),name:u.trim(),password:o===""?void 0:o,role:k.trim()===""?void 0:k.trim()}),e(),w()}catch(r){y(Z(r))}finally{b(!1)}},"submit"),A=a(()=>{O(n())},"onSubmit");return(0,t.jsxDEV)(X,{label:s("Create user"),onClose:w,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:s("Create user")},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"uc-email",children:s("email")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"uc-email",id:"uc-email",onChange:h,type:"email",value:c},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"uc-name",children:s("name")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"uc-name",id:"uc-name",onChange:p,value:u},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"uc-password",children:s("Password (optional)")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"uc-password",id:"uc-password",onChange:x,type:"password",value:o},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"uc-role",children:s("Role (optional)")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"uc-role",id:"uc-role",onChange:v,value:k},void 0,!1)]},void 0,!0),N!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:N},void 0,!1),(0,t.jsxDEV)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,t.jsxDEV)(S,{"data-testid":"uc-cancel",onClick:w,size:"sm",type:"button",variant:"outline",children:s("Cancel")},void 0,!1),(0,t.jsxDEV)(S,{"data-testid":"uc-submit",disabled:C||c.trim()===""||u.trim()==="",onClick:A,size:"sm",type:"button",children:s(C?"Creating\u2026":"Create")},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserCreateDialog"),_=a(w=>{let e=(0,q.c)(2),{children:i}=w,s;return e[0]!==i?(s=(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=s):s=e[1],s},"SectionHeading"),Ce=a(w=>{let e=(0,q.c)(29),{busy:i,runAction:s,userId:c,version:d}=w,u=$(),l=M(),[o,f]=(0,m.useState)(null),[k,I]=(0,m.useState)(null),C;e[0]!==u||e[1]!==c?(C=a(()=>{O((async()=>{I(null);try{let r=await u.listAuthSessions({limit:50,userId:c});f(r.rows)}catch(r){let R=r;f(null),I(Z(R))}})())},"t1"),e[0]=u,e[1]=c,e[2]=C):C=e[2];let b;e[3]!==u||e[4]!==c||e[5]!==d?(b=[u,c,d],e[3]=u,e[4]=c,e[5]=d,e[6]=b):b=e[6],(0,m.useEffect)(C,b);let N;e[7]!==u||e[8]!==s?(N=a(r=>{s(()=>u.revokeAuthSession({sessionId:r}))},"t3"),e[7]=u,e[8]=s,e[9]=N):N=e[9];let y=N,h;e[10]!==l?(h=l("Sessions"),e[10]=l,e[11]=h):h=e[11];let p;e[12]!==h?(p=(0,t.jsxDEV)(_,{children:h},void 0,!1),e[12]=h,e[13]=p):p=e[13];let x;e[14]!==k?(x=k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:k},void 0,!1),e[14]=k,e[15]=x):x=e[15];let v;e[16]!==o||e[17]!==l?(v=o!==null&&o.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:l("No active sessions.")},void 0,!1),e[16]=o,e[17]=l,e[18]=v):v=e[18];let n;e[19]!==i||e[20]!==y||e[21]!==o||e[22]!==l?(n=o!==null&&o.length>0&&(0,t.jsxDEV)(V,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(j,{className:"px-0",children:(0,t.jsxDEV)(G,{"data-testid":"ud-sessions-table",children:[(0,t.jsxDEV)(W,{children:(0,t.jsxDEV)(B,{children:[(0,t.jsxDEV)(F,{children:l("expires")},void 0,!1),(0,t.jsxDEV)(F,{children:l("ip")},void 0,!1),(0,t.jsxDEV)(F,{children:l("user agent")},void 0,!1),(0,t.jsxDEV)(F,{"aria-label":l("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Y,{children:o.map(r=>(0,t.jsxDEV)(B,{"data-testid":`ud-session-${r.id}`,children:[(0,t.jsxDEV)(U,{className:"text-muted-foreground tabular-nums",children:Q(r.expiresAt)},void 0,!1),(0,t.jsxDEV)(U,{children:r.ipAddress??""},void 0,!1),(0,t.jsxDEV)(U,{className:"max-w-40 truncate",children:r.userAgent??""},void 0,!1),(0,t.jsxDEV)(U,{children:(0,t.jsxDEV)(S,{"data-testid":`ud-revoke-${r.id}`,disabled:i,onClick:a(()=>{y(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Revoke")},void 0,!1)},void 0,!1)]},r.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[19]=i,e[20]=y,e[21]=o,e[22]=l,e[23]=n):n=e[23];let A;return e[24]!==p||e[25]!==x||e[26]!==v||e[27]!==n?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[p,x,v,n]},void 0,!0),e[24]=p,e[25]=x,e[26]=v,e[27]=n,e[28]=A):A=e[28],A},"UserSessionsPanel"),Ae=a(w=>{let e=(0,q.c)(30),{busy:i,runAction:s,userId:c,version:d}=w,u=$(),l=M(),[o,f]=(0,m.useState)(null),[k,I]=(0,m.useState)(null),C;e[0]!==u||e[1]!==c?(C=a(()=>{O((async()=>{I(null);try{f(await u.listAuthAccounts({userId:c}))}catch(r){let R=r;f(null),I(Z(R))}})())},"t1"),e[0]=u,e[1]=c,e[2]=C):C=e[2];let b;e[3]!==u||e[4]!==c||e[5]!==d?(b=[u,c,d],e[3]=u,e[4]=c,e[5]=d,e[6]=b):b=e[6],(0,m.useEffect)(C,b);let N;e[7]!==u||e[8]!==s||e[9]!==c?(N=a(r=>{s(()=>u.unlinkAuthAccount({accountId:r,userId:c}))},"t3"),e[7]=u,e[8]=s,e[9]=c,e[10]=N):N=e[10];let y=N,h;e[11]!==l?(h=l("Linked accounts"),e[11]=l,e[12]=h):h=e[12];let p;e[13]!==h?(p=(0,t.jsxDEV)(_,{children:h},void 0,!1),e[13]=h,e[14]=p):p=e[14];let x;e[15]!==k?(x=k!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive",role:"alert",children:k},void 0,!1),e[15]=k,e[16]=x):x=e[16];let v;e[17]!==o||e[18]!==l?(v=o!==null&&o.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:l("No linked accounts.")},void 0,!1),e[17]=o,e[18]=l,e[19]=v):v=e[19];let n;e[20]!==o||e[21]!==i||e[22]!==y||e[23]!==l?(n=o!==null&&o.length>0&&(0,t.jsxDEV)(V,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(j,{className:"px-0",children:(0,t.jsxDEV)(G,{"data-testid":"ud-accounts-table",children:[(0,t.jsxDEV)(W,{children:(0,t.jsxDEV)(B,{children:[(0,t.jsxDEV)(F,{children:l("provider")},void 0,!1),(0,t.jsxDEV)(F,{children:l("created")},void 0,!1),(0,t.jsxDEV)(F,{"aria-label":l("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Y,{children:o.map(r=>{let R=H(r.id);return(0,t.jsxDEV)(B,{"data-testid":`ud-account-${R}`,children:[(0,t.jsxDEV)(U,{children:H(r.providerId)},void 0,!1),(0,t.jsxDEV)(U,{className:"text-muted-foreground tabular-nums",children:Q(r.createdAt)},void 0,!1),(0,t.jsxDEV)(U,{children:(0,t.jsxDEV)(S,{"data-testid":`ud-unlink-${R}`,disabled:i,onClick:a(()=>{y(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Unlink")},void 0,!1)},void 0,!1)]},R,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[20]=o,e[21]=i,e[22]=y,e[23]=l,e[24]=n):n=e[24];let A;return e[25]!==p||e[26]!==x||e[27]!==v||e[28]!==n?(A=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[p,x,v,n]},void 0,!0),e[25]=p,e[26]=x,e[27]=v,e[28]=n,e[29]=A):A=e[29],A},"UserAccountsPanel"),Ie=a(w=>{let e=(0,q.c)(40),{busy:i,capabilities:s,runAction:c,userId:d,version:u}=w,l=$(),o=M(),[f,k]=(0,m.useState)(null),I;e[0]!==s.passkey||e[1]!==l||e[2]!==d?(I=a(()=>{s.passkey&&O((async()=>{try{k(await l.listAuthPasskeys({userId:d}))}catch{k(null)}})())},"t1"),e[0]=s.passkey,e[1]=l,e[2]=d,e[3]=I):I=e[3];let C;e[4]!==s.passkey||e[5]!==l||e[6]!==d||e[7]!==u?(C=[s.passkey,l,d,u],e[4]=s.passkey,e[5]=l,e[6]=d,e[7]=u,e[8]=C):C=e[8],(0,m.useEffect)(I,C);let b;e[9]!==l||e[10]!==c||e[11]!==d?(b=a(()=>{c(()=>l.disableAuthTwoFactor({userId:d}))},"t3"),e[9]=l,e[10]=c,e[11]=d,e[12]=b):b=e[12];let N=b,y;e[13]!==l||e[14]!==c?(y=a(R=>{c(()=>l.deleteAuthPasskey({passkeyId:R}))},"t4"),e[13]=l,e[14]=c,e[15]=y):y=e[15];let h=y,p;e[16]!==o?(p=o("Security"),e[16]=o,e[17]=p):p=e[17];let x;e[18]!==p?(x=(0,t.jsxDEV)(_,{children:p},void 0,!1),e[18]=p,e[19]=x):x=e[19];let v;e[20]!==i||e[21]!==s.twoFactor||e[22]!==N||e[23]!==o?(v=s.twoFactor&&(0,t.jsxDEV)(S,{"data-testid":"ud-disable-2fa",disabled:i,onClick:N,size:"sm",type:"button",variant:"outline",children:o("Disable two-factor")},void 0,!1),e[20]=i,e[21]=s.twoFactor,e[22]=N,e[23]=o,e[24]=v):v=e[24];let n;e[25]!==s.passkey||e[26]!==f||e[27]!==o?(n=s.passkey&&f!==null&&f.length===0&&(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:o("No passkeys.")},void 0,!1),e[25]=s.passkey,e[26]=f,e[27]=o,e[28]=n):n=e[28];let A;e[29]!==i||e[30]!==s.passkey||e[31]!==h||e[32]!==f||e[33]!==o?(A=s.passkey&&f!==null&&f.length>0&&(0,t.jsxDEV)(V,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(j,{className:"px-0",children:(0,t.jsxDEV)(G,{"data-testid":"ud-passkeys-table",children:[(0,t.jsxDEV)(W,{children:(0,t.jsxDEV)(B,{children:[(0,t.jsxDEV)(F,{children:o("name")},void 0,!1),(0,t.jsxDEV)(F,{children:o("created")},void 0,!1),(0,t.jsxDEV)(F,{"aria-label":o("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Y,{children:f.map(R=>{let T=H(R.id);return(0,t.jsxDEV)(B,{"data-testid":`ud-passkey-${T}`,children:[(0,t.jsxDEV)(U,{children:H(R.name)||T},void 0,!1),(0,t.jsxDEV)(U,{className:"text-muted-foreground tabular-nums",children:Q(R.createdAt)},void 0,!1),(0,t.jsxDEV)(U,{children:(0,t.jsxDEV)(S,{"data-testid":`ud-delete-passkey-${T}`,disabled:i,onClick:a(()=>{h(T)},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")},void 0,!1)},void 0,!1)]},T,!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),e[29]=i,e[30]=s.passkey,e[31]=h,e[32]=f,e[33]=o,e[34]=A):A=e[34];let r;return e[35]!==x||e[36]!==v||e[37]!==n||e[38]!==A?(r=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[x,v,n,A]},void 0,!0),e[35]=x,e[36]=v,e[37]=n,e[38]=A,e[39]=r):r=e[39],r},"UserSecurityPanel"),Se=/(?:at|expires)$/iu,Fe=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),Ue=a((w,e)=>typeof e=="number"&&Se.test(w)?Q(e):H(e),"formatField"),Re=a(({capabilities:w,onChanged:e,onClose:i,user:s})=>{let c=$(),d=M(),u=s.banned===!0,[l,o]=(0,m.useState)(null),[f,k]=(0,m.useState)(!1),[I,C]=(0,m.useState)(0),[b,N]=(0,m.useState)(typeof s.role=="string"?s.role:""),[y,h]=(0,m.useState)(""),[p,x]=(0,m.useState)(""),[v,n]=(0,m.useState)(""),[A,r]=(0,m.useState)(null),[R,T]=(0,m.useState)(!1),P=a((g,L)=>{O((async()=>{k(!0),o(null);try{let J=await g();L?.refresh!==!1&&(C(ye=>ye+1),e()),L?.onResult?.(J)}catch(J){o(Z(J))}finally{k(!1)}})())},"runAction"),ie=a(g=>{N(g.target.value)},"onRoleInputChange"),de=a(g=>{h(g.target.value)},"onBanReasonChange"),oe=a(g=>{x(g.target.value)},"onBanDaysChange"),ne=a(g=>{n(g.target.value)},"onNewPasswordChange"),re=a(()=>{let g=b.trim();g!==""&&P(async()=>{await c.setAuthUserRole({role:g,userId:s.id})})},"onSetRole"),ce=a(()=>{let g=Number.parseInt(p,10),L=Number.isFinite(g)&&g>0?g*86400:void 0;P(async()=>{await c.banAuthUser({expiresInSeconds:L,reason:y.trim()===""?void 0:y.trim(),userId:s.id})})},"onBan"),ue=a(()=>{P(async()=>{await c.unbanAuthUser({userId:s.id})})},"onUnban"),fe=a(()=>{P(async()=>{await c.setAuthUserPassword({newPassword:v,userId:s.id}),n("")})},"onSetPassword"),ve=a(()=>{P(()=>c.impersonateAuthUser({userId:s.id}),{onResult:a(g=>{r(g.token)},"onResult"),refresh:!1})},"onImpersonate"),me=a(()=>{P(async()=>{await c.revokeAuthUserSessions({userId:s.id})})},"onRevokeAll"),he=a(()=>{P(async()=>{await c.removeAuthUser({userId:s.id}),i()})},"onDelete"),pe=a(()=>{T(!0)},"onConfirmDelete"),xe=a(()=>{T(!1)},"onCancelDelete"),be=Object.entries(s).filter(([g])=>!Fe.has(g));return(0,t.jsxDEV)(X,{label:d("User details"),onClose:i,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[(0,t.jsxDEV)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxDEV)("h2",{className:"text-sm font-semibold text-foreground",children:s.name??s.email??s.id},void 0,!1),(0,t.jsxDEV)("p",{className:"font-mono text-xs text-muted-foreground",children:s.id},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof s.role=="string"&&s.role!==""&&(0,t.jsxDEV)(E,{variant:"secondary",children:s.role},void 0,!1),u?(0,t.jsxDEV)(E,{variant:"destructive",children:d("Banned")},void 0,!1):(0,t.jsxDEV)(E,{variant:"outline",children:d("Active")},void 0,!1),s.emailVerified===!0?(0,t.jsxDEV)(E,{variant:"secondary",children:d("verified")},void 0,!1):(0,t.jsxDEV)(E,{variant:"outline",children:d("unverified")},void 0,!1)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(S,{"data-testid":"ud-close",onClick:i,size:"sm",type:"button",variant:"ghost",children:d("Close")},void 0,!1)]},void 0,!0),l!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:l},void 0,!1),w.admin&&(0,t.jsxDEV)(V,{className:"gap-0 py-0",children:[(0,t.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Actions")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(j,{className:"flex flex-col gap-3 p-3",children:[(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"ud-role",children:d("Role")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"ud-role-input",id:"ud-role",onChange:ie,value:b},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(S,{"data-testid":"ud-set-role",disabled:f||b.trim()==="",onClick:re,size:"sm",type:"button",variant:"outline",children:d("Set role")},void 0,!1)]},void 0,!0),u?(0,t.jsxDEV)(S,{"data-testid":"ud-unban",disabled:f,onClick:ue,size:"sm",type:"button",variant:"outline",children:d("Unban")},void 0,!1):(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"ud-ban-reason",children:d("Ban reason (optional)")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:de,value:y},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex w-24 flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"ud-ban-days",children:d("Days")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"ud-ban-days",id:"ud-ban-days",onChange:oe,type:"number",value:p},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(S,{"data-testid":"ud-ban",disabled:f,onClick:ce,size:"sm",type:"button",variant:"destructive",children:d("Ban user")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex items-end gap-2",children:[(0,t.jsxDEV)("div",{className:"flex flex-1 flex-col gap-1",children:[(0,t.jsxDEV)(z,{htmlFor:"ud-password",children:d("New password")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"ud-password",id:"ud-password",onChange:ne,type:"password",value:v},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(S,{"data-testid":"ud-set-password",disabled:f||v==="",onClick:fe,size:"sm",type:"button",variant:"outline",children:d("Set password")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex flex-wrap gap-2",children:[(0,t.jsxDEV)(S,{"data-testid":"ud-impersonate",disabled:f,onClick:ve,size:"sm",type:"button",variant:"outline",children:d("Impersonate")},void 0,!1),(0,t.jsxDEV)(S,{"data-testid":"ud-revoke-all",disabled:f,onClick:me,size:"sm",type:"button",variant:"outline",children:d("Revoke all sessions")},void 0,!1),R?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(S,{"data-testid":"ud-delete-confirm",disabled:f,onClick:he,size:"sm",type:"button",variant:"destructive",children:d("Confirm delete")},void 0,!1),(0,t.jsxDEV)(S,{"data-testid":"ud-delete-cancel",onClick:xe,size:"sm",type:"button",variant:"ghost",children:d("Cancel")},void 0,!1)]},void 0,!0):(0,t.jsxDEV)(S,{"data-testid":"ud-delete",disabled:f,onClick:pe,size:"sm",type:"button",variant:"destructive",children:d("Delete user")},void 0,!1)]},void 0,!0),A!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[(0,t.jsxDEV)(z,{htmlFor:"ud-token",children:d("Impersonation token")},void 0,!1),(0,t.jsxDEV)(D,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:A},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),(0,t.jsxDEV)(Ce,{busy:f,runAction:P,userId:s.id,version:I},void 0,!1),w.accounts&&(0,t.jsxDEV)(Ae,{busy:f,runAction:P,userId:s.id,version:I},void 0,!1),(w.twoFactor||w.passkey)&&(0,t.jsxDEV)(Ie,{busy:f,capabilities:w,runAction:P,userId:s.id,version:I},void 0,!1),(0,t.jsxDEV)("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[(0,t.jsxDEV)("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Fields")},void 0,!1),(0,t.jsxDEV)("dl",{className:"flex flex-col",children:be.map(([g,L])=>(0,t.jsxDEV)("div",{className:"flex flex-col border-t border-border py-1.5",children:[(0,t.jsxDEV)("dt",{className:"text-xs font-semibold text-muted-foreground",children:g},void 0,!1),(0,t.jsxDEV)("dd",{className:"m-0 font-mono text-xs break-words",children:Ue(g,L)},void 0,!1)]},g,!0))},void 0,!1)]},void 0,!0)]},void 0,!0)},"UserDetailDrawer"),De=50,We=a(({pageSize:w=De}={})=>{let e=$(),i=M(),[s,c]=(0,m.useState)(""),[d,u]=(0,m.useState)(""),l=se(s),[o,f]=(0,m.useState)(null),[k,I]=(0,m.useState)(!1),{capabilities:C}=le(),b=l.trim(),N=d.trim(),y=te(["lunora-auth-users",b,N,w],()=>e.listAuthUsers({filterField:N===""?void 0:"role",filterValue:N===""?void 0:N,limit:w,search:b===""?void 0:b}),{keepPreviousData:!0}),h=y.data?.rows??null,p=y.error,x=a(()=>{y.refetch()},"reloadUsers");ae(()=>{y.refetch()},!0);let v=o===null?null:h?.find(n=>n.id===o)??null;return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(D,{"aria-label":i("Search users"),className:"w-56","data-testid":"us-search",onChange:a(n=>{c(n.target.value)},"onChange"),placeholder:i("Search by email or name\u2026"),value:s},void 0,!1),(0,t.jsxDEV)(D,{"aria-label":i("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:a(n=>{u(n.target.value)},"onChange"),placeholder:i("Filter by role"),value:d},void 0,!1),(0,t.jsxDEV)(S,{"data-testid":"us-new",onClick:a(()=>{I(!0)},"onClick"),size:"sm",type:"button",children:i("New user")},void 0,!1)]},void 0,!0),p!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:p},void 0,!1),h!==null&&h.length===0&&(0,t.jsxDEV)(ee,{description:i("Users who sign up to your app will appear here."),icon:(0,t.jsxDEV)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsxDEV)("path",{d:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"},void 0,!1)},void 0,!1),testId:"us-empty",title:i("No users.")},void 0,!1),h!==null&&h.length>0&&(0,t.jsxDEV)(V,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(j,{className:"px-0",children:(0,t.jsxDEV)(G,{"data-testid":"us-table",children:[(0,t.jsxDEV)(W,{children:(0,t.jsxDEV)(B,{children:[(0,t.jsxDEV)(F,{children:i("id")},void 0,!1),(0,t.jsxDEV)(F,{children:i("email")},void 0,!1),(0,t.jsxDEV)(F,{children:i("name")},void 0,!1),(0,t.jsxDEV)(F,{children:i("role")},void 0,!1),(0,t.jsxDEV)(F,{children:i("status")},void 0,!1),(0,t.jsxDEV)(F,{children:i("verified")},void 0,!1),(0,t.jsxDEV)(F,{children:i("created")},void 0,!1),(0,t.jsxDEV)(F,{"aria-label":i("Actions")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(Y,{children:h.map(n=>(0,t.jsxDEV)(B,{"data-testid":`us-row-${n.id}`,children:[(0,t.jsxDEV)(U,{className:"font-mono text-xs",children:n.id},void 0,!1),(0,t.jsxDEV)(U,{children:n.email??""},void 0,!1),(0,t.jsxDEV)(U,{children:n.name??""},void 0,!1),(0,t.jsxDEV)(U,{children:typeof n.role=="string"&&n.role!==""?(0,t.jsxDEV)(E,{variant:"secondary",children:n.role},void 0,!1):""},void 0,!1),(0,t.jsxDEV)(U,{children:n.banned===!0?(0,t.jsxDEV)(E,{variant:"destructive",children:i("Banned")},void 0,!1):(0,t.jsxDEV)(E,{variant:"success",children:i("Active")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(U,{children:n.emailVerified===!0?(0,t.jsxDEV)(E,{variant:"success",children:i("yes")},void 0,!1):(0,t.jsxDEV)(E,{variant:"outline",children:i("no")},void 0,!1)},void 0,!1),(0,t.jsxDEV)(U,{className:"text-muted-foreground tabular-nums",children:Q(n.createdAt)},void 0,!1),(0,t.jsxDEV)(U,{children:(0,t.jsxDEV)(S,{"data-testid":`us-manage-${n.id}`,onClick:a(()=>{f(n.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:i("Manage")},void 0,!1)},void 0,!1)]},n.id,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),v!==null&&(0,t.jsxDEV)(Re,{capabilities:C,onChanged:x,onClose:a(()=>{f(null)},"onClose"),user:v},void 0,!1),k&&(0,t.jsxDEV)(ke,{onClose:a(()=>{I(!1)},"onClose"),onCreated:x},void 0,!1)]},void 0,!0)},"UsersPanel");export{We as UsersPanel};
@@ -0,0 +1 @@
1
+ import{a as _}from"./chunk-3OA7PECS.js";import{a as n,e as E,f as S}from"./chunk-RRCPZMC2.js";var u=E(_(),1),o="base-ui-disable-scrollbar",d={className:o,getElement(t){return(0,u.jsx)("style",{nonce:t,href:o,precedence:"base-ui:low",children:`.${o}{scrollbar-width:none}.${o}::-webkit-scrollbar{display:none}`})}};d.getElement.displayName="styleDisableScrollbar.getElement";var s=E(S(),1);var p=s.createContext(void 0);p.displayName="CSPContext";var N={disableStyleElements:!1};function C(){return s.useContext(p)??N}n(C,"useCSPContext");function f(t,e=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER){return Math.max(e,Math.min(t,r))}n(f,"clamp");var m=1;function h(t,e){return Math.max(0,t-e)}n(h,"getMaxScrollOffset");function O(t,e){if(e<=0)return 0;let r=f(t,0,e),c=r,l=e-r,a=c<=m,i=l<=m;return a&&i?c<=l?0:e:a?0:i?e:r}n(O,"normalizeScrollOffset");export{d as a,C as b,f as c,m as d,h as e,O as f};
@@ -0,0 +1 @@
1
+ import{a as dt,b as nt,c as ct,d as ut,e as Me}from"./chunk-ASLGNHAX.js";import{a as ft,b as mt,c as vt,d as ht,e as gt}from"./chunk-N4JI6VQD.js";import"./chunk-DWDILV2E.js";import"./chunk-6VTGE3WJ.js";import{e as it}from"./chunk-TQ36RWOP.js";import"./chunk-UGMRUEBU.js";import{a as ot}from"./chunk-7RYIQKZA.js";import"./chunk-NNISYDNI.js";import"./chunk-5OIBXYZM.js";import"./chunk-FQKNJSRA.js";import"./chunk-BJGBHGK3.js";import"./chunk-UII66UVF.js";import{a as rt}from"./chunk-2K47A3P6.js";import"./chunk-KEGAWN6Y.js";import{a as st,b as lt,c as at,d as je,e as $e,f as Te}from"./chunk-GTM65MVX.js";import"./chunk-4QHKBC77.js";import{a as tt}from"./chunk-RMYA7NAH.js";import{a as Ze,b as et}from"./chunk-TBMYIZIO.js";import"./chunk-BHTPZS7L.js";import{c as Oe}from"./chunk-YQQJ4N6U.js";import"./chunk-TICVNLPM.js";import"./chunk-HV7G6DFP.js";import{a as Pe}from"./chunk-AQGOX5DK.js";import{b as Ye}from"./chunk-FCR3HKFV.js";import{a as B,b as Re,c as _e,d as Ve,e as P}from"./chunk-SEU5V7I6.js";import{b as Ke}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import{f as Ue}from"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as Qe,e as Ge,f as Je,g as We,i as Xe,k as Ae}from"./chunk-YJGANMU7.js";import{a as n,e as Be,f as pt,g as xt,h as bt}from"./chunk-RRCPZMC2.js";var Le=Be(xt(),1);var v=Be(pt(),1);var t=Be(bt(),1);var ze=n(l=>l>=100?"critical":l>=50?"warning":"good","performanceLevel"),He=n(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"formatLatency"),Ee=n(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"formatCount"),Nt=n(l=>{let e=(0,Le.c)(3),{level:s}=l;if(s==="critical"){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)(Ke,{variant:"destructive",children:"Slow"},void 0,!1),e[0]=i):i=e[0],i}if(s==="warning"){let i;return e[1]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"},void 0,!1),e[1]=i):i=e[1],i}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsxDEV)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"},void 0,!1),e[2]=r):r=e[2],r},"PerformanceBadge"),yt=n(l=>{let e=(0,Le.c)(152),{queryStats:s}=l,r=Qe(),[i,Q]=(0,v.useState)("totalTime"),C;e[0]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[0]=C):C=e[0];let[h,T]=(0,v.useState)(C),p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=n(o=>{o!==null&&Q(o)},"t2"),e[1]=p):p=e[1];let S=p,u;if(e[2]!==s||e[3]!==i){u=[...s];let o;e[5]!==i?(o=n((m,c)=>{switch(i){case"avgTime":return c.avgDurationMs-m.avgDurationMs;case"execCount":return c.execCount-m.execCount;case"rowsRead":return c.rowsRead-m.rowsRead;default:return c.totalDurationMs-m.totalDurationMs}},"t310"),e[5]=i,e[6]=o):o=e[6],u.sort(o),e[2]=s,e[3]=i,e[4]=u}else u=e[4];let g=u,$;e[7]!==s?($=s.filter(St),e[7]=s,e[8]=$):$=e[8];let j=$.length,H;e[9]!==s?(H=s.filter(wt),e[9]=s,e[10]=H):H=e[10];let d=H.length,_;e[11]!==s?(_=s.filter(qt),e[11]=s,e[12]=_):_=e[12];let U=_.length,O;e[13]===Symbol.for("react.memo_cache_sentinel")?(O=n(o=>{T(m=>{let c=new Set(m);return c.has(o)?c.delete(o):c.add(o),c})},"t6"),e[13]=O):O=e[13];let Fe=O;if(s.length===0){let o;e[14]!==r?(o=r("No query insights yet"),e[14]=r,e[15]=o):o=e[15];let m;e[16]!==o?(m=(0,t.jsxDEV)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:o},void 0,!1),e[16]=o,e[17]=m):m=e[17];let c;e[18]!==r?(c=r("Query insights appear once statements are executed against this shard."),e[18]=r,e[19]=c):c=e[19];let z;e[20]!==c?(z=(0,t.jsxDEV)("p",{className:"mt-1 text-sm",children:c},void 0,!1),e[20]=c,e[21]=z):z=e[21];let ke;return e[22]!==z||e[23]!==m?(ke=(0,t.jsxDEV)(B,{children:(0,t.jsxDEV)(P,{className:"py-12",children:(0,t.jsxDEV)("div",{className:"text-center text-muted-foreground",children:[m,z]},void 0,!0)},void 0,!1)},void 0,!1),e[22]=z,e[23]=m,e[24]=ke):ke=e[24],ke}let I;e[25]!==r?(I=r("Critical queries"),e[25]=r,e[26]=I):I=e[26];let f;e[27]!==I?(f=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:I},void 0,!1)},void 0,!1),e[27]=I,e[28]=f):f=e[28];let M;e[29]!==j?(M=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:j},void 0,!1),e[29]=j,e[30]=M):M=e[30];let D;e[31]!==r?(D=r(">100ms avg execution"),e[31]=r,e[32]=D):D=e[32];let R;e[33]!==D?(R=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:D},void 0,!1),e[33]=D,e[34]=R):R=e[34];let F;e[35]!==R||e[36]!==M?(F=(0,t.jsxDEV)(P,{children:[M,R]},void 0,!0),e[35]=R,e[36]=M,e[37]=F):F=e[37];let b;e[38]!==F||e[39]!==f?(b=(0,t.jsxDEV)(B,{children:[f,F]},void 0,!0),e[38]=F,e[39]=f,e[40]=b):b=e[40];let N;e[41]!==r?(N=r("Moderate queries"),e[41]=r,e[42]=N):N=e[42];let k;e[43]!==N?(k=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:N},void 0,!1)},void 0,!1),e[43]=N,e[44]=k):k=e[44];let A;e[45]!==d?(A=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:d},void 0,!1),e[45]=d,e[46]=A):A=e[46];let E;e[47]!==r?(E=r("50\u2013100ms avg execution"),e[47]=r,e[48]=E):E=e[48];let L;e[49]!==E?(L=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:E},void 0,!1),e[49]=E,e[50]=L):L=e[50];let a;e[51]!==A||e[52]!==L?(a=(0,t.jsxDEV)(P,{children:[A,L]},void 0,!0),e[51]=A,e[52]=L,e[53]=a):a=e[53];let w;e[54]!==k||e[55]!==a?(w=(0,t.jsxDEV)(B,{children:[k,a]},void 0,!0),e[54]=k,e[55]=a,e[56]=w):w=e[56];let x;e[57]!==r?(x=r("Fast queries"),e[57]=r,e[58]=x):x=e[58];let y;e[59]!==x?(y=(0,t.jsxDEV)(Re,{className:"pb-2",children:(0,t.jsxDEV)(_e,{className:"text-sm font-medium",children:x},void 0,!1)},void 0,!1),e[59]=x,e[60]=y):y=e[60];let K;e[61]!==U?(K=(0,t.jsxDEV)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:U},void 0,!1),e[61]=U,e[62]=K):K=e[62];let V;e[63]!==r?(V=r("<50ms avg execution"),e[63]=r,e[64]=V):V=e[64];let G;e[65]!==V?(G=(0,t.jsxDEV)("p",{className:"text-xs text-muted-foreground",children:V},void 0,!1),e[65]=V,e[66]=G):G=e[66];let J;e[67]!==K||e[68]!==G?(J=(0,t.jsxDEV)(P,{children:[K,G]},void 0,!0),e[67]=K,e[68]=G,e[69]=J):J=e[69];let W;e[70]!==y||e[71]!==J?(W=(0,t.jsxDEV)(B,{children:[y,J]},void 0,!0),e[70]=y,e[71]=J,e[72]=W):W=e[72];let X;e[73]!==b||e[74]!==w||e[75]!==W?(X=(0,t.jsxDEV)("div",{className:"grid gap-4 md:grid-cols-3",children:[b,w,W]},void 0,!0),e[73]=b,e[74]=w,e[75]=W,e[76]=X):X=e[76];let Y;e[77]!==r?(Y=r("Query leaderboard"),e[77]=r,e[78]=Y):Y=e[78];let Z;e[79]!==Y?(Z=(0,t.jsxDEV)("h3",{className:"text-lg font-semibold",children:Y},void 0,!1),e[79]=Y,e[80]=Z):Z=e[80];let ee;e[81]!==i||e[82]!==r?(ee=r("Slow queries sorted by {sortField}",{sortField:r(i)}),e[81]=i,e[82]=r,e[83]=ee):ee=e[83];let te;e[84]!==ee?(te=(0,t.jsxDEV)("p",{className:"text-sm text-muted-foreground",children:ee},void 0,!1),e[84]=ee,e[85]=te):te=e[85];let re;e[86]!==Z||e[87]!==te?(re=(0,t.jsxDEV)("div",{children:[Z,te]},void 0,!0),e[86]=Z,e[87]=te,e[88]=re):re=e[88];let se;e[89]!==r?(se=r("Sort by"),e[89]=r,e[90]=se):se=e[90];let le;e[91]!==se?(le=(0,t.jsxDEV)("span",{className:"text-sm text-muted-foreground",children:se},void 0,!1),e[91]=se,e[92]=le):le=e[92];let ae;e[93]!==r?(ae=r("Sort queries by"),e[93]=r,e[94]=ae):ae=e[94];let Ie;e[95]===Symbol.for("react.memo_cache_sentinel")?(Ie=(0,t.jsxDEV)(nt,{},void 0,!1),e[95]=Ie):Ie=e[95];let ie;e[96]!==ae?(ie=(0,t.jsxDEV)(ct,{"aria-label":ae,className:"w-[140px]","data-testid":"qi-sort",children:Ie},void 0,!1),e[96]=ae,e[97]=ie):ie=e[97];let oe;e[98]!==r?(oe=r("Total time"),e[98]=r,e[99]=oe):oe=e[99];let de;e[100]!==oe?(de=(0,t.jsxDEV)(Me,{value:"totalTime",children:oe},void 0,!1),e[100]=oe,e[101]=de):de=e[101];let ne;e[102]!==r?(ne=r("Avg time"),e[102]=r,e[103]=ne):ne=e[103];let ce;e[104]!==ne?(ce=(0,t.jsxDEV)(Me,{value:"avgTime",children:ne},void 0,!1),e[104]=ne,e[105]=ce):ce=e[105];let ue;e[106]!==r?(ue=r("Execution count"),e[106]=r,e[107]=ue):ue=e[107];let fe;e[108]!==ue?(fe=(0,t.jsxDEV)(Me,{value:"execCount",children:ue},void 0,!1),e[108]=ue,e[109]=fe):fe=e[109];let me;e[110]!==r?(me=r("Rows read"),e[110]=r,e[111]=me):me=e[111];let ve;e[112]!==me?(ve=(0,t.jsxDEV)(Me,{value:"rowsRead",children:me},void 0,!1),e[112]=me,e[113]=ve):ve=e[113];let he;e[114]!==de||e[115]!==ce||e[116]!==fe||e[117]!==ve?(he=(0,t.jsxDEV)(ut,{children:[de,ce,fe,ve]},void 0,!0),e[114]=de,e[115]=ce,e[116]=fe,e[117]=ve,e[118]=he):he=e[118];let ge;e[119]!==i||e[120]!==ie||e[121]!==he?(ge=(0,t.jsxDEV)(dt,{onValueChange:S,value:i,children:[ie,he]},void 0,!0),e[119]=i,e[120]=ie,e[121]=he,e[122]=ge):ge=e[122];let pe;e[123]!==le||e[124]!==ge?(pe=(0,t.jsxDEV)("div",{className:"flex items-center gap-2",children:[le,ge]},void 0,!0),e[123]=le,e[124]=ge,e[125]=pe):pe=e[125];let xe;e[126]!==re||e[127]!==pe?(xe=(0,t.jsxDEV)("div",{className:"flex items-center justify-between",children:[re,pe]},void 0,!0),e[126]=re,e[127]=pe,e[128]=xe):xe=e[128];let be;e[129]!==r?(be=r("Statements"),e[129]=r,e[130]=be):be=e[130];let Ne;e[131]!==be?(Ne=(0,t.jsxDEV)(_e,{children:be},void 0,!1),e[131]=be,e[132]=Ne):Ne=e[132];let ye;e[133]!==g.length||e[134]!==r?(ye=r("{count} tracked statements",{count:g.length}),e[133]=g.length,e[134]=r,e[135]=ye):ye=e[135];let Se;e[136]!==ye?(Se=(0,t.jsxDEV)(Ve,{children:ye},void 0,!1),e[136]=ye,e[137]=Se):Se=e[137];let we;e[138]!==Ne||e[139]!==Se?(we=(0,t.jsxDEV)(Re,{children:[Ne,Se]},void 0,!0),e[138]=Ne,e[139]=Se,e[140]=we):we=e[140];let qe;e[141]!==h||e[142]!==g||e[143]!==r?(qe=(0,t.jsxDEV)(P,{children:(0,t.jsxDEV)("div",{className:"space-y-2",children:g.map(o=>{let m=o.normalizedSql,c=h.has(m),z=ze(o.avgDurationMs);return(0,t.jsxDEV)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxDEV)("button",{"aria-expanded":c,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:n(()=>{Fe(m)},"onClick"),type:"button",children:[(0,t.jsxDEV)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsxDEV)(Nt,{level:z},void 0,!1),(0,t.jsxDEV)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.totalDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("total")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:He(o.avgDurationMs)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("avg")},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"text-right",children:[(0,t.jsxDEV)("div",{className:"text-sm font-medium",children:Ee(o.execCount)},void 0,!1),(0,t.jsxDEV)("div",{className:"text-xs text-muted-foreground",children:r("calls")},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0),c&&(0,t.jsxDEV)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")},void 0,!1),(0,t.jsxDEV)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:o.normalizedSql},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Exec count")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.execCount)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Total time")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:He(o.totalDurationMs)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows read")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsRead)},void 0,!1)]},void 0,!0),(0,t.jsxDEV)("div",{children:[(0,t.jsxDEV)("span",{className:"text-muted-foreground",children:r("Rows written")},void 0,!1),(0,t.jsxDEV)("span",{className:"block font-medium tabular-nums",children:Ee(o.rowsWritten)},void 0,!1)]},void 0,!0)]},void 0,!0)]},void 0,!0)]},m,!0)})},void 0,!1)},void 0,!1),e[141]=h,e[142]=g,e[143]=r,e[144]=qe):qe=e[144];let Ce;e[145]!==we||e[146]!==qe?(Ce=(0,t.jsxDEV)(B,{children:[we,qe]},void 0,!0),e[145]=we,e[146]=qe,e[147]=Ce):Ce=e[147];let De;return e[148]!==X||e[149]!==xe||e[150]!==Ce?(De=(0,t.jsxDEV)("div",{className:"space-y-4","data-testid":"qi-root",children:[X,xe,Ce]},void 0,!0),e[148]=X,e[149]=xe,e[150]=Ce,e[151]=De):De=e[151],De},"QueryInsights");function St(l){return ze(l.avgDurationMs)==="critical"}n(St,"_temp");function wt(l){return ze(l.avgDurationMs)==="warning"}n(wt,"_temp2");function qt(l){return ze(l.avgDurationMs)==="good"}n(qt,"_temp3");var Ct=Ge(Pe.getMetrics),Tt=n(l=>{let e=Math.floor(l/1e3),s=Math.floor(e/3600),r=Math.floor(e%3600/60),i=e%60;return s>0?`${s.toString()}h ${r.toString()}m`:r>0?`${r.toString()}m ${i.toString()}s`:`${i.toString()}s`},"formatDuration"),Rt=n((l,e)=>l?e:"overview","resolveTab"),_t=n((l,e)=>{let s=l+e;return s===0?"\u2014":`${(l/s*100).toFixed(1)}%`},"hitRate"),q=n(l=>{let e=(0,Le.c)(16),{chart:s,footer:r,label:i,testId:Q,value:C}=l,h;e[0]!==i?(h=(0,t.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i},void 0,!1),e[0]=i,e[1]=h):h=e[1];let T;e[2]!==Q||e[3]!==C?(T=(0,t.jsxDEV)("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":Q,children:C},void 0,!1),e[2]=Q,e[3]=C,e[4]=T):T=e[4];let p;e[5]!==s||e[6]!==T?(p=(0,t.jsxDEV)("div",{className:"flex items-center justify-between gap-3",children:[T,s]},void 0,!0),e[5]=s,e[6]=T,e[7]=p):p=e[7];let S;e[8]!==h||e[9]!==p?(S=(0,t.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[h,p]},void 0,!0),e[8]=h,e[9]=p,e[10]=S):S=e[10];let u;e[11]!==r?(u=r!=null&&(0,t.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:r},void 0,!1),e[11]=r,e[12]=u):u=e[12];let g;return e[13]!==S||e[14]!==u?(g=(0,t.jsxDEV)(B,{className:"justify-between gap-0 py-0",children:[S,u]},void 0,!0),e[13]=S,e[14]=u,e[15]=g):g=e[15],g},"StatCard"),Kt=n(({initialShardKey:l})=>{let e=Ue(),s=Qe(),[r,i]=(0,v.useState)(l??""),[Q,C]=(0,v.useState)("overview"),[h,T]=(0,v.useState)([]),p=(0,v.useRef)(null),S=(0,v.useRef)(null),u=(0,v.useRef)(!0);(0,v.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let g=rt(r.trim(),400),{data:$,error:j,liveError:H}=Ye(Pe.getMetrics,{},{live:!0,shardKey:g}),d=$??null;(0,v.useEffect)(()=>{if($===void 0)return;et(g);let a=$,w=p.current,x=S.current!==null&&S.current!==a.shard;if(S.current=a.shard,p.current=a.requests,x){T([]);return}w!==null&&a.requests>=w&&T(y=>[...y,a.requests-w].slice(-30))},[$,g]);let[_,U]=(0,v.useState)(null),[O,Fe]=(0,v.useState)(!1),I=n(async()=>{Fe(!0);let a=mt(r,Ze());try{let w=await Promise.all(a.map(async x=>{try{let y=await e.query(Ct,{},Je(x));return{error:null,metrics:y,shard:x===""?y.shard:x}}catch(y){return{error:We(y),metrics:null,shard:x===""?"__root__":x}}}));u.current&&U(w)}finally{u.current&&Fe(!1)}},"aggregateAll"),f=_===null?null:ft(_),M=d===null||d.requests===0?"\u2014":`${(d.errors/d.requests*100).toFixed(1)}%`,D=h.length>0?h.at(-1):0,R=d?vt(d):{p90:0,p95:0},F=n(a=>a<=0?"\u2014":a<1?`${(a*1e3).toFixed(0)}\u03BCs`:a<1e3?`${a.toFixed(1)}ms`:`${(a/1e3).toFixed(2)}s`,"formatMs"),b=(0,v.useMemo)(()=>{if(!d||!("queryStats"in d))return;let a=d.queryStats;if(!(!a||!Array.isArray(a)))return ht(a)},[d]),N=Rt(b!==void 0,Q),k=n(()=>{Xe(I())},"runAggregate"),A=n(()=>{U(null)},"clearAggregate"),E=n(()=>{C("overview")},"switchToOverview"),L=n(()=>{C("query-insights")},"switchToQueryInsights");return(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxDEV)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxDEV)(tt,{onChange:i,testId:"mt-shard-input",value:r},void 0,!1),(0,t.jsxDEV)(ot,{message:H,prefix:"mt"},void 0,!1),(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate",disabled:O,onClick:k,size:"sm",type:"button",variant:"secondary",children:s(O?"Aggregating\u2026":"All shards")},void 0,!1),_!==null&&(0,t.jsxDEV)(Oe,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")},void 0,!1),(0,t.jsxDEV)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:it,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")},void 0,!1)]},void 0,!0),j!==null&&(0,t.jsxDEV)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:j},void 0,!1),b!==void 0&&(0,t.jsxDEV)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:E,type:"button",children:s("Overview")},void 0,!1),(0,t.jsxDEV)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:L,type:"button",children:[s("Query insights"),b.length>0&&(0,t.jsxDEV)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:b.length},void 0,!1)]},void 0,!0)]},void 0,!0),N==="query-insights"&&b!==void 0&&(0,t.jsxDEV)(yt,{queryStats:b},void 0,!1),N==="overview"&&d!==null&&(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[(0,t.jsxDEV)(q,{chart:h.length>=2?(0,t.jsxDEV)(gt,{ariaLabel:s("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:h,testId:"mt-sparkline"},void 0,!1):void 0,footer:h.length>=2?(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)("span",{className:"font-semibold text-foreground",children:`+${D.toLocaleString()}`},void 0,!1)," ",s("last interval")]},void 0,!0):(0,t.jsxDEV)("span",{"data-testid":"mt-sparkline-empty",children:s("collecting samples\u2026")},void 0,!1),label:s("Requests"),testId:"mt-requests",value:d.requests},void 0,!1),(0,t.jsxDEV)(q,{footer:s("{rate} error rate",{rate:M}),label:s("Errors"),testId:"mt-errors",value:(0,t.jsxDEV)(t.Fragment,{children:[d.errors," (",M,")"]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(q,{footer:R.p90>0?`P90 ${F(R.p90)}`:void 0,label:s("P95 latency"),testId:"mt-p95",value:R.p95>0?F(R.p95):"\u2014"},void 0,!1),(0,t.jsxDEV)(q,{footer:d.cache===null?void 0:`${d.cache.entries.toLocaleString()} ${s("cache entries")}`,label:s("Database size"),testId:"mt-db-size",value:Ae(d.databaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Shard"),testId:"mt-shard",value:d.shard},void 0,!1),(0,t.jsxDEV)(q,{label:s("Uptime"),testId:"mt-uptime",value:Tt(d.uptimeMs)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Cache hit rate"),testId:"mt-cache",value:d.cache===null?s("no cache configured"):s("{rate} ({count} entries)",{count:d.cache.entries,rate:_t(d.cache.hits,d.cache.misses)})},void 0,!1)]},void 0,!0),N==="overview"&&d===null&&null,N==="overview"&&f!==null&&_!==null&&(0,t.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[(0,t.jsxDEV)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[(0,t.jsxDEV)(q,{label:s("Shards"),testId:"mt-agg-shards",value:f.failed>0?s("{reachable} reachable, {failed} unreachable",{failed:f.failed,reachable:f.reachable}):s("{reachable} reachable",{reachable:f.reachable})},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total requests"),testId:"mt-agg-requests",value:f.totalRequests},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total errors"),testId:"mt-agg-errors",value:f.totalErrors},void 0,!1),(0,t.jsxDEV)(q,{label:s("Total database size"),testId:"mt-agg-db-size",value:Ae(f.totalDatabaseSize)},void 0,!1),(0,t.jsxDEV)(q,{label:s("Combined cache hit rate"),testId:"mt-agg-cache",value:f.hitRate===null?s("no cache configured"):`${(f.hitRate*100).toFixed(1)}%`},void 0,!1)]},void 0,!0),(0,t.jsxDEV)(B,{className:"overflow-hidden py-0",children:(0,t.jsxDEV)(P,{className:"px-0",children:(0,t.jsxDEV)(st,{"data-testid":"mt-agg-table",children:[(0,t.jsxDEV)(lt,{children:(0,t.jsxDEV)(je,{children:[(0,t.jsxDEV)($e,{children:s("shard")},void 0,!1),(0,t.jsxDEV)($e,{children:s("requests")},void 0,!1),(0,t.jsxDEV)($e,{children:s("errors")},void 0,!1),(0,t.jsxDEV)($e,{children:s("db size")},void 0,!1)]},void 0,!0)},void 0,!1),(0,t.jsxDEV)(at,{children:_.map(a=>(0,t.jsxDEV)(je,{"data-testid":`mt-agg-row-${a.shard}`,children:[(0,t.jsxDEV)(Te,{children:a.shard},void 0,!1),a.metrics===null?(0,t.jsxDEV)(Te,{className:"text-destructive",colSpan:3,children:a.error??s("unreachable")},void 0,!1):(0,t.jsxDEV)(t.Fragment,{children:[(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.requests},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:a.metrics.errors},void 0,!1),(0,t.jsxDEV)(Te,{className:"tabular-nums",children:Ae(a.metrics.databaseSize)},void 0,!1)]},void 0,!0)]},a.shard,!0))},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"MetricsPanel");export{Kt as MetricsPanel};
@@ -0,0 +1 @@
1
+ import{a as C}from"./chunk-J6J54MBP.js";import{a as g,b as I,c as N,d as v,e as l,f as i}from"./chunk-GTM65MVX.js";import{a as x}from"./chunk-AQGOX5DK.js";import{a as E}from"./chunk-TAD43CG5.js";import{b as y}from"./chunk-FCR3HKFV.js";import{a as m,e as h}from"./chunk-SEU5V7I6.js";import{b as u}from"./chunk-O4PXDNR3.js";import"./chunk-ZH7UES4T.js";import"./chunk-KODWGUAB.js";import"./chunk-3OA7PECS.js";import{d as A,l as b}from"./chunk-YJGANMU7.js";import{a as c,e as w,h as j}from"./chunk-RRCPZMC2.js";var e=w(j(),1);var P=new Set(["active","trialing"]),Q=new Set(["past_due","unpaid"]),a=c((r,s)=>{if(r[s]!==void 0)return r[s];let n=r.__doc__;if(typeof n=="string")try{let o=JSON.parse(n);if(o!==null&&typeof o=="object"&&!Array.isArray(o))return o[s]}catch{}},"readField"),d=c(r=>typeof r=="string"?r:typeof r=="number"||typeof r=="bigint"||typeof r=="boolean"?String(r):"","text"),V=c(r=>P.has(r)?"default":Q.has(r)?"destructive":"outline","badgeVariant"),q=c(({limit:r=100})=>{let s=A(),n=y(x.readTablePage,{filters:[],limit:r,offset:0,orderBy:[],search:"",table:"subscriptions"}),o=y(x.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"});C(()=>{n.refetch(),o.refetch()},!0);let f=n.data?.rows??[],R=o.data?.rows??[],T=n.error??o.error,S=f.filter(t=>P.has(d(a(t,"state")))).length,B=R.toSorted((t,p)=>Number(a(p,"processedAt")??0)-Number(a(t,"processedAt")??0));return(0,e.jsxDEV)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsxDEV)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxDEV)(m,{className:"justify-between gap-0 py-0",children:[(0,e.jsxDEV)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Subscriptions")},void 0,!1),(0,e.jsxDEV)("div",{className:"flex items-center gap-2",children:[(0,e.jsxDEV)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:S},void 0,!1),(0,e.jsxDEV)(u,{variant:"default",children:s("{count} active",{count:S})},void 0,!1)]},void 0,!0)]},void 0,!0),(0,e.jsxDEV)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:s("{total} total",{total:f.length})},void 0,!1)]},void 0,!0)},void 0,!1),T===null?void 0:(0,e.jsxDEV)("p",{className:"text-sm text-destructive",children:T},void 0,!1),f.length===0&&!n.isLoading?(0,e.jsxDEV)(E,{testId:"payments-empty",title:s("No subscriptions yet")},void 0,!1):(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(g,{children:[(0,e.jsxDEV)(I,{children:(0,e.jsxDEV)(v,{children:[(0,e.jsxDEV)(l,{children:s("Provider")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Reference")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Plan")},void 0,!1),(0,e.jsxDEV)(l,{children:s("State")},void 0,!1),(0,e.jsxDEV)(l,{children:s("Renews")},void 0,!1)]},void 0,!0)},void 0,!1),(0,e.jsxDEV)(N,{children:f.map(t=>{let p=d(a(t,"state"));return(0,e.jsxDEV)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsxDEV)(i,{children:d(a(t,"provider"))},void 0,!1),(0,e.jsxDEV)(i,{children:d(a(t,"referenceId"))},void 0,!1),(0,e.jsxDEV)(i,{children:d(a(t,"priceId"))},void 0,!1),(0,e.jsxDEV)(i,{children:(0,e.jsxDEV)(u,{variant:V(p),children:p},void 0,!1)},void 0,!1),(0,e.jsxDEV)(i,{children:b(a(t,"currentPeriodEnd"))},void 0,!1)]},d(a(t,"providerSubscriptionId")),!0)})},void 0,!1)]},void 0,!0)},void 0,!1)},void 0,!1),(0,e.jsxDEV)(m,{className:"overflow-hidden py-0",children:[(0,e.jsxDEV)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsxDEV)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Recent webhook events")},void 0,!1)},void 0,!1),(0,e.jsxDEV)(h,{className:"px-0",children:(0,e.jsxDEV)(g,{children:(0,e.jsxDEV)(N,{children:B.map(t=>(0,e.jsxDEV)(v,{"data-testid":"payment-event-row",children:[(0,e.jsxDEV)(i,{children:d(a(t,"provider"))},void 0,!1),(0,e.jsxDEV)(i,{className:"font-medium",children:d(a(t,"type"))},void 0,!1),(0,e.jsxDEV)(i,{className:"text-muted-foreground",children:d(a(t,"providerEventId"))},void 0,!1),(0,e.jsxDEV)(i,{children:b(a(t,"processedAt"))},void 0,!1)]},d(a(t,"providerEventId")),!0))},void 0,!1)},void 0,!1)},void 0,!1)]},void 0,!0)]},void 0,!0)},"PaymentsPanel");export{q as PaymentsPanel};
@@ -0,0 +1 @@
1
+ import{b,c as v,d as g,f as D}from"./chunk-KODWGUAB.js";import{e as y,f as p,g as P,i as O}from"./chunk-YJGANMU7.js";import{a as n,e as Q,f as N,g as _}from"./chunk-RRCPZMC2.js";var S=Q(_(),1);var c=Q(N(),1);var C=n((e,r,t)=>["lunora-admin",e,r,t.trim()],"adminQueryKey"),h=1e3,q=25,E=new Map,k=n(e=>{let r=Date.now(),t=(E.get(e)??[]).filter(s=>r-s<h);t.push(r),E.set(e,t),t.length===q&&(console.error(`[lunora-studio] possible request loop: ${e} fired ${String(q)}\xD7 in <1s \u2014 a render/effect is re-issuing this read unbounded.`),console.trace("[lunora-studio] request-loop call site"))},"noteQueryFetch");function R(e,r,t={}){let{enabled:s=!0,keepPreviousData:a=!1,staleTime:i=0}=t,o=g({enabled:s,queryFn:n(()=>(k(JSON.stringify(e)),r()),"trackedQueryFunction"),placeholderData:a?b:void 0,queryKey:e,staleTime:i});return{data:o.data,error:o.error?P(o.error):o.error,isLoading:o.isLoading,liveError:void 0,refetch:n(()=>{O(o.refetch())},"refetch")}}n(R,"useClientQuery");function K(e,r,t={}){let s=D(),a=v(),{enabled:i=!0,keepPreviousData:u=!1,live:o=!1,shardKey:l="",staleTime:I}=t,d=C(e,r,l),L=R(d,()=>s.query(y(e),r,p(l)),{enabled:i,keepPreviousData:u,staleTime:I??(o?Number.POSITIVE_INFINITY:0)}),[T,f]=(0,c.useState)(void 0),F=JSON.stringify(d);return(0,c.useEffect)(()=>{if(!(!i||!o))return f(void 0),s.subscribe(y(e),r,m=>{f(void 0),a.setQueryData(d,m)},{...p(l),onError:n(m=>{f(m.message)},"onError")})},[F,i,o]),{...L,liveError:i&&o?T:void 0}}n(K,"useAdminQuery");var M=n(()=>{let e=(0,S.c)(2),r=v(),t;return e[0]!==r?(t=n((s,a,i)=>{let u=a===void 0?["lunora-admin",s]:C(s,a,i??"");O(r.invalidateQueries({queryKey:u}))},"t0"),e[0]=r,e[1]=t):t=e[1],t},"useInvalidateAdmin");export{R as a,K as b,M as c};
@@ -0,0 +1,4 @@
1
+ import{a as H}from"./chunk-HV7G6DFP.js";import{a as f,e as D,f as B}from"./chunk-RRCPZMC2.js";function k(r,u,t){let e=new Array(r);return new Proxy(e,{get(s,n,i){if(typeof n=="string"){let o=n.charCodeAt(0);if(o>=48&&o<=57){let l=+n;if(Number.isInteger(l)&&l>=0&&l<r){let h=s[l];if(!h){let c=u[l*2];h=s[l]={index:l,key:t(l),start:c,size:u[l*2+1],end:c+u[l*2+1],lane:0}}return h}}if(n==="length")return r}return Reflect.get(s,n,i)}})}f(k,"createLazyMeasurementsView");function w(r,u,t){let e=t.initialDeps??[],s,n=!0;function i(){var o;let l=!!t.key&&!!((o=t.debug)!=null&&o.call(t)),h=0;l&&(h=Date.now());let c=r();if(!(c.length!==e.length||c.some((p,d)=>e[d]!==p)))return s;e=c;let a=0;if(l&&(a=Date.now()),s=u(...c),l){let p=Math.round((Date.now()-h)*100)/100,d=Math.round((Date.now()-a)*100)/100,E=d/16,v=f((g,b)=>{for(g=String(g);g.length<b;)g=" "+g;return g},"pad");console.info(`%c\u23F1 ${v(d,5)} /${v(p,5)} ms`,`
2
+ font-size: .6rem;
3
+ font-weight: bold;
4
+ color: hsl(${Math.max(0,Math.min(120-120*E,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(n&&t.skipInitialOnChange)&&t.onChange(s),n=!1,s}return f(i,"memoizedFunction"),i.updateDeps=o=>{e=o},i}f(w,"memo");function C(r,u){if(r===void 0)throw new Error(`Unexpected undefined${u?`: ${u}`:""}`);return r}f(C,"notUndefined");var W=f((r,u)=>Math.abs(r-u)<1.01,"approxEqual"),L=f((r,u,t)=>{let e;return function(...s){r.clearTimeout(e),e=r.setTimeout(()=>u.apply(this,s),t)}},"debounce");var I,A=f(()=>{if(I!==void 0)return I;if(typeof navigator>"u")return I=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return I=!0;let r=navigator.maxTouchPoints;return I=navigator.platform==="MacIntel"&&r!==void 0&&r>0},"isIOSWebKit");var V=f(r=>{let{offsetWidth:u,offsetHeight:t}=r;return{width:u,height:t}},"getRect"),J=f(r=>r,"defaultKeyExtractor"),q=f(r=>{let u=Math.max(r.startIndex-r.overscan,0),e=Math.min(r.endIndex+r.overscan,r.count-1)-u+1,s=new Array(e);for(let n=0;n<e;n++)s[n]=u+n;return s},"defaultRangeExtractor"),j=f((r,u)=>{let t=r.scrollElement;if(!t)return;let e=r.targetWindow;if(!e)return;let s=f(i=>{let{width:o,height:l}=i;u({width:Math.round(o),height:Math.round(l)})},"handler");if(s(V(t)),!e.ResizeObserver)return()=>{};let n=new e.ResizeObserver(i=>{let o=f(()=>{let l=i[0];if(l?.borderBoxSize){let h=l.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(V(t))},"run");r.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return n.observe(t,{box:"border-box"}),()=>{n.unobserve(t)}},"observeElementRect"),_={passive:!0};var U=typeof window>"u"?!0:"onscrollend"in window,X=f((r,u,t)=>{let e=r.scrollElement;if(!e)return;let s=r.targetWindow;if(!s)return;let n=r.options.useScrollendEvent&&U,i=0,o=n?null:L(s,()=>u(i,!1),r.options.isScrollingResetDelay),l=f(m=>()=>{i=t(e),o?.(),u(i,m)},"createHandler"),h=l(!0),c=l(!1);return e.addEventListener("scroll",h,_),n&&e.addEventListener("scrollend",c,_),()=>{e.removeEventListener("scroll",h),n&&e.removeEventListener("scrollend",c)}},"observeOffset"),N=f((r,u)=>X(r,u,t=>{let{horizontal:e,isRtl:s}=r.options;return e?t.scrollLeft*(s&&-1||1):t.scrollTop}),"observeElementOffset");var Y=f((r,u,t)=>{if(t.options.useCachedMeasurements){let e=t.indexFromElement(r),s=t.options.getItemKey(e);return t.itemSizeCache.get(s)??t.options.estimateSize(e)}if(u?.borderBoxSize){let e=u.borderBoxSize[0];if(e)return Math.round(e[t.options.horizontal?"inlineSize":"blockSize"])}if(!u){let e=t.indexFromElement(r),s=t.options.getItemKey(e),n=t.itemSizeCache.get(s);if(n!==void 0)return n}return r[t.options.horizontal?"offsetWidth":"offsetHeight"]},"measureElement"),G=f((r,{adjustments:u=0,behavior:t},e)=>{var s,n;(n=(s=e.scrollElement)==null?void 0:s.scrollTo)==null||n.call(s,{[e.options.horizontal?"left":"top"]:r+u,behavior:t})},"scrollWithAdjustments");var K=G,T=class{static{f(this,"Virtualizer")}constructor(u){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var t,e,s;return((s=(e=(t=this.targetWindow)==null?void 0:t.performance)==null?void 0:e.now)==null?void 0:s.call(e))??Date.now()},this.observer=(()=>{let t=null,e=f(()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(s=>{s.forEach(n=>{let i=f(()=>{let o=n.target,l=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);for(let[h,c]of this.elementsCache)if(c===o){this.elementsCache.delete(h);break}return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(o,n,this))},"run");this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})})),"get");return{disconnect:f(()=>{var s;(s=e())==null||s.disconnect(),t=null},"disconnect"),observe:f(s=>{var n;return(n=e())==null?void 0:n.observe(s,{box:"border-box"})},"observe"),unobserve:f(s=>{var n;return(n=e())==null?void 0:n.unobserve(s)},"unobserve")}})(),this.range=null,this.setOptions=t=>{var e,s;let n={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:J,rangeExtractor:q,onChange:f(()=>{},"onChange"),measureElement:Y,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,anchorTo:"start",followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:"estimate",useCachedMeasurements:!1};for(let a in t){let p=t[a];p!==void 0&&(n[a]=p)}let i=this.options,o=null,l=null,h=!1;if(i!==void 0&&i.enabled&&n.enabled&&n.anchorTo==="end"&&this.scrollElement!==null){let a=i.count,p=n.count,d=this.getMeasurements(),E=a>0?((e=d[0])==null?void 0:e.key)??i.getItemKey(0):null,v=a>0?((s=d[a-1])==null?void 0:s.key)??i.getItemKey(a-1):null;if(p!==a||a>0&&p>0&&(n.getItemKey(0)!==E||n.getItemKey(p-1)!==v)){h=!0;let S=a>0?this.getVirtualItemForOffset(this.getScrollOffset())??d[0]:null;S&&(o=[S.key,this.getScrollOffset()-S.start]);let x=n.followOnAppend===!0?"auto":n.followOnAppend||null;x&&p>a&&this.isAtEnd(i.scrollEndThreshold)&&(a===0||n.getItemKey(p-1)!==v)&&(l=x)}}this.options=n,h&&(this.pendingMin=0,this.itemSizeCacheVersion++);let c=!1,m=0;if(o&&this.scrollOffset!==null){let[a,p]=o,d=this.getMeasurements(),{count:E,getItemKey:v}=this.options,g=0;for(;g<E&&v(g)!==a;)g++;if(g<E){let b=d[g];if(b){let S=b.start+p;S!==this.scrollOffset&&(m=S-this.scrollOffset,this.scrollOffset=S,c=!0)}}}(c||l)&&(this.pendingScrollAnchor=[c?o[0]:null,c?o[1]:0,l,m])},this.notify=t=>{var e,s;(s=(e=this.options).onChange)==null||s.call(e,this,t)},this.maybeNotify=w(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:"maybeNotify",debug:f(()=>this.options.debug,"debug"),initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,i)=>{i&&this._intendedScrollOffset===null&&n===this.scrollOffset||(this._intendedScrollOffset!==null&&Math.abs(n-this._intendedScrollOffset)<1.5&&(n=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=i,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify())})),"addEventListener"in this.scrollElement){let n=this.scrollElement,i=f(()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},"onTouchStart"),o=f(()=>{this._iosTouching=!1,!(!A()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))},"onTouchEnd");n.addEventListener("touchstart",i,_),n.addEventListener("touchend",o,_),this.unsubs.push(()=>{n.removeEventListener("touchstart",i),n.removeEventListener("touchend",o),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let s=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,s&&this.scrollElement&&this.options.enabled){let[n,i,o,l]=s;n!==null&&!o&&(A()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?l!==0&&(this._iosDeferredAdjustment+=l):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),o&&this.scrollToEnd({behavior:o})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let t=this.getScrollOffset(),e=this.getMaxScrollOffset();if(t<0||t>e)return;let s=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(t,{adjustments:this.scrollAdjustments+=s,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,e)=>{let s=new Map,n=new Map;for(let i=e-1;i>=0;i--){let o=t[i];if(s.has(o.lane))continue;let l=n.get(o.lane);if(l==null||o.end>l.end?n.set(o.lane,o):o.end<l.end&&s.set(o.lane,!0),s.size===this.options.lanes)break}return n.size===this.options.lanes?Array.from(n.values()).sort((i,o)=>i.end===o.end?i.index-o.index:i.end-o.end)[0]:void 0},this.getMeasurementOptions=w(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(t,e,s,n,i,o,l)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMin=null,{count:t,paddingStart:e,scrollMargin:s,getItemKey:n,enabled:i,lanes:o,laneAssignmentMode:l}),{key:!1}),this.getMeasurements=w(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:t,paddingStart:e,scrollMargin:s,getItemKey:n,enabled:i,lanes:o,laneAssignmentMode:l},h)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(let d of this.laneAssignments.keys())d>=t&&this.laneAssignments.delete(d);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));let m=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1),o===1){let d=this.options.gap,E=t*2,v=this._flatMeasurements;if(!v||v.length<E){let S=new Float64Array(E);v&&m>0&&S.set(v.subarray(0,m*2)),v=S,this._flatMeasurements=v}let g;if(m===0)g=e+s;else{let S=m-1;g=v[S*2]+v[S*2+1]+d}for(let S=m;S<t;S++){let x=n(S),y=c.get(x),M=typeof y=="number"?y:this.options.estimateSize(S);v[S*2]=g,v[S*2+1]=M,g+=M+d}let b=k(t,v,n);return this.measurementsCache=b,b}let a=this.measurementsCache.slice(0,m),p=new Array(o).fill(void 0);for(let d=0;d<m;d++){let E=a[d];E&&(p[E.lane]=d)}for(let d=m;d<t;d++){let E=n(d),v=this.laneAssignments.get(d),g,b,S=l==="estimate"||c.has(E);if(v!==void 0&&this.options.lanes>1){g=v;let z=p[g],F=z!==void 0?a[z]:void 0;b=F?F.end+this.options.gap:e+s}else{let z=this.options.lanes===1?a[d-1]:this.getFurthestMeasurement(a,d);b=z?z.end+this.options.gap:e+s,g=z?z.lane:d%this.options.lanes,this.options.lanes>1&&S&&this.laneAssignments.set(d,g)}let x=c.get(E),y=typeof x=="number"?x:this.options.estimateSize(d),M=b+y;a[d]={index:d,start:b,size:y,end:M,key:E,lane:g},p[g]=d}return this.measurementsCache=a,a},{key:"getMeasurements",debug:f(()=>this.options.debug,"debug")}),this.calculateRange=w(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,e,s,n)=>this.range=t.length>0&&e>0?Q({measurements:t,outerSize:e,scrollOffset:s,lanes:n,flat:n===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:"calculateRange",debug:f(()=>this.options.debug,"debug")}),this.getVirtualIndexes=w(()=>{let t=null,e=null,s=this.calculateRange();return s&&(t=s.startIndex,e=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,e]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,e]},(t,e,s,n,i)=>n===null||i===null?[]:t({startIndex:n,endIndex:i,overscan:e,count:s}),{key:"getVirtualIndexes",debug:f(()=>this.options.debug,"debug")}),this.indexFromElement=t=>{let e=this.options.indexAttribute,s=t.getAttribute(e);return s?parseInt(s,10):(console.warn(`Missing attribute name '${e}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=t=>{var e;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let s=this.scrollState.index??((e=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:e.index);if(s!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,s-n),o=Math.min(this.options.count-1,s+n);return t>=i&&t<=o}return!0},this.measureElement=t=>{if(!t){this.elementsCache.forEach((i,o)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(o))});return}let e=this.indexFromElement(t),s=this.options.getItemKey(e),n=this.elementsCache.get(s);n!==t&&(n&&this.observer.unobserve(n),this.observer.observe(t),this.elementsCache.set(s,t)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(e)&&this.resizeItem(e,this.options.measureElement(t,void 0,this))},this.resizeItem=(t,e)=>{var s,n;if(t<0||t>=this.options.count)return;let i,o,l,h=this._flatMeasurements;if(this.options.lanes===1&&h!==null)l=this.options.getItemKey(t),o=h[t*2],i=h[t*2+1];else{let a=this.measurementsCache[t];if(!a)return;l=a.key,o=a.start,i=a.size}let c=this.itemSizeCache.get(l)??i,m=e-c;if(m!==0){let a=this.options.anchorTo==="end"&&((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,p=a?this.getTotalSize():0,d=((n=this.scrollState)==null?void 0:n.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[t]??{index:t,key:l,start:o,size:i,end:o+i,lane:0},m,this):o<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(l)||this.scrollDirection!=="backward"));(this.pendingMin===null||t<this.pendingMin)&&(this.pendingMin=t),this.itemSizeCache.set(l,e),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-p):d&&this.applyScrollAdjustment(m),this.notify(!1)}},this.getVirtualItems=w(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,e)=>{let s=[];for(let n=0,i=t.length;n<i;n++){let o=t[n],l=e[o];s.push(l)}return s},{key:"getVirtualItems",debug:f(()=>this.options.debug,"debug")}),this.getVirtualItemForOffset=t=>{let e=this.getMeasurements();if(e.length===0)return;let s=this._flatMeasurements,n=this.options.lanes===1&&s!=null,i=P(0,e.length-1,n?o=>s[o*2]:o=>C(e[o]).start,t);return C(e[i])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(t=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=t,this.getOffsetForAlignment=(t,e,s=0)=>{if(!this.scrollElement)return 0;let n=this.getSize(),i=this.getScrollOffset();e==="auto"&&(e=t>=i+n?"end":"start"),e==="center"?t+=(s-n)/2:e==="end"&&(t-=n);let o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,e="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));let s=this.getSize(),n=this.getScrollOffset(),i=this.measurementsCache[t];if(!i)return;if(e==="auto")if(i.end>=n+s-this.options.scrollPaddingEnd)e="end";else if(i.start<=n+this.options.scrollPaddingStart)e="start";else return[n,e];if(e==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),e];let o=e==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,e,i.size),e]},this.scrollToOffset=(t,{align:e="start",behavior:s="auto"}={})=>{let n=this.getOffsetForAlignment(t,e),i=this.now();this.scrollState={index:null,align:e,behavior:s,startedAt:i,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(t,{align:e="auto",behavior:s="auto"}={})=>{t=Math.max(0,Math.min(t,this.options.count-1));let n=this.getOffsetForIndex(t,e);if(!n)return;let[i,o]=n,l=this.now();this.scrollState={index:t,align:o,behavior:s,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(t,{behavior:e="auto"}={})=>{let s=this.getScrollOffset()+t,n=this.now();this.scrollState={index:null,align:"start",behavior:e,startedAt:n,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:e}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:t="auto"}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:"end",behavior:t});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:t})},this.getTotalSize=()=>{var t;let e=this.getMeasurements(),s;if(e.length===0)s=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,i=this._flatMeasurements;i!=null?s=i[n*2]+i[n*2+1]:s=((t=e[n])==null?void 0:t.end)??0}else{let n=Array(this.options.lanes).fill(null),i=e.length-1;for(;i>=0&&n.some(o=>o===null);){let o=e[i];n[o.lane]===null&&(n[o.lane]=o.end),i--}s=Math.max(...n.filter(o=>o!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let t=[];if(this.itemSizeCache.size===0)return t;let e=this.getMeasurements();for(let s of e)s&&this.itemSizeCache.has(s.key)&&t.push({index:s.index,key:s.key,start:s.start,size:s.size,end:s.end,lane:s.lane});return t},this._scrollToOffset=(t,{adjustments:e,behavior:s})=>{this._intendedScrollOffset=t+(e??0),this.options.scrollToFn(t,{behavior:s,adjustments:e},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(u)}applyScrollAdjustment(u,t){u!==0&&(this.options.debug&&console.info("correction",u),A()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=u:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=u,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=e?e[0]:this.scrollState.lastTargetOffset,n=1,i=s!==this.scrollState.lastTargetOffset;if(!i&&W(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=n){this.getScrollOffset()!==s&&this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,i){let o=this.getSize()||600,l=Math.abs(s-this.getScrollOffset()),h=this.scrollState.behavior==="smooth"&&l>o;this.scrollState.lastTargetOffset=s,h||(this.scrollState.behavior="auto"),this._scrollToOffset(s,{adjustments:void 0,behavior:h?"smooth":"auto"})}this.scheduleScrollReconcile()}},P=f((r,u,t,e)=>{for(;r<=u;){let s=(r+u)/2|0,n=t(s);if(n<e)r=s+1;else if(n>e)u=s-1;else return s}return r>0?r-1:0},"findNearestBinarySearch");function Q({measurements:r,outerSize:u,scrollOffset:t,lanes:e,flat:s}){let n=r.length-1,i=s?c=>s[c*2]:c=>r[c].start,o=s?c=>s[c*2]+s[c*2+1]:c=>r[c].end;if(r.length<=e)return{startIndex:0,endIndex:n};let l=P(0,n,i,t),h=l;if(e===1)for(;h<n&&o(h)<t+u;)h++;else if(e>1){let c=Array(e).fill(0);for(;h<n&&c.some(a=>a<t+u);){let a=r[h];c[a.lane]=a.end,h++}let m=Array(e).fill(t+u);for(;l>=0&&m.some(a=>a>=t);){let a=r[l];m[a.lane]=a.start,l--}l=Math.max(0,l-l%e),h=Math.min(n,h+(e-1-h%e))}return{startIndex:l,endIndex:h}}f(Q,"calculateRange");var O=D(B(),1),$=D(H(),1);var R=typeof document<"u"?O.useLayoutEffect:O.useEffect;function Z({useFlushSync:r=!0,directDomUpdates:u=!1,directDomUpdatesMode:t="transform",...e}){let s=O.useReducer(h=>h+1,0)[1],n=O.useRef({enabled:u,mode:t,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});n.current.enabled=u,n.current.mode=t;let i=f(h=>{let c=n.current;if(!c.enabled||!c.container)return;let m=h.getTotalSize();if(m!==c.lastSize){c.lastSize=m;let g=h.options.horizontal?"width":"height";c.container.style[g]=`${m}px`}let a=!!h.options.horizontal,p=c.mode==="transform",d=a?"left":"top",E=h.options.scrollMargin,v=h.getVirtualItems();for(let g of v){let b=g.start-E,S=h.elementsCache.get(g.key);S&&c.lastPositions.get(S)!==b&&(c.lastPositions.set(S,b),p?S.style.transform=a?`translate3d(${b}px, 0, 0)`:`translate3d(0, ${b}px, 0)`:S.style[d]=`${b}px`)}},"applyDirectStyles"),o={...e,onChange:f((h,c)=>{var m;let a=n.current,p=!0;if(a.enabled){i(h);let d=h.range,E=a.prevRange;p=!E||E.isScrolling!==h.isScrolling||E.startIndex!==d?.startIndex||E.endIndex!==d?.endIndex,p&&(a.prevRange=d?{startIndex:d.startIndex,endIndex:d.endIndex,isScrolling:h.isScrolling}:null)}p&&(r&&c?(0,$.flushSync)(s):s()),(m=e.onChange)==null||m.call(e,h,c)},"onChange")},[l]=O.useState(()=>{let h=new T(o);return Object.assign(h,{containerRef:f(c=>{let m=n.current;if(m.container=c,m.lastSize=null,c&&m.enabled){let a=h.getTotalSize();m.lastSize=a;let p=h.options.horizontal?"width":"height";c.style[p]=`${a}px`}},"containerRef")})});return l.setOptions(o),R(()=>l._didMount(),[]),R(()=>l._willUpdate()),R(()=>{i(l)}),l}f(Z,"useVirtualizerBase");function dt(r){return Z({observeElementRect:j,observeElementOffset:N,scrollToFn:K,...r})}f(dt,"useVirtualizer");export{j as a,dt as b};