@quillsql/react 2.16.49 → 2.16.50

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.
package/dist/index.js CHANGED
@@ -37,6 +37,89 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  mod
38
38
  ));
39
39
 
40
+ // src/utils/textProcessing.ts
41
+ function capitalize(text) {
42
+ return text.charAt(0).toUpperCase() + text.slice(1);
43
+ }
44
+ function matchCasing(text, template) {
45
+ if (!text || !template) {
46
+ return text ?? "";
47
+ }
48
+ const isTitleCase = (str) => /^[A-Z][a-z]*([A-Z][a-z]*)*$/.test(str);
49
+ const isCamelCase = (str) => /^[a-z]+([A-Z][a-z]*)*$/.test(str);
50
+ const isSnakeCase = (str) => /^[a-z0-9]+(_[a-z0-9]+)*$/.test(str);
51
+ const isAllLowerCase = (str) => /^[a-z]+$/.test(str);
52
+ const isAllUpperCase = (str) => /^[A-Z]+$/.test(str);
53
+ const isCapitalized = (str) => /^[A-Z][a-z]*$/.test(str);
54
+ const isScreamingSnakeCase = (str) => /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/.test(str);
55
+ const toTitleCase = (str) => str.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase());
56
+ const toCamelCase = (str) => str.replace(/_./g, (match) => match.charAt(1).toUpperCase()).toLowerCase();
57
+ const toSnakeCase = (str) => str.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
58
+ const toLowerCase = (str) => str.toLowerCase();
59
+ const toUpperCase = (str) => str.toUpperCase();
60
+ const toCapitalized = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
61
+ const toScreamingSnakeCase = (str) => str.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toUpperCase();
62
+ if (isTitleCase(template)) {
63
+ return toTitleCase(text);
64
+ } else if (isCamelCase(template)) {
65
+ return toCamelCase(text);
66
+ } else if (isSnakeCase(template)) {
67
+ return toSnakeCase(text);
68
+ } else if (isAllLowerCase(template)) {
69
+ return toLowerCase(text);
70
+ } else if (isAllUpperCase(template)) {
71
+ return toUpperCase(text);
72
+ } else if (isCapitalized(template)) {
73
+ return toCapitalized(text);
74
+ } else if (isScreamingSnakeCase(template)) {
75
+ return toScreamingSnakeCase(text);
76
+ } else {
77
+ return text;
78
+ }
79
+ }
80
+ function snakeCaseToTitleCase(str) {
81
+ if (!str) {
82
+ return str;
83
+ }
84
+ return str.toString().split(/_| /).map(
85
+ (word) => word === "id" ? "ID" : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
86
+ ).join(" ");
87
+ }
88
+ function snakeAndCamelCaseToTitleCase(str) {
89
+ if (!str || typeof str !== "string") {
90
+ return str;
91
+ }
92
+ if (str.includes("_")) {
93
+ return str.split(/_| /).map((word) => word === "id" ? "ID" : capitalize(word)).join(" ");
94
+ } else {
95
+ const text = str.replace(/([a-z])([A-Z])/g, "$1 $2");
96
+ const newText = text.split(" ").map((word) => word === "Id" || word === "id" ? "ID" : capitalize(word)).join(" ");
97
+ return newText;
98
+ }
99
+ }
100
+ function formatIdentifierLabel(str) {
101
+ if (!str || typeof str !== "string") {
102
+ return str;
103
+ }
104
+ const hasUnderscore = str.includes("_");
105
+ const hasCamelCaseBoundary = /[a-z0-9][A-Z]/.test(str);
106
+ if (hasUnderscore || hasCamelCaseBoundary) {
107
+ return snakeAndCamelCaseToTitleCase(str);
108
+ }
109
+ return str;
110
+ }
111
+ function removeDoubleQuotes(str) {
112
+ if (!str) {
113
+ return str;
114
+ }
115
+ return str.replace(/"/g, "");
116
+ }
117
+ var init_textProcessing = __esm({
118
+ "src/utils/textProcessing.ts"() {
119
+ "use strict";
120
+ }
121
+ });
122
+
40
123
  // src/utils/valueFormatter.ts
41
124
  import {
42
125
  endOfWeek,
@@ -73,6 +156,7 @@ var DATE_FORMAT_TYPES, NUMBER_FORMAT_TYPES, valueFormatter, quillFormat, quillAu
73
156
  var init_valueFormatter = __esm({
74
157
  "src/utils/valueFormatter.ts"() {
75
158
  "use strict";
159
+ init_textProcessing();
76
160
  DATE_FORMAT_TYPES = [
77
161
  "yyyy",
78
162
  "MMM_yyyy",
@@ -235,7 +319,7 @@ var init_valueFormatter = __esm({
235
319
  if (typeof value === "object") {
236
320
  return JSON.stringify(value);
237
321
  }
238
- return value.toString();
322
+ return formatIdentifierLabel(value.toString());
239
323
  };
240
324
  formatterDollar = new Intl.NumberFormat("en-US", {
241
325
  style: "currency",
@@ -508,78 +592,6 @@ var init_ast = __esm({
508
592
  }
509
593
  });
510
594
 
511
- // src/utils/textProcessing.ts
512
- function capitalize(text) {
513
- return text.charAt(0).toUpperCase() + text.slice(1);
514
- }
515
- function matchCasing(text, template) {
516
- if (!text || !template) {
517
- return text ?? "";
518
- }
519
- const isTitleCase = (str) => /^[A-Z][a-z]*([A-Z][a-z]*)*$/.test(str);
520
- const isCamelCase = (str) => /^[a-z]+([A-Z][a-z]*)*$/.test(str);
521
- const isSnakeCase = (str) => /^[a-z0-9]+(_[a-z0-9]+)*$/.test(str);
522
- const isAllLowerCase = (str) => /^[a-z]+$/.test(str);
523
- const isAllUpperCase = (str) => /^[A-Z]+$/.test(str);
524
- const isCapitalized = (str) => /^[A-Z][a-z]*$/.test(str);
525
- const isScreamingSnakeCase = (str) => /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$/.test(str);
526
- const toTitleCase = (str) => str.toLowerCase().replace(/\b\w/g, (char) => char.toUpperCase());
527
- const toCamelCase = (str) => str.replace(/_./g, (match) => match.charAt(1).toUpperCase()).toLowerCase();
528
- const toSnakeCase = (str) => str.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
529
- const toLowerCase = (str) => str.toLowerCase();
530
- const toUpperCase = (str) => str.toUpperCase();
531
- const toCapitalized = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
532
- const toScreamingSnakeCase = (str) => str.replace(/([A-Z])/g, "_$1").replace(/^_/, "").toUpperCase();
533
- if (isTitleCase(template)) {
534
- return toTitleCase(text);
535
- } else if (isCamelCase(template)) {
536
- return toCamelCase(text);
537
- } else if (isSnakeCase(template)) {
538
- return toSnakeCase(text);
539
- } else if (isAllLowerCase(template)) {
540
- return toLowerCase(text);
541
- } else if (isAllUpperCase(template)) {
542
- return toUpperCase(text);
543
- } else if (isCapitalized(template)) {
544
- return toCapitalized(text);
545
- } else if (isScreamingSnakeCase(template)) {
546
- return toScreamingSnakeCase(text);
547
- } else {
548
- return text;
549
- }
550
- }
551
- function snakeCaseToTitleCase(str) {
552
- if (!str) {
553
- return str;
554
- }
555
- return str.toString().split(/_| /).map(
556
- (word) => word === "id" ? "ID" : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()
557
- ).join(" ");
558
- }
559
- function snakeAndCamelCaseToTitleCase(str) {
560
- if (!str || typeof str !== "string") {
561
- return str;
562
- }
563
- if (str.includes("_")) {
564
- return str.split(/_| /).map((word) => word === "id" ? "ID" : capitalize(word)).join(" ");
565
- } else {
566
- const text = str.replace(/([a-z])([A-Z])/g, "$1 $2");
567
- const newText = text.split(" ").map((word) => word === "Id" || word === "id" ? "ID" : capitalize(word)).join(" ");
568
- return newText;
569
- }
570
- }
571
- function removeDoubleQuotes(str) {
572
- if (!str) {
573
- return str;
574
- }
575
- return str.replace(/"/g, "");
576
- }
577
- var init_textProcessing = __esm({
578
- "src/utils/textProcessing.ts"() {
579
- "use strict";
580
- }
581
- });
582
-
583
595
  // src/components/ReportBuilder/bigDateMap.ts
584
596
  function cleanDateFieldName(fieldName) {
585
597
  if (!fieldName) return void 0;
@@ -15133,6 +15145,63 @@ function getDateString(value, dateRange, dateBucket, databaseType) {
15133
15145
  function isDateField(fieldType) {
15134
15146
  return fieldType === "date" || fieldType === "datetime" || fieldType === "timestamp" || fieldType === "timestamptz" || fieldType === "yyyy" || fieldType === "MMM_yyyy" || fieldType === "MMM_dd" || fieldType === "MMM_dd_yyyy" || fieldType === "MMM_dd_hh:mm_ap_pm" || fieldType === "hh_ap_pm";
15135
15147
  }
15148
+ function getExclusiveDateBucketRange(startInput, bucket) {
15149
+ const parsed = startInput instanceof Date ? startInput : new Date(startInput);
15150
+ if (Number.isNaN(parsed.getTime())) {
15151
+ throw new Error(`Invalid bucket start date: ${String(startInput)}`);
15152
+ }
15153
+ let start;
15154
+ let endExclusive;
15155
+ switch (bucket) {
15156
+ case "day": {
15157
+ start = new Date(
15158
+ Date.UTC(
15159
+ parsed.getUTCFullYear(),
15160
+ parsed.getUTCMonth(),
15161
+ parsed.getUTCDate()
15162
+ )
15163
+ );
15164
+ endExclusive = new Date(start);
15165
+ endExclusive.setUTCDate(endExclusive.getUTCDate() + 1);
15166
+ break;
15167
+ }
15168
+ case "week": {
15169
+ const day = parsed.getUTCDay();
15170
+ start = new Date(
15171
+ Date.UTC(
15172
+ parsed.getUTCFullYear(),
15173
+ parsed.getUTCMonth(),
15174
+ parsed.getUTCDate() - (day + 6) % 7
15175
+ )
15176
+ );
15177
+ endExclusive = new Date(start);
15178
+ endExclusive.setUTCDate(endExclusive.getUTCDate() + 7);
15179
+ break;
15180
+ }
15181
+ case "month": {
15182
+ start = new Date(
15183
+ Date.UTC(parsed.getUTCFullYear(), parsed.getUTCMonth(), 1)
15184
+ );
15185
+ endExclusive = new Date(
15186
+ Date.UTC(parsed.getUTCFullYear(), parsed.getUTCMonth() + 1, 1)
15187
+ );
15188
+ break;
15189
+ }
15190
+ case "year": {
15191
+ start = new Date(Date.UTC(parsed.getUTCFullYear(), 0, 1));
15192
+ endExclusive = new Date(Date.UTC(parsed.getUTCFullYear() + 1, 0, 1));
15193
+ break;
15194
+ }
15195
+ default: {
15196
+ const _exhaustive = bucket;
15197
+ throw new Error(`Unsupported date bucket: ${String(_exhaustive)}`);
15198
+ }
15199
+ }
15200
+ return {
15201
+ start: start.toISOString(),
15202
+ endExclusive: endExclusive.toISOString()
15203
+ };
15204
+ }
15136
15205
  var init_dates = __esm({
15137
15206
  "src/utils/dates.ts"() {
15138
15207
  "use strict";
@@ -17252,7 +17321,7 @@ async function generatePivotWithSQL({
17252
17321
  client,
17253
17322
  task: "pivot-template",
17254
17323
  metadata: {
17255
- clientId: client.clientId,
17324
+ clientId: client.id,
17256
17325
  pivot: pivotConfig,
17257
17326
  reportId: report?.id !== "__quillTempReport" ? report?.id : void 0,
17258
17327
  itemQuery: reportBuilderState ? void 0 : report?.queryString,
@@ -19077,7 +19146,7 @@ var init_tableProcessing = __esm({
19077
19146
  metadata: {
19078
19147
  reportBuilderState,
19079
19148
  stringColumns: stringColumns.map((col) => col.field),
19080
- clientId: client.clientId,
19149
+ clientId: client.id,
19081
19150
  databaseType: client.databaseType?.toLowerCase() || "postgresql",
19082
19151
  customFields,
19083
19152
  filters: void 0,
@@ -19268,7 +19337,7 @@ var init_tableProcessing = __esm({
19268
19337
  metadata: {
19269
19338
  reportBuilderState,
19270
19339
  columns: stringNames,
19271
- clientId: client.publicKey,
19340
+ clientId: client.id,
19272
19341
  databaseType: client.databaseType,
19273
19342
  customFieldsByTable: customFields,
19274
19343
  useNewNodeSql: true,
@@ -19283,7 +19352,7 @@ var init_tableProcessing = __esm({
19283
19352
  task: "query",
19284
19353
  metadata: {
19285
19354
  query: countQuery,
19286
- clientId: client.publicKey,
19355
+ clientId: client.id,
19287
19356
  databaseType: client.databaseType,
19288
19357
  customFieldsByTable: customFields,
19289
19358
  useNewNodeSql: true,
@@ -19343,7 +19412,7 @@ var init_tableProcessing = __esm({
19343
19412
  metadata: {
19344
19413
  reportBuilderState,
19345
19414
  stringColumns: columns,
19346
- clientId: client.clientId,
19415
+ clientId: client.id,
19347
19416
  databaseType: client.databaseType?.toLowerCase() || "postgresql",
19348
19417
  customFields,
19349
19418
  filters,
@@ -19393,7 +19462,7 @@ var init_tableProcessing = __esm({
19393
19462
  task: "query",
19394
19463
  metadata: {
19395
19464
  query,
19396
- clientId: client.publicKey,
19465
+ clientId: client.id,
19397
19466
  databaseType: client.databaseType,
19398
19467
  customFieldsByTable: customFields,
19399
19468
  useNewNodeSql: true,
@@ -19505,7 +19574,7 @@ var init_tableProcessing = __esm({
19505
19574
  task: "query",
19506
19575
  metadata: {
19507
19576
  query,
19508
- clientId: client.publicKey,
19577
+ clientId: client.id,
19509
19578
  databaseType: client.databaseType,
19510
19579
  customFieldsByTable: customFields,
19511
19580
  useNewNodeSql: true,
@@ -19634,7 +19703,7 @@ var init_tableProcessing = __esm({
19634
19703
  metadata: {
19635
19704
  query,
19636
19705
  filterMap,
19637
- clientId: client.publicKey,
19706
+ clientId: client.id,
19638
19707
  databaseType: client?.databaseType,
19639
19708
  customFieldsByTable: customFields,
19640
19709
  additionalProcessing: processing,
@@ -19669,7 +19738,7 @@ var init_tableProcessing = __esm({
19669
19738
  task: "log-broken-query",
19670
19739
  metadata: {
19671
19740
  query,
19672
- clientId: client.clientId,
19741
+ clientId: client.id,
19673
19742
  error: parsingError
19674
19743
  },
19675
19744
  getToken
@@ -19780,7 +19849,7 @@ var init_tableProcessing = __esm({
19780
19849
  metadata: {
19781
19850
  dashboardItemId: reportId,
19782
19851
  filters: minimalFilters,
19783
- clientId: client?.publicKey,
19852
+ clientId: client?.id,
19784
19853
  databaseType: client?.databaseType,
19785
19854
  additionalProcessing: updatedProcessing,
19786
19855
  forcePagination: true,
@@ -19853,7 +19922,7 @@ var init_tableProcessing = __esm({
19853
19922
  rowCountOnly,
19854
19923
  customFields,
19855
19924
  tenants,
19856
- clientId: client.clientId,
19925
+ clientId: client.id,
19857
19926
  databaseType: client.databaseType?.toLowerCase() || "postgresql",
19858
19927
  dashboardName,
19859
19928
  ...reportId ? {
@@ -20024,7 +20093,7 @@ async function testSqlViewState(client, referencedTables, getToken) {
20024
20093
  task: "test-view",
20025
20094
  metadata: {
20026
20095
  tables: [table],
20027
- clientId: client.clientId
20096
+ clientId: client.id
20028
20097
  },
20029
20098
  getToken
20030
20099
  });
@@ -20033,7 +20102,7 @@ async function testSqlViewState(client, referencedTables, getToken) {
20033
20102
  metadata: {
20034
20103
  table,
20035
20104
  task: "set-broken-view",
20036
- clientId: client.clientId
20105
+ clientId: client.id
20037
20106
  }
20038
20107
  };
20039
20108
  quillFetch({
@@ -20143,7 +20212,7 @@ async function* quillStream({
20143
20212
  body: JSON.stringify({
20144
20213
  metadata: {
20145
20214
  task,
20146
- clientId: client.clientId,
20215
+ clientId: client.id,
20147
20216
  ...metadata
20148
20217
  }
20149
20218
  }),
@@ -20372,7 +20441,7 @@ async function getData(client, cloudQueryEndpoint, noCred, hostedRequestBody, cl
20372
20441
  body: method === "POST" ? JSON.stringify({
20373
20442
  ...cloudRequestBody,
20374
20443
  ...{
20375
- publicKey: client?.publicKey
20444
+ publicKey: client?.id
20376
20445
  }
20377
20446
  }) : null,
20378
20447
  signal: abortSignal
@@ -20401,7 +20470,7 @@ async function fetchSqlQuery(ast, client, getToken, formData) {
20401
20470
  client,
20402
20471
  task: "sqlify",
20403
20472
  metadata: {
20404
- clientId: client.clientId,
20473
+ clientId: client.id,
20405
20474
  useNewNodeSql: true,
20406
20475
  ast: { ...ast, where }
20407
20476
  },
@@ -20422,7 +20491,7 @@ async function fetchSqlQueryFromState(reportBuilderState, client, getToken, data
20422
20491
  client,
20423
20492
  task: "sqlify",
20424
20493
  metadata: {
20425
- clientId: client.clientId,
20494
+ clientId: client.id,
20426
20495
  useNewNodeSql: true,
20427
20496
  ast
20428
20497
  },
@@ -20439,7 +20508,7 @@ async function fetchQueryDateRangesFromState(reportBuilderState, columns, client
20439
20508
  client,
20440
20509
  task: "report-builder-date-ranges",
20441
20510
  metadata: {
20442
- clientId: client.clientId,
20511
+ clientId: client.id,
20443
20512
  reportBuilderState,
20444
20513
  dateColumns: columns,
20445
20514
  databaseType: databaseType || "postgresql",
@@ -20557,7 +20626,7 @@ var init_dataFetcher = __esm({
20557
20626
  body: JSON.stringify({
20558
20627
  metadata: {
20559
20628
  task,
20560
- clientId: client.clientId,
20629
+ clientId: client.id ?? client.clientId,
20561
20630
  ...metadata
20562
20631
  }
20563
20632
  }),
@@ -21037,7 +21106,7 @@ import {
21037
21106
  useEffect as useEffect19,
21038
21107
  useState as useState26,
21039
21108
  useMemo as useMemo19,
21040
- useRef as useRef15
21109
+ useRef as useRef16
21041
21110
  } from "react";
21042
21111
 
21043
21112
  // src/Chart.tsx
@@ -21046,7 +21115,7 @@ import {
21046
21115
  useEffect as useEffect16,
21047
21116
  useContext as useContext17,
21048
21117
  useMemo as useMemo16,
21049
- useRef as useRef13
21118
+ useRef as useRef14
21050
21119
  } from "react";
21051
21120
 
21052
21121
  // src/utils/csv.ts
@@ -21528,7 +21597,7 @@ async function getDashboard(dashboardName, client, getToken, tenants, flags) {
21528
21597
  task: "dashboard",
21529
21598
  metadata: {
21530
21599
  name: dashboardName,
21531
- clientId: client.publicKey,
21600
+ clientId: client.id,
21532
21601
  databaseType: client.databaseType,
21533
21602
  useNewNodeSql: true,
21534
21603
  tenants,
@@ -21903,7 +21972,7 @@ function createPivotTemplateMetadata({
21903
21972
  reportId,
21904
21973
  dashboardItemId: reportId,
21905
21974
  ...draftSessionId ? { draftSessionId: String(draftSessionId).trim() } : {},
21906
- clientId: client.publicKey,
21975
+ clientId: client.id,
21907
21976
  databaseType: client.databaseType,
21908
21977
  filters: removeFilterOptions(filters),
21909
21978
  additionalProcessing: normalizedAdditionalProcessing,
@@ -22220,7 +22289,7 @@ async function fetchReportRows({
22220
22289
  task: "report",
22221
22290
  metadata: {
22222
22291
  reportId,
22223
- clientId: client.publicKey,
22292
+ clientId: client.id,
22224
22293
  databaseType: client.databaseType,
22225
22294
  filters: filters.map((filter) => ({ ...filter, options: void 0 })),
22226
22295
  useNewNodeSql: true,
@@ -22290,7 +22359,7 @@ async function fetchReport({
22290
22359
  reportId,
22291
22360
  dashboardItemId: reportId,
22292
22361
  ...draftSessionId ? { draftSessionId: String(draftSessionId).trim() } : {},
22293
- clientId: client.publicKey,
22362
+ clientId: client.id,
22294
22363
  databaseType: client.databaseType,
22295
22364
  filters: filters.map((filter) => ({ ...filter, options: void 0 })),
22296
22365
  customFields,
@@ -22427,7 +22496,7 @@ async function fetchReportName({
22427
22496
  task: "report-name",
22428
22497
  metadata: {
22429
22498
  reportId,
22430
- clientId: client.publicKey,
22499
+ clientId: client.id,
22431
22500
  databaseType: client.databaseType,
22432
22501
  tenants
22433
22502
  },
@@ -22451,7 +22520,7 @@ async function fetchReportRowCount(reportId, client, getToken, tenants, flags, u
22451
22520
  metadata: {
22452
22521
  reportId,
22453
22522
  dashboardItemId: reportId,
22454
- clientId: client.publicKey,
22523
+ clientId: client.id,
22455
22524
  databaseType: client.databaseType,
22456
22525
  filters: filters.map((filter) => ({ ...filter, options: void 0 })),
22457
22526
  customFields,
@@ -22481,7 +22550,7 @@ async function saveReport({
22481
22550
  tenants,
22482
22551
  draftSessionId
22483
22552
  }) {
22484
- const { publicKey, databaseType } = client;
22553
+ const { id, databaseType } = client;
22485
22554
  const {
22486
22555
  reportBuilderState,
22487
22556
  queryString,
@@ -22521,7 +22590,7 @@ async function saveReport({
22521
22590
  ...dashboardItemId ? { reportId: dashboardItemId } : {},
22522
22591
  ...draftSessionId ? { draftSessionId: String(draftSessionId).trim() } : {},
22523
22592
  // Remove useNewNodeSql since backend will handle conversion
22524
- clientId: publicKey,
22593
+ clientId: id,
22525
22594
  tenants,
22526
22595
  // Only include adminMode for 'create' task, not 'create-report'
22527
22596
  ...isCreateTask && { adminMode },
@@ -23335,7 +23404,6 @@ var getSchemaInfo = async ({
23335
23404
  getToken,
23336
23405
  eventTracking
23337
23406
  }) => {
23338
- const { publicKey } = client;
23339
23407
  let customFieldsByTableUnique = null;
23340
23408
  if (client.featureFlags?.customFieldsEnabled && tenants && tenants[0] !== "QUILL_ALL_TENANTS" && tenants.length === 1 && (typeof tenants[0] !== "object" || tenants[0].tenantIds?.[0] !== "QUILL_ALL_TENANTS" && tenants[0].tenantIds?.length === 1)) {
23341
23409
  try {
@@ -23354,13 +23422,13 @@ var getSchemaInfo = async ({
23354
23422
  client,
23355
23423
  task: "schema",
23356
23424
  metadata: {
23357
- clientId: publicKey,
23425
+ clientId: client.id,
23358
23426
  removeCustomerField: true,
23359
23427
  removeCustomFieldRef: true,
23360
23428
  tableIds,
23361
23429
  customFieldsByTable: customFieldsByTableUnique,
23362
23430
  useNewCustomFields: true,
23363
- gatherSchemaData: "665610862cf7a3000be66453" === publicKey ? true : false,
23431
+ gatherSchemaData: "665610862cf7a3000be66453" === client.id ? true : false,
23364
23432
  // TODO: this should be a feature flag on the client
23365
23433
  tenants
23366
23434
  },
@@ -24477,7 +24545,7 @@ var CacheCab = class {
24477
24545
  task: "report",
24478
24546
  metadata: {
24479
24547
  reportId,
24480
- clientId: client.publicKey,
24548
+ clientId: client.id,
24481
24549
  databaseType: client.databaseType,
24482
24550
  filters: adjusted,
24483
24551
  additionalProcessing: { page: { rowsPerPage: 1e3, rowsPerRequest: 1e5 } },
@@ -24616,7 +24684,7 @@ var CacheCab = class {
24616
24684
  );
24617
24685
  const keyParts = [
24618
24686
  reportId,
24619
- client.publicKey,
24687
+ client.id,
24620
24688
  client.databaseType,
24621
24689
  hashString(stableStringify(canonicalizeForKey(tenants ?? null))),
24622
24690
  hashString(stableStringify(canonicalizeForKey(flags ?? null))),
@@ -25254,12 +25322,11 @@ var ContextProvider = ({
25254
25322
  typeof window !== "undefined" && sessionStorage ? JSON.parse(sessionStorage.getItem("quill-client") ?? "null") : null
25255
25323
  );
25256
25324
  const populatedClient = useMemo(() => {
25257
- if (!client || client.clientId !== publicKey) return null;
25325
+ if (!client || client.id !== publicKey) return null;
25258
25326
  return {
25259
25327
  ...client,
25260
- publicKey,
25261
- _id: publicKey,
25262
25328
  id: publicKey,
25329
+ clientId: publicKey,
25263
25330
  queryHeaders,
25264
25331
  queryEndpoint,
25265
25332
  streamEndpoint,
@@ -25422,7 +25489,7 @@ var ContextProvider = ({
25422
25489
  try {
25423
25490
  const result = await quillFetch({
25424
25491
  client: {
25425
- clientId: publicKey,
25492
+ id: publicKey,
25426
25493
  queryEndpoint,
25427
25494
  queryHeaders,
25428
25495
  withCredentials: !!withCredentials
@@ -25544,7 +25611,7 @@ var ContextProvider = ({
25544
25611
  try {
25545
25612
  const resp = await quillFetch({
25546
25613
  client: {
25547
- clientId: publicKey,
25614
+ id: publicKey,
25548
25615
  queryEndpoint,
25549
25616
  queryHeaders,
25550
25617
  withCredentials: !!withCredentials
@@ -25552,7 +25619,7 @@ var ContextProvider = ({
25552
25619
  task: fetchRows ? "report" : "report-info",
25553
25620
  metadata: {
25554
25621
  reportId,
25555
- clientId: populatedClient.publicKey,
25622
+ clientId: populatedClient.id,
25556
25623
  useNewNodeSql: true,
25557
25624
  filters: filters?.map((f) => ({ ...f, options: void 0 })),
25558
25625
  additionalProcessing,
@@ -25735,7 +25802,7 @@ var ContextProvider = ({
25735
25802
  try {
25736
25803
  const result = await quillFetch({
25737
25804
  client: {
25738
- clientId: publicKey,
25805
+ id: publicKey,
25739
25806
  queryEndpoint,
25740
25807
  queryHeaders,
25741
25808
  withCredentials: !!withCredentials
@@ -25955,7 +26022,7 @@ var ContextProvider = ({
25955
26022
  });
25956
26023
  return curDashboardConfig;
25957
26024
  }
25958
- if (!populatedClient || !populatedClient.publicKey) {
26025
+ if (!populatedClient || !populatedClient.id) {
25959
26026
  return curDashboardConfig;
25960
26027
  }
25961
26028
  if (dashboardName === null || dashboardName === void 0)
@@ -26109,7 +26176,7 @@ var ContextProvider = ({
26109
26176
  try {
26110
26177
  const result = await quillFetch({
26111
26178
  client: {
26112
- clientId: publicKey2,
26179
+ id: publicKey2,
26113
26180
  queryEndpoint,
26114
26181
  queryHeaders,
26115
26182
  withCredentials: !!withCredentials
@@ -26652,8 +26719,7 @@ var ContextProvider = ({
26652
26719
  withCredentials: withCredentials ?? false,
26653
26720
  databaseType: envClient.databaseType,
26654
26721
  name: envClient.name,
26655
- clientId: publicKey2,
26656
- publicKey: publicKey2,
26722
+ id: publicKey2,
26657
26723
  featureFlags: envClient.featureFlags,
26658
26724
  clerkOrgId: envClient.clerkOrgId,
26659
26725
  allTenantTypes: hydratedTenantTypes
@@ -26725,16 +26791,16 @@ var ContextProvider = ({
26725
26791
  }, [publicKey]);
26726
26792
  useEffect(() => {
26727
26793
  if (!hasHandledInitialPopulatedClient.current) {
26728
- if (!populatedClient?.publicKey && !populatedClient?.currentTenants) {
26794
+ if (!populatedClient?.id && !populatedClient?.currentTenants) {
26729
26795
  return;
26730
26796
  }
26731
26797
  hasHandledInitialPopulatedClient.current = true;
26732
- currentPublicKey.current = populatedClient?.publicKey ?? null;
26798
+ currentPublicKey.current = populatedClient?.id ?? null;
26733
26799
  currentTenant.current = populatedClient?.currentTenants ?? null;
26734
26800
  return;
26735
26801
  }
26736
26802
  let publicKeyChanged = false;
26737
- if (populatedClient?.publicKey && currentPublicKey.current !== populatedClient?.publicKey) {
26803
+ if (populatedClient?.id && currentPublicKey.current !== populatedClient?.id) {
26738
26804
  publicKeyChanged = true;
26739
26805
  dispatch({ type: "CLEAR_DASHBOARDS" });
26740
26806
  dashboardFiltersDispatch({ type: "CLEAR_DASHBOARD_FILTERS" });
@@ -26743,7 +26809,7 @@ var ContextProvider = ({
26743
26809
  backfilledDashboards.current.clear();
26744
26810
  if (isAdmin) {
26745
26811
  setIsDashboardsLoading(true);
26746
- fetchDashboards(populatedClient?.publicKey);
26812
+ fetchDashboards(populatedClient?.id);
26747
26813
  } else {
26748
26814
  setIsDashboardsLoading(false);
26749
26815
  }
@@ -26775,17 +26841,17 @@ var ContextProvider = ({
26775
26841
  })
26776
26842
  );
26777
26843
  }
26778
- if (populatedClient?.currentTenants && populatedClient?.publicKey) {
26844
+ if (populatedClient?.currentTenants && populatedClient?.id) {
26779
26845
  const tenant = typeof populatedClient?.currentTenants[0] === "object" ? populatedClient?.currentTenants[0]?.tenantField : void 0;
26780
26846
  const tenantIds = tenant && typeof populatedClient?.currentTenants[0] === "object" ? populatedClient?.currentTenants[0]?.tenantIds : populatedClient?.currentTenants;
26781
26847
  eventTracking?.setUser?.({
26782
- clientId: populatedClient.publicKey,
26848
+ clientId: populatedClient.id,
26783
26849
  clerkOrgId: populatedClient.clerkOrgId,
26784
26850
  tenant,
26785
26851
  tenantIds
26786
26852
  });
26787
26853
  }
26788
- }, [populatedClient?.currentTenants, populatedClient?.publicKey]);
26854
+ }, [populatedClient?.currentTenants, populatedClient?.id]);
26789
26855
  if (!theme) {
26790
26856
  return null;
26791
26857
  }
@@ -27100,7 +27166,7 @@ var useDashboardInternal = (dashboardName, customFilters) => {
27100
27166
  });
27101
27167
  const body = {
27102
27168
  task: "set-section-order",
27103
- clientId: client.clientId,
27169
+ clientId: client.id,
27104
27170
  dashboardName,
27105
27171
  sectionOrder
27106
27172
  };
@@ -27328,7 +27394,7 @@ var useDashboards = () => {
27328
27394
  dateFilter,
27329
27395
  name: name2.trim(),
27330
27396
  task: "edit-dashboard",
27331
- clientId: clientId ?? client.clientId,
27397
+ clientId: clientId ?? client.id,
27332
27398
  tenantKeys: dashboardOwners
27333
27399
  };
27334
27400
  try {
@@ -27403,7 +27469,7 @@ var useDashboards = () => {
27403
27469
  initialCacheDateRange,
27404
27470
  name: name2.trim(),
27405
27471
  task: "edit-dashboard",
27406
- clientId: clientId ?? client.clientId,
27472
+ clientId: clientId ?? client.id,
27407
27473
  tenantKeys
27408
27474
  };
27409
27475
  try {
@@ -27581,7 +27647,7 @@ var useDashboards = () => {
27581
27647
  client,
27582
27648
  task: "delete-dashboard",
27583
27649
  metadata: {
27584
- clientId: client.clientId,
27650
+ clientId: client.id,
27585
27651
  databaseType: client.databaseType,
27586
27652
  name: name2
27587
27653
  }
@@ -28426,7 +28492,7 @@ async function getExportData(client, dashboardFilters, reportId, getToken, event
28426
28492
  metadata: {
28427
28493
  reportId,
28428
28494
  dashboardItemId: reportId,
28429
- clientId: client.publicKey,
28495
+ clientId: client.id,
28430
28496
  databaseType: client?.databaseType,
28431
28497
  filters: minimalFilters,
28432
28498
  useNewNodeSql: true,
@@ -29199,6 +29265,69 @@ function linspace(start, end, num) {
29199
29265
  }
29200
29266
  return result;
29201
29267
  }
29268
+ function stableColorIndex(field) {
29269
+ let hash = 0;
29270
+ for (const character of field.replace("comparison_", "")) {
29271
+ hash = Math.imul(hash, 31) + character.charCodeAt(0) >>> 0;
29272
+ }
29273
+ return hash;
29274
+ }
29275
+ function assignStableSeriesColors(fields, colors, knownFields = fields) {
29276
+ const normalize2 = (values) => [
29277
+ ...new Set(
29278
+ values.filter((field) => typeof field === "string").map((field) => field.replace("comparison_", ""))
29279
+ )
29280
+ ];
29281
+ const uniqueFields = normalize2(fields);
29282
+ const universe = normalize2([...knownFields, ...fields]);
29283
+ const result = /* @__PURE__ */ new Map();
29284
+ if (universe.length === 0) {
29285
+ return result;
29286
+ }
29287
+ if (!colors.length) {
29288
+ for (const field of uniqueFields) {
29289
+ result.set(field, "gray");
29290
+ }
29291
+ return result;
29292
+ }
29293
+ const palette = colors.length >= universe.length ? colors : generateArrayFromColor(colors, universe.length);
29294
+ const ordered = [...universe].sort((a, b) => {
29295
+ const diff = stableColorIndex(a) - stableColorIndex(b);
29296
+ return diff !== 0 ? diff : a.localeCompare(b);
29297
+ });
29298
+ const usedIndices = /* @__PURE__ */ new Set();
29299
+ const deferred = [];
29300
+ const assigned = /* @__PURE__ */ new Map();
29301
+ for (const field of ordered) {
29302
+ const preferred = stableColorIndex(field) % palette.length;
29303
+ if (!usedIndices.has(preferred)) {
29304
+ usedIndices.add(preferred);
29305
+ assigned.set(field, palette[preferred]);
29306
+ } else {
29307
+ deferred.push(field);
29308
+ }
29309
+ }
29310
+ for (const field of deferred) {
29311
+ const preferred = stableColorIndex(field) % palette.length;
29312
+ let found = false;
29313
+ for (let offset = 1; offset < palette.length; offset++) {
29314
+ const idx = (preferred + offset) % palette.length;
29315
+ if (!usedIndices.has(idx)) {
29316
+ usedIndices.add(idx);
29317
+ assigned.set(field, palette[idx]);
29318
+ found = true;
29319
+ break;
29320
+ }
29321
+ }
29322
+ if (!found) {
29323
+ assigned.set(field, palette[preferred]);
29324
+ }
29325
+ }
29326
+ for (const field of uniqueFields) {
29327
+ result.set(field, assigned.get(field));
29328
+ }
29329
+ return result;
29330
+ }
29202
29331
  function selectColor(element, colors, index) {
29203
29332
  if (!element?.field) return "gray";
29204
29333
  const isComparison = element.field.includes("comparison_");
@@ -31494,15 +31623,19 @@ var QuillPortal = ({
31494
31623
  };
31495
31624
 
31496
31625
  // src/components/Chart/CustomLegend.tsx
31626
+ init_textProcessing();
31497
31627
  import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
31498
31628
  var getLegendLabel = (entry) => {
31499
31629
  const label = entry?.payload?.name ?? entry?.value ?? entry?.dataKey ?? "";
31500
- return typeof label === "string" ? label : String(label ?? "");
31630
+ return snakeAndCamelCaseToTitleCase(
31631
+ typeof label === "string" ? label : String(label ?? "")
31632
+ );
31501
31633
  };
31502
31634
  var LegendItem = ({
31503
31635
  entry,
31504
31636
  index,
31505
- theme
31637
+ theme,
31638
+ onClick
31506
31639
  }) => /* @__PURE__ */ jsx27(
31507
31640
  "div",
31508
31641
  {
@@ -31511,30 +31644,37 @@ var LegendItem = ({
31511
31644
  alignItems: "baseline",
31512
31645
  marginRight: "1rem"
31513
31646
  },
31514
- children: /* @__PURE__ */ jsxs19("div", { style: { display: "flex", flexDirection: "row", alignItems: "center" }, children: [
31515
- /* @__PURE__ */ jsx27(
31516
- "svg",
31517
- {
31518
- style: { marginRight: "0.5rem" },
31519
- width: "16",
31520
- height: "16",
31521
- viewBox: "0 0 16 16",
31522
- children: /* @__PURE__ */ jsx27("rect", { width: "16", height: "16", rx: "3", fill: entry?.color })
31523
- }
31524
- ),
31525
- /* @__PURE__ */ jsx27(
31526
- "span",
31527
- {
31528
- style: {
31529
- color: theme?.secondaryTextColor,
31530
- fontFamily: theme?.fontFamily,
31531
- fontSize: theme?.fontSizeMedium || "14px",
31532
- whiteSpace: "nowrap"
31533
- },
31534
- children: getLegendLabel(entry)
31535
- }
31536
- )
31537
- ] })
31647
+ onClick: () => onClick ? onClick(entry) : void 0,
31648
+ children: /* @__PURE__ */ jsxs19(
31649
+ "div",
31650
+ {
31651
+ style: { display: "flex", flexDirection: "row", alignItems: "center" },
31652
+ children: [
31653
+ /* @__PURE__ */ jsx27(
31654
+ "svg",
31655
+ {
31656
+ style: { marginRight: "0.5rem" },
31657
+ width: "16",
31658
+ height: "16",
31659
+ viewBox: "0 0 16 16",
31660
+ children: /* @__PURE__ */ jsx27("rect", { width: "16", height: "16", rx: "3", fill: entry?.color })
31661
+ }
31662
+ ),
31663
+ /* @__PURE__ */ jsx27(
31664
+ "span",
31665
+ {
31666
+ style: {
31667
+ color: theme?.secondaryTextColor,
31668
+ fontFamily: theme?.fontFamily,
31669
+ fontSize: theme?.fontSizeMedium || "14px",
31670
+ whiteSpace: "nowrap"
31671
+ },
31672
+ children: getLegendLabel(entry)
31673
+ }
31674
+ )
31675
+ ]
31676
+ }
31677
+ )
31538
31678
  },
31539
31679
  `legend-${index}`
31540
31680
  );
@@ -31548,7 +31688,8 @@ var getOuterWidth = (element) => {
31548
31688
  };
31549
31689
  var RenderLegend = ({
31550
31690
  payload,
31551
- limit
31691
+ limit,
31692
+ onClickLegendElement
31552
31693
  }) => {
31553
31694
  const [theme] = useContext5(ThemeContext);
31554
31695
  const [isOpen, setIsOpen] = useState9(false);
@@ -31561,7 +31702,10 @@ var RenderLegend = ({
31561
31702
  const safePayload = payload ?? [];
31562
31703
  const maxItems = limit ?? safePayload.length;
31563
31704
  const measuredLimit = visibleCount ?? maxItems;
31564
- const visiblePayload = safePayload.slice(0, Math.min(maxItems, measuredLimit));
31705
+ const visiblePayload = safePayload.slice(
31706
+ 0,
31707
+ Math.min(maxItems, measuredLimit)
31708
+ );
31565
31709
  const handleOpen = () => setIsOpen(true);
31566
31710
  const handleClose = () => setIsOpen(false);
31567
31711
  useLayoutEffect2(() => {
@@ -31622,7 +31766,6 @@ var RenderLegend = ({
31622
31766
  visibility: "hidden",
31623
31767
  height: 0,
31624
31768
  overflow: "hidden",
31625
- pointerEvents: "none",
31626
31769
  display: "flex",
31627
31770
  alignItems: "center",
31628
31771
  flexWrap: "nowrap",
@@ -31646,7 +31789,15 @@ var RenderLegend = ({
31646
31789
  ref: (element) => {
31647
31790
  itemRefs.current[index] = element;
31648
31791
  },
31649
- children: /* @__PURE__ */ jsx27(LegendItem, { entry, index, theme })
31792
+ children: /* @__PURE__ */ jsx27(
31793
+ LegendItem,
31794
+ {
31795
+ entry,
31796
+ index,
31797
+ theme,
31798
+ onClick: onClickLegendElement
31799
+ }
31800
+ )
31650
31801
  },
31651
31802
  `legend-measure-${index}`
31652
31803
  ))
@@ -31687,7 +31838,8 @@ var RenderLegend = ({
31687
31838
  {
31688
31839
  entry,
31689
31840
  index,
31690
- theme
31841
+ theme,
31842
+ onClick: onClickLegendElement
31691
31843
  },
31692
31844
  `legend-${index}`
31693
31845
  ))
@@ -31734,7 +31886,8 @@ var RenderLegend = ({
31734
31886
  {
31735
31887
  entry,
31736
31888
  index,
31737
- theme
31889
+ theme,
31890
+ onClick: onClickLegendElement
31738
31891
  },
31739
31892
  `legend-popover-${index}`
31740
31893
  ))
@@ -32006,6 +32159,7 @@ var PieChartWrapper = React4.forwardRef(
32006
32159
  containerStyle,
32007
32160
  theme,
32008
32161
  onClickChartElement,
32162
+ onClickLegendElement,
32009
32163
  yAxisFields,
32010
32164
  showLegend = false,
32011
32165
  ...other
@@ -32102,7 +32256,13 @@ var PieChartWrapper = React4.forwardRef(
32102
32256
  paddingBottom: 20,
32103
32257
  fontFamily: theme?.fontFamily
32104
32258
  },
32105
- content: /* @__PURE__ */ jsx28(RenderLegend, { limit: 5 })
32259
+ content: /* @__PURE__ */ jsx28(
32260
+ RenderLegend,
32261
+ {
32262
+ limit: 5,
32263
+ onClickLegendElement
32264
+ }
32265
+ )
32106
32266
  }
32107
32267
  ),
32108
32268
  /* @__PURE__ */ jsx28(
@@ -32745,6 +32905,7 @@ import {
32745
32905
  } from "recharts";
32746
32906
 
32747
32907
  // src/utils/axisFormatter.ts
32908
+ init_textProcessing();
32748
32909
  import { endOfWeek as endOfWeek2, format as format5, getWeek as getWeek2, isValid as isValid5, startOfWeek as startOfWeek5 } from "date-fns";
32749
32910
  import { utcToZonedTime as utcToZonedTime4 } from "date-fns-tz";
32750
32911
  var axisFormatter = ({ value, field, fields }) => {
@@ -32796,7 +32957,7 @@ var formatString2 = (value) => {
32796
32957
  if (typeof value === "object") {
32797
32958
  return JSON.stringify(value);
32798
32959
  }
32799
- return value.toString();
32960
+ return formatIdentifierLabel(value.toString());
32800
32961
  };
32801
32962
  var formatterDecimal2 = new Intl.NumberFormat("en-US", {
32802
32963
  style: "decimal",
@@ -33003,6 +33164,7 @@ function ChartTooltipRow2({
33003
33164
  }
33004
33165
 
33005
33166
  // src/components/Chart/ChartTooltipGroup.tsx
33167
+ init_textProcessing();
33006
33168
  import { jsx as jsx32, jsxs as jsxs23 } from "react/jsx-runtime";
33007
33169
  function ChartTooltipGroup({
33008
33170
  name: name2,
@@ -33037,7 +33199,7 @@ function ChartTooltipGroup({
33037
33199
  paddingBottom: 2,
33038
33200
  textTransform: "capitalize"
33039
33201
  },
33040
- children: name2.replaceAll("_", " ").toLowerCase()
33202
+ children: formatIdentifierLabel(name2)
33041
33203
  }
33042
33204
  ),
33043
33205
  items.map(({ color, value, name: name3 }, idx) => /* @__PURE__ */ jsx32(
@@ -33058,6 +33220,7 @@ function ChartTooltipGroup({
33058
33220
 
33059
33221
  // src/components/Chart/ChartTooltip.tsx
33060
33222
  init_dates();
33223
+ init_textProcessing();
33061
33224
  import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
33062
33225
  var ChartTooltipPrimary = (props) => /* @__PURE__ */ jsxs24(ChartTooltipFrame2, { theme: props.theme, children: [
33063
33226
  /* @__PURE__ */ jsx33(
@@ -33092,7 +33255,7 @@ var ChartTooltipPrimary = (props) => /* @__PURE__ */ jsxs24(ChartTooltipFrame2,
33092
33255
  paddingTop: 2,
33093
33256
  paddingBottom: 2
33094
33257
  },
33095
- children: !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? format6(new Date(props.label), "MMM yyyy") : props.label
33258
+ children: !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? format6(new Date(props.label), "MMM yyyy") : formatIdentifierLabel(props.label)
33096
33259
  }
33097
33260
  )
33098
33261
  }
@@ -33175,7 +33338,7 @@ function reformatComparisonPayload(props, primaryLabel, comparisonLabel) {
33175
33338
  return columnsByKey;
33176
33339
  }
33177
33340
  function getTooltipLabel(props, altTooltipLabel, isDateXAxis) {
33178
- return props.payload.length <= 2 && altTooltipLabel && isDateXAxis ? !isNaN(new Date(altTooltipLabel)) && props.dateFormatter ? props.dateFormatter(altTooltipLabel) : !isNaN(new Date(altTooltipLabel)) ? format6(new Date(altTooltipLabel), "MMM yyyy") : altTooltipLabel : !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? format6(new Date(props.label), "MMM yyyy") : props.label;
33341
+ return props.payload.length <= 2 && altTooltipLabel && isDateXAxis ? !isNaN(new Date(altTooltipLabel)) && props.dateFormatter ? props.dateFormatter(altTooltipLabel) : !isNaN(new Date(altTooltipLabel)) ? format6(new Date(altTooltipLabel), "MMM yyyy") : formatIdentifierLabel(altTooltipLabel) : !isNaN(new Date(props.label)) && props.dateFormatter ? props.dateFormatter(props.label) : !isNaN(new Date(props.label)) ? format6(new Date(props.label), "MMM yyyy") : formatIdentifierLabel(props.label);
33179
33342
  }
33180
33343
  function ChartTooltipComparison(props) {
33181
33344
  const isDateXAxis = isDateFormat2(props.xAxisFormat);
@@ -33431,6 +33594,7 @@ function CustomReferenceLine({
33431
33594
 
33432
33595
  // src/components/Chart/LineChart.tsx
33433
33596
  init_columnProcessing();
33597
+ init_textProcessing();
33434
33598
  import { jsx as jsx35, jsxs as jsxs26 } from "react/jsx-runtime";
33435
33599
  function createLineForEmptyChart(yAxisFields, dateFilter, xAxisField, xAxisFormat) {
33436
33600
  let lineChartData = [];
@@ -33467,6 +33631,8 @@ function LineChart({
33467
33631
  cartesianGridLineColor,
33468
33632
  onClickChartElement = () => {
33469
33633
  },
33634
+ onClickLegendElement = () => {
33635
+ },
33470
33636
  dateFilter,
33471
33637
  referenceLines,
33472
33638
  showLegend = false
@@ -33563,7 +33729,7 @@ function LineChart({
33563
33729
  paddingBottom: 20,
33564
33730
  fontFamily: theme?.fontFamily
33565
33731
  },
33566
- content: /* @__PURE__ */ jsx35(RenderLegend, {})
33732
+ content: /* @__PURE__ */ jsx35(RenderLegend, { onClickLegendElement })
33567
33733
  }
33568
33734
  ),
33569
33735
  /* @__PURE__ */ jsx35(
@@ -33651,7 +33817,9 @@ function LineChart({
33651
33817
  color: p.color || "black",
33652
33818
  chartType: "line",
33653
33819
  dataKey: p.dataKey?.toLocaleString() || "",
33654
- name: name2 || p.name?.toString() || "",
33820
+ name: snakeAndCamelCaseToTitleCase(
33821
+ name2 || p.name?.toString() || ""
33822
+ ),
33655
33823
  payload: p.payload || {},
33656
33824
  type: p.type || "none",
33657
33825
  unit: "string",
@@ -33744,6 +33912,7 @@ function LineChart({
33744
33912
  Area,
33745
33913
  {
33746
33914
  type: "linear",
33915
+ name: elem.label || elem.field,
33747
33916
  dataKey: elem.field,
33748
33917
  stroke: getCustomColor(index, elem.field) ?? selectColor(elem, colors, index - numComparisons),
33749
33918
  fill: `url(#${uniqueId})`,
@@ -33774,6 +33943,7 @@ import {
33774
33943
  Tooltip as Tooltip3
33775
33944
  } from "recharts";
33776
33945
  import { useMemo as useMemo6 } from "react";
33946
+ init_textProcessing();
33777
33947
  import { jsx as jsx36, jsxs as jsxs27 } from "react/jsx-runtime";
33778
33948
  function RadarChart({
33779
33949
  colors,
@@ -33789,6 +33959,8 @@ function RadarChart({
33789
33959
  isAnimationActive = true,
33790
33960
  onClickChartElement = () => {
33791
33961
  },
33962
+ onClickLegendElement = () => {
33963
+ },
33792
33964
  dateFilter,
33793
33965
  showLegend = false
33794
33966
  }) {
@@ -33882,7 +34054,7 @@ function RadarChart({
33882
34054
  paddingBottom: 20,
33883
34055
  fontFamily: theme?.fontFamily
33884
34056
  },
33885
- content: /* @__PURE__ */ jsx36(RenderLegend, {})
34057
+ content: /* @__PURE__ */ jsx36(RenderLegend, { onClickLegendElement })
33886
34058
  }
33887
34059
  ),
33888
34060
  /* @__PURE__ */ jsx36(
@@ -33917,7 +34089,9 @@ function RadarChart({
33917
34089
  color: p.color || "black",
33918
34090
  chartType: "radar",
33919
34091
  dataKey: p.dataKey?.toLocaleString() || "",
33920
- name: name2 || p.name?.toString() || "",
34092
+ name: snakeAndCamelCaseToTitleCase(
34093
+ name2 || p.name?.toString() || ""
34094
+ ),
33921
34095
  payload: p.payload || {},
33922
34096
  type: p.type || "none",
33923
34097
  unit: "string",
@@ -34034,6 +34208,10 @@ var CustomBar = memo((props) => {
34034
34208
  width: rawWidth,
34035
34209
  height: rawHeight,
34036
34210
  fill,
34211
+ fillOpacity,
34212
+ stroke,
34213
+ strokeWidth,
34214
+ style,
34037
34215
  yAxisFields = [],
34038
34216
  dataKey,
34039
34217
  payload = {},
@@ -34091,18 +34269,43 @@ var CustomBar = memo((props) => {
34091
34269
  rawY,
34092
34270
  radius
34093
34271
  ]);
34094
- return /* @__PURE__ */ jsx37("path", { d: path, fill });
34272
+ return /* @__PURE__ */ jsx37(
34273
+ "path",
34274
+ {
34275
+ d: path,
34276
+ fill,
34277
+ fillOpacity,
34278
+ stroke,
34279
+ strokeWidth,
34280
+ style
34281
+ }
34282
+ );
34095
34283
  });
34096
34284
  CustomBar.displayName = "CustomBar";
34097
34285
  var CustomBar_default = CustomBar;
34098
34286
 
34099
34287
  // src/components/Chart/BarChart.tsx
34100
34288
  init_columnProcessing();
34101
- import { useMemo as useMemo8 } from "react";
34289
+ init_textProcessing();
34290
+ import { useMemo as useMemo8, useRef as useRef6 } from "react";
34102
34291
  import { Fragment as Fragment3, jsx as jsx38, jsxs as jsxs28 } from "react/jsx-runtime";
34103
34292
  var CATEGORY_AXIS_WIDTH = 120;
34104
34293
  var VALUE_AXIS_WIDTH = 44;
34105
34294
  var STACKED_DOMAIN_HEADROOM = 1.05;
34295
+ function rowValueFromPivotRow(row, xAxisField, fallbackLabel) {
34296
+ const rawDate = row?.__quillRawDate;
34297
+ if (rawDate != null && rawDate !== "") {
34298
+ return String(rawDate);
34299
+ }
34300
+ const category = row?.[xAxisField];
34301
+ if (category != null && category !== "") {
34302
+ return String(category);
34303
+ }
34304
+ if (fallbackLabel != null && fallbackLabel !== "") {
34305
+ return String(fallbackLabel);
34306
+ }
34307
+ return null;
34308
+ }
34106
34309
  function getStackedDomain(data, fields, comparison) {
34107
34310
  const fieldsArray = fields.filter((field) => comparison || !field.field.startsWith("comparison_")).map((field) => field.field);
34108
34311
  if (fieldsArray.length === 0 || data.length === 0) {
@@ -34124,14 +34327,16 @@ function getStackedDomain(data, fields, comparison) {
34124
34327
  }
34125
34328
  return [0, maxStack * STACKED_DOMAIN_HEADROOM];
34126
34329
  }
34127
- var createCustomBar = (yAxisFields, theme, layout) => {
34330
+ var createCustomBar = (yAxisFields, theme, layout, active = false) => {
34128
34331
  return (props) => /* @__PURE__ */ jsx38(
34129
34332
  CustomBar_default,
34130
34333
  {
34131
34334
  ...props,
34132
34335
  yAxisFields,
34133
34336
  theme,
34134
- layout
34337
+ layout,
34338
+ stroke: active ? theme?.primaryTextColor ?? "#111827" : props.stroke,
34339
+ strokeWidth: active ? 1.5 : props.strokeWidth
34135
34340
  }
34136
34341
  );
34137
34342
  };
@@ -34152,6 +34357,7 @@ function BarChart({
34152
34357
  hideYAxis = false,
34153
34358
  hideCartesianGrid = false,
34154
34359
  onClickChartElement,
34360
+ onClickLegendElement,
34155
34361
  dateFilter,
34156
34362
  referenceLines,
34157
34363
  showLegend = false,
@@ -34181,6 +34387,21 @@ function BarChart({
34181
34387
  () => stackedMode ? getStackedDomain(data, yAxisFields, comparison) : getDomain(data, yAxisFields, referenceLines),
34182
34388
  [stackedMode, data, yAxisFields, referenceLines, comparison]
34183
34389
  );
34390
+ const knownSeriesFieldsRef = useRef6([]);
34391
+ const knownColorsKeyRef = useRef6("");
34392
+ const seriesColorByField = useMemo8(() => {
34393
+ const visibleFields = yAxisFields.filter((field) => comparison || !field.field.startsWith("comparison_")).map((field) => field.field);
34394
+ const colorsKey = colors.join("\0");
34395
+ if (knownColorsKeyRef.current !== colorsKey) {
34396
+ knownSeriesFieldsRef.current = [];
34397
+ knownColorsKeyRef.current = colorsKey;
34398
+ }
34399
+ const knownFields = [
34400
+ .../* @__PURE__ */ new Set([...knownSeriesFieldsRef.current, ...visibleFields])
34401
+ ];
34402
+ knownSeriesFieldsRef.current = knownFields;
34403
+ return assignStableSeriesColors(visibleFields, colors, knownFields);
34404
+ }, [yAxisFields, colors, comparison]);
34184
34405
  const allowDecimals = useMemo8(
34185
34406
  () => getAllowDecimals(data, yAxisFields, referenceLines),
34186
34407
  [data, yAxisFields, referenceLines]
@@ -34204,6 +34425,16 @@ function BarChart({
34204
34425
  return void 0;
34205
34426
  return createCustomBar(sortYAxisFields([...yAxisFields]), theme, layout);
34206
34427
  }, [isStacked, yAxisFields, theme, layout]);
34428
+ const customActiveBarShape = useMemo8(() => {
34429
+ if (!theme?.barChartCornerRadius && !theme?.barChartCornerRadiusRatio)
34430
+ return void 0;
34431
+ return createCustomBar(
34432
+ sortYAxisFields([...yAxisFields]),
34433
+ theme,
34434
+ layout,
34435
+ true
34436
+ );
34437
+ }, [isStacked, yAxisFields, theme, layout]);
34207
34438
  if (!data || data.length === 0) {
34208
34439
  return /* @__PURE__ */ jsx38(
34209
34440
  "div",
@@ -34245,9 +34476,28 @@ function BarChart({
34245
34476
  {
34246
34477
  data: data ?? [],
34247
34478
  layout,
34248
- onClick: (event) => onClickChartElement ? onClickChartElement(
34249
- event?.activePayload ? event.activePayload[0].payload : void 0
34250
- ) : void 0,
34479
+ onClick: (event) => {
34480
+ if (!onClickChartElement || event?.activeLabel === void 0 || event?.activeTooltipIndex === void 0) {
34481
+ return;
34482
+ }
34483
+ const index = Number(event.activeTooltipIndex);
34484
+ const row = event.activePayload?.[0]?.payload ?? data[index] ?? {};
34485
+ onClickChartElement({
34486
+ ...row,
34487
+ interactionType: "bucket",
34488
+ activeLabel: event.activeLabel,
34489
+ rowValue: rowValueFromPivotRow(row, xAxisField, event.activeLabel),
34490
+ columnValue: void 0,
34491
+ activeDataKey: void 0,
34492
+ activeValue: void 0,
34493
+ activePayload: event.activePayload ?? [],
34494
+ category: event.activeLabel,
34495
+ series: void 0,
34496
+ value: void 0,
34497
+ row,
34498
+ index
34499
+ });
34500
+ },
34251
34501
  children: [
34252
34502
  !hideCartesianGrid && /* @__PURE__ */ jsx38(
34253
34503
  CartesianGrid2,
@@ -34267,7 +34517,7 @@ function BarChart({
34267
34517
  wrapperStyle: {
34268
34518
  paddingBottom: 20
34269
34519
  },
34270
- content: /* @__PURE__ */ jsx38(RenderLegend, {})
34520
+ content: /* @__PURE__ */ jsx38(RenderLegend, { onClickLegendElement })
34271
34521
  }
34272
34522
  ),
34273
34523
  isHorizontalBars ? /* @__PURE__ */ jsxs28(Fragment3, { children: [
@@ -34346,11 +34596,13 @@ function BarChart({
34346
34596
  {
34347
34597
  wrapperStyle: { outline: "none", zIndex: 2 },
34348
34598
  isAnimationActive: false,
34349
- cursor: { fill: "#d1d5db", opacity: "0.15" },
34599
+ cursor: false,
34600
+ shared: false,
34350
34601
  content: ({ active, payload, label }) => {
34351
34602
  if (!payload || payload.length === 0) {
34352
34603
  return null;
34353
34604
  }
34605
+ const activeLabel = label ?? payload[0]?.payload?.[xAxisField] ?? "";
34354
34606
  const payloadItems = payload.map((p) => {
34355
34607
  const rawName = yAxisFields?.find(
34356
34608
  (f) => f.field === p.name?.toString()
@@ -34361,7 +34613,9 @@ function BarChart({
34361
34613
  color: p.color || "black",
34362
34614
  chartType: "line",
34363
34615
  dataKey: p.dataKey?.toLocaleString() || "",
34364
- name: name2 || p.name?.toString() || "",
34616
+ name: snakeAndCamelCaseToTitleCase(
34617
+ name2 || p.name?.toString() || ""
34618
+ ),
34365
34619
  payload: p.payload || {},
34366
34620
  type: p.type || "none",
34367
34621
  unit: "string",
@@ -34374,7 +34628,7 @@ function BarChart({
34374
34628
  theme,
34375
34629
  active,
34376
34630
  payload: payloadItems,
34377
- label,
34631
+ label: `${activeLabel}`,
34378
34632
  dateFormatter: (value) => valueFormatter({
34379
34633
  value,
34380
34634
  field: xAxisField,
@@ -34406,21 +34660,55 @@ function BarChart({
34406
34660
  return /* @__PURE__ */ jsx38(
34407
34661
  Bar,
34408
34662
  {
34663
+ name: elem.label || elem.field,
34409
34664
  dataKey: elem.field,
34410
34665
  stackId: stackedMode ? "same_id" : isStacked ? elem.field.replace("comparison_", "") : void 0,
34411
34666
  type: "linear",
34412
34667
  fill: getCustomColor(elem.field) ?? selectColor(
34413
34668
  elem,
34414
- colors.length >= yAxisFields.length / (comparison ? 2 : 1) ? colors : generateArrayFromColor(
34415
- colors.slice(0, 2),
34416
- yAxisFields.length
34417
- ),
34418
- yAxisFields.findIndex(
34419
- (field) => field.field === elem.field?.replace("comparison_", "")
34420
- )
34669
+ [
34670
+ seriesColorByField.get(
34671
+ elem.field.replace("comparison_", "")
34672
+ ) ?? colors[0] ?? "gray"
34673
+ ],
34674
+ 0
34421
34675
  ),
34422
34676
  isAnimationActive,
34423
- shape: customBarShape
34677
+ shape: customBarShape,
34678
+ activeBar: customActiveBarShape ?? {
34679
+ fillOpacity: 1,
34680
+ stroke: theme?.primaryTextColor ?? "#111827",
34681
+ strokeWidth: 1.5
34682
+ },
34683
+ style: {
34684
+ cursor: onClickChartElement ? "pointer" : void 0
34685
+ },
34686
+ onClick: (bar, index, event) => {
34687
+ event?.stopPropagation();
34688
+ const payload = bar.payload ?? data[index] ?? {};
34689
+ onClickChartElement?.({
34690
+ ...payload,
34691
+ interactionType: "bar",
34692
+ activeLabel: payload[xAxisField],
34693
+ rowValue: rowValueFromPivotRow(payload, xAxisField),
34694
+ columnValue: elem.field,
34695
+ activeDataKey: elem.field,
34696
+ activeValue: payload[elem.field] ?? bar.value,
34697
+ activePayload: [
34698
+ {
34699
+ dataKey: elem.field,
34700
+ name: elem.label || elem.field,
34701
+ payload,
34702
+ value: payload[elem.field] ?? bar.value
34703
+ }
34704
+ ],
34705
+ category: payload[xAxisField],
34706
+ series: elem.field,
34707
+ value: payload[elem.field] ?? bar.value,
34708
+ row: payload,
34709
+ index
34710
+ });
34711
+ }
34424
34712
  },
34425
34713
  elem.field
34426
34714
  );
@@ -34578,7 +34866,7 @@ import { useMemo as useMemo12 } from "react";
34578
34866
  import {
34579
34867
  useContext as useContext9,
34580
34868
  useEffect as useEffect10,
34581
- useRef as useRef7,
34869
+ useRef as useRef8,
34582
34870
  useState as useState12
34583
34871
  } from "react";
34584
34872
  import {
@@ -34601,7 +34889,7 @@ import {
34601
34889
  import {
34602
34890
  useContext as useContext8,
34603
34891
  useMemo as useMemo9,
34604
- useRef as useRef6,
34892
+ useRef as useRef7,
34605
34893
  useState as useState11,
34606
34894
  useEffect as useEffect9
34607
34895
  } from "react";
@@ -34620,8 +34908,8 @@ function QuillSelectComponent({
34620
34908
  }) {
34621
34909
  const [theme] = useContext8(ThemeContext);
34622
34910
  const [showModal, setShowModal] = useState11(false);
34623
- const modalRef = useRef6(null);
34624
- const buttonRef = useRef6(null);
34911
+ const modalRef = useRef7(null);
34912
+ const buttonRef = useRef7(null);
34625
34913
  useOnClickOutside_default(
34626
34914
  modalRef,
34627
34915
  (event) => {
@@ -34646,7 +34934,7 @@ function QuillSelectComponent({
34646
34934
  }, [sortedItems]);
34647
34935
  const [popoverPosition, setPopoverPosition] = useState11(void 0);
34648
34936
  const [z, setZ] = useState11(10);
34649
- const scrollableParentRef = useRef6(document.body);
34937
+ const scrollableParentRef = useRef7(document.body);
34650
34938
  const updatePosition = () => {
34651
34939
  if (buttonRef.current) {
34652
34940
  requestAnimationFrame(() => {
@@ -34971,8 +35259,8 @@ function QuillDateRangePicker({
34971
35259
  );
34972
35260
  const [localPreset, setLocalPreset] = useState12(preset);
34973
35261
  const [showModal, setShowModal] = useState12(false);
34974
- const buttonRef = useRef7(null);
34975
- const modalRef = useRef7(null);
35262
+ const buttonRef = useRef8(null);
35263
+ const modalRef = useRef8(null);
34976
35264
  useEffect10(() => {
34977
35265
  setLocalEndDate(dateRange.endDate);
34978
35266
  setLocalStartDate(dateRange.startDate);
@@ -35488,7 +35776,7 @@ import React7, {
35488
35776
  useContext as useContext10,
35489
35777
  useEffect as useEffect11,
35490
35778
  useMemo as useMemo10,
35491
- useRef as useRef8,
35779
+ useRef as useRef9,
35492
35780
  useState as useState13
35493
35781
  } from "react";
35494
35782
  import { createPortal as createPortal3 } from "react-dom";
@@ -35508,15 +35796,15 @@ function QuillMultiSelectComponentWithCombo({
35508
35796
  const [theme] = useContext10(ThemeContext);
35509
35797
  const [selectedOptions, setSelectedOptions] = useState13([]);
35510
35798
  const [showModal, setShowModal] = useState13(false);
35511
- const modalRef = useRef8(null);
35512
- const buttonRef = useRef8(null);
35513
- const debounceTimeoutId = useRef8(null);
35799
+ const modalRef = useRef9(null);
35800
+ const buttonRef = useRef9(null);
35801
+ const debounceTimeoutId = useRef9(null);
35514
35802
  const [searchQuery, setSearchQuery] = React7.useState("");
35515
35803
  const [exceedsLimit, setExceedsLimit] = useState13(false);
35516
35804
  const [popoverPosition, setPopoverPosition] = useState13(void 0);
35517
35805
  const [z, setZ] = useState13(10);
35518
- const scrollableParentRef = useRef8(document.body);
35519
- const selectAllRef = useRef8(null);
35806
+ const scrollableParentRef = useRef9(document.body);
35807
+ const selectAllRef = useRef9(null);
35520
35808
  let CheckboxState;
35521
35809
  ((CheckboxState2) => {
35522
35810
  CheckboxState2[CheckboxState2["SELECTED"] = 0] = "SELECTED";
@@ -36153,7 +36441,7 @@ var ListboxTextInput = ({
36153
36441
  import React8, {
36154
36442
  useContext as useContext11,
36155
36443
  useMemo as useMemo11,
36156
- useRef as useRef9,
36444
+ useRef as useRef10,
36157
36445
  useState as useState14
36158
36446
  } from "react";
36159
36447
  import { jsx as jsx43, jsxs as jsxs33 } from "react/jsx-runtime";
@@ -36170,8 +36458,8 @@ function QuillSelectComponentWithCombo({
36170
36458
  }) {
36171
36459
  const [theme] = useContext11(ThemeContext);
36172
36460
  const [showModal, setShowModal] = useState14(false);
36173
- const modalRef = useRef9(null);
36174
- const buttonRef = useRef9(null);
36461
+ const modalRef = useRef10(null);
36462
+ const buttonRef = useRef10(null);
36175
36463
  const [searchQuery, setSearchQuery] = React8.useState("");
36176
36464
  const filteredItems = React8.useMemo(() => {
36177
36465
  if (searchQuery === "") {
@@ -37128,7 +37416,7 @@ var MetricDisplay = ({
37128
37416
  };
37129
37417
 
37130
37418
  // src/components/Dashboard/DataLoader.tsx
37131
- import { useContext as useContext13, useEffect as useEffect12, useMemo as useMemo13, useRef as useRef10, useState as useState15 } from "react";
37419
+ import { useContext as useContext13, useEffect as useEffect12, useMemo as useMemo13, useRef as useRef11, useState as useState15 } from "react";
37132
37420
  init_paginationProcessing();
37133
37421
  init_tableProcessing();
37134
37422
  import equal2 from "fast-deep-equal";
@@ -37268,17 +37556,17 @@ function DataLoader({
37268
37556
  reportFilters,
37269
37557
  dashboardFilters
37270
37558
  ]);
37271
- const previousFilters = useRef10(filters);
37272
- const previousUserFilters = useRef10(userFilters);
37273
- const previousTenants = useRef10(tenants);
37274
- const previousCustomFields = useRef10(schemaData.customFields);
37559
+ const previousFilters = useRef11(filters);
37560
+ const previousUserFilters = useRef11(userFilters);
37561
+ const previousTenants = useRef11(tenants);
37562
+ const previousCustomFields = useRef11(schemaData.customFields);
37275
37563
  const [rowCountIsLoading, setRowCountIsLoading] = useState15(false);
37276
- const rowsRequestId = useRef10(0);
37277
- const rowsAbortController = useRef10(null);
37278
- const rowCountRequestId = useRef10(0);
37279
- const rowCountAbortController = useRef10(null);
37280
- const updateTableRowsRequestId = useRef10(0);
37281
- const updateTableRowsAbortController = useRef10(null);
37564
+ const rowsRequestId = useRef11(0);
37565
+ const rowsAbortController = useRef11(null);
37566
+ const rowCountRequestId = useRef11(0);
37567
+ const rowCountAbortController = useRef11(null);
37568
+ const updateTableRowsRequestId = useRef11(0);
37569
+ const updateTableRowsAbortController = useRef11(null);
37282
37570
  const fetchRowCount = async (processing) => {
37283
37571
  if (!client || !filters) {
37284
37572
  if (!rowCountAbortController.current) return;
@@ -37678,13 +37966,13 @@ var ChartDataLoader = ({
37678
37966
  const [error, setError] = useState15(void 0);
37679
37967
  const [client] = useContext13(ClientContext);
37680
37968
  const [schemaData] = useContext13(SchemaDataContext);
37681
- const previousFilters = useRef10(filters);
37682
- const previousUserFilters = useRef10(userFilters);
37683
- const previousDateBucket = useRef10(dateBucket);
37684
- const previousTenants = useRef10(tenants);
37685
- const previousCustomFields = useRef10(schemaData.customFields);
37686
- const fetchReportAbortController = useRef10(null);
37687
- const rowsRequestId = useRef10(0);
37969
+ const previousFilters = useRef11(filters);
37970
+ const previousUserFilters = useRef11(userFilters);
37971
+ const previousDateBucket = useRef11(dateBucket);
37972
+ const previousTenants = useRef11(tenants);
37973
+ const previousCustomFields = useRef11(schemaData.customFields);
37974
+ const fetchReportAbortController = useRef11(null);
37975
+ const rowsRequestId = useRef11(0);
37688
37976
  const chartReport = useMemo13(() => {
37689
37977
  const report = dashboardName ? dashboard[item.id] : reports[item.id];
37690
37978
  if (!report) {
@@ -37959,7 +38247,7 @@ var useReportInternal = (reportId) => {
37959
38247
  import equal3 from "fast-deep-equal";
37960
38248
 
37961
38249
  // src/components/Chart/MapChart.tsx
37962
- import { useEffect as useEffect13, useMemo as useMemo15, useRef as useRef11, useState as useState17 } from "react";
38250
+ import { useEffect as useEffect13, useMemo as useMemo15, useRef as useRef12, useState as useState17 } from "react";
37963
38251
  init_valueFormatter();
37964
38252
  import usStates10m from "us-atlas/states-10m.json";
37965
38253
  import worldCountries50m from "world-atlas/countries-50m.json";
@@ -38573,7 +38861,7 @@ function USMap({
38573
38861
  containerStyle
38574
38862
  }) {
38575
38863
  const simpleMaps = useSimpleMapsModule();
38576
- const containerRef = useRef11(null);
38864
+ const containerRef = useRef12(null);
38577
38865
  const [hoveredState, setHoveredState] = useState17(
38578
38866
  void 0
38579
38867
  );
@@ -38769,7 +39057,7 @@ function WorldMap({
38769
39057
  containerStyle
38770
39058
  }) {
38771
39059
  const simpleMaps = useSimpleMapsModule();
38772
- const containerRef = useRef11(null);
39060
+ const containerRef = useRef12(null);
38773
39061
  const [hoveredCountry, setHoveredCountry] = useState17(
38774
39062
  void 0
38775
39063
  );
@@ -39020,7 +39308,7 @@ function MapLayout({
39020
39308
  }
39021
39309
 
39022
39310
  // src/components/Chart/GaugeChart.tsx
39023
- import { useEffect as useEffect14, useRef as useRef12, useState as useState18 } from "react";
39311
+ import { useEffect as useEffect14, useRef as useRef13, useState as useState18 } from "react";
39024
39312
  import { jsx as jsx48 } from "react/jsx-runtime";
39025
39313
  function GaugeChart({
39026
39314
  data,
@@ -39052,15 +39340,15 @@ function D3Gauge({
39052
39340
  colors,
39053
39341
  isAnimationActive
39054
39342
  }) {
39055
- const containerRef = useRef12(null);
39056
- const svgRef = useRef12(null);
39057
- const gaugeGroupRef = useRef12(null);
39058
- const needleRef = useRef12(null);
39059
- const needleOutlineRef = useRef12(null);
39060
- const textRef = useRef12(null);
39061
- const animationFrameRef = useRef12(null);
39062
- const previousPercentageRef = useRef12(0);
39063
- const firstMountRef = useRef12(true);
39343
+ const containerRef = useRef13(null);
39344
+ const svgRef = useRef13(null);
39345
+ const gaugeGroupRef = useRef13(null);
39346
+ const needleRef = useRef13(null);
39347
+ const needleOutlineRef = useRef13(null);
39348
+ const textRef = useRef13(null);
39349
+ const animationFrameRef = useRef13(null);
39350
+ const previousPercentageRef = useRef13(0);
39351
+ const firstMountRef = useRef13(true);
39064
39352
  const startAngle = -(3 * Math.PI) / 4;
39065
39353
  const totalAngle = 3 * Math.PI / 2;
39066
39354
  const [arc, setArc] = useState18(null);
@@ -39597,7 +39885,7 @@ function Chart({
39597
39885
  filters,
39598
39886
  dashboardCustomFilters[allReportsById[reportId]?.dashboardName ?? ""]
39599
39887
  ]);
39600
- const previousFilters = useRef13(void 0);
39888
+ const previousFilters = useRef14(void 0);
39601
39889
  if (!equal3(previousFilters.current, filters)) {
39602
39890
  previousFilters.current = filters;
39603
39891
  }
@@ -40014,6 +40302,7 @@ var ChartDisplay = ({
40014
40302
  onPageChange,
40015
40303
  onSortChange,
40016
40304
  onClickChartElement,
40305
+ onClickLegendElement,
40017
40306
  overrideTheme,
40018
40307
  referenceLines,
40019
40308
  showLegend,
@@ -40098,6 +40387,7 @@ var ChartDisplay = ({
40098
40387
  theme: overrideTheme ?? theme,
40099
40388
  colorMap,
40100
40389
  onClickChartElement,
40390
+ onClickLegendElement,
40101
40391
  yAxisFields: config?.yAxisFields,
40102
40392
  showLegend: resolvedShowLegend
40103
40393
  }
@@ -40174,6 +40464,7 @@ var ChartDisplay = ({
40174
40464
  hideCartesianGrid,
40175
40465
  colorMap,
40176
40466
  onClickChartElement,
40467
+ onClickLegendElement,
40177
40468
  dateFilter: !hideDateRangeFilter ? dateFilter : void 0,
40178
40469
  referenceLines,
40179
40470
  showLegend: resolvedShowLegend
@@ -40201,6 +40492,7 @@ var ChartDisplay = ({
40201
40492
  hideCartesianGrid,
40202
40493
  colorMap,
40203
40494
  onClickChartElement,
40495
+ onClickLegendElement,
40204
40496
  dateFilter: !hideDateRangeFilter ? dateFilter : void 0,
40205
40497
  referenceLines,
40206
40498
  showLegend: resolvedShowLegend,
@@ -40357,6 +40649,7 @@ var ChartDisplay = ({
40357
40649
  className,
40358
40650
  isAnimationActive,
40359
40651
  onClickChartElement,
40652
+ onClickLegendElement,
40360
40653
  dateFilter: !hideDateRangeFilter ? dateFilter : void 0,
40361
40654
  showLegend: resolvedShowLegend
40362
40655
  }
@@ -40387,6 +40680,7 @@ var ChartDisplay = ({
40387
40680
  comparisonLineStyle: comparisonLineStyle ?? "solid",
40388
40681
  cartesianGridLineColor,
40389
40682
  onClickChartElement,
40683
+ onClickLegendElement,
40390
40684
  dateFilter: !hideDateRangeFilter ? dateFilter : void 0,
40391
40685
  referenceLines,
40392
40686
  showLegend: resolvedShowLegend
@@ -40650,7 +40944,7 @@ import {
40650
40944
  useContext as useContext20,
40651
40945
  useEffect as useEffect17,
40652
40946
  useMemo as useMemo17,
40653
- useRef as useRef14,
40947
+ useRef as useRef15,
40654
40948
  useState as useState22
40655
40949
  } from "react";
40656
40950
  init_util();
@@ -41149,7 +41443,7 @@ var FilterPopoverWrapper = ({
41149
41443
  const [isOpen, setIsOpen] = useState22(false);
41150
41444
  const [uniqueValues, setUniqueValues] = useState22(void 0);
41151
41445
  const [uniqueValuesIsLoading, setUniqueValuesIsLoading] = useState22(false);
41152
- const prevFiltersRef = useRef14("");
41446
+ const prevFiltersRef = useRef15("");
41153
41447
  const columnInternals = useMemo17(() => {
41154
41448
  if (!tables) {
41155
41449
  return null;
@@ -42408,7 +42702,7 @@ function DashboardLegacy({
42408
42702
  });
42409
42703
  return map;
42410
42704
  }, [data?.sections, data?.sectionOrder]);
42411
- const mounted = useRef15(false);
42705
+ const mounted = useRef16(false);
42412
42706
  useEffect19(() => {
42413
42707
  if (!mounted.current) {
42414
42708
  mounted.current = true;
@@ -42450,16 +42744,16 @@ function DashboardLegacy({
42450
42744
  ) : defaultOptionsV2;
42451
42745
  }, [populatedDashboardFilters]);
42452
42746
  const [filterValues, setFilterValues] = useState26({});
42453
- const prevNameRef = useRef15(name2);
42454
- const prevFlagsRef = useRef15(flags);
42455
- const prevClientRef = useRef15(client?.publicKey ?? "");
42456
- const addFilterPopoverButtonRef = useRef15(null);
42457
- const viewFiltersPopoverButtonRef = useRef15(null);
42458
- const previousFilters = useRef15(filters);
42747
+ const prevNameRef = useRef16(name2);
42748
+ const prevFlagsRef = useRef16(flags);
42749
+ const prevClientRef = useRef16(client?.id ?? "");
42750
+ const addFilterPopoverButtonRef = useRef16(null);
42751
+ const viewFiltersPopoverButtonRef = useRef16(null);
42752
+ const previousFilters = useRef16(filters);
42459
42753
  if (!equal4(previousFilters.current, filters)) {
42460
42754
  previousFilters.current = filters;
42461
42755
  }
42462
- const isInitialLoadOfDashboardRef = useRef15(false);
42756
+ const isInitialLoadOfDashboardRef = useRef16(false);
42463
42757
  const referencedTables = useMemo19(() => {
42464
42758
  const sections = data?.sections || {};
42465
42759
  const tables2 = Object.values(sections).flatMap(
@@ -42487,7 +42781,7 @@ function DashboardLegacy({
42487
42781
  prevFlagsRef.current = flags;
42488
42782
  });
42489
42783
  }, [name2, isClientLoading]);
42490
- const tenantMounted = useRef15(false);
42784
+ const tenantMounted = useRef16(false);
42491
42785
  useEffect19(() => {
42492
42786
  if (!tenantMounted.current) {
42493
42787
  tenantMounted.current = true;
@@ -42508,15 +42802,15 @@ function DashboardLegacy({
42508
42802
  });
42509
42803
  }, [flags]);
42510
42804
  useEffect19(() => {
42511
- if (prevClientRef.current === client?.publicKey) {
42805
+ if (prevClientRef.current === client?.id) {
42512
42806
  return;
42513
42807
  }
42514
- const isInitialKeySet = !prevClientRef.current && client?.publicKey;
42808
+ const isInitialKeySet = !prevClientRef.current && client?.id;
42515
42809
  if (isInitialKeySet && Object.values(data?.sections ?? {}).flat().length) {
42516
- prevClientRef.current = client?.publicKey ?? "";
42810
+ prevClientRef.current = client?.id ?? "";
42517
42811
  return;
42518
42812
  }
42519
- prevClientRef.current = client?.publicKey ?? "";
42813
+ prevClientRef.current = client?.id ?? "";
42520
42814
  if (isClientLoading) {
42521
42815
  return;
42522
42816
  }
@@ -42528,7 +42822,7 @@ function DashboardLegacy({
42528
42822
  prevFlagsRef.current = flags;
42529
42823
  isInitialLoadOfDashboardRef.current = false;
42530
42824
  });
42531
- }, [client?.publicKey]);
42825
+ }, [client?.id]);
42532
42826
  useEffect19(() => {
42533
42827
  setFilterValues(
42534
42828
  Object.values(populatedDashboardFilters ?? {}).reduce((acc, f) => {
@@ -43511,6 +43805,7 @@ function StaticChart(props) {
43511
43805
  const {
43512
43806
  reportId,
43513
43807
  onClickChartElement,
43808
+ onClickLegendElement,
43514
43809
  containerStyle,
43515
43810
  showLegend,
43516
43811
  className
@@ -43563,6 +43858,7 @@ function StaticChart(props) {
43563
43858
  reportId,
43564
43859
  config,
43565
43860
  onClickChartElement,
43861
+ onClickLegendElement,
43566
43862
  loading,
43567
43863
  className,
43568
43864
  containerStyle: safeContainerStyle,
@@ -44514,7 +44810,7 @@ import {
44514
44810
  useState as useState33,
44515
44811
  useContext as useContext30,
44516
44812
  useEffect as useEffect25,
44517
- useRef as useRef20,
44813
+ useRef as useRef21,
44518
44814
  useMemo as useMemo27,
44519
44815
  useCallback as useCallback4
44520
44816
  } from "react";
@@ -44523,7 +44819,7 @@ import MonacoEditor from "@monaco-editor/react";
44523
44819
  // src/ChartBuilder.tsx
44524
44820
  import {
44525
44821
  useEffect as useEffect23,
44526
- useRef as useRef19,
44822
+ useRef as useRef20,
44527
44823
  useState as useState31,
44528
44824
  useContext as useContext28,
44529
44825
  useMemo as useMemo26,
@@ -44553,7 +44849,7 @@ import {
44553
44849
  useMemo as useMemo23,
44554
44850
  useState as useState28,
44555
44851
  useEffect as useEffect21,
44556
- useRef as useRef16
44852
+ useRef as useRef17
44557
44853
  } from "react";
44558
44854
 
44559
44855
  // src/internals/ReportBuilder/PivotList.tsx
@@ -45028,8 +45324,8 @@ var PivotModal = ({
45028
45324
  const [schemaData] = useContext25(SchemaDataContext);
45029
45325
  const { tenants } = useContext25(TenantContext);
45030
45326
  const { eventTracking } = useContext25(EventTrackingContext);
45031
- const rowFieldRef = useRef16(null);
45032
- const colFieldRef = useRef16(null);
45327
+ const rowFieldRef = useRef17(null);
45328
+ const colFieldRef = useRef17(null);
45033
45329
  const [pivotCardWidth, setPivotCardWidth] = useState28(420);
45034
45330
  const [samplePivotTable, setSamplePivotTable] = useState28(null);
45035
45331
  const [hasNoRecommendedPivots, sethasNoRecommendedPivots] = useState28(false);
@@ -45038,7 +45334,7 @@ var PivotModal = ({
45038
45334
  const [allowedRowFields, setAllowedRowFields] = useState28([]);
45039
45335
  const [allowedValueFields, setAllowedValueFields] = useState28([]);
45040
45336
  const [uniqueValues, setUniqueValues] = useState28(initialUniqueValues);
45041
- const buttonRef = useRef16(null);
45337
+ const buttonRef = useRef17(null);
45042
45338
  const [dateRanges, setDateRanges] = useState28({});
45043
45339
  const [pivotError, setPivotError] = useState28("");
45044
45340
  const [limitInput, setLimitInput] = useState28(
@@ -45057,7 +45353,7 @@ var PivotModal = ({
45057
45353
  const [popoverPosition, setPopoverPosition] = useState28(
45058
45354
  "bottom"
45059
45355
  );
45060
- const popoverRef = useRef16(null);
45356
+ const popoverRef = useRef17(null);
45061
45357
  const columnsToShow = useMemo23(() => {
45062
45358
  return (columns || []).reduce((map, col) => {
45063
45359
  map[col.field] = col.format;
@@ -45386,7 +45682,7 @@ var PivotModal = ({
45386
45682
  };
45387
45683
  fetchPivotTables();
45388
45684
  }, [selectedPivotIndex, data, dateRange, createdPivots]);
45389
- const previousUniqueValuesRef = useRef16();
45685
+ const previousUniqueValuesRef = useRef17();
45390
45686
  useEffect21(() => {
45391
45687
  if (!uniqueValuesIsLoading && !equal5(uniqueValues, previousUniqueValuesRef.current)) {
45392
45688
  previousUniqueValuesRef.current = uniqueValues;
@@ -46798,7 +47094,7 @@ import {
46798
47094
  useEffect as useEffect22,
46799
47095
  useContext as useContext26,
46800
47096
  useMemo as useMemo24,
46801
- useRef as useRef17,
47097
+ useRef as useRef18,
46802
47098
  useLayoutEffect as useLayoutEffect3
46803
47099
  } from "react";
46804
47100
  import { differenceInHours as differenceInHours2 } from "date-fns";
@@ -46920,7 +47216,7 @@ function InternalChart({
46920
47216
  const { dashboardConfig } = useContext26(DashboardConfigContext);
46921
47217
  const { eventTracking } = useContext26(EventTrackingContext);
46922
47218
  const [filtersPopoverOpen, setFiltersPopoverOpen] = useState29(false);
46923
- const filtersButtonRef = useRef17(null);
47219
+ const filtersButtonRef = useRef18(null);
46924
47220
  const currentReportFilters = useMemo24(() => {
46925
47221
  const dashFilters = dashboardConfig[report?.dashboardName ?? ""]?.config.filters;
46926
47222
  if (!dashFilters)
@@ -46949,8 +47245,8 @@ function InternalChart({
46949
47245
  ) : defaultOptionsV2;
46950
47246
  }, [reportDateFilter]);
46951
47247
  const [filterValues, setFilterValues] = useState29({});
46952
- const multiselectDebounceRef = useRef17({});
46953
- const latestMultiselectValueRef = useRef17({});
47248
+ const multiselectDebounceRef = useRef18({});
47249
+ const latestMultiselectValueRef = useRef18({});
46954
47250
  const [lockedFilters, setLockedFilters] = useState29(
46955
47251
  {}
46956
47252
  );
@@ -47112,7 +47408,7 @@ function InternalChart({
47112
47408
  onDashboardFilterChange(filter.label, filterValue);
47113
47409
  };
47114
47410
  const [filtersExpanded, setFiltersExpanded] = useState29(false);
47115
- const filtersContainerRef = useRef17(null);
47411
+ const filtersContainerRef = useRef18(null);
47116
47412
  const [visibleFilters, setVisibleFilters] = useState29([]);
47117
47413
  const filtersOverflowing = useMemo24(() => {
47118
47414
  return visibleFilters.some((visible) => visible);
@@ -47378,7 +47674,7 @@ init_dates();
47378
47674
  import React16, {
47379
47675
  useContext as useContext27,
47380
47676
  useMemo as useMemo25,
47381
- useRef as useRef18,
47677
+ useRef as useRef19,
47382
47678
  useState as useState30
47383
47679
  } from "react";
47384
47680
  import { Fragment as Fragment12, jsx as jsx68, jsxs as jsxs49 } from "react/jsx-runtime";
@@ -47398,9 +47694,9 @@ function QuillMultiSelectSectionList({
47398
47694
  }) {
47399
47695
  const [theme] = useContext27(ThemeContext);
47400
47696
  const [showModal, setShowModal] = useState30(false);
47401
- const modalRef = useRef18(null);
47402
- const buttonRef = useRef18(null);
47403
- const debounceTimeoutId = useRef18(null);
47697
+ const modalRef = useRef19(null);
47698
+ const buttonRef = useRef19(null);
47699
+ const debounceTimeoutId = useRef19(null);
47404
47700
  const [searchQuery, setSearchQuery] = React16.useState("");
47405
47701
  useOnClickOutside_default(
47406
47702
  modalRef,
@@ -48187,7 +48483,7 @@ function createReportFromForm(formData, report, eventTracking, selectedPivotTabl
48187
48483
  return newReport;
48188
48484
  }
48189
48485
  function ChartBuilderWithModal(props) {
48190
- const parentRef = useRef19(null);
48486
+ const parentRef = useRef20(null);
48191
48487
  const [modalWidth, setModalWidth] = useState31(200);
48192
48488
  const [modalHeight, setModalHeight] = useState31(200);
48193
48489
  const { isOpen, setIsOpen, title, isHorizontalView } = props;
@@ -48354,8 +48650,8 @@ function ChartBuilder({
48354
48650
  const MIN_FORM_WIDTH = 700;
48355
48651
  const [pivotCardWidth, setPivotCardWidth] = useState31(MIN_FORM_WIDTH);
48356
48652
  const [formWidth, setFormWidth] = useState31(MIN_FORM_WIDTH);
48357
- const inputRef = useRef19(null);
48358
- const selectRef = useRef19(null);
48653
+ const inputRef = useRef20(null);
48654
+ const selectRef = useRef20(null);
48359
48655
  const processColumns = (columns2) => {
48360
48656
  if (schemaData.schemaWithCustomFields) {
48361
48657
  const newProcessedColumns = columns2?.map((col) => {
@@ -48414,8 +48710,8 @@ function ChartBuilder({
48414
48710
  processColumns(report?.columnInternal ?? [])
48415
48711
  );
48416
48712
  const [currentPage, setCurrentPage] = useState31(0);
48417
- const parentRef = useRef19(null);
48418
- const deleteRef = useRef19(null);
48713
+ const parentRef = useRef20(null);
48714
+ const deleteRef = useRef20(null);
48419
48715
  const modalPadding = 20;
48420
48716
  const deleteButtonMargin = -12;
48421
48717
  const { dashboardFilters } = useContext28(DashboardFiltersContext);
@@ -48468,7 +48764,7 @@ function ChartBuilder({
48468
48764
  abortLoadingFilters
48469
48765
  } = useContext28(ReportFiltersContext);
48470
48766
  const { reportsDispatch } = useContext28(ReportsContext);
48471
- const initialFilters = useRef19(reportFilters[report?.id ?? TEMP_REPORT_ID]);
48767
+ const initialFilters = useRef20(reportFilters[report?.id ?? TEMP_REPORT_ID]);
48472
48768
  const [reportFiltersLoaded, setReportFiltersLoaded] = useState31(!filtersEnabled);
48473
48769
  const hasExistingData = useMemo26(() => {
48474
48770
  return report?.rows && report.rows.length > 0 || report?.pivotRows && report.pivotRows.length > 0;
@@ -48664,7 +48960,7 @@ function ChartBuilder({
48664
48960
  task: "dashboard",
48665
48961
  metadata: {
48666
48962
  name: dashboardName,
48667
- clientId: client.clientId,
48963
+ clientId: client.id,
48668
48964
  databaseType: client.databaseType,
48669
48965
  useNewNodeSql: true,
48670
48966
  tenants
@@ -48724,11 +49020,11 @@ function ChartBuilder({
48724
49020
  const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
48725
49021
  const metadata = reportBuilderState2 ? {
48726
49022
  reportBuilderState: reportBuilderState2,
48727
- clientId: client2.clientId,
49023
+ clientId: client2.id,
48728
49024
  useNewNodeSql: true
48729
49025
  } : {
48730
49026
  query: sqlQuery,
48731
- clientId: client2.clientId,
49027
+ clientId: client2.id,
48732
49028
  useNewNodeSql: true
48733
49029
  };
48734
49030
  try {
@@ -48762,7 +49058,7 @@ function ChartBuilder({
48762
49058
  };
48763
49059
  }
48764
49060
  };
48765
- const initializedRef = useRef19(false);
49061
+ const initializedRef = useRef20(false);
48766
49062
  const getCurrentSection = () => {
48767
49063
  let id = report?.id ?? "";
48768
49064
  if (id === "" || id === TEMP_REPORT_ID) {
@@ -48954,7 +49250,7 @@ function ChartBuilder({
48954
49250
  client,
48955
49251
  task: "dashnames",
48956
49252
  metadata: {
48957
- clientId: client.clientId
49253
+ clientId: client.id
48958
49254
  }
48959
49255
  });
48960
49256
  dashNames = resp.dashboardNames;
@@ -49091,7 +49387,7 @@ function ChartBuilder({
49091
49387
  }));
49092
49388
  }
49093
49389
  }, [report?.triggerReload, report?.columns, formData.columns.length]);
49094
- const ranMountQuery = useRef19(false);
49390
+ const ranMountQuery = useRef20(false);
49095
49391
  useEffect23(() => {
49096
49392
  if (runQueryOnMount && reportFiltersLoaded && filtersEnabled && !ranMountQuery.current) {
49097
49393
  ranMountQuery.current = true;
@@ -49328,7 +49624,7 @@ function ChartBuilder({
49328
49624
  return handleRunQuery(baseProcessing, updatedFilters);
49329
49625
  });
49330
49626
  };
49331
- const filtersEnabledRef = useRef19(filtersEnabled);
49627
+ const filtersEnabledRef = useRef20(filtersEnabled);
49332
49628
  useEffect23(() => {
49333
49629
  if (filtersEnabledRef.current !== filtersEnabled) {
49334
49630
  filtersEnabledRef.current = filtersEnabled;
@@ -52333,7 +52629,7 @@ function SQLEditor({
52333
52629
  }) {
52334
52630
  const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
52335
52631
  const [sqlPrompt, setSqlPrompt] = useState33("");
52336
- const sqlPromptFormRef = useRef20(null);
52632
+ const sqlPromptFormRef = useRef21(null);
52337
52633
  const sqlPromptInputWidth = useResponsiveFirstChildWidth_default(sqlPromptFormRef, {
52338
52634
  gap: 12,
52339
52635
  initialWidth: 320,
@@ -52393,7 +52689,7 @@ function SQLEditor({
52393
52689
  };
52394
52690
  return initial;
52395
52691
  });
52396
- const tableRef = useRef20(null);
52692
+ const tableRef = useRef21(null);
52397
52693
  const [cachedHeight, setCachedHeight] = useState33(0);
52398
52694
  const DEFAULT_ROWS_PER_PAGE = 5;
52399
52695
  const ROW_HEIGHT = 37;
@@ -52499,7 +52795,7 @@ function SQLEditor({
52499
52795
  setColumns([]);
52500
52796
  setDisplayTable(false);
52501
52797
  }
52502
- }, [client?.publicKey]);
52798
+ }, [client?.id]);
52503
52799
  useEffect25(() => {
52504
52800
  if (isChartBuilderOpen === false) {
52505
52801
  onCloseChartBuilder && onCloseChartBuilder();
@@ -52758,7 +53054,7 @@ function SQLEditor({
52758
53054
  task: "astify",
52759
53055
  metadata: {
52760
53056
  query: sqlQuery,
52761
- clientId: client2.clientId,
53057
+ clientId: client2.id,
52762
53058
  useNewNodeSql: true
52763
53059
  }
52764
53060
  });
@@ -52951,7 +53247,7 @@ function SQLEditor({
52951
53247
  query: query || "",
52952
53248
  schema: filteredSchema,
52953
53249
  databaseType: client?.databaseType ?? "postgresql",
52954
- clientName: client?.publicKey || "",
53250
+ clientName: client?.id || "",
52955
53251
  setQuery,
52956
53252
  handleRunQuery: () => {
52957
53253
  handleRunQuery(currentProcessing, true);
@@ -53395,7 +53691,7 @@ var SQLEditorComponent = ({
53395
53691
  }) => {
53396
53692
  const [editorKey, setEditorKey] = useState33(0);
53397
53693
  const { eventTracking } = useContext30(EventTrackingContext);
53398
- const currentProvider = useRef20(null);
53694
+ const currentProvider = useRef21(null);
53399
53695
  useEffect25(() => {
53400
53696
  if (currentProvider.current) {
53401
53697
  currentProvider.current.dispose();
@@ -53867,7 +54163,7 @@ function SchemaItem({
53867
54163
  import {
53868
54164
  useContext as useContext34,
53869
54165
  useEffect as useEffect29,
53870
- useRef as useRef22,
54166
+ useRef as useRef23,
53871
54167
  useState as useState39
53872
54168
  } from "react";
53873
54169
  init_constants();
@@ -55110,7 +55406,7 @@ var useReportBuilderInternal = ({
55110
55406
  !client.featureFlags?.["recommendedPivotsDisabled"]
55111
55407
  );
55112
55408
  }
55113
- if (!initialTableName && !reportId && client.publicKey) {
55409
+ if (!initialTableName && !reportId && client.id) {
55114
55410
  clearAllState();
55115
55411
  }
55116
55412
  }, [client]);
@@ -55403,7 +55699,7 @@ var useReportBuilder = ({
55403
55699
  init_ReportBuilder();
55404
55700
 
55405
55701
  // src/components/ReportBuilder/AddColumnModal.tsx
55406
- import { useState as useState35, useRef as useRef21, useMemo as useMemo29, useEffect as useEffect27, useContext as useContext32 } from "react";
55702
+ import { useState as useState35, useRef as useRef22, useMemo as useMemo29, useEffect as useEffect27, useContext as useContext32 } from "react";
55407
55703
  import {
55408
55704
  DndContext as DndContext2,
55409
55705
  closestCenter as closestCenter2,
@@ -55444,7 +55740,7 @@ function AddColumnModal({
55444
55740
  const [theme] = useContext32(ThemeContext);
55445
55741
  const [search, setSearch] = useState35("");
55446
55742
  const [initialLoad, setInitialLoad] = useState35(true);
55447
- const textInputContainerRef = useRef21(null);
55743
+ const textInputContainerRef = useRef22(null);
55448
55744
  const [modalSelectedColumns, setModalSelectedColumns] = useState35(
55449
55745
  selectedColumns.map((col) => `${col.table}.${col.field}`)
55450
55746
  );
@@ -57898,8 +58194,8 @@ function ReportBuilder({
57898
58194
  const [theme] = useContext34(ThemeContext);
57899
58195
  const [client] = useContext34(ClientContext);
57900
58196
  const { getToken } = useContext34(FetchContext);
57901
- const parentRef = useRef22(null);
57902
- const askAIFormRef = useRef22(null);
58197
+ const parentRef = useRef23(null);
58198
+ const askAIFormRef = useRef23(null);
57903
58199
  const [isCopying, setIsCopying] = useState39(false);
57904
58200
  const [isChartBuilderOpen, setIsChartBuilderOpen] = useState39(false);
57905
58201
  const [isSaveQueryModalOpen, setIsSaveQueryModalOpen] = useState39(false);
@@ -58406,7 +58702,7 @@ import {
58406
58702
  useContext as useContext35,
58407
58703
  useEffect as useEffect30,
58408
58704
  useMemo as useMemo31,
58409
- useRef as useRef23,
58705
+ useRef as useRef24,
58410
58706
  useState as useState40
58411
58707
  } from "react";
58412
58708
  import { jsx as jsx86 } from "react/jsx-runtime";
@@ -58455,7 +58751,7 @@ function ChartEditor({
58455
58751
  onClickChartElement,
58456
58752
  onClickChartError
58457
58753
  }) {
58458
- const parentRef = useRef23(null);
58754
+ const parentRef = useRef24(null);
58459
58755
  const [modalWidth, setModalWidth] = useState40(200);
58460
58756
  const [modalHeight, setModalHeight] = useState40(200);
58461
58757
  const { allReportsById } = useAllReports();
@@ -58633,7 +58929,7 @@ function ChartEditor({
58633
58929
  }
58634
58930
 
58635
58931
  // src/Chat.tsx
58636
- import { useContext as useContext37, useEffect as useEffect32, useRef as useRef25, useState as useState42 } from "react";
58932
+ import { useContext as useContext37, useEffect as useEffect32, useRef as useRef26, useState as useState42 } from "react";
58637
58933
 
58638
58934
  // src/ChatChartCard.tsx
58639
58935
  import { useMemo as useMemo33 } from "react";
@@ -58648,7 +58944,7 @@ import {
58648
58944
  useLayoutEffect as useLayoutEffect4,
58649
58945
  useMemo as useMemo32,
58650
58946
  useReducer as useReducer2,
58651
- useRef as useRef24,
58947
+ useRef as useRef25,
58652
58948
  useState as useState41
58653
58949
  } from "react";
58654
58950
  import { keepPreviousData, useQuery } from "@tanstack/react-query";
@@ -58665,6 +58961,7 @@ init_valueFormatter();
58665
58961
  // src/utils/queryBuilderFilters.ts
58666
58962
  init_Filter();
58667
58963
  init_reportBuilder();
58964
+ init_dates();
58668
58965
  var buildOperatorOption = (value, label, arity) => ({
58669
58966
  name: value,
58670
58967
  value,
@@ -58833,6 +59130,26 @@ var DATE_UNIT_BY_KEY = {
58833
59130
  day: TimeUnit.Day,
58834
59131
  hour: TimeUnit.Hour
58835
59132
  };
59133
+ var DATE_BUCKETS = /* @__PURE__ */ new Set(["day", "week", "month", "year"]);
59134
+ var parseInBucketValue = (value) => {
59135
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
59136
+ throw new Error(
59137
+ 'inBucket value must be `{ start: string, bucket: "day"|"week"|"month"|"year" }`'
59138
+ );
59139
+ }
59140
+ const record = value;
59141
+ const start = String(record.start ?? "").trim();
59142
+ const bucket = String(record.bucket ?? "").trim().toLowerCase();
59143
+ if (!start) {
59144
+ throw new Error("inBucket value.start is required");
59145
+ }
59146
+ if (!DATE_BUCKETS.has(bucket)) {
59147
+ throw new Error(
59148
+ `inBucket value.bucket must be day|week|month|year (got "${String(record.bucket)}")`
59149
+ );
59150
+ }
59151
+ return { start, bucket };
59152
+ };
58836
59153
  var EMPTY_QUERY_GROUP = {
58837
59154
  combinator: "and",
58838
59155
  rules: []
@@ -59052,6 +59369,17 @@ var internalFilterToRule = (filter) => {
59052
59369
  }
59053
59370
  case "date-custom-filter" /* DateCustomFilter */: {
59054
59371
  const customDate = filter.value;
59372
+ const dateCustom = filter;
59373
+ if (dateCustom.fromInBucket && dateCustom.dateBucket) {
59374
+ return {
59375
+ field,
59376
+ operator: "inBucket",
59377
+ value: {
59378
+ start: customDate.startDate,
59379
+ bucket: dateCustom.dateBucket
59380
+ }
59381
+ };
59382
+ }
59055
59383
  return {
59056
59384
  field,
59057
59385
  operator: "between",
@@ -59236,6 +59564,24 @@ var queryRuleToInternalFilter = (rule, fieldConfigByName) => {
59236
59564
  }
59237
59565
  };
59238
59566
  }
59567
+ if (compactOperatorKey === "inbucket") {
59568
+ const { start, bucket } = parseInBucketValue(rule.value);
59569
+ const range = getExclusiveDateBucketRange(start, bucket);
59570
+ const endInclusive = new Date(Date.parse(range.endExclusive) - 1).toISOString();
59571
+ return {
59572
+ filterType: "date-custom-filter" /* DateCustomFilter */,
59573
+ fieldType: FieldType.Date,
59574
+ operator: DateOperator.Custom,
59575
+ field,
59576
+ table,
59577
+ value: {
59578
+ startDate: range.start,
59579
+ endDate: endInclusive
59580
+ },
59581
+ dateBucket: bucket,
59582
+ fromInBucket: true
59583
+ };
59584
+ }
59239
59585
  const dateComparisonOperator = QUERY_TO_DATE_COMPARISON_OPERATOR[compactOperatorKey] ?? QUERY_TO_DATE_COMPARISON_OPERATOR[operatorKey];
59240
59586
  if (!dateComparisonOperator) {
59241
59587
  throw new Error(`Unsupported date operator "${String(rule.operator)}"`);
@@ -59422,6 +59768,31 @@ var filterStackToQueryBuilderFilters = (filterStack, fieldConfigByName, qualifyA
59422
59768
  ) : base;
59423
59769
  return qualified;
59424
59770
  };
59771
+ var queryBuilderFiltersForEditor = (group) => {
59772
+ const mapEntry = (entry) => {
59773
+ if (isCombinator(entry)) return entry;
59774
+ if (isRuleGroup(entry)) {
59775
+ return queryBuilderFiltersForEditor(entry);
59776
+ }
59777
+ if (!isRule(entry)) return entry;
59778
+ const operator = String(entry.operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
59779
+ if (operator !== "inbucket") return entry;
59780
+ const { start, bucket } = parseInBucketValue(entry.value);
59781
+ const range = getExclusiveDateBucketRange(start, bucket);
59782
+ const endInclusive = new Date(
59783
+ Date.parse(range.endExclusive) - 1
59784
+ ).toISOString();
59785
+ return {
59786
+ ...entry,
59787
+ operator: "between",
59788
+ value: [range.start, endInclusive]
59789
+ };
59790
+ };
59791
+ return {
59792
+ combinator: normalizeCombinator(group.combinator, "and"),
59793
+ rules: (group.rules ?? []).map(mapEntry)
59794
+ };
59795
+ };
59425
59796
  var queryBuilderFiltersToFilterStack = (query, fieldConfigByName) => {
59426
59797
  if (!isRuleGroup(query)) {
59427
59798
  throw new Error("Query must be a rule group");
@@ -59940,6 +60311,7 @@ var AXIS_FORMAT_OPTIONS = [
59940
60311
  var USEFORM_FILTERS_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_FILTERS__";
59941
60312
  var USEFORM_REFRESH_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_REFRESH__";
59942
60313
  var USEFORM_PIVOT_SHAPE_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_PIVOT_SHAPE__";
60314
+ var USEFORM_TASK_DEBUG_FLAG = "__QUILL_DEBUG_USEFORM_TASKS__";
59943
60315
  var isUseFormFiltersDebugEnabled = () => {
59944
60316
  const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_FILTERS_DEBUG_FLAG] : void 0;
59945
60317
  if (globalValue === true) {
@@ -59966,6 +60338,23 @@ var isUseFormRefreshDebugEnabled = () => {
59966
60338
  }
59967
60339
  return false;
59968
60340
  };
60341
+ var isUseFormTaskDebugEnabled = () => {
60342
+ const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_TASK_DEBUG_FLAG] : void 0;
60343
+ if (globalValue === true) {
60344
+ return true;
60345
+ }
60346
+ if (typeof process !== "undefined" && typeof process.env !== "undefined") {
60347
+ const envValue = String(
60348
+ process?.env?.QUILL_DEBUG_USEFORM_TASKS ?? ""
60349
+ ).trim().toLowerCase();
60350
+ return envValue === "1" || envValue === "true";
60351
+ }
60352
+ return false;
60353
+ };
60354
+ var logUseFormTaskDebug = (label, payload) => {
60355
+ if (!isUseFormTaskDebugEnabled()) return;
60356
+ console.log(`[useReport][task] ${label}`, payload);
60357
+ };
59969
60358
  var isUseFormPivotShapeDebugEnabled = () => {
59970
60359
  const globalValue = typeof globalThis !== "undefined" ? globalThis?.[USEFORM_PIVOT_SHAPE_DEBUG_FLAG] : void 0;
59971
60360
  if (globalValue === true) {
@@ -60450,6 +60839,8 @@ function normalizePivotForRefreshComparison(pivot) {
60450
60839
  const {
60451
60840
  rowFieldTable: _pivotRowTable,
60452
60841
  columnFieldTable: _pivotColumnTable,
60842
+ rowFilter: _rowFilter,
60843
+ columnFilter: _columnFilter,
60453
60844
  aggregations,
60454
60845
  ...pivotRest
60455
60846
  } = record;
@@ -62059,16 +62450,6 @@ function mergeDisplayAndSourceForTableFormats(args) {
62059
62450
  });
62060
62451
  return { columns, formatByColumnOptionId };
62061
62452
  }
62062
- var USE_FORM_AXIS_SERIES_COLORS = [
62063
- "#6366f1",
62064
- "#f59e0b",
62065
- "#10b981",
62066
- "#ef4444",
62067
- "#8b5cf6",
62068
- "#06b6d4",
62069
- "#f97316",
62070
- "#84cc16"
62071
- ];
62072
62453
  function axisFormatToSelectLabel(format9) {
62073
62454
  const raw = String(format9 ?? "").trim();
62074
62455
  const exact = AXIS_FORMAT_OPTIONS.find((option) => option.value === raw);
@@ -62548,6 +62929,9 @@ async function loadViaInMemoryEngines({
62548
62929
  pivot,
62549
62930
  reportBuilderState,
62550
62931
  allowReportTaskBootstrap = false,
62932
+ debugSource,
62933
+ debugRunId,
62934
+ debugLoadRequestId,
62551
62935
  draftSessionId
62552
62936
  }) {
62553
62937
  const requestedTask = allowReportTaskBootstrap ? "report" : "item";
@@ -62557,6 +62941,17 @@ async function loadViaInMemoryEngines({
62557
62941
  rowsPerRequest: DEFAULT_USE_REPORT_ROWS_PER_REQUEST
62558
62942
  }
62559
62943
  } : {};
62944
+ logUseFormTaskDebug("dispatch fetchReport", {
62945
+ reportId,
62946
+ task: requestedTask,
62947
+ source: debugSource ?? "unknown",
62948
+ runId: debugRunId ?? null,
62949
+ loadRequestId: debugLoadRequestId ?? null,
62950
+ allowReportTaskBootstrap,
62951
+ filterCount: internalFilters.length,
62952
+ hasPivot: Boolean(pivot),
62953
+ hasReportBuilderState: Boolean(reportBuilderState)
62954
+ });
62560
62955
  const { report, error } = await fetchReport({
62561
62956
  reportId,
62562
62957
  client,
@@ -62636,6 +63031,9 @@ async function loadViaPivotTemplate({
62636
63031
  reportBuilderState,
62637
63032
  baseReport,
62638
63033
  schema,
63034
+ debugSource,
63035
+ debugRunId,
63036
+ debugLoadRequestId,
62639
63037
  draftSessionId
62640
63038
  }) {
62641
63039
  const pivotForTemplate = enrichPivotRowFieldTypeForTemplate(
@@ -62643,6 +63041,16 @@ async function loadViaPivotTemplate({
62643
63041
  schema,
62644
63042
  baseReport
62645
63043
  );
63044
+ logUseFormTaskDebug("dispatch fetchReport", {
63045
+ reportId,
63046
+ task: "pivot-template",
63047
+ source: debugSource ?? "unknown",
63048
+ runId: debugRunId ?? null,
63049
+ loadRequestId: debugLoadRequestId ?? null,
63050
+ filterCount: internalFilters.length,
63051
+ hasPivot: Boolean(pivotForTemplate),
63052
+ hasReportBuilderState: Boolean(reportBuilderState)
63053
+ });
62646
63054
  const { report, error } = await fetchPivotTemplateReportForUseForm({
62647
63055
  reportId,
62648
63056
  client,
@@ -62870,8 +63278,19 @@ async function loadPivotTemplateInParallelWithReportTask({
62870
63278
  customFields,
62871
63279
  dashboardName,
62872
63280
  pivotRefreshOnly = false,
63281
+ debugSource,
63282
+ debugRunId,
63283
+ debugLoadRequestId,
62873
63284
  draftSessionId
62874
63285
  }) {
63286
+ logUseFormTaskDebug("parallel loader route", {
63287
+ reportId,
63288
+ source: debugSource ?? "unknown",
63289
+ runId: debugRunId ?? null,
63290
+ loadRequestId: debugLoadRequestId ?? null,
63291
+ pivotRefreshOnly,
63292
+ tasks: pivotRefreshOnly ? ["pivot-template"] : ["report", "pivot-template", "report-builder-state"]
63293
+ });
62875
63294
  if (pivotRefreshOnly) {
62876
63295
  const pivotOnlyResult = await loadViaPivotTemplate({
62877
63296
  reportId,
@@ -62884,6 +63303,9 @@ async function loadPivotTemplateInParallelWithReportTask({
62884
63303
  reportBuilderState,
62885
63304
  baseReport,
62886
63305
  schema,
63306
+ debugSource,
63307
+ debugRunId,
63308
+ debugLoadRequestId,
62887
63309
  draftSessionId
62888
63310
  });
62889
63311
  return pivotOnlyResult;
@@ -62899,6 +63321,9 @@ async function loadPivotTemplateInParallelWithReportTask({
62899
63321
  pivot,
62900
63322
  reportBuilderState,
62901
63323
  allowReportTaskBootstrap: true,
63324
+ debugSource,
63325
+ debugRunId,
63326
+ debugLoadRequestId,
62902
63327
  draftSessionId
62903
63328
  }),
62904
63329
  loadViaPivotTemplate({
@@ -62912,6 +63337,9 @@ async function loadPivotTemplateInParallelWithReportTask({
62912
63337
  reportBuilderState,
62913
63338
  baseReport,
62914
63339
  schema,
63340
+ debugSource,
63341
+ debugRunId,
63342
+ debugLoadRequestId,
62915
63343
  draftSessionId
62916
63344
  }),
62917
63345
  fetchReportBuilderStateByReportId({
@@ -63094,6 +63522,9 @@ async function loadReportForUseForm({
63094
63522
  customFields,
63095
63523
  dashboardName,
63096
63524
  useInMemoryEngines,
63525
+ debugSource,
63526
+ debugRunId,
63527
+ debugLoadRequestId,
63097
63528
  draftSessionId
63098
63529
  }) {
63099
63530
  const effectivePivot = pivot ?? initialReportBuilderState?.pivot ?? void 0;
@@ -63102,6 +63533,18 @@ async function loadReportForUseForm({
63102
63533
  ...initialReportBuilderState,
63103
63534
  pivot: effectivePivot ?? initialReportBuilderState.pivot ?? null
63104
63535
  } : void 0;
63536
+ logUseFormTaskDebug("resolve loader route", {
63537
+ reportId,
63538
+ source: debugSource ?? "unknown",
63539
+ runId: debugRunId ?? null,
63540
+ loadRequestId: debugLoadRequestId ?? null,
63541
+ hasPivot,
63542
+ hasReportBuilderState: Boolean(reportBuilderStateForLoad),
63543
+ allowReportTaskBootstrap,
63544
+ includeReportBuilderStateInPivotTask,
63545
+ filterCount: internalFilters.length,
63546
+ useInMemoryEngines
63547
+ });
63105
63548
  if (hasPivot) {
63106
63549
  const pivotResult = await loadPivotTemplateInParallelWithReportTask({
63107
63550
  reportId,
@@ -63117,6 +63560,9 @@ async function loadReportForUseForm({
63117
63560
  customFields,
63118
63561
  dashboardName,
63119
63562
  pivotRefreshOnly: includeReportBuilderStateInPivotTask,
63563
+ debugSource,
63564
+ debugRunId,
63565
+ debugLoadRequestId,
63120
63566
  draftSessionId
63121
63567
  });
63122
63568
  const pivotRows = pivotResult.report?.pivotRows;
@@ -63165,6 +63611,9 @@ async function loadReportForUseForm({
63165
63611
  schema,
63166
63612
  customFields,
63167
63613
  dashboardName,
63614
+ debugSource,
63615
+ debugRunId,
63616
+ debugLoadRequestId,
63168
63617
  draftSessionId
63169
63618
  });
63170
63619
  const normalizedBootstrapResult = bootstrapResult.report?.pivot == null ? stripPivotFromResult(bootstrapResult) : bootstrapResult;
@@ -63172,6 +63621,15 @@ async function loadReportForUseForm({
63172
63621
  }
63173
63622
  const shouldUseReportTaskForReload = internalFilters.length > 0;
63174
63623
  const resolvedTask = shouldUseReportTaskForReload ? "report" : "item";
63624
+ logUseFormTaskDebug("non-bootstrap task route", {
63625
+ reportId,
63626
+ task: resolvedTask,
63627
+ source: debugSource ?? "unknown",
63628
+ runId: debugRunId ?? null,
63629
+ loadRequestId: debugLoadRequestId ?? null,
63630
+ reason: shouldUseReportTaskForReload ? "live internal filters are present" : "no live internal filters are present",
63631
+ filterCount: internalFilters.length
63632
+ });
63175
63633
  return loadViaInMemoryEngines({
63176
63634
  reportId,
63177
63635
  client,
@@ -63180,6 +63638,9 @@ async function loadReportForUseForm({
63180
63638
  tenants,
63181
63639
  flags,
63182
63640
  allowReportTaskBootstrap: shouldUseReportTaskForReload,
63641
+ debugSource,
63642
+ debugRunId,
63643
+ debugLoadRequestId,
63183
63644
  draftSessionId
63184
63645
  });
63185
63646
  }
@@ -63198,12 +63659,18 @@ async function loadReportForUseForm({
63198
63659
  function generateDraftSessionId() {
63199
63660
  return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `draft-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
63200
63661
  }
63662
+ var nextUseReportDebugRunId = 0;
63201
63663
  function useReport(reportIdArg, options = {}) {
63202
63664
  const propReportId = String(reportIdArg ?? "").trim();
63203
63665
  const [createdReportId, setCreatedReportId] = useState41(null);
63204
63666
  const effectiveReportId = propReportId || createdReportId || "";
63205
63667
  const { eventTracking } = useContext36(EventTrackingContext);
63206
63668
  const [draftSessionId, setDraftSessionId] = useState41(generateDraftSessionId);
63669
+ const [taskDebugRunId] = useState41(() => {
63670
+ nextUseReportDebugRunId += 1;
63671
+ return nextUseReportDebugRunId;
63672
+ });
63673
+ const taskDebugLoadRequestIdRef = useRef25(0);
63207
63674
  const useInMemoryEngines = options.useInMemoryEngines ?? false;
63208
63675
  const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
63209
63676
  const reportOverride = options.reportOverride ?? null;
@@ -63212,7 +63679,7 @@ function useReport(reportIdArg, options = {}) {
63212
63679
  options.destinationDashboardName ?? ""
63213
63680
  ).trim();
63214
63681
  const controlledPagination = options.state?.pagination;
63215
- const initialPaginationRef = useRef24({
63682
+ const initialPaginationRef = useRef25({
63216
63683
  ...getDefaultPaginationState(),
63217
63684
  ...options.initialState?.pagination ?? {}
63218
63685
  });
@@ -63226,15 +63693,15 @@ function useReport(reportIdArg, options = {}) {
63226
63693
  );
63227
63694
  const pagination = controlledPagination ?? internalPagination;
63228
63695
  const paginationActive = paginationInteracted || Boolean(controlledPagination);
63229
- const paginationRef = useRef24(pagination);
63696
+ const paginationRef = useRef25(pagination);
63230
63697
  paginationRef.current = pagination;
63231
- const onPaginationChangeRef = useRef24(options.onPaginationChange);
63698
+ const onPaginationChangeRef = useRef25(options.onPaginationChange);
63232
63699
  onPaginationChangeRef.current = options.onPaginationChange;
63233
- const controlledPaginationRef = useRef24(Boolean(controlledPagination));
63700
+ const controlledPaginationRef = useRef25(Boolean(controlledPagination));
63234
63701
  controlledPaginationRef.current = Boolean(controlledPagination);
63235
- const autoResetPageIndexRef = useRef24(true);
63702
+ const autoResetPageIndexRef = useRef25(true);
63236
63703
  autoResetPageIndexRef.current = options.autoResetPageIndex ?? true;
63237
- const paginationPageCountRef = useRef24(-1);
63704
+ const paginationPageCountRef = useRef25(-1);
63238
63705
  const applyPaginationUpdate = useCallback5(
63239
63706
  (updater, { activate = true } = {}) => {
63240
63707
  if (activate) {
@@ -63303,13 +63770,13 @@ function useReport(reportIdArg, options = {}) {
63303
63770
  () => setPageIndex(paginationPageCountRef.current - 1),
63304
63771
  [setPageIndex]
63305
63772
  );
63306
- const chartPivotHydratedFromSourceRef = useRef24(false);
63307
- const lastPivotHydrateCompletedSourceIdRef = useRef24(null);
63308
- const groupRowsBySetViaSetReportRef = useRef24(false);
63309
- const groupColumnsBySetViaSetReportRef = useRef24(false);
63310
- const dateBucketSetViaSetReportRef = useRef24(false);
63311
- const aggregationStateSetViaSetReportRef = useRef24(false);
63312
- const prevReportIdForChartPivotHydrationRef = useRef24(effectiveReportId);
63773
+ const chartPivotHydratedFromSourceRef = useRef25(false);
63774
+ const lastPivotHydrateCompletedSourceIdRef = useRef25(null);
63775
+ const groupRowsBySetViaSetReportRef = useRef25(false);
63776
+ const groupColumnsBySetViaSetReportRef = useRef25(false);
63777
+ const dateBucketSetViaSetReportRef = useRef25(false);
63778
+ const aggregationStateSetViaSetReportRef = useRef25(false);
63779
+ const prevReportIdForChartPivotHydrationRef = useRef25(effectiveReportId);
63313
63780
  if (prevReportIdForChartPivotHydrationRef.current !== effectiveReportId) {
63314
63781
  prevReportIdForChartPivotHydrationRef.current = effectiveReportId;
63315
63782
  chartPivotHydratedFromSourceRef.current = false;
@@ -63323,11 +63790,11 @@ function useReport(reportIdArg, options = {}) {
63323
63790
  expandReportBuilderColumnsForFlatTable,
63324
63791
  setExpandReportBuilderColumnsForFlatTable
63325
63792
  ] = useState41(false);
63326
- const prevPivotStateForColumnExpansionRef = useRef24(null);
63793
+ const prevPivotStateForColumnExpansionRef = useRef25(null);
63327
63794
  const [sourceReport, setSourceReport] = useState41(
63328
63795
  null
63329
63796
  );
63330
- const prevSourceReportIdForPivotHydrationRef = useRef24(null);
63797
+ const prevSourceReportIdForPivotHydrationRef = useRef25(null);
63331
63798
  {
63332
63799
  const currentSourceId = sourceReport ? String(
63333
63800
  sourceReport.id ?? sourceReport._id ?? ""
@@ -63413,7 +63880,7 @@ function useReport(reportIdArg, options = {}) {
63413
63880
  const dashboardNameForNewReport = useMemo32(() => {
63414
63881
  return [clientDefaultDashboardName, destinationDashboardName].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
63415
63882
  }, [clientDefaultDashboardName, destinationDashboardName]);
63416
- const filterStackRef = useRef24(filterStack);
63883
+ const filterStackRef = useRef25(filterStack);
63417
63884
  filterStackRef.current = filterStack;
63418
63885
  const resolvedGroupRowsBy = decodePivotGroupOptionValue(groupRowsBy);
63419
63886
  const resolvedGroupColumnsBy = decodePivotGroupOptionValue(groupColumnsBy);
@@ -63428,8 +63895,8 @@ function useReport(reportIdArg, options = {}) {
63428
63895
  setChartAxisEdits({});
63429
63896
  setChartVisibilityOverrides({});
63430
63897
  }, [effectiveReportId]);
63431
- const bootstrapReportTaskUsedForReportIdRef = useRef24(null);
63432
- const schemaScopeInitializedForReportIdRef = useRef24(null);
63898
+ const bootstrapReportTaskUsedForReportIdRef = useRef25(null);
63899
+ const schemaScopeInitializedForReportIdRef = useRef25(null);
63433
63900
  const initializeSchemaScopeForReport = (report) => {
63434
63901
  if (!report) return;
63435
63902
  if (schemaScopeInitializedForReportIdRef.current === effectiveReportId)
@@ -63457,8 +63924,8 @@ function useReport(reportIdArg, options = {}) {
63457
63924
  }
63458
63925
  return schemaData.schema ?? [];
63459
63926
  }, [schemaData.schema, schemaData.schemaWithCustomFields]);
63460
- const schemaForReportBuilderStateRef = useRef24(schemaForReportBuilderState);
63461
- const customFieldsRef = useRef24(schemaData.customFields);
63927
+ const schemaForReportBuilderStateRef = useRef25(schemaForReportBuilderState);
63928
+ const customFieldsRef = useRef25(schemaData.customFields);
63462
63929
  schemaForReportBuilderStateRef.current = schemaForReportBuilderState;
63463
63930
  customFieldsRef.current = schemaData.customFields;
63464
63931
  const isBoolAggregationField = useCallback5(
@@ -64273,8 +64740,8 @@ function useReport(reportIdArg, options = {}) {
64273
64740
  queryBuilderFieldConfigByName,
64274
64741
  queryFilters
64275
64742
  ]);
64276
- const filterFieldsStableReportIdRef = useRef24("");
64277
- const filterFieldsStableCacheRef = useRef24([]);
64743
+ const filterFieldsStableReportIdRef = useRef25("");
64744
+ const filterFieldsStableCacheRef = useRef25([]);
64278
64745
  const filterFields = useMemo32(() => {
64279
64746
  const rid = String(effectiveReportId ?? "");
64280
64747
  if (filterFieldsStableReportIdRef.current !== rid) {
@@ -64506,6 +64973,8 @@ function useReport(reportIdArg, options = {}) {
64506
64973
  clientHash
64507
64974
  }),
64508
64975
  queryFn: createUseFormQueryFn(async () => {
64976
+ taskDebugLoadRequestIdRef.current += 1;
64977
+ const debugLoadRequestId = taskDebugLoadRequestIdRef.current;
64509
64978
  const allowReportTaskBootstrap = !initialReportBuilderState && bootstrapReportTaskUsedForReportIdRef.current !== effectiveReportId;
64510
64979
  const loadTargetId = String(effectiveReportId ?? "").trim();
64511
64980
  const sourceReportIdentity = String(
@@ -64529,6 +64998,9 @@ function useReport(reportIdArg, options = {}) {
64529
64998
  customFields: customFieldsRef.current,
64530
64999
  dashboardName: resolvedSourceDashboardName,
64531
65000
  useInMemoryEngines,
65001
+ debugSource: "initial-load",
65002
+ debugRunId: taskDebugRunId,
65003
+ debugLoadRequestId,
64532
65004
  draftSessionId: draftSessionId || void 0
64533
65005
  });
64534
65006
  return loadResult;
@@ -65158,7 +65630,7 @@ function useReport(reportIdArg, options = {}) {
65158
65630
  () => stableSerializeForQueryKey(effectiveReportBuilderState),
65159
65631
  [effectiveReportBuilderState]
65160
65632
  );
65161
- const prevPaginationResetStateHashRef = useRef24(null);
65633
+ const prevPaginationResetStateHashRef = useRef25(null);
65162
65634
  useEffect31(() => {
65163
65635
  const prevHash = prevPaginationResetStateHashRef.current;
65164
65636
  prevPaginationResetStateHashRef.current = effectiveReportBuilderStateHash;
@@ -65836,6 +66308,7 @@ function useReport(reportIdArg, options = {}) {
65836
66308
  ...sourceReport,
65837
66309
  reportBuilderState: effectiveReportBuilderState
65838
66310
  };
66311
+ taskDebugLoadRequestIdRef.current += 1;
65839
66312
  const pivotRefreshResult = await loadReportForUseForm({
65840
66313
  reportId: effectiveReportId,
65841
66314
  initialReportBuilderState: effectiveReportBuilderState,
@@ -65851,6 +66324,9 @@ function useReport(reportIdArg, options = {}) {
65851
66324
  customFields: schemaData.customFields,
65852
66325
  dashboardName: resolvedSourceDashboardName,
65853
66326
  useInMemoryEngines,
66327
+ debugSource: "pivot-refresh",
66328
+ debugRunId: taskDebugRunId,
66329
+ debugLoadRequestId: taskDebugLoadRequestIdRef.current,
65854
66330
  draftSessionId: draftSessionId || void 0
65855
66331
  });
65856
66332
  return pivotRefreshResult;
@@ -65995,6 +66471,9 @@ function useReport(reportIdArg, options = {}) {
65995
66471
  return {
65996
66472
  ...previousReport,
65997
66473
  ...report,
66474
+ xAxisFormat: previousReport.xAxisFormat,
66475
+ columns: previousReport.columns,
66476
+ yAxisFields: previousReport.yAxisFields,
65998
66477
  pivot: previousReport.pivot,
65999
66478
  pivotRows: previousReport.pivotRows,
66000
66479
  pivotColumns: previousReport.pivotColumns,
@@ -66131,8 +66610,8 @@ function useReport(reportIdArg, options = {}) {
66131
66610
  for (const column of chartAxesBaseChart.columns ?? []) {
66132
66611
  registerOption(column.field, column.label, column.format);
66133
66612
  }
66134
- for (const yAxis of chartAxesBaseChart.yAxisFields ?? []) {
66135
- registerOption(yAxis.field, yAxis.label, yAxis.format);
66613
+ for (const yAxis2 of chartAxesBaseChart.yAxisFields ?? []) {
66614
+ registerOption(yAxis2.field, yAxis2.label, yAxis2.format);
66136
66615
  }
66137
66616
  if (chartAxesBaseChart.pivot?.columnField) {
66138
66617
  for (const aggregationAxis of buildPivotAggregationAxisFields(
@@ -66355,48 +66834,35 @@ function useReport(reportIdArg, options = {}) {
66355
66834
  }),
66356
66835
  [baseChart?.showLegend, chartVisibilityOverrides]
66357
66836
  );
66358
- const axisConfig = useMemo32(() => {
66837
+ const xAxis = useMemo32(() => {
66359
66838
  const pivotBucketXAxis = isPivotTableDateBucketRowAxis(
66360
66839
  chartAxesBaseChart,
66361
66840
  resolvedXAxisField
66362
66841
  );
66363
66842
  const xFormatLabel = pivotBucketXAxis && String(resolvedXAxisFormat ?? "").trim() === "string" ? "date" : axisFormatToSelectLabel(resolvedXAxisFormat);
66364
66843
  return {
66365
- xAxis: {
66366
- field: resolvedXAxisField,
66367
- label: resolvedXAxisLabel,
66368
- format: xFormatLabel,
66369
- show: true,
66370
- rotation: 0,
66371
- fontSize: 12
66372
- },
66373
- yAxis: {
66374
- fields: resolvedYAxisFields.map((yAxisField, index) => ({
66375
- field: yAxisField.field,
66376
- label: String(yAxisField.label ?? "").trim(),
66377
- format: axisFormatToSelectLabel(
66378
- toAxisFormat(yAxisField.format, "string")
66379
- ),
66380
- color: USE_FORM_AXIS_SERIES_COLORS[index % USE_FORM_AXIS_SERIES_COLORS.length]
66381
- })),
66382
- label: "",
66383
- show: true,
66384
- min: "",
66385
- max: "",
66386
- fontSize: 12
66387
- },
66388
- legend: {
66389
- show: chartVisibility.showLegend
66390
- }
66844
+ field: resolvedXAxisField,
66845
+ label: resolvedXAxisLabel,
66846
+ format: xFormatLabel
66391
66847
  };
66392
66848
  }, [
66393
66849
  chartAxesBaseChart,
66394
66850
  resolvedXAxisLabel,
66395
66851
  resolvedXAxisField,
66396
- resolvedXAxisFormat,
66397
- resolvedYAxisFields,
66398
- chartVisibility.showLegend
66852
+ resolvedXAxisFormat
66399
66853
  ]);
66854
+ const yAxis = useMemo32(
66855
+ () => ({
66856
+ fields: resolvedYAxisFields.map((yAxisField) => ({
66857
+ field: yAxisField.field,
66858
+ label: String(yAxisField.label ?? "").trim(),
66859
+ format: axisFormatToSelectLabel(
66860
+ toAxisFormat(yAxisField.format, "string")
66861
+ )
66862
+ }))
66863
+ }),
66864
+ [resolvedYAxisFields]
66865
+ );
66400
66866
  const resolvedYAxisFieldsForDisplay = useMemo32(() => {
66401
66867
  if (!baseChart) return resolvedYAxisFields;
66402
66868
  return mapResolvedPivotYAxisFieldsForDisplay({
@@ -66453,6 +66919,124 @@ function useReport(reportIdArg, options = {}) {
66453
66919
  resolvedXAxisLabel,
66454
66920
  resolvedYAxisFieldsForDisplay
66455
66921
  ]);
66922
+ const filterOptions = useMemo32(() => {
66923
+ const out = [];
66924
+ for (const [field, values] of filterValueOptionsByFieldName) {
66925
+ out.push({
66926
+ field,
66927
+ fieldType: "string",
66928
+ operator: "in",
66929
+ options: values.map(({ label, value }) => ({ label, value }))
66930
+ });
66931
+ }
66932
+ const pivot = chart?.pivot;
66933
+ const rowField = String(pivot?.rowField ?? "").trim();
66934
+ if (rowField && isDateType(String(pivot?.rowFieldType ?? ""))) {
66935
+ const field = pivot?.rowFieldTable ? `${pivot.rowFieldTable}.${rowField}` : rowField;
66936
+ const bucket = dateBucket || pivot?.dateBucket || "month";
66937
+ const byRaw = /* @__PURE__ */ new Map();
66938
+ for (const row of chart?.rows ?? []) {
66939
+ const record = row;
66940
+ const raw = record.__quillRawDate;
66941
+ if (raw == null || raw === "") continue;
66942
+ const key = String(raw);
66943
+ if (!byRaw.has(key)) {
66944
+ byRaw.set(key, String(record[rowField] ?? key));
66945
+ }
66946
+ }
66947
+ out.push({
66948
+ field,
66949
+ fieldType: "date",
66950
+ operator: "inBucket",
66951
+ dateBucket: bucket,
66952
+ options: [...byRaw.keys()].sort().map((value) => ({
66953
+ value,
66954
+ label: byRaw.get(value) ?? value
66955
+ }))
66956
+ });
66957
+ }
66958
+ return out;
66959
+ }, [
66960
+ chart?.pivot,
66961
+ chart?.rows,
66962
+ dateBucket,
66963
+ filterValueOptionsByFieldName
66964
+ ]);
66965
+ const chartForUi = useMemo32(() => {
66966
+ if (!chart?.pivot) return chart;
66967
+ const pivot = chart.pivot;
66968
+ const qualify = (field, table2) => table2 ? `${table2}.${field}` : field;
66969
+ const labelFor = (field) => chart.columns?.find((column) => column.field === field)?.label ?? field.split(".").pop().replace(/[_-]+/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());
66970
+ const matchField = (entryField, field, table2) => {
66971
+ const qualified = qualify(field, table2);
66972
+ return entryField === qualified || entryField === field || entryField.endsWith(`.${field}`);
66973
+ };
66974
+ const selectedValue = (field, operator, options2) => {
66975
+ const rule = filtersForQueryBuilder.rules.find(
66976
+ (entry) => typeof entry === "object" && entry !== null && "field" in entry && entry.field === field && entry.operator === operator
66977
+ );
66978
+ if (!rule) return null;
66979
+ const raw = operator === "inBucket" ? rule.value?.start : Array.isArray(rule.value) ? rule.value[0] : void 0;
66980
+ if (raw == null) return null;
66981
+ const value = String(raw);
66982
+ return options2.some((option) => option.value === value) ? value : null;
66983
+ };
66984
+ let rowFilter = null;
66985
+ const rowField = String(pivot.rowField ?? "").trim();
66986
+ if (rowField) {
66987
+ if (isDateType(String(pivot.rowFieldType ?? ""))) {
66988
+ const entry = filterOptions.find(
66989
+ (option) => option.operator === "inBucket" && matchField(option.field, rowField, pivot.rowFieldTable)
66990
+ );
66991
+ if (entry) {
66992
+ const field = qualify(rowField, pivot.rowFieldTable);
66993
+ rowFilter = {
66994
+ ...entry,
66995
+ field,
66996
+ label: labelFor(rowField),
66997
+ value: selectedValue(field, entry.operator, entry.options)
66998
+ };
66999
+ }
67000
+ } else {
67001
+ const entry = filterOptions.find(
67002
+ (option) => option.operator === "in" && matchField(option.field, rowField, pivot.rowFieldTable)
67003
+ );
67004
+ if (entry) {
67005
+ const field = qualify(rowField, pivot.rowFieldTable);
67006
+ rowFilter = {
67007
+ ...entry,
67008
+ field,
67009
+ label: labelFor(rowField),
67010
+ value: selectedValue(field, entry.operator, entry.options)
67011
+ };
67012
+ }
67013
+ }
67014
+ }
67015
+ let columnFilter = null;
67016
+ const columnField = String(pivot.columnField ?? "").trim();
67017
+ if (columnField) {
67018
+ const entry = filterOptions.find(
67019
+ (option) => option.operator === "in" && matchField(option.field, columnField, pivot.columnFieldTable)
67020
+ );
67021
+ if (entry) {
67022
+ const field = qualify(columnField, pivot.columnFieldTable);
67023
+ columnFilter = {
67024
+ ...entry,
67025
+ field,
67026
+ label: labelFor(columnField),
67027
+ value: selectedValue(field, entry.operator, entry.options)
67028
+ };
67029
+ }
67030
+ }
67031
+ return {
67032
+ ...chart,
67033
+ pivot: {
67034
+ ...pivot,
67035
+ rowFilter,
67036
+ columnFilter
67037
+ }
67038
+ };
67039
+ }, [chart, filterOptions, filtersForQueryBuilder]);
66456
67040
  const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(
66457
67041
  chart && chart.pivot && Array.isArray(chart.columns) && chart.columns.length > 0
66458
67042
  );
@@ -66605,7 +67189,7 @@ function useReport(reportIdArg, options = {}) {
66605
67189
  xAxisOptions,
66606
67190
  yAxisOptions
66607
67191
  ]);
66608
- const tableFormatCacheRef = useRef24(/* @__PURE__ */ new Map());
67192
+ const tableFormatCacheRef = useRef25(/* @__PURE__ */ new Map());
66609
67193
  const tableFormatMerge = useMemo32(
66610
67194
  () => mergeDisplayAndSourceForTableFormats({
66611
67195
  effectiveReportBuilderTableNames,
@@ -66783,14 +67367,6 @@ function useReport(reportIdArg, options = {}) {
66783
67367
  schemaColumnOptions,
66784
67368
  table.columns
66785
67369
  ]);
66786
- const availableFields = useMemo32(
66787
- () => tableColumnPickerPoolOptions.map((option) => ({
66788
- id: option.value,
66789
- label: option.label,
66790
- type: option.type
66791
- })),
66792
- [tableColumnPickerPoolOptions]
66793
- );
66794
67370
  const axisSelectFormatLabels = useMemo32(
66795
67371
  () => AXIS_FORMAT_OPTIONS.map((option) => option.label),
66796
67372
  []
@@ -66988,7 +67564,7 @@ function useReport(reportIdArg, options = {}) {
66988
67564
  sourceReport?.columns,
66989
67565
  tableFormatMerge
66990
67566
  ]);
66991
- const tableColumnSettingsCoalesceRef = useRef24(
67567
+ const tableColumnSettingsCoalesceRef = useRef25(
66992
67568
  /* @__PURE__ */ new Map()
66993
67569
  );
66994
67570
  useLayoutEffect4(() => {
@@ -67236,8 +67812,12 @@ function useReport(reportIdArg, options = {}) {
67236
67812
  showLegend: Boolean(effectiveNextState.showLegend)
67237
67813
  }));
67238
67814
  }
67239
- if (effectiveNextState.chartAxes !== void 0) {
67240
- const cx = effectiveNextState.chartAxes;
67815
+ if (effectiveNextState.xAxis !== void 0 || effectiveNextState.yAxis !== void 0 || effectiveNextState.chartAxes !== void 0) {
67816
+ const cx = {
67817
+ ...effectiveNextState.chartAxes,
67818
+ ...effectiveNextState.xAxis !== void 0 ? { xAxis: effectiveNextState.xAxis } : {},
67819
+ ...effectiveNextState.yAxis !== void 0 ? { yAxis: effectiveNextState.yAxis } : {}
67820
+ };
67241
67821
  setChartAxisEdits((previousEdits) => {
67242
67822
  const nextEdits = { ...previousEdits };
67243
67823
  if (cx.xAxis) {
@@ -67757,8 +68337,9 @@ function useReport(reportIdArg, options = {}) {
67757
68337
  }
67758
68338
  };
67759
68339
  const setFilters = (nextFilters) => {
68340
+ const resolved = typeof nextFilters === "function" ? nextFilters(filtersForQueryBuilder) : nextFilters;
67760
68341
  const preparedForStack = prepareQueryBuilderFiltersForSet(
67761
- nextFilters,
68342
+ resolved,
67762
68343
  queryFilters
67763
68344
  );
67764
68345
  const nextFiltersNormalizedForConfig = normalizeQueryBuilderFiltersForConfig(preparedForStack);
@@ -67799,17 +68380,16 @@ function useReport(reportIdArg, options = {}) {
67799
68380
  });
67800
68381
  }
67801
68382
  } catch (error) {
67802
- if (isUseFormFiltersDebugEnabled()) {
67803
- console.error("[useForm-debug] setFilters swallowed error", {
67804
- error: error instanceof Error ? error.message : String(error),
67805
- requestedRules: (nextFilters?.rules ?? []).map((rule) => ({
67806
- table: rule?.table,
67807
- field: rule?.field,
67808
- operator: rule?.operator
67809
- })),
67810
- fieldConfigKeys: Object.keys(queryBuilderFieldConfigByName ?? {})
67811
- });
67812
- }
68383
+ console.error("[useForm] setFilters swallowed error", {
68384
+ error: error instanceof Error ? error.message : String(error),
68385
+ requestedRules: (resolved?.rules ?? []).map((rule) => ({
68386
+ table: rule?.table,
68387
+ field: rule?.field,
68388
+ operator: rule?.operator,
68389
+ value: rule?.value
68390
+ })),
68391
+ fieldConfigKeys: Object.keys(queryBuilderFieldConfigByName ?? {})
68392
+ });
67813
68393
  }
67814
68394
  };
67815
68395
  const saveChanges = useCallback5(async () => {
@@ -67871,7 +68451,7 @@ function useReport(reportIdArg, options = {}) {
67871
68451
  ]);
67872
68452
  return {
67873
68453
  /* ── Chart & table (exceptions: not value/options pairs) ── */
67874
- chart,
68454
+ chart: chartForUi,
67875
68455
  chartLoading,
67876
68456
  table,
67877
68457
  tableLoading,
@@ -67909,9 +68489,9 @@ function useReport(reportIdArg, options = {}) {
67909
68489
  columnActions,
67910
68490
  /** Schema columns for current datasources — pool for the table column picker. */
67911
68491
  columnOptions: tableColumnPickerPoolOptions,
67912
- xAxis: chartAxes.xAxis,
68492
+ xAxis,
67913
68493
  xAxisOptions: normalizedChartXAxisOptions,
67914
- yAxis: chartAxes.yAxis,
68494
+ yAxis,
67915
68495
  yAxisOptions: normalizedChartYAxisOptions,
67916
68496
  /** Same strings as `axisSelectFormatLabels` (X/Y share chart format presets). */
67917
68497
  xAxisFormatOptions: xAxisFormatOptionLabels,
@@ -67919,8 +68499,6 @@ function useReport(reportIdArg, options = {}) {
67919
68499
  /** Table column format dropdown labels (same set as chart axis formats). */
67920
68500
  tableFormatOptions: axisSelectFormatLabels,
67921
68501
  showLegend: chartVisibility.showLegend,
67922
- axisConfig,
67923
- availableFields,
67924
68502
  axisSelectFormatLabels,
67925
68503
  /** @deprecated Prefer top-level `xAxis`, `yAxis`, and `showLegend`. */
67926
68504
  chartAxes,
@@ -67933,6 +68511,12 @@ function useReport(reportIdArg, options = {}) {
67933
68511
  hasTableDrivenColumnOrder,
67934
68512
  filters: filtersForQueryBuilder,
67935
68513
  filterQueryBuilderProps,
68514
+ /**
68515
+ * Filter value pick lists for custom UIs (string unique values + pivot date
68516
+ * buckets). Same string data as `filterQueryBuilderProps.getValues`; not
68517
+ * wired into react-querybuilder unless you use it yourself.
68518
+ */
68519
+ filterOptions,
67936
68520
  /** True while `report-builder-unique-values` runs for filter value options (not chart/table load). */
67937
68521
  filterUniqueValuesLoading,
67938
68522
  limit,
@@ -68298,9 +68882,9 @@ function Chat({
68298
68882
  const [inputError, setInputError] = useState42("");
68299
68883
  const [isLoading, setIsLoading] = useState42(false);
68300
68884
  const [model, setModel] = useState42("gemini-3-flash-preview");
68301
- const containerRef = useRef25(null);
68302
- const textareaRef = useRef25(null);
68303
- const abortControllerRef = useRef25(null);
68885
+ const containerRef = useRef26(null);
68886
+ const textareaRef = useRef26(null);
68887
+ const abortControllerRef = useRef26(null);
68304
68888
  useEffect32(() => {
68305
68889
  if (!containerRef.current) {
68306
68890
  return;
@@ -68313,11 +68897,11 @@ function Chat({
68313
68897
  setIsLoading(false);
68314
68898
  };
68315
68899
  const submitDefaultMessage = async (nextMessages, abortController) => {
68316
- const clientId = client.clientId ?? client.publicKey;
68900
+ const clientId = client.id;
68317
68901
  let responseBuffer = "";
68318
68902
  for await (const chunk of quillStream({
68319
68903
  client: {
68320
- clientId,
68904
+ id: clientId,
68321
68905
  queryEndpoint: client.queryEndpoint,
68322
68906
  streamEndpoint: client.streamEndpoint,
68323
68907
  queryHeaders: client.queryHeaders,
@@ -68401,12 +68985,12 @@ function Chat({
68401
68985
  }
68402
68986
  };
68403
68987
  const submitAgentMessage = async (nextMessages, abortController) => {
68404
- const clientId = client.clientId ?? client.publicKey;
68988
+ const clientId = client.id;
68405
68989
  let updatedMessages = [...nextMessages];
68406
68990
  for await (const event of quillAgentStream({
68407
68991
  endpoint: `${agentEndpoint}/agent/chat`,
68408
68992
  messages: updatedMessages,
68409
- sourceClientId: clientId,
68993
+ sourceClientId: clientId ?? "<unknown>",
68410
68994
  getToken,
68411
68995
  abortSignal: abortController.signal
68412
68996
  })) {
@@ -68474,7 +69058,7 @@ function Chat({
68474
69058
  setIsLoading(true);
68475
69059
  const abortController = new AbortController();
68476
69060
  abortControllerRef.current = abortController;
68477
- const clientId = client.clientId ?? client.publicKey;
69061
+ const clientId = client.id;
68478
69062
  if (!clientId) {
68479
69063
  setInputError("No client selected.");
68480
69064
  setIsLoading(false);
@@ -68735,7 +69319,7 @@ function Chat({
68735
69319
  }
68736
69320
 
68737
69321
  // src/hooks/useReportFilterDraft.ts
68738
- import { useCallback as useCallback6, useMemo as useMemo34, useRef as useRef26, useState as useState43 } from "react";
69322
+ import { useCallback as useCallback6, useMemo as useMemo34, useRef as useRef27, useState as useState43 } from "react";
68739
69323
  var normalizeOperatorKey = (operator) => String(operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
68740
69324
  var defaultFilterRuleValueForOperator = (operator) => {
68741
69325
  const key = normalizeOperatorKey(operator);
@@ -68771,13 +69355,15 @@ var committedFiltersSignature = (committed) => {
68771
69355
  };
68772
69356
  function useReportFilterDraft(args) {
68773
69357
  const { reportId, committedFilters, queryBuilderProps, setFilters } = args;
68774
- const committed = isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS;
68775
- const committedRef = useRef26(committed);
69358
+ const committed = queryBuilderFiltersForEditor(
69359
+ isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS
69360
+ );
69361
+ const committedRef = useRef27(committed);
68776
69362
  committedRef.current = committed;
68777
- const setFiltersRef = useRef26(setFilters);
69363
+ const setFiltersRef = useRef27(setFilters);
68778
69364
  setFiltersRef.current = setFilters;
68779
- const lastNonEmptyFieldsRef = useRef26([]);
68780
- const prevReportIdForFieldsRef = useRef26(reportId);
69365
+ const lastNonEmptyFieldsRef = useRef27([]);
69366
+ const prevReportIdForFieldsRef = useRef27(reportId);
68781
69367
  if (prevReportIdForFieldsRef.current !== reportId) {
68782
69368
  prevReportIdForFieldsRef.current = reportId;
68783
69369
  lastNonEmptyFieldsRef.current = [];
@@ -68799,7 +69385,7 @@ function useReportFilterDraft(args) {
68799
69385
  const [draftQuery, setDraftQuery] = useState43(committed);
68800
69386
  const [hasUnappliedFilterChanges, setHasUnappliedFilterChanges] = useState43(false);
68801
69387
  const draftResetKey = `${reportId}|${committedSignature}|${resetEpoch}`;
68802
- const prevDraftResetKeyRef = useRef26(draftResetKey);
69388
+ const prevDraftResetKeyRef = useRef27(draftResetKey);
68803
69389
  if (prevDraftResetKeyRef.current !== draftResetKey) {
68804
69390
  prevDraftResetKeyRef.current = draftResetKey;
68805
69391
  setDraftQuery(committed);
@@ -68826,6 +69412,12 @@ function useReportFilterDraft(args) {
68826
69412
  setHasUnappliedFilterChanges(false);
68827
69413
  setResetEpoch((epoch) => epoch + 1);
68828
69414
  }, []);
69415
+ const getDefaultField = useCallback6((fields) => {
69416
+ const stringField = fields.find(
69417
+ (field) => field.quillFieldType === "string" && String(field.name ?? "").trim()
69418
+ );
69419
+ return stringField?.name ?? fields[0]?.name ?? "";
69420
+ }, []);
68829
69421
  const getDefaultValue = useCallback6(
68830
69422
  (rule) => defaultFilterRuleValueForOperator(rule?.operator),
68831
69423
  []
@@ -68836,9 +69428,12 @@ function useReportFilterDraft(args) {
68836
69428
  fields: effectiveFields,
68837
69429
  // Uncontrolled: react-querybuilder owns the draft; only read at mount,
68838
69430
  // while state keeps the next mount hydrated from the latest edits.
68839
- defaultQuery: draftQuery,
69431
+ // Empty draft: omit defaultQuery so addRuleToNewGroups seeds a root rule
69432
+ // (RQB ignores auto-add when defaultQuery.rules is []).
69433
+ ...draftQuery.rules.length > 0 ? { defaultQuery: draftQuery } : {},
68840
69434
  onQueryChange: handleQueryChange,
68841
69435
  addRuleToNewGroups: true,
69436
+ getDefaultField,
68842
69437
  getDefaultValue
68843
69438
  }),
68844
69439
  // eslint-disable-next-line react-hooks/exhaustive-deps -- filterDraftKey covers draftRef resets
@@ -68847,6 +69442,7 @@ function useReportFilterDraft(args) {
68847
69442
  effectiveFields,
68848
69443
  draftQuery,
68849
69444
  handleQueryChange,
69445
+ getDefaultField,
68850
69446
  getDefaultValue,
68851
69447
  filterDraftKey
68852
69448
  ]
@@ -68882,7 +69478,7 @@ function useReportQueryBuilder(args) {
68882
69478
  import {
68883
69479
  useContext as useContext38,
68884
69480
  useLayoutEffect as useLayoutEffect5,
68885
- useRef as useRef27,
69481
+ useRef as useRef28,
68886
69482
  useState as useState44
68887
69483
  } from "react";
68888
69484
  import { jsx as jsx89, jsxs as jsxs66 } from "react/jsx-runtime";
@@ -68983,7 +69579,7 @@ function ReportDetail({
68983
69579
  const isTableChart = type === "table";
68984
69580
  const useDetailTableFromUseForm = isTableChart && !isPivotTableChartConfig(chart);
68985
69581
  const showBottomRawTable = !isTableChart;
68986
- const chartSlotRef = useRef27(null);
69582
+ const chartSlotRef = useRef28(null);
68987
69583
  const [chartHeightPx, setChartHeightPx] = useState44(360);
68988
69584
  useLayoutEffect5(() => {
68989
69585
  const el = chartSlotRef.current;
@@ -69735,7 +70331,7 @@ var useVirtualTables = () => {
69735
70331
  };
69736
70332
  };
69737
70333
  const handleRefreshSome = async (client, tables) => {
69738
- if (!client.clientId) return schemaData;
70334
+ if (!client.id) return schemaData;
69739
70335
  setLoadingTables({
69740
70336
  ...loadingTables,
69741
70337
  ...tables.reduce((acc, table) => {
@@ -69753,7 +70349,7 @@ var useVirtualTables = () => {
69753
70349
  name: table.name,
69754
70350
  customFieldInfo: table.customFieldInfo,
69755
70351
  id: table._id,
69756
- clientId: client.clientId,
70352
+ clientId: client.id,
69757
70353
  runQueryConfig: { getColumns: true },
69758
70354
  databaseType: client.databaseType,
69759
70355
  useNewNodeSql: true
@@ -69901,11 +70497,12 @@ var useChangelogRefresh = () => {
69901
70497
  reportsDispatch({ type: "DELETE_REPORT", id: reportId });
69902
70498
  dashboardDispatch({ type: "REMOVE_DASHBOARD_ITEM", id: reportId });
69903
70499
  }
69904
- const finalDashboardSet = reloadAllDashboards ? new Set(
69905
- Object.keys(dashboardConfig).filter(
70500
+ const finalDashboardSet = reloadAllDashboards ? /* @__PURE__ */ new Set([
70501
+ ...Object.keys(dashboardConfig).filter(
69906
70502
  (d) => !dashboardsToRemove.has(d)
69907
- )
69908
- ) : dashboardsToReload;
70503
+ ),
70504
+ ...dashboardsToReload
70505
+ ]) : dashboardsToReload;
69909
70506
  const tasks = [];
69910
70507
  const schemaIdsToReload = schemaIds.filter(
69911
70508
  (id) => !schemaIdsToRemove.has(id)
@@ -70020,6 +70617,7 @@ export {
70020
70617
  isQueryBuilderDisplayRule,
70021
70618
  normalizeRelativeDateRules,
70022
70619
  prepareQueryBuilderFiltersForSet,
70620
+ queryBuilderFiltersForEditor,
70023
70621
  quillFetch,
70024
70622
  stripQueryBuilderTransientFields,
70025
70623
  tableColumnFormatFromUiSelection,