react-semaphor 0.1.382 → 0.1.383

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 (50) hide show
  1. package/dist/brand-studio/index.cjs +4 -4
  2. package/dist/brand-studio/index.js +27 -27
  3. package/dist/chunks/{braces-CP8BEzl3.js → braces--20GzUQh.js} +1 -1
  4. package/dist/chunks/{braces-CGi-YFZp.js → braces-C0Vh_Mft.js} +1 -1
  5. package/dist/chunks/{calendar-preferences-dialog-CV4xF2Tp.js → calendar-preferences-dialog-B-VsxhsA.js} +3 -3
  6. package/dist/chunks/calendar-preferences-dialog-DE67Z3oQ.js +1 -0
  7. package/dist/chunks/{dashboard-briefing-launcher-BT00MvGB.js → dashboard-briefing-launcher-BIj3X7b3.js} +107 -106
  8. package/dist/chunks/dashboard-briefing-launcher-Czx6BcXW.js +80 -0
  9. package/dist/chunks/dashboard-controls-BP-DcPFs.js +52 -0
  10. package/dist/chunks/{dashboard-controls-B6y7jkKO.js → dashboard-controls-BXxucM4f.js} +114 -113
  11. package/dist/chunks/dashboard-json-BNwshkK2.js +1 -0
  12. package/dist/chunks/{dashboard-json-CfIUG8k1.js → dashboard-json-C6oZuipD.js} +8 -8
  13. package/dist/chunks/edit-dashboard-visual-BAprin3J.js +178 -0
  14. package/dist/chunks/{edit-dashboard-visual-DMbf89xa.js → edit-dashboard-visual-CmfrI_L3.js} +1277 -1276
  15. package/dist/chunks/{index-CrKxP9uF.js → index-4W_ElSBJ.js} +219 -239
  16. package/dist/chunks/{index-BAsWLkZ8.js → index-icb12JV1.js} +879 -932
  17. package/dist/chunks/{layout-grid-jJQUqDN9.js → layout-grid-B7-klXiK.js} +1 -1
  18. package/dist/chunks/{layout-grid-BsKH3TgY.js → layout-grid-DV89AC9_.js} +1 -1
  19. package/dist/chunks/{palette-xU9Qt6bE.js → palette-5IwhMbSF.js} +1 -1
  20. package/dist/chunks/{palette-9zLPGlj2.js → palette-Dj-dgPYh.js} +1 -1
  21. package/dist/chunks/{save-DzciESDh.js → save-16C6YSW2.js} +1 -1
  22. package/dist/chunks/{save-8A_q6K4E.js → save-C5fwVdTF.js} +1 -1
  23. package/dist/chunks/search-0LmWwZzW.js +57 -0
  24. package/dist/chunks/search-Dq1Mbb03.js +21 -0
  25. package/dist/chunks/{switch-DArtNJZh.js → switch-DUdaHFZQ.js} +2332 -2419
  26. package/dist/chunks/{switch-k7kj6NRg.js → switch-bdJp0Bkw.js} +29 -54
  27. package/dist/chunks/use-create-flow-overlay-state-BIHKf_XK.js +21 -0
  28. package/dist/chunks/{use-create-flow-overlay-state-BdG1DiSx.js → use-create-flow-overlay-state-YvqCp6Zo.js} +74 -74
  29. package/dist/chunks/x-B_cx7LwM.js +26 -0
  30. package/dist/chunks/x-IdR_js6f.js +139 -0
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/data-app-builder/index.cjs +23 -23
  34. package/dist/data-app-builder/index.js +17 -15
  35. package/dist/data-app-sdk/index.cjs +68 -1
  36. package/dist/data-app-sdk/index.js +2705 -422
  37. package/dist/index.cjs +1 -1
  38. package/dist/index.js +14 -14
  39. package/dist/surfboard/index.cjs +1 -1
  40. package/dist/surfboard/index.js +2 -2
  41. package/dist/types/data-app-sdk.d.ts +127 -1
  42. package/package.json +1 -1
  43. package/dist/chunks/calendar-preferences-dialog-rDDobeLo.js +0 -1
  44. package/dist/chunks/dashboard-briefing-launcher-Dcbh-mjY.js +0 -80
  45. package/dist/chunks/dashboard-controls-CRqnPibB.js +0 -52
  46. package/dist/chunks/dashboard-json-DEQqRR1x.js +0 -1
  47. package/dist/chunks/edit-dashboard-visual-wDOcHak3.js +0 -178
  48. package/dist/chunks/index-BxM99sFL.js +0 -1
  49. package/dist/chunks/index-CuHybtft.js +0 -51
  50. package/dist/chunks/use-create-flow-overlay-state-ipeaE65_.js +0 -21
@@ -1,23 +1,24 @@
1
- import { toSemaphorInputSnapshots as H, toSemaphorInputBinding as Q, toSemaphorActiveInputSnapshots as y, toSemaphorMatrixIntent as J, toSemaphorSqlIntent as F, toSemaphorInputOptionsIntent as Y, toSemaphorRecordsIntent as W, toSemaphorAnalysisQueryOptions as X, toSemaphorAnalysisIntent as G, toSemaphorMetricIntent as Z, hasSemaphorInputValue as q, normalizeSemaphorInputOptions as L, toSemaphorInputSpec as U } from "../data-app-sdk-adapters/index.js";
2
- import { j as ee } from "../chunks/index-CuHybtft.js";
3
- import { createContext as te, useContext as re, useMemo as p, useEffect as R, useState as w, useCallback as O, useRef as N } from "react";
4
- import { b as ne } from "../chunks/validators-CHPH6ORs.js";
1
+ import { toSemaphorInputSnapshots as bt, toSemaphorInputBinding as St, toSemaphorActiveInputSnapshots as U, toSemaphorMatrixIntent as xt, toSemaphorSqlIntent as wt, toSemaphorInputOptionsIntent as It, toSemaphorRecordsIntent as qt, toSemaphorAnalysisQueryOptions as Rt, toSemaphorAnalysisIntent as At, toSemaphorMetricIntent as Et, hasSemaphorInputValue as ee, normalizeSemaphorInputOptions as Ge, toSemaphorInputSpec as Je } from "../data-app-sdk-adapters/index.js";
2
+ import { jsxs as p, Fragment as Tt, jsx as s } from "react/jsx-runtime";
3
+ import { createContext as ce, useContext as z, useState as H, useRef as C, useEffect as B, useMemo as b, useId as Ye, useCallback as D, useReducer as kt } from "react";
4
+ import { M as Ct, a as Dt, S as Ot, E as Lt } from "../chunks/search-0LmWwZzW.js";
5
+ import { X as Bt, j as Kt } from "../chunks/x-IdR_js6f.js";
6
+ import { b as $t } from "../chunks/validators-CHPH6ORs.js";
5
7
  import "../chunks/analyze-result-contract-DuhlklhI.js";
