adonisjs-server-stats 1.10.0 → 1.10.3

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 (210) hide show
  1. package/README.md +23 -14
  2. package/dist/core/config-utils.d.ts +8 -0
  3. package/dist/core/constants.d.ts +4 -0
  4. package/dist/core/dashboard-data-controller.d.ts +16 -0
  5. package/dist/core/dashboard-data-helpers.d.ts +12 -0
  6. package/dist/core/debug-data-controller.d.ts +4 -0
  7. package/dist/core/define-config-helpers.d.ts +25 -0
  8. package/dist/core/feature-detect-helpers.d.ts +36 -0
  9. package/dist/core/formatters-helpers.d.ts +23 -0
  10. package/dist/core/index.js +594 -509
  11. package/dist/core/log-utils-helpers.d.ts +13 -0
  12. package/dist/core/metrics.d.ts +3 -28
  13. package/dist/core/pagination.d.ts +0 -9
  14. package/dist/core/server-stats-controller.d.ts +6 -0
  15. package/dist/core/transmit-helpers.d.ts +7 -0
  16. package/dist/core/types-dashboard.d.ts +178 -0
  17. package/dist/core/types-diagnostics.d.ts +85 -0
  18. package/dist/core/types.d.ts +10 -442
  19. package/dist/react/{CacheSection-UCMptWyn.js → CacheSection-baMZotSn.js} +2 -2
  20. package/dist/react/CacheTab-2cw_rMzj.js +117 -0
  21. package/dist/react/{ConfigSection-DfFd-WRq.js → ConfigSection-DGgqjAal.js} +1 -1
  22. package/dist/react/{ConfigTab-Bdg8YMer.js → ConfigTab-H3OnYqmK.js} +1 -1
  23. package/dist/react/CustomPaneTab-B6r7ha0u.js +98 -0
  24. package/dist/react/{EmailsSection-CM7stSyh.js → EmailsSection-C-UZISG-.js} +2 -2
  25. package/dist/react/EmailsTab-DbK4Eobn.js +139 -0
  26. package/dist/react/{EventsSection-ByQ-9blq.js → EventsSection-C7RQW_LY.js} +2 -2
  27. package/dist/react/EventsTab-CfVr7AiM.js +57 -0
  28. package/dist/react/{FilterBar-DQRXpWrb.js → FilterBar-CQ7bD669.js} +15 -15
  29. package/dist/react/{JobsSection-DF3qEv9O.js → JobsSection-CQHNK_Ls.js} +2 -2
  30. package/dist/react/{JobsTab-BbrBWIOb.js → JobsTab-znzf6jzk.js} +54 -42
  31. package/dist/react/{LogsSection-DcFTZY7b.js → LogsSection-Dmm3rE2B.js} +9 -3
  32. package/dist/react/LogsTab-D8unMV5P.js +108 -0
  33. package/dist/react/{OverviewSection-C4T1ur51.js → OverviewSection-ABP9ueBo.js} +1 -1
  34. package/dist/react/{QueriesSection-PswteoF9.js → QueriesSection-CnmSkznA.js} +2 -2
  35. package/dist/react/{QueriesTab-osLUWd4L.js → QueriesTab-BQzcxEiW.js} +37 -40
  36. package/dist/react/{RelatedLogs-DFDOyUMr.js → RelatedLogs-3A8RuGKH.js} +15 -3
  37. package/dist/react/{RequestsSection-Nag30rEA.js → RequestsSection-kW79_M7k.js} +3 -3
  38. package/dist/react/{RoutesSection-BUSkM6PY.js → RoutesSection-BRhxrtjZ.js} +2 -2
  39. package/dist/react/RoutesTab-CpYH5lUw.js +68 -0
  40. package/dist/react/{TimelineTab-Covg5weo.js → TimelineTab-DjLR35Ce.js} +47 -53
  41. package/dist/react/index-CsImORX6.js +1121 -0
  42. package/dist/react/index.js +1 -1
  43. package/dist/react/react/components/{Dashboard/shared → shared}/FilterBar.d.ts +4 -3
  44. package/dist/react/react/hooks/useDashboardData.d.ts +4 -8
  45. package/dist/react/style.css +1 -1
  46. package/dist/src/collectors/app_collector.d.ts +0 -8
  47. package/dist/src/collectors/app_collector.js +45 -52
  48. package/dist/src/collectors/auto_detect.d.ts +0 -23
  49. package/dist/src/collectors/auto_detect.js +33 -55
  50. package/dist/src/collectors/db_pool_collector.d.ts +14 -16
  51. package/dist/src/collectors/db_pool_collector.js +72 -57
  52. package/dist/src/collectors/log_collector.d.ts +0 -47
  53. package/dist/src/collectors/log_collector.js +36 -65
  54. package/dist/src/collectors/queue_collector.d.ts +0 -20
  55. package/dist/src/collectors/queue_collector.js +60 -76
  56. package/dist/src/collectors/redis_collector.d.ts +10 -10
  57. package/dist/src/collectors/redis_collector.js +69 -66
  58. package/dist/src/config/deprecation_migration.d.ts +7 -0
  59. package/dist/src/config/deprecation_migration.js +201 -0
  60. package/dist/src/controller/debug_controller.d.ts +1 -1
  61. package/dist/src/controller/debug_controller.js +87 -81
  62. package/dist/src/dashboard/cache_handlers.d.ts +14 -0
  63. package/dist/src/dashboard/cache_handlers.js +52 -0
  64. package/dist/src/dashboard/chart_aggregator.d.ts +0 -7
  65. package/dist/src/dashboard/chart_aggregator.js +68 -50
  66. package/dist/src/dashboard/coalesce_cache.d.ts +25 -0
  67. package/dist/src/dashboard/coalesce_cache.js +47 -0
  68. package/dist/src/dashboard/dashboard_controller.d.ts +11 -37
  69. package/dist/src/dashboard/dashboard_controller.js +51 -544
  70. package/dist/src/dashboard/dashboard_page_assets.d.ts +17 -0
  71. package/dist/src/dashboard/dashboard_page_assets.js +51 -0
  72. package/dist/src/dashboard/dashboard_store.d.ts +19 -218
  73. package/dist/src/dashboard/dashboard_store.js +115 -1116
  74. package/dist/src/dashboard/dashboard_types.d.ts +83 -0
  75. package/dist/src/dashboard/dashboard_types.js +4 -0
  76. package/dist/src/dashboard/detail_queries.d.ts +19 -0
  77. package/dist/src/dashboard/detail_queries.js +98 -0
  78. package/dist/src/dashboard/email_event_builder.d.ts +8 -0
  79. package/dist/src/dashboard/email_event_builder.js +65 -0
  80. package/dist/src/dashboard/explain_query.d.ts +8 -0
  81. package/dist/src/dashboard/explain_query.js +22 -0
  82. package/dist/src/dashboard/filter_handlers.d.ts +23 -0
  83. package/dist/src/dashboard/filter_handlers.js +56 -0
  84. package/dist/src/dashboard/filtered_queries.d.ts +15 -0
  85. package/dist/src/dashboard/filtered_queries.js +155 -0
  86. package/dist/src/dashboard/flush_manager.d.ts +25 -0
  87. package/dist/src/dashboard/flush_manager.js +107 -0
  88. package/dist/src/dashboard/format_helpers.d.ts +126 -0
  89. package/dist/src/dashboard/format_helpers.js +140 -0
  90. package/dist/src/dashboard/inspector_manager.d.ts +36 -0
  91. package/dist/src/dashboard/inspector_manager.js +102 -0
  92. package/dist/src/dashboard/integrations/config_inspector.js +11 -13
  93. package/dist/src/dashboard/integrations/queue_inspector.d.ts +3 -3
  94. package/dist/src/dashboard/integrations/queue_inspector.js +13 -10
  95. package/dist/src/dashboard/jobs_handlers.d.ts +14 -0
  96. package/dist/src/dashboard/jobs_handlers.js +61 -0
  97. package/dist/src/dashboard/knex_factory.d.ts +18 -0
  98. package/dist/src/dashboard/knex_factory.js +91 -0
  99. package/dist/src/dashboard/migrator.js +30 -159
  100. package/dist/src/dashboard/migrator_tables.d.ts +19 -0
  101. package/dist/src/dashboard/migrator_tables.js +153 -0
  102. package/dist/src/dashboard/overview_queries.d.ts +66 -0
  103. package/dist/src/dashboard/overview_queries.js +155 -0
  104. package/dist/src/dashboard/overview_query_runners.d.ts +25 -0
  105. package/dist/src/dashboard/overview_query_runners.js +84 -0
  106. package/dist/src/dashboard/overview_store_queries.d.ts +40 -0
  107. package/dist/src/dashboard/overview_store_queries.js +69 -0
  108. package/dist/src/dashboard/paginate_helper.d.ts +12 -0
  109. package/dist/src/dashboard/paginate_helper.js +33 -0
  110. package/dist/src/dashboard/query_explain_handler.d.ts +10 -0
  111. package/dist/src/dashboard/query_explain_handler.js +80 -0
  112. package/dist/src/dashboard/read_queries.d.ts +32 -0
  113. package/dist/src/dashboard/read_queries.js +107 -0
  114. package/dist/src/dashboard/saved_filter_queries.d.ts +10 -0
  115. package/dist/src/dashboard/saved_filter_queries.js +24 -0
  116. package/dist/src/dashboard/storage_stats.d.ts +41 -0
  117. package/dist/src/dashboard/storage_stats.js +81 -0
  118. package/dist/src/dashboard/write_queue.d.ts +106 -0
  119. package/dist/src/dashboard/write_queue.js +225 -0
  120. package/dist/src/data/data_access.d.ts +2 -39
  121. package/dist/src/data/data_access.js +17 -193
  122. package/dist/src/data/data_access_helpers.d.ts +130 -0
  123. package/dist/src/data/data_access_helpers.js +212 -0
  124. package/dist/src/debug/debug_store.js +37 -32
  125. package/dist/src/debug/email_collector.d.ts +1 -10
  126. package/dist/src/debug/email_collector.js +78 -81
  127. package/dist/src/debug/event_collector.d.ts +0 -9
  128. package/dist/src/debug/event_collector.js +79 -62
  129. package/dist/src/debug/query_collector.js +23 -19
  130. package/dist/src/debug/route_inspector.d.ts +1 -5
  131. package/dist/src/debug/route_inspector.js +50 -51
  132. package/dist/src/debug/trace_collector.d.ts +9 -1
  133. package/dist/src/debug/trace_collector.js +21 -15
  134. package/dist/src/debug/types.d.ts +1 -1
  135. package/dist/src/define_config.d.ts +0 -65
  136. package/dist/src/define_config.js +93 -333
  137. package/dist/src/edge/client/dashboard.js +2 -2
  138. package/dist/src/edge/client/debug-panel-deferred.js +1 -1
  139. package/dist/src/edge/client/stats-bar.js +1 -1
  140. package/dist/src/edge/client-vue/dashboard.js +5 -5
  141. package/dist/src/edge/client-vue/debug-panel-deferred.js +3 -3
  142. package/dist/src/edge/client-vue/stats-bar.js +3 -3
  143. package/dist/src/edge/plugin.d.ts +0 -16
  144. package/dist/src/edge/plugin.js +57 -64
  145. package/dist/src/engine/request_metrics.d.ts +1 -0
  146. package/dist/src/engine/request_metrics.js +32 -42
  147. package/dist/src/middleware/request_tracking_middleware.d.ts +2 -8
  148. package/dist/src/middleware/request_tracking_middleware.js +65 -93
  149. package/dist/src/provider/auth_middleware_detector.d.ts +16 -0
  150. package/dist/src/provider/auth_middleware_detector.js +97 -0
  151. package/dist/src/provider/boot_helpers.d.ts +20 -0
  152. package/dist/src/provider/boot_helpers.js +91 -0
  153. package/dist/src/provider/boot_initializer.d.ts +28 -0
  154. package/dist/src/provider/boot_initializer.js +35 -0
  155. package/dist/src/provider/dashboard_init.d.ts +30 -0
  156. package/dist/src/provider/dashboard_init.js +138 -0
  157. package/dist/src/provider/dashboard_setup.d.ts +25 -0
  158. package/dist/src/provider/dashboard_setup.js +78 -0
  159. package/dist/src/provider/diagnostics.d.ts +134 -0
  160. package/dist/src/provider/diagnostics.js +127 -0
  161. package/dist/src/provider/email_bridge.d.ts +43 -0
  162. package/dist/src/provider/email_bridge.js +80 -0
  163. package/dist/src/provider/email_helpers.d.ts +13 -0
  164. package/dist/src/provider/email_helpers.js +68 -0
  165. package/dist/src/provider/pino_hook.d.ts +17 -0
  166. package/dist/src/provider/pino_hook.js +35 -0
  167. package/dist/src/provider/provider_helpers_extra.d.ts +47 -0
  168. package/dist/src/provider/provider_helpers_extra.js +177 -0
  169. package/dist/src/provider/server_stats_provider.d.ts +39 -85
  170. package/dist/src/provider/server_stats_provider.js +132 -951
  171. package/dist/src/provider/shutdown_helpers.d.ts +43 -0
  172. package/dist/src/provider/shutdown_helpers.js +70 -0
  173. package/dist/src/provider/toolbar_setup.d.ts +57 -0
  174. package/dist/src/provider/toolbar_setup.js +141 -0
  175. package/dist/src/routes/dashboard_routes.d.ts +14 -0
  176. package/dist/src/routes/dashboard_routes.js +197 -0
  177. package/dist/src/routes/debug_routes.d.ts +14 -0
  178. package/dist/src/routes/debug_routes.js +101 -0
  179. package/dist/src/routes/register_routes.d.ts +0 -78
  180. package/dist/src/routes/register_routes.js +22 -352
  181. package/dist/src/routes/stats_routes.d.ts +5 -0
  182. package/dist/src/routes/stats_routes.js +14 -0
  183. package/dist/src/styles/components.css +96 -0
  184. package/dist/src/styles/dashboard.css +8 -90
  185. package/dist/src/styles/debug-panel.css +1 -31
  186. package/dist/src/types.d.ts +305 -14
  187. package/dist/vue/{CacheSection-oFAJL3mo.js → CacheSection-ITqvpfH5.js} +1 -1
  188. package/dist/vue/{ConfigSection-BhfJ4KqL.js → ConfigSection-DTn3GslE.js} +1 -1
  189. package/dist/vue/{EmailsSection-BcNyhyHs.js → EmailsSection-DtLJ4XoS.js} +1 -1
  190. package/dist/vue/{EventsSection-r60Q5Lmu.js → EventsSection-BOYYz0Ty.js} +1 -1
  191. package/dist/vue/{JobsSection-BHL-hkQw.js → JobsSection-BazTxcJL.js} +1 -1
  192. package/dist/vue/{LogsSection-DRMGzJmg.js → LogsSection-D55PjTKX.js} +9 -3
  193. package/dist/vue/{LogsTab-Bg3o0Mm6.js → LogsTab-47zEK7jL.js} +4 -1
  194. package/dist/vue/{OverviewSection-CXh6Ja1B.js → OverviewSection-1uBKo-Tu.js} +1 -1
  195. package/dist/vue/{QueriesSection-IodIsCJ-.js → QueriesSection-rpoZ4ogd.js} +1 -1
  196. package/dist/vue/{RequestsSection-BPuMdmMc.js → RequestsSection-x7LvT0MC.js} +1 -1
  197. package/dist/vue/{RoutesSection-NKo3Rbq3.js → RoutesSection-CCD0zZqQ.js} +1 -1
  198. package/dist/vue/composables/useDashboardData.d.ts +12 -23
  199. package/dist/vue/index-C8MxnS7Q.js +1232 -0
  200. package/dist/vue/index.js +1 -1
  201. package/dist/vue/style.css +1 -1
  202. package/package.json +1 -1
  203. package/dist/react/CacheTab-CA8LB1J5.js +0 -123
  204. package/dist/react/CustomPaneTab-Bxtv_8Rw.js +0 -104
  205. package/dist/react/EmailsTab-BDhEiomM.js +0 -153
  206. package/dist/react/EventsTab-CMfY98Rl.js +0 -63
  207. package/dist/react/LogsTab-CicucmVk.js +0 -103
  208. package/dist/react/RoutesTab-DgVzd2PZ.js +0 -74
  209. package/dist/react/index-Cflz9Ebj.js +0 -1069
  210. package/dist/vue/index-Dtgysd26.js +0 -1229
