@quillsql/react 2.16.47 → 2.16.49

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
@@ -58633,23 +58633,23 @@ function ChartEditor({
58633
58633
  }
58634
58634
 
58635
58635
  // src/Chat.tsx
58636
- import { useContext as useContext37, useEffect as useEffect32, useRef as useRef26, useState as useState43 } from "react";
58636
+ import { useContext as useContext37, useEffect as useEffect32, useRef as useRef25, useState as useState42 } from "react";
58637
58637
 
58638
58638
  // src/ChatChartCard.tsx
58639
- import { useMemo as useMemo34 } from "react";
58639
+ import { useMemo as useMemo33 } from "react";
58640
58640
 
58641
58641
  // src/hooks/useForm.tsx
58642
58642
  init_Filter();
58643
58643
  init_ReportBuilder();
58644
58644
  import {
58645
- useCallback as useCallback6,
58645
+ useCallback as useCallback5,
58646
58646
  useContext as useContext36,
58647
58647
  useEffect as useEffect31,
58648
58648
  useLayoutEffect as useLayoutEffect4,
58649
- useMemo as useMemo33,
58649
+ useMemo as useMemo32,
58650
58650
  useReducer as useReducer2,
58651
- useRef as useRef25,
58652
- useState as useState42
58651
+ useRef as useRef24,
58652
+ useState as useState41
58653
58653
  } from "react";
58654
58654
  import { keepPreviousData, useQuery } from "@tanstack/react-query";
58655
58655
  init_util();
@@ -59657,171 +59657,6 @@ function countFilterRules(value) {
59657
59657
  }, 0);
59658
59658
  }
59659
59659
 