6
- import { jsx as oe } from "react/jsx-runtime";
7
- function g(e, t, n = {}) {
8
+ function ne(e, t, r = {}) {
8
9
  return {
9
- ...n,
10
+ ...r,
10
11
  name: e,
11
12
  role: t
12
13
  };
13
14
  }
14
- function ze(e) {
15
+ function kn(e) {
15
16
  return e;
16
17
  }
17
- function Me(e) {
18
+ function Cn(e) {
18
19
  return e;
19
20
  }
20
- const He = {
21
+ const Dn = {
21
22
  source: {
22
23
  semantic(e) {
23
24
  return {
@@ -34,16 +35,16 @@ const He = {
34
35
  },
35
36
  field: {
36
37
  measure(e, t) {
37
- return g(e, "measure", t);
38
+ return ne(e, "measure", t);
38
39
  },
39
40
  dimension(e, t) {
40
- return g(e, "dimension", t);
41
+ return ne(e, "dimension", t);
41
42
  },
42
43
  date(e, t) {
43
- return g(e, "date", t);
44
+ return ne(e, "date", t);
44
45
  },
45
46
  id(e, t) {
46
- return g(e, "id", t);
47
+ return ne(e, "id", t);
47
48
  }
48
49
  },
49
50
  filter(e) {
@@ -55,18 +56,18 @@ const He = {
55
56
  bindInput(e, t) {
56
57
  return {
57
58
  toAnalyticsInput() {
58
- const [n] = H([e]), r = Q({
59
+ const [r] = bt([e]), n = St({
59
60
  ...t,
60
- inputId: t.inputId || n.inputId
61
+ inputId: t.inputId || r.inputId
61
62
  });
62
63
  return {
63
- ...n,
64
- inputId: r.inputId,
65
- ...r.kind ? { kind: r.kind } : {},
66
- ...r.controlRole ? { controlRole: r.controlRole } : {},
67
- ...r.operator ? { operator: r.operator } : {},
68
- ...r.field ? { field: r.field } : {},
69
- ...r.relationshipHint ? { relationshipHint: r.relationshipHint } : {}
64
+ ...r,
65
+ inputId: n.inputId,
66
+ ...n.kind ? { kind: n.kind } : {},
67
+ ...n.controlRole ? { controlRole: n.controlRole } : {},
68
+ ...n.operator ? { operator: n.operator } : {},
69
+ ...n.field ? { field: n.field } : {},
70
+ ...n.relationshipHint ? { relationshipHint: n.relationshipHint } : {}
70
71
  };
71
72
  }
72
73
  };
@@ -127,7 +128,2230 @@ const He = {
127
128
  queryKind: "matrix"
128
129
  };
129
130
  }
130
- }, ie = [
131
+ }, ge = 10, he = 100, _t = 25, Ft = 500, Xe = {
132
+ enabled: !1,
133
+ queries: [],
134
+ getQuery: () => {
135
+ },
136
+ getQueries: () => []
137
+ }, Ee = ce(null), Te = ce(null), ke = ce(
138
+ void 0
139
+ ), M = [];
140
+ function Wt({
141
+ debug: e,
142
+ children: t
143
+ }) {
144
+ const r = b(() => Cr(e), [e]), [n, i] = kt(
145
+ xr,
146
+ r,
147
+ dt
148
+ ), d = C(n), l = Ye(), [u, c] = H({ open: !1 });
149
+ d.current = n, B(() => {
150
+ i({ type: "config", config: r });
151
+ }, [r]), B(() => {
152
+ if (!n.enabled || !n.exposeWindowBridge || typeof window > "u")
153
+ return;
154
+ const v = Er(() => d.current);
155
+ return Nt({
156
+ ownerId: l,
157
+ bridge: v
158
+ }), () => {
159
+ Mt(l);
160
+ };
161
+ }, [l, n.enabled, n.exposeWindowBridge]);
162
+ const f = b(() => ({ state: n, dispatch: i }), [n]), h = D((v) => {
163
+ c({ open: !0, focus: v });
164
+ }, []), g = D(() => {
165
+ c((v) => ({ ...v, open: !1 }));
166
+ }, []), y = D((v) => {
167
+ c({ open: !0, focus: v });
168
+ }, []), m = b(
169
+ () => ({
170
+ open: u.open,
171
+ focus: u.focus,
172
+ openDevtools: h,
173
+ closeDevtools: g,
174
+ focusTrace: y
175
+ }),
176
+ [
177
+ g,
178
+ y,
179
+ h,
180
+ u.focus,
181
+ u.open
182
+ ]
183
+ );
184
+ return /* @__PURE__ */ s(Ee.Provider, { value: f, children: /* @__PURE__ */ s(Te.Provider, { value: m, children: t }) });
185
+ }
186
+ function Nt(e) {
187
+ const t = M.findIndex(
188
+ (r) => r.ownerId === e.ownerId
189
+ );
190
+ t >= 0 && M.splice(t, 1), M.push(e), Ze();
191
+ }
192
+ function Mt(e) {
193
+ const t = M.findIndex(
194
+ (r) => r.ownerId === e
195
+ );
196
+ t >= 0 && M.splice(t, 1), Ze();
197
+ }
198
+ function Ze() {
199
+ if (typeof window > "u")
200
+ return;
201
+ const e = M[M.length - 1];
202
+ e ? window.__SEMAPHOR_DEVTOOLS__ = e.bridge : delete window.__SEMAPHOR_DEVTOOLS__;
203
+ }
204
+ function On({
205
+ id: e,
206
+ title: t,
207
+ children: r
208
+ }) {
209
+ const n = b(() => ({ id: e, title: t }), [e, t]);
210
+ return /* @__PURE__ */ s(ke.Provider, { value: n, children: r });
211
+ }
212
+ function Ln({
213
+ buttonPosition: e = "bottom-right",
214
+ initialIsOpen: t = !1,
215
+ panelPosition: r = "right",
216
+ className: n,
217
+ style: i
218
+ } = {}) {
219
+ const d = et(), l = z(Te), [u, c] = H(""), [f, h] = H(!1), g = C(null), y = C(null), m = l == null ? void 0 : l.openDevtools, v = l == null ? void 0 : l.closeDevtools, A = (l == null ? void 0 : l.open) === !0;
220
+ B(() => {
221
+ at();
222
+ }, []), B(() => {
223
+ t && d.enabled && (m == null || m());
224
+ }, [t, d.enabled, m]), B(() => {
225
+ if (!A || !v)
226
+ return;
227
+ const w = (q) => {
228
+ var E, L;
229
+ const O = q.target;
230
+ O instanceof Node && ((E = g.current) != null && E.contains(O) || (L = y.current) != null && L.contains(O) || v());
231
+ };
232
+ return document.addEventListener("pointerdown", w, !0), document.addEventListener("mousedown", w, !0), document.addEventListener("click", w, !0), () => {
233
+ document.removeEventListener("pointerdown", w, !0), document.removeEventListener("mousedown", w, !0), document.removeEventListener("click", w, !0);
234
+ };
235
+ }, [v, A]);
236
+ const o = b(
237
+ () => Yt(d.queries),
238
+ [d.queries]
239
+ ), S = b(
240
+ () => Xt(d.queries, u),
241
+ [d.queries, u]
242
+ ), T = b(
243
+ () => Zt(S),
244
+ [S]
245
+ ), k = b(
246
+ () => tt(S, l == null ? void 0 : l.focus) || S[0],
247
+ [S, l == null ? void 0 : l.focus]
248
+ );
249
+ return !d.enabled || !l ? null : /* @__PURE__ */ p(Tt, { children: [
250
+ /* @__PURE__ */ p(
251
+ "button",
252
+ {
253
+ ref: g,
254
+ type: "button",
255
+ "aria-label": "Open Semaphor DevTools",
256
+ title: "Open Semaphor DevTools",
257
+ className: n ? `${$} ${n}` : $,
258
+ style: {
259
+ ...a.launcher,
260
+ ...mr(e),
261
+ ...gr(o.severity),
262
+ ...i
263
+ },
264
+ onClick: () => l.openDevtools(),
265
+ children: [
266
+ /* @__PURE__ */ s(jt, {}),
267
+ /* @__PURE__ */ s("span", { style: a.launcherText, children: o.total }),
268
+ o.issueCount > 0 ? /* @__PURE__ */ s("span", { style: a.launcherIssueCount, children: o.issueCount }) : null
269
+ ]
270
+ }
271
+ ),
272
+ l.open ? /* @__PURE__ */ p(
273
+ "div",
274
+ {
275
+ ref: y,
276
+ role: "dialog",
277
+ "aria-label": "Semaphor DevTools",
278
+ "aria-modal": "false",
279
+ className: $,
280
+ style: {
281
+ ...a.panel,
282
+ ...hr(r),
283
+ ...f ? a.panelFullscreen : null
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ p("div", { style: a.panelHeader, children: [
287
+ /* @__PURE__ */ p("div", { style: a.panelTitleBlock, children: [
288
+ /* @__PURE__ */ s("div", { style: a.panelTitle, children: "Semaphor DevTools" }),
289
+ /* @__PURE__ */ p("div", { style: a.panelSubtitle, children: [
290
+ o.total,
291
+ " queries · ",
292
+ o.loading,
293
+ " loading ·",
294
+ " ",
295
+ o.failed,
296
+ " failed"
297
+ ] })
298
+ ] }),
299
+ /* @__PURE__ */ p("div", { style: a.panelActions, children: [
300
+ /* @__PURE__ */ s(
301
+ "button",
302
+ {
303
+ type: "button",
304
+ "aria-label": f ? "Exit fullscreen Semaphor DevTools" : "Enter fullscreen Semaphor DevTools",
305
+ title: f ? "Exit fullscreen Semaphor DevTools" : "Enter fullscreen Semaphor DevTools",
306
+ style: a.iconButton,
307
+ onClick: () => h((w) => !w),
308
+ children: f ? /* @__PURE__ */ s(Ct, { size: 15 }) : /* @__PURE__ */ s(Dt, { size: 15 })
309
+ }
310
+ ),
311
+ /* @__PURE__ */ s(
312
+ "button",
313
+ {
314
+ type: "button",
315
+ "aria-label": "Close Semaphor DevTools",
316
+ style: a.iconButton,
317
+ onClick: l.closeDevtools,
318
+ children: /* @__PURE__ */ s(Bt, { size: 15 })
319
+ }
320
+ )
321
+ ] })
322
+ ] }),
323
+ /* @__PURE__ */ p("label", { style: a.searchBox, children: [
324
+ /* @__PURE__ */ s(Ot, { size: 14 }),
325
+ /* @__PURE__ */ s(
326
+ "input",
327
+ {
328
+ "aria-label": "Search Semaphor traces",
329
+ value: u,
330
+ onChange: (w) => c(w.currentTarget.value),
331
+ placeholder: "Search traces",
332
+ style: a.searchInput
333
+ }
334
+ )
335
+ ] }),
336
+ /* @__PURE__ */ p(
337
+ "div",
338
+ {
339
+ style: {
340
+ ...a.panelBody,
341
+ ...yr(r)
342
+ },
343
+ children: [
344
+ /* @__PURE__ */ s(
345
+ "div",
346
+ {
347
+ style: {
348
+ ...a.queryList,
349
+ ...vr()
350
+ },
351
+ "aria-label": "Registered queries",
352
+ children: S.length ? T.map((w) => /* @__PURE__ */ p("div", { style: a.queryGroup, children: [
353
+ /* @__PURE__ */ p("div", { style: a.queryGroupHeader, children: [
354
+ /* @__PURE__ */ s("span", { children: w.title }),
355
+ /* @__PURE__ */ s("span", { style: a.queryGroupCount, children: w.traces.length })
356
+ ] }),
357
+ w.traces.length ? w.traces.map((q) => {
358
+ var K;
359
+ const O = tr(q, k), E = Ce(q), L = rt(q.queryKind), x = fe(q);
360
+ return /* @__PURE__ */ p(
361
+ "button",
362
+ {
363
+ type: "button",
364
+ title: `${E} · ${L} · ${x}`,
365
+ style: {
366
+ ...a.queryListItem,
367
+ ...O ? a.queryListItemSelected : null
368
+ },
369
+ onClick: () => l.focusTrace({
370
+ traceId: q.traceId,
371
+ queryId: q.queryId,
372
+ viewId: q.viewId
373
+ }),
374
+ children: [
375
+ /* @__PURE__ */ p("span", { style: a.queryListItemHeader, children: [
376
+ /* @__PURE__ */ s(Vt, { status: (K = q.latestAttempt) == null ? void 0 : K.status }),
377
+ /* @__PURE__ */ s("span", { style: a.queryListTitle, title: E, children: E }),
378
+ /* @__PURE__ */ s("span", { style: a.queryListKindChip, children: L })
379
+ ] }),
380
+ /* @__PURE__ */ s(
381
+ "span",
382
+ {
383
+ className: `${$}-source`,
384
+ style: a.queryListSource,
385
+ title: x,
386
+ children: x
387
+ }
388
+ )
389
+ ]
390
+ },
391
+ Re(q)
392
+ );
393
+ }) : /* @__PURE__ */ s("div", { style: a.queryGroupEmpty, children: "No input traces" })
394
+ ] }, w.title)) : /* @__PURE__ */ s("div", { style: a.emptyState, children: "No matching traces" })
395
+ }
396
+ ),
397
+ /* @__PURE__ */ s(Pt, { trace: k })
398
+ ]
399
+ }
400
+ )
401
+ ]
402
+ }
403
+ ) : null
404
+ ] });
405
+ }
406
+ function Bn({
407
+ queryId: e,
408
+ viewId: t,
409
+ label: r,
410
+ className: n,
411
+ style: i
412
+ } = {}) {
413
+ var g, y;
414
+ const d = et(), l = z(Te), u = z(ke);
415
+ B(() => {
416
+ at();
417
+ }, []);
418
+ const c = t || (u == null ? void 0 : u.id), f = b(
419
+ () => er(d.queries, {
420
+ queryId: e,
421
+ viewId: c
422
+ }),
423
+ [
424
+ d.queries,
425
+ e,
426
+ c
427
+ ]
428
+ );
429
+ if (!d.enabled || !l || !f)
430
+ return null;
431
+ const h = r || `Inspect ${Ce(f)}`;
432
+ return /* @__PURE__ */ p(
433
+ "button",
434
+ {
435
+ type: "button",
436
+ "aria-label": h,
437
+ title: h,
438
+ className: n ? `${$} ${n}` : $,
439
+ style: {
440
+ ...a.inspectButton,
441
+ ...br((g = f.latestAttempt) == null ? void 0 : g.status),
442
+ ...i
443
+ },
444
+ onClick: () => l.openDevtools({
445
+ traceId: f.traceId,
446
+ queryId: f.queryId,
447
+ viewId: f.viewId
448
+ }),
449
+ children: [
450
+ /* @__PURE__ */ s(Lt, { size: 13 }),
451
+ /* @__PURE__ */ s("span", { style: a.inspectButtonText, children: ((y = f.latestAttempt) == null ? void 0 : y.status) || "idle" })
452
+ ]
453
+ }
454
+ );
455
+ }
456
+ function et() {
457
+ const e = z(Ee);
458
+ return !e || !e.state.enabled ? Xe : le(e.state);
459
+ }
460
+ function zt({
461
+ spec: e,
462
+ queryKind: t,
463
+ queryKey: r,
464
+ intent: n,
465
+ activeInputs: i,
466
+ debug: d
467
+ }) {
468
+ const l = z(Ee), u = z(ke), c = !!(l != null && l.state.enabled), f = l == null ? void 0 : l.dispatch, h = Dr(e), g = e.label, y = b(
469
+ () => JSON.stringify(e),
470
+ [e]
471
+ ), m = b(
472
+ () => JSON.stringify(i || []),
473
+ [i]
474
+ ), v = b(
475
+ () => JSON.stringify(n || null),
476
+ [n]
477
+ ), A = C(e), o = C(y), S = C(n), T = C(v), k = C(i), w = C(m);
478
+ o.current !== y && (o.current = y, A.current = e), T.current !== v && (T.current = v, S.current = n), w.current !== m && (w.current = m, k.current = i);
479
+ const q = A.current, O = S.current, E = k.current, L = Ye(), x = b(
480
+ () => h || `query_${pt(r)}`,
481
+ [r, h]
482
+ ), K = (d == null ? void 0 : d.viewId) || (u == null ? void 0 : u.id), Be = (d == null ? void 0 : d.title) || (u == null ? void 0 : u.title), W = b(
483
+ () => [
484
+ K || "unscoped-view",
485
+ x,
486
+ L
487
+ ].join("::"),
488
+ [x, L, K]
489
+ ), Ke = b(
490
+ () => ({
491
+ traceKey: W,
492
+ spec: q,
493
+ queryId: x,
494
+ queryLabel: g,
495
+ queryKind: t,
496
+ builder: Or(t),
497
+ viewId: K,
498
+ viewTitle: Be,
499
+ intent: O,
500
+ activeInputs: E,
501
+ clientWarnings: h ? [] : ["Query spec is missing an explicit id; using an opaque internal id."]
502
+ }),
503
+ [
504
+ x,
505
+ t,
506
+ h,
507
+ g,
508
+ q,
509
+ E,
510
+ O,
511
+ W,
512
+ K,
513
+ Be
514
+ ]
515
+ );
516
+ B(() => {
517
+ if (!(!c || !f))
518
+ return f({ type: "register", descriptor: Ke }), () => {
519
+ f({ type: "unregister", traceKey: W });
520
+ };
521
+ }, [Ke, f, c, W]);
522
+ const _ = D(
523
+ (R, j) => {
524
+ !c || !f || f({ type: "event", traceKey: W, event: R, latestAttempt: j });
525
+ },
526
+ [f, c, W]
527
+ ), $e = D(() => {
528
+ _(
529
+ {
530
+ type: "query_started",
531
+ queryId: x,
532
+ at: se()
533
+ },
534
+ { status: "loading" }
535
+ );
536
+ }, [_, x]), _e = D(
537
+ (R, j) => {
538
+ const J = Qe(R), Y = Nr(R), vt = Mr(R);
539
+ _(
540
+ {
541
+ type: "query_succeeded",
542
+ queryId: x,
543
+ requestId: J,
544
+ at: se(),
545
+ rowCount: Y,
546
+ durationMs: j
547
+ },
548
+ {
549
+ requestId: J,
550
+ status: "success",
551
+ durationMs: j,
552
+ rowCount: Y,
553
+ columnCount: vt,
554
+ executionResult: Ve(R)
555
+ }
556
+ );
557
+ },
558
+ [_, x]
559
+ ), re = D(
560
+ (R, j) => {
561
+ const J = Qe(R), Y = R instanceof Error ? R.message : String(R);
562
+ _(
563
+ {
564
+ type: "query_failed",
565
+ queryId: x,
566
+ requestId: J,
567
+ at: se(),
568
+ errorMessage: Y
569
+ },
570
+ {
571
+ requestId: J,
572
+ status: "error",
573
+ durationMs: j,
574
+ errorMessage: Y,
575
+ executionResult: Ve(R)
576
+ }
577
+ );
578
+ },
579
+ [_, x]
580
+ ), Fe = D(
581
+ (R) => {
582
+ _(
583
+ {
584
+ type: "query_ignored_stale",
585
+ queryId: x,
586
+ at: se(),
587
+ reason: R
588
+ }
589
+ );
590
+ },
591
+ [_, x]
592
+ ), We = D(
593
+ (R) => {
594
+ re(R, 0);
595
+ },
596
+ [re]
597
+ ), me = c ? l == null ? void 0 : l.state.entries[W] : void 0;
598
+ return b(
599
+ () => ({
600
+ enabled: c,
601
+ queryId: x,
602
+ trace: me ? de(me) : void 0,
603
+ start: $e,
604
+ success: _e,
605
+ failure: re,
606
+ ignored: Fe,
607
+ validationFailure: We
608
+ }),
609
+ [
610
+ c,
611
+ re,
612
+ Fe,
613
+ x,
614
+ $e,
615
+ _e,
616
+ me,
617
+ We
618
+ ]
619
+ );
620
+ }
621
+ function jt() {
622
+ return /* @__PURE__ */ s("span", { style: a.logoMark, "aria-hidden": !0, children: /* @__PURE__ */ p(
623
+ "svg",
624
+ {
625
+ viewBox: "0 0 100 100",
626
+ fill: "none",
627
+ width: "16",
628
+ height: "16",
629
+ focusable: "false",
630
+ children: [
631
+ /* @__PURE__ */ s("rect", { x: "20", y: "15", width: "60", height: "12", rx: "6", fill: "currentColor" }),
632
+ /* @__PURE__ */ s("rect", { x: "20", y: "35", width: "40", height: "12", rx: "6", fill: "currentColor" }),
633
+ /* @__PURE__ */ s("rect", { x: "40", y: "55", width: "40", height: "12", rx: "6", fill: "currentColor" }),
634
+ /* @__PURE__ */ s("rect", { x: "20", y: "75", width: "60", height: "12", rx: "6", fill: "currentColor" })
635
+ ]
636
+ }
637
+ ) });
638
+ }
639
+ function Pt({
640
+ trace: e
641
+ }) {
642
+ var m, v, A, o, S;
643
+ if (!e)
644
+ return /* @__PURE__ */ s("div", { style: a.detailsPane, children: /* @__PURE__ */ s("div", { style: a.emptyState, children: "No traces registered yet" }) });
645
+ const t = e.latestAttempt, r = t == null ? void 0 : t.executionResult, n = ye(
646
+ (m = r == null ? void 0 : r.validation) == null ? void 0 : m.warnings
647
+ ), i = ye((v = r == null ? void 0 : r.validation) == null ? void 0 : v.errors), d = ye(
648
+ (A = r == null ? void 0 : r.coverage) == null ? void 0 : A.missingObligations
649
+ ), l = r == null ? void 0 : r.compiledQuery, u = t != null && t.errorMessage ? [t.errorMessage] : [], c = [
650
+ ...e.clientWarnings,
651
+ ...n,
652
+ ...i,
653
+ ...d
654
+ ], f = fe(e), h = e.viewId ? `${e.viewId} - ${e.queryId}` : e.queryId, g = e.inputsApplied.length > 0, y = !!(l || (o = e.server) != null && o.compiledSql);
655
+ return /* @__PURE__ */ p("div", { style: a.detailsPane, children: [
656
+ /* @__PURE__ */ p("div", { style: a.detailsHeader, children: [
657
+ /* @__PURE__ */ p("div", { style: a.detailsHeaderTopRow, children: [
658
+ /* @__PURE__ */ s(
659
+ "span",
660
+ {
661
+ "aria-hidden": !0,
662
+ style: {
663
+ ...a.detailsHeaderStatusDot,
664
+ ...st(t == null ? void 0 : t.status)
665
+ }
666
+ }
667
+ ),
668
+ /* @__PURE__ */ s("span", { style: a.detailsTitle, children: Ce(e) }),
669
+ /* @__PURE__ */ s("span", { style: a.detailsKindChip, children: rt(e.queryKind) })
670
+ ] }),
671
+ /* @__PURE__ */ p("div", { style: a.detailsCaption, children: [
672
+ /* @__PURE__ */ s(
673
+ "span",
674
+ {
675
+ style: { ...a.detailsCaptionItem, ...a.detailsCaptionItemMono },
676
+ children: h
677
+ }
678
+ ),
679
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
680
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Source" }),
681
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: f })
682
+ ] }),
683
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
684
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Rows" }),
685
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: dr(t == null ? void 0 : t.rowCount) })
686
+ ] }),
687
+ /* @__PURE__ */ p("span", { style: a.detailsCaptionItem, children: [
688
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionLabel, children: "Duration" }),
689
+ /* @__PURE__ */ s("span", { style: a.detailsCaptionValue, children: lr(t == null ? void 0 : t.durationMs) })
690
+ ] })
691
+ ] })
692
+ ] }),
693
+ u.length ? /* @__PURE__ */ s(Ne, { tone: "error", title: "Error", items: u }) : null,
694
+ c.length ? /* @__PURE__ */ s(Ne, { tone: "warning", title: "Warnings", items: c }) : null,
695
+ /* @__PURE__ */ s(Qt, { trace: e }),
696
+ /* @__PURE__ */ s(Ht, { trace: e }),
697
+ g ? /* @__PURE__ */ s(Gt, { inputs: e.inputsApplied }) : null,
698
+ y ? /* @__PURE__ */ s(ae, { title: "Compiled query", children: /* @__PURE__ */ s(
699
+ Jt,
700
+ {
701
+ compiledQuery: l,
702
+ compiledSql: (S = e.server) == null ? void 0 : S.compiledSql
703
+ }
704
+ ) }) : null,
705
+ /* @__PURE__ */ s(ae, { title: "Lifecycle events", children: e.recentEvents.length ? /* @__PURE__ */ s("div", { style: a.eventList, children: e.recentEvents.slice(-5).map((T, k) => /* @__PURE__ */ p(
706
+ "div",
707
+ {
708
+ style: a.eventRow,
709
+ children: [
710
+ /* @__PURE__ */ s("span", { style: a.eventType, children: cr(T) }),
711
+ /* @__PURE__ */ s("span", { style: a.eventMeta, children: fr(T) })
712
+ ]
713
+ },
714
+ `${T.type}:${T.at}:${k}`
715
+ )) }) : /* @__PURE__ */ s("div", { style: a.mutedText, children: "No attempts recorded" }) }),
716
+ /* @__PURE__ */ s(ae, { title: "Raw trace JSON", children: /* @__PURE__ */ s("pre", { style: a.codeBlock, children: ur(e) }) })
717
+ ] });
718
+ }
719
+ function Ne({
720
+ tone: e,
721
+ title: t,
722
+ items: r
723
+ }) {
724
+ const n = e === "error" ? a.alertCardError : a.alertCardWarning;
725
+ return /* @__PURE__ */ p("div", { style: { ...a.alertCard, ...n }, children: [
726
+ /* @__PURE__ */ s("div", { style: a.alertCardTitle, children: t }),
727
+ r.length > 1 ? /* @__PURE__ */ s("ul", { style: a.alertCardList, children: r.map((i, d) => /* @__PURE__ */ s("li", { children: i }, `${e}-${d}`)) }) : /* @__PURE__ */ s("div", { children: r[0] })
728
+ ] });
729
+ }
730
+ function Vt({
731
+ status: e
732
+ }) {
733
+ return /* @__PURE__ */ s(
734
+ "span",
735
+ {
736
+ "aria-hidden": !0,
737
+ style: {
738
+ ...a.statusDot,
739
+ ...st(e)
740
+ }
741
+ }
742
+ );
743
+ }
744
+ function ae({
745
+ title: e,
746
+ children: t
747
+ }) {
748
+ return /* @__PURE__ */ p("details", { style: a.disclosure, children: [
749
+ /* @__PURE__ */ s("summary", { style: a.disclosureSummary, children: e }),
750
+ /* @__PURE__ */ s("div", { style: a.disclosureBody, children: t })
751
+ ] });
752
+ }
753
+ function Qt({
754
+ trace: e
755
+ }) {
756
+ var d;
757
+ const t = (d = e.projectionFieldRefs) != null && d.length ? e.projectionFieldRefs : e.fieldRefs, r = e.inputFieldRefs || [], n = rr(t), i = nr(e, n, t);
758
+ return /* @__PURE__ */ p("div", { style: a.recipe, children: [
759
+ /* @__PURE__ */ s("div", { style: a.recipeSummary, children: i.map((l) => /* @__PURE__ */ p("div", { style: a.recipeSummaryRow, children: [
760
+ /* @__PURE__ */ s("span", { style: a.recipeSummaryLabel, children: l.label }),
761
+ /* @__PURE__ */ s("span", { style: a.recipeSummaryValue, title: l.value, children: l.value })
762
+ ] }, l.label)) }),
763
+ /* @__PURE__ */ s(N, { title: "Measures", fields: n.measures }),
764
+ /* @__PURE__ */ s(N, { title: "Time fields", fields: n.timeFields }),
765
+ /* @__PURE__ */ s(
766
+ N,
767
+ {
768
+ title: "Dimensions",
769
+ fields: n.dimensions,
770
+ emptyText: "No dimensions selected"
771
+ }
772
+ ),
773
+ /* @__PURE__ */ s(N, { title: "Identifiers", fields: n.identifiers }),
774
+ /* @__PURE__ */ s(N, { title: "Other fields", fields: n.other }),
775
+ /* @__PURE__ */ s(N, { title: "Input bindings", fields: r })
776
+ ] });
777
+ }
778
+ function Ht({
779
+ trace: e
780
+ }) {
781
+ return !e.sourceRefs.length && !e.fieldRefs.length ? null : /* @__PURE__ */ s(ae, { title: "Sources and field refs", children: /* @__PURE__ */ p("div", { style: a.traceLineage, children: [
782
+ /* @__PURE__ */ s(Ut, { sources: e.sourceRefs }),
783
+ /* @__PURE__ */ s(
784
+ N,
785
+ {
786
+ title: "All field refs",
787
+ fields: e.fieldRefs,
788
+ emptyText: "No field refs captured"
789
+ }
790
+ )
791
+ ] }) });
792
+ }
793
+ function Ut({
794
+ sources: e
795
+ }) {
796
+ return /* @__PURE__ */ p("div", { style: a.recipeGroup, children: [
797
+ /* @__PURE__ */ p("div", { style: a.recipeGroupHeader, children: [
798
+ /* @__PURE__ */ s("span", { style: a.recipeGroupTitle, children: "Sources" }),
799
+ /* @__PURE__ */ s("span", { style: a.recipeGroupCount, children: e.length })
800
+ ] }),
801
+ e.length ? /* @__PURE__ */ s("div", { style: a.recipeFieldList, children: e.map((t, r) => /* @__PURE__ */ p(
802
+ "div",
803
+ {
804
+ style: a.recipeFieldRow,
805
+ title: Q(t),
806
+ children: [
807
+ /* @__PURE__ */ s("span", { style: a.recipeFieldName, children: Q(t) }),
808
+ /* @__PURE__ */ s("span", { style: a.recipeFieldMeta, children: t.kind })
809
+ ]
810
+ },
811
+ `${Q(t)}:${r}`
812
+ )) }) : /* @__PURE__ */ s("div", { style: a.recipeEmptyText, children: "No sources captured" })
813
+ ] });
814
+ }
815
+ function N({
816
+ title: e,
817
+ fields: t,
818
+ emptyText: r
819
+ }) {
820
+ return !t.length && !r ? null : /* @__PURE__ */ p("div", { style: a.recipeGroup, children: [
821
+ /* @__PURE__ */ p("div", { style: a.recipeGroupHeader, children: [
822
+ /* @__PURE__ */ s("span", { style: a.recipeGroupTitle, children: e }),
823
+ /* @__PURE__ */ s("span", { style: a.recipeGroupCount, children: t.length })
824
+ ] }),
825
+ t.length ? /* @__PURE__ */ s("div", { style: a.recipeFieldList, children: t.map((n, i) => {
826
+ const d = it(n), l = n.dataType && n.dataType !== "unknown" ? n.dataType : void 0, u = n.source ? Q(n.source) : void 0, c = [d, l, u].filter(Boolean).join(" · ");
827
+ return /* @__PURE__ */ p(
828
+ "div",
829
+ {
830
+ style: a.recipeFieldRow,
831
+ title: c,
832
+ children: [
833
+ /* @__PURE__ */ s("span", { style: a.recipeFieldName, children: d }),
834
+ /* @__PURE__ */ p("span", { style: a.recipeFieldMeta, children: [
835
+ l ? /* @__PURE__ */ s("span", { children: l }) : null,
836
+ l && u ? /* @__PURE__ */ s("span", { style: a.recipeFieldMetaDivider, children: " · " }) : null,
837
+ u ? /* @__PURE__ */ s("span", { children: u }) : null
838
+ ] })
839
+ ]
840
+ },
841
+ `${De(n)}:${i}`
842
+ );
843
+ }) }) : /* @__PURE__ */ s("div", { style: a.recipeEmptyText, children: r })
844
+ ] });
845
+ }
846
+ function Gt({
847
+ inputs: e
848
+ }) {
849
+ return /* @__PURE__ */ p("div", { style: a.inputsAppliedBlock, children: [
850
+ /* @__PURE__ */ p("div", { style: a.inputsAppliedHeader, children: [
851
+ /* @__PURE__ */ s("span", { style: a.inputsAppliedTitle, children: "Inputs applied" }),
852
+ /* @__PURE__ */ s("span", { style: a.inputsAppliedCount, children: e.length })
853
+ ] }),
854
+ /* @__PURE__ */ s("div", { style: a.inputRecipeList, children: e.map((t) => {
855
+ const r = ot(t);
856
+ return /* @__PURE__ */ p(
857
+ "div",
858
+ {
859
+ style: a.inputRecipeRow,
860
+ title: r.title,
861
+ children: [
862
+ /* @__PURE__ */ p("div", { style: a.inputRecipeHeader, children: [
863
+ /* @__PURE__ */ s("span", { style: a.inputRecipeId, title: t.inputId, children: t.inputId }),
864
+ r.operator ? /* @__PURE__ */ s("span", { style: a.inputOperatorBadge, children: r.operator }) : null,
865
+ /* @__PURE__ */ s("span", { style: a.inputValuePreview, title: r.value, children: r.value })
866
+ ] }),
867
+ r.binding ? /* @__PURE__ */ s("div", { style: a.inputRecipeBinding, title: r.binding, children: r.binding }) : null
868
+ ]
869
+ },
870
+ t.inputId
871
+ );
872
+ }) })
873
+ ] });
874
+ }
875
+ function Jt({
876
+ compiledQuery: e,
877
+ compiledSql: t
878
+ }) {
879
+ return (e == null ? void 0 : e.kind) === "sql" ? /* @__PURE__ */ p("div", { style: a.compiledQuery, children: [
880
+ /* @__PURE__ */ s(X, { label: "SQL", value: e.sql }),
881
+ e.pythonCode ? /* @__PURE__ */ s(X, { label: "Python", value: e.pythonCode }) : null,
882
+ e.parameters ? /* @__PURE__ */ s(
883
+ X,
884
+ {
885
+ label: "Parameters",
886
+ value: Ae(e.parameters)
887
+ }
888
+ ) : null
889
+ ] }) : t ? /* @__PURE__ */ s(X, { label: "SQL", value: t }) : /* @__PURE__ */ s(X, { label: "Compiled query", value: Ae(e) });
890
+ }
891
+ function X({
892
+ label: e,
893
+ value: t
894
+ }) {
895
+ return /* @__PURE__ */ p("div", { style: a.codeBlockGroup, children: [
896
+ /* @__PURE__ */ s("div", { style: a.codeBlockLabel, children: e }),
897
+ /* @__PURE__ */ s("pre", { style: a.codeBlock, children: t })
898
+ ] });
899
+ }
900
+ function Yt(e) {
901
+ const t = e.filter(
902
+ (i) => {
903
+ var d;
904
+ return ((d = i.latestAttempt) == null ? void 0 : d.status) === "error";
905
+ }
906
+ ).length, r = e.filter(
907
+ (i) => {
908
+ var d;
909
+ return ((d = i.latestAttempt) == null ? void 0 : d.status) === "loading";
910
+ }
911
+ ).length, n = e.filter(
912
+ (i) => {
913
+ var d, l, u, c;
914
+ return i.clientWarnings.length > 0 || !!((c = (u = (l = (d = i.latestAttempt) == null ? void 0 : d.executionResult) == null ? void 0 : l.validation) == null ? void 0 : u.warnings) != null && c.length);
915
+ }
916
+ ).length;
917
+ return {
918
+ total: e.length,
919
+ failed: t,
920
+ loading: r,
921
+ warningCount: n,
922
+ issueCount: t + n,
923
+ severity: t ? "error" : n ? "warning" : "ok"
924
+ };
925
+ }
926
+ function Xt(e, t) {
927
+ const r = t.trim().toLowerCase();
928
+ return r ? e.filter(
929
+ (n) => [
930
+ n.queryId,
931
+ n.queryLabel,
932
+ n.viewId,
933
+ n.builder,
934
+ n.queryKind,
935
+ fe(n)
936
+ ].filter(Boolean).join(" ").toLowerCase().includes(r)
937
+ ) : e;
938
+ }
939
+ function Zt(e) {
940
+ const t = e.filter((i) => i.queryKind === "inputOptions"), r = new Set(t.map(Re));
941
+ return [
942
+ { title: "Cards", traces: e.filter((i) => !r.has(Re(i))) },
943
+ { title: "Inputs", traces: t }
944
+ ];
945
+ }
946
+ function tt(e, t) {
947
+ if (!(!(t != null && t.traceId) && !(t != null && t.queryId) && !(t != null && t.viewId)))
948
+ return t.traceId ? e.find((r) => r.traceId === t.traceId) : e.find((r) => !(t.queryId && r.queryId !== t.queryId || t.viewId && r.viewId !== t.viewId));
949
+ }
950
+ function er(e, t) {
951
+ if (t.queryId)
952
+ return tt(e, t);
953
+ if (!t.viewId)
954
+ return;
955
+ const r = e.filter((n) => n.viewId === t.viewId);
956
+ return r.length === 1 ? r[0] : void 0;
957
+ }
958
+ function tr(e, t) {
959
+ return !!(e && t && e.traceId === t.traceId);
960
+ }
961
+ function Re(e) {
962
+ return e.traceId;
963
+ }
964
+ function rt(e) {
965
+ switch (e) {
966
+ case "metric":
967
+ return "metric";
968
+ case "records":
969
+ return "records";
970
+ case "matrix":
971
+ return "matrix";
972
+ case "analysis":
973
+ return "analysis";
974
+ case "inputOptions":
975
+ return "inputs";
976
+ case "sql":
977
+ return "sql";
978
+ default:
979
+ return pe(e);
980
+ }
981
+ }
982
+ function Ce(e) {
983
+ return e.queryLabel || e.viewId || e.queryId;
984
+ }
985
+ function fe(e) {
986
+ const t = e.sourceRefs.map(Q);
987
+ return t.length ? t.length === 1 ? t[0] : `${t[0]} + ${t.length - 1} more` : "No source";
988
+ }
989
+ function rr(e) {
990
+ return e.reduce(
991
+ (t, r) => (r.role === "measure" ? t.measures.push(r) : r.role === "date" ? t.timeFields.push(r) : r.role === "dimension" ? t.dimensions.push(r) : r.role === "id" ? t.identifiers.push(r) : t.other.push(r), t),
992
+ {
993
+ measures: [],
994
+ timeFields: [],
995
+ dimensions: [],
996
+ identifiers: [],
997
+ other: []
998
+ }
999
+ );
1000
+ }
1001
+ function nr(e, t, r) {
1002
+ const n = [
1003
+ {
1004
+ label: "Operation",
1005
+ value: ir(e)
1006
+ }
1007
+ ], i = or(e, t, r);
1008
+ i && n.push(i);
1009
+ const d = sr(t);
1010
+ d && n.push({
1011
+ label: "Grouped by",
1012
+ value: d
1013
+ });
1014
+ const l = ar(e.inputsApplied);
1015
+ return l && n.push({
1016
+ label: "Filtered by",
1017
+ value: l
1018
+ }), n.push({
1019
+ label: "Source",
1020
+ value: fe(e)
1021
+ }), n;
1022
+ }
1023
+ function ir(e) {
1024
+ var t, r;
1025
+ if (e.queryKind === "records" && ((t = e.projectionFieldRefs) != null && t.length) && e.projectionFieldRefs.every((n) => n.role === "measure") && ((r = e.latestAttempt) == null ? void 0 : r.rowCount) === 1)
1026
+ return "KPI query";
1027
+ switch (e.queryKind) {
1028
+ case "metric":
1029
+ return "KPI query";
1030
+ case "records":
1031
+ return "Records query";
1032
+ case "matrix":
1033
+ return "Matrix query";
1034
+ case "analysis":
1035
+ return "Analysis query";
1036
+ case "inputOptions":
1037
+ return "Input options query";
1038
+ case "sql":
1039
+ return "SQL query";
1040
+ default:
1041
+ return pe(e.queryKind);
1042
+ }
1043
+ }
1044
+ function or(e, t, r) {
1045
+ if (e.queryKind === "records")
1046
+ return {
1047
+ label: t.measures.length ? "Computes" : "Selects",
1048
+ value: Z(r)
1049
+ };
1050
+ if (e.queryKind === "inputOptions")
1051
+ return {
1052
+ label: "Options from",
1053
+ value: Z(r)
1054
+ };
1055
+ if (t.measures.length)
1056
+ return {
1057
+ label: "Computes",
1058
+ value: Z(t.measures)
1059
+ };
1060
+ if (r.length)
1061
+ return {
1062
+ label: "Uses",
1063
+ value: Z(r)
1064
+ };
1065
+ if (e.queryKind === "sql")
1066
+ return {
1067
+ label: "Inspect",
1068
+ value: "Open compiled query for SQL or Python."
1069
+ };
1070
+ }
1071
+ function sr(e) {
1072
+ const t = [
1073
+ ...e.dimensions,
1074
+ ...e.timeFields
1075
+ ];
1076
+ return t.length ? Z(t) : void 0;
1077
+ }
1078
+ function ar(e) {
1079
+ if (e.length)
1080
+ return nt(
1081
+ e.map((t) => {
1082
+ const r = ot(t);
1083
+ return [
1084
+ t.inputId,
1085
+ r.operator,
1086
+ r.value
1087
+ ].filter(Boolean).join(" ");
1088
+ })
1089
+ );
1090
+ }
1091
+ function Z(e) {
1092
+ return nt(e.map(it));
1093
+ }
1094
+ function nt(e) {
1095
+ const t = e.filter(Boolean);
1096
+ return t.length === 0 ? "-" : t.length === 1 ? t[0] : t.length === 2 ? `${t[0]} and ${t[1]}` : `${t.slice(0, -1).join(", ")}, and ${t[t.length - 1]}`;
1097
+ }
1098
+ function it(e) {
1099
+ return [e.aggregate, e.label || e.name].filter(Boolean).join(" ");
1100
+ }
1101
+ function ot(e) {
1102
+ var l, u, c;
1103
+ const t = e.valuePreview || "redacted", r = ((l = e.fieldRef) == null ? void 0 : l.label) || ((u = e.fieldRef) == null ? void 0 : u.name), n = (c = e.fieldRef) != null && c.source ? Q(e.fieldRef.source) : void 0, i = [r ? `on ${r}` : void 0, n].filter(Boolean).join(" · "), d = [
1104
+ e.inputId,
1105
+ e.operator,
1106
+ t,
1107
+ i
1108
+ ].filter(Boolean).join(" - ");
1109
+ return {
1110
+ operator: e.operator,
1111
+ value: t,
1112
+ binding: i,
1113
+ title: d
1114
+ };
1115
+ }
1116
+ function Q(e) {
1117
+ return e.kind === "semantic" ? e.datasetName || e.datasetId || e.domainId : e.kind === "physical" ? [
1118
+ e.schemaName,
1119
+ e.tableName
1120
+ ].filter(Boolean).join(".") || e.tableName : e.connectionId ? `SQL ${e.connectionId}` : "SQL source";
1121
+ }
1122
+ function dr(e) {
1123
+ return typeof e == "number" ? e.toLocaleString() : "-";
1124
+ }
1125
+ function lr(e) {
1126
+ return typeof e == "number" ? `${Math.round(e)}ms` : "-";
1127
+ }
1128
+ function ur(e) {
1129
+ return Ae(e);
1130
+ }
1131
+ function Ae(e) {
1132
+ return JSON.stringify(e, null, 2) ?? "undefined";
1133
+ }
1134
+ function cr(e) {
1135
+ switch (e.type) {
1136
+ case "query_started":
1137
+ return "Started";
1138
+ case "query_succeeded":
1139
+ return "Succeeded";
1140
+ case "query_failed":
1141
+ return "Failed";
1142
+ case "query_ignored_stale":
1143
+ return "Ignored stale";
1144
+ case "input_changed":
1145
+ return "Input changed";
1146
+ default:
1147
+ return pr(e);
1148
+ }
1149
+ }
1150
+ function fr(e) {
1151
+ return [
1152
+ e.at,
1153
+ "durationMs" in e && typeof e.durationMs == "number" ? `${Math.round(e.durationMs)}ms` : void 0,
1154
+ "rowCount" in e && typeof e.rowCount == "number" ? `${e.rowCount} rows` : void 0,
1155
+ "reason" in e ? e.reason : void 0,
1156
+ "errorMessage" in e ? e.errorMessage : void 0
1157
+ ].filter(Boolean).join(" - ");
1158
+ }
1159
+ function pr(e) {
1160
+ throw new Error(`Unsupported Semaphor trace event: ${JSON.stringify(e)}`);
1161
+ }
1162
+ function ye(e) {
1163
+ return Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
1164
+ }
1165
+ function mr(e) {
1166
+ return e === "relative" ? {
1167
+ position: "relative",
1168
+ top: "auto",
1169
+ right: "auto",
1170
+ bottom: "auto",
1171
+ left: "auto"
1172
+ } : {
1173
+ top: e.startsWith("top") ? 20 : "auto",
1174
+ right: e.endsWith("right") ? 20 : "auto",
1175
+ bottom: e.startsWith("bottom") ? 20 : "auto",
1176
+ left: e.endsWith("left") ? 20 : "auto"
1177
+ };
1178
+ }
1179
+ function gr(e) {
1180
+ return e === "error" ? {
1181
+ borderColor: "var(--sd-error-border)",
1182
+ background: "var(--sd-error-bg)",
1183
+ color: "var(--sd-error-fg)"
1184
+ } : e === "warning" ? {
1185
+ borderColor: "var(--sd-warning-border)",
1186
+ background: "var(--sd-warning-bg)",
1187
+ color: "var(--sd-warning-fg)"
1188
+ } : {
1189
+ borderColor: "var(--sd-success-border)",
1190
+ background: "var(--sd-success-bg)",
1191
+ color: "var(--sd-success-fg)"
1192
+ };
1193
+ }
1194
+ function hr(e) {
1195
+ return e === "right" ? {
1196
+ top: 16,
1197
+ right: 16,
1198
+ bottom: 16,
1199
+ left: "auto",
1200
+ width: "min(720px, calc(100vw - 32px))",
1201
+ height: "auto",
1202
+ borderRadius: 6
1203
+ } : {
1204
+ top: "auto",
1205
+ right: 16,
1206
+ bottom: 16,
1207
+ left: 16,
1208
+ width: "auto",
1209
+ height: "min(420px, 45vh)",
1210
+ borderRadius: 6
1211
+ };
1212
+ }
1213
+ function yr(e) {
1214
+ return e === "right" ? {
1215
+ gridTemplateColumns: "minmax(210px, 280px) minmax(0, 1fr)"
1216
+ } : {
1217
+ gridTemplateColumns: "minmax(260px, 340px) minmax(0, 1fr)"
1218
+ };
1219
+ }
1220
+ function vr(e) {
1221
+ return {
1222
+ borderRight: "1px solid var(--sd-border)",
1223
+ borderBottom: 0
1224
+ };
1225
+ }
1226
+ function st(e) {
1227
+ return e === "error" ? { background: "var(--sd-error-dot)" } : e === "success" ? { background: "var(--sd-success-dot)" } : e === "loading" ? { background: "var(--sd-loading-dot)" } : { background: "var(--sd-idle-dot)" };
1228
+ }
1229
+ function br(e) {
1230
+ return e === "error" ? {
1231
+ borderColor: "var(--sd-error-border)",
1232
+ color: "var(--sd-error-fg)"
1233
+ } : e === "success" ? {
1234
+ borderColor: "var(--sd-success-border)",
1235
+ color: "var(--sd-success-fg)"
1236
+ } : e === "loading" ? {
1237
+ borderColor: "var(--sd-loading-border)",
1238
+ color: "var(--sd-loading-fg)"
1239
+ } : {
1240
+ borderColor: "var(--sd-border)",
1241
+ color: "var(--sd-fg-muted)"
1242
+ };
1243
+ }
1244
+ const Me = "semaphor-devtools-stylesheet", $ = "semaphor-devtools", Sr = `
1245
+ .${$} {
1246
+ --sd-bg: #ffffff;
1247
+ --sd-bg-muted: #fafafa;
1248
+ --sd-bg-raised: #ffffff;
1249
+ --sd-bg-accent: #f4f4f5;
1250
+ --sd-fg: #18181b;
1251
+ --sd-fg-muted: #71717a;
1252
+ --sd-fg-subtle: #a1a1aa;
1253
+ --sd-border: #e4e4e7;
1254
+ --sd-border-soft: #f4f4f5;
1255
+ --sd-border-strong: #d4d4d8;
1256
+ --sd-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
1257
+ --sd-success-bg: #f0fdf4;
1258
+ --sd-success-fg: #166534;
1259
+ --sd-success-border: #bbf7d0;
1260
+ --sd-success-dot: #16a34a;
1261
+ --sd-warning-bg: #fff7ed;
1262
+ --sd-warning-fg: #9a3412;
1263
+ --sd-warning-border: #fed7aa;
1264
+ --sd-warning-dot: #f59e0b;
1265
+ --sd-error-bg: #fef2f2;
1266
+ --sd-error-fg: #991b1b;
1267
+ --sd-error-border: #fecaca;
1268
+ --sd-error-dot: #dc2626;
1269
+ --sd-loading-bg: #eff6ff;
1270
+ --sd-loading-fg: #1d4ed8;
1271
+ --sd-loading-border: #bfdbfe;
1272
+ --sd-loading-dot: #2563eb;
1273
+ --sd-idle-dot: #94a3b8;
1274
+ }
1275
+
1276
+ @media (prefers-color-scheme: dark) {
1277
+ .${$} {
1278
+ --sd-bg: #09090b;
1279
+ --sd-bg-muted: #18181b;
1280
+ --sd-bg-raised: #18181b;
1281
+ --sd-bg-accent: #1f1f23;
1282
+ --sd-fg: #fafafa;
1283
+ --sd-fg-muted: #a1a1aa;
1284
+ --sd-fg-subtle: #71717a;
1285
+ --sd-border: #27272a;
1286
+ --sd-border-soft: #1f1f23;
1287
+ --sd-border-strong: #3f3f46;
1288
+ --sd-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
1289
+ --sd-success-bg: rgba(34, 197, 94, 0.12);
1290
+ --sd-success-fg: #86efac;
1291
+ --sd-success-border: rgba(34, 197, 94, 0.35);
1292
+ --sd-warning-bg: rgba(249, 115, 22, 0.12);
1293
+ --sd-warning-fg: #fdba74;
1294
+ --sd-warning-border: rgba(249, 115, 22, 0.35);
1295
+ --sd-error-bg: rgba(239, 68, 68, 0.12);
1296
+ --sd-error-fg: #fca5a5;
1297
+ --sd-error-border: rgba(239, 68, 68, 0.35);
1298
+ --sd-loading-bg: rgba(59, 130, 246, 0.12);
1299
+ --sd-loading-fg: #93c5fd;
1300
+ --sd-loading-border: rgba(59, 130, 246, 0.35);
1301
+ }
1302
+ }
1303
+
1304
+ .${$}-source {
1305
+ display: -webkit-box;
1306
+ -webkit-line-clamp: 2;
1307
+ -webkit-box-orient: vertical;
1308
+ overflow: hidden;
1309
+ word-break: break-all;
1310
+ }
1311
+ `;
1312
+ function at() {
1313
+ if (typeof document > "u" || document.getElementById(Me))
1314
+ return;
1315
+ const e = document.createElement("style");
1316
+ e.id = Me, e.textContent = Sr, document.head.appendChild(e);
1317
+ }
1318
+ const ie = 'ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif', oe = "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace", ve = {
1319
+ color: "var(--sd-fg-muted)",
1320
+ fontSize: 10,
1321
+ fontWeight: 600,
1322
+ textTransform: "uppercase",
1323
+ letterSpacing: "0.08em"
1324
+ }, a = {
1325
+ launcher: {
1326
+ position: "fixed",
1327
+ bottom: 20,
1328
+ zIndex: 2147483e3,
1329
+ display: "inline-flex",
1330
+ alignItems: "center",
1331
+ gap: 7,
1332
+ height: 36,
1333
+ minWidth: 36,
1334
+ padding: "0 10px",
1335
+ borderWidth: 1,
1336
+ borderStyle: "solid",
1337
+ borderRadius: 6,
1338
+ boxShadow: "var(--sd-shadow)",
1339
+ font: `600 12px/1.2 ${ie}`,
1340
+ cursor: "pointer"
1341
+ },
1342
+ launcherText: {
1343
+ fontVariantNumeric: "tabular-nums"
1344
+ },
1345
+ launcherIssueCount: {
1346
+ display: "grid",
1347
+ minWidth: 16,
1348
+ height: 16,
1349
+ placeItems: "center",
1350
+ borderRadius: 8,
1351
+ background: "currentColor",
1352
+ color: "var(--sd-bg)",
1353
+ fontSize: 10,
1354
+ lineHeight: "16px"
1355
+ },
1356
+ logoMark: {
1357
+ display: "grid",
1358
+ width: 18,
1359
+ height: 18,
1360
+ placeItems: "center",
1361
+ flex: "0 0 auto",
1362
+ borderRadius: 4,
1363
+ background: "var(--sd-fg)",
1364
+ color: "var(--sd-bg)"
1365
+ },
1366
+ panel: {
1367
+ position: "fixed",
1368
+ top: 16,
1369
+ right: 16,
1370
+ bottom: 16,
1371
+ zIndex: 2147483001,
1372
+ width: "min(720px, calc(100vw - 32px))",
1373
+ display: "flex",
1374
+ flexDirection: "column",
1375
+ overflow: "hidden",
1376
+ border: "1px solid var(--sd-border)",
1377
+ borderRadius: 6,
1378
+ background: "var(--sd-bg)",
1379
+ color: "var(--sd-fg)",
1380
+ boxShadow: "var(--sd-shadow)",
1381
+ font: `13px/1.4 ${ie}`
1382
+ },
1383
+ panelFullscreen: {
1384
+ top: 0,
1385
+ right: 0,
1386
+ bottom: 0,
1387
+ left: 0,
1388
+ width: "100vw",
1389
+ height: "100vh",
1390
+ borderRadius: 0
1391
+ },
1392
+ panelHeader: {
1393
+ display: "flex",
1394
+ alignItems: "center",
1395
+ justifyContent: "space-between",
1396
+ gap: 12,
1397
+ padding: "10px 12px",
1398
+ borderBottom: "1px solid var(--sd-border)"
1399
+ },
1400
+ panelTitleBlock: {
1401
+ minWidth: 0
1402
+ },
1403
+ panelTitle: {
1404
+ fontSize: 13,
1405
+ fontWeight: 600
1406
+ },
1407
+ panelSubtitle: {
1408
+ marginTop: 2,
1409
+ color: "var(--sd-fg-muted)",
1410
+ fontSize: 11
1411
+ },
1412
+ panelActions: {
1413
+ display: "flex",
1414
+ alignItems: "center",
1415
+ gap: 6
1416
+ },
1417
+ iconButton: {
1418
+ display: "grid",
1419
+ width: 28,
1420
+ height: 28,
1421
+ placeItems: "center",
1422
+ borderWidth: 1,
1423
+ borderStyle: "solid",
1424
+ borderColor: "var(--sd-border)",
1425
+ borderRadius: 5,
1426
+ background: "var(--sd-bg)",
1427
+ color: "var(--sd-fg-muted)",
1428
+ cursor: "pointer"
1429
+ },
1430
+ searchBox: {
1431
+ display: "flex",
1432
+ alignItems: "center",
1433
+ gap: 8,
1434
+ margin: 10,
1435
+ height: 28,
1436
+ padding: "0 8px",
1437
+ borderWidth: 1,
1438
+ borderStyle: "solid",
1439
+ borderColor: "var(--sd-border)",
1440
+ borderRadius: 5,
1441
+ color: "var(--sd-fg-muted)"
1442
+ },
1443
+ searchInput: {
1444
+ minWidth: 0,
1445
+ flex: 1,
1446
+ border: 0,
1447
+ outline: 0,
1448
+ background: "transparent",
1449
+ color: "var(--sd-fg)",
1450
+ font: `12px/1.4 ${ie}`
1451
+ },
1452
+ panelBody: {
1453
+ display: "grid",
1454
+ gridTemplateColumns: "minmax(210px, 280px) minmax(0, 1fr)",
1455
+ minHeight: 0,
1456
+ flex: 1,
1457
+ borderTop: "1px solid var(--sd-border-soft)"
1458
+ },
1459
+ queryList: {
1460
+ minHeight: 0,
1461
+ overflowY: "auto",
1462
+ padding: 8,
1463
+ borderRight: "1px solid var(--sd-border)",
1464
+ background: "var(--sd-bg-muted)"
1465
+ },
1466
+ queryGroup: {
1467
+ display: "grid",
1468
+ gap: 3,
1469
+ marginBottom: 8
1470
+ },
1471
+ queryGroupHeader: {
1472
+ display: "flex",
1473
+ alignItems: "center",
1474
+ justifyContent: "space-between",
1475
+ padding: "4px 6px 3px",
1476
+ ...ve
1477
+ },
1478
+ queryGroupCount: {
1479
+ color: "var(--sd-fg-subtle)",
1480
+ fontVariantNumeric: "tabular-nums"
1481
+ },
1482
+ queryGroupEmpty: {
1483
+ padding: "7px 8px",
1484
+ color: "var(--sd-fg-subtle)",
1485
+ fontSize: 11
1486
+ },
1487
+ queryListItem: {
1488
+ display: "grid",
1489
+ gap: 3,
1490
+ width: "100%",
1491
+ padding: "7px 8px",
1492
+ borderWidth: 1,
1493
+ borderStyle: "solid",
1494
+ borderColor: "transparent",
1495
+ borderRadius: 5,
1496
+ background: "transparent",
1497
+ color: "var(--sd-fg)",
1498
+ textAlign: "left",
1499
+ cursor: "pointer"
1500
+ },
1501
+ queryListItemSelected: {
1502
+ borderColor: "var(--sd-border-strong)",
1503
+ background: "var(--sd-bg-raised)"
1504
+ },
1505
+ queryListItemHeader: {
1506
+ display: "flex",
1507
+ alignItems: "center",
1508
+ gap: 7,
1509
+ minWidth: 0
1510
+ },
1511
+ statusDot: {
1512
+ width: 7,
1513
+ height: 7,
1514
+ flex: "0 0 auto",
1515
+ borderRadius: 999
1516
+ },
1517
+ queryListTitle: {
1518
+ flex: 1,
1519
+ minWidth: 0,
1520
+ overflow: "hidden",
1521
+ textOverflow: "ellipsis",
1522
+ whiteSpace: "nowrap",
1523
+ fontSize: 12,
1524
+ fontWeight: 650,
1525
+ color: "var(--sd-fg)"
1526
+ },
1527
+ queryListKindChip: {
1528
+ flex: "0 0 auto",
1529
+ color: "var(--sd-fg-subtle)",
1530
+ fontSize: 9,
1531
+ fontWeight: 600,
1532
+ textTransform: "uppercase",
1533
+ letterSpacing: "0.08em"
1534
+ },
1535
+ queryListSource: {
1536
+ minWidth: 0,
1537
+ paddingLeft: 14,
1538
+ color: "var(--sd-fg-muted)",
1539
+ fontSize: 11,
1540
+ lineHeight: 1.35
1541
+ },
1542
+ detailsPane: {
1543
+ minHeight: 0,
1544
+ overflowY: "auto",
1545
+ padding: 16
1546
+ },
1547
+ detailsHeader: {
1548
+ display: "grid",
1549
+ gap: 6,
1550
+ marginBottom: 14
1551
+ },
1552
+ detailsHeaderTopRow: {
1553
+ display: "flex",
1554
+ alignItems: "center",
1555
+ gap: 8,
1556
+ minWidth: 0
1557
+ },
1558
+ detailsHeaderStatusDot: {
1559
+ width: 8,
1560
+ height: 8,
1561
+ flex: "0 0 auto",
1562
+ borderRadius: 999
1563
+ },
1564
+ detailsTitle: {
1565
+ flex: 1,
1566
+ minWidth: 0,
1567
+ overflow: "hidden",
1568
+ textOverflow: "ellipsis",
1569
+ whiteSpace: "nowrap",
1570
+ fontSize: 14,
1571
+ fontWeight: 700,
1572
+ color: "var(--sd-fg)"
1573
+ },
1574
+ detailsKindChip: {
1575
+ flex: "0 0 auto",
1576
+ padding: "2px 6px",
1577
+ borderRadius: 3,
1578
+ background: "var(--sd-bg-accent)",
1579
+ color: "var(--sd-fg-muted)",
1580
+ fontSize: 10,
1581
+ fontWeight: 600,
1582
+ textTransform: "uppercase",
1583
+ letterSpacing: "0.08em"
1584
+ },
1585
+ detailsCaption: {
1586
+ display: "flex",
1587
+ flexWrap: "wrap",
1588
+ alignItems: "center",
1589
+ columnGap: 10,
1590
+ rowGap: 2,
1591
+ color: "var(--sd-fg-muted)",
1592
+ fontSize: 11
1593
+ },
1594
+ detailsCaptionItem: {
1595
+ display: "inline-flex",
1596
+ alignItems: "center",
1597
+ gap: 4
1598
+ },
1599
+ detailsCaptionItemMono: {
1600
+ fontFamily: oe
1601
+ },
1602
+ detailsCaptionLabel: {
1603
+ color: "var(--sd-fg-subtle)"
1604
+ },
1605
+ detailsCaptionValue: {
1606
+ color: "var(--sd-fg)",
1607
+ fontVariantNumeric: "tabular-nums"
1608
+ },
1609
+ disclosure: {
1610
+ marginTop: 16
1611
+ },
1612
+ disclosureSummary: {
1613
+ cursor: "pointer",
1614
+ ...ve
1615
+ },
1616
+ disclosureBody: {
1617
+ marginTop: 8
1618
+ },
1619
+ alertCard: {
1620
+ marginTop: 12,
1621
+ padding: "8px 10px",
1622
+ borderWidth: 1,
1623
+ borderStyle: "solid",
1624
+ borderRadius: 5,
1625
+ fontSize: 12,
1626
+ lineHeight: 1.45
1627
+ },
1628
+ alertCardError: {
1629
+ borderColor: "var(--sd-error-border)",
1630
+ background: "var(--sd-error-bg)",
1631
+ color: "var(--sd-error-fg)"
1632
+ },
1633
+ alertCardWarning: {
1634
+ borderColor: "var(--sd-warning-border)",
1635
+ background: "var(--sd-warning-bg)",
1636
+ color: "var(--sd-warning-fg)"
1637
+ },
1638
+ alertCardTitle: {
1639
+ fontWeight: 600,
1640
+ textTransform: "uppercase",
1641
+ letterSpacing: "0.08em",
1642
+ fontSize: 10,
1643
+ marginBottom: 4
1644
+ },
1645
+ alertCardList: {
1646
+ margin: 0,
1647
+ paddingLeft: 16,
1648
+ display: "grid",
1649
+ gap: 3
1650
+ },
1651
+ recipe: {
1652
+ display: "grid",
1653
+ gap: 12
1654
+ },
1655
+ traceLineage: {
1656
+ display: "grid",
1657
+ gap: 12
1658
+ },
1659
+ recipeSummary: {
1660
+ display: "grid",
1661
+ gap: 4,
1662
+ padding: "8px 10px",
1663
+ border: "1px solid var(--sd-border)",
1664
+ borderRadius: 5,
1665
+ background: "var(--sd-bg-muted)",
1666
+ color: "var(--sd-fg)",
1667
+ fontSize: 12
1668
+ },
1669
+ recipeSummaryRow: {
1670
+ display: "grid",
1671
+ gridTemplateColumns: "76px minmax(0, 1fr)",
1672
+ gap: 8,
1673
+ minWidth: 0,
1674
+ alignItems: "baseline"
1675
+ },
1676
+ recipeSummaryLabel: {
1677
+ color: "var(--sd-fg-subtle)",
1678
+ fontSize: 10,
1679
+ fontWeight: 600,
1680
+ textTransform: "uppercase",
1681
+ letterSpacing: "0.08em"
1682
+ },
1683
+ recipeSummaryValue: {
1684
+ minWidth: 0,
1685
+ overflow: "hidden",
1686
+ textOverflow: "ellipsis",
1687
+ whiteSpace: "nowrap",
1688
+ color: "var(--sd-fg)",
1689
+ fontSize: 12
1690
+ },
1691
+ recipeGroup: {
1692
+ display: "grid",
1693
+ gap: 4
1694
+ },
1695
+ recipeGroupHeader: {
1696
+ display: "flex",
1697
+ alignItems: "baseline",
1698
+ justifyContent: "space-between",
1699
+ gap: 8,
1700
+ paddingBottom: 4,
1701
+ borderBottom: "1px solid var(--sd-border-soft)"
1702
+ },
1703
+ recipeGroupTitle: {
1704
+ color: "var(--sd-fg-muted)",
1705
+ fontSize: 10,
1706
+ fontWeight: 600,
1707
+ textTransform: "uppercase",
1708
+ letterSpacing: "0.08em"
1709
+ },
1710
+ recipeGroupCount: {
1711
+ color: "var(--sd-fg-subtle)",
1712
+ fontSize: 10,
1713
+ fontVariantNumeric: "tabular-nums"
1714
+ },
1715
+ recipeFieldList: {
1716
+ display: "grid"
1717
+ },
1718
+ recipeEmptyText: {
1719
+ padding: "5px 0",
1720
+ color: "var(--sd-fg-subtle)",
1721
+ fontSize: 11
1722
+ },
1723
+ recipeFieldRow: {
1724
+ display: "grid",
1725
+ gridTemplateColumns: "minmax(0, 1fr) minmax(0, auto)",
1726
+ alignItems: "center",
1727
+ gap: 10,
1728
+ minHeight: 26,
1729
+ padding: "4px 0",
1730
+ borderBottom: "1px solid var(--sd-border-soft)"
1731
+ },
1732
+ recipeFieldName: {
1733
+ minWidth: 0,
1734
+ overflow: "hidden",
1735
+ textOverflow: "ellipsis",
1736
+ whiteSpace: "nowrap",
1737
+ color: "var(--sd-fg)",
1738
+ fontSize: 12,
1739
+ fontWeight: 500
1740
+ },
1741
+ recipeFieldMeta: {
1742
+ minWidth: 0,
1743
+ display: "inline-flex",
1744
+ alignItems: "baseline",
1745
+ overflow: "hidden",
1746
+ textOverflow: "ellipsis",
1747
+ whiteSpace: "nowrap",
1748
+ color: "var(--sd-fg-subtle)",
1749
+ fontSize: 11,
1750
+ textAlign: "right"
1751
+ },
1752
+ recipeFieldMetaDivider: {
1753
+ color: "var(--sd-fg-subtle)",
1754
+ margin: "0 4px"
1755
+ },
1756
+ inputsAppliedBlock: {
1757
+ marginTop: 16,
1758
+ padding: "10px 12px",
1759
+ border: "1px solid var(--sd-border)",
1760
+ borderLeft: "2px solid var(--sd-fg-muted)",
1761
+ borderRadius: 5,
1762
+ background: "var(--sd-bg-muted)"
1763
+ },
1764
+ inputsAppliedHeader: {
1765
+ display: "flex",
1766
+ alignItems: "baseline",
1767
+ justifyContent: "space-between",
1768
+ gap: 8,
1769
+ marginBottom: 6
1770
+ },
1771
+ inputsAppliedTitle: {
1772
+ color: "var(--sd-fg)",
1773
+ fontSize: 10,
1774
+ fontWeight: 700,
1775
+ textTransform: "uppercase",
1776
+ letterSpacing: "0.08em"
1777
+ },
1778
+ inputsAppliedCount: {
1779
+ color: "var(--sd-fg-subtle)",
1780
+ fontSize: 10,
1781
+ fontVariantNumeric: "tabular-nums"
1782
+ },
1783
+ inputRecipeList: {
1784
+ display: "grid"
1785
+ },
1786
+ inputRecipeRow: {
1787
+ display: "grid",
1788
+ gap: 2,
1789
+ minWidth: 0,
1790
+ padding: "6px 0",
1791
+ borderBottom: "1px solid var(--sd-border-soft)"
1792
+ },
1793
+ inputRecipeHeader: {
1794
+ display: "flex",
1795
+ alignItems: "center",
1796
+ gap: 8,
1797
+ minWidth: 0
1798
+ },
1799
+ inputRecipeId: {
1800
+ flex: "0 0 auto",
1801
+ maxWidth: "40%",
1802
+ overflow: "hidden",
1803
+ textOverflow: "ellipsis",
1804
+ whiteSpace: "nowrap",
1805
+ color: "var(--sd-fg)",
1806
+ fontFamily: oe,
1807
+ fontSize: 11,
1808
+ fontWeight: 600
1809
+ },
1810
+ inputOperatorBadge: {
1811
+ display: "inline-flex",
1812
+ flex: "0 0 auto",
1813
+ alignItems: "center",
1814
+ height: 16,
1815
+ padding: "0 5px",
1816
+ borderRadius: 3,
1817
+ background: "var(--sd-bg-accent)",
1818
+ color: "var(--sd-fg-muted)",
1819
+ fontFamily: oe,
1820
+ fontSize: 10,
1821
+ textTransform: "uppercase",
1822
+ letterSpacing: "0.06em"
1823
+ },
1824
+ inputValuePreview: {
1825
+ flex: 1,
1826
+ minWidth: 0,
1827
+ overflow: "hidden",
1828
+ textOverflow: "ellipsis",
1829
+ whiteSpace: "nowrap",
1830
+ color: "var(--sd-fg)",
1831
+ fontSize: 12,
1832
+ textAlign: "right"
1833
+ },
1834
+ inputRecipeBinding: {
1835
+ minWidth: 0,
1836
+ overflow: "hidden",
1837
+ textOverflow: "ellipsis",
1838
+ whiteSpace: "nowrap",
1839
+ color: "var(--sd-fg-muted)",
1840
+ fontSize: 11
1841
+ },
1842
+ eventList: {
1843
+ display: "grid"
1844
+ },
1845
+ eventRow: {
1846
+ display: "grid",
1847
+ gridTemplateColumns: "96px minmax(0, 1fr)",
1848
+ gap: 10,
1849
+ padding: "6px 0",
1850
+ borderBottom: "1px solid var(--sd-border-soft)"
1851
+ },
1852
+ eventType: {
1853
+ color: "var(--sd-fg)",
1854
+ fontWeight: 600,
1855
+ fontSize: 12
1856
+ },
1857
+ eventMeta: {
1858
+ minWidth: 0,
1859
+ overflow: "hidden",
1860
+ textOverflow: "ellipsis",
1861
+ whiteSpace: "nowrap",
1862
+ color: "var(--sd-fg-muted)",
1863
+ fontSize: 11
1864
+ },
1865
+ mutedText: {
1866
+ color: "var(--sd-fg-muted)",
1867
+ fontSize: 12
1868
+ },
1869
+ compiledQuery: {
1870
+ display: "grid",
1871
+ gap: 10
1872
+ },
1873
+ codeBlockGroup: {
1874
+ display: "grid",
1875
+ gap: 5
1876
+ },
1877
+ codeBlockLabel: {
1878
+ ...ve
1879
+ },
1880
+ codeBlock: {
1881
+ maxHeight: 260,
1882
+ margin: 0,
1883
+ overflow: "auto",
1884
+ padding: "8px 10px",
1885
+ border: "1px solid var(--sd-border)",
1886
+ borderRadius: 5,
1887
+ background: "var(--sd-bg-muted)",
1888
+ color: "var(--sd-fg)",
1889
+ fontFamily: oe,
1890
+ fontSize: 11,
1891
+ lineHeight: 1.5,
1892
+ whiteSpace: "pre-wrap"
1893
+ },
1894
+ emptyState: {
1895
+ padding: 10,
1896
+ color: "var(--sd-fg-muted)",
1897
+ textAlign: "center",
1898
+ fontSize: 12
1899
+ },
1900
+ inspectButton: {
1901
+ display: "inline-flex",
1902
+ alignItems: "center",
1903
+ gap: 5,
1904
+ height: 24,
1905
+ maxWidth: "100%",
1906
+ padding: "0 7px",
1907
+ borderWidth: 1,
1908
+ borderStyle: "solid",
1909
+ borderRadius: 5,
1910
+ background: "var(--sd-bg)",
1911
+ font: `600 11px/1 ${ie}`,
1912
+ cursor: "pointer"
1913
+ },
1914
+ inspectButtonText: {
1915
+ overflow: "hidden",
1916
+ textOverflow: "ellipsis",
1917
+ whiteSpace: "nowrap"
1918
+ }
1919
+ };
1920
+ function dt(e) {
1921
+ return {
1922
+ ...e,
1923
+ order: [],
1924
+ entries: {},
1925
+ sequence: 0
1926
+ };
1927
+ }
1928
+ function xr(e, t) {
1929
+ if (t.type === "config")
1930
+ return t.config.enabled ? {
1931
+ ...e,
1932
+ ...t.config
1933
+ } : dt(t.config);
1934
+ if (!e.enabled)
1935
+ return e;
1936
+ switch (t.type) {
1937
+ case "register":
1938
+ return Rr(wr(e, t.descriptor));
1939
+ case "unregister":
1940
+ return Ir(e, t.traceKey);
1941
+ case "event":
1942
+ return qr(e, t);
1943
+ default:
1944
+ return e;
1945
+ }
1946
+ }
1947
+ function wr(e, t) {
1948
+ const r = e.entries[t.traceKey], n = r ? e.sequence : e.sequence + 1, i = Oe(), d = {
1949
+ ...r || Ar(t),
1950
+ ...lt(t),
1951
+ traceKey: t.traceKey,
1952
+ latestAttempt: (r == null ? void 0 : r.latestAttempt) || { status: "idle" },
1953
+ recentEvents: (r == null ? void 0 : r.recentEvents) || [],
1954
+ mounted: !0,
1955
+ registeredAt: (r == null ? void 0 : r.registeredAt) || n,
1956
+ lastEventAt: (r == null ? void 0 : r.lastEventAt) || i
1957
+ };
1958
+ return {
1959
+ ...e,
1960
+ sequence: n,
1961
+ order: r ? e.order : [...e.order, t.traceKey],
1962
+ entries: {
1963
+ ...e.entries,
1964
+ [t.traceKey]: d
1965
+ }
1966
+ };
1967
+ }
1968
+ function Ir(e, t) {
1969
+ const r = e.entries[t];
1970
+ return r ? {
1971
+ ...e,
1972
+ entries: {
1973
+ ...e.entries,
1974
+ [t]: {
1975
+ ...r,
1976
+ mounted: !1
1977
+ }
1978
+ }
1979
+ } : e;
1980
+ }
1981
+ function qr(e, t) {
1982
+ const r = e.entries[t.traceKey];
1983
+ if (!r)
1984
+ return e;
1985
+ const n = Oe(), i = [
1986
+ ...r.recentEvents,
1987
+ t.event
1988
+ ].slice(-e.maxEventsPerQuery);
1989
+ return {
1990
+ ...e,
1991
+ entries: {
1992
+ ...e.entries,
1993
+ [t.traceKey]: {
1994
+ ...r,
1995
+ latestAttempt: t.latestAttempt ? {
1996
+ ...r.latestAttempt,
1997
+ ...t.latestAttempt
1998
+ } : r.latestAttempt,
1999
+ recentEvents: i,
2000
+ lastEventAt: n
2001
+ }
2002
+ }
2003
+ };
2004
+ }
2005
+ function Rr(e) {
2006
+ if (e.order.length <= e.maxQueries)
2007
+ return e;
2008
+ const t = e.order.map((i) => e.entries[i]).filter((i) => !!i).sort((i, d) => i.mounted !== d.mounted ? i.mounted ? 1 : -1 : i.lastEventAt - d.lastEventAt), r = e.order.length - e.maxQueries, n = new Set(
2009
+ t.slice(0, r).map((i) => i.traceKey)
2010
+ );
2011
+ return n.size ? {
2012
+ ...e,
2013
+ order: e.order.filter((i) => !n.has(i)),
2014
+ entries: Object.fromEntries(
2015
+ Object.entries(e.entries).filter(([i]) => !n.has(i))
2016
+ )
2017
+ } : e;
2018
+ }
2019
+ function Ar(e) {
2020
+ const t = Oe();
2021
+ return {
2022
+ ...lt(e),
2023
+ traceKey: e.traceKey,
2024
+ latestAttempt: { status: "idle" },
2025
+ recentEvents: [],
2026
+ mounted: !0,
2027
+ registeredAt: 0,
2028
+ lastEventAt: t
2029
+ };
2030
+ }
2031
+ function lt(e) {
2032
+ const t = $r(e.spec), r = _r(
2033
+ e.spec,
2034
+ e.activeInputs
2035
+ );
2036
+ return {
2037
+ traceId: pt(e.traceKey),
2038
+ viewId: e.viewId,
2039
+ queryId: e.queryId,
2040
+ queryLabel: e.queryLabel || e.viewTitle,
2041
+ queryKind: e.queryKind,
2042
+ builder: e.builder,
2043
+ sourceRefs: Kr(e.intent),
2044
+ projectionFieldRefs: t,
2045
+ inputFieldRefs: r,
2046
+ fieldRefs: Fr(e.intent),
2047
+ inputsApplied: (e.activeInputs || []).map((n) => ({
2048
+ inputId: n.inputId,
2049
+ fieldRef: n.field,
2050
+ operator: n.operator,
2051
+ valuePreview: Lr(n)
2052
+ })),
2053
+ recentEvents: [],
2054
+ clientWarnings: e.clientWarnings
2055
+ };
2056
+ }
2057
+ function de(e) {
2058
+ const {
2059
+ traceKey: t,
2060
+ mounted: r,
2061
+ registeredAt: n,
2062
+ lastEventAt: i,
2063
+ ...d
2064
+ } = e;
2065
+ return d;
2066
+ }
2067
+ function le(e) {
2068
+ return e.enabled ? {
2069
+ enabled: !0,
2070
+ queries: e.order.map((r) => e.entries[r]).filter((r) => !!r).map(de),
2071
+ getQuery: (r) => {
2072
+ const n = Object.values(e.entries).find(
2073
+ (i) => i.queryId === r
2074
+ );
2075
+ return n ? de(n) : void 0;
2076
+ },
2077
+ getQueries: (r) => Object.values(e.entries).filter((n) => n.queryId === r).map(de)
2078
+ } : Xe;
2079
+ }
2080
+ function Er(e) {
2081
+ return {
2082
+ snapshot: () => Tr(le(e())),
2083
+ getQuery: (t) => ze(le(e()).getQuery(t)),
2084
+ getQueries: (t) => le(e()).getQueries(t).map((r) => ze(r)).filter((r) => !!r)
2085
+ };
2086
+ }
2087
+ function Tr(e) {
2088
+ if (!e.enabled)
2089
+ return e;
2090
+ const t = e.queries.map(ut);
2091
+ return {
2092
+ enabled: e.enabled,
2093
+ queries: t,
2094
+ getQuery: (r) => t.find((n) => n.queryId === r),
2095
+ getQueries: (r) => t.filter((n) => n.queryId === r)
2096
+ };
2097
+ }
2098
+ function ze(e) {
2099
+ return e ? ut(e) : void 0;
2100
+ }
2101
+ function ut(e) {
2102
+ var t;
2103
+ return (t = e == null ? void 0 : e.latestAttempt) != null && t.executionResult ? {
2104
+ ...e,
2105
+ latestAttempt: {
2106
+ ...e.latestAttempt,
2107
+ executionResult: kr(
2108
+ e.latestAttempt.executionResult
2109
+ )
2110
+ }
2111
+ } : e;
2112
+ }
2113
+ function kr(e) {
2114
+ const {
2115
+ compiledQuery: t,
2116
+ intent: r,
2117
+ result: n,
2118
+ ...i
2119
+ } = e;
2120
+ return i;
2121
+ }
2122
+ function Cr(e) {
2123
+ return e === void 0 || e === !1 ? {
2124
+ enabled: !1,
2125
+ exposeWindowBridge: !1,
2126
+ maxEventsPerQuery: ge,
2127
+ maxQueries: he
2128
+ } : e === !0 ? {
2129
+ enabled: !0,
2130
+ exposeWindowBridge: !1,
2131
+ maxEventsPerQuery: ge,
2132
+ maxQueries: he
2133
+ } : {
2134
+ enabled: e.enabled !== !1,
2135
+ exposeWindowBridge: e.exposeWindowBridge === !0,
2136
+ maxEventsPerQuery: je(
2137
+ e.maxEventsPerQuery,
2138
+ ge,
2139
+ _t
2140
+ ),
2141
+ maxQueries: je(
2142
+ e.maxQueries,
2143
+ he,
2144
+ Ft
2145
+ )
2146
+ };
2147
+ }
2148
+ function je(e, t, r) {
2149
+ return e === void 0 || !Number.isFinite(e) || !Number.isInteger(e) || e <= 0 ? t : Math.min(e, r);
2150
+ }
2151
+ function Dr(e) {
2152
+ return typeof e.id == "string" && e.id.trim() ? e.id : void 0;
2153
+ }
2154
+ function Or(e) {
2155
+ switch (e) {
2156
+ case "metric":
2157
+ return "semaphor.metric";
2158
+ case "records":
2159
+ return "semaphor.records";
2160
+ case "matrix":
2161
+ return "semaphor.matrix";
2162
+ case "analysis":
2163
+ return "semaphor.analysis";
2164
+ case "inputOptions":
2165
+ return "semaphor.inputOptions";
2166
+ case "sql":
2167
+ return "semaphor.sql";
2168
+ default:
2169
+ return pe(e);
2170
+ }
2171
+ }
2172
+ function pe(e) {
2173
+ throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
2174
+ }
2175
+ function Lr(e) {
2176
+ if (Br(e))
2177
+ return;
2178
+ const t = e.value;
2179
+ if (t !== void 0) {
2180
+ if (Array.isArray(t)) {
2181
+ const r = t.filter(
2182
+ (n) => typeof n == "string" || typeof n == "number" || typeof n == "boolean"
2183
+ ).map((n) => String(n));
2184
+ if (r.length === t.length && r.length > 0) {
2185
+ const n = r.slice(0, 3).join(", "), i = r.length > 3 ? `, +${r.length - 3} more` : "";
2186
+ return Pe(`${n}${i}`);
2187
+ }
2188
+ return `${t.length} selected`;
2189
+ }
2190
+ return typeof t == "number" || typeof t == "boolean" ? String(t) : typeof t == "string" ? Pe(t) : t && typeof t == "object" ? `object(${Object.keys(t).slice(0, 5).join(",")})` : String(t);
2191
+ }
2192
+ }
2193
+ function Pe(e) {
2194
+ return e.length > 80 ? `${e.slice(0, 77)}...` : e;
2195
+ }
2196
+ function Br(e) {
2197
+ var r;
2198
+ const t = [
2199
+ e.inputId,
2200
+ e.label,
2201
+ (r = e.field) == null ? void 0 : r.name
2202
+ ].filter(Boolean).join(" ").toLowerCase();
2203
+ return ["token", "secret", "password", "email", "phone", "ssn"].some(
2204
+ (n) => t.includes(n)
2205
+ );
2206
+ }
2207
+ function Kr(e) {
2208
+ const t = /* @__PURE__ */ new Map();
2209
+ return ue(e, (r) => {
2210
+ Wr(r) && t.set(ft(r), r);
2211
+ }), [...t.values()];
2212
+ }
2213
+ function $r(e) {
2214
+ switch (e.queryKind) {
2215
+ case "metric":
2216
+ case "analysis":
2217
+ return V([
2218
+ ...e.measures || [],
2219
+ e.primaryMeasure,
2220
+ e.dateField,
2221
+ ...e.dimensions || []
2222
+ ]);
2223
+ case "records":
2224
+ return V(e.fields || []);
2225
+ case "inputOptions":
2226
+ return V([
2227
+ e.labelField,
2228
+ e.valueField,
2229
+ e.searchField,
2230
+ ...e.disambiguationFields || []
2231
+ ]);
2232
+ case "sql":
2233
+ return V(e.fields || []);
2234
+ case "matrix":
2235
+ return V([
2236
+ ...(e.rows || []).map(be),
2237
+ ...(e.columns || []).map(be),
2238
+ ...(e.values || []).map(be)
2239
+ ]);
2240
+ default:
2241
+ return pe(e);
2242
+ }
2243
+ }
2244
+ function _r(e, t) {
2245
+ const r = [
2246
+ ...(e.inputs || []).map(ct),
2247
+ ...(t || []).map((n) => n.field)
2248
+ ];
2249
+ return V(r);
2250
+ }
2251
+ function V(e) {
2252
+ const t = /* @__PURE__ */ new Map();
2253
+ return e.forEach((r) => {
2254
+ r && te(r) && t.set(De(r), r);
2255
+ }), [...t.values()];
2256
+ }
2257
+ function ct(e) {
2258
+ if (!e || typeof e != "object")
2259
+ return;
2260
+ const t = e.toAnalyticsInput;
2261
+ if (typeof t == "function") {
2262
+ const n = t.call(e);
2263
+ return ct(n);
2264
+ }
2265
+ const r = e.field;
2266
+ return te(r) ? r : void 0;
2267
+ }
2268
+ function be(e) {
2269
+ if (te(e))
2270
+ return e;
2271
+ if (!e || typeof e != "object")
2272
+ return;
2273
+ const t = e.field;
2274
+ return te(t) ? t : void 0;
2275
+ }
2276
+ function Fr(e) {
2277
+ const t = /* @__PURE__ */ new Map();
2278
+ return ue(e, (r) => {
2279
+ te(r) && t.set(De(r), r);
2280
+ }), [...t.values()];
2281
+ }
2282
+ function ue(e, t) {
2283
+ if (!(!e || typeof e != "object")) {
2284
+ if (t(e), Array.isArray(e)) {
2285
+ e.forEach((r) => ue(r, t));
2286
+ return;
2287
+ }
2288
+ Object.values(e).forEach(
2289
+ (r) => ue(r, t)
2290
+ );
2291
+ }
2292
+ }
2293
+ function Wr(e) {
2294
+ if (!e || typeof e != "object")
2295
+ return !1;
2296
+ const t = e;
2297
+ return t.kind === "semantic" ? typeof t.domainId == "string" && typeof t.datasetName == "string" : t.kind === "physical" ? typeof t.connectionId == "string" && typeof t.tableName == "string" : t.kind === "sql" ? typeof t.connectionId == "string" : !1;
2298
+ }
2299
+ function te(e) {
2300
+ if (!e || typeof e != "object")
2301
+ return !1;
2302
+ const t = e;
2303
+ return typeof t.name == "string" && (t.source !== void 0 || t.role !== void 0 || t.dataType !== void 0 || t.aggregate !== void 0);
2304
+ }
2305
+ function ft(e) {
2306
+ return e.kind === "semantic" ? [
2307
+ e.kind,
2308
+ e.domainId,
2309
+ e.datasetId || e.datasetName
2310
+ ].join(":") : e.kind === "physical" ? [
2311
+ e.kind,
2312
+ e.connectionId,
2313
+ e.databaseName,
2314
+ e.schemaName,
2315
+ e.tableName
2316
+ ].join(":") : [e.kind, e.connectionId].join(":");
2317
+ }
2318
+ function De(e) {
2319
+ return [
2320
+ e.name,
2321
+ e.role,
2322
+ e.aggregate,
2323
+ e.source ? ft(e.source) : ""
2324
+ ].join(":");
2325
+ }
2326
+ function Nr(e) {
2327
+ const t = e;
2328
+ return typeof (t == null ? void 0 : t.rowCount) == "number" ? t.rowCount : Array.isArray(t == null ? void 0 : t.records) ? t.records.length : void 0;
2329
+ }
2330
+ function Mr(e) {
2331
+ const t = e;
2332
+ return Array.isArray(t == null ? void 0 : t.columns) ? t.columns.length : void 0;
2333
+ }
2334
+ function Ve(e) {
2335
+ const t = e;
2336
+ return t == null ? void 0 : t.executionResult;
2337
+ }
2338
+ function Qe(e) {
2339
+ const t = e;
2340
+ return typeof (t == null ? void 0 : t.requestId) == "string" ? t.requestId : void 0;
2341
+ }
2342
+ function pt(e) {
2343
+ let t = 2166136261;
2344
+ for (let r = 0; r < e.length; r += 1)
2345
+ t ^= e.charCodeAt(r), t = Math.imul(t, 16777619);
2346
+ return (t >>> 0).toString(36);
2347
+ }
2348
+ function se() {
2349
+ return (/* @__PURE__ */ new Date()).toISOString();
2350
+ }
2351
+ function Oe() {
2352
+ return typeof performance < "u" && performance.now ? performance.now() : Date.now();
2353
+ }
2354
+ const zr = [
131
2355
  "records",
132
2356
  "changes",
133
2357
  "drivers",
@@ -135,7 +2359,7 @@ const He = {
135
2359
  "largestPositiveChanges",
136
2360
  "largestNegativeDrivers",
137
2361
  "largestPositiveDrivers"
138
- ], ue = [
2362
+ ], jr = [
139
2363
  "records",
140
2364
  "changes",
141
2365
  "drivers",
@@ -144,139 +2368,139 @@ const He = {
144
2368
  "largestNegativeDrivers",
145
2369
  "largestPositiveDrivers"
146
2370
  ];
147
- function B(e) {
2371
+ function mt(e) {
148
2372
  if (!e)
149
2373
  return {};
150
- const t = de(e.executionResult), n = se(e, t), r = ce(n);
2374
+ const t = Ur(e.executionResult), r = Pr(e, t), n = Qr(r);
151
2375
  return {
152
2376
  ...e,
153
- ...Object.keys(n).length ? { resultSets: n } : {},
154
- ...r ? {
155
- columns: r.columns,
156
- records: r.records,
157
- rowCount: r.rowCount
2377
+ ...Object.keys(r).length ? { resultSets: r } : {},
2378
+ ...n ? {
2379
+ columns: n.columns,
2380
+ records: n.records,
2381
+ rowCount: n.rowCount
158
2382
  } : {}
159
2383
  };
160
2384
  }
161
- function se(e, t) {
162
- const n = ae(e.resultSets);
163
- for (const i of ie) {
164
- if (n[i]) {
165
- n[i] = z(n[i]);
2385
+ function Pr(e, t) {
2386
+ const r = Vr(e.resultSets);
2387
+ for (const i of zr) {
2388
+ if (r[i]) {
2389
+ r[i] = gt(r[i]);
166
2390
  continue;
167
2391
  }
168
- const u = fe(e[i]);
169
- if (!u.length)
2392
+ const d = Gr(e[i]);
2393
+ if (!d.length)
170
2394
  continue;
171
- const s = t.length ? t : pe(u);
172
- n[i] = {
173
- records: C(u, s),
174
- columns: s,
175
- rowCount: u.length
2395
+ const l = t.length ? t : Jr(d);
2396
+ r[i] = {
2397
+ records: Le(d, l),
2398
+ columns: l,
2399
+ rowCount: d.length
176
2400
  };
177
2401
  }
178
- const r = le(e.executionResult);
179
- return r && r.records.length > 0 && !n.records && (n.records = r), n;
2402
+ const n = Hr(e.executionResult);
2403
+ return n && n.records.length > 0 && !r.records && (r.records = n), r;
180
2404
  }
181
- function ae(e) {
2405
+ function Vr(e) {
182
2406
  return Object.fromEntries(
183
- Object.entries(e || {}).map(([t, n]) => [
2407
+ Object.entries(e || {}).map(([t, r]) => [
184
2408
  t,
185
- z(n)
2409
+ gt(r)
186
2410
  ])
187
2411
  );
188
2412
  }
189
- function z(e) {
2413
+ function gt(e) {
190
2414
  var t;
191
2415
  return {
192
2416
  ...e,
193
- records: C(
2417
+ records: Le(
194
2418
  e.records || [],
195
2419
  e.columns || []
196
2420
  ),
197
2421
  rowCount: e.rowCount ?? ((t = e.records) == null ? void 0 : t.length) ?? 0
198
2422
  };
199
2423
  }
200
- function ce(e) {
2424
+ function Qr(e) {
201
2425
  var t;
202
- for (const n of ue)
203
- if ((t = e[n]) != null && t.records.length)
204
- return e[n];
205
- return Object.values(e).find((n) => n.records.length) || Object.values(e)[0];
2426
+ for (const r of jr)
2427
+ if ((t = e[r]) != null && t.records.length)
2428
+ return e[r];
2429
+ return Object.values(e).find((r) => r.records.length) || Object.values(e)[0];
206
2430
  }
207
- function le(e) {
2431
+ function Hr(e) {
208
2432
  const t = e == null ? void 0 : e.result;
209
2433
  if (!(!t || t.kind !== "records" && t.kind !== "sql"))
210
2434
  return {
211
- records: C(t.records, t.columns),
2435
+ records: Le(t.records, t.columns),
212
2436
  columns: t.columns,
213
2437
  rowCount: t.rowCount ?? t.records.length
214
2438
  };
215
2439
  }
216
- function de(e) {
2440
+ function Ur(e) {
217
2441
  const t = e == null ? void 0 : e.result;
218
2442
  return !t || t.kind !== "records" && t.kind !== "sql" ? [] : t.columns;
219
2443
  }
220
- function fe(e) {
2444
+ function Gr(e) {
221
2445
  return Array.isArray(e) ? e.filter(
222
2446
  (t) => !!(t && typeof t == "object" && !Array.isArray(t))
223
2447
  ) : [];
224
2448
  }
225
- function C(e, t) {
226
- return t.length ? e.map((n) => {
227
- const r = {};
228
- return t.forEach((i, u) => {
229
- const s = me(n, {
2449
+ function Le(e, t) {
2450
+ return t.length ? e.map((r) => {
2451
+ const n = {};
2452
+ return t.forEach((i, d) => {
2453
+ const l = Yr(r, {
230
2454
  name: i.key,
231
2455
  label: i.label,
232
- fallbackNames: [i.name, Object.keys(n)[u]]
2456
+ fallbackNames: [i.name, Object.keys(r)[d]]
233
2457
  });
234
- s !== void 0 && (r[i.key] = s);
235
- }), Object.keys(r).length ? r : n;
2458
+ l !== void 0 && (n[i.key] = l);
2459
+ }), Object.keys(n).length ? n : r;
236
2460
  }) : e;
237
2461
  }
238
- function pe(e) {
2462
+ function Jr(e) {
239
2463
  return Array.from(
240
- new Set(e.flatMap((n) => Object.keys(n)))
241
- ).map((n) => ({
242
- key: n,
243
- name: n,
244
- label: n
2464
+ new Set(e.flatMap((r) => Object.keys(r)))
2465
+ ).map((r) => ({
2466
+ key: r,
2467
+ name: r,
2468
+ label: r
245
2469
  }));
246
2470
  }
247
- function me(e, t) {
248
- const n = [
2471
+ function Yr(e, t) {
2472
+ const r = [
249
2473
  t.name,
250
2474
  t.label,
251
2475
  ...t.fallbackNames || []
252
- ].filter((r) => !!r);
253
- for (const r of n)
254
- if (Object.prototype.hasOwnProperty.call(e, r))
255
- return e[r];
2476
+ ].filter((n) => !!n);
2477
+ for (const n of r)
2478
+ if (Object.prototype.hasOwnProperty.call(e, n))
2479
+ return e[n];
256
2480
  }
257
- function he() {
2481
+ function Xr() {
258
2482
  return {
259
- executeAnalysis: (e, t, n) => h(
2483
+ executeAnalysis: (e, t, r) => P(
260
2484
  e,
261
2485
  t,
262
- n ?? {}
263
- ).then(B),
264
- executeMetric: (e, t) => h(e, t),
265
- executeRecords: (e, t) => h(e, t),
266
- executeInputOptions: (e, t) => h(e, t),
267
- executeSql: (e, t) => h(e, t),
268
- executeMatrix: (e, t) => h(e, t)
2486
+ r ?? {}
2487
+ ).then(mt),
2488
+ executeMetric: (e, t) => P(e, t),
2489
+ executeRecords: (e, t) => P(e, t),
2490
+ executeInputOptions: (e, t) => P(e, t),
2491
+ executeSql: (e, t) => P(e, t),
2492
+ executeMatrix: (e, t) => P(e, t)
269
2493
  };
270
2494
  }
271
- async function h(e, t, n) {
2495
+ async function P(e, t, r) {
272
2496
  if (!t.token)
273
2497
  throw new Error(
274
2498
  "SemaphorDataAppProvider needs a token to execute queries."
275
2499
  );
276
- const r = Ie(t), i = ye(e, r);
277
- let u;
2500
+ const n = sn(t), i = en(e, n);
2501
+ let d;
278
2502
  try {
279
- u = await fetch(r, {
2503
+ d = await fetch(n, {
280
2504
  method: "POST",
281
2505
  headers: {
282
2506
  "Content-Type": "application/json",
@@ -285,32 +2509,37 @@ async function h(e, t, n) {
285
2509
  body: JSON.stringify({
286
2510
  intent: e,
287
2511
  activeInputs: t.activeInputs,
288
- ...n ? { analysisOptions: n } : {},
2512
+ ...r ? { analysisOptions: r } : {},
289
2513
  resultShape: e.kind
290
2514
  })
291
2515
  });
292
- } catch (l) {
2516
+ } catch (u) {
293
2517
  throw new Error(
294
- `${i}: ${l instanceof Error ? l.message : String(l)}`
2518
+ `${i}: ${u instanceof Error ? u.message : String(u)}`
295
2519
  );
296
2520
  }
297
- const s = await Se(u);
298
- if (!u.ok || s.error)
299
- throw new Error(
300
- `${i}: ${s.error || `Semaphor Data App execution failed with status ${u.status}.`}`
2521
+ const l = await nn(d);
2522
+ if (!d.ok || l.error)
2523
+ throw Zr(
2524
+ `${i}: ${l.error || `Semaphor Data App execution failed with status ${d.status}.`}`,
2525
+ l
301
2526
  );
302
- return s;
2527
+ return l;
2528
+ }
2529
+ function Zr(e, t) {
2530
+ const r = new Error(e);
2531
+ return t.requestId && (r.requestId = t.requestId), t.details !== void 0 && (r.details = t.details), t.executionResult !== void 0 && (r.executionResult = t.executionResult), r;
303
2532
  }
304
- function ye(e, t) {
2533
+ function en(e, t) {
305
2534
  return [
306
2535
  `Semaphor ${e.kind} query`,
307
2536
  e.id ? `id=${e.id}` : void 0,
308
2537
  e.label ? `label=${e.label}` : void 0,
309
- ve(e),
310
- `endpoint=${qe(t)}`
311
- ].filter((n) => !!n).join(" ");
2538
+ tn(e),
2539
+ `endpoint=${rn(t)}`
2540
+ ].filter((r) => !!r).join(" ");
312
2541
  }
313
- function ve(e) {
2542
+ function tn(e) {
314
2543
  const t = "source" in e ? e.source : void 0;
315
2544
  if (!(!t || typeof t != "object")) {
316
2545
  if (t.kind === "semantic")
@@ -329,7 +2558,7 @@ function ve(e) {
329
2558
  return t.connectionId ? `source=${t.connectionId}` : void 0;
330
2559
  }
331
2560
  }
332
- function qe(e) {
2561
+ function rn(e) {
333
2562
  if (!e)
334
2563
  return "/api/v1/data-app/execute";
335
2564
  try {
@@ -338,7 +2567,7 @@ function qe(e) {
338
2567
  return e;
339
2568
  }
340
2569
  }
341
- async function Se(e) {
2570
+ async function nn(e) {
342
2571
  const t = await e.text().catch(() => "");
343
2572
  if (!t.trim())
344
2573
  return e.ok ? {
@@ -351,440 +2580,476 @@ async function Se(e) {
351
2580
  error: "Semaphor Data App execution returned invalid JSON.",
352
2581
  details: t
353
2582
  } : {
354
- error: Ae(e, t),
2583
+ error: on(e, t),
355
2584
  details: t
356
2585
  };
357
2586
  }
358
2587
  }
359
- function Ae(e, t) {
360
- const n = e.statusText ? ` ${e.statusText}` : "", r = t.replace(/\s+/g, " ").trim();
361
- return r ? `Semaphor Data App execution failed with status ${e.status}${n}: ${r.slice(0, 240)}` : `Semaphor Data App execution failed with status ${e.status}${n}.`;
2588
+ function on(e, t) {
2589
+ const r = e.statusText ? ` ${e.statusText}` : "", n = t.replace(/\s+/g, " ").trim();
2590
+ return n ? `Semaphor Data App execution failed with status ${e.status}${r}: ${n.slice(0, 240)}` : `Semaphor Data App execution failed with status ${e.status}${r}.`;
362
2591
  }
363
- function Ie(e) {
364
- const t = ke(e).replace(/\/+$/, "");
2592
+ function sn(e) {
2593
+ const t = an(e).replace(/\/+$/, "");
365
2594
  return t ? t.endsWith("/api") ? `${t}/v1/data-app/execute` : `${t}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
366
2595
  }
367
- function ke(e) {
2596
+ function an(e) {
368
2597
  if (e.apiBaseUrl)
369
2598
  return e.apiBaseUrl;
370
2599
  if (!e.token)
371
2600
  return "";
372
2601
  try {
373
- return ee(e.token).apiServiceUrl || "";
2602
+ return Kt(e.token).apiServiceUrl || "";
374
2603
  } catch {
375
2604
  return "";
376
2605
  }
377
2606
  }
378
- const M = te({});
379
- function ge() {
2607
+ const ht = ce({});
2608
+ function dn() {
380
2609
  if (!(typeof window > "u"))
381
2610
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
382
2611
  }
383
- function xe() {
384
- return re(M);
2612
+ function ln() {
2613
+ return z(ht);
385
2614
  }
386
- const x = { value: null }, E = {}, Ee = { records: [] }, D = { options: [] }, De = { records: [] }, K = {};
387
- function Ke(e) {
388
- const t = y(e.inputs), n = X(e);
2615
+ const Se = { value: null }, xe = {}, un = { records: [] }, we = { options: [] }, cn = { records: [] }, Ie = {};
2616
+ function fn(e) {
2617
+ const t = U(e.inputs), r = Rt(e);
389
2618
  try {
390
- const r = G(e), i = v(r);
2619
+ const n = At(e), i = G(n);
391
2620
  return i ? {
392
2621
  error: i,
393
2622
  activeInputs: t,
394
- analysisOptions: n,
395
- queryKey: f(
2623
+ analysisOptions: r,
2624
+ queryKey: I(
396
2625
  void 0,
397
2626
  t,
398
2627
  i,
399
- n
2628
+ r
400
2629
  ),
401
- idleData: E
2630
+ idleData: xe
402
2631
  } : {
403
- intent: r,
2632
+ intent: n,
404
2633
  error: null,
405
2634
  activeInputs: t,
406
- analysisOptions: n,
407
- queryKey: f(r, t, void 0, n),
408
- idleData: E
2635
+ analysisOptions: r,
2636
+ queryKey: I(n, t, void 0, r),
2637
+ idleData: xe
409
2638
  };
410
- } catch (r) {
411
- const i = m(r);
2639
+ } catch (n) {
2640
+ const i = F(n);
412
2641
  return {
413
2642
  error: i,
414
2643
  activeInputs: t,
415
- analysisOptions: n,
416
- queryKey: f(
2644
+ analysisOptions: r,
2645
+ queryKey: I(
417
2646
  void 0,
418
2647
  t,
419
2648
  i,
420
- n
2649
+ r
421
2650
  ),
422
- idleData: E
2651
+ idleData: xe
423
2652
  };
424
2653
  }
425
2654
  }
426
- function be(e) {
427
- const t = y(e.inputs);
2655
+ function pn(e) {
2656
+ const t = U(e.inputs);
428
2657
  try {
429
- const n = Z(e), r = v(n);
430
- return r ? {
431
- error: r,
2658
+ const r = Et(e), n = G(r);
2659
+ return n ? {
2660
+ error: n,
432
2661
  activeInputs: t,
433
- queryKey: f(void 0, t, r),
434
- idleData: x
2662
+ queryKey: I(void 0, t, n),
2663
+ idleData: Se
435
2664
  } : {
436
- intent: n,
2665
+ intent: r,
437
2666
  error: null,
438
2667
  activeInputs: t,
439
- queryKey: f(n, t),
440
- idleData: x
2668
+ queryKey: I(r, t),
2669
+ idleData: Se
441
2670
  };
442
- } catch (n) {
443
- const r = m(n);
2671
+ } catch (r) {
2672
+ const n = F(r);
444
2673
  return {
445
- error: r,
2674
+ error: n,
446
2675
  activeInputs: t,
447
- queryKey: f(void 0, t, r),
448
- idleData: x
2676
+ queryKey: I(void 0, t, n),
2677
+ idleData: Se
449
2678
  };
450
2679
  }
451
2680
  }
452
- function Oe(e) {
453
- const t = y(e.inputs), n = Ee;
2681
+ function mn(e) {
2682
+ const t = U(e.inputs), r = un;
454
2683
  try {
455
- const r = W(e), i = v(r);
2684
+ const n = qt(e), i = G(n);
456
2685
  return i ? {
457
2686
  error: i,
458
2687
  activeInputs: t,
459
- queryKey: f(void 0, t, i),
460
- idleData: n
2688
+ queryKey: I(void 0, t, i),
2689
+ idleData: r
461
2690
  } : {
462
- intent: r,
2691
+ intent: n,
463
2692
  error: null,
464
2693
  activeInputs: t,
465
- queryKey: f(r, t),
466
- idleData: n
2694
+ queryKey: I(n, t),
2695
+ idleData: r
467
2696
  };
468
- } catch (r) {
469
- const i = m(r);
2697
+ } catch (n) {
2698
+ const i = F(n);
470
2699
  return {
471
2700
  error: i,
472
2701
  activeInputs: t,
473
- queryKey: f(void 0, t, i),
474
- idleData: n
2702
+ queryKey: I(void 0, t, i),
2703
+ idleData: r
475
2704
  };
476
2705
  }
477
2706
  }
478
- function Re(e) {
479
- const t = y(e.inputs);
2707
+ function gn(e) {
2708
+ const t = U(e.inputs);
480
2709
  try {
481
- const n = Y(e), r = v(n);
482
- return r ? {
483
- error: r,
2710
+ const r = It(e), n = G(r);
2711
+ return n ? {
2712
+ error: n,
484
2713
  activeInputs: t,
485
- queryKey: f(void 0, t, r),
486
- idleData: D
2714
+ queryKey: I(void 0, t, n),
2715
+ idleData: we
487
2716
  } : {
488
- intent: n,
2717
+ intent: r,
489
2718
  error: null,
490
2719
  activeInputs: t,
491
- queryKey: f(n, t),
492
- idleData: D
2720
+ queryKey: I(r, t),
2721
+ idleData: we
493
2722
  };
494
- } catch (n) {
495
- const r = m(n);
2723
+ } catch (r) {
2724
+ const n = F(r);
496
2725
  return {
497
- error: r,
2726
+ error: n,
498
2727
  activeInputs: t,
499
- queryKey: f(void 0, t, r),
500
- idleData: D
2728
+ queryKey: I(void 0, t, n),
2729
+ idleData: we
501
2730
  };
502
2731
  }
503
2732
  }
504
- function we(e) {
505
- const t = y(e.inputs), n = De;
2733
+ function hn(e) {
2734
+ const t = U(e.inputs), r = cn;
506
2735
  try {
507
- const r = F(e), i = v(r);
2736
+ const n = wt(e), i = G(n);
508
2737
  return i ? {
509
2738
  error: i,
510
2739
  activeInputs: t,
511
- queryKey: f(void 0, t, i),
512
- idleData: n
2740
+ queryKey: I(void 0, t, i),
2741
+ idleData: r
513
2742
  } : {
514
- intent: r,
2743
+ intent: n,
515
2744
  error: null,
516
2745
  activeInputs: t,
517
- queryKey: f(r, t),
518
- idleData: n
2746
+ queryKey: I(n, t),
2747
+ idleData: r
519
2748
  };
520
- } catch (r) {
521
- const i = m(r);
2749
+ } catch (n) {
2750
+ const i = F(n);
522
2751
  return {
523
2752
  error: i,
524
2753
  activeInputs: t,
525
- queryKey: f(void 0, t, i),
526
- idleData: n
2754
+ queryKey: I(void 0, t, i),
2755
+ idleData: r
527
2756
  };
528
2757
  }
529
2758
  }
530
- function Ce(e) {
531
- const t = y(e.inputs);
2759
+ function yn(e) {
2760
+ const t = U(e.inputs);
532
2761
  try {
533
- const n = J(e), r = v(n);
534
- return r ? {
535
- error: r,
2762
+ const r = xt(e), n = G(r);
2763
+ return n ? {
2764
+ error: n,
536
2765
  activeInputs: t,
537
- queryKey: f(void 0, t, r),
538
- idleData: K
2766
+ queryKey: I(void 0, t, n),
2767
+ idleData: Ie
539
2768
  } : {
540
- intent: n,
2769
+ intent: r,
541
2770
  error: null,
542
2771
  activeInputs: t,
543
- queryKey: f(n, t),
544
- idleData: K
2772
+ queryKey: I(r, t),
2773
+ idleData: Ie
545
2774
  };
546
- } catch (n) {
547
- const r = m(n);
2775
+ } catch (r) {
2776
+ const n = F(r);
548
2777
  return {
549
- error: r,
2778
+ error: n,
550
2779
  activeInputs: t,
551
- queryKey: f(void 0, t, r),
552
- idleData: K
2780
+ queryKey: I(void 0, t, n),
2781
+ idleData: Ie
553
2782
  };
554
2783
  }
555
2784
  }
556
- function m(e) {
2785
+ function F(e) {
557
2786
  return e instanceof Error ? e : new Error(String(e));
558
2787
  }
559
- function v(e) {
560
- const t = ne(e);
2788
+ function G(e) {
2789
+ const t = $t(e);
561
2790
  if (t.ok)
562
2791
  return null;
563
- const n = t.errors.map(
564
- (r) => r.path ? `${r.code} at ${r.path}: ${r.message}` : `${r.code}: ${r.message}`
2792
+ const r = t.errors.map(
2793
+ (n) => n.path ? `${n.code} at ${n.path}: ${n.message}` : `${n.code}: ${n.message}`
565
2794
  ).join("; ");
566
- return new Error(`Invalid Semaphor analytics intent. ${n}`);
2795
+ return new Error(`Invalid Semaphor analytics intent. ${r}`);
567
2796
  }
568
- function f(e, t, n, r) {
2797
+ function I(e, t, r, n) {
569
2798
  return JSON.stringify({
570
2799
  intent: e,
571
2800
  activeInputs: t,
572
- analysisOptions: r,
573
- error: n == null ? void 0 : n.message
2801
+ analysisOptions: n,
2802
+ error: r == null ? void 0 : r.message
574
2803
  });
575
2804
  }
576
- function Qe(e) {
577
- const [t, n] = w(e.defaultValue), r = Object.prototype.hasOwnProperty.call(e, "value"), i = r ? e.value : t, u = p(
578
- () => L(e.options),
2805
+ function Kn(e) {
2806
+ const [t, r] = H(e.defaultValue), n = Object.prototype.hasOwnProperty.call(e, "value"), i = n ? e.value : t, d = b(
2807
+ () => Ge(e.options),
579
2808
  [e.options]
580
- ), s = O(
581
- (a) => {
582
- var o;
583
- const c = a;
584
- (o = e.onValueChange) == null || o.call(e, c), r || n(c);
2809
+ ), l = D(
2810
+ (c) => {
2811
+ var h;
2812
+ const f = c;
2813
+ (h = e.onValueChange) == null || h.call(e, f), n || r(f);
585
2814
  },
586
- [r, e]
587
- ), l = O(() => s(void 0), [s]);
588
- return p(() => {
589
- const a = U(e);
2815
+ [n, e]
2816
+ ), u = D(() => l(void 0), [l]);
2817
+ return b(() => {
2818
+ const c = Je(e);
590
2819
  return {
591
2820
  id: e.id,
592
2821
  kind: e.kind,
593
2822
  label: e.label,
594
- field: a.field,
595
- operator: a.operator,
596
- relationshipHint: a.relationshipHint,
2823
+ field: c.field,
2824
+ operator: c.operator,
2825
+ relationshipHint: c.relationshipHint,
597
2826
  controlRole: e.kind === "control" ? e.role : void 0,
598
2827
  value: i,
599
- options: u,
600
- isActive: q(i),
601
- setValue: s,
602
- clear: l,
2828
+ options: d,
2829
+ isActive: ee(i),
2830
+ setValue: l,
2831
+ clear: u,
603
2832
  toAnalyticsInput: () => ({
604
- inputId: a.inputId,
605
- field: a.field,
2833
+ inputId: c.inputId,
2834
+ field: c.field,
606
2835
  kind: e.kind,
607
2836
  label: e.label,
608
2837
  value: i,
609
- isActive: q(i),
610
- operator: a.operator,
611
- relationshipHint: a.relationshipHint,
2838
+ isActive: ee(i),
2839
+ operator: c.operator,
2840
+ relationshipHint: c.relationshipHint,
612
2841
  controlRole: e.kind === "control" ? e.role : void 0
613
2842
  })
614
2843
  };
615
- }, [l, u, s, e, i]);
2844
+ }, [u, d, l, e, i]);
616
2845
  }
617
- function Je(e) {
618
- const [t, n] = w(() => je(e));
619
- return R(() => {
620
- n((r) => {
621
- let i = r;
622
- for (const u of e)
623
- !Object.prototype.hasOwnProperty.call(i, u.id) && u.defaultValue !== void 0 && (i = { ...i, [u.id]: u.defaultValue });
2846
+ function $n(e) {
2847
+ const [t, r] = H(() => xn(e));
2848
+ return B(() => {
2849
+ r((n) => {
2850
+ let i = n;
2851
+ for (const d of e)
2852
+ !Object.prototype.hasOwnProperty.call(i, d.id) && d.defaultValue !== void 0 && (i = { ...i, [d.id]: d.defaultValue });
624
2853
  return i;
625
2854
  });
626
- }, [e]), p(
627
- () => e.map((r) => {
2855
+ }, [e]), b(
2856
+ () => e.map((n) => {
628
2857
  const i = Object.prototype.hasOwnProperty.call(
629
- r,
2858
+ n,
630
2859
  "value"
631
- ), u = i ? r.value : t[r.id], s = L(r.options), l = (o) => {
632
- var d;
633
- (d = r.onValueChange) == null || d.call(r, o), i || n((S) => ({
634
- ...S,
635
- [r.id]: o
2860
+ ), d = i ? n.value : t[n.id], l = Ge(n.options), u = (h) => {
2861
+ var g;
2862
+ (g = n.onValueChange) == null || g.call(n, h), i || r((y) => ({
2863
+ ...y,
2864
+ [n.id]: h
636
2865
  }));
637
- }, a = () => l(void 0), c = U(r);
2866
+ }, c = () => u(void 0), f = Je(n);
638
2867
  return {
639
- id: r.id,
640
- kind: r.kind,
641
- label: r.label,
642
- field: c.field,
643
- operator: c.operator,
644
- relationshipHint: c.relationshipHint,
645
- controlRole: r.kind === "control" ? r.role : void 0,
646
- value: u,
647
- options: s,
648
- isActive: q(u),
649
- setValue: l,
650
- clear: a,
2868
+ id: n.id,
2869
+ kind: n.kind,
2870
+ label: n.label,
2871
+ field: f.field,
2872
+ operator: f.operator,
2873
+ relationshipHint: f.relationshipHint,
2874
+ controlRole: n.kind === "control" ? n.role : void 0,
2875
+ value: d,
2876
+ options: l,
2877
+ isActive: ee(d),
2878
+ setValue: u,
2879
+ clear: c,
651
2880
  toAnalyticsInput: () => ({
652
- inputId: c.inputId,
653
- field: c.field,
654
- kind: r.kind,
655
- label: r.label,
656
- value: u,
657
- isActive: q(u),
658
- operator: c.operator,
659
- relationshipHint: c.relationshipHint,
660
- controlRole: r.kind === "control" ? r.role : void 0
2881
+ inputId: f.inputId,
2882
+ field: f.field,
2883
+ kind: n.kind,
2884
+ label: n.label,
2885
+ value: d,
2886
+ isActive: ee(d),
2887
+ operator: f.operator,
2888
+ relationshipHint: f.relationshipHint,
2889
+ controlRole: n.kind === "control" ? n.role : void 0
661
2890
  })
662
2891
  };
663
2892
  }),
664
2893
  [e, t]
665
2894
  );
666
2895
  }
667
- function Fe(e, t) {
668
- const n = (t == null ? void 0 : t.status) === "success" ? t.options : void 0, r = p(() => _e(n), [n]);
669
- R(() => {
670
- $e(e.value, n) || e.clear();
671
- }, [e, r, t == null ? void 0 : t.status, n]);
2896
+ function _n(e, t) {
2897
+ const r = (t == null ? void 0 : t.status) === "success" ? t.options : void 0, n = b(() => bn(r), [r]);
2898
+ B(() => {
2899
+ vn(e.value, r) || e.clear();
2900
+ }, [e, n, t == null ? void 0 : t.status, r]);
672
2901
  }
673
- function $e(e, t) {
674
- if (!q(e) || t === void 0)
2902
+ function vn(e, t) {
2903
+ if (!ee(e) || t === void 0)
675
2904
  return !0;
676
- const n = new Set(
677
- t.map((i) => P(i.value))
2905
+ const r = new Set(
2906
+ t.map((i) => He(i.value))
678
2907
  );
679
2908
  return (Array.isArray(e) ? e : [e]).every(
680
- (i) => n.has(P(i))
2909
+ (i) => r.has(He(i))
681
2910
  );
682
2911
  }
683
- function _e(e) {
2912
+ function bn(e) {
684
2913
  return JSON.stringify((e || []).map((t) => t.value));
685
2914
  }
686
- function P(e) {
2915
+ function He(e) {
687
2916
  return `${typeof e}:${String(e)}`;
688
2917
  }
689
- function Ye(e, t = {}) {
690
- const n = p(
2918
+ function Fn(e, t = {}) {
2919
+ const r = b(
691
2920
  () => t.inputs ? {
692
2921
  ...e,
693
2922
  inputs: t.inputs
694
2923
  } : e,
695
2924
  [t.inputs, e]
696
- ), r = p(() => {
697
- switch (n.queryKind) {
2925
+ ), n = b(() => {
2926
+ switch (r.queryKind) {
698
2927
  case "metric":
699
2928
  return {
700
- queryKind: n.queryKind,
701
- request: be(n)
2929
+ queryKind: r.queryKind,
2930
+ request: pn(r)
702
2931
  };
703
2932
  case "analysis":
704
2933
  return {
705
- queryKind: n.queryKind,
706
- request: Ke(n)
2934
+ queryKind: r.queryKind,
2935
+ request: fn(r)
707
2936
  };
708
2937
  case "records":
709
2938
  return {
710
- queryKind: n.queryKind,
711
- request: Oe(n)
2939
+ queryKind: r.queryKind,
2940
+ request: mn(r)
712
2941
  };
713
2942
  case "inputOptions":
714
2943
  return {
715
- queryKind: n.queryKind,
716
- request: Re(n)
2944
+ queryKind: r.queryKind,
2945
+ request: gn(r)
717
2946
  };
718
2947
  case "sql":
719
2948
  return {
720
- queryKind: n.queryKind,
721
- request: we(n)
2949
+ queryKind: r.queryKind,
2950
+ request: hn(r)
722
2951
  };
723
2952
  case "matrix":
724
2953
  return {
725
- queryKind: n.queryKind,
726
- request: Ce(n)
2954
+ queryKind: r.queryKind,
2955
+ request: yn(r)
727
2956
  };
728
2957
  default:
729
- return b(n);
2958
+ return qe(r);
730
2959
  }
731
- }, [n]), i = O(
2960
+ }, [r]), i = zt({
2961
+ spec: r,
2962
+ queryKind: n.queryKind,
2963
+ queryKey: n.request.queryKey,
2964
+ intent: n.request.intent,
2965
+ activeInputs: n.request.activeInputs,
2966
+ debug: t.debug
2967
+ }), d = C(null), l = b(
2968
+ () => ({
2969
+ start: i.start,
2970
+ success: i.success,
2971
+ failure: i.failure,
2972
+ ignored: i.ignored
2973
+ }),
2974
+ [
2975
+ i.failure,
2976
+ i.ignored,
2977
+ i.start,
2978
+ i.success
2979
+ ]
2980
+ ), u = D(
732
2981
  (o) => {
733
- var S, A, $, _, V, I, j, k, T;
734
- const d = r.request;
735
- if (d.intent)
736
- switch (r.queryKind) {
2982
+ var T, k, w, q, O, E, L, x, K;
2983
+ const S = n.request;
2984
+ if (S.intent)
2985
+ switch (n.queryKind) {
737
2986
  case "metric":
738
- return (S = o.executor) == null ? void 0 : S.executeMetric(
739
- d.intent,
2987
+ return (T = o.executor) == null ? void 0 : T.executeMetric(
2988
+ S.intent,
740
2989
  o
741
2990
  );
742
2991
  case "analysis":
743
- return ($ = (A = o.executor) == null ? void 0 : A.executeAnalysis) == null ? void 0 : $.call(
744
- A,
745
- d.intent,
2992
+ return (w = (k = o.executor) == null ? void 0 : k.executeAnalysis) == null ? void 0 : w.call(
2993
+ k,
2994
+ S.intent,
746
2995
  o,
747
- d.analysisOptions
2996
+ S.analysisOptions
748
2997
  );
749
2998
  case "records":
750
- return (_ = o.executor) == null ? void 0 : _.executeRecords(
751
- d.intent,
2999
+ return (q = o.executor) == null ? void 0 : q.executeRecords(
3000
+ S.intent,
752
3001
  o
753
3002
  );
754
3003
  case "inputOptions":
755
- return (V = o.executor) == null ? void 0 : V.executeInputOptions(
756
- d.intent,
3004
+ return (O = o.executor) == null ? void 0 : O.executeInputOptions(
3005
+ S.intent,
757
3006
  o
758
3007
  );
759
3008
  case "sql":
760
- return (j = (I = o.executor) == null ? void 0 : I.executeSql) == null ? void 0 : j.call(
761
- I,
762
- d.intent,
3009
+ return (L = (E = o.executor) == null ? void 0 : E.executeSql) == null ? void 0 : L.call(
3010
+ E,
3011
+ S.intent,
763
3012
  o
764
3013
  );
765
3014
  case "matrix":
766
- return (T = (k = o.executor) == null ? void 0 : k.executeMatrix) == null ? void 0 : T.call(
767
- k,
768
- d.intent,
3015
+ return (K = (x = o.executor) == null ? void 0 : x.executeMatrix) == null ? void 0 : K.call(
3016
+ x,
3017
+ S.intent,
769
3018
  o
770
3019
  );
771
3020
  default:
772
- return b(r);
3021
+ return qe(n);
773
3022
  }
774
3023
  },
775
- [r]
776
- ), u = Ve(
777
- r.request.queryKey,
778
- i,
779
- r.request.idleData,
780
- r.request.activeInputs
781
- ), s = r.request.error ? r.request.idleData : u.data, l = r.request.error ? "error" : u.status, a = !r.request.error && u.status === "loading", c = r.request.error || u.error;
782
- switch (r.queryKind) {
3024
+ [n]
3025
+ ), c = Sn(
3026
+ n.request.queryKey,
3027
+ u,
3028
+ n.request.idleData,
3029
+ n.request.activeInputs,
3030
+ l
3031
+ ), f = i.queryId, h = i.validationFailure;
3032
+ B(() => {
3033
+ const o = n.request.error;
3034
+ if (!o) {
3035
+ d.current = null;
3036
+ return;
3037
+ }
3038
+ const S = `${f}:${o.message}`;
3039
+ d.current !== S && (d.current = S, h(o));
3040
+ }, [
3041
+ n.request.error,
3042
+ n.request.queryKey,
3043
+ f,
3044
+ h
3045
+ ]);
3046
+ const g = n.request.error ? n.request.idleData : c.data, y = n.request.error ? "error" : c.status, m = !n.request.error && c.status === "loading", v = n.request.error || c.error, A = i.trace;
3047
+ switch (n.queryKind) {
783
3048
  case "metric": {
784
- const o = s;
3049
+ const o = g;
785
3050
  return {
786
- id: n.id,
787
- intent: r.request.intent,
3051
+ id: r.id,
3052
+ intent: n.request.intent,
788
3053
  value: (o == null ? void 0 : o.value) ?? null,
789
3054
  measures: o == null ? void 0 : o.measures,
790
3055
  comparisonValue: o == null ? void 0 : o.comparisonValue,
@@ -792,54 +3057,58 @@ function Ye(e, t = {}) {
792
3057
  deltaPercent: o == null ? void 0 : o.deltaPercent,
793
3058
  records: o == null ? void 0 : o.records,
794
3059
  executionResult: o == null ? void 0 : o.executionResult,
795
- status: l,
796
- isLoading: a,
797
- error: c
3060
+ status: y,
3061
+ isLoading: m,
3062
+ error: v,
3063
+ trace: A
798
3064
  };
799
3065
  }
800
3066
  case "analysis": {
801
- const o = B(s);
3067
+ const o = mt(g);
802
3068
  return {
803
- id: n.id,
804
- intent: r.request.intent,
3069
+ id: r.id,
3070
+ intent: n.request.intent,
805
3071
  ...o || {},
806
- status: l,
807
- isLoading: a,
808
- error: c
3072
+ status: y,
3073
+ isLoading: m,
3074
+ error: v,
3075
+ trace: A
809
3076
  };
810
3077
  }
811
3078
  case "records": {
812
- const o = s;
3079
+ const o = g;
813
3080
  return {
814
- id: n.id,
815
- intent: r.request.intent,
3081
+ id: r.id,
3082
+ intent: n.request.intent,
816
3083
  records: (o == null ? void 0 : o.records) || [],
817
3084
  columns: o == null ? void 0 : o.columns,
818
3085
  rowCount: o == null ? void 0 : o.rowCount,
819
3086
  pagination: o == null ? void 0 : o.pagination,
820
3087
  executionResult: o == null ? void 0 : o.executionResult,
821
- status: l,
822
- isLoading: a,
823
- error: c
3088
+ status: y,
3089
+ isLoading: m,
3090
+ error: v,
3091
+ trace: A
824
3092
  };
825
3093
  }
826
3094
  case "inputOptions": {
827
- const o = s;
3095
+ const o = g;
828
3096
  return {
829
- id: n.id,
830
- intent: r.request.intent,
3097
+ id: r.id,
3098
+ intent: n.request.intent,
831
3099
  options: (o == null ? void 0 : o.options) || [],
832
3100
  executionResult: o == null ? void 0 : o.executionResult,
833
- status: l,
834
- isLoading: a,
835
- error: c
3101
+ status: y,
3102
+ isLoading: m,
3103
+ error: v,
3104
+ trace: A
836
3105
  };
837
3106
  }
838
3107
  case "sql": {
839
- const o = s;
3108
+ const o = g;
840
3109
  return {
841
- id: n.id,
842
- intent: r.request.intent,
3110
+ id: r.id,
3111
+ intent: n.request.intent,
843
3112
  records: (o == null ? void 0 : o.records) || [],
844
3113
  columns: o == null ? void 0 : o.columns,
845
3114
  rowCount: o == null ? void 0 : o.rowCount,
@@ -847,106 +3116,120 @@ function Ye(e, t = {}) {
847
3116
  output: o == null ? void 0 : o.output,
848
3117
  rowLimitExceeded: o == null ? void 0 : o.rowLimitExceeded,
849
3118
  executionResult: o == null ? void 0 : o.executionResult,
850
- status: l,
851
- isLoading: a,
852
- error: c
3119
+ status: y,
3120
+ isLoading: m,
3121
+ error: v,
3122
+ trace: A
853
3123
  };
854
3124
  }
855
3125
  case "matrix": {
856
- const o = s;
3126
+ const o = g;
857
3127
  return {
858
- id: n.id,
859
- intent: r.request.intent,
3128
+ id: r.id,
3129
+ intent: n.request.intent,
860
3130
  matrixResult: o == null ? void 0 : o.matrixResult,
861
3131
  grid: o == null ? void 0 : o.grid,
862
3132
  expansion: o == null ? void 0 : o.expansion,
863
3133
  executionResult: o == null ? void 0 : o.executionResult,
864
- status: l,
865
- isLoading: a,
866
- error: c
3134
+ status: y,
3135
+ isLoading: m,
3136
+ error: v,
3137
+ trace: A
867
3138
  };
868
3139
  }
869
3140
  default:
870
- return b(r);
3141
+ return qe(n);
871
3142
  }
872
3143
  }
873
- function Ve(e, t, n, r) {
874
- const i = xe(), u = N(t), s = N(r), [l, a] = w({
3144
+ function Sn(e, t, r, n, i) {
3145
+ const d = ln(), l = C(t), u = C(n), [c, f] = H({
875
3146
  status: "idle",
876
- data: n,
3147
+ data: r,
877
3148
  error: null
878
3149
  });
879
- return u.current = t, s.current = r, R(() => {
880
- let c;
3150
+ return l.current = t, u.current = n, B(() => {
3151
+ let h;
881
3152
  try {
882
- c = u.current({
883
- ...i,
884
- activeInputs: s.current
3153
+ h = l.current({
3154
+ ...d,
3155
+ activeInputs: u.current
885
3156
  });
886
- } catch (d) {
887
- a({
3157
+ } catch (m) {
3158
+ i == null || i.failure(m, 0), f({
888
3159
  status: "error",
889
- data: n,
890
- error: m(d)
3160
+ data: r,
3161
+ error: F(m)
891
3162
  });
892
3163
  return;
893
3164
  }
894
- if (!c) {
895
- a({ status: "idle", data: n, error: null });
3165
+ if (!h) {
3166
+ f({ status: "idle", data: r, error: null });
896
3167
  return;
897
3168
  }
898
- let o = !1;
899
- return a((d) => ({
3169
+ let g = !1;
3170
+ const y = yt();
3171
+ return i == null || i.start(), f((m) => ({
900
3172
  status: "loading",
901
- data: d.data,
3173
+ data: m.data,
902
3174
  error: null
903
- })), c.then((d) => {
904
- o || a({ status: "success", data: d, error: null });
905
- }).catch((d) => {
906
- o || a({
3175
+ })), h.then((m) => {
3176
+ g ? i == null || i.ignored("superseded") : (i == null || i.success(m, Ue(y)), f({ status: "success", data: m, error: null }));
3177
+ }).catch((m) => {
3178
+ g ? i == null || i.ignored("superseded") : (i == null || i.failure(m, Ue(y)), f({
907
3179
  status: "error",
908
- data: n,
909
- error: m(d)
910
- });
3180
+ data: r,
3181
+ error: F(m)
3182
+ }));
911
3183
  }), () => {
912
- o = !0;
3184
+ g = !0;
913
3185
  };
914
- }, [n, e, i]), l;
3186
+ }, [r, e, d, i]), c;
3187
+ }
3188
+ function yt() {
3189
+ return typeof performance < "u" && performance.now ? performance.now() : Date.now();
915
3190
  }
916
- function je(e) {
3191
+ function Ue(e) {
3192
+ return Math.max(0, Math.round(yt() - e));
3193
+ }
3194
+ function xn(e) {
917
3195
  return Object.fromEntries(
918
3196
  e.filter((t) => t.defaultValue !== void 0).map((t) => [t.id, t.defaultValue])
919
3197
  );
920
3198
  }
921
- function b(e) {
3199
+ function qe(e) {
922
3200
  throw new Error(`Unsupported Semaphor query kind: ${JSON.stringify(e)}`);
923
3201
  }
924
- function We({
3202
+ function Wn({
925
3203
  token: e,
926
3204
  apiBaseUrl: t,
927
- executor: n,
928
- children: r
3205
+ executor: r,
3206
+ debug: n,
3207
+ children: i
929
3208
  }) {
930
- var o;
931
- const i = ge(), u = ((o = i == null ? void 0 : i.authToken) == null ? void 0 : o.accessToken) || e, s = (i == null ? void 0 : i.dataApiBaseUrl) || (i == null ? void 0 : i.apiBaseUrl) || t, l = p(() => he(), []), a = n || l, c = p(
3209
+ var g;
3210
+ const d = dn(), l = ((g = d == null ? void 0 : d.authToken) == null ? void 0 : g.accessToken) || e, u = (d == null ? void 0 : d.dataApiBaseUrl) || (d == null ? void 0 : d.apiBaseUrl) || t, c = b(() => Xr(), []), f = r || c, h = b(
932
3211
  () => ({
933
- token: u,
934
- apiBaseUrl: s,
935
- executor: a
3212
+ token: l,
3213
+ apiBaseUrl: u,
3214
+ executor: f
936
3215
  }),
937
- [s, a, u]
3216
+ [u, f, l]
938
3217
  );
939
- return /* @__PURE__ */ oe(M.Provider, { value: c, children: r });
3218
+ return /* @__PURE__ */ s(Wt, { debug: n, children: /* @__PURE__ */ s(ht.Provider, { value: h, children: i }) });
940
3219
  }
941
3220
  export {
942
- We as SemaphorDataAppProvider,
943
- he as createSemaphorQueryExecutor,
944
- ze as defineSemaphorDataApp,
945
- Me as defineSemaphorInput,
946
- $e as isSemaphorInputValueValidForOptions,
947
- He as semaphor,
948
- Fe as useClearInvalidSemaphorInputValue,
949
- Qe as useSemaphorInput,
950
- Je as useSemaphorInputs,
951
- Ye as useSemaphorQuery
3221
+ Wn as SemaphorDataAppProvider,
3222
+ Ln as SemaphorDevtools,
3223
+ Bn as SemaphorDevtoolsInspectButton,
3224
+ On as SemaphorViewBoundary,
3225
+ Xr as createSemaphorQueryExecutor,
3226
+ kn as defineSemaphorDataApp,
3227
+ Cn as defineSemaphorInput,
3228
+ vn as isSemaphorInputValueValidForOptions,
3229
+ Dn as semaphor,
3230
+ _n as useClearInvalidSemaphorInputValue,
3231
+ et as useSemaphorDevtools,
3232
+ Kn as useSemaphorInput,
3233
+ $n as useSemaphorInputs,
3234
+ Fn as useSemaphorQuery
952
3235
  };