@@ -0,0 +1,1232 @@
1
+ import { ref as h, reactive as ne, computed as p, onMounted as G, onUnmounted as Y, defineComponent as Z, openBlock as a, createElementBlock as l, normalizeStyle as me, Fragment as V, createElementVNode as i, watch as J, nextTick as ye, onBeforeUnmount as ce, normalizeClass as B, toDisplayString as _, createCommentVNode as k, createBlock as j, Teleport as we, withModifiers as Ce, unref as n, createVNode as ue, renderList as se, defineAsyncComponent as E, createTextVNode as Te, provide as te, Suspense as _e, withCtx as he, resolveDynamicComponent as Ee } from "vue";
2
+ import { ServerStatsController as Se, DEFAULT_FEATURES as xe, detectFeatures as $e, getTheme as ve, onThemeChange as Le, toggleTheme as Me, buildSparklineData as Ue, computeStats as Be, formatStatNum as ie, detectMetricGroupsFromStats as Pe, getVisibleMetricGroups as Re, getMetricsByGroup as De, TAB_ICONS as $, DebugDataController as be, DashboardDataController as He, UnauthorizedError as Ae, subscribeToChannel as je } from "adonisjs-server-stats/core";
3
+ function ze(e) {
4
+ return {
5
+ onStatsUpdate: (s) => {
6
+ e.stats.value = s;
7
+ },
8
+ onConnectionChange: (s) => {
9
+ e.isConnected.value = s;
10
+ },
11
+ onStaleChange: (s) => {
12
+ e.isStale.value = s;
13
+ },
14
+ onError: (s) => {
15
+ e.error.value = s;
16
+ },
17
+ onUnauthorizedChange: (s) => {
18
+ e.isUnauthorized.value = s;
19
+ },
20
+ onHistoryChange: (s) => {
21
+ for (const t of Object.keys(s))
22
+ e.history[t] = s[t];
23
+ },
24
+ onSseActiveChange: (s) => {
25
+ e.sseActive.value = s;
26
+ },
27
+ onPollActiveChange: (s) => {
28
+ e.pollActive.value = s;
29
+ }
30
+ };
31
+ }
32
+ function Ie(e, s) {
33
+ if (e.isUnauthorized.value) return null;
34
+ const t = ze(e), r = new Se({ ...s, ...t });
35
+ return r.start(), r;
36
+ }
37
+ function qe(e = {}) {
38
+ const {
39
+ baseUrl: s = "",
40
+ endpoint: t = "/admin/api/server-stats",
41
+ channelName: r = "admin/server-stats",
42
+ authToken: o,
43
+ pollInterval: c = 3e3
44
+ } = e, y = h(null), v = ne({}), f = h(!1), S = h(!1), R = h(null), P = h(!1), b = h(!1), u = h(!1), H = {
45
+ stats: y,
46
+ history: v,
47
+ isConnected: f,
48
+ isStale: S,
49
+ error: R,
50
+ isUnauthorized: P,
51
+ sseActive: b,
52
+ pollActive: u
53
+ };
54
+ let g = null;
55
+ const I = p(() => P.value ? "disconnected" : b.value ? "live" : u.value ? "polling" : "disconnected");
56
+ return G(() => {
57
+ g = Ie(H, { baseUrl: s, endpoint: t, channelName: r, authToken: o, pollInterval: c });
58
+ }), Y(() => {
59
+ g?.stop(), g = null;
60
+ }), { stats: y, history: v, isConnected: f, isStale: S, isUnauthorized: P, error: R, connectionMode: I };
61
+ }
62
+ function de(e = {}) {
63
+ const { baseUrl: s = "", debugEndpoint: t = "/admin/api/debug", authToken: r } = e, o = h({ ...xe }), c = h(!0);
64
+ return G(async () => {
65
+ o.value = await $e({ baseUrl: s, debugEndpoint: t, authToken: r }), c.value = !1;
66
+ }), {
67
+ features: o,
68
+ loading: c
69
+ };
70
+ }
71
+ function oe() {
72
+ const e = h(ve());
73
+ let s = null;
74
+ function t(o) {
75
+ e.value = o;
76
+ }
77
+ function r() {
78
+ const o = Me();
79
+ return e.value = o, o;
80
+ }
81
+ return G(() => {
82
+ e.value = ve(), s = Le(t);
83
+ }), Y(() => {
84
+ s?.();
85
+ }), {
86
+ theme: e,
87
+ toggleTheme: r
88
+ };
89
+ }
90
+ const Oe = ["width", "height", "viewBox"], Ne = ["id"], Fe = ["stop-color"], Ve = ["stop-color"], Ge = ["d", "fill"], Qe = ["d", "stroke"], Je = ["x", "y"], We = /* @__PURE__ */ Z({
91
+ __name: "Sparkline",
92
+ props: {
93
+ data: {},
94
+ color: { default: "#34d399" },
95
+ width: { default: 120 },
96
+ height: { default: 32 }
97
+ },
98
+ setup(e) {
99
+ const s = e, t = p(
100
+ () => Ue(s.data, {
101
+ width: s.width,
102
+ height: s.height,
103
+ color: s.color
104
+ })
105
+ ), r = p(() => t.value !== null), o = p(() => `sg-${s.color.replace("#", "")}`);
106
+ return (c, y) => (a(), l("div", {
107
+ class: "ss-dash-sparkline",
108
+ style: me({ "--ss-accent": e.color })
109
+ }, [
110
+ (a(), l("svg", {
111
+ width: e.width,
112
+ height: e.height,
113
+ viewBox: `0 0 ${e.width} ${e.height}`,
114
+ style: { display: "block" }
115
+ }, [
116
+ r.value && t.value ? (a(), l(V, { key: 0 }, [
117
+ i("defs", null, [
118
+ i("linearGradient", {
119
+ id: o.value,
120
+ x1: "0",
121
+ y1: "0",
122
+ x2: "0",
123
+ y2: "1"
124
+ }, [
125
+ i("stop", {
126
+ offset: "0%",
127
+ "stop-color": e.color,
128
+ "stop-opacity": "0.25"
129
+ }, null, 8, Fe),
130
+ i("stop", {
131
+ offset: "100%",
132
+ "stop-color": e.color,
133
+ "stop-opacity": "0.02"
134
+ }, null, 8, Ve)
135
+ ], 8, Ne)
136
+ ]),
137
+ i("path", {
138
+ d: t.value.areaPath,
139
+ fill: `url(#${o.value})`
140
+ }, null, 8, Ge),
141
+ i("path", {
142
+ class: "ss-dash-sparkline-line",
143
+ d: "M" + t.value.points.replace(/ /g, " L"),
144
+ fill: "none",
145
+ stroke: e.color,
146
+ "stroke-width": "1.5",
147
+ "stroke-linejoin": "round",
148
+ "stroke-linecap": "round"
149
+ }, null, 8, Qe)
150
+ ], 64)) : (a(), l("text", {
151
+ key: 1,
152
+ x: e.width / 2,
153
+ y: e.height / 2 + 3,
154
+ "text-anchor": "middle",
155
+ fill: "#737373",
156
+ "font-size": "9"
157
+ }, " collecting... ", 8, Je))
158
+ ], 8, Oe))
159
+ ], 4));
160
+ }
161
+ }), Ke = ["id"], Xe = { class: "ss-label" }, Ye = {
162
+ class: "ss-tooltip-inner",
163
+ style: { position: "relative" }
164
+ }, Ze = { class: "ss-tooltip-header" }, et = { class: "ss-tooltip-title" }, tt = {
165
+ key: 0,
166
+ class: "ss-tooltip-unit"
167
+ }, st = { class: "ss-tooltip-current" }, at = { class: "ss-tooltip-current-value" }, nt = {
168
+ key: 1,
169
+ class: "ss-tooltip-stats"
170
+ }, ot = {
171
+ key: 2,
172
+ class: "ss-tooltip-details"
173
+ }, lt = {
174
+ key: 3,
175
+ class: "ss-tooltip-sparkline"
176
+ }, it = {
177
+ key: 4,
178
+ class: "ss-tooltip-samples"
179
+ }, rt = /* @__PURE__ */ Z({
180
+ __name: "MetricCard",
181
+ props: {
182
+ metric: {},
183
+ stats: {},
184
+ history: {}
185
+ },
186
+ emits: ["pin"],
187
+ setup(e, { emit: s }) {
188
+ const t = e, r = s, o = h(!1), c = h(!1), y = h(null), v = h(null), f = h(null), S = h({
189
+ position: "absolute",
190
+ bottom: "100%",
191
+ left: "0",
192
+ marginBottom: "10px",
193
+ zIndex: "180"
194
+ });
195
+ G(() => {
196
+ y.value && (f.value = y.value.closest(".ss-bar"));
197
+ });
198
+ function R() {
199
+ const U = y.value, O = v.value, X = f.value;
200
+ if (!U || !O || !X) return;
201
+ const z = U.getBoundingClientRect(), W = X.getBoundingClientRect(), ee = z.left - W.left + z.width / 2;
202
+ S.value = {
203
+ position: "absolute",
204
+ bottom: "100%",
205
+ left: `${ee}px`,
206
+ transform: "translateX(-50%)",
207
+ marginBottom: "10px",
208
+ zIndex: "180"
209
+ }, requestAnimationFrame(() => {
210
+ if (!v.value) return;
211
+ const T = v.value.getBoundingClientRect();
212
+ let d = 0;
213
+ T.left < 8 ? d = 8 - T.left : T.right > window.innerWidth - 8 && (d = window.innerWidth - 8 - T.right), d && (S.value = {
214
+ ...S.value,
215
+ transform: `translateX(calc(-50% + ${d}px))`
216
+ });
217
+ });
218
+ }
219
+ const P = p(() => o.value || c.value);
220
+ J(P, (U) => {
221
+ U && ye(R);
222
+ });
223
+ let b = null;
224
+ function u() {
225
+ P.value && R();
226
+ }
227
+ function H() {
228
+ P.value && R();
229
+ }
230
+ G(() => {
231
+ b = y.value?.closest(".ss-bar-scroll") ?? null, b?.addEventListener("scroll", u), window.addEventListener("resize", H);
232
+ }), ce(() => {
233
+ b?.removeEventListener("scroll", u), window.removeEventListener("resize", H);
234
+ });
235
+ const g = p(() => t.stats ? (t.metric.value || t.metric.format)(t.stats) : "..."), I = p(() => !t.stats || !t.metric.color ? "green" : t.metric.color(t.stats)), x = p(() => !t.stats || !t.metric.show ? !0 : t.metric.show(t.stats)), A = p(() => t.metric.detail ? typeof t.metric.detail == "function" ? t.stats ? t.metric.detail(t.stats) : "" : t.metric.detail : ""), N = p(() => ({
236
+ green: "#34d399",
237
+ amber: "#fbbf24",
238
+ red: "#f87171",
239
+ muted: "#737373"
240
+ })[I.value] || "#34d399"), q = p(() => Be(t.history));
241
+ function m() {
242
+ o.value = !0;
243
+ }
244
+ function L() {
245
+ o.value = !1;
246
+ }
247
+ function M() {
248
+ c.value = !c.value, c.value && r("pin", t.metric.id);
249
+ }
250
+ function D() {
251
+ c.value = !1;
252
+ }
253
+ function K(U) {
254
+ U.key === "Enter" && M();
255
+ }
256
+ function F(U) {
257
+ const O = U.target;
258
+ y.value && !y.value.contains(O) && v.value && !v.value.contains(O) && (c.value = !1);
259
+ }
260
+ function Q(U) {
261
+ U.key === "Escape" && (c.value = !1);
262
+ }
263
+ return J(c, (U) => {
264
+ U ? (document.addEventListener("click", F), document.addEventListener("keydown", Q)) : (document.removeEventListener("click", F), document.removeEventListener("keydown", Q));
265
+ }), ce(() => {
266
+ document.removeEventListener("click", F), document.removeEventListener("keydown", Q);
267
+ }), (U, O) => (a(), l(V, null, [
268
+ x.value ? (a(), l("div", {
269
+ key: 0,
270
+ ref_key: "badgeRef",
271
+ ref: y,
272
+ id: `ss-b-${e.metric.id}`,
273
+ class: B(["ss-badge", { "ss-pinned": c.value }]),
274
+ role: "button",
275
+ tabindex: 0,
276
+ onMouseenter: m,
277
+ onMouseleave: L,
278
+ onClick: M,
279
+ onKeydown: K
280
+ }, [
281
+ i("span", Xe, _(e.metric.label), 1),
282
+ i("span", {
283
+ class: B(["ss-value", `ss-${I.value}`])
284
+ }, _(g.value), 3)
285
+ ], 42, Ke)) : k("", !0),
286
+ P.value && f.value ? (a(), j(we, {
287
+ key: 1,
288
+ to: f.value
289
+ }, [
290
+ i("div", {
291
+ ref_key: "tooltipRef",
292
+ ref: v,
293
+ class: B(["ss-tooltip", { "ss-pinned": c.value }]),
294
+ style: me(S.value)
295
+ }, [
296
+ i("div", Ye, [
297
+ c.value ? (a(), l("button", {
298
+ key: 0,
299
+ class: "ss-tooltip-close",
300
+ onClick: Ce(D, ["stop"])
301
+ }, "×")) : k("", !0),
302
+ i("div", Ze, [
303
+ i("span", et, _(e.metric.title), 1),
304
+ e.metric.unit ? (a(), l("span", tt, _(e.metric.unit), 1)) : k("", !0)
305
+ ]),
306
+ i("div", st, [
307
+ O[0] || (O[0] = i("span", { class: "ss-tooltip-current-label" }, "Current: ", -1)),
308
+ i("span", at, _(g.value), 1)
309
+ ]),
310
+ q.value ? (a(), l("div", nt, [
311
+ i("span", null, "Min: " + _(n(ie)(q.value.min, e.metric.unit)), 1),
312
+ i("span", null, "Max: " + _(n(ie)(q.value.max, e.metric.unit)), 1),
313
+ i("span", null, "Avg: " + _(n(ie)(q.value.avg, e.metric.unit)), 1)
314
+ ])) : k("", !0),
315
+ A.value ? (a(), l("div", ot, _(A.value), 1)) : k("", !0),
316
+ e.history.length > 0 ? (a(), l("div", lt, [
317
+ ue(We, {
318
+ data: e.history,
319
+ color: N.value
320
+ }, null, 8, ["data", "color"])
321
+ ])) : k("", !0),
322
+ e.history.length > 0 ? (a(), l("div", it, " Last " + _(Math.min(e.history.length, 60)) + " samples (~" + _(Math.round(Math.min(e.history.length, 60) * 3 / 60)) + " min) ", 1)) : k("", !0)
323
+ ]),
324
+ O[1] || (O[1] = i("div", { class: "ss-tooltip-arrow" }, null, -1))
325
+ ], 6)
326
+ ], 8, ["to"])) : k("", !0)
327
+ ], 64));
328
+ }
329
+ }), ut = ["data-ss-theme"], dt = { class: "ss-bar-left" }, ct = ["viewBox", "innerHTML"], ht = { class: "ss-group" }, vt = {
330
+ key: 0,
331
+ class: "ss-group-sep"
332
+ }, bt = ["data-ss-theme", "title"], gt = {
333
+ key: 0,
334
+ class: "ss-toggle-summary",
335
+ style: { display: "flex" }
336
+ }, pt = {
337
+ key: 1,
338
+ class: "ss-value ss-green"
339
+ }, ft = {
340
+ key: 1,
341
+ class: "ss-toggle-label",
342
+ style: { color: "#737373" }
343
+ }, mt = { class: "ss-toggle-arrow" }, ge = "admin:stats-bar", ms = /* @__PURE__ */ Z({
344
+ __name: "StatsBar",
345
+ props: {
346
+ debugEndpoint: { default: "/admin/api/debug" },
347
+ baseUrl: { default: "" },
348
+ endpoint: { default: "/admin/api/server-stats" },
349
+ channelName: { default: "admin/server-stats" },
350
+ authToken: {},
351
+ pollInterval: { default: 3e3 },
352
+ className: {},
353
+ debugPanelOpen: { type: Boolean, default: !1 }
354
+ },
355
+ emits: ["openDebugPanel", "connectionChange"],
356
+ setup(e, { emit: s }) {
357
+ const t = e, r = s, { stats: o, history: c, isStale: y, isUnauthorized: v, isConnected: f, connectionMode: S } = qe({
358
+ baseUrl: t.baseUrl,
359
+ endpoint: t.endpoint,
360
+ channelName: t.channelName,
361
+ authToken: t.authToken,
362
+ pollInterval: t.pollInterval
363
+ });
364
+ J(f, (L) => {
365
+ r("connectionChange", L);
366
+ });
367
+ const { features: R } = de({
368
+ baseUrl: t.baseUrl,
369
+ debugEndpoint: t.debugEndpoint,
370
+ authToken: t.authToken
371
+ }), { theme: P } = oe(), b = h(!0), u = h(null);
372
+ G(() => {
373
+ b.value = localStorage.getItem(ge) !== "hidden";
374
+ const L = u.value;
375
+ if (L) {
376
+ const M = (D) => {
377
+ Math.abs(D.deltaX) > Math.abs(D.deltaY) || (D.preventDefault(), L.scrollLeft += D.deltaY);
378
+ };
379
+ L.addEventListener("wheel", M, { passive: !1 }), Y(() => L.removeEventListener("wheel", M));
380
+ }
381
+ });
382
+ function H() {
383
+ b.value = !b.value, localStorage.setItem(ge, b.value ? "visible" : "hidden");
384
+ }
385
+ J(v, (L) => {
386
+ L && (b.value = !1);
387
+ });
388
+ const g = p(() => o.value ? Pe(o.value) : Re(R.value)), I = p(() => {
389
+ const L = De();
390
+ return Array.from(L.entries()).filter(([M]) => g.value.has(M)).map(([M, D]) => ({
391
+ name: M,
392
+ metrics: D
393
+ }));
394
+ });
395
+ function x(L) {
396
+ return L ? c[L] || [] : [];
397
+ }
398
+ const A = p(() => o.value ? `${o.value.cpuPercent.toFixed(0)}%` : "..."), N = p(() => o.value ? o.value.memHeapUsed !== void 0 ? Math.round(o.value.memHeapUsed / (1024 * 1024)) + "M" : "-" : "..."), q = p(() => o.value ? o.value.redisOk ? "✓" : "✗" : "..."), m = p(() => P.value);
399
+ return (L, M) => (a(), l(V, null, [
400
+ n(v) ? k("", !0) : (a(), l("div", {
401
+ key: 0,
402
+ id: "ss-bar",
403
+ class: B(["ss-bar", { "ss-hidden": !b.value }]),
404
+ "data-ss-theme": m.value
405
+ }, [
406
+ i("div", dt, [
407
+ n(R).tracing || g.value.has("redis") || g.value.has("queue") ? (a(), l("button", {
408
+ key: 0,
409
+ type: "button",
410
+ class: B(["ss-dbg-btn", { "ss-dbg-active": e.debugPanelOpen }]),
411
+ title: "Toggle debug panel",
412
+ id: "ss-dbg-wrench",
413
+ onClick: M[0] || (M[0] = (D) => r("openDebugPanel"))
414
+ }, [
415
+ (a(), l("svg", {
416
+ width: "14",
417
+ height: "14",
418
+ viewBox: n($).wrench.viewBox,
419
+ fill: "none",
420
+ stroke: "currentColor",
421
+ "stroke-width": "2",
422
+ "stroke-linecap": "round",
423
+ "stroke-linejoin": "round",
424
+ innerHTML: n($).wrench.elements.join("")
425
+ }, null, 8, ct))
426
+ ], 2)) : k("", !0),
427
+ i("div", {
428
+ class: B(["ss-dot", { "ss-stale": n(y) }])
429
+ }, null, 2)
430
+ ]),
431
+ i("div", {
432
+ ref_key: "scrollRef",
433
+ ref: u,
434
+ id: "ss-bar-scroll",
435
+ class: "ss-bar-scroll"
436
+ }, [
437
+ (a(!0), l(V, null, se(I.value, (D, K) => (a(), l(V, {
438
+ key: D.name
439
+ }, [
440
+ i("div", ht, [
441
+ (a(!0), l(V, null, se(D.metrics, (F) => (a(), j(rt, {
442
+ key: F.id,
443
+ metric: F,
444
+ stats: n(o),
445
+ history: x(F.historyKey)
446
+ }, null, 8, ["metric", "stats", "history"]))), 128))
447
+ ]),
448
+ K < I.value.length - 1 ? (a(), l("div", vt)) : k("", !0)
449
+ ], 64))), 128))
450
+ ], 512)
451
+ ], 10, ut)),
452
+ n(v) ? k("", !0) : (a(), l("button", {
453
+ key: 1,
454
+ type: "button",
455
+ class: B(["ss-toggle", b.value ? "ss-visible" : "ss-collapsed"]),
456
+ "data-ss-theme": m.value,
457
+ title: b.value ? "Hide stats bar" : "Show stats bar",
458
+ onClick: H
459
+ }, [
460
+ !b.value && n(o) ? (a(), l("span", gt, [
461
+ g.value.has("process") ? (a(), l("span", {
462
+ key: 0,
463
+ class: B([
464
+ "ss-value",
465
+ n(o).cpuPercent > 80 ? "ss-red" : n(o).cpuPercent > 50 ? "ss-amber" : "ss-green"
466
+ ])
467
+ }, _(A.value), 3)) : k("", !0),
468
+ g.value.has("process") ? (a(), l("span", pt, _(N.value), 1)) : k("", !0),
469
+ g.value.has("redis") && n(o)?.redisOk !== void 0 ? (a(), l("span", {
470
+ key: 2,
471
+ class: B(["ss-value", n(o)?.redisOk ? "ss-green" : "ss-red"])
472
+ }, _(q.value), 3)) : k("", !0)
473
+ ])) : k("", !0),
474
+ b.value ? (a(), l("span", ft, "hide stats")) : k("", !0),
475
+ i("span", mt, _(b.value ? "▼" : "▲"), 1)
476
+ ], 10, bt))
477
+ ], 64));
478
+ }
479
+ }), pe = /* @__PURE__ */ new Set(["cache", "jobs", "config"]);
480
+ function fe(e) {
481
+ return {
482
+ onData: (s) => {
483
+ e.data.value = s;
484
+ },
485
+ onLoading: (s) => {
486
+ e.loading.value = s;
487
+ },
488
+ onError: (s) => {
489
+ e.error.value = s;
490
+ },
491
+ onUnauthorized: () => {
492
+ e.isUnauthorized.value = !0;
493
+ }
494
+ };
495
+ }
496
+ class kt {
497
+ constructor(s, t, r, o) {
498
+ this.refs = s, this.config = t, this.dashboardEndpoint = o, this.controller = new be({
499
+ ...t,
500
+ endpoint: r,
501
+ ...fe(s)
502
+ });
503
+ }
504
+ controller;
505
+ dashboardController = null;
506
+ dashboardEndpoint;
507
+ getDashboardController() {
508
+ return !this.dashboardController && this.dashboardEndpoint && (this.dashboardController = new be({
509
+ ...this.config,
510
+ endpoint: this.dashboardEndpoint,
511
+ ...fe(this.refs)
512
+ })), this.dashboardController;
513
+ }
514
+ startForTab(s) {
515
+ const t = s();
516
+ !t || t.startsWith("custom-") || (pe.has(t) && this.dashboardEndpoint ? (this.controller.stop(), this.getDashboardController().start(t)) : (this.dashboardController?.stop(), this.controller.start(t)));
517
+ }
518
+ stopAll() {
519
+ this.controller.stop(), this.dashboardController?.stop();
520
+ }
521
+ refresh(s) {
522
+ const t = s();
523
+ pe.has(t) && this.dashboardEndpoint && this.dashboardController ? this.dashboardController.refresh() : this.controller.refresh();
524
+ }
525
+ fetchCustomPane(s, t = !1) {
526
+ return this.controller.fetchCustomPane(s, t);
527
+ }
528
+ }
529
+ function yt(e, s = {}) {
530
+ const {
531
+ baseUrl: t = "",
532
+ debugEndpoint: r = "/admin/api/debug",
533
+ dashboardEndpoint: o,
534
+ authToken: c,
535
+ refreshInterval: y
536
+ } = s, v = h(null), f = h(!1), S = h(null), R = h(!1), P = { data: v, loading: f, error: S, isUnauthorized: R }, b = new kt(
537
+ P,
538
+ { baseUrl: t, authToken: c, refreshInterval: y },
539
+ r,
540
+ o
541
+ );
542
+ return J(e, () => {
543
+ v.value = null, b.startForTab(e);
544
+ }), G(() => b.startForTab(e)), Y(() => b.stopAll()), {
545
+ data: v,
546
+ loading: f,
547
+ error: S,
548
+ isUnauthorized: R,
549
+ refresh: () => b.refresh(e),
550
+ clear: () => {
551
+ v.value = null;
552
+ },
553
+ fetchCustomPane: (u, H = !1) => b.fetchCustomPane(u, H),
554
+ startRefresh: () => b.startForTab(e),
555
+ stopRefresh: () => b.stopAll()
556
+ };
557
+ }
558
+ const wt = ["title", "aria-label"], Ct = ["viewBox", "innerHTML"], Tt = ["viewBox", "innerHTML"], ke = /* @__PURE__ */ Z({
559
+ __name: "ThemeToggle",
560
+ props: {
561
+ classPrefix: { default: "ss-dbg" }
562
+ },
563
+ setup(e) {
564
+ const s = e, { theme: t, toggleTheme: r } = oe(), o = p(() => t.value === "dark"), c = p(() => o.value ? "Switch to light theme" : "Switch to dark theme"), y = p(
565
+ () => s.classPrefix === "ss-dbg" ? "ss-dbg-theme-toggle" : "ss-dash-theme-btn"
566
+ );
567
+ return (v, f) => (a(), l("button", {
568
+ type: "button",
569
+ class: B(y.value),
570
+ title: c.value,
571
+ "aria-label": c.value,
572
+ onClick: f[0] || (f[0] = //@ts-ignore
573
+ (...S) => n(r) && n(r)(...S))
574
+ }, [
575
+ o.value ? (a(), l("svg", {
576
+ key: 0,
577
+ width: "16",
578
+ height: "16",
579
+ viewBox: n($).sun.viewBox,
580
+ fill: "none",
581
+ stroke: "currentColor",
582
+ "stroke-width": "2",
583
+ "stroke-linecap": "round",
584
+ "stroke-linejoin": "round",
585
+ innerHTML: n($).sun.elements.join("")
586
+ }, null, 8, Ct)) : (a(), l("svg", {
587
+ key: 1,
588
+ width: "16",
589
+ height: "16",
590
+ viewBox: n($).moon.viewBox,
591
+ fill: "none",
592
+ stroke: "currentColor",
593
+ "stroke-width": "2",
594
+ "stroke-linecap": "round",
595
+ "stroke-linejoin": "round",
596
+ innerHTML: n($).moon.elements.join("")
597
+ }, null, 8, Tt))
598
+ ], 10, wt));
599
+ }
600
+ }), _t = ["data-ss-theme"], Et = { class: "ss-dbg-tabs" }, St = { class: "ss-dbg-tabs-scroll" }, xt = ["onClick"], $t = ["viewBox", "innerHTML"], Lt = { class: "ss-dbg-tabs-right" }, Mt = ["title"], Ut = ["href"], Bt = ["viewBox", "innerHTML"], Pt = { class: "ss-dbg-content" }, Rt = {
601
+ key: 0,
602
+ class: "ss-dbg-empty"
603
+ }, Dt = {
604
+ key: 1,
605
+ class: "ss-dbg-empty",
606
+ style: { color: "var(--ss-red-fg)" }
607
+ }, ks = /* @__PURE__ */ Z({
608
+ __name: "DebugPanel",
609
+ props: {
610
+ dashboardPath: { default: "/__stats" },
611
+ tracingEnabled: { type: Boolean, default: !1 },
612
+ isLive: { type: Boolean, default: !1 },
613
+ baseUrl: { default: "" },
614
+ debugEndpoint: { default: "/admin/api/debug" },
615
+ authToken: {},
616
+ className: {},
617
+ defaultOpen: { type: Boolean, default: !1 }
618
+ },
619
+ setup(e, { expose: s }) {
620
+ const t = E(() => import("./QueriesTab-C8_7oprC.js")), r = E(() => import("./EventsTab-BBM7olXF.js")), o = E(() => import("./EmailsTab-CNyEODVB.js")), c = E(() => import("./RoutesTab-Dz0MkZuF.js")), y = E(() => import("./LogsTab-47zEK7jL.js")), v = E(() => import("./TimelineTab-zj5Z5OdT.js")), f = E(() => import("./CacheTab-BPisYYiQ.js")), S = E(() => import("./JobsTab-WFnxPdN7.js")), R = E(() => import("./ConfigTab-C8cafGUj.js")), P = E(() => import("./InternalsTab-DEMjqtlw.js")), b = E(() => import("./CustomPaneTab-BJxT5Dp7.js")), u = e, H = h(u.defaultOpen), g = h("queries"), { theme: I } = oe(), { features: x } = de({
621
+ baseUrl: u.baseUrl,
622
+ debugEndpoint: u.debugEndpoint,
623
+ authToken: u.authToken
624
+ }), A = u.dashboardPath ? u.dashboardPath.replace(/\/+$/, "") + "/api" : void 0, N = p(() => g.value.startsWith("custom-")), q = p(() => N.value || g.value === "internals"), { data: m, loading: L, error: M, isUnauthorized: D, refresh: K, startRefresh: F, stopRefresh: Q } = yt(
625
+ () => g.value,
626
+ {
627
+ baseUrl: u.baseUrl,
628
+ debugEndpoint: u.debugEndpoint,
629
+ dashboardEndpoint: A,
630
+ authToken: u.authToken
631
+ }
632
+ ), U = p(() => {
633
+ const T = [
634
+ { id: "queries", label: "Queries", icon: "Q" },
635
+ { id: "events", label: "Events", icon: "E" },
636
+ { id: "emails", label: "Emails", icon: "M" },
637
+ { id: "routes", label: "Routes", icon: "R" },
638
+ { id: "logs", label: "Logs", icon: "L" }
639
+ ];
640
+ (x.value.tracing || u.tracingEnabled) && T.push({ id: "timeline", label: "Requests", icon: "R" }), x.value.cache && T.push({ id: "cache", label: "Cache", icon: "C" }), x.value.queues && T.push({ id: "jobs", label: "Jobs", icon: "J" }), T.push({ id: "config", label: "Config", icon: "G" }), T.push({ id: "internals", label: "Internals", icon: "I" });
641
+ for (const d of x.value.customPanes)
642
+ T.push({
643
+ id: `custom-${d.id}`,
644
+ label: d.label,
645
+ icon: d.label.charAt(0).toUpperCase()
646
+ });
647
+ return T;
648
+ });
649
+ function O(T) {
650
+ const d = T.replace("custom-", "");
651
+ return x.value.customPanes.find((w) => w.id === d);
652
+ }
653
+ function X() {
654
+ H.value = !0, F();
655
+ }
656
+ function z() {
657
+ H.value = !1, Q();
658
+ }
659
+ function W() {
660
+ H.value ? z() : X();
661
+ }
662
+ function ee(T) {
663
+ g.value = T;
664
+ }
665
+ return J(H, (T) => {
666
+ T ? F() : Q();
667
+ }), s({ toggle: W, open: X, close: z }), (T, d) => n(D) ? k("", !0) : (a(), l("div", {
668
+ key: 0,
669
+ class: B(["ss-dbg-panel", { "ss-dbg-open": H.value }]),
670
+ "data-ss-theme": n(I)
671
+ }, [
672
+ i("div", Et, [
673
+ i("div", St, [
674
+ (a(!0), l(V, null, se(U.value, (w) => (a(), l("button", {
675
+ key: w.id,
676
+ type: "button",
677
+ class: B(["ss-dbg-tab", { "ss-dbg-active": g.value === w.id }]),
678
+ onClick: (C) => ee(w.id)
679
+ }, [
680
+ n($)[w.id] ? (a(), l("svg", {
681
+ key: 0,
682
+ class: "ss-dbg-tab-icon",
683
+ viewBox: n($)[w.id].viewBox,
684
+ innerHTML: n($)[w.id].elements.join("")
685
+ }, null, 8, $t)) : k("", !0),
686
+ Te(" " + _(w.label), 1)
687
+ ], 10, xt))), 128))
688
+ ]),
689
+ i("div", Lt, [
690
+ i("span", {
691
+ class: B(["ss-dbg-conn-mode", e.isLive ? "ss-dbg-conn-live" : "ss-dbg-conn-polling"]),
692
+ title: e.isLive ? "Connected via Transmit (SSE) — real-time updates" : "Polling every 3s"
693
+ }, _(e.isLive ? "live" : "polling"), 11, Mt),
694
+ e.dashboardPath && n(x).dashboard ? (a(), l("a", {
695
+ key: 0,
696
+ href: e.dashboardPath,
697
+ target: "_blank",
698
+ rel: "noopener noreferrer",
699
+ class: "ss-dbg-dashboard-link",
700
+ title: "Open dashboard"
701
+ }, [
702
+ (a(), l("svg", {
703
+ width: "14",
704
+ height: "14",
705
+ viewBox: n($)["external-link"].viewBox,
706
+ fill: "none",
707
+ stroke: "currentColor",
708
+ "stroke-width": "2",
709
+ "stroke-linecap": "round",
710
+ "stroke-linejoin": "round",
711
+ innerHTML: n($)["external-link"].elements.join("")
712
+ }, null, 8, Bt))
713
+ ], 8, Ut)) : k("", !0),
714
+ ue(ke),
715
+ i("button", {
716
+ type: "button",
717
+ class: "ss-dbg-close",
718
+ onClick: z,
719
+ title: "Close panel"
720
+ }, " × ")
721
+ ])
722
+ ]),
723
+ i("div", Pt, [
724
+ n(L) && !n(m) && !q.value ? (a(), l("div", Rt, "Loading...")) : n(M) && !q.value ? (a(), l("div", Dt, " Error: " + _(n(M).message), 1)) : (a(), l(V, { key: 2 }, [
725
+ g.value === "queries" ? (a(), j(n(t), {
726
+ key: 0,
727
+ data: n(m),
728
+ "dashboard-path": e.dashboardPath
729
+ }, null, 8, ["data", "dashboard-path"])) : g.value === "events" ? (a(), j(n(r), {
730
+ key: 1,
731
+ data: n(m),
732
+ "dashboard-path": e.dashboardPath
733
+ }, null, 8, ["data", "dashboard-path"])) : g.value === "emails" ? (a(), j(n(o), {
734
+ key: 2,
735
+ data: n(m),
736
+ "dashboard-path": e.dashboardPath,
737
+ "debug-endpoint": e.debugEndpoint,
738
+ "auth-token": e.authToken
739
+ }, null, 8, ["data", "dashboard-path", "debug-endpoint", "auth-token"])) : g.value === "routes" ? (a(), j(n(c), {
740
+ key: 3,
741
+ data: n(m)
742
+ }, null, 8, ["data"])) : g.value === "logs" ? (a(), j(n(y), {
743
+ key: 4,
744
+ data: n(m),
745
+ "dashboard-path": e.dashboardPath
746
+ }, null, 8, ["data", "dashboard-path"])) : g.value === "timeline" ? (a(), j(n(v), {
747
+ key: 5,
748
+ data: n(m),
749
+ "dashboard-path": e.dashboardPath,
750
+ "base-url": e.baseUrl,
751
+ "debug-endpoint": e.debugEndpoint,
752
+ "auth-token": e.authToken
753
+ }, null, 8, ["data", "dashboard-path", "base-url", "debug-endpoint", "auth-token"])) : g.value === "cache" ? (a(), j(n(f), {
754
+ key: 6,
755
+ data: n(m)
756
+ }, null, 8, ["data"])) : g.value === "jobs" ? (a(), j(n(S), {
757
+ key: 7,
758
+ data: n(m)
759
+ }, null, 8, ["data"])) : g.value === "config" ? (a(), j(n(R), {
760
+ key: 8,
761
+ data: n(m)
762
+ }, null, 8, ["data"])) : g.value === "internals" ? (a(), j(n(P), {
763
+ key: 9,
764
+ data: n(m),
765
+ "base-url": e.baseUrl,
766
+ "debug-endpoint": e.debugEndpoint,
767
+ "auth-token": e.authToken
768
+ }, null, 8, ["data", "base-url", "debug-endpoint", "auth-token"])) : g.value.startsWith("custom-") ? (a(), j(n(b), {
769
+ key: 10,
770
+ pane: O(g.value),
771
+ "base-url": e.baseUrl,
772
+ "auth-token": e.authToken
773
+ }, null, 8, ["pane", "base-url", "auth-token"])) : k("", !0)
774
+ ], 64))
775
+ ])
776
+ ], 10, _t));
777
+ }
778
+ });
779
+ function Ht(e) {
780
+ let s = null;
781
+ return {
782
+ onData: (t) => {
783
+ s = t;
784
+ },
785
+ onPagination: (t) => {
786
+ t ? (e.pagination.total = t.total, e.pagination.totalPages = t.lastPage ?? (Math.ceil(t.total / e.pagination.perPage) || 1), e.data.value = { data: s, meta: t }) : e.data.value = s;
787
+ },
788
+ onLoading: (t) => {
789
+ e.loading.value = t;
790
+ },
791
+ onError: (t) => {
792
+ e.error.value = t;
793
+ },
794
+ onUnauthorized: () => {
795
+ e.isUnauthorized.value = !0;
796
+ }
797
+ };
798
+ }
799
+ function At(e) {
800
+ const s = {};
801
+ for (const [t, r] of Object.entries(e))
802
+ t !== "search" && r !== "" && r !== void 0 && r !== null && (s[t] = String(r));
803
+ return s;
804
+ }
805
+ async function re(e) {
806
+ try {
807
+ return await e();
808
+ } catch {
809
+ return null;
810
+ }
811
+ }
812
+ function jt(e) {
813
+ return {
814
+ fetchGroupedQueries: () => re(() => e.fetchGroupedQueries()),
815
+ explainQuery: (s) => re(() => e.explainQuery(s)),
816
+ fetchEmailPreview: async (s) => (await re(() => e.fetchEmailPreview(s)))?.html || null
817
+ };
818
+ }
819
+ function zt(e) {
820
+ return {
821
+ retryJob: async (s) => {
822
+ try {
823
+ return await e.retryJob(s), !0;
824
+ } catch {
825
+ return !1;
826
+ }
827
+ },
828
+ deleteCacheKey: async (s) => {
829
+ try {
830
+ return await e.deleteCacheKey(s), !0;
831
+ } catch {
832
+ return !1;
833
+ }
834
+ }
835
+ };
836
+ }
837
+ function It(e, s) {
838
+ return {
839
+ fetchChart: async (t) => {
840
+ try {
841
+ return await e.fetchChart(t);
842
+ } catch (r) {
843
+ return r instanceof Ae && (s.value = !0), null;
844
+ }
845
+ }
846
+ };
847
+ }
848
+ function ae(e, s, t) {
849
+ const r = s(), o = At(t.filter);
850
+ e.configure({
851
+ page: t.pagination.page,
852
+ perPage: t.pagination.perPage,
853
+ search: t.filter.search || void 0,
854
+ sort: t.sort.column || void 0,
855
+ sortDir: t.sort.column ? t.sort.direction : void 0,
856
+ filters: Object.keys(o).length > 0 ? o : void 0,
857
+ timeRange: r.startsWith("overview") ? t.timeRange.value : void 0
858
+ });
859
+ }
860
+ function qt(e, s) {
861
+ return {
862
+ goToPage(t) {
863
+ e.pagination.page = t, s();
864
+ },
865
+ setSearch(t) {
866
+ e.filter.search = t, e.pagination.page = 1, s();
867
+ },
868
+ setFilter(t, r) {
869
+ e.filter[t] = r, e.pagination.page = 1, s();
870
+ },
871
+ setSort(t, r) {
872
+ e.sort.column === t && !r ? e.sort.direction = e.sort.direction === "asc" ? "desc" : "asc" : (e.sort.column = t, e.sort.direction = r || "desc"), s();
873
+ },
874
+ setTimeRange(t) {
875
+ e.timeRange.value = t, s();
876
+ }
877
+ };
878
+ }
879
+ function Ot(e, s, t) {
880
+ return {
881
+ async mutate(r, o = "post", c) {
882
+ return e.mutate(r, o, c);
883
+ },
884
+ refresh() {
885
+ ae(e, s, t), e.fetch(!0);
886
+ },
887
+ startRefresh() {
888
+ e.start();
889
+ },
890
+ stopRefresh() {
891
+ e.stop();
892
+ }
893
+ };
894
+ }
895
+ function Nt(e, s, t, r) {
896
+ J(s, () => {
897
+ t.pagination.page = 1;
898
+ for (const o of Object.keys(t.filter))
899
+ o === "search" ? t.filter.search = "" : delete t.filter[o];
900
+ t.sort.column = "", t.data.value = null, e.setSection(s()), ae(e, s, t);
901
+ }), r && J(r, () => {
902
+ ae(e, s, t), e.handleRefreshSignal();
903
+ });
904
+ }
905
+ function Ft(e) {
906
+ return {
907
+ data: h(null),
908
+ loading: h(!1),
909
+ error: h(null),
910
+ isUnauthorized: h(!1),
911
+ timeRange: h("1h"),
912
+ pagination: ne({ page: 1, perPage: e, total: 0, totalPages: 1 }),
913
+ filter: ne({ search: "" }),
914
+ sort: ne({
915
+ column: "",
916
+ direction: "desc"
917
+ })
918
+ };
919
+ }
920
+ function Vt(e, s, t, r) {
921
+ return {
922
+ data: e.data,
923
+ loading: e.loading,
924
+ error: e.error,
925
+ isUnauthorized: e.isUnauthorized,
926
+ pagination: e.pagination,
927
+ filter: e.filter,
928
+ sort: e.sort,
929
+ timeRange: e.timeRange,
930
+ ...s,
931
+ ...t,
932
+ ...r
933
+ };
934
+ }
935
+ function Gt(e, s = {}) {
936
+ const {
937
+ baseUrl: t = "",
938
+ dashboardEndpoint: r = "/__stats/api",
939
+ authToken: o,
940
+ perPage: c = 50,
941
+ refreshKey: y
942
+ } = s, v = Ft(c), f = new He({
943
+ baseUrl: t,
944
+ endpoint: r,
945
+ authToken: o,
946
+ section: e(),
947
+ perPage: c,
948
+ callbacks: Ht(v)
949
+ }), S = f.getApi(), P = qt(v, () => {
950
+ ae(f, e, v), f.fetch(!1);
951
+ }), b = Ot(f, e, v), u = {
952
+ ...It(S, v.isUnauthorized),
953
+ ...jt(S),
954
+ ...zt(S)
955
+ };
956
+ return Nt(f, e, v, y), G(() => {
957
+ ae(f, e, v), f.start();
958
+ }), Y(() => {
959
+ f.stop();
960
+ }), Vt(v, P, b, u);
961
+ }
962
+ const Qt = ["data-theme"], Jt = { class: "ss-dash-header" }, Wt = { class: "ss-dash-header-center" }, Kt = { class: "ss-dash-header-right" }, Xt = ["href"], Yt = { class: "ss-dash-body" }, Zt = { class: "ss-dash-nav" }, es = ["data-ss-section", "onClick", "title"], ts = { class: "ss-dash-nav-icon" }, ss = ["viewBox", "innerHTML"], as = { class: "ss-dash-nav-label" }, ns = {
963
+ key: 0,
964
+ class: "ss-dash-nav-sep"
965
+ }, os = ["onClick", "title"], ls = { class: "ss-dash-nav-icon" }, is = ["viewBox", "innerHTML"], rs = { class: "ss-dash-nav-label" }, us = ["title"], ds = ["viewBox", "innerHTML"], cs = ["viewBox", "innerHTML"], hs = { class: "ss-dash-main" }, vs = ["id"], bs = { class: "ss-dash-pane-inner" }, gs = {
966
+ key: 1,
967
+ class: "ss-dash-empty"
968
+ }, ys = /* @__PURE__ */ Z({
969
+ __name: "DashboardPage",
970
+ props: {
971
+ baseUrl: { default: "" },
972
+ dashboardEndpoint: { default: "/__stats/api" },
973
+ debugEndpoint: { default: void 0 },
974
+ authToken: { default: void 0 },
975
+ backUrl: { default: "/" },
976
+ channelName: { default: "server-stats/dashboard" }
977
+ },
978
+ setup(e) {
979
+ const s = E(() => import("./OverviewSection-1uBKo-Tu.js")), t = E(() => import("./RequestsSection-x7LvT0MC.js")), r = E(() => import("./QueriesSection-rpoZ4ogd.js")), o = E(() => import("./EventsSection-BOYYz0Ty.js")), c = E(() => import("./RoutesSection-CCD0zZqQ.js")), y = E(() => import("./LogsSection-D55PjTKX.js")), v = E(() => import("./EmailsSection-DtLJ4XoS.js")), f = E(() => import("./CacheSection-ITqvpfH5.js")), S = E(() => import("./JobsSection-BazTxcJL.js")), R = E(() => import("./ConfigSection-DTn3GslE.js")), P = E(() => import("./InternalsSection-BJUXE-5F.js")), b = [
980
+ "overview",
981
+ "requests",
982
+ "queries",
983
+ "events",
984
+ "routes",
985
+ "logs",
986
+ "emails",
987
+ "cache",
988
+ "jobs",
989
+ "config",
990
+ "internals"
991
+ ], u = e, { theme: H, toggleTheme: g } = oe(), { features: I } = de({
992
+ baseUrl: u.baseUrl,
993
+ debugEndpoint: u.debugEndpoint,
994
+ authToken: u.authToken
995
+ }), x = h("overview"), A = h(!1), N = h(!1), q = h(0);
996
+ te("ss-refresh-key", q), te("ss-base-url", u.baseUrl), te("ss-dashboard-endpoint", u.dashboardEndpoint), te("ss-debug-endpoint", u.debugEndpoint), te("ss-auth-token", u.authToken), typeof window < "u" && (A.value = localStorage.getItem("ss-dash-sidebar") === "collapsed");
997
+ let m = null;
998
+ function L() {
999
+ if (m && (m(), m = null), !u.channelName) return;
1000
+ m = je({
1001
+ baseUrl: u.baseUrl,
1002
+ channelName: u.channelName,
1003
+ authToken: u.authToken,
1004
+ onMessage: () => {
1005
+ q.value += 1;
1006
+ },
1007
+ onConnect: () => {
1008
+ N.value = !0;
1009
+ },
1010
+ onDisconnect: () => {
1011
+ N.value = !1;
1012
+ },
1013
+ onError: () => {
1014
+ N.value = !1;
1015
+ }
1016
+ }).unsubscribe;
1017
+ }
1018
+ G(() => {
1019
+ L();
1020
+ }), Y(() => {
1021
+ m && (m(), m = null);
1022
+ });
1023
+ const M = p(() => I.value.customPanes || []);
1024
+ function D(d) {
1025
+ const w = d.replace("#", "").split("?")[0];
1026
+ return w && [...b, ...M.value.map((le) => le.id)].includes(w) ? w : "overview";
1027
+ }
1028
+ function K() {
1029
+ const d = D(window.location.hash);
1030
+ d !== x.value && (x.value = d);
1031
+ }
1032
+ G(() => {
1033
+ if (typeof window > "u") return;
1034
+ const d = D(window.location.hash);
1035
+ (d !== "overview" || window.location.hash) && (x.value = d), window.addEventListener("hashchange", K);
1036
+ }), Y(() => {
1037
+ window.removeEventListener("hashchange", K);
1038
+ }), J(x, (d) => {
1039
+ typeof window < "u" && (window.location.hash = d);
1040
+ });
1041
+ function F() {
1042
+ A.value = !A.value, localStorage.setItem("ss-dash-sidebar", A.value ? "collapsed" : "expanded");
1043
+ }
1044
+ function Q(d) {
1045
+ d !== x.value && (x.value = d);
1046
+ }
1047
+ const U = p(() => [
1048
+ { id: "overview", label: "Overview", visible: !0 },
1049
+ { id: "requests", label: "Requests", visible: !0 },
1050
+ { id: "queries", label: "Queries", visible: !0 },
1051
+ { id: "events", label: "Events", visible: !0 },
1052
+ { id: "routes", label: "Routes", visible: !0 },
1053
+ { id: "logs", label: "Logs", visible: !0 },
1054
+ { id: "emails", label: "Emails", visible: !0 },
1055
+ { id: "cache", label: "Cache", visible: I.value.cache },
1056
+ { id: "jobs", label: "Jobs", visible: I.value.queues },
1057
+ { id: "config", label: "Config", visible: !0 },
1058
+ { id: "internals", label: "Internals", visible: !0 }
1059
+ ]), O = p(() => U.value.filter((d) => d.visible)), { data: X } = Gt(() => "overview", {
1060
+ baseUrl: u.baseUrl,
1061
+ dashboardEndpoint: u.dashboardEndpoint,
1062
+ authToken: u.authToken,
1063
+ refreshKey: q
1064
+ }), z = p(() => X.value), W = p(() => {
1065
+ const d = {};
1066
+ if (!z.value) return d;
1067
+ if (z.value.totalRequests > 0 && (d.requests = { count: z.value.totalRequests }), z.value.queryStats?.total > 0 && (d.queries = { count: z.value.queryStats.total }), z.value.logLevelBreakdown) {
1068
+ const w = z.value.logLevelBreakdown, C = w.error + w.warn + w.info + w.debug;
1069
+ C > 0 && (d.logs = { count: C });
1070
+ }
1071
+ return d;
1072
+ }), ee = {
1073
+ overview: s,
1074
+ requests: t,
1075
+ queries: r,
1076
+ events: o,
1077
+ routes: c,
1078
+ logs: y,
1079
+ emails: v,
1080
+ cache: f,
1081
+ jobs: S,
1082
+ config: R,
1083
+ internals: P
1084
+ }, T = p(() => ee[x.value] || null);
1085
+ return (d, w) => (a(), l("div", {
1086
+ class: "ss-dash",
1087
+ "data-theme": n(H),
1088
+ id: "ss-dash"
1089
+ }, [
1090
+ i("div", Jt, [
1091
+ w[0] || (w[0] = i("div", { class: "ss-dash-header-left" }, [
1092
+ i("span", { class: "ss-dash-logo" }, "Server Stats"),
1093
+ i("span", { class: "ss-dash-logo-sub" }, "Dashboard")
1094
+ ], -1)),
1095
+ i("div", Wt, [
1096
+ i("span", {
1097
+ class: B(["ss-dash-live-dot", { "ss-dash-connected": N.value }]),
1098
+ id: "ss-dash-live-dot"
1099
+ }, null, 2),
1100
+ i("span", {
1101
+ class: B(["ss-dash-live-label", { "ss-dash-connected": N.value }]),
1102
+ id: "ss-dash-live-label"
1103
+ }, _(N.value ? "Live" : "Polling"), 3)
1104
+ ]),
1105
+ i("div", Kt, [
1106
+ ue(ke, { "class-prefix": "ss-dash" }),
1107
+ e.backUrl ? (a(), l("a", {
1108
+ key: 0,
1109
+ href: e.backUrl,
1110
+ class: "ss-dash-back-link",
1111
+ title: "Back to app"
1112
+ }, " ← App ", 8, Xt)) : k("", !0)
1113
+ ])
1114
+ ]),
1115
+ i("div", Yt, [
1116
+ i("div", {
1117
+ class: B(["ss-dash-sidebar", { "ss-dash-collapsed": A.value }]),
1118
+ id: "ss-dash-sidebar"
1119
+ }, [
1120
+ i("nav", Zt, [
1121
+ (a(!0), l(V, null, se(O.value, (C) => (a(), l("button", {
1122
+ key: C.id,
1123
+ type: "button",
1124
+ class: B(["ss-dash-nav-item", { "ss-dash-active": x.value === C.id }]),
1125
+ "data-ss-section": C.id,
1126
+ onClick: (le) => Q(C.id),
1127
+ title: A.value ? C.label : void 0
1128
+ }, [
1129
+ i("span", ts, [
1130
+ (a(), l("svg", {
1131
+ width: "20",
1132
+ height: "20",
1133
+ viewBox: (n($)[C.id] || n($).config).viewBox,
1134
+ fill: "none",
1135
+ stroke: "currentColor",
1136
+ "stroke-width": "2",
1137
+ "stroke-linecap": "round",
1138
+ "stroke-linejoin": "round",
1139
+ innerHTML: (n($)[C.id] || n($).config).elements.join("")
1140
+ }, null, 8, ss))
1141
+ ]),
1142
+ i("span", as, _(C.label), 1),
1143
+ W.value[C.id] && W.value[C.id].count > 0 ? (a(), l("span", {
1144
+ key: 0,
1145
+ class: B(["ss-dash-nav-badge", W.value[C.id].variant || ""])
1146
+ }, _(W.value[C.id].count), 3)) : k("", !0)
1147
+ ], 10, es))), 128)),
1148
+ M.value.length > 0 ? (a(), l("div", ns)) : k("", !0),
1149
+ (a(!0), l(V, null, se(M.value, (C) => (a(), l("button", {
1150
+ key: C.id,
1151
+ type: "button",
1152
+ class: B(["ss-dash-nav-item", { "ss-dash-active": x.value === C.id }]),
1153
+ onClick: (le) => Q(C.id),
1154
+ title: A.value ? C.label : void 0
1155
+ }, [
1156
+ i("span", ls, [
1157
+ (a(), l("svg", {
1158
+ width: "20",
1159
+ height: "20",
1160
+ viewBox: n($)["custom-pane"].viewBox,
1161
+ fill: "none",
1162
+ stroke: "currentColor",
1163
+ "stroke-width": "2",
1164
+ "stroke-linecap": "round",
1165
+ "stroke-linejoin": "round",
1166
+ innerHTML: n($)["custom-pane"].elements.join("")
1167
+ }, null, 8, is))
1168
+ ]),
1169
+ i("span", rs, _(C.label), 1)
1170
+ ], 10, os))), 128))
1171
+ ]),
1172
+ i("button", {
1173
+ type: "button",
1174
+ class: "ss-dash-sidebar-toggle",
1175
+ id: "ss-dash-sidebar-toggle",
1176
+ onClick: F,
1177
+ title: A.value ? "Expand sidebar" : "Collapse sidebar"
1178
+ }, [
1179
+ A.value ? (a(), l("svg", {
1180
+ key: 0,
1181
+ width: "16",
1182
+ height: "16",
1183
+ viewBox: n($)["chevron-right"].viewBox,
1184
+ fill: "none",
1185
+ stroke: "currentColor",
1186
+ "stroke-width": "1.5",
1187
+ innerHTML: n($)["chevron-right"].elements.join("")
1188
+ }, null, 8, ds)) : (a(), l("svg", {
1189
+ key: 1,
1190
+ width: "16",
1191
+ height: "16",
1192
+ viewBox: n($)["chevron-left"].viewBox,
1193
+ fill: "none",
1194
+ stroke: "currentColor",
1195
+ "stroke-width": "1.5",
1196
+ innerHTML: n($)["chevron-left"].elements.join("")
1197
+ }, null, 8, cs))
1198
+ ], 8, us)
1199
+ ], 2),
1200
+ i("div", hs, [
1201
+ i("div", {
1202
+ class: "ss-dash-pane ss-dash-active",
1203
+ id: `ss-dash-pane-${x.value}`
1204
+ }, [
1205
+ i("div", bs, [
1206
+ (a(), j(_e, null, {
1207
+ fallback: he(() => [...w[1] || (w[1] = [
1208
+ i("div", { class: "ss-dash-empty" }, "Loading...", -1)
1209
+ ])]),
1210
+ default: he(() => [
1211
+ T.value ? (a(), j(Ee(T.value), { key: 0 })) : (a(), l("div", gs, "Unknown section"))
1212
+ ]),
1213
+ _: 1
1214
+ }))
1215
+ ])
1216
+ ], 8, vs)
1217
+ ])
1218
+ ])
1219
+ ], 8, Qt));
1220
+ }
1221
+ });
1222
+ export {
1223
+ We as _,
1224
+ ys as a,
1225
+ ks as b,
1226
+ ms as c,
1227
+ yt as d,
1228
+ de as e,
1229
+ qe as f,
1230
+ oe as g,
1231
+ Gt as u
1232
+ };