react-semaphor 0.1.338 → 0.1.340

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 (59) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +58 -57
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +3 -3
  5. package/dist/chunks/{braces-Q86XHDaD.js → braces-Ccvdip75.js} +1 -1
  6. package/dist/chunks/{braces-BLa_lORs.js → braces-DDHkbW1c.js} +1 -1
  7. package/dist/chunks/{calendar-preferences-dialog-Cocogo9H.js → calendar-preferences-dialog-2IbYrrP1.js} +3 -3
  8. package/dist/chunks/{calendar-preferences-dialog-Bm7ji3k9.js → calendar-preferences-dialog-8-KE5sVX.js} +1 -1
  9. package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +100 -0
  10. package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +1 -0
  11. package/dist/chunks/{chevrons-up-down-BBTZ5pAY.js → chevrons-up-down-B9fTSds9.js} +1 -1
  12. package/dist/chunks/{chevrons-up-down-CYuWasy_.js → chevrons-up-down-pV0i9ptS.js} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-BtqtLx1-.js → dashboard-briefing-launcher-CcqDPVke.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-DF4CoaRn.js → dashboard-briefing-launcher-DtxDRAiu.js} +4 -4
  15. package/dist/chunks/{dashboard-controls-B5U-VUxs.js → dashboard-controls-Bi98DhYD.js} +6 -6
  16. package/dist/chunks/{dashboard-controls-0VMAeMoa.js → dashboard-controls-By7aKmDj.js} +1 -1
  17. package/dist/chunks/{dashboard-json-CqbLOfnr.js → dashboard-json-BOyLuhS6.js} +1 -1
  18. package/dist/chunks/{dashboard-json-Hmc0Ri5z.js → dashboard-json-CGxIsTEP.js} +2 -2
  19. package/dist/chunks/{edit-dashboard-visual-D4VVu-QQ.js → edit-dashboard-visual-Ba8LenNc.js} +6 -6
  20. package/dist/chunks/{edit-dashboard-visual-C0EDM0QB.js → edit-dashboard-visual-BuXlHmJH.js} +1 -1
  21. package/dist/chunks/{index-DE0vIuYG.js → index-DT9osgRT.js} +2 -2
  22. package/dist/chunks/{index-DzyUhzV3.js → index-DVPvpd8u.js} +5 -5
  23. package/dist/chunks/{palette-DalASD28.js → palette-BMXS-AcI.js} +1 -1
  24. package/dist/chunks/{palette-B9AbDw0n.js → palette-DKecBucs.js} +1 -1
  25. package/dist/chunks/{resource-management-panel-C4YydU9I.js → resource-management-panel-98Hy6SYB.js} +3 -3
  26. package/dist/chunks/{resource-management-panel-P9iNqBM1.js → resource-management-panel-ByR-FD3h.js} +1 -1
  27. package/dist/chunks/{switch-BAYfpAEb.js → switch-CP7SmEIZ.js} +1 -1
  28. package/dist/chunks/{switch-CyRoZr5T.js → switch-DYRgERrC.js} +1 -1
  29. package/dist/chunks/{use-create-flow-overlay-state-P1LMwQ89.js → use-create-flow-overlay-state-D5uvjbwY.js} +3 -3
  30. package/dist/chunks/{use-create-flow-overlay-state-CbhjxI3W.js → use-create-flow-overlay-state-uNxArZdj.js} +1 -1
  31. package/dist/chunks/{use-visual-utils-lB-3Zk0b.js → use-visual-utils-BLh9mKic.js} +2 -2
  32. package/dist/chunks/{use-visual-utils-CV6_-y4p.js → use-visual-utils-CpaqIHoc.js} +1 -1
  33. package/dist/chunks/{validators-BOqiGymD.js → validators-CPEQojnV.js} +325 -250
  34. package/dist/chunks/validators-CfP-49k9.js +1 -0
  35. package/dist/dashboard/index.cjs +1 -1
  36. package/dist/dashboard/index.js +1 -1
  37. package/dist/dashboard-authoring/index.cjs +3 -3
  38. package/dist/dashboard-authoring/index.js +424 -561
  39. package/dist/data-app-builder/index.cjs +1 -1
  40. package/dist/data-app-builder/index.js +1 -1
  41. package/dist/data-app-sdk/index.cjs +1 -1
  42. package/dist/data-app-sdk/index.js +313 -308
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.js +7 -7
  45. package/dist/surfboard/index.cjs +1 -1
  46. package/dist/surfboard/index.js +2 -2
  47. package/dist/types/analytics-protocol.d.ts +75 -49
  48. package/dist/types/dashboard-authoring.d.ts +26 -52
  49. package/dist/types/dashboard.d.ts +1 -2
  50. package/dist/types/data-app-builder.d.ts +23 -13
  51. package/dist/types/data-app-sdk.d.ts +33 -46
  52. package/dist/types/main.d.ts +29 -50
  53. package/dist/types/shared.d.ts +1 -2
  54. package/dist/types/surfboard.d.ts +1 -2
  55. package/dist/types/types.d.ts +1 -2
  56. package/package.json +1 -1
  57. package/dist/chunks/catalog-field-grounding-DmT7aGUA.js +0 -191
  58. package/dist/chunks/catalog-field-grounding-VgVzDd25.js +0 -1
  59. package/dist/chunks/validators-BtFXY3S_.js +0 -2
