react-semaphor 0.1.564 → 0.1.566
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/DATA_APP_SDK.md +3 -3
- package/README.md +2 -2
- package/dist/analytics-protocol/index.js +8 -8
- package/dist/assistant-context/index.js +3 -2
- package/dist/brand-studio/index.js +28 -29
- package/dist/briefings/index.js +53 -49
- package/dist/chunks/{assistant-chat-D1BEEHUF.js → assistant-chat-DNKAYSQL.js} +204 -204
- package/dist/chunks/{bookmark-impact-XOsVUAqW.js → bookmark-impact-BeUbq0jc.js} +2 -2
- package/dist/chunks/bookmark-state-ByODVqee.js +1613 -0
- package/dist/chunks/card-filter-builder-SXaRWbKr.js +4100 -0
- package/dist/chunks/{switch-BW4yXSYs.js → code-editor-DJNOsgJH.js} +463 -442
- package/dist/chunks/{comparison-window-caption-D1EUXzaR.js → comparison-window-caption-CMLb3mut.js} +451 -419
- package/dist/chunks/{dashboard-DfYsASNd.js → dashboard-Cni7nGhg.js} +1 -1
- package/dist/chunks/dashboard-briefing-launcher-CXeXRTem.js +4910 -0
- package/dist/chunks/{dashboard-controls-CJ8Dz50D.js → dashboard-controls-CsqKybrf.js} +685 -675
- package/dist/chunks/{dashboard-json-D3uZxGO-.js → dashboard-json-WWmw3Piu.js} +4 -4
- package/dist/chunks/{dates-EvDtT25n.js → dates-DJRUS-he.js} +12 -12
- package/dist/chunks/{edit-dashboard-visual-CgHJXBQv.js → edit-dashboard-visual-BrIEaBhc.js} +7724 -10341
- package/dist/chunks/filter-reach-copy-D5LqgrUf.js +4667 -0
- package/dist/chunks/{filter-value-text-CPwFkrMz.js → filter-value-text-7zhmth1S.js} +2 -2
- package/dist/chunks/{index-CAgf2x4E.js → index-Bq9UbCGk.js} +653 -574
- package/dist/chunks/{layout-grid-BM65viQh.js → layout-grid-0hIlqEtk.js} +1 -1
- package/dist/chunks/{list-filter-BoeLBfL3.js → list-filter-DkgoCeBm.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-hEucouWM.js → matrix-analytical-definition-C9xB_T84.js} +18 -18
- package/dist/chunks/{matrix-card-CCh9JjP1.js → matrix-card-BSUeSXpD.js} +2 -2
- package/dist/chunks/{matrix-member-presentation-DsAUbuoL.js → matrix-member-presentation-DZNgQpUq.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-DsLdFdSa.js → matrix-operation-contract-Eb6elidS.js} +1 -1
- package/dist/chunks/{metric-comparison-Bnso1cm1.js → metric-comparison-ChXUFaZu.js} +1 -1
- package/dist/chunks/{palette-p1XSJFgB.js → palette-4vf2BEEg.js} +1 -1
- package/dist/chunks/{pivot-result-contract-expectations-B53jqszr.js → pivot-result-contract-expectations-Ddh1rNz5.js} +4 -4
- package/dist/chunks/{pivot-result-identity-Dq5jm-EC.js → pivot-result-identity-BlbLrqaC.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-DMqxSU4X.js → report-preferences-dialog-CeHioJwL.js} +122 -131
- package/dist/chunks/{report-runtime-context-BITkNSDa.js → report-runtime-context-DnA_PiKo.js} +1 -1
- package/dist/chunks/resolve-dashboard-input-context-CwS-2r-b.js +21419 -0
- package/dist/chunks/{save-CHV1B1fL.js → save-D6pHmSSP.js} +1 -1
- package/dist/chunks/saved-dashboard-context-c-MZZTx2.js +629 -0
- package/dist/chunks/{selection-reducer-Bz5aywT4.js → selection-reducer-OaJ-N5uN.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator-CFeCIuaw.js → semaphor-ready-indicator-B2NpYRE-.js} +81034 -80950
- package/dist/chunks/{shelf-drop-preview-context-cEyVkKTF.js → shelf-drop-preview-context-DM7yypwC.js} +407 -407
- package/dist/chunks/{source-entity-resolution-DdDVXFB8.js → source-entity-resolution-DF6GulDn.js} +1 -1
- package/dist/chunks/stored-dashboard-DTWc2pzt.js +5026 -0
- package/dist/chunks/{table-export-sheet-bSXxGn-v.js → table-export-sheet--DUKWk6o.js} +1 -1
- package/dist/chunks/{temporal-input-presentation-sk9gqLi6.js → temporal-input-presentation--2r9BLr0.js} +392 -377
- package/dist/chunks/{token-types-BUK06hU2.js → token-types-C8JymO8s.js} +1 -1
- package/dist/chunks/{upload-BnmuyPqW.js → upload-Cf3wXZT8.js} +1 -1
- package/dist/chunks/{validators-BIM0FE31.js → validators-wtjw0aw6.js} +7 -7
- package/dist/chunks/variable-draft-DFizFCJu.js +241 -0
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +2324 -1796
- package/dist/data-app-sdk/index.js +4 -4
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +5 -5
- package/dist/format-utils/index.js +174 -167
- package/dist/index.js +189 -187
- package/dist/pdf-export-policy/index.js +80 -28
- package/dist/pdf-table-layout/index.js +65 -65
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
- package/dist/types/briefings/delivery-outcome.d.ts +37 -0
- package/dist/types/briefings/index.d.ts +2 -0
- package/dist/types/briefings/run-outcomes.d.ts +6 -0
- package/dist/types/components/briefings/briefing-author/run-model.d.ts +9 -0
- package/dist/types/components/dashboard-variables/data-variables-menu.d.ts +8 -0
- package/dist/types/components/dashboard-variables/variable-editor-host.d.ts +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/index.js +5 -5
- package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +62 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +33 -2
- package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +7 -2
- package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +4 -2
- package/dist/types/lib/dashboard-variables/data-text.d.ts +33 -0
- package/dist/types/lib/dashboard-variables/types.d.ts +207 -0
- package/dist/types/lib/document/document-edits.d.ts +16 -1
- package/dist/types/lib/document/document-panel-target.d.ts +1 -1
- package/dist/types/lib/document/document-section-query-options.d.ts +29 -0
- package/dist/types/lib/document/document-table-data-policy.d.ts +0 -1
- package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +92 -0
- package/dist/types/lib/query-context/build-card-query-context.d.ts +6 -0
- package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +15 -3
- package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +1 -0
- package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +36 -0
- package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
- package/dist/types/lib/text-variables/text-variable-types.d.ts +72 -0
- package/dist/types/lib/types/common-types.d.ts +155 -51
- package/dist/types/lib/utils/card-definition.d.ts +2 -2
- package/dist/types/shared/assistant-context/index.d.ts +1 -1
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +51 -1
- package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +7 -1
- package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +10 -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 +1087 -430
- package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +20 -1
- package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +40 -40
- package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -16
- package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-sql-subscription.d.ts +24 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-targets.d.ts +29 -0
- package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +7 -4
- package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +159 -0
- package/dist/types/shared/dashboard-authoring/dashboard-variable-changes.d.ts +61 -0
- package/dist/types/shared/dashboard-authoring/document-section-cards.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +50 -3
- package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +48 -1
- package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +22 -6
- package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +87 -13
- package/dist/types/shared/dashboard-authoring/text-card-words/chip-colors.d.ts +23 -0
- package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +90 -8
- package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +31 -3
- package/dist/types/shared/dashboard-authoring/text-card-words/variable-words.d.ts +8 -0
- package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +125 -0
- package/dist/types/shared/dashboard-authoring/variable-editability.d.ts +24 -0
- package/dist/types/shared/dashboard-authoring/variable-references.d.ts +39 -0
- package/dist/types/shared/format-utils/document-print.d.ts +4 -2
- package/dist/types/shared/format-utils/index.d.ts +1 -0
- package/dist/types/shared/format-utils/pdf-capacity-lines.d.ts +17 -0
- package/dist/types/shared/format-utils/pdf-delivery.d.ts +8 -1
- package/dist/types/shared/format-utils/pdf-export-policy.d.ts +74 -6
- package/dist/types/shared/format-utils/presentation-execution.d.ts +9 -0
- package/package.json +2 -2
- package/src/data-app-sdk/README.md +3 -3
- package/dist/chunks/bookmark-state-CWeoGbrx.js +0 -743
- package/dist/chunks/braces-DzgoQC64.js +0 -23
- package/dist/chunks/dashboard-briefing-launcher-lvYfJoUQ.js +0 -3878
- package/dist/chunks/filter-reach-copy-Cmb05jlE.js +0 -3965
- package/dist/chunks/global-date-filter-utils-ruJYwjgZ.js +0 -16733
- package/dist/chunks/resolve-dashboard-input-context-i_jCSYae.js +0 -8214
- package/dist/chunks/saved-dashboard-context-Dg3oDmH_.js +0 -564
- package/dist/chunks/use-create-flow-overlay-state-Dl6DCxh8.js +0 -1436
|
@@ -0,0 +1,4667 @@
|
|
|
1
|
+
import { J as fr, K as mr, M as pr, N as rn, O as gr, P as hr, Q as yr, R as br, S as vr, T as an, U as Ir, V as Cr, W as Fr, X as _e, Y as Sr, Z as xr, _ as wr, g as Tr, k as be, $ as Dr, a0 as kr } from "./stored-dashboard-DTWc2pzt.js";
|
|
2
|
+
import { fz as on, bo as ve, fA as Mr, fB as Or, fC as _r, fD as Pr, O as H, fE as sn, bq as Ar, fF as Nr, fG as Xe, ah as Qe, fH as Er, fI as $r, fJ as Rr, K as Je, fK as Kr, bz as Vr, P as Lr, fL as qr, L as Br, m as Ze, fM as et, fN as Ur, fO as F, o as xe, fP as J, fQ as T, fR as zr, fS as jr, fT as Tt, fU as Gr, fV as Dt, fW as Wr, aN as w, fX as cn, aY as we, fY as Hr, fZ as Yr, f_ as Xr, f$ as Qr, g0 as Jr, g1 as ln, cg as dn, g2 as un, g3 as fn, g4 as Ie, g5 as kt, a2 as Y, g6 as tt, g7 as Mt, g8 as nt, t as Ot, g9 as _t, c3 as rt, ga as Zr, gb as ei, gc as ti, gd as re, ge as ni, gf as ri, gg as ii, a5 as ai, bt as oi, c8 as it, gh as mn, gi as Le, J as si, aC as ci, dZ as li, gj as di, gk as ui, gl as fi, gm as mi, gn as pi, go as gi, gp as hi, gq as yi, gr as qe, gs as bi, fu as Pe, gt as vi, gu as Ii, gv as pn, a as gn, gw as Ci, gx as Fi, d1 as hn, gy as Pt, cB as Si, d4 as At, d3 as xi, e5 as wi, aR as Ti, eG as Di, gz as ki, gA as Mi, cn as Nt } from "./resolve-dashboard-input-context-CwS-2r-b.js";
|
|
3
|
+
import { H as ce, f as Oi, e as _i, G as yn, aA as Pi, v as Ai, n as Ni, d as Ei } from "./validators-wtjw0aw6.js";
|
|
4
|
+
import { N as $i, r as Ae } from "./matrix-operation-contract-Eb6elidS.js";
|
|
5
|
+
import { r as Ri, C as Ki } from "./metric-comparison-ChXUFaZu.js";
|
|
6
|
+
import { t as Et, e as $t } from "./analytics-base-schemas-BaIQrEzX.js";
|
|
7
|
+
import "zod";
|
|
8
|
+
import { b as Q, i as N, aI as Vi, aJ as Li, m as qi, h as Bi, d as Be, e as Ui, Q as _, af as zi, am as ji, c as Gi, ah as Wi, W as Hi, w as Yi, a5 as Xi } from "./temporal-input-presentation--2r9BLr0.js";
|
|
9
|
+
import "../value-format-preferences/index.js";
|
|
10
|
+
import { y as Qi, R as Ji, J as Zi, ae as ea, a0 as Rt, M as bn, z as vn, ap as ta, N as In, A as na, a4 as ra, a5 as ia, F as Cn, W as aa, X as Fn, H as at, Y as Sn, aq as oa } from "./bookmark-state-ByODVqee.js";
|
|
11
|
+
import { g as sa } from "./_commonjsHelpers-DimLPMtv.js";
|
|
12
|
+
import "./index-CuHybtft.js";
|
|
13
|
+
import "./index-RNaTnE3m.js";
|
|
14
|
+
import "./context-R31TSL5V.js";
|
|
15
|
+
import { a as ca } from "./source-entity-resolution-DF6GulDn.js";
|
|
16
|
+
import { R as la, l as da } from "./matrix-analytical-definition-C9xB_T84.js";
|
|
17
|
+
import { r as Ue } from "./pivot-result-identity-BlbLrqaC.js";
|
|
18
|
+
import { r as xn } from "./applied-constraints-DU-wndZ7.js";
|
|
19
|
+
function ua(e, t) {
|
|
20
|
+
if (!(typeof e != "number" || typeof t != "number"))
|
|
21
|
+
return e === t ? t : void 0;
|
|
22
|
+
}
|
|
23
|
+
function U(e, t) {
|
|
24
|
+
const n = Q(e, t);
|
|
25
|
+
if (n) {
|
|
26
|
+
if (n.type === "date")
|
|
27
|
+
return {
|
|
28
|
+
type: "date",
|
|
29
|
+
locale: n.locale,
|
|
30
|
+
dateFormat: n.pattern,
|
|
31
|
+
...n.dialect ? { dateDialect: n.dialect } : {},
|
|
32
|
+
...n.preset ? { datePreset: n.preset } : {},
|
|
33
|
+
timezone: n.timezone,
|
|
34
|
+
sourceTimezone: n.sourceTimezone,
|
|
35
|
+
relative: n.relative,
|
|
36
|
+
prefix: n.prefix,
|
|
37
|
+
suffix: n.suffix
|
|
38
|
+
};
|
|
39
|
+
if (n.type === "duration")
|
|
40
|
+
return {
|
|
41
|
+
type: "duration",
|
|
42
|
+
durationInputUnit: n.inputUnit,
|
|
43
|
+
durationDisplayStyle: n.outputStyle,
|
|
44
|
+
durationLargestUnit: n.largestUnit,
|
|
45
|
+
durationSmallestUnit: n.smallestUnit,
|
|
46
|
+
durationMaxUnits: n.maxUnits,
|
|
47
|
+
prefix: n.prefix,
|
|
48
|
+
suffix: n.suffix,
|
|
49
|
+
negativeInParentheses: n.negativeStyle === "parentheses"
|
|
50
|
+
};
|
|
51
|
+
if (N(n))
|
|
52
|
+
return {
|
|
53
|
+
type: n.type,
|
|
54
|
+
locale: n.locale,
|
|
55
|
+
currency: n.type === "currency" ? n.currency : void 0,
|
|
56
|
+
decimalPlaces: t != null && t.preserveOmittedProperties ? void 0 : ua(
|
|
57
|
+
n.minimumFractionDigits,
|
|
58
|
+
n.maximumFractionDigits
|
|
59
|
+
),
|
|
60
|
+
minimumFractionDigits: n.minimumFractionDigits,
|
|
61
|
+
maximumFractionDigits: n.maximumFractionDigits,
|
|
62
|
+
useGrouping: n.useGrouping,
|
|
63
|
+
prefix: n.prefix,
|
|
64
|
+
suffix: n.suffix,
|
|
65
|
+
useSuffix: !!n.compact,
|
|
66
|
+
negativeInParentheses: n.negativeStyle === "parentheses",
|
|
67
|
+
...n.signDisplay ? { signDisplay: n.signDisplay } : {},
|
|
68
|
+
multiplyBy: n.type === "percent" ? n.scale ?? (n.percentValueMode === "whole" ? 1 : 100) : n.scale,
|
|
69
|
+
percentValueMode: n.type === "percent" ? n.percentValueMode : void 0
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function wn(e, t) {
|
|
74
|
+
const n = Q(e, t);
|
|
75
|
+
return (n == null ? void 0 : n.type) === "duration" ? {
|
|
76
|
+
style: "duration",
|
|
77
|
+
duration: {
|
|
78
|
+
inputUnit: n.inputUnit,
|
|
79
|
+
outputStyle: n.outputStyle,
|
|
80
|
+
largestUnit: n.largestUnit,
|
|
81
|
+
smallestUnit: n.smallestUnit,
|
|
82
|
+
maxUnits: n.maxUnits
|
|
83
|
+
},
|
|
84
|
+
prefix: n.prefix,
|
|
85
|
+
suffix: n.suffix,
|
|
86
|
+
negativeStyle: n.negativeStyle
|
|
87
|
+
} : !n || !N(n) ? void 0 : {
|
|
88
|
+
style: n.type === "currency" ? "currency" : n.type === "percent" ? "percent" : n.type === "scientific" ? "scientific" : "decimal",
|
|
89
|
+
currency: n.type === "currency" && n.currency || (t != null && t.preserveOmittedProperties ? void 0 : "USD"),
|
|
90
|
+
locale: n.locale || (t != null && t.preserveOmittedProperties ? void 0 : Vi),
|
|
91
|
+
minimumFractionDigits: n.minimumFractionDigits ?? (t != null && t.preserveOmittedProperties ? void 0 : 0),
|
|
92
|
+
maximumFractionDigits: n.maximumFractionDigits ?? (t != null && t.preserveOmittedProperties ? void 0 : 2),
|
|
93
|
+
useGrouping: typeof n.useGrouping == "boolean" ? n.useGrouping : !0,
|
|
94
|
+
percentValueMode: n.type === "percent" ? n.percentValueMode || "fraction" : "whole",
|
|
95
|
+
scale: n.scale,
|
|
96
|
+
compact: n.compact,
|
|
97
|
+
negativeStyle: n.negativeStyle,
|
|
98
|
+
...n.signDisplay ? { signDisplay: n.signDisplay } : {},
|
|
99
|
+
prefix: n.prefix,
|
|
100
|
+
suffix: n.suffix
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const Kt = [10, 20, 50, 100, 500, 1e3], fa = 50;
|
|
104
|
+
function ma(e) {
|
|
105
|
+
return e && e > 0 ? e : fa;
|
|
106
|
+
}
|
|
107
|
+
function ac(e) {
|
|
108
|
+
const t = ma(e), n = [...Kt];
|
|
109
|
+
return Kt.includes(
|
|
110
|
+
t
|
|
111
|
+
) || (n.push(t), n.sort((r, i) => r - i)), n;
|
|
112
|
+
}
|
|
113
|
+
function oc(e) {
|
|
114
|
+
var t, n;
|
|
115
|
+
return !!((e.type === "table" || e.type === "detailTable") && e.sql && !on(e.config) && !((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) != null && n.forceClientPagination));
|
|
116
|
+
}
|
|
117
|
+
function pa(e, t) {
|
|
118
|
+
var r, i, o, a;
|
|
119
|
+
if (t === "table-print")
|
|
120
|
+
return "disabled";
|
|
121
|
+
if ((i = (r = e.preferences) == null ? void 0 : r.tablePrefs) != null && i.forceClientPagination)
|
|
122
|
+
return "client";
|
|
123
|
+
const n = on(e.config);
|
|
124
|
+
return e.sql && !n ? (a = (o = e.preferences) == null ? void 0 : o.tablePrefs) != null && a.enableDevModePagination ? "server" : "client" : n && fr(e) ? "server" : "client";
|
|
125
|
+
}
|
|
126
|
+
const Tn = Object.freeze({}), sc = {
|
|
127
|
+
access: "session-only",
|
|
128
|
+
printMode: !1,
|
|
129
|
+
baseline: null,
|
|
130
|
+
applied: null,
|
|
131
|
+
appliedBookmark: null,
|
|
132
|
+
tableSettings: Tn,
|
|
133
|
+
notices: [],
|
|
134
|
+
isFavorite: !1,
|
|
135
|
+
fetchedAt: 0
|
|
136
|
+
};
|
|
137
|
+
function cc(e) {
|
|
138
|
+
return !e.viewer.printMode && e.viewer.access !== "session-only" && !!e.viewer.baseline && !!e.viewerStateClient && !e.isDashboardEditing;
|
|
139
|
+
}
|
|
140
|
+
function ga(e) {
|
|
141
|
+
return e.isDashboardEditing ? Tn : e.viewer.tableSettings;
|
|
142
|
+
}
|
|
143
|
+
function ha(e, t) {
|
|
144
|
+
return ga(e)[t];
|
|
145
|
+
}
|
|
146
|
+
function lc(e, t, n) {
|
|
147
|
+
if (!(n.isEditorPreview || e.isDashboardEditing) && Qi(e.dashboard, t))
|
|
148
|
+
return { settings: ha(e, t) };
|
|
149
|
+
}
|
|
150
|
+
function ya(e) {
|
|
151
|
+
var t;
|
|
152
|
+
return mr({
|
|
153
|
+
card: e.card,
|
|
154
|
+
paginationMode: pa(e.card) === "server" ? "server" : "client",
|
|
155
|
+
result: {
|
|
156
|
+
keys: e.keys ?? pr(e.records),
|
|
157
|
+
rows: e.records,
|
|
158
|
+
columns: e.resultColumns,
|
|
159
|
+
columnKeyMap: e.columnKeyMap,
|
|
160
|
+
comparisonMetadata: e.comparisonMetadata
|
|
161
|
+
},
|
|
162
|
+
settings: (t = e.viewerTable) == null ? void 0 : t.settings,
|
|
163
|
+
projection: "export"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function ba(e) {
|
|
167
|
+
if (e)
|
|
168
|
+
return U(
|
|
169
|
+
Q(e, { preserveOmittedProperties: !0 }),
|
|
170
|
+
{ preserveOmittedProperties: !0 }
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
function va(e) {
|
|
174
|
+
if (e.type === "percent") {
|
|
175
|
+
const { multiplyBy: t, percentValueMode: n, ...r } = e, i = t === 100 ? "fraction" : t === 1 ? "whole" : t === void 0 ? n : void 0;
|
|
176
|
+
if (i || t === void 0)
|
|
177
|
+
return Et(
|
|
178
|
+
ve({ ...r, ...i ? { percentValueMode: i } : {} }, { preserveOmittedProperties: !0 })
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
return Et(
|
|
182
|
+
ve(e, { preserveOmittedProperties: !0 })
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
const Te = ba, dc = va, Ia = () => ({
|
|
186
|
+
urlTemplate: "{value}",
|
|
187
|
+
// Default: use cell value as-is
|
|
188
|
+
labelType: "value",
|
|
189
|
+
// Default: show cell value as label
|
|
190
|
+
staticLabel: "",
|
|
191
|
+
labelColumn: "",
|
|
192
|
+
openInNewTab: !0
|
|
193
|
+
// Default: open in new tab (current behavior)
|
|
194
|
+
}), ot = () => ({
|
|
195
|
+
type: "none",
|
|
196
|
+
inheritMetricFormat: !0,
|
|
197
|
+
textAlign: "left",
|
|
198
|
+
// The table's one width rule (card appearance P2-21).
|
|
199
|
+
width: _r,
|
|
200
|
+
minWidth: Or,
|
|
201
|
+
maxWidth: Mr,
|
|
202
|
+
textOverflow: "ellipsis",
|
|
203
|
+
textWrap: "default",
|
|
204
|
+
numberFormat: {
|
|
205
|
+
style: "decimal",
|
|
206
|
+
currency: "USD",
|
|
207
|
+
locale: "en-US",
|
|
208
|
+
minimumFractionDigits: 0,
|
|
209
|
+
maximumFractionDigits: 2,
|
|
210
|
+
useGrouping: !0,
|
|
211
|
+
percentValueMode: "whole"
|
|
212
|
+
},
|
|
213
|
+
dateFormat: {
|
|
214
|
+
format: "MM/dd/yyyy",
|
|
215
|
+
useCustomFormat: !1,
|
|
216
|
+
customFormat: "yyyy-MM-dd'T'HH:mm:ss",
|
|
217
|
+
useRelativeTime: !1,
|
|
218
|
+
timezone: "auto",
|
|
219
|
+
// Default to auto (use context or browser timezone for display)
|
|
220
|
+
sourceTimezone: "auto"
|
|
221
|
+
// Default to auto (use explicit timezone if present, otherwise assume UTC)
|
|
222
|
+
},
|
|
223
|
+
linkFormat: Ia()
|
|
224
|
+
});
|
|
225
|
+
function uc(e, t, n, r) {
|
|
226
|
+
return t && t !== "auto" ? t : n;
|
|
227
|
+
}
|
|
228
|
+
const fc = (e) => !e || e === "auto" ? "local time" : {
|
|
229
|
+
"America/New_York": "Eastern Time",
|
|
230
|
+
"America/Chicago": "Central Time",
|
|
231
|
+
"America/Denver": "Mountain Time",
|
|
232
|
+
"America/Los_Angeles": "Pacific Time",
|
|
233
|
+
"Europe/London": "London Time",
|
|
234
|
+
"Europe/Paris": "Central European Time",
|
|
235
|
+
"Asia/Tokyo": "Japan Time",
|
|
236
|
+
"Asia/Shanghai": "China Time",
|
|
237
|
+
UTC: "UTC"
|
|
238
|
+
}[e] || e;
|
|
239
|
+
function Dn(e, t) {
|
|
240
|
+
const n = typeof e.decimalPlaces == "number", r = typeof e.minimumFractionDigits == "number" ? e.minimumFractionDigits : n ? e.decimalPlaces : t.min, i = typeof e.maximumFractionDigits == "number" ? e.maximumFractionDigits : n ? e.decimalPlaces : t.max;
|
|
241
|
+
return {
|
|
242
|
+
minimumFractionDigits: r,
|
|
243
|
+
maximumFractionDigits: Math.max(r, i)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function Ce(e, t) {
|
|
247
|
+
const n = Dn(e, t), r = typeof e.suffix == "string" && e.suffix.length > 0;
|
|
248
|
+
return {
|
|
249
|
+
style: "decimal",
|
|
250
|
+
locale: e.locale,
|
|
251
|
+
currency: e.currency,
|
|
252
|
+
minimumFractionDigits: n.minimumFractionDigits,
|
|
253
|
+
maximumFractionDigits: n.maximumFractionDigits,
|
|
254
|
+
useGrouping: e.useGrouping,
|
|
255
|
+
// Preserve legacy behavior: explicit custom suffix should not trigger compacting.
|
|
256
|
+
useSuffix: !!(e.useSuffix && !r),
|
|
257
|
+
prefix: e.prefix,
|
|
258
|
+
suffix: e.suffix,
|
|
259
|
+
negativeInParentheses: e.negativeInParentheses,
|
|
260
|
+
multiplyBy: e.multiplyBy,
|
|
261
|
+
percentValueMode: e.percentValueMode
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function st(e, t = "auto", n = {}) {
|
|
265
|
+
if (t === "auto" && (t = wa(e, n)), (t === "number" || t === "currency" || t === "percent" || t === "scientific") && n.signDisplay && n.signDisplay !== "auto" && Number.isFinite(Number(e))) {
|
|
266
|
+
const i = typeof n.multiplyBy == "number" && Number.isFinite(n.multiplyBy) ? n.multiplyBy : 1, o = Number(e) * i, a = Li(o, n.signDisplay), s = st(a.value === o ? e : -Number(e), t, { ...n, signDisplay: void 0 });
|
|
267
|
+
if (!a.plus) return s;
|
|
268
|
+
const c = n.prefix ?? "";
|
|
269
|
+
return c && s.startsWith(c) ? `${c}+${s.slice(c.length)}` : `+${s}`;
|
|
270
|
+
}
|
|
271
|
+
switch (t) {
|
|
272
|
+
case "number":
|
|
273
|
+
return kn(e, n);
|
|
274
|
+
case "currency":
|
|
275
|
+
return Mn(e, n);
|
|
276
|
+
case "percent":
|
|
277
|
+
return Ca(e, n);
|
|
278
|
+
case "date":
|
|
279
|
+
return Fa(e, n);
|
|
280
|
+
case "scientific":
|
|
281
|
+
return Sa(e, n);
|
|
282
|
+
case "duration":
|
|
283
|
+
return xa(e, n);
|
|
284
|
+
default:
|
|
285
|
+
return String(e);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function kn(e, t = {}) {
|
|
289
|
+
return e < 0 && !!t.prefix && !t.negativeInParentheses ? `-${Be(
|
|
290
|
+
Math.abs(e),
|
|
291
|
+
Ce(t, {
|
|
292
|
+
min: 0,
|
|
293
|
+
max: 0
|
|
294
|
+
})
|
|
295
|
+
)}` : Be(
|
|
296
|
+
e,
|
|
297
|
+
Ce(t, {
|
|
298
|
+
min: 0,
|
|
299
|
+
max: 0
|
|
300
|
+
})
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
function Mn(e, t = {}) {
|
|
304
|
+
return Ui(e, {
|
|
305
|
+
...Ce(t, {
|
|
306
|
+
min: 2,
|
|
307
|
+
max: 2
|
|
308
|
+
}),
|
|
309
|
+
style: "currency",
|
|
310
|
+
currency: t.currency || "USD"
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function Ca(e, t = {}) {
|
|
314
|
+
const n = Dn(t, { min: 1, max: 1 }), i = typeof t.multiplyBy == "number" && Number.isFinite(t.multiplyBy) ? t.multiplyBy : t.percentValueMode === "whole" ? 1 : 100, o = e * i;
|
|
315
|
+
return Be(o, {
|
|
316
|
+
locale: t.locale,
|
|
317
|
+
minimumFractionDigits: n.minimumFractionDigits,
|
|
318
|
+
maximumFractionDigits: n.maximumFractionDigits,
|
|
319
|
+
useGrouping: t.useGrouping,
|
|
320
|
+
prefix: t.prefix,
|
|
321
|
+
suffix: t.suffix || "%",
|
|
322
|
+
negativeInParentheses: t.negativeInParentheses,
|
|
323
|
+
useSuffix: !1
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function Fa(e, t = {}) {
|
|
327
|
+
const { locale: n = "en-US" } = t;
|
|
328
|
+
try {
|
|
329
|
+
const r = new Date(e);
|
|
330
|
+
return isNaN(r.getTime()) ? String(e) : new Intl.DateTimeFormat(n, {
|
|
331
|
+
dateStyle: "short"
|
|
332
|
+
}).format(r);
|
|
333
|
+
} catch {
|
|
334
|
+
return String(e);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function Sa(e, t = {}) {
|
|
338
|
+
return Bi(
|
|
339
|
+
e,
|
|
340
|
+
Ce(t, { min: 2, max: 2 })
|
|
341
|
+
);
|
|
342
|
+
}
|
|
343
|
+
function xa(e, t = {}) {
|
|
344
|
+
return qi(e, {
|
|
345
|
+
inputUnit: t.durationInputUnit,
|
|
346
|
+
outputStyle: t.durationDisplayStyle,
|
|
347
|
+
largestUnit: t.durationLargestUnit,
|
|
348
|
+
smallestUnit: t.durationSmallestUnit,
|
|
349
|
+
maxUnits: t.durationMaxUnits,
|
|
350
|
+
prefix: t.prefix,
|
|
351
|
+
suffix: t.suffix,
|
|
352
|
+
negativeInParentheses: t.negativeInParentheses
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
function wa(e, t) {
|
|
356
|
+
return t.currency ? "currency" : typeof e == "string" && !isNaN(Date.parse(e)) ? "date" : "number";
|
|
357
|
+
}
|
|
358
|
+
function mc(e, t = {}) {
|
|
359
|
+
return (n) => st(n, e, t);
|
|
360
|
+
}
|
|
361
|
+
function Ta({
|
|
362
|
+
number: e,
|
|
363
|
+
decimalPlaces: t = 0,
|
|
364
|
+
useSuffix: n = !1,
|
|
365
|
+
customSuffix: r = "",
|
|
366
|
+
currency: i = "",
|
|
367
|
+
locale: o = "en-US"
|
|
368
|
+
}) {
|
|
369
|
+
if (i) {
|
|
370
|
+
const a = Mn(e, {
|
|
371
|
+
currency: i,
|
|
372
|
+
decimalPlaces: t,
|
|
373
|
+
locale: o,
|
|
374
|
+
useSuffix: n && !r
|
|
375
|
+
});
|
|
376
|
+
return n && r ? `${a}${r}` : a;
|
|
377
|
+
}
|
|
378
|
+
return kn(e, {
|
|
379
|
+
decimalPlaces: t,
|
|
380
|
+
useSuffix: n && !r,
|
|
381
|
+
suffix: r,
|
|
382
|
+
locale: o
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
var Da = function e(t, n) {
|
|
386
|
+
if (t === n) return !0;
|
|
387
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
388
|
+
if (t.constructor !== n.constructor) return !1;
|
|
389
|
+
var r, i, o;
|
|
390
|
+
if (Array.isArray(t)) {
|
|
391
|
+
if (r = t.length, r != n.length) return !1;
|
|
392
|
+
for (i = r; i-- !== 0; )
|
|
393
|
+
if (!e(t[i], n[i])) return !1;
|
|
394
|
+
return !0;
|
|
395
|
+
}
|
|
396
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
397
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
398
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
399
|
+
if (o = Object.keys(t), r = o.length, r !== Object.keys(n).length) return !1;
|
|
400
|
+
for (i = r; i-- !== 0; )
|
|
401
|
+
if (!Object.prototype.hasOwnProperty.call(n, o[i])) return !1;
|
|
402
|
+
for (i = r; i-- !== 0; ) {
|
|
403
|
+
var a = o[i];
|
|
404
|
+
if (!(a === "_owner" && t.$$typeof) && !e(t[a], n[a]))
|
|
405
|
+
return !1;
|
|
406
|
+
}
|
|
407
|
+
return !0;
|
|
408
|
+
}
|
|
409
|
+
return t !== t && n !== n;
|
|
410
|
+
};
|
|
411
|
+
const Fe = /* @__PURE__ */ sa(Da);
|
|
412
|
+
function ct(e, t) {
|
|
413
|
+
var n;
|
|
414
|
+
if (t.id)
|
|
415
|
+
return (n = e.sql) != null && n.trim() ? { kind: "column", columnKey: t.id } : { kind: "metric", metricId: t.id };
|
|
416
|
+
}
|
|
417
|
+
function On(e) {
|
|
418
|
+
const t = e.context.preferences;
|
|
419
|
+
if (!t)
|
|
420
|
+
return e.authoredFormat;
|
|
421
|
+
const n = ct(e.card, e.metric);
|
|
422
|
+
return _(
|
|
423
|
+
e.authoredFormat,
|
|
424
|
+
t,
|
|
425
|
+
n ? e.context.resolveBoundCurrency(n) : void 0
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
function ka(e) {
|
|
429
|
+
const t = H(e.card)[e.columnKey], n = (t == null ? void 0 : t.type) === "number" ? gr(
|
|
430
|
+
{ dataType: "number", format: void 0 },
|
|
431
|
+
t
|
|
432
|
+
) : void 0, r = n == null ? void 0 : n.authoredFormat, i = N(r) ? On({
|
|
433
|
+
card: e.card,
|
|
434
|
+
metric: {
|
|
435
|
+
id: e.columnKey
|
|
436
|
+
},
|
|
437
|
+
context: e.context,
|
|
438
|
+
authoredFormat: r
|
|
439
|
+
}) : void 0;
|
|
440
|
+
return {
|
|
441
|
+
id: e.columnKey,
|
|
442
|
+
name: e.columnKey,
|
|
443
|
+
label: e.columnKey,
|
|
444
|
+
alias: e.columnKey,
|
|
445
|
+
dataType: "number",
|
|
446
|
+
role: "metric",
|
|
447
|
+
format: i
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
function pc(e) {
|
|
451
|
+
const t = new Set(
|
|
452
|
+
Pr(e.records)
|
|
453
|
+
), n = new Set(
|
|
454
|
+
e.renderedMetricKeys || e.resultKeys
|
|
455
|
+
), r = H(e.card);
|
|
456
|
+
return e.resultKeys.filter(
|
|
457
|
+
(i) => {
|
|
458
|
+
var o;
|
|
459
|
+
return n.has(i) && (t.has(i) || ((o = r[i]) == null ? void 0 : o.type) === "number");
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
function gc(e) {
|
|
464
|
+
var o, a;
|
|
465
|
+
const { card: t, context: n } = e;
|
|
466
|
+
if (!(n != null && n.preferences) || !sn(t.type))
|
|
467
|
+
return t;
|
|
468
|
+
const r = n.preferences, i = (o = t.sql) != null && o.trim() ? e.resultMetricKeys.map(
|
|
469
|
+
(s) => ka({
|
|
470
|
+
card: t,
|
|
471
|
+
columnKey: s,
|
|
472
|
+
context: n
|
|
473
|
+
})
|
|
474
|
+
) : (((a = t.config) == null ? void 0 : a.metricColumns) || []).map((s) => {
|
|
475
|
+
const c = rn(t, s), l = c.authoredFormat;
|
|
476
|
+
if (!N(l))
|
|
477
|
+
return s;
|
|
478
|
+
const d = ct(t, s), u = d ? n.resolveBoundCurrency(d) : void 0;
|
|
479
|
+
return c.source === "inferred" && !u ? s : {
|
|
480
|
+
...s,
|
|
481
|
+
format: c.source === "inferred" ? _(
|
|
482
|
+
l,
|
|
483
|
+
r,
|
|
484
|
+
u
|
|
485
|
+
) : On({
|
|
486
|
+
card: t,
|
|
487
|
+
metric: s,
|
|
488
|
+
context: n,
|
|
489
|
+
authoredFormat: l
|
|
490
|
+
})
|
|
491
|
+
};
|
|
492
|
+
});
|
|
493
|
+
return {
|
|
494
|
+
...t,
|
|
495
|
+
config: {
|
|
496
|
+
...t.config || {},
|
|
497
|
+
metricColumns: i
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
function De(e) {
|
|
502
|
+
var c;
|
|
503
|
+
const { card: t, context: n, formatOptions: r } = e, i = n == null ? void 0 : n.preferences;
|
|
504
|
+
if (!t || !i || !sn(t.type))
|
|
505
|
+
return r;
|
|
506
|
+
if (!r) {
|
|
507
|
+
const l = e.metrics.filter(
|
|
508
|
+
(u) => !!u
|
|
509
|
+
), d = l.some(
|
|
510
|
+
(u) => N(u.format)
|
|
511
|
+
);
|
|
512
|
+
return l.length < 2 || !d ? r : U(
|
|
513
|
+
_({ type: "number" }, i),
|
|
514
|
+
{ preserveOmittedProperties: !0 }
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
if ((c = t.sql) != null && c.trim()) {
|
|
518
|
+
const l = e.metrics.filter(
|
|
519
|
+
(u) => !!u
|
|
520
|
+
), d = l.filter(
|
|
521
|
+
(u) => N(u.format)
|
|
522
|
+
);
|
|
523
|
+
if (d.length === 0)
|
|
524
|
+
return r;
|
|
525
|
+
if (d.length !== l.length)
|
|
526
|
+
return U(
|
|
527
|
+
_({ type: "number" }, i),
|
|
528
|
+
{ preserveOmittedProperties: !0 }
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
const o = ve(r, {
|
|
532
|
+
preserveOmittedProperties: !0
|
|
533
|
+
});
|
|
534
|
+
if (!N(o))
|
|
535
|
+
return r;
|
|
536
|
+
const a = e.metrics.flatMap((l) => {
|
|
537
|
+
if (!l)
|
|
538
|
+
return [];
|
|
539
|
+
const d = ct(t, l);
|
|
540
|
+
return [
|
|
541
|
+
_(
|
|
542
|
+
o,
|
|
543
|
+
i,
|
|
544
|
+
d ? n.resolveBoundCurrency(d) : void 0
|
|
545
|
+
)
|
|
546
|
+
];
|
|
547
|
+
});
|
|
548
|
+
if (a.length === 0)
|
|
549
|
+
return U(
|
|
550
|
+
_(o, i),
|
|
551
|
+
{ preserveOmittedProperties: !0 }
|
|
552
|
+
);
|
|
553
|
+
const [s] = a;
|
|
554
|
+
if (a.some((l) => !Fe(l, s))) {
|
|
555
|
+
const l = _(
|
|
556
|
+
{
|
|
557
|
+
...o,
|
|
558
|
+
type: "number",
|
|
559
|
+
currency: void 0
|
|
560
|
+
},
|
|
561
|
+
i
|
|
562
|
+
);
|
|
563
|
+
return U(l, {
|
|
564
|
+
preserveOmittedProperties: !0
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
return U(s, {
|
|
568
|
+
preserveOmittedProperties: !0
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function ze(e) {
|
|
572
|
+
return e ? Object.entries(e).some(([t, n]) => n == null || n === "" ? !1 : t === "type" ? n !== "auto" : !0) : !1;
|
|
573
|
+
}
|
|
574
|
+
function _n(e) {
|
|
575
|
+
if (e)
|
|
576
|
+
return e.alias || e.label || e.name;
|
|
577
|
+
}
|
|
578
|
+
function je(e, t) {
|
|
579
|
+
var r;
|
|
580
|
+
return (((r = e == null ? void 0 : e.config) == null ? void 0 : r.metricColumns) || []).find((i) => {
|
|
581
|
+
const o = _n(i);
|
|
582
|
+
return t.metricId && i.id === t.metricId || t.metricAlias && o === t.metricAlias || t.metricAlias && i.alias === t.metricAlias || t.columnId && o === t.columnId || t.columnId && i.alias === t.columnId || t.columnId && i.label === t.columnId || t.columnId && i.name === t.columnId;
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function le(e, t) {
|
|
586
|
+
var r, i;
|
|
587
|
+
const n = Ar(e, t);
|
|
588
|
+
if (!(n && ((i = (r = e == null ? void 0 : e.config) == null ? void 0 : r.groupByColumns) != null && i.includes(n)) && !Nr(n)))
|
|
589
|
+
return n;
|
|
590
|
+
}
|
|
591
|
+
function Ma(e) {
|
|
592
|
+
return !!e && !(e != null && e.format) && ce(e == null ? void 0 : e.dataType) === "number";
|
|
593
|
+
}
|
|
594
|
+
const Oa = {
|
|
595
|
+
style: "decimal"
|
|
596
|
+
};
|
|
597
|
+
function Pn(e) {
|
|
598
|
+
if (!e)
|
|
599
|
+
return;
|
|
600
|
+
const t = ot();
|
|
601
|
+
return {
|
|
602
|
+
...t,
|
|
603
|
+
...e,
|
|
604
|
+
inheritMetricFormat: e.numberFormat ? e.inheritMetricFormat : e.inheritMetricFormat ?? t.inheritMetricFormat,
|
|
605
|
+
numberFormat: {
|
|
606
|
+
...Oa,
|
|
607
|
+
...e.numberFormat
|
|
608
|
+
},
|
|
609
|
+
dateFormat: {
|
|
610
|
+
...t.dateFormat,
|
|
611
|
+
...e.dateFormat
|
|
612
|
+
},
|
|
613
|
+
linkFormat: {
|
|
614
|
+
...t.linkFormat,
|
|
615
|
+
...e.linkFormat
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
function hc(e) {
|
|
620
|
+
return Object.fromEntries(
|
|
621
|
+
Object.entries(e || {}).map(([t, n]) => [
|
|
622
|
+
t,
|
|
623
|
+
Pn(n)
|
|
624
|
+
])
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
function fe(e) {
|
|
628
|
+
return !!(e && typeof e == "object" && !Array.isArray(e) && Object.getPrototypeOf(e) === Object.prototype);
|
|
629
|
+
}
|
|
630
|
+
function An(e, t, n) {
|
|
631
|
+
if (!fe(n))
|
|
632
|
+
return n;
|
|
633
|
+
const r = fe(e) ? e : {}, i = fe(t) ? t : {}, o = {};
|
|
634
|
+
for (const a of Object.keys(n)) {
|
|
635
|
+
const s = n[a];
|
|
636
|
+
if (s === void 0)
|
|
637
|
+
continue;
|
|
638
|
+
const c = Object.prototype.hasOwnProperty.call(
|
|
639
|
+
r,
|
|
640
|
+
a
|
|
641
|
+
), l = i[a];
|
|
642
|
+
if (c && Fe(s, l)) {
|
|
643
|
+
o[a] = r[a];
|
|
644
|
+
continue;
|
|
645
|
+
}
|
|
646
|
+
if (!c && Fe(s, l))
|
|
647
|
+
continue;
|
|
648
|
+
const d = An(
|
|
649
|
+
r[a],
|
|
650
|
+
l,
|
|
651
|
+
s
|
|
652
|
+
);
|
|
653
|
+
fe(d) && Object.keys(d).length === 0 && !c || (o[a] = d);
|
|
654
|
+
}
|
|
655
|
+
return o;
|
|
656
|
+
}
|
|
657
|
+
function yc(e) {
|
|
658
|
+
let t = An(
|
|
659
|
+
e.persisted,
|
|
660
|
+
e.baseline,
|
|
661
|
+
e.next
|
|
662
|
+
);
|
|
663
|
+
if (e.enforceDeclaredSqlTemporalFormat && e.next.type === "date" && !e.next.dateFormat.useRelativeTime && e.next.dateFormat.useCustomFormat) {
|
|
664
|
+
const n = e.next.dateFormat.customFormat;
|
|
665
|
+
if (!(n != null && n.trim()))
|
|
666
|
+
throw new zi(
|
|
667
|
+
"invalid_raw_temporal_format",
|
|
668
|
+
"Custom table date formatting requires a non-empty pattern."
|
|
669
|
+
);
|
|
670
|
+
ji({
|
|
671
|
+
dialect: "date_fns",
|
|
672
|
+
pattern: n,
|
|
673
|
+
valueKind: e.rawTemporalValueKind
|
|
674
|
+
}), t = {
|
|
675
|
+
...t,
|
|
676
|
+
dateFormat: {
|
|
677
|
+
...t.dateFormat,
|
|
678
|
+
useCustomFormat: !0,
|
|
679
|
+
customFormat: n
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
return e.next.type === "number" && !Fe(e.next.numberFormat, e.baseline.numberFormat) && t.numberFormat ? {
|
|
684
|
+
...t,
|
|
685
|
+
type: "number",
|
|
686
|
+
inheritMetricFormat: e.next.inheritMetricFormat ?? !1
|
|
687
|
+
} : e.next.type === "number" && e.baseline.inheritMetricFormat === !0 && e.next.inheritMetricFormat === !1 ? {
|
|
688
|
+
...t,
|
|
689
|
+
type: "number",
|
|
690
|
+
inheritMetricFormat: !1
|
|
691
|
+
} : e.forcePersistDateType && e.next.type === "date" ? {
|
|
692
|
+
...t,
|
|
693
|
+
type: "date"
|
|
694
|
+
} : t;
|
|
695
|
+
}
|
|
696
|
+
function _a(e, t) {
|
|
697
|
+
const n = e || ot(), r = !t;
|
|
698
|
+
return {
|
|
699
|
+
...n,
|
|
700
|
+
type: "number",
|
|
701
|
+
textAlign: n.type === "none" ? "right" : n.textAlign,
|
|
702
|
+
numberFormat: {
|
|
703
|
+
style: "decimal",
|
|
704
|
+
minimumFractionDigits: r ? n.numberFormat.minimumFractionDigits : void 0,
|
|
705
|
+
maximumFractionDigits: r ? n.numberFormat.maximumFractionDigits : void 0,
|
|
706
|
+
useGrouping: n.numberFormat.useGrouping
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function Ne(e) {
|
|
711
|
+
if (e)
|
|
712
|
+
return e.trim().toLowerCase();
|
|
713
|
+
}
|
|
714
|
+
const Nn = /\s*(?:\((?:previous|last year|start|target|comparison)\)|δ)\s*$/i;
|
|
715
|
+
function Pa(e) {
|
|
716
|
+
const t = e == null ? void 0 : e.trim();
|
|
717
|
+
return t ? t.replace(Nn, "").trim() || t : void 0;
|
|
718
|
+
}
|
|
719
|
+
function Aa(e) {
|
|
720
|
+
const t = e == null ? void 0 : e.trim();
|
|
721
|
+
return t ? Nn.test(t) : !1;
|
|
722
|
+
}
|
|
723
|
+
function Na(e, t) {
|
|
724
|
+
return t.metricAlias ? e.find(
|
|
725
|
+
(n) => Ri(n) === t.metricAlias
|
|
726
|
+
) : t.metricId ? e.find((n) => n.id === t.metricId) : void 0;
|
|
727
|
+
}
|
|
728
|
+
function Ea(e) {
|
|
729
|
+
var y;
|
|
730
|
+
const {
|
|
731
|
+
card: t,
|
|
732
|
+
metricId: n,
|
|
733
|
+
metricAlias: r,
|
|
734
|
+
datasetIndex: i,
|
|
735
|
+
datasetLabel: o,
|
|
736
|
+
metricKey: a
|
|
737
|
+
} = e, s = ((y = t == null ? void 0 : t.config) == null ? void 0 : y.metricColumns) || [];
|
|
738
|
+
if (r || n)
|
|
739
|
+
return Na(s, {
|
|
740
|
+
metricAlias: r,
|
|
741
|
+
metricId: n
|
|
742
|
+
});
|
|
743
|
+
const c = [a, o], l = c.some(
|
|
744
|
+
(g) => Aa(g)
|
|
745
|
+
), d = c.filter(
|
|
746
|
+
(g) => !!g
|
|
747
|
+
);
|
|
748
|
+
for (const g of d) {
|
|
749
|
+
const h = je(t, {
|
|
750
|
+
columnId: g,
|
|
751
|
+
metricAlias: g
|
|
752
|
+
});
|
|
753
|
+
if (h)
|
|
754
|
+
return h;
|
|
755
|
+
}
|
|
756
|
+
const u = d.map((g) => Ne(g)).filter((g) => !!g), f = d.map((g) => Pa(g)).filter((g) => !!g);
|
|
757
|
+
for (const g of f) {
|
|
758
|
+
const h = je(t, {
|
|
759
|
+
columnId: g,
|
|
760
|
+
metricAlias: g
|
|
761
|
+
});
|
|
762
|
+
if (h)
|
|
763
|
+
return h;
|
|
764
|
+
}
|
|
765
|
+
if (s.length === 1)
|
|
766
|
+
return s[0];
|
|
767
|
+
if (!l && typeof i == "number" && i >= 0 && i < s.length)
|
|
768
|
+
return s[i];
|
|
769
|
+
const m = f.map((g) => Ne(g)).filter((g) => !!g), p = [
|
|
770
|
+
...u,
|
|
771
|
+
...m
|
|
772
|
+
];
|
|
773
|
+
if (p.length !== 0)
|
|
774
|
+
return s.find((g) => {
|
|
775
|
+
const h = [
|
|
776
|
+
g.alias,
|
|
777
|
+
g.label,
|
|
778
|
+
g.name,
|
|
779
|
+
_n(g)
|
|
780
|
+
].map((C) => Ne(C)).filter((C) => !!C);
|
|
781
|
+
return p.some(
|
|
782
|
+
(C) => h.includes(C)
|
|
783
|
+
);
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
function $a(e) {
|
|
787
|
+
const t = Q(e == null ? void 0 : e.format);
|
|
788
|
+
return U(t);
|
|
789
|
+
}
|
|
790
|
+
function Vt(e, t) {
|
|
791
|
+
if (t)
|
|
792
|
+
return je(e, {
|
|
793
|
+
columnId: t,
|
|
794
|
+
metricAlias: t
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function Lt(e) {
|
|
798
|
+
const t = ve(e);
|
|
799
|
+
if (t)
|
|
800
|
+
return JSON.stringify(t);
|
|
801
|
+
}
|
|
802
|
+
function Ra(e, t) {
|
|
803
|
+
const n = Lt(e), r = Lt(t);
|
|
804
|
+
return !!(n && r && n === r);
|
|
805
|
+
}
|
|
806
|
+
function Ka(e) {
|
|
807
|
+
if (e.length === 0)
|
|
808
|
+
return;
|
|
809
|
+
const t = e.map(
|
|
810
|
+
(a) => $a(a)
|
|
811
|
+
);
|
|
812
|
+
if (!t.every(
|
|
813
|
+
(a) => ze(a)
|
|
814
|
+
))
|
|
815
|
+
return;
|
|
816
|
+
const r = t, [i] = r;
|
|
817
|
+
return r.every(
|
|
818
|
+
(a) => Ra(i, a)
|
|
819
|
+
) ? i : void 0;
|
|
820
|
+
}
|
|
821
|
+
function ke(e) {
|
|
822
|
+
if (ze(e.overrideFormatOptions))
|
|
823
|
+
return {
|
|
824
|
+
formatOptions: e.overrideFormatOptions || void 0,
|
|
825
|
+
source: "override"
|
|
826
|
+
};
|
|
827
|
+
const t = Ka(
|
|
828
|
+
e.metrics || []
|
|
829
|
+
);
|
|
830
|
+
return ze(t) ? {
|
|
831
|
+
formatOptions: t,
|
|
832
|
+
source: "metric"
|
|
833
|
+
} : {
|
|
834
|
+
formatOptions: void 0,
|
|
835
|
+
source: "auto"
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
function En(e) {
|
|
839
|
+
var c, l, d;
|
|
840
|
+
const { card: t, chartType: n, axis: r, preferences: i } = e, o = ((c = t == null ? void 0 : t.config) == null ? void 0 : c.metricColumns) || [], a = (i == null ? void 0 : i.datasetOptions) || [];
|
|
841
|
+
if (!o.length)
|
|
842
|
+
return [];
|
|
843
|
+
if (n === "combo")
|
|
844
|
+
return r === "x" ? [] : o.filter((u, f) => {
|
|
845
|
+
const m = a.find((y) => y.idx === f);
|
|
846
|
+
return ((m == null ? void 0 : m.yAxisId) === "y2" ? "y2" : "y") === r;
|
|
847
|
+
});
|
|
848
|
+
if (n === "bubble" || n === "scatter") {
|
|
849
|
+
if (r === "y2")
|
|
850
|
+
return [];
|
|
851
|
+
const u = Vt(
|
|
852
|
+
t,
|
|
853
|
+
(l = i == null ? void 0 : i.bubbleScatterConfig) == null ? void 0 : l.xMetricKey
|
|
854
|
+
) || o[0], f = Vt(
|
|
855
|
+
t,
|
|
856
|
+
(d = i == null ? void 0 : i.bubbleScatterConfig) == null ? void 0 : d.yMetricKey
|
|
857
|
+
) || o[1] || o[0];
|
|
858
|
+
return r === "x" ? u ? [u] : [] : f ? [f] : [];
|
|
859
|
+
}
|
|
860
|
+
const s = Qe(n, i);
|
|
861
|
+
return n === "radar" ? r === "y" ? o : [] : r !== s ? [] : o;
|
|
862
|
+
}
|
|
863
|
+
function lt(e) {
|
|
864
|
+
const { card: t, chartType: n, axis: r, preferences: i, axisConfig: o } = e, a = En({
|
|
865
|
+
card: t,
|
|
866
|
+
chartType: n,
|
|
867
|
+
axis: r,
|
|
868
|
+
preferences: i
|
|
869
|
+
}), s = ke({
|
|
870
|
+
overrideFormatOptions: Te(o == null ? void 0 : o.valueFormat),
|
|
871
|
+
metrics: a
|
|
872
|
+
});
|
|
873
|
+
return {
|
|
874
|
+
...s,
|
|
875
|
+
formatOptions: De({
|
|
876
|
+
card: t,
|
|
877
|
+
metrics: a,
|
|
878
|
+
formatOptions: s.formatOptions,
|
|
879
|
+
context: e.numericPresentation
|
|
880
|
+
})
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
function Va(e) {
|
|
884
|
+
const { preferences: t, metric: n } = e, r = t == null ? void 0 : t.tooltipConfig, i = ke({
|
|
885
|
+
overrideFormatOptions: Te(r == null ? void 0 : r.valueFormat),
|
|
886
|
+
metrics: n ? [n] : []
|
|
887
|
+
});
|
|
888
|
+
return {
|
|
889
|
+
...i,
|
|
890
|
+
formatOptions: De({
|
|
891
|
+
card: e.card,
|
|
892
|
+
metrics: e.metric ? [e.metric] : [],
|
|
893
|
+
formatOptions: i.formatOptions,
|
|
894
|
+
context: e.numericPresentation
|
|
895
|
+
})
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
function dt(e, t, n) {
|
|
899
|
+
return t === Qe(n, e) ? Er(n, e) : t === "x" ? e == null ? void 0 : e.xAxisConfig : t === "y2" ? e == null ? void 0 : e.secondaryYAxisConfig : e == null ? void 0 : e.yAxisConfig;
|
|
900
|
+
}
|
|
901
|
+
function ut(e) {
|
|
902
|
+
const { chartType: t, preferences: n } = e;
|
|
903
|
+
return t === "bubble" || t === "scatter" ? "y" : Qe(t, n);
|
|
904
|
+
}
|
|
905
|
+
function $n(e) {
|
|
906
|
+
switch (e) {
|
|
907
|
+
case "pie":
|
|
908
|
+
case "doughnut":
|
|
909
|
+
case "polarArea":
|
|
910
|
+
case "funnel":
|
|
911
|
+
case "treemap":
|
|
912
|
+
case "heatmap":
|
|
913
|
+
return !1;
|
|
914
|
+
default:
|
|
915
|
+
return !0;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function bc(e) {
|
|
919
|
+
const { card: t, chartType: n, preferences: r, metric: i } = e, o = Va({
|
|
920
|
+
card: t,
|
|
921
|
+
preferences: r,
|
|
922
|
+
metric: i,
|
|
923
|
+
numericPresentation: e.numericPresentation
|
|
924
|
+
});
|
|
925
|
+
if (o.source === "override")
|
|
926
|
+
return o;
|
|
927
|
+
const a = e.axis || ut({ chartType: n, preferences: r }), s = lt({
|
|
928
|
+
card: t,
|
|
929
|
+
chartType: n,
|
|
930
|
+
axis: a,
|
|
931
|
+
preferences: r,
|
|
932
|
+
axisConfig: dt(r, a, n),
|
|
933
|
+
numericPresentation: e.numericPresentation
|
|
934
|
+
});
|
|
935
|
+
return s.source === "override" ? s : o;
|
|
936
|
+
}
|
|
937
|
+
function vc(e) {
|
|
938
|
+
const { card: t, chartType: n, preferences: r, dataLabelsConfig: i } = e, o = n || (t == null ? void 0 : t.type), a = ut({
|
|
939
|
+
chartType: o,
|
|
940
|
+
preferences: r
|
|
941
|
+
}), s = En({
|
|
942
|
+
card: t,
|
|
943
|
+
chartType: o,
|
|
944
|
+
axis: a,
|
|
945
|
+
preferences: r
|
|
946
|
+
}), c = ke({
|
|
947
|
+
overrideFormatOptions: Te(i == null ? void 0 : i.valueFormat),
|
|
948
|
+
metrics: s
|
|
949
|
+
}), l = {
|
|
950
|
+
...c,
|
|
951
|
+
formatOptions: De({
|
|
952
|
+
card: t,
|
|
953
|
+
metrics: s,
|
|
954
|
+
formatOptions: c.formatOptions,
|
|
955
|
+
context: e.numericPresentation
|
|
956
|
+
})
|
|
957
|
+
};
|
|
958
|
+
if (l.source === "override" || !$n(o))
|
|
959
|
+
return l;
|
|
960
|
+
const d = lt({
|
|
961
|
+
card: t,
|
|
962
|
+
chartType: o,
|
|
963
|
+
axis: a,
|
|
964
|
+
preferences: r,
|
|
965
|
+
axisConfig: dt(
|
|
966
|
+
r,
|
|
967
|
+
a,
|
|
968
|
+
o
|
|
969
|
+
),
|
|
970
|
+
numericPresentation: e.numericPresentation
|
|
971
|
+
});
|
|
972
|
+
return d.source === "override" ? d : l;
|
|
973
|
+
}
|
|
974
|
+
function La(e) {
|
|
975
|
+
const { preferences: t, dataLabelsConfig: n, metric: r } = e, i = ke({
|
|
976
|
+
overrideFormatOptions: Te(n == null ? void 0 : n.valueFormat),
|
|
977
|
+
metrics: r ? [r] : []
|
|
978
|
+
});
|
|
979
|
+
return {
|
|
980
|
+
...i,
|
|
981
|
+
formatOptions: De({
|
|
982
|
+
card: e.card,
|
|
983
|
+
metrics: e.metric ? [e.metric] : [],
|
|
984
|
+
formatOptions: i.formatOptions,
|
|
985
|
+
context: e.numericPresentation
|
|
986
|
+
})
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
function Ic(e) {
|
|
990
|
+
var a, s;
|
|
991
|
+
const t = Ea({
|
|
992
|
+
card: e.card,
|
|
993
|
+
metricId: e.metricId,
|
|
994
|
+
metricAlias: e.metricAlias,
|
|
995
|
+
datasetIndex: e.datasetIndex,
|
|
996
|
+
datasetLabel: e.datasetLabel,
|
|
997
|
+
metricKey: e.metricKey
|
|
998
|
+
}), n = La({
|
|
999
|
+
card: e.card,
|
|
1000
|
+
preferences: e.preferences,
|
|
1001
|
+
dataLabelsConfig: e.dataLabelsConfig,
|
|
1002
|
+
metric: t,
|
|
1003
|
+
numericPresentation: e.numericPresentation
|
|
1004
|
+
});
|
|
1005
|
+
if (n.source === "override")
|
|
1006
|
+
return n;
|
|
1007
|
+
const r = (a = e.card) == null ? void 0 : a.type;
|
|
1008
|
+
if (!$n(r))
|
|
1009
|
+
return n;
|
|
1010
|
+
let i = ut({
|
|
1011
|
+
chartType: r,
|
|
1012
|
+
preferences: e.preferences
|
|
1013
|
+
});
|
|
1014
|
+
if (r === "combo" && typeof e.datasetIndex == "number") {
|
|
1015
|
+
const l = (((s = e.preferences) == null ? void 0 : s.datasetOptions) || []).find(
|
|
1016
|
+
(d) => d.idx === e.datasetIndex
|
|
1017
|
+
);
|
|
1018
|
+
i = (l == null ? void 0 : l.yAxisId) === "y2" ? "y2" : "y";
|
|
1019
|
+
}
|
|
1020
|
+
const o = lt({
|
|
1021
|
+
card: e.card,
|
|
1022
|
+
chartType: r,
|
|
1023
|
+
axis: i,
|
|
1024
|
+
preferences: e.preferences,
|
|
1025
|
+
axisConfig: dt(
|
|
1026
|
+
e.preferences,
|
|
1027
|
+
i,
|
|
1028
|
+
r
|
|
1029
|
+
),
|
|
1030
|
+
numericPresentation: e.numericPresentation
|
|
1031
|
+
});
|
|
1032
|
+
return o.source === "override" ? o : n;
|
|
1033
|
+
}
|
|
1034
|
+
function Cc(e) {
|
|
1035
|
+
return (e == null ? void 0 : e.rawValue) === !0;
|
|
1036
|
+
}
|
|
1037
|
+
function qa(e) {
|
|
1038
|
+
const t = e == null ? void 0 : e.numberFormat;
|
|
1039
|
+
if (!t)
|
|
1040
|
+
return;
|
|
1041
|
+
if (t.style === "duration")
|
|
1042
|
+
return U(Xe(t), {
|
|
1043
|
+
preserveOmittedProperties: !0
|
|
1044
|
+
});
|
|
1045
|
+
const n = t.style === "currency" ? "currency" : t.style === "percent" ? "percent" : t.style === "scientific" ? "scientific" : "number", r = t.minimumFractionDigits, i = t.maximumFractionDigits;
|
|
1046
|
+
return {
|
|
1047
|
+
type: n,
|
|
1048
|
+
currency: n === "currency" ? t.currency : void 0,
|
|
1049
|
+
locale: t.locale,
|
|
1050
|
+
decimalPlaces: r === i ? i : void 0,
|
|
1051
|
+
minimumFractionDigits: r,
|
|
1052
|
+
maximumFractionDigits: i,
|
|
1053
|
+
useGrouping: t.useGrouping,
|
|
1054
|
+
percentValueMode: n === "percent" ? t.percentValueMode : void 0,
|
|
1055
|
+
multiplyBy: t.scale,
|
|
1056
|
+
useSuffix: t.compact,
|
|
1057
|
+
negativeInParentheses: t.negativeStyle === "parentheses",
|
|
1058
|
+
prefix: t.prefix,
|
|
1059
|
+
suffix: t.suffix
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
function Ba(e, t, n = !1) {
|
|
1063
|
+
const r = n ? { preserveOmittedProperties: !0 } : void 0, i = Q(e == null ? void 0 : e.format, r), o = wn(
|
|
1064
|
+
i,
|
|
1065
|
+
r
|
|
1066
|
+
);
|
|
1067
|
+
if (!o)
|
|
1068
|
+
return;
|
|
1069
|
+
const a = t || ot(), s = n ? void 0 : a.numberFormat, c = a.type && a.type !== "none";
|
|
1070
|
+
return {
|
|
1071
|
+
...a,
|
|
1072
|
+
type: c ? a.type : "number",
|
|
1073
|
+
// A column's own format (an override) shows as its own, not the measure's
|
|
1074
|
+
// (column formats CF-D20, ledger P5-42).
|
|
1075
|
+
inheritMetricFormat: (e == null ? void 0 : e.formatOrigin) === "override" ? !1 : a.inheritMetricFormat ?? !0,
|
|
1076
|
+
textAlign: c ? a.textAlign : "right",
|
|
1077
|
+
numberFormat: {
|
|
1078
|
+
...s,
|
|
1079
|
+
...o
|
|
1080
|
+
}
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
function Rn(e) {
|
|
1084
|
+
var D;
|
|
1085
|
+
const {
|
|
1086
|
+
card: t,
|
|
1087
|
+
columnId: n,
|
|
1088
|
+
persistedSettings: r,
|
|
1089
|
+
resolvedSettings: i,
|
|
1090
|
+
fallbackSettings: o,
|
|
1091
|
+
metricId: a,
|
|
1092
|
+
metricAlias: s,
|
|
1093
|
+
fieldId: c,
|
|
1094
|
+
fieldRole: l,
|
|
1095
|
+
columnKeyMap: d,
|
|
1096
|
+
valueFormatPreferences: u,
|
|
1097
|
+
boundCurrency: f,
|
|
1098
|
+
preserveOmittedProperties: m
|
|
1099
|
+
} = e, p = r ?? H(t)[n], y = !((D = t == null ? void 0 : t.sql) != null && D.trim()) || hr(p), g = y ? u : null, h = y ? f : void 0, C = i ?? Pn(p);
|
|
1100
|
+
if (C && C.inheritMetricFormat !== !0)
|
|
1101
|
+
return qt(
|
|
1102
|
+
C,
|
|
1103
|
+
g,
|
|
1104
|
+
h
|
|
1105
|
+
);
|
|
1106
|
+
const v = le(t, {
|
|
1107
|
+
columnId: n,
|
|
1108
|
+
metricId: a,
|
|
1109
|
+
metricAlias: s,
|
|
1110
|
+
columnKeyMap: d,
|
|
1111
|
+
fieldId: c,
|
|
1112
|
+
fieldRole: l
|
|
1113
|
+
}), b = Ba(
|
|
1114
|
+
v,
|
|
1115
|
+
C || o,
|
|
1116
|
+
m ?? !!u
|
|
1117
|
+
), S = !b && g && Ma(v) ? _a(
|
|
1118
|
+
C || o,
|
|
1119
|
+
h
|
|
1120
|
+
) : void 0;
|
|
1121
|
+
return qt(
|
|
1122
|
+
b || S || C || o,
|
|
1123
|
+
g,
|
|
1124
|
+
h
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
function qt(e, t, n) {
|
|
1128
|
+
if (!e || e.type !== "number" || !t)
|
|
1129
|
+
return e;
|
|
1130
|
+
const r = e.numberFormat, i = r ? Xe(r, {
|
|
1131
|
+
preserveOmittedProperties: !0
|
|
1132
|
+
}) : { type: "number" };
|
|
1133
|
+
if (!i || !N(i))
|
|
1134
|
+
return e;
|
|
1135
|
+
const o = _(
|
|
1136
|
+
i,
|
|
1137
|
+
t,
|
|
1138
|
+
n
|
|
1139
|
+
), a = wn(o, {
|
|
1140
|
+
preserveOmittedProperties: !0
|
|
1141
|
+
});
|
|
1142
|
+
return a ? {
|
|
1143
|
+
...e,
|
|
1144
|
+
numberFormat: {
|
|
1145
|
+
...r,
|
|
1146
|
+
...a
|
|
1147
|
+
}
|
|
1148
|
+
} : e;
|
|
1149
|
+
}
|
|
1150
|
+
function Se(e) {
|
|
1151
|
+
if (!e.valueFormatPreferences)
|
|
1152
|
+
return;
|
|
1153
|
+
const t = Rn(e);
|
|
1154
|
+
if (!t || t.type !== "number")
|
|
1155
|
+
return;
|
|
1156
|
+
const n = Xe(t.numberFormat, {
|
|
1157
|
+
preserveOmittedProperties: !0
|
|
1158
|
+
});
|
|
1159
|
+
if (!(!n || !Gi(n)))
|
|
1160
|
+
return n;
|
|
1161
|
+
}
|
|
1162
|
+
function Ua(e) {
|
|
1163
|
+
var r, i;
|
|
1164
|
+
if (!e.presentation.preferences)
|
|
1165
|
+
return;
|
|
1166
|
+
const t = le(e.card, {
|
|
1167
|
+
columnId: e.columnId,
|
|
1168
|
+
metricId: e.metricId,
|
|
1169
|
+
metricAlias: e.metricAlias,
|
|
1170
|
+
columnKeyMap: e.columnKeyMap
|
|
1171
|
+
});
|
|
1172
|
+
if (e.comparisonValueKind === "percent_change" || e.comparisonValueKind === "ratio") {
|
|
1173
|
+
const o = Se({
|
|
1174
|
+
card: e.card,
|
|
1175
|
+
columnId: e.columnId,
|
|
1176
|
+
persistedSettings: e.persistedSettings,
|
|
1177
|
+
resolvedSettings: e.resolvedSettings,
|
|
1178
|
+
fallbackSettings: e.fallbackSettings,
|
|
1179
|
+
metricId: e.metricId,
|
|
1180
|
+
columnKeyMap: e.columnKeyMap,
|
|
1181
|
+
metricAlias: e.metricAlias ?? (t == null ? void 0 : t.alias),
|
|
1182
|
+
valueFormatPreferences: e.presentation.preferences
|
|
1183
|
+
}), a = Ji(e.comparisonPrecision) ?? (N(o) ? o.maximumFractionDigits : void 0) ?? (e.comparisonValueKind === "percent_change" ? 1 : 2);
|
|
1184
|
+
return e.comparisonValueKind === "percent_change" ? {
|
|
1185
|
+
type: "percent",
|
|
1186
|
+
locale: e.presentation.preferences.locale,
|
|
1187
|
+
percentValueMode: "fraction",
|
|
1188
|
+
minimumFractionDigits: a,
|
|
1189
|
+
maximumFractionDigits: a
|
|
1190
|
+
} : {
|
|
1191
|
+
type: "number",
|
|
1192
|
+
locale: e.presentation.preferences.locale,
|
|
1193
|
+
minimumFractionDigits: a,
|
|
1194
|
+
maximumFractionDigits: a,
|
|
1195
|
+
suffix: "×"
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
const n = yr({
|
|
1199
|
+
card: e.card,
|
|
1200
|
+
columnKey: e.columnId,
|
|
1201
|
+
metricId: e.metricId ?? (t && !((i = (r = e.card.config) == null ? void 0 : r.groupByColumns) != null && i.includes(t)) ? t.id : void 0)
|
|
1202
|
+
});
|
|
1203
|
+
return Se({
|
|
1204
|
+
card: e.card,
|
|
1205
|
+
columnId: e.columnId,
|
|
1206
|
+
persistedSettings: e.persistedSettings,
|
|
1207
|
+
resolvedSettings: e.resolvedSettings,
|
|
1208
|
+
fallbackSettings: e.fallbackSettings,
|
|
1209
|
+
metricId: e.metricId,
|
|
1210
|
+
columnKeyMap: e.columnKeyMap,
|
|
1211
|
+
metricAlias: e.metricAlias ?? (t == null ? void 0 : t.alias),
|
|
1212
|
+
valueFormatPreferences: e.presentation.preferences,
|
|
1213
|
+
boundCurrency: n ? e.presentation.resolveBoundCurrency(n) : void 0
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
function za(e) {
|
|
1217
|
+
var s, c, l, d, u;
|
|
1218
|
+
if (e.card.type === "matrixTable" && e.target.kind === "matrix_measure") {
|
|
1219
|
+
const f = e.target, m = br(e.card, e.matrixCatalog).find(
|
|
1220
|
+
(y) => y.measureId === f.measureId
|
|
1221
|
+
), p = m == null ? void 0 : m.canonical;
|
|
1222
|
+
return p && (p.type === "number" || p.type === "currency") ? _(
|
|
1223
|
+
p,
|
|
1224
|
+
e.valueFormatPreferences,
|
|
1225
|
+
e.boundCurrency
|
|
1226
|
+
) : void 0;
|
|
1227
|
+
}
|
|
1228
|
+
if (e.target.kind === "matrix_measure")
|
|
1229
|
+
return;
|
|
1230
|
+
if (e.card.type === "kpi") {
|
|
1231
|
+
const f = e.target.kind === "metric" ? e.target.metricId : void 0;
|
|
1232
|
+
if (f && !((c = (s = e.card.config) == null ? void 0 : s.metricColumns) != null && c.some(
|
|
1233
|
+
(y) => y.id === f
|
|
1234
|
+
)))
|
|
1235
|
+
return;
|
|
1236
|
+
const m = vr(e.card, {
|
|
1237
|
+
...f ? { column: { kind: "field", fieldId: f } } : {},
|
|
1238
|
+
resultColumnKey: e.target.kind === "column" ? e.target.columnKey : void 0
|
|
1239
|
+
}), p = m.authoredFormat;
|
|
1240
|
+
return m.currencyBindable && p && N(p) ? _(
|
|
1241
|
+
p,
|
|
1242
|
+
e.valueFormatPreferences,
|
|
1243
|
+
e.boundCurrency
|
|
1244
|
+
) : void 0;
|
|
1245
|
+
}
|
|
1246
|
+
if (!((l = e.card.sql) != null && l.trim()) && !$r(e.card.type) && e.target.kind === "metric") {
|
|
1247
|
+
const f = e.target.metricId, m = (u = (d = e.card.config) == null ? void 0 : d.metricColumns) == null ? void 0 : u.find(
|
|
1248
|
+
(g) => g.id === f
|
|
1249
|
+
);
|
|
1250
|
+
if (!m)
|
|
1251
|
+
return;
|
|
1252
|
+
const p = rn(
|
|
1253
|
+
e.card,
|
|
1254
|
+
m
|
|
1255
|
+
), y = p.authoredFormat;
|
|
1256
|
+
return p.currencyBindable && y && N(y) ? _(
|
|
1257
|
+
y,
|
|
1258
|
+
e.valueFormatPreferences,
|
|
1259
|
+
e.boundCurrency
|
|
1260
|
+
) : void 0;
|
|
1261
|
+
}
|
|
1262
|
+
const n = H(e.card), r = e.target.kind === "metric" ? e.target.metricId : void 0, i = e.target.kind === "column" ? [e.target.columnKey] : [
|
|
1263
|
+
...e.resultColumnKeys || [],
|
|
1264
|
+
...Object.keys(n),
|
|
1265
|
+
e.target.metricId
|
|
1266
|
+
], o = e.target.kind === "column" ? e.target.columnKey : i.find(
|
|
1267
|
+
(f) => {
|
|
1268
|
+
var m;
|
|
1269
|
+
return ((m = le(e.card, {
|
|
1270
|
+
columnId: f
|
|
1271
|
+
})) == null ? void 0 : m.id) === r;
|
|
1272
|
+
}
|
|
1273
|
+
) || r, a = Se({
|
|
1274
|
+
card: e.card,
|
|
1275
|
+
columnId: o,
|
|
1276
|
+
metricId: r,
|
|
1277
|
+
persistedSettings: n[o],
|
|
1278
|
+
valueFormatPreferences: e.valueFormatPreferences,
|
|
1279
|
+
boundCurrency: e.boundCurrency
|
|
1280
|
+
});
|
|
1281
|
+
return N(a) ? a : void 0;
|
|
1282
|
+
}
|
|
1283
|
+
function Fc(e) {
|
|
1284
|
+
var n, r;
|
|
1285
|
+
const t = e.persistedSettings ?? H(e.card)[e.columnId];
|
|
1286
|
+
if (!t && !e.resolvedSettings || (t == null ? void 0 : t.inheritMetricFormat) === !0 || ((n = e.resolvedSettings) == null ? void 0 : n.inheritMetricFormat) === !0) {
|
|
1287
|
+
const i = Q(
|
|
1288
|
+
(r = le(e.card, {
|
|
1289
|
+
columnId: e.columnId,
|
|
1290
|
+
metricId: e.metricId,
|
|
1291
|
+
metricAlias: e.metricAlias,
|
|
1292
|
+
columnKeyMap: e.columnKeyMap
|
|
1293
|
+
})) == null ? void 0 : r.format,
|
|
1294
|
+
{ preserveOmittedProperties: !0 }
|
|
1295
|
+
);
|
|
1296
|
+
if ((i == null ? void 0 : i.type) === "date" || (i == null ? void 0 : i.type) === "duration")
|
|
1297
|
+
return U(i, {
|
|
1298
|
+
preserveOmittedProperties: !0
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
return qa(
|
|
1302
|
+
Rn({
|
|
1303
|
+
...e,
|
|
1304
|
+
persistedSettings: t
|
|
1305
|
+
})
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
function Sc(e) {
|
|
1309
|
+
const { value: t, formatOptions: n, preferences: r } = e;
|
|
1310
|
+
return n != null && n.type && n.type !== "auto" ? st(t, n.type, n) : Ta({
|
|
1311
|
+
number: t,
|
|
1312
|
+
decimalPlaces: 0,
|
|
1313
|
+
useSuffix: !1,
|
|
1314
|
+
customSuffix: "",
|
|
1315
|
+
locale: "en-US",
|
|
1316
|
+
currency: ""
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
function ja(e) {
|
|
1320
|
+
return Rr({
|
|
1321
|
+
...e,
|
|
1322
|
+
activation: Je({
|
|
1323
|
+
card: e.card,
|
|
1324
|
+
cardConfig: e.cardConfig
|
|
1325
|
+
})
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
function xc(e) {
|
|
1329
|
+
return Kr({
|
|
1330
|
+
activation: Je({
|
|
1331
|
+
card: e.card,
|
|
1332
|
+
cardConfig: e.cardConfig
|
|
1333
|
+
}),
|
|
1334
|
+
result: e.result,
|
|
1335
|
+
expectedResultOwner: e.expectedResultOwner
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function Ga(e) {
|
|
1339
|
+
const t = an(e.card, e.effectiveCardConfig), n = ya({
|
|
1340
|
+
card: t,
|
|
1341
|
+
records: e.rows,
|
|
1342
|
+
keys: e.rows.length === 0 ? e.resultKeys : void 0,
|
|
1343
|
+
columnKeyMap: e.result.columnKeyMap,
|
|
1344
|
+
resultColumns: e.result.resultColumns,
|
|
1345
|
+
comparisonMetadata: e.result.comparisonMetadata,
|
|
1346
|
+
viewerTable: e.file.viewerTable
|
|
1347
|
+
});
|
|
1348
|
+
return e.rows.length === 0 && !e.resultKeys || n.visibleKeys.length === 0 ? null : {
|
|
1349
|
+
view: n,
|
|
1350
|
+
formatOptions: {
|
|
1351
|
+
useFormattedValues: e.file.useFormattedValues,
|
|
1352
|
+
timezone: e.reportContext.calendar.tz,
|
|
1353
|
+
delimiter: e.file.delimiter,
|
|
1354
|
+
csvEncoding: e.file.csvEncoding,
|
|
1355
|
+
includeHeaders: e.file.includeHeaders,
|
|
1356
|
+
columnSettings: H(e.card),
|
|
1357
|
+
visibleColumns: [...n.visibleKeys],
|
|
1358
|
+
columnLabels: Object.fromEntries(n.visibleKeys.map((r) => [r, n.labels[r] ?? r]))
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
function Wa(e) {
|
|
1363
|
+
var n;
|
|
1364
|
+
const t = (n = e.preferences) == null ? void 0 : n.comparisonPresentation;
|
|
1365
|
+
return {
|
|
1366
|
+
...Ki,
|
|
1367
|
+
...t,
|
|
1368
|
+
...t != null && t.conditionalLabels ? { conditionalLabels: { ...t.conditionalLabels } } : {},
|
|
1369
|
+
...t != null && t.colors ? { colors: { ...t.colors } } : {}
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
function Ha(e) {
|
|
1373
|
+
const t = an(e.card, e.effectiveCardConfig), { cardId: n, ...r } = e.requestPayloadBase, i = e.formatOptions.visibleColumns ?? [], o = [
|
|
1374
|
+
...i,
|
|
1375
|
+
...Object.keys(e.formatOptions.columnSettings ?? {})
|
|
1376
|
+
], a = Ir(
|
|
1377
|
+
e.card,
|
|
1378
|
+
i,
|
|
1379
|
+
e.effectiveCardConfig
|
|
1380
|
+
), s = Cr(
|
|
1381
|
+
e.card,
|
|
1382
|
+
e.effectiveCardConfig,
|
|
1383
|
+
a
|
|
1384
|
+
), c = Fr(
|
|
1385
|
+
t,
|
|
1386
|
+
o
|
|
1387
|
+
), l = new Set(
|
|
1388
|
+
c.eligibleTargets.map(_e)
|
|
1389
|
+
), d = (v) => l.has(_e(v)) ? xr({
|
|
1390
|
+
bindings: r.controlBindings,
|
|
1391
|
+
controls: [
|
|
1392
|
+
...r.controlDefinitions ?? [],
|
|
1393
|
+
...r.cardControlDefinitions ?? []
|
|
1394
|
+
],
|
|
1395
|
+
values: r.controlValues,
|
|
1396
|
+
target: v,
|
|
1397
|
+
knownTargets: c.knownTargets,
|
|
1398
|
+
eligibleTargets: c.eligibleTargets
|
|
1399
|
+
}).currency : void 0, u = Sr({
|
|
1400
|
+
card: e.card,
|
|
1401
|
+
comparisonMetadata: e.comparisonMetadata,
|
|
1402
|
+
columnKeyMap: e.columnKeyMap
|
|
1403
|
+
}), f = Je({
|
|
1404
|
+
card: e.card,
|
|
1405
|
+
cardConfig: e.effectiveCardConfig
|
|
1406
|
+
}), m = ja({
|
|
1407
|
+
card: e.card,
|
|
1408
|
+
cardConfig: e.effectiveCardConfig,
|
|
1409
|
+
columns: e.resultColumns,
|
|
1410
|
+
columnKeyMap: e.columnKeyMap,
|
|
1411
|
+
resultRowCount: e.totalRows,
|
|
1412
|
+
valueFormatPreferences: e.reportContext.valueFormat
|
|
1413
|
+
}), p = (f == null ? void 0 : f.fields) ?? [], y = new Map(
|
|
1414
|
+
p.map((v) => [
|
|
1415
|
+
`${v.role}:${v.id}`,
|
|
1416
|
+
v
|
|
1417
|
+
])
|
|
1418
|
+
), g = /* @__PURE__ */ new Map();
|
|
1419
|
+
if (e.card.type === "detailTable" && r.resultOwner === "config") {
|
|
1420
|
+
const v = e.resultColumns || [];
|
|
1421
|
+
if (v.filter(
|
|
1422
|
+
(b) => b.rawTemporal
|
|
1423
|
+
).length > 0) {
|
|
1424
|
+
if (!e.columnKeyMap)
|
|
1425
|
+
throw new Error(
|
|
1426
|
+
"Canonical raw temporal export requires an authoritative columnKeyMap."
|
|
1427
|
+
);
|
|
1428
|
+
const b = Vr({
|
|
1429
|
+
cardType: e.card.type,
|
|
1430
|
+
resultOwner: r.resultOwner,
|
|
1431
|
+
effectiveCardConfig: e.effectiveCardConfig,
|
|
1432
|
+
result: {
|
|
1433
|
+
records: [],
|
|
1434
|
+
columns: v,
|
|
1435
|
+
columnKeyMap: e.columnKeyMap
|
|
1436
|
+
},
|
|
1437
|
+
preferences: e.reportContext.valueFormat,
|
|
1438
|
+
calendar: e.reportContext.calendar
|
|
1439
|
+
});
|
|
1440
|
+
if (b.kind === "invalid") throw b.error;
|
|
1441
|
+
if (b.kind === "loaded_empty" || b.kind === "loaded_valid")
|
|
1442
|
+
for (const [S, P] of b.presentation.byColumnKey)
|
|
1443
|
+
g.set(S, P.format);
|
|
1444
|
+
}
|
|
1445
|
+
} else if (r.resultOwner === "freeform" && r.sql.trim() && !r.python.trim())
|
|
1446
|
+
for (const [v, I] of Object.entries(
|
|
1447
|
+
H(e.card)
|
|
1448
|
+
)) {
|
|
1449
|
+
if (I.type !== "date") continue;
|
|
1450
|
+
const b = Lr(I.dateFormat);
|
|
1451
|
+
b && g.set(
|
|
1452
|
+
v,
|
|
1453
|
+
Wi({
|
|
1454
|
+
format: b,
|
|
1455
|
+
preferences: e.reportContext.valueFormat,
|
|
1456
|
+
calendar: e.reportContext.calendar
|
|
1457
|
+
})
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
const h = [
|
|
1461
|
+
...new Set(o)
|
|
1462
|
+
].flatMap((v) => {
|
|
1463
|
+
var G, $, ue;
|
|
1464
|
+
if (m.byColumnKey.has(v) || g.has(v))
|
|
1465
|
+
return [];
|
|
1466
|
+
const I = u.columnPresentationOwners.get(v), b = {
|
|
1467
|
+
...qr(t, v, {
|
|
1468
|
+
columnKeyMap: e.columnKeyMap,
|
|
1469
|
+
resultColumns: e.resultColumns
|
|
1470
|
+
}),
|
|
1471
|
+
...I ? { metricId: I.metricId, metricAlias: I.metricAlias } : {}
|
|
1472
|
+
}, S = (G = t.sql) != null && G.trim() ? void 0 : le(t, b), P = S ? { kind: "metric", metricId: S.id } : { kind: "column", columnKey: v }, D = l.has(
|
|
1473
|
+
_e(P)
|
|
1474
|
+
), L = d(P), j = H(t)[v], E = {
|
|
1475
|
+
dashboardId: e.dashboardId,
|
|
1476
|
+
cardId: t.id
|
|
1477
|
+
}, ee = { kind: "column", columnKey: v }, k = S && (!j || j.inheritMetricFormat === !0) ? Q(S.format, {
|
|
1478
|
+
preserveOmittedProperties: !0
|
|
1479
|
+
}) : void 0;
|
|
1480
|
+
if ((k == null ? void 0 : k.type) === "date")
|
|
1481
|
+
return [
|
|
1482
|
+
{
|
|
1483
|
+
scope: E,
|
|
1484
|
+
target: ee,
|
|
1485
|
+
format: {
|
|
1486
|
+
type: "date",
|
|
1487
|
+
locale: k.locale ?? e.reportContext.valueFormat.locale,
|
|
1488
|
+
...k.pattern ? { pattern: k.pattern } : {},
|
|
1489
|
+
...k.timezone ? { timezone: k.timezone } : {},
|
|
1490
|
+
...k.sourceTimezone ? { sourceTimezone: k.sourceTimezone } : {}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
];
|
|
1494
|
+
const q = (I ? Ua({
|
|
1495
|
+
card: t,
|
|
1496
|
+
columnId: v,
|
|
1497
|
+
columnKeyMap: e.columnKeyMap,
|
|
1498
|
+
persistedSettings: j,
|
|
1499
|
+
metricId: I.metricId,
|
|
1500
|
+
metricAlias: I.metricAlias,
|
|
1501
|
+
comparisonValueKind: I.kind,
|
|
1502
|
+
comparisonPrecision: (ue = ($ = t.preferences) == null ? void 0 : $.comparisonPresentation) == null ? void 0 : ue.precision,
|
|
1503
|
+
presentation: {
|
|
1504
|
+
preferences: e.reportContext.valueFormat,
|
|
1505
|
+
resolveBoundCurrency: d
|
|
1506
|
+
}
|
|
1507
|
+
}) : void 0) ?? (D ? za({
|
|
1508
|
+
card: t,
|
|
1509
|
+
target: P,
|
|
1510
|
+
resultColumnKeys: o,
|
|
1511
|
+
valueFormatPreferences: e.reportContext.valueFormat,
|
|
1512
|
+
boundCurrency: L
|
|
1513
|
+
}) : void 0) ?? Se({
|
|
1514
|
+
card: t,
|
|
1515
|
+
...b,
|
|
1516
|
+
persistedSettings: j,
|
|
1517
|
+
valueFormatPreferences: e.reportContext.valueFormat
|
|
1518
|
+
}), B = (q == null ? void 0 : q.type) === "duration" ? q : q ? _(
|
|
1519
|
+
q,
|
|
1520
|
+
e.reportContext.valueFormat,
|
|
1521
|
+
L
|
|
1522
|
+
) : _(
|
|
1523
|
+
{
|
|
1524
|
+
type: "number",
|
|
1525
|
+
minimumFractionDigits: 0,
|
|
1526
|
+
maximumFractionDigits: 3
|
|
1527
|
+
},
|
|
1528
|
+
e.reportContext.valueFormat
|
|
1529
|
+
);
|
|
1530
|
+
return [
|
|
1531
|
+
B.type === "duration" ? { scope: E, target: ee, format: B } : { scope: E, target: ee, format: B }
|
|
1532
|
+
];
|
|
1533
|
+
});
|
|
1534
|
+
h.push(
|
|
1535
|
+
...[...m.byColumnKey.values()].map((v) => {
|
|
1536
|
+
const I = y.get(
|
|
1537
|
+
`${v.role ?? "groupby"}:${v.fieldId}`
|
|
1538
|
+
);
|
|
1539
|
+
if (!I)
|
|
1540
|
+
throw new Error(
|
|
1541
|
+
`Unable to resolve temporal export field "${v.fieldId}".`
|
|
1542
|
+
);
|
|
1543
|
+
return {
|
|
1544
|
+
scope: {
|
|
1545
|
+
dashboardId: e.dashboardId,
|
|
1546
|
+
cardId: e.card.id
|
|
1547
|
+
},
|
|
1548
|
+
target: { kind: "column", columnKey: v.columnKey },
|
|
1549
|
+
format: Br(
|
|
1550
|
+
I,
|
|
1551
|
+
{
|
|
1552
|
+
dateStyle: e.reportContext.valueFormat.dateStyle,
|
|
1553
|
+
dateTime: { ...e.reportContext.valueFormat.dateTime }
|
|
1554
|
+
},
|
|
1555
|
+
e.reportContext.valueFormat.locale
|
|
1556
|
+
)
|
|
1557
|
+
};
|
|
1558
|
+
})
|
|
1559
|
+
), h.push(
|
|
1560
|
+
...[...g].map(([v, I]) => ({
|
|
1561
|
+
scope: { dashboardId: e.dashboardId, cardId: e.card.id },
|
|
1562
|
+
target: { kind: "column", columnKey: v },
|
|
1563
|
+
format: I
|
|
1564
|
+
}))
|
|
1565
|
+
);
|
|
1566
|
+
const C = Hi({
|
|
1567
|
+
reportContext: e.reportContext,
|
|
1568
|
+
resolvedFormats: h
|
|
1569
|
+
});
|
|
1570
|
+
return {
|
|
1571
|
+
formatOptions: {
|
|
1572
|
+
...e.formatOptions,
|
|
1573
|
+
...a ? { tableTotalsLabelColumnKey: a } : {},
|
|
1574
|
+
comparisonPresentation: Wa(e.card),
|
|
1575
|
+
presentationExecutionSnapshot: C
|
|
1576
|
+
},
|
|
1577
|
+
...s ? { tableTotalsRequest: s } : {}
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
function Ya(e) {
|
|
1581
|
+
const t = Tr(
|
|
1582
|
+
e.card,
|
|
1583
|
+
e.requestPayloadBase
|
|
1584
|
+
), { cardId: n, ...r } = t.requestPayloadBase, i = Ha(e);
|
|
1585
|
+
return {
|
|
1586
|
+
type: "card",
|
|
1587
|
+
dashboardId: e.dashboardId,
|
|
1588
|
+
cardId: e.card.id,
|
|
1589
|
+
title: e.title,
|
|
1590
|
+
connection_id: t.connectionId,
|
|
1591
|
+
...r,
|
|
1592
|
+
...i.tableTotalsRequest ? { tableTotalsRequest: i.tableTotalsRequest } : {},
|
|
1593
|
+
totalRows: e.totalRows,
|
|
1594
|
+
format: e.format,
|
|
1595
|
+
formatOptions: i.formatOptions
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
function wc(e) {
|
|
1599
|
+
const { card: t, result: n } = e;
|
|
1600
|
+
if (t.type !== "table" && t.type !== "detailTable")
|
|
1601
|
+
return { status: "refused", reason: "not_a_table" };
|
|
1602
|
+
const r = n.modelFormats ? Yi(e.effectiveCardConfig ?? t.config, n) : e.effectiveCardConfig;
|
|
1603
|
+
if (wr({ card: t, comparisonMetadata: n.comparisonMetadata }))
|
|
1604
|
+
return { status: "refused", reason: "comparison_metadata_missing" };
|
|
1605
|
+
const i = Ga({
|
|
1606
|
+
card: t,
|
|
1607
|
+
effectiveCardConfig: r,
|
|
1608
|
+
rows: e.rows,
|
|
1609
|
+
resultKeys: n.resultColumns.map((o) => o.key),
|
|
1610
|
+
result: n,
|
|
1611
|
+
reportContext: e.reportContext,
|
|
1612
|
+
file: e.file
|
|
1613
|
+
});
|
|
1614
|
+
return i ? {
|
|
1615
|
+
status: "ready",
|
|
1616
|
+
request: Ya({
|
|
1617
|
+
card: t,
|
|
1618
|
+
dashboardId: e.dashboardId,
|
|
1619
|
+
title: e.title,
|
|
1620
|
+
reportContext: e.reportContext,
|
|
1621
|
+
totalRows: n.totalRows,
|
|
1622
|
+
format: e.file.format,
|
|
1623
|
+
formatOptions: i.formatOptions,
|
|
1624
|
+
comparisonMetadata: n.comparisonMetadata,
|
|
1625
|
+
requestPayloadBase: e.query,
|
|
1626
|
+
resultColumns: [...n.resultColumns],
|
|
1627
|
+
columnKeyMap: n.columnKeyMap,
|
|
1628
|
+
effectiveCardConfig: r
|
|
1629
|
+
})
|
|
1630
|
+
} : { status: "refused", reason: "columns_unresolved" };
|
|
1631
|
+
}
|
|
1632
|
+
function Kn(e, t, n) {
|
|
1633
|
+
if (Oi(
|
|
1634
|
+
_i(t),
|
|
1635
|
+
e.aggregateOrigin
|
|
1636
|
+
))
|
|
1637
|
+
return { aggregate: void 0, aggregateOrigin: void 0 };
|
|
1638
|
+
const r = n === "selection" && e.role === "metric" ? t.aggregate : void 0;
|
|
1639
|
+
return {
|
|
1640
|
+
aggregate: e.aggregate ?? r,
|
|
1641
|
+
aggregateOrigin: e.aggregate ? e.aggregateOrigin : r ? t.aggregateOrigin : void 0
|
|
1642
|
+
};
|
|
1643
|
+
}
|
|
1644
|
+
function Xa(e, t, n) {
|
|
1645
|
+
var r, i, o, a, s, c;
|
|
1646
|
+
if (n === "domain")
|
|
1647
|
+
return {
|
|
1648
|
+
filters: (r = t.parameters) == null ? void 0 : r.filters,
|
|
1649
|
+
windowTransform: (i = e.parameters) == null ? void 0 : i.windowTransform
|
|
1650
|
+
};
|
|
1651
|
+
if (!(!e.parameters && !t.parameters))
|
|
1652
|
+
return {
|
|
1653
|
+
filters: ((o = e.parameters) == null ? void 0 : o.filters) ?? ((a = t.parameters) == null ? void 0 : a.filters),
|
|
1654
|
+
windowTransform: ((s = e.parameters) == null ? void 0 : s.windowTransform) ?? ((c = t.parameters) == null ? void 0 : c.windowTransform)
|
|
1655
|
+
};
|
|
1656
|
+
}
|
|
1657
|
+
function Tc(e, t, n) {
|
|
1658
|
+
const r = e;
|
|
1659
|
+
return {
|
|
1660
|
+
id: e.id,
|
|
1661
|
+
role: e.role,
|
|
1662
|
+
// Result-column names belong to the selection's consumer (for example,
|
|
1663
|
+
// range bounds). They do not identify or redefine the catalog calculation.
|
|
1664
|
+
...n === "selection" && e.alias ? { alias: e.alias } : {},
|
|
1665
|
+
granularity: e.granularity ?? t.granularity,
|
|
1666
|
+
...Kn(e, t, n),
|
|
1667
|
+
...e.role === "metric" ? {
|
|
1668
|
+
aliasTemplate: r.aliasTemplate,
|
|
1669
|
+
valueAliases: r.valueAliases,
|
|
1670
|
+
comparison: r.comparison,
|
|
1671
|
+
comparisonPolarity: r.comparisonPolarity,
|
|
1672
|
+
parameters: Xa(
|
|
1673
|
+
r,
|
|
1674
|
+
t,
|
|
1675
|
+
"domain"
|
|
1676
|
+
)
|
|
1677
|
+
} : {},
|
|
1678
|
+
...Qa(e)
|
|
1679
|
+
};
|
|
1680
|
+
}
|
|
1681
|
+
function Qa(e) {
|
|
1682
|
+
const t = {
|
|
1683
|
+
...e.labelOrigin === "override" ? { label: e.label, labelOrigin: e.labelOrigin } : {},
|
|
1684
|
+
...e.formatOrigin === "override" ? { format: e.format, formatOrigin: e.formatOrigin } : {}
|
|
1685
|
+
};
|
|
1686
|
+
switch (e.role) {
|
|
1687
|
+
case "pivotby":
|
|
1688
|
+
return {
|
|
1689
|
+
...t,
|
|
1690
|
+
memberOrder: e.memberOrder
|
|
1691
|
+
};
|
|
1692
|
+
case "sortby":
|
|
1693
|
+
return {
|
|
1694
|
+
...t,
|
|
1695
|
+
direction: e.direction
|
|
1696
|
+
};
|
|
1697
|
+
default:
|
|
1698
|
+
return t;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
const Ja = "table";
|
|
1702
|
+
function Dc({ preferences: e, ...t }) {
|
|
1703
|
+
return {
|
|
1704
|
+
...t,
|
|
1705
|
+
type: Ja,
|
|
1706
|
+
preferences: e ?? { onClickFilter: [{ columnIndex: 0, expression: "" }] },
|
|
1707
|
+
sql: "",
|
|
1708
|
+
data: []
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1711
|
+
function kc(e) {
|
|
1712
|
+
return {
|
|
1713
|
+
id: e.id,
|
|
1714
|
+
title: e.title,
|
|
1715
|
+
...e.description ? { description: e.description } : {},
|
|
1716
|
+
type: "text",
|
|
1717
|
+
preferences: { textVisualOptions: { richContent: e.richContent } },
|
|
1718
|
+
data: []
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
const Za = {
|
|
1722
|
+
SUM: "total",
|
|
1723
|
+
AVG: "average",
|
|
1724
|
+
MIN: "lowest",
|
|
1725
|
+
MAX: "latest",
|
|
1726
|
+
MEDIAN: "median",
|
|
1727
|
+
COUNT: "count of",
|
|
1728
|
+
DISTINCT: "number of distinct"
|
|
1729
|
+
};
|
|
1730
|
+
function ne(e) {
|
|
1731
|
+
return e.label || e.name;
|
|
1732
|
+
}
|
|
1733
|
+
function me(e) {
|
|
1734
|
+
const t = e;
|
|
1735
|
+
return !e.aggregate || t.labelOrigin === "override" ? ne(e) : et(e.name);
|
|
1736
|
+
}
|
|
1737
|
+
function Bt(e) {
|
|
1738
|
+
return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
1739
|
+
}
|
|
1740
|
+
function eo(e) {
|
|
1741
|
+
var i, o, a;
|
|
1742
|
+
const t = Zi({ variables: [e] })[0];
|
|
1743
|
+
if (!t) return;
|
|
1744
|
+
const n = Ze(t.card), r = n.kind === "config" ? n.executableSources[0] : n.kind === "sql" ? (i = n.pinnedCatalogSources[0]) == null ? void 0 : i.source : void 0;
|
|
1745
|
+
if (!r) {
|
|
1746
|
+
const s = (a = (o = e.query.dataSource) == null ? void 0 : o.selectedEntities) == null ? void 0 : a[0];
|
|
1747
|
+
return (s == null ? void 0 : s.label) || (s == null ? void 0 : s.name) || void 0;
|
|
1748
|
+
}
|
|
1749
|
+
if (r.kind === "semantic") return r.label || r.datasetName;
|
|
1750
|
+
if (r.kind === "physical") return r.label || r.tableName;
|
|
1751
|
+
}
|
|
1752
|
+
function to(e) {
|
|
1753
|
+
var r;
|
|
1754
|
+
const t = (r = e.query.config) == null ? void 0 : r.filters, n = t ? Vn(t) : 0;
|
|
1755
|
+
return n ? n === 1 ? " with one condition" : ` with ${n} conditions` : "";
|
|
1756
|
+
}
|
|
1757
|
+
function Vn(e) {
|
|
1758
|
+
var t;
|
|
1759
|
+
return (((t = e.conditions) == null ? void 0 : t.length) ?? 0) + (e.groups ?? []).reduce((n, r) => n + Vn(r), 0);
|
|
1760
|
+
}
|
|
1761
|
+
function Ut(e) {
|
|
1762
|
+
if (!e) return "";
|
|
1763
|
+
const t = ce(e.dataType), n = t === "date" || t === "datetime" ? e.direction === "desc" ? "latest first" : "earliest first" : t === "number" ? e.direction === "desc" ? "highest first" : "lowest first" : e.direction === "desc" ? "Z to A" : "A to Z";
|
|
1764
|
+
return ` by ${e.aggregate ? me(e) : ne(e)}, ${n}`;
|
|
1765
|
+
}
|
|
1766
|
+
function no(e) {
|
|
1767
|
+
var s, c, l;
|
|
1768
|
+
const t = eo(e), n = t ? ` in ${t}` : "", r = to(e);
|
|
1769
|
+
if ((s = e.query.sql) != null && s.trim()) {
|
|
1770
|
+
const d = e.get.kind === "first" ? "the first row" : "the only row";
|
|
1771
|
+
return `${ro(d)} of a SQL query${t ? ` on ${t}` : ""}`;
|
|
1772
|
+
}
|
|
1773
|
+
const i = e.query.config ?? {}, o = i.groupByColumns ?? [], a = i.metricColumns ?? [];
|
|
1774
|
+
switch (e.get.kind) {
|
|
1775
|
+
case "aggregate": {
|
|
1776
|
+
const d = a[0];
|
|
1777
|
+
return d ? d.aggregate ? `The ${Za[String(d.aggregate).toUpperCase()] ?? String(d.aggregate).toLowerCase()} ${me(d)}${n}${r}${zt(e)}` : `The ${ne(d)}${n}${r}${zt(e)}` : "An aggregate, with no measure chosen yet";
|
|
1778
|
+
}
|
|
1779
|
+
case "list": {
|
|
1780
|
+
const d = o[0];
|
|
1781
|
+
return d ? `The ${ne(d)} values${n}${r}, as a list${Ut((c = i.sortByColumns) == null ? void 0 : c[0])}` : "A list, with no field chosen yet";
|
|
1782
|
+
}
|
|
1783
|
+
case "first": {
|
|
1784
|
+
const d = [...o.map(ne), ...a.map(me)];
|
|
1785
|
+
return d.length ? `The first ${Bt(d)}${n}${r}${Ut((l = i.sortByColumns) == null ? void 0 : l[0])}` : "The first row, with no field chosen yet";
|
|
1786
|
+
}
|
|
1787
|
+
default: {
|
|
1788
|
+
const d = [...o.map(ne), ...a.map(me)];
|
|
1789
|
+
return d.length ? `The ${Bt(d)}${n}${r}, the only value` : "The only value, with no field chosen yet";
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
}
|
|
1793
|
+
function zt(e) {
|
|
1794
|
+
const t = ea(e);
|
|
1795
|
+
return t ? `, compared with ${Ur({ mode: "explicit", spec: t })}` : "";
|
|
1796
|
+
}
|
|
1797
|
+
function ro(e) {
|
|
1798
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1799
|
+
}
|
|
1800
|
+
function io(e, t) {
|
|
1801
|
+
const n = e.sheets ?? [], r = n.findIndex((a) => a.id === t.sheetId), i = n[r];
|
|
1802
|
+
if (!i)
|
|
1803
|
+
throw new F("sheet_not_found", `No sheet ${t.sheetId} on this dashboard.`);
|
|
1804
|
+
if (xe(i))
|
|
1805
|
+
throw new F(
|
|
1806
|
+
"sheet_not_a_grid",
|
|
1807
|
+
"This sheet is a document: it has no grid to arrange.",
|
|
1808
|
+
"Arrange a grid sheet; Document sheets are laid out in the editor."
|
|
1809
|
+
);
|
|
1810
|
+
const o = J(i, { kind: "arrange", keepOrder: t.keepOrder === !0 });
|
|
1811
|
+
return {
|
|
1812
|
+
dashboard: { ...e, sheets: n.map((a, s) => s === r ? o : a) },
|
|
1813
|
+
clauses: [T.arranged(i.title || "the dashboard", t.keepOrder === !0, !(i.frames ?? []).length)]
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1816
|
+
function ao(e) {
|
|
1817
|
+
return !!(e && Object.prototype.hasOwnProperty.call(e, "calculatedFields"));
|
|
1818
|
+
}
|
|
1819
|
+
function X(...e) {
|
|
1820
|
+
return zr(e.flatMap((t) => t || []));
|
|
1821
|
+
}
|
|
1822
|
+
function ie(e, t) {
|
|
1823
|
+
return {
|
|
1824
|
+
...e,
|
|
1825
|
+
fieldScope: t
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
function ft(e) {
|
|
1829
|
+
return ((e == null ? void 0 : e.calculatedFields) || []).filter((t) => t.fieldScope === "sheet").map((t) => ie(t, "sheet"));
|
|
1830
|
+
}
|
|
1831
|
+
function Ln(e) {
|
|
1832
|
+
return ((e == null ? void 0 : e.calculatedFields) || []).filter((t) => !t.fieldScope).map((t) => ie(t, "sheet"));
|
|
1833
|
+
}
|
|
1834
|
+
function oo(e) {
|
|
1835
|
+
return e ? [
|
|
1836
|
+
...(e.calculatedFields || []).filter(
|
|
1837
|
+
(t) => t.fieldScope === "dashboard"
|
|
1838
|
+
),
|
|
1839
|
+
...(e.frames || []).flatMap((t) => t.calculatedFields || [])
|
|
1840
|
+
].map((t) => ie(t, "dashboard")) : [];
|
|
1841
|
+
}
|
|
1842
|
+
function so(e) {
|
|
1843
|
+
if (e !== void 0)
|
|
1844
|
+
return X(
|
|
1845
|
+
e.map((t) => ie(t, "dashboard"))
|
|
1846
|
+
);
|
|
1847
|
+
}
|
|
1848
|
+
function Mc(e) {
|
|
1849
|
+
var r;
|
|
1850
|
+
const t = [], n = (e.sheets || []).map((i) => {
|
|
1851
|
+
var o;
|
|
1852
|
+
return t.push(...oo(i)), {
|
|
1853
|
+
...i,
|
|
1854
|
+
calculatedFields: X(
|
|
1855
|
+
ft(i),
|
|
1856
|
+
Ln(i)
|
|
1857
|
+
),
|
|
1858
|
+
frames: (o = i.frames) == null ? void 0 : o.map(
|
|
1859
|
+
(a) => a.calculatedFields === void 0 ? a : { ...a, calculatedFields: void 0 }
|
|
1860
|
+
)
|
|
1861
|
+
};
|
|
1862
|
+
});
|
|
1863
|
+
return {
|
|
1864
|
+
...e,
|
|
1865
|
+
calculatedFields: so(
|
|
1866
|
+
X(
|
|
1867
|
+
(r = e.calculatedFields) == null ? void 0 : r.map(
|
|
1868
|
+
(i) => ie(i, "dashboard")
|
|
1869
|
+
),
|
|
1870
|
+
t
|
|
1871
|
+
)
|
|
1872
|
+
),
|
|
1873
|
+
sheets: n
|
|
1874
|
+
};
|
|
1875
|
+
}
|
|
1876
|
+
function jt(e, t) {
|
|
1877
|
+
var i;
|
|
1878
|
+
if (!((i = e == null ? void 0 : e.frames) != null && i.length))
|
|
1879
|
+
return [];
|
|
1880
|
+
const n = t ? e.frames.find((o) => o.id === t) : void 0, r = e.frames.filter(
|
|
1881
|
+
(o) => !t || o.id !== t
|
|
1882
|
+
);
|
|
1883
|
+
return X(
|
|
1884
|
+
n == null ? void 0 : n.calculatedFields,
|
|
1885
|
+
...r.map((o) => o.calculatedFields)
|
|
1886
|
+
);
|
|
1887
|
+
}
|
|
1888
|
+
function co(e, t) {
|
|
1889
|
+
return e ? ft(e) : [];
|
|
1890
|
+
}
|
|
1891
|
+
function Oc(e, t) {
|
|
1892
|
+
if (!e)
|
|
1893
|
+
return [];
|
|
1894
|
+
const n = ft(e), r = Ln(e), i = X(
|
|
1895
|
+
n,
|
|
1896
|
+
r
|
|
1897
|
+
);
|
|
1898
|
+
return ao(e) ? i.length === 0 ? [] : r.length === 0 ? i : X(
|
|
1899
|
+
i,
|
|
1900
|
+
jt(e, t)
|
|
1901
|
+
) : jt(e, t);
|
|
1902
|
+
}
|
|
1903
|
+
function lo(e) {
|
|
1904
|
+
if (e !== void 0)
|
|
1905
|
+
return X(
|
|
1906
|
+
e.map((t) => ie(t, "sheet"))
|
|
1907
|
+
);
|
|
1908
|
+
}
|
|
1909
|
+
function _c(e) {
|
|
1910
|
+
const { field: t, sheetFields: n = [], dashboardFields: r = [] } = e, i = (s) => s.find(
|
|
1911
|
+
(c) => jr(c, t, {
|
|
1912
|
+
allowComparableFallback: !0
|
|
1913
|
+
})
|
|
1914
|
+
);
|
|
1915
|
+
if (t.fieldScope === "sheet")
|
|
1916
|
+
return { scope: "sheet", matchedField: i(n) };
|
|
1917
|
+
if (t.fieldScope === "dashboard")
|
|
1918
|
+
return { scope: "dashboard", matchedField: i(r) };
|
|
1919
|
+
const o = i(n);
|
|
1920
|
+
if (o)
|
|
1921
|
+
return { scope: "sheet", matchedField: o };
|
|
1922
|
+
const a = i(r);
|
|
1923
|
+
return a ? { scope: "dashboard", matchedField: a } : { scope: "card" };
|
|
1924
|
+
}
|
|
1925
|
+
function uo(e, t) {
|
|
1926
|
+
var C, v, I;
|
|
1927
|
+
const n = (e.sheets ?? []).findIndex((b) => b.id === t.sheetId), r = (C = e.sheets) == null ? void 0 : C[n];
|
|
1928
|
+
if (!(r != null && r.frames))
|
|
1929
|
+
throw new F("sheet_not_found", `No sheet ${t.sheetId} with frames on this dashboard.`);
|
|
1930
|
+
const { frame: i } = t, o = r.frames.findIndex((b) => b.id === i.id);
|
|
1931
|
+
if (o === -1)
|
|
1932
|
+
throw new F("frame_not_found", `No frame ${i.id} on sheet ${t.sheetId}.`);
|
|
1933
|
+
const a = r.frames[o], s = Tt(r), c = (b) => b.calculatedFields === void 0 ? b : { ...b, calculatedFields: void 0 }, l = t.rewrittenFrames, d = l && l.length > 0 ? (() => {
|
|
1934
|
+
const b = l.map((S) => S.id === i.id ? i : S);
|
|
1935
|
+
return b.some((S) => S.id === i.id) ? b : [i, ...b];
|
|
1936
|
+
})() : [i], u = new Map(d.map((b) => [b.id, b])), f = J(r, { kind: "frame_updated", frame: i, resizeForNewKind: t.resizeLayouts });
|
|
1937
|
+
let m = /* @__PURE__ */ new Set();
|
|
1938
|
+
const p = Gr.produce(e, (b) => {
|
|
1939
|
+
const S = b.sheets[n];
|
|
1940
|
+
f.layouts !== r.layouts && (S.layouts = Dt(f.layouts)), f.customizedBreakpoints !== r.customizedBreakpoints && (S.customizedBreakpoints = f.customizedBreakpoints), t.sheetCalculatedFields !== void 0 && (S.calculatedFields = lo(t.sheetCalculatedFields)), S.frames = S.frames.map((D) => {
|
|
1941
|
+
const L = u.get(D.id);
|
|
1942
|
+
return L ? Dt(c(L)) : D.calculatedFields === void 0 ? D : { ...D, calculatedFields: void 0 };
|
|
1943
|
+
});
|
|
1944
|
+
const P = Tt(S);
|
|
1945
|
+
m = new Set([...s].filter((D) => !P.has(D))), Wr(b, m), t.dashboardCalculatedFields && (b.calculatedFields = t.dashboardCalculatedFields);
|
|
1946
|
+
}), y = p.sheets[n].frames.find((b) => b.id === i.id), g = [
|
|
1947
|
+
...m.size ? [{ kind: "cards_removed", cardIds: [...m] }] : [],
|
|
1948
|
+
{ kind: "frame_committed", sheetId: t.sheetId, before: a, after: y }
|
|
1949
|
+
], h = ((v = i.cards) == null ? void 0 : v.find((b) => b.id === i.activeCardId)) ?? ((I = i.cards) == null ? void 0 : I[0]);
|
|
1950
|
+
return { dashboard: p, runtimeEffects: g, clauses: [T.committed(h == null ? void 0 : h.title)] };
|
|
1951
|
+
}
|
|
1952
|
+
function fo(e, t) {
|
|
1953
|
+
const n = { ...e }, r = [];
|
|
1954
|
+
return t.title !== void 0 && t.title !== e.title && (n.title = t.title, r.push(T.plain("dashboard", `renames the dashboard to ${w(t.title)}`))), t.description === null && e.description ? (delete n.description, r.push(T.plain("dashboard", "removes the dashboard's description"))) : typeof t.description == "string" && t.description !== e.description && (n.description = t.description, r.push(T.plain("dashboard", "changes the dashboard's description"))), { dashboard: n, clauses: r.length ? r : [T.plain("dashboard", "changes nothing on the dashboard")] };
|
|
1955
|
+
}
|
|
1956
|
+
function mo(e, t, n) {
|
|
1957
|
+
const r = e.sheets ?? [], i = r.findIndex((s) => s.id === t), o = r[i];
|
|
1958
|
+
if (!o) throw new F("sheet_not_found", `No sheet ${t} on this dashboard.`);
|
|
1959
|
+
if (xe(o))
|
|
1960
|
+
throw new F("sheet_not_a_grid", `"${o.title}" is a Document sheet.`, "Document sheets are changed in the editor.");
|
|
1961
|
+
const a = n.map((s) => {
|
|
1962
|
+
const c = (o.frames ?? []).find((l) => l.cards.some((d) => d.id === s));
|
|
1963
|
+
if (!c)
|
|
1964
|
+
throw new F("card_not_found", `No card ${s} on ${Hr(o)}.`, "Read the outline again and use its card ids.");
|
|
1965
|
+
return c.cards.find((l) => l.id === s);
|
|
1966
|
+
});
|
|
1967
|
+
return { sheets: r, sheetIndex: i, sheet: o, cards: a };
|
|
1968
|
+
}
|
|
1969
|
+
const pe = (e, t) => (e.frames ?? []).find((n) => n.cards.some((r) => r.id === t));
|
|
1970
|
+
function Ge(e) {
|
|
1971
|
+
const { visualId: t, ...n } = e;
|
|
1972
|
+
return n;
|
|
1973
|
+
}
|
|
1974
|
+
const qn = (e) => e.cards.find((t) => t.id === e.activeCardId) ?? e.cards[0], Ee = (e) => T.plain("detached", `makes ${e} local to this report; it no longer follows its library visual`);
|
|
1975
|
+
function po(e, t) {
|
|
1976
|
+
var p;
|
|
1977
|
+
const { sheets: n, sheetIndex: r, sheet: i, cards: o } = mo(e, t.sheetId, t.cardIds), a = pe(i, t.cardIds[0]).id;
|
|
1978
|
+
let s = i;
|
|
1979
|
+
const c = [];
|
|
1980
|
+
for (const y of t.cardIds.slice(1)) {
|
|
1981
|
+
const g = pe(s, y);
|
|
1982
|
+
if (g.id === a) continue;
|
|
1983
|
+
const h = cn(g, y);
|
|
1984
|
+
if (!h.cards.length) {
|
|
1985
|
+
g.visualId && c.push(Ee(w(g.cards[0].title))), s = J(s, { kind: "frame_removed", frameId: g.id });
|
|
1986
|
+
continue;
|
|
1987
|
+
}
|
|
1988
|
+
g.visualId && c.push(Ee(`the tile of ${w((p = qn(h)) == null ? void 0 : p.title)}`)), s = J(s, { kind: "frame_updated", frame: g.visualId ? Ge(h) : h, resizeForNewKind: !0 });
|
|
1989
|
+
}
|
|
1990
|
+
const l = pe(s, t.cardIds[0]), d = new Set(t.cardIds), u = {
|
|
1991
|
+
...l,
|
|
1992
|
+
cards: [...o, ...l.cards.filter((y) => !d.has(y.id))],
|
|
1993
|
+
activeCardId: t.cardIds[0]
|
|
1994
|
+
};
|
|
1995
|
+
l.visualId && c.push(Ee("the tabs")), s = J(s, { kind: "frame_updated", frame: l.visualId ? Ge(u) : u, resizeForNewKind: !0 });
|
|
1996
|
+
const f = o.map((y) => w(y.title)), m = [...new Map(c.map((y) => [y.lead, y])).values()];
|
|
1997
|
+
return {
|
|
1998
|
+
dashboard: { ...e, sheets: n.map((y, g) => g === r ? s : y) },
|
|
1999
|
+
clauses: [T.plain("layout", `puts ${we(f)} in one spot as tabs, ${f[0]} first`), ...m],
|
|
2000
|
+
detached: m.length > 0
|
|
2001
|
+
};
|
|
2002
|
+
}
|
|
2003
|
+
function go(e, t) {
|
|
2004
|
+
var d;
|
|
2005
|
+
const n = e.sheets ?? [], r = n.findIndex((u) => !xe(u) && (u.frames ?? []).some((f) => f.cards.some((m) => m.id === t.cardId)));
|
|
2006
|
+
if (r < 0)
|
|
2007
|
+
throw new F("card_not_found", `No card ${t.cardId} on this dashboard.`, "Read the outline again and use its card ids.");
|
|
2008
|
+
if (n.some((u) => (u.frames ?? []).some((f) => f.id === t.newFrameId)))
|
|
2009
|
+
throw new F("frame_id_taken", `A frame with id ${t.newFrameId} is already on this dashboard.`);
|
|
2010
|
+
const i = n[r], o = pe(i, t.cardId), a = o.cards.find((u) => u.id === t.cardId);
|
|
2011
|
+
if (o.cards.length < 2)
|
|
2012
|
+
throw new F("frame_not_found", `${w(a.title)} already has its own spot.`);
|
|
2013
|
+
const s = cn(o, t.cardId);
|
|
2014
|
+
let c = J(i, {
|
|
2015
|
+
kind: "frame_updated",
|
|
2016
|
+
frame: o.visualId ? Ge(s) : s,
|
|
2017
|
+
resizeForNewKind: !0
|
|
2018
|
+
});
|
|
2019
|
+
c = J(c, {
|
|
2020
|
+
kind: "frame_added",
|
|
2021
|
+
frame: { id: t.newFrameId, cards: [a], activeCardId: a.id },
|
|
2022
|
+
placement: { position: { beside: o.id } }
|
|
2023
|
+
});
|
|
2024
|
+
const l = !!o.visualId;
|
|
2025
|
+
return {
|
|
2026
|
+
dashboard: { ...e, sheets: n.map((u, f) => f === r ? c : u) },
|
|
2027
|
+
clauses: [
|
|
2028
|
+
T.plain("layout", `gives ${w(a.title)} its own spot beside ${w((d = qn(s)) == null ? void 0 : d.title)}`),
|
|
2029
|
+
...l ? [T.plain("detached", "makes both spots local to this report; they no longer follow their library visual")] : []
|
|
2030
|
+
],
|
|
2031
|
+
detached: l
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
function ho() {
|
|
2035
|
+
return {
|
|
2036
|
+
version: 1,
|
|
2037
|
+
page: {
|
|
2038
|
+
size: "letter",
|
|
2039
|
+
orientation: "portrait",
|
|
2040
|
+
margins: {
|
|
2041
|
+
top: 0.5,
|
|
2042
|
+
right: 0.5,
|
|
2043
|
+
bottom: 0.5,
|
|
2044
|
+
left: 0.5,
|
|
2045
|
+
unit: "in"
|
|
2046
|
+
}
|
|
2047
|
+
},
|
|
2048
|
+
runtime: {
|
|
2049
|
+
generatedAtFormat: Yr
|
|
2050
|
+
},
|
|
2051
|
+
inputs: [],
|
|
2052
|
+
sections: []
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
function yo() {
|
|
2056
|
+
return {
|
|
2057
|
+
region: "header",
|
|
2058
|
+
enabled: !0,
|
|
2059
|
+
heightPx: 72,
|
|
2060
|
+
layout: { type: "preset", preset: "mvp_header" },
|
|
2061
|
+
blocks: []
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
function bo() {
|
|
2065
|
+
return {
|
|
2066
|
+
region: "footer",
|
|
2067
|
+
enabled: !0,
|
|
2068
|
+
heightPx: 40,
|
|
2069
|
+
layout: { type: "preset", preset: "mvp_footer" },
|
|
2070
|
+
blocks: []
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
function Bn(e) {
|
|
2074
|
+
return [{ type: "text", value: e }];
|
|
2075
|
+
}
|
|
2076
|
+
function Pc(e, t = []) {
|
|
2077
|
+
return Xr(e, { by: "then" }).flatMap((n) => n.type === "link" ? n.children ?? [] : [n]).map((n) => n.type === "text" ? n.value : `{{${Qr(n.ref, Jr({ kind: "document", inputs: t }))}}}`).join("") || "";
|
|
2078
|
+
}
|
|
2079
|
+
function vo(e, t) {
|
|
2080
|
+
return e.find(
|
|
2081
|
+
(n) => n.type === "text" && n.role === t
|
|
2082
|
+
);
|
|
2083
|
+
}
|
|
2084
|
+
function Ac(e, t) {
|
|
2085
|
+
return e.find(
|
|
2086
|
+
(n) => n.type === "image" && n.role === t
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
function Gt(e, t) {
|
|
2090
|
+
const n = {
|
|
2091
|
+
...t,
|
|
2092
|
+
type: "text",
|
|
2093
|
+
content: typeof t.content == "string" ? Bn(t.content) : t.content
|
|
2094
|
+
};
|
|
2095
|
+
return Un(e, n);
|
|
2096
|
+
}
|
|
2097
|
+
function Nc(e, t) {
|
|
2098
|
+
return Un(e, t);
|
|
2099
|
+
}
|
|
2100
|
+
function Un(e, t) {
|
|
2101
|
+
const n = e.findIndex((r) => r.id === t.id);
|
|
2102
|
+
return n === -1 ? [...e, t] : e.map(
|
|
2103
|
+
(r, i) => i === n ? t : r
|
|
2104
|
+
);
|
|
2105
|
+
}
|
|
2106
|
+
function Io(e, t) {
|
|
2107
|
+
const n = e.sheets ?? [], { id: r, title: i, kind: o } = t.sheet;
|
|
2108
|
+
if (n.some((s) => s.id === r))
|
|
2109
|
+
throw new F("sheet_id_taken", `A sheet with id ${r} is already on this dashboard.`);
|
|
2110
|
+
const a = o === "document" ? { id: r, title: i, kind: o, document: ho() } : { id: r, title: i };
|
|
2111
|
+
return {
|
|
2112
|
+
dashboard: { ...e, sheets: [...n, a] },
|
|
2113
|
+
created: [{ kind: "sheet", id: r, title: i, ...t.changeIndex !== void 0 ? { changeIndex: t.changeIndex } : {} }],
|
|
2114
|
+
clauses: [T.plain("sheet", `adds the sheet ${w(i)}`)]
|
|
2115
|
+
};
|
|
2116
|
+
}
|
|
2117
|
+
function Co(e, t) {
|
|
2118
|
+
const n = e.sheets ?? [], r = n.findIndex((o) => o.id === t.sheetId);
|
|
2119
|
+
if (r < 0)
|
|
2120
|
+
throw new F("sheet_not_found", `No sheet ${t.sheetId} on this dashboard.`);
|
|
2121
|
+
const i = n[r];
|
|
2122
|
+
return {
|
|
2123
|
+
dashboard: { ...e, sheets: n.map((o, a) => a === r ? { ...o, title: t.title } : o) },
|
|
2124
|
+
clauses: [T.plain("sheet", `renames the sheet ${w(i.title)} to ${w(t.title)}`)]
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
function Fo(e, t, n) {
|
|
2128
|
+
var o;
|
|
2129
|
+
if (!e || !t || t.customFilterPreferences) return;
|
|
2130
|
+
const r = t.defaultDateFilter;
|
|
2131
|
+
return (t.dateSelectionMode === "day" ? Zr(r) : t.dateSelectionMode === "months" && (ei(r) || ti(r) && r.unit === "month" && (r.mode === "previous" || r.mode === "this" && !r.toDate && !r.boundary))) && ((o = re(t, n)) == null ? void 0 : o.valueType) === "date" ? !0 : void 0;
|
|
2132
|
+
}
|
|
2133
|
+
function Ec(e) {
|
|
2134
|
+
const t = e.createId ?? Ie, n = t(), r = ri({
|
|
2135
|
+
field: e.field,
|
|
2136
|
+
dataSource: e.dataSource,
|
|
2137
|
+
connectionId: e.connectionId,
|
|
2138
|
+
connectionType: e.connectionType,
|
|
2139
|
+
filterId: t()
|
|
2140
|
+
});
|
|
2141
|
+
return So({
|
|
2142
|
+
filter: e.label ? { ...r, title: e.label } : r,
|
|
2143
|
+
label: e.label || e.field.label || e.field.name,
|
|
2144
|
+
scope: e.scope,
|
|
2145
|
+
dashboard: e.dashboard,
|
|
2146
|
+
createId: () => n
|
|
2147
|
+
});
|
|
2148
|
+
}
|
|
2149
|
+
function So(e) {
|
|
2150
|
+
const t = e.createId ?? Ie, n = e.label || e.filter.title || e.filter.column || e.filter.id, r = ln(e.dashboard, { label: n }), i = {
|
|
2151
|
+
...dn(e.filter),
|
|
2152
|
+
variableName: r
|
|
2153
|
+
};
|
|
2154
|
+
return {
|
|
2155
|
+
id: t(),
|
|
2156
|
+
kind: "filter",
|
|
2157
|
+
label: n,
|
|
2158
|
+
variableName: r,
|
|
2159
|
+
requiredAtExecution: !1,
|
|
2160
|
+
scope: e.scope,
|
|
2161
|
+
runtimeScope: "shared",
|
|
2162
|
+
presentation: fn(i),
|
|
2163
|
+
filter: i,
|
|
2164
|
+
exports: un(i)
|
|
2165
|
+
};
|
|
2166
|
+
}
|
|
2167
|
+
function xo(e, t, n, r = { calendar: null }) {
|
|
2168
|
+
var ht, yt, bt, vt, It, Ct, Ft, St;
|
|
2169
|
+
const o = Y(e).findFilterInput(t), a = (O, x) => ({
|
|
2170
|
+
ok: !1,
|
|
2171
|
+
issues: [
|
|
2172
|
+
{
|
|
2173
|
+
code: "invalidSettings",
|
|
2174
|
+
message: O,
|
|
2175
|
+
ref: t,
|
|
2176
|
+
...o ? { inputId: o.input.id } : {},
|
|
2177
|
+
...x ? { contractIssue: x } : {}
|
|
2178
|
+
}
|
|
2179
|
+
]
|
|
2180
|
+
});
|
|
2181
|
+
if (!o)
|
|
2182
|
+
return {
|
|
2183
|
+
ok: !1,
|
|
2184
|
+
issues: [
|
|
2185
|
+
{
|
|
2186
|
+
code: "inputNotFound",
|
|
2187
|
+
ref: t,
|
|
2188
|
+
message: "This filter no longer exists on the dashboard."
|
|
2189
|
+
}
|
|
2190
|
+
]
|
|
2191
|
+
};
|
|
2192
|
+
if (o.origin !== "embeddedInput")
|
|
2193
|
+
return a("This filter can not be edited here.");
|
|
2194
|
+
const s = o.input, c = s.filter;
|
|
2195
|
+
if (((ht = n.mapping) == null ? void 0 : ht.kind) === "save") {
|
|
2196
|
+
if (!n.mapping.draft.acceptance.ok)
|
|
2197
|
+
return { ok: !1, issues: n.mapping.draft.acceptance.issues };
|
|
2198
|
+
if (n.mapping.draft.inputId !== s.id)
|
|
2199
|
+
return a("The card mapping was prepared for another filter.");
|
|
2200
|
+
}
|
|
2201
|
+
const l = n.definition ? dn(n.definition) : c;
|
|
2202
|
+
if (l.kind === "global-date" && n.scope && !wo(n.scope))
|
|
2203
|
+
return a("The Global Date filter applies to regular tabs only.");
|
|
2204
|
+
const d = (yt = r.calendar) == null ? void 0 : yt.tz, u = n.definition !== void 0, f = n.forceSelection !== void 0 || u ? Fo(
|
|
2205
|
+
n.forceSelection ?? s.forceSelection,
|
|
2206
|
+
l,
|
|
2207
|
+
d
|
|
2208
|
+
) : s.forceSelection ? !0 : void 0, m = n.variableName !== void 0 ? ln(
|
|
2209
|
+
e,
|
|
2210
|
+
{ name: n.variableName },
|
|
2211
|
+
{ exclude: { source: "input", inputId: s.id } }
|
|
2212
|
+
) : s.variableName, p = u && (c.title || c.column) !== (l.title || l.column), y = n.label ?? (p ? l.title || l.column || l.id : void 0), g = u && c.hide !== l.hide, h = u && c.toolbarWidth !== l.toolbarWidth, C = (O) => {
|
|
2213
|
+
var xt, wt;
|
|
2214
|
+
const x = { ...O };
|
|
2215
|
+
if (y !== void 0 && (x.label = y), n.variableName !== void 0 && (x.variableName = m), n.scope && (x.scope = n.scope), g || h) {
|
|
2216
|
+
const Oe = fn(l);
|
|
2217
|
+
x.presentation = { ...O.presentation }, g && (x.presentation.placement = Oe.placement), h && (Oe.widthPx === void 0 ? delete x.presentation.widthPx : x.presentation.widthPx = Oe.widthPx);
|
|
2218
|
+
}
|
|
2219
|
+
return (n.forceSelection !== void 0 || u) && (f ? x.forceSelection = f : delete x.forceSelection), n.requiredAtExecution !== void 0 && (n.requiredAtExecution ? x.requiredAtExecution = !0 : delete x.requiredAtExecution), $e(x, "optionSource", n.optionSource), $e(x, "optionDependencies", n.optionDependencies), $e(x, "optionPopulation", n.optionPopulation), ((xt = n.mapping) == null ? void 0 : xt.kind) === "save" && n.mapping.draft.acceptance.ok ? x.application = n.mapping.draft.acceptance.application : ((wt = n.mapping) == null ? void 0 : wt.kind) === "remove" && delete x.application, x;
|
|
2220
|
+
}, v = n.label !== void 0 && n.label !== s.label && n.label !== l.title ? n.label : void 0, I = u || n.variableName !== void 0 || v !== void 0, b = (O) => ({
|
|
2221
|
+
...O,
|
|
2222
|
+
...n.variableName !== void 0 ? { variableName: m } : {},
|
|
2223
|
+
...v !== void 0 ? { title: v } : {}
|
|
2224
|
+
}), S = Array.isArray(e.inputs) ? [...e.inputs] : [], P = S.findIndex((O) => O.id === s.id), D = S[P];
|
|
2225
|
+
if (P < 0 || (D == null ? void 0 : D.kind) !== "filter" || !D.filter)
|
|
2226
|
+
return a("This filter can not be edited here.");
|
|
2227
|
+
const L = C(
|
|
2228
|
+
I ? {
|
|
2229
|
+
...D,
|
|
2230
|
+
filter: b(l)
|
|
2231
|
+
} : D
|
|
2232
|
+
);
|
|
2233
|
+
u && (L.exports = un(l)), S[P] = L;
|
|
2234
|
+
const j = rt({
|
|
2235
|
+
inputs: [L],
|
|
2236
|
+
dashboardFilters: []
|
|
2237
|
+
});
|
|
2238
|
+
if (!j.ok)
|
|
2239
|
+
return a(
|
|
2240
|
+
((bt = j.issues[0]) == null ? void 0 : bt.message) ?? "These settings could not be saved.",
|
|
2241
|
+
j.issues[0]
|
|
2242
|
+
);
|
|
2243
|
+
let E = { ...e, inputs: S };
|
|
2244
|
+
const ee = Y(E), k = ee.findFilterInput({ filterId: l.id });
|
|
2245
|
+
if (!k)
|
|
2246
|
+
return a(
|
|
2247
|
+
((vt = ee.issues[0]) == null ? void 0 : vt.message) ?? "These settings could not be saved."
|
|
2248
|
+
);
|
|
2249
|
+
const q = n.variableName !== void 0 || n.scope !== void 0 ? To(E, k.input) : void 0;
|
|
2250
|
+
if (q)
|
|
2251
|
+
return a(
|
|
2252
|
+
`Another filter on the same cards is already named "${q}". Choose another name.`
|
|
2253
|
+
);
|
|
2254
|
+
const B = [], G = {
|
|
2255
|
+
id: k.input.id,
|
|
2256
|
+
runtimeScope: k.input.runtimeScope
|
|
2257
|
+
};
|
|
2258
|
+
let $ = {
|
|
2259
|
+
defaultInputValues: E.defaultInputValues,
|
|
2260
|
+
dashboardInputValues: {}
|
|
2261
|
+
};
|
|
2262
|
+
const ue = ((It = n.values) == null ? void 0 : It.target) ?? {}, A = Mo(
|
|
2263
|
+
c,
|
|
2264
|
+
l,
|
|
2265
|
+
{
|
|
2266
|
+
defaultValueChanged: (Ct = n.values) == null ? void 0 : Ct.defaultChanged,
|
|
2267
|
+
selectionIdentityChanged: (Ft = n.values) == null ? void 0 : Ft.selectionIdentityChanged,
|
|
2268
|
+
...((St = n.values) == null ? void 0 : St.defaultComparisonSelection) !== void 0 ? {
|
|
2269
|
+
defaultComparisonChanged: !0,
|
|
2270
|
+
defaultComparisonSelection: n.values.defaultComparisonSelection ?? void 0
|
|
2271
|
+
} : {}
|
|
2272
|
+
},
|
|
2273
|
+
ue,
|
|
2274
|
+
r.calendar ?? void 0
|
|
2275
|
+
);
|
|
2276
|
+
if (A.defaultValueChanged || A.selectionIdentityChanged || A.defaultComparisonChanged) {
|
|
2277
|
+
const O = zn({
|
|
2278
|
+
state: { ...$, dashboardInputValues: {} },
|
|
2279
|
+
input: G,
|
|
2280
|
+
settings: A
|
|
2281
|
+
});
|
|
2282
|
+
$ = { ...$, defaultInputValues: O.defaultInputValues }, A.selectionIdentityChanged && B.push({
|
|
2283
|
+
kind: "clear",
|
|
2284
|
+
inputId: G.id,
|
|
2285
|
+
target: A.target
|
|
2286
|
+
}), A.defaultValueChanged && B.push({
|
|
2287
|
+
kind: "resetToDefault",
|
|
2288
|
+
inputId: G.id,
|
|
2289
|
+
target: A.target,
|
|
2290
|
+
...A.defaultFilterValue ? { filterValue: A.defaultFilterValue } : {}
|
|
2291
|
+
}), A.defaultComparisonChanged && B.push({
|
|
2292
|
+
kind: "setDefaultComparison",
|
|
2293
|
+
inputId: G.id,
|
|
2294
|
+
target: A.target
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
if (n.scope && k.input.runtimeScope !== "shared") {
|
|
2298
|
+
const O = Do(
|
|
2299
|
+
E,
|
|
2300
|
+
s,
|
|
2301
|
+
k.input,
|
|
2302
|
+
$.defaultInputValues
|
|
2303
|
+
);
|
|
2304
|
+
$ = {
|
|
2305
|
+
...$,
|
|
2306
|
+
defaultInputValues: O.defaultInputValues
|
|
2307
|
+
}, B.push(
|
|
2308
|
+
...O.dropped.map((x) => ({
|
|
2309
|
+
kind: "dropTargetSlot",
|
|
2310
|
+
inputId: G.id,
|
|
2311
|
+
target: x
|
|
2312
|
+
}))
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
return E = ko(E, $), {
|
|
2316
|
+
ok: !0,
|
|
2317
|
+
dashboard: E,
|
|
2318
|
+
inputId: k.input.id,
|
|
2319
|
+
valueEffects: B
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
function $c(e) {
|
|
2323
|
+
let t = kt({
|
|
2324
|
+
dashboard: e.before,
|
|
2325
|
+
runtimeValues: e.dashboardInputValues,
|
|
2326
|
+
calendar: e.calendar
|
|
2327
|
+
});
|
|
2328
|
+
const n = Y(e.after), r = (i) => {
|
|
2329
|
+
var o;
|
|
2330
|
+
return (o = n.findFilterInput({ inputId: i })) == null ? void 0 : o.input;
|
|
2331
|
+
};
|
|
2332
|
+
for (const i of e.effects)
|
|
2333
|
+
switch (i.kind) {
|
|
2334
|
+
case "resetToDefault":
|
|
2335
|
+
case "clear":
|
|
2336
|
+
case "setDefaultComparison": {
|
|
2337
|
+
const o = r(i.inputId);
|
|
2338
|
+
if (!o) break;
|
|
2339
|
+
t = zn({
|
|
2340
|
+
state: { dashboardInputValues: t },
|
|
2341
|
+
input: o,
|
|
2342
|
+
settings: {
|
|
2343
|
+
target: i.target,
|
|
2344
|
+
defaultValueChanged: i.kind === "resetToDefault",
|
|
2345
|
+
defaultFilterValue: i.kind === "resetToDefault" ? i.filterValue : void 0,
|
|
2346
|
+
selectionIdentityChanged: i.kind === "clear",
|
|
2347
|
+
defaultComparisonChanged: i.kind === "setDefaultComparison"
|
|
2348
|
+
}
|
|
2349
|
+
}).dashboardInputValues;
|
|
2350
|
+
break;
|
|
2351
|
+
}
|
|
2352
|
+
case "dropTargetSlot": {
|
|
2353
|
+
const o = r(i.inputId);
|
|
2354
|
+
if (!o) break;
|
|
2355
|
+
t = tt(
|
|
2356
|
+
t,
|
|
2357
|
+
o,
|
|
2358
|
+
i.target
|
|
2359
|
+
);
|
|
2360
|
+
break;
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2363
|
+
return kt({
|
|
2364
|
+
dashboard: e.after,
|
|
2365
|
+
runtimeValues: t,
|
|
2366
|
+
calendar: e.calendar
|
|
2367
|
+
});
|
|
2368
|
+
}
|
|
2369
|
+
function wo(e) {
|
|
2370
|
+
var t;
|
|
2371
|
+
return e.kind !== "documentSections" && (e.kind !== "allSheets" || ((t = e.sheetKinds) == null ? void 0 : t.length) === 1 && e.sheetKinds[0] === "dashboard");
|
|
2372
|
+
}
|
|
2373
|
+
function $e(e, t, n) {
|
|
2374
|
+
n !== void 0 && (n === null ? delete e[t] : e[t] = n);
|
|
2375
|
+
}
|
|
2376
|
+
function To(e, t) {
|
|
2377
|
+
const n = [
|
|
2378
|
+
...Y(e).inputs.map((i) => i.input),
|
|
2379
|
+
...(Array.isArray(e.inputs) ? e.inputs : []).filter(
|
|
2380
|
+
(i) => i.kind === "control"
|
|
2381
|
+
)
|
|
2382
|
+
].filter(
|
|
2383
|
+
(i) => i.id !== t.id && i.variableName === t.variableName
|
|
2384
|
+
);
|
|
2385
|
+
if (!n.length) return;
|
|
2386
|
+
const r = Rt(e, t);
|
|
2387
|
+
return n.some(
|
|
2388
|
+
(i) => [...Rt(e, i)].some(
|
|
2389
|
+
(o) => r.has(o)
|
|
2390
|
+
)
|
|
2391
|
+
) ? t.variableName : void 0;
|
|
2392
|
+
}
|
|
2393
|
+
function Do(e, t, n, r) {
|
|
2394
|
+
var d, u;
|
|
2395
|
+
const i = [], o = bn(e), a = (f) => Wt(t, f, o), s = (f) => Wt(n, f, o), c = [];
|
|
2396
|
+
if (n.runtimeScope === "perSheet")
|
|
2397
|
+
for (const f of o.values())
|
|
2398
|
+
c.push({ sheetId: f.sheetId, sheetKind: f.sheetKind });
|
|
2399
|
+
else if (n.runtimeScope === "perCard") {
|
|
2400
|
+
for (const f of vn(e))
|
|
2401
|
+
c.push({
|
|
2402
|
+
sheetId: f.sheetId,
|
|
2403
|
+
cardId: f.cardId,
|
|
2404
|
+
sheetKind: (d = o.get(f.sheetId)) == null ? void 0 : d.sheetKind
|
|
2405
|
+
});
|
|
2406
|
+
for (const f of e.variables ?? [])
|
|
2407
|
+
c.push(...ta(e, f.id));
|
|
2408
|
+
} else if (n.runtimeScope === "perDocumentSection")
|
|
2409
|
+
for (const f of e.sheets ?? [])
|
|
2410
|
+
for (const m of ((u = f.document) == null ? void 0 : u.sections) ?? [])
|
|
2411
|
+
c.push({
|
|
2412
|
+
sheetId: f.id,
|
|
2413
|
+
sectionId: m.id,
|
|
2414
|
+
sheetKind: "document"
|
|
2415
|
+
});
|
|
2416
|
+
let l = r;
|
|
2417
|
+
for (const f of c) {
|
|
2418
|
+
if (s(f)) continue;
|
|
2419
|
+
const m = !!(l && nt(l, n, f));
|
|
2420
|
+
if (m && (l = tt(l, n, f)), m || a(f)) {
|
|
2421
|
+
const { sheetKind: p, ...y } = f;
|
|
2422
|
+
i.push(y);
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
return { defaultInputValues: l, dropped: i };
|
|
2426
|
+
}
|
|
2427
|
+
function Wt(e, t, n) {
|
|
2428
|
+
if (e.runtimeScope === "perSheet" && t.sheetId && !t.cardId && !t.sectionId) {
|
|
2429
|
+
const r = n.get(t.sheetId);
|
|
2430
|
+
return r ? In(e, r) : !1;
|
|
2431
|
+
}
|
|
2432
|
+
return na(e, t);
|
|
2433
|
+
}
|
|
2434
|
+
function ko(e, t) {
|
|
2435
|
+
const n = { ...e };
|
|
2436
|
+
return t.defaultInputValues && Object.keys(t.defaultInputValues).length ? n.defaultInputValues = t.defaultInputValues : e.defaultInputValues !== void 0 && delete n.defaultInputValues, n;
|
|
2437
|
+
}
|
|
2438
|
+
function Mo(e, t, n, r, i) {
|
|
2439
|
+
const o = !!(n != null && n.defaultValueChanged || n != null && n.selectionIdentityChanged) || ni(e, t);
|
|
2440
|
+
return {
|
|
2441
|
+
...n,
|
|
2442
|
+
target: (n == null ? void 0 : n.target) ?? r,
|
|
2443
|
+
defaultValueChanged: o,
|
|
2444
|
+
defaultFilterValue: o ? re(t, i) : void 0
|
|
2445
|
+
};
|
|
2446
|
+
}
|
|
2447
|
+
function zn(e) {
|
|
2448
|
+
const { settings: t } = e;
|
|
2449
|
+
if (!t) return e.state;
|
|
2450
|
+
const n = e.input;
|
|
2451
|
+
let r = e.state.dashboardInputValues, i = e.state.defaultInputValues;
|
|
2452
|
+
if (t.selectionIdentityChanged && (r = Mt(
|
|
2453
|
+
r,
|
|
2454
|
+
n,
|
|
2455
|
+
t.target,
|
|
2456
|
+
{ status: "cleared" }
|
|
2457
|
+
)), t.defaultValueChanged) {
|
|
2458
|
+
const o = nt(
|
|
2459
|
+
i,
|
|
2460
|
+
n,
|
|
2461
|
+
t.target
|
|
2462
|
+
);
|
|
2463
|
+
let a = tt(
|
|
2464
|
+
i || {},
|
|
2465
|
+
n,
|
|
2466
|
+
t.target
|
|
2467
|
+
);
|
|
2468
|
+
t.defaultFilterValue ? a = Ot(
|
|
2469
|
+
a,
|
|
2470
|
+
n,
|
|
2471
|
+
t.target,
|
|
2472
|
+
{
|
|
2473
|
+
status: "set",
|
|
2474
|
+
value: {
|
|
2475
|
+
kind: "filter",
|
|
2476
|
+
filterValue: t.defaultFilterValue
|
|
2477
|
+
},
|
|
2478
|
+
...o != null && o.comparisonSelection ? { comparisonSelection: o.comparisonSelection } : {}
|
|
2479
|
+
}
|
|
2480
|
+
) : o != null && o.comparisonSelection && (a = Ot(
|
|
2481
|
+
a,
|
|
2482
|
+
n,
|
|
2483
|
+
t.target,
|
|
2484
|
+
{ comparisonSelection: o.comparisonSelection }
|
|
2485
|
+
)), i = Object.keys(a).length ? a : void 0, r = Mt(
|
|
2486
|
+
r,
|
|
2487
|
+
n,
|
|
2488
|
+
t.target,
|
|
2489
|
+
t.defaultFilterValue ? {
|
|
2490
|
+
status: "set",
|
|
2491
|
+
value: {
|
|
2492
|
+
kind: "filter",
|
|
2493
|
+
filterValue: t.defaultFilterValue
|
|
2494
|
+
}
|
|
2495
|
+
} : { status: "cleared" }
|
|
2496
|
+
);
|
|
2497
|
+
}
|
|
2498
|
+
return t.defaultComparisonChanged && (i = _t(
|
|
2499
|
+
i || {},
|
|
2500
|
+
n,
|
|
2501
|
+
t.target,
|
|
2502
|
+
t.defaultComparisonSelection
|
|
2503
|
+
), Object.keys(i).length || (i = void 0), r = _t(
|
|
2504
|
+
r,
|
|
2505
|
+
n,
|
|
2506
|
+
t.target,
|
|
2507
|
+
void 0
|
|
2508
|
+
)), {
|
|
2509
|
+
...e.state,
|
|
2510
|
+
dashboardInputValues: r,
|
|
2511
|
+
defaultInputValues: i
|
|
2512
|
+
};
|
|
2513
|
+
}
|
|
2514
|
+
const Z = (e) => Array.isArray(e.inputs) ? e.inputs : [];
|
|
2515
|
+
function Me(e, t) {
|
|
2516
|
+
const n = Z(e).find((r) => r.id === t);
|
|
2517
|
+
if (!n || n.kind !== "filter")
|
|
2518
|
+
throw new F("filter_not_found", `No filter ${t} on this dashboard.`, "Read the outline again and use its filter ids.");
|
|
2519
|
+
return n;
|
|
2520
|
+
}
|
|
2521
|
+
function jn(e, t) {
|
|
2522
|
+
const n = Cn(e, t);
|
|
2523
|
+
return (n == null ? void 0 : n.kind) === "variable" ? `the variable ${n.variable.name}` : w(n == null ? void 0 : n.card.title);
|
|
2524
|
+
}
|
|
2525
|
+
function Gn(e, t) {
|
|
2526
|
+
if (!Cn(e, t))
|
|
2527
|
+
throw new F("card_not_found", `No card or variable ${t} on this dashboard.`, "Read the outline again and use its card ids and variable names.");
|
|
2528
|
+
}
|
|
2529
|
+
function Oo(e, t, n) {
|
|
2530
|
+
const r = Y(e), i = r.findFilterInput({ inputId: t });
|
|
2531
|
+
return i ? r.reachedCards({ inputId: t }).filter(
|
|
2532
|
+
(o) => ["bound", "automatic", "sql", "relationshipApplied"].includes(
|
|
2533
|
+
ai(i.input, o.card, n).reach
|
|
2534
|
+
)
|
|
2535
|
+
).length : 0;
|
|
2536
|
+
}
|
|
2537
|
+
function _o(e, t) {
|
|
2538
|
+
return Wn(e, t, "relationship");
|
|
2539
|
+
}
|
|
2540
|
+
function Po(e, t) {
|
|
2541
|
+
return Wn(e, t, "sqlTemplate");
|
|
2542
|
+
}
|
|
2543
|
+
function Wn(e, t, n) {
|
|
2544
|
+
const r = Y(e), i = r.findFilterInput({ inputId: t });
|
|
2545
|
+
return i ? r.reachedCards({ inputId: t }).filter((o) => oi(i.input, o.card) === n).length : 0;
|
|
2546
|
+
}
|
|
2547
|
+
function Hn(e, t) {
|
|
2548
|
+
if (t.scope.kind === "allSheets") return "every sheet";
|
|
2549
|
+
if (t.scope.kind !== "sheets") return "its cards";
|
|
2550
|
+
const n = [...bn(e).values()].filter((r) => In(t, r));
|
|
2551
|
+
return we(n.map((r) => {
|
|
2552
|
+
var i, o;
|
|
2553
|
+
return ((o = (i = e.sheets) == null ? void 0 : i.find((a) => a.id === r.sheetId)) == null ? void 0 : o.title) ?? r.sheetId;
|
|
2554
|
+
}));
|
|
2555
|
+
}
|
|
2556
|
+
const Yn = (e) => {
|
|
2557
|
+
var t;
|
|
2558
|
+
return ((t = e.filter) == null ? void 0 : t.type) === "single" ? "single select" : "multi select";
|
|
2559
|
+
};
|
|
2560
|
+
function Xn(e) {
|
|
2561
|
+
var t, n, r;
|
|
2562
|
+
if ((n = (t = e.filter) == null ? void 0 : t.defaultValues) != null && n.length) return `default ${e.filter.defaultValues.join(", ")}`;
|
|
2563
|
+
if ((r = e.filter) != null && r.defaultDateFilter) return "a default period";
|
|
2564
|
+
}
|
|
2565
|
+
function de(e) {
|
|
2566
|
+
return T.plain("filter", e);
|
|
2567
|
+
}
|
|
2568
|
+
function Ao(e, t) {
|
|
2569
|
+
const { input: n } = t, r = Z(e);
|
|
2570
|
+
if (r.some((d) => d.id === n.id))
|
|
2571
|
+
throw new F("filter_id_taken", `A filter with id ${n.id} is already on this dashboard.`);
|
|
2572
|
+
if (Y(e).findFilterInput({ filterId: n.filter.id }))
|
|
2573
|
+
throw new F("filter_id_taken", `A filter definition with id ${n.filter.id} is already on this dashboard.`);
|
|
2574
|
+
const i = { ...e, inputs: [...r, n] }, o = Oo(i, n.id), a = _o(i, n.id), s = Po(i, n.id), c = we([
|
|
2575
|
+
...a ? [`may filter ${a} more through the domain's relationships`] : [],
|
|
2576
|
+
...s ? [`may filter ${s} more through ${s === 1 ? "its" : "their"} SQL`] : []
|
|
2577
|
+
]), l = [Yn(n), Xn(n)].filter(Boolean).join(", ");
|
|
2578
|
+
return {
|
|
2579
|
+
dashboard: i,
|
|
2580
|
+
created: [
|
|
2581
|
+
{
|
|
2582
|
+
kind: "filter",
|
|
2583
|
+
id: n.id,
|
|
2584
|
+
title: n.label,
|
|
2585
|
+
...t.changeIndex !== void 0 ? { changeIndex: t.changeIndex } : {}
|
|
2586
|
+
}
|
|
2587
|
+
],
|
|
2588
|
+
clauses: [
|
|
2589
|
+
de(
|
|
2590
|
+
`adds the filter ${w(n.label)} (${l}) to ${Hn(i, n)}; it filters ${o} card${o === 1 ? "" : "s"}${c ? ` and ${c}` : ""}`
|
|
2591
|
+
)
|
|
2592
|
+
]
|
|
2593
|
+
};
|
|
2594
|
+
}
|
|
2595
|
+
function No(e, t, n) {
|
|
2596
|
+
const r = xo(e, { inputId: t.filterId }, t.settings, {
|
|
2597
|
+
calendar: n.calendar
|
|
2598
|
+
});
|
|
2599
|
+
if (!r.ok) {
|
|
2600
|
+
const [a] = r.issues;
|
|
2601
|
+
throw new F(
|
|
2602
|
+
(a == null ? void 0 : a.code) === "inputNotFound" ? "filter_not_found" : "filter_invalid",
|
|
2603
|
+
(a == null ? void 0 : a.message) ?? "These filter settings could not be saved.",
|
|
2604
|
+
(a == null ? void 0 : a.code) === "inputNotFound" ? "Read the outline again and use its filter ids." : "Change the filter settings and propose again.",
|
|
2605
|
+
{ issues: r.issues }
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
const i = Z(e).find((a) => a.id === r.inputId), o = Z(r.dashboard).find((a) => a.id === r.inputId);
|
|
2609
|
+
return {
|
|
2610
|
+
dashboard: r.dashboard,
|
|
2611
|
+
runtimeEffects: [{ kind: "filter_value", effects: r.valueEffects }],
|
|
2612
|
+
clauses: [de(`changes the filter ${w((i == null ? void 0 : i.label) ?? o.label)}: ${Eo(r.dashboard, i, o)}`)]
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2615
|
+
function Eo(e, t, n) {
|
|
2616
|
+
var a, s, c, l, d, u;
|
|
2617
|
+
if (!t) return "updates its settings";
|
|
2618
|
+
const r = [];
|
|
2619
|
+
t.label !== n.label && r.push(`renames it ${w(n.label)}`), (((a = t.filter) == null ? void 0 : a.type) ?? "multiple") !== (((s = n.filter) == null ? void 0 : s.type) ?? "multiple") && r.push(`makes it ${Yn(n)}`);
|
|
2620
|
+
const i = JSON.stringify([((c = t.filter) == null ? void 0 : c.defaultValues) ?? null, ((l = t.filter) == null ? void 0 : l.defaultDateFilter) ?? null]), o = JSON.stringify([((d = n.filter) == null ? void 0 : d.defaultValues) ?? null, ((u = n.filter) == null ? void 0 : u.defaultDateFilter) ?? null]);
|
|
2621
|
+
if (i !== o) {
|
|
2622
|
+
const f = Xn(n);
|
|
2623
|
+
r.push(f ? `sets its ${f.replace(/^default /, "default to ").replace(/^a default period$/, "default period")}` : "removes its default");
|
|
2624
|
+
}
|
|
2625
|
+
return JSON.stringify(t.scope) !== JSON.stringify(n.scope) && r.push(`applies it to ${Hn(e, n)}`), r.length ? we(r) : "keeps its settings";
|
|
2626
|
+
}
|
|
2627
|
+
function $o(e, t) {
|
|
2628
|
+
const n = Me(e, t);
|
|
2629
|
+
return {
|
|
2630
|
+
dashboard: {
|
|
2631
|
+
...e,
|
|
2632
|
+
inputs: Z(e).filter((i) => i.id !== t),
|
|
2633
|
+
defaultInputValues: ii(e.defaultInputValues, t)
|
|
2634
|
+
},
|
|
2635
|
+
runtimeEffects: [{ kind: "input_removed", inputId: t }],
|
|
2636
|
+
clauses: [de(`removes the filter ${w(n.label)}`)]
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
function Ro(e, t, n) {
|
|
2640
|
+
var a;
|
|
2641
|
+
Gn(e, n);
|
|
2642
|
+
const r = ia(t.scope, n);
|
|
2643
|
+
if (!r)
|
|
2644
|
+
throw new F(
|
|
2645
|
+
"filter_invalid",
|
|
2646
|
+
"This filter applies to Document sections, so it can't leave out one card.",
|
|
2647
|
+
"Change it in the editor."
|
|
2648
|
+
);
|
|
2649
|
+
const i = { ...t, scope: r }, o = rt({ inputs: [i], dashboardFilters: [] });
|
|
2650
|
+
if (!o.ok)
|
|
2651
|
+
throw new F("filter_invalid", ((a = o.issues[0]) == null ? void 0 : a.message) ?? "This filter could not be saved.", "Change it in the editor.");
|
|
2652
|
+
return {
|
|
2653
|
+
...e,
|
|
2654
|
+
inputs: Z(e).map((s) => s.id === t.id ? i : s)
|
|
2655
|
+
};
|
|
2656
|
+
}
|
|
2657
|
+
function Qn(e, t, n, r, i) {
|
|
2658
|
+
var d, u;
|
|
2659
|
+
const o = Me(e, t);
|
|
2660
|
+
Gn(e, n);
|
|
2661
|
+
const a = [...((d = o.application) == null ? void 0 : d.cards) ?? []], s = a.findIndex((f) => f.cardId === n);
|
|
2662
|
+
s >= 0 ? a[s] = r : a.push(r);
|
|
2663
|
+
const c = {
|
|
2664
|
+
...o,
|
|
2665
|
+
...i ? { scope: i } : {},
|
|
2666
|
+
application: { ...o.application ?? { kind: "cardMappings" }, cards: a }
|
|
2667
|
+
}, l = rt({ inputs: [c], dashboardFilters: [] });
|
|
2668
|
+
if (!l.ok)
|
|
2669
|
+
throw new F(
|
|
2670
|
+
"filter_invalid",
|
|
2671
|
+
((u = l.issues[0]) == null ? void 0 : u.message) ?? "This filter mapping could not be saved.",
|
|
2672
|
+
"Change the mapping and propose again."
|
|
2673
|
+
);
|
|
2674
|
+
return {
|
|
2675
|
+
...e,
|
|
2676
|
+
inputs: Z(e).map((f) => f.id === t ? c : f)
|
|
2677
|
+
};
|
|
2678
|
+
}
|
|
2679
|
+
function Ko(e) {
|
|
2680
|
+
switch (e.kind) {
|
|
2681
|
+
case "field":
|
|
2682
|
+
return `by ${e.field.name}`;
|
|
2683
|
+
case "relationship":
|
|
2684
|
+
return "through a chosen relationship path";
|
|
2685
|
+
default:
|
|
2686
|
+
return String(e.kind);
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
function Vo(e, t) {
|
|
2690
|
+
const n = Me(e, t.filterId), r = { ...t.binding, kind: "bound", cardId: t.cardId }, i = ra(n.scope, t.cardId), o = i !== n.scope;
|
|
2691
|
+
return {
|
|
2692
|
+
dashboard: Qn(e, t.filterId, t.cardId, r, o ? i : void 0),
|
|
2693
|
+
clauses: [
|
|
2694
|
+
de(
|
|
2695
|
+
`makes ${w(n.label)} filter ${jn(e, t.cardId)} ${Ko(r.target)}${o ? ", which it used to leave out" : ""}`
|
|
2696
|
+
)
|
|
2697
|
+
]
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2700
|
+
function Lo(e, t) {
|
|
2701
|
+
var i;
|
|
2702
|
+
const n = Me(e, t.filterId);
|
|
2703
|
+
return {
|
|
2704
|
+
dashboard: ((i = n.filter) == null ? void 0 : i.kind) === "global-date" ? Ro(e, n, t.cardId) : Qn(e, t.filterId, t.cardId, { kind: "excluded", cardId: t.cardId }),
|
|
2705
|
+
clauses: [de(`stops ${w(n.label)} from filtering ${jn(e, t.cardId)}`)]
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
function mt(e, t) {
|
|
2709
|
+
const n = e[0];
|
|
2710
|
+
throw new F(
|
|
2711
|
+
(n == null ? void 0 : n.code) === "unknownVariable" ? "variable_not_found" : "variable_invalid",
|
|
2712
|
+
(n == null ? void 0 : n.message) ?? t,
|
|
2713
|
+
n == null ? void 0 : n.fix,
|
|
2714
|
+
{ issues: e }
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
function We(e, t) {
|
|
2718
|
+
const n = (e.variables ?? []).find((r) => r.id === t);
|
|
2719
|
+
if (!n)
|
|
2720
|
+
throw new F("variable_not_found", `No variable ${t} on this dashboard.`, "Read the outline again and use its variable names.");
|
|
2721
|
+
return n;
|
|
2722
|
+
}
|
|
2723
|
+
function Jn(e) {
|
|
2724
|
+
var r;
|
|
2725
|
+
const t = no(e), n = t.charAt(0).toLowerCase() + t.slice(1);
|
|
2726
|
+
return e.get.kind === "only" && !((r = e.query.sql) != null && r.trim()) ? `${n}. When more than one matches it shows nothing` : n;
|
|
2727
|
+
}
|
|
2728
|
+
function qo(e, t) {
|
|
2729
|
+
const n = it(e, { kind: "add", variable: t.variable });
|
|
2730
|
+
n.ok || mt(n.issues, "This variable could not be added.");
|
|
2731
|
+
const { variable: r } = t;
|
|
2732
|
+
return {
|
|
2733
|
+
dashboard: n.dashboard,
|
|
2734
|
+
created: [{ kind: "variable", id: r.id, title: r.name, ...t.changeIndex !== void 0 ? { changeIndex: t.changeIndex } : {} }],
|
|
2735
|
+
queryFrames: n.queryFrames,
|
|
2736
|
+
clauses: [T.plain("variable", `adds the variable ${r.name}: ${Jn(r)}`)]
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
function Bo(e, t) {
|
|
2740
|
+
const n = We(e, t.variableId), r = Object.fromEntries(Object.entries(t.patch).map(([m, p]) => [m, p === null ? void 0 : p])), i = it(e, { kind: "update", id: t.variableId, patch: r });
|
|
2741
|
+
i.ok || mt(i.issues, "This variable could not be changed.");
|
|
2742
|
+
const o = We(i.dashboard, t.variableId), a = [];
|
|
2743
|
+
t.patch.name !== void 0 && t.patch.name !== n.name && a.push(T.plain("variable", `renames the variable ${n.name} to ${o.name}`));
|
|
2744
|
+
const { name: s, label: c, ...l } = n, { name: d, label: u, ...f } = o;
|
|
2745
|
+
return JSON.stringify(l) !== JSON.stringify(f) ? a.push(T.plain("variable", `changes the variable ${o.name}: ${Jn(o)}`)) : n.label !== o.label && a.push(T.plain("variable", `labels the variable ${o.name} ${w(o.label ?? o.name)}`)), {
|
|
2746
|
+
dashboard: i.dashboard,
|
|
2747
|
+
queryFrames: i.queryFrames,
|
|
2748
|
+
clauses: a.length ? a : [T.plain("variable", `changes nothing on the variable ${o.name}`)]
|
|
2749
|
+
};
|
|
2750
|
+
}
|
|
2751
|
+
function Uo(e, t) {
|
|
2752
|
+
const n = We(e, t.variableId), r = it(e, { kind: "remove", id: t.variableId, confirmed: !1 });
|
|
2753
|
+
r.ok || mt(r.issues, "This variable could not be removed.");
|
|
2754
|
+
const i = r.removedMappings ? ` and its ${r.removedMappings === 1 ? "filter mapping" : `${r.removedMappings} filter mappings`}` : "";
|
|
2755
|
+
return {
|
|
2756
|
+
dashboard: r.dashboard,
|
|
2757
|
+
clauses: [T.plain("variable", `removes the variable ${n.name}${i}`)]
|
|
2758
|
+
};
|
|
2759
|
+
}
|
|
2760
|
+
function Zn(e) {
|
|
2761
|
+
return e.cards.length < aa;
|
|
2762
|
+
}
|
|
2763
|
+
function zo(e) {
|
|
2764
|
+
return e.kpi.layout === "tiles" && e.cards.length + 1 > Fn;
|
|
2765
|
+
}
|
|
2766
|
+
function jo(e, t) {
|
|
2767
|
+
return !Zn(e) || t.type !== "kpi" || e.cards.some(({ id: n }) => n === t.id) ? e : {
|
|
2768
|
+
...e,
|
|
2769
|
+
cards: [...e.cards, t],
|
|
2770
|
+
kpi: zo(e) ? { ...e.kpi, layout: "lines" } : e.kpi
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
function Go(e, t) {
|
|
2774
|
+
if (e.cards.length <= 1) return e;
|
|
2775
|
+
const n = e.cards.filter(({ id: r }) => r !== t);
|
|
2776
|
+
return n.length === e.cards.length ? e : { ...e, cards: n };
|
|
2777
|
+
}
|
|
2778
|
+
function er(e) {
|
|
2779
|
+
return e.cards.length <= Fn;
|
|
2780
|
+
}
|
|
2781
|
+
function Wo(e, t) {
|
|
2782
|
+
const n = { ...e.kpi, ...t };
|
|
2783
|
+
return n.layout === "tiles" && !er(e) ? e : { ...e, kpi: n };
|
|
2784
|
+
}
|
|
2785
|
+
const Ho = ["table"], Yo = ["matrixTable"];
|
|
2786
|
+
function Ht(e, t, n) {
|
|
2787
|
+
return {
|
|
2788
|
+
id: e.section(),
|
|
2789
|
+
type: "table",
|
|
2790
|
+
title: n,
|
|
2791
|
+
card: {
|
|
2792
|
+
id: e.card(),
|
|
2793
|
+
title: n,
|
|
2794
|
+
type: t,
|
|
2795
|
+
preferences: {
|
|
2796
|
+
tablePrefs: {
|
|
2797
|
+
density: "compact",
|
|
2798
|
+
tableStyle: {
|
|
2799
|
+
headerStyle: "filled",
|
|
2800
|
+
stripedRows: !1,
|
|
2801
|
+
gridLines: "horizontal",
|
|
2802
|
+
wrapText: !1,
|
|
2803
|
+
totals: {
|
|
2804
|
+
enabled: !1
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
},
|
|
2810
|
+
table: {
|
|
2811
|
+
totalsRow: !1,
|
|
2812
|
+
repeatHeaderOnPageBreak: !0,
|
|
2813
|
+
rowHeightPx: 28
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
function tr(e) {
|
|
2818
|
+
return { id: e, title: "KPI", type: "kpi" };
|
|
2819
|
+
}
|
|
2820
|
+
const V = {
|
|
2821
|
+
text: {
|
|
2822
|
+
id: "text",
|
|
2823
|
+
label: "Text",
|
|
2824
|
+
description: "Headings, notes and input values.",
|
|
2825
|
+
group: "content",
|
|
2826
|
+
addable: !0,
|
|
2827
|
+
cardTypes: [],
|
|
2828
|
+
create: (e) => ({
|
|
2829
|
+
id: e.section(),
|
|
2830
|
+
type: "text",
|
|
2831
|
+
content: Bn("New text section")
|
|
2832
|
+
})
|
|
2833
|
+
},
|
|
2834
|
+
table: {
|
|
2835
|
+
id: "table",
|
|
2836
|
+
label: "Table",
|
|
2837
|
+
description: "Rows and columns from one dataset.",
|
|
2838
|
+
group: "data",
|
|
2839
|
+
addable: !0,
|
|
2840
|
+
cardTypes: Ho,
|
|
2841
|
+
create: (e) => Ht(e, "table", "Table")
|
|
2842
|
+
},
|
|
2843
|
+
matrix: {
|
|
2844
|
+
id: "matrix",
|
|
2845
|
+
label: "Matrix",
|
|
2846
|
+
description: "Grouped rows with subtotals, and optional column levels.",
|
|
2847
|
+
group: "data",
|
|
2848
|
+
addable: !0,
|
|
2849
|
+
cardTypes: Yo,
|
|
2850
|
+
create: (e) => Ht(e, "matrixTable", "Matrix")
|
|
2851
|
+
},
|
|
2852
|
+
kpi: {
|
|
2853
|
+
id: "kpi",
|
|
2854
|
+
label: "KPIs",
|
|
2855
|
+
description: "Headline numbers, each with its own dataset and filters.",
|
|
2856
|
+
group: "data",
|
|
2857
|
+
addable: !0,
|
|
2858
|
+
cardTypes: ["kpi"],
|
|
2859
|
+
create: (e) => ({
|
|
2860
|
+
id: e.section(),
|
|
2861
|
+
type: "kpi",
|
|
2862
|
+
cards: [tr(e.card())],
|
|
2863
|
+
kpi: { layout: "tiles" }
|
|
2864
|
+
})
|
|
2865
|
+
},
|
|
2866
|
+
chart: {
|
|
2867
|
+
id: "chart",
|
|
2868
|
+
label: "Chart",
|
|
2869
|
+
description: "Not available in documents.",
|
|
2870
|
+
group: "data",
|
|
2871
|
+
addable: !1,
|
|
2872
|
+
cardTypes: [],
|
|
2873
|
+
create: (e) => ({
|
|
2874
|
+
id: e.section(),
|
|
2875
|
+
type: "chart",
|
|
2876
|
+
card: { id: e.card(), title: "Chart", type: "bar" },
|
|
2877
|
+
heightPx: 240
|
|
2878
|
+
})
|
|
2879
|
+
},
|
|
2880
|
+
spacer: {
|
|
2881
|
+
id: "spacer",
|
|
2882
|
+
label: "Spacer",
|
|
2883
|
+
description: "Vertical space between sections.",
|
|
2884
|
+
group: "layout",
|
|
2885
|
+
addable: !0,
|
|
2886
|
+
cardTypes: [],
|
|
2887
|
+
create: (e) => ({ id: e.section(), type: "spacer", heightPx: 24 })
|
|
2888
|
+
},
|
|
2889
|
+
page_break: {
|
|
2890
|
+
id: "page_break",
|
|
2891
|
+
label: "Page break",
|
|
2892
|
+
description: "Start the next section on a new page.",
|
|
2893
|
+
group: "layout",
|
|
2894
|
+
addable: !0,
|
|
2895
|
+
cardTypes: [],
|
|
2896
|
+
create: (e) => ({ id: e.section(), type: "page_break" })
|
|
2897
|
+
}
|
|
2898
|
+
};
|
|
2899
|
+
function nr(e) {
|
|
2900
|
+
var t;
|
|
2901
|
+
switch (e.type) {
|
|
2902
|
+
case "table":
|
|
2903
|
+
return ((t = e.card) == null ? void 0 : t.type) === "matrixTable" ? V.matrix : V.table;
|
|
2904
|
+
case "kpi":
|
|
2905
|
+
return V.kpi;
|
|
2906
|
+
case "chart":
|
|
2907
|
+
return V.chart;
|
|
2908
|
+
case "text":
|
|
2909
|
+
return V.text;
|
|
2910
|
+
case "spacer":
|
|
2911
|
+
return V.spacer;
|
|
2912
|
+
case "page_break":
|
|
2913
|
+
return V.page_break;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
function Xo(e, t) {
|
|
2917
|
+
return nr(e).cardTypes.includes(t);
|
|
2918
|
+
}
|
|
2919
|
+
function rr(e, t) {
|
|
2920
|
+
if (Xo(e, t)) return null;
|
|
2921
|
+
const n = nr(e);
|
|
2922
|
+
return n.id === "table" ? "Table sections hold Table cards only" : n.id === "kpi" ? "KPI sections hold KPI cards only" : n.id === "matrix" ? "Matrix sections hold Matrix cards only" : `${n.label} sections do not accept this visual`;
|
|
2923
|
+
}
|
|
2924
|
+
function Qo(e, t, n) {
|
|
2925
|
+
if (!at(e).some(({ id: i }) => i === t))
|
|
2926
|
+
throw new Error(
|
|
2927
|
+
`Document section '${e.id}' has no card '${t}'.`
|
|
2928
|
+
);
|
|
2929
|
+
const r = rr(e, n.type);
|
|
2930
|
+
if (r)
|
|
2931
|
+
throw new Error(r);
|
|
2932
|
+
return Sn(
|
|
2933
|
+
e,
|
|
2934
|
+
(i) => i.id === t ? n : i
|
|
2935
|
+
);
|
|
2936
|
+
}
|
|
2937
|
+
const Jo = [
|
|
2938
|
+
{ id: "data", label: "Data" },
|
|
2939
|
+
{ id: "content", label: "Content" },
|
|
2940
|
+
{ id: "layout", label: "Layout" }
|
|
2941
|
+
];
|
|
2942
|
+
function Rc() {
|
|
2943
|
+
const e = Object.values(V).filter(
|
|
2944
|
+
(t) => t.addable
|
|
2945
|
+
);
|
|
2946
|
+
return Jo.map((t) => ({
|
|
2947
|
+
...t,
|
|
2948
|
+
kinds: e.filter((n) => n.group === t.id)
|
|
2949
|
+
})).filter((t) => t.kinds.length > 0);
|
|
2950
|
+
}
|
|
2951
|
+
const Zo = {
|
|
2952
|
+
header: ["title", "metadata"],
|
|
2953
|
+
footer: ["note", "pageInfo"]
|
|
2954
|
+
};
|
|
2955
|
+
class M extends Error {
|
|
2956
|
+
constructor(t) {
|
|
2957
|
+
super(t), this.name = "DocumentEditError";
|
|
2958
|
+
}
|
|
2959
|
+
}
|
|
2960
|
+
const Yt = 8, es = 240;
|
|
2961
|
+
function Kc() {
|
|
2962
|
+
return {
|
|
2963
|
+
section: () => `doc_section_${Ie()}`,
|
|
2964
|
+
card: () => `doc_card_${Ie()}`
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
function ts(e) {
|
|
2968
|
+
return Number.isFinite(e) ? Math.min(
|
|
2969
|
+
es,
|
|
2970
|
+
Math.max(Yt, Math.round(e))
|
|
2971
|
+
) : Yt;
|
|
2972
|
+
}
|
|
2973
|
+
function Vc(e, t, n, r) {
|
|
2974
|
+
const i = e.findIndex(({ id: s }) => s === t), o = e.findIndex(({ id: s }) => s === n);
|
|
2975
|
+
if (i === -1 || o === -1) return i;
|
|
2976
|
+
const a = r === "after" ? o + 1 : o;
|
|
2977
|
+
return i < a ? a - 1 : a;
|
|
2978
|
+
}
|
|
2979
|
+
const ns = /* @__PURE__ */ new Set(["table", "matrixTable", "kpi"]);
|
|
2980
|
+
function rs(e, t = {}) {
|
|
2981
|
+
const n = new Set(
|
|
2982
|
+
(e.sheets || []).flatMap(
|
|
2983
|
+
(r) => (r.frames || []).flatMap(
|
|
2984
|
+
(i) => i.visualId ? [i.id] : []
|
|
2985
|
+
)
|
|
2986
|
+
)
|
|
2987
|
+
);
|
|
2988
|
+
return vn(e).filter(
|
|
2989
|
+
(r) => ns.has(r.card.type) && !r.card.linkedSourceCardId && !(r.kind === "frameCard" && n.has(r.frameId)) && !(r.kind === "documentSectionCard" && r.sectionId === t.excludeSectionId) && !si(r.card)
|
|
2990
|
+
);
|
|
2991
|
+
}
|
|
2992
|
+
function is(e) {
|
|
2993
|
+
return e.type === "kpi" ? "kpi" : e.type === "matrixTable" ? "matrix" : "table";
|
|
2994
|
+
}
|
|
2995
|
+
function as(e, t, n) {
|
|
2996
|
+
const r = e.sections, i = (a) => ({
|
|
2997
|
+
...e,
|
|
2998
|
+
sections: a
|
|
2999
|
+
}), o = (a, s) => s ? { kind: "section", sectionId: a, cardId: s } : { kind: "section", sectionId: a };
|
|
3000
|
+
switch (t.type) {
|
|
3001
|
+
case "insert": {
|
|
3002
|
+
const a = V[t.kind];
|
|
3003
|
+
if (!a.addable)
|
|
3004
|
+
throw new M(`${a.label} sections cannot be added.`);
|
|
3005
|
+
const s = a.create(n.ids);
|
|
3006
|
+
return {
|
|
3007
|
+
document: i(Ke(r, s, t.index)),
|
|
3008
|
+
target: o(s.id)
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3011
|
+
case "copyCard": {
|
|
3012
|
+
const a = Re(t.source, n), c = V[is(a.card)].create({
|
|
3013
|
+
section: n.ids.section,
|
|
3014
|
+
card: () => a.card.id
|
|
3015
|
+
}), l = c.type === "kpi" ? { ...c, title: void 0, cards: [a.card] } : c.type === "table" ? { ...c, title: a.card.title || c.title, card: a.card } : c;
|
|
3016
|
+
return {
|
|
3017
|
+
document: i(Ke(r, l, t.index)),
|
|
3018
|
+
target: o(l.id),
|
|
3019
|
+
...a.calculatedFields ? { calculatedFields: a.calculatedFields } : {}
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
case "replaceWithCopy": {
|
|
3023
|
+
const a = K(r, t.sectionId);
|
|
3024
|
+
if (a.type !== "table")
|
|
3025
|
+
throw new M(
|
|
3026
|
+
"Only a table section can be replaced with a copied card."
|
|
3027
|
+
);
|
|
3028
|
+
const s = Re(t.source, n, t.sectionId), c = rr(a, s.card.type);
|
|
3029
|
+
if (c) throw new M(c);
|
|
3030
|
+
const l = {
|
|
3031
|
+
...a,
|
|
3032
|
+
title: s.card.title || a.title,
|
|
3033
|
+
card: s.card
|
|
3034
|
+
};
|
|
3035
|
+
return {
|
|
3036
|
+
document: i(R(r, l)),
|
|
3037
|
+
target: o(a.id),
|
|
3038
|
+
// The section keeps its identity, so references follow its new card,
|
|
3039
|
+
// as they do for `replaceCard`. `to: null` is only for removals.
|
|
3040
|
+
retargetedCardIds: [{ from: a.card.id, to: s.card.id }],
|
|
3041
|
+
...s.calculatedFields ? { calculatedFields: s.calculatedFields } : {}
|
|
3042
|
+
};
|
|
3043
|
+
}
|
|
3044
|
+
case "move": {
|
|
3045
|
+
const a = r.findIndex(({ id: l }) => l === t.sectionId);
|
|
3046
|
+
if (a === -1) throw ge(t.sectionId);
|
|
3047
|
+
const s = [...r], [c] = s.splice(a, 1);
|
|
3048
|
+
return s.splice(He(t.toIndex, s.length), 0, c), {
|
|
3049
|
+
document: i(s),
|
|
3050
|
+
target: o(t.sectionId)
|
|
3051
|
+
};
|
|
3052
|
+
}
|
|
3053
|
+
case "duplicate": {
|
|
3054
|
+
const a = r.findIndex(({ id: c }) => c === t.sectionId);
|
|
3055
|
+
if (a === -1) throw ge(t.sectionId);
|
|
3056
|
+
const s = os(r[a], n.ids);
|
|
3057
|
+
return {
|
|
3058
|
+
document: i(Ke(r, s, a + 1)),
|
|
3059
|
+
target: o(s.id)
|
|
3060
|
+
};
|
|
3061
|
+
}
|
|
3062
|
+
case "remove": {
|
|
3063
|
+
const a = r.findIndex(({ id: d }) => d === t.sectionId);
|
|
3064
|
+
if (a === -1) throw ge(t.sectionId);
|
|
3065
|
+
const s = r[a], c = r.filter((d, u) => u !== a), l = c[a] ?? c[a - 1];
|
|
3066
|
+
return {
|
|
3067
|
+
document: i(c),
|
|
3068
|
+
target: l ? o(l.id) : { kind: "document" },
|
|
3069
|
+
retargetedCardIds: at(s).map(({ id: d }) => ({
|
|
3070
|
+
from: d,
|
|
3071
|
+
to: null
|
|
3072
|
+
}))
|
|
3073
|
+
};
|
|
3074
|
+
}
|
|
3075
|
+
case "rename": {
|
|
3076
|
+
const a = K(r, t.sectionId);
|
|
3077
|
+
if (a.type !== "table" && a.type !== "kpi" && a.type !== "chart")
|
|
3078
|
+
throw W("rename", a);
|
|
3079
|
+
return {
|
|
3080
|
+
document: i(R(r, { ...a, title: t.title })),
|
|
3081
|
+
target: o(a.id)
|
|
3082
|
+
};
|
|
3083
|
+
}
|
|
3084
|
+
case "updateText": {
|
|
3085
|
+
const a = K(r, t.sectionId);
|
|
3086
|
+
if (a.type !== "text") throw W(t.type, a);
|
|
3087
|
+
return {
|
|
3088
|
+
document: i(
|
|
3089
|
+
R(r, {
|
|
3090
|
+
...a,
|
|
3091
|
+
content: t.content,
|
|
3092
|
+
...t.style !== void 0 ? { style: t.style } : {}
|
|
3093
|
+
})
|
|
3094
|
+
),
|
|
3095
|
+
target: o(a.id)
|
|
3096
|
+
};
|
|
3097
|
+
}
|
|
3098
|
+
case "updateRegionText": {
|
|
3099
|
+
if (!Zo[t.region].includes(t.role))
|
|
3100
|
+
throw new M(
|
|
3101
|
+
`The ${t.region} has ${t.region === "header" ? "a title and a metadata line" : "a note and a page info line"}, not a ${t.role} line.`
|
|
3102
|
+
);
|
|
3103
|
+
const a = e[t.region], s = a ? vo(a.blocks, t.role) : void 0, c = {
|
|
3104
|
+
id: (s == null ? void 0 : s.id) ?? `${t.region}_${t.role}`,
|
|
3105
|
+
role: t.role,
|
|
3106
|
+
area: (s == null ? void 0 : s.area) ?? t.role,
|
|
3107
|
+
content: t.content,
|
|
3108
|
+
...t.style !== void 0 ? { style: t.style } : s != null && s.style ? { style: s.style } : {}
|
|
3109
|
+
};
|
|
3110
|
+
if (t.region === "header") {
|
|
3111
|
+
const d = (a == null ? void 0 : a.region) === "header" ? a : yo();
|
|
3112
|
+
return {
|
|
3113
|
+
document: { ...e, header: { ...d, enabled: !0, blocks: Gt(d.blocks, c) } },
|
|
3114
|
+
target: { kind: "header" }
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
const l = (a == null ? void 0 : a.region) === "footer" ? a : bo();
|
|
3118
|
+
return {
|
|
3119
|
+
document: { ...e, footer: { ...l, enabled: !0, blocks: Gt(l.blocks, c) } },
|
|
3120
|
+
target: { kind: "footer" }
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
case "updateTableOptions": {
|
|
3124
|
+
const a = K(r, t.sectionId);
|
|
3125
|
+
if (a.type !== "table") throw W(t.type, a);
|
|
3126
|
+
return {
|
|
3127
|
+
document: i(
|
|
3128
|
+
R(r, {
|
|
3129
|
+
...a,
|
|
3130
|
+
table: { ...a.table, ...t.options }
|
|
3131
|
+
})
|
|
3132
|
+
),
|
|
3133
|
+
target: o(a.id)
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
case "updateKpiOptions": {
|
|
3137
|
+
const a = K(r, t.sectionId);
|
|
3138
|
+
if (a.type !== "kpi") throw W(t.type, a);
|
|
3139
|
+
if (t.options.layout === "tiles" && !er(a))
|
|
3140
|
+
throw new M("Tiles hold up to 6 KPIs.");
|
|
3141
|
+
return {
|
|
3142
|
+
document: i(
|
|
3143
|
+
R(r, Wo(a, t.options))
|
|
3144
|
+
),
|
|
3145
|
+
target: o(a.id)
|
|
3146
|
+
};
|
|
3147
|
+
}
|
|
3148
|
+
case "setSpacerHeight": {
|
|
3149
|
+
const a = K(r, t.sectionId);
|
|
3150
|
+
if (a.type !== "spacer") throw W(t.type, a);
|
|
3151
|
+
return {
|
|
3152
|
+
document: i(
|
|
3153
|
+
R(r, {
|
|
3154
|
+
...a,
|
|
3155
|
+
heightPx: ts(t.heightPx)
|
|
3156
|
+
})
|
|
3157
|
+
),
|
|
3158
|
+
target: o(a.id)
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
case "replaceCard": {
|
|
3162
|
+
const a = K(r, t.sectionId);
|
|
3163
|
+
t.card.id !== t.oldCardId && Xt(n, t.card.id);
|
|
3164
|
+
let s;
|
|
3165
|
+
try {
|
|
3166
|
+
s = Qo(a, t.oldCardId, t.card);
|
|
3167
|
+
} catch (c) {
|
|
3168
|
+
throw new M(c.message);
|
|
3169
|
+
}
|
|
3170
|
+
return (s.type === "table" || s.type === "chart") && (s = { ...s, title: t.card.title || s.title }), {
|
|
3171
|
+
document: i(R(r, s)),
|
|
3172
|
+
target: o(a.id, a.type === "kpi" ? t.card.id : void 0),
|
|
3173
|
+
...t.oldCardId !== t.card.id ? { retargetedCardIds: [{ from: t.oldCardId, to: t.card.id }] } : {},
|
|
3174
|
+
...t.calculatedFields !== void 0 ? { calculatedFields: t.calculatedFields } : {}
|
|
3175
|
+
};
|
|
3176
|
+
}
|
|
3177
|
+
case "addKpi": {
|
|
3178
|
+
const a = K(r, t.sectionId);
|
|
3179
|
+
if (a.type !== "kpi") throw W(t.type, a);
|
|
3180
|
+
if (!Zn(a))
|
|
3181
|
+
throw new M("A KPI section holds up to 8 KPIs.");
|
|
3182
|
+
const s = t.source ? Re(t.source, n, a.id) : void 0;
|
|
3183
|
+
t.card && !s && Xt(n, t.card.id);
|
|
3184
|
+
const c = (s == null ? void 0 : s.card) ?? t.card ?? tr(n.ids.card());
|
|
3185
|
+
if (c.type !== "kpi")
|
|
3186
|
+
throw new M("KPI sections hold KPI cards only");
|
|
3187
|
+
const l = jo(a, c);
|
|
3188
|
+
if (l === a)
|
|
3189
|
+
throw new M(`KPI section '${a.id}' already has card '${c.id}'.`);
|
|
3190
|
+
return {
|
|
3191
|
+
document: i(R(r, l)),
|
|
3192
|
+
target: o(a.id, c.id),
|
|
3193
|
+
...s != null && s.calculatedFields ? { calculatedFields: s.calculatedFields } : {}
|
|
3194
|
+
};
|
|
3195
|
+
}
|
|
3196
|
+
case "removeKpi": {
|
|
3197
|
+
const a = K(r, t.sectionId);
|
|
3198
|
+
if (a.type !== "kpi") throw W(t.type, a);
|
|
3199
|
+
if (!a.cards.some(({ id: c }) => c === t.cardId))
|
|
3200
|
+
throw new M(`KPI section '${a.id}' has no card '${t.cardId}'.`);
|
|
3201
|
+
const s = Go(a, t.cardId);
|
|
3202
|
+
if (s === a)
|
|
3203
|
+
throw new M("A KPI section keeps at least one KPI.");
|
|
3204
|
+
return {
|
|
3205
|
+
document: i(R(r, s)),
|
|
3206
|
+
target: o(a.id),
|
|
3207
|
+
retargetedCardIds: [{ from: t.cardId, to: null }]
|
|
3208
|
+
};
|
|
3209
|
+
}
|
|
3210
|
+
case "moveKpi": {
|
|
3211
|
+
const a = K(r, t.sectionId);
|
|
3212
|
+
if (a.type !== "kpi") throw W(t.type, a);
|
|
3213
|
+
const s = a.cards.findIndex(({ id: d }) => d === t.cardId);
|
|
3214
|
+
if (s === -1)
|
|
3215
|
+
throw new M(`KPI section '${a.id}' has no card '${t.cardId}'.`);
|
|
3216
|
+
const c = [...a.cards], [l] = c.splice(s, 1);
|
|
3217
|
+
return c.splice(He(t.toIndex, c.length), 0, l), {
|
|
3218
|
+
document: i(R(r, { ...a, cards: c })),
|
|
3219
|
+
target: o(a.id, t.cardId)
|
|
3220
|
+
};
|
|
3221
|
+
}
|
|
3222
|
+
default:
|
|
3223
|
+
return cs(t);
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
function Re(e, t, n) {
|
|
3227
|
+
const r = rs(t.dashboard, {
|
|
3228
|
+
excludeSectionId: n
|
|
3229
|
+
}).find((p) => ss(p, e));
|
|
3230
|
+
if (!r)
|
|
3231
|
+
throw new M(
|
|
3232
|
+
`Card '${e.cardId}' cannot be copied into this document.`
|
|
3233
|
+
);
|
|
3234
|
+
const i = t.dashboard.sheets || [], o = i.find(({ id: p }) => p === e.sheetId), a = i.find(({ id: p }) => p === t.sheetId), s = t.ids.card(), c = be({ ...r.card, id: s });
|
|
3235
|
+
mn(c, /* @__PURE__ */ new Map([[e.cardId, s]]));
|
|
3236
|
+
const l = /* @__PURE__ */ new Set();
|
|
3237
|
+
if (oe(c, {
|
|
3238
|
+
oldCardId: e.cardId,
|
|
3239
|
+
newCardId: s,
|
|
3240
|
+
sourceSheetId: e.sheetId,
|
|
3241
|
+
targetSheetId: t.sheetId,
|
|
3242
|
+
onSheetField: (p) => l.add(p)
|
|
3243
|
+
}), e.sheetId === t.sheetId || l.size === 0)
|
|
3244
|
+
return { card: c };
|
|
3245
|
+
const d = co(o), u = /* @__PURE__ */ new Map(), f = [...l];
|
|
3246
|
+
for (; f.length > 0; ) {
|
|
3247
|
+
const p = f.pop();
|
|
3248
|
+
if (u.has(p)) continue;
|
|
3249
|
+
const y = d.find(
|
|
3250
|
+
(h) => Le(h.id) === p
|
|
3251
|
+
);
|
|
3252
|
+
if (!y) continue;
|
|
3253
|
+
const g = be(y);
|
|
3254
|
+
oe(g, {
|
|
3255
|
+
oldCardId: e.cardId,
|
|
3256
|
+
newCardId: s,
|
|
3257
|
+
sourceSheetId: e.sheetId,
|
|
3258
|
+
targetSheetId: t.sheetId,
|
|
3259
|
+
onSheetField: (h) => {
|
|
3260
|
+
u.has(h) || f.push(h);
|
|
3261
|
+
}
|
|
3262
|
+
}), u.set(p, g);
|
|
3263
|
+
}
|
|
3264
|
+
const m = d.flatMap((p) => {
|
|
3265
|
+
const y = u.get(Le(p.id) ?? "");
|
|
3266
|
+
return y ? [y] : [];
|
|
3267
|
+
});
|
|
3268
|
+
return m.length === 0 ? { card: c } : {
|
|
3269
|
+
card: c,
|
|
3270
|
+
calculatedFields: X(a == null ? void 0 : a.calculatedFields, m)
|
|
3271
|
+
};
|
|
3272
|
+
}
|
|
3273
|
+
function oe(e, t) {
|
|
3274
|
+
if (!e || typeof e != "object") return;
|
|
3275
|
+
if (Array.isArray(e)) {
|
|
3276
|
+
e.forEach((r) => oe(r, t));
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
const n = e;
|
|
3280
|
+
typeof n.entityId == "string" && (n.fieldScope === "card" && n.entityId === t.oldCardId ? n.entityId = t.newCardId : n.fieldScope === "sheet" && n.entityId === t.sourceSheetId && (typeof n.id == "string" && t.onSheetField(Le(n.id) ?? n.id), n.entityId = t.targetSheetId)), Object.values(n).forEach((r) => oe(r, t));
|
|
3281
|
+
}
|
|
3282
|
+
function os(e, t) {
|
|
3283
|
+
const n = { ...be(e), id: t.section() }, r = new Map(
|
|
3284
|
+
at(n).map((i) => [i.id, t.card()])
|
|
3285
|
+
);
|
|
3286
|
+
return Sn(n, (i) => {
|
|
3287
|
+
const o = r.get(i.id), a = be({ ...i, id: o });
|
|
3288
|
+
return mn(a, r), oe(a, {
|
|
3289
|
+
oldCardId: i.id,
|
|
3290
|
+
newCardId: o,
|
|
3291
|
+
sourceSheetId: "",
|
|
3292
|
+
targetSheetId: "",
|
|
3293
|
+
onSheetField: () => {
|
|
3294
|
+
}
|
|
3295
|
+
}), a;
|
|
3296
|
+
});
|
|
3297
|
+
}
|
|
3298
|
+
function ss(e, t) {
|
|
3299
|
+
return e.kind !== t.kind || e.sheetId !== t.sheetId || e.cardId !== t.cardId ? !1 : e.kind === "frameCard" && t.kind === "frameCard" ? e.frameId === t.frameId : e.kind === "documentSectionCard" && t.kind === "documentSectionCard" ? e.sectionId === t.sectionId : !0;
|
|
3300
|
+
}
|
|
3301
|
+
function Xt(e, t) {
|
|
3302
|
+
if (oa(e.dashboard, t))
|
|
3303
|
+
throw new M(
|
|
3304
|
+
`Card id '${t}' is already used by another card in this dashboard.`
|
|
3305
|
+
);
|
|
3306
|
+
}
|
|
3307
|
+
function Ke(e, t, n) {
|
|
3308
|
+
const r = He(n, e.length);
|
|
3309
|
+
return [...e.slice(0, r), t, ...e.slice(r)];
|
|
3310
|
+
}
|
|
3311
|
+
function R(e, t) {
|
|
3312
|
+
return e.map(
|
|
3313
|
+
(n) => n.id === t.id ? t : n
|
|
3314
|
+
);
|
|
3315
|
+
}
|
|
3316
|
+
function He(e, t) {
|
|
3317
|
+
return Number.isFinite(e) ? Math.min(t, Math.max(0, Math.trunc(e))) : t;
|
|
3318
|
+
}
|
|
3319
|
+
function K(e, t) {
|
|
3320
|
+
const n = e.find(({ id: r }) => r === t);
|
|
3321
|
+
if (!n) throw ge(t);
|
|
3322
|
+
return n;
|
|
3323
|
+
}
|
|
3324
|
+
function ge(e) {
|
|
3325
|
+
return new M(`Document section '${e}' does not exist.`);
|
|
3326
|
+
}
|
|
3327
|
+
function W(e, t) {
|
|
3328
|
+
return new M(
|
|
3329
|
+
`'${e}' does not apply to a ${t.type} section.`
|
|
3330
|
+
);
|
|
3331
|
+
}
|
|
3332
|
+
function cs(e) {
|
|
3333
|
+
throw new M(
|
|
3334
|
+
`Unknown document edit '${e.type}'.`
|
|
3335
|
+
);
|
|
3336
|
+
}
|
|
3337
|
+
const ls = {
|
|
3338
|
+
section: () => {
|
|
3339
|
+
throw new F("document_invalid", "A text edit mints no section id.");
|
|
3340
|
+
},
|
|
3341
|
+
card: () => {
|
|
3342
|
+
throw new F("document_invalid", "A text edit mints no card id.");
|
|
3343
|
+
}
|
|
3344
|
+
}, ds = { title: "title", metadata: "metadata", note: "note", pageInfo: "page info" };
|
|
3345
|
+
function us(e, t) {
|
|
3346
|
+
const n = e.sheets ?? [], r = n.findIndex((d) => d.id === t.sheetId), i = n[r];
|
|
3347
|
+
if (!i) throw new F("sheet_not_found", `No sheet ${t.sheetId} on this dashboard.`, "Read the outline again and use its sheet ids.");
|
|
3348
|
+
if (!xe(i) || !i.document)
|
|
3349
|
+
throw new F("document_invalid", `"${i.title ?? i.id}" is not a Document sheet.`, "Name a Document sheet; a grid sheet's words are its text cards.");
|
|
3350
|
+
let o;
|
|
3351
|
+
try {
|
|
3352
|
+
o = as(i.document, t.edit, { dashboard: e, sheetId: i.id, ids: ls }).document;
|
|
3353
|
+
} catch (d) {
|
|
3354
|
+
throw d instanceof M ? new F("document_invalid", d.message, "Read the outline again and use its section ids and line roles.") : d;
|
|
3355
|
+
}
|
|
3356
|
+
const a = { ...e, sheets: n.map((d, u) => u === r ? { ...d, document: o } : d) }, s = t.edit.type === "updateRegionText" ? `the ${ds[t.edit.role]} line of the ${w(i.title)} ${t.edit.region}` : `a text section of ${w(i.title)}`, c = ci(t.edit.content, { inputs: a.inputs, variables: a.variables }), l = li(c);
|
|
3357
|
+
return {
|
|
3358
|
+
dashboard: a,
|
|
3359
|
+
clauses: [T.plain("document", `sets ${s} to ${w(di(c))}${l ? `, ${l}` : ""}`)]
|
|
3360
|
+
};
|
|
3361
|
+
}
|
|
3362
|
+
function Lc(e, t, n) {
|
|
3363
|
+
let r = e;
|
|
3364
|
+
const i = [], o = [], a = [], s = [], c = [];
|
|
3365
|
+
let l = !1;
|
|
3366
|
+
for (const [u, f] of t.entries()) {
|
|
3367
|
+
let m;
|
|
3368
|
+
try {
|
|
3369
|
+
m = ms(r, f, n);
|
|
3370
|
+
} catch (p) {
|
|
3371
|
+
if (!(p instanceof F)) throw p;
|
|
3372
|
+
return {
|
|
3373
|
+
ok: !1,
|
|
3374
|
+
failedAt: {
|
|
3375
|
+
index: u,
|
|
3376
|
+
op: f.op,
|
|
3377
|
+
code: p.code,
|
|
3378
|
+
message: p.message,
|
|
3379
|
+
...p.fix ? { fix: p.fix } : {},
|
|
3380
|
+
...p.details ? { details: p.details } : {}
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3384
|
+
r = m.dashboard, i.push(...m.created ?? []);
|
|
3385
|
+
for (const p of m.touched ?? []) o.includes(p) || o.push(p);
|
|
3386
|
+
a.push(...m.runtimeEffects ?? []), s.push(...m.queryFrames ?? []), c.push({ index: u, changeIndex: f.changeIndex, clauses: m.clauses }), l || (l = m.detached === !0);
|
|
3387
|
+
}
|
|
3388
|
+
const d = new Set(i.map((u) => u.id));
|
|
3389
|
+
return {
|
|
3390
|
+
ok: !0,
|
|
3391
|
+
dashboard: r,
|
|
3392
|
+
created: i,
|
|
3393
|
+
touched: o.filter((u) => !d.has(u)),
|
|
3394
|
+
queryFrames: [...fs(r, i, o), ...s],
|
|
3395
|
+
descriptions: ps(c),
|
|
3396
|
+
runtimeEffects: a,
|
|
3397
|
+
detaches: l
|
|
3398
|
+
};
|
|
3399
|
+
}
|
|
3400
|
+
function fs(e, t, n) {
|
|
3401
|
+
const r = /* @__PURE__ */ new Set([...t.filter((i) => i.kind === "card").map((i) => i.id), ...n]);
|
|
3402
|
+
return (e.sheets ?? []).flatMap(
|
|
3403
|
+
(i) => (i.frames ?? []).filter((o) => (o.cards ?? []).some((a) => r.has(a.id)))
|
|
3404
|
+
);
|
|
3405
|
+
}
|
|
3406
|
+
function ms(e, t, n) {
|
|
3407
|
+
switch (t.op) {
|
|
3408
|
+
case "card.add":
|
|
3409
|
+
return mi(e, t);
|
|
3410
|
+
case "card.remove":
|
|
3411
|
+
return fi(e, t.cardId);
|
|
3412
|
+
case "card.update":
|
|
3413
|
+
return te(ui(e, t.cardId, t.update), [t.cardId]);
|
|
3414
|
+
case "layout.arrange":
|
|
3415
|
+
return io(e, t);
|
|
3416
|
+
case "frame.commit":
|
|
3417
|
+
return te(uo(e, t.commit), [t.commit.frame.activeCardId]);
|
|
3418
|
+
case "filter.add":
|
|
3419
|
+
return Ao(e, t);
|
|
3420
|
+
case "filter.update":
|
|
3421
|
+
return No(e, t, n);
|
|
3422
|
+
case "filter.remove":
|
|
3423
|
+
return $o(e, t.filterId);
|
|
3424
|
+
case "filter.bind":
|
|
3425
|
+
return te(Vo(e, t), [t.cardId]);
|
|
3426
|
+
case "filter.exclude":
|
|
3427
|
+
return te(Lo(e, t), [t.cardId]);
|
|
3428
|
+
case "dashboard.update":
|
|
3429
|
+
return fo(e, t);
|
|
3430
|
+
case "sheet.add":
|
|
3431
|
+
return Io(e, t);
|
|
3432
|
+
case "sheet.update":
|
|
3433
|
+
return Co(e, t);
|
|
3434
|
+
case "layout.tabs":
|
|
3435
|
+
return te(po(e, t), t.cardIds.slice(0, 1));
|
|
3436
|
+
case "layout.untab":
|
|
3437
|
+
return te(go(e, t), [t.cardId]);
|
|
3438
|
+
case "variable.add":
|
|
3439
|
+
return qo(e, t);
|
|
3440
|
+
case "variable.update":
|
|
3441
|
+
return Bo(e, t);
|
|
3442
|
+
case "variable.remove":
|
|
3443
|
+
return Uo(e, t);
|
|
3444
|
+
case "document.text":
|
|
3445
|
+
return us(e, t);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
function te(e, t) {
|
|
3449
|
+
return { ...e, touched: t.filter(Boolean) };
|
|
3450
|
+
}
|
|
3451
|
+
function ps(e) {
|
|
3452
|
+
const t = [];
|
|
3453
|
+
for (const n of e) {
|
|
3454
|
+
const r = n.changeIndex === void 0 ? void 0 : t.find((i) => i.changeIndex === n.changeIndex);
|
|
3455
|
+
if (r) {
|
|
3456
|
+
r.operations.push(n.index), r.clauses.push(...n.clauses);
|
|
3457
|
+
continue;
|
|
3458
|
+
}
|
|
3459
|
+
t.push({
|
|
3460
|
+
...n.changeIndex !== void 0 ? { changeIndex: n.changeIndex } : {},
|
|
3461
|
+
operations: [n.index],
|
|
3462
|
+
sentence: "",
|
|
3463
|
+
clauses: [...n.clauses]
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
return t.map(({ clauses: n, ...r }) => ({
|
|
3467
|
+
...r,
|
|
3468
|
+
sentence: pi(gs(n))
|
|
3469
|
+
}));
|
|
3470
|
+
}
|
|
3471
|
+
function gs(e) {
|
|
3472
|
+
let t = !1;
|
|
3473
|
+
return e.filter((n) => n.kind !== "detached" ? !0 : t ? !1 : (t = !0, !0));
|
|
3474
|
+
}
|
|
3475
|
+
function Qt(e) {
|
|
3476
|
+
return Object.fromEntries(
|
|
3477
|
+
Object.entries(e).filter(
|
|
3478
|
+
(t) => typeof t[1] == "string" && t[1].length > 0
|
|
3479
|
+
)
|
|
3480
|
+
);
|
|
3481
|
+
}
|
|
3482
|
+
function se(e) {
|
|
3483
|
+
return e.kind === "semantic" ? [
|
|
3484
|
+
e.kind,
|
|
3485
|
+
e.domainId,
|
|
3486
|
+
e.datasetId || "",
|
|
3487
|
+
e.datasetName || "",
|
|
3488
|
+
e.connectionId || ""
|
|
3489
|
+
].join(":") : [
|
|
3490
|
+
e.kind,
|
|
3491
|
+
e.connectionId,
|
|
3492
|
+
e.databaseName || "",
|
|
3493
|
+
e.schemaName || "",
|
|
3494
|
+
e.tableName
|
|
3495
|
+
].join(":");
|
|
3496
|
+
}
|
|
3497
|
+
function hs(e, t) {
|
|
3498
|
+
if (e.kind === "semantic")
|
|
3499
|
+
return {
|
|
3500
|
+
status: "ready",
|
|
3501
|
+
request: Qt({
|
|
3502
|
+
connection_id: e.connectionId,
|
|
3503
|
+
domain_id: e.domainId,
|
|
3504
|
+
dataset_id: Pi(e),
|
|
3505
|
+
dataset_name: e.datasetName
|
|
3506
|
+
})
|
|
3507
|
+
};
|
|
3508
|
+
const n = ca({
|
|
3509
|
+
source: e,
|
|
3510
|
+
capabilities: t
|
|
3511
|
+
});
|
|
3512
|
+
return n.kind === "incompatible_capabilities" ? {
|
|
3513
|
+
status: "unavailable",
|
|
3514
|
+
message: "Connection capabilities are unavailable for field metadata."
|
|
3515
|
+
} : n.kind === "missing_coordinates" ? {
|
|
3516
|
+
status: "unavailable",
|
|
3517
|
+
message: `Source is missing required field-metadata coordinates: ${n.missing.join(", ")}.`
|
|
3518
|
+
} : {
|
|
3519
|
+
status: "ready",
|
|
3520
|
+
request: Qt({
|
|
3521
|
+
connection_id: e.connectionId,
|
|
3522
|
+
datamodel_id: "",
|
|
3523
|
+
database_name: n.coordinates.databaseName,
|
|
3524
|
+
schema_name: n.coordinates.schemaName,
|
|
3525
|
+
table_name: n.coordinates.tableName
|
|
3526
|
+
})
|
|
3527
|
+
};
|
|
3528
|
+
}
|
|
3529
|
+
function qc(e, t = /* @__PURE__ */ new Map()) {
|
|
3530
|
+
const n = /* @__PURE__ */ new Map();
|
|
3531
|
+
for (const { card: r } of e) {
|
|
3532
|
+
const i = Ze(r), o = i.kind === "config" ? i.executableSources : i.kind === "sql" ? i.pinnedCatalogSources.map((a) => a.source) : [];
|
|
3533
|
+
for (const a of o) {
|
|
3534
|
+
const s = se(a);
|
|
3535
|
+
if (!n.has(s)) {
|
|
3536
|
+
const c = hs(
|
|
3537
|
+
a,
|
|
3538
|
+
a.connectionId ? t.get(a.connectionId) : void 0
|
|
3539
|
+
);
|
|
3540
|
+
n.set(s, {
|
|
3541
|
+
key: s,
|
|
3542
|
+
source: a,
|
|
3543
|
+
...c
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
return Array.from(n.values());
|
|
3549
|
+
}
|
|
3550
|
+
function ys(e, t) {
|
|
3551
|
+
if (e.kind !== "semantic" || !e.connectionId) return;
|
|
3552
|
+
const n = (t.qualifiedEntityName || "").split(".").map((i) => i.trim()).filter(Boolean), r = n.at(-1);
|
|
3553
|
+
if (r)
|
|
3554
|
+
return {
|
|
3555
|
+
kind: "physical",
|
|
3556
|
+
connectionId: e.connectionId,
|
|
3557
|
+
tableName: r,
|
|
3558
|
+
...n.length > 1 ? { schemaName: n.at(-2) } : {},
|
|
3559
|
+
...n.length > 2 ? { databaseName: n.at(-3) } : {}
|
|
3560
|
+
};
|
|
3561
|
+
}
|
|
3562
|
+
function he(e, t) {
|
|
3563
|
+
let n = e.get(t);
|
|
3564
|
+
return n || (n = { fields: /* @__PURE__ */ new Map(), fieldConflicts: /* @__PURE__ */ new Set() }, e.set(t, n)), n;
|
|
3565
|
+
}
|
|
3566
|
+
function ir(e, t) {
|
|
3567
|
+
e.sourceLabel === void 0 ? e.sourceLabel = t : e.sourceLabel !== t && (e.sourceLabelConflict = !0);
|
|
3568
|
+
}
|
|
3569
|
+
function Ye(e, t, n) {
|
|
3570
|
+
for (const r of t) {
|
|
3571
|
+
const i = r == null ? void 0 : r.trim();
|
|
3572
|
+
if (!i) continue;
|
|
3573
|
+
const o = yn(i), a = e.fields.get(o);
|
|
3574
|
+
a === void 0 ? e.fields.set(o, n) : a !== n && e.fieldConflicts.add(o);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
function ar(e, t) {
|
|
3578
|
+
t.sourceLabel && ir(e, t.sourceLabel), t.sourceLabelConflict && (e.sourceLabelConflict = !0);
|
|
3579
|
+
for (const [n, r] of t.fields)
|
|
3580
|
+
Ye(e, [n], r);
|
|
3581
|
+
for (const n of t.fieldConflicts ?? [])
|
|
3582
|
+
e.fieldConflicts.add(n);
|
|
3583
|
+
}
|
|
3584
|
+
function or(e) {
|
|
3585
|
+
return e.kind === "semantic" && (e.label || e.datasetName || "").trim() || void 0;
|
|
3586
|
+
}
|
|
3587
|
+
function Bc(e, t) {
|
|
3588
|
+
var r, i;
|
|
3589
|
+
const n = /* @__PURE__ */ new Map();
|
|
3590
|
+
for (const [o, a] of e) {
|
|
3591
|
+
if (a.status !== "ready") continue;
|
|
3592
|
+
const s = t == null ? void 0 : t.get(o), c = s ? or(s) : void 0;
|
|
3593
|
+
for (const l of a.columns) {
|
|
3594
|
+
const d = (r = l.column_name) == null ? void 0 : r.trim(), u = (i = l.label) == null ? void 0 : i.trim(), f = s ? ys(s, l) : void 0;
|
|
3595
|
+
f && c && ir(
|
|
3596
|
+
he(n, se(f)),
|
|
3597
|
+
c
|
|
3598
|
+
), !(!d || !u || u === d) && (Ye(
|
|
3599
|
+
he(n, o),
|
|
3600
|
+
[d, l.sourceField],
|
|
3601
|
+
u
|
|
3602
|
+
), f && Ye(
|
|
3603
|
+
he(n, se(f)),
|
|
3604
|
+
[l.sourceField, d],
|
|
3605
|
+
u
|
|
3606
|
+
));
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
return n;
|
|
3610
|
+
}
|
|
3611
|
+
function Uc(...e) {
|
|
3612
|
+
const t = /* @__PURE__ */ new Map();
|
|
3613
|
+
for (const n of e)
|
|
3614
|
+
for (const [r, i] of n ?? [])
|
|
3615
|
+
ar(he(t, r), i);
|
|
3616
|
+
return t;
|
|
3617
|
+
}
|
|
3618
|
+
function pt(e) {
|
|
3619
|
+
return [e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".");
|
|
3620
|
+
}
|
|
3621
|
+
function bs(e) {
|
|
3622
|
+
return e.split(":").slice(2).filter(Boolean).join(".");
|
|
3623
|
+
}
|
|
3624
|
+
function sr(e, t) {
|
|
3625
|
+
const n = se(t), r = e.get(n);
|
|
3626
|
+
if (t.kind !== "physical") return r;
|
|
3627
|
+
const i = `physical:${t.connectionId}:`, o = pt(t), a = {
|
|
3628
|
+
fields: /* @__PURE__ */ new Map(),
|
|
3629
|
+
fieldConflicts: /* @__PURE__ */ new Set()
|
|
3630
|
+
};
|
|
3631
|
+
let s = !1;
|
|
3632
|
+
for (const [c, l] of e)
|
|
3633
|
+
c.startsWith(i) && (c !== n && !la(o, bs(c)) || (ar(a, l), s = !0));
|
|
3634
|
+
return s ? a : void 0;
|
|
3635
|
+
}
|
|
3636
|
+
function vs(e, t) {
|
|
3637
|
+
var i;
|
|
3638
|
+
if (!e) return;
|
|
3639
|
+
const n = yn(t.name), r = sr(e, t.source);
|
|
3640
|
+
return r && !((i = r.fieldConflicts) != null && i.has(n)) ? r.fields.get(n) : void 0;
|
|
3641
|
+
}
|
|
3642
|
+
function Is(e, t) {
|
|
3643
|
+
if (t.kind === "semantic")
|
|
3644
|
+
return or(t) || t.datasetId || "Dataset";
|
|
3645
|
+
const n = e ? sr(e, t) : void 0;
|
|
3646
|
+
return n != null && n.sourceLabel && !n.sourceLabelConflict ? n.sourceLabel : pt(t);
|
|
3647
|
+
}
|
|
3648
|
+
function zc(e, t) {
|
|
3649
|
+
const n = vs(e, t);
|
|
3650
|
+
return {
|
|
3651
|
+
name: t.name,
|
|
3652
|
+
...n ? { label: n } : {},
|
|
3653
|
+
entityName: Is(e, t.source),
|
|
3654
|
+
...t.source.kind === "physical" ? { qualifiedEntityName: pt(t.source) } : {},
|
|
3655
|
+
dataType: t.dataType
|
|
3656
|
+
};
|
|
3657
|
+
}
|
|
3658
|
+
function Cs(e, t) {
|
|
3659
|
+
var i, o;
|
|
3660
|
+
const n = (i = t.column_name) == null ? void 0 : i.trim(), r = ce(t.data_type);
|
|
3661
|
+
if (!(!n || r === "unknown"))
|
|
3662
|
+
return {
|
|
3663
|
+
kind: "field",
|
|
3664
|
+
field: {
|
|
3665
|
+
name: n,
|
|
3666
|
+
source: { ...e },
|
|
3667
|
+
dataType: r,
|
|
3668
|
+
...(o = t.sourceField) != null && o.trim() ? { sourceField: t.sourceField.trim() } : {}
|
|
3669
|
+
}
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3672
|
+
function jc(e) {
|
|
3673
|
+
const t = {};
|
|
3674
|
+
for (const { card: n } of e.cards) {
|
|
3675
|
+
const r = Ze(n), i = r.kind === "config" ? r.executableSources : r.kind === "sql" ? r.pinnedCatalogSources.map((s) => s.source) : [];
|
|
3676
|
+
if (!i.length) continue;
|
|
3677
|
+
const o = [];
|
|
3678
|
+
let a;
|
|
3679
|
+
for (const s of i) {
|
|
3680
|
+
const c = e.metadataBySourceKey.get(
|
|
3681
|
+
se(s)
|
|
3682
|
+
);
|
|
3683
|
+
if (!c || c.status === "unavailable") {
|
|
3684
|
+
a = (c == null ? void 0 : c.status) === "unavailable" ? c.message : "Field metadata is not available yet.";
|
|
3685
|
+
break;
|
|
3686
|
+
}
|
|
3687
|
+
for (const l of c.columns) {
|
|
3688
|
+
const d = Cs(s, l);
|
|
3689
|
+
d && o.push(d);
|
|
3690
|
+
}
|
|
3691
|
+
}
|
|
3692
|
+
t[n.id] = a ? { status: "metadataUnavailable", message: a } : { status: "ready", targets: o };
|
|
3693
|
+
}
|
|
3694
|
+
return t;
|
|
3695
|
+
}
|
|
3696
|
+
function Gc(e) {
|
|
3697
|
+
const { dashboard: t, target: n, calendar: r } = e, i = lr(n), o = cr(t, n, r);
|
|
3698
|
+
return {
|
|
3699
|
+
value: o,
|
|
3700
|
+
mode: Dr(
|
|
3701
|
+
kr(o == null ? void 0 : o.operation) ? o.operation : i.operation
|
|
3702
|
+
)
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3705
|
+
function cr(e, t, n) {
|
|
3706
|
+
var r;
|
|
3707
|
+
switch (t.kind) {
|
|
3708
|
+
case "dashboardInput": {
|
|
3709
|
+
const i = hi({
|
|
3710
|
+
dashboard: e,
|
|
3711
|
+
input: t.input,
|
|
3712
|
+
target: t.scope,
|
|
3713
|
+
calendar: n
|
|
3714
|
+
});
|
|
3715
|
+
return (i == null ? void 0 : i.status) === "set" && i.value.kind === "filter" ? i.value.filterValue : void 0;
|
|
3716
|
+
}
|
|
3717
|
+
case "dashboardFilter": {
|
|
3718
|
+
const i = (r = e.defaultFilterValues) == null ? void 0 : r.find(
|
|
3719
|
+
(o) => o.filterId === t.filter.id
|
|
3720
|
+
);
|
|
3721
|
+
return i ? gi({
|
|
3722
|
+
filterDefinitions: [t.filter],
|
|
3723
|
+
filterValues: [i]
|
|
3724
|
+
})[0] : re(t.filter, n);
|
|
3725
|
+
}
|
|
3726
|
+
case "definition":
|
|
3727
|
+
return re(t.filter, n);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
function lr(e) {
|
|
3731
|
+
return e.kind === "dashboardInput" ? e.input.filter : e.filter;
|
|
3732
|
+
}
|
|
3733
|
+
function Wc(e) {
|
|
3734
|
+
var o;
|
|
3735
|
+
const { dashboard: t, filter: n, input: r, scope: i } = e;
|
|
3736
|
+
return r && (t.inputs || []).some((a) => a.id === r.id) ? { kind: "dashboardInput", input: r, scope: i } : ((o = Y(t).findFilterInput({ filterId: n.id })) == null ? void 0 : o.origin) === "toolbarFilter" ? { kind: "dashboardFilter", filter: n } : { kind: "definition", filter: n };
|
|
3737
|
+
}
|
|
3738
|
+
function Hc(e) {
|
|
3739
|
+
const { dashboard: t, target: n, calendar: r } = e, i = lr(n), o = yi(i), a = Fs(t, n);
|
|
3740
|
+
if (!a) return o;
|
|
3741
|
+
if (a === "cleared")
|
|
3742
|
+
return {
|
|
3743
|
+
operation: i.operation,
|
|
3744
|
+
defaultValues: void 0,
|
|
3745
|
+
defaultDateFilter: void 0
|
|
3746
|
+
};
|
|
3747
|
+
const s = cr(t, n, r);
|
|
3748
|
+
if (!s || Ss(s, re(i, r)))
|
|
3749
|
+
return o;
|
|
3750
|
+
if (s.valueType === "date") {
|
|
3751
|
+
const c = Ai(
|
|
3752
|
+
"relativeMeta" in s ? s.relativeMeta : void 0
|
|
3753
|
+
) ?? xs(i, s, r);
|
|
3754
|
+
return c ? {
|
|
3755
|
+
operation: s.operation,
|
|
3756
|
+
defaultValues: i.defaultValues,
|
|
3757
|
+
defaultDateFilter: c
|
|
3758
|
+
} : o;
|
|
3759
|
+
}
|
|
3760
|
+
return {
|
|
3761
|
+
operation: s.operation,
|
|
3762
|
+
defaultValues: s.values,
|
|
3763
|
+
defaultDateFilter: i.defaultDateFilter
|
|
3764
|
+
};
|
|
3765
|
+
}
|
|
3766
|
+
function Fs(e, t) {
|
|
3767
|
+
var n;
|
|
3768
|
+
if (t.kind === "dashboardInput") {
|
|
3769
|
+
const r = nt(
|
|
3770
|
+
e.defaultInputValues,
|
|
3771
|
+
t.input,
|
|
3772
|
+
t.scope
|
|
3773
|
+
);
|
|
3774
|
+
return (r == null ? void 0 : r.status) === "set" || (r == null ? void 0 : r.status) === "cleared" ? r.status : void 0;
|
|
3775
|
+
}
|
|
3776
|
+
if (t.kind === "dashboardFilter")
|
|
3777
|
+
return (n = e.defaultFilterValues) != null && n.some(
|
|
3778
|
+
(r) => r.filterId === t.filter.id
|
|
3779
|
+
) ? "set" : void 0;
|
|
3780
|
+
}
|
|
3781
|
+
function Ss(e, t) {
|
|
3782
|
+
return !!(t && e.operation === t.operation && qe(Jt(e), Jt(t)) && qe(
|
|
3783
|
+
"relativeMeta" in e ? e.relativeMeta : void 0,
|
|
3784
|
+
"relativeMeta" in t ? t.relativeMeta : void 0
|
|
3785
|
+
));
|
|
3786
|
+
}
|
|
3787
|
+
function Jt(e) {
|
|
3788
|
+
return e.values.map(
|
|
3789
|
+
(t) => t instanceof Date ? t.getTime() : t
|
|
3790
|
+
);
|
|
3791
|
+
}
|
|
3792
|
+
function xs(e, t, n) {
|
|
3793
|
+
const r = bi(n == null ? void 0 : n.tz), i = Pe(t.values[0], r);
|
|
3794
|
+
if (!i) return;
|
|
3795
|
+
const [o, a, s] = new Intl.DateTimeFormat("en-CA", {
|
|
3796
|
+
timeZone: r,
|
|
3797
|
+
year: "numeric",
|
|
3798
|
+
month: "2-digit",
|
|
3799
|
+
day: "2-digit"
|
|
3800
|
+
}).format(i).split("-").map(Number), c = [
|
|
3801
|
+
{
|
|
3802
|
+
mode: "fixed",
|
|
3803
|
+
unit: "day",
|
|
3804
|
+
date: `${o}-${String(a).padStart(2, "0")}-${String(s).padStart(2, "0")}`
|
|
3805
|
+
},
|
|
3806
|
+
{ mode: "fixed", unit: "month", year: o, month: a - 1 }
|
|
3807
|
+
], l = t.values.map(
|
|
3808
|
+
(d) => {
|
|
3809
|
+
var u;
|
|
3810
|
+
return (u = Pe(d, r)) == null ? void 0 : u.getTime();
|
|
3811
|
+
}
|
|
3812
|
+
);
|
|
3813
|
+
return c.find((d) => {
|
|
3814
|
+
const u = re(
|
|
3815
|
+
{ ...e, defaultDateFilter: d },
|
|
3816
|
+
n
|
|
3817
|
+
);
|
|
3818
|
+
return (u == null ? void 0 : u.operation) === t.operation && qe(
|
|
3819
|
+
u.values.map(
|
|
3820
|
+
(f) => {
|
|
3821
|
+
var m;
|
|
3822
|
+
return (m = Pe(f, r)) == null ? void 0 : m.getTime();
|
|
3823
|
+
}
|
|
3824
|
+
),
|
|
3825
|
+
l
|
|
3826
|
+
);
|
|
3827
|
+
});
|
|
3828
|
+
}
|
|
3829
|
+
function Zt(e) {
|
|
3830
|
+
return da(void 0, e ?? "");
|
|
3831
|
+
}
|
|
3832
|
+
const ws = {
|
|
3833
|
+
type: "temporal_bucket",
|
|
3834
|
+
presentation: { mode: "pattern", pattern: "YYYY-MM-DD" }
|
|
3835
|
+
};
|
|
3836
|
+
function Ts(e) {
|
|
3837
|
+
const t = ce(e.dataType);
|
|
3838
|
+
if (!["date", "datetime"].includes(t))
|
|
3839
|
+
return e;
|
|
3840
|
+
const n = e.granularity !== void 0 || e.format !== void 0, r = vi({
|
|
3841
|
+
fieldId: e.id,
|
|
3842
|
+
dataType: e.dataType,
|
|
3843
|
+
granularity: e.granularity,
|
|
3844
|
+
format: e.format,
|
|
3845
|
+
semanticTemporalPresentation: e.semanticTemporalPresentation
|
|
3846
|
+
});
|
|
3847
|
+
if (!r.ok)
|
|
3848
|
+
return e;
|
|
3849
|
+
const i = n ? r.selection.format : ws;
|
|
3850
|
+
return {
|
|
3851
|
+
...e,
|
|
3852
|
+
granularity: r.granularity,
|
|
3853
|
+
format: i
|
|
3854
|
+
};
|
|
3855
|
+
}
|
|
3856
|
+
function Yc(e, t) {
|
|
3857
|
+
var r, i;
|
|
3858
|
+
const n = ((i = (r = globalThis.crypto) == null ? void 0 : r.randomUUID) == null ? void 0 : i.call(r).slice(0, 8)) ?? Math.random().toString(36).slice(2, 10);
|
|
3859
|
+
return `${e}-${t.qualifiedEntityName}-${t.name}-${Date.now()}-${n}`;
|
|
3860
|
+
}
|
|
3861
|
+
function Ds(e, t) {
|
|
3862
|
+
const n = pn(e.replace(/_/g, " "));
|
|
3863
|
+
switch (t) {
|
|
3864
|
+
case "SUM":
|
|
3865
|
+
return `Sum of ${n}`;
|
|
3866
|
+
case "COUNT":
|
|
3867
|
+
return `Count of ${n}`;
|
|
3868
|
+
case "DISTINCT":
|
|
3869
|
+
return `Unique ${n}`;
|
|
3870
|
+
case "AVG":
|
|
3871
|
+
return `Average of ${n}`;
|
|
3872
|
+
case "MIN":
|
|
3873
|
+
return `Min of ${n}`;
|
|
3874
|
+
case "MAX":
|
|
3875
|
+
return `Max of ${n}`;
|
|
3876
|
+
default:
|
|
3877
|
+
return n;
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
function Xc(e, t, n) {
|
|
3881
|
+
var i;
|
|
3882
|
+
const r = gn(e.dataType);
|
|
3883
|
+
return n === "detailTable" ? "detailColumns" : n === "matrixTable" ? ((i = e.derivedField) == null ? void 0 : i.computeStage) === "aggregate" || ce(e.dataType) === "number" ? "metrics" : "groupBy" : n === "kpi" ? r === "date" ? "groupBy" : "metrics" : t.length === 0 || r === "number" ? "metrics" : r === "date" || r === "string" || r === "boolean" ? "groupBy" : "metrics";
|
|
3884
|
+
}
|
|
3885
|
+
function Qc(e, t, n, r) {
|
|
3886
|
+
const i = gn(e.dataType), o = i === "date";
|
|
3887
|
+
e = Ni(e);
|
|
3888
|
+
const a = Ei(e), s = a.representation !== "physical", c = a.computeStage, l = s ? e.fieldScope === "domain" ? e.calculatedFieldOrigin : e.calculatedFieldOrigin || {
|
|
3889
|
+
id: e.id,
|
|
3890
|
+
role: e.role
|
|
3891
|
+
} : void 0;
|
|
3892
|
+
e = {
|
|
3893
|
+
...e,
|
|
3894
|
+
...s ? { calculatedFieldOrigin: l } : {},
|
|
3895
|
+
...e.calculatedFormula && c ? {
|
|
3896
|
+
calculatedFormula: { ...e.calculatedFormula, computeStage: c }
|
|
3897
|
+
} : {}
|
|
3898
|
+
};
|
|
3899
|
+
const d = s && e.role === "metric", u = s && e.role === "groupby", m = {
|
|
3900
|
+
...s ? {
|
|
3901
|
+
calculationRepresentation: e.calculationRepresentation,
|
|
3902
|
+
expression: e.expression,
|
|
3903
|
+
calculatedFormula: e.calculatedFormula,
|
|
3904
|
+
derivedField: e.derivedField,
|
|
3905
|
+
fieldScope: e.fieldScope,
|
|
3906
|
+
calculatedFieldOrigin: e.calculatedFieldOrigin
|
|
3907
|
+
} : {},
|
|
3908
|
+
id: r,
|
|
3909
|
+
name: e.name,
|
|
3910
|
+
dataType: e.dataType,
|
|
3911
|
+
// Semantic-model labels are customer-facing names. Preserve them when a
|
|
3912
|
+
// source field moves into a non-metric shelf; only derive a label when
|
|
3913
|
+
// the source did not provide one.
|
|
3914
|
+
label: e.label || et(e.name),
|
|
3915
|
+
derivedLabel: e.derivedLabel,
|
|
3916
|
+
alias: e.alias,
|
|
3917
|
+
nativeDataType: e.nativeDataType,
|
|
3918
|
+
description: e.description,
|
|
3919
|
+
// A card column's own override moves with it. The model's format is
|
|
3920
|
+
// never copied onto the card: the query response carries it live
|
|
3921
|
+
// (column formats CF-D17).
|
|
3922
|
+
...e.formatOrigin === "override" ? { format: e.format, formatOrigin: "override" } : {},
|
|
3923
|
+
labelOrigin: e.labelOrigin || (e.fieldScope === "domain" ? "semantic" : void 0),
|
|
3924
|
+
granularity: e.granularity,
|
|
3925
|
+
qualifiedFieldName: e.qualifiedFieldName,
|
|
3926
|
+
qualifiedEntityName: e.qualifiedEntityName,
|
|
3927
|
+
entityId: e.entityId,
|
|
3928
|
+
entityName: e.entityName,
|
|
3929
|
+
entityType: e.entityType,
|
|
3930
|
+
source: e.source,
|
|
3931
|
+
sourceField: e.sourceField
|
|
3932
|
+
};
|
|
3933
|
+
if (t === "metrics") {
|
|
3934
|
+
if (d || s && c === "aggregate") {
|
|
3935
|
+
const h = e, C = {
|
|
3936
|
+
...m,
|
|
3937
|
+
role: "metric",
|
|
3938
|
+
...Kn(h, h, "selection"),
|
|
3939
|
+
parameters: h.parameters,
|
|
3940
|
+
aliasTemplate: h.aliasTemplate,
|
|
3941
|
+
valueAliases: h.valueAliases,
|
|
3942
|
+
isPreAggregated: h.isPreAggregated,
|
|
3943
|
+
comparison: h.comparison,
|
|
3944
|
+
comparisonPolarity: h.comparisonPolarity,
|
|
3945
|
+
semanticComparisonPolarity: h.semanticComparisonPolarity
|
|
3946
|
+
}, v = e.expression || "";
|
|
3947
|
+
if (!a.legacyManual && c !== "aggregate") {
|
|
3948
|
+
const b = !C.aggregate && (c === "row" || $i(v).calls.length === 0), S = Zt(i);
|
|
3949
|
+
return {
|
|
3950
|
+
...C,
|
|
3951
|
+
id: r,
|
|
3952
|
+
label: e.label || e.name,
|
|
3953
|
+
role: "metric",
|
|
3954
|
+
...b ? { aggregate: S, aggregateOrigin: "default" } : {}
|
|
3955
|
+
};
|
|
3956
|
+
}
|
|
3957
|
+
return {
|
|
3958
|
+
...C,
|
|
3959
|
+
id: r,
|
|
3960
|
+
label: e.label || e.name,
|
|
3961
|
+
role: "metric"
|
|
3962
|
+
};
|
|
3963
|
+
}
|
|
3964
|
+
const p = e.aggregate || Zt(i), y = Ds(
|
|
3965
|
+
e.label,
|
|
3966
|
+
p
|
|
3967
|
+
), g = Ci(
|
|
3968
|
+
{ ...m, label: y },
|
|
3969
|
+
n,
|
|
3970
|
+
t
|
|
3971
|
+
);
|
|
3972
|
+
return {
|
|
3973
|
+
...m,
|
|
3974
|
+
role: "metric",
|
|
3975
|
+
label: g,
|
|
3976
|
+
aggregate: p,
|
|
3977
|
+
aggregateOrigin: e.aggregate ? e.aggregateOrigin : "default"
|
|
3978
|
+
};
|
|
3979
|
+
}
|
|
3980
|
+
if (t === "groupBy") {
|
|
3981
|
+
if (u) {
|
|
3982
|
+
const p = e;
|
|
3983
|
+
return Ts({
|
|
3984
|
+
...m,
|
|
3985
|
+
label: e.label || e.name,
|
|
3986
|
+
role: "groupby",
|
|
3987
|
+
timeDrillPath: p.timeDrillPath
|
|
3988
|
+
});
|
|
3989
|
+
}
|
|
3990
|
+
return {
|
|
3991
|
+
...m,
|
|
3992
|
+
role: "groupby",
|
|
3993
|
+
...o && {
|
|
3994
|
+
granularity: $t(e.granularity) ? e.granularity : "month",
|
|
3995
|
+
// A new shelf placement does not author a presentation override.
|
|
3996
|
+
// Same-grain semantic presentation may therefore win; otherwise the
|
|
3997
|
+
// viewer's resolved automatic locale/style policy applies.
|
|
3998
|
+
format: void 0,
|
|
3999
|
+
formatOrigin: void 0
|
|
4000
|
+
}
|
|
4001
|
+
};
|
|
4002
|
+
}
|
|
4003
|
+
if (t === "pivotBy")
|
|
4004
|
+
return {
|
|
4005
|
+
...m,
|
|
4006
|
+
role: "pivotby",
|
|
4007
|
+
...o && {
|
|
4008
|
+
granularity: $t(e.granularity) ? e.granularity : "month",
|
|
4009
|
+
format: void 0,
|
|
4010
|
+
formatOrigin: void 0
|
|
4011
|
+
}
|
|
4012
|
+
};
|
|
4013
|
+
if (t === "detailColumns") {
|
|
4014
|
+
const p = Fi(m, "detail");
|
|
4015
|
+
if (d) {
|
|
4016
|
+
const y = e;
|
|
4017
|
+
return {
|
|
4018
|
+
...p,
|
|
4019
|
+
label: e.label || e.name,
|
|
4020
|
+
role: "detail",
|
|
4021
|
+
// Retain aggregate intent as provenance for later compatible placement
|
|
4022
|
+
// and validation, even though detail SQL evaluates the row expression.
|
|
4023
|
+
aggregate: y.aggregate,
|
|
4024
|
+
aggregateOrigin: y.aggregateOrigin
|
|
4025
|
+
};
|
|
4026
|
+
}
|
|
4027
|
+
return u ? {
|
|
4028
|
+
...p,
|
|
4029
|
+
label: e.label || e.name,
|
|
4030
|
+
role: "detail"
|
|
4031
|
+
} : {
|
|
4032
|
+
...p,
|
|
4033
|
+
role: "detail"
|
|
4034
|
+
};
|
|
4035
|
+
}
|
|
4036
|
+
return t === "sortBy" ? {
|
|
4037
|
+
...m,
|
|
4038
|
+
role: "sortby",
|
|
4039
|
+
label: e.label,
|
|
4040
|
+
direction: "asc"
|
|
4041
|
+
} : null;
|
|
4042
|
+
}
|
|
4043
|
+
function Jc(e) {
|
|
4044
|
+
return Object.values(Ii(e)).some((t) => t.length > 0);
|
|
4045
|
+
}
|
|
4046
|
+
function ks(e) {
|
|
4047
|
+
const t = Q(e.format);
|
|
4048
|
+
if ((t == null ? void 0 : t.type) === "temporal_bucket") {
|
|
4049
|
+
if (!e.granularity) return {};
|
|
4050
|
+
const n = Xi(
|
|
4051
|
+
t,
|
|
4052
|
+
e.granularity
|
|
4053
|
+
);
|
|
4054
|
+
return n ? {
|
|
4055
|
+
granularity: e.granularity,
|
|
4056
|
+
semanticTemporalPresentation: {
|
|
4057
|
+
granularity: e.granularity,
|
|
4058
|
+
format: n
|
|
4059
|
+
}
|
|
4060
|
+
} : {};
|
|
4061
|
+
}
|
|
4062
|
+
return {
|
|
4063
|
+
...e.granularity ? { granularity: e.granularity } : {},
|
|
4064
|
+
...t ? { format: t } : {}
|
|
4065
|
+
};
|
|
4066
|
+
}
|
|
4067
|
+
function Ms(e, t) {
|
|
4068
|
+
var i, o;
|
|
4069
|
+
const n = ((i = e.nativeDataType) == null ? void 0 : i.trim()) || ((o = e.native_data_type) == null ? void 0 : o.trim());
|
|
4070
|
+
return n || ((e.dataTypeProvenance || t) === "physical" ? e.data_type : void 0);
|
|
4071
|
+
}
|
|
4072
|
+
function dr(e) {
|
|
4073
|
+
const t = (e.label ?? "").trim();
|
|
4074
|
+
return t ? e.derivedLabel === void 0 ? !0 : t !== e.derivedLabel.trim() : !1;
|
|
4075
|
+
}
|
|
4076
|
+
function gt(e) {
|
|
4077
|
+
return dr(e) ? e.label.trim() : e.name || (e.label ?? "").trim();
|
|
4078
|
+
}
|
|
4079
|
+
function en(e) {
|
|
4080
|
+
return gt(e).toLowerCase().trim();
|
|
4081
|
+
}
|
|
4082
|
+
function Os(e, t) {
|
|
4083
|
+
return en(e).localeCompare(en(t), void 0, {
|
|
4084
|
+
numeric: !0,
|
|
4085
|
+
sensitivity: "base"
|
|
4086
|
+
});
|
|
4087
|
+
}
|
|
4088
|
+
function ae(e) {
|
|
4089
|
+
return String(e ?? "").toLowerCase().replace(/[\s_\-.]+/g, "");
|
|
4090
|
+
}
|
|
4091
|
+
function Zc(e, t) {
|
|
4092
|
+
const n = ae(t);
|
|
4093
|
+
return n ? [
|
|
4094
|
+
gt(e),
|
|
4095
|
+
e.label,
|
|
4096
|
+
e.name,
|
|
4097
|
+
e.description,
|
|
4098
|
+
e.entityName,
|
|
4099
|
+
e.qualifiedEntityName,
|
|
4100
|
+
e.entityName && e.name ? `${e.entityName}.${e.name}` : "",
|
|
4101
|
+
e.dataType
|
|
4102
|
+
].some(
|
|
4103
|
+
(i) => !!i && ae(i).includes(n)
|
|
4104
|
+
) : !0;
|
|
4105
|
+
}
|
|
4106
|
+
function tn(e, t) {
|
|
4107
|
+
const n = ae(t);
|
|
4108
|
+
if (!n) return 0;
|
|
4109
|
+
const r = ae(gt(e));
|
|
4110
|
+
return r.startsWith(n) ? 0 : r.includes(n) ? 1 : [e.label, e.name].filter(Boolean).map(ae).some((o) => o.includes(n)) ? 2 : 3;
|
|
4111
|
+
}
|
|
4112
|
+
function el(e, t, n) {
|
|
4113
|
+
return tn(e, n) - tn(t, n) || Os(e, t);
|
|
4114
|
+
}
|
|
4115
|
+
function _s(e, t) {
|
|
4116
|
+
var o;
|
|
4117
|
+
const n = e.type === "dataset" ? (o = t.find((a) => a.entityName)) == null ? void 0 : o.entityName : void 0, r = n || e.name, i = Pt(
|
|
4118
|
+
e.type === "dataset" && n ? { ...e, name: n } : e
|
|
4119
|
+
);
|
|
4120
|
+
return {
|
|
4121
|
+
entityId: e.id || e.name,
|
|
4122
|
+
entityType: e.type,
|
|
4123
|
+
entityName: r,
|
|
4124
|
+
label: e.label,
|
|
4125
|
+
description: e.description,
|
|
4126
|
+
qualifiedEntityName: i,
|
|
4127
|
+
columns: t.map((a) => {
|
|
4128
|
+
var m;
|
|
4129
|
+
const s = e.type === "dataset" ? a.entityName || r : e.name, c = a.qualifiedEntityName || (e.type === "dataset" && s ? Pt({ ...e, name: s }) : i), l = Ms(
|
|
4130
|
+
a,
|
|
4131
|
+
e.type === "dataset" ? "semantic" : "physical"
|
|
4132
|
+
), d = (m = a.label) != null && m.trim() ? a.label : void 0, u = d ? void 0 : et(a.column_name);
|
|
4133
|
+
return {
|
|
4134
|
+
id: Si(s, a.column_name),
|
|
4135
|
+
name: a.column_name,
|
|
4136
|
+
qualifiedFieldName: a.qualifiedFieldName || a.column_name,
|
|
4137
|
+
dataType: a.data_type,
|
|
4138
|
+
...l ? { nativeDataType: l } : {},
|
|
4139
|
+
label: d ?? u ?? a.column_name,
|
|
4140
|
+
...u !== void 0 ? { derivedLabel: u } : {},
|
|
4141
|
+
description: a.description || "",
|
|
4142
|
+
qualifiedEntityName: c,
|
|
4143
|
+
entityId: a.entityId || e.id || e.id || s,
|
|
4144
|
+
entityName: s,
|
|
4145
|
+
entityType: a.entityType || e.type,
|
|
4146
|
+
role: a.role,
|
|
4147
|
+
expression: a.expression,
|
|
4148
|
+
calculatedFormula: a.calculatedFormula,
|
|
4149
|
+
calculationRepresentation: a.calculationRepresentation,
|
|
4150
|
+
derivedField: a.derivedField,
|
|
4151
|
+
fieldScope: a.fieldScope,
|
|
4152
|
+
source: a.source,
|
|
4153
|
+
sourceField: a.sourceField,
|
|
4154
|
+
calculatedFieldOrigin: a.calculatedFieldOrigin,
|
|
4155
|
+
aggregateOrigin: a.aggregateOrigin,
|
|
4156
|
+
labelOrigin: a.labelOrigin,
|
|
4157
|
+
formatOrigin: a.formatOrigin,
|
|
4158
|
+
...ks(a),
|
|
4159
|
+
aggregate: a.aggregate
|
|
4160
|
+
};
|
|
4161
|
+
})
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
function Ps(e) {
|
|
4165
|
+
return e.map((t) => ({
|
|
4166
|
+
...t,
|
|
4167
|
+
id: hn({ ...t }),
|
|
4168
|
+
fieldScope: "domain"
|
|
4169
|
+
}));
|
|
4170
|
+
}
|
|
4171
|
+
function As(e) {
|
|
4172
|
+
return e.flatMap(
|
|
4173
|
+
(t) => t.columns.map((n) => {
|
|
4174
|
+
const r = dr(n) ? n.label : void 0, i = r ? void 0 : n.derivedLabel ?? pn(n.name), o = r ?? i ?? n.name;
|
|
4175
|
+
return {
|
|
4176
|
+
...n,
|
|
4177
|
+
id: n.id || `${t.entityId}-${n.name}`,
|
|
4178
|
+
name: n.name,
|
|
4179
|
+
qualifiedFieldName: n.qualifiedFieldName || n.name,
|
|
4180
|
+
dataType: n.dataType,
|
|
4181
|
+
qualifiedEntityName: n.qualifiedEntityName || t.qualifiedEntityName,
|
|
4182
|
+
label: o,
|
|
4183
|
+
...i !== void 0 ? { derivedLabel: i } : {},
|
|
4184
|
+
description: n.description,
|
|
4185
|
+
entityId: n.entityId || t.entityId,
|
|
4186
|
+
entityName: n.entityName || t.entityName,
|
|
4187
|
+
entityType: n.entityType || t.entityType
|
|
4188
|
+
};
|
|
4189
|
+
})
|
|
4190
|
+
);
|
|
4191
|
+
}
|
|
4192
|
+
function tl(e) {
|
|
4193
|
+
const t = e.map((r) => _s(r.target, r.columns || [])).filter((r) => {
|
|
4194
|
+
var i;
|
|
4195
|
+
return ((i = r == null ? void 0 : r.columns) == null ? void 0 : i.length) > 0;
|
|
4196
|
+
}), n = Ps(e.flatMap((r) => r.calculatedFields || []));
|
|
4197
|
+
if (n.length > 0) {
|
|
4198
|
+
const r = /* @__PURE__ */ new Map();
|
|
4199
|
+
n.forEach((i) => {
|
|
4200
|
+
const o = hn(i);
|
|
4201
|
+
r.has(o) || r.set(o, i);
|
|
4202
|
+
}), t.unshift({
|
|
4203
|
+
entityId: xi,
|
|
4204
|
+
entityType: "dataset",
|
|
4205
|
+
entityName: At,
|
|
4206
|
+
label: "Calculated Fields",
|
|
4207
|
+
description: "Domain-level calculated metrics and dimensions",
|
|
4208
|
+
qualifiedEntityName: At,
|
|
4209
|
+
columns: Array.from(r.values())
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
return { columnGroups: t, columns: As(t) };
|
|
4213
|
+
}
|
|
4214
|
+
function Ns(e, t) {
|
|
4215
|
+
var i;
|
|
4216
|
+
const n = (i = t.columnKeyMap) == null ? void 0 : i.byRole;
|
|
4217
|
+
if (!n) return;
|
|
4218
|
+
const r = Object.values(n).flatMap((o) => {
|
|
4219
|
+
const a = o == null ? void 0 : o[e];
|
|
4220
|
+
return a ? [a] : [];
|
|
4221
|
+
});
|
|
4222
|
+
if (r.length === 1)
|
|
4223
|
+
return r[0].outputKey ?? r[0].rawKey;
|
|
4224
|
+
}
|
|
4225
|
+
function Es(e, t) {
|
|
4226
|
+
var r;
|
|
4227
|
+
const n = (r = t.resultColumns) == null ? void 0 : r.find((i) => {
|
|
4228
|
+
const o = i.pivotIdentity;
|
|
4229
|
+
return (o == null ? void 0 : o.metricId) === e.metricId && o.members.length === e.members.length && o.members.every(
|
|
4230
|
+
(a, s) => a.fieldId === e.members[s].fieldId && a.value === e.members[s].value
|
|
4231
|
+
);
|
|
4232
|
+
});
|
|
4233
|
+
return n == null ? void 0 : n.key;
|
|
4234
|
+
}
|
|
4235
|
+
function nn(e, t) {
|
|
4236
|
+
var n;
|
|
4237
|
+
switch (e.kind) {
|
|
4238
|
+
case "field":
|
|
4239
|
+
return Ns(e.fieldId, t);
|
|
4240
|
+
case "pivot":
|
|
4241
|
+
return Es(e, t);
|
|
4242
|
+
case "result":
|
|
4243
|
+
return !t.keys || t.keys.includes(e.key) ? e.key : void 0;
|
|
4244
|
+
case "sqlKpiValue":
|
|
4245
|
+
return (n = t.keys) == null ? void 0 : n[0];
|
|
4246
|
+
case "matrixMeasure":
|
|
4247
|
+
return e.measureId;
|
|
4248
|
+
case "matrixLevel":
|
|
4249
|
+
return;
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
function nl(e, t) {
|
|
4253
|
+
return e.flatMap((n) => {
|
|
4254
|
+
var s, c;
|
|
4255
|
+
const r = nn(n.condition.column, t);
|
|
4256
|
+
if (r === void 0) return [];
|
|
4257
|
+
const i = (s = n.target.columns) == null ? void 0 : s.flatMap((l) => {
|
|
4258
|
+
const d = nn(l, t);
|
|
4259
|
+
return d === void 0 ? [] : [d];
|
|
4260
|
+
});
|
|
4261
|
+
if ((c = n.target.columns) != null && c.length && !(i != null && i.length)) return [];
|
|
4262
|
+
const { columns: o, ...a } = n.target;
|
|
4263
|
+
return [
|
|
4264
|
+
{
|
|
4265
|
+
...n,
|
|
4266
|
+
condition: { ...n.condition, column: r },
|
|
4267
|
+
target: i ? { ...a, columns: i } : a
|
|
4268
|
+
}
|
|
4269
|
+
];
|
|
4270
|
+
});
|
|
4271
|
+
}
|
|
4272
|
+
function rl(e, t, n) {
|
|
4273
|
+
var a, s, c, l, d;
|
|
4274
|
+
const r = wi(e);
|
|
4275
|
+
if (r.includes("matrixMeasure"))
|
|
4276
|
+
return (s = (a = e.config) == null ? void 0 : a.matrix) != null && s.spec.measures.some((u) => u.id === t) ? { kind: "matrixMeasure", measureId: t } : void 0;
|
|
4277
|
+
if (r.includes("sqlKpiValue")) return { kind: "sqlKpiValue" };
|
|
4278
|
+
if (r.includes("result"))
|
|
4279
|
+
return !n.keys || n.keys.includes(t) ? { kind: "result", key: t } : void 0;
|
|
4280
|
+
const i = r.includes("pivot") ? (l = (c = n.resultColumns) == null ? void 0 : c.find((u) => u.key === t)) == null ? void 0 : l.pivotIdentity : void 0;
|
|
4281
|
+
if (i)
|
|
4282
|
+
return {
|
|
4283
|
+
kind: "pivot",
|
|
4284
|
+
metricId: i.metricId,
|
|
4285
|
+
members: i.members.map((u) => ({ fieldId: u.fieldId, value: u.value }))
|
|
4286
|
+
};
|
|
4287
|
+
if (!r.includes("field")) return;
|
|
4288
|
+
const o = Object.values(((d = n.columnKeyMap) == null ? void 0 : d.byRole) ?? {}).flatMap(
|
|
4289
|
+
(u) => Object.entries(u ?? {}).flatMap(
|
|
4290
|
+
([f, m]) => (m.outputKey ?? m.rawKey) === t ? [f] : []
|
|
4291
|
+
)
|
|
4292
|
+
);
|
|
4293
|
+
return o.length === 1 ? { kind: "field", fieldId: o[0] } : void 0;
|
|
4294
|
+
}
|
|
4295
|
+
function il(e, t) {
|
|
4296
|
+
var i, o;
|
|
4297
|
+
const n = (i = t == null ? void 0 : t.find(
|
|
4298
|
+
(a) => a.filterId === e.id
|
|
4299
|
+
)) == null ? void 0 : i.name, r = /* @__PURE__ */ new Set([
|
|
4300
|
+
e.column,
|
|
4301
|
+
...((o = e.targetColumns) == null ? void 0 : o.map((a) => a.column)) ?? []
|
|
4302
|
+
]);
|
|
4303
|
+
return n && r.has(n) ? n : e.column;
|
|
4304
|
+
}
|
|
4305
|
+
function al(e, t, n) {
|
|
4306
|
+
const r = Ti({ card: e, stated: t, context: n });
|
|
4307
|
+
return r.ok ? { ok: !0, card: r.update ? Di(e, r.update).card : e, warnings: r.warnings } : r;
|
|
4308
|
+
}
|
|
4309
|
+
function ol({
|
|
4310
|
+
resolvedCardConfig: e,
|
|
4311
|
+
card: t,
|
|
4312
|
+
row: n,
|
|
4313
|
+
columnKeyMap: r,
|
|
4314
|
+
temporalPresentation: i,
|
|
4315
|
+
rawTemporalPresentation: o
|
|
4316
|
+
}) {
|
|
4317
|
+
const a = e || t.config, { groupByColumns: s = [], metricColumns: c = [], detailColumns: l = [] } = a || {}, d = t.type === "detailTable", u = d ? "detail" : "groupby", f = d ? l : s, m = d ? [] : c, p = [];
|
|
4318
|
+
for (const g of f) {
|
|
4319
|
+
const h = r ? Ue(r, g.id, u) : void 0, C = (h == null ? void 0 : h.outputKey) || (h == null ? void 0 : h.rawKey) || g.label, v = n.getValue(C), I = i == null ? void 0 : i.byColumnKey.get(C);
|
|
4320
|
+
if (v == null && I)
|
|
4321
|
+
p.push({
|
|
4322
|
+
field: g,
|
|
4323
|
+
operator: "isNull",
|
|
4324
|
+
value: null,
|
|
4325
|
+
...I ? { label: "(Blank)", temporalBucket: I.metadata } : {}
|
|
4326
|
+
});
|
|
4327
|
+
else if (v != null) {
|
|
4328
|
+
const b = I || o == null ? void 0 : o.byColumnKey.get(C);
|
|
4329
|
+
p.push({
|
|
4330
|
+
field: g,
|
|
4331
|
+
operator: "=",
|
|
4332
|
+
value: String(v),
|
|
4333
|
+
// Convert to string for consistency
|
|
4334
|
+
...I ? {
|
|
4335
|
+
label: Mi({
|
|
4336
|
+
value: String(v),
|
|
4337
|
+
presentation: I
|
|
4338
|
+
}),
|
|
4339
|
+
temporalBucket: I.metadata
|
|
4340
|
+
} : {},
|
|
4341
|
+
...b ? {
|
|
4342
|
+
label: ki({ value: String(v), presentation: b }).label,
|
|
4343
|
+
rawTemporal: { ...b.metadata, tz: b.format.calendarTimezone }
|
|
4344
|
+
} : {}
|
|
4345
|
+
});
|
|
4346
|
+
}
|
|
4347
|
+
}
|
|
4348
|
+
if (p.length === 0)
|
|
4349
|
+
return;
|
|
4350
|
+
const y = [];
|
|
4351
|
+
for (const g of m) {
|
|
4352
|
+
const h = r ? Ue(r, g.id, "metric") : void 0, C = n.getValue(
|
|
4353
|
+
(h == null ? void 0 : h.outputKey) || (h == null ? void 0 : h.rawKey) || g.label
|
|
4354
|
+
);
|
|
4355
|
+
C != null && y.push({
|
|
4356
|
+
field: g,
|
|
4357
|
+
value: Number(C)
|
|
4358
|
+
// Convert to number for metrics
|
|
4359
|
+
});
|
|
4360
|
+
}
|
|
4361
|
+
return {
|
|
4362
|
+
conditions: p,
|
|
4363
|
+
// Only include metrics if we have at least one
|
|
4364
|
+
metrics: y.length > 0 ? y : void 0
|
|
4365
|
+
};
|
|
4366
|
+
}
|
|
4367
|
+
function sl({
|
|
4368
|
+
resolvedCardConfig: e,
|
|
4369
|
+
card: t,
|
|
4370
|
+
columnId: n,
|
|
4371
|
+
columnKeyMap: r
|
|
4372
|
+
}) {
|
|
4373
|
+
const i = e || t.config, o = t.type === "detailTable", a = o ? "detail" : "groupby";
|
|
4374
|
+
return ((o ? i == null ? void 0 : i.detailColumns : i == null ? void 0 : i.groupByColumns) || []).find((c) => {
|
|
4375
|
+
const l = r ? Ue(r, c.id, a) : void 0;
|
|
4376
|
+
return ((l == null ? void 0 : l.outputKey) || (l == null ? void 0 : l.rawKey) || c.label) === n;
|
|
4377
|
+
});
|
|
4378
|
+
}
|
|
4379
|
+
const $s = {
|
|
4380
|
+
noFields: "There is nothing to filter by here.",
|
|
4381
|
+
clickedColumnNotFilterable: "This column cannot filter other cards.",
|
|
4382
|
+
noChosenColumns: "This column is not set up to filter other cards.",
|
|
4383
|
+
fieldNotFilterable: "This value cannot filter other cards.",
|
|
4384
|
+
unsupportedCondition: "This value cannot filter other cards."
|
|
4385
|
+
};
|
|
4386
|
+
function Ve(e) {
|
|
4387
|
+
return { status: "unavailable", code: e, reason: $s[e] };
|
|
4388
|
+
}
|
|
4389
|
+
function cl(e) {
|
|
4390
|
+
const t = e.conditions.filter(
|
|
4391
|
+
(s) => s.field.role !== "metric"
|
|
4392
|
+
);
|
|
4393
|
+
if (!t.length) return Ve("noFields");
|
|
4394
|
+
const n = (s) => {
|
|
4395
|
+
if (s.operator !== "=" && s.operator !== "isNull")
|
|
4396
|
+
return "unsupportedCondition";
|
|
4397
|
+
const c = Nt(
|
|
4398
|
+
s.field,
|
|
4399
|
+
e.sourceIndex
|
|
4400
|
+
);
|
|
4401
|
+
if (!c) return "fieldNotFilterable";
|
|
4402
|
+
const l = s.operator === "isNull" || s.value === null;
|
|
4403
|
+
return {
|
|
4404
|
+
field: c,
|
|
4405
|
+
operator: l ? "isNull" : "=",
|
|
4406
|
+
value: l ? null : s.value,
|
|
4407
|
+
...s.label ? { label: s.label } : {},
|
|
4408
|
+
...s.temporalBucket ? { temporalBucket: s.temporalBucket } : {},
|
|
4409
|
+
...s.rawTemporal ? { rawTemporal: s.rawTemporal } : {}
|
|
4410
|
+
};
|
|
4411
|
+
}, r = e.settings.fields, i = [];
|
|
4412
|
+
if (r.kind === "wholeRow")
|
|
4413
|
+
for (const s of t) {
|
|
4414
|
+
const c = n(s);
|
|
4415
|
+
if (typeof c == "string") return Ve(c);
|
|
4416
|
+
i.push(c);
|
|
4417
|
+
}
|
|
4418
|
+
else {
|
|
4419
|
+
const s = r.kind === "clickedCell" && e.clickedField ? Nt(e.clickedField, e.sourceIndex) : void 0, c = r.kind === "chosenColumns" ? r.clickedFieldKeys : s ? [Ae(s)] : [];
|
|
4420
|
+
for (const l of t) {
|
|
4421
|
+
const d = n(l);
|
|
4422
|
+
typeof d != "string" && c.includes(Ae(d.field)) && i.push(d);
|
|
4423
|
+
}
|
|
4424
|
+
if (!i.length)
|
|
4425
|
+
return Ve(
|
|
4426
|
+
r.kind === "clickedCell" ? "clickedColumnNotFilterable" : "noChosenColumns"
|
|
4427
|
+
);
|
|
4428
|
+
}
|
|
4429
|
+
const o = /* @__PURE__ */ new Set();
|
|
4430
|
+
return { status: "ready", tuple: { conditions: i.filter((s) => {
|
|
4431
|
+
const c = Ae(s.field);
|
|
4432
|
+
return o.has(c) ? !1 : (o.add(c), !0);
|
|
4433
|
+
}) } };
|
|
4434
|
+
}
|
|
4435
|
+
function ll(e, t) {
|
|
4436
|
+
const n = e.answers.relationshipIds;
|
|
4437
|
+
return !n || !t ? !n && !t : n.length === t.length && n.every((r, i) => t[i] === r);
|
|
4438
|
+
}
|
|
4439
|
+
const Rs = /* @__PURE__ */ new Set([
|
|
4440
|
+
"dataset_not_reachable",
|
|
4441
|
+
"field_not_resolvable",
|
|
4442
|
+
"missing_metadata",
|
|
4443
|
+
"unsupported_calculated_filter",
|
|
4444
|
+
"relationship_unsupported",
|
|
4445
|
+
"relationship_missing",
|
|
4446
|
+
"relationship_ambiguous"
|
|
4447
|
+
]);
|
|
4448
|
+
function z(e) {
|
|
4449
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
4450
|
+
}
|
|
4451
|
+
function Ks(e) {
|
|
4452
|
+
if (z(e))
|
|
4453
|
+
switch (e.status) {
|
|
4454
|
+
case "applied": {
|
|
4455
|
+
const t = xn(e.route);
|
|
4456
|
+
return t ? { status: "applied", route: t } : void 0;
|
|
4457
|
+
}
|
|
4458
|
+
case "skipped":
|
|
4459
|
+
return typeof e.reason == "string" && Rs.has(e.reason) ? { status: "skipped", reason: e.reason } : void 0;
|
|
4460
|
+
case "needsPath":
|
|
4461
|
+
return { status: "needsPath" };
|
|
4462
|
+
case "blocked":
|
|
4463
|
+
return typeof e.message == "string" ? { status: "blocked", message: e.message } : void 0;
|
|
4464
|
+
case "kept":
|
|
4465
|
+
return { status: "kept" };
|
|
4466
|
+
case "notRelationship":
|
|
4467
|
+
return { status: "notRelationship" };
|
|
4468
|
+
default:
|
|
4469
|
+
return;
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
function ur(e) {
|
|
4473
|
+
if (e !== void 0)
|
|
4474
|
+
return Array.isArray(e) && e.length > 0 && e.every((t) => typeof t == "string" && t.length > 0) ? e : null;
|
|
4475
|
+
}
|
|
4476
|
+
function Vs(e) {
|
|
4477
|
+
if (!z(e)) return;
|
|
4478
|
+
const t = xn(e.route), n = e.target;
|
|
4479
|
+
if (!(!t || !z(n) || n.kind !== "relationship" || !z(n.field) || typeof n.field.name != "string" || !z(n.field.source) || n.field.source.kind !== "semantic" || !ur(n.relationshipIds)))
|
|
4480
|
+
return { route: t, target: n };
|
|
4481
|
+
}
|
|
4482
|
+
function dl(e) {
|
|
4483
|
+
if (!z(e) || !Array.isArray(e.previews)) return { previews: [] };
|
|
4484
|
+
const t = [];
|
|
4485
|
+
for (const r of e.previews) {
|
|
4486
|
+
if (!z(r) || typeof r.cardId != "string" || !r.cardId || !z(r.answers)) continue;
|
|
4487
|
+
const i = ur(r.answers.relationshipIds), o = Ks(r.outcome), a = Array.isArray(r.paths) ? r.paths.map(Vs) : [];
|
|
4488
|
+
i === null || !o || !a.every(Boolean) || o.status === "needsPath" && a.length < 2 || t.push({
|
|
4489
|
+
cardId: r.cardId,
|
|
4490
|
+
answers: i ? { relationshipIds: i } : {},
|
|
4491
|
+
outcome: o,
|
|
4492
|
+
paths: a
|
|
4493
|
+
});
|
|
4494
|
+
}
|
|
4495
|
+
const n = z(e.manageRelationships) && typeof e.manageRelationships.href == "string" ? { href: e.manageRelationships.href } : void 0;
|
|
4496
|
+
return { previews: t, ...n ? { manageRelationships: n } : {} };
|
|
4497
|
+
}
|
|
4498
|
+
const ye = (e) => (e == null ? void 0 : e.label) || (e == null ? void 0 : e.name) || "";
|
|
4499
|
+
function Ls(e) {
|
|
4500
|
+
return !e || /s$/i.test(e) ? e : /[^aeiou]y$/i.test(e) ? `${e.slice(0, -1)}ies` : `${e}s`;
|
|
4501
|
+
}
|
|
4502
|
+
function ul(e) {
|
|
4503
|
+
if (e.direction === "to_many") {
|
|
4504
|
+
const n = ye(e.matchingDataset ?? e.datasets[e.datasets.length - 1]);
|
|
4505
|
+
return `${e.base ? Ls(ye(e.base)) : "Rows"} with at least one matching ${n}`;
|
|
4506
|
+
}
|
|
4507
|
+
return `through ${(e.datasets.length > 1 ? e.datasets.slice(0, -1) : e.datasets).map(ye).join(", ")}`;
|
|
4508
|
+
}
|
|
4509
|
+
const fl = "The relationship this card used changed; choose it again";
|
|
4510
|
+
function ml(e, t) {
|
|
4511
|
+
switch (e) {
|
|
4512
|
+
case "relationship_missing":
|
|
4513
|
+
return t ? `Not related to ${ye(t)}` : "Not related to this card";
|
|
4514
|
+
case "relationship_ambiguous":
|
|
4515
|
+
return "Connects through more than one path";
|
|
4516
|
+
case "relationship_unsupported":
|
|
4517
|
+
return "Can't be applied to this card";
|
|
4518
|
+
case "dataset_not_reachable":
|
|
4519
|
+
case "field_not_resolvable":
|
|
4520
|
+
case "missing_metadata":
|
|
4521
|
+
case "unsupported_calculated_filter":
|
|
4522
|
+
return "No matching field on this card";
|
|
4523
|
+
default:
|
|
4524
|
+
return String(e);
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
export {
|
|
4528
|
+
M as $,
|
|
4529
|
+
_s as A,
|
|
4530
|
+
Ps as B,
|
|
4531
|
+
As as C,
|
|
4532
|
+
Zo as D,
|
|
4533
|
+
tl as E,
|
|
4534
|
+
nn as F,
|
|
4535
|
+
nl as G,
|
|
4536
|
+
rl as H,
|
|
4537
|
+
al as I,
|
|
4538
|
+
ll as J,
|
|
4539
|
+
dl as K,
|
|
4540
|
+
Ls as L,
|
|
4541
|
+
ul as M,
|
|
4542
|
+
Ja as N,
|
|
4543
|
+
ml as O,
|
|
4544
|
+
gt as P,
|
|
4545
|
+
za as Q,
|
|
4546
|
+
fl as R,
|
|
4547
|
+
ba as S,
|
|
4548
|
+
va as T,
|
|
4549
|
+
Te as U,
|
|
4550
|
+
dc as V,
|
|
4551
|
+
_c as W,
|
|
4552
|
+
sc as X,
|
|
4553
|
+
Fe as Y,
|
|
4554
|
+
so as Z,
|
|
4555
|
+
lo as _,
|
|
4556
|
+
Yc as a,
|
|
4557
|
+
Oc as a$,
|
|
4558
|
+
as as a0,
|
|
4559
|
+
ho as a1,
|
|
4560
|
+
Mc as a2,
|
|
4561
|
+
Kc as a3,
|
|
4562
|
+
$c as a4,
|
|
4563
|
+
ha as a5,
|
|
4564
|
+
pa as a6,
|
|
4565
|
+
ga as a7,
|
|
4566
|
+
xc as a8,
|
|
4567
|
+
lt as a9,
|
|
4568
|
+
ot as aA,
|
|
4569
|
+
uc as aB,
|
|
4570
|
+
fc as aC,
|
|
4571
|
+
Se as aD,
|
|
4572
|
+
le as aE,
|
|
4573
|
+
oc as aF,
|
|
4574
|
+
sl as aG,
|
|
4575
|
+
yc as aH,
|
|
4576
|
+
Fo as aI,
|
|
4577
|
+
V as aJ,
|
|
4578
|
+
Pc as aK,
|
|
4579
|
+
nr as aL,
|
|
4580
|
+
Zc as aM,
|
|
4581
|
+
dr as aN,
|
|
4582
|
+
zc as aO,
|
|
4583
|
+
Is as aP,
|
|
4584
|
+
se as aQ,
|
|
4585
|
+
pt as aR,
|
|
4586
|
+
qc as aS,
|
|
4587
|
+
jc as aT,
|
|
4588
|
+
Bc as aU,
|
|
4589
|
+
hs as aV,
|
|
4590
|
+
Ms as aW,
|
|
4591
|
+
Hc as aX,
|
|
4592
|
+
Wc as aY,
|
|
4593
|
+
Uc as aZ,
|
|
4594
|
+
vs as a_,
|
|
4595
|
+
mc as aa,
|
|
4596
|
+
vc as ab,
|
|
4597
|
+
Cc as ac,
|
|
4598
|
+
Ic as ad,
|
|
4599
|
+
st as ae,
|
|
4600
|
+
Ea as af,
|
|
4601
|
+
bc as ag,
|
|
4602
|
+
Fc as ah,
|
|
4603
|
+
Ta as ai,
|
|
4604
|
+
Va as aj,
|
|
4605
|
+
La as ak,
|
|
4606
|
+
Sc as al,
|
|
4607
|
+
U as am,
|
|
4608
|
+
je as an,
|
|
4609
|
+
$a as ao,
|
|
4610
|
+
pc as ap,
|
|
4611
|
+
gc as aq,
|
|
4612
|
+
Jc as ar,
|
|
4613
|
+
hc as as,
|
|
4614
|
+
Rn as at,
|
|
4615
|
+
lc as au,
|
|
4616
|
+
ja as av,
|
|
4617
|
+
ma as aw,
|
|
4618
|
+
ac as ax,
|
|
4619
|
+
wn as ay,
|
|
4620
|
+
Ia as az,
|
|
4621
|
+
Ds as b,
|
|
4622
|
+
ao as b0,
|
|
4623
|
+
Na as b1,
|
|
4624
|
+
el as b2,
|
|
4625
|
+
tn as b3,
|
|
4626
|
+
co as b4,
|
|
4627
|
+
ks as b5,
|
|
4628
|
+
Rc as b6,
|
|
4629
|
+
rs as b7,
|
|
4630
|
+
Xc as b8,
|
|
4631
|
+
Ts as b9,
|
|
4632
|
+
ae as ba,
|
|
4633
|
+
Ac as bb,
|
|
4634
|
+
yo as bc,
|
|
4635
|
+
Nc as bd,
|
|
4636
|
+
Gt as be,
|
|
4637
|
+
bo as bf,
|
|
4638
|
+
er as bg,
|
|
4639
|
+
Zn as bh,
|
|
4640
|
+
zo as bi,
|
|
4641
|
+
Vc as bj,
|
|
4642
|
+
cc as bk,
|
|
4643
|
+
Zt as c,
|
|
4644
|
+
il as d,
|
|
4645
|
+
vo as e,
|
|
4646
|
+
Ec as f,
|
|
4647
|
+
Qc as g,
|
|
4648
|
+
kc as h,
|
|
4649
|
+
Dc as i,
|
|
4650
|
+
Lc as j,
|
|
4651
|
+
Cs as k,
|
|
4652
|
+
So as l,
|
|
4653
|
+
xo as m,
|
|
4654
|
+
ol as n,
|
|
4655
|
+
Ga as o,
|
|
4656
|
+
Ha as p,
|
|
4657
|
+
Ya as q,
|
|
4658
|
+
Gc as r,
|
|
4659
|
+
cl as s,
|
|
4660
|
+
wc as t,
|
|
4661
|
+
Kn as u,
|
|
4662
|
+
no as v,
|
|
4663
|
+
Xa as w,
|
|
4664
|
+
Tc as x,
|
|
4665
|
+
Qa as y,
|
|
4666
|
+
eo as z
|
|
4667
|
+
};
|