drizzle-cube 0.2.25 → 0.2.27

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 (95) hide show
  1. package/dist/client/charts.js +2 -2
  2. package/dist/client/chunks/{charts-BsXrHSCm.js → charts-BfXEKIrq.js} +44 -44
  3. package/dist/client/chunks/{charts-BsXrHSCm.js.map → charts-BfXEKIrq.js.map} +1 -1
  4. package/dist/client/chunks/charts-DQuOI5HA.js +9465 -0
  5. package/dist/client/chunks/charts-DQuOI5HA.js.map +1 -0
  6. package/dist/client/chunks/components-CWMeA5e-.js +14872 -0
  7. package/dist/client/chunks/components-CWMeA5e-.js.map +1 -0
  8. package/dist/client/chunks/core-DrhYtHHa.js +6 -0
  9. package/dist/client/chunks/core-DrhYtHHa.js.map +1 -0
  10. package/dist/client/chunks/hooks-CAKGR-w0.js +828 -0
  11. package/dist/client/chunks/hooks-CAKGR-w0.js.map +1 -0
  12. package/dist/client/components/AIAssistant/index.d.ts +5 -2
  13. package/dist/client/components/AnalysisBuilder/index.d.ts +6 -0
  14. package/dist/client/components/AnalysisBuilder/types.d.ts +9 -7
  15. package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +46 -0
  16. package/dist/client/components/AnalysisBuilder/utils/filterUtils.d.ts +19 -0
  17. package/dist/client/components/AnalysisBuilder/utils/idUtils.d.ts +11 -0
  18. package/dist/client/components/AnalysisBuilder/utils/index.d.ts +11 -0
  19. package/dist/client/components/AnalysisBuilder/utils/queryUtils.d.ts +11 -0
  20. package/dist/client/components/AnalysisBuilder/utils/recentFieldsUtils.d.ts +14 -0
  21. package/dist/client/components/AnalysisBuilder/utils/storageUtils.d.ts +42 -0
  22. package/dist/client/components/ConfirmModal.d.ts +30 -0
  23. package/dist/client/components/DashboardFilters/CompactFilterBar.d.ts +13 -0
  24. package/dist/client/components/DashboardFilters/CustomDateDropdown.d.ts +10 -0
  25. package/dist/client/components/DashboardFilters/DashboardFilterConfigModal.d.ts +20 -0
  26. package/dist/client/components/DashboardFilters/DashboardFilterItem.d.ts +14 -0
  27. package/dist/client/components/DashboardFilters/DatePresetChips.d.ts +8 -0
  28. package/dist/client/components/DashboardFilters/FilterChip.d.ts +12 -0
  29. package/dist/client/components/DashboardFilters/FilterValuePopover.d.ts +11 -0
  30. package/dist/client/components/DashboardFilters/XTDDropdown.d.ts +10 -0
  31. package/dist/client/components/DashboardPortletCard.d.ts +13 -34
  32. package/dist/client/components/PortletAnalysisModal.d.ts +4 -2
  33. package/dist/client/components/QueryBuilder/types.d.ts +0 -17
  34. package/dist/client/components/shared/utils.d.ts +33 -109
  35. package/dist/client/components.d.ts +0 -1
  36. package/dist/client/components.js +12 -13
  37. package/dist/client/hooks/queries/index.d.ts +15 -0
  38. package/dist/client/hooks/queries/useCubeLoadQuery.d.ts +67 -0
  39. package/dist/client/hooks/queries/useCubeMetaQuery.d.ts +51 -0
  40. package/dist/client/hooks/queries/useDryRunQuery.d.ts +103 -0
  41. package/dist/client/hooks/queries/useMultiCubeLoadQuery.d.ts +68 -0
  42. package/dist/client/hooks/useAnalysisAI.d.ts +44 -0
  43. package/dist/client/hooks/useAnalysisBuilderHook.d.ts +113 -0
  44. package/dist/client/hooks/useAnalysisChartDefaults.d.ts +35 -0
  45. package/dist/client/hooks/useAnalysisCombinedFields.d.ts +18 -0
  46. package/dist/client/hooks/useAnalysisInitialization.d.ts +25 -0
  47. package/dist/client/hooks/useAnalysisQueryBuilder.d.ts +32 -0
  48. package/dist/client/hooks/useAnalysisQueryExecution.d.ts +38 -0
  49. package/dist/client/hooks/useAnalysisShare.d.ts +23 -0
  50. package/dist/client/hooks/useAnalysisUIState.d.ts +24 -0
  51. package/dist/client/hooks/useDashboardHook.d.ts +108 -0
  52. package/dist/client/hooks/useDebounceQuery.d.ts +48 -0
  53. package/dist/client/hooks/useDirtyStateTracking.d.ts +37 -0
  54. package/dist/client/hooks/useFilterValues.d.ts +4 -1
  55. package/dist/client/hooks.d.ts +4 -2
  56. package/dist/client/hooks.js +12 -170
  57. package/dist/client/hooks.js.map +1 -1
  58. package/dist/client/icons.js +1 -1
  59. package/dist/client/index.d.ts +11 -4
  60. package/dist/client/index.js +99 -70
  61. package/dist/client/providers/CubeMetaProvider.d.ts +1 -1
  62. package/dist/client/providers/CubeProvider.d.ts +7 -3
  63. package/dist/client/providers.js +1 -1
  64. package/dist/client/shared/queryKey.d.ts +1 -0
  65. package/dist/client/shared/utils.d.ts +5 -0
  66. package/dist/client/stores/analysisBuilderStore.d.ts +271 -0
  67. package/dist/client/stores/dashboardStore.d.ts +267 -0
  68. package/dist/client/stores/index.d.ts +13 -0
  69. package/dist/client/styles.css +1 -1
  70. package/dist/client/types.d.ts +27 -1
  71. package/dist/client/utils/chartUtils.d.ts +1 -2
  72. package/dist/client/utils/filterUtils.d.ts +15 -10
  73. package/dist/client/utils/pivotUtils.d.ts +1 -2
  74. package/dist/client-bundle-stats.html +1 -1
  75. package/package.json +13 -19
  76. package/dist/client/chunks/charts-BvLb1eub.js +0 -7427
  77. package/dist/client/chunks/charts-BvLb1eub.js.map +0 -1
  78. package/dist/client/chunks/components-DhA8GIUY.js +0 -14851
  79. package/dist/client/chunks/components-DhA8GIUY.js.map +0 -1
  80. package/dist/client/chunks/core-DcwgBEzv.js +0 -6
  81. package/dist/client/chunks/core-DcwgBEzv.js.map +0 -1
  82. package/dist/client/chunks/index-9x0R-Fme.js +0 -551
  83. package/dist/client/chunks/index-9x0R-Fme.js.map +0 -1
  84. package/dist/client/components/AIAssistant/AIAssistantModal.d.ts +0 -10
  85. package/dist/client/components/AnalysisBuilder/utils.d.ts +0 -103
  86. package/dist/client/components/CubeRelationshipDiagram/CubeNode.d.ts +0 -13
  87. package/dist/client/components/CubeRelationshipDiagram/ERDControls.d.ts +0 -7
  88. package/dist/client/components/CubeRelationshipDiagram/RelationshipEdge.d.ts +0 -11
  89. package/dist/client/components/CubeRelationshipDiagram/index.d.ts +0 -10
  90. package/dist/client/components/CubeRelationshipDiagram/useERDLayout.d.ts +0 -21
  91. package/dist/client/components/PortletEditModal.d.ts +0 -12
  92. package/dist/client/components/shared/CubeMetaExplorer.d.ts +0 -4
  93. package/dist/client/hooks/useCubeMeta.d.ts +0 -39
  94. package/dist/client/hooks/useCubeQuery.d.ts +0 -9
  95. package/dist/client/hooks/useMultiCubeQuery.d.ts +0 -36