59660
- // src/hooks/useReportFilterDraft.ts
59661
- import { useCallback as useCallback5, useMemo as useMemo32, useRef as useRef24, useState as useState41 } from "react";
59662
- var normalizeOperatorKey = (operator) => String(operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
59663
- var defaultFilterRuleValueForOperator = (operator) => {
59664
- const key = normalizeOperatorKey(operator);
59665
- if (key === "in" || key === "notin") {
59666
- return [];
59667
- }
59668
- return "";
59669
- };
59670
- var buildSeededFilterQuery = (queryBuilderProps) => {
59671
- const fieldData = queryBuilderProps?.fields?.[0];
59672
- const fieldName = String(fieldData?.name ?? "").trim();
59673
- let operator = "in";
59674
- const firstOperator = queryBuilderProps?.getOperators?.(fieldName, {
59675
- fieldData
59676
- })?.[0];
59677
- if (firstOperator) {
59678
- operator = String(firstOperator.name ?? firstOperator.value ?? "in");
59679
- }
59680
- return {
59681
- combinator: "and",
59682
- rules: [
59683
- {
59684
- field: fieldName,
59685
- operator,
59686
- value: defaultFilterRuleValueForOperator(operator)
59687
- }
59688
- ]
59689
- };
59690
- };
59691
- var EMPTY_COMMITTED_FILTERS = {
59692
- combinator: "and",
59693
- rules: []
59694
- };
59695
- var hashString2 = (input) => {
59696
- let hash = 2166136261;
59697
- for (let i = 0; i < input.length; i++) {
59698
- hash ^= input.charCodeAt(i);
59699
- hash = Math.imul(hash, 16777619);
59700
- }
59701
- return String(hash >>> 0);
59702
- };
59703
- var fieldCatalogSignature = (fields) => {
59704
- const names = fields.map((field) => String(field.name ?? "").trim()).filter(Boolean).sort();
59705
- return `${names.length}:${hashString2(names.join("\0"))}`;
59706
- };
59707
- var committedFiltersSignature = (committed) => {
59708
- try {
59709
- return hashString2(
59710
- JSON.stringify(stripQueryBuilderTransientFields(committed))
59711
- );
59712
- } catch {
59713
- return "unserializable";
59714
- }
59715
- };
59716
- function useReportFilterDraft(args) {
59717
- const { reportId, committedFilters, queryBuilderProps, setFilters } = args;
59718
- const committed = isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS;
59719
- const committedRef = useRef24(committed);
59720
- committedRef.current = committed;
59721
- const setFiltersRef = useRef24(setFilters);
59722
- setFiltersRef.current = setFilters;
59723
- const lastNonEmptyFieldsRef = useRef24([]);
59724
- const prevReportIdForFieldsRef = useRef24(reportId);
59725
- if (prevReportIdForFieldsRef.current !== reportId) {
59726
- prevReportIdForFieldsRef.current = reportId;
59727
- lastNonEmptyFieldsRef.current = [];
59728
- }
59729
- if (queryBuilderProps.fields.length > 0) {
59730
- lastNonEmptyFieldsRef.current = queryBuilderProps.fields;
59731
- }
59732
- const effectiveFields = queryBuilderProps.fields.length > 0 ? queryBuilderProps.fields : lastNonEmptyFieldsRef.current;
59733
- const effectiveFieldsRef = useRef24(effectiveFields);
59734
- effectiveFieldsRef.current = effectiveFields;
59735
- const getOperatorsRef = useRef24(queryBuilderProps.getOperators);
59736
- getOperatorsRef.current = queryBuilderProps.getOperators;
59737
- const committedSignature = useMemo32(
59738
- () => committedFiltersSignature(committed),
59739
- // eslint-disable-next-line react-hooks/exhaustive-deps -- `committed` normalizes null to a stable constant
59740
- [committedFilters]
59741
- );
59742
- const fieldsSignature = useMemo32(
59743
- () => fieldCatalogSignature(effectiveFields),
59744
- [effectiveFields]
59745
- );
59746
- const [resetEpoch, setResetEpoch] = useState41(0);
59747
- const [seedEpoch, setSeedEpoch] = useState41(0);
59748
- const draftRef = useRef24(committed);
59749
- const [isFilterDraftDirty, setIsFilterDraftDirty] = useState41(false);
59750
- const [isFilterDraftEmpty, setIsFilterDraftEmpty] = useState41(
59751
- committed.rules.length === 0
59752
- );
59753
- const draftResetKey = `${reportId}|${committedSignature}|${resetEpoch}`;
59754
- const prevDraftResetKeyRef = useRef24(draftResetKey);
59755
- if (prevDraftResetKeyRef.current !== draftResetKey) {
59756
- prevDraftResetKeyRef.current = draftResetKey;
59757
- draftRef.current = committed;
59758
- const nextEmpty = committed.rules.length === 0;
59759
- if (isFilterDraftDirty) setIsFilterDraftDirty(false);
59760
- if (isFilterDraftEmpty !== nextEmpty) setIsFilterDraftEmpty(nextEmpty);
59761
- }
59762
- const filterDraftKey = `${draftResetKey}|${seedEpoch}|${fieldsSignature}`;
59763
- const handleQueryChange = useCallback5((next) => {
59764
- if (!isQueryBuilderDisplayGroup(next)) return;
59765
- const nextGroup = next;
59766
- draftRef.current = nextGroup;
59767
- const nextDirty = areQueryBuilderFilterDraftsDirty(
59768
- nextGroup,
59769
- committedRef.current
59770
- );
59771
- const nextEmpty = nextGroup.rules.length === 0;
59772
- setIsFilterDraftDirty((prev) => prev === nextDirty ? prev : nextDirty);
59773
- setIsFilterDraftEmpty((prev) => prev === nextEmpty ? prev : nextEmpty);
59774
- }, []);
59775
- const commitFilterDraft = useCallback5(() => {
59776
- setFiltersRef.current(draftRef.current);
59777
- }, []);
59778
- const resetFilterDraft = useCallback5(() => {
59779
- draftRef.current = committedRef.current;
59780
- setIsFilterDraftDirty(false);
59781
- setIsFilterDraftEmpty(committedRef.current.rules.length === 0);
59782
- setResetEpoch((epoch) => epoch + 1);
59783
- }, []);
59784
- const seedFilterDraft = useCallback5(() => {
59785
- const seeded = buildSeededFilterQuery({
59786
- fields: effectiveFieldsRef.current,
59787
- getOperators: getOperatorsRef.current
59788
- });
59789
- draftRef.current = seeded;
59790
- setIsFilterDraftDirty(
59791
- areQueryBuilderFilterDraftsDirty(seeded, committedRef.current)
59792
- );
59793
- setIsFilterDraftEmpty(false);
59794
- setSeedEpoch((epoch) => epoch + 1);
59795
- }, []);
59796
- const getDefaultValue = useCallback5(
59797
- (rule) => defaultFilterRuleValueForOperator(rule?.operator),
59798
- []
59799
- );
59800
- const filterDraftQueryBuilderProps = useMemo32(
59801
- () => ({
59802
- ...queryBuilderProps,
59803
- fields: effectiveFields,
59804
- // Uncontrolled: react-querybuilder owns the draft; only read at mount,
59805
- // so passing the live draft means popover/remount cycles keep edits.
59806
- defaultQuery: draftRef.current,
59807
- onQueryChange: handleQueryChange,
59808
- addRuleToNewGroups: true,
59809
- getDefaultValue
59810
- }),
59811
- // eslint-disable-next-line react-hooks/exhaustive-deps -- filterDraftKey covers draftRef resets
59812
- [queryBuilderProps, effectiveFields, handleQueryChange, getDefaultValue, filterDraftKey]
59813
- );
59814
- return {
59815
- filterDraftKey,
59816
- filterDraftQueryBuilderProps,
59817
- isFilterDraftDirty,
59818
- isFilterDraftEmpty,
59819
- commitFilterDraft,
59820
- resetFilterDraft,
59821
- seedFilterDraft
59822
- };
59823
- }
59824
-
59825
59660
  // src/hooks/useFormRefreshDecision.ts
59826
59661
  var normalize = (value) => String(value ?? "").trim();
59827
59662
  var toColumnKey = (table, field) => `${table}::${field}`;
@@ -60079,6 +59914,13 @@ var AGGREGATION_OPTION_TYPES = [
60079
59914
  var QUERY_BUILDER_MULTI_VALUE_OPERATORS = /* @__PURE__ */ new Set(["in", "notin"]);
60080
59915
  var TABLE_FORMAT_CACHE_MAX_ENTRIES = 5e3;
60081
59916
  var PIVOT_DATE_BUCKET_FORMAT_OPTIONS = ["date"];
59917
+ var PIVOT_DATE_BUCKET_OPTIONS = [
59918
+ { label: "Automatic", value: "" },
59919
+ { label: "Daily", value: "day" },
59920
+ { label: "Weekly", value: "week" },
59921
+ { label: "Monthly", value: "month" },
59922
+ { label: "Yearly", value: "year" }
59923
+ ];
60082
59924
  var AXIS_FORMAT_OPTIONS = [
60083
59925
  { value: "string", label: "string" },
60084
59926
  { value: "whole_number", label: "whole number" },
@@ -60141,6 +59983,10 @@ var logUseFormPivotShapeDebug = (label, payload) => {
60141
59983
  if (!isUseFormPivotShapeDebugEnabled()) return;
60142
59984
  console.log(`[useReport][pivot-shape] ${label}`, payload);
60143
59985
  };
59986
+ var BOOLEAN_FILTER_VALUE_OPTIONS = [
59987
+ { name: "true", label: "True", value: "true" },
59988
+ { name: "false", label: "False", value: "false" }
59989
+ ];
60144
59990
  function canonicalTablesForFilterUniqueValuesQueryKey(tables) {
60145
59991
  return (tables ?? []).map((table) => {
60146
59992
  const name2 = String(table?.name ?? "").trim();
@@ -61087,6 +60933,13 @@ function normalizePivotChartForDisplay(chart) {
61087
60933
  if (aggregation?.aggregationType === "count") {
61088
60934
  return "whole_number";
61089
60935
  }
60936
+ if (aggregation?.aggregationType === "percentage") {
60937
+ const savedFormat = yAxisFormatByField.get(field);
60938
+ if (savedFormat === "percent" || savedFormat === "percentage") {
60939
+ return savedFormat;
60940
+ }
60941
+ return "percentage";
60942
+ }
61090
60943
  const directAxisFormat = yAxisFormatByField.get(field);
61091
60944
  if (directAxisFormat) return directAxisFormat;
61092
60945
  const aggType = aggregation?.aggregationType ? String(aggregation.aggregationType) : void 0;
@@ -62276,9 +62129,6 @@ function getChartTypeOptions2(formData) {
62276
62129
  (elem) => !(formData.pivot && formData.pivot.columnField && (elem === "bar" || elem === "pie" || elem === "US map" || elem === "World map"))
62277
62130
  ).map((elem) => ({ label: elem, value: elem }));
62278
62131
  }
62279
- function isSetReportTableColumnSidebarPatch(columns) {
62280
- return Boolean(columns) && typeof columns === "object" && !Array.isArray(columns) && "patch" in columns && typeof columns.patch === "object" && columns.patch !== null && typeof columns.patch.id === "string";
62281
- }
62282
62132
  function processPivotState(next, options = {}) {
62283
62133
  const {
62284
62134
  nextState,
@@ -62335,7 +62185,10 @@ function processPivotState(next, options = {}) {
62335
62185
  }
62336
62186
  const valueField = String(aggregation.valueField ?? "").trim();
62337
62187
  if (!valueField) {
62338
- return { ...aggregation, aggregationType: "count" };
62188
+ return {
62189
+ ...aggregation,
62190
+ aggregationType: "count"
62191
+ };
62339
62192
  }
62340
62193
  const valueField2 = String(aggregation.valueField2 ?? "").trim();
62341
62194
  if (valueField2 && valueField2 !== valueField) {
@@ -63347,10 +63200,10 @@ function generateDraftSessionId() {
63347
63200
  }
63348
63201
  function useReport(reportIdArg, options = {}) {
63349
63202
  const propReportId = String(reportIdArg ?? "").trim();
63350
- const [createdReportId, setCreatedReportId] = useState42(null);
63203
+ const [createdReportId, setCreatedReportId] = useState41(null);
63351
63204
  const effectiveReportId = propReportId || createdReportId || "";
63352
63205
  const { eventTracking } = useContext36(EventTrackingContext);
63353
- const [draftSessionId, setDraftSessionId] = useState42(generateDraftSessionId);
63206
+ const [draftSessionId, setDraftSessionId] = useState41(generateDraftSessionId);
63354
63207
  const useInMemoryEngines = options.useInMemoryEngines ?? false;
63355
63208
  const restrictFieldOptionsToSelectedDatasources = options.restrictFieldOptionsToSelectedDatasources ?? true;
63356
63209
  const reportOverride = options.reportOverride ?? null;
@@ -63359,30 +63212,30 @@ function useReport(reportIdArg, options = {}) {
63359
63212
  options.destinationDashboardName ?? ""
63360
63213
  ).trim();
63361
63214
  const controlledPagination = options.state?.pagination;
63362
- const initialPaginationRef = useRef25({
63215
+ const initialPaginationRef = useRef24({
63363
63216
  ...getDefaultPaginationState(),
63364
63217
  ...options.initialState?.pagination ?? {}
63365
63218
  });
63366
- const [internalPagination, setInternalPagination] = useState42(
63219
+ const [internalPagination, setInternalPagination] = useState41(
63367
63220
  initialPaginationRef.current
63368
63221
  );
63369
- const [paginationInteracted, setPaginationInteracted] = useState42(
63222
+ const [paginationInteracted, setPaginationInteracted] = useState41(
63370
63223
  () => Boolean(
63371
63224
  options.state?.pagination || options.initialState?.pagination || options.onPaginationChange
63372
63225
  )
63373
63226
  );
63374
63227
  const pagination = controlledPagination ?? internalPagination;
63375
63228
  const paginationActive = paginationInteracted || Boolean(controlledPagination);
63376
- const paginationRef = useRef25(pagination);
63229
+ const paginationRef = useRef24(pagination);
63377
63230
  paginationRef.current = pagination;
63378
- const onPaginationChangeRef = useRef25(options.onPaginationChange);
63231
+ const onPaginationChangeRef = useRef24(options.onPaginationChange);
63379
63232
  onPaginationChangeRef.current = options.onPaginationChange;
63380
- const controlledPaginationRef = useRef25(Boolean(controlledPagination));
63233
+ const controlledPaginationRef = useRef24(Boolean(controlledPagination));
63381
63234
  controlledPaginationRef.current = Boolean(controlledPagination);
63382
- const autoResetPageIndexRef = useRef25(true);
63235
+ const autoResetPageIndexRef = useRef24(true);
63383
63236
  autoResetPageIndexRef.current = options.autoResetPageIndex ?? true;
63384
- const paginationPageCountRef = useRef25(-1);
63385
- const applyPaginationUpdate = useCallback6(
63237
+ const paginationPageCountRef = useRef24(-1);
63238
+ const applyPaginationUpdate = useCallback5(
63386
63239
  (updater, { activate = true } = {}) => {
63387
63240
  if (activate) {
63388
63241
  setPaginationInteracted(true);
@@ -63394,11 +63247,11 @@ function useReport(reportIdArg, options = {}) {
63394
63247
  },
63395
63248
  []
63396
63249
  );
63397
- const setPagination = useCallback6(
63250
+ const setPagination = useCallback5(
63398
63251
  (updater) => applyPaginationUpdate(updater),
63399
63252
  [applyPaginationUpdate]
63400
63253
  );
63401
- const setPageIndex = useCallback6(
63254
+ const setPageIndex = useCallback5(
63402
63255
  (updater) => applyPaginationUpdate((old) => ({
63403
63256
  ...old,
63404
63257
  pageIndex: clampPageIndex(
@@ -63408,7 +63261,7 @@ function useReport(reportIdArg, options = {}) {
63408
63261
  })),
63409
63262
  [applyPaginationUpdate]
63410
63263
  );
63411
- const setPageSize = useCallback6(
63264
+ const setPageSize = useCallback5(
63412
63265
  (updater) => applyPaginationUpdate(
63413
63266
  (old) => paginationStateAfterPageSizeChange(
63414
63267
  old,
@@ -63417,62 +63270,64 @@ function useReport(reportIdArg, options = {}) {
63417
63270
  ),
63418
63271
  [applyPaginationUpdate]
63419
63272
  );
63420
- const resetPagination = useCallback6(
63273
+ const resetPagination = useCallback5(
63421
63274
  (defaultState) => applyPaginationUpdate(
63422
63275
  defaultState ? getDefaultPaginationState() : initialPaginationRef.current
63423
63276
  ),
63424
63277
  [applyPaginationUpdate]
63425
63278
  );
63426
- const resetPageIndex = useCallback6(
63279
+ const resetPageIndex = useCallback5(
63427
63280
  (defaultState) => {
63428
63281
  const target = defaultState ? 0 : initialPaginationRef.current.pageIndex;
63429
63282
  setPageIndex(target);
63430
63283
  },
63431
63284
  [setPageIndex]
63432
63285
  );
63433
- const resetPageSize = useCallback6(
63286
+ const resetPageSize = useCallback5(
63434
63287
  (defaultState) => {
63435
63288
  const target = defaultState ? getDefaultPaginationState().pageSize : initialPaginationRef.current.pageSize;
63436
63289
  setPageSize(target);
63437
63290
  },
63438
63291
  [setPageSize]
63439
63292
  );
63440
- const nextPage = useCallback6(
63293
+ const nextPage = useCallback5(
63441
63294
  () => setPageIndex((old) => old + 1),
63442
63295
  [setPageIndex]
63443
63296
  );
63444
- const previousPage = useCallback6(
63297
+ const previousPage = useCallback5(
63445
63298
  () => setPageIndex((old) => old - 1),
63446
63299
  [setPageIndex]
63447
63300
  );
63448
- const firstPage = useCallback6(() => setPageIndex(0), [setPageIndex]);
63449
- const lastPage = useCallback6(
63301
+ const firstPage = useCallback5(() => setPageIndex(0), [setPageIndex]);
63302
+ const lastPage = useCallback5(
63450
63303
  () => setPageIndex(paginationPageCountRef.current - 1),
63451
63304
  [setPageIndex]
63452
63305
  );
63453
- const chartPivotHydratedFromSourceRef = useRef25(false);
63454
- const lastPivotHydrateCompletedSourceIdRef = useRef25(null);
63455
- const groupRowsBySetViaSetReportRef = useRef25(false);
63456
- const groupColumnsBySetViaSetReportRef = useRef25(false);
63457
- const aggregationStateSetViaSetReportRef = useRef25(false);
63458
- const prevReportIdForChartPivotHydrationRef = useRef25(effectiveReportId);
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);
63459
63313
  if (prevReportIdForChartPivotHydrationRef.current !== effectiveReportId) {
63460
63314
  prevReportIdForChartPivotHydrationRef.current = effectiveReportId;
63461
63315
  chartPivotHydratedFromSourceRef.current = false;
63462
63316
  groupRowsBySetViaSetReportRef.current = false;
63463
63317
  groupColumnsBySetViaSetReportRef.current = false;
63318
+ dateBucketSetViaSetReportRef.current = false;
63464
63319
  aggregationStateSetViaSetReportRef.current = false;
63465
63320
  }
63466
- const [chartPivotHydrationEpoch, setChartPivotHydrationEpoch] = useState42(0);
63321
+ const [chartPivotHydrationEpoch, setChartPivotHydrationEpoch] = useState41(0);
63467
63322
  const [
63468
63323
  expandReportBuilderColumnsForFlatTable,
63469
63324
  setExpandReportBuilderColumnsForFlatTable
63470
- ] = useState42(false);
63471
- const prevPivotStateForColumnExpansionRef = useRef25(null);
63472
- const [sourceReport, setSourceReport] = useState42(
63325
+ ] = useState41(false);
63326
+ const prevPivotStateForColumnExpansionRef = useRef24(null);
63327
+ const [sourceReport, setSourceReport] = useState41(
63473
63328
  null
63474
63329
  );
63475
- const prevSourceReportIdForPivotHydrationRef = useRef25(null);
63330
+ const prevSourceReportIdForPivotHydrationRef = useRef24(null);
63476
63331
  {
63477
63332
  const currentSourceId = sourceReport ? String(
63478
63333
  sourceReport.id ?? sourceReport._id ?? ""
@@ -63484,11 +63339,11 @@ function useReport(reportIdArg, options = {}) {
63484
63339
  lastPivotHydrateCompletedSourceIdRef.current = null;
63485
63340
  }
63486
63341
  }
63487
- const [preserveSchemaWideOptions, setPreserveSchemaWideOptions] = useState42(false);
63488
- const [initialSchemaScopedTableNames, setInitialSchemaScopedTableNames] = useState42(null);
63489
- const [tableColumnsEditedSignature, setTableColumnsEditedSignature] = useState42(null);
63490
- const [chartAxisEdits, setChartAxisEdits] = useState42({});
63491
- const [chartVisibilityOverrides, setChartVisibilityOverrides] = useState42({});
63342
+ const [preserveSchemaWideOptions, setPreserveSchemaWideOptions] = useState41(false);
63343
+ const [initialSchemaScopedTableNames, setInitialSchemaScopedTableNames] = useState41(null);
63344
+ const [tableColumnsEditedSignature, setTableColumnsEditedSignature] = useState41(null);
63345
+ const [chartAxisEdits, setChartAxisEdits] = useState41({});
63346
+ const [chartVisibilityOverrides, setChartVisibilityOverrides] = useState41({});
63492
63347
  const [client] = useContext36(ClientContext);
63493
63348
  const [schemaData] = useContext36(SchemaDataContext);
63494
63349
  const { tenants, flags } = useContext36(TenantContext);
@@ -63501,7 +63356,7 @@ function useReport(reportIdArg, options = {}) {
63501
63356
  clientDefaultDashboardName,
63502
63357
  destinationDashboardName
63503
63358
  ].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
63504
- const initialFormState = useMemo33(
63359
+ const initialFormState = useMemo32(
63505
63360
  () => ({
63506
63361
  columns: [],
63507
63362
  queryColumns: [],
@@ -63509,6 +63364,7 @@ function useReport(reportIdArg, options = {}) {
63509
63364
  queryFilters: { combinator: "and", rules: [] },
63510
63365
  groupRowsBy: void 0,
63511
63366
  groupColumnsBy: void 0,
63367
+ dateBucket: void 0,
63512
63368
  aggregationState: [],
63513
63369
  aggregationTablesByIndex: [],
63514
63370
  pivotSort: void 0,
@@ -63538,6 +63394,7 @@ function useReport(reportIdArg, options = {}) {
63538
63394
  queryFilters,
63539
63395
  groupRowsBy,
63540
63396
  groupColumnsBy,
63397
+ dateBucket,
63541
63398
  aggregationState,
63542
63399
  aggregationTablesByIndex,
63543
63400
  pivotSort,
@@ -63547,16 +63404,16 @@ function useReport(reportIdArg, options = {}) {
63547
63404
  schemaDatasourceIds
63548
63405
  } = formState;
63549
63406
  const schemaDatasourceIdsKey = schemaDatasourceIds?.map((id) => String(id ?? "").trim()).join("\0") ?? "";
63550
- const queryColumnsBootstrapKey = useMemo33(
63407
+ const queryColumnsBootstrapKey = useMemo32(
63551
63408
  () => queryColumns.map(
63552
63409
  (c) => `${String(c.table ?? "").trim()}\0${String(c.field ?? "").trim()}`
63553
63410
  ).join("\n"),
63554
63411
  [queryColumns]
63555
63412
  );
63556
- const dashboardNameForNewReport = useMemo33(() => {
63413
+ const dashboardNameForNewReport = useMemo32(() => {
63557
63414
  return [clientDefaultDashboardName, destinationDashboardName].map((entry) => String(entry ?? "").trim()).find((entry) => entry.length > 0) ?? "";
63558
63415
  }, [clientDefaultDashboardName, destinationDashboardName]);
63559
- const filterStackRef = useRef25(filterStack);
63416
+ const filterStackRef = useRef24(filterStack);
63560
63417
  filterStackRef.current = filterStack;
63561
63418
  const resolvedGroupRowsBy = decodePivotGroupOptionValue(groupRowsBy);
63562
63419
  const resolvedGroupColumnsBy = decodePivotGroupOptionValue(groupColumnsBy);
@@ -63571,8 +63428,8 @@ function useReport(reportIdArg, options = {}) {
63571
63428
  setChartAxisEdits({});
63572
63429
  setChartVisibilityOverrides({});
63573
63430
  }, [effectiveReportId]);
63574
- const bootstrapReportTaskUsedForReportIdRef = useRef25(null);
63575
- const schemaScopeInitializedForReportIdRef = useRef25(null);
63431
+ const bootstrapReportTaskUsedForReportIdRef = useRef24(null);
63432
+ const schemaScopeInitializedForReportIdRef = useRef24(null);
63576
63433
  const initializeSchemaScopeForReport = (report) => {
63577
63434
  if (!report) return;
63578
63435
  if (schemaScopeInitializedForReportIdRef.current === effectiveReportId)
@@ -63585,26 +63442,26 @@ function useReport(reportIdArg, options = {}) {
63585
63442
  );
63586
63443
  schemaScopeInitializedForReportIdRef.current = effectiveReportId;
63587
63444
  };
63588
- const internalFilters = useMemo33(
63445
+ const internalFilters = useMemo32(
63589
63446
  () => internalFiltersFromFilterStack(filterStack),
63590
63447
  [filterStack]
63591
63448
  );
63592
- const customFilters = useMemo33(
63449
+ const customFilters = useMemo32(
63593
63450
  () => customFiltersFromFilterStack(filterStack),
63594
63451
  [filterStack]
63595
63452
  );
63596
- const reloadKey = useMemo33(() => 0, []);
63597
- const schemaForReportBuilderState = useMemo33(() => {
63453
+ const reloadKey = useMemo32(() => 0, []);
63454
+ const schemaForReportBuilderState = useMemo32(() => {
63598
63455
  if (schemaData.schemaWithCustomFields?.length) {
63599
63456
  return schemaData.schemaWithCustomFields;
63600
63457
  }
63601
63458
  return schemaData.schema ?? [];
63602
63459
  }, [schemaData.schema, schemaData.schemaWithCustomFields]);
63603
- const schemaForReportBuilderStateRef = useRef25(schemaForReportBuilderState);
63604
- const customFieldsRef = useRef25(schemaData.customFields);
63460
+ const schemaForReportBuilderStateRef = useRef24(schemaForReportBuilderState);
63461
+ const customFieldsRef = useRef24(schemaData.customFields);
63605
63462
  schemaForReportBuilderStateRef.current = schemaForReportBuilderState;
63606
63463
  customFieldsRef.current = schemaData.customFields;
63607
- const isBoolAggregationField = useCallback6(
63464
+ const isBoolAggregationField = useCallback5(
63608
63465
  (field, table2) => {
63609
63466
  const fieldType = resolveFieldType({
63610
63467
  field,
@@ -63617,19 +63474,19 @@ function useReport(reportIdArg, options = {}) {
63617
63474
  },
63618
63475
  []
63619
63476
  );
63620
- const schemaForeignKeyMap = useMemo33(
63477
+ const schemaForeignKeyMap = useMemo32(
63621
63478
  () => getSchemaForeignKeyMapping(schemaForReportBuilderState),
63622
63479
  [schemaForReportBuilderState]
63623
63480
  );
63624
63481
  const reportBuilderBaseTableNamesKey = (sourceReport?.reportBuilderState?.tables ?? []).map((t) => String(t?.name ?? "").trim()).filter(Boolean).join("\0") ?? "";
63625
- const selectedBaseTableNamesForFieldOptions = useMemo33(() => {
63482
+ const selectedBaseTableNamesForFieldOptions = useMemo32(() => {
63626
63483
  const fromPicker = schemaDatasourceIds?.map((id) => String(id ?? "").trim()).filter(Boolean) ?? [];
63627
63484
  if (fromPicker.length > 0) {
63628
63485
  return fromPicker;
63629
63486
  }
63630
63487
  return (sourceReport?.reportBuilderState?.tables ?? []).map((t) => String(t?.name ?? "").trim()).filter(Boolean);
63631
63488
  }, [schemaDatasourceIdsKey, reportBuilderBaseTableNamesKey]);
63632
- const fieldOptionsAllowedTableNames = useMemo33(() => {
63489
+ const fieldOptionsAllowedTableNames = useMemo32(() => {
63633
63490
  if (!restrictFieldOptionsToSelectedDatasources) {
63634
63491
  return null;
63635
63492
  }
@@ -63731,18 +63588,18 @@ function useReport(reportIdArg, options = {}) {
63731
63588
  schemaForReportBuilderState,
63732
63589
  queryColumnsBootstrapKey
63733
63590
  ]);
63734
- const datasourceOptions = useMemo33(() => {
63591
+ const datasourceOptions = useMemo32(() => {
63735
63592
  const seen = /* @__PURE__ */ new Set();
63736
63593
  const result = [];
63737
63594
  for (const table2 of schemaForReportBuilderState) {
63738
63595
  const name2 = String(table2.name ?? "").trim();
63739
63596
  if (!name2 || seen.has(name2)) continue;
63740
63597
  seen.add(name2);
63741
- result.push({ id: name2, label: toTitleCaseLabel(name2) });
63598
+ result.push({ value: name2, label: toTitleCaseLabel(name2) });
63742
63599
  }
63743
63600
  return result;
63744
63601
  }, [schemaForReportBuilderState]);
63745
- const queryBuilderFieldConfigByName = useMemo33(() => {
63602
+ const queryBuilderFieldConfigByName = useMemo32(() => {
63746
63603
  const configByName = buildQueryBuilderFieldConfigByName(
63747
63604
  schemaForReportBuilderState
63748
63605
  );
@@ -63876,7 +63733,7 @@ function useReport(reportIdArg, options = {}) {
63876
63733
  sourceReport?.columns,
63877
63734
  sourceReport?.reportBuilderState?.columns
63878
63735
  ]);
63879
- const filterUniqueValuesRequest = useMemo33(() => {
63736
+ const filterUniqueValuesRequest = useMemo32(() => {
63880
63737
  const dashboardName = resolvedSourceDashboardName;
63881
63738
  const reportBuilderStateFromSource = sourceReport?.reportBuilderState;
63882
63739
  const isStringReportBuilderColumn = (column) => {
@@ -64097,13 +63954,13 @@ function useReport(reportIdArg, options = {}) {
64097
63954
  sourceReport?.reportBuilderState,
64098
63955
  resolvedSourceDashboardName
64099
63956
  ]);
64100
- const filterUniqueValuesRequestHash = useMemo33(
63957
+ const filterUniqueValuesRequestHash = useMemo32(
64101
63958
  () => stableSerializeForQueryKey(
64102
63959
  filterUniqueValuesRequestForQueryKey(filterUniqueValuesRequest)
64103
63960
  ),
64104
63961
  [filterUniqueValuesRequest]
64105
63962
  );
64106
- const customFiltersHashForUniqueValues = useMemo33(
63963
+ const customFiltersHashForUniqueValues = useMemo32(
64107
63964
  () => stableSerializeForQueryKey(customFilters),
64108
63965
  [customFilters]
64109
63966
  );
@@ -64200,7 +64057,7 @@ function useReport(reportIdArg, options = {}) {
64200
64057
  enabled: filterUniqueValuesEnabled,
64201
64058
  retry: false
64202
64059
  });
64203
- const backendUniqueValuesByFieldName = useMemo33(() => {
64060
+ const backendUniqueValuesByFieldName = useMemo32(() => {
64204
64061
  const valuesByField = /* @__PURE__ */ new Map();
64205
64062
  const uniqueValuesByColumn = filterUniqueValuesQuery.data?.uniqueValuesByColumn;
64206
64063
  if (!uniqueValuesByColumn || typeof uniqueValuesByColumn !== "object") {
@@ -64249,7 +64106,7 @@ function useReport(reportIdArg, options = {}) {
64249
64106
  effectiveReportId,
64250
64107
  useFormFiltersDebugEnabled
64251
64108
  ]);
64252
- const filterValueOptionsByFieldName = useMemo33(() => {
64109
+ const filterValueOptionsByFieldName = useMemo32(() => {
64253
64110
  const optionsByField = /* @__PURE__ */ new Map();
64254
64111
  const selectedMultiselectByField = collectSelectedStringMultiselectValuesByField(queryFilters);
64255
64112
  const collectValuesForField = (fieldName) => {
@@ -64315,7 +64172,7 @@ function useReport(reportIdArg, options = {}) {
64315
64172
  queryBuilderFieldConfigByName,
64316
64173
  queryFilters
64317
64174
  ]);
64318
- const filterFieldsComputed = useMemo33(() => {
64175
+ const filterFieldsComputed = useMemo32(() => {
64319
64176
  const fields = [];
64320
64177
  const seen = /* @__PURE__ */ new Set();
64321
64178
  const addField = (fieldName, fieldType, tableName, rawFieldName) => {
@@ -64416,9 +64273,9 @@ function useReport(reportIdArg, options = {}) {
64416
64273
  queryBuilderFieldConfigByName,
64417
64274
  queryFilters
64418
64275
  ]);
64419
- const filterFieldsStableReportIdRef = useRef25("");
64420
- const filterFieldsStableCacheRef = useRef25([]);
64421
- const filterFields = useMemo33(() => {
64276
+ const filterFieldsStableReportIdRef = useRef24("");
64277
+ const filterFieldsStableCacheRef = useRef24([]);
64278
+ const filterFields = useMemo32(() => {
64422
64279
  const rid = String(effectiveReportId ?? "");
64423
64280
  if (filterFieldsStableReportIdRef.current !== rid) {
64424
64281
  filterFieldsStableReportIdRef.current = rid;
@@ -64433,14 +64290,14 @@ function useReport(reportIdArg, options = {}) {
64433
64290
  }
64434
64291
  return filterFieldsComputed;
64435
64292
  }, [effectiveReportId, filterFieldsComputed]);
64436
- const getFilterOperators = useMemo33(
64293
+ const getFilterOperators = useMemo32(
64437
64294
  () => (_field, misc) => {
64438
64295
  const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType ?? "string";
64439
64296
  return QUERY_BUILDER_OPERATORS_BY_FIELD_TYPE[fieldType] ?? QUERY_BUILDER_OPERATORS_BY_FIELD_TYPE.string;
64440
64297
  },
64441
64298
  [queryBuilderFieldConfigByName]
64442
64299
  );
64443
- const getFilterInputType = useMemo33(
64300
+ const getFilterInputType = useMemo32(
64444
64301
  () => (_field, operator, misc) => {
64445
64302
  const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType ?? "string";
64446
64303
  if (fieldType === "date" && isRelativeDateQueryBuilderOperator(operator)) {
@@ -64450,17 +64307,20 @@ function useReport(reportIdArg, options = {}) {
64450
64307
  },
64451
64308
  [queryBuilderFieldConfigByName]
64452
64309
  );
64453
- const getFilterValueEditorType = useMemo33(
64310
+ const getFilterValueEditorType = useMemo32(
64454
64311
  () => (_field, operator, misc) => {
64455
64312
  const fieldType = misc?.fieldData?.quillFieldType ?? queryBuilderFieldConfigByName[String(_field ?? "").trim()]?.fieldType;
64456
64313
  if (fieldType === "string" && isMultiValueOperator(operator)) {
64457
64314
  return "multiselect";
64458
64315
  }
64316
+ if (fieldType === "boolean") {
64317
+ return "select";
64318
+ }
64459
64319
  return void 0;
64460
64320
  },
64461
64321
  [queryBuilderFieldConfigByName]
64462
64322
  );
64463
- const getFilterValues = useMemo33(
64323
+ const getFilterValues = useMemo32(
64464
64324
  () => (_field, operator, misc) => {
64465
64325
  const fieldName = String(_field ?? "").trim();
64466
64326
  if (!fieldName) {
@@ -64471,6 +64331,9 @@ function useReport(reportIdArg, options = {}) {
64471
64331
  misc,
64472
64332
  queryBuilderFieldConfigByName
64473
64333
  );
64334
+ if (fieldType === "boolean") {
64335
+ return BOOLEAN_FILTER_VALUE_OPTIONS;
64336
+ }
64474
64337
  if (fieldType !== "string" || !isMultiValueOperator(operator)) {
64475
64338
  return [];
64476
64339
  }
@@ -64487,7 +64350,7 @@ function useReport(reportIdArg, options = {}) {
64487
64350
  },
64488
64351
  [filterValueOptionsByFieldName, queryBuilderFieldConfigByName]
64489
64352
  );
64490
- const filterQueryBuilderProps = useMemo33(
64353
+ const filterQueryBuilderProps = useMemo32(
64491
64354
  () => ({
64492
64355
  fields: filterFields,
64493
64356
  listsAsArrays: true,
@@ -64504,7 +64367,7 @@ function useReport(reportIdArg, options = {}) {
64504
64367
  getFilterValues
64505
64368
  ]
64506
64369
  );
64507
- const filtersForQueryBuilder = useMemo33(
64370
+ const filtersForQueryBuilder = useMemo32(
64508
64371
  () => canonicalizeMultiselectStringRulesToOptionValues(
64509
64372
  queryFilters,
64510
64373
  filterValueOptionsByFieldName,
@@ -64571,12 +64434,12 @@ function useReport(reportIdArg, options = {}) {
64571
64434
  ...table2 ? { table: table2 } : {}
64572
64435
  };
64573
64436
  };
64574
- const tenantHash = useMemo33(
64437
+ const tenantHash = useMemo32(
64575
64438
  () => stableSerializeForQueryKey(tenants),
64576
64439
  [tenants]
64577
64440
  );
64578
- const flagHash = useMemo33(() => stableSerializeForQueryKey(flags), [flags]);
64579
- const clientHash = useMemo33(
64441
+ const flagHash = useMemo32(() => stableSerializeForQueryKey(flags), [flags]);
64442
+ const clientHash = useMemo32(
64580
64443
  () => stableSerializeForQueryKey({
64581
64444
  publicKey: client?.publicKey,
64582
64445
  clientId: client?.clientId,
@@ -64584,7 +64447,7 @@ function useReport(reportIdArg, options = {}) {
64584
64447
  }),
64585
64448
  [client]
64586
64449
  );
64587
- const reloadKeyHash = useMemo33(
64450
+ const reloadKeyHash = useMemo32(
64588
64451
  () => stableSerializeForQueryKey(reloadKey),
64589
64452
  [reloadKey]
64590
64453
  );
@@ -64617,6 +64480,7 @@ function useReport(reportIdArg, options = {}) {
64617
64480
  // grouping from the prior report would otherwise win over the new report.
64618
64481
  groupRowsBy: void 0,
64619
64482
  groupColumnsBy: void 0,
64483
+ dateBucket: void 0,
64620
64484
  aggregationState: [],
64621
64485
  aggregationTablesByIndex: [],
64622
64486
  pivotSort: void 0,
@@ -64803,6 +64667,8 @@ function useReport(reportIdArg, options = {}) {
64803
64667
  const sourceDisplayColumns = sourceDisplayColumnsFromSchema.length > 0 ? sourceDisplayColumnsFromSchema : sourceQueryColumns;
64804
64668
  const nextGroupRowsBy = shouldTakePivotGroupsFromSource ? groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption : prev.groupRowsBy !== void 0 ? prev.groupRowsBy : groupRowsBySetViaSetReportRef.current ? prev.groupRowsBy : sourceRowGroupOption;
64805
64669
  const nextGroupColumnsBy = shouldTakePivotGroupsFromSource ? groupColumnsBySetViaSetReportRef.current ? prev.groupColumnsBy : sourceColumnGroupOption : prev.groupColumnsBy !== void 0 ? prev.groupColumnsBy : prev.groupRowsBy !== void 0 ? prev.groupColumnsBy : sourceColumnGroupOption;
64670
+ const sourceDateBucket = sourceReport.pivot?.dateBucket ?? sourceReport.reportBuilderState?.pivot?.dateBucket;
64671
+ const nextDateBucket = dateBucketSetViaSetReportRef.current ? prev.dateBucket : sourceDateBucket;
64806
64672
  const nextFromSource = {
64807
64673
  ...prev,
64808
64674
  queryColumns: prev.queryColumns.length ? prev.queryColumns : sourceQueryColumns,
@@ -64811,6 +64677,7 @@ function useReport(reportIdArg, options = {}) {
64811
64677
  queryFilters: nextQueryFilters,
64812
64678
  groupRowsBy: nextGroupRowsBy,
64813
64679
  groupColumnsBy: nextGroupColumnsBy,
64680
+ dateBucket: nextDateBucket,
64814
64681
  aggregationState: nextAggregationState,
64815
64682
  aggregationTablesByIndex: nextAggregationTablesByIndex,
64816
64683
  pivotSort: prev.pivotSort ?? (sourceReport.pivot?.sort && sourceReport.pivot?.sortField && sourceReport.pivot?.sortDirection ? {
@@ -64843,11 +64710,11 @@ function useReport(reportIdArg, options = {}) {
64843
64710
  schemaForReportBuilderState,
64844
64711
  sourceReport
64845
64712
  ]);
64846
- const appliedAggregationState = useMemo33(
64713
+ const appliedAggregationState = useMemo32(
64847
64714
  () => aggregationState.filter(isAppliedAggregation),
64848
64715
  [aggregationState]
64849
64716
  );
64850
- const pivotState = useMemo33(() => {
64717
+ const pivotState = useMemo32(() => {
64851
64718
  if (!resolvedGroupRowsBy && !resolvedGroupColumnsBy && appliedAggregationState.length === 0) {
64852
64719
  return null;
64853
64720
  }
@@ -64891,6 +64758,7 @@ function useReport(reportIdArg, options = {}) {
64891
64758
  rowFieldType,
64892
64759
  columnField: effectiveColumnField,
64893
64760
  columnFieldType,
64761
+ dateBucket: chartPivotHydratedFromSourceRef.current ? dateBucket : dateBucket ?? priorPivot?.dateBucket,
64894
64762
  aggregations,
64895
64763
  ...rowFieldTable ? { rowFieldTable } : {},
64896
64764
  ...columnFieldTable ? { columnFieldTable } : {}
@@ -64901,6 +64769,7 @@ function useReport(reportIdArg, options = {}) {
64901
64769
  aggregationTablesByIndex,
64902
64770
  appliedAggregationState,
64903
64771
  baseReportBuilderTables,
64772
+ dateBucket,
64904
64773
  groupColumnsBy,
64905
64774
  groupRowsBy,
64906
64775
  schemaForReportBuilderState,
@@ -64922,7 +64791,7 @@ function useReport(reportIdArg, options = {}) {
64922
64791
  }
64923
64792
  prevPivotStateForColumnExpansionRef.current = pivotState;
64924
64793
  }, [pivotState]);
64925
- const effectiveReportBuilderTables = useMemo33(() => {
64794
+ const effectiveReportBuilderTables = useMemo32(() => {
64926
64795
  const explicitBaseFromSchemaPicker = Array.isArray(schemaDatasourceIds) && schemaDatasourceIds.length > 0 ? schemaDatasourceIds.map((tableName) => String(tableName ?? "").trim()).filter(Boolean).map((name2) => ({ name: name2 })) : null;
64927
64796
  const baseTablesForMerge = explicitBaseFromSchemaPicker ?? baseReportBuilderTables;
64928
64797
  return mergeReportBuilderTables(
@@ -64946,28 +64815,18 @@ function useReport(reportIdArg, options = {}) {
64946
64815
  queryColumns,
64947
64816
  schemaDatasourceIds
64948
64817
  ]);
64949
- const datasources = useMemo33(() => {
64950
- return effectiveReportBuilderTables.map((table2) => {
64951
- const name2 = String(table2.name ?? "").trim();
64952
- if (!name2) return null;
64953
- const alias = String(table2.alias ?? "").trim();
64954
- return {
64955
- id: name2,
64956
- label: alias || name2
64957
- };
64958
- }).filter(
64959
- (entry) => Boolean(entry)
64960
- );
64818
+ const datasources = useMemo32(() => {
64819
+ return effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2));
64961
64820
  }, [effectiveReportBuilderTables]);
64962
- const effectiveReportBuilderTableNames = useMemo33(
64821
+ const effectiveReportBuilderTableNames = useMemo32(
64963
64822
  () => effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2)),
64964
64823
  [effectiveReportBuilderTables]
64965
64824
  );
64966
- const baseReportBuilderTableNames = useMemo33(
64825
+ const baseReportBuilderTableNames = useMemo32(
64967
64826
  () => baseReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).filter((name2) => Boolean(name2)),
64968
64827
  [baseReportBuilderTables]
64969
64828
  );
64970
- const normalizeQueryBuilderFieldNameForConfig = useMemo33(() => {
64829
+ const normalizeQueryBuilderFieldNameForConfig = useMemo32(() => {
64971
64830
  const configEntries = Object.entries(queryBuilderFieldConfigByName);
64972
64831
  const preferredTableNames = /* @__PURE__ */ new Set([
64973
64832
  ...effectiveReportBuilderTableNames,
@@ -65029,7 +64888,7 @@ function useReport(reportIdArg, options = {}) {
65029
64888
  effectiveReportBuilderTableNames,
65030
64889
  queryBuilderFieldConfigByName
65031
64890
  ]);
65032
- const normalizeQueryBuilderFiltersForConfig = useMemo33(() => {
64891
+ const normalizeQueryBuilderFiltersForConfig = useMemo32(() => {
65033
64892
  const normalizeGroup = (group) => {
65034
64893
  const groupRules = Array.isArray(group.rules) ? group.rules : [];
65035
64894
  const nextRules = groupRules.map((entry) => {
@@ -65066,14 +64925,14 @@ function useReport(reportIdArg, options = {}) {
65066
64925
  return normalizeGroup(group);
65067
64926
  };
65068
64927
  }, [normalizeQueryBuilderFieldNameForConfig, queryBuilderFieldConfigByName]);
65069
- const refreshSelectionTables = useMemo33(() => {
64928
+ const refreshSelectionTables = useMemo32(() => {
65070
64929
  return [
65071
64930
  getPivotGroupOptionTable(groupRowsBy),
65072
64931
  getPivotGroupOptionTable(groupColumnsBy),
65073
64932
  ...aggregationTablesByIndex
65074
64933
  ].map((tableName) => String(tableName ?? "").trim()).filter((tableName) => Boolean(tableName));
65075
64934
  }, [aggregationTablesByIndex, groupColumnsBy, groupRowsBy]);
65076
- const refreshSelectionFields = useMemo33(() => {
64935
+ const refreshSelectionFields = useMemo32(() => {
65077
64936
  const resolveFieldTableForSelection = (field, tableHint) => {
65078
64937
  const fieldName = String(field ?? "").trim();
65079
64938
  if (!fieldName) return "";
@@ -65123,7 +64982,7 @@ function useReport(reportIdArg, options = {}) {
65123
64982
  schemaForReportBuilderState,
65124
64983
  sourceReport
65125
64984
  ]);
65126
- const refreshDecision = useMemo33(
64985
+ const refreshDecision = useMemo32(
65127
64986
  () => decideReportBuilderRefresh({
65128
64987
  baseTables: baseReportBuilderTables,
65129
64988
  baseColumns: baseReportBuilderColumns,
@@ -65137,7 +64996,7 @@ function useReport(reportIdArg, options = {}) {
65137
64996
  refreshSelectionTables
65138
64997
  ]
65139
64998
  );
65140
- const effectiveReportBuilderColumns = useMemo33(() => {
64999
+ const effectiveReportBuilderColumns = useMemo32(() => {
65141
65000
  const columnsFromPivot = [];
65142
65001
  const appendPivotColumn = (field, tableHint) => {
65143
65002
  const normalizedField = String(field ?? "").trim();
@@ -65235,7 +65094,7 @@ function useReport(reportIdArg, options = {}) {
65235
65094
  queryBuilderFieldConfigByName,
65236
65095
  queryFilters
65237
65096
  ]);
65238
- const resolvedSortFieldType = useMemo33(() => {
65097
+ const resolvedSortFieldType = useMemo32(() => {
65239
65098
  const sortField = pivotSort?.sortField;
65240
65099
  if (!sortField || !pivotState) return void 0;
65241
65100
  if (sortField === resolvedGroupRowsBy) {
@@ -65256,7 +65115,7 @@ function useReport(reportIdArg, options = {}) {
65256
65115
  resolvedGroupColumnsBy,
65257
65116
  resolvedGroupRowsBy
65258
65117
  ]);
65259
- const effectiveReportBuilderState = useMemo33(() => {
65118
+ const effectiveReportBuilderState = useMemo32(() => {
65260
65119
  if (!sourceReport && effectiveReportBuilderTables.length === 0) {
65261
65120
  return void 0;
65262
65121
  }
@@ -65295,11 +65154,11 @@ function useReport(reportIdArg, options = {}) {
65295
65154
  resolvedSortFieldType,
65296
65155
  sourceReport
65297
65156
  ]);
65298
- const effectiveReportBuilderStateHash = useMemo33(
65157
+ const effectiveReportBuilderStateHash = useMemo32(
65299
65158
  () => stableSerializeForQueryKey(effectiveReportBuilderState),
65300
65159
  [effectiveReportBuilderState]
65301
65160
  );
65302
- const prevPaginationResetStateHashRef = useRef25(null);
65161
+ const prevPaginationResetStateHashRef = useRef24(null);
65303
65162
  useEffect31(() => {
65304
65163
  const prevHash = prevPaginationResetStateHashRef.current;
65305
65164
  prevPaginationResetStateHashRef.current = effectiveReportBuilderStateHash;
@@ -65316,7 +65175,7 @@ function useReport(reportIdArg, options = {}) {
65316
65175
  activate: false
65317
65176
  });
65318
65177
  }, [applyPaginationUpdate, effectiveReportBuilderStateHash]);
65319
- const pivotTableDataReportBuilderState = useMemo33(() => {
65178
+ const pivotTableDataReportBuilderState = useMemo32(() => {
65320
65179
  if (!effectiveReportBuilderState?.pivot) {
65321
65180
  return void 0;
65322
65181
  }
@@ -65336,11 +65195,11 @@ function useReport(reportIdArg, options = {}) {
65336
65195
  limit: null
65337
65196
  };
65338
65197
  }, [effectiveReportBuilderState, schemaForReportBuilderState]);
65339
- const pivotTableDataReportBuilderStateHash = useMemo33(
65198
+ const pivotTableDataReportBuilderStateHash = useMemo32(
65340
65199
  () => stableSerializeForQueryKey(pivotTableDataReportBuilderState),
65341
65200
  [pivotTableDataReportBuilderState]
65342
65201
  );
65343
- const sourceReportMatchesEffectiveReportId = useMemo33(() => {
65202
+ const sourceReportMatchesEffectiveReportId = useMemo32(() => {
65344
65203
  const loadTarget = String(effectiveReportId ?? "").trim();
65345
65204
  if (!loadTarget || !sourceReport) {
65346
65205
  return true;
@@ -65350,7 +65209,7 @@ function useReport(reportIdArg, options = {}) {
65350
65209
  ).trim();
65351
65210
  return sid === loadTarget;
65352
65211
  }, [effectiveReportId, sourceReport]);
65353
- const shouldSkipRedundantFlatTableReportBuilderQuery = useMemo33(() => {
65212
+ const shouldSkipRedundantFlatTableReportBuilderQuery = useMemo32(() => {
65354
65213
  if (!sourceReport || pivotState) {
65355
65214
  return false;
65356
65215
  }
@@ -65416,7 +65275,7 @@ function useReport(reportIdArg, options = {}) {
65416
65275
  tableRefreshQueryEnabled,
65417
65276
  useFormRefreshDebugEnabled
65418
65277
  ]);
65419
- const chartTypes = useMemo33(() => {
65278
+ const chartTypes = useMemo32(() => {
65420
65279
  return getChartTypeOptions2({ pivot: pivotState });
65421
65280
  }, [pivotState]);
65422
65281
  useEffect31(() => {
@@ -65454,7 +65313,7 @@ function useReport(reportIdArg, options = {}) {
65454
65313
  });
65455
65314
  }
65456
65315
  }, [chartType, chartTypes, sourceReport]);
65457
- const schemaScopedTableNames = useMemo33(() => {
65316
+ const schemaScopedTableNames = useMemo32(() => {
65458
65317
  if (preserveSchemaWideOptions) {
65459
65318
  return [];
65460
65319
  }
@@ -65469,7 +65328,7 @@ function useReport(reportIdArg, options = {}) {
65469
65328
  preserveSchemaWideOptions,
65470
65329
  sourceReport?.reportBuilderState?.tables
65471
65330
  ]);
65472
- const joinCompatibleSchemaTableNames = useMemo33(() => {
65331
+ const joinCompatibleSchemaTableNames = useMemo32(() => {
65473
65332
  if (schemaScopedTableNames.length === 0) {
65474
65333
  return [];
65475
65334
  }
@@ -65478,7 +65337,7 @@ function useReport(reportIdArg, options = {}) {
65478
65337
  schemaForeignKeyMap
65479
65338
  );
65480
65339
  }, [schemaForeignKeyMap, schemaScopedTableNames]);
65481
- const aggregationFallbackTarget = useMemo33(() => {
65340
+ const aggregationFallbackTarget = useMemo32(() => {
65482
65341
  const tableNames = effectiveReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
65483
65342
  const referencedTableNames = (sourceReport?.referencedTables ?? []).filter(
65484
65343
  (name2) => typeof name2 === "string" && name2.length > 0
@@ -65486,7 +65345,7 @@ function useReport(reportIdArg, options = {}) {
65486
65345
  const tableNamesToUse = tableNames.length ? tableNames : referencedTableNames;
65487
65346
  return tableNamesToUse.length > 0 ? tableNamesToUse.join(", ") : "table";
65488
65347
  }, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
65489
- const aggregationFallbackTableName = useMemo33(() => {
65348
+ const aggregationFallbackTableName = useMemo32(() => {
65490
65349
  const tableNames = effectiveReportBuilderTables.map((table2) => table2.name).filter((name2) => Boolean(name2));
65491
65350
  const referencedTableNames = (sourceReport?.referencedTables ?? []).filter(
65492
65351
  (name2) => typeof name2 === "string" && name2.length > 0
@@ -65494,7 +65353,7 @@ function useReport(reportIdArg, options = {}) {
65494
65353
  const tableNamesToUse = tableNames.length ? tableNames : referencedTableNames;
65495
65354
  return tableNamesToUse[0] ?? "table";
65496
65355
  }, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
65497
- const cleanedAggregations = useMemo33(() => {
65356
+ const cleanedAggregations = useMemo32(() => {
65498
65357
  return aggregationState.filter((aggregation) => Boolean(aggregation?.aggregationType)).map((aggregation, index) => {
65499
65358
  const aggregationType = String(aggregation.aggregationType);
65500
65359
  const normalizedAggregationType = aggregationType.toLowerCase();
@@ -65516,7 +65375,7 @@ function useReport(reportIdArg, options = {}) {
65516
65375
  aggregationTablesByIndex,
65517
65376
  isBoolAggregationField
65518
65377
  ]);
65519
- const { aggregationBaseOptions, aggregationOptionTableLookup } = useMemo33(() => {
65378
+ const { aggregationBaseOptions, aggregationOptionTableLookup } = useMemo32(() => {
65520
65379
  const joinScoped = fieldOptionsAllowedTableNames ? joinCompatibleSchemaTableNames.filter(
65521
65380
  (name2) => fieldOptionsAllowedTableNames.has(name2)
65522
65381
  ) : joinCompatibleSchemaTableNames;
@@ -65562,7 +65421,7 @@ function useReport(reportIdArg, options = {}) {
65562
65421
  if (!canAggregateColumn(column, aggregationType)) continue;
65563
65422
  const isNumberSharePercentage = aggregationType === "percentage" && !isBoolColumn;
65564
65423
  if (isNumberSharePercentage && !resolvedGroupRowsBy) continue;
65565
- const value = `${aggregationType}:${fieldName}`;
65424
+ const value = tableName ? `${aggregationType}:${tableName}::${fieldName}` : `${aggregationType}:${fieldName}`;
65566
65425
  if (seen.has(value)) continue;
65567
65426
  const aggregationWord = aggregationType === "percentage" ? isBoolColumn ? "Percent" : "Percent of Total" : formatAggregationTypeForDisplay(aggregationType);
65568
65427
  options2.push({
@@ -65570,8 +65429,14 @@ function useReport(reportIdArg, options = {}) {
65570
65429
  label: tableName ? `${aggregationWord} ${toTitleCaseLabel(tableName)} ${toTitleCaseLabel(fieldName)}` : `${aggregationWord} ${toTitleCaseLabel(fieldName)}`
65571
65430
  });
65572
65431
  seen.add(value);
65573
- if (tableName && !tableLookup.has(value)) {
65574
- tableLookup.set(value, tableName);
65432
+ if (tableName) {
65433
+ if (!tableLookup.has(value)) {
65434
+ tableLookup.set(value, tableName);
65435
+ }
65436
+ const unqualifiedValue = `${aggregationType}:${fieldName}`;
65437
+ if (!tableLookup.has(unqualifiedValue)) {
65438
+ tableLookup.set(unqualifiedValue, tableName);
65439
+ }
65575
65440
  }
65576
65441
  }
65577
65442
  }
@@ -65593,7 +65458,7 @@ function useReport(reportIdArg, options = {}) {
65593
65458
  resolvedGroupRowsBy,
65594
65459
  schemaForReportBuilderState
65595
65460
  ]);
65596
- const { schemaColumnOptions, columnIdentifierLookup } = useMemo33(() => {
65461
+ const { schemaColumnOptions, columnIdentifierLookup } = useMemo32(() => {
65597
65462
  const lookup = /* @__PURE__ */ new Map();
65598
65463
  const options2 = [];
65599
65464
  for (const table2 of schemaData.schemaWithCustomFields) {
@@ -65620,7 +65485,7 @@ function useReport(reportIdArg, options = {}) {
65620
65485
  columnIdentifierLookup: lookup
65621
65486
  };
65622
65487
  }, [schemaData.schemaWithCustomFields]);
65623
- const tableColumnPickerPoolOptions = useMemo33(() => {
65488
+ const tableColumnPickerPoolOptions = useMemo32(() => {
65624
65489
  const allowed = new Set(
65625
65490
  effectiveReportBuilderTableNames.map((name2) => String(name2 ?? "").trim()).filter(Boolean)
65626
65491
  );
@@ -65631,16 +65496,16 @@ function useReport(reportIdArg, options = {}) {
65631
65496
  (option) => allowed.has(String(option.tableName ?? "").trim())
65632
65497
  );
65633
65498
  }, [effectiveReportBuilderTableNames, schemaColumnOptions]);
65634
- const columns = useMemo33(() => {
65499
+ const columns = useMemo32(() => {
65635
65500
  return displayColumns.filter((column) => Boolean(column.field)).map((column) => encodeColumnOptionValue(column.table, column.field));
65636
65501
  }, [displayColumns]);
65637
- const selectedColumnOptions = useMemo33(() => {
65502
+ const selectedColumnOptions = useMemo32(() => {
65638
65503
  return displayColumns.map((column) => {
65639
65504
  const value = column.alias || column.field;
65640
65505
  return value ? { label: value, value } : null;
65641
65506
  }).filter((option) => option !== null);
65642
65507
  }, [displayColumns]);
65643
- const scopedSchemaColumns = useMemo33(() => {
65508
+ const scopedSchemaColumns = useMemo32(() => {
65644
65509
  const tableNames = fieldOptionsAllowedTableNames ? Array.from(fieldOptionsAllowedTableNames) : joinCompatibleSchemaTableNames;
65645
65510
  const schemaTables = schemaForReportBuilderState;
65646
65511
  const tablesToUse = tableNames.length ? schemaTables.filter((table2) => tableNames.includes(table2.name ?? "")) : schemaTables;
@@ -65661,7 +65526,7 @@ function useReport(reportIdArg, options = {}) {
65661
65526
  joinCompatibleSchemaTableNames,
65662
65527
  schemaForReportBuilderState
65663
65528
  ]);
65664
- const pivotUniqueValuesByColumn = useMemo33(() => {
65529
+ const pivotUniqueValuesByColumn = useMemo32(() => {
65665
65530
  const explicitUniqueValues = sourceReport?.uniqueStringsByColumn ?? sourceReport?.columnUniqueValues ?? sourceReport?.uniqueValues;
65666
65531
  if (explicitUniqueValues && typeof explicitUniqueValues === "object" && !Array.isArray(explicitUniqueValues)) {
65667
65532
  return explicitUniqueValues;
@@ -65687,7 +65552,7 @@ function useReport(reportIdArg, options = {}) {
65687
65552
  }
65688
65553
  return result;
65689
65554
  }, [sourceReport]);
65690
- const possiblePivotFields = useMemo33(() => {
65555
+ const possiblePivotFields = useMemo32(() => {
65691
65556
  const options2 = getPossiblePivotFieldOptions(
65692
65557
  scopedSchemaColumns,
65693
65558
  pivotUniqueValuesByColumn
@@ -65698,7 +65563,7 @@ function useReport(reportIdArg, options = {}) {
65698
65563
  columnFields: options2.columnFields.filter((field) => !isIdColumn(field))
65699
65564
  };
65700
65565
  }, [scopedSchemaColumns, pivotUniqueValuesByColumn]);
65701
- const groupRowsByOptions = useMemo33(() => {
65566
+ const groupRowsByOptions = useMemo32(() => {
65702
65567
  const allowedFields = new Set(possiblePivotFields.rowFields);
65703
65568
  const seenValues = /* @__PURE__ */ new Set();
65704
65569
  const options2 = [];
@@ -65725,7 +65590,7 @@ function useReport(reportIdArg, options = {}) {
65725
65590
  }
65726
65591
  return options2;
65727
65592
  }, [groupRowsBy, possiblePivotFields.rowFields, scopedSchemaColumns]);
65728
- const groupColumnsByOptions = useMemo33(() => {
65593
+ const groupColumnsByOptions = useMemo32(() => {
65729
65594
  const allowedFields = new Set(possiblePivotFields.columnFields);
65730
65595
  const seenValues = /* @__PURE__ */ new Set();
65731
65596
  const options2 = [];
@@ -65752,19 +65617,19 @@ function useReport(reportIdArg, options = {}) {
65752
65617
  }
65753
65618
  return options2;
65754
65619
  }, [groupColumnsBy, possiblePivotFields.columnFields, scopedSchemaColumns]);
65755
- const cleanedSort = useMemo33(() => {
65620
+ const cleanedSort = useMemo32(() => {
65756
65621
  const activeSort = resolvedGroupRowsBy ? pivotSort : regularSort;
65757
65622
  if (!activeSort?.sortField || !activeSort?.sortDirection) {
65758
65623
  return "";
65759
65624
  }
65760
65625
  return toFlatSortValue(activeSort.sortField, activeSort.sortDirection);
65761
65626
  }, [pivotSort, regularSort, resolvedGroupRowsBy]);
65762
- const aggregationSortLabelFallbackTable = useMemo33(() => {
65627
+ const aggregationSortLabelFallbackTable = useMemo32(() => {
65763
65628
  const reportBuilderTableName = effectiveReportBuilderTables.map((table2) => String(table2.name ?? "").trim()).find((tableName) => Boolean(tableName));
65764
65629
  if (reportBuilderTableName) return reportBuilderTableName;
65765
65630
  return (sourceReport?.referencedTables ?? []).map((tableName) => String(tableName ?? "").trim()).find((tableName) => Boolean(tableName));
65766
65631
  }, [effectiveReportBuilderTables, sourceReport?.referencedTables]);
65767
- const sortOptions = useMemo33(() => {
65632
+ const sortOptions = useMemo32(() => {
65768
65633
  if (resolvedGroupRowsBy) {
65769
65634
  const aggregationSortFields = getPivotAggregationSortFields(
65770
65635
  aggregationState,
@@ -65823,12 +65688,14 @@ function useReport(reportIdArg, options = {}) {
65823
65688
  resolvedGroupRowsBy,
65824
65689
  selectedColumnOptions
65825
65690
  ]);
65826
- const aggregationOptions = useMemo33(() => {
65691
+ const { aggregationValues, aggregationOptions } = useMemo32(() => {
65827
65692
  const baseOptions = aggregationBaseOptions.map((option) => ({
65828
65693
  value: option.value,
65829
65694
  label: option.label
65830
65695
  }));
65831
- return aggregationState.map((aggregation, index) => {
65696
+ const seenValues = new Set(baseOptions.map((option) => option.value));
65697
+ const injectedOptions = [];
65698
+ const values = aggregationState.map((aggregation, index) => {
65832
65699
  const normalizedAggregationType = String(
65833
65700
  aggregation.aggregationType ?? ""
65834
65701
  ).toLowerCase();
@@ -65836,27 +65703,36 @@ function useReport(reportIdArg, options = {}) {
65836
65703
  const currentValueField = String(aggregation.valueField ?? "").trim();
65837
65704
  const currentValueField2 = String(aggregation.valueField2 ?? "").trim();
65838
65705
  const isPercentageRatio = normalizedAggregationType === "percentage" && Boolean(currentValueField) && Boolean(currentValueField2);
65839
- const currentTarget = isPercentageRatio ? `${currentValueField}:${currentValueField2}` : currentValueField ? currentValueField : normalizedAggregationType === "count" || normalizedAggregationType === "percentage" ? tableHint || aggregationFallbackTableName : aggregationFallbackTarget;
65840
- const currentValue = aggregation.aggregationType ? `${aggregation.aggregationType}:${currentTarget}` : void 0;
65841
- const isBoolPercentage = normalizedAggregationType === "percentage" && Boolean(currentValueField) && isBoolAggregationField(currentValueField, tableHint || void 0) === true;
65842
- const currentLabel = aggregation.aggregationType ? isPercentageRatio ? `Percent ${toTitleCaseLabel(currentValueField)} of ${toTitleCaseLabel(currentValueField2)}` : normalizedAggregationType === "percentage" ? isBoolPercentage ? `Percent ${toTitleCaseLabel(currentTarget)}` : `Percent of Total ${toTitleCaseLabel(currentTarget)}` : `${formatAggregationTypeForDisplay(aggregation.aggregationType)} ${toTitleCaseLabel(currentTarget)}` : "Select aggregation";
65843
- const options2 = currentValue ? baseOptions.some((option) => option.value === currentValue) ? baseOptions : [{ value: currentValue, label: currentLabel }, ...baseOptions] : baseOptions;
65844
- return {
65845
- key: `aggregation-${index}`,
65846
- label: `Aggregation ${index + 1}`,
65847
- value: currentValue ?? "",
65848
- options: options2
65849
- };
65706
+ const isTableTarget = !isPercentageRatio && !currentValueField && (normalizedAggregationType === "count" || normalizedAggregationType === "percentage");
65707
+ const labelTarget = isPercentageRatio ? `${currentValueField}:${currentValueField2}` : currentValueField ? currentValueField : isTableTarget ? tableHint || aggregationFallbackTableName : aggregationFallbackTarget;
65708
+ const fieldTable = isTableTarget || !aggregation.aggregationType ? "" : tableHint || String(
65709
+ aggregationOptionTableLookup.get(
65710
+ `${aggregation.aggregationType}:${labelTarget}`
65711
+ ) ?? ""
65712
+ ).trim();
65713
+ const currentValue = aggregation.aggregationType ? `${aggregation.aggregationType}:${fieldTable ? `${fieldTable}::` : ""}${labelTarget}` : "";
65714
+ if (currentValue && !seenValues.has(currentValue)) {
65715
+ const isBoolPercentage = normalizedAggregationType === "percentage" && Boolean(currentValueField) && isBoolAggregationField(currentValueField, tableHint || void 0) === true;
65716
+ const currentLabel = isPercentageRatio ? `Percent ${toTitleCaseLabel(currentValueField)} of ${toTitleCaseLabel(currentValueField2)}` : normalizedAggregationType === "percentage" ? isBoolPercentage ? `Percent ${toTitleCaseLabel(labelTarget)}` : `Percent of Total ${toTitleCaseLabel(labelTarget)}` : `${formatAggregationTypeForDisplay(aggregation.aggregationType)} ${toTitleCaseLabel(labelTarget)}`;
65717
+ injectedOptions.push({ value: currentValue, label: currentLabel });
65718
+ seenValues.add(currentValue);
65719
+ }
65720
+ return currentValue;
65850
65721
  });
65722
+ return {
65723
+ aggregationValues: values,
65724
+ aggregationOptions: [...injectedOptions, ...baseOptions]
65725
+ };
65851
65726
  }, [
65852
65727
  aggregationFallbackTableName,
65853
65728
  aggregationFallbackTarget,
65854
65729
  aggregationState,
65855
65730
  aggregationBaseOptions,
65731
+ aggregationOptionTableLookup,
65856
65732
  aggregationTablesByIndex,
65857
65733
  isBoolAggregationField
65858
65734
  ]);
65859
- const nextPivot = useMemo33(() => {
65735
+ const nextPivot = useMemo32(() => {
65860
65736
  if (!sourceReport) return null;
65861
65737
  return pivotState ? {
65862
65738
  ...pivotState,
@@ -65867,15 +65743,15 @@ function useReport(reportIdArg, options = {}) {
65867
65743
  rowLimit: limit?.value
65868
65744
  } : null;
65869
65745
  }, [sourceReport, pivotState, pivotSort, limit, resolvedSortFieldType]);
65870
- const nextPivotHash = useMemo33(
65746
+ const nextPivotHash = useMemo32(
65871
65747
  () => stableSerializeForQueryKey(nextPivot),
65872
65748
  [nextPivot]
65873
65749
  );
65874
- const filterStackHash = useMemo33(
65750
+ const filterStackHash = useMemo32(
65875
65751
  () => stableSerializeForQueryKey(filterStack),
65876
65752
  [filterStack]
65877
65753
  );
65878
- const shouldSkipPivotRefreshForUnchangedPivot = useMemo33(() => {
65754
+ const shouldSkipPivotRefreshForUnchangedPivot = useMemo32(() => {
65879
65755
  if (!sourceReport || !nextPivot) return false;
65880
65756
  if (!Array.isArray(sourceReport.rows) || sourceReport.rows.length === 0) {
65881
65757
  return false;
@@ -65913,7 +65789,7 @@ function useReport(reportIdArg, options = {}) {
65913
65789
  shouldSkipPivotRefreshForUnchangedPivot,
65914
65790
  sourceReport
65915
65791
  ]);
65916
- const shouldSkipRedundantPivotTableDataReportBuilderQuery = useMemo33(() => {
65792
+ const shouldSkipRedundantPivotTableDataReportBuilderQuery = useMemo32(() => {
65917
65793
  if (!sourceReport || !nextPivot) {
65918
65794
  return false;
65919
65795
  }
@@ -66015,7 +65891,7 @@ function useReport(reportIdArg, options = {}) {
66015
65891
  });
66016
65892
  const tablePageReportBuilderState = pivotTableDataReportBuilderState ?? effectiveReportBuilderState;
66017
65893
  const tablePageReportBuilderStateHash = pivotTableDataReportBuilderState ? pivotTableDataReportBuilderStateHash : effectiveReportBuilderStateHash;
66018
- const tablePaginationSort = useMemo33(() => {
65894
+ const tablePaginationSort = useMemo32(() => {
66019
65895
  const sortEntry = tablePageReportBuilderState?.sort?.[0];
66020
65896
  const field = String(sortEntry?.field ?? "").trim();
66021
65897
  if (!field || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(field)) {
@@ -66077,7 +65953,7 @@ function useReport(reportIdArg, options = {}) {
66077
65953
  const tablePageRows = tablePageQueryEnabled && !tablePageQuery.data?.error && Array.isArray(tablePageQuery.data?.report?.rows) ? tablePageQuery.data.report.rows : void 0;
66078
65954
  const tablePageRowCount = tablePageQueryEnabled && typeof tablePageQuery.data?.report?.rowCount === "number" && tablePageQuery.data.report.rowCount > 0 ? tablePageQuery.data.report.rowCount : void 0;
66079
65955
  const tablePageFetching = tablePageQueryEnabled && tablePageQuery.isFetching;
66080
- const paginationTotalRowCount = useMemo33(() => {
65956
+ const paginationTotalRowCount = useMemo32(() => {
66081
65957
  if (tablePageRowCount !== void 0) {
66082
65958
  return Math.max(tablePageRowCount, baseWindowRowsLength);
66083
65959
  }
@@ -66191,7 +66067,7 @@ function useReport(reportIdArg, options = {}) {
66191
66067
  effectiveReportId,
66192
66068
  useFormRefreshDebugEnabled
66193
66069
  ]);
66194
- const chartData = useMemo33(() => {
66070
+ const chartData = useMemo32(() => {
66195
66071
  if (!sourceReport) return void 0;
66196
66072
  const rowsForChart = Array.isArray(sourceReport.rows) ? sourceReport.rows : [];
66197
66073
  const chartPivotForDisplay = nextPivot ?? (!chartPivotHydratedFromSourceRef.current ? sourceReport.pivot ?? null : null);
@@ -66227,18 +66103,18 @@ function useReport(reportIdArg, options = {}) {
66227
66103
  useInMemoryEngines,
66228
66104
  chartPivotHydrationEpoch
66229
66105
  ]);
66230
- const baseChart = useMemo33(
66106
+ const baseChart = useMemo32(
66231
66107
  () => normalizePivotChartForDisplay(chartData),
66232
66108
  [chartData]
66233
66109
  );
66234
- const chartAxesBaseChart = useMemo33(() => {
66110
+ const chartAxesBaseChart = useMemo32(() => {
66235
66111
  if (!chartData) return void 0;
66236
66112
  if (chartData.pivot?.columnField) {
66237
66113
  return normalizePivotChartForAxisControls(chartData, effectiveReportId);
66238
66114
  }
66239
66115
  return baseChart;
66240
66116
  }, [baseChart, chartData, effectiveReportId]);
66241
- const chartAxisOptions = useMemo33(() => {
66117
+ const chartAxisOptions = useMemo32(() => {
66242
66118
  if (!chartAxesBaseChart) return [];
66243
66119
  const optionsByField = /* @__PURE__ */ new Map();
66244
66120
  const registerOption = (fieldRaw, labelRaw, formatRaw) => {
@@ -66276,14 +66152,14 @@ function useReport(reportIdArg, options = {}) {
66276
66152
  );
66277
66153
  return Array.from(optionsByField.values());
66278
66154
  }, [chartAxesBaseChart]);
66279
- const chartAxisOptionByField = useMemo33(() => {
66155
+ const chartAxisOptionByField = useMemo32(() => {
66280
66156
  const optionsByField = /* @__PURE__ */ new Map();
66281
66157
  for (const option of chartAxisOptions) {
66282
66158
  optionsByField.set(option.value, option);
66283
66159
  }
66284
66160
  return optionsByField;
66285
66161
  }, [chartAxisOptions]);
66286
- const xAxisOptions = useMemo33(() => {
66162
+ const xAxisOptions = useMemo32(() => {
66287
66163
  if (!chartAxesBaseChart) return chartAxisOptions;
66288
66164
  const pivot = chartAxesBaseChart.pivot;
66289
66165
  const pivotRowField = String(pivot?.rowField ?? "").trim();
@@ -66306,7 +66182,7 @@ function useReport(reportIdArg, options = {}) {
66306
66182
  }
66307
66183
  return chartAxisOptions;
66308
66184
  }, [chartAxesBaseChart, chartAxisOptions, chartAxisOptionByField]);
66309
- const yAxisOptions = useMemo33(() => {
66185
+ const yAxisOptions = useMemo32(() => {
66310
66186
  if (!chartAxesBaseChart) return [];
66311
66187
  const keepOption = (option) => {
66312
66188
  const col = findSchemaColumnForChartAxisField(
@@ -66342,21 +66218,21 @@ function useReport(reportIdArg, options = {}) {
66342
66218
  chartAxisOptions,
66343
66219
  schemaColumnOptions
66344
66220
  ]);
66345
- const normalizedChartXAxisOptions = useMemo33(() => {
66221
+ const normalizedChartXAxisOptions = useMemo32(() => {
66346
66222
  return xAxisOptions.map((option) => ({
66347
66223
  value: String(option.value ?? "").trim(),
66348
66224
  label: String(option.label ?? option.value ?? "").trim(),
66349
66225
  format: String(option.format ?? "").trim()
66350
66226
  }));
66351
66227
  }, [xAxisOptions]);
66352
- const normalizedChartYAxisOptions = useMemo33(() => {
66228
+ const normalizedChartYAxisOptions = useMemo32(() => {
66353
66229
  return yAxisOptions.map((option) => ({
66354
66230
  value: String(option.value ?? "").trim(),
66355
66231
  label: String(option.label ?? option.value ?? "").trim(),
66356
66232
  format: String(option.format ?? "").trim()
66357
66233
  }));
66358
66234
  }, [yAxisOptions]);
66359
- const resolvedYAxisFields = useMemo33(() => {
66235
+ const resolvedYAxisFields = useMemo32(() => {
66360
66236
  if (!chartAxesBaseChart) return [];
66361
66237
  const normalizeYAxisField = (yAxisFieldRaw) => {
66362
66238
  const field = String(yAxisFieldRaw?.field ?? "").trim();
@@ -66399,7 +66275,7 @@ function useReport(reportIdArg, options = {}) {
66399
66275
  chartAxisOptionByField,
66400
66276
  chartAxisOptions
66401
66277
  ]);
66402
- const resolvedXAxisField = useMemo33(() => {
66278
+ const resolvedXAxisField = useMemo32(() => {
66403
66279
  if (!chartAxesBaseChart) return "";
66404
66280
  const chartType2 = String(chartAxesBaseChart.chartType ?? "").toLowerCase();
66405
66281
  const pivotRowField = String(
@@ -66431,7 +66307,7 @@ function useReport(reportIdArg, options = {}) {
66431
66307
  chartAxisOptions,
66432
66308
  resolvedYAxisFields
66433
66309
  ]);
66434
- const resolvedXAxisFormat = useMemo33(() => {
66310
+ const resolvedXAxisFormat = useMemo32(() => {
66435
66311
  if (!chartAxesBaseChart) {
66436
66312
  return "string";
66437
66313
  }
@@ -66459,7 +66335,7 @@ function useReport(reportIdArg, options = {}) {
66459
66335
  resolvedXAxisField,
66460
66336
  resolvedYAxisFields
66461
66337
  ]);
66462
- const resolvedXAxisLabel = useMemo33(() => {
66338
+ const resolvedXAxisLabel = useMemo32(() => {
66463
66339
  const defaultXLabel = String(
66464
66340
  chartAxesBaseChart?.xAxisLabel ?? chartAxisOptionByField.get(resolvedXAxisField)?.label ?? ""
66465
66341
  ).trim();
@@ -66473,13 +66349,13 @@ function useReport(reportIdArg, options = {}) {
66473
66349
  chartAxisOptionByField,
66474
66350
  resolvedXAxisField
66475
66351
  ]);
66476
- const chartVisibility = useMemo33(
66352
+ const chartVisibility = useMemo32(
66477
66353
  () => ({
66478
66354
  showLegend: chartVisibilityOverrides.showLegend ?? Boolean(baseChart?.showLegend ?? false)
66479
66355
  }),
66480
66356
  [baseChart?.showLegend, chartVisibilityOverrides]
66481
66357
  );
66482
- const axisConfig = useMemo33(() => {
66358
+ const axisConfig = useMemo32(() => {
66483
66359
  const pivotBucketXAxis = isPivotTableDateBucketRowAxis(
66484
66360
  chartAxesBaseChart,
66485
66361
  resolvedXAxisField
@@ -66521,14 +66397,14 @@ function useReport(reportIdArg, options = {}) {
66521
66397
  resolvedYAxisFields,
66522
66398
  chartVisibility.showLegend
66523
66399
  ]);
66524
- const resolvedYAxisFieldsForDisplay = useMemo33(() => {
66400
+ const resolvedYAxisFieldsForDisplay = useMemo32(() => {
66525
66401
  if (!baseChart) return resolvedYAxisFields;
66526
66402
  return mapResolvedPivotYAxisFieldsForDisplay({
66527
66403
  chart: baseChart,
66528
66404
  resolvedYAxisFields
66529
66405
  });
66530
66406
  }, [baseChart, resolvedYAxisFields]);
66531
- const chart = useMemo33(() => {
66407
+ const chart = useMemo32(() => {
66532
66408
  if (!baseChart) return void 0;
66533
66409
  let columns2 = mergeChartColumnFormatsFromYAxisFields(
66534
66410
  baseChart.columns,
@@ -66580,7 +66456,7 @@ function useReport(reportIdArg, options = {}) {
66580
66456
  const isPivotTableChart = String(chartType ?? "").toLowerCase() === "table" && Boolean(
66581
66457
  chart && chart.pivot && Array.isArray(chart.columns) && chart.columns.length > 0
66582
66458
  );
66583
- const chartAxes = useMemo33(() => {
66459
+ const chartAxes = useMemo32(() => {
66584
66460
  const yAxisItems = resolvedYAxisFields.map(
66585
66461
  (yAxisField, index) => ({
66586
66462
  id: String(index),
@@ -66729,8 +66605,8 @@ function useReport(reportIdArg, options = {}) {
66729
66605
  xAxisOptions,
66730
66606
  yAxisOptions
66731
66607
  ]);
66732
- const tableFormatCacheRef = useRef25(/* @__PURE__ */ new Map());
66733
- const tableFormatMerge = useMemo33(
66608
+ const tableFormatCacheRef = useRef24(/* @__PURE__ */ new Map());
66609
+ const tableFormatMerge = useMemo32(
66734
66610
  () => mergeDisplayAndSourceForTableFormats({
66735
66611
  effectiveReportBuilderTableNames,
66736
66612
  scopedSchemaColumns,
@@ -66744,7 +66620,7 @@ function useReport(reportIdArg, options = {}) {
66744
66620
  sourceReport
66745
66621
  ]
66746
66622
  );
66747
- const table = useMemo33(() => {
66623
+ const table = useMemo32(() => {
66748
66624
  const baseWindowRows = Array.isArray(sourceReport?.rows) ? sourceReport.rows : [];
66749
66625
  const rawRows = !paginationActive ? baseWindowRows : tablePageRows ?? baseWindowRows.slice(paginationRangeStart, paginationRangeEnd);
66750
66626
  const { columns: mergedFromReport } = mergeDisplayAndSourceForTableFormats({
@@ -66873,7 +66749,7 @@ function useReport(reportIdArg, options = {}) {
66873
66749
  const {
66874
66750
  columnsOptions: tableFormattingColumnOptions,
66875
66751
  hasTableDrivenColumnOrder
66876
- } = useMemo33(() => {
66752
+ } = useMemo32(() => {
66877
66753
  if (isPivotTableChart && chart?.columns?.length) {
66878
66754
  const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
66879
66755
  const pivotTableColumns = aggregationSlotColumns ? aggregationSlotColumns.tableColumns : chart.columns.map((c) => ({
@@ -66907,7 +66783,7 @@ function useReport(reportIdArg, options = {}) {
66907
66783
  schemaColumnOptions,
66908
66784
  table.columns
66909
66785
  ]);
66910
- const availableFields = useMemo33(
66786
+ const availableFields = useMemo32(
66911
66787
  () => tableColumnPickerPoolOptions.map((option) => ({
66912
66788
  id: option.value,
66913
66789
  label: option.label,
@@ -66915,24 +66791,24 @@ function useReport(reportIdArg, options = {}) {
66915
66791
  })),
66916
66792
  [tableColumnPickerPoolOptions]
66917
66793
  );
66918
- const axisSelectFormatLabels = useMemo33(
66794
+ const axisSelectFormatLabels = useMemo32(
66919
66795
  () => AXIS_FORMAT_OPTIONS.map((option) => option.label),
66920
66796
  []
66921
66797
  );
66922
- const xAxisFormatOptionLabels = useMemo33(() => {
66798
+ const xAxisFormatOptionLabels = useMemo32(() => {
66923
66799
  if (isPivotTableDateBucketRowAxis(chartAxesBaseChart, resolvedXAxisField)) {
66924
66800
  return ["date", ...axisSelectFormatLabels];
66925
66801
  }
66926
66802
  return axisSelectFormatLabels;
66927
66803
  }, [chartAxesBaseChart, resolvedXAxisField, axisSelectFormatLabels]);
66928
- const tableDerivedColumnOrder = useMemo33(() => {
66804
+ const tableDerivedColumnOrder = useMemo32(() => {
66929
66805
  return tableFormattingColumnOptions.map((option) => option.value);
66930
66806
  }, [tableFormattingColumnOptions]);
66931
- const tableDerivedColumnOrderSignature = useMemo33(
66807
+ const tableDerivedColumnOrderSignature = useMemo32(
66932
66808
  () => tableDerivedColumnOrder.join("|"),
66933
66809
  [tableDerivedColumnOrder]
66934
66810
  );
66935
- const activeTableColumnIds = useMemo33(() => {
66811
+ const activeTableColumnIds = useMemo32(() => {
66936
66812
  if (isPivotTableChart && chart?.columns?.length) {
66937
66813
  const aggregationSlotColumns = buildPivotColumnPivotTableFormattingColumns(chart);
66938
66814
  if (aggregationSlotColumns) {
@@ -66971,7 +66847,7 @@ function useReport(reportIdArg, options = {}) {
66971
66847
  tableDerivedColumnOrder,
66972
66848
  tableFormattingColumnOptions
66973
66849
  ]);
66974
- const columnOptionById = useMemo33(() => {
66850
+ const columnOptionById = useMemo32(() => {
66975
66851
  const map = /* @__PURE__ */ new Map();
66976
66852
  for (const option of tableColumnPickerPoolOptions) {
66977
66853
  map.set(option.value, option);
@@ -66983,7 +66859,7 @@ function useReport(reportIdArg, options = {}) {
66983
66859
  }
66984
66860
  return map;
66985
66861
  }, [tableColumnPickerPoolOptions, tableFormattingColumnOptions]);
66986
- const displayColumnById = useMemo33(() => {
66862
+ const displayColumnById = useMemo32(() => {
66987
66863
  const map = /* @__PURE__ */ new Map();
66988
66864
  for (const column of displayColumns) {
66989
66865
  const field = String(column.field ?? "").trim();
@@ -66994,7 +66870,7 @@ function useReport(reportIdArg, options = {}) {
66994
66870
  }
66995
66871
  return map;
66996
66872
  }, [displayColumns]);
66997
- const tableColumnSettingsById = useMemo33(() => {
66873
+ const tableColumnSettingsById = useMemo32(() => {
66998
66874
  const map = /* @__PURE__ */ new Map();
66999
66875
  const effectiveById = tableFormatMerge.formatByColumnOptionId;
67000
66876
  const chartColById = /* @__PURE__ */ new Map();
@@ -67112,13 +66988,13 @@ function useReport(reportIdArg, options = {}) {
67112
66988
  sourceReport?.columns,
67113
66989
  tableFormatMerge
67114
66990
  ]);
67115
- const tableColumnSettingsCoalesceRef = useRef25(
66991
+ const tableColumnSettingsCoalesceRef = useRef24(
67116
66992
  /* @__PURE__ */ new Map()
67117
66993
  );
67118
66994
  useLayoutEffect4(() => {
67119
66995
  tableColumnSettingsCoalesceRef.current = new Map(tableColumnSettingsById);
67120
66996
  }, [tableColumnSettingsById]);
67121
- const tableColumnItems = useMemo33(() => {
66997
+ const tableColumnItems = useMemo32(() => {
67122
66998
  const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
67123
66999
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
67124
67000
  const items = activeTableColumnIds.map((columnId) => {
@@ -67154,19 +67030,18 @@ function useReport(reportIdArg, options = {}) {
67154
67030
  isPivotTableChart,
67155
67031
  tableColumnSettingsById
67156
67032
  ]);
67157
- const tableColumnById = useMemo33(() => {
67033
+ const tableColumnById = useMemo32(() => {
67158
67034
  return new Map(tableColumnItems.map((item) => [item.id, item]));
67159
67035
  }, [tableColumnItems]);
67160
- const tableColumnList = useMemo33(() => {
67036
+ const tableColumnValues = useMemo32(() => {
67161
67037
  const pivotRowFieldForFormat = String(chart?.pivot?.rowField ?? "").trim();
67162
67038
  const pivotRowFieldType = String(chart?.pivot?.rowFieldType ?? "").trim();
67163
67039
  return tableColumnItems.map((item) => {
67164
67040
  const coerced = coerceTableColumnFormatToAxisValue(item.format);
67165
67041
  const usePivotDateOptions = isPivotTableChart && item.field === pivotRowFieldForFormat && isDateType(pivotRowFieldType) && coerced === "string";
67166
67042
  return {
67167
- id: item.id,
67043
+ value: item.id,
67168
67044
  label: item.label,
67169
- visible: true,
67170
67045
  format: item.formatLabel,
67171
67046
  ...usePivotDateOptions ? { formatOptions: [...PIVOT_DATE_BUCKET_FORMAT_OPTIONS] } : {}
67172
67047
  };
@@ -67329,22 +67204,32 @@ function useReport(reportIdArg, options = {}) {
67329
67204
  columns: buildSetReportColumnsFromIds(nextColumnIds, nextSettingsById)
67330
67205
  };
67331
67206
  };
67332
- let setReport;
67207
+ let applyReportChange;
67208
+ const setReport = (nextState) => {
67209
+ const { columns: nextColumns, ...rest } = nextState;
67210
+ const nextSettingsById = nextColumns === void 0 ? tableColumnSettingsById : new Map(
67211
+ nextColumns.map((column) => [
67212
+ column.value,
67213
+ { label: column.label, format: column.format }
67214
+ ])
67215
+ );
67216
+ applyReportChange({
67217
+ ...rest,
67218
+ ...nextColumns !== void 0 ? {
67219
+ columns: buildSetReportColumnsFromIds(
67220
+ nextColumns.map((column) => column.value),
67221
+ nextSettingsById
67222
+ )
67223
+ } : {}
67224
+ });
67225
+ };
67333
67226
  const commitTableColumns = (nextColumnIds, settingsById) => {
67334
- setReport({
67227
+ applyReportChange({
67335
67228
  columns: buildSetReportColumnsFromIds(nextColumnIds, settingsById)
67336
67229
  });
67337
67230
  };
67338
- setReport = (nextState) => {
67339
- let effectiveNextState = nextState;
67340
- if (isSetReportTableColumnSidebarPatch(nextState.columns)) {
67341
- const expanded = buildColumnSidebarSetReportInput(
67342
- nextState.columns.patch
67343
- );
67344
- if (!expanded) return;
67345
- const { columns: _omitSidebarColumnPatch, ...rest } = nextState;
67346
- effectiveNextState = { ...rest, ...expanded };
67347
- }
67231
+ applyReportChange = (nextState) => {
67232
+ const effectiveNextState = nextState;
67348
67233
  if (effectiveNextState.showLegend !== void 0) {
67349
67234
  setChartVisibilityOverrides((previous) => ({
67350
67235
  ...previous,
@@ -67417,15 +67302,18 @@ function useReport(reportIdArg, options = {}) {
67417
67302
  });
67418
67303
  }
67419
67304
  const isPivotSortUpdate = effectiveNextState.sort !== void 0 && Boolean(nextPivot);
67420
- const indexedAggregationUpdate = effectiveNextState.aggregations !== void 0 && typeof effectiveNextState.aggregations === "object" && !Array.isArray(effectiveNextState.aggregations) && "index" in effectiveNextState.aggregations && "value" in effectiveNextState.aggregations ? effectiveNextState.aggregations : null;
67421
- const isAppendingEmptyAggregationPlaceholder = indexedAggregationUpdate !== null && indexedAggregationUpdate.index === aggregationState.length && String(indexedAggregationUpdate.value ?? "").trim().length === 0;
67422
- const touchesPivotState = effectiveNextState.groupRowsBy !== void 0 || effectiveNextState.groupColumnsBy !== void 0 || effectiveNextState.aggregations !== void 0 && !isAppendingEmptyAggregationPlaceholder || isPivotSortUpdate || effectiveNextState.limit !== void 0;
67305
+ const isAppendingEmptyAggregationPlaceholder = Array.isArray(effectiveNextState.aggregations) && effectiveNextState.aggregations.length === aggregationValues.length + 1 && effectiveNextState.aggregations.slice(0, aggregationValues.length).every(
67306
+ (value, index) => String(value ?? "") === aggregationValues[index]
67307
+ ) && String(
67308
+ effectiveNextState.aggregations[aggregationValues.length] ?? ""
67309
+ ).trim().length === 0;
67310
+ const touchesPivotState = effectiveNextState.groupRowsBy !== void 0 || effectiveNextState.groupColumnsBy !== void 0 || effectiveNextState.dateBucket !== void 0 || effectiveNextState.aggregations !== void 0 && !isAppendingEmptyAggregationPlaceholder || isPivotSortUpdate || effectiveNextState.limit !== void 0;
67423
67311
  const isDatasourceUpdate = effectiveNextState.datasources !== void 0;
67424
67312
  const hasRowGroupSelection = typeof effectiveNextState.groupRowsBy === "string" && effectiveNextState.groupRowsBy.trim().length > 0;
67425
67313
  const hasColumnGroupSelection = typeof effectiveNextState.groupColumnsBy === "string" && effectiveNextState.groupColumnsBy.trim().length > 0;
67426
- const hasAggregationSelection = effectiveNextState.aggregations !== void 0 && (typeof effectiveNextState.aggregations === "string" ? effectiveNextState.aggregations.trim().length > 0 : Array.isArray(effectiveNextState.aggregations) ? effectiveNextState.aggregations.some(
67427
- (aggregation) => Boolean(aggregation?.aggregationType) && Boolean(String(aggregation?.valueField ?? "").trim())
67428
- ) : String(effectiveNextState.aggregations.value ?? "").trim().length > 0);
67314
+ const hasAggregationSelection = effectiveNextState.aggregations !== void 0 && (typeof effectiveNextState.aggregations === "string" ? effectiveNextState.aggregations.trim().length > 0 : effectiveNextState.aggregations.some(
67315
+ (aggregation) => typeof aggregation === "string" ? aggregation.trim().length > 0 : Boolean(aggregation?.aggregationType) && Boolean(String(aggregation?.valueField ?? "").trim())
67316
+ ));
67429
67317
  const isClearingRowGrouping = effectiveNextState.groupRowsBy !== void 0 && String(effectiveNextState.groupRowsBy ?? "").trim().length === 0;
67430
67318
  const queuePromoteColumnToRow = isClearingRowGrouping && !sourceReport;
67431
67319
  const shouldRefreshExpandedTableData = useInMemoryEngines && (hasRowGroupSelection || hasColumnGroupSelection || hasAggregationSelection) || !useInMemoryEngines && !nextPivot && effectiveNextState.sort !== void 0;
@@ -67498,7 +67386,7 @@ function useReport(reportIdArg, options = {}) {
67498
67386
  }
67499
67387
  }
67500
67388
  }
67501
- if (effectiveNextState.columns !== void 0 && !isSetReportTableColumnSidebarPatch(effectiveNextState.columns)) {
67389
+ if (effectiveNextState.columns !== void 0) {
67502
67390
  const normalizedDisplayColumns = normalizeColumnsInput(
67503
67391
  effectiveNextState.columns,
67504
67392
  columnIdentifierLookup
@@ -67585,6 +67473,10 @@ function useReport(reportIdArg, options = {}) {
67585
67473
  groupColumnsBySetViaSetReportRef.current = true;
67586
67474
  next.groupColumnsBy = effectiveNextState.groupColumnsBy || void 0;
67587
67475
  }
67476
+ if (effectiveNextState.dateBucket !== void 0) {
67477
+ dateBucketSetViaSetReportRef.current = true;
67478
+ next.dateBucket = effectiveNextState.dateBucket || void 0;
67479
+ }
67588
67480
  if (effectiveNextState.aggregations !== void 0) {
67589
67481
  aggregationStateSetViaSetReportRef.current = true;
67590
67482
  next.aggregationTablesByIndex = [...next.aggregationTablesByIndex];
@@ -67599,54 +67491,7 @@ function useReport(reportIdArg, options = {}) {
67599
67491
  ],
67600
67492
  schemaForeignKeyMap
67601
67493
  ).map((table2) => table2.name).filter((name2) => Boolean(name2));
67602
- if (typeof effectiveNextState.aggregations === "object" && !Array.isArray(effectiveNextState.aggregations) && "index" in effectiveNextState.aggregations && "value" in effectiveNextState.aggregations) {
67603
- const { index, value } = effectiveNextState.aggregations;
67604
- if (index >= 0 && index <= next.aggregationState.length) {
67605
- const rawValue = String(value ?? "").trim();
67606
- next.aggregationState = [...next.aggregationState];
67607
- if (!rawValue) {
67608
- if (index === next.aggregationState.length) {
67609
- next.aggregationState.push({ valueField: "" });
67610
- next.aggregationTablesByIndex.push(void 0);
67611
- } else if (index < next.aggregationState.length) {
67612
- next.aggregationState.splice(index, 1);
67613
- next.aggregationTablesByIndex.splice(index, 1);
67614
- }
67615
- } else {
67616
- const [aggregationTypeRaw] = rawValue.split(":");
67617
- const aggregationType = aggregationTypeRaw;
67618
- const { field: target, table: table2 } = resolveAggregationSelection(
67619
- rawValue,
67620
- aggregationOptionTableLookup,
67621
- preferredTables
67622
- );
67623
- const normalizedSelection = normalizeAggregationSelection(
67624
- aggregationType,
67625
- target,
67626
- table2,
67627
- preferredTables
67628
- );
67629
- const existing = next.aggregationState[index];
67630
- const preservedValueField2 = aggregationType !== "percentage" && existing?.valueField2 ? { valueField2: existing.valueField2 } : {};
67631
- const nextAggregation = {
67632
- ...preservedValueField2,
67633
- aggregationType,
67634
- ...normalizedSelection.valueField ? { valueField: normalizedSelection.valueField } : {},
67635
- ...normalizedSelection.valueField2 ? { valueField2: normalizedSelection.valueField2 } : {},
67636
- ...normalizedSelection.table ? { valueFieldTable: normalizedSelection.table } : {}
67637
- };
67638
- if (index === next.aggregationState.length) {
67639
- next.aggregationState.push(nextAggregation);
67640
- next.aggregationTablesByIndex.push(
67641
- normalizedSelection.table || void 0
67642
- );
67643
- } else {
67644
- next.aggregationState[index] = nextAggregation;
67645
- next.aggregationTablesByIndex[index] = normalizedSelection.table || void 0;
67646
- }
67647
- }
67648
- }
67649
- } else if (typeof effectiveNextState.aggregations === "string") {
67494
+ if (typeof effectiveNextState.aggregations === "string") {
67650
67495
  const rawValue = effectiveNextState.aggregations.trim();
67651
67496
  if (!rawValue) {
67652
67497
  next.aggregationState = [];
@@ -67678,15 +67523,49 @@ function useReport(reportIdArg, options = {}) {
67678
67523
  ];
67679
67524
  }
67680
67525
  } else {
67681
- next.aggregationState = effectiveNextState.aggregations;
67682
- next.aggregationTablesByIndex = effectiveNextState.aggregations.map(
67683
- (aggregation) => String(aggregation.valueFieldTable ?? "").trim() || resolveFieldTable({
67684
- report: sourceReport,
67685
- field: aggregation.valueField,
67686
- schemaTables: schemaForReportBuilderState,
67687
- preferredTables
67688
- }) || void 0
67526
+ const decoded = effectiveNextState.aggregations.map(
67527
+ (aggregation) => {
67528
+ if (typeof aggregation !== "string") {
67529
+ return {
67530
+ aggregation,
67531
+ table: String(aggregation.valueFieldTable ?? "").trim() || resolveFieldTable({
67532
+ report: sourceReport,
67533
+ field: aggregation.valueField,
67534
+ schemaTables: schemaForReportBuilderState,
67535
+ preferredTables
67536
+ }) || void 0
67537
+ };
67538
+ }
67539
+ const rawValue = aggregation.trim();
67540
+ if (!rawValue) {
67541
+ return { aggregation: { valueField: "" }, table: void 0 };
67542
+ }
67543
+ const [aggregationTypeRaw] = rawValue.split(":");
67544
+ const aggregationType = aggregationTypeRaw;
67545
+ const { field: target, table: table2 } = resolveAggregationSelection(
67546
+ rawValue,
67547
+ aggregationOptionTableLookup,
67548
+ preferredTables
67549
+ );
67550
+ const normalizedSelection = normalizeAggregationSelection(
67551
+ aggregationType,
67552
+ target,
67553
+ table2,
67554
+ preferredTables
67555
+ );
67556
+ return {
67557
+ aggregation: {
67558
+ aggregationType,
67559
+ ...normalizedSelection.valueField ? { valueField: normalizedSelection.valueField } : {},
67560
+ ...normalizedSelection.valueField2 ? { valueField2: normalizedSelection.valueField2 } : {},
67561
+ ...normalizedSelection.table ? { valueFieldTable: normalizedSelection.table } : {}
67562
+ },
67563
+ table: normalizedSelection.table || void 0
67564
+ };
67565
+ }
67689
67566
  );
67567
+ next.aggregationState = decoded.map((entry) => entry.aggregation);
67568
+ next.aggregationTablesByIndex = decoded.map((entry) => entry.table);
67690
67569
  }
67691
67570
  }
67692
67571
  if (effectiveNextState.sort !== void 0) {
@@ -67801,29 +67680,9 @@ function useReport(reportIdArg, options = {}) {
67801
67680
  }
67802
67681
  });
67803
67682
  };
67804
- const tableColumns = {
67805
- items: tableColumnItems,
67806
- optionById: columnOptionById,
67807
- byId: tableColumnById,
67808
- columnList: tableColumnList,
67809
- getSetReportColumns: (ids) => {
67810
- const out = [];
67811
- for (const rawId of ids) {
67812
- const id = String(rawId ?? "").trim();
67813
- if (!id) continue;
67814
- const option = columnOptionById.get(id);
67815
- if (!option) continue;
67816
- const item = tableColumnById.get(id);
67817
- const customLabel = String(item?.customLabel ?? "").trim();
67818
- const format9 = String(item?.format ?? "").trim();
67819
- out.push({
67820
- field: option.field,
67821
- ...option.tableName ? { table: option.tableName } : {},
67822
- ...customLabel ? { label: customLabel } : {},
67823
- ...format9 ? { format: format9 } : {}
67824
- });
67825
- }
67826
- return out;
67683
+ const columnActions = {
67684
+ replace: (nextColumns) => {
67685
+ applyReportChange({ columns: nextColumns });
67827
67686
  },
67828
67687
  reorder: (oldIndex, newIndex) => {
67829
67688
  if (loading || isPivotTableChart) return;
@@ -67887,21 +67746,15 @@ function useReport(reportIdArg, options = {}) {
67887
67746
  setTableColumnsEditedSignature(tableDerivedColumnOrderSignature);
67888
67747
  commitTableColumns(nextColumnIds, tableColumnSettingsById);
67889
67748
  },
67890
- getColumnSidebarSetReportInput: (id, updates) => {
67891
- const normalizedId = String(id ?? "").trim();
67892
- if (!normalizedId) return null;
67893
- return {
67894
- columns: { patch: { id: normalizedId, ...updates } }
67895
- };
67896
- },
67897
67749
  update: (id, updates) => {
67898
67750
  const normalizedId = String(id ?? "").trim();
67899
67751
  if (!normalizedId) return;
67900
- setReport({
67901
- columns: { patch: { id: normalizedId, ...updates } }
67752
+ const expanded = buildColumnSidebarSetReportInput({
67753
+ id: normalizedId,
67754
+ ...updates
67902
67755
  });
67903
- },
67904
- structureEditsLocked: isPivotTableChart
67756
+ if (expanded) applyReportChange(expanded);
67757
+ }
67905
67758
  };
67906
67759
  const setFilters = (nextFilters) => {
67907
67760
  const preparedForStack = prepareQueryBuilderFiltersForSet(
@@ -67959,13 +67812,7 @@ function useReport(reportIdArg, options = {}) {
67959
67812
  }
67960
67813
  }
67961
67814
  };
67962
- const filterDraft = useReportFilterDraft({
67963
- reportId: effectiveReportId,
67964
- committedFilters: filtersForQueryBuilder,
67965
- queryBuilderProps: filterQueryBuilderProps,
67966
- setFilters
67967
- });
67968
- const saveChanges = useCallback6(async () => {
67815
+ const saveChanges = useCallback5(async () => {
67969
67816
  if (!client) return;
67970
67817
  if (!String(dashboardNameForNewReport ?? "").trim()) return;
67971
67818
  if (!sourceReport) return;
@@ -68043,17 +67890,23 @@ function useReport(reportIdArg, options = {}) {
68043
67890
  groupRowsByOptions,
68044
67891
  groupColumnsBy,
68045
67892
  groupColumnsByOptions,
68046
- aggregations: aggregationState,
67893
+ dateBucket,
67894
+ dateBucketOptions: PIVOT_DATE_BUCKET_OPTIONS,
67895
+ /** Encoded selection per aggregation slot (`'sum:transactions::amount'`, `'count:transactions'`, `''` = placeholder). Update via `setReport({ aggregations: nextStringArray })`. */
67896
+ aggregations: aggregationValues,
67897
+ /** Flat aggregation pick list shared by all slots; always contains every non-empty `aggregations` entry. */
68047
67898
  aggregationOptions,
68048
67899
  aggregationDescriptionOptions: cleanedAggregations,
68049
67900
  sort: cleanedSort,
68050
67901
  sortOptions,
68051
67902
  chartType,
68052
67903
  chartTypeOptions: chartTypes,
68053
- /** Encoded field keys for the current column selection (for `setReport({ columns })`, etc.). */
68054
- columnIds: columns,
68055
- /** Selected columns + `reorder` / `toggle` / `update` / `remove`. */
68056
- columns: tableColumns,
67904
+ /** Selected tabular columns in display order. */
67905
+ columns: tableColumnValues,
67906
+ /** Pivot table columns only allow label and format changes. */
67907
+ columnStructureEditsLocked: isPivotTableChart,
67908
+ /** Optional rich operations; simple selection updates use `setReport({ columns })`. */
67909
+ columnActions,
68057
67910
  /** Schema columns for current datasources — pool for the table column picker. */
68058
67911
  columnOptions: tableColumnPickerPoolOptions,
68059
67912
  xAxis: chartAxes.xAxis,
@@ -68080,13 +67933,6 @@ function useReport(reportIdArg, options = {}) {
68080
67933
  hasTableDrivenColumnOrder,
68081
67934
  filters: filtersForQueryBuilder,
68082
67935
  filterQueryBuilderProps,
68083
- /**
68084
- * Draft → Apply lifecycle for react-querybuilder (flat keys):
68085
- * `<QueryBuilder key={filterDraftKey} {...filterDraftQueryBuilderProps} />`
68086
- * plus `isFilterDraftDirty` / `isFilterDraftEmpty` /
68087
- * `commitFilterDraft` / `resetFilterDraft` / `seedFilterDraft`.
68088
- */
68089
- ...filterDraft,
68090
67936
  /** True while `report-builder-unique-values` runs for filter value options (not chart/table load). */
68091
67937
  filterUniqueValuesLoading,
68092
67938
  limit,
@@ -68094,7 +67940,6 @@ function useReport(reportIdArg, options = {}) {
68094
67940
  chartTypes,
68095
67941
  columnsOptions: tableColumnPickerPoolOptions,
68096
67942
  tableColumnOptions: tableColumnPickerPoolOptions,
68097
- tableColumns,
68098
67943
  setReport,
68099
67944
  saveChanges,
68100
67945
  setFilters,
@@ -68112,7 +67957,7 @@ function ChatChartCard({
68112
67957
  ButtonComponent = MemoizedButton
68113
67958
  }) {
68114
67959
  const {
68115
- columnIds,
67960
+ columns,
68116
67961
  columnOptions,
68117
67962
  groupRowsBy,
68118
67963
  groupRowsByOptions,
@@ -68126,20 +67971,10 @@ function ChatChartCard({
68126
67971
  loading,
68127
67972
  setReport
68128
67973
  } = useReport(reportId);
68129
- const columnSelectOptions = useMemo34(() => {
68130
- return (columnOptions ?? []).map((option) => {
68131
- const value = String(option?.value ?? "").trim();
68132
- if (!value) return null;
68133
- const tableName = String(option?.tableName ?? "").trim();
68134
- const fieldName = String(option?.field ?? "").trim() || String(option?.label ?? "").trim() || value;
68135
- return {
68136
- value,
68137
- label: tableName ? `${tableName}.${fieldName}` : fieldName
68138
- };
68139
- }).filter(
68140
- (option) => Boolean(option)
68141
- );
68142
- }, [columnOptions]);
67974
+ const selectedColumnValues = useMemo33(
67975
+ () => columns.map((column) => column.value),
67976
+ [columns]
67977
+ );
68143
67978
  return /* @__PURE__ */ jsxs64(
68144
67979
  "div",
68145
67980
  {
@@ -68175,7 +68010,7 @@ function ChatChartCard({
68175
68010
  padding: 16
68176
68011
  },
68177
68012
  children: [
68178
- JSON.stringify(columnIds, null, 2),
68013
+ JSON.stringify(columns, null, 2),
68179
68014
  /* @__PURE__ */ jsxs64(
68180
68015
  "label",
68181
68016
  {
@@ -68192,13 +68027,24 @@ function ChatChartCard({
68192
68027
  "select",
68193
68028
  {
68194
68029
  multiple: true,
68195
- size: Math.min(10, Math.max(4, columnSelectOptions.length || 4)),
68196
- value: columnIds,
68030
+ size: Math.min(10, Math.max(4, columnOptions.length || 4)),
68031
+ value: selectedColumnValues,
68197
68032
  onChange: (event) => {
68198
- const nextColumns = Array.from(event.target.selectedOptions).map(
68199
- (option) => option.value
68033
+ const selectedByValue = new Map(
68034
+ columns.map((column) => [column.value, column])
68200
68035
  );
68201
- setReport({ columns: nextColumns });
68036
+ const optionByValue = new Map(
68037
+ columnOptions.map((option) => [option.value, option])
68038
+ );
68039
+ setReport({
68040
+ columns: Array.from(event.target.selectedOptions).map(
68041
+ (selectedOption) => selectedByValue.get(selectedOption.value) ?? {
68042
+ value: selectedOption.value,
68043
+ label: optionByValue.get(selectedOption.value)?.label ?? selectedOption.value,
68044
+ format: ""
68045
+ }
68046
+ )
68047
+ });
68202
68048
  },
68203
68049
  style: {
68204
68050
  width: 200,
@@ -68208,7 +68054,7 @@ function ChatChartCard({
68208
68054
  padding: 8,
68209
68055
  background: "#fff"
68210
68056
  },
68211
- children: columnSelectOptions.map((option) => /* @__PURE__ */ jsx87("option", { value: option.value, children: option.label }, option.value))
68057
+ children: columnOptions.map((option) => /* @__PURE__ */ jsx87("option", { value: option.value, children: option.label }, option.value))
68212
68058
  }
68213
68059
  )
68214
68060
  ]
@@ -68234,28 +68080,27 @@ function ChatChartCard({
68234
68080
  onChange: (e) => setReport({ groupColumnsBy: e.target.value ?? "" })
68235
68081
  }
68236
68082
  ),
68237
- aggregationOptions.map((row, index) => /* @__PURE__ */ jsx87(
68083
+ aggregations.map((value, index) => /* @__PURE__ */ jsx87(
68238
68084
  SelectComponent,
68239
68085
  {
68240
- value: row.value,
68241
- label: row.label,
68086
+ value,
68087
+ label: `Aggregation ${index + 1}`,
68242
68088
  width: 200,
68243
- options: row.options,
68089
+ options: aggregationOptions,
68244
68090
  onChange: (e) => setReport({
68245
- aggregations: { index, value: e.target.value ?? "" }
68091
+ aggregations: aggregations.map(
68092
+ (aggregation, i) => i === index ? e.target.value ?? "" : aggregation
68093
+ )
68246
68094
  })
68247
68095
  },
68248
- row.key
68096
+ `aggregation-${index}`
68249
68097
  )),
68250
68098
  /* @__PURE__ */ jsx87(
68251
68099
  ButtonComponent,
68252
68100
  {
68253
68101
  label: "Add aggregation",
68254
68102
  onClick: () => setReport({
68255
- aggregations: {
68256
- index: aggregations.length,
68257
- value: "count transactions"
68258
- }
68103
+ aggregations: [...aggregations, "count:transactions"]
68259
68104
  })
68260
68105
  }
68261
68106
  ),
@@ -68393,7 +68238,7 @@ function ToolCallBlock({ toolCall }) {
68393
68238
  );
68394
68239
  }
68395
68240
  function ToolCallResult({ content }) {
68396
- const [expanded, setExpanded] = useState43(false);
68241
+ const [expanded, setExpanded] = useState42(false);
68397
68242
  if (!content) return null;
68398
68243
  const isLong = content.length > 300;
68399
68244
  const displayed = isLong && !expanded ? content.slice(0, 300) + "..." : content;
@@ -68448,14 +68293,14 @@ function Chat({
68448
68293
  const [client] = useContext37(ClientContext);
68449
68294
  const { getToken } = useContext37(FetchContext);
68450
68295
  const { tenants } = useContext37(TenantContext);
68451
- const [messages, setMessages] = useState43([]);
68452
- const [input, setInput] = useState43("");
68453
- const [inputError, setInputError] = useState43("");
68454
- const [isLoading, setIsLoading] = useState43(false);
68455
- const [model, setModel] = useState43("gemini-3-flash-preview");
68456
- const containerRef = useRef26(null);
68457
- const textareaRef = useRef26(null);
68458
- const abortControllerRef = useRef26(null);
68296
+ const [messages, setMessages] = useState42([]);
68297
+ const [input, setInput] = useState42("");
68298
+ const [inputError, setInputError] = useState42("");
68299
+ const [isLoading, setIsLoading] = useState42(false);
68300
+ const [model, setModel] = useState42("gemini-3-flash-preview");
68301
+ const containerRef = useRef25(null);
68302
+ const textareaRef = useRef25(null);
68303
+ const abortControllerRef = useRef25(null);
68459
68304
  useEffect32(() => {
68460
68305
  if (!containerRef.current) {
68461
68306
  return;
@@ -68889,6 +68734,150 @@ function Chat({
68889
68734
  );
68890
68735
  }
68891
68736
 
68737
+ // src/hooks/useReportFilterDraft.ts
68738
+ import { useCallback as useCallback6, useMemo as useMemo34, useRef as useRef26, useState as useState43 } from "react";
68739
+ var normalizeOperatorKey = (operator) => String(operator ?? "").trim().toLowerCase().replace(/[_\s]+/g, "");
68740
+ var defaultFilterRuleValueForOperator = (operator) => {
68741
+ const key = normalizeOperatorKey(operator);
68742
+ if (key === "in" || key === "notin") {
68743
+ return [];
68744
+ }
68745
+ return "";
68746
+ };
68747
+ var EMPTY_COMMITTED_FILTERS = {
68748
+ combinator: "and",
68749
+ rules: []
68750
+ };
68751
+ var hashString2 = (input) => {
68752
+ let hash = 2166136261;
68753
+ for (let i = 0; i < input.length; i++) {
68754
+ hash ^= input.charCodeAt(i);
68755
+ hash = Math.imul(hash, 16777619);
68756
+ }
68757
+ return String(hash >>> 0);
68758
+ };
68759
+ var fieldCatalogSignature = (fields) => {
68760
+ const names = fields.map((field) => String(field.name ?? "").trim()).filter(Boolean).sort();
68761
+ return `${names.length}:${hashString2(names.join("\0"))}`;
68762
+ };
68763
+ var committedFiltersSignature = (committed) => {
68764
+ try {
68765
+ return hashString2(
68766
+ JSON.stringify(stripQueryBuilderTransientFields(committed))
68767
+ );
68768
+ } catch {
68769
+ return "unserializable";
68770
+ }
68771
+ };
68772
+ function useReportFilterDraft(args) {
68773
+ const { reportId, committedFilters, queryBuilderProps, setFilters } = args;
68774
+ const committed = isQueryBuilderDisplayGroup(committedFilters) ? committedFilters : EMPTY_COMMITTED_FILTERS;
68775
+ const committedRef = useRef26(committed);
68776
+ committedRef.current = committed;
68777
+ const setFiltersRef = useRef26(setFilters);
68778
+ setFiltersRef.current = setFilters;
68779
+ const lastNonEmptyFieldsRef = useRef26([]);
68780
+ const prevReportIdForFieldsRef = useRef26(reportId);
68781
+ if (prevReportIdForFieldsRef.current !== reportId) {
68782
+ prevReportIdForFieldsRef.current = reportId;
68783
+ lastNonEmptyFieldsRef.current = [];
68784
+ }
68785
+ if (queryBuilderProps.fields.length > 0) {
68786
+ lastNonEmptyFieldsRef.current = queryBuilderProps.fields;
68787
+ }
68788
+ const effectiveFields = queryBuilderProps.fields.length > 0 ? queryBuilderProps.fields : lastNonEmptyFieldsRef.current;
68789
+ const committedSignature = useMemo34(
68790
+ () => committedFiltersSignature(committed),
68791
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- `committed` normalizes null to a stable constant
68792
+ [committedFilters]
68793
+ );
68794
+ const fieldsSignature = useMemo34(
68795
+ () => fieldCatalogSignature(effectiveFields),
68796
+ [effectiveFields]
68797
+ );
68798
+ const [resetEpoch, setResetEpoch] = useState43(0);
68799
+ const [draftQuery, setDraftQuery] = useState43(committed);
68800
+ const [hasUnappliedFilterChanges, setHasUnappliedFilterChanges] = useState43(false);
68801
+ const draftResetKey = `${reportId}|${committedSignature}|${resetEpoch}`;
68802
+ const prevDraftResetKeyRef = useRef26(draftResetKey);
68803
+ if (prevDraftResetKeyRef.current !== draftResetKey) {
68804
+ prevDraftResetKeyRef.current = draftResetKey;
68805
+ setDraftQuery(committed);
68806
+ if (hasUnappliedFilterChanges) setHasUnappliedFilterChanges(false);
68807
+ }
68808
+ const filterDraftKey = `${draftResetKey}|${fieldsSignature}`;
68809
+ const handleQueryChange = useCallback6((next) => {
68810
+ if (!isQueryBuilderDisplayGroup(next)) return;
68811
+ const nextGroup = next;
68812
+ setDraftQuery(nextGroup);
68813
+ const nextDirty = areQueryBuilderFilterDraftsDirty(
68814
+ nextGroup,
68815
+ committedRef.current
68816
+ );
68817
+ setHasUnappliedFilterChanges(
68818
+ (prev) => prev === nextDirty ? prev : nextDirty
68819
+ );
68820
+ }, []);
68821
+ const applyFilterDraft = useCallback6(() => {
68822
+ setFiltersRef.current(draftQuery);
68823
+ }, [draftQuery]);
68824
+ const resetFilterDraft = useCallback6(() => {
68825
+ setDraftQuery(committedRef.current);
68826
+ setHasUnappliedFilterChanges(false);
68827
+ setResetEpoch((epoch) => epoch + 1);
68828
+ }, []);
68829
+ const getDefaultValue = useCallback6(
68830
+ (rule) => defaultFilterRuleValueForOperator(rule?.operator),
68831
+ []
68832
+ );
68833
+ const filterDraftQueryBuilderProps = useMemo34(
68834
+ () => ({
68835
+ ...queryBuilderProps,
68836
+ fields: effectiveFields,
68837
+ // Uncontrolled: react-querybuilder owns the draft; only read at mount,
68838
+ // while state keeps the next mount hydrated from the latest edits.
68839
+ defaultQuery: draftQuery,
68840
+ onQueryChange: handleQueryChange,
68841
+ addRuleToNewGroups: true,
68842
+ getDefaultValue
68843
+ }),
68844
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- filterDraftKey covers draftRef resets
68845
+ [
68846
+ queryBuilderProps,
68847
+ effectiveFields,
68848
+ draftQuery,
68849
+ handleQueryChange,
68850
+ getDefaultValue,
68851
+ filterDraftKey
68852
+ ]
68853
+ );
68854
+ return {
68855
+ filterDraftKey,
68856
+ filterDraftQueryBuilderProps,
68857
+ hasUnappliedFilterChanges,
68858
+ applyFilterDraft,
68859
+ resetFilterDraft
68860
+ };
68861
+ }
68862
+
68863
+ // src/hooks/useReportQueryBuilder.ts
68864
+ function useReportQueryBuilder(args) {
68865
+ const draft = useReportFilterDraft({
68866
+ reportId: args.reportId ?? "",
68867
+ committedFilters: args.filters,
68868
+ queryBuilderProps: args.queryBuilderProps,
68869
+ setFilters: args.onApply
68870
+ });
68871
+ return {
68872
+ key: draft.filterDraftKey,
68873
+ props: draft.filterDraftQueryBuilderProps,
68874
+ hasUnappliedChanges: draft.hasUnappliedFilterChanges,
68875
+ apply: draft.applyFilterDraft,
68876
+ discard: draft.resetFilterDraft,
68877
+ reset: draft.resetFilterDraft
68878
+ };
68879
+ }
68880
+
68892
68881
  // src/ReportDetail.tsx
68893
68882
  import {
68894
68883
  useContext as useContext38,
@@ -70023,7 +70012,6 @@ export {
70023
70012
  Table_default as Table,
70024
70013
  ThemeContext,
70025
70014
  areQueryBuilderFilterDraftsDirty,
70026
- buildSeededFilterQuery,
70027
70015
  countFilterRules,
70028
70016
  defaultFilterRuleValueForOperator,
70029
70017
  downloadCSV,
@@ -70048,6 +70036,7 @@ export {
70048
70036
  useQuill,
70049
70037
  useReport,
70050
70038
  useReportBuilder,
70039
+ useReportQueryBuilder,
70051
70040
  useReports,
70052
70041
  useTenants,
70053
70042
  useVirtualTables