@blazes/data-visualization 0.0.0-stage → 1.0.0-alpha.1

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 (170) hide show
  1. package/README.md +238 -2
  2. package/dist/.vite/manifest.json +129 -0
  3. package/dist/PivotTableS2Renderer-C-Urwhuv.js +109 -0
  4. package/dist/PivotTableS2Renderer-C-Urwhuv.js.map +1 -0
  5. package/dist/WordCloudRenderer-7tzJz57a.js +96 -0
  6. package/dist/WordCloudRenderer-7tzJz57a.js.map +1 -0
  7. package/dist/core/adapter/index.d.ts +5 -0
  8. package/dist/core/adapter/index.d.ts.map +1 -0
  9. package/dist/core/adapter/standard-adapters.d.ts +211 -0
  10. package/dist/core/adapter/standard-adapters.d.ts.map +1 -0
  11. package/dist/core/adapter/standard-definitions.d.ts +230 -0
  12. package/dist/core/adapter/standard-definitions.d.ts.map +1 -0
  13. package/dist/core/adapter/types.d.ts +44 -0
  14. package/dist/core/adapter/types.d.ts.map +1 -0
  15. package/dist/core/adapter/view-models.d.ts +101 -0
  16. package/dist/core/adapter/view-models.d.ts.map +1 -0
  17. package/dist/core/config/config-validator.d.ts +27 -0
  18. package/dist/core/config/config-validator.d.ts.map +1 -0
  19. package/dist/core/config/dashboard-config-schema.d.ts +1360 -0
  20. package/dist/core/config/dashboard-config-schema.d.ts.map +1 -0
  21. package/dist/core/config/dashboard-config.d.ts +410 -0
  22. package/dist/core/config/dashboard-config.d.ts.map +1 -0
  23. package/dist/core/config/index.d.ts +9 -0
  24. package/dist/core/config/index.d.ts.map +1 -0
  25. package/dist/core/config/json-value.d.ts +5 -0
  26. package/dist/core/config/json-value.d.ts.map +1 -0
  27. package/dist/core/config/runtime-schema.d.ts +28 -0
  28. package/dist/core/config/runtime-schema.d.ts.map +1 -0
  29. package/dist/core/config/schema-version.d.ts +3 -0
  30. package/dist/core/config/schema-version.d.ts.map +1 -0
  31. package/dist/core/config/serializable.d.ts +6 -0
  32. package/dist/core/config/serializable.d.ts.map +1 -0
  33. package/dist/core/config/value-path.d.ts +2 -0
  34. package/dist/core/config/value-path.d.ts.map +1 -0
  35. package/dist/core/dataset/dataset-runner.d.ts +28 -0
  36. package/dist/core/dataset/dataset-runner.d.ts.map +1 -0
  37. package/dist/core/dataset/index.d.ts +4 -0
  38. package/dist/core/dataset/index.d.ts.map +1 -0
  39. package/dist/core/dataset/normalize.d.ts +8 -0
  40. package/dist/core/dataset/normalize.d.ts.map +1 -0
  41. package/dist/core/dataset/types.d.ts +37 -0
  42. package/dist/core/dataset/types.d.ts.map +1 -0
  43. package/dist/core/export/csv.d.ts +11 -0
  44. package/dist/core/export/csv.d.ts.map +1 -0
  45. package/dist/core/export/index.d.ts +2 -0
  46. package/dist/core/export/index.d.ts.map +1 -0
  47. package/dist/core/formatter/index.d.ts +2 -0
  48. package/dist/core/formatter/index.d.ts.map +1 -0
  49. package/dist/core/formatter/value-formatter.d.ts +14 -0
  50. package/dist/core/formatter/value-formatter.d.ts.map +1 -0
  51. package/dist/core/index.d.ts +11 -0
  52. package/dist/core/index.d.ts.map +1 -0
  53. package/dist/core/index.js +111 -0
  54. package/dist/core/index.js.map +1 -0
  55. package/dist/core/provider/data-provider.d.ts +18 -0
  56. package/dist/core/provider/data-provider.d.ts.map +1 -0
  57. package/dist/core/provider/index.d.ts +5 -0
  58. package/dist/core/provider/index.d.ts.map +1 -0
  59. package/dist/core/provider/request-executor.d.ts +48 -0
  60. package/dist/core/provider/request-executor.d.ts.map +1 -0
  61. package/dist/core/provider/request-value-codec.d.ts +15 -0
  62. package/dist/core/provider/request-value-codec.d.ts.map +1 -0
  63. package/dist/core/provider/resolve-request-input.d.ts +12 -0
  64. package/dist/core/provider/resolve-request-input.d.ts.map +1 -0
  65. package/dist/core/registry/core-registries.d.ts +15 -0
  66. package/dist/core/registry/core-registries.d.ts.map +1 -0
  67. package/dist/core/registry/index.d.ts +4 -0
  68. package/dist/core/registry/index.d.ts.map +1 -0
  69. package/dist/core/registry/plugin-registry.d.ts +28 -0
  70. package/dist/core/registry/plugin-registry.d.ts.map +1 -0
  71. package/dist/core/registry/register-standard.d.ts +4 -0
  72. package/dist/core/registry/register-standard.d.ts.map +1 -0
  73. package/dist/core/runtime/dashboard-data-runtime.d.ts +26 -0
  74. package/dist/core/runtime/dashboard-data-runtime.d.ts.map +1 -0
  75. package/dist/core/runtime/dashboard-runtime.d.ts +458 -0
  76. package/dist/core/runtime/dashboard-runtime.d.ts.map +1 -0
  77. package/dist/core/runtime/dependency-graph.d.ts +11 -0
  78. package/dist/core/runtime/dependency-graph.d.ts.map +1 -0
  79. package/dist/core/runtime/index.d.ts +5 -0
  80. package/dist/core/runtime/index.d.ts.map +1 -0
  81. package/dist/core/runtime/types.d.ts +47 -0
  82. package/dist/core/runtime/types.d.ts.map +1 -0
  83. package/dist/core/telemetry/index.d.ts +2 -0
  84. package/dist/core/telemetry/index.d.ts.map +1 -0
  85. package/dist/core/telemetry/telemetry.d.ts +15 -0
  86. package/dist/core/telemetry/telemetry.d.ts.map +1 -0
  87. package/dist/core/variable/dashboard-context.d.ts +22 -0
  88. package/dist/core/variable/dashboard-context.d.ts.map +1 -0
  89. package/dist/core/variable/index.d.ts +3 -0
  90. package/dist/core/variable/index.d.ts.map +1 -0
  91. package/dist/core/variable/url-state.d.ts +17 -0
  92. package/dist/core/variable/url-state.d.ts.map +1 -0
  93. package/dist/csv-Dyrr2yMA.js +254 -0
  94. package/dist/csv-Dyrr2yMA.js.map +1 -0
  95. package/dist/dashboard-runtime-8a-9P8Ku.js +1540 -0
  96. package/dist/dashboard-runtime-8a-9P8Ku.js.map +1 -0
  97. package/dist/experimental/s2/PivotTableS2Renderer.vue.d.ts +18 -0
  98. package/dist/experimental/s2/PivotTableS2Renderer.vue.d.ts.map +1 -0
  99. package/dist/experimental/s2/index.d.ts +13 -0
  100. package/dist/experimental/s2/index.d.ts.map +1 -0
  101. package/dist/experimental/s2/index.js +66 -0
  102. package/dist/experimental/s2/index.js.map +1 -0
  103. package/dist/experimental/s2/pivot-table-s2.d.ts +23 -0
  104. package/dist/experimental/s2/pivot-table-s2.d.ts.map +1 -0
  105. package/dist/index.css +1 -0
  106. package/dist/index.d.ts +2 -0
  107. package/dist/index.d.ts.map +1 -0
  108. package/dist/index.js +111 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/renderers/word-cloud/WordCloudRenderer.vue.d.ts +20 -0
  111. package/dist/renderers/word-cloud/WordCloudRenderer.vue.d.ts.map +1 -0
  112. package/dist/renderers/word-cloud/index.d.ts +8 -0
  113. package/dist/renderers/word-cloud/index.d.ts.map +1 -0
  114. package/dist/renderers/word-cloud/index.js +17 -0
  115. package/dist/renderers/word-cloud/index.js.map +1 -0
  116. package/dist/runtime-schema-BO2qLlvE.js +580 -0
  117. package/dist/runtime-schema-BO2qLlvE.js.map +1 -0
  118. package/dist/serializable-DOOpLZyk.js +36 -0
  119. package/dist/serializable-DOOpLZyk.js.map +1 -0
  120. package/dist/standard-definitions-DHtaLAf1.js +351 -0
  121. package/dist/standard-definitions-DHtaLAf1.js.map +1 -0
  122. package/dist/value-formatter-D5QmLSMG.js +47 -0
  123. package/dist/value-formatter-D5QmLSMG.js.map +1 -0
  124. package/dist/visual-theme-DH-k3L51.js +23 -0
  125. package/dist/visual-theme-DH-k3L51.js.map +1 -0
  126. package/dist/vue/components/DashboardFilterBar.vue.d.ts +23 -0
  127. package/dist/vue/components/DashboardFilterBar.vue.d.ts.map +1 -0
  128. package/dist/vue/components/DashboardPanel.vue.d.ts +39 -0
  129. package/dist/vue/components/DashboardPanel.vue.d.ts.map +1 -0
  130. package/dist/vue/components/DashboardRenderer.vue.d.ts +57 -0
  131. package/dist/vue/components/DashboardRenderer.vue.d.ts.map +1 -0
  132. package/dist/vue/components/index.d.ts +4 -0
  133. package/dist/vue/components/index.d.ts.map +1 -0
  134. package/dist/vue/composables/index.d.ts +2 -0
  135. package/dist/vue/composables/index.d.ts.map +1 -0
  136. package/dist/vue/composables/use-dashboard-runtime.d.ts +17 -0
  137. package/dist/vue/composables/use-dashboard-runtime.d.ts.map +1 -0
  138. package/dist/vue/export/browser-download.d.ts +3 -0
  139. package/dist/vue/export/browser-download.d.ts.map +1 -0
  140. package/dist/vue/export/index.d.ts +2 -0
  141. package/dist/vue/export/index.d.ts.map +1 -0
  142. package/dist/vue/index.d.ts +7 -0
  143. package/dist/vue/index.d.ts.map +1 -0
  144. package/dist/vue/index.js +1075 -0
  145. package/dist/vue/index.js.map +1 -0
  146. package/dist/vue/registry/index.d.ts +3 -0
  147. package/dist/vue/registry/index.d.ts.map +1 -0
  148. package/dist/vue/registry/register-standard.d.ts +3 -0
  149. package/dist/vue/registry/register-standard.d.ts.map +1 -0
  150. package/dist/vue/registry/renderer-registry.d.ts +12 -0
  151. package/dist/vue/registry/renderer-registry.d.ts.map +1 -0
  152. package/dist/vue/renderers/BarRenderer.vue.d.ts +24 -0
  153. package/dist/vue/renderers/BarRenderer.vue.d.ts.map +1 -0
  154. package/dist/vue/renderers/LineRenderer.vue.d.ts +24 -0
  155. package/dist/vue/renderers/LineRenderer.vue.d.ts.map +1 -0
  156. package/dist/vue/renderers/MetricRenderer.vue.d.ts +17 -0
  157. package/dist/vue/renderers/MetricRenderer.vue.d.ts.map +1 -0
  158. package/dist/vue/renderers/PieRenderer.vue.d.ts +24 -0
  159. package/dist/vue/renderers/PieRenderer.vue.d.ts.map +1 -0
  160. package/dist/vue/renderers/TableRenderer.vue.d.ts +21 -0
  161. package/dist/vue/renderers/TableRenderer.vue.d.ts.map +1 -0
  162. package/dist/vue/renderers/chart-format.d.ts +8 -0
  163. package/dist/vue/renderers/chart-format.d.ts.map +1 -0
  164. package/dist/vue/renderers/index.d.ts +7 -0
  165. package/dist/vue/renderers/index.d.ts.map +1 -0
  166. package/dist/vue/theme/index.d.ts +2 -0
  167. package/dist/vue/theme/index.d.ts.map +1 -0
  168. package/dist/vue/theme/visual-theme.d.ts +46 -0
  169. package/dist/vue/theme/visual-theme.d.ts.map +1 -0
  170. package/package.json +129 -4
