react-semaphor 0.1.607 → 0.1.609
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/analytics-protocol/index.js +1 -1
- package/dist/assistant-context/index.js +1 -1
- package/dist/brand-studio/index.js +1 -1
- package/dist/briefings/index.js +1 -1
- package/dist/chunks/{appearance-provider-C4lPZcaN.js → appearance-provider-BW022_Qu.js} +106 -106
- package/dist/chunks/{assistant-chat-B7Fngg8U.js → assistant-chat-DAmFZEnD.js} +8 -8
- package/dist/chunks/attachment-filter-line-ClTS4GvQ.js +1 -0
- package/dist/chunks/{bookmark-impact-DjrrJomS.js → bookmark-impact-BEVaXjug.js} +1 -1
- package/dist/chunks/{bookmark-state-x9hJS83D.js → bookmark-state-DnkzIsyw.js} +1 -1
- package/dist/chunks/{brand-DgFcvKJI.js → brand-BjC1mPjw.js} +1 -1
- package/dist/chunks/card-filter-builder-BGIVEHmJ.js +11 -0
- package/dist/chunks/{visual-contract-DQPKg5QW.js → check-input-qgwboKei.js} +13 -5
- package/dist/chunks/{comparison-window-caption-zUZDe4tL.js → comparison-window-caption-WzGsqv4n.js} +1 -1
- package/dist/chunks/{currency-presentation-binding-w9WDUk3b.js → currency-presentation-binding-ClrH_6Tq.js} +1 -1
- package/dist/chunks/{custom-visual-inputs-D8U98aBz.js → custom-visual-inputs-CoAs_73N.js} +1 -1
- package/dist/chunks/custom-visual-write-BWApKrHe.js +1 -0
- package/dist/chunks/{dashboard-BEd6i29E.js → dashboard-DbBgEesz.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DMDYM9IA.js → dashboard-briefing-launcher-DadG4ES9.js} +14 -9
- package/dist/chunks/{dashboard-controls-5B2vCIjJ.js → dashboard-controls-CyQg_GC1.js} +3 -3
- package/dist/chunks/{dashboard-json-C6r30x-5.js → dashboard-json-ZSAQQkcR.js} +1 -1
- package/dist/chunks/{dashboard-temporal-snapshot-Wki-YACw.js → dashboard-temporal-snapshot-BSTfqT29.js} +1 -1
- package/dist/chunks/edit-dashboard-visual-DIF1fllI.js +103 -0
- package/dist/chunks/{filter-line-COFQaF4_.js → filter-line-W-qQAjke.js} +1 -1
- package/dist/chunks/{filter-reach-preview-BWRGfSmb.js → filter-reach-preview-CfbwaLf4.js} +1 -1
- package/dist/chunks/filter-value-text-DQwYZHz0.js +1 -0
- package/dist/chunks/kpi-trend-rule-B4ebKzNj.js +1 -0
- package/dist/chunks/{layout-grid-DahW4ClC.js → layout-grid-Cs350bW-.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-Bd-dXB8q.js → matrix-analytical-definition-jn075ooo.js} +1 -1
- package/dist/chunks/{matrix-member-presentation-CfvxPV-i.js → matrix-member-presentation-Chz6uGYz.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-Cw7U53Ao.js → matrix-operation-contract-DceN49RX.js} +1 -1
- package/dist/chunks/{metric-formatting-QDqXfQGY.js → metric-formatting-toJrRqu4.js} +1 -1
- package/dist/chunks/{numeric-range-options-s6i_nDXg.js → numeric-range-options-Drc1EZ6H.js} +1 -1
- package/dist/chunks/{palette-CYvJHSqP.js → palette-DpLPXjUd.js} +1 -1
- package/dist/chunks/{pivot-result-contract-expectations-BX5gLcze.js → pivot-result-contract-expectations-D_ane7I2.js} +1 -1
- package/dist/chunks/{pivot-result-identity-DOISzHU4.js → pivot-result-identity-DRhVJMsF.js} +1 -1
- package/dist/chunks/{raw-temporal-value-Cssny3RJ.js → raw-temporal-value-B4Md6Xfb.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-BNpB9byP.js → report-preferences-dialog-DEfUYExu.js} +1 -1
- package/dist/chunks/{report-runtime-context-B8HuY0bu.js → report-runtime-context-CkxgMKr6.js} +1 -1
- package/dist/chunks/resolve-dashboard-input-context-Dm4PD8Gx.js +8 -0
- package/dist/chunks/{sandbox-host-Drf58_oU.js → sandbox-host-BqcLSoTV.js} +1 -1
- package/dist/chunks/{saved-dashboard-context-dbdbQ5bB.js → saved-dashboard-context-GjEJuDjj.js} +1 -1
- package/dist/chunks/{selection-filter-compiler-DK8KkS9g.js → selection-filter-compiler-BxtEEB6Z.js} +1 -1
- package/dist/chunks/semaphor-ready-indicator-BViyPq5k.js +622 -0
- package/dist/chunks/set-q-2M4nis.js +1 -0
- package/dist/chunks/slider-C2nbml5r.js +599 -0
- package/dist/chunks/{stored-dashboard-DmgJQcyZ.js → stored-dashboard-CTwrNvBy.js} +1 -1
- package/dist/chunks/{table-cell-text-2x6r_oHO.js → table-cell-text-DJe6I1G3.js} +1 -1
- package/dist/chunks/{table-export-sheet-CWqKiQu4.js → table-export-sheet-CthBUHu4.js} +1 -1
- package/dist/chunks/{token-types-BSyWn2pb.js → token-types-BM0mpZce.js} +1 -1
- package/dist/chunks/{validators-BPGmPz8-.js → validators-U8IL8djK.js} +1 -1
- package/dist/chunks/variable-draft-DAVLIY3l.js +1 -0
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/extensions/index.js +1 -1
- package/dist/format-utils/index.js +1 -1
- package/dist/index.js +1 -1
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/lib/dashboard-viewer/table-view.d.ts +6 -1
- package/dist/types/lib/types/explorer-types.d.ts +12 -0
- package/dist/types/shared/dashboard-authoring/card-settings/custom-visual-write.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/card-sort-comparison.d.ts +13 -0
- package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +12 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +8 -0
- package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +1 -0
- package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -0
- package/dist/types/shared/extensions/visual-contract.d.ts +3 -1
- package/dist/types/shared/usage-events/envelope.d.ts +2 -2
- package/package.json +1 -1
- package/dist/chunks/attachment-filter-line-wJRB0GSP.js +0 -1
- package/dist/chunks/card-filter-builder-CvxygmsE.js +0 -16
- package/dist/chunks/check-input-7DVPUuco.js +0 -1
- package/dist/chunks/edit-dashboard-visual-F2w7v4iB.js +0 -83
- package/dist/chunks/filter-value-text-BSAMEgve.js +0 -1
- package/dist/chunks/kpi-trend-rule-BcnKbY7d.js +0 -1
- package/dist/chunks/resolve-dashboard-input-context-B-0tONJg.js +0 -8
- package/dist/chunks/semaphor-ready-indicator-BSFsqsBJ.js +0 -617
- package/dist/chunks/set-oJDaJdtI.js +0 -1
- package/dist/chunks/slider-DAvAdfMC.js +0 -599
- package/dist/chunks/variable-draft-DGA22H2g.js +0 -1
package/dist/surfboard/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,R as s,D as o}from"../chunks/report-preferences-dialog-
|
|
1
|
+
import{a,R as s,D as o}from"../chunks/report-preferences-dialog-DEfUYExu.js";import{C as f,E as D}from"../chunks/bookmark-state-DnkzIsyw.js";export{f as CONTROL_CARD_DEFAULT_VALUE,a as DisplayFormatPreferencesFields,D as EMPTY_SELECTION,s as ReportPreferencesDialog,o as Surfboard};
|
package/dist/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as
|
|
1
|
+
import{B as s,A as r,C as l,E as o,V as i,j as n,c as d,g as m,f as u,b as E,e as c,d as C,a as T,z as p,y as A,q as D,h as I,s as _,x as F,w as S,m as b,n as L,o as f,p as y,k as N,u as R,v as h,i as g,r as x,l as M,t as O}from"../chunks/bookmark-state-DnkzIsyw.js";import{C as w,D as z,L as K,d as U,g as k,e as B,h as v,f as Y,c as q,a as G,i as P,b as Q,n as W,s as j}from"../chunks/validators-U8IL8djK.js";import{D as X}from"../chunks/token-types-BM0mpZce.js";import{r as Z,a as $}from"../chunks/pivot-result-identity-DRhVJMsF.js";import{D as ae}from"../chunks/report-runtime-context-CkxgMKr6.js";const e=["concatenate","conditional-category","date-part","date-difference","null-to-zero","safe-ratio","nested-conditional","membership-test","uppercase","lowercase","trim-whitespace","replace-text","first-characters","character-count","starts-with","number-to-text","start-of-month","start-of-quarter","start-of-year","year-number","add-days","round-number","round-down","round-up","absolute-value","cap-maximum","floor-minimum","fill-blanks","null-if-zero","is-blank"];export{s as BOOKMARK_STATE_VERSION,r as BOOKMARK_VISIBILITIES,w as CALCULATED_FIELD_ENTITY_MARKER,e as CALCULATED_FIELD_TEMPLATE_IDS,l as CONTROL_CARD_DEFAULT_VALUE,z as DATE_FORMAT_VALUES,ae as DEFAULT_CALENDAR_CONTEXT,X as DEFAULT_SEMANTIC_DOMAIN_ACCESS,o as EMPTY_SELECTION,K as LEGACY_CALCULATED_FIELD_ENTITY_MARKER,i as VIEWER_LIMITS,n as VIEWER_TABLE_SETTINGS_VERSION,d as collectDatasetNamesFromExplorerField,m as collectDatasetNamesFromFilterGroup,u as collectExecutionDatasetNamesFromExplorerField,E as collectPreferredDatasetNamesFromExplorerField,c as collectQualifiedDatasetNamesFromExplorerField,C as datasetRefFromSource,T as dependencyDisplayIdentity,U as getCalculatedFieldComputeStage,p as getCustomizableTableCardIds,k as getFieldRuntimeColumnName,A as getSortableTableCardIds,B as hasCalculatedFieldMarker,v as hasCalculatedFormulaInputs,D as hasColumnCustomization,Y as hasSyntheticCalculatedFieldOwner,I as humanizeDatasetName,q as inspectCalculatedField,G as isCalculatedDimension,P as isCalculatedMetric,Q as isDerivedField,_ as isEmptyViewerTableSettings,F as isTableCardCustomizable,S as isTableCardSortable,b as measureJsonBytes,W as normalizeCalculatedFieldRepresentation,L as normalizeTableColumnOrder,f as normalizeViewerTableSettings,y as parseBookmarkState,N as parseTableColumnId,R as parseViewerTableSettings,h as parseViewerTableSettingsMap,g as readBookmarkState,x as resolveFieldDatasetDependencies,Z as resolveQueryColumnKeyMapEntry,$ as resolveUniqueQueryColumnKeyMapEntry,j as shouldDropInheritedCalculationAggregate,M as tableSortEntryKey,O as toTableColumnId};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TCard } from '../types/common-types.js';
|
|
2
|
-
import { CardConfig, DetailField, GroupByField, MetricField, QueryColumnKeyMap } from '../types/explorer-types.js';
|
|
2
|
+
import { CardConfig, ComparisonSortPart, DetailField, GroupByField, MetricField, QueryColumnKeyMap } from '../types/explorer-types.js';
|
|
3
3
|
import { ComparisonMetadataMap } from '../types/query-types.js';
|
|
4
4
|
import { SemaphorResultColumn } from '../../shared/analytics-protocol/index.js';
|
|
5
5
|
import { TableColumnId, ViewerTableSettings } from '../../shared/dashboard-viewer/table-settings.js';
|
|
@@ -63,6 +63,11 @@ export type TableViewColumn = {
|
|
|
63
63
|
readonly pinned: boolean;
|
|
64
64
|
/** Can be pinned (PIN-2): an addressable base column; in a pivoted table, a row dimension only. */
|
|
65
65
|
readonly pinnable: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A measure's "Δ" column in a table sorted in the query: the part a click
|
|
68
|
+
* sorts by, the number the cell shows first (table comparison sort TCS-D2).
|
|
69
|
+
*/
|
|
70
|
+
readonly comparisonSortPart?: ComparisonSortPart;
|
|
66
71
|
};
|
|
67
72
|
/** A base column with an id: the columns a viewer's sort and widths address. */
|
|
68
73
|
export declare function isAddressableBaseColumn(column: Pick<TableViewColumn, 'part' | 'columnId'>): column is Pick<TableViewColumn, 'part'> & {
|
|
@@ -401,9 +401,21 @@ export declare function hasCalculatedFieldMarker(field: Pick<Field, 'entityName'
|
|
|
401
401
|
* the historical `calculated_fields` namespace.
|
|
402
402
|
*/
|
|
403
403
|
export declare function hasSyntheticCalculatedFieldOwner(field: Partial<Pick<Field, 'entityName' | 'entityId' | 'qualifiedEntityName'>> | null | undefined): boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Which output of a compared measure a sort ranks by (table comparison sort
|
|
406
|
+
* TCS-D1): `change` is current − previous, `percentChange` that change over
|
|
407
|
+
* |previous|, with `evaluateMetricComparison`'s arithmetic.
|
|
408
|
+
*/
|
|
409
|
+
export type ComparisonSortPart = 'change' | 'percentChange';
|
|
404
410
|
export interface SortByField extends Field {
|
|
405
411
|
role: 'sortby';
|
|
406
412
|
direction: 'asc' | 'desc';
|
|
413
|
+
/**
|
|
414
|
+
* Sorts by the measure's comparison instead of its value: the "Δ" column.
|
|
415
|
+
* Absent means the value, as every sort before it. A run without a
|
|
416
|
+
* comparison for the measure sorts by its value (TCS-D6).
|
|
417
|
+
*/
|
|
418
|
+
comparisonPart?: ComparisonSortPart;
|
|
407
419
|
}
|
|
408
420
|
/**
|
|
409
421
|
* Persisted authoring intent for the order of generated pivot-member columns.
|
|
@@ -38,7 +38,13 @@ export type CustomVisualWrite<T> = {
|
|
|
38
38
|
* for a saved visual the one the caller passes. Unknown ids and values the
|
|
39
39
|
* definition doesn't take are refused; a setting equal to its default and
|
|
40
40
|
* `null` both remove the override; an empty map is left out.
|
|
41
|
+
* - HTML that doesn't read is refused, unless the caller keeps it
|
|
42
|
+
* (`keepUnreadable`, the editor only, review P5G-16): then it is the card's
|
|
43
|
+
* draft as typed, with its overrides as they were. The card draws its table
|
|
44
|
+
* with the reason, and the save refuses it (`prepare-drafts`), so a visual
|
|
45
|
+
* that doesn't read is never saved, by either caller.
|
|
41
46
|
*/
|
|
42
47
|
export declare function writeCustomVisual<T extends Pick<TCard, 'type' | 'customVisual'>>(card: T, change: CustomVisualChange, context?: {
|
|
43
48
|
manifest?: VisualManifest;
|
|
49
|
+
keepUnreadable?: boolean;
|
|
44
50
|
}): CustomVisualWrite<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TCard } from '../../lib/types/common-types.js';
|
|
2
|
+
import { ComparisonSortPart, SortByField } from '../../lib/types/explorer-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a card's sort entry can rank its rows by a measure's change
|
|
5
|
+
* (table comparison sort TCS-D2, TCS-D7): a config Table that isn't pivoted,
|
|
6
|
+
* sorting by a measure whose comparison isn't off (`measureComparisonStateOn`). A measure without
|
|
7
|
+
* its own comparison follows the Date filter's; a run without one sorts by
|
|
8
|
+
* the value (TCS-D6). The one rule the editor's sort pill and the MCP's card
|
|
9
|
+
* order both apply.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sortCanRankByChange(card: Pick<TCard, 'type' | 'config' | 'sql' | 'preferences'>, sort: SortByField): boolean;
|
|
12
|
+
/** A sort's words for its part: "Change in Revenue", "% change in Revenue". */
|
|
13
|
+
export declare function comparisonSortLabel(part: ComparisonSortPart, measureLabel: string): string;
|
|
@@ -1255,6 +1255,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
|
|
|
1255
1255
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
1256
1256
|
}>]>;
|
|
1257
1257
|
direction: z.ZodEnum<["asc", "desc"]>;
|
|
1258
|
+
part: z.ZodOptional<z.ZodEnum<["change", "percentChange"]>>;
|
|
1258
1259
|
}, "strict", z.ZodTypeAny, {
|
|
1259
1260
|
field: string | {
|
|
1260
1261
|
name: string;
|
|
@@ -1272,6 +1273,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
|
|
|
1272
1273
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
1273
1274
|
};
|
|
1274
1275
|
direction: "asc" | "desc";
|
|
1276
|
+
part?: "change" | "percentChange" | undefined;
|
|
1275
1277
|
}, {
|
|
1276
1278
|
field: string | {
|
|
1277
1279
|
name: string;
|
|
@@ -1289,6 +1291,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
|
|
|
1289
1291
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
1290
1292
|
};
|
|
1291
1293
|
direction: "asc" | "desc";
|
|
1294
|
+
part?: "change" | "percentChange" | undefined;
|
|
1292
1295
|
}>>;
|
|
1293
1296
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
1294
1297
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -1471,6 +1474,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
|
|
|
1471
1474
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
1472
1475
|
};
|
|
1473
1476
|
direction: "asc" | "desc";
|
|
1477
|
+
part?: "change" | "percentChange" | undefined;
|
|
1474
1478
|
} | undefined;
|
|
1475
1479
|
dateField?: string | {
|
|
1476
1480
|
name: string;
|
|
@@ -1681,6 +1685,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
|
|
|
1681
1685
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
1682
1686
|
};
|
|
1683
1687
|
direction: "asc" | "desc";
|
|
1688
|
+
part?: "change" | "percentChange" | undefined;
|
|
1684
1689
|
} | undefined;
|
|
1685
1690
|
dateField?: string | {
|
|
1686
1691
|
name: string;
|
|
@@ -2756,6 +2761,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
|
|
|
2756
2761
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
2757
2762
|
}>]>;
|
|
2758
2763
|
direction: z.ZodEnum<["asc", "desc"]>;
|
|
2764
|
+
part: z.ZodOptional<z.ZodEnum<["change", "percentChange"]>>;
|
|
2759
2765
|
}, "strict", z.ZodTypeAny, {
|
|
2760
2766
|
field: string | {
|
|
2761
2767
|
name: string;
|
|
@@ -2773,6 +2779,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
|
|
|
2773
2779
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
2774
2780
|
};
|
|
2775
2781
|
direction: "asc" | "desc";
|
|
2782
|
+
part?: "change" | "percentChange" | undefined;
|
|
2776
2783
|
}, {
|
|
2777
2784
|
field: string | {
|
|
2778
2785
|
name: string;
|
|
@@ -2790,6 +2797,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
|
|
|
2790
2797
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
2791
2798
|
};
|
|
2792
2799
|
direction: "asc" | "desc";
|
|
2800
|
+
part?: "change" | "percentChange" | undefined;
|
|
2793
2801
|
}>>>;
|
|
2794
2802
|
limit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
2795
2803
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
@@ -2990,6 +2998,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
|
|
|
2990
2998
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
2991
2999
|
};
|
|
2992
3000
|
direction: "asc" | "desc";
|
|
3001
|
+
part?: "change" | "percentChange" | undefined;
|
|
2993
3002
|
} | null | undefined;
|
|
2994
3003
|
dateField?: string | {
|
|
2995
3004
|
name: string;
|
|
@@ -3216,6 +3225,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
|
|
|
3216
3225
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
3217
3226
|
};
|
|
3218
3227
|
direction: "asc" | "desc";
|
|
3228
|
+
part?: "change" | "percentChange" | undefined;
|
|
3219
3229
|
} | null | undefined;
|
|
3220
3230
|
dateField?: string | {
|
|
3221
3231
|
name: string;
|
|
@@ -4703,6 +4713,7 @@ export declare const dashboardChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zod
|
|
|
4703
4713
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
4704
4714
|
};
|
|
4705
4715
|
direction: "asc" | "desc";
|
|
4716
|
+
part?: "change" | "percentChange" | undefined;
|
|
4706
4717
|
} | null | undefined;
|
|
4707
4718
|
dateField?: string | {
|
|
4708
4719
|
name: string;
|
|
@@ -5042,6 +5053,7 @@ export declare const dashboardChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zod
|
|
|
5042
5053
|
aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
|
|
5043
5054
|
};
|
|
5044
5055
|
direction: "asc" | "desc";
|
|
5056
|
+
part?: "change" | "percentChange" | undefined;
|
|
5045
5057
|
} | null | undefined;
|
|
5046
5058
|
dateField?: string | {
|
|
5047
5059
|
name: string;
|
|
@@ -65,6 +65,14 @@ export type ColumnRef = Pick<Field, 'id' | 'name' | 'qualifiedEntityName'>;
|
|
|
65
65
|
export declare function ungroupRows(card: TCard, level: ColumnRef, ctx: ShapeContext): ShapeChange;
|
|
66
66
|
/** Stop spreading a field across columns; with no level left, back to every row. */
|
|
67
67
|
export declare function unspreadAcross(card: TCard, across: ColumnRef, ctx: ShapeContext): ShapeChange;
|
|
68
|
+
/**
|
|
69
|
+
* Put a level of Group rows by, or a field of Columns across, in front of
|
|
70
|
+
* another on the same lane (`before`), or last when `before` is absent: the
|
|
71
|
+
* Columns pane's grip. A Collapsible table moves the Matrix level as its Axis
|
|
72
|
+
* menu does (`moveMatrixLevel`); a Flat one reorders its Group by or pivot
|
|
73
|
+
* fields. Nothing else changes, so a level keeps its grain, sort and label.
|
|
74
|
+
*/
|
|
75
|
+
export declare function reorderShape(card: TCard, lane: 'levels' | 'across', ref: ColumnRef, before: ColumnRef | undefined, ctx: ShapeContext): ShapeChange;
|
|
68
76
|
/**
|
|
69
77
|
* Show a summary Flat (one row per group, paged by row) or Collapsible
|
|
70
78
|
* (levels, paged by level); Collapsible needs a level.
|
|
@@ -110,6 +110,7 @@ export declare const SHELF_FIELD_KEYS: {
|
|
|
110
110
|
readonly semanticComparisonPolarity: "shelf";
|
|
111
111
|
readonly parameters: "shelf";
|
|
112
112
|
readonly direction: "shelf";
|
|
113
|
+
readonly comparisonPart: "shelf";
|
|
113
114
|
readonly grainMode: "shelf";
|
|
114
115
|
};
|
|
115
116
|
/** The dialog's draft for a saved variable. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TCard, TDashboard } from '../../lib/types/common-types.js';
|
|
2
|
+
import { ComparisonSortPart } from '../../lib/types/explorer-types.js';
|
|
2
3
|
export declare const VIEWER_LIMITS: {
|
|
3
4
|
readonly bookmarksPerViewerPerDashboard: 20;
|
|
4
5
|
readonly bookmarkNameMaxChars: 100;
|
|
@@ -44,7 +45,14 @@ export declare function parseTableColumnId(value: string): TableColumnIdentity |
|
|
|
44
45
|
export type TableSortEntry = {
|
|
45
46
|
readonly columnId: TableColumnId;
|
|
46
47
|
readonly direction: 'asc' | 'desc';
|
|
48
|
+
/**
|
|
49
|
+
* A measure sorted by its comparison, its "Δ" column (table comparison
|
|
50
|
+
* sort TCS-D1): the measure's id with the part. Absent: the column's value.
|
|
51
|
+
*/
|
|
52
|
+
readonly comparisonPart?: ComparisonSortPart;
|
|
47
53
|
};
|
|
54
|
+
/** One sort per column and part: a measure can sort by its value and by its change. */
|
|
55
|
+
export declare function tableSortEntryKey(entry: Pick<TableSortEntry, 'columnId' | 'comparisonPart'>): string;
|
|
48
56
|
/**
|
|
49
57
|
* One viewer's choices for one table card. Sparse and normalized: a field that
|
|
50
58
|
* is empty or equals the author's is omitted, and settings equal to the
|
|
@@ -3,7 +3,8 @@ import { TCard } from '../../lib/types/common-types.js';
|
|
|
3
3
|
* The custom visual contract (version 2) as one text (PLAN-1-SPEC.md §3.2):
|
|
4
4
|
* what the editor's Copy prompt copies and what
|
|
5
5
|
* `semaphor_get_extension_contract` returns. One owner, two callers. It
|
|
6
|
-
* never names the product. `card` adds the card's own fields
|
|
6
|
+
* never names the product. `card` adds the card's own fields, and `current`
|
|
7
|
+
* the visual it draws now, for an assistant asked to change it (P5G-09).
|
|
7
8
|
*/
|
|
8
9
|
export declare function visualContractText(card?: {
|
|
9
10
|
fields: readonly {
|
|
@@ -11,6 +12,7 @@ export declare function visualContractText(card?: {
|
|
|
11
12
|
kind: 'dimension' | 'measure';
|
|
12
13
|
type: string;
|
|
13
14
|
}[];
|
|
15
|
+
current?: string;
|
|
14
16
|
}): string;
|
|
15
17
|
/** One of a card's fields as the contract lists it. */
|
|
16
18
|
export type ContractField = {
|
|
@@ -91,9 +91,9 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
91
91
|
message: string;
|
|
92
92
|
} | null;
|
|
93
93
|
surface: "api" | "embed" | "console" | "mcp" | "public_link" | "scheduler" | "pdf_renderer";
|
|
94
|
-
category: "runtime" | "usage" | "delivery" | "agent";
|
|
95
94
|
card_id: string | null;
|
|
96
95
|
sheet_id: string | null;
|
|
96
|
+
category: "runtime" | "usage" | "delivery" | "agent";
|
|
97
97
|
connection_id: string | null;
|
|
98
98
|
outcome: "cancelled" | "failed" | "timed_out" | "succeeded" | null;
|
|
99
99
|
domain_id: string | null;
|
|
@@ -120,9 +120,9 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
120
120
|
message: string;
|
|
121
121
|
} | null;
|
|
122
122
|
surface: "api" | "embed" | "console" | "mcp" | "public_link" | "scheduler" | "pdf_renderer";
|
|
123
|
-
category: "runtime" | "usage" | "delivery" | "agent";
|
|
124
123
|
card_id: string | null;
|
|
125
124
|
sheet_id: string | null;
|
|
125
|
+
category: "runtime" | "usage" | "delivery" | "agent";
|
|
126
126
|
connection_id: string | null;
|
|
127
127
|
outcome: "cancelled" | "failed" | "timed_out" | "succeeded" | null;
|
|
128
128
|
domain_id: string | null;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{T as M,aM as A,aN as N,aO as F,aP as $,aQ as S}from"./pivot-result-contract-expectations-BX5gLcze.js";import{h as T}from"./export-file-format-B-wQNHIn.js";import{j,aX as E,m as y,l as G}from"./validators-BPGmPz8-.js";import"./matrix-operation-contract-Cw7U53Ao.js";import"./analytics-base-schemas-DMFrDqn_.js";const de={rowLabels:"tabular",subtotals:"after"};function pe(e,t){const r=t.rowLabels==="outline"?{kind:"compact"}:e.layout.kind==="tabular"?e.layout:{kind:"tabular",repeatLabels:!1},o=e.totals.rows;return{...e,layout:r,totals:{...e.totals,rows:{...o,levels:Object.fromEntries(Object.entries(o.levels).map(([a,i])=>[a,{...i,position:t.subtotals}]))}}};}const U=2;function X(e){return typeof e=="number"?Number.isInteger(e):E(e)?!e.value.includes("."):!0;}function H(e,t,r){const o=e.descriptors.measures.filter(s=>r.measureFormats[s.id]===void 0&&s.semanticFormat===void 0&&j(s.column.dataType)==="number");if(o.length===0)return r;const a=/* @__PURE__ */new Set();e.columns.forEach((s,u)=>{if(!(s.kind!=="measure"||a.has(s.measureId)))for(const d of t){const c=d.values[u];if((c==null?void 0:c.kind)==="value"&&!X(c.value)){a.add(s.measureId);return;}}});const i={...r.measureFormats};for(const{id:s}of o){const u=a.has(s)?U:0;i[s]={type:"number",minimumFractionDigits:u,maximumFractionDigits:u,useGrouping:!0};}return{...r,measureFormats:i};}function P(e){return y(e.slice(0,-1));}function V(e,t){return t.length>e.length&&y(t.slice(0,e.length))===y(e);}function B(e){return e.map((t,r)=>{if(r===0||t.kind!=="layout")return!1;const o=e[r-1];if(o.kind!=="layout")return!1;if(t.role!=="member"||V(o.rowPath,t.rowPath))return!0;const a=e[r-2];return o.role==="member"&&(!a||a.kind!=="layout"||a.role!=="member"||P(a.rowPath)!==P(o.rowPath))&&t.rowPath.length===o.rowPath.length&&P(t.rowPath)===P(o.rowPath);});}const z="pdf-group-continuation";function R(e,t,r){return!(r!=null&&r.hasTextAffixes)&&t.kind==="value"&&(typeof t.value=="number"||E(t.value))?e:T(e);}function K(e,t,r){const o=M(e.descriptors,t.presentation,r),a=e.columns.map(n=>{var l;return n.kind==="measure"&&((l=o.measureSemantics.get(n.measureId))==null?void 0:l.isNumeric)===!0;}),i=n=>A([n],o.levels),s=(n,l,m)=>N(n,l,t.presentation.totals[m],o.levels),u=e.columns.map(n=>{if(n.kind!=="measure")return n.label;const l=n.columnPath.map(i);return n.role!=="member"&&l.push(s(n.columnPath,n.role,"columns")),[...l,n.label].join(" / ");}),d=Math.min(t.spec.columns.length,Math.max(0,...e.columns.map(n=>n.kind==="measure"?n.columnPath.length+(n.role!=="member"?1:0):0))),c=Array.from({length:d+1},(n,l)=>e.columns.map(m=>l===d?m.label:m.kind!=="measure"?"":l<m.columnPath.length?i(m.columnPath[l]):l===m.columnPath.length&&m.role!=="member"?s(m.columnPath,m.role,"columns"):"")),h=(n,l)=>F({path:n.rowPath,role:n.kind==="layout"?n.role:"member",levelCount:Math.max(1,t.spec.rows.length),repeatLabels:t.presentation.layout.kind!=="tabular"||t.presentation.layout.repeatLabels,previousPath:l==null?void 0:l.rowPath}),g=(n,l)=>{if(n.kind!=="layout")throw new Error("Layout presentation requires layout rows.");if(n.values.length!==e.columns.length)throw new Error("Matrix row does not match its frozen layout.");const m=h(n,l);return e.columns.map((p,f)=>{if(p.kind==="hierarchy")return`${" ".repeat(Math.max(0,n.rowPath.length-1))}${s(n.rowPath,n.role,"rows")}`;if(p.kind==="level"){const L=t.spec.rows.findIndex(O=>O.id===p.levelId),w=m[L];return w!=null&&w.visible?w.total?s(n.rowPath,n.role,"rows"):A(w.path,o.levels):"";}const x=n.values[f],v=o.measures.get(p.measureId);if(x.kind==="value"&&!v)throw new Error("Matrix value is missing its measure descriptor.");return $(x,v,t.presentation.absence);});},b=(n,l)=>g(n,l).map((m,p)=>{const f=e.columns[p];return f.kind==="measure"?R(m,n.values[p],o.measureSemantics.get(f.measureId)):T(m);});return{headers:u,headerBands:c,numericColumns:a,formatting:o,row:(n,l)=>g(n,l),continuedColumns:(n,l)=>{const m=f=>(f==null?void 0:f.kind)==="layout"&&f.role==="member";if(!m(n)||!m(l))return[];const p=h(n,l);return e.columns.flatMap((f,x)=>{var L;if(f.kind!=="level")return[];const v=t.spec.rows.findIndex(w=>w.id===f.levelId);return v<n.rowPath.length&&((L=p[v])==null?void 0:L.visible)===!1?[x]:[];});},csvRow:n=>b(n),csvRows:(n,l)=>n.map((m,p)=>b(m,p?n[p-1]:l??void 0))};}function fe(e){return e.columns.map(t=>T(t.label));}function he(e,t,r){return W(e,t,r).map((o,a)=>{const i=t.columns[a];return i.kind==="measure"?R(o,e.values[a],r.measureSemantics.get(i.measureId)):T(o);});}function W(e,t,r){if(e.kind!=="flat")throw new Error("Flat Matrix CSV requires flat rows.");if(e.values.length!==t.columns.length)throw new Error("Matrix row does not match its frozen layout.");const o=[...e.rowPath,...e.columnPath];return t.columns.map((a,i)=>{if(a.kind==="measure"){const u=e.values[i],d=r.measures.get(a.measureId);if(u.kind==="value"&&!d)throw new Error("Matrix value is missing its measure descriptor.");return $(u,d,r.absence);}const s=a.kind==="level"?o.find(u=>u.levelId===a.levelId):void 0;if(!s)throw new Error("Flat Matrix row does not match its frozen layout.");return A([s],r.levels);});}function q(e){const t=K(e.layout,e.request,e.report),r=e.layout.columns.map((s,u)=>({index:u,columnId:`matrix:${u}`,label:t.headers[u],isNumeric:t.numericColumns[u]})),o=(s,u,d)=>({text:s,colspan:1,rowspan:1,columnId:r[u].columnId,isHeader:d,isNumeric:r[u].isNumeric,className:r[u].isNumeric?"numeric":e.layout.columns[u].kind==="hierarchy"?"matrix-hierarchy":""}),a=[],i=e.layout.columns.findIndex(s=>s.kind==="measure");e.request.spec.columns.length&&i>=0&&a.push({repeatHeader:!0,headerType:"pivot-axis",headerRowIndex:0,cells:[...(i?[{...o("",0,!0),colspan:i}]:[]),{...o(e.request.spec.columns.map(s=>S(s,e.request.presentation)).join(" / "),i,!0),colspan:e.layout.columns.length-i,isNumeric:!1,className:""}]});for(const[s,u]of t.headerBands.entries())a.push({repeatHeader:!0,headerType:s===t.headerBands.length-1?"metrics":"pivot-level",headerRowIndex:a.length,cells:u.map((d,c)=>o(d,c,!0))});return{headers:a,rows:e.rows.map((s,u)=>{const d=new Set(t.continuedColumns(s,e.rows[u-1]));return{index:u,type:s.kind==="layout"&&s.role!=="member"?"subtotal":"data",subtotalLevel:String(s.rowPath.length),cells:t.row(s,e.rows[u-1]).map((c,h)=>d.has(h)?{...o(c,h,!1),className:z}:o(c,h,!1))};}),grandTotal:null,metadata:{tableType:"pivot",totalRows:e.rows.length,totalColumns:r.length,rowLevels:e.layout.columns.filter(s=>s.kind!=="measure").length,pivotLevels:e.request.spec.columns.length,hasGrandTotal:!1,columnOrder:r.map(s=>s.columnId),columns:r}};}function J(e,t,r){const{levels:o}=M(e.descriptors,t.presentation,r),a=t.spec.columns.length>0,i=[],s=[],u=e.columns.map((c,h)=>{if(c.kind!=="measure")return null;const g=a?`${c.role}:${y(c.columnPath)}`:`measure:${h}`;let b=i.indexOf(g);return b<0&&(b=i.push(g)-1,s.push(a?N(c.columnPath,c.role,t.presentation.totals.columns,o):c.label)),b;}),d=t.spec.columns[t.spec.columns.length-1];return{columnGroups:u,groupLabels:s,groupLevelLabel:d?S(d,t.presentation):"Measures"};}function _e(e){const{layout:t,rows:r,report:o}=e,a={...e.request,presentation:H(t,r,e.request.presentation)},i=q({layout:t,rows:r,request:a,report:o}),s=B(r),u=J(t,a,o),d={...i,rows:i.rows.map((c,h)=>({...c,keepWithPrevious:s[h]})),metadata:{...i.metadata,...u}};return{request:a,table:d,...u};}const we=1,D=["loading","measuring","checking","laidOut"],Y=["document_matrix_too_large","document_matrix_unavailable","document_matrix_too_wide","document_kpi_value_overflow","print_inputs_not_captured","document_section_setup","document_input_missing","document_section_query_failed","document_table_completeness_unverified","document_row_limit_exceeded","document_section_render_failed","document_page_overflow","document_sheet_not_found","document_print_timed_out","document_page_limit_exceeded"];function be(e){return Y.includes(e);}const Q=64,Z=120,ee=3,te=80,re=[...D,"noPageStack","unknown"];function C(e,t){return typeof e!="string"?void 0:e.trim().slice(0,t).trim()||void 0;}function _(e,t){return typeof e=="number"&&Number.isInteger(e)&&e>=t?e:void 0;}function I(e,t){return t.includes(e)?e:void 0;}function oe(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e);}catch{return{};}if(!t||typeof t!="object"||Array.isArray(t))return{};const r=t,o=Array.isArray(r.inputLabels)?r.inputLabels.map(i=>C(i,te)).filter(i=>i!==void 0).slice(0,ee):[],a={sectionId:C(r.sectionId,Q),sectionTitle:C(r.sectionTitle,Z),pageNumber:_(r.pageNumber,1),rowCount:_(r.rowCount,0),rowLimit:_(r.rowLimit,1),inputLabels:o.length?o:void 0,overflowAxis:I(r.overflowAxis,["height","width"]),overflowPx:_(r.overflowPx,0),matrixLimit:I(r.matrixLimit,["rows","bytes"]),layoutStage:I(r.layoutStage,re),loadingSectionCount:_(r.loadingSectionCount,0),measuredRowCount:_(r.measuredRowCount,0),totalRowCount:_(r.totalRowCount,0),pageCount:_(r.pageCount,0),pageLimit:_(r.pageLimit,1)};return Object.fromEntries(Object.entries(a).filter(([,i])=>i!==void 0));}function ge(e){const t=oe(e.facts),r=t.sectionTitle?`Section "${t.sectionTitle}"`:t.sectionId?`Section ${t.sectionId}`:"A section",o=t.pageNumber!==void 0?` on page ${t.pageNumber}`:"";switch(e.code){case"document_section_setup":return`${r} is not set up to print.`;case"document_input_missing":return t.inputLabels?`${r} needs a value for ${t.inputLabels.join(", ")}.`:`${r} needs a value for a required input.`;case"document_section_query_failed":return`${r}: its data could not be loaded.`;case"document_table_completeness_unverified":return`${r}: the query returned no total row count, so the table could not be confirmed complete.`;case"document_row_limit_exceeded":return t.rowCount!==void 0&&t.rowLimit!==void 0?`${r} has ${t.rowCount} rows; a document table prints up to ${t.rowLimit}.`:`${r} has more rows than a document table prints.`;case"document_section_render_failed":return`${r} could not be drawn.`;case"document_page_overflow":return`${r}${o} does not fit the page${t.overflowAxis?` (${t.overflowAxis}`:""}${t.overflowAxis&&t.overflowPx!==void 0?`, ${t.overflowPx} px over`:""}${t.overflowAxis?")":""}.`;case"document_matrix_too_large":return t.matrixLimit==="rows"&&t.rowLimit!==void 0?`${r}: the Matrix has more than ${t.rowLimit} rows, the most a report prints.`:`${r}: the Matrix is too large to print.`;case"document_matrix_unavailable":return`${r}: the Matrix result could not be loaded.`;case"document_matrix_too_wide":return`${r}: the Matrix is wider than the page.`;case"document_kpi_value_overflow":return`${r}: a KPI value does not fit its tile.`;case"print_inputs_not_captured":return t.inputLabels?`The report's input values were not saved: ${t.inputLabels.join(", ")}.`:"The report's input values were not saved.";case"document_sheet_not_found":return"The requested Document sheet is not in the dashboard.";case"document_page_limit_exceeded":return t.pageCount!==void 0&&t.pageLimit!==void 0?`The Document is ${t.pageCount} pages; a PDF holds up to ${t.pageLimit}.`:"The Document has more pages than a PDF holds.";case"document_print_timed_out":return[`The Document did not finish preparing in time (stage ${t.layoutStage??"unknown"}`,t.measuredRowCount!==void 0?`; ${t.measuredRowCount} of ${t.totalRowCount??"unknown"} rows measured`:"",t.pageCount!==void 0?`; ${t.pageCount} pages`:"",t.loadingSectionCount?`; ${t.loadingSectionCount} sections loading`:"",")."].join("");}}function ne(e){return D.includes(e);}function k(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0;}function ve(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e);}catch{return;}if(!t||typeof t!="object"||Array.isArray(t))return;const{stage:r,measuredRowCount:o,totalRowCount:a,pageCount:i}=t;if(!(!ne(r)||!k(o)||a!==null&&!k(a)||i!==null&&!k(i)))return{stage:r,measuredRowCount:o,totalRowCount:a,pageCount:i};}function xe(e){return((e==null?void 0:e.filterValues)??[]).filter(se).map(ae);}function se(e){return!!e&&typeof e=="object"&&typeof e.name=="string"&&Array.isArray(e.values);}function ae(e){if(!("relativeMeta"in e)||e.relativeMeta===void 0)return e;const{relativeMeta:t,...r}=e,o=G(t);return o?{...r,relativeMeta:o}:r;}export{we as D,de as M,z as P,fe as a,he as b,q as c,_e as d,pe as e,U as f,H as g,B as h,Y as i,be as j,ge as k,ve as l,W as m,xe as n,K as p,oe as r};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import{c as qe,u as Ht,F as pe,an as mt,ao as ft,ap as ht,aq as Xt,ar as gt,as as bt,at as Yt,B,au as Jt,d as ge,ac as Je,af as xt,av as ae,a2 as be,a4 as le,a5 as ie,a6 as oe,a7 as de,a8 as ee,aa as Ve,aw as Pt,ax as Zt,ay as vt,az as Pe,aA as er,aB as tr,aC as ce,P as yt,b as Nt,X as Ct,e as wt,aD as St,aE as rr,aF as ar,aG as nr,aH as sr,aI as lr,ag as ir,ab as or,aJ as kt}from"./appearance-provider-C4lPZcaN.js";import{jsx as e,jsxs as o,Fragment as me}from"react/jsx-runtime";import{m as U,bh as dr,bi as cr,bj as fe,bk as Ze,bl as et,bm as Oe,bn as Ae,bo as ur,bp as pr,bq as tt,br as mr,bs as fr,bt as he,bu as hr,bv as rt,bw as Dt,bx as Tt,by as Lt,bz as Ot,bA as gr,bB as br,bC as at,bD as xr,bE as nt,bF as vr,bG as yr,bH as Nr,bI as Cr,bJ as Ee,e as xe,bK as st,bL as wr,bM as Ie,bN as Sr,bO as kr,bP as Dr,bQ as Tr,bR as Lr}from"./resolve-dashboard-input-context-B-0tONJg.js";import{l as At,r as Or,aE as Et,aF as It}from"./validators-BPGmPz8-.js";import{a as Ft}from"./matrix-operation-contract-Cw7U53Ao.js";import"./analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{u as Ar,ar as lt,as as Er,at as $t,au as Vt,av as Ir,aw as Fr,ax as $r,ay as Vr,az as Rr,aA as _r,aB as it,aC as Re,aD as se,aE as _e,aF as ze,aG as Ge,aH as zr,aI as ve,aJ as ye,aK as Ne,aL as Ce,aM as Rt,aN as _t,aO as Gr}from"./semaphor-ready-indicator-BSFsqsBJ.js";import*as we from"react";import{forwardRef as Mr,useMemo as Z,useState as te,useRef as Fe,useCallback as P,useEffect as Me,Fragment as qr}from"react";import{r as jr,m as Br}from"./raw-temporal-value-Cssny3RJ.js";/**
|
|
2
|
-
* @license lucide-react v0.453.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Na=qe("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
|
|
7
|
-
* @license lucide-react v0.453.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ca=qe("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/**
|
|
12
|
-
* @license lucide-react v0.453.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Ur=qe("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);function wa({type:t,isLinked:a,className:s,showLabel:i=!1,showLocal:A=!1}){const f=Ht(O=>O.selectedFrameId),S=Ar(O=>O.selectedVisual),g=pe(O=>O.frame);let m;if(t)m=t;else if(a!==void 0)m=a?"linked":"library";else if(!!!(g!=null&&g.visualId||S!=null&&S.id)&&f)m="local";else if(S&&!f)m="library";else if(g!=null&&g.visualId&&f)m="linked";else if(S!=null&&S.id&&f)m="library";else return null;if(m==="local"&&!A)return null;const b={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},L={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},N={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},F={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},k={local:/* @__PURE__ */e("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:/* @__PURE__ */e(Yt,{className:"h-3.5 w-3.5"}),library:/* @__PURE__ */e(Ur,{className:"h-3.5 w-3.5"})},y={local:"Local",linked:"Linked",library:"Library"};return/* @__PURE__ */e(mt,{children:/* @__PURE__ */o(ft,{delayDuration:300,children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */o(Xt,{variant:"outline",className:U("cursor-help select-none transition-all",b[m],s),children:[k[m],i&&/* @__PURE__ */e("span",{className:"ml-1 text-xs font-medium leading-none",children:y[m]})]})}),/* @__PURE__ */o(gt,{side:"bottom",className:U("max-w-xs",N[m]),children:[/* @__PURE__ */e(bt,{className:F[m]}),/* @__PURE__ */e("p",{children:L[m]})]})]})});}const Wr=Mr(({side:t="bottom",children:a,className:s,tooltip:i,onClick:A,openDelay:f=300,buttonProps:S,disabled:g,...m},b)=>/* @__PURE__ */e(mt,{children:/* @__PURE__ */o(ft,{delayDuration:f,children:[/* @__PURE__ */e(ht,{asChild:!0,children:/* @__PURE__ */e(B,{disabled:g,ref:b,size:"sm",variant:"ghost",onClick:A,...m,...S,className:U(`${dr}`,s),children:a})}),i&&/* @__PURE__ */o(gt,{side:t,sideOffset:10,className:U("border-foreground/20 bg-foreground text-background"),children:[i,/* @__PURE__ */e(bt,{className:"fill-foreground"})]})]})}));Wr.displayName="IconButton";function zt(t){const{control:a,onChange:s}=t;return/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),/* @__PURE__ */e(be,{size:"xs",value:a.label,placeholder:"Control label",onChange:i=>s(i.target.value)})]});}function Kr(t){const{currentStep:a,labels:s}=t;return/* @__PURE__ */e("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:/* @__PURE__ */e("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:s.map((i,A)=>{const f=A+1,S=f===a,g=f<a;return/* @__PURE__ */o(qr,{children:[/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e("span",{className:U("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",S?"border-foreground bg-foreground text-background":g?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:f}),/* @__PURE__ */e("span",{className:U("text-[12px]",S?"font-medium text-foreground":"text-muted-foreground"),children:i})]}),A<s.length-1?/* @__PURE__ */e("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},i);})})});}function Se(t){const{secondary:a,tertiary:s,primary:i}=t;return/* @__PURE__ */o("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,s,i]});}function Qr(t){const{control:a,scope:s,detail:i}=t;return/* @__PURE__ */o("div",{className:"flex items-start gap-2.5 rounded-control border border-border/60 bg-muted/30 px-3 py-2.5",children:[/* @__PURE__ */e(Pt,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),/* @__PURE__ */o("div",{className:"min-w-0 space-y-0.5",children:[/* @__PURE__ */e("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),/* @__PURE__ */o("div",{className:"text-[12px] text-muted-foreground",children:[Dt(a.type).label," ·"," ",Lt(a)," ·"," ",Tt(s,a.placement)]}),i?/* @__PURE__ */e("div",{className:"text-[12px] text-muted-foreground",children:i}):null]})]});}function ot(t){const{control:a,defaultValue:s,availableFieldChoices:i,availableMetricChoices:A,previewControlDefinitions:f,previewControlValues:S,onControlChange:g,onLabelChange:m,onDefaultValueChange:b,onBack:L,onNext:N,nextDisabled:F}=t;return/* @__PURE__ */o("div",{className:"space-y-3",children:[/* @__PURE__ */e(zt,{control:a,onChange:m}),/* @__PURE__ */e($t,{control:a,availableFieldChoices:i,availableMetricChoices:A,previewControlDefinitions:f,previewControlValues:S,controlLifecycle:"create",onChange:g}),/* @__PURE__ */e(Vt,{control:a,value:s,onChange:b,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:f,previewControlValues:S}),/* @__PURE__ */e(Se,{secondary:/* @__PURE__ */e(B,{type:"button",variant:"outline",size:"xs",onClick:L,children:"Back"}),primary:/* @__PURE__ */e(B,{type:"button",size:"xs",onClick:N,disabled:F,children:"Next"})})]});}const Hr=/* @__PURE__ */new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function dt(t){const{text:a,ariaLabel:s}=t,[i,A]=te(!1);return/* @__PURE__ */o("button",{type:"button","aria-label":s,onClick:async()=>{try{await navigator.clipboard.writeText(a),A(!0),setTimeout(()=>A(!1),1200);}catch(f){console.error("Failed to copy",f);}},className:"group flex w-full items-center justify-between gap-2 rounded-control bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[/* @__PURE__ */e("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),/* @__PURE__ */e("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:i?"Copied":"Click to copy"})]});}function ct(t){const{control:a,scope:s,createdReference:i,explorerContent:A,sqlDescription:f,summaryDetail:S,onBack:g,onCancel:m,onDone:b}=t,L=Hr.has(a.type),N=i.match(/\[\[param\.(.+?)\]\]/),F=N?`{{ param('${N[1]}') }}`:"";return/* @__PURE__ */o("div",{className:"space-y-4",children:[/* @__PURE__ */e(Qr,{control:a,scope:s,detail:S}),/* @__PURE__ */o("div",{className:"space-y-2",children:[/* @__PURE__ */e("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),/* @__PURE__ */o("div",{className:"divide-y divide-border/60 overflow-hidden rounded-control border border-border/60",children:[L?/* @__PURE__ */o("div",{className:"space-y-1 px-3 py-2.5",children:[/* @__PURE__ */e("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),/* @__PURE__ */e("div",{className:"text-[12px] text-muted-foreground",children:A})]}):null,/* @__PURE__ */o("div",{className:"space-y-1.5 px-3 py-2.5",children:[/* @__PURE__ */e("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),/* @__PURE__ */e(dt,{text:i,ariaLabel:"Copy SQL control reference"}),F?/* @__PURE__ */e(dt,{text:F,ariaLabel:"Copy Jinja control reference"}):null,/* @__PURE__ */o("p",{className:"text-[12px] text-muted-foreground",children:[f," ",/* @__PURE__ */e("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),/* @__PURE__ */e(Se,{secondary:/* @__PURE__ */e(B,{type:"button",variant:"outline",size:"xs",onClick:g,children:"Back"}),tertiary:/* @__PURE__ */e(B,{type:"button",variant:"outline",size:"xs",onClick:m,children:"Cancel"}),primary:/* @__PURE__ */e(B,{type:"button",size:"xs",onClick:b,children:"Done"})})]});}function Xr(t){const a=fe(t.scope,t.existingControls,t.reservedIds),s=t.type===a.type?{...a,label:Ee[t.type]}:{...Ot({controls:[{...a,label:Ee[t.type]}],controlId:a.id,nextType:t.type}).controls[0],label:Ee[t.type]};return{step:2,control:s,defaultValue:he(s,void 0)};}function Sa({scope:t,controls:a,reservedControlIds:s,defaultValues:i,onChange:A,emptyMessage:f,initialCreateFlow:S=!1,usageByControlId:g,availableFieldChoices:m,availableMetricChoices:b,structuralParticipants:L,structuralParticipantIdsByControlId:N,card:F,allowedControlTypes:k,onCreateFlowActiveChange:y,onCreateFlowComplete:O}){const z=Z(()=>new Set(s||[]),[s]),$=gr(t),Y=cr(t),[D,T]=te(null),[Q,X]=te(null),[n,x]=te(()=>S?{step:1,control:fe(t,a,Array.from(z))}:null),C=Fe({}),h=Fe(void 0),c=Fe(S),l=Z(()=>{const r=Ze({scope:t,card:F});if(!k)return r;const u=new Set(k);return r.filter(d=>u.has(d.value));},[k,F,t]),V=P(r=>{const u=Ze({scope:t,card:F,includeType:k?void 0:r});if(!k)return u;const d=new Set(k);return u.filter(v=>d.has(v.value));},[k,F,t]),p=P(r=>t==="dashboard"&&(r==="field_selector"||r==="metric_selector"),[t]),K=Z(()=>n?et(L||[],n.control.type):[],[n,L]),E=Z(()=>{if(!n)return{fields:m||[],metrics:b||[]};if(!p(n.control.type))return{fields:m||[],metrics:b||[]};const r=n.selectedCardIds||[],u=Oe({controlType:n.control.type,participants:L||[],selectedCardIds:r});return{fields:n.control.type==="field_selector"?u.choices.map(d=>({option:d,target:u.fieldTargetMap[d.value]})):[],metrics:n.control.type==="metric_selector"?u.choices.map(d=>({option:d,target:u.metricTargetMap[d.value]})):[]};},[m,b,n,p,L]);Me(()=>{y==null||y(!!n);},[n,y]),Me(()=>{const r=S&&!c.current;c.current=S,r&&(x({step:1,control:fe(t,a,Array.from(z))}),X(null),T(null));},[a,S,z,t]);const _=r=>{if(!p(r.type))return{fields:m||[],metrics:b||[]};const u=(N==null?void 0:N[r.id])||[];if(u.length===0)return{fields:m||[],metrics:b||[]};const d=Oe({controlType:r.type,participants:L||[],selectedCardIds:u});return{fields:r.type==="field_selector"?d.choices.map(v=>({option:v,target:d.fieldTargetMap[v.value]})):[],metrics:r.type==="metric_selector"?d.choices.map(v=>({option:v,target:d.metricTargetMap[v.value]})):[]};},q=r=>{if(!p(r.control.type))return{nextControl:r.control,cardBindingsById:void 0};const u=(N==null?void 0:N[r.control.id])||[],d=Oe({controlType:r.control.type,participants:L||[],selectedCardIds:r.nextSelectedCardIds}),v=Nr({control:r.control,choices:d.choices}),I=Object.fromEntries(u.filter(R=>!r.nextSelectedCardIds.includes(R)).map(R=>[R,void 0]));return r.nextSelectedCardIds.length>0&&v.source.kind==="manual"&&v.source.options.length>0&&Object.assign(I,nt({control:v,participants:L||[],selectedCardIds:r.nextSelectedCardIds,matrixTargetIds:r.matrixTargetIds})),{nextControl:v,cardBindingsById:I};},j=P((r,u=i,d={type:"update"})=>{const v=r.map(I=>(Ae({control:I,defaultValues:u}),ur(I)));A(v,u,d);},[i,A]),H=(r,u)=>{const d=a.find(M=>M.id===r);let v=a.map(M=>M.id!==r?M:u(M));const I=v.find(M=>M.id===r);let R,w;if(I&&(!d||vr({control:d},{control:I}))&&t==="dashboard"&&(I.type==="field_selector"||I.type==="metric_selector")){const M=(N==null?void 0:N[I.id])||[],ne=q({control:I,nextSelectedCardIds:M});v=v.map(re=>re.id===r?ne.nextControl:re),R=ne.cardBindingsById,w=[I.id];}else if(d&&(!I||!yr(I.type))&&t==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")){const M=(N==null?void 0:N[d.id])||[];R=Object.fromEntries(M.map(ne=>[ne,void 0])),w=[d.id];}const G=v.find(M=>M.id===r);let W=i;if(d&&G){const M=Ae({control:d,defaultValues:i});d.source.kind==="manual"&&G.source.kind==="sql_query"&&(C.current[r]=M);const ne=M===void 0&&d.source.kind==="sql_query"&&G.source.kind==="manual"?C.current[r]:M,re=at({previousControl:d,nextControl:G,currentDefaultValue:ne});G.source.kind==="manual"&&(C.current[r]=re),i&&(W={...i},re===void 0?delete W[r]:W[r]=re),v=v.map(Ye=>Ye.id===r?{...G,defaultValue:re}:Ye);}j(v,W,{type:"update",cardBindingsById:R,affectedBindingControlIds:w});},J=(r,u)=>{if(!u.trim())return;const d=Cr(u);if(d===r||z.has(d)||a.some(R=>R.id===d&&R.id!==r))return;const v=a.map(R=>R.id===r?{...R,id:d}:R);if(!i){j(v,void 0,{type:"rename",oldId:r,newId:d});return;}const I={...i};Object.prototype.hasOwnProperty.call(I,r)&&(I[d]=I[r],delete I[r]),j(v,I,{type:"rename",oldId:r,newId:d});},Wt=r=>{const u=a.filter(v=>v.id!==r);if(!i){j(u,void 0,{type:"remove",controlId:r});return;}const d={...i};delete d[r],j(u,d,{type:"remove",controlId:r});},Kt=P(()=>{h.current=void 0,x({step:1,control:fe(t,a,Array.from(z))}),X(null),T(null);},[a,z,t]),ue=r=>{x(u=>u&&(()=>{const d=r(u.control);u.control.source.kind==="manual"&&d.source.kind==="sql_query"&&(h.current=u.defaultValue);const v=u.defaultValue===void 0&&u.control.source.kind==="sql_query"&&d.source.kind==="manual"?h.current:u.defaultValue,I=at({previousControl:u.control,nextControl:d,currentDefaultValue:v});return d.source.kind==="manual"&&(h.current=I),{...u,control:d,defaultValue:I};})());},We=r=>{x(u=>u&&(u.control.source.kind==="manual"&&(h.current=r),{...u,defaultValue:r}));},ke=(()=>{if(!n)return!1;if(n.step===2&&p(n.control.type))return(n.selectedCardIds||[]).length>0&&pr({participants:L||[],selectedCardIds:n.selectedCardIds||[],control:n.control,selected:n.matrixTargetIds});if(n.step!==2&&n.step!==3||!n.control.label.trim())return!1;const u=n.control.source.kind==="sql_query"?n.control:tt(n.control);if(u.source.kind==="manual"&&(mr(u)&&u.source.options.length===0||u.source.options.some(v=>v.label.trim().length===0||v.value.trim().length===0)))return!1;if(u.source.kind==="sql_query"){const{connectionId:d,sql:v,valueColumn:I}=u.source;return d.trim().length>0&&v.trim().length>0&&I.trim().length>0;}return fr(he(u,n.defaultValue));})(),Ke=()=>{var R;if(!n)return;const r=tt(n.control),u=xr({label:r.label,fallbackId:r.id,existingControls:a,reservedIds:Array.from(z)}),d={...r,id:u},v=t==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")&&(R=n.selectedCardIds)!=null&&R.length?nt({control:d,participants:L||[],selectedCardIds:n.selectedCardIds,matrixTargetIds:n.matrixTargetIds}):void 0,I=he(d,n.defaultValue);x({step:t==="dashboard"&&(d.type==="field_selector"||d.type==="metric_selector")?4:3,control:d,defaultValue:I,createdControlId:u,selectedCardIds:n.selectedCardIds,matrixTargetIds:n.matrixTargetIds,cardBindingsById:v});},De=P(()=>{x(null);},[]),Qe=P(()=>{if(!(n!=null&&n.createdControlId)){x(null);return;}const r=n.control,u=n.createdControlId,d=he(r,n.defaultValue);if(i){const v={...i};d===void 0?delete v[u]:v[u]=d,j([...a,{...r,defaultValue:d}],v,{type:"add",cardBindingsById:n.cardBindingsById});}else j([...a,{...r,defaultValue:d}],void 0,{type:"add",cardBindingsById:n.cardBindingsById});X(u),x(null),O==null||O();},[a,n,i,j,O]),Qt=n?p(n.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],He=n!=null&&n.createdControlId?`[[param.${n.createdControlId}]]`:n?`[[param.${hr(n.control.label)||n.control.id}]]`:"",Te=rt({controls:a,defaultValues:i}),Le=n?[...a,n.control]:a,Xe=n?rt({controls:Le,defaultValues:i,overrides:[{controlId:n.control.id,value:n.defaultValue}]}):Te;return/* @__PURE__ */o("div",{className:"space-y-4",children:[n?/* @__PURE__ */o("div",{className:"space-y-4 pb-1",children:[/* @__PURE__ */e(Kr,{currentStep:n.step,labels:Qt}),n.step===1&&(()=>{const r=/* @__PURE__ */new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),u=/* @__PURE__ */new Set(["date","text"]),d=l.filter(R=>!r.has(R.value)&&!u.has(R.value)),v=l.filter(R=>r.has(R.value)),I=R=>/* @__PURE__ */o("button",{type:"button",className:"rounded-control border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>x(Xr({scope:t,existingControls:a,reservedIds:Array.from(z),type:R.value})),children:[/* @__PURE__ */e("div",{className:"text-[13px] font-medium text-foreground",children:R.label}),/* @__PURE__ */e("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:R.description})]},R.value);return/* @__PURE__ */o("div",{className:"space-y-4",children:[t==="card"&&(F==null?void 0:F.sql)==null?/* @__PURE__ */e("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,d.length>0&&/* @__PURE__ */o("div",{className:"space-y-1.5",children:[/* @__PURE__ */e("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),/* @__PURE__ */e("div",{className:"grid gap-1.5 sm:grid-cols-2",children:d.map(I)})]}),v.length>0&&/* @__PURE__ */o("div",{className:"space-y-1.5",children:[/* @__PURE__ */e("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),/* @__PURE__ */e("div",{className:"grid gap-1.5 sm:grid-cols-2",children:v.map(I)})]}),/* @__PURE__ */e(Se,{secondary:/* @__PURE__ */e(B,{type:"button",variant:"outline",size:"xs",onClick:De,children:"Back to controls"})})]});})(),n.step===2&&p(n.control.type)&&/* @__PURE__ */o("div",{className:"space-y-3",children:[/* @__PURE__ */o("div",{className:"space-y-3",children:[/* @__PURE__ */e(zt,{control:n.control,onChange:r=>ue(u=>({...u,label:r}))}),/* @__PURE__ */e("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),K.length===0?/* @__PURE__ */e("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):/* @__PURE__ */e("div",{className:"space-y-1 rounded-control border border-border/60 bg-background p-2",children:K.map(r=>{const u=(n.selectedCardIds||[]).includes(r.cardId);return/* @__PURE__ */o("label",{className:"flex items-start gap-2 rounded-control px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[/* @__PURE__ */e(Jt,{checked:u,onCheckedChange:d=>x(v=>v&&{...v,selectedCardIds:d===!0?[...(v.selectedCardIds||[]),r.cardId]:(v.selectedCardIds||[]).filter(I=>I!==r.cardId)})}),/* @__PURE__ */o("div",{className:"min-w-0",children:[/* @__PURE__ */e("div",{className:"font-medium text-foreground",children:r.title}),/* @__PURE__ */e("div",{className:"text-[12px] text-muted-foreground",children:n.control.type==="field_selector"?`${r.fieldChoices.length} compatible group-by fields`:`${r.metricChoices.length} compatible metrics`})]})]},r.cardId);})}),/* @__PURE__ */e(lt,{participants:K,selectedCardIds:n.selectedCardIds||[],control:n.control,selected:n.matrixTargetIds,onChange:(r,u)=>x(d=>d&&{...d,matrixTargetIds:{...d.matrixTargetIds,[r]:u}})}),/* @__PURE__ */e(Se,{secondary:/* @__PURE__ */e(B,{type:"button",variant:"outline",size:"xs",onClick:()=>x(r=>r&&{...r,step:1,selectedCardIds:[]}),children:"Back"}),primary:/* @__PURE__ */e(B,{type:"button",size:"xs",onClick:()=>x(r=>r&&{...r,step:3}),disabled:!ke,children:"Next"})})]}),n.step===2&&!p(n.control.type)&&/* @__PURE__ */e(ot,{control:n.control,defaultValue:n.defaultValue,availableFieldChoices:E.fields,availableMetricChoices:E.metrics,previewControlDefinitions:Le,previewControlValues:Xe,onControlChange:r=>ue(()=>r),onLabelChange:r=>ue(u=>({...u,label:r})),onDefaultValueChange:We,onBack:()=>x(r=>r&&{...r,step:1}),onNext:Ke,nextDisabled:!ke}),n.step===3&&p(n.control.type)&&/* @__PURE__ */e(ot,{control:n.control,defaultValue:n.defaultValue,availableFieldChoices:E.fields,availableMetricChoices:E.metrics,previewControlDefinitions:Le,previewControlValues:Xe,onControlChange:r=>ue(()=>r),onLabelChange:r=>ue(u=>({...u,label:r})),onDefaultValueChange:We,onBack:()=>x(r=>r&&{...r,step:2}),onNext:Ke,nextDisabled:!ke}),n.step===3&&!p(n.control.type)&&/* @__PURE__ */e(ct,{control:n.control,scope:t,createdReference:He,explorerContent:/* @__PURE__ */o(me,{children:["Open the card and use"," ",/* @__PURE__ */e("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>x(r=>r&&{...r,step:2}),onCancel:De,onDone:Qe}),n.step===4&&p(n.control.type)&&/* @__PURE__ */e(ct,{control:n.control,scope:t,createdReference:He,summaryDetail:/* @__PURE__ */o(me,{children:["Used by ",(n.selectedCardIds||[]).length," selected card",(n.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:/* @__PURE__ */e(me,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>x(r=>r&&{...r,step:3}),onCancel:De,onDone:Qe})]}):null,!n&&a.length===0?/* @__PURE__ */e("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:f}):null,!n&&a.map(r=>{const u=_(r),d=g==null?void 0:g[r.id],v=Ae({control:r,defaultValues:i}),I=Q===r.id,R="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return/* @__PURE__ */o("div",{className:"rounded-control border border-border/60",children:[/* @__PURE__ */o("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[/* @__PURE__ */o("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-control text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>X(w=>w===r.id?null:r.id),children:[I?/* @__PURE__ */e(ge,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):/* @__PURE__ */e(Je,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),/* @__PURE__ */o("div",{className:"min-w-0",children:[/* @__PURE__ */o("div",{className:"flex flex-wrap items-center gap-1.5",children:[/* @__PURE__ */e("span",{className:"truncate text-[13px] font-medium text-foreground",children:r.label||"Untitled control"}),/* @__PURE__ */e("span",{className:R,children:Dt(r.type).label}),/* @__PURE__ */e("span",{className:R,children:Tt(t,r.placement)})]}),/* @__PURE__ */o("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[Lt(r),d!=null&&d.status?` · ${d.status}`:""]})]})]}),/* @__PURE__ */e(B,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>Wt(r.id),"aria-label":`Remove ${r.label}`,children:/* @__PURE__ */e(xt,{className:"h-3.5 w-3.5"})})]}),I&&/* @__PURE__ */o("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[/* @__PURE__ */o("div",{className:"grid gap-3 md:grid-cols-3",children:[/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),/* @__PURE__ */e(be,{size:"xs",value:r.label,placeholder:"Control label",onChange:w=>H(r.id,G=>({...G,label:w.target.value}))})]}),/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),/* @__PURE__ */o(le,{value:r.type,onValueChange:w=>{const G=Ot({controls:a,controlId:r.id,nextType:w,defaultValues:i});j(G.controls,G.defaultValues);},children:[/* @__PURE__ */e(ie,{size:"xs",children:/* @__PURE__ */e(oe,{})}),/* @__PURE__ */e(de,{children:V(r.type).map(w=>/* @__PURE__ */e(ee,{value:w.value,children:w.label},w.value))})]})]}),/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),/* @__PURE__ */o(le,{value:r.placement||Y,onValueChange:w=>H(r.id,G=>({...G,placement:w})),children:[/* @__PURE__ */e(ie,{size:"xs",children:/* @__PURE__ */e(oe,{})}),/* @__PURE__ */e(de,{children:$.map(w=>/* @__PURE__ */e(ee,{value:w.value,children:w.label},w.value))})]})]})]}),p(r.type)?/* @__PURE__ */o(me,{children:[/* @__PURE__ */e(Er,{type:r.type,participants:et(L||[],r.type).map(w=>({cardId:w.cardId,title:w.title,choiceCount:r.type==="field_selector"?w.fieldChoices.length:w.metricChoices.length})),selectedCardIds:(N==null?void 0:N[r.id])||[],onChange:w=>{const G=q({control:r,nextSelectedCardIds:w}),W=a.map(M=>M.id===r.id?G.nextControl:M);j(W,i,{type:"update",cardBindingsById:G.cardBindingsById});}}),/* @__PURE__ */e(lt,{participants:L||[],selectedCardIds:(N==null?void 0:N[r.id])||[],control:r,onChange:(w,G)=>{const W=q({control:r,nextSelectedCardIds:(N==null?void 0:N[r.id])||[],matrixTargetIds:{[w]:G}});j(a.map(M=>M.id===r.id?W.nextControl:M),i,{type:"update",cardBindingsById:W.cardBindingsById});}})]}):null,/* @__PURE__ */e($t,{control:r,availableFieldChoices:u.fields,availableMetricChoices:u.metrics,previewControlDefinitions:a,previewControlValues:Te,controlLifecycle:"edit",onChange:w=>H(r.id,()=>w)}),r.initialValueStrategy==="saved_default"&&/* @__PURE__ */e(Vt,{control:r,value:v,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:Te,onChange:w=>{const G=a.map(W=>W.id===r.id?{...W,defaultValue:w}:W);if(r.source.kind==="manual"&&(C.current[r.id]=w),i){const W={...i};w===void 0?delete W[r.id]:W[r.id]=w,j(G,W);return;}j(G,void 0);}}),/* @__PURE__ */o(Ir,{open:D===r.id,onOpenChange:w=>T(w?r.id:null),children:[/* @__PURE__ */e(Fr,{asChild:!0,children:/* @__PURE__ */o(B,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[D===r.id?/* @__PURE__ */e(ge,{className:"h-3.5 w-3.5"}):/* @__PURE__ */e(Je,{className:"h-3.5 w-3.5"}),"Advanced"]})}),/* @__PURE__ */o($r,{className:"space-y-3 pt-2",children:[/* @__PURE__ */o("div",{className:"grid gap-3 md:grid-cols-2",children:[/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),/* @__PURE__ */e(Vr,{controlId:r.id,onCommit:w=>J(r.id,w)},r.id)]}),/* @__PURE__ */o("div",{className:"flex flex-col gap-1.5",children:[/* @__PURE__ */e(ae,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),/* @__PURE__ */o(le,{value:r.initialValueStrategy,onValueChange:w=>H(r.id,G=>({...G,initialValueStrategy:w})),children:[/* @__PURE__ */e(ie,{size:"xs",children:/* @__PURE__ */e(oe,{})}),/* @__PURE__ */e(de,{children:br.map(w=>/* @__PURE__ */e(ee,{value:w.value,children:w.label},w.value))})]})]})]}),/* @__PURE__ */e(Rr,{control:r,onChange:w=>H(r.id,()=>w)})]})]})]})]},r.id);}),!n&&/* @__PURE__ */o(B,{type:"button",variant:"outline",size:"xs",onClick:Kt,children:[/* @__PURE__ */e(Ve,{className:"h-3.5 w-3.5"}),"Add control"]})]});}function ka(t){const{open:a,onOpenChange:s,initialCreateFlowActive:i=!1,dismissMode:A="passive"}=t,f=a!==void 0,[S,g]=te(!1),[m,b]=te(i),L=f?a:S,N=P(y=>{!y&&m&&A==="passive"||(f||g(y),y||b(!1),s==null||s(y));},[f,m,A,s]),F=P(()=>{f||g(!1),b(!1),s==null||s(!1);},[f,s]);Me(()=>{L||b(!1);},[L]);const k=P(y=>{m&&y.preventDefault();},[m]);return{forceClose:F,handleOpenChange:N,isCreateFlowActive:m,preventPassiveDismissDuringCreate:k,resolvedOpen:L,setIsCreateFlowActive:b};}function Gt(t){const{relativeMeta:a,latestValue:s,...i}=t;return i;}function je(t,a){const s=Gt(t);return a.relativeMeta?{...s,value:a.value,relativeMeta:a.relativeMeta}:{...s,value:a.value};}function Yr(t,a){const s=a==="in"||a==="not in"||a==="between"||a==="not between"?[]:a==="isNull"||a==="isNotNull"?null:"";return je({...t,operator:a},{value:s});}function Jr(t,a){const s=xe(a.dataType)==="date";return je({...t,field:a,operator:s?"between":"="},{value:""});}function Pr({initialFilters:t,availableFields:a,onChange:s}={}){const[i,A]=te(t||{id:`group-${Date.now()}`,logicalOperator:"AND",negate:!1,conditions:[],groups:[]}),f=x=>{A(x),s==null||s(x);};pe(x=>x.card.dataSource);const{filterableFields:S,isLoading:g}=_r(),m=a||S||[],b={id:"default",qualifiedFieldName:"default",name:"default",dataType:"string",label:"Default",entityId:"default",entityName:"Default",entityType:"table"},L=x=>{const C=h=>{if(h.id===x){const c=m[0]||b,l=xe(c.dataType)==="date";return{...h,conditions:[...h.conditions,{id:`condition-${Date.now()}`,field:c,operator:l?"between":"=",value:l?[]:""}]};}return{...h,groups:h.groups.map(C)};};f(C(i));},N=x=>{const C=h=>{if(h.id===x){const c=m[0]||b,l=xe(c.dataType)==="date";return{...h,groups:[...h.groups,{id:`group-${Date.now()}`,logicalOperator:"AND",negate:!1,conditions:[{id:`condition-${Date.now()}`,field:c,operator:l?"between":"=",value:l?[]:""}],groups:[]}]};}return{...h,groups:h.groups.map(C)};};f(C(i));},F=(x,C)=>{const h=c=>c.id===x?{...c,conditions:c.conditions.filter(l=>l.id!==C)}:{...c,groups:c.groups.map(h)};f(h(i));},k=(x,C)=>{const h=c=>c.id===x?{...c,groups:c.groups.filter(l=>l.id!==C)}:{...c,groups:c.groups.map(h)};f(h(i));},y=(x,C,h)=>{const c=l=>l.id===x?{...l,conditions:l.conditions.map(V=>V.id===C?h(V):V)}:{...l,groups:l.groups.map(c)};f(c(i));},O=(x,C,h)=>y(x,C,c=>({...("value"in h||"operator"in h||"field"in h?Gt(c):c),...h})),z=(x,C,h)=>y(x,C,()=>h),$=Zt(),Y=(x,C)=>{const h=c=>c.id===x?{...c,logicalOperator:C}:{...c,groups:c.groups.map(h)};f(h(i));},D=(x,C)=>{const h=c=>c.id===x?{...c,negate:C}:{...c,groups:c.groups.map(h)};f(h(i));},T=(x,C,h)=>{const c=l=>l.id===x?{...l,conditions:it(l.conditions,C,h)}:{...l,groups:l.groups.map(c)};f(c(i));},Q=(x,C,h)=>{const c=l=>l.id===x?{...l,groups:it(l.groups,C,h)}:{...l,groups:l.groups.map(c)};f(c(i));},X=x=>{if(!x||x.conditions.length===0&&x.groups.length===0)return"-- No filters defined";const C=c=>{let l="";typeof c.field=="object"?l=c.field.entityName?`${c.field.entityName}.${c.field.name}`:c.field.name:l=String(c.field);const V=c.operator;let p=c.value;if(c.latestValue&&V==="=")return`${l} = ${vt} /* the latest value each time the card runs */`;const K=At(c.relativeMeta);if(K&&Or(V)&&Et(V,K)){const E=jr(V,K),{label:_,range:q}=Pe(K,{tz:($==null?void 0:$.tz)??"UTC",weekStart:($==null?void 0:$.weekStart)??1,anchor:($==null?void 0:$.anchor)??"now"}),j=E?Br(E):_;if(q){const[H]=It(V,[q.start,q.end]);return`${l} ${V} '${H.toISOString()}' /* ${j}: the date updates each time the card runs */`;}return`${l} ${V} ${j} /* the date follows your calendar each time the card runs */`;}if(K&&(V==="between"||V==="not between")){const E=V==="between"?"BETWEEN":"NOT BETWEEN",{label:_,range:q}=Pe(K,{tz:($==null?void 0:$.tz)??"UTC",weekStart:($==null?void 0:$.weekStart)??1,anchor:($==null?void 0:$.anchor)??"now"});return q?`${l} ${E} '${q.start.toISOString()}' AND '${q.end.toISOString()}' /* ${_}: dates update each time the card runs */`:Ft(K).dataAnchored?`${l} ${E} ${_} /* dates count back from the latest data each time the card runs */`:`${l} ${E} ${_} /* dates follow your calendar each time the card runs */`;}if(c.field.dataType==="string"&&!["in","not in"].includes(c.operator))typeof p=="string"?p=`'${p}'`:Array.isArray(p)&&(p=`'${p.join(", ")}'`);else if(c.field.dataType==="date"||c.field.dataType==="datetime"||c.field.dataType==="timestamp"){if(c.operator==="between"&&Array.isArray(p)&&p.length===2){const E=p[0]?`'${p[0]}'`:"NULL",_=p[1]?`'${p[1]}'`:"NULL";return`${l} BETWEEN ${E} AND ${_}`;}else if((c.operator==="in"||c.operator==="not in")&&Array.isArray(p)){const E=p.map(_=>_?`'${_}'`:"NULL").join(", ");return`${l} ${V} (${E})`;}else typeof p=="string"||p instanceof Date?p=`'${p}'`:Array.isArray(p)&&p.length>0&&(p=`'${p[0]}'`);}else if(["in","not in"].includes(c.operator)){let E=[];Array.isArray(p)?E=p.map(_=>typeof _=="string"?`'${_}'`:String(_)):typeof p=="string"?E=p.split(",").map(_=>{const q=_.trim();return c.field.dataType==="string"?`'${q}'`:q;}):typeof p=="number"&&(E=[String(p)]),p=`(${E.join(", ")})`;}switch(V){case"contains":return typeof p=="string"?`${l} LIKE '%${p.replace(/'/g,"")}'`:`${l} LIKE '%${String(p)}'`;case"startsWith":return typeof p=="string"?`${l} LIKE '${p.replace(/'/g,"")}%'`:`${l} LIKE '${String(p)}%'`;case"endsWith":return typeof p=="string"?`${l} LIKE '%${p.replace(/'/g,"")}'`:`${l} LIKE '%${String(p)}'`;case"isNull":return`${l} IS NULL`;case"isNotNull":return`${l} IS NOT NULL`;default:return`${l} ${V} ${p}`;}},h=c=>{const l=c.conditions.map(C),V=c.groups.map(_=>h(_)),p=[...l,...V].filter(Boolean);if(p.length===0)return"";const K=p.join(` ${c.logicalOperator} `),E=p.length>1?`(${K})`:K;return c.negate?`NOT ${E}`:E;};return h(x);},n=i.conditions.length>0||i.groups.length>0;return{currentFilters:i,setCurrentFilters:f,availableFields:m,isLoading:g,addCondition:L,addGroup:N,removeCondition:F,removeGroup:k,updateConditionFields:O,replaceCondition:z,updateGroupOperator:Y,updateGroupNegate:D,reorderConditions:T,reorderGroups:Q,generateSQLPreview:X,hasAnyFilters:n};}function Mt(t,a){const s=pe(b=>b.card.dataSource),i=pe(b=>b.card.connectionId),A=pe(b=>b.selectedConnectionId),{dataSource:f,connectionId:S}=a?st(a):st({dataSource:s,connectionId:i},A),g=Z(()=>({id:`card-filter-option:${t.id}`,...wr(t,{dataSource:f,connectionId:S})}),[S,f,t]),m=Z(()=>er({filter:g}),[g]);return tr(g,{inputContext:m,currentSelectionPolicy:"exclude"});}function Zr({field:t,source:a,selected:s,onChange:i,placeholder:A="Select values…",className:f}){const[S,g]=we.useState(!1),m=Mt(t,a),b=we.useMemo(()=>new Set(s.map(k=>ce(k))),[s]),L=k=>{var y,O;return((O=(y=m.allRecords.find(z=>ce(z.value)===ce(k)))==null?void 0:y.label)==null?void 0:O.toString())??k;},N=k=>{i(s.filter(y=>y!==k));},F=k=>{g(k),!k&&m.query&&m.setQuery("");};return/* @__PURE__ */e("div",{className:U("w-full",f),children:/* @__PURE__ */o(yt,{open:S,onOpenChange:F,modal:!0,children:[/* @__PURE__ */e(Nt,{asChild:!0,children:/* @__PURE__ */o(B,{variant:"outline",size:"xs",role:"combobox","aria-expanded":S,className:"h-auto min-h-7 w-full justify-between gap-1.5 px-2 py-0.5 font-normal",children:[/* @__PURE__ */e("div",{className:"flex min-w-0 flex-1 flex-wrap gap-1",children:s.length>0?s.map(k=>{const y=L(k);return(/* @__PURE__ */o("span",{className:"inline-flex max-w-full items-center gap-1 rounded-[4px] border border-border/70 bg-muted/40 px-1.5 py-0.5 text-[11px] leading-[14px] text-foreground",children:[/* @__PURE__ */e("span",{className:"truncate",children:y}),/* @__PURE__ */e("span",{role:"button",tabIndex:0,"aria-label":`Remove ${y}`,className:"shrink-0 rounded-[2px] text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring",onKeyDown:O=>{O.key==="Enter"&&N(k);},onMouseDown:O=>{O.preventDefault(),O.stopPropagation();},onClick:O=>{O.stopPropagation(),N(k);},children:/* @__PURE__ */e(Ct,{className:"h-3 w-3"})})]},k));}):/* @__PURE__ */e("span",{className:"truncate text-muted-foreground",children:A})}),/* @__PURE__ */e(ge,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),/* @__PURE__ */e(wt,{className:"w-[var(--radix-popover-trigger-width)] min-w-[240px] rounded-control p-1.5",align:"start",onOpenAutoFocus:k=>{var y,O;k.preventDefault(),(O=(y=k.currentTarget)==null?void 0:y.querySelector('input[type="text"]'))==null||O.focus();},children:/* @__PURE__ */e(St,{records:m.displayRecords,selectedIdentities:b,onToggle:k=>{const y=String(k.value);s.includes(y)?N(y):i([...s,y]);},browse:m,searchPlaceholder:`Search ${(t.label||t.name).toLowerCase()}`,listLabel:t.label||t.name,density:"compact"})})]})});}function ea({field:t,source:a,value:s,onChange:i,placeholder:A="Select value…",className:f}){var F,k;const[S,g]=we.useState(!1),m=Mt(t,a),b=we.useMemo(()=>new Set(s?[ce(s)]:[]),[s]),L=s?((k=(F=m.allRecords.find(y=>ce(y.value)===ce(s)))==null?void 0:F.label)==null?void 0:k.toString())??s:"",N=y=>{g(y),!y&&m.query&&m.setQuery("");};return/* @__PURE__ */o(yt,{open:S,onOpenChange:N,modal:!0,children:[/* @__PURE__ */e(Nt,{asChild:!0,children:/* @__PURE__ */o(B,{variant:"outline",size:"xs",role:"combobox","aria-expanded":S,className:U("min-w-0 flex-1 justify-between gap-1.5 px-2 font-normal",f),children:[/* @__PURE__ */e("span",{className:U("truncate",!s&&"text-muted-foreground"),children:s?L:A}),/* @__PURE__ */e(ge,{className:"h-3.5 w-3.5 shrink-0 opacity-50"})]})}),/* @__PURE__ */e(wt,{className:"w-[var(--radix-popover-trigger-width)] min-w-[240px] rounded-control p-1.5",align:"start",onOpenAutoFocus:y=>{var O,z;y.preventDefault(),(z=(O=y.currentTarget)==null?void 0:O.querySelector('input[type="text"]'))==null||z.focus();},children:/* @__PURE__ */e(St,{records:m.displayRecords,selectedIdentities:b,onToggle:y=>{i(String(y.value)),N(!1);},selectionMode:"single",browse:m,searchPlaceholder:`Search ${(t.label||t.name).toLowerCase()}`,listLabel:t.label||t.name,density:"compact"})})]});}function ta({value:t,operator:a,relativeMeta:s,latestValue:i,field:A,onChange:f,className:S}){const g=rr(),m=ar(),b=a==="between"||a==="not between",L=Et(a),N=L?s:void 0,F=Z(()=>{if(!b||!s)return;const D=m(s);return{...D,tooltip:D.dates?void 0:Ft(s).dataAnchored?nr:sr};},[b,s,m]),k=Z(()=>{if(b){if(F){const{range:D}=F;return D?{from:D.start,to:D.end}:void 0;}if(t&&Array.isArray(t)&&t.length===2){const D=Ie(t[0],g,"start"),T=Ie(t[1],g,"end");if(D&&T)return{from:D,to:T};}}},[t,b,F,g]),y=Z(()=>{if(!t||b||i)return;const D=Array.isArray(t)?t[0]:t;return Ie(D,g,"start");},[t,b,i,g]),O=D=>a==="<="||a===">"?Dr(D,g):Tr(D,g);return/* @__PURE__ */e(lr,{value:b?k:void 0,selectionMode:b?"range":"single",singleValue:b?void 0:y,singleValueLabel:!b&&i?vt:void 0,onChange:D=>{if(D!=null&&D.from&&D.to){f({value:[D.from.toISOString(),D.to.toISOString()]});return;}f({value:[]});},onSingleChange:D=>{if(!D){f({value:""});return;}const T=O(D),Q=kr(T,a,{timezone:g});f({value:typeof Q=="string"?Q:Q.toISOString()});},onRelativeSelect:L?(D,T)=>{if(!D.from||!D.to){f({value:b?[]:""});return;}const Q=It(a,[D.from.toISOString(),D.to.toISOString()]);f({value:Q.length===1?Q[0]:Q,relativeMeta:T});}:void 0,relativeValue:N,comparisonValue:!b&&L?a:void 0,relativePoints:!b&&L?{operator:a}:"none",relativeSummary:F,supplementalFooter:L?/* @__PURE__ */e("p",{className:"border-t border-border px-3 py-2 text-[11px] text-muted-foreground",children:"Presets and Relative update each time the card runs. Static dates stay fixed."}):void 0,timezone:g,enableTimePrecision:Sr(A),staticTimeInputs:!1,showRelativeTab:L,className:U("min-w-0",S),buttonClassName:"h-7 text-[12px] [&>span]:text-[12px]",placeholder:"Select date…"});}const ra=t=>t.conditions.length>0||t.groups.length>0,Be=["contains","startsWith","endsWith","like","not like"],aa=["=","!=",">",">=","<","<=",...Be,"in","not in","isNull","isNotNull"],na=["=","!=",...Be,"in","not in","isNull","isNotNull"],sa=["=","!=",">",">=","<","<=","in","not in","isNull","isNotNull"],la=["=","!=","isNull","isNotNull"],ia=["between","=","!=","<","<=",">",">=","isNull","isNotNull"],oa={"=":"Equals","!=":"Not equals",">":"Greater than",">=":"Greater than or equal","<":"Less than","<=":"Less than or equal",contains:"Contains",startsWith:"Starts with",endsWith:"Ends with",like:"Like","not like":"Not like",in:"In","not in":"Not in",between:"Between",isNull:"Is null",isNotNull:"Is not null","not between":"Not between"};function $e(t){return oa[t]||Lr(t);}function da(t){switch(t){case"string":return na;case"number":return sa;case"boolean":return la;case"date":return ia;default:return aa;}}const qt="w-[68px] shrink-0",ut="group-data-[inline]/filters:w-auto group-data-[inline]/filters:min-w-0 group-data-[inline]/filters:flex-1 group-data-[inline]/filters:shrink",Ue="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function jt({value:t,onValueChange:a,"aria-label":s}){return/* @__PURE__ */o(le,{value:t,onValueChange:i=>a(i),children:[/* @__PURE__ */e(ie,{size:"xs","aria-label":s,className:U(qt,"font-medium"),children:/* @__PURE__ */e(oe,{})}),/* @__PURE__ */o(de,{className:"min-w-[var(--radix-select-trigger-width)]",children:[/* @__PURE__ */e(ee,{value:"AND",className:"text-[12px] font-medium",children:"AND"}),/* @__PURE__ */e(ee,{value:"OR",className:"text-[12px] font-medium",children:"OR"})]})]});}function Bt({condition:t,index:a,groupId:s,groupLogicalOperator:i,onRemoveCondition:A,onUpdateGroupOperator:f,availableFields:S,source:g,updateConditionFields:m,replaceCondition:b}){const{attributes:L,listeners:N,setNodeRef:F,transform:k,transition:y,isDragging:O}=Rt({id:t.id}),z={transform:_t.Transform.toString(k),transition:y},$=xe(t.field.dataType),Y=t.operator==="isNull"||t.operator==="isNotNull",D=t.operator==="in"||t.operator==="not in";return/* @__PURE__ */o("div",{ref:F,style:z,className:U("flex items-center gap-2 rounded-control px-1.5 py-1 transition-colors hover:bg-muted/40",O&&"z-50 opacity-50"),children:[/* @__PURE__ */e("button",{type:"button",...L,...N,"aria-label":"Drag to reorder condition",className:"flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded-control text-muted-foreground/60 hover:text-foreground focus-visible:outline-none active:cursor-grabbing",children:/* @__PURE__ */e(kt,{className:"h-3.5 w-3.5"})}),a>0?/* @__PURE__ */e(jt,{value:i,onValueChange:T=>f(s,T),"aria-label":"Logical operator"}):/* @__PURE__ */e("span",{className:U(qt,"text-center",Ue),children:"Where"}),/* @__PURE__ */e(Gr,{value:t.field,onValueChange:T=>{b(s,t.id,Jr(t,T));},availableFields:S,placeholder:"Select field",className:U("w-60 shrink-0",ut)}),/* @__PURE__ */o(le,{value:t.operator,onValueChange:T=>b(s,t.id,Yr(t,T)),children:[/* @__PURE__ */e(ie,{size:"xs","aria-label":"Operator",className:U("w-40 shrink-0",ut),children:/* @__PURE__ */e(oe,{children:t.operator?$e(t.operator):""})}),/* @__PURE__ */e(de,{children:da($).map(T=>/* @__PURE__ */e(ee,{value:T,children:$e(T)},T))})]}),Y?/* @__PURE__ */e("div",{className:"min-w-0 flex-1"}):$==="string"?D?/* @__PURE__ */e(Zr,{field:t.field,source:g,selected:Array.isArray(t.value)&&t.value.every(T=>typeof T=="string")?t.value:[],onChange:T=>m(s,t.id,{value:T}),placeholder:"Select values…",className:"min-w-0 flex-1"}):Be.includes(t.operator)?/* @__PURE__ */e(be,{size:"xs",value:typeof t.value=="string"?t.value:"",onChange:T=>m(s,t.id,{value:T.target.value}),className:"min-w-0 flex-1",placeholder:`${$e(t.operator)}…`}):/* @__PURE__ */e(ea,{field:t.field,source:g,value:typeof t.value=="string"?t.value:"",onChange:T=>m(s,t.id,{value:T}),placeholder:"Select value…",className:"min-w-0 flex-1"}):$==="boolean"?/* @__PURE__ */o(le,{value:typeof t.value=="boolean"?String(t.value):"",onValueChange:T=>m(s,t.id,{value:T==="true"}),children:[/* @__PURE__ */e(ie,{size:"xs",className:"min-w-0 flex-1",children:/* @__PURE__ */e(oe,{placeholder:"Select value…"})}),/* @__PURE__ */o(de,{children:[/* @__PURE__ */e(ee,{value:"true",children:"True"}),/* @__PURE__ */e(ee,{value:"false",children:"False"})]})]}):$==="date"?/* @__PURE__ */e(ta,{value:t.value,operator:t.operator,relativeMeta:At(t.relativeMeta),latestValue:t.latestValue===!0,field:t.field,onChange:T=>b(s,t.id,je(t,T)),className:"min-w-0 flex-1"}):/* @__PURE__ */e(be,{size:"xs",value:typeof t.value=="string"||typeof t.value=="number"?t.value:"",onChange:T=>m(s,t.id,{value:T.target.value}),className:"min-w-0 flex-1",placeholder:D?"value1, value2, value3":"Value"}),/* @__PURE__ */e(B,{variant:"ghost",size:"xs","aria-label":"Remove condition",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground hover:text-foreground",onClick:()=>A(s,t.id),children:/* @__PURE__ */e(Ct,{className:"h-3.5 w-3.5"})})]});}const pt="group-data-[inline]/filters:h-auto group-data-[inline]/filters:gap-1 group-data-[inline]/filters:border-0 group-data-[inline]/filters:bg-transparent group-data-[inline]/filters:px-0 group-data-[inline]/filters:py-0.5 group-data-[inline]/filters:text-[11px] group-data-[inline]/filters:font-medium group-data-[inline]/filters:text-muted-foreground group-data-[inline]/filters:shadow-none group-data-[inline]/filters:underline-offset-2 group-data-[inline]/filters:hover:bg-transparent group-data-[inline]/filters:hover:text-foreground group-data-[inline]/filters:hover:underline";function Ut({onAddCondition:t,onAddGroup:a}){return/* @__PURE__ */o("div",{className:"mt-2 flex items-center gap-1.5 group-data-[inline]/filters:mt-1 group-data-[inline]/filters:gap-3",children:[/* @__PURE__ */o(B,{type:"button",size:"xs",variant:"outline",className:U("gap-1.5",pt),onClick:t,children:[/* @__PURE__ */e(Ve,{className:"h-3 w-3"}),"Add condition"]}),a&&/* @__PURE__ */o(B,{type:"button",size:"xs",variant:"ghost",className:U("gap-1.5 text-muted-foreground hover:text-foreground",pt),onClick:a,children:[/* @__PURE__ */e(Ve,{className:"h-3 w-3"}),"Add group"]})]});}function ca({group:t,depth:a,parentGroupId:s,onUpdateGroupOperator:i,onUpdateGroupNegate:A,onRemoveGroup:f,onRemoveCondition:S,onReorderConditions:g,onReorderGroups:m,onAddCondition:b,onAddGroup:L,availableFields:N,source:F,renderFilterGroup:k,updateConditionFields:y,replaceCondition:O}){const{attributes:z,listeners:$,setNodeRef:Y,transform:D,transition:T,isDragging:Q}=Rt({id:t.id}),X={transform:_t.Transform.toString(D),transition:T},n=C=>{const{active:h,over:c}=C;if(c&&h.id!==c.id){const l=t.conditions.findIndex(p=>p.id===h.id),V=t.conditions.findIndex(p=>p.id===c.id);l!==-1&&V!==-1&&g(t.id,l,V);}},x=C=>{const{active:h,over:c}=C;if(c&&h.id!==c.id&&s){const l=t.groups.findIndex(p=>p.id===h.id),V=t.groups.findIndex(p=>p.id===c.id);l!==-1&&V!==-1&&m(s,l,V);}};return/* @__PURE__ */o("div",{ref:Y,style:X,className:U(a>0&&"mt-2 overflow-hidden rounded-[6px] border border-border/60",Q&&"z-50 opacity-50"),children:[a>0&&/* @__PURE__ */o("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 bg-muted/40 px-2 py-1",children:[/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e("button",{type:"button",...z,...$,"aria-label":"Drag to reorder group",className:"flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded-control text-muted-foreground/60 hover:text-foreground focus-visible:outline-none active:cursor-grabbing",children:/* @__PURE__ */e(kt,{className:"h-3.5 w-3.5"})}),/* @__PURE__ */e(B,{type:"button",variant:t.negate?"default":"outline",size:"xs","aria-pressed":t.negate,className:"px-2",onClick:()=>A(t.id,!t.negate),children:"NOT"}),/* @__PURE__ */e(jt,{value:t.logicalOperator,onValueChange:C=>i(t.id,C),"aria-label":"Group logical operator"}),/* @__PURE__ */e("span",{className:Ue,children:"Group"})]}),/* @__PURE__ */e(B,{type:"button",variant:"ghost",size:"xs","aria-label":"Remove group",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:()=>s&&f(s,t.id),children:/* @__PURE__ */e(xt,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */o("div",{className:U(a>0&&"p-2"),children:[/* @__PURE__ */e(ve,{sensors:Re(se(Ge),se(ze,{coordinateGetter:_e})),collisionDetection:ye,onDragEnd:n,children:/* @__PURE__ */e(Ne,{items:t.conditions.map(C=>C.id),strategy:Ce,children:/* @__PURE__ */e("div",{className:"space-y-0.5",children:t.conditions.map((C,h)=>/* @__PURE__ */e(Bt,{condition:C,index:h,groupId:t.id,groupLogicalOperator:t.logicalOperator,onRemoveCondition:S,onUpdateGroupOperator:i,availableFields:N,source:F,updateConditionFields:y,replaceCondition:O},C.id))})})}),/* @__PURE__ */e(ve,{sensors:Re(se(Ge),se(ze,{coordinateGetter:_e})),collisionDetection:ye,onDragEnd:x,children:/* @__PURE__ */e(Ne,{items:t.groups.map(C=>C.id),strategy:Ce,children:t.groups.map(C=>k(C,a+1,t.id))})}),t.conditions.length===0&&t.groups.length===0&&/* @__PURE__ */e("p",{className:"rounded-control border border-dashed border-border/60 px-3 py-2 text-center text-[11.5px] text-muted-foreground",children:"No conditions in this group."}),/* @__PURE__ */e(Ut,{onAddCondition:()=>b(t.id),onAddGroup:()=>L(t.id)})]})]});}function Da({filters:t,availableFields:a,source:s,onSave:i,onClearAll:A,onCancel:f,onChange:S}){const g=S!==void 0,{currentFilters:m,availableFields:b,isLoading:L,addCondition:N,addGroup:F,removeCondition:k,removeGroup:y,updateConditionFields:O,replaceCondition:z,updateGroupOperator:$,updateGroupNegate:Y,reorderConditions:D,reorderGroups:T,generateSQLPreview:Q,hasAnyFilters:X}=Pr({initialFilters:t,availableFields:a,...(S?{onChange:l=>S(ra(l)?l:null)}:{})}),n=Re(se(Ge),se(ze,{coordinateGetter:_e})),[x,C]=te(!1),h=(l,V=0,p)=>{if(V===0){const K=l.conditions.length===0&&l.groups.length===0;return/* @__PURE__ */o("div",{children:[/* @__PURE__ */e(ve,{sensors:n,collisionDetection:ye,onDragEnd:E=>{const{active:_,over:q}=E;if(q&&_.id!==q.id){const j=l.conditions.findIndex(J=>J.id===_.id),H=l.conditions.findIndex(J=>J.id===q.id);j!==-1&&H!==-1&&D(l.id,j,H);}},children:/* @__PURE__ */e(Ne,{items:l.conditions.map(E=>E.id),strategy:Ce,children:/* @__PURE__ */e("div",{className:"space-y-0.5",children:l.conditions.map((E,_)=>/* @__PURE__ */e(Bt,{condition:E,index:_,groupId:l.id,groupLogicalOperator:l.logicalOperator,onRemoveCondition:k,onUpdateGroupOperator:$,availableFields:b,source:s,updateConditionFields:O,replaceCondition:z},E.id))})})}),/* @__PURE__ */e(ve,{sensors:n,collisionDetection:ye,onDragEnd:E=>{const{active:_,over:q}=E;if(q&&_.id!==q.id){const j=l.groups.findIndex(J=>J.id===_.id),H=l.groups.findIndex(J=>J.id===q.id);j!==-1&&H!==-1&&T(l.id,j,H);}},children:/* @__PURE__ */e(Ne,{items:l.groups.map(E=>E.id),strategy:Ce,children:l.groups.map(E=>h(E,V+1,l.id))})}),K&&!g&&/* @__PURE__ */e("p",{className:"rounded-control border border-dashed border-border/60 px-3 py-2 text-center text-[11.5px] text-muted-foreground",children:"No filters yet. Add a condition to limit the rows this card shows."}),/* @__PURE__ */e(Ut,{onAddCondition:()=>N(l.id),onAddGroup:(g?l.conditions.length+l.groups.length>=2:x)?()=>F(l.id):void 0})]},l.id);}return/* @__PURE__ */e(ca,{group:l,depth:V,parentGroupId:p,onUpdateGroupOperator:$,onUpdateGroupNegate:Y,onRemoveGroup:y,onRemoveCondition:k,onReorderConditions:D,onReorderGroups:T,onAddCondition:N,onAddGroup:F,availableFields:b,source:s,renderFilterGroup:h,updateConditionFields:O,replaceCondition:z},l.id);},c=zr(t);return/* @__PURE__ */o("div",{className:U("group/filters",g?"flex flex-col":"flex min-h-0 flex-1 flex-col"),"data-inline":g||void 0,children:[/* @__PURE__ */o("div",{className:g?"":"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:[L?/* @__PURE__ */o("div",{className:"flex items-center justify-center gap-2 py-6 text-[12px] text-muted-foreground",children:[/* @__PURE__ */e(ir,{className:"h-3.5 w-3.5 animate-spin"}),"Loading columns…"]}):h(m),!g&&/* @__PURE__ */o("div",{className:"mt-3 flex items-center gap-2 border-t border-border/60 pt-3",children:[/* @__PURE__ */e(or,{size:"xs",id:"advanced-mode",checked:x,onCheckedChange:l=>C(l)}),/* @__PURE__ */e(ae,{htmlFor:"advanced-mode",className:"text-[12px] font-normal leading-none text-foreground",children:"Advanced mode"}),/* @__PURE__ */e("span",{className:"text-[11px] text-muted-foreground",children:"Nest conditions in groups"})]}),X&&!g&&/* @__PURE__ */o("div",{className:"mt-3 border-t border-border/60 pt-3",children:[/* @__PURE__ */e("div",{className:U("mb-1.5",Ue),children:"Where clause"}),/* @__PURE__ */e("pre",{className:"overflow-x-auto whitespace-pre-wrap break-words rounded-[6px] border border-border bg-muted/40 px-3 py-2 font-mono text-[12px] leading-[1.55] text-foreground",children:Q(m)})]})]}),g?null:/* @__PURE__ */o("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border px-3 py-2.5",children:[/* @__PURE__ */e("div",{children:c>0&&/* @__PURE__ */e(B,{size:"xs",variant:"ghost",className:"text-muted-foreground hover:text-foreground",onClick:()=>A==null?void 0:A(),children:"Clear all"})}),/* @__PURE__ */o("div",{className:"flex items-center gap-1.5",children:[/* @__PURE__ */e(B,{size:"xs",variant:"ghost",onClick:()=>f==null?void 0:f(),children:"Cancel"}),/* @__PURE__ */e(B,{size:"xs",onClick:()=>i==null?void 0:i(X?m:null),children:"Apply filters"})]})]})]});}export{Na as C,Ca as F,Wr as I,Ur as L,wa as V,Sa as a,Da as b,ka as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as b}from"./visual-contract-DQPKg5QW.js";function y(s,r){var o,i,l,u;const g=b(s),a=[...(((o=s.config)==null?void 0:o.groupByColumns)??[]),...(((i=s.config)==null?void 0:i.metricColumns)??[])],e=Object.fromEntries(Object.entries(((l=s.customVisual)==null?void 0:l.slots)??{}).flatMap(([c,t])=>{if(!t)return[];if("column"in t)return[[c,t.column]];const n=a.find(f=>f.id===t.fieldId),m=(n==null?void 0:n.label)||(n==null?void 0:n.name);return m?[[c,m]]:[];}));return{html:r,fields:g,...(Object.keys(e).length?{slots:e}:{}),...((u=s.customVisual)!=null&&u.settings?{settings:{...s.customVisual.settings}}:{})};}function C(s){return JSON.stringify([s.html,s.fields,s.slots??null,s.settings??null]);}export{C as a,y as e};
|