@@ -1,124 +1,153 @@
1
+ import { e as b, f as R, v as $ } from "../chunks/validators-CPEQojnV.js";
1
2
  import { j as w } from "../chunks/index-CuHybtft.js";
2
- import { createContext as $, useContext as O, useMemo as p, useState as x, useCallback as h, useRef as b, useEffect as _ } from "react";
3
- import { jsx as B } from "react/jsx-runtime";
4
- import { v as T } from "../chunks/validators-BOqiGymD.js";
5
- function M(t) {
6
- var r;
3
+ import { createContext as B, useContext as T, useMemo as p, useState as M, useCallback as h, useRef as E, useEffect as _ } from "react";
4
+ import { jsx as K } from "react/jsx-runtime";
5
+ function P(t) {
6
+ var n;
7
+ const e = U(t);
7
8
  return {
8
9
  version: 1,
9
10
  kind: "metric",
10
11
  id: t.id,
11
12
  label: t.label,
12
- source: k(t),
13
- metrics: K(t),
14
- primaryMetric: t.primaryMetric || t.metrics[0],
15
- dateField: t.dateField ? f(t.dateField, "date") : void 0,
13
+ source: D(t),
14
+ metrics: e,
15
+ primaryMetric: C(t, e),
16
+ dateField: t.dateField ? d(t.dateField, "date") : void 0,
16
17
  timeGrain: t.timeGrain,
17
- dimensions: (r = t.dimensions) == null ? void 0 : r.map((o) => f(o, "dimension")),
18
- comparison: G(t.comparison),
19
- inputs: g(t.inputs),
18
+ dimensions: (n = t.dimensions) == null ? void 0 : n.map((o) => d(o, "dimension")),
19
+ comparison: H(t.comparison),
20
+ inputs: k(t.inputs),
20
21
  limit: t.limit
21
22
  };
22
23
  }
23
- function K(t) {
24
- return Array.from(
25
- new Set(
26
- t.metrics.filter(
27
- (r) => typeof r == "string" && r.trim().length > 0
28
- )
29
- )
30
- );
24
+ function C(t, e) {
25
+ if (!t.primaryMetric)
26
+ return e[0] || { name: "", role: "measure" };
27
+ const n = d(t.primaryMetric, "measure"), o = n.source ? e.find((r) => b(r, n)) : (() => {
28
+ const r = e.filter(
29
+ (i) => i.name === n.name
30
+ );
31
+ return r.length === 1 ? r[0] : void 0;
32
+ })();
33
+ return o ? R(n, o) : n;
34
+ }
35
+ function U(t) {
36
+ const e = [];
37
+ for (const n of t.metrics.map((o) => d(o, "measure"))) {
38
+ if (!n.name)
39
+ continue;
40
+ const o = e.findIndex(
41
+ (r) => b(r, n)
42
+ );
43
+ if (o === -1) {
44
+ e.push(n);
45
+ continue;
46
+ }
47
+ e[o] = R(
48
+ e[o],
49
+ n
50
+ );
51
+ }
52
+ return e;
31
53
  }
32
- function C(t) {
54
+ function F(t) {
33
55
  if ("sort" in t)
34
56
  throw new Error(
35
57
  "useSemaphorRecords supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet."
36
58
  );
37
- if (!L(t))
59
+ if (!J(t))
38
60
  throw new Error(
39
- "useSemaphorRecords needs at least one field, dimension, or measure."
61
+ "useSemaphorRecords needs at least one field."
40
62
  );
41
- const r = Q(
42
- t.fields,
43
- t.dimensions,
44
- t.measures
45
- );
63
+ const e = z(t.fields);
46
64
  return {
47
65
  version: 1,
48
66
  kind: "records",
49
67
  id: t.id,
50
68
  label: t.label,
51
- source: k(t),
52
- fields: r,
53
- measures: t.measures,
54
- dateField: t.dateField ? f(t.dateField, "date") : void 0,
69
+ source: D(t),
70
+ fields: e,
71
+ dateField: t.dateField ? d(t.dateField, "date") : void 0,
55
72
  timeGrain: t.timeGrain,
56
- orderBy: t.orderBy,
57
- inputs: g(t.inputs),
73
+ orderBy: t.orderBy ? {
74
+ field: d(t.orderBy.field),
75
+ direction: t.orderBy.direction
76
+ } : void 0,
77
+ inputs: k(t.inputs),
58
78
  limit: t.limit
59
79
  };
60
80
  }
61
- function P(t) {
81
+ function z(t) {
82
+ return t.map((e) => {
83
+ const n = d(e);
84
+ if (!n.role)
85
+ throw new Error(
86
+ `useSemaphorRecords field "${n.name}" needs an explicit role.`
87
+ );
88
+ return n;
89
+ });
90
+ }
91
+ function V(t) {
62
92
  return {
63
93
  version: 1,
64
94
  kind: "inputOptions",
65
95
  id: t.id,
66
96
  label: t.label,
67
- source: k(t),
68
- field: f(t.field, "dimension"),
97
+ source: D(t),
98
+ field: d(t.field, "dimension"),
69
99
  search: t.search,
70
100
  limit: t.limit
71
101
  };
72
102
  }
73
- function U(t) {
103
+ function j(t) {
74
104
  if ("toAnalyticsInput" in t) {
75
- const r = t.toAnalyticsInput();
105
+ const e = t.toAnalyticsInput();
76
106
  return {
77
- inputId: r.inputId,
78
- field: r.field
107
+ inputId: e.inputId,
108
+ ...e.field ? { field: e.field } : {}
79
109
  };
80
110
  }
81
111
  return {
82
112
  inputId: t.inputId,
83
- field: t.field
113
+ ...t.field ? { field: t.field } : {}
84
114
  };
85
115
  }
86
- function lt(t) {
87
- const r = g(t);
88
- return r.length > 0 ? r : void 0;
116
+ function ct(t) {
117
+ const e = k(t);
118
+ return e.length > 0 ? e : void 0;
89
119
  }
90
120
  function N(t) {
91
- return (t || []).map(j);
121
+ return (t || []).map(G);
92
122
  }
93
- function R(t) {
94
- return N(t).filter((r) => r.isActive);
123
+ function q(t) {
124
+ return N(t).filter((e) => e.isActive);
95
125
  }
96
- function V(t) {
126
+ function L(t) {
97
127
  return t.kind === "filter" ? {
98
128
  inputId: t.id,
99
129
  kind: t.kind,
100
130
  label: t.label,
101
- field: f(t.field, "dimension"),
102
- operator: t.operator || "in",
103
- source: t.source
131
+ field: d(t.field, "dimension"),
132
+ operator: t.operator || "in"
104
133
  } : {
105
134
  inputId: t.id,
106
135
  kind: t.kind,
107
136
  label: t.label
108
137
  };
109
138
  }
110
- function F(t = []) {
139
+ function Q(t = []) {
111
140
  return t.map(
112
- (r) => typeof r == "object" ? r : {
113
- label: String(r),
114
- value: r
141
+ (e) => typeof e == "object" ? e : {
142
+ label: String(e),
143
+ value: e
115
144
  }
116
145
  );
117
146
  }
118
147
  function A(t) {
119
148
  return t == null ? !1 : Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.trim().length > 0 : !0;
120
149
  }
121
- function j(t) {
150
+ function G(t) {
122
151
  return "toAnalyticsInput" in t ? t.toAnalyticsInput() : "kind" in t && "isActive" in t ? t : {
123
152
  ...t,
124
153
  kind: "filter",
@@ -128,103 +157,81 @@ function j(t) {
128
157
  value: t.value
129
158
  };
130
159
  }
131
- function k(t) {
132
- if ("source" in t && t.source)
133
- return t.source;
134
- const r = t.datasetName || t.dataset;
135
- if (!r)
136
- throw new Error("Semaphor data app source needs datasetName or dataset.");
137
- return {
138
- kind: "semantic",
139
- domainId: t.domainId,
140
- datasetName: r,
141
- datasetId: t.datasetId,
142
- connectionId: t.connectionId,
143
- label: t.sourceLabel
144
- };
145
- }
146
- function L(t) {
147
- var r, o, n;
148
- return !!((r = t.fields) != null && r.length || (o = t.dimensions) != null && o.length || (n = t.measures) != null && n.length);
149
- }
150
- function z(t) {
151
- return !!(t != null && t.length);
160
+ function D(t) {
161
+ return t.source;
152
162
  }
153
- function Q(t, r, o) {
154
- const n = [], e = /* @__PURE__ */ new Set(), a = (i) => {
155
- const s = `${i.role || ""}:${i.name}`;
156
- e.has(s) || (e.add(s), n.push(i));
157
- };
158
- return z(t) && t.map((i) => f(i)).forEach(a), r == null || r.map((i) => f(i, "dimension")).forEach(a), o == null || o.map((i) => f(i, "measure")).forEach(a), n;
163
+ function J(t) {
164
+ var e;
165
+ return !!((e = t.fields) != null && e.length);
159
166
  }
160
- function f(t, r) {
161
- return typeof t == "string" ? r ? { name: t, role: r } : { name: t } : {
167
+ function d(t, e) {
168
+ return {
162
169
  ...t,
163
- role: t.role || r
170
+ role: t.role || e
164
171
  };
165
172
  }
166
- function g(t) {
167
- return (t || []).map(U);
173
+ function k(t) {
174
+ return (t || []).map(j);
168
175
  }
169
- function G(t) {
170
- if (!(!t || t === "none"))
171
- return typeof t == "object" ? t : t === "same_period_last_year" ? { kind: "previous_year" } : { kind: t };
176
+ function H(t) {
177
+ if (t)
178
+ return t;
172
179
  }
173
- function J() {
180
+ function W() {
174
181
  return {
175
- executeMetric: (t, r) => v(t, r),
176
- executeRecords: (t, r) => v(t, r),
177
- executeInputOptions: (t, r) => v(t, r)
182
+ executeMetric: (t, e) => v(t, e),
183
+ executeRecords: (t, e) => v(t, e),
184
+ executeInputOptions: (t, e) => v(t, e)
178
185
  };
179
186
  }
180
- async function v(t, r) {
181
- if (!r.token)
187
+ async function v(t, e) {
188
+ if (!e.token)
182
189
  throw new Error("SemaphorDataAppProvider needs a token to execute queries.");
183
- const o = await fetch(X(r), {
190
+ const n = await fetch(Z(e), {
184
191
  method: "POST",
185
192
  headers: {
186
193
  "Content-Type": "application/json",
187
- Authorization: `Bearer ${r.token}`
194
+ Authorization: `Bearer ${e.token}`
188
195
  },
189
196
  body: JSON.stringify({
190
197
  intent: t,
191
- activeInputs: r.activeInputs,
198
+ activeInputs: e.activeInputs,
192
199
  resultShape: t.kind
193
200
  })
194
- }), n = await H(o);
195
- if (!o.ok || n.error)
201
+ }), o = await X(n);
202
+ if (!n.ok || o.error)
196
203
  throw new Error(
197
- n.error || `Semaphor Data App execution failed with status ${o.status}.`
204
+ o.error || `Semaphor Data App execution failed with status ${n.status}.`
198
205
  );
199
- return n;
206
+ return o;
200
207
  }
201
- async function H(t) {
202
- const r = await t.text().catch(() => "");
203
- if (!r.trim())
208
+ async function X(t) {
209
+ const e = await t.text().catch(() => "");
210
+ if (!e.trim())
204
211
  return t.ok ? {
205
212
  error: "Semaphor Data App execution returned an empty response."
206
213
  } : {};
207
214
  try {
208
- return JSON.parse(r);
215
+ return JSON.parse(e);
209
216
  } catch {
210
217
  return t.ok ? {
211
218
  error: "Semaphor Data App execution returned invalid JSON.",
212
- details: r
219
+ details: e
213
220
  } : {
214
- error: W(t, r),
215
- details: r
221
+ error: Y(t, e),
222
+ details: e
216
223
  };
217
224
  }
218
225
  }
219
- function W(t, r) {
220
- const o = t.statusText ? ` ${t.statusText}` : "", n = r.replace(/\s+/g, " ").trim();
221
- return n ? `Semaphor Data App execution failed with status ${t.status}${o}: ${n.slice(0, 240)}` : `Semaphor Data App execution failed with status ${t.status}${o}.`;
226
+ function Y(t, e) {
227
+ const n = t.statusText ? ` ${t.statusText}` : "", o = e.replace(/\s+/g, " ").trim();
228
+ return o ? `Semaphor Data App execution failed with status ${t.status}${n}: ${o.slice(0, 240)}` : `Semaphor Data App execution failed with status ${t.status}${n}.`;
222
229
  }
223
- function X(t) {
224
- const r = Y(t).replace(/\/+$/, "");
225
- return r ? r.endsWith("/api") ? `${r}/v1/data-app/execute` : `${r}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
230
+ function Z(t) {
231
+ const e = tt(t).replace(/\/+$/, "");
232
+ return e ? e.endsWith("/api") ? `${e}/v1/data-app/execute` : `${e}/api/v1/data-app/execute` : "/api/v1/data-app/execute";
226
233
  }
227
- function Y(t) {
234
+ function tt(t) {
228
235
  if (t.apiBaseUrl)
229
236
  return t.apiBaseUrl;
230
237
  if (!t.token)
@@ -235,299 +242,297 @@ function Y(t) {
235
242
  return "";
236
243
  }
237
244
  }
238
- const q = $({});
239
- function Z() {
245
+ const O = B({});
246
+ function et() {
240
247
  if (!(typeof window > "u"))
241
248
  return window.__SEMAPHOR_DATA_APP_RUNTIME__;
242
249
  }
243
- function tt() {
244
- return O(q);
250
+ function rt() {
251
+ return T(O);
245
252
  }
246
- function dt({
253
+ function ft({
247
254
  token: t,
248
- apiBaseUrl: r,
249
- executor: o,
250
- children: n
255
+ apiBaseUrl: e,
256
+ executor: n,
257
+ children: o
251
258
  }) {
252
- var l;
253
- const e = Z(), a = ((l = e == null ? void 0 : e.authToken) == null ? void 0 : l.accessToken) || t, i = (e == null ? void 0 : e.dataApiBaseUrl) || (e == null ? void 0 : e.apiBaseUrl) || r, s = p(() => J(), []), u = o || s, c = p(
259
+ var s;
260
+ const r = et(), i = ((s = r == null ? void 0 : r.authToken) == null ? void 0 : s.accessToken) || t, a = (r == null ? void 0 : r.dataApiBaseUrl) || (r == null ? void 0 : r.apiBaseUrl) || e, m = p(() => W(), []), u = n || m, c = p(
254
261
  () => ({
255
- token: a,
256
- apiBaseUrl: i,
262
+ token: i,
263
+ apiBaseUrl: a,
257
264
  executor: u
258
265
  }),
259
- [i, u, a]
266
+ [a, u, i]
260
267
  );
261
- return /* @__PURE__ */ B(q.Provider, { value: c, children: n });
268
+ return /* @__PURE__ */ K(O.Provider, { value: c, children: o });
262
269
  }
263
- const I = { value: null }, rt = { records: [] }, S = { options: [] };
264
- function et(t) {
265
- const r = R(t.inputs);
270
+ const S = { value: null }, nt = { records: [] }, I = { options: [] };
271
+ function ot(t) {
272
+ const e = q(t.inputs);
266
273
  try {
267
- const o = M(t), n = D(o);
268
- return n ? {
269
- error: n,
270
- activeInputs: r,
271
- queryKey: d(void 0, r, n),
272
- idleData: I
274
+ const n = P(t), o = x(n);
275
+ return o ? {
276
+ error: o,
277
+ activeInputs: e,
278
+ queryKey: l(void 0, e, o),
279
+ idleData: S
273
280
  } : {
274
- intent: o,
281
+ intent: n,
275
282
  error: null,
276
- activeInputs: r,
277
- queryKey: d(o, r),
278
- idleData: I
283
+ activeInputs: e,
284
+ queryKey: l(n, e),
285
+ idleData: S
279
286
  };
280
- } catch (o) {
281
- const n = y(o);
287
+ } catch (n) {
288
+ const o = y(n);
282
289
  return {
283
- error: n,
284
- activeInputs: r,
285
- queryKey: d(void 0, r, n),
286
- idleData: I
290
+ error: o,
291
+ activeInputs: e,
292
+ queryKey: l(void 0, e, o),
293
+ idleData: S
287
294
  };
288
295
  }
289
296
  }
290
- function nt(t) {
291
- const r = R(t.inputs), o = rt;
297
+ function it(t) {
298
+ const e = q(t.inputs), n = nt;
292
299
  try {
293
- const n = C(t), e = D(n);
294
- return e ? {
295
- error: e,
296
- activeInputs: r,
297
- queryKey: d(void 0, r, e),
298
- idleData: o
300
+ const o = F(t), r = x(o);
301
+ return r ? {
302
+ error: r,
303
+ activeInputs: e,
304
+ queryKey: l(void 0, e, r),
305
+ idleData: n
299
306
  } : {
300
- intent: n,
307
+ intent: o,
301
308
  error: null,
302
- activeInputs: r,
303
- queryKey: d(n, r),
304
- idleData: o
309
+ activeInputs: e,
310
+ queryKey: l(o, e),
311
+ idleData: n
305
312
  };
306
- } catch (n) {
307
- const e = y(n);
313
+ } catch (o) {
314
+ const r = y(o);
308
315
  return {
309
- error: e,
310
- activeInputs: r,
311
- queryKey: d(void 0, r, e),
312
- idleData: o
316
+ error: r,
317
+ activeInputs: e,
318
+ queryKey: l(void 0, e, r),
319
+ idleData: n
313
320
  };
314
321
  }
315
322
  }
316
- function ot(t) {
323
+ function at(t) {
317
324
  try {
318
- const r = P(t), o = D(r);
319
- return o ? {
320
- error: o,
321
- queryKey: d(void 0, void 0, o),
322
- idleData: S
325
+ const e = V(t), n = x(e);
326
+ return n ? {
327
+ error: n,
328
+ queryKey: l(void 0, void 0, n),
329
+ idleData: I
323
330
  } : {
324
- intent: r,
331
+ intent: e,
325
332
  error: null,
326
- queryKey: d(r),
327
- idleData: S
333
+ queryKey: l(e),
334
+ idleData: I
328
335
  };
329
- } catch (r) {
330
- const o = y(r);
336
+ } catch (e) {
337
+ const n = y(e);
331
338
  return {
332
- error: o,
333
- queryKey: d(void 0, void 0, o),
334
- idleData: S
339
+ error: n,
340
+ queryKey: l(void 0, void 0, n),
341
+ idleData: I
335
342
  };
336
343
  }
337
344
  }
338
345
  function y(t) {
339
346
  return t instanceof Error ? t : new Error(String(t));
340
347
  }
341
- function D(t) {
342
- const r = T(t);
343
- if (r.ok)
348
+ function x(t) {
349
+ const e = $(t);
350
+ if (e.ok)
344
351
  return null;
345
- const o = r.errors.map(
346
- (n) => n.path ? `${n.code} at ${n.path}: ${n.message}` : `${n.code}: ${n.message}`
352
+ const n = e.errors.map(
353
+ (o) => o.path ? `${o.code} at ${o.path}: ${o.message}` : `${o.code}: ${o.message}`
347
354
  ).join("; ");
348
- return new Error(`Invalid Semaphor analytics intent. ${o}`);
355
+ return new Error(`Invalid Semaphor analytics intent. ${n}`);
349
356
  }
350
- function d(t, r, o) {
357
+ function l(t, e, n) {
351
358
  return JSON.stringify({
352
359
  intent: t,
353
- activeInputs: r,
354
- error: o == null ? void 0 : o.message
360
+ activeInputs: e,
361
+ error: n == null ? void 0 : n.message
355
362
  });
356
363
  }
357
- function ct(t) {
358
- const [r, o] = x(t.defaultValue), n = Object.prototype.hasOwnProperty.call(t, "value"), e = n ? t.value : r, a = p(
359
- () => F(t.options),
364
+ function pt(t) {
365
+ const [e, n] = M(t.defaultValue), o = Object.prototype.hasOwnProperty.call(t, "value"), r = o ? t.value : e, i = p(
366
+ () => Q(t.options),
360
367
  [t.options]
361
- ), i = h(
368
+ ), a = h(
362
369
  (u) => {
363
- var l;
370
+ var s;
364
371
  const c = u;
365
- (l = t.onValueChange) == null || l.call(t, c), n || o(c);
372
+ (s = t.onValueChange) == null || s.call(t, c), o || n(c);
366
373
  },
367
- [n, t]
368
- ), s = h(() => i(void 0), [i]);
374
+ [o, t]
375
+ ), m = h(() => a(void 0), [a]);
369
376
  return p(() => {
370
- const u = V(t);
377
+ const u = L(t);
371
378
  return {
372
379
  id: t.id,
373
380
  kind: t.kind,
374
381
  label: t.label,
375
382
  field: u.field,
376
383
  operator: u.operator,
377
- source: u.source,
378
384
  controlRole: t.kind === "control" ? t.role : void 0,
379
- value: e,
380
- options: a,
381
- isActive: A(e),
382
- setValue: i,
383
- clear: s,
385
+ value: r,
386
+ options: i,
387
+ isActive: A(r),
388
+ setValue: a,
389
+ clear: m,
384
390
  toAnalyticsInput: () => ({
385
391
  inputId: u.inputId,
386
392
  field: u.field,
387
393
  kind: t.kind,
388
394
  label: t.label,
389
- value: e,
390
- isActive: A(e),
395
+ value: r,
396
+ isActive: A(r),
391
397
  operator: u.operator,
392
- source: u.source,
393
398
  controlRole: t.kind === "control" ? t.role : void 0
394
399
  })
395
400
  };
396
- }, [s, a, i, t, e]);
401
+ }, [m, i, a, t, r]);
397
402
  }
398
- function ft(t) {
399
- const r = p(() => et(t), [t]), o = h(
400
- (a) => {
401
- var i;
402
- return r.intent ? (i = a.executor) == null ? void 0 : i.executeMetric(r.intent, a) : void 0;
403
+ function mt(t) {
404
+ const e = p(() => ot(t), [t]), n = h(
405
+ (i) => {
406
+ var a;
407
+ return e.intent ? (a = i.executor) == null ? void 0 : a.executeMetric(e.intent, i) : void 0;
403
408
  },
404
- [r.intent]
405
- ), n = E(
406
- r.queryKey,
407
- o,
408
- r.idleData,
409
- r.activeInputs
410
- ), e = r.error ? r.idleData : n.data;
409
+ [e.intent]
410
+ ), o = g(
411
+ e.queryKey,
412
+ n,
413
+ e.idleData,
414
+ e.activeInputs
415
+ ), r = e.error ? e.idleData : o.data;
411
416
  return {
412
417
  id: t.id,
413
- intent: r.intent,
414
- value: (e == null ? void 0 : e.value) ?? null,
415
- metrics: e == null ? void 0 : e.metrics,
416
- comparisonValue: e == null ? void 0 : e.comparisonValue,
417
- delta: e == null ? void 0 : e.delta,
418
- deltaPercent: e == null ? void 0 : e.deltaPercent,
419
- records: e == null ? void 0 : e.records,
420
- status: r.error ? "error" : n.status,
421
- isLoading: !r.error && n.status === "loading",
422
- error: r.error || n.error
418
+ intent: e.intent,
419
+ value: (r == null ? void 0 : r.value) ?? null,
420
+ metrics: r == null ? void 0 : r.metrics,
421
+ comparisonValue: r == null ? void 0 : r.comparisonValue,
422
+ delta: r == null ? void 0 : r.delta,
423
+ deltaPercent: r == null ? void 0 : r.deltaPercent,
424
+ records: r == null ? void 0 : r.records,
425
+ status: e.error ? "error" : o.status,
426
+ isLoading: !e.error && o.status === "loading",
427
+ error: e.error || o.error
423
428
  };
424
429
  }
425
- function mt(t) {
426
- const r = p(() => nt(t), [t]), o = h(
427
- (a) => {
428
- var i;
429
- return r.intent ? (i = a.executor) == null ? void 0 : i.executeRecords(r.intent, a) : void 0;
430
+ function ht(t) {
431
+ const e = p(() => it(t), [t]), n = h(
432
+ (i) => {
433
+ var a;
434
+ return e.intent ? (a = i.executor) == null ? void 0 : a.executeRecords(e.intent, i) : void 0;
430
435
  },
431
- [r.intent]
432
- ), n = E(
433
- r.queryKey,
434
- o,
435
- r.idleData,
436
- r.activeInputs
437
- ), e = r.error ? r.idleData : n.data;
436
+ [e.intent]
437
+ ), o = g(
438
+ e.queryKey,
439
+ n,
440
+ e.idleData,
441
+ e.activeInputs
442
+ ), r = e.error ? e.idleData : o.data;
438
443
  return {
439
444
  id: t.id,
440
- intent: r.intent,
441
- records: (e == null ? void 0 : e.records) || [],
442
- columns: e == null ? void 0 : e.columns,
443
- rowCount: e == null ? void 0 : e.rowCount,
444
- status: r.error ? "error" : n.status,
445
- isLoading: !r.error && n.status === "loading",
446
- error: r.error || n.error
445
+ intent: e.intent,
446
+ records: (r == null ? void 0 : r.records) || [],
447
+ columns: r == null ? void 0 : r.columns,
448
+ rowCount: r == null ? void 0 : r.rowCount,
449
+ status: e.error ? "error" : o.status,
450
+ isLoading: !e.error && o.status === "loading",
451
+ error: e.error || o.error
447
452
  };
448
453
  }
449
- function pt(t) {
450
- const r = p(() => ot(t), [t]), o = h(
451
- (a) => {
452
- var i;
453
- return r.intent ? (i = a.executor) == null ? void 0 : i.executeInputOptions(r.intent, a) : void 0;
454
+ function yt(t) {
455
+ const e = p(() => at(t), [t]), n = h(
456
+ (i) => {
457
+ var a;
458
+ return e.intent ? (a = i.executor) == null ? void 0 : a.executeInputOptions(e.intent, i) : void 0;
454
459
  },
455
- [r.intent]
456
- ), n = E(
457
- r.queryKey,
458
- o,
459
- r.idleData
460
- ), e = r.error ? r.idleData : n.data;
460
+ [e.intent]
461
+ ), o = g(
462
+ e.queryKey,
463
+ n,
464
+ e.idleData
465
+ ), r = e.error ? e.idleData : o.data;
461
466
  return {
462
467
  id: t.id,
463
- intent: r.intent,
464
- options: (e == null ? void 0 : e.options) || [],
465
- status: r.error ? "error" : n.status,
466
- isLoading: !r.error && n.status === "loading",
467
- error: r.error || n.error
468
+ intent: e.intent,
469
+ options: (r == null ? void 0 : r.options) || [],
470
+ status: e.error ? "error" : o.status,
471
+ isLoading: !e.error && o.status === "loading",
472
+ error: e.error || o.error
468
473
  };
469
474
  }
470
- function E(t, r, o, n) {
471
- const e = tt(), a = b(r), i = b(n), [s, u] = x({
475
+ function g(t, e, n, o) {
476
+ const r = rt(), i = E(e), a = E(o), [m, u] = M({
472
477
  status: "idle",
473
- data: o,
478
+ data: n,
474
479
  error: null
475
480
  });
476
- return a.current = r, i.current = n, _(() => {
481
+ return i.current = e, a.current = o, _(() => {
477
482
  let c;
478
483
  try {
479
- c = a.current({
480
- ...e,
481
- activeInputs: i.current
484
+ c = i.current({
485
+ ...r,
486
+ activeInputs: a.current
482
487
  });
483
- } catch (m) {
488
+ } catch (f) {
484
489
  u({
485
490
  status: "error",
486
- data: o,
487
- error: y(m)
491
+ data: n,
492
+ error: y(f)
488
493
  });
489
494
  return;
490
495
  }
491
496
  if (!c) {
492
- u({ status: "idle", data: o, error: null });
497
+ u({ status: "idle", data: n, error: null });
493
498
  return;
494
499
  }
495
- let l = !1;
496
- return u((m) => ({
500
+ let s = !1;
501
+ return u((f) => ({
497
502
  status: "loading",
498
- data: m.data,
503
+ data: f.data,
499
504
  error: null
500
- })), c.then((m) => {
501
- l || u({ status: "success", data: m, error: null });
502
- }).catch((m) => {
503
- l || u({
505
+ })), c.then((f) => {
506
+ s || u({ status: "success", data: f, error: null });
507
+ }).catch((f) => {
508
+ s || u({
504
509
  status: "error",
505
- data: o,
506
- error: y(m)
510
+ data: n,
511
+ error: y(f)
507
512
  });
508
513
  }), () => {
509
- l = !0;
514
+ s = !0;
510
515
  };
511
- }, [o, t, e]), s;
516
+ }, [n, t, r]), m;
512
517
  }
513
518
  export {
514
- q as SemaphorDataAppContext,
515
- dt as SemaphorDataAppProvider,
516
- J as createSemaphorDataAppExecutor,
519
+ O as SemaphorDataAppContext,
520
+ ft as SemaphorDataAppProvider,
521
+ W as createSemaphorDataAppExecutor,
517
522
  A as hasSemaphorInputValue,
518
- F as normalizeSemaphorInputOptions,
519
- Z as readWindowRuntime,
520
- R as toSemaphorActiveInputSnapshots,
521
- U as toSemaphorInputBinding,
522
- lt as toSemaphorInputBindings,
523
- P as toSemaphorInputOptionsIntent,
523
+ Q as normalizeSemaphorInputOptions,
524
+ et as readWindowRuntime,
525
+ q as toSemaphorActiveInputSnapshots,
526
+ j as toSemaphorInputBinding,
527
+ ct as toSemaphorInputBindings,
528
+ V as toSemaphorInputOptionsIntent,
524
529
  N as toSemaphorInputSnapshots,
525
- V as toSemaphorInputSpec,
526
- M as toSemaphorMetricIntent,
527
- C as toSemaphorRecordsIntent,
528
- tt as useSemaphorDataAppRuntime,
529
- ct as useSemaphorInput,
530
- pt as useSemaphorInputOptions,
531
- ft as useSemaphorMetric,
532
- mt as useSemaphorRecords
530
+ L as toSemaphorInputSpec,
531
+ P as toSemaphorMetricIntent,
532
+ F as toSemaphorRecordsIntent,
533
+ rt as useSemaphorDataAppRuntime,
534
+ pt as useSemaphorInput,
535
+ yt as useSemaphorInputOptions,
536
+ mt as useSemaphorMetric,
537
+ ht as useSemaphorRecords
533
538
  };