@@ -0,0 +1,1540 @@
1
+ var Ce = Object.defineProperty;
2
+ var Ee = (s) => {
3
+ throw TypeError(s);
4
+ };
5
+ var Ve = (s, e, t) => e in s ? Ce(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
6
+ var E = (s, e, t) => Ve(s, typeof e != "symbol" ? e + "" : e, t), Ie = (s, e, t) => e.has(s) || Ee("Cannot " + t);
7
+ var n = (s, e, t) => (Ie(s, e, "read from private field"), t ? t.call(s) : e.get(s)), w = (s, e, t) => e.has(s) ? Ee("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(s) : e.set(s, t), D = (s, e, t, r) => (Ie(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t);
8
+ var W = (s, e, t, r) => ({
9
+ set _(i) {
10
+ D(s, e, i, t);
11
+ },
12
+ get _() {
13
+ return n(s, e, r);
14
+ }
15
+ });
16
+ import { e as V, r as ke, P as J, c as Me, d as Te, w as Ne } from "./csv-Dyrr2yMA.js";
17
+ import { i as he, s as le, c as $e } from "./serializable-DOOpLZyk.js";
18
+ import { S as Be, a as xe } from "./standard-definitions-DHtaLAf1.js";
19
+ import { H as Le, J as Ue, c as Ke, v as We } from "./runtime-schema-BO2qLlvE.js";
20
+ const Ae = Le(Ke, [Ue]);
21
+ function Rt(s) {
22
+ if (!he(s))
23
+ throw new We([
24
+ {
25
+ path: "/",
26
+ keyword: "jsonSerializable",
27
+ message: "must contain only finite JSON values and must not contain cycles or class instances",
28
+ params: {}
29
+ }
30
+ ]);
31
+ return Ae.assert(s);
32
+ }
33
+ class Je extends Error {
34
+ constructor(t) {
35
+ super(t.map((r) => `${r.path}: ${r.message}`).join(`
36
+ `));
37
+ E(this, "diagnostics");
38
+ this.name = "DashboardConfigValidationError", this.diagnostics = t;
39
+ }
40
+ }
41
+ function X(s) {
42
+ const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
43
+ return s.forEach((r) => e.has(r) ? t.add(r) : e.add(r)), Array.from(t);
44
+ }
45
+ function Ge(s) {
46
+ switch (s.type) {
47
+ case "metric":
48
+ return [s.valueField, s.compareField].filter((e) => !!e);
49
+ case "line":
50
+ return [s.xField, ...s.yFields, s.seriesField].filter(
51
+ (e) => !!e
52
+ );
53
+ case "bar":
54
+ return [s.categoryField, ...s.valueFields, s.seriesField].filter(
55
+ (e) => !!e
56
+ );
57
+ case "pie":
58
+ return [s.nameField, s.valueField];
59
+ case "table":
60
+ return s.columns;
61
+ case "wordCloud":
62
+ return [...s.labelFields, s.valueField, s.semanticField].filter(
63
+ (e) => !!e
64
+ );
65
+ case "pivotTableS2":
66
+ return [...s.rowFields, ...s.columnFields, ...s.valueFields];
67
+ }
68
+ }
69
+ function Ye(s, e, t, r, i, a) {
70
+ !t || a(t) || s.push({
71
+ level: "error",
72
+ code: "panel_field_semantics_invalid",
73
+ message: `Field ${r} must be ${i}; received ${t.role}/${t.dataType}.`,
74
+ path: `/panels/${e}/binding`
75
+ });
76
+ }
77
+ function He(s, e, t, r) {
78
+ var u, p;
79
+ const i = (f) => f.role === "metric" && f.dataType === "number", a = (f) => f.role === "dimension" || f.role === "time", d = (f) => f.role === "dimension", c = (f, m, b) => Ye(s, t, r.get(f), f, m, b);
80
+ switch (e.binding.type) {
81
+ case "metric":
82
+ c(e.binding.valueField, "a numeric metric", i), e.binding.compareField && c(e.binding.compareField, "a numeric metric", i);
83
+ break;
84
+ case "line":
85
+ c(e.binding.xField, "a dimension or time field", a), e.binding.yFields.forEach((m) => c(m, "a numeric metric", i)), e.binding.seriesField && (c(e.binding.seriesField, "a dimension field", d), e.binding.yFields.length !== 1 && s.push({
86
+ level: "error",
87
+ code: "panel_series_value_arity_invalid",
88
+ message: "Line binding with seriesField must contain exactly one yField.",
89
+ path: `/panels/${t}/binding/yFields`
90
+ })), new Set(
91
+ e.binding.yFields.flatMap((m) => {
92
+ var h, y, l;
93
+ const b = r.get(m);
94
+ if (!b) return [];
95
+ const o = ((l = (y = (h = e.enhancement) == null ? void 0 : h.common) == null ? void 0 : y.formatOverrides) == null ? void 0 : l[m]) ?? b.format ?? { type: "number" };
96
+ return [le({ format: o, unit: b.unit ?? null })];
97
+ })
98
+ ).size > 2 && s.push({
99
+ level: "error",
100
+ code: "panel_line_axis_count_invalid",
101
+ message: "Line binding supports at most two distinct format and unit axis groups.",
102
+ path: `/panels/${t}/binding/yFields`
103
+ });
104
+ break;
105
+ case "bar":
106
+ c(e.binding.categoryField, "a dimension or time field", a), e.binding.valueFields.forEach((m) => c(m, "a numeric metric", i)), e.binding.seriesField && (c(e.binding.seriesField, "a dimension field", d), e.binding.valueFields.length !== 1 && s.push({
107
+ level: "error",
108
+ code: "panel_series_value_arity_invalid",
109
+ message: "Bar binding with seriesField must contain exactly one valueField.",
110
+ path: `/panels/${t}/binding/valueFields`
111
+ }));
112
+ break;
113
+ case "pie":
114
+ c(e.binding.nameField, "a dimension or time field", a), c(e.binding.valueField, "a numeric metric", i);
115
+ break;
116
+ case "wordCloud":
117
+ e.binding.labelFields.forEach((m) => c(m, "a dimension field", d)), c(e.binding.valueField, "a numeric metric", i), e.binding.semanticField && c(e.binding.semanticField, "a dimension field", d);
118
+ break;
119
+ case "pivotTableS2": {
120
+ e.binding.rowFields.forEach((o) => c(o, "a dimension or time field", a)), e.binding.columnFields.forEach((o) => c(o, "a dimension or time field", a)), e.binding.valueFields.forEach((o) => c(o, "a numeric metric", i));
121
+ const m = new Set(e.binding.rowFields), b = e.binding.columnFields.find((o) => m.has(o));
122
+ b && s.push({
123
+ level: "error",
124
+ code: "panel_pivot_dimension_duplicate",
125
+ message: `Pivot table field ${b} cannot be used as both a row and column dimension.`,
126
+ path: `/panels/${t}/binding`
127
+ });
128
+ break;
129
+ }
130
+ case "table": {
131
+ const m = ((u = e.enhancement) == null ? void 0 : u.type) === "table" ? (p = e.enhancement.table) == null ? void 0 : p.columnDisplays : void 0;
132
+ Object.entries(m ?? {}).forEach(([b, o]) => {
133
+ (o.type === "progress" || o.type === "trend") && c(b, `a numeric field for ${o.type} display`, (h) => h.dataType === "number");
134
+ });
135
+ break;
136
+ }
137
+ }
138
+ }
139
+ function Qe(s, e, t, r) {
140
+ const i = e.bindingSchema.validate(t.binding);
141
+ if (i.success || i.issues.forEach(
142
+ (a) => s.push({
143
+ level: "error",
144
+ code: "panel_binding_schema_invalid",
145
+ message: a.message,
146
+ path: `/panels/${r}/binding${a.path === "/" ? "" : a.path}`
147
+ })
148
+ ), t.enhancement) {
149
+ const a = e.enhancementSchema.validate(t.enhancement);
150
+ a.success || a.issues.forEach(
151
+ (d) => s.push({
152
+ level: "error",
153
+ code: "panel_enhancement_schema_invalid",
154
+ message: d.message,
155
+ path: `/panels/${r}/enhancement${d.path === "/" ? "" : d.path}`
156
+ })
157
+ );
158
+ }
159
+ }
160
+ function Ze(s, e, t = {}) {
161
+ var m, b;
162
+ if (!he(s))
163
+ return {
164
+ valid: !1,
165
+ diagnostics: [
166
+ {
167
+ level: "error",
168
+ code: "config_not_serializable",
169
+ message: "DashboardConfig must contain only finite JSON values and must not contain cycles or class instances.",
170
+ path: "/"
171
+ }
172
+ ]
173
+ };
174
+ const r = Ae.validate(s);
175
+ if (!r.success)
176
+ return {
177
+ valid: !1,
178
+ diagnostics: r.issues.map((o) => ({
179
+ level: "error",
180
+ code: "config_schema_invalid",
181
+ message: o.message,
182
+ path: o.path
183
+ }))
184
+ };
185
+ const i = r.value, a = [], d = i.variables ?? [], c = new Set(d.map((o) => o.id)), u = new Set(i.requests.map((o) => o.id)), p = new Map(i.datasets.map((o) => [o.id, o]));
186
+ return [
187
+ ["variable_id_duplicate", "/variables", d.map((o) => o.id)],
188
+ ["filter_control_id_duplicate", "/filterBar/controls", (((m = i.filterBar) == null ? void 0 : m.controls) ?? []).map((o) => o.id)],
189
+ ["request_id_duplicate", "/requests", i.requests.map((o) => o.id)],
190
+ ["dataset_id_duplicate", "/datasets", i.datasets.map((o) => o.id)],
191
+ ["panel_id_duplicate", "/panels", i.panels.map((o) => o.id)]
192
+ ].forEach(
193
+ ([o, h, y]) => X(y).forEach(
194
+ (l) => a.push({ level: "error", code: o, message: `Duplicate ID: ${l}`, path: h })
195
+ )
196
+ ), X(d.flatMap((o) => o.urlKey ? [o.urlKey] : [])).forEach(
197
+ (o) => a.push({
198
+ level: "error",
199
+ code: "variable_url_key_duplicate",
200
+ message: `Duplicate variable URL key: ${o}`,
201
+ path: "/variables"
202
+ })
203
+ ), (((b = i.filterBar) == null ? void 0 : b.controls) ?? []).forEach((o, h) => {
204
+ if ((o.type === "date-range" ? [o.startVariableId, o.endVariableId] : [o.variableId]).forEach((l) => {
205
+ c.has(l) || a.push({
206
+ level: "error",
207
+ code: "filter_variable_not_found",
208
+ message: `Filter control ${o.id} references missing variable: ${l}`,
209
+ path: `/filterBar/controls/${h}`
210
+ });
211
+ }), o.type === "date-range")
212
+ X((o.presets ?? []).map((l) => l.id)).forEach(
213
+ (l) => a.push({
214
+ level: "error",
215
+ code: "filter_preset_id_duplicate",
216
+ message: `Duplicate preset ID in filter ${o.id}: ${l}`,
217
+ path: `/filterBar/controls/${h}/presets`
218
+ })
219
+ );
220
+ else {
221
+ const l = o.options.map((g) => le(g.value));
222
+ X(l).forEach(
223
+ (g) => a.push({
224
+ level: "error",
225
+ code: "filter_option_value_duplicate",
226
+ message: `Duplicate option value in filter ${o.id}: ${g}`,
227
+ path: `/filterBar/controls/${h}/options`
228
+ })
229
+ );
230
+ }
231
+ }), i.requests.forEach((o, h) => {
232
+ const y = e.providers.get(o.providerId);
233
+ y ? y.operations[o.operationId] || a.push({
234
+ level: "error",
235
+ code: "request_operation_not_found",
236
+ message: `Provider operation is not registered: ${o.providerId}/${o.operationId}`,
237
+ path: `/requests/${h}/operationId`
238
+ }) : a.push({
239
+ level: "error",
240
+ code: "request_provider_not_found",
241
+ message: `Provider is not registered: ${o.providerId}`,
242
+ path: `/requests/${h}/providerId`
243
+ }), Object.entries(o.input ?? {}).forEach(([l, g]) => {
244
+ g.source === "variable" && (c.has(g.variableId) || a.push({
245
+ level: "error",
246
+ code: "request_variable_not_found",
247
+ message: `Request input references missing variable: ${g.variableId}`,
248
+ path: `/requests/${h}/input/${l}/variableId`
249
+ }), g.codecId && !e.requestValueCodecs.has(g.codecId) && a.push({
250
+ level: "error",
251
+ code: "request_codec_not_found",
252
+ message: `Request value codec is not registered: ${g.codecId}`,
253
+ path: `/requests/${h}/input/${l}/codecId`
254
+ }));
255
+ });
256
+ }), i.datasets.forEach((o, h) => {
257
+ X(o.fields.map((l) => l.key)).forEach(
258
+ (l) => a.push({
259
+ level: "error",
260
+ code: "dataset_field_key_duplicate",
261
+ message: `Duplicate field key in dataset ${o.id}: ${l}`,
262
+ path: `/datasets/${h}/fields`
263
+ })
264
+ ), (o.input.type === "single" ? [["default", o.input]] : Object.entries(o.input.inputs)).forEach(([l, g]) => {
265
+ u.has(g.requestId) || a.push({
266
+ level: "error",
267
+ code: "dataset_request_not_found",
268
+ message: `Dataset input references missing request: ${g.requestId}`,
269
+ path: `/datasets/${h}/input/${l}`
270
+ });
271
+ }), o.input.type === "multiple" && !o.transformerId && a.push({
272
+ level: "error",
273
+ code: "dataset_transformer_required",
274
+ message: `Dataset ${o.id} has multiple inputs and requires a transformer.`,
275
+ path: `/datasets/${h}/transformerId`
276
+ }), o.transformerId && !e.transformers.has(o.transformerId) && a.push({
277
+ level: "error",
278
+ code: "dataset_transformer_not_found",
279
+ message: `Dataset transformer is not registered: ${o.transformerId}`,
280
+ path: `/datasets/${h}/transformerId`
281
+ }), o.fields.forEach((l, g) => {
282
+ const _ = l.coerce === "number-string" ? "number" : l.coerce === "boolean-string" ? "boolean" : l.coerce === "iso-date" ? "date-or-datetime" : void 0;
283
+ _ && (_ === "date-or-datetime" ? l.dataType !== "date" && l.dataType !== "datetime" : l.dataType !== _) && a.push({
284
+ level: "error",
285
+ code: "dataset_coercion_type_mismatch",
286
+ message: `Coercion ${l.coerce} is not compatible with data type ${l.dataType}.`,
287
+ path: `/datasets/${h}/fields/${g}/coerce`
288
+ });
289
+ });
290
+ }), i.panels.forEach((o, h) => {
291
+ var g, _, Z, B, I, M, pe, ge, be, ye, we, _e, ve, De;
292
+ const y = p.get(o.binding.datasetId);
293
+ if (!y)
294
+ a.push({
295
+ level: "error",
296
+ code: "panel_dataset_not_found",
297
+ message: `Panel references missing dataset: ${o.binding.datasetId}`,
298
+ path: `/panels/${h}/binding/datasetId`
299
+ });
300
+ else {
301
+ const v = new Map(y.fields.map((A) => [A.key, A])), T = new Set(v.keys());
302
+ if (Ge(o.binding).forEach((A) => {
303
+ T.has(A) || a.push({
304
+ level: "error",
305
+ code: "panel_field_not_found",
306
+ message: `Panel binding references missing field ${A} in dataset ${y.id}.`,
307
+ path: `/panels/${h}/binding`
308
+ });
309
+ }), Object.keys(((_ = (g = o.enhancement) == null ? void 0 : g.common) == null ? void 0 : _.formatOverrides) ?? {}).forEach((A) => {
310
+ T.has(A) || a.push({
311
+ level: "error",
312
+ code: "panel_format_field_not_found",
313
+ message: `Panel format override references missing field ${A} in dataset ${y.id}.`,
314
+ path: `/panels/${h}/enhancement/common/formatOverrides/${A}`
315
+ });
316
+ }), He(a, o, h, v), ((Z = o.enhancement) == null ? void 0 : Z.type) === "table" && (/* @__PURE__ */ new Set([
317
+ ...((B = o.enhancement.table) == null ? void 0 : B.sortableFields) ?? [],
318
+ ...((I = o.enhancement.table) == null ? void 0 : I.filterableFields) ?? [],
319
+ ...Object.keys(((M = o.enhancement.table) == null ? void 0 : M.columnWidths) ?? {}),
320
+ ...Object.keys(((pe = o.enhancement.table) == null ? void 0 : pe.columnDisplays) ?? {})
321
+ ])).forEach((se) => {
322
+ (!o.binding.type || o.binding.type !== "table" || !o.binding.columns.includes(se)) && a.push({
323
+ level: "error",
324
+ code: "panel_table_enhancement_field_invalid",
325
+ message: `Table enhancement field ${se} must be included in the table columns.`,
326
+ path: `/panels/${h}/enhancement/table`
327
+ });
328
+ }), ((ge = o.enhancement) == null ? void 0 : ge.type) === "wordCloud") {
329
+ const A = (be = o.enhancement.wordCloud) == null ? void 0 : be.minFontSize, se = (ye = o.enhancement.wordCloud) == null ? void 0 : ye.maxFontSize;
330
+ A !== void 0 && se !== void 0 && A > se && a.push({
331
+ level: "error",
332
+ code: "panel_word_cloud_font_range_invalid",
333
+ message: "Word cloud minFontSize cannot be greater than maxFontSize.",
334
+ path: `/panels/${h}/enhancement/wordCloud`
335
+ });
336
+ }
337
+ }
338
+ o.enhancement && o.enhancement.type !== o.binding.type && a.push({
339
+ level: "error",
340
+ code: "panel_enhancement_type_mismatch",
341
+ message: `Panel enhancement type ${o.enhancement.type} does not match binding type ${o.binding.type}.`,
342
+ path: `/panels/${h}/enhancement/type`
343
+ });
344
+ const l = e.rendererDefinitions.get(o.rendererId);
345
+ if (!l)
346
+ a.push({
347
+ level: "error",
348
+ code: "panel_renderer_not_found",
349
+ message: `Renderer definition is not registered: ${o.rendererId}`,
350
+ path: `/panels/${h}/rendererId`
351
+ });
352
+ else {
353
+ Qe(a, l, o, h);
354
+ const v = o.adapterId ?? l.defaultAdapterId;
355
+ e.adapters.has(v) || a.push({
356
+ level: "error",
357
+ code: "panel_adapter_not_found",
358
+ message: `Visualization adapter is not registered: ${v}`,
359
+ path: `/panels/${h}/adapterId`
360
+ });
361
+ }
362
+ (((_e = (we = o.enhancement) == null ? void 0 : we.common) == null ? void 0 : _e.presetIds) ?? []).forEach((v) => {
363
+ const T = e.presets.get(v);
364
+ T ? T.rendererId && T.rendererId !== o.rendererId && a.push({
365
+ level: "error",
366
+ code: "panel_preset_renderer_mismatch",
367
+ message: `Preset ${v} belongs to renderer ${T.rendererId}, not ${o.rendererId}.`,
368
+ path: `/panels/${h}/enhancement/common/presetIds`
369
+ }) : a.push({
370
+ level: "error",
371
+ code: "panel_preset_not_found",
372
+ message: `Visualization preset is not registered: ${v}`,
373
+ path: `/panels/${h}/enhancement/common/presetIds`
374
+ });
375
+ }), (((De = (ve = o.enhancement) == null ? void 0 : ve.common) == null ? void 0 : De.interactions) ?? []).forEach((v) => {
376
+ e.actions.has(v.actionId) || a.push({
377
+ level: "error",
378
+ code: "panel_action_not_found",
379
+ message: `Visualization action is not registered: ${v.actionId}`,
380
+ path: `/panels/${h}/enhancement/common/interactions`
381
+ });
382
+ }), X((o.actions ?? []).map((v) => v.id)).forEach(
383
+ (v) => a.push({
384
+ level: "error",
385
+ code: "panel_action_id_duplicate",
386
+ message: `Duplicate panel action ID: ${v}`,
387
+ path: `/panels/${h}/actions`
388
+ })
389
+ ), (o.actions ?? []).forEach((v, T) => {
390
+ e.actions.has(v.actionId) || a.push({
391
+ level: "error",
392
+ code: "panel_action_not_found",
393
+ message: `Visualization action is not registered: ${v.actionId}`,
394
+ path: `/panels/${h}/actions/${T}/actionId`
395
+ });
396
+ });
397
+ }), V(t.telemetry, {
398
+ name: "config_validated",
399
+ dashboardId: i.id,
400
+ ...a.length ? { errorCode: "config_reference_invalid" } : {}
401
+ }), a.length ? { valid: !1, diagnostics: Object.freeze(a) } : { valid: !0, config: i, diagnostics: [] };
402
+ }
403
+ function Xe(s, e, t = {}) {
404
+ const r = Ze(s, e, t);
405
+ if (!r.valid)
406
+ throw new Je(r.diagnostics);
407
+ return r.config;
408
+ }
409
+ const et = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
410
+ function me(s, e) {
411
+ return e ? e.split(".").reduce((t, r) => {
412
+ if (!(!r || et.has(r) || t === null || typeof t != "object"))
413
+ return t[r];
414
+ }, s) : s;
415
+ }
416
+ class ue extends Error {
417
+ constructor(t, r, i, a) {
418
+ super(a);
419
+ E(this, "code");
420
+ E(this, "requestId");
421
+ E(this, "inputName");
422
+ this.name = "RequestInputError", this.code = t, this.requestId = r, this.inputName = i;
423
+ }
424
+ }
425
+ function tt(s) {
426
+ return s === null || s === "" || Array.isArray(s) && s.length === 0;
427
+ }
428
+ function st(s, e, t, r) {
429
+ const i = {};
430
+ for (const [a, d] of Object.entries(s.input ?? {})) {
431
+ if (d.source === "constant") {
432
+ i[a] = $e(d.value);
433
+ continue;
434
+ }
435
+ let c = ke(e, t, d.variableId);
436
+ if (c = me(c, d.select), c === void 0) {
437
+ if (d.omitWhenEmpty) continue;
438
+ throw new ue(
439
+ "request_input_missing",
440
+ s.id,
441
+ a,
442
+ `DataRequest ${s.id} input ${a} resolved to undefined.`
443
+ );
444
+ }
445
+ if (!he(c))
446
+ throw new ue(
447
+ "request_input_not_serializable",
448
+ s.id,
449
+ a,
450
+ `DataRequest ${s.id} input ${a} is not JSON serializable.`
451
+ );
452
+ if (d.omitWhenEmpty && tt(c))
453
+ continue;
454
+ const u = d.codecId ? r.require(d.codecId).encode(c, t) : c;
455
+ if (u === void 0) {
456
+ if (d.omitWhenEmpty) continue;
457
+ throw new ue(
458
+ "request_input_missing",
459
+ s.id,
460
+ a,
461
+ `DataRequest ${s.id} input ${a} was omitted by codec ${d.codecId}.`
462
+ );
463
+ }
464
+ i[a] = $e(u);
465
+ }
466
+ return Object.freeze(i);
467
+ }
468
+ class rt extends Error {
469
+ constructor(t, r, i) {
470
+ super(`Provider input validation failed: ${t}/${r}`);
471
+ E(this, "code", "provider_input_invalid");
472
+ E(this, "providerId");
473
+ E(this, "operationId");
474
+ E(this, "issues");
475
+ this.name = "ProviderInputValidationError", this.providerId = t, this.operationId = r, this.issues = i;
476
+ }
477
+ }
478
+ function Re() {
479
+ return new DOMException("The request was aborted.", "AbortError");
480
+ }
481
+ function it(s, e) {
482
+ return e.aborted || s instanceof DOMException && s.name === "AbortError";
483
+ }
484
+ function at(s, e) {
485
+ return `${s.providerId}:${s.operationId}:${le(e)}`;
486
+ }
487
+ var G, C, Y, x, de, ce;
488
+ class nt {
489
+ constructor(e, t, r, i = {}) {
490
+ w(this, G, /* @__PURE__ */ new Map());
491
+ w(this, C, /* @__PURE__ */ new Map());
492
+ w(this, Y, /* @__PURE__ */ new Set());
493
+ w(this, x, /* @__PURE__ */ new Map());
494
+ w(this, de, 0);
495
+ w(this, ce, 0);
496
+ this.config = e, this.providers = t, this.codecs = r, this.options = i;
497
+ }
498
+ async execute(e, t, r = {}) {
499
+ var B;
500
+ const i = this.config.requests.find((I) => I.id === e);
501
+ if (!i)
502
+ throw new Error(`DataRequest not found: ${e}`);
503
+ const a = r.signal;
504
+ if (a != null && a.aborted) throw Re();
505
+ const d = st(i, this.config, t, this.codecs), c = at(i, d), u = r.isolated ?? !1;
506
+ u || this.trackCacheKey(i.id, c);
507
+ const p = `${i.id}:${++W(this, ce)._}`, f = u ? void 0 : n(this, G).get(c);
508
+ if (!r.force && f)
509
+ return V(this.options.telemetry, {
510
+ name: "request_cache_hit",
511
+ dashboardId: t.dashboardId,
512
+ requestId: p,
513
+ providerId: i.providerId,
514
+ operationId: i.operationId
515
+ }), { ...f, requestConfigId: e, executionId: p, cacheKey: c, input: d, fromCache: !0 };
516
+ let m = u ? void 0 : n(this, C).get(c);
517
+ if (r.force && m && (m.controller.abort(), n(this, C).delete(c), m = void 0), m) {
518
+ const I = () => m.controller.abort();
519
+ a == null || a.addEventListener("abort", I, { once: !0 }), V(this.options.telemetry, {
520
+ name: "request_cache_hit",
521
+ dashboardId: t.dashboardId,
522
+ requestId: p,
523
+ providerId: i.providerId,
524
+ operationId: i.operationId
525
+ });
526
+ try {
527
+ return { ...await m.promise, requestConfigId: e, executionId: p, cacheKey: c, input: d, fromCache: !0 };
528
+ } finally {
529
+ a == null || a.removeEventListener("abort", I);
530
+ }
531
+ }
532
+ const o = this.providers.require(i.providerId).operations[i.operationId];
533
+ if (!o)
534
+ throw new Error(`Provider operation not found: ${i.providerId}/${i.operationId}`);
535
+ const h = (B = o.inputSchema) == null ? void 0 : B.validate(d);
536
+ if (h && !h.success)
537
+ throw new rt(i.providerId, i.operationId, h.issues);
538
+ const y = Date.now(), l = new AbortController();
539
+ u && n(this, Y).add(l);
540
+ const g = () => l.abort();
541
+ a == null || a.addEventListener("abort", g, { once: !0 }), V(this.options.telemetry, {
542
+ name: "request_started",
543
+ dashboardId: t.dashboardId,
544
+ requestId: p,
545
+ providerId: i.providerId,
546
+ operationId: i.operationId
547
+ });
548
+ const _ = Promise.resolve().then(
549
+ () => o.execute(d, {
550
+ signal: l.signal,
551
+ requestId: p,
552
+ timezone: t.timezone,
553
+ locale: t.locale,
554
+ emit: (I) => V(this.options.telemetry, I)
555
+ })
556
+ ).then((I) => {
557
+ if (l.signal.aborted) throw Re();
558
+ const M = {
559
+ response: I,
560
+ version: ++W(this, de)._,
561
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
562
+ };
563
+ return u || n(this, G).set(c, M), V(this.options.telemetry, {
564
+ name: "request_succeeded",
565
+ dashboardId: t.dashboardId,
566
+ requestId: p,
567
+ providerId: i.providerId,
568
+ operationId: i.operationId,
569
+ durationMs: Date.now() - y
570
+ }), M;
571
+ }).catch((I) => {
572
+ const M = it(I, l.signal);
573
+ throw V(this.options.telemetry, {
574
+ name: M ? "request_cancelled" : "request_failed",
575
+ dashboardId: t.dashboardId,
576
+ requestId: p,
577
+ providerId: i.providerId,
578
+ operationId: i.operationId,
579
+ durationMs: Date.now() - y,
580
+ errorCode: M ? "request_cancelled" : "request_failed"
581
+ }), I;
582
+ }).finally(() => {
583
+ var I;
584
+ a == null || a.removeEventListener("abort", g), u ? n(this, Y).delete(l) : ((I = n(this, C).get(c)) == null ? void 0 : I.promise) === _ && n(this, C).delete(c);
585
+ });
586
+ return u || n(this, C).set(c, { controller: l, promise: _ }), { ...await _, requestConfigId: e, executionId: p, cacheKey: c, input: d, fromCache: !1 };
587
+ }
588
+ invalidateRequest(e) {
589
+ var t;
590
+ for (const r of n(this, x).get(e) ?? [])
591
+ n(this, G).delete(r), (t = n(this, C).get(r)) == null || t.controller.abort(), n(this, C).delete(r);
592
+ n(this, x).delete(e);
593
+ }
594
+ clear() {
595
+ n(this, C).forEach(({ controller: e }) => e.abort()), n(this, Y).forEach((e) => e.abort()), n(this, C).clear(), n(this, Y).clear(), n(this, G).clear(), n(this, x).clear();
596
+ }
597
+ trackCacheKey(e, t) {
598
+ const r = n(this, x).get(e) ?? /* @__PURE__ */ new Set();
599
+ r.add(t), n(this, x).set(e, r);
600
+ }
601
+ }
602
+ G = new WeakMap(), C = new WeakMap(), Y = new WeakMap(), x = new WeakMap(), de = new WeakMap(), ce = new WeakMap();
603
+ function ot() {
604
+ return {
605
+ providers: new J("DataProvider"),
606
+ transformers: new J("DatasetTransformer"),
607
+ adapters: new J("VisualizationAdapter"),
608
+ rendererDefinitions: new J("VisualizationRendererDefinition"),
609
+ presets: new J("VisualizationPreset"),
610
+ actions: new J("VisualizationAction"),
611
+ requestValueCodecs: lt()
612
+ };
613
+ }
614
+ function dt(s) {
615
+ return s.adapters.registerMany(Be), s.rendererDefinitions.registerMany(xe), s;
616
+ }
617
+ function qt() {
618
+ return dt(ot());
619
+ }
620
+ class k extends Error {
621
+ constructor(t, r) {
622
+ super(r);
623
+ E(this, "code", "request_value_codec_failed");
624
+ E(this, "codecId");
625
+ this.name = "RequestValueCodecError", this.codecId = t;
626
+ }
627
+ }
628
+ function qe(s, e) {
629
+ const t = typeof s == "number" ? s : typeof s == "string" && s.trim() !== "" ? Number(s) : Number.NaN;
630
+ if (!Number.isFinite(t))
631
+ throw new k(e, `Value cannot be encoded as a finite number by ${e}.`);
632
+ return t;
633
+ }
634
+ function ct(s) {
635
+ const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
636
+ if (!e) return !1;
637
+ const t = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = new Date(Date.UTC(t, r - 1, i));
638
+ return a.getUTCFullYear() === t && a.getUTCMonth() === r - 1 && a.getUTCDate() === i;
639
+ }
640
+ const ht = Object.freeze([
641
+ {
642
+ id: "string",
643
+ encode(s) {
644
+ if (typeof s == "string") return s;
645
+ if (typeof s == "number" || typeof s == "boolean") return String(s);
646
+ throw new k("string", "Value cannot be encoded as a string.");
647
+ }
648
+ },
649
+ {
650
+ id: "number",
651
+ encode(s) {
652
+ return qe(s, "number");
653
+ }
654
+ },
655
+ {
656
+ id: "boolean",
657
+ encode(s) {
658
+ if (typeof s == "boolean") return s;
659
+ if (s === "true") return !0;
660
+ if (s === "false") return !1;
661
+ throw new k("boolean", "Value cannot be encoded as a boolean.");
662
+ }
663
+ },
664
+ {
665
+ id: "string-array",
666
+ encode(s) {
667
+ if (!Array.isArray(s))
668
+ throw new k("string-array", "Value must be an array.");
669
+ return s.map((e) => {
670
+ if (typeof e == "string" || typeof e == "number" || typeof e == "boolean")
671
+ return String(e);
672
+ throw new k("string-array", "Array entries must be primitive values.");
673
+ });
674
+ }
675
+ },
676
+ {
677
+ id: "number-array",
678
+ encode(s) {
679
+ if (!Array.isArray(s))
680
+ throw new k("number-array", "Value must be an array.");
681
+ return s.map((e) => qe(e, "number-array"));
682
+ }
683
+ },
684
+ {
685
+ id: "iso-date",
686
+ encode(s) {
687
+ var r;
688
+ if (typeof s != "string")
689
+ throw new k("iso-date", "ISO date input must be a string.");
690
+ const e = (r = /^(\d{4}-\d{2}-\d{2})/.exec(s)) == null ? void 0 : r[1];
691
+ if (e) {
692
+ if (ct(e)) return e;
693
+ throw new k("iso-date", "Value contains an invalid calendar date.");
694
+ }
695
+ const t = new Date(s);
696
+ if (Number.isNaN(t.getTime()))
697
+ throw new k("iso-date", "Value cannot be encoded as an ISO date.");
698
+ return t.toISOString().slice(0, 10);
699
+ }
700
+ },
701
+ {
702
+ id: "json",
703
+ encode(s) {
704
+ if (!he(s))
705
+ throw new k("json", "Value is not JSON serializable.");
706
+ return s;
707
+ }
708
+ }
709
+ ]);
710
+ function lt() {
711
+ return new J("RequestValueCodec").registerMany(ht);
712
+ }
713
+ function ut(s) {
714
+ const e = /^(\d{4})-(\d{2})-(\d{2})$/.exec(s);
715
+ if (!e) return !1;
716
+ const t = Number(e[1]), r = Number(e[2]), i = Number(e[3]), a = new Date(Date.UTC(t, r - 1, i));
717
+ return a.getUTCFullYear() === t && a.getUTCMonth() === r - 1 && a.getUTCDate() === i;
718
+ }
719
+ function Se(s, e) {
720
+ if (typeof s != "string") return;
721
+ if (e === "date" && ut(s)) return s;
722
+ const t = new Date(s);
723
+ if (!Number.isNaN(t.getTime()))
724
+ return e === "date" ? t.toISOString().slice(0, 10) : t.toISOString();
725
+ }
726
+ function ft(s, e) {
727
+ if (!(s == null || s === "")) {
728
+ switch (e.coerce) {
729
+ case "number-string": {
730
+ if (typeof s == "number" && Number.isFinite(s)) return s;
731
+ if (typeof s != "string") return;
732
+ const t = Number(s);
733
+ return Number.isFinite(t) ? t : void 0;
734
+ }
735
+ case "boolean-string":
736
+ return typeof s == "boolean" ? s : s === "true" ? !0 : s === "false" ? !1 : void 0;
737
+ case "iso-date":
738
+ return e.dataType === "date" || e.dataType === "datetime" ? Se(s, e.dataType) : void 0;
739
+ }
740
+ switch (e.dataType) {
741
+ case "string":
742
+ return typeof s == "string" ? s : void 0;
743
+ case "number":
744
+ return typeof s == "number" && Number.isFinite(s) ? s : void 0;
745
+ case "boolean":
746
+ return typeof s == "boolean" ? s : void 0;
747
+ case "date":
748
+ case "datetime":
749
+ return Se(s, e.dataType);
750
+ }
751
+ }
752
+ }
753
+ function mt(s, e, t = []) {
754
+ const r = [...t], i = s.map((a, d) => {
755
+ const c = a !== null && typeof a == "object" && !Array.isArray(a) ? a : void 0, u = {};
756
+ for (const p of e.fields) {
757
+ const f = c ? me(c, p.sourcePath ?? p.key) : void 0, m = ft(f, p);
758
+ m === void 0 ? (r.push({
759
+ level: p.required ? "error" : "warning",
760
+ code: p.required ? "dataset_required_field_invalid" : "dataset_optional_field_invalid",
761
+ message: `Dataset ${e.id} row ${d + 1} has an invalid value for ${p.key}.`,
762
+ field: p.key,
763
+ rowIndex: d
764
+ }), u[p.key] = null) : u[p.key] = m;
765
+ }
766
+ return Object.freeze(u);
767
+ });
768
+ return {
769
+ rows: Object.freeze(i),
770
+ diagnostics: Object.freeze(r)
771
+ };
772
+ }
773
+ class N extends Error {
774
+ constructor(t, r, i, a = []) {
775
+ super(i);
776
+ E(this, "code");
777
+ E(this, "datasetId");
778
+ E(this, "diagnostics");
779
+ this.name = "DatasetExecutionError", this.datasetId = t, this.code = r, this.diagnostics = a;
780
+ }
781
+ }
782
+ function Pe(s) {
783
+ return s.input.type === "single" ? [["default", s.input]] : Object.entries(s.input.inputs);
784
+ }
785
+ function pt(s, e) {
786
+ if (s == null) return [];
787
+ if (Array.isArray(s)) return s;
788
+ if (typeof s == "object") return [s];
789
+ throw new N(
790
+ e,
791
+ "dataset_input_invalid",
792
+ `Dataset ${e} input must resolve to an object or an array of objects.`
793
+ );
794
+ }
795
+ function gt(s) {
796
+ const e = s.map((t) => Date.parse(t.execution.updatedAt)).filter(Number.isFinite);
797
+ return e.length ? new Date(Math.max(...e)).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
798
+ }
799
+ var H, L;
800
+ class bt {
801
+ constructor(e, t, r, i = {}) {
802
+ w(this, H, /* @__PURE__ */ new Map());
803
+ w(this, L, /* @__PURE__ */ new Map());
804
+ this.config = e, this.requestExecutor = t, this.transformers = r, this.options = i;
805
+ }
806
+ async run(e, t, r = {}) {
807
+ var c;
808
+ if (t.dashboardId !== this.config.id)
809
+ throw new N(
810
+ e,
811
+ "dashboard_context_mismatch",
812
+ `DashboardContext ${t.dashboardId} cannot be used with dashboard ${this.config.id}.`
813
+ );
814
+ const i = this.config.datasets.find((u) => u.id === e);
815
+ if (!i)
816
+ throw new N(e, "dataset_not_found", `Dataset not found: ${e}`);
817
+ const a = Date.now(), d = r.isolated ?? !1;
818
+ try {
819
+ const u = await Promise.all(
820
+ Pe(i).map(async ([g, _]) => {
821
+ const Z = await this.requestExecutor.execute(_.requestId, t, r), B = me(Z.response, _.responsePath);
822
+ if (_.responsePath && B === void 0)
823
+ throw new N(
824
+ i.id,
825
+ "dataset_input_path_missing",
826
+ `Dataset ${i.id} input ${g} path was not found: ${_.responsePath}`,
827
+ [
828
+ {
829
+ level: "error",
830
+ code: "dataset_input_path_missing",
831
+ message: `Response path was not found: ${_.responsePath}`,
832
+ inputName: g
833
+ }
834
+ ]
835
+ );
836
+ return {
837
+ name: g,
838
+ requestId: _.requestId,
839
+ ..._.responsePath ? { responsePath: _.responsePath } : {},
840
+ execution: Z,
841
+ value: B
842
+ };
843
+ })
844
+ ), p = Object.freeze(
845
+ Object.fromEntries(u.map((g) => [g.requestId, g.execution.version]))
846
+ ), f = le({
847
+ datasetId: i.id,
848
+ requestVersions: p,
849
+ transformerId: i.transformerId ?? null
850
+ });
851
+ d || this.trackCacheKey(i.id, f);
852
+ const m = d ? void 0 : n(this, H).get(f);
853
+ if (!r.force && m)
854
+ return V(this.options.telemetry, {
855
+ name: "dataset_cache_hit",
856
+ dashboardId: t.dashboardId,
857
+ datasetId: i.id
858
+ }), m;
859
+ const b = Object.freeze(Object.fromEntries(u.map((g) => [g.name, g.value])));
860
+ let o, h = [];
861
+ if (i.transformerId) {
862
+ const g = this.transformers.require(i.transformerId).transform(b, {
863
+ datasetId: i.id,
864
+ timezone: t.timezone,
865
+ locale: t.locale
866
+ });
867
+ if (!Array.isArray(g.rows))
868
+ throw new N(
869
+ i.id,
870
+ "dataset_transform_invalid",
871
+ `Dataset transformer ${i.transformerId} did not return a rows array.`
872
+ );
873
+ o = g.rows, h = g.diagnostics ?? [];
874
+ } else {
875
+ if (i.input.type === "multiple")
876
+ throw new N(
877
+ i.id,
878
+ "dataset_transformer_required",
879
+ `Dataset ${i.id} has multiple inputs and requires a transformer.`
880
+ );
881
+ o = pt((c = u[0]) == null ? void 0 : c.value, i.id);
882
+ }
883
+ const y = mt(o, i, h);
884
+ if (y.diagnostics.some((g) => g.level === "error"))
885
+ throw new N(
886
+ i.id,
887
+ "dataset_validation_failed",
888
+ `Dataset ${i.id} failed field validation.`,
889
+ y.diagnostics
890
+ );
891
+ const l = Object.freeze({
892
+ datasetId: i.id,
893
+ fields: Object.freeze([...i.fields]),
894
+ rows: y.rows,
895
+ updatedAt: gt(u),
896
+ requestVersions: p,
897
+ diagnostics: y.diagnostics
898
+ });
899
+ return d || n(this, H).set(f, l), V(this.options.telemetry, {
900
+ name: "dataset_succeeded",
901
+ dashboardId: t.dashboardId,
902
+ datasetId: i.id,
903
+ durationMs: Date.now() - a
904
+ }), l;
905
+ } catch (u) {
906
+ throw V(this.options.telemetry, {
907
+ name: "dataset_failed",
908
+ dashboardId: t.dashboardId,
909
+ datasetId: e,
910
+ durationMs: Date.now() - a,
911
+ errorCode: u instanceof N ? u.code : "dataset_failed"
912
+ }), u;
913
+ }
914
+ }
915
+ async refresh(e, t, r) {
916
+ const i = this.config.datasets.find((a) => a.id === e);
917
+ if (!i)
918
+ throw new N(e, "dataset_not_found", `Dataset not found: ${e}`);
919
+ this.invalidateDataset(e);
920
+ for (const [, a] of Pe(i))
921
+ this.requestExecutor.invalidateRequest(a.requestId);
922
+ return this.run(e, t, { ...r ? { signal: r } : {}, force: !0 });
923
+ }
924
+ invalidateDataset(e) {
925
+ for (const t of n(this, L).get(e) ?? [])
926
+ n(this, H).delete(t);
927
+ n(this, L).delete(e);
928
+ }
929
+ clear() {
930
+ n(this, H).clear(), n(this, L).clear(), this.requestExecutor.clear();
931
+ }
932
+ trackCacheKey(e, t) {
933
+ const r = n(this, L).get(e) ?? /* @__PURE__ */ new Set();
934
+ r.add(t), n(this, L).set(e, r);
935
+ }
936
+ }
937
+ H = new WeakMap(), L = new WeakMap();
938
+ var ae, te, ne;
939
+ class je {
940
+ constructor(e) {
941
+ E(this, "config");
942
+ E(this, "datasetRunner");
943
+ w(this, ae);
944
+ w(this, te);
945
+ w(this, ne);
946
+ try {
947
+ new Intl.DateTimeFormat(e.locale, { timeZone: e.timezone }).format(0);
948
+ } catch {
949
+ throw new TypeError(`Invalid locale or timezone: ${e.locale}/${e.timezone}`);
950
+ }
951
+ D(this, ae, e.registries), D(this, ne, e.telemetry);
952
+ const t = e.telemetry ? { telemetry: e.telemetry } : {};
953
+ this.config = Xe(e.config, e.registries, t), D(this, te, { timezone: e.timezone, locale: e.locale });
954
+ const r = new nt(
955
+ this.config,
956
+ e.registries.providers,
957
+ e.registries.requestValueCodecs,
958
+ t
959
+ );
960
+ this.datasetRunner = new bt(
961
+ this.config,
962
+ r,
963
+ e.registries.transformers,
964
+ t
965
+ );
966
+ }
967
+ createContext(e) {
968
+ return Me(this.config, {
969
+ ...n(this, te),
970
+ ...e ? { variables: e } : {}
971
+ });
972
+ }
973
+ restoreContext(e, t) {
974
+ return Te(
975
+ this.config,
976
+ e,
977
+ { ...n(this, te), ...t ? { variables: t } : {} },
978
+ n(this, ne)
979
+ );
980
+ }
981
+ runDataset(e, t, r) {
982
+ return this.datasetRunner.run(e, t, r);
983
+ }
984
+ refreshDataset(e, t, r) {
985
+ return this.datasetRunner.refresh(e, t, r);
986
+ }
987
+ clear() {
988
+ this.datasetRunner.clear();
989
+ }
990
+ get registries() {
991
+ return n(this, ae);
992
+ }
993
+ }
994
+ ae = new WeakMap(), te = new WeakMap(), ne = new WeakMap();
995
+ function St(s) {
996
+ return new je(s);
997
+ }
998
+ function yt(s) {
999
+ return s.input.type === "single" ? [s.input.requestId] : Object.values(s.input.inputs).map((e) => e.requestId);
1000
+ }
1001
+ function Fe(s, e, t) {
1002
+ const r = s.get(e) ?? /* @__PURE__ */ new Set();
1003
+ r.add(t), s.set(e, r);
1004
+ }
1005
+ function wt(s) {
1006
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1007
+ return s.datasets.forEach((a) => {
1008
+ const d = new Set(yt(a));
1009
+ e.set(a.id, d), d.forEach((c) => Fe(t, c, a.id));
1010
+ }), s.panels.forEach((a) => {
1011
+ i.set(a.id, a.binding.datasetId), Fe(r, a.binding.datasetId, a.id);
1012
+ }), Object.freeze({
1013
+ requestIdsByDatasetId: e,
1014
+ datasetIdsByRequestId: t,
1015
+ panelIdsByDatasetId: r,
1016
+ datasetIdByPanelId: i
1017
+ });
1018
+ }
1019
+ function ze(s, e) {
1020
+ const t = /* @__PURE__ */ new Set();
1021
+ return e.forEach(
1022
+ (r) => {
1023
+ var i;
1024
+ return (i = s.datasetIdsByRequestId.get(r)) == null ? void 0 : i.forEach((a) => t.add(a));
1025
+ }
1026
+ ), t;
1027
+ }
1028
+ function Oe(s, e) {
1029
+ const t = /* @__PURE__ */ new Set();
1030
+ return e.forEach(
1031
+ (r) => {
1032
+ var i;
1033
+ return (i = s.panelIdsByDatasetId.get(r)) == null ? void 0 : i.forEach((a) => t.add(a));
1034
+ }
1035
+ ), t;
1036
+ }
1037
+ function ee() {
1038
+ return (/* @__PURE__ */ new Date()).toISOString();
1039
+ }
1040
+ function re(s, e) {
1041
+ const t = s;
1042
+ return Object.freeze({
1043
+ code: typeof (t == null ? void 0 : t.code) == "string" ? t.code : e,
1044
+ message: typeof (t == null ? void 0 : t.message) == "string" ? t.message : String(s),
1045
+ cause: s
1046
+ });
1047
+ }
1048
+ function ie(s) {
1049
+ return s instanceof DOMException && s.name === "AbortError";
1050
+ }
1051
+ function fe(s) {
1052
+ return Object.freeze(Object.fromEntries(s));
1053
+ }
1054
+ var Q, z, $, R, q, S, P, j, oe, O, U, K, F;
1055
+ class _t {
1056
+ constructor(e) {
1057
+ E(this, "dataRuntime");
1058
+ E(this, "graph");
1059
+ w(this, Q, /* @__PURE__ */ new Set());
1060
+ w(this, z, /* @__PURE__ */ new Map());
1061
+ w(this, $, /* @__PURE__ */ new Map());
1062
+ w(this, R, /* @__PURE__ */ new Map());
1063
+ w(this, q, /* @__PURE__ */ new Map());
1064
+ w(this, S, /* @__PURE__ */ new Map());
1065
+ w(this, P);
1066
+ w(this, j, 0);
1067
+ w(this, oe, 0);
1068
+ w(this, O);
1069
+ w(this, U, /* @__PURE__ */ new Set());
1070
+ w(this, K, !1);
1071
+ w(this, F, !1);
1072
+ this.options = e, this.dataRuntime = new je(e), this.graph = wt(this.dataRuntime.config), D(this, P, this.dataRuntime.createContext(e.variables)), this.dataRuntime.config.requests.forEach(
1073
+ (t) => n(this, z).set(t.id, { id: t.id, status: "idle", generation: 0 })
1074
+ ), this.dataRuntime.config.datasets.forEach(
1075
+ (t) => n(this, $).set(t.id, { id: t.id, status: "idle", generation: 0 })
1076
+ ), this.dataRuntime.config.panels.forEach(
1077
+ (t) => n(this, R).set(t.id, { id: t.id, status: "idle", generation: 0, isRefreshing: !1 })
1078
+ );
1079
+ }
1080
+ get config() {
1081
+ return this.dataRuntime.config;
1082
+ }
1083
+ get context() {
1084
+ return n(this, P);
1085
+ }
1086
+ get snapshot() {
1087
+ return Object.freeze({
1088
+ generation: n(this, j),
1089
+ isGlobalLoading: !!(n(this, O) && n(this, K)),
1090
+ context: n(this, P),
1091
+ requestStates: fe(n(this, z)),
1092
+ datasetStates: fe(n(this, $)),
1093
+ panelStates: fe(n(this, R))
1094
+ });
1095
+ }
1096
+ subscribe(e) {
1097
+ return n(this, Q).add(e), () => n(this, Q).delete(e);
1098
+ }
1099
+ load() {
1100
+ return this.schedule(new Set(this.config.datasets.map((e) => e.id)), !1);
1101
+ }
1102
+ refreshAll() {
1103
+ return this.schedule(new Set(this.config.datasets.map((e) => e.id)), !0);
1104
+ }
1105
+ refreshDataset(e) {
1106
+ const t = this.graph.requestIdsByDatasetId.get(e);
1107
+ if (!t) throw new Error(`Dataset not found: ${e}`);
1108
+ return this.schedule(ze(this.graph, t), !0);
1109
+ }
1110
+ loadPanels(e) {
1111
+ return this.loadPanelDatasets(this.datasetIdsForPanels(e));
1112
+ }
1113
+ refreshPanels(e, t = {}) {
1114
+ const r = this.datasetIdsForPanels(e);
1115
+ if (!r.size && !t.deferUnselected) return Promise.resolve(this.snapshot);
1116
+ n(this, U).forEach((c) => r.add(c));
1117
+ const i = t.deferUnselected ? this.deferUnselectedDatasets(r, n(this, j) + 1) : /* @__PURE__ */ new Set();
1118
+ if (!r.size)
1119
+ return i.size && (D(this, j, n(this, j) + 1), this.notify()), Promise.resolve(this.snapshot);
1120
+ const a = this.requestIdsForDatasets(r), d = ze(this.graph, a);
1121
+ return r.forEach((c) => d.delete(c)), this.resetDatasets(d), this.schedule(r, !0);
1122
+ }
1123
+ refreshPanel(e) {
1124
+ const t = this.requirePanel(e);
1125
+ return n(this, O) || n(this, S).has(t.binding.datasetId) ? Promise.resolve(this.snapshot) : this.schedulePanel(t);
1126
+ }
1127
+ retryPanel(e) {
1128
+ return this.refreshPanel(e);
1129
+ }
1130
+ setVariables(e, t) {
1131
+ var c;
1132
+ let r = n(this, P);
1133
+ if (Object.entries(e).forEach(([u, p]) => {
1134
+ r = Ne(this.config, r, u, p);
1135
+ }), D(this, P, r), t === void 0) return this.refreshAll();
1136
+ const i = this.datasetIdsForPanels(t);
1137
+ this.cancelPanelRefreshes(new Set(n(this, q).keys())), this.cancelPanelLoads(new Set(n(this, S).keys())), (c = n(this, O)) == null || c.abort(), D(this, O, void 0), n(this, U).clear(), D(this, K, !1);
1138
+ const a = ++W(this, j)._;
1139
+ n(this, z).forEach((u, p) => {
1140
+ n(this, z).set(p, Object.freeze({ id: u.id, status: "idle", generation: a }));
1141
+ });
1142
+ const d = new Set(this.config.datasets.map((u) => u.id));
1143
+ return i.forEach((u) => d.delete(u)), this.resetDatasets(d, a), i.size ? this.schedule(i, !0) : (this.notify(), Promise.resolve(this.snapshot));
1144
+ }
1145
+ restoreContext(e, t) {
1146
+ return this.cancelPanelRefreshes(new Set(n(this, q).keys()), !0), this.resetDatasets(new Set(n(this, S).keys())), D(this, P, this.dataRuntime.restoreContext(e, t).context), this.notify(), this.snapshot;
1147
+ }
1148
+ async dispatchEvent(e) {
1149
+ var i, a, d;
1150
+ const r = ((d = (a = (i = this.requirePanel(e.panelId).enhancement) == null ? void 0 : i.common) == null ? void 0 : a.interactions) == null ? void 0 : d.filter((c) => c.event === e.type)) ?? [];
1151
+ await Promise.all(
1152
+ r.map((c) => this.dataRuntime.registries.actions.require(c.actionId).execute(e, n(this, P)))
1153
+ );
1154
+ }
1155
+ async executePanelAction(e, t) {
1156
+ var a;
1157
+ const r = this.requirePanel(e), i = (a = r.actions) == null ? void 0 : a.find((d) => d.id === t);
1158
+ if (!i) throw new Error(`Panel action not found: ${e}/${t}`);
1159
+ await this.dataRuntime.registries.actions.require(i.actionId).execute(
1160
+ {
1161
+ type: "dataPointClick",
1162
+ panelId: e,
1163
+ datasetId: r.binding.datasetId,
1164
+ fields: Object.freeze({})
1165
+ },
1166
+ n(this, P)
1167
+ );
1168
+ }
1169
+ destroy() {
1170
+ var e;
1171
+ D(this, F, !0), (e = n(this, O)) == null || e.abort(), D(this, O, void 0), n(this, U).clear(), D(this, K, !1), this.cancelPanelLoads(new Set(n(this, S).keys())), this.cancelPanelRefreshes(new Set(n(this, q).keys())), n(this, Q).clear(), this.dataRuntime.clear();
1172
+ }
1173
+ requirePanel(e) {
1174
+ const t = this.config.panels.find((r) => r.id === e);
1175
+ if (!t) throw new Error(`Panel not found: ${e}`);
1176
+ return t;
1177
+ }
1178
+ notify() {
1179
+ if (n(this, F)) return;
1180
+ const e = this.snapshot;
1181
+ n(this, Q).forEach((t) => t(e));
1182
+ }
1183
+ requestIdsForDatasets(e) {
1184
+ const t = /* @__PURE__ */ new Set();
1185
+ return e.forEach(
1186
+ (r) => {
1187
+ var i;
1188
+ return (i = this.graph.requestIdsByDatasetId.get(r)) == null ? void 0 : i.forEach((a) => t.add(a));
1189
+ }
1190
+ ), t;
1191
+ }
1192
+ datasetIdsForPanels(e) {
1193
+ const t = /* @__PURE__ */ new Set();
1194
+ for (const r of e) {
1195
+ this.requirePanel(r);
1196
+ const i = this.graph.datasetIdByPanelId.get(r);
1197
+ i && t.add(i);
1198
+ }
1199
+ return t;
1200
+ }
1201
+ resetDatasets(e, t = n(this, j)) {
1202
+ const r = Oe(this.graph, e);
1203
+ this.cancelPanelRefreshes(r), this.cancelPanelLoads(e), e.forEach((i) => {
1204
+ n(this, $).set(i, Object.freeze({ id: i, status: "idle", generation: t }));
1205
+ }), r.forEach((i) => {
1206
+ n(this, R).set(i, Object.freeze({ id: i, status: "idle", generation: t, isRefreshing: !1 }));
1207
+ });
1208
+ }
1209
+ deferUnselectedDatasets(e, t) {
1210
+ const r = new Set(this.config.datasets.map((d) => d.id));
1211
+ if (e.forEach((d) => r.delete(d)), !r.size) return r;
1212
+ const i = this.requestIdsForDatasets(e);
1213
+ return this.requestIdsForDatasets(r).forEach((d) => {
1214
+ this.dataRuntime.datasetRunner.requestExecutor.invalidateRequest(d), i.has(d) || n(this, z).set(d, Object.freeze({ id: d, status: "idle", generation: t }));
1215
+ }), r.forEach((d) => {
1216
+ this.dataRuntime.datasetRunner.invalidateDataset(d);
1217
+ }), this.resetDatasets(r, t), r;
1218
+ }
1219
+ loadPanelDatasets(e) {
1220
+ if (n(this, F)) return Promise.reject(new Error("DashboardRuntime has been destroyed."));
1221
+ const t = [];
1222
+ return e.forEach((r) => {
1223
+ var d;
1224
+ const i = n(this, S).get(r);
1225
+ if (i) {
1226
+ t.push(i.promise);
1227
+ return;
1228
+ }
1229
+ const a = (d = n(this, $).get(r)) == null ? void 0 : d.status;
1230
+ a !== "idle" && a !== "cancelled" || t.push(this.schedulePanelLoad(r));
1231
+ }), t.length ? Promise.all(t).then(() => this.snapshot) : Promise.resolve(this.snapshot);
1232
+ }
1233
+ schedulePanelLoad(e) {
1234
+ const t = new AbortController(), r = ++W(this, oe)._, i = n(this, P), a = ee(), d = {
1235
+ controller: t,
1236
+ context: i,
1237
+ generation: r,
1238
+ startedAt: a,
1239
+ promise: Promise.resolve()
1240
+ };
1241
+ n(this, S).set(e, d);
1242
+ const c = this.graph.requestIdsByDatasetId.get(e) ?? /* @__PURE__ */ new Set(), u = this.graph.panelIdsByDatasetId.get(e) ?? /* @__PURE__ */ new Set();
1243
+ c.forEach((b) => {
1244
+ n(this, z).set(b, Object.freeze({ id: b, status: "loading", generation: r, startedAt: a }));
1245
+ });
1246
+ const p = n(this, $).get(e), { error: f, ...m } = p;
1247
+ return n(this, $).set(e, Object.freeze({ ...m, status: "loading", generation: r })), u.forEach((b) => {
1248
+ const o = n(this, R).get(b), { error: h, ...y } = o;
1249
+ n(this, R).set(
1250
+ b,
1251
+ Object.freeze({
1252
+ ...y,
1253
+ status: o.viewModel ? o.status : "loading",
1254
+ generation: r,
1255
+ isRefreshing: !!o.viewModel
1256
+ })
1257
+ );
1258
+ }), this.notify(), d.promise = this.executePanelLoad(e, d, c, u), d.promise;
1259
+ }
1260
+ async executePanelLoad(e, t, r, i) {
1261
+ try {
1262
+ const a = await this.dataRuntime.runDataset(e, t.context, {
1263
+ signal: t.controller.signal
1264
+ });
1265
+ if (n(this, S).get(e) !== t || n(this, F)) return;
1266
+ n(this, $).set(
1267
+ e,
1268
+ Object.freeze({
1269
+ id: e,
1270
+ status: a.rows.length ? "success" : "empty",
1271
+ generation: t.generation,
1272
+ result: a,
1273
+ lastSuccessfulAt: a.updatedAt
1274
+ })
1275
+ ), r.forEach((d) => {
1276
+ n(this, z).set(
1277
+ d,
1278
+ Object.freeze({
1279
+ id: d,
1280
+ status: "success",
1281
+ generation: t.generation,
1282
+ startedAt: t.startedAt,
1283
+ completedAt: ee()
1284
+ })
1285
+ );
1286
+ }), this.config.panels.filter((d) => d.binding.datasetId === e && i.has(d.id)).forEach((d) => this.adaptPanel(d, a, t.generation, t.context));
1287
+ } catch (a) {
1288
+ if (n(this, S).get(e) !== t || n(this, F) || t.controller.signal.aborted)
1289
+ return;
1290
+ const d = ie(a) ? "cancelled" : "error", c = n(this, $).get(e);
1291
+ n(this, $).set(
1292
+ e,
1293
+ Object.freeze({
1294
+ ...c,
1295
+ status: c.result && !ie(a) ? "stale" : d,
1296
+ generation: t.generation,
1297
+ error: re(a, "dataset_failed")
1298
+ })
1299
+ ), r.forEach((u) => {
1300
+ n(this, z).set(
1301
+ u,
1302
+ Object.freeze({
1303
+ id: u,
1304
+ status: d,
1305
+ generation: t.generation,
1306
+ startedAt: t.startedAt,
1307
+ completedAt: ee(),
1308
+ error: re(a, "request_failed")
1309
+ })
1310
+ );
1311
+ }), i.forEach((u) => this.failPanel(u, t.generation, a, "dataset_failed"));
1312
+ } finally {
1313
+ n(this, S).get(e) === t && (n(this, S).delete(e), this.notify());
1314
+ }
1315
+ }
1316
+ cancelPanelLoads(e) {
1317
+ e.forEach((t) => {
1318
+ const r = n(this, S).get(t);
1319
+ r && (n(this, S).delete(t), r.controller.abort());
1320
+ });
1321
+ }
1322
+ applyPresets(e) {
1323
+ var r, i, a;
1324
+ let t = e.enhancement;
1325
+ return (a = (i = (r = e.enhancement) == null ? void 0 : r.common) == null ? void 0 : i.presetIds) == null || a.forEach((d) => {
1326
+ t = this.dataRuntime.registries.presets.require(d).apply(t);
1327
+ }), t;
1328
+ }
1329
+ adaptPanel(e, t, r, i = n(this, P)) {
1330
+ try {
1331
+ const a = this.dataRuntime.registries.rendererDefinitions.require(e.rendererId), d = this.dataRuntime.registries.adapters.require(
1332
+ e.adapterId ?? a.defaultAdapterId
1333
+ ), c = this.applyPresets(e), u = d.adapt({
1334
+ dataset: t,
1335
+ binding: e.binding,
1336
+ ...c ? { enhancement: c } : {},
1337
+ context: i
1338
+ }), p = u.empty ? "empty" : "success";
1339
+ n(this, R).set(
1340
+ e.id,
1341
+ Object.freeze({
1342
+ id: e.id,
1343
+ status: p,
1344
+ generation: r,
1345
+ isRefreshing: !1,
1346
+ viewModel: u,
1347
+ dataset: t,
1348
+ lastSuccessfulAt: t.updatedAt
1349
+ })
1350
+ );
1351
+ } catch (a) {
1352
+ V(this.options.telemetry, {
1353
+ name: "adapter_failed",
1354
+ dashboardId: this.config.id,
1355
+ panelId: e.id,
1356
+ datasetId: e.binding.datasetId,
1357
+ errorCode: "adapter_failed"
1358
+ }), this.failPanel(e.id, r, a, "adapter_failed");
1359
+ }
1360
+ }
1361
+ failPanel(e, t, r, i) {
1362
+ const a = n(this, R).get(e);
1363
+ n(this, R).set(
1364
+ e,
1365
+ Object.freeze({
1366
+ ...a,
1367
+ status: a.viewModel ? "stale" : ie(r) ? "cancelled" : "error",
1368
+ generation: t,
1369
+ isRefreshing: !1,
1370
+ error: re(r, i)
1371
+ })
1372
+ );
1373
+ }
1374
+ cancelPanelRefreshes(e, t = !1) {
1375
+ e.forEach((r) => {
1376
+ var a;
1377
+ const i = n(this, q).get(r);
1378
+ i && (n(this, q).delete(r), i.controller.abort(), t && ((a = n(this, R).get(r)) == null ? void 0 : a.generation) === i.generation && n(this, R).set(r, i.previousState));
1379
+ });
1380
+ }
1381
+ async schedulePanel(e) {
1382
+ if (n(this, F)) throw new Error("DashboardRuntime has been destroyed.");
1383
+ const t = e.binding.datasetId, r = n(this, q).get(e.id), i = (r == null ? void 0 : r.previousState) ?? n(this, R).get(e.id);
1384
+ r && (n(this, q).delete(e.id), r.controller.abort());
1385
+ const a = new AbortController(), d = ++W(this, oe)._, c = n(this, P), u = { controller: a, generation: d, previousState: i };
1386
+ n(this, q).set(e.id, u);
1387
+ const { error: p, viewModel: f, dataset: m, ...b } = i, o = !!(f && !f.empty);
1388
+ n(this, R).set(
1389
+ e.id,
1390
+ Object.freeze({
1391
+ ...b,
1392
+ ...o && f ? { viewModel: f } : {},
1393
+ ...o && m ? { dataset: m } : {},
1394
+ status: o ? i.status === "stale" ? "success" : i.status : "loading",
1395
+ generation: d,
1396
+ isRefreshing: o
1397
+ })
1398
+ ), this.notify();
1399
+ try {
1400
+ const h = await this.dataRuntime.runDataset(t, c, {
1401
+ signal: a.signal,
1402
+ force: !0,
1403
+ isolated: !0
1404
+ });
1405
+ if (n(this, q).get(e.id) !== u || n(this, F)) return this.snapshot;
1406
+ this.adaptPanel(e, h, d, c);
1407
+ } catch (h) {
1408
+ if (n(this, q).get(e.id) !== u || n(this, F) || a.signal.aborted)
1409
+ return this.snapshot;
1410
+ this.failPanel(e.id, d, h, "dataset_failed");
1411
+ } finally {
1412
+ n(this, q).get(e.id) === u && (n(this, q).delete(e.id), this.notify());
1413
+ }
1414
+ return this.snapshot;
1415
+ }
1416
+ async schedule(e, t, r = !0) {
1417
+ var p;
1418
+ if (n(this, F)) throw new Error("DashboardRuntime has been destroyed.");
1419
+ const i = this.requestIdsForDatasets(e), a = Oe(this.graph, e);
1420
+ this.cancelPanelRefreshes(a), this.cancelPanelLoads(e), (p = n(this, O)) == null || p.abort();
1421
+ const d = new AbortController();
1422
+ D(this, O, d), D(this, U, new Set(e)), D(this, K, r);
1423
+ const c = ++W(this, j)._, u = ee();
1424
+ return t && (i.forEach((f) => this.dataRuntime.datasetRunner.requestExecutor.invalidateRequest(f)), e.forEach((f) => this.dataRuntime.datasetRunner.invalidateDataset(f))), i.forEach((f) => {
1425
+ n(this, z).set(f, Object.freeze({ id: f, status: "loading", generation: c, startedAt: u }));
1426
+ }), e.forEach((f) => {
1427
+ const m = n(this, $).get(f), { error: b, ...o } = m;
1428
+ n(this, $).set(
1429
+ f,
1430
+ Object.freeze({
1431
+ ...o,
1432
+ status: "loading",
1433
+ generation: c
1434
+ })
1435
+ );
1436
+ }), a.forEach((f) => {
1437
+ const m = n(this, R).get(f), { error: b, viewModel: o, dataset: h, ...y } = m, l = !!(o && !o.empty);
1438
+ n(this, R).set(
1439
+ f,
1440
+ Object.freeze({
1441
+ ...y,
1442
+ ...l && o ? { viewModel: o } : {},
1443
+ ...l && h ? { dataset: h } : {},
1444
+ status: l ? m.status : "loading",
1445
+ generation: c,
1446
+ isRefreshing: l
1447
+ })
1448
+ );
1449
+ }), this.notify(), await Promise.all(
1450
+ Array.from(e, async (f) => {
1451
+ var m, b;
1452
+ try {
1453
+ const o = await this.dataRuntime.runDataset(f, n(this, P), { signal: d.signal });
1454
+ if (c !== n(this, j) || n(this, F)) return;
1455
+ n(this, $).set(
1456
+ f,
1457
+ Object.freeze({
1458
+ id: f,
1459
+ status: o.rows.length ? "success" : "empty",
1460
+ generation: c,
1461
+ result: o,
1462
+ lastSuccessfulAt: o.updatedAt
1463
+ })
1464
+ ), (m = this.graph.requestIdsByDatasetId.get(f)) == null || m.forEach((h) => {
1465
+ n(this, z).set(
1466
+ h,
1467
+ Object.freeze({
1468
+ id: h,
1469
+ status: "success",
1470
+ generation: c,
1471
+ startedAt: u,
1472
+ completedAt: ee()
1473
+ })
1474
+ );
1475
+ }), this.config.panels.filter((h) => h.binding.datasetId === f && a.has(h.id)).forEach((h) => this.adaptPanel(h, o, c));
1476
+ } catch (o) {
1477
+ if (c !== n(this, j) || n(this, F)) return;
1478
+ const h = ie(o) ? "cancelled" : "error", y = n(this, $).get(f);
1479
+ n(this, $).set(
1480
+ f,
1481
+ Object.freeze({
1482
+ ...y,
1483
+ status: y.result && !ie(o) ? "stale" : h,
1484
+ generation: c,
1485
+ error: re(o, "dataset_failed")
1486
+ })
1487
+ ), (b = this.graph.requestIdsByDatasetId.get(f)) == null || b.forEach((l) => {
1488
+ n(this, z).set(
1489
+ l,
1490
+ Object.freeze({
1491
+ id: l,
1492
+ status: h,
1493
+ generation: c,
1494
+ startedAt: u,
1495
+ completedAt: ee(),
1496
+ error: re(o, "request_failed")
1497
+ })
1498
+ );
1499
+ }), this.config.panels.filter((l) => l.binding.datasetId === f && a.has(l.id)).forEach((l) => this.failPanel(l.id, c, o, "dataset_failed"));
1500
+ } finally {
1501
+ c === n(this, j) && n(this, O) === d && !n(this, F) && this.notify();
1502
+ }
1503
+ })
1504
+ ), c === n(this, j) && n(this, O) === d && (D(this, O, void 0), n(this, U).clear(), D(this, K, !1), this.notify()), this.snapshot;
1505
+ }
1506
+ }
1507
+ Q = new WeakMap(), z = new WeakMap(), $ = new WeakMap(), R = new WeakMap(), q = new WeakMap(), S = new WeakMap(), P = new WeakMap(), j = new WeakMap(), oe = new WeakMap(), O = new WeakMap(), U = new WeakMap(), K = new WeakMap(), F = new WeakMap();
1508
+ function Pt(s) {
1509
+ return new _t(s);
1510
+ }
1511
+ export {
1512
+ ht as B,
1513
+ Je as D,
1514
+ rt as P,
1515
+ nt as R,
1516
+ je as a,
1517
+ _t as b,
1518
+ N as c,
1519
+ bt as d,
1520
+ ue as e,
1521
+ k as f,
1522
+ Xe as g,
1523
+ ze as h,
1524
+ Oe as i,
1525
+ ot as j,
1526
+ St as k,
1527
+ wt as l,
1528
+ Pt as m,
1529
+ at as n,
1530
+ lt as o,
1531
+ qt as p,
1532
+ Ae as q,
1533
+ mt as r,
1534
+ Rt as s,
1535
+ me as t,
1536
+ dt as u,
1537
+ st as v,
1538
+ Ze as w
1539
+ };
1540
+ //# sourceMappingURL=dashboard-runtime-8a-9P8Ku.js.map