react-semaphor 0.1.560 → 0.1.562

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/analytics-protocol/index.js +450 -423
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +9 -9
  5. package/dist/briefings/index.js +5 -5
  6. package/dist/chunks/{analytics-base-schemas-CHLxsPfX.js → analytics-base-schemas-BaIQrEzX.js} +221 -188
  7. package/dist/chunks/{assistant-chat-Bu2fFm_I.js → assistant-chat-R_yT8xH4.js} +116 -117
  8. package/dist/chunks/bookmark-impact-D4Kl4amw.js +75 -0
  9. package/dist/chunks/bookmark-state-CWeoGbrx.js +743 -0
  10. package/dist/chunks/{braces-Da41xfUd.js → braces-DzgoQC64.js} +1 -1
  11. package/dist/chunks/{comparison-window-caption-4FNkMrzE.js → comparison-window-caption-D1EUXzaR.js} +550 -425
  12. package/dist/chunks/{context-BgPDzLHZ.js → context-R31TSL5V.js} +1 -1
  13. package/dist/chunks/{dashboard-_MeBuy67.js → dashboard-Bp1y5oun.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-CEi4Pr_v.js → dashboard-briefing-launcher-S5FB3aUW.js} +236 -236
  15. package/dist/chunks/dashboard-controls-CfC_6Ztn.js +2277 -0
  16. package/dist/chunks/{dashboard-json-B1mU_OMa.js → dashboard-json-gYZT7ZQY.js} +5 -5
  17. package/dist/chunks/dates-DFY7Gfss.js +91 -0
  18. package/dist/chunks/{edit-dashboard-visual-0CJN31Y3.js → edit-dashboard-visual-u7OI_g8Q.js} +7119 -7198
  19. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +3965 -0
  20. package/dist/chunks/{filter-value-text-CRC-K_l_.js → filter-value-text-CPwFkrMz.js} +11 -10
  21. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +16722 -0
  22. package/dist/chunks/{index-DtHidOPV.js → index-CNGkfUp4.js} +269 -264
  23. package/dist/chunks/{layout-grid-BvsH4RY2.js → layout-grid-BM65viQh.js} +1 -1
  24. package/dist/chunks/{list-filter-Dg0otx5E.js → list-filter-BoeLBfL3.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-CM18W8w6.js → matrix-analytical-definition-hEucouWM.js} +4 -4
  26. package/dist/chunks/{matrix-card-HPskLaPy.js → matrix-card-CCh9JjP1.js} +3 -3
  27. package/dist/chunks/{matrix-member-presentation-Bbrfrke4.js → matrix-member-presentation-DsAUbuoL.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-WPv4R-H_.js → matrix-operation-contract-DsLdFdSa.js} +365 -349
  29. package/dist/chunks/{metric-comparison-ljMKYZKa.js → metric-comparison-Bnso1cm1.js} +6 -6
  30. package/dist/chunks/{model-change-Ccn1zaxl.js → model-change-T1cRkh3m.js} +1 -1
  31. package/dist/chunks/{palette-Bsh376zO.js → palette-p1XSJFgB.js} +1 -1
  32. package/dist/chunks/pivot-result-contract-expectations-B53jqszr.js +56 -0
  33. package/dist/chunks/{pivot-result-identity-vS9TSh4f.js → pivot-result-identity-Dq5jm-EC.js} +1 -1
  34. package/dist/chunks/{zoned-wall-clock-B1n_WjW3.js → raw-temporal-value-Bqz8wc7L.js} +97 -46
  35. package/dist/chunks/{report-preferences-dialog-BV8L0SeS.js → report-preferences-dialog-C4RAR8u5.js} +68 -63
  36. package/dist/chunks/{report-runtime-context-BZQh9ywy.js → report-runtime-context-BITkNSDa.js} +2 -2
  37. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +8214 -0
  38. package/dist/chunks/{save-B5EAsgQF.js → save-CHV1B1fL.js} +1 -1
  39. package/dist/chunks/{saved-dashboard-context-n2Wn11cV.js → saved-dashboard-context-DFYBrE6O.js} +93 -94
  40. package/dist/chunks/{selection-filter-compiler-BKXmyLrS.js → selection-filter-compiler-CUDRnUxc.js} +19 -18
  41. package/dist/chunks/{selection-reducer-D0YnaAD9.js → selection-reducer-Bz5aywT4.js} +1 -1
  42. package/dist/chunks/{semaphor-ready-indicator-XLBLOJ2V.js → semaphor-ready-indicator-Cfuafnem.js} +38188 -40344
  43. package/dist/chunks/{shelf-drop-preview-context-DHMa54a-.js → shelf-drop-preview-context-BR2GEYog.js} +81 -82
  44. package/dist/chunks/{source-entity-resolution-dUG5VWRm.js → source-entity-resolution-DdDVXFB8.js} +6 -6
  45. package/dist/chunks/{switch-ByxH4M7t.js → switch-BW4yXSYs.js} +3 -3
  46. package/dist/chunks/{table-export-sheet-C_GdeTYU.js → table-export-sheet-bSXxGn-v.js} +1 -1
  47. package/dist/chunks/temporal-input-presentation-sk9gqLi6.js +4960 -0
  48. package/dist/chunks/{token-types-CQtXUVMy.js → token-types-BUK06hU2.js} +1 -1
  49. package/dist/chunks/{upload-wbR-NVzq.js → upload-BnmuyPqW.js} +1 -1
  50. package/dist/chunks/{use-create-flow-overlay-state-CEBaLOKC.js → use-create-flow-overlay-state-DyzhWvRJ.js} +6 -6
  51. package/dist/chunks/{validators-CXTneCA4.js → validators-BIM0FE31.js} +774 -895
  52. package/dist/dashboard/index.js +2 -2
  53. package/dist/dashboard-authoring/index.js +2477 -2685
  54. package/dist/data-app-sdk/index.js +30 -30
  55. package/dist/data-app-sdk-adapters/index.js +3 -3
  56. package/dist/data-app-sdk-validation/index.js +25 -25
  57. package/dist/format-utils/index.js +274 -267
  58. package/dist/index.js +59 -59
  59. package/dist/report-runtime-context/index.js +2 -2
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/dashboard/dashboard-create-dialog.d.ts +23 -0
  64. package/dist/types/components/dashboard/summary-number-formatter.d.ts +6 -0
  65. package/dist/types/components/index.d.ts +1 -2
  66. package/dist/types/components/surfboard/filter/types.d.ts +3 -1
  67. package/dist/types/index.js +50 -51
  68. package/dist/types/lib/formatters/kpi-number-formatter.d.ts +41 -0
  69. package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +59 -2
  70. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +5 -0
  71. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +45 -0
  72. package/dist/types/lib/print/print-inputs.d.ts +2 -1
  73. package/dist/types/lib/query-context/assemble-card-query.d.ts +2 -0
  74. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -0
  75. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  76. package/dist/types/lib/stores/editor-store.d.ts +9 -1
  77. package/dist/types/lib/stores/table-actions.d.ts +0 -2
  78. package/dist/types/lib/types/common-types.d.ts +6 -0
  79. package/dist/types/lib/types/explorer-types.d.ts +7 -1
  80. package/dist/types/lib/types/interaction-types.d.ts +3 -1
  81. package/dist/types/lib/types/token-types.d.ts +0 -1
  82. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +13 -1
  83. package/dist/types/shared/analytics-protocol/contracts.d.ts +9 -40
  84. package/dist/types/shared/analytics-protocol/measure-aggregation-profile.d.ts +12 -0
  85. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +12 -2
  86. package/dist/types/shared/analytics-protocol/validators.d.ts +1 -2
  87. package/dist/types/shared/assistant-protocol/context.d.ts +8 -8
  88. package/dist/types/shared/dashboard-authoring/card-formats/sql-date-pattern.d.ts +7 -1
  89. package/dist/types/shared/dashboard-authoring/card-settings/apply-card-settings.d.ts +11 -0
  90. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +76 -0
  91. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +14 -0
  92. package/dist/types/shared/dashboard-authoring/card-settings/carry-column-settings.d.ts +3 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/column-format-write.d.ts +8 -0
  94. package/dist/types/shared/dashboard-authoring/card-settings/column-names.d.ts +51 -0
  95. package/dist/types/shared/dashboard-authoring/card-settings/column-polarity-write.d.ts +5 -0
  96. package/dist/types/shared/dashboard-authoring/card-settings/column-sources.d.ts +14 -0
  97. package/dist/types/shared/dashboard-authoring/card-settings/confirm-class.d.ts +9 -0
  98. package/dist/types/shared/dashboard-authoring/card-settings/highlight-inputs.d.ts +19 -0
  99. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +17 -0
  100. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +117 -0
  101. package/dist/types/shared/dashboard-authoring/card-settings/read-card-settings.d.ts +10 -0
  102. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +14 -0
  103. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-settings.d.ts +59 -0
  104. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +51 -0
  105. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +30 -0
  106. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  107. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +32 -0
  108. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +3402 -4313
  109. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +49 -8
  110. package/dist/types/shared/dashboard-authoring/changes/field-ref.d.ts +91 -0
  111. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +7 -0
  112. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +52 -2
  113. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-create.d.ts +26 -0
  114. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +2 -1
  115. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +1 -8
  116. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +20 -20
  117. package/dist/types/shared/dashboard-authoring/detail-date-presentation.d.ts +9 -0
  118. package/dist/types/shared/dashboard-authoring/index.d.ts +11 -6
  119. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +123 -0
  120. package/dist/types/shared/dashboard-authoring/measure-calculations/apply.d.ts +8 -0
  121. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +16 -0
  122. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +41 -0
  123. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +17 -0
  124. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +63 -0
  125. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +16 -0
  126. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +79 -0
  127. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +934 -0
  128. package/dist/types/shared/dashboard-authoring/measure-calculations/sentences.d.ts +4 -0
  129. package/dist/types/shared/dashboard-authoring/measure-calculations/set.d.ts +11 -0
  130. package/dist/types/shared/dashboard-authoring/measure-calculations/transform.d.ts +63 -0
  131. package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +60 -0
  132. package/dist/types/shared/dashboard-authoring/new-card.d.ts +12 -1
  133. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +2 -1
  134. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +46 -0
  135. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +73 -3
  136. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +21 -3
  137. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +55 -0
  139. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +18 -0
  140. package/dist/types/shared/dashboard-viewer/bookmark-impact.d.ts +33 -0
  141. package/dist/types/shared/format-utils/document-print.d.ts +82 -0
  142. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +8 -1
  143. package/dist/types/shared/format-utils/index.d.ts +1 -0
  144. package/dist/types/shared/format-utils/raw-temporal.d.ts +18 -7
  145. package/dist/types/shared/temporal/index.d.ts +1 -0
  146. package/dist/types/shared/temporal/raw-temporal-equality.d.ts +19 -0
  147. package/dist/types/shared/temporal/raw-temporal-value.d.ts +29 -0
  148. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +6 -0
  149. package/package.json +2 -2
  150. package/dist/chunks/bookmark-state-BFY9oNmr.js +0 -111
  151. package/dist/chunks/custom-visual-inputs-Dz-enUNR.js +0 -292
  152. package/dist/chunks/dashboard-controls-Bi7fyG-4.js +0 -2339
  153. package/dist/chunks/document-dashboard-inputs-CkWfDB8c.js +0 -3010
  154. package/dist/chunks/filter-reach-copy-BF4w4kI2.js +0 -3738
  155. package/dist/chunks/global-date-filter-utils-D8365uPH.js +0 -12889
  156. package/dist/chunks/pivot-result-contract-expectations-Bl5suy4-.js +0 -1832
  157. package/dist/chunks/raw-temporal-presentation-BHm7s-hz.js +0 -540
  158. package/dist/chunks/resolve-dashboard-input-context-CAMiWvyR.js +0 -5280
  159. package/dist/chunks/table-settings-Imz0FgWi.js +0 -637
  160. package/dist/chunks/temporal-input-presentation-uvNK_tM0.js +0 -3228
  161. package/dist/types/components/dashboard/ai-dashboard-create-dialog.d.ts +0 -38
  162. package/dist/types/components/dashboard/dashboard-create-template.d.ts +0 -10
  163. package/dist/types/lib/hooks/use-dashboard-authoring.d.ts +0 -49
  164. package/dist/types/shared/dashboard-authoring/artifact-compiler.d.ts +0 -6
  165. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -106
  166. package/dist/types/shared/dashboard-authoring/protocol-adapter.d.ts +0 -7
  167. package/dist/types/shared/dashboard-authoring/source-matching.d.ts +0 -34
  168. package/dist/types/shared/dashboard-authoring/validators.d.ts +0 -2