@@ -0,0 +1,828 @@
1
+ import { useState as w, useRef as g, useMemo as h, useEffect as _, useCallback as v } from "react";
2
+ import { a as M, M as x, O as k, Q as $ } from "./charts-DQuOI5HA.js";
3
+ const N = {
4
+ // String operators
5
+ equals: {
6
+ label: "equals",
7
+ description: "Exact match",
8
+ requiresValues: !0,
9
+ supportsMultipleValues: !0,
10
+ valueType: "any",
11
+ fieldTypes: ["string", "number", "boolean", "time"]
12
+ },
13
+ notEquals: {
14
+ label: "not equals",
15
+ description: "Does not match",
16
+ requiresValues: !0,
17
+ supportsMultipleValues: !0,
18
+ valueType: "any",
19
+ fieldTypes: ["string", "number", "boolean", "time"]
20
+ },
21
+ contains: {
22
+ label: "contains",
23
+ description: "Contains text (case insensitive)",
24
+ requiresValues: !0,
25
+ supportsMultipleValues: !1,
26
+ valueType: "string",
27
+ fieldTypes: ["string"]
28
+ },
29
+ notContains: {
30
+ label: "not contains",
31
+ description: "Does not contain text",
32
+ requiresValues: !0,
33
+ supportsMultipleValues: !1,
34
+ valueType: "string",
35
+ fieldTypes: ["string"]
36
+ },
37
+ startsWith: {
38
+ label: "starts with",
39
+ description: "Starts with text",
40
+ requiresValues: !0,
41
+ supportsMultipleValues: !1,
42
+ valueType: "string",
43
+ fieldTypes: ["string"]
44
+ },
45
+ notStartsWith: {
46
+ label: "not starts with",
47
+ description: "Does not start with text",
48
+ requiresValues: !0,
49
+ supportsMultipleValues: !1,
50
+ valueType: "string",
51
+ fieldTypes: ["string"]
52
+ },
53
+ endsWith: {
54
+ label: "ends with",
55
+ description: "Ends with text",
56
+ requiresValues: !0,
57
+ supportsMultipleValues: !1,
58
+ valueType: "string",
59
+ fieldTypes: ["string"]
60
+ },
61
+ notEndsWith: {
62
+ label: "not ends with",
63
+ description: "Does not end with text",
64
+ requiresValues: !0,
65
+ supportsMultipleValues: !1,
66
+ valueType: "string",
67
+ fieldTypes: ["string"]
68
+ },
69
+ like: {
70
+ label: "like",
71
+ description: "SQL LIKE pattern matching (case sensitive)",
72
+ requiresValues: !0,
73
+ supportsMultipleValues: !1,
74
+ valueType: "string",
75
+ fieldTypes: ["string"]
76
+ },
77
+ notLike: {
78
+ label: "not like",
79
+ description: "SQL NOT LIKE pattern matching (case sensitive)",
80
+ requiresValues: !0,
81
+ supportsMultipleValues: !1,
82
+ valueType: "string",
83
+ fieldTypes: ["string"]
84
+ },
85
+ ilike: {
86
+ label: "ilike",
87
+ description: "SQL ILIKE pattern matching (case insensitive)",
88
+ requiresValues: !0,
89
+ supportsMultipleValues: !1,
90
+ valueType: "string",
91
+ fieldTypes: ["string"]
92
+ },
93
+ // Numeric operators
94
+ gt: {
95
+ label: "greater than",
96
+ description: "Greater than value",
97
+ requiresValues: !0,
98
+ supportsMultipleValues: !1,
99
+ valueType: "number",
100
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
101
+ },
102
+ gte: {
103
+ label: "greater than or equal",
104
+ description: "Greater than or equal to value",
105
+ requiresValues: !0,
106
+ supportsMultipleValues: !1,
107
+ valueType: "number",
108
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
109
+ },
110
+ lt: {
111
+ label: "less than",
112
+ description: "Less than value",
113
+ requiresValues: !0,
114
+ supportsMultipleValues: !1,
115
+ valueType: "number",
116
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
117
+ },
118
+ lte: {
119
+ label: "less than or equal",
120
+ description: "Less than or equal to value",
121
+ requiresValues: !0,
122
+ supportsMultipleValues: !1,
123
+ valueType: "number",
124
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
125
+ },
126
+ between: {
127
+ label: "between",
128
+ description: "Between two values (inclusive)",
129
+ requiresValues: !0,
130
+ supportsMultipleValues: !1,
131
+ valueType: "number",
132
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
133
+ },
134
+ notBetween: {
135
+ label: "not between",
136
+ description: "Not between two values",
137
+ requiresValues: !0,
138
+ supportsMultipleValues: !1,
139
+ valueType: "number",
140
+ fieldTypes: ["number", "count", "sum", "avg", "min", "max"]
141
+ },
142
+ // Array operators
143
+ in: {
144
+ label: "in",
145
+ description: "Matches any of the provided values",
146
+ requiresValues: !0,
147
+ supportsMultipleValues: !0,
148
+ valueType: "any",
149
+ fieldTypes: ["string", "number", "boolean"]
150
+ },
151
+ notIn: {
152
+ label: "not in",
153
+ description: "Does not match any of the provided values",
154
+ requiresValues: !0,
155
+ supportsMultipleValues: !0,
156
+ valueType: "any",
157
+ fieldTypes: ["string", "number", "boolean"]
158
+ },
159
+ // Null/Empty operators
160
+ set: {
161
+ label: "is set",
162
+ description: "Is not null/empty",
163
+ requiresValues: !1,
164
+ supportsMultipleValues: !1,
165
+ valueType: "any",
166
+ fieldTypes: ["string", "number", "time", "boolean"]
167
+ },
168
+ notSet: {
169
+ label: "is not set",
170
+ description: "Is null/empty",
171
+ requiresValues: !1,
172
+ supportsMultipleValues: !1,
173
+ valueType: "any",
174
+ fieldTypes: ["string", "number", "time", "boolean"]
175
+ },
176
+ isEmpty: {
177
+ label: "is empty",
178
+ description: "Is empty string or null",
179
+ requiresValues: !1,
180
+ supportsMultipleValues: !1,
181
+ valueType: "string",
182
+ fieldTypes: ["string"]
183
+ },
184
+ isNotEmpty: {
185
+ label: "is not empty",
186
+ description: "Is not empty string and not null",
187
+ requiresValues: !1,
188
+ supportsMultipleValues: !1,
189
+ valueType: "string",
190
+ fieldTypes: ["string"]
191
+ },
192
+ // Date operators
193
+ inDateRange: {
194
+ label: "in date range",
195
+ description: "Between two dates",
196
+ requiresValues: !0,
197
+ supportsMultipleValues: !1,
198
+ valueType: "date",
199
+ fieldTypes: ["time"]
200
+ },
201
+ beforeDate: {
202
+ label: "before date",
203
+ description: "Before specified date",
204
+ requiresValues: !0,
205
+ supportsMultipleValues: !1,
206
+ valueType: "date",
207
+ fieldTypes: ["time"]
208
+ },
209
+ afterDate: {
210
+ label: "after date",
211
+ description: "After specified date",
212
+ requiresValues: !0,
213
+ supportsMultipleValues: !1,
214
+ valueType: "date",
215
+ fieldTypes: ["time"]
216
+ },
217
+ // Regex operators
218
+ regex: {
219
+ label: "matches regex",
220
+ description: "Matches regular expression pattern",
221
+ requiresValues: !0,
222
+ supportsMultipleValues: !1,
223
+ valueType: "string",
224
+ fieldTypes: ["string"]
225
+ },
226
+ notRegex: {
227
+ label: "not matches regex",
228
+ description: "Does not match regular expression pattern",
229
+ requiresValues: !0,
230
+ supportsMultipleValues: !1,
231
+ valueType: "string",
232
+ fieldTypes: ["string"]
233
+ },
234
+ // PostgreSQL array operators
235
+ arrayContains: {
236
+ label: "array contains all",
237
+ description: "Array field contains all specified values (PostgreSQL only)",
238
+ requiresValues: !0,
239
+ supportsMultipleValues: !0,
240
+ valueType: "string",
241
+ fieldTypes: ["string"]
242
+ },
243
+ arrayOverlaps: {
244
+ label: "array contains any",
245
+ description: "Array field contains any of the specified values (PostgreSQL only)",
246
+ requiresValues: !0,
247
+ supportsMultipleValues: !0,
248
+ valueType: "string",
249
+ fieldTypes: ["string"]
250
+ },
251
+ arrayContained: {
252
+ label: "array values in",
253
+ description: "All array field values are within specified values (PostgreSQL only)",
254
+ requiresValues: !0,
255
+ supportsMultipleValues: !0,
256
+ valueType: "string",
257
+ fieldTypes: ["string"]
258
+ }
259
+ }, oe = [
260
+ { value: "custom", label: "Custom" },
261
+ { value: "today", label: "Today" },
262
+ { value: "yesterday", label: "Yesterday" },
263
+ { value: "this_week", label: "This week" },
264
+ { value: "this_month", label: "This month" },
265
+ { value: "this_quarter", label: "This quarter" },
266
+ { value: "this_year", label: "This year" },
267
+ { value: "last_7_days", label: "Last 7 days" },
268
+ { value: "last_30_days", label: "Last 30 days" },
269
+ { value: "last_n_days", label: "Last N days" },
270
+ { value: "last_week", label: "Last week" },
271
+ { value: "last_n_weeks", label: "Last N weeks" },
272
+ { value: "last_month", label: "Last month" },
273
+ { value: "last_12_months", label: "Last 12 months" },
274
+ { value: "last_n_months", label: "Last N months" },
275
+ { value: "last_quarter", label: "Last quarter" },
276
+ { value: "last_n_quarters", label: "Last N quarters" },
277
+ { value: "last_year", label: "Last year" },
278
+ { value: "last_n_years", label: "Last N years" }
279
+ ];
280
+ function G(e) {
281
+ return "member" in e && "operator" in e && "values" in e;
282
+ }
283
+ function U(e) {
284
+ return "type" in e && "filters" in e;
285
+ }
286
+ function z(e) {
287
+ const r = (t) => {
288
+ if (G(t))
289
+ return t;
290
+ if (U(t)) {
291
+ const s = t.filters.map(r);
292
+ return t.type === "and" ? { and: s } : { or: s };
293
+ }
294
+ return t;
295
+ };
296
+ return e.map(r);
297
+ }
298
+ function J(e) {
299
+ const r = {};
300
+ return e.measures && e.measures.length > 0 && (r.measures = e.measures), e.dimensions && e.dimensions.length > 0 && (r.dimensions = e.dimensions), e.timeDimensions && e.timeDimensions.length > 0 && (r.timeDimensions = e.timeDimensions), e.filters && e.filters.length > 0 && (r.filters = e.filters), e.order && (r.order = e.order), e.limit && (r.limit = e.limit), e.offset && (r.offset = e.offset), e.segments && e.segments.length > 0 && (r.segments = e.segments), r;
301
+ }
302
+ function q(e) {
303
+ const r = J(e);
304
+ return r.filters && r.filters.length > 0 && (r.filters = z(r.filters)), r;
305
+ }
306
+ function ce(e) {
307
+ const r = [];
308
+ for (const [t, s] of Object.entries(N))
309
+ s.fieldTypes.includes(e) && r.push({
310
+ operator: t,
311
+ label: s.label
312
+ });
313
+ return r;
314
+ }
315
+ function pe(e, r) {
316
+ const t = {
317
+ today: "today",
318
+ yesterday: "yesterday",
319
+ this_week: "this week",
320
+ this_month: "this month",
321
+ this_quarter: "this quarter",
322
+ this_year: "this year",
323
+ last_7_days: "last 7 days",
324
+ last_30_days: "last 30 days",
325
+ last_week: "last week",
326
+ last_month: "last month",
327
+ last_quarter: "last quarter",
328
+ last_year: "last year",
329
+ last_12_months: "last 12 months"
330
+ };
331
+ if (e.startsWith("last_n_") && r !== void 0 && r > 0) {
332
+ const s = e.replace("last_n_", ""), n = s.slice(0, -1);
333
+ return r === 1 ? `last ${n}` : `last ${r} ${s}`;
334
+ }
335
+ return t[e] || e;
336
+ }
337
+ function fe(e) {
338
+ return e.startsWith("last_n_");
339
+ }
340
+ function de(e) {
341
+ return e.toISOString().split("T")[0];
342
+ }
343
+ function E(e) {
344
+ const r = /* @__PURE__ */ new WeakSet(), t = (s) => {
345
+ if (s === null || typeof s != "object")
346
+ return JSON.stringify(s);
347
+ if (r.has(s))
348
+ return '"[Circular]"';
349
+ if (r.add(s), Array.isArray(s))
350
+ return `[${s.map((f) => t(f)).join(",")}]`;
351
+ const n = s;
352
+ return `{${Object.keys(n).sort().map((f) => `${JSON.stringify(f)}:${t(n[f])}`).join(",")}}`;
353
+ };
354
+ return t(e);
355
+ }
356
+ function I(e, r) {
357
+ const { isValid: t, skip: s = !1, debounceMs: n = 300 } = r, [l, u] = w(null), [f, c] = w(!1), d = g(null), a = g(""), i = g(s), o = h(() => e ? E(e) : "", [e]);
358
+ return _(() => {
359
+ const y = i.current && !s;
360
+ if (i.current = s, !(o === a.current && !y))
361
+ return d.current && clearTimeout(d.current), t && !s ? (c(!0), d.current = setTimeout(() => {
362
+ a.current = o, u(e), c(!1);
363
+ }, n)) : (a.current = o, u(null), c(!1)), () => {
364
+ d.current && clearTimeout(d.current);
365
+ };
366
+ }, [o, t, s, n, e]), {
367
+ debouncedValue: l,
368
+ isDebouncing: f
369
+ };
370
+ }
371
+ const H = 300;
372
+ function C(e) {
373
+ return e ? ["cube", "load", E(e)] : ["cube", "load", null];
374
+ }
375
+ function Y(e) {
376
+ if (!e) return !1;
377
+ const r = !!(e.measures && e.measures.length > 0), t = !!(e.dimensions && e.dimensions.length > 0), s = !!(e.timeDimensions && e.timeDimensions.length > 0);
378
+ return r || t || s;
379
+ }
380
+ function X(e, r = {}) {
381
+ const {
382
+ skip: t = !1,
383
+ debounceMs: s = H,
384
+ resetResultSetOnChange: n = !0,
385
+ staleTime: l = 60 * 1e3,
386
+ keepPreviousData: u = !0
387
+ } = r, { cubeApi: f } = M(), c = x(), d = Y(e), { debouncedValue: a, isDebouncing: i } = I(e, {
388
+ isValid: d,
389
+ skip: t,
390
+ debounceMs: s
391
+ }), o = h(() => a ? q(a) : null, [a]), p = k({
392
+ queryKey: C(o),
393
+ queryFn: async () => {
394
+ if (!o) throw new Error("No query provided");
395
+ return f.load(o);
396
+ },
397
+ enabled: !!o && !t,
398
+ staleTime: l,
399
+ placeholderData: u ? (S) => S : void 0
400
+ }), y = h(() => {
401
+ if (!p.data) return null;
402
+ try {
403
+ return p.data.rawData();
404
+ } catch {
405
+ return null;
406
+ }
407
+ }, [p.data]), Q = () => {
408
+ o && c.refetchQueries({ queryKey: C(o) });
409
+ }, L = () => {
410
+ c.removeQueries({ queryKey: ["cube", "load"] });
411
+ };
412
+ return {
413
+ resultSet: h(() => p.data ?? null, [p.data, i, n]),
414
+ rawData: y,
415
+ isLoading: p.isLoading || i,
416
+ isFetching: p.isFetching,
417
+ isDebouncing: i,
418
+ error: p.error,
419
+ debouncedQuery: a,
420
+ isValidQuery: d,
421
+ refetch: Q,
422
+ clearCache: L
423
+ };
424
+ }
425
+ function O(e) {
426
+ return e.length > 0 && typeof e[0] == "object" && e[0] !== null && "__queryIndex" in e[0];
427
+ }
428
+ function ye(e) {
429
+ if (!O(e)) return [];
430
+ const r = /* @__PURE__ */ new Set();
431
+ for (const t of e) {
432
+ const s = t.__queryLabel;
433
+ typeof s == "string" && r.add(s);
434
+ }
435
+ return Array.from(r);
436
+ }
437
+ function me(e) {
438
+ if (!O(e)) return [];
439
+ const r = /* @__PURE__ */ new Set();
440
+ for (const t of e) {
441
+ const s = t.__queryIndex;
442
+ typeof s == "number" && r.add(s);
443
+ }
444
+ return Array.from(r).sort((t, s) => t - s);
445
+ }
446
+ function Z(e, r, t) {
447
+ const s = [];
448
+ return e.forEach((n, l) => {
449
+ const u = n.rawData(), f = t?.[l] || `Query ${l + 1}`;
450
+ u.forEach((c) => {
451
+ s.push({
452
+ ...c,
453
+ __queryIndex: l,
454
+ __queryLabel: f
455
+ });
456
+ });
457
+ }), s;
458
+ }
459
+ function ee(e, r, t, s) {
460
+ const n = /* @__PURE__ */ new Map();
461
+ return e.forEach((l, u) => {
462
+ const f = l.rawData(), c = r[u].measures || [];
463
+ f.forEach((d) => {
464
+ const a = t.map((o) => String(d[o] ?? "")).join("|");
465
+ if (!n.has(a)) {
466
+ const o = {};
467
+ t.forEach((p) => {
468
+ o[p] = d[p];
469
+ }), n.set(a, o);
470
+ }
471
+ const i = n.get(a);
472
+ c.forEach((o) => {
473
+ o in i || (i[o] = d[o]);
474
+ }), u === 0 && Object.keys(d).forEach((o) => {
475
+ !t.includes(o) && !c.includes(o) && (o in i || (i[o] = d[o]));
476
+ });
477
+ });
478
+ }), Array.from(n.values()).sort((l, u) => {
479
+ const f = String(l[t[0]] ?? ""), c = String(u[t[0]] ?? "");
480
+ return f.localeCompare(c);
481
+ });
482
+ }
483
+ function te(e, r, t, s, n) {
484
+ return e.length === 0 ? [] : e.length === 1 ? e[0].rawData() : t === "merge" && s && s.length > 0 ? ee(e, r, s) : Z(e, r, n);
485
+ }
486
+ function be(e, r) {
487
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
488
+ return e.forEach((l) => {
489
+ l.measures?.forEach((u) => t.add(u)), l.dimensions?.forEach((u) => s.add(u)), l.timeDimensions?.forEach((u) => n.add(u.dimension));
490
+ }), {
491
+ measures: Array.from(t),
492
+ dimensions: Array.from(s),
493
+ timeDimensions: Array.from(n)
494
+ };
495
+ }
496
+ function he(e, r) {
497
+ if (e.measures && e.measures.length > 0) {
498
+ const t = e.measures[0], s = t.split(".");
499
+ return s.length > 1 ? s[s.length - 1] : t;
500
+ }
501
+ return `Query ${r + 1}`;
502
+ }
503
+ function ge(e, r) {
504
+ const t = [];
505
+ return e.forEach((s, n) => {
506
+ [
507
+ ...s.dimensions || [],
508
+ ...s.timeDimensions?.map((u) => u.dimension) || []
509
+ ].includes(r) || t.push(n);
510
+ }), {
511
+ isValid: t.length === 0,
512
+ missingInQueries: t
513
+ };
514
+ }
515
+ const se = 300;
516
+ function F(e) {
517
+ return e ? ["cube", "multiLoad", E(e)] : ["cube", "multiLoad", null];
518
+ }
519
+ function re(e) {
520
+ return !e || !e.queries || e.queries.length < 2 ? !1 : e.queries.filter(
521
+ (t) => t.measures && t.measures.length > 0 || t.dimensions && t.dimensions.length > 0 || t.timeDimensions && t.timeDimensions.length > 0
522
+ ).length >= 2;
523
+ }
524
+ function ve(e, r = {}) {
525
+ const {
526
+ skip: t = !1,
527
+ debounceMs: s = se,
528
+ staleTime: n = 60 * 1e3,
529
+ keepPreviousData: l = !0
530
+ } = r, { cubeApi: u, batchCoordinator: f, enableBatching: c } = M(), d = x(), a = re(e), { debouncedValue: i, isDebouncing: o } = I(e, {
531
+ isValid: a,
532
+ skip: t,
533
+ debounceMs: s
534
+ }), p = h(() => i ? {
535
+ ...i,
536
+ queries: i.queries.map((b) => q(b))
537
+ } : null, [i]), y = k({
538
+ queryKey: F(p),
539
+ queryFn: async () => {
540
+ if (!p) throw new Error("No config provided");
541
+ let b;
542
+ c && f ? b = await Promise.all(
543
+ p.queries.map((m) => f.register(m))
544
+ ) : b = await u.batchLoad(p.queries);
545
+ const T = b.map((m) => m && "error" in m && m.error ? new Error(m.error) : null), P = b.map((m, V) => {
546
+ if (T[V]) return null;
547
+ try {
548
+ return m.rawData();
549
+ } catch {
550
+ return null;
551
+ }
552
+ }), A = b.filter((m, V) => !T[V]), j = p.queries.filter((m, V) => !T[V]);
553
+ return {
554
+ data: A.length > 0 ? te(
555
+ A,
556
+ j,
557
+ p.mergeStrategy,
558
+ p.mergeKeys,
559
+ p.queryLabels
560
+ ) : [],
561
+ resultSets: b,
562
+ perQueryData: P,
563
+ errors: T,
564
+ firstError: T.find((m) => m !== null) || null
565
+ };
566
+ },
567
+ enabled: !!p && !t,
568
+ staleTime: n,
569
+ placeholderData: l ? (b) => b : void 0
570
+ }), Q = () => {
571
+ p && d.refetchQueries({
572
+ queryKey: F(p)
573
+ });
574
+ }, L = y.data?.data ?? null, R = y.data?.resultSets ?? null, S = y.data?.perQueryData ?? null, B = y.data?.errors ?? [], K = y.data?.firstError ?? y.error;
575
+ return {
576
+ data: L,
577
+ resultSets: R,
578
+ perQueryData: S,
579
+ isLoading: y.isLoading || o,
580
+ isFetching: y.isFetching,
581
+ isDebouncing: o,
582
+ error: K,
583
+ errors: B,
584
+ debouncedConfig: i,
585
+ isValidConfig: a,
586
+ refetch: Q
587
+ };
588
+ }
589
+ function W(e) {
590
+ return e ? ["cube", "dryRun", E(e)] : ["cube", "dryRun", null];
591
+ }
592
+ function Te(e, r = {}) {
593
+ const { skip: t = !1, staleTime: s = 300 * 1e3 } = r, { cubeApi: n } = M(), l = h(() => e ? q(e) : null, [e]), u = k({
594
+ queryKey: W(l),
595
+ queryFn: async () => {
596
+ if (!l) throw new Error("No query provided");
597
+ const c = await n.dryRun(l);
598
+ return {
599
+ sql: c.sql,
600
+ analysis: c.analysis
601
+ };
602
+ },
603
+ enabled: !!l && !t,
604
+ staleTime: s
605
+ });
606
+ return {
607
+ debugData: {
608
+ sql: u.data?.sql ?? null,
609
+ analysis: u.data?.analysis ?? null,
610
+ loading: u.isLoading,
611
+ error: u.error ?? null
612
+ },
613
+ refetch: () => u.refetch()
614
+ };
615
+ }
616
+ function ne(e, r = {}) {
617
+ const { skip: t = !1, staleTime: s = 300 * 1e3 } = r, { cubeApi: n } = M(), l = h(() => e.map((a) => q(a)), [e]), u = $({
618
+ queries: l.map((a) => ({
619
+ queryKey: W(a),
620
+ queryFn: async () => {
621
+ const i = await n.dryRun(a);
622
+ return {
623
+ sql: i.sql,
624
+ analysis: i.analysis
625
+ };
626
+ },
627
+ enabled: !t,
628
+ staleTime: s
629
+ }))
630
+ }), f = u.map((a) => ({
631
+ sql: a.data?.sql ?? null,
632
+ analysis: a.data?.analysis ?? null,
633
+ loading: a.isLoading,
634
+ error: a.error ?? null
635
+ })), c = u.some((a) => a.isLoading);
636
+ return {
637
+ debugDataPerQuery: f,
638
+ isLoading: c,
639
+ refetchAll: () => {
640
+ u.forEach((a) => a.refetch());
641
+ }
642
+ };
643
+ }
644
+ function Ve(e) {
645
+ const { queries: r, isMultiQueryMode: t, skip: s = !1, staleTime: n } = e, l = t ? r : r.slice(0, 1);
646
+ return ne(l, { skip: s, staleTime: n });
647
+ }
648
+ function we(e, r = !0) {
649
+ const [t, s] = w(null), n = g(""), {
650
+ resultSet: l,
651
+ isLoading: u,
652
+ error: f
653
+ } = X(t, {
654
+ skip: !t || !r || !e,
655
+ debounceMs: 150,
656
+ // Quick debounce for filter searches
657
+ keepPreviousData: !0
658
+ }), c = h(() => {
659
+ if (!l || u || f || !e)
660
+ return [];
661
+ try {
662
+ const i = l.tablePivot(), o = /* @__PURE__ */ new Set();
663
+ return i.forEach((p) => {
664
+ const y = p[e];
665
+ y != null && y !== "" && o.add(y);
666
+ }), Array.from(o);
667
+ } catch (i) {
668
+ return console.error("Error extracting values from result set:", i), [];
669
+ }
670
+ }, [l, u, f, e]);
671
+ _(() => {
672
+ (!e || !r) && (s(null), n.current = "");
673
+ }, [e, r]);
674
+ const d = v(() => {
675
+ if (e) {
676
+ n.current = "";
677
+ try {
678
+ const i = {
679
+ dimensions: [e],
680
+ limit: 25,
681
+ order: { [e]: "asc" }
682
+ };
683
+ s(i);
684
+ } catch (i) {
685
+ console.error("Error creating query:", i);
686
+ }
687
+ }
688
+ }, [e]), a = v((i, o = !1) => {
689
+ if (e && !(!o && i === n.current)) {
690
+ n.current = i;
691
+ try {
692
+ const p = {
693
+ dimensions: [e],
694
+ limit: 25,
695
+ order: { [e]: "asc" }
696
+ };
697
+ i && i.trim() && (p.filters = [{
698
+ member: e,
699
+ operator: "contains",
700
+ values: [i.trim()]
701
+ }]), s(p);
702
+ } catch (p) {
703
+ console.error("Error creating search query:", p);
704
+ }
705
+ }
706
+ }, [e]);
707
+ return {
708
+ values: c,
709
+ loading: u,
710
+ error: f ? f instanceof Error ? f.message : String(f) : null,
711
+ refetch: d,
712
+ searchValues: a
713
+ };
714
+ }
715
+ function _e(e, r) {
716
+ const [t, s] = w(e);
717
+ return _(() => {
718
+ const n = setTimeout(() => {
719
+ s(e);
720
+ }, r);
721
+ return () => {
722
+ clearTimeout(n);
723
+ };
724
+ }, [e, r]), t;
725
+ }
726
+ const D = 1200, ae = 768;
727
+ function De() {
728
+ const [e, r] = w(
729
+ () => typeof window < "u" ? window.innerWidth : D
730
+ ), t = g(null), s = g(null), n = v((c) => {
731
+ if (t.current && (t.current.disconnect(), t.current = null), s.current = c, c) {
732
+ const d = c.offsetWidth;
733
+ d > 0 && r(d), t.current = new ResizeObserver((a) => {
734
+ const i = a[0]?.contentRect.width;
735
+ i && i > 0 && r(i);
736
+ }), t.current.observe(c);
737
+ }
738
+ }, []);
739
+ _(() => () => {
740
+ t.current && t.current.disconnect();
741
+ }, []), _(() => {
742
+ const c = () => {
743
+ if (s.current) {
744
+ const a = s.current.offsetWidth;
745
+ a > 0 && r(a);
746
+ }
747
+ };
748
+ window.addEventListener("resize", c);
749
+ const d = setTimeout(c, 100);
750
+ return () => {
751
+ window.removeEventListener("resize", c), clearTimeout(d);
752
+ };
753
+ }, []);
754
+ const l = h(() => e >= D ? "desktop" : e >= ae ? "scaled" : "mobile", [e]), u = h(() => l !== "scaled" ? 1 : e / D, [e, l]);
755
+ return {
756
+ containerRef: n,
757
+ containerWidth: e,
758
+ displayMode: l,
759
+ scaleFactor: u,
760
+ isEditable: l === "desktop",
761
+ designWidth: D
762
+ };
763
+ }
764
+ function Me({
765
+ initialConfig: e,
766
+ onConfigChange: r,
767
+ onSave: t,
768
+ onDirtyStateChange: s
769
+ }) {
770
+ const n = g(e), l = g(!1), u = v(
771
+ async (a) => {
772
+ if (l.current) {
773
+ s && s(!0);
774
+ try {
775
+ t && await t(a), n.current = a, s && s(!1);
776
+ } catch (i) {
777
+ throw console.error("Save failed:", i), i;
778
+ }
779
+ }
780
+ },
781
+ [t, s]
782
+ ), f = v(
783
+ (a) => {
784
+ r && r(a);
785
+ const i = JSON.stringify(a), o = JSON.stringify(n.current);
786
+ i !== o && (l.current = !0, s && s(!0));
787
+ },
788
+ [r, s]
789
+ ), c = v(() => l.current, []), d = v((a) => {
790
+ n.current = a, l.current = !1;
791
+ }, []);
792
+ return {
793
+ handleConfigChange: f,
794
+ handleSave: u,
795
+ hasChanged: c,
796
+ resetInitialConfig: d
797
+ };
798
+ }
799
+ export {
800
+ oe as D,
801
+ N as F,
802
+ ve as a,
803
+ Te as b,
804
+ ne as c,
805
+ Ve as d,
806
+ Z as e,
807
+ ee as f,
808
+ be as g,
809
+ ye as h,
810
+ O as i,
811
+ me as j,
812
+ he as k,
813
+ q as l,
814
+ te as m,
815
+ F as n,
816
+ C as o,
817
+ pe as p,
818
+ _e as q,
819
+ ce as r,
820
+ we as s,
821
+ fe as t,
822
+ X as u,
823
+ ge as v,
824
+ de as w,
825
+ De as x,
826
+ Me as y
827
+ };
828
+ //# sourceMappingURL=hooks-CAKGR-w0.js.map