@@ -1,540 +0,0 @@
1
- import { r as R, n as S, a as k } from "./global-date-filter-utils-D8365uPH.js";
2
- import "./analytics-base-schemas-CHLxsPfX.js";
3
- import { r as E } from "./pivot-result-identity-vS9TSh4f.js";
4
- import "./validators-CXTneCA4.js";
5
- import "./matrix-operation-contract-WPv4R-H_.js";
6
- import { v as x } from "./zoned-wall-clock-B1n_WjW3.js";
7
- import "zod";
8
- import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as O } from "../value-format-preferences/index.js";
9
- import { f as P, M as q, p as h, r as b, c as z, R as L, s as $, v as N } from "./temporal-input-presentation-uvNK_tM0.js";
10
- const j = "SEMAPHOR_CALCULATED_FIELD";
11
- function F(e, a, t) {
12
- if (t && (a === "groupby" || a === "pivotby"))
13
- return t;
14
- if (a === "metric" && e.name === "*" && !e.expression)
15
- return e.alias || "count";
16
- if (e.alias) return e.alias;
17
- const n = e.entityName && e.entityName !== j ? e.entityName : void 0;
18
- if (e.role === "metric") {
19
- let o = e.aggregate || "metric";
20
- if (e.expression) {
21
- const r = e.expression.match(
22
- /^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
23
- );
24
- o = r ? r[1].toLowerCase() : "expr";
25
- } else
26
- o = o.toLowerCase();
27
- return n && n !== e.name ? `${n}_${e.name}_${o}` : `${e.name}_${o}`;
28
- }
29
- return n && n !== e.name ? `${n}_${e.name}` : e.name;
30
- }
31
- function se(e) {
32
- return F(e, "detail");
33
- }
34
- function B(e) {
35
- const a = e.label;
36
- return a && e.labelCount === 1 && (a === e.rawKey || !e.rawKeys.has(a)) ? a : e.rawKey;
37
- }
38
- function ie(e) {
39
- const a = [
40
- ...(e.groupByColumns ?? []).map((r) => ({ field: r, role: "groupby" })),
41
- ...(e.metricColumns ?? []).map((r) => ({ field: r, role: "metric" })),
42
- ...(e.pivotByColumns ?? []).map((r) => ({ field: r, role: "pivotby" })),
43
- ...(e.detailColumns ?? []).map((r) => ({ field: r, role: "detail" }))
44
- ], t = new Map(a.map(({ field: r, role: i }) => [r, F(r, i)])), n = new Set(t.values()), o = /* @__PURE__ */ new Map();
45
- for (const { field: r } of a)
46
- r.label && o.set(r.label, (o.get(r.label) ?? 0) + 1);
47
- return new Map(
48
- a.map(({ field: r }) => [
49
- r,
50
- B({
51
- label: r.label,
52
- labelCount: r.label ? o.get(r.label) ?? 0 : 0,
53
- rawKey: t.get(r),
54
- rawKeys: n
55
- })
56
- ])
57
- );
58
- }
59
- class l extends Error {
60
- constructor(a, t, n) {
61
- super(`${a}: ${t}`), this.code = a, this.context = n, Object.setPrototypeOf(this, l.prototype), this.name = "RawTemporalPresentationBoundaryError";
62
- }
63
- }
64
- function I() {
65
- return { type: "raw_temporal", presentation: { mode: "auto" } };
66
- }
67
- function U(e) {
68
- if (e.locale || e.relative || e.timezone && e.timezone !== "auto" || e.sourceTimezone && e.sourceTimezone !== "auto" || e.prefix || e.suffix)
69
- throw new l(
70
- "invalid_raw_temporal_format",
71
- "Activated raw temporal presentation contains unsupported locale, relative-time, timezone, prefix, or suffix settings."
72
- );
73
- }
74
- function V(e) {
75
- const a = e.format;
76
- if ((a == null ? void 0 : a.type) === "date") {
77
- U(a);
78
- const t = $(a);
79
- if (t.mode !== "auto") return { type: "raw_temporal", presentation: t };
80
- }
81
- if (a)
82
- throw new l(
83
- "invalid_raw_temporal_format",
84
- `Raw temporal detail field "${e.id}" has an incompatible authored format.`,
85
- { fieldId: e.id }
86
- );
87
- return I();
88
- }
89
- function D(e) {
90
- var i;
91
- if (e != null && e.useRelativeTime) return;
92
- if (!e) return I();
93
- if (e.useCustomFormat && !((i = e.customFormat) != null && i.trim()))
94
- throw new l(
95
- "invalid_raw_temporal_format",
96
- "Declared SQL temporal presentation selects a custom pattern but has no customFormat.",
97
- { reason: "missing_declared_sql_custom_date_format" }
98
- );
99
- const a = e.useCustomFormat && e.customFormat ? e.customFormat : e.format, t = e.timezone, n = e.sourceTimezone, o = t && t !== "auto" ? { timezone: t } : void 0, r = {
100
- sourceTimezone: n && n !== "auto" ? n : "UTC"
101
- };
102
- return !a && e.preset ? {
103
- type: "raw_temporal",
104
- ...o,
105
- ...r,
106
- presentation: { mode: "preset", preset: e.preset }
107
- } : a ? {
108
- type: "raw_temporal",
109
- ...o,
110
- ...r,
111
- presentation: {
112
- mode: "pattern",
113
- dialect: e.useCustomFormat ? "date_fns" : e.dialect ?? "date_fns",
114
- pattern: a
115
- }
116
- } : {
117
- type: "raw_temporal",
118
- ...o,
119
- ...r,
120
- presentation: { mode: "auto" }
121
- };
122
- }
123
- function ce(e) {
124
- return e === "instant" ? "yyyy-MM-dd'T'HH:mm:ssXXX" : e === "wall_datetime" ? "yyyy-MM-dd'T'HH:mm:ss" : "yyyy-MM-dd";
125
- }
126
- function me(e) {
127
- N({
128
- dialect: "date_fns",
129
- pattern: e.pattern,
130
- valueKind: e.valueKind
131
- });
132
- }
133
- function Q(e) {
134
- const a = D(e.settings);
135
- if (!a)
136
- throw new l(
137
- "invalid_raw_temporal_format",
138
- "Relative-time SQL presentation does not have an absolute date preview."
139
- );
140
- const t = e.valueKind ?? (a.presentation.mode === "pattern" ? "instant" : "date"), n = {
141
- kind: "raw_temporal",
142
- valueKind: t
143
- }, o = e.value ?? (t === "date" ? "2023-05-15" : t === "wall_datetime" ? "2023-05-15T14:30:45" : "2023-05-15T14:30:45Z"), r = h({
144
- metadata: n,
145
- format: b({
146
- format: a,
147
- preferences: e.preferences,
148
- calendar: { tz: e.calendarTimezone }
149
- })
150
- })(o);
151
- if (!r.ok)
152
- throw new l(
153
- "invalid_raw_temporal_format",
154
- r.diagnostic.message
155
- );
156
- return r.text;
157
- }
158
- function de(e) {
159
- try {
160
- return { ok: !0, text: Q(e) };
161
- } catch (a) {
162
- return {
163
- ok: !1,
164
- message: a instanceof Error ? a.message : "Invalid SQL temporal presentation."
165
- };
166
- }
167
- }
168
- function H(e) {
169
- var t;
170
- const a = e.effectiveCardConfig ?? e.card.config;
171
- return R(e.card, a) === "freeform" && !!((t = e.card.sql) != null && t.trim()) && !S(e.card.python || "").trim();
172
- }
173
- function X() {
174
- return {
175
- activatedColumnKeys: /* @__PURE__ */ new Set(),
176
- byColumnKey: /* @__PURE__ */ new Map(),
177
- byFieldId: /* @__PURE__ */ new Map()
178
- };
179
- }
180
- function T(e, a) {
181
- return e === void 0 ? { kind: "invalid", error: a } : {
182
- kind: "invalid",
183
- error: e instanceof l ? e : e instanceof L ? new l(
184
- e.code,
185
- e.message,
186
- a.context
187
- ) : new l(
188
- a.code,
189
- e instanceof Error ? e.message : a.message,
190
- a.context
191
- )
192
- };
193
- }
194
- function G(e) {
195
- var o;
196
- if (e.cardType !== "detailTable" || e.resultOwner !== "config")
197
- return { kind: "inactive" };
198
- if (!e.result) return { kind: "loading" };
199
- const { records: a, columns: t, columnKeyMap: n } = e.result;
200
- if (!Array.isArray(a) || !Array.isArray(t) || !n)
201
- return T(
202
- void 0,
203
- new l(
204
- "missing_raw_temporal_result_contract",
205
- "Activated raw temporal detail results require records, columns, and columnKeyMap atomically."
206
- )
207
- );
208
- try {
209
- const r = t.filter((d) => d.rawTemporal);
210
- if (r.length === 0) return { kind: "inactive" };
211
- const i = new Map(
212
- (((o = e.effectiveCardConfig) == null ? void 0 : o.detailColumns) || []).map((d) => [
213
- d.id,
214
- d
215
- ])
216
- ), c = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
217
- for (const d of r) {
218
- const _ = Array.from(i).flatMap(
219
- ([y, A]) => {
220
- const g = E(
221
- n,
222
- y,
223
- "detail"
224
- );
225
- return g && g.role === "detail" && (g.outputKey ?? g.rawKey) === d.key ? [{ field: A, binding: g }] : [];
226
- }
227
- ), m = _.length === 1 ? _[0] : null;
228
- if (!m || typeof m.binding.rawKey != "string" || m.binding.rawKey.trim().length === 0 || m.binding.outputKey !== void 0 && (typeof m.binding.outputKey != "string" || m.binding.outputKey.trim().length === 0))
229
- throw new l(
230
- "missing_raw_temporal_column_binding",
231
- `Raw temporal result column "${d.key}" does not have one valid exact detail result binding.`,
232
- { columnKey: d.key }
233
- );
234
- const { field: u, binding: C } = m, f = C.outputKey ?? C.rawKey, p = x(d, {
235
- metadataRequired: !0
236
- });
237
- if (!p)
238
- throw new l(
239
- "invalid_raw_temporal_metadata",
240
- `Raw temporal result column "${f}" has no metadata.`,
241
- { fieldId: u.id, columnKey: f }
242
- );
243
- const w = b({
244
- format: V(u),
245
- preferences: e.preferences,
246
- calendar: e.calendar
247
- }), K = {
248
- fieldId: u.id,
249
- columnKey: f,
250
- metadata: p,
251
- format: w,
252
- formatValue: h({ metadata: p, format: w })
253
- };
254
- for (let y = 0; y < a.length; y += 1)
255
- if (!Object.prototype.hasOwnProperty.call(a[y], f) || a[y][f] === void 0)
256
- throw new l(
257
- "missing_raw_temporal_result_contract",
258
- `Raw temporal result row ${y} is missing column "${f}".`,
259
- { fieldId: u.id, columnKey: f }
260
- );
261
- c.set(f, K), v.set(u.id, K);
262
- }
263
- const s = {
264
- activatedColumnKeys: new Set(c.keys()),
265
- byColumnKey: c,
266
- byFieldId: v
267
- };
268
- return a.length === 0 ? { kind: "loaded_empty", presentation: s } : { kind: "loaded_valid", presentation: s };
269
- } catch (r) {
270
- return T(
271
- r,
272
- new l(
273
- "invalid_raw_temporal_metadata",
274
- "Activated raw temporal result metadata is invalid."
275
- )
276
- );
277
- }
278
- }
279
- function Y(e) {
280
- var n;
281
- const a = e.effectiveCardConfig ?? e.card.config, t = R(
282
- e.card,
283
- a
284
- );
285
- if (e.card.type === "detailTable" && t === "config") {
286
- const o = !!((n = e.columns) != null && n.some((r) => r.rawTemporal));
287
- return o && e.records !== void 0 && !e.columnKeyMap ? {
288
- kind: "invalid",
289
- error: new l(
290
- "missing_raw_temporal_result_contract",
291
- "Activated raw temporal detail results require records, columns, and columnKeyMap atomically."
292
- )
293
- } : e.records !== void 0 && !o ? { kind: "inactive" } : M(
294
- G({
295
- cardType: e.card.type,
296
- resultOwner: t,
297
- effectiveCardConfig: a,
298
- result: e.records === void 0 || !e.columns || !e.columnKeyMap ? void 0 : {
299
- records: e.records,
300
- columns: e.columns,
301
- columnKeyMap: e.columnKeyMap
302
- },
303
- preferences: e.preferences,
304
- calendar: e.calendar
305
- }),
306
- e
307
- );
308
- }
309
- return M(
310
- Z({
311
- resultOwner: t,
312
- sql: e.card.sql,
313
- normalizedPython: S(
314
- e.card.python || ""
315
- ),
316
- records: e.records,
317
- columns: e.columns,
318
- columnSettings: k(e.card),
319
- preferences: e.preferences,
320
- calendar: e.calendar
321
- }),
322
- e
323
- );
324
- }
325
- function ue(e) {
326
- var n;
327
- const a = e.effectiveCardConfig ?? e.card.config, t = R(
328
- e.card,
329
- a
330
- );
331
- return e.card.type === "detailTable" && t === "config" ? !!((n = e.columns) != null && n.some((o) => o.rawTemporal)) : H(e) ? Object.values(
332
- k(e.card)
333
- ).some(
334
- (o) => {
335
- var r;
336
- return o.type === "date" && !((r = o.dateFormat) != null && r.useRelativeTime);
337
- }
338
- ) : !1;
339
- }
340
- function M(e, a) {
341
- if (!a.executionSnapshot || e.kind === "inactive" || e.kind === "loading" || e.kind === "invalid")
342
- return e;
343
- if (!a.dashboardId)
344
- return {
345
- kind: "invalid",
346
- error: new l(
347
- "missing_raw_temporal_result_contract",
348
- "A dashboard ID is required to resolve the captured raw temporal presentation."
349
- )
350
- };
351
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
352
- for (const o of e.presentation.activatedColumnKeys) {
353
- const r = P({
354
- snapshot: a.executionSnapshot,
355
- scope: {
356
- dashboardId: a.dashboardId,
357
- cardId: a.card.id,
358
- ...a.attachmentIndex !== void 0 ? { attachmentIndex: a.attachmentIndex } : {}
359
- },
360
- target: { kind: "column", columnKey: o }
361
- });
362
- if (!r)
363
- return {
364
- kind: "invalid",
365
- error: new q(o)
366
- };
367
- const i = e.presentation.byColumnKey.get(o);
368
- if (!i) continue;
369
- const c = {
370
- ...i,
371
- format: r,
372
- formatValue: h({
373
- metadata: i.metadata,
374
- format: r
375
- })
376
- };
377
- t.set(i.columnKey, c), i.fieldId && n.set(i.fieldId, c);
378
- }
379
- return {
380
- ...e,
381
- presentation: {
382
- activatedColumnKeys: e.presentation.activatedColumnKeys,
383
- byColumnKey: t,
384
- byFieldId: n
385
- }
386
- };
387
- }
388
- function Z(e) {
389
- var t, n;
390
- if (e.resultOwner !== "freeform" || !((t = e.sql) != null && t.trim()) || (n = e.normalizedPython) != null && n.trim())
391
- return { kind: "inactive" };
392
- const a = Object.entries(
393
- e.columnSettings || {}
394
- ).filter(
395
- ([, o]) => {
396
- var r;
397
- return o.type === "date" && !((r = o.dateFormat) != null && r.useRelativeTime);
398
- }
399
- );
400
- if (a.length === 0) return { kind: "inactive" };
401
- if (!e.records) return { kind: "loading" };
402
- try {
403
- const o = /* @__PURE__ */ new Map(), r = new Set(
404
- a.map(([s]) => s)
405
- ), i = /* @__PURE__ */ new Map(), c = [...e.columns || []];
406
- for (const [s, d] of a) {
407
- const _ = D(
408
- d.dateFormat
409
- );
410
- if (!_) continue;
411
- const m = z({
412
- columnKey: s,
413
- values: e.records.map((p) => {
414
- if (!Object.prototype.hasOwnProperty.call(p, s))
415
- throw new l(
416
- "missing_raw_temporal_result_contract",
417
- `Declared SQL temporal column "${s}" is absent from a physical result row.`,
418
- { columnKey: s }
419
- );
420
- const w = p[s];
421
- return w === null || typeof w == "string" ? w : String(w);
422
- })
423
- });
424
- if (i.set(s, m), m.status !== "classified") continue;
425
- let u = c.findIndex(
426
- (p) => p.key === s
427
- );
428
- if (e.columns && u < 0)
429
- throw new l(
430
- "missing_raw_temporal_result_contract",
431
- `Classified SQL temporal column "${s}" is absent from result columns.`,
432
- { columnKey: s }
433
- );
434
- u < 0 && (u = c.length, c.push({
435
- key: s,
436
- name: s,
437
- label: s,
438
- role: "dimension",
439
- dataType: "string"
440
- }));
441
- const C = {
442
- ...c[u],
443
- role: "date",
444
- dataType: m.metadata.valueKind === "date" ? "date" : "datetime",
445
- rawTemporal: m.metadata
446
- };
447
- x(C, {
448
- metadataRequired: !0
449
- }), c[u] = C;
450
- const f = b({
451
- format: _,
452
- preferences: e.preferences,
453
- calendar: e.calendar
454
- });
455
- o.set(s, {
456
- columnKey: s,
457
- metadata: m.metadata,
458
- format: f,
459
- formatValue: h({
460
- metadata: m.metadata,
461
- format: f
462
- })
463
- });
464
- }
465
- const v = {
466
- ...X(),
467
- activatedColumnKeys: r,
468
- byColumnKey: o
469
- };
470
- return e.records.length === 0 ? {
471
- kind: "loaded_empty",
472
- presentation: v,
473
- adaptedColumns: c,
474
- sqlClassifications: i
475
- } : {
476
- kind: "loaded_valid",
477
- presentation: v,
478
- adaptedColumns: c,
479
- sqlClassifications: i
480
- };
481
- } catch (o) {
482
- return T(
483
- o,
484
- new l(
485
- "invalid_raw_temporal_format",
486
- "Declared SQL raw temporal presentation is invalid."
487
- )
488
- );
489
- }
490
- }
491
- function fe(e) {
492
- if (e.value !== null && typeof e.value != "string")
493
- return {
494
- value: e.value,
495
- label: String(e.value),
496
- result: {
497
- ok: !1,
498
- text: String(e.value),
499
- diagnostic: {
500
- code: "invalid_raw_temporal_value",
501
- message: `Raw temporal column "${e.presentation.columnKey}" must contain a string or null.`
502
- }
503
- }
504
- };
505
- const a = e.presentation.formatValue(e.value);
506
- return { value: e.value, label: a.text, result: a };
507
- }
508
- function pe(e) {
509
- if (!e.result || typeof e.result != "object") return !1;
510
- const a = e.result;
511
- if (e.expectedResultOwner !== void 0 && a.resultOwner !== e.expectedResultOwner || !Array.isArray(a.records)) return !1;
512
- const t = Y({
513
- card: e.card,
514
- effectiveCardConfig: e.effectiveCardConfig,
515
- records: a.records,
516
- columns: a.columns,
517
- columnKeyMap: a.columnKeyMap,
518
- preferences: O,
519
- calendar: { tz: "UTC" }
520
- });
521
- return t.kind === "inactive" || t.kind === "loaded_empty" || t.kind === "loaded_valid";
522
- }
523
- export {
524
- l as R,
525
- V as a,
526
- D as b,
527
- F as c,
528
- se as d,
529
- B as e,
530
- G as f,
531
- Y as g,
532
- ue as h,
533
- pe as i,
534
- ce as j,
535
- de as k,
536
- H as l,
537
- fe as p,
538
- ie as r,
539
- me as v
540
- };