react-semaphor 0.1.568 → 0.1.570

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 (191) hide show
  1. package/README.md +0 -7
  2. package/dist/analytics-protocol/index.js +434 -454
  3. package/dist/appearance/index.js +6 -3
  4. package/dist/appearance-runtime/index.js +1 -1
  5. package/dist/assistant-context/index.js +1 -1
  6. package/dist/brand-studio/index.js +572 -436
  7. package/dist/briefings/index.js +4 -4
  8. package/dist/chunks/appearance-context-BwBp25ZG.js +162 -0
  9. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +80 -0
  10. package/dist/chunks/assistant-chat-B-Ddyy8b.js +5940 -0
  11. package/dist/chunks/{bookmark-impact-CJ-65omV.js → bookmark-impact-DCYD-6Fr.js} +2 -2
  12. package/dist/chunks/{bookmark-state-Du3s13_V.js → bookmark-state-CflS88gq.js} +251 -250
  13. package/dist/chunks/brand-B4BdpAB_.js +54 -0
  14. package/dist/chunks/{card-filter-builder-BBuB99GZ.js → card-filter-builder-0VvKmRst.js} +992 -991
  15. package/dist/chunks/{comparison-window-caption-CMLb3mut.js → comparison-window-caption-PtcDWvkN.js} +252 -253
  16. package/dist/chunks/{dashboard-YnWZC4dK.js → dashboard-DxGIr1vZ.js} +1 -1
  17. package/dist/chunks/{dashboard-briefing-launcher-BF89TU2h.js → dashboard-briefing-launcher-B-quOOOQ.js} +253 -253
  18. package/dist/chunks/{dashboard-controls-atHc1EjP.js → dashboard-controls-Caodx80b.js} +288 -285
  19. package/dist/chunks/dashboard-json-Ct-AGDHF.js +66 -0
  20. package/dist/chunks/{dates-CKO05ino.js → dates-B9mL8BHE.js} +16 -15
  21. package/dist/chunks/edit-Bpdh_P_a.js +226 -0
  22. package/dist/chunks/{edit-dashboard-visual-DdmTfn-J.js → edit-dashboard-visual-DeDTuYB5.js} +2257 -2270
  23. package/dist/chunks/{filter-reach-copy-jZGzK_IH.js → filter-reach-copy-BSY33ro5.js} +1440 -1301
  24. package/dist/chunks/filter-value-text-DvvSNlho.js +146 -0
  25. package/dist/chunks/index-BVKzKl5d.js +90 -0
  26. package/dist/chunks/{index-RNaTnE3m.js → index-CV_Kzou0.js} +233 -223
  27. package/dist/chunks/{index-CPNZW0mu.js → index-y3HUzRNk.js} +76 -77
  28. package/dist/chunks/{layout-grid-0hIlqEtk.js → layout-grid-8rR-LPTk.js} +1 -1
  29. package/dist/chunks/{list-filter-DkgoCeBm.js → list-filter-C1-uTgjR.js} +1 -1
  30. package/dist/chunks/matrix-analytical-definition-dkS8szLM.js +1253 -0
  31. package/dist/chunks/matrix-member-presentation-DRa-9e6Q.js +169 -0
  32. package/dist/chunks/{matrix-operation-contract-Eb6elidS.js → matrix-operation-contract-DCVinw1o.js} +122 -122
  33. package/dist/chunks/{metric-comparison-ChXUFaZu.js → metric-comparison-n9NsIa-2.js} +175 -128
  34. package/dist/chunks/paintbrush-aR17Z3C9.js +27 -0
  35. package/dist/chunks/{palette-4vf2BEEg.js → palette-a5FCZKFI.js} +1 -1
  36. package/dist/chunks/{_commonjsHelpers-DimLPMtv.js → pickers-DkqmtnTL.js} +352 -290
  37. package/dist/chunks/pivot-result-contract-expectations-C-HnUKYe.js +55 -0
  38. package/dist/chunks/{pivot-result-identity-BlbLrqaC.js → pivot-result-identity-B89X5xjb.js} +1 -1
  39. package/dist/chunks/raw-temporal-value-DdT0s47W.js +159 -0
  40. package/dist/chunks/{report-preferences-dialog-Mbd-I0wV.js → report-preferences-dialog-Yvhv3WX2.js} +95 -97
  41. package/dist/chunks/{report-runtime-context-DnA_PiKo.js → report-runtime-context-BhPzLTbS.js} +1 -1
  42. package/dist/chunks/{resolve-dashboard-input-context-Du0fjN3h.js → resolve-dashboard-input-context-Lkbwycwe.js} +5491 -5683
  43. package/dist/chunks/resolver-DG_tfEpt.js +156 -0
  44. package/dist/chunks/{save-D6pHmSSP.js → save-D985VvYp.js} +1 -1
  45. package/dist/chunks/{saved-dashboard-context-y8N6RvjS.js → saved-dashboard-context-DC_TEd6y.js} +6 -6
  46. package/dist/chunks/schema-C9NPiIru.js +2568 -0
  47. package/dist/chunks/{semaphor-ready-indicator-BSEdUq40.js → semaphor-ready-indicator-ByFvqHEO.js} +35916 -36001
  48. package/dist/chunks/{shelf-drop-preview-context-D7QqPl36.js → shelf-drop-preview-context-CjoVaK6J.js} +64 -66
  49. package/dist/chunks/{stored-dashboard-d3xQYxBD.js → stored-dashboard-C0hekXiI.js} +332 -333
  50. package/dist/chunks/{code-editor-DJNOsgJH.js → style-sheet-parts-C7qGZuH1.js} +2402 -2040
  51. package/dist/chunks/{table-export-sheet--DUKWk6o.js → table-export-sheet-CP8zSOhj.js} +1 -1
  52. package/dist/chunks/{temporal-input-presentation--2r9BLr0.js → temporal-input-presentation-CqbJjIuu.js} +18 -18
  53. package/dist/chunks/{token-types-C8JymO8s.js → token-types-iKMplaBL.js} +1 -1
  54. package/dist/chunks/{upload-Cf3wXZT8.js → upload-CiGNKJ_0.js} +1 -1
  55. package/dist/chunks/validators-B8fpdinG.js +3651 -0
  56. package/dist/chunks/{variable-draft-DOX03R4A.js → variable-draft-9-huI1h4.js} +4 -4
  57. package/dist/dashboard/index.js +2 -2
  58. package/dist/dashboard-authoring/index.js +1888 -1826
  59. package/dist/format-utils/index.js +230 -231
  60. package/dist/index.js +349 -353
  61. package/dist/layouts/index.js +1 -1
  62. package/dist/report-runtime-context/index.js +1 -1
  63. package/dist/style.css +1 -1
  64. package/dist/surfboard/index.js +2 -2
  65. package/dist/types/appearance/index.d.ts +1 -0
  66. package/dist/types/brand-studio/brand-studio-draft.d.ts +7 -0
  67. package/dist/types/brand-studio/index.d.ts +1 -1
  68. package/dist/types/components/briefings/briefing-author/run-model.d.ts +1 -2
  69. package/dist/types/components/providers/appearance-runtime-provider.d.ts +4 -1
  70. package/dist/types/components/sharing-and-management/hooks/use-resource-management.d.ts +0 -2
  71. package/dist/types/components/sharing-and-management/utils/types.d.ts +0 -72
  72. package/dist/types/components/surfboard/filter/types.d.ts +5 -4
  73. package/dist/types/components/ui-custom/date-range-presets.d.ts +1 -17
  74. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +0 -1
  75. package/dist/types/components/visual/data-table/types/data-table.d.ts +0 -9
  76. package/dist/types/components/visual/data-table/utils/pagination-utils.d.ts +0 -19
  77. package/dist/types/components/visual/shared/utils/table-column-order.d.ts +0 -1
  78. package/dist/types/index.js +9 -9
  79. package/dist/types/lib/appearance/aliases.d.ts +42 -0
  80. package/dist/types/lib/appearance/compiler.d.ts +6 -0
  81. package/dist/types/lib/appearance/defaults.d.ts +6 -0
  82. package/dist/types/lib/appearance/index.d.ts +2 -0
  83. package/dist/types/lib/appearance/normalize-organization.d.ts +17 -0
  84. package/dist/types/lib/appearance/resolver.d.ts +2 -2
  85. package/dist/types/lib/appearance/types.d.ts +38 -1
  86. package/dist/types/lib/charts/types.d.ts +6 -2
  87. package/dist/types/lib/dashboard/semantic-dataset-references.d.ts +0 -1
  88. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +0 -2
  89. package/dist/types/lib/dashboard-variables/types.d.ts +1 -6
  90. package/dist/types/lib/download-pdf.d.ts +0 -1
  91. package/dist/types/lib/hooks/use-dashboard.d.ts +3 -4
  92. package/dist/types/lib/hooks/use-date-filter.d.ts +3 -3
  93. package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +1 -1
  94. package/dist/types/lib/stores/dashboard-store.d.ts +15 -6
  95. package/dist/types/lib/stores/editor-store.d.ts +0 -1
  96. package/dist/types/lib/stores/table-actions.d.ts +0 -1
  97. package/dist/types/lib/table-formatting/table-formatting-css.d.ts +0 -5
  98. package/dist/types/lib/types/common-types.d.ts +3 -2
  99. package/dist/types/lib/types/explorer-types.d.ts +2 -2
  100. package/dist/types/lib/types/index.d.ts +1 -1
  101. package/dist/types/lib/types/summary-types.d.ts +0 -5
  102. package/dist/types/lib/utils/card-definition.d.ts +7 -7
  103. package/dist/types/shared/analytics-protocol/agent-time-window.d.ts +84 -0
  104. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +4 -4
  105. package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +2 -2
  106. package/dist/types/shared/analytics-protocol/contracts.d.ts +8 -17
  107. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +10 -10
  108. package/dist/types/shared/analytics-protocol/fixtures.d.ts +3 -2
  109. package/dist/types/shared/analytics-protocol/index.d.ts +2 -4
  110. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +72 -72
  111. package/dist/types/shared/analytics-protocol/relative-date/describe.d.ts +18 -0
  112. package/dist/types/shared/analytics-protocol/relative-date/index.d.ts +7 -0
  113. package/dist/types/shared/analytics-protocol/relative-date/limits.d.ts +3 -0
  114. package/dist/types/shared/analytics-protocol/relative-date/presets.d.ts +11 -0
  115. package/dist/types/shared/analytics-protocol/relative-date/resolve.d.ts +49 -0
  116. package/dist/types/shared/analytics-protocol/relative-date/schemas.d.ts +76 -0
  117. package/dist/types/shared/analytics-protocol/relative-date/traits.d.ts +51 -0
  118. package/dist/types/shared/analytics-protocol/relative-date/window.d.ts +111 -0
  119. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +1 -1
  120. package/dist/types/shared/assistant-protocol/context.d.ts +30 -30
  121. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +0 -2
  122. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +344 -1772
  123. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +4 -1
  124. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -4
  125. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +9 -0
  126. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +104 -104
  127. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +20 -20
  128. package/dist/types/shared/dashboard-authoring/dashboard-style/bounds.d.ts +17 -0
  129. package/dist/types/shared/dashboard-authoring/dashboard-style/brand.d.ts +20 -0
  130. package/dist/types/shared/dashboard-authoring/dashboard-style/edit-words.d.ts +7 -0
  131. package/dist/types/shared/dashboard-authoring/dashboard-style/edit.d.ts +19 -0
  132. package/dist/types/shared/dashboard-authoring/dashboard-style/index.d.ts +15 -0
  133. package/dist/types/shared/dashboard-authoring/dashboard-style/layers.d.ts +19 -0
  134. package/dist/types/shared/dashboard-authoring/dashboard-style/legacy.d.ts +21 -0
  135. package/dist/types/shared/dashboard-authoring/dashboard-style/parse.d.ts +18 -0
  136. package/dist/types/shared/dashboard-authoring/dashboard-style/pickers.d.ts +12 -0
  137. package/dist/types/shared/dashboard-authoring/dashboard-style/types.d.ts +122 -0
  138. package/dist/types/shared/dashboard-authoring/dashboard-style/view.d.ts +10 -0
  139. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  140. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +11 -0
  141. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +23 -0
  142. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +10 -2
  143. package/dist/types/shared/format-utils/filter-detail.d.ts +2 -8
  144. package/dist/types/shared/format-utils/filter-line.d.ts +2 -2
  145. package/dist/types/shared/format-utils/matrix-continuation.d.ts +10 -10
  146. package/dist/types/shared/temporal/index.d.ts +0 -2
  147. package/dist/types/shared/temporal/temporal-parity-fixtures.d.ts +2 -2
  148. package/package.json +7 -26
  149. package/DATA_APP_SDK.md +0 -339
  150. package/dist/chunks/appearance-context-DEYtWinQ.js +0 -126
  151. package/dist/chunks/appearance-runtime-provider-B-M8gwlZ.js +0 -81
  152. package/dist/chunks/assistant-chat-BN5I8KuN.js +0 -8849
  153. package/dist/chunks/color-CJvdlFM_.js +0 -2162
  154. package/dist/chunks/dashboard-json-Cxp3inxd.js +0 -68
  155. package/dist/chunks/filter-value-text-7zhmth1S.js +0 -163
  156. package/dist/chunks/index-CLIro-EG.js +0 -425
  157. package/dist/chunks/index-CuHybtft.js +0 -51
  158. package/dist/chunks/matrix-analytical-definition-C9xB_T84.js +0 -717
  159. package/dist/chunks/matrix-card-BSUeSXpD.js +0 -42
  160. package/dist/chunks/matrix-member-presentation-DZNgQpUq.js +0 -105
  161. package/dist/chunks/operators-B3zZoskU.js +0 -66
  162. package/dist/chunks/pivot-result-contract-expectations-Ddh1rNz5.js +0 -56
  163. package/dist/chunks/raw-temporal-value-Bqz8wc7L.js +0 -242
  164. package/dist/chunks/selection-reducer-OaJ-N5uN.js +0 -46
  165. package/dist/chunks/source-entity-resolution-DF6GulDn.js +0 -607
  166. package/dist/chunks/validators-wtjw0aw6.js +0 -3332
  167. package/dist/data-app-sdk/index.js +0 -1412
  168. package/dist/data-app-sdk-adapters/index.js +0 -361
  169. package/dist/data-app-sdk-validation/index.js +0 -1031
  170. package/dist/types/components/sharing-and-management/utils/group-types.d.ts +0 -105
  171. package/dist/types/data-app-sdk/adapters.d.ts +0 -35
  172. package/dist/types/data-app-sdk/builders.d.ts +0 -62
  173. package/dist/types/data-app-sdk/contracts.d.ts +0 -419
  174. package/dist/types/data-app-sdk/executor.d.ts +0 -5
  175. package/dist/types/data-app-sdk/field-catalog-validation.d.ts +0 -29
  176. package/dist/types/data-app-sdk/hooks.d.ts +0 -11
  177. package/dist/types/data-app-sdk/index.d.ts +0 -9
  178. package/dist/types/data-app-sdk/provider.d.ts +0 -8
  179. package/dist/types/data-app-sdk/relationship-aware-field-policy.d.ts +0 -21
  180. package/dist/types/data-app-sdk/selection.d.ts +0 -2
  181. package/dist/types/data-app-sdk/validation.d.ts +0 -58
  182. package/dist/types/data-app-sdk-adapters.d.ts +0 -2
  183. package/dist/types/data-app-sdk-validation.d.ts +0 -2
  184. package/dist/types/data-app-sdk.d.ts +0 -2
  185. package/dist/types/shared/analytics-protocol/relative-date-filter.d.ts +0 -68
  186. package/dist/types/shared/analytics-protocol/relative-date-label.d.ts +0 -20
  187. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +0 -314
  188. package/dist/types/shared/analytics-protocol/time-window.d.ts +0 -52
  189. package/dist/types/shared/temporal/relative-date.d.ts +0 -21
  190. package/dist/types/shared/temporal/time-window-periods.d.ts +0 -21
  191. package/src/data-app-sdk/README.md +0 -402
@@ -0,0 +1,3651 @@
1
+ import { M as Oe, y as K, x as qt, C as Bt, D as Wt, F as Ut, H as Vt, w as Ht, h as tt, j as pe, k as zt, m as Gt, b as Qt, d as Xt } from "./analytics-base-schemas-BaIQrEzX.js";
2
+ import { z as a } from "zod";
3
+ function Kt(e) {
4
+ return typeof e == "string" || typeof e == "number" && Number.isFinite(e) || typeof e == "boolean";
5
+ }
6
+ function Zt(e) {
7
+ return !Array.isArray(e) || e.length === 0 || e.length > Oe || !e.every(Kt) ? {
8
+ ok: !1,
9
+ error: `matchValues must be 1 to ${Oe} string, number or boolean values.`
10
+ } : { ok: !0, values: e };
11
+ }
12
+ function Jt(e, t) {
13
+ const i = e.map((n, o) => `${t[o]} ${ti(n)}`);
14
+ return a.union(e, {
15
+ errorMap: (n, o) => {
16
+ if (n.code !== a.ZodIssueCode.invalid_union) return { message: o.defaultError };
17
+ const s = n.path.length, r = o.data && typeof o.data == "object" && !Array.isArray(o.data) ? Object.keys(o.data) : [], l = n.unionErrors.map((p, f) => {
18
+ const b = ei(e[f]);
19
+ return { index: f, issues: p.issues, overlap: b ? r.filter((A) => b.includes(A)).length : 0 };
20
+ }).filter(({ issues: p }) => !p.every((f) => f.code === a.ZodIssueCode.invalid_type && f.path.length === s)).filter(({ overlap: p }) => !r.length || p > 0);
21
+ if (!l.length) {
22
+ const p = r.length ? ` Its keys (${r.join(", ")}) belong to none of them.` : "";
23
+ return { message: `Matches none of: ${i.join("; ")}.${p}` };
24
+ }
25
+ const c = l.reduce(
26
+ (p, f) => f.overlap > p.overlap || f.overlap === p.overlap && f.issues.length < p.issues.length ? f : p
27
+ ), m = c.issues.slice(0, 4).map((p) => {
28
+ const f = p.path.slice(s).join(".");
29
+ return f ? `${p.message} at ${f}` : p.message;
30
+ }), u = c.issues.length > 4 ? ` (and ${c.issues.length - 4} more)` : "";
31
+ return {
32
+ message: `Matches none of: ${i.join("; ")}. Nearest is the ${t[c.index]}: ${m.join("; ")}${u}`
33
+ };
34
+ }
35
+ });
36
+ }
37
+ function ei(e) {
38
+ let t = e;
39
+ for (; t instanceof a.ZodEffects; ) t = t._def.schema;
40
+ return t instanceof a.ZodObject ? Object.keys(t.shape) : void 0;
41
+ }
42
+ function ti(e) {
43
+ let t = e;
44
+ for (; t instanceof a.ZodEffects; ) t = t._def.schema;
45
+ return t instanceof a.ZodObject ? `{ ${Object.entries(t.shape).map(([n, o]) => o.isOptional() ? `${n}?` : n).join(", ")} }` : "";
46
+ }
47
+ const ii = {
48
+ minute: 5256e3,
49
+ hour: 87600,
50
+ day: 3650,
51
+ week: 520,
52
+ month: 120,
53
+ quarter: 40,
54
+ year: 10
55
+ }, E = a.enum(["day", "week", "month", "quarter", "year"]), ni = a.enum(["minute", "hour"]), ai = a.enum(["minute", "hour", "day", "week", "month", "quarter", "year"]), fe = a.number().int().positive(), Z = a.number().int(), $ = {
56
+ lastSubDay: a.object({
57
+ mode: a.literal("last"),
58
+ n: fe,
59
+ unit: ni,
60
+ complete: a.literal(!1).optional(),
61
+ relativeTo: a.literal("latest_data").optional()
62
+ }),
63
+ last: a.object({
64
+ mode: a.literal("last"),
65
+ n: fe,
66
+ unit: E,
67
+ complete: a.boolean().optional(),
68
+ relativeTo: a.literal("latest_data").optional()
69
+ }),
70
+ this: a.object({
71
+ mode: a.literal("this"),
72
+ unit: E,
73
+ toDate: a.boolean().optional(),
74
+ boundary: a.enum(["first_day", "last_day"]).optional()
75
+ }),
76
+ previous: a.object({ mode: a.literal("previous"), unit: E }),
77
+ between: a.object({ mode: a.literal("between"), unit: E, from: Z, to: Z })
78
+ }, he = {
79
+ check: (e) => e.boundary === void 0 || e.unit === "month",
80
+ message: 'A month boundary requires unit "month".'
81
+ }, it = (e) => a.object({
82
+ kind: a.literal("periods"),
83
+ unit: E,
84
+ from: Z,
85
+ to: Z,
86
+ toDate: a.boolean().optional(),
87
+ anchor: a.union([a.enum(["now", "latest_data"]), e])
88
+ }), nt = a.object({ lastComplete: E }), at = it(nt.strict()).strict(), B = {
89
+ periods: it(nt),
90
+ rolling: a.object({
91
+ kind: a.literal("rolling"),
92
+ unit: ai,
93
+ n: fe,
94
+ anchor: a.enum(["now", "latest_data"])
95
+ }),
96
+ monthDay: a.object({ kind: a.literal("monthDay"), day: a.enum(["first", "last"]) })
97
+ };
98
+ function si(e) {
99
+ return e === "between" || e === "not between";
100
+ }
101
+ function F(e, t = {}) {
102
+ const i = ri(e);
103
+ if (!(!i || st(i, t)))
104
+ return oi(i);
105
+ }
106
+ function st(e, t = {}) {
107
+ if (e.kind === "periods")
108
+ return e.from > e.to ? { rule: "W1", message: `from (${e.from}) is after to (${e.to}).`, path: "from" } : e.toDate && e.to !== 0 ? { rule: "W2", message: `toDate needs to 0, not ${e.to}.`, path: "toDate" } : typeof e.anchor == "object" && e.to > 0 ? {
109
+ rule: "W3",
110
+ message: `A window ending at the last complete ${e.anchor.lastComplete} can't reach past it (to ${e.to}).`,
111
+ path: "to"
112
+ } : void 0;
113
+ if (e.kind !== "rolling") return;
114
+ if (!Number.isInteger(e.n) || e.n < 1)
115
+ return { rule: "W4", message: `n (${e.n}) must be a whole number of at least 1.`, path: "n" };
116
+ const i = ii[e.unit];
117
+ if (t.authoring && e.n > i)
118
+ return { rule: "limit", message: `At most ${i} ${e.unit}s (ten years).`, path: "n", max: i };
119
+ }
120
+ function ri(e) {
121
+ if (!e || typeof e != "object") return;
122
+ if ("kind" in e) {
123
+ for (const r of Object.values(B)) {
124
+ const l = r.safeParse(e);
125
+ if (l.success) return l.data;
126
+ }
127
+ return;
128
+ }
129
+ const t = $.lastSubDay.safeParse(e), i = t.success ? t : $.last.safeParse(e);
130
+ if (i.success) {
131
+ const { n: r, unit: l, complete: c, relativeTo: m } = i.data, u = m ?? "now";
132
+ return c ? { kind: "periods", unit: l, from: -r, to: -1, anchor: u } : { kind: "rolling", unit: l, n: r, anchor: u };
133
+ }
134
+ const n = $.this.safeParse(e);
135
+ if (n.success) {
136
+ const { unit: r, toDate: l, boundary: c } = n.data;
137
+ return he.check(n.data) ? c ? { kind: "monthDay", day: c === "first_day" ? "first" : "last" } : { kind: "periods", unit: r, from: 0, to: 0, ...l ? { toDate: !0 } : {}, anchor: "now" } : void 0;
138
+ }
139
+ const o = $.previous.safeParse(e);
140
+ if (o.success)
141
+ return { kind: "periods", unit: o.data.unit, from: -1, to: -1, anchor: "now" };
142
+ const s = $.between.safeParse(e);
143
+ if (s.success) {
144
+ const { unit: r, from: l, to: c } = s.data;
145
+ return { kind: "periods", unit: r, from: l, to: c, anchor: "now" };
146
+ }
147
+ }
148
+ function oi(e) {
149
+ switch (e.kind) {
150
+ case "periods": {
151
+ const { unit: t, anchor: i } = e;
152
+ return typeof i == "object" && i.lastComplete === t ? { kind: "periods", unit: t, from: e.from - 1, to: e.to - 1, anchor: "now" } : {
153
+ kind: "periods",
154
+ unit: t,
155
+ from: e.from,
156
+ to: e.to,
157
+ ...e.toDate ? { toDate: !0 } : {},
158
+ anchor: typeof i == "object" ? { lastComplete: i.lastComplete } : i
159
+ };
160
+ }
161
+ case "rolling":
162
+ return { kind: "rolling", unit: e.unit, n: e.n, anchor: e.anchor };
163
+ case "monthDay":
164
+ return { kind: "monthDay", day: e.day };
165
+ }
166
+ }
167
+ const y = (e, t, i, n) => {
168
+ const o = F(n);
169
+ if (!o) throw new Error(`The preset ${e} is not a relative date window.`);
170
+ return { id: e, label: t, category: i, window: o };
171
+ }, v = (e, t, i) => ({
172
+ kind: "periods",
173
+ unit: e,
174
+ from: t,
175
+ to: i,
176
+ anchor: "now"
177
+ }), j = (e, t) => ({
178
+ kind: "rolling",
179
+ unit: e,
180
+ n: t,
181
+ anchor: "now"
182
+ }), di = [
183
+ y("last_30_minutes", "Last 30 minutes", "time", j("minute", 30)),
184
+ y("last_1_hour", "Last 1 hour", "time", j("hour", 1)),
185
+ y("last_4_hours", "Last 4 hours", "time", j("hour", 4)),
186
+ y("last_12_hours", "Last 12 hours", "time", j("hour", 12)),
187
+ y("last_24_hours", "Last 24 hours", "time", j("hour", 24)),
188
+ y("today", "Today", "day", v("day", 0, 0)),
189
+ y("yesterday", "Yesterday", "day", v("day", -1, -1)),
190
+ y("first_day_of_month", "First day of the month", "day", { kind: "monthDay", day: "first" }),
191
+ y("last_day_of_month", "Last day of the month", "day", { kind: "monthDay", day: "last" }),
192
+ y("last_7_days", "Last 7 days", "day", v("day", -6, 0)),
193
+ y("last_30_days", "Last 30 days", "day", v("day", -29, 0)),
194
+ y("last_90_days", "Last 90 days", "day", v("day", -89, 0)),
195
+ y("this_week", "This week", "week", v("week", 0, 0)),
196
+ y("last_week", "Last week", "week", v("week", -1, -1)),
197
+ y("last_2_weeks", "Last 2 weeks", "week", v("week", -2, -1)),
198
+ y("this_month", "This month", "month", v("month", 0, 0)),
199
+ y("last_month", "Last month", "month", v("month", -1, -1)),
200
+ y("last_3_months", "Last 3 months", "month", v("month", -3, -1)),
201
+ y("last_6_months", "Last 6 months", "month", v("month", -6, -1)),
202
+ y("last_9_months", "Last 9 months", "month", v("month", -9, -1)),
203
+ y("last_12_months", "Last 12 months", "month", v("month", -12, -1)),
204
+ y("this_quarter", "This quarter", "quarter", v("quarter", 0, 0)),
205
+ y("last_quarter", "Last quarter", "quarter", v("quarter", -1, -1)),
206
+ y("last_4_quarters", "Last 4 quarters", "quarter", v("quarter", -4, -1)),
207
+ y("this_year", "This year", "year", v("year", 0, 0)),
208
+ y("last_year", "Last year", "year", v("year", -1, -1)),
209
+ // January 1 through the end of the last complete month; in January, all of last year (AO-D3).
210
+ y("year_to_last_completed_month", "Year to last completed month", "year", {
211
+ kind: "periods",
212
+ unit: "year",
213
+ from: 0,
214
+ to: 0,
215
+ toDate: !0,
216
+ anchor: { lastComplete: "month" }
217
+ })
218
+ ];
219
+ function li(e, t) {
220
+ return Le(e) === Le(t);
221
+ }
222
+ function Le(e) {
223
+ return JSON.stringify(
224
+ e,
225
+ (t, i) => i && typeof i == "object" && !Array.isArray(i) ? Object.fromEntries(Object.entries(i).sort(([n], [o]) => n < o ? -1 : n > o ? 1 : 0)) : i
226
+ );
227
+ }
228
+ function Pe(e) {
229
+ const t = di.find((i) => rt(i.window, e));
230
+ return {
231
+ label: t ? t.label : mi(e),
232
+ ...t ? { presetId: t.id } : {},
233
+ definition: dt(e)
234
+ };
235
+ }
236
+ function ui(e, t) {
237
+ const i = F(e), n = F(t);
238
+ return i && n ? rt(i, n) : i || n ? !1 : li(e ?? null, t ?? null);
239
+ }
240
+ function rt(e, t) {
241
+ return JSON.stringify(e) === JSON.stringify(t);
242
+ }
243
+ const J = (e, t) => Math.abs(e) === 1 ? t : `${t}s`;
244
+ function z(e, t) {
245
+ if (e === 0) return t === "day" ? "today" : `this ${t}`;
246
+ if (e === -1) return t === "day" ? "yesterday" : `last ${t}`;
247
+ if (e === 1) return t === "day" ? "tomorrow" : `next ${t}`;
248
+ const i = Math.abs(e);
249
+ return e < 0 ? `${i} ${J(i, t)} ago` : `${i} ${J(i, t)} ahead`;
250
+ }
251
+ const oe = (e) => e.charAt(0).toUpperCase() + e.slice(1), ci = {
252
+ day: "yesterday",
253
+ week: "last week",
254
+ month: "last month",
255
+ quarter: "last quarter",
256
+ year: "last year"
257
+ };
258
+ function ot(e) {
259
+ return F({ kind: "periods", unit: e.unit, from: e.from, to: e.to, anchor: "now" });
260
+ }
261
+ function mi(e) {
262
+ if (e.kind === "periods" && typeof e.anchor == "object")
263
+ return `${Pe(ot(e)).label}, as of end of ${ci[e.anchor.lastComplete]}`;
264
+ if (e.kind !== "monthDay" && e.anchor === "latest_data") {
265
+ const t = F({ ...e, anchor: "now" });
266
+ return `${Pe(t).label} of data`;
267
+ }
268
+ switch (e.kind) {
269
+ case "monthDay":
270
+ return e.day === "first" ? "First day of the month" : "Last day of the month";
271
+ case "rolling":
272
+ return `Last ${e.n} ${J(e.n, e.unit)}`;
273
+ case "periods": {
274
+ const { unit: t, from: i, to: n } = e;
275
+ return e.toDate ? i === 0 ? `This ${t} to date` : `${oe(z(i, t))} to date` : n === -1 && i <= -2 ? `Last ${-i} ${J(-i, t)}` : i === n ? oe(z(i, t)) : `${oe(z(i, t))} to ${z(n, t)}`;
276
+ }
277
+ }
278
+ }
279
+ const O = (e, t) => `${e} ${t}${Math.abs(e) === 1 ? "" : "s"}`;
280
+ function C(e, t) {
281
+ return e === 0 ? `the current ${t}` : e < 0 ? `${O(-e, t)} before the current one` : `${O(e, t)} after the current one`;
282
+ }
283
+ function dt(e) {
284
+ switch (e.kind) {
285
+ case "monthDay":
286
+ return e.day === "first" ? "the first day of the current month" : "the last day of the current month";
287
+ case "rolling": {
288
+ const t = O(e.n, e.unit);
289
+ return e.anchor === "latest_data" ? `the last ${t}, up to the latest date in the data` : `the last ${t}, up to now`;
290
+ }
291
+ case "periods": {
292
+ const { unit: t, from: i, to: n } = e;
293
+ if (typeof e.anchor == "object") {
294
+ const r = `the end of the last complete ${e.anchor.lastComplete}`;
295
+ return e.toDate ? i === 0 ? `the current ${t} up to ${r}` : `from ${C(i, t)} up to ${r}` : `${dt(ot(e))}, as of ${r}`;
296
+ }
297
+ if (e.anchor === "latest_data" && n === -1)
298
+ return `the ${O(-i, t)} before the ${t} of the latest date in the data, whole ${t}s only`;
299
+ const o = e.anchor === "latest_data" ? "the latest date in the data" : "now";
300
+ if (e.toDate)
301
+ return i === 0 ? `the current ${t} up to ${o}` : `from ${C(i, t)} up to ${o}`;
302
+ const s = e.anchor === "latest_data" ? ", counted from the latest date in the data" : "";
303
+ return i === 0 && n === 0 ? `the whole current ${t}${s}` : i === -1 && n === -1 ? `the ${t} before the current one` : n === -1 ? `the ${O(-i, t)} before the current ${t}, whole ${t}s only` : i === n ? `${C(i, t)}${s}` : `from ${C(i, t)} through ${C(n, t)}${s}`;
304
+ }
305
+ }
306
+ }
307
+ const lt = "Not a relative date window", pi = a.union([
308
+ $.lastSubDay.strict(),
309
+ $.last.strict(),
310
+ $.this.strict().refine(he.check, {
311
+ message: he.message,
312
+ path: ["boundary"]
313
+ }),
314
+ $.previous.strict(),
315
+ $.between.strict(),
316
+ at,
317
+ B.rolling.strict(),
318
+ B.monthDay.strict()
319
+ ]).transform((e, t) => {
320
+ const i = F(e);
321
+ return i || (t.addIssue({ code: a.ZodIssueCode.custom, message: lt }), a.NEVER);
322
+ }), M = {
323
+ periods: at,
324
+ rolling: B.rolling.strict(),
325
+ monthDay: B.monthDay.strict()
326
+ }, da = a.union([M.periods, M.rolling, M.monthDay]).transform((e, t) => {
327
+ const i = F(e, { authoring: !0 });
328
+ return i || (t.addIssue({ code: a.ZodIssueCode.custom, message: lt }), a.NEVER);
329
+ });
330
+ function G(e) {
331
+ return e.kind === "absolute";
332
+ }
333
+ const Q = "Use { kind: 'periods', unit, from, to, anchor } for whole periods (the last 3 complete months: from -3, to -1; this month: from 0, to 0) or { kind: 'rolling', unit, n, anchor } for elapsed time.", fi = "Ask the user which.", Ie = /* @__PURE__ */ new Set(["minute", "hour"]);
334
+ function la(e, t) {
335
+ if (!e || !t) return e === t;
336
+ if (G(e) || G(t)) {
337
+ if (!G(e) || !G(t)) return !1;
338
+ const i = (n) => {
339
+ var o;
340
+ return (o = ne(n)) == null ? void 0 : o.getTime();
341
+ };
342
+ return i(e.start) === i(t.start) && i(e.end) === i(t.end);
343
+ }
344
+ return ui(e, t);
345
+ }
346
+ function Se(e, t) {
347
+ const i = ct(e, t);
348
+ return i.ok ? i : { ok: !1, refusal: wi(i.problem, t) };
349
+ }
350
+ function ua(e, t, i) {
351
+ const n = Se(e, t);
352
+ if (!n.ok)
353
+ return { ...n.refusal, message: `${n.refusal.message} It stays while ${i} is left out.` };
354
+ }
355
+ const hi = a.object({ kind: a.literal("absolute"), start: a.string(), end: a.string() }).strict(), gi = { kind: "monthDay", day: "first" };
356
+ function ca(e) {
357
+ const t = typeof e == "function" ? e : () => e, i = Jt(
358
+ [M.periods, M.rolling, M.monthDay, hi],
359
+ ["periods window", "rolling window", "month day window", "absolute window"]
360
+ );
361
+ return a.preprocess((n, o) => {
362
+ const s = Se(n, { use: t(o.path) });
363
+ return s.ok ? s.window : (o.addIssue({
364
+ code: a.ZodIssueCode.custom,
365
+ message: ut(s.refusal),
366
+ ...s.refusal.path ? { path: [s.refusal.path] } : {}
367
+ }), gi);
368
+ }, i);
369
+ }
370
+ const ge = " Fix: ";
371
+ function ut(e) {
372
+ return `${e.message}${ge}${e.fix}`;
373
+ }
374
+ function ma(e) {
375
+ const t = e.indexOf(ge);
376
+ return t > 0 ? { message: e.slice(0, t), fix: e.slice(t + ge.length) } : void 0;
377
+ }
378
+ function ct(e, t) {
379
+ if (!e || typeof e != "object" || Array.isArray(e))
380
+ return w("not_a_window", "timeWindow must be an object.", `Send a window. ${Q}`, []);
381
+ const i = e;
382
+ if ("value" in i || "completeness" in i || "period" in i || i.kind === "relative" || i.kind === "calendar")
383
+ return w("old_form", "timeWindow uses the window form: kind periods or rolling, with an anchor.", Q, []);
384
+ if (i.kind === "absolute") return yi(i, t);
385
+ const n = i.kind;
386
+ if (n !== "periods" && n !== "rolling" && n !== "monthDay")
387
+ return w(
388
+ "not_a_window",
389
+ `timeWindow kind must be periods, rolling, monthDay or absolute${n === void 0 ? "" : `, not ${JSON.stringify(n)}`}.`,
390
+ Q,
391
+ [],
392
+ "kind"
393
+ );
394
+ if (n !== "monthDay" && i.anchor === void 0) return _i(i, t);
395
+ if (i.unit === "second") return bi(i);
396
+ if (n === "periods" && typeof i.unit == "string" && Ie.has(i.unit)) return vi(i);
397
+ const o = M[n].safeParse(i);
398
+ if (!o.success) {
399
+ const m = o.error.issues[0], u = m.path.join(".");
400
+ return w(
401
+ "not_a_window",
402
+ `timeWindow ${u ? `${u}: ` : ""}${m.message}.`,
403
+ `Send a ${n} window: ${Ai(n)}.`,
404
+ [],
405
+ u || void 0
406
+ );
407
+ }
408
+ const s = o.data, r = st(s, { authoring: !0 });
409
+ if (r) {
410
+ if (r.rule === "limit" && s.kind === "rolling")
411
+ return w(
412
+ "over_limit",
413
+ r.message,
414
+ `Use at most ${r.max}, or the same span in a longer unit.`,
415
+ [{ ...s, n: r.max }],
416
+ "n"
417
+ );
418
+ const m = r.rule === "W1" && s.kind === "periods" ? [{ ...s, from: s.to, to: s.from }] : [];
419
+ return w("not_a_window", r.message, ki(r.rule), m, r.path);
420
+ }
421
+ const l = Ii(s, t);
422
+ if (l) return l;
423
+ const c = F(s, { authoring: !0 });
424
+ return c ? { ok: !0, window: c } : w("not_a_window", "timeWindow is not a window.", Q, []);
425
+ }
426
+ function yi(e, t) {
427
+ if (t.use === "filterDefault")
428
+ return w(
429
+ "absolute_default",
430
+ "A filter's default moves with time.",
431
+ "Use a window that moves with time, or leave defaultPeriod out.",
432
+ [{ kind: "periods", unit: "month", from: -1, to: -1, anchor: "now" }]
433
+ );
434
+ const i = typeof e.start == "string" ? ne(e.start) : null, n = typeof e.end == "string" ? ne(e.end) : null;
435
+ return !i || !n || i.getTime() > n.getTime() ? w(
436
+ "absolute_invalid",
437
+ "start and end must be ISO dates or timestamps, start first.",
438
+ "Send start before end, as YYYY-MM-DD or an ISO timestamp.",
439
+ [],
440
+ i ? "end" : "start"
441
+ ) : { ok: !0, window: { kind: "absolute", start: e.start, end: e.end } };
442
+ }
443
+ function _i(e, t) {
444
+ const i = typeof e.unit == "string" ? e.unit : "month", n = [
445
+ { anchor: "now", words: '"now" counts from the run' },
446
+ ...t.use === "filterDefault" ? [] : [{ anchor: "latest_data", words: '"latest_data" from the newest row' }],
447
+ ...e.kind === "periods" ? [{ anchor: { lastComplete: i }, words: `{ "lastComplete": "${i}" } ends at the last complete ${i}` }] : []
448
+ ];
449
+ return w(
450
+ "missing_anchor",
451
+ "A window needs an anchor: where it counts from.",
452
+ `Add an anchor: ${n.map((o) => o.words).join(", ")}.`,
453
+ n.map((o) => ({ ...e, anchor: o.anchor })),
454
+ "anchor"
455
+ );
456
+ }
457
+ function bi(e) {
458
+ const t = typeof e.n == "number" ? e.n : 0, i = [.../* @__PURE__ */ new Set([Math.floor(t / 60), Math.ceil(t / 60)])].filter((n) => n >= 1);
459
+ return w(
460
+ "seconds",
461
+ "Windows count minutes, not seconds.",
462
+ "Round to whole minutes.",
463
+ i.map((n) => ({ kind: "rolling", unit: "minute", n, anchor: e.anchor })),
464
+ "unit"
465
+ );
466
+ }
467
+ function vi(e) {
468
+ const t = typeof e.from == "number" ? e.from : 0, n = (typeof e.to == "number" ? e.to : 0) - t + 1;
469
+ return w(
470
+ "sub_day_periods",
471
+ "Minutes and hours count elapsed time; there are no whole-minute or whole-hour periods.",
472
+ `The nearest is the last ${n} ${String(e.unit)}s up to the anchor.`,
473
+ n >= 1 ? [{ kind: "rolling", unit: e.unit, n, anchor: e.anchor }] : [],
474
+ "unit"
475
+ );
476
+ }
477
+ function Ii(e, t) {
478
+ if (!(t.use === "analysis" || e.kind === "monthDay")) {
479
+ if (e.kind === "rolling" && !Ie.has(e.unit)) return Si(e);
480
+ if (e.kind === "rolling" && t.columnHasTime === !1)
481
+ return w(
482
+ "sub_day_on_date",
483
+ "The date field has dates only, so it can't count minutes or hours.",
484
+ "Use whole days.",
485
+ [
486
+ { kind: "periods", unit: "day", from: 0, to: 0, anchor: e.anchor },
487
+ { kind: "periods", unit: "day", from: -1, to: 0, anchor: e.anchor }
488
+ ],
489
+ "unit"
490
+ );
491
+ if (t.use === "filterDefault" && e.anchor === "latest_data")
492
+ return w(
493
+ "data_anchor_default",
494
+ "A filter's default counts from the run, not from the latest data.",
495
+ "Count from the run instead.",
496
+ [{ ...e, anchor: "now" }],
497
+ "anchor"
498
+ );
499
+ }
500
+ }
501
+ function Si(e) {
502
+ const t = e.unit, i = e.n === 1 ? `Choose the current ${t} so far, or the last complete ${t}.` : `Choose the current ${t} so far and the ${e.n - 1} before it, or the last ${e.n} complete ${t}s.`;
503
+ return w("rolling_days_saved", `A saved card or default counts whole ${t}s.`, i, [
504
+ { kind: "periods", unit: t, from: 1 - e.n, to: 0, anchor: e.anchor },
505
+ { kind: "periods", unit: t, from: -e.n, to: -1, anchor: e.anchor }
506
+ ]);
507
+ }
508
+ function wi(e, t) {
509
+ const i = [], n = /* @__PURE__ */ new Set(), o = [e.sentence], s = (m, u) => {
510
+ for (const p of m) {
511
+ const f = ct(p, t);
512
+ if (f.ok) {
513
+ const b = JSON.stringify(p);
514
+ n.has(b) || (n.add(b), i.push(p));
515
+ } else u < 4 && f.problem.repairs.length && (o.includes(f.problem.sentence) || o.push(f.problem.sentence), s(f.problem.repairs, u + 1));
516
+ }
517
+ };
518
+ s(e.repairs, 0);
519
+ let r = o.join(" ");
520
+ const l = i.some((m) => "unit" in m && Ie.has(String(m.unit)));
521
+ t.use !== "analysis" && t.columnHasTime === void 0 && l && (r = `${r.replace(/\.$/, "")}, if the date field has a time of day.`), i.length > 1 && (r = `${r} ${fi}`);
522
+ const c = i.length ? ` ${i.length > 1 ? "Send one of" : "Send"}: ${i.map((m) => JSON.stringify(m)).join("; ")}.` : "";
523
+ return {
524
+ reason: e.reason,
525
+ message: e.message,
526
+ fix: `${r}${c}`,
527
+ suggestions: i,
528
+ ...e.path ? { path: e.path } : {}
529
+ };
530
+ }
531
+ function w(e, t, i, n, o) {
532
+ return { ok: !1, problem: { reason: e, message: t, sentence: i, repairs: n, ...o ? { path: o } : {} } };
533
+ }
534
+ function ki(e) {
535
+ switch (e) {
536
+ case "W1":
537
+ return "from must be at most to; -1 is the period before the anchor's.";
538
+ case "W2":
539
+ return "toDate needs to 0: the current period, up to the anchor.";
540
+ case "W3":
541
+ return "A window ending at the last complete period ends at or before it: to at most 0.";
542
+ case "W4":
543
+ case "limit":
544
+ return "n is a whole number of at least 1.";
545
+ }
546
+ }
547
+ function Ai(e) {
548
+ switch (e) {
549
+ case "periods":
550
+ return "{ kind: 'periods', unit: day | week | month | quarter | year, from, to, toDate?: true, anchor: 'now' | 'latest_data' | { lastComplete: unit } }";
551
+ case "rolling":
552
+ return "{ kind: 'rolling', unit: minute | hour | day | week | month | quarter | year, n, anchor: 'now' | 'latest_data' }";
553
+ case "monthDay":
554
+ return "{ kind: 'monthDay', day: 'first' | 'last' }";
555
+ }
556
+ }
557
+ function d(e, t, i) {
558
+ return i ? { code: e, message: t, path: i } : { code: e, message: t };
559
+ }
560
+ function h(e) {
561
+ return typeof e == "string" && e.trim().length > 0;
562
+ }
563
+ function Di(e) {
564
+ const t = /* @__PURE__ */ new Set();
565
+ return $i(e, (i) => (t.add(i), `{${i}}`)), Array.from(t);
566
+ }
567
+ function $i(e, t) {
568
+ let i = "", n = 0, o = 0;
569
+ for (; o < e.length; ) {
570
+ const s = e[o];
571
+ if (s === "'" || s === '"') {
572
+ o = xi(e, o);
573
+ continue;
574
+ }
575
+ if (s === "{") {
576
+ const r = e.indexOf("}", o + 1);
577
+ if (r === -1) {
578
+ o += 1;
579
+ continue;
580
+ }
581
+ const l = e.slice(o + 1, r);
582
+ /^[A-Za-z_][A-Za-z0-9_]*$/.test(l) && (i += e.slice(n, o) + t(l), n = r + 1), o = r + 1;
583
+ continue;
584
+ }
585
+ o += 1;
586
+ }
587
+ return i + e.slice(n);
588
+ }
589
+ function xi(e, t) {
590
+ const i = e[t];
591
+ let n = t + 1;
592
+ for (; n < e.length; ) {
593
+ if (e[n] === i) {
594
+ if (e[n + 1] === i) {
595
+ n += 2;
596
+ continue;
597
+ }
598
+ return n + 1;
599
+ }
600
+ n += 1;
601
+ }
602
+ return e.length;
603
+ }
604
+ function g(e) {
605
+ return !!(e && typeof e == "object" && !Array.isArray(e));
606
+ }
607
+ const Fi = /* @__PURE__ */ new Set([
608
+ "SUM",
609
+ "COUNT",
610
+ "AVG",
611
+ "MIN",
612
+ "MAX",
613
+ "MEDIAN",
614
+ "DISTINCT"
615
+ ]);
616
+ function we(e, t, i) {
617
+ if (!e || typeof e != "object") {
618
+ i.push(
619
+ d("missing_source", "Analytics intent needs a source.", t)
620
+ );
621
+ return;
622
+ }
623
+ if (e.kind === "semantic") {
624
+ h(e.domainId) || i.push(
625
+ d(
626
+ "missing_semantic_domain",
627
+ "Semantic source needs a domainId.",
628
+ `${t}.domainId`
629
+ )
630
+ ), h(e.datasetName) || i.push(
631
+ d(
632
+ "missing_dataset_name",
633
+ "Semantic source needs a datasetName.",
634
+ `${t}.datasetName`
635
+ )
636
+ );
637
+ return;
638
+ }
639
+ if (e.kind === "physical") {
640
+ h(e.connectionId) || i.push(
641
+ d(
642
+ "missing_connection_id",
643
+ "Physical source needs a connectionId.",
644
+ `${t}.connectionId`
645
+ )
646
+ ), h(e.tableName) || i.push(
647
+ d(
648
+ "missing_table_name",
649
+ "Physical source needs a tableName.",
650
+ `${t}.tableName`
651
+ )
652
+ );
653
+ return;
654
+ }
655
+ if (e.kind === "sql") {
656
+ h(e.connectionId) || i.push(
657
+ d(
658
+ "missing_connection_id",
659
+ "SQL source needs a connectionId.",
660
+ `${t}.connectionId`
661
+ )
662
+ );
663
+ return;
664
+ }
665
+ i.push(
666
+ d("invalid_source_kind", "Source kind is not supported.", t)
667
+ );
668
+ }
669
+ function I(e, t, i, n = {}) {
670
+ if (!e || !g(e)) {
671
+ n.required && i.push(
672
+ d("missing_field_ref", "Field reference needs a name.", t)
673
+ );
674
+ return;
675
+ }
676
+ h(e.name) || i.push(
677
+ d(
678
+ "missing_field_ref",
679
+ "Field reference needs a name.",
680
+ `${t}.name`
681
+ )
682
+ ), e.source !== void 0 && we(e.source, `${t}.source`, i), ke(e.aggregate, `${t}.aggregate`, i);
683
+ }
684
+ function ke(e, t, i) {
685
+ e !== void 0 && (typeof e != "string" || !Fi.has(e)) && i.push(
686
+ d(
687
+ "invalid_aggregate",
688
+ "Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",
689
+ t
690
+ )
691
+ );
692
+ }
693
+ const Mi = /* @__PURE__ */ new Set([
694
+ "measure",
695
+ "dimension",
696
+ "date",
697
+ "id",
698
+ "unknown"
699
+ ]), Ei = /* @__PURE__ */ new Set(["row", "aggregate"]), Ni = /* @__PURE__ */ new Set([
700
+ "string",
701
+ "number",
702
+ "boolean",
703
+ "date",
704
+ "datetime",
705
+ "unknown"
706
+ ]);
707
+ function Ti(e, t, i) {
708
+ if (e === void 0)
709
+ return;
710
+ if (!g(e)) {
711
+ i.push(
712
+ d(
713
+ "invalid_value_format",
714
+ "Value format must be a structured object.",
715
+ t
716
+ )
717
+ );
718
+ return;
719
+ }
720
+ const n = (e.type === "temporal_bucket" ? K : qt).safeParse(e);
721
+ if (n.success) return;
722
+ const o = e.type === "temporal_bucket" ? "invalid_temporal_bucket_format" : "invalid_value_format";
723
+ for (const s of n.error.issues)
724
+ i.push(
725
+ d(
726
+ o,
727
+ s.message,
728
+ [t, ...s.path.map(String)].filter(Boolean).join(".")
729
+ )
730
+ );
731
+ }
732
+ const Ri = /* @__PURE__ */ new Set([
733
+ "additive",
734
+ "non_additive",
735
+ "ratio_of_sums",
736
+ "weighted",
737
+ "pre_aggregated",
738
+ "snapshot"
739
+ ]), ji = /* @__PURE__ */ new Set([
740
+ "default",
741
+ "symmetric_aggregate",
742
+ "aggregate_then_join",
743
+ "weighted"
744
+ ]);
745
+ function Ci(e, t, i) {
746
+ if (!e || !g(e)) {
747
+ i.push(
748
+ d(
749
+ "invalid_derived_field_input",
750
+ "Derived field inputs must be structured input references.",
751
+ t
752
+ )
753
+ );
754
+ return;
755
+ }
756
+ if (e.kind === "field") {
757
+ I(e.field, `${t}.field`, i, { required: !0 }), ke(e.aggregate, `${t}.aggregate`, i);
758
+ return;
759
+ }
760
+ i.push(
761
+ d(
762
+ "invalid_derived_field_input",
763
+ "Derived field input kind must be field.",
764
+ `${t}.kind`
765
+ )
766
+ );
767
+ }
768
+ function Ae(e) {
769
+ const t = [];
770
+ if (!g(e))
771
+ return t.push(
772
+ d(
773
+ "invalid_derived_field",
774
+ "Derived field definition must be a structured object."
775
+ )
776
+ ), { ok: !1, errors: t, warnings: [] };
777
+ if (e.kind !== "derived_field" && t.push(
778
+ d(
779
+ "invalid_derived_field_kind",
780
+ "Derived field kind must be derived_field.",
781
+ "kind"
782
+ )
783
+ ), h(e.name) || t.push(
784
+ d(
785
+ "invalid_derived_field_name",
786
+ "Derived field needs a name.",
787
+ "name"
788
+ )
789
+ ), h(e.label) || t.push(
790
+ d(
791
+ "invalid_derived_field_label",
792
+ "Derived field needs a label.",
793
+ "label"
794
+ )
795
+ ), Mi.has(e.resultRole) || t.push(
796
+ d(
797
+ "invalid_derived_field_role",
798
+ "Derived field resultRole must be measure, dimension, date, id, or unknown.",
799
+ "resultRole"
800
+ )
801
+ ), Ni.has(e.dataType) || t.push(
802
+ d(
803
+ "invalid_derived_field_data_type",
804
+ "Derived field dataType must be string, number, boolean, date, datetime, or unknown.",
805
+ "dataType"
806
+ )
807
+ ), Ei.has(e.computeStage) || t.push(
808
+ d(
809
+ "invalid_derived_field_compute_stage",
810
+ "Derived field computeStage must be row or aggregate.",
811
+ "computeStage"
812
+ )
813
+ ), e.computeStage === "aggregate" && e.resultRole !== "measure" && t.push(
814
+ d(
815
+ "invalid_derived_field_compute_stage",
816
+ "Aggregate-stage derived fields must have resultRole measure.",
817
+ "computeStage"
818
+ )
819
+ ), e.resultRole !== "measure" && e.defaultAggregate !== void 0 && t.push(
820
+ d(
821
+ "invalid_derived_field_aggregate",
822
+ "Only measure derived fields may declare defaultAggregate.",
823
+ "defaultAggregate"
824
+ )
825
+ ), e.computeStage === "row" && e.resultRole === "measure" && e.defaultAggregate === void 0 && t.push(
826
+ d(
827
+ "missing_derived_field_default_aggregate",
828
+ "Row-stage measure derived fields must declare defaultAggregate so row results have explicit rollup semantics.",
829
+ "defaultAggregate"
830
+ )
831
+ ), ke(
832
+ e.defaultAggregate,
833
+ "defaultAggregate",
834
+ t
835
+ ), e.aggregationBehavior !== void 0 && !Ri.has(
836
+ e.aggregationBehavior
837
+ ) && t.push(
838
+ d(
839
+ "invalid_derived_field_aggregation_behavior",
840
+ "Derived field aggregationBehavior is not supported.",
841
+ "aggregationBehavior"
842
+ )
843
+ ), e.aggregationStrategy !== void 0 && !ji.has(
844
+ e.aggregationStrategy
845
+ ) && t.push(
846
+ d(
847
+ "invalid_derived_field_aggregation_strategy",
848
+ "Derived field aggregationStrategy is not supported.",
849
+ "aggregationStrategy"
850
+ )
851
+ ), h(e.expression) || t.push(
852
+ d(
853
+ "invalid_derived_field_expression",
854
+ "Derived field needs a named-token expression.",
855
+ "expression"
856
+ )
857
+ ), e.expressionLanguage !== void 0 && e.expressionLanguage !== "semaphor_sql_template" && t.push(
858
+ d(
859
+ "invalid_derived_field_expression_language",
860
+ "Derived field expressionLanguage must be semaphor_sql_template.",
861
+ "expressionLanguage"
862
+ )
863
+ ), !g(e.inputs) || Object.keys(e.inputs).length === 0 ? t.push(
864
+ d(
865
+ "invalid_derived_field_inputs",
866
+ "Derived field needs at least one typed input.",
867
+ "inputs"
868
+ )
869
+ ) : Object.entries(e.inputs).forEach(([n, o]) => {
870
+ if (!h(n)) {
871
+ t.push(
872
+ d(
873
+ "invalid_derived_field_input_name",
874
+ "Derived field input names must be non-empty strings.",
875
+ "inputs"
876
+ )
877
+ );
878
+ return;
879
+ }
880
+ Ci(
881
+ o,
882
+ `inputs.${n}`,
883
+ t
884
+ );
885
+ }), h(e.expression) && g(e.inputs)) {
886
+ const n = Di(
887
+ e.expression
888
+ ), o = new Set(n), s = Object.keys(e.inputs).filter(
889
+ (r) => h(r)
890
+ );
891
+ n.forEach((r) => {
892
+ Object.prototype.hasOwnProperty.call(e.inputs, r) || t.push(
893
+ d(
894
+ "invalid_derived_field_expression_token",
895
+ `Derived field expression token "{${r}}" needs a matching inputs.${r} entry.`,
896
+ "expression"
897
+ )
898
+ );
899
+ }), s.forEach((r) => {
900
+ o.has(r) || t.push(
901
+ d(
902
+ "unused_derived_field_input",
903
+ `Derived field input "${r}" is not referenced by expression.`,
904
+ `inputs.${r}`
905
+ )
906
+ );
907
+ });
908
+ }
909
+ const i = e.format;
910
+ return g(i) && i.type === "temporal_bucket" ? t.push(
911
+ d(
912
+ "invalid_derived_field_format",
913
+ "Derived field computation metadata cannot own temporal bucket presentation; declare grain and format on the grouped field.",
914
+ "format"
915
+ )
916
+ ) : Ti(i, "format", t), e.tags !== void 0 && (!Array.isArray(e.tags) || e.tags.some((n) => !h(n))) && t.push(
917
+ d(
918
+ "invalid_derived_field_tags",
919
+ "Derived field tags must be non-empty strings.",
920
+ "tags"
921
+ )
922
+ ), { ok: t.length === 0, errors: t, warnings: [] };
923
+ }
924
+ const Y = a.string().min(1).refine((e) => e.trim().length > 0, "Must not be blank."), De = a.union([
925
+ Bt.extend({ domainId: Y, datasetName: Y }).strict(),
926
+ Wt.extend({ connectionId: Y, tableName: Y }).strict()
927
+ ]), mt = Ut.extend({
928
+ name: Y,
929
+ source: De.optional()
930
+ }).strict(), $e = Vt.extend({
931
+ format: Ht.optional(),
932
+ inputs: a.record(
933
+ a.object({
934
+ kind: a.literal("field"),
935
+ field: mt,
936
+ aggregate: tt.optional()
937
+ }).strict()
938
+ )
939
+ }).strict().superRefine((e, t) => {
940
+ var i;
941
+ for (const n of Ae(e).errors)
942
+ t.addIssue({
943
+ code: "custom",
944
+ path: ((i = n.path) == null ? void 0 : i.split(".")) ?? [],
945
+ message: n.message
946
+ });
947
+ }), Yi = mt.extend({
948
+ derivedField: $e.optional()
949
+ }).strict();
950
+ function xe(e) {
951
+ return typeof e == "string" ? e.trim().toLowerCase() : "";
952
+ }
953
+ function Oi(e) {
954
+ return String(
955
+ e.column_name || e.name || e.qualifiedFieldName || ""
956
+ );
957
+ }
958
+ function Li(e) {
959
+ return Array.from(
960
+ new Set(
961
+ [e.column_name, e.name, e.qualifiedFieldName, e.alias].filter(
962
+ (t) => typeof t == "string" && t.trim().length > 0
963
+ ).map((t) => t.trim())
964
+ )
965
+ );
966
+ }
967
+ function Fe(e) {
968
+ const t = ft(e);
969
+ return t ? Wi(t) ? "number" : t.includes("timestamp") || t.includes("datetime") || t.startsWith("time") ? "datetime" : t.includes("date") ? "date" : t.includes("bool") ? "boolean" : "string" : "unknown";
970
+ }
971
+ const de = /* @__PURE__ */ new Map([
972
+ // Integer families (PostgreSQL, ClickHouse, DuckDB, MySQL).
973
+ ["int", "integer"],
974
+ ["uint", "integer"],
975
+ ["integer", "integer"],
976
+ ["uinteger", "integer"],
977
+ ["bigint", "integer"],
978
+ ["ubigint", "integer"],
979
+ ["smallint", "integer"],
980
+ ["usmallint", "integer"],
981
+ ["tinyint", "integer"],
982
+ ["utinyint", "integer"],
983
+ ["mediumint", "integer"],
984
+ ["hugeint", "integer"],
985
+ ["uhugeint", "integer"],
986
+ // Exact decimal families.
987
+ ["numeric", "decimal"],
988
+ ["decimal", "decimal"],
989
+ // Binary floating point.
990
+ ["float", "float"],
991
+ ["double", "float"],
992
+ ["real", "float"],
993
+ ["bfloat16", "float"],
994
+ // Numeric for grounding; storage representation not established
995
+ // (`number(p, s)` with an explicit scale is resolved before this table).
996
+ ["number", null],
997
+ ["money", null],
998
+ ["currency", null],
999
+ ["percent", null]
1000
+ ]), Pi = ["int", "uint", "decimal", "float"];
1001
+ function qi(e) {
1002
+ return e.length > 0 && Array.from(e).every((t) => t >= "0" && t <= "9");
1003
+ }
1004
+ function Bi(e) {
1005
+ var i;
1006
+ const t = (i = /^number\s*\(\s*\d+\s*,\s*(\d+)\s*\)$/.exec(e)) == null ? void 0 : i[1];
1007
+ return t === void 0 ? null : Number(t) === 0 ? "integer" : "decimal";
1008
+ }
1009
+ function pt(e) {
1010
+ const t = e.split(/[\s(]/, 1)[0] || "";
1011
+ if (t === "number")
1012
+ return { numeric: !0, kind: Bi(e) };
1013
+ if (de.has(t))
1014
+ return { numeric: !0, kind: de.get(t) ?? null };
1015
+ const i = Pi.find(
1016
+ (n) => t.startsWith(n) && qi(t.slice(n.length))
1017
+ );
1018
+ return i ? { numeric: !0, kind: de.get(i) ?? null } : { numeric: !1, kind: null };
1019
+ }
1020
+ function Wi(e) {
1021
+ return pt(e).numeric;
1022
+ }
1023
+ function Ui(e) {
1024
+ return pt(ft(e)).kind;
1025
+ }
1026
+ function ft(e) {
1027
+ let t = xe(e), i = "";
1028
+ for (; t && t !== i; )
1029
+ i = t, t = qe(t, "nullable"), t = qe(t, "lowcardinality");
1030
+ return t;
1031
+ }
1032
+ function qe(e, t) {
1033
+ const i = `${t}(`;
1034
+ return !e.startsWith(i) || !e.endsWith(")") ? e : e.slice(i.length, -1).trim();
1035
+ }
1036
+ function Vi(e) {
1037
+ const t = Fe(e);
1038
+ return t === "date" || t === "datetime";
1039
+ }
1040
+ function ht(e) {
1041
+ return Vi(e.dataType || e.data_type);
1042
+ }
1043
+ function gt(e) {
1044
+ const t = yt(e);
1045
+ return t === "id" || t === "row_id";
1046
+ }
1047
+ function Be(e) {
1048
+ const t = yt(e);
1049
+ return gt(e) || t.endsWith("_id") || t.endsWith("_key") || t.endsWith("_number");
1050
+ }
1051
+ function yt(e) {
1052
+ return xe(
1053
+ Oi(e) || e.name || e.alias
1054
+ ).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
1055
+ }
1056
+ function _t(e, t = {}) {
1057
+ const i = xe(e.role);
1058
+ return i === "metric" || i === "measure" ? !t.excludeIdentifiers || !Be(e) : i === "groupby" || i === "dimension" || i === "date" || i === "id" ? !1 : Fe(
1059
+ e.dataType || e.data_type
1060
+ ) === "number" && (!t.excludeIdentifiers || !Be(e));
1061
+ }
1062
+ function pa(e) {
1063
+ return !_t(e) && !ht(e);
1064
+ }
1065
+ function fa(e) {
1066
+ const t = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
1067
+ for (const o of e) {
1068
+ if (gt(o))
1069
+ continue;
1070
+ const s = Li(o);
1071
+ if (s.length !== 0) {
1072
+ if (ht(o)) {
1073
+ s.forEach((r) => i.add(r));
1074
+ continue;
1075
+ }
1076
+ if (_t(o, { excludeIdentifiers: !0 })) {
1077
+ s.forEach((r) => t.add(r));
1078
+ continue;
1079
+ }
1080
+ s.forEach((r) => n.add(r));
1081
+ }
1082
+ }
1083
+ return {
1084
+ validMeasureCandidates: Array.from(t).sort(),
1085
+ validDateCandidates: Array.from(i).sort(),
1086
+ validDimensionCandidates: Array.from(n).sort()
1087
+ };
1088
+ }
1089
+ const L = 16 * 1024;
1090
+ function ee(e) {
1091
+ const t = /^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))(?:[eE]([+-]?\d+))?$/.exec(e);
1092
+ return t ? {
1093
+ sign: t[1],
1094
+ whole: t[2] ?? "",
1095
+ fraction: t[3] ?? t[4],
1096
+ exponent: Number(t[5] ?? "0")
1097
+ } : null;
1098
+ }
1099
+ function We(e) {
1100
+ const { sign: t, whole: i, fraction: n = "", exponent: o } = e, s = (i + n).replace(/^0+/, ""), r = s.replace(/0+$/, ""), l = o - n.length + s.length - r.length;
1101
+ return !Number.isSafeInteger(o) || !Number.isSafeInteger(l) ? null : r ? `${t === "-" ? "-" : ""}${r}e${l}` : "0";
1102
+ }
1103
+ function ha(e) {
1104
+ const t = ee(e);
1105
+ if (!t) return null;
1106
+ const i = t.sign === "+" ? e.slice(1) : e, n = Number(e);
1107
+ if (!Number.isFinite(n)) return i;
1108
+ const o = We(t), s = ee(String(n));
1109
+ return o !== null && s !== null && o === We(s) ? n : i;
1110
+ }
1111
+ function ga(e) {
1112
+ if (e.length > L)
1113
+ throw new RangeError("Exact numeric text exceeds 16 KiB.");
1114
+ const t = ee(e);
1115
+ if (!t) throw new TypeError("Expected finite decimal text.");
1116
+ const { sign: i, whole: n, fraction: o, exponent: s } = t, r = `${i}${n || "0"}${o ? `.${o}` : ""}`;
1117
+ return W(`${r}e${s}`);
1118
+ }
1119
+ function W(e) {
1120
+ if (e.length > L)
1121
+ throw new RangeError("Exact numeric text exceeds 16 KiB.");
1122
+ const t = ee(e);
1123
+ if (!t || t.whole === "" || t.fraction === "")
1124
+ throw new TypeError("Expected finite decimal text.");
1125
+ const { sign: i, whole: n, fraction: o = "", exponent: s } = t;
1126
+ if (!Number.isSafeInteger(s) || Math.abs(s) > L)
1127
+ throw new RangeError("Exact numeric exponent exceeds the text budget.");
1128
+ const r = n + o, l = n.length + s;
1129
+ if (Math.max(r.length, l) + Math.max(0, -l) + 3 > L)
1130
+ throw new RangeError("Normalized exact numeric text exceeds 16 KiB.");
1131
+ let m;
1132
+ l <= 0 ? m = `0.${"0".repeat(-l)}${r}` : l >= r.length ? m = r + "0".repeat(l - r.length) : m = `${r.slice(0, l)}.${r.slice(l)}`;
1133
+ const [u, p = ""] = m.split("."), f = u.replace(/^0+(?=\d)/, ""), b = p.replace(/0+$/, ""), A = f + (b ? `.${b}` : "");
1134
+ return i === "-" && A !== "0" ? `-${A}` : A;
1135
+ }
1136
+ function ya(e, t) {
1137
+ const i = e.startsWith("-"), n = t.startsWith("-");
1138
+ if (i !== n) return i ? -1 : 1;
1139
+ const [o, s = ""] = (i ? e.slice(1) : e).split("."), [r, l = ""] = (n ? t.slice(1) : t).split(".");
1140
+ let c = Math.sign(o.length - r.length);
1141
+ if (!c && o !== r && (c = o < r ? -1 : 1), !c) {
1142
+ const m = Math.max(s.length, l.length), u = s.padEnd(m, "0"), p = l.padEnd(m, "0");
1143
+ c = u === p ? 0 : u < p ? -1 : 1;
1144
+ }
1145
+ return c === 0 ? 0 : i ? -c : c;
1146
+ }
1147
+ function _a(e, t) {
1148
+ if (typeof t == "number" && !Number.isFinite(t))
1149
+ throw new TypeError("Numeric scale must be finite.");
1150
+ const i = [e, W(String(t))].map((s) => {
1151
+ const [r, l = ""] = s.split(".");
1152
+ return { coefficient: BigInt(r + l), digits: l.length };
1153
+ }), n = i[0].coefficient * i[1].coefficient, o = i[0].digits + i[1].digits;
1154
+ return W(`${n}e-${o}`);
1155
+ }
1156
+ function Hi(e) {
1157
+ try {
1158
+ return W(e) === e;
1159
+ } catch {
1160
+ return !1;
1161
+ }
1162
+ }
1163
+ const bt = a.object({
1164
+ kind: a.literal("exact_number"),
1165
+ type: a.enum(["integer", "decimal"]),
1166
+ value: a.string().max(L).refine(Hi, "Expected canonical decimal text.")
1167
+ }).strict().superRefine((e, t) => {
1168
+ e.type === "integer" && e.value.includes(".") && t.addIssue({ code: "custom", path: ["value"], message: "An integer cannot have fractional digits." });
1169
+ }), zi = a.union([
1170
+ a.null(),
1171
+ a.string(),
1172
+ a.boolean(),
1173
+ a.number().finite(),
1174
+ bt
1175
+ ]);
1176
+ function Gi(e, t) {
1177
+ return bt.parse({ kind: "exact_number", type: t, value: W(e) });
1178
+ }
1179
+ function ba(e) {
1180
+ return typeof e == "object" && e !== null && "kind" in e && e.kind === "exact_number" && "type" in e && (e.type === "integer" || e.type === "decimal") && "value" in e && typeof e.value == "string";
1181
+ }
1182
+ function va(e) {
1183
+ const t = Ui(e.nativeDataType);
1184
+ if (!t) throw new TypeError("Numeric result type is not established.");
1185
+ if (e.value === null) return null;
1186
+ if (t === "float") {
1187
+ if (typeof e.value != "number" || !Number.isFinite(e.value))
1188
+ throw new TypeError("Expected a finite floating-point result.");
1189
+ return e.value;
1190
+ }
1191
+ if (e.exactText === void 0)
1192
+ throw new TypeError("Exact numeric sidecar is required; rounded result values cannot substitute.");
1193
+ return Gi(e.exactText, t);
1194
+ }
1195
+ const Me = a.string().uuid(), Ee = a.enum(["rows", "columns"]), Ia = a.enum(["member", "subtotal", "grand_total", "others"]), Qi = a.discriminatedUnion("kind", [
1196
+ a.object({ kind: a.literal("value"), value: zi }).strict(),
1197
+ a.object({ kind: a.literal("others"), rankingId: Me }).strict()
1198
+ ]), N = a.array(a.object({ levelId: Me, member: Qi }).strict()).readonly().superRefine((e, t) => {
1199
+ new Set(e.map((i) => i.levelId)).size !== e.length && t.addIssue({
1200
+ code: "custom",
1201
+ path: [],
1202
+ message: "Duplicate identity."
1203
+ }), e.some(
1204
+ (i, n) => i.member.kind === "others" && n !== e.length - 1
1205
+ ) && t.addIssue({
1206
+ code: "custom",
1207
+ path: [],
1208
+ message: "Others is terminal."
1209
+ });
1210
+ }), Sa = a.object({
1211
+ rowPath: N,
1212
+ columnPath: N,
1213
+ measureId: Me
1214
+ }).strict();
1215
+ function vt(e) {
1216
+ return JSON.stringify(
1217
+ e.map(({ levelId: t, member: i }) => [
1218
+ t,
1219
+ i.kind === "others" ? ["others", i.rankingId] : typeof i.value == "object" && i.value !== null ? ["exact_number", i.value.value] : [typeof i.value, i.value]
1220
+ ])
1221
+ );
1222
+ }
1223
+ const ye = "SEMAPHOR_CALCULATED_FIELD", Xi = "calculated_fields";
1224
+ function Ki(e) {
1225
+ return (e == null ? void 0 : e.sourceField) || (e == null ? void 0 : e.name) || "";
1226
+ }
1227
+ const Zi = [
1228
+ // Day granularity formats
1229
+ "MM-DD-YYYY",
1230
+ "YYYY-MM-DD",
1231
+ "MM/DD/YYYY",
1232
+ "DD/MM/YYYY",
1233
+ "MMMM DD, YYYY",
1234
+ "MMM DD, YYYY",
1235
+ "DD MMM YYYY",
1236
+ "YYYY-MM-DD HH:mm",
1237
+ "YYYY-MM-DD HH:mm:ss",
1238
+ "YYYY-MM-DD HH:mm Z",
1239
+ "YYYY-MM-DD HH:mm:ss Z",
1240
+ // Week granularity formats
1241
+ "Week of MMM DD, YYYY",
1242
+ "Week of MMMM DD, YYYY",
1243
+ "YYYY-WW",
1244
+ // Month granularity formats
1245
+ "MMM YYYY",
1246
+ "MMMM YYYY",
1247
+ "YYYY-MM",
1248
+ "MM/YYYY",
1249
+ "YYYY MMM",
1250
+ // Quarter granularity formats
1251
+ "Q1 YYYY",
1252
+ "YYYY Q1",
1253
+ "1st Quarter YYYY",
1254
+ "YYYY-Q1",
1255
+ "Quarter 1, YYYY",
1256
+ // Year granularity formats
1257
+ "YYYY",
1258
+ "YY",
1259
+ // Custom format
1260
+ "custom"
1261
+ ];
1262
+ function wa(e) {
1263
+ return e.role === "metric" && "expression" in e && !!e.expression;
1264
+ }
1265
+ function ka(e) {
1266
+ return !!e.expression;
1267
+ }
1268
+ function Ji(e) {
1269
+ return !!(e && (e.calculationRepresentation || e.expression || e.derivedField || e.calculatedFieldOrigin || e.calculatedFormula || _e(e)));
1270
+ }
1271
+ function It(e) {
1272
+ var p, f, b;
1273
+ if (!e)
1274
+ return {
1275
+ representation: "physical",
1276
+ ownership: "local",
1277
+ completeness: "not-calculated",
1278
+ runtimeExecutable: !1,
1279
+ legacyManual: !1
1280
+ };
1281
+ const t = e.fieldScope === "domain" ? "domain" : "local", i = ((p = e.derivedField) == null ? void 0 : p.computeStage) || ((f = e.calculatedFormula) == null ? void 0 : f.computeStage), n = !e.calculatedFormula || Array.isArray(e.calculatedFormula.inputFields) && e.calculatedFormula.inputFields.every((A) => {
1282
+ const Ye = A && Ki(A);
1283
+ return typeof Ye == "string" && !!Ye.trim();
1284
+ }), o = typeof e.expression == "string" && !!e.expression.trim() && n, s = e.calculationRepresentation;
1285
+ if (e.derivedField || s === "typed-derived") {
1286
+ const A = e.derivedField !== void 0 && Ae(e.derivedField).ok;
1287
+ return {
1288
+ representation: "typed-derived",
1289
+ ownership: t,
1290
+ completeness: (!s || s === "typed-derived") && A && (!e.expression && !e.calculatedFormula || o) ? "complete" : "incomplete",
1291
+ computeStage: i,
1292
+ runtimeExecutable: o,
1293
+ legacyManual: !1
1294
+ };
1295
+ }
1296
+ if (!(!!s || Ji(e)))
1297
+ return {
1298
+ representation: "physical",
1299
+ ownership: t,
1300
+ completeness: "not-calculated",
1301
+ runtimeExecutable: !1,
1302
+ legacyManual: !1
1303
+ };
1304
+ const l = i || (e.role === "groupby" || ((b = e.calculatedFieldOrigin) == null ? void 0 : b.role) === "groupby" ? "row" : void 0), c = t === "domain" || _e(e) || e.fieldScope === "card" || e.fieldScope === "sheet" || e.fieldScope === "dashboard" ? "manual" : "inline-expression", m = s === "manual" || s === "inline-expression" ? s : c, u = (!s || s === "manual" || s === "inline-expression") && !(s === "inline-expression" && _e(e));
1305
+ return {
1306
+ representation: m,
1307
+ ownership: t,
1308
+ completeness: o && u ? "complete" : "incomplete",
1309
+ computeStage: l,
1310
+ runtimeExecutable: o,
1311
+ legacyManual: m === "manual" && t === "local" && !l
1312
+ };
1313
+ }
1314
+ function Aa(e) {
1315
+ if (e.calculationRepresentation) return e;
1316
+ const { representation: t } = It(e);
1317
+ return t === "physical" ? e : { ...e, calculationRepresentation: t };
1318
+ }
1319
+ function Da(e) {
1320
+ return It(e).computeStage;
1321
+ }
1322
+ function $a(e, t) {
1323
+ return e === "aggregate" && t === "default";
1324
+ }
1325
+ function xa(e) {
1326
+ var i, n;
1327
+ const t = e;
1328
+ return !!(t != null && t.expression && ((n = (i = t.calculatedFormula) == null ? void 0 : i.inputFields) != null && n.length));
1329
+ }
1330
+ function Fa(e) {
1331
+ return !!(e && (e.entityName === ye || e.entityId === ye));
1332
+ }
1333
+ function _e(e) {
1334
+ return e ? [e.entityName, e.entityId, e.qualifiedEntityName].some(
1335
+ (t) => t === ye || t === Xi
1336
+ ) : !1;
1337
+ }
1338
+ function en(e) {
1339
+ const t = wt(e);
1340
+ return t.length > 0 ? t.join(".") : void 0;
1341
+ }
1342
+ function Ma(e) {
1343
+ const t = en(
1344
+ e.qualifiedName
1345
+ ), i = (t == null ? void 0 : t.split(".")) || [];
1346
+ if (i.length === 0) return {};
1347
+ const n = {};
1348
+ let o = i.length - 1;
1349
+ for (let s = e.capabilities.prefixLevels.length - 1; s >= 0 && o >= 0; s -= 1, o -= 1)
1350
+ an(
1351
+ n,
1352
+ e.capabilities.prefixLevels[s],
1353
+ i[o]
1354
+ );
1355
+ return n;
1356
+ }
1357
+ function Ea(e) {
1358
+ return !e.left.tableName || !e.right.tableName ? !1 : e.capabilities.prefixLevels.every((t) => {
1359
+ const i = T(e.left, t), n = T(e.right, t);
1360
+ return !i || !n || i === n;
1361
+ });
1362
+ }
1363
+ function Na(e) {
1364
+ return e.capabilities.prefixLevels.every((t) => {
1365
+ const i = T(e.requested, t);
1366
+ return i ? T(e.allowed, t) === i : !0;
1367
+ });
1368
+ }
1369
+ function St(e, t = {}) {
1370
+ const i = U(e), n = {
1371
+ connectionId: t.connectionId,
1372
+ connectionType: e,
1373
+ path: ["database", "schema", "table"],
1374
+ labels: {
1375
+ database: "Database",
1376
+ schema: "Schema",
1377
+ table: "Table"
1378
+ },
1379
+ prefixLevels: ["database", "schema", "table"],
1380
+ dialect: "postgres",
1381
+ supportsFilterClause: !0
1382
+ };
1383
+ return i.includes("postgres") ? {
1384
+ ...n,
1385
+ prefixLevels: ["schema", "table"],
1386
+ dialect: "postgres"
1387
+ } : i.includes("mysql") ? {
1388
+ ...n,
1389
+ prefixLevels: ["database", "table"],
1390
+ dialect: "mysql",
1391
+ supportsFilterClause: !1
1392
+ } : i.includes("mssql") || i.includes("sqlserver") ? {
1393
+ ...n,
1394
+ dialect: "mssql",
1395
+ supportsFilterClause: !1
1396
+ } : i.includes("redshift") ? {
1397
+ ...n,
1398
+ prefixLevels: ["schema", "table"],
1399
+ dialect: "redshift"
1400
+ } : i.includes("snowflake") ? {
1401
+ ...n,
1402
+ dialect: "snowflake"
1403
+ } : i.includes("clickhouse") ? {
1404
+ connectionId: t.connectionId,
1405
+ connectionType: e,
1406
+ path: ["database", "table"],
1407
+ labels: {
1408
+ database: "Database",
1409
+ table: "Table"
1410
+ },
1411
+ prefixLevels: ["database", "table"],
1412
+ dialect: "clickhouse",
1413
+ supportsFilterClause: !1
1414
+ } : i === "s3" || i === "api" ? {
1415
+ connectionId: t.connectionId,
1416
+ connectionType: e,
1417
+ path: ["table"],
1418
+ labels: {
1419
+ table: i === "api" ? "API Table" : "File Table"
1420
+ },
1421
+ prefixLevels: ["table"],
1422
+ dialect: "duckdb",
1423
+ supportsFilterClause: !0
1424
+ } : i === "googlesheets" || i === "fileupload" ? {
1425
+ connectionId: t.connectionId,
1426
+ connectionType: e,
1427
+ path: ["table"],
1428
+ labels: {
1429
+ table: "Table"
1430
+ },
1431
+ prefixLevels: ["table"],
1432
+ dialect: "postgres",
1433
+ supportsFilterClause: !0
1434
+ } : i === "bigquery" ? {
1435
+ ...n,
1436
+ labels: {
1437
+ database: "Project",
1438
+ schema: "Dataset",
1439
+ table: "Table"
1440
+ },
1441
+ prefixLevels: ["schema", "table"],
1442
+ dialect: "bigquery",
1443
+ supportsFilterClause: !1
1444
+ } : n;
1445
+ }
1446
+ const Ne = [
1447
+ "GoogleSheets",
1448
+ "FileUpload",
1449
+ "MySQL",
1450
+ "MSSQL",
1451
+ "PostgreSQL",
1452
+ "BigQuery",
1453
+ "Redshift",
1454
+ "Snowflake",
1455
+ "S3",
1456
+ "clickhouse",
1457
+ "API",
1458
+ "none"
1459
+ ];
1460
+ function Ta(e) {
1461
+ if (!e) return;
1462
+ const t = Ne.filter(
1463
+ (i) => i !== "none" && St(i).dialect === e
1464
+ );
1465
+ return t.length === 1 ? t[0] : void 0;
1466
+ }
1467
+ const tn = {
1468
+ postgres: "PostgreSQL",
1469
+ sqlserver: "MSSQL"
1470
+ };
1471
+ function Ra(e) {
1472
+ const t = U(e);
1473
+ if (t)
1474
+ return Ne.find(
1475
+ (i) => U(i) === t
1476
+ ) ?? tn[t];
1477
+ }
1478
+ function ja(e, t = {}) {
1479
+ return nn(
1480
+ e
1481
+ ) ? St(e, t) : void 0;
1482
+ }
1483
+ function nn(e) {
1484
+ const t = U(e);
1485
+ if (t.includes("postgres")) return "postgres";
1486
+ if (t.includes("mysql")) return "mysql";
1487
+ if (t.includes("mssql") || t.includes("sqlserver"))
1488
+ return "mssql";
1489
+ if (t.includes("redshift")) return "redshift";
1490
+ if (t.includes("snowflake")) return "snowflake";
1491
+ if (t.includes("clickhouse")) return "clickhouse";
1492
+ if (t === "s3" || t === "api" || t === "googlesheets" || t === "fileupload" || t === "bigquery")
1493
+ return t;
1494
+ }
1495
+ function Ca(e) {
1496
+ const t = U(e);
1497
+ switch (t) {
1498
+ case "mysql":
1499
+ case "bigquery":
1500
+ case "redshift":
1501
+ case "snowflake":
1502
+ case "clickhouse":
1503
+ case "duckdb":
1504
+ case "sqlite":
1505
+ return t;
1506
+ case "mssql":
1507
+ case "sqlserver":
1508
+ return "mssql";
1509
+ case "postgres":
1510
+ case "postgresql":
1511
+ return "postgres";
1512
+ default:
1513
+ return "unknown";
1514
+ }
1515
+ }
1516
+ function Ya(e) {
1517
+ return e.capabilities.prefixLevels.every(
1518
+ (t) => !!T(e.source, t)
1519
+ );
1520
+ }
1521
+ function Oa(e) {
1522
+ const t = e.quoteIdentifier ?? on;
1523
+ return e.capabilities.prefixLevels.map((i) => T(e.source, i)).filter((i) => !!i).map((i) => t(i, e.capabilities.dialect)).join(".");
1524
+ }
1525
+ function T(e, t) {
1526
+ return t === "database" ? e.databaseName : t === "schema" ? e.schemaName : e.tableName;
1527
+ }
1528
+ function an(e, t, i) {
1529
+ t === "database" ? e.databaseName = i : t === "schema" ? e.schemaName = i : e.tableName = i;
1530
+ }
1531
+ const sn = [
1532
+ ['"', '"'],
1533
+ ["`", "`"],
1534
+ ["[", "]"]
1535
+ ];
1536
+ function rn(e) {
1537
+ const t = e.trim();
1538
+ for (const [i, n] of sn)
1539
+ if (t.length >= 2 && t.startsWith(i) && t.endsWith(n))
1540
+ return t.slice(1, -1).split(n + n).join(n);
1541
+ return t;
1542
+ }
1543
+ function wt(e) {
1544
+ const t = e == null ? void 0 : e.trim();
1545
+ if (!t) return [];
1546
+ const i = t.split(".").map(rn);
1547
+ return i.some((n) => !n) ? [] : i;
1548
+ }
1549
+ function La(e) {
1550
+ const t = wt(e ?? void 0);
1551
+ return t[t.length - 1] || "";
1552
+ }
1553
+ function on(e, t) {
1554
+ return t === "mysql" || t === "bigquery" || t === "clickhouse" || t === "duckdb" ? `\`${e.replace(/`/g, "``")}\`` : t === "mssql" ? `[${e.replace(/]/g, "]]")}]` : `"${e.replace(/"/g, '""')}"`;
1555
+ }
1556
+ function U(e) {
1557
+ if (typeof e != "string")
1558
+ return "";
1559
+ const t = [];
1560
+ for (const i of e.trim().toLowerCase())
1561
+ dn(i) && t.push(i);
1562
+ return t.join("");
1563
+ }
1564
+ function dn(e) {
1565
+ const t = e.charCodeAt(0);
1566
+ return t >= 48 && t <= 57 || t >= 97 && t <= 122;
1567
+ }
1568
+ const k = a.string().min(1), Ue = a.enum(["groupby", "metric", "sortby", "pivotby", "detail"]), kt = a.enum([
1569
+ "table",
1570
+ "view",
1571
+ "materialized view",
1572
+ "model",
1573
+ "file",
1574
+ "dataset",
1575
+ "url",
1576
+ "upload"
1577
+ ]), le = a.object({
1578
+ connectionId: k,
1579
+ connectionType: a.enum(Ne),
1580
+ type: kt,
1581
+ name: k,
1582
+ // Grounded relationship plans retain semantic identity and display metadata.
1583
+ // SQL stays server-resolved; it is not accepted inside a join entity.
1584
+ alias: a.string().optional(),
1585
+ id: k.optional(),
1586
+ domainId: k.optional(),
1587
+ datasetType: a.enum(["physical", "virtual"]).optional(),
1588
+ label: a.string().optional(),
1589
+ description: a.string().optional(),
1590
+ dbObjectType: a.string().optional(),
1591
+ database: a.string().optional(),
1592
+ schema: a.string().optional(),
1593
+ dialect: a.enum([
1594
+ "mysql",
1595
+ "postgres",
1596
+ "bigquery",
1597
+ "redshift",
1598
+ "snowflake",
1599
+ "clickhouse",
1600
+ "duckdb",
1601
+ "mssql"
1602
+ ]).optional()
1603
+ }).strict(), te = a.lazy(
1604
+ () => a.object({
1605
+ id: k,
1606
+ name: k,
1607
+ label: a.string(),
1608
+ /** Set when `label` was synthesized from `name`; see `Field.derivedLabel`. */
1609
+ derivedLabel: a.string().optional(),
1610
+ qualifiedFieldName: k,
1611
+ dataType: k,
1612
+ entityId: k,
1613
+ entityName: k,
1614
+ entityType: kt,
1615
+ alias: a.string().optional(),
1616
+ sourceField: a.string().optional(),
1617
+ source: De.optional(),
1618
+ nativeDataType: a.string().optional(),
1619
+ description: a.string().optional(),
1620
+ qualifiedEntityName: a.string().optional(),
1621
+ dateFormat: a.enum(Zi).optional(),
1622
+ customFormat: a.string().optional(),
1623
+ granularity: pe.optional(),
1624
+ role: Ue.optional(),
1625
+ calculationRepresentation: a.enum(["inline-expression", "manual", "typed-derived"]).optional(),
1626
+ calculatedFieldOrigin: a.object({ id: k, role: Ue.optional() }).strict().optional(),
1627
+ aggregateOrigin: a.enum(["default", "explicit"]).optional(),
1628
+ labelOrigin: a.enum(["semantic", "override"]).optional(),
1629
+ formatOrigin: a.enum(["semantic", "override"]).optional(),
1630
+ expression: a.string().optional(),
1631
+ derivedField: $e.optional(),
1632
+ format: K.optional(),
1633
+ semanticTemporalPresentation: a.object({
1634
+ granularity: pe,
1635
+ format: zt
1636
+ }).strict().optional(),
1637
+ aggregate: tt.optional(),
1638
+ fieldScope: a.enum(["card", "sheet", "dashboard", "domain"]).optional(),
1639
+ calculatedFormula: a.object({
1640
+ operation: a.enum([
1641
+ "sum",
1642
+ "difference",
1643
+ "product",
1644
+ "ratio",
1645
+ "change",
1646
+ "percentage",
1647
+ "scale",
1648
+ "custom"
1649
+ ]),
1650
+ inputFields: a.array(te),
1651
+ constant: a.number().finite().optional(),
1652
+ computeStage: a.enum(["row", "aggregate"]).optional()
1653
+ }).strict().optional()
1654
+ }).strict()
1655
+ ), ln = a.union([
1656
+ a.string(),
1657
+ a.number().finite(),
1658
+ a.boolean(),
1659
+ a.date(),
1660
+ a.null()
1661
+ ]), un = a.object({
1662
+ id: k,
1663
+ field: te,
1664
+ operator: a.enum([
1665
+ "=",
1666
+ "!=",
1667
+ ">",
1668
+ ">=",
1669
+ "<",
1670
+ "<=",
1671
+ "contains",
1672
+ "startsWith",
1673
+ "endsWith",
1674
+ "like",
1675
+ "not like",
1676
+ "in",
1677
+ "not in",
1678
+ "between",
1679
+ "not between",
1680
+ "isNull",
1681
+ "isNotNull"
1682
+ ]),
1683
+ value: a.union([ln, a.array(a.string()), a.array(a.number().finite())]),
1684
+ label: a.string().optional(),
1685
+ temporalBucket: Qt.optional(),
1686
+ rawTemporal: Gt.optional(),
1687
+ relativeMeta: pi.optional(),
1688
+ latestValue: a.literal(!0).optional(),
1689
+ latestValuePolicy: a.literal("snapshot").optional()
1690
+ }).strict().superRefine((e, t) => {
1691
+ const { operator: i, value: n } = e;
1692
+ if ((i === "between" || i === "not between") && (!Array.isArray(n) || n.length !== 2) && t.addIssue({
1693
+ code: "custom",
1694
+ path: ["value"],
1695
+ message: "Between requires two endpoints."
1696
+ }), e.relativeMeta && !si(i) && t.addIssue({
1697
+ code: "custom",
1698
+ path: ["relativeMeta"],
1699
+ message: "A relative date requires between or not between."
1700
+ }), e.latestValue) {
1701
+ const s = [e.field.nativeDataType, e.field.dataType].map((r) => Fe(r)).some((r) => r === "date" || r === "datetime");
1702
+ (i !== "=" || !s) && t.addIssue({
1703
+ code: "custom",
1704
+ path: ["latestValue"],
1705
+ message: "Latest value requires = on a date or timestamp field."
1706
+ });
1707
+ }
1708
+ (i === "in" || i === "not in") && !Array.isArray(n) && t.addIssue({
1709
+ code: "custom",
1710
+ path: ["value"],
1711
+ message: "Membership requires an array."
1712
+ });
1713
+ }), At = a.lazy(
1714
+ () => a.object({
1715
+ id: k,
1716
+ logicalOperator: a.enum(["AND", "OR"]),
1717
+ negate: a.boolean(),
1718
+ conditions: a.array(un),
1719
+ groups: a.array(At)
1720
+ }).strict()
1721
+ ), cn = a.object({
1722
+ baseEntity: le,
1723
+ joins: a.array(
1724
+ a.object({
1725
+ id: k,
1726
+ source: le,
1727
+ target: le,
1728
+ joinType: a.enum(["INNER", "LEFT", "RIGHT", "FULL"]),
1729
+ sequence: a.number().int().nonnegative(),
1730
+ autoResolved: a.boolean().optional(),
1731
+ relationshipId: a.string().optional(),
1732
+ relationshipName: a.string().optional(),
1733
+ relationshipCardinality: a.enum(["one_to_one", "one_to_many", "many_to_one", "many_to_many"]).optional(),
1734
+ relationshipTraversalDirection: a.enum(["forward", "reverse"]).optional(),
1735
+ joinKeyGroups: a.array(
1736
+ a.object({
1737
+ id: k,
1738
+ operator: a.enum(["AND", "OR"]),
1739
+ keys: a.array(
1740
+ a.object({
1741
+ id: a.string().optional(),
1742
+ source: te,
1743
+ target: te,
1744
+ operator: a.enum(["=", "!=", ">", ">=", "<", "<="])
1745
+ }).strict()
1746
+ ).min(1)
1747
+ }).strict()
1748
+ ).min(1)
1749
+ }).strict()
1750
+ )
1751
+ }).strict(), S = a.string().uuid(), mn = a.string().min(1), pn = a.number().int().positive().max(Number.MAX_SAFE_INTEGER), fn = a.enum([
1752
+ "SUM",
1753
+ "COUNT",
1754
+ "DISTINCT",
1755
+ "AVG",
1756
+ "MIN",
1757
+ "MAX",
1758
+ "MEDIAN"
1759
+ ]), Dt = Yi.omit({
1760
+ aggregate: !0
1761
+ }), hn = {
1762
+ id: S,
1763
+ field: Dt,
1764
+ grain: pe.optional()
1765
+ }, be = a.object(hn).strict(), gn = a.object({
1766
+ id: S,
1767
+ kind: a.literal("aggregate"),
1768
+ field: Dt,
1769
+ aggregate: fn
1770
+ }).strict(), yn = a.object({
1771
+ id: S,
1772
+ kind: a.literal("calculated"),
1773
+ definition: $e
1774
+ }).strict(), $t = a.discriminatedUnion("kind", [gn, yn]), _n = a.discriminatedUnion("kind", [
1775
+ a.object({ kind: a.literal("member") }).strict(),
1776
+ a.object({
1777
+ kind: a.literal("measure"),
1778
+ measureId: S,
1779
+ oppositePath: N
1780
+ }).strict()
1781
+ ]), bn = {
1782
+ axis: Ee,
1783
+ levelId: S,
1784
+ scope: a.discriminatedUnion("kind", [
1785
+ a.object({ kind: a.literal("level") }).strict(),
1786
+ a.object({ kind: a.literal("branch"), parent: N }).strict()
1787
+ ]),
1788
+ target: _n,
1789
+ direction: a.enum(["asc", "desc"]),
1790
+ nulls: a.enum(["first", "last"])
1791
+ }, xt = a.object(bn).strict(), vn = a.object({
1792
+ id: S,
1793
+ axis: Ee,
1794
+ levelId: S,
1795
+ direction: a.enum(["top", "bottom"]),
1796
+ count: pn,
1797
+ measureId: S,
1798
+ oppositePath: N,
1799
+ others: a.boolean()
1800
+ }).strict(), ue = a.number().finite(), In = a.object({
1801
+ id: S,
1802
+ axis: Ee,
1803
+ levelId: S,
1804
+ measureId: S,
1805
+ operator: a.enum(["=", "!=", ">", ">=", "<", "<=", "between", "not between"]),
1806
+ value: a.union([
1807
+ ue,
1808
+ a.tuple([ue, ue]).readonly()
1809
+ ])
1810
+ }).strict().superRefine((e, t) => {
1811
+ const i = e.operator === "between" || e.operator === "not between";
1812
+ i !== Array.isArray(e.value) ? _(t, ["value"], i ? "A range condition needs a low and a high bound." : "A comparison needs one number.") : i && e.value[0] > e.value[1] && _(t, ["value"], "The low bound must not exceed the high bound.");
1813
+ }), Ft = a.object({
1814
+ source: De,
1815
+ rows: a.array(be).min(1).readonly(),
1816
+ columns: a.array(be).readonly(),
1817
+ measures: a.array($t).min(1).readonly(),
1818
+ filters: At.optional(),
1819
+ joinPlan: cn.optional(),
1820
+ relationshipHint: a.object({ relationshipIds: a.array(mn).optional() }).strict().optional(),
1821
+ sorts: a.array(xt).readonly(),
1822
+ rankings: a.array(vn).readonly(),
1823
+ measureFilters: a.array(In).readonly().optional()
1824
+ }).strict();
1825
+ function Mt(e) {
1826
+ return JSON.stringify([
1827
+ e.axis,
1828
+ e.levelId,
1829
+ e.scope.kind,
1830
+ e.scope.kind === "branch" ? vt(e.scope.parent) : null
1831
+ ]);
1832
+ }
1833
+ function _(e, t, i) {
1834
+ e.addIssue({ code: "custom", path: t, message: i });
1835
+ }
1836
+ function x(e, t, i) {
1837
+ new Set(e).size !== e.length && _(t, i, "Duplicate identity.");
1838
+ }
1839
+ function ie(e, t, i, n, o, s = !1) {
1840
+ i.length > e[t].length && _(n, o, "Path exceeds axis depth."), i.forEach((r, l) => {
1841
+ var c;
1842
+ if (r.levelId !== ((c = e[t][l]) == null ? void 0 : c.id) && _(n, [...o, l], "Path must be an ordered axis prefix."), r.member.kind === "others") {
1843
+ const m = r.member.rankingId;
1844
+ (s || l !== i.length - 1 || !e.rankings.some(
1845
+ (u) => u.id === m && u.others && u.axis === t && u.levelId === r.levelId
1846
+ )) && _(
1847
+ n,
1848
+ [...o, l],
1849
+ "Others must terminate a path at its enabled ranking and cannot be a sort/rank target."
1850
+ );
1851
+ }
1852
+ });
1853
+ }
1854
+ function Et(e, t, i, n) {
1855
+ x(t.map(Mt), i, n), t.forEach((o, s) => {
1856
+ const r = [...n, s], l = e[o.axis].findIndex((c) => c.id === o.levelId);
1857
+ if (l < 0 && _(i, r, "Sort level is not on its axis."), o.scope.kind === "branch" && (ie(
1858
+ e,
1859
+ o.axis,
1860
+ o.scope.parent,
1861
+ i,
1862
+ [...r, "scope", "parent"],
1863
+ !0
1864
+ ), o.scope.parent.length !== l && _(
1865
+ i,
1866
+ r,
1867
+ "Branch sort must name the immediate parent of its level."
1868
+ )), o.target.kind === "measure") {
1869
+ const c = o.target.measureId;
1870
+ e.measures.some((m) => m.id === c) || _(i, r, "Unknown sort measure."), ie(
1871
+ e,
1872
+ o.axis === "rows" ? "columns" : "rows",
1873
+ o.target.oppositePath,
1874
+ i,
1875
+ [...r, "target", "oppositePath"],
1876
+ !0
1877
+ );
1878
+ }
1879
+ });
1880
+ }
1881
+ function X(e, t, i, n) {
1882
+ e && (e.kind !== t.kind || e.kind === "semantic" && t.kind === "semantic" && e.domainId !== t.domainId || e.kind === "physical" && t.kind === "physical" && e.connectionId !== t.connectionId) && _(
1883
+ i,
1884
+ n,
1885
+ "Field source must belong to the same semantic domain or physical connection."
1886
+ );
1887
+ }
1888
+ function ce(e, t, i) {
1889
+ (e.aggregationBehavior === "snapshot" || e.aggregationBehavior === "weighted" || e.aggregationStrategy === "weighted") && _(t, i, "This measure semantic requires a later capability.");
1890
+ }
1891
+ function Nt(e, t) {
1892
+ x(
1893
+ [...e.rows, ...e.columns, ...e.measures].map((s) => s.id),
1894
+ t,
1895
+ []
1896
+ ), x(
1897
+ e.rankings.map((s) => s.id),
1898
+ t,
1899
+ ["rankings"]
1900
+ ), x(
1901
+ e.rankings.map((s) => JSON.stringify([s.axis, s.levelId])),
1902
+ t,
1903
+ ["rankings"]
1904
+ );
1905
+ for (const s of ["rows", "columns"])
1906
+ e[s].forEach((r, l) => {
1907
+ r.grain && r.field.dataType !== void 0 && !["date", "datetime", "unknown"].includes(r.field.dataType) && _(t, [s, l, "grain"], "Grain requires a temporal field.");
1908
+ });
1909
+ const i = [
1910
+ ...e.rows,
1911
+ ...e.columns,
1912
+ ...e.measures.filter((s) => s.kind === "aggregate")
1913
+ ];
1914
+ for (const s of i)
1915
+ if (X(s.field.source, e.source, t, [
1916
+ s.id,
1917
+ "field",
1918
+ "source"
1919
+ ]), s.field.derivedField) {
1920
+ s.field.derivedField.computeStage !== "row" && _(
1921
+ t,
1922
+ [s.id],
1923
+ "Aggregate-stage calculations cannot be grouped or wrapped in an aggregate."
1924
+ ), ce(s.field.derivedField, t, [s.id]);
1925
+ for (const r of Object.values(s.field.derivedField.inputs))
1926
+ X(r.field.source, e.source, t, [s.id, "inputs"]);
1927
+ }
1928
+ for (const s of e.measures)
1929
+ if (s.kind === "calculated") {
1930
+ (s.definition.computeStage !== "aggregate" || s.definition.resultRole !== "measure") && _(
1931
+ t,
1932
+ [s.id],
1933
+ "Calculated measures require aggregate stage and measure role."
1934
+ ), ce(s.definition, t, [s.id]);
1935
+ for (const r of Object.values(s.definition.inputs))
1936
+ X(r.field.source, e.source, t, [
1937
+ s.id,
1938
+ "inputs"
1939
+ ]);
1940
+ }
1941
+ const n = (s) => {
1942
+ const r = (l, c) => {
1943
+ var m, u;
1944
+ if ((l.aggregate || ((m = l.derivedField) == null ? void 0 : m.computeStage) === "aggregate") && _(t, c, "Aggregate/HAVING filters are not supported."), l.derivedField) {
1945
+ ce(l.derivedField, t, c);
1946
+ for (const p of Object.values(l.derivedField.inputs))
1947
+ X(p.field.source, e.source, t, c);
1948
+ }
1949
+ for (const p of ((u = l.calculatedFormula) == null ? void 0 : u.inputFields) ?? [])
1950
+ r(p, c);
1951
+ };
1952
+ for (const l of s.conditions)
1953
+ r(l.field, ["filters", l.id]);
1954
+ s.groups.forEach(n);
1955
+ };
1956
+ if (e.filters && n(e.filters), e.joinPlan) {
1957
+ const s = [
1958
+ e.joinPlan.baseEntity,
1959
+ ...e.joinPlan.joins.flatMap((r) => [r.source, r.target])
1960
+ ];
1961
+ (new Set(s.map((r) => r.connectionId)).size > 1 || e.source.kind === "physical" && s[0].connectionId !== e.source.connectionId) && _(t, ["joinPlan"], "Joins must stay within the source connection."), x(
1962
+ e.joinPlan.joins.map((r) => r.id),
1963
+ t,
1964
+ ["joinPlan", "joins"]
1965
+ );
1966
+ }
1967
+ Et(e, e.sorts, t, ["sorts"]);
1968
+ const o = e.measureFilters ?? [];
1969
+ x(o.map((s) => s.id), t, ["measureFilters"]), x(
1970
+ o.map((s) => JSON.stringify([s.axis, s.levelId])),
1971
+ t,
1972
+ ["measureFilters"]
1973
+ ), o.forEach((s, r) => {
1974
+ (!e[s.axis].some((l) => l.id === s.levelId) || !e.measures.some((l) => l.id === s.measureId)) && _(t, ["measureFilters", r], "Unknown measure filter level or measure.");
1975
+ }), e.rankings.forEach((s, r) => {
1976
+ (!e[s.axis].some((l) => l.id === s.levelId) || !e.measures.some((l) => l.id === s.measureId)) && _(t, ["rankings", r], "Unknown ranking level or measure."), ie(
1977
+ e,
1978
+ s.axis === "rows" ? "columns" : "rows",
1979
+ s.oppositePath,
1980
+ t,
1981
+ ["rankings", r, "oppositePath"],
1982
+ !0
1983
+ );
1984
+ });
1985
+ }
1986
+ const H = Ft.superRefine(Nt), Sn = Ft.extend({
1987
+ rows: a.array(be).readonly(),
1988
+ measures: a.array($t).readonly()
1989
+ }), wn = Sn.superRefine(Nt), kn = H.innerType().extend({ kind: a.literal("matrix") }), An = kn.superRefine(({ kind: e, ...t }, i) => {
1990
+ const n = H.safeParse(t);
1991
+ n.success || n.error.issues.forEach((o) => i.addIssue(o));
1992
+ }), Dn = "{member}", Ve = a.object({
1993
+ visible: a.boolean(),
1994
+ position: a.enum(["before", "after"]),
1995
+ /** As written; a subtotal's `{member}` becomes its member's name. */
1996
+ label: a.string().optional()
1997
+ }).strict(), He = a.object({
1998
+ grand: Ve,
1999
+ levels: a.record(S, Ve).readonly(),
2000
+ /**
2001
+ * Skip a subtotal that only repeats one row: an expanded group with
2002
+ * exactly one child shows no subtotal. Off when absent.
2003
+ */
2004
+ skipRedundant: a.boolean().optional()
2005
+ }).strict(), $n = {
2006
+ layout: a.discriminatedUnion("kind", [
2007
+ a.object({ kind: a.literal("compact") }).strict(),
2008
+ a.object({ kind: a.literal("tabular"), repeatLabels: a.boolean() }).strict()
2009
+ ]),
2010
+ absence: a.object({ emptyText: a.string(), nullText: a.string() }).strict(),
2011
+ levelLabels: a.record(S, a.string()).readonly(),
2012
+ measureLabels: a.record(S, a.string()).readonly(),
2013
+ levelFormats: a.record(S, K).readonly(),
2014
+ measureFormats: a.record(S, K).readonly(),
2015
+ totals: a.object({ rows: He, columns: He }).strict()
2016
+ }, Te = a.object($n).strict(), xn = a.object({
2017
+ depth: a.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
2018
+ overrides: a.array(
2019
+ a.object({ path: N, expanded: a.boolean() }).strict()
2020
+ ).readonly()
2021
+ }).strict(), ze = xn.superRefine(
2022
+ (e, t) => x(
2023
+ e.overrides.map((i) => vt(i.path)),
2024
+ t,
2025
+ ["overrides"]
2026
+ )
2027
+ ), Fn = { rows: ze, columns: ze }, se = a.object(Fn).strict(), Mn = se.extend({ sorts: a.array(xt).readonly() }).strict(), En = Mn.superRefine(
2028
+ (e, t) => x(e.sorts.map(Mt), t, ["sorts"])
2029
+ );
2030
+ function re(e, t) {
2031
+ var c, m;
2032
+ const { spec: i, presentation: n, defaults: o, session: s } = e, r = new Set([...i.rows, ...i.columns].map((u) => u.id)), l = new Set(i.measures.map((u) => u.id));
2033
+ for (const u of [
2034
+ "levelLabels",
2035
+ "levelFormats",
2036
+ "measureLabels",
2037
+ "measureFormats"
2038
+ ]) {
2039
+ const p = u.startsWith("level") ? r : l;
2040
+ for (const f of Object.keys(n[u]))
2041
+ p.has(f) || _(
2042
+ t,
2043
+ ["presentation", u, f],
2044
+ "Unknown presentation reference."
2045
+ );
2046
+ }
2047
+ for (const [u, p] of Object.entries(n.measureFormats))
2048
+ p.type === "temporal_bucket" && _(
2049
+ t,
2050
+ ["presentation", "measureFormats", u],
2051
+ "Measures cannot own temporal bucket formats."
2052
+ );
2053
+ for (const [u, p] of Object.entries(n.levelFormats))
2054
+ p.type === "temporal_bucket" && !((c = [...i.rows, ...i.columns].find((f) => f.id === u)) != null && c.grain) && _(
2055
+ t,
2056
+ ["presentation", "levelFormats", u],
2057
+ "Temporal bucket formats require a grain."
2058
+ );
2059
+ for (const u of ["rows", "columns"]) {
2060
+ (m = n.totals[u].grand.label) != null && m.includes(
2061
+ Dn
2062
+ ) && _(
2063
+ t,
2064
+ ["presentation", "totals", u, "grand", "label"],
2065
+ "The grand total has no member, so its label cannot use {member}."
2066
+ );
2067
+ const p = Object.keys(n.totals[u].levels);
2068
+ (p.length !== i[u].length || p.some((f) => !i[u].some((b) => b.id === f))) && _(
2069
+ t,
2070
+ ["presentation", "totals", u],
2071
+ "Subtotal map must contain exactly the current axis levels."
2072
+ );
2073
+ for (const f of [o, ...s ? [s] : []])
2074
+ for (const b of f[u].overrides)
2075
+ ie(
2076
+ i,
2077
+ u,
2078
+ b.path,
2079
+ t,
2080
+ [u, "overrides"],
2081
+ !0
2082
+ ), b.path.length || _(
2083
+ t,
2084
+ [u, "overrides"],
2085
+ "Use depth to expand/collapse the root."
2086
+ );
2087
+ }
2088
+ s && Et(i, s.sorts, t, ["session", "sorts"]);
2089
+ }
2090
+ const Nn = a.object({
2091
+ spec: H,
2092
+ presentation: Te,
2093
+ defaults: se,
2094
+ session: En.optional()
2095
+ }).strict(), Pa = Nn.superRefine(re), Tn = a.object({
2096
+ version: a.literal(1),
2097
+ spec: H,
2098
+ presentation: Te,
2099
+ defaultView: se
2100
+ }).strict(), Rn = Tn.superRefine(
2101
+ (e, t) => re({ ...e, defaults: e.defaultView }, t)
2102
+ ), jn = Rn.innerType().extend({
2103
+ spec: wn
2104
+ }), qa = jn.superRefine((e, t) => re({ ...e, defaults: e.defaultView }, t)), Ge = a.object({ spec: H, presentation: Te }).strict(), Cn = a.union([
2105
+ Ge.extend({
2106
+ mode: a.literal("layout"),
2107
+ format: a.enum(["csv", "xlsx", "pdf"]),
2108
+ expansion: a.union([
2109
+ se.extend({ kind: a.literal("current") }).strict(),
2110
+ a.object({ kind: a.literal("all") }).strict()
2111
+ ])
2112
+ }).strict(),
2113
+ Ge.extend({ mode: a.literal("flat"), format: a.enum(["csv", "xlsx"]) }).strict()
2114
+ ]), Ba = Cn.superRefine(
2115
+ (e, t) => re(
2116
+ {
2117
+ ...e,
2118
+ defaults: e.mode === "layout" && e.expansion.kind === "current" ? e.expansion : {
2119
+ rows: { depth: 0, overrides: [] },
2120
+ columns: { depth: 0, overrides: [] }
2121
+ }
2122
+ },
2123
+ t
2124
+ )
2125
+ );
2126
+ function Wa(e) {
2127
+ return e && "id" in e ? e.id : void 0;
2128
+ }
2129
+ const Yn = "SUM";
2130
+ function D(e) {
2131
+ return typeof e == "string" && e.trim().length > 0;
2132
+ }
2133
+ function P(e) {
2134
+ return D(e) ? e.trim().toLowerCase() : "";
2135
+ }
2136
+ function Ua(e) {
2137
+ const t = D(e.id) ? e.id.trim() : void 0;
2138
+ if (!t) return;
2139
+ const i = P(t), n = D(e.table) ? e.table.trim() : void 0;
2140
+ if (!(i === P(e.name) || n && i === P(n)))
2141
+ return t;
2142
+ }
2143
+ function R(e) {
2144
+ const t = D(e.datasetId) ? e.datasetId.trim() : void 0;
2145
+ if (t)
2146
+ return P(t) === P(e.datasetName) ? void 0 : t;
2147
+ }
2148
+ function Tt(e) {
2149
+ if (e.kind !== "semantic") return e;
2150
+ const t = R(e), { datasetId: i, ...n } = e;
2151
+ return {
2152
+ ...n,
2153
+ ...t ? { datasetId: t } : {}
2154
+ };
2155
+ }
2156
+ function Va(e) {
2157
+ return e ? e.kind === "semantic" ? !!(D(e.domainId) && (D(e.datasetId) || D(e.datasetName))) : e.kind === "physical" ? D(e.connectionId) && D(e.tableName) : D(e.connectionId) : !1;
2158
+ }
2159
+ function ve(e) {
2160
+ if (!e)
2161
+ return "";
2162
+ if (e.kind === "semantic") {
2163
+ const t = R(e);
2164
+ return [
2165
+ e.kind,
2166
+ e.domainId,
2167
+ t ? `datasetId:${t}` : `datasetName:${e.datasetName}`
2168
+ ].join(":");
2169
+ }
2170
+ return e.kind === "physical" ? [
2171
+ e.kind,
2172
+ e.connectionId,
2173
+ e.databaseName || "",
2174
+ e.schemaName || "",
2175
+ e.tableName
2176
+ ].join(":") : [
2177
+ e.kind,
2178
+ e.connectionId,
2179
+ e.dialect || "",
2180
+ e.label || ""
2181
+ ].join(":");
2182
+ }
2183
+ function Re(e, t) {
2184
+ if (!e || !t)
2185
+ return e === t;
2186
+ if (e.kind !== t.kind)
2187
+ return !1;
2188
+ if (e.kind === "semantic" && t.kind === "semantic") {
2189
+ if (e.domainId !== t.domainId)
2190
+ return !1;
2191
+ const i = R(e), n = R(t);
2192
+ return i && n ? i === n : e.datasetName === t.datasetName;
2193
+ }
2194
+ return ve(e) === ve(t);
2195
+ }
2196
+ function Rt(e, t) {
2197
+ return e.kind !== "semantic" || t.kind !== "semantic" ? e : Tt({
2198
+ ...e,
2199
+ datasetName: e.datasetName || t.datasetName,
2200
+ datasetId: R(e) || R(t),
2201
+ label: e.label || t.label,
2202
+ connectionId: e.connectionId || t.connectionId
2203
+ });
2204
+ }
2205
+ function Ha(e) {
2206
+ const t = [];
2207
+ for (const i of e) {
2208
+ const n = Tt(
2209
+ i
2210
+ ), o = t.findIndex(
2211
+ (s) => Re(s, n)
2212
+ );
2213
+ if (o === -1) {
2214
+ t.push(n);
2215
+ continue;
2216
+ }
2217
+ t[o] = Rt(
2218
+ t[o],
2219
+ n
2220
+ );
2221
+ }
2222
+ return t;
2223
+ }
2224
+ function On(e, t) {
2225
+ return e.name === t.name && Re(e.source, t.source);
2226
+ }
2227
+ function za(e) {
2228
+ return [
2229
+ e.source ? ve(e.source) : "unknown",
2230
+ jt(e),
2231
+ e.name
2232
+ ].filter(Boolean).join(":");
2233
+ }
2234
+ function jt(e) {
2235
+ return Ln(
2236
+ e.aggregate || Yn
2237
+ );
2238
+ }
2239
+ function Ln(e) {
2240
+ return e.trim().toUpperCase();
2241
+ }
2242
+ function Ga(e, t) {
2243
+ return {
2244
+ ...e,
2245
+ label: e.label || t.label,
2246
+ role: e.role || t.role,
2247
+ dataType: e.dataType || t.dataType,
2248
+ source: e.source && t.source ? Rt(e.source, t.source) : e.source || t.source
2249
+ };
2250
+ }
2251
+ function Pn(e) {
2252
+ for (let t = 0; t < e.length; t += 1) {
2253
+ const i = e[t];
2254
+ if (e.some(
2255
+ (n, o) => o !== t && Yt(n, i)
2256
+ ))
2257
+ return !1;
2258
+ }
2259
+ return !0;
2260
+ }
2261
+ function Ct(e, t) {
2262
+ return On(e, t);
2263
+ }
2264
+ function Yt(e, t) {
2265
+ return Ct(e, t) && V(e) === V(t);
2266
+ }
2267
+ function qn(e) {
2268
+ return `Metric intent has duplicate measure "${e.name}" with the same aggregate (${V(e)}). Use different aggregates to request both, or remove one entry.`;
2269
+ }
2270
+ function Qe(e) {
2271
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
2272
+ }
2273
+ function Bn(e, t, i) {
2274
+ if (e !== void 0) {
2275
+ if (!e || typeof e != "object" || Array.isArray(e)) {
2276
+ i.push(
2277
+ d(
2278
+ "invalid_sql_default_parameters",
2279
+ "SQL defaultParameters must be an object keyed by parameter name.",
2280
+ t
2281
+ )
2282
+ );
2283
+ return;
2284
+ }
2285
+ Object.entries(e).forEach(([n, o]) => {
2286
+ if (!n.trim()) {
2287
+ i.push(
2288
+ d(
2289
+ "invalid_sql_default_parameter_name",
2290
+ "SQL defaultParameters names must be non-empty strings.",
2291
+ `${t}.${n}`
2292
+ )
2293
+ );
2294
+ return;
2295
+ }
2296
+ (Array.isArray(o) ? o.every(Qe) : Qe(o)) || i.push(
2297
+ d(
2298
+ "invalid_sql_default_parameter_value",
2299
+ "SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",
2300
+ `${t}.${n}`
2301
+ )
2302
+ );
2303
+ });
2304
+ }
2305
+ }
2306
+ function Wn(e, t) {
2307
+ return je(e, t).length === 1;
2308
+ }
2309
+ function Un(e, t) {
2310
+ return je(e, t).length === 1;
2311
+ }
2312
+ function je(e, t) {
2313
+ return t.filter(
2314
+ (n) => Vn(e, n)
2315
+ );
2316
+ }
2317
+ function Vn(e, t) {
2318
+ return Hn(e, t) ? e.source ? Ct(t, e) : !0 : !1;
2319
+ }
2320
+ function Hn(e, t) {
2321
+ return !(t.name !== e.name || e.role !== void 0 && t.role !== void 0 && t.role !== e.role || zn(e, t) && V(t) !== V(e));
2322
+ }
2323
+ function zn(e, t) {
2324
+ return e.role === "measure" || t.role === "measure" || e.aggregate !== void 0 || t.aggregate !== void 0;
2325
+ }
2326
+ function V(e) {
2327
+ return jt(e);
2328
+ }
2329
+ const Gn = /^(\d{4})-(\d{2})-(\d{2})$/, Ot = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})$/;
2330
+ function ne(e) {
2331
+ if (typeof e != "string")
2332
+ return null;
2333
+ const t = e.trim(), i = Gn.exec(t);
2334
+ if (i) {
2335
+ const [, f, b, A] = i;
2336
+ return Xe(f, b, A) ? new Date(Date.UTC(Number(f), Number(b) - 1, Number(A))) : null;
2337
+ }
2338
+ const n = Ot.exec(t);
2339
+ if (!n)
2340
+ return null;
2341
+ const [, o, s, r, l, c, m = "00", , u] = n;
2342
+ if (!Xe(o, s, r) || !q(l, 0, 23) || !q(c, 0, 59) || !q(m, 0, 59) || !Qn(u))
2343
+ return null;
2344
+ const p = new Date(t);
2345
+ return Number.isFinite(p.getTime()) ? p : null;
2346
+ }
2347
+ function Qa(e) {
2348
+ return typeof e != "string" || !Ot.test(e.trim()) ? null : ne(e);
2349
+ }
2350
+ function Xe(e, t, i) {
2351
+ const n = Number(e), o = Number(t), s = Number(i);
2352
+ if (!Number.isInteger(n) || !Number.isInteger(o) || !Number.isInteger(s) || o < 1 || o > 12)
2353
+ return !1;
2354
+ const r = new Date(Date.UTC(n, o - 1, s));
2355
+ return r.getUTCFullYear() === n && r.getUTCMonth() === o - 1 && r.getUTCDate() === s;
2356
+ }
2357
+ function q(e, t, i) {
2358
+ const n = Number(e);
2359
+ return Number.isInteger(n) && n >= t && n <= i;
2360
+ }
2361
+ function Qn(e) {
2362
+ if (e === "Z")
2363
+ return !0;
2364
+ const t = /^([+-])(\d{2}):(\d{2})$/.exec(e);
2365
+ return !!(t && q(t[2], 0, 23) && q(t[3], 0, 59));
2366
+ }
2367
+ function Ke(e, t, i) {
2368
+ if (e !== void 0) {
2369
+ if (!g(e)) {
2370
+ i.push(
2371
+ d(
2372
+ "invalid_pagination",
2373
+ "Pagination must be an object with positive integer page and pageSize.",
2374
+ t
2375
+ )
2376
+ );
2377
+ return;
2378
+ }
2379
+ (!Number.isInteger(e.page) || typeof e.page != "number" || e.page < 1) && i.push(
2380
+ d(
2381
+ "invalid_pagination_page",
2382
+ "Pagination page must be a positive integer.",
2383
+ `${t}.page`
2384
+ )
2385
+ ), (!Number.isInteger(e.pageSize) || typeof e.pageSize != "number" || e.pageSize < 1) && i.push(
2386
+ d(
2387
+ "invalid_pagination_page_size",
2388
+ "Pagination pageSize must be a positive integer.",
2389
+ `${t}.pageSize`
2390
+ )
2391
+ );
2392
+ }
2393
+ }
2394
+ function Ze(e) {
2395
+ const t = /* @__PURE__ */ new Set();
2396
+ for (const i of e) {
2397
+ if (t.has(i))
2398
+ return i;
2399
+ t.add(i);
2400
+ }
2401
+ return null;
2402
+ }
2403
+ function Xn(e, t, i) {
2404
+ if (!g(e)) {
2405
+ i.push(
2406
+ d(
2407
+ "invalid_input_binding",
2408
+ "Input bindings must be structured objects.",
2409
+ t
2410
+ )
2411
+ );
2412
+ return;
2413
+ }
2414
+ h(e.inputId) || i.push(
2415
+ d(
2416
+ "invalid_input_binding",
2417
+ "Input bindings need a non-empty inputId.",
2418
+ `${t}.inputId`
2419
+ )
2420
+ ), e.kind !== void 0 && e.kind !== "filter" && e.kind !== "control" && i.push(
2421
+ d(
2422
+ "invalid_input_binding",
2423
+ "Input binding kind must be filter or control.",
2424
+ `${t}.kind`
2425
+ )
2426
+ ), e.field !== void 0 && I(e.field, `${t}.field`, i), e.relationshipHint !== void 0 && Ce(
2427
+ e.relationshipHint,
2428
+ `${t}.relationshipHint`,
2429
+ i
2430
+ );
2431
+ }
2432
+ function Ce(e, t, i) {
2433
+ if (!g(e)) {
2434
+ i.push(
2435
+ d(
2436
+ "invalid_relationship_hint",
2437
+ "Relationship hints must be structured objects.",
2438
+ t
2439
+ )
2440
+ );
2441
+ return;
2442
+ }
2443
+ e.relationshipIds !== void 0 && (!Array.isArray(e.relationshipIds) || e.relationshipIds.some((n) => !h(n))) && i.push(
2444
+ d(
2445
+ "invalid_relationship_hint",
2446
+ "Relationship hint relationshipIds must be non-empty strings.",
2447
+ `${t}.relationshipIds`
2448
+ )
2449
+ );
2450
+ }
2451
+ function Kn(e, t) {
2452
+ var n, o;
2453
+ if (((n = e.source) == null ? void 0 : n.kind) !== "semantic" && ((o = e.source) == null ? void 0 : o.kind) !== "physical" && t.push(
2454
+ d(
2455
+ "invalid_input_options_source",
2456
+ "Input options must use a semantic or physical source.",
2457
+ "source"
2458
+ )
2459
+ ), h(e.inputId) || t.push(
2460
+ d(
2461
+ "missing_input_options_input_id",
2462
+ "Input options intent needs the inputId it populates.",
2463
+ "inputId"
2464
+ )
2465
+ ), e.search !== void 0 && typeof e.search != "string" && t.push(
2466
+ d(
2467
+ "invalid_input_options_search",
2468
+ "Input options search must be a string.",
2469
+ "search"
2470
+ )
2471
+ ), e.matchValues !== void 0) {
2472
+ const s = Zt(e.matchValues);
2473
+ s.ok || t.push(
2474
+ d("invalid_input_options_match_values", s.error, "matchValues")
2475
+ ), typeof e.search == "string" && e.search.trim() && t.push(
2476
+ d(
2477
+ "invalid_input_options_match_values",
2478
+ "Input options matchValues cannot be combined with search.",
2479
+ "matchValues"
2480
+ )
2481
+ );
2482
+ }
2483
+ if (e.limit !== void 0 && (typeof e.limit != "number" || !Number.isFinite(e.limit) || !Number.isInteger(e.limit) || e.limit <= 0) && t.push(
2484
+ d(
2485
+ "invalid_input_options_limit",
2486
+ "Input options limit must be a positive finite number.",
2487
+ "limit"
2488
+ )
2489
+ ), (!e.labelField || !h(e.labelField.name)) && t.push(
2490
+ d(
2491
+ "missing_input_options_label_field",
2492
+ "Input options intent needs a labelField.",
2493
+ "labelField"
2494
+ )
2495
+ ), I(e.labelField, "labelField", t, {
2496
+ required: !0
2497
+ }), (!e.valueField || !h(e.valueField.name)) && t.push(
2498
+ d(
2499
+ "missing_input_options_value_field",
2500
+ "Input options intent needs a valueField.",
2501
+ "valueField"
2502
+ )
2503
+ ), I(e.valueField, "valueField", t, {
2504
+ required: !0
2505
+ }), e.searchField !== void 0 && I(e.searchField, "searchField", t, {
2506
+ required: !0
2507
+ }), e.disambiguationFields !== void 0 && (Array.isArray(e.disambiguationFields) ? e.disambiguationFields.forEach((s, r) => {
2508
+ I(s, `disambiguationFields.${r}`, t, {
2509
+ required: !0
2510
+ });
2511
+ }) : t.push(
2512
+ d(
2513
+ "invalid_input_options_disambiguation_fields",
2514
+ "Input options disambiguationFields must be an array of field refs.",
2515
+ "disambiguationFields"
2516
+ )
2517
+ )), [
2518
+ { field: e.labelField, path: "labelField" },
2519
+ { field: e.valueField, path: "valueField" },
2520
+ ...e.searchField ? [{ field: e.searchField, path: "searchField" }] : [],
2521
+ ...Array.isArray(e.disambiguationFields) ? e.disambiguationFields.map((s, r) => ({
2522
+ field: s,
2523
+ path: `disambiguationFields.${r}`
2524
+ })) : []
2525
+ ].forEach(({ field: s, path: r }) => {
2526
+ s != null && s.source && !Re(s.source, e.source) && t.push(
2527
+ d(
2528
+ "input_options_field_source_mismatch",
2529
+ "Input option fields must belong to the declared option source.",
2530
+ `${r}.source`
2531
+ )
2532
+ );
2533
+ }), e.dependencies !== void 0) {
2534
+ const s = Jn(
2535
+ e.dependencies
2536
+ );
2537
+ t.push(...s.errors), s.ok && ta(e, t);
2538
+ }
2539
+ if (e.population !== void 0) {
2540
+ const s = e.population;
2541
+ if (!g(s))
2542
+ t.push(
2543
+ d(
2544
+ "invalid_input_options_population",
2545
+ "Input options population must be a structured object.",
2546
+ "population"
2547
+ )
2548
+ );
2549
+ else {
2550
+ const r = s.kind;
2551
+ r !== "option_source" && r !== "related_population" && t.push(
2552
+ d(
2553
+ "invalid_input_options_population",
2554
+ "Input options population kind must be option_source or related_population.",
2555
+ "population.kind"
2556
+ )
2557
+ ), r === "option_source" && s.baseSource !== void 0 && t.push(
2558
+ d(
2559
+ "invalid_input_options_population",
2560
+ "Input options population baseSource is only valid for related_population.",
2561
+ "population.baseSource"
2562
+ )
2563
+ ), r === "option_source" && s.relationshipHint !== void 0 && t.push(
2564
+ d(
2565
+ "invalid_input_options_population",
2566
+ "Input options population relationshipHint is only valid for related_population.",
2567
+ "population.relationshipHint"
2568
+ )
2569
+ ), r === "related_population" && (we(
2570
+ s.baseSource,
2571
+ "population.baseSource",
2572
+ t
2573
+ ), s.relationshipHint !== void 0 && Ce(
2574
+ s.relationshipHint,
2575
+ "population.relationshipHint",
2576
+ t
2577
+ ));
2578
+ }
2579
+ }
2580
+ }
2581
+ function Zn(e, t) {
2582
+ if (!(!("inputs" in e) || e.inputs === void 0)) {
2583
+ if (!Array.isArray(e.inputs)) {
2584
+ t.push(
2585
+ d(
2586
+ "invalid_input_binding",
2587
+ "Analytics intent inputs must be an array of input bindings.",
2588
+ "inputs"
2589
+ )
2590
+ );
2591
+ return;
2592
+ }
2593
+ e.inputs.forEach(
2594
+ (i, n) => Xn(i, `inputs.${n}`, t)
2595
+ );
2596
+ }
2597
+ }
2598
+ function Jn(e, t = "protocol") {
2599
+ const i = [];
2600
+ if (!g(e))
2601
+ return i.push(
2602
+ d(
2603
+ "invalid_input_options_dependencies",
2604
+ "Input options dependencies must be a structured object.",
2605
+ "dependencies"
2606
+ )
2607
+ ), { ok: !1, errors: i, warnings: [] };
2608
+ const n = e, o = n.mode;
2609
+ if (o !== void 0 && o !== "independent" && o !== "explicit" && o !== "all_applicable" && i.push(
2610
+ d(
2611
+ "invalid_input_options_dependencies",
2612
+ "Input options dependencies mode must be independent, explicit, or all_applicable.",
2613
+ "dependencies.mode"
2614
+ )
2615
+ ), me(
2616
+ n.includeInputIds,
2617
+ "dependencies.includeInputIds",
2618
+ i,
2619
+ "Input options includeInputIds must be non-empty strings."
2620
+ ), me(
2621
+ n.excludeInputIds,
2622
+ "dependencies.excludeInputIds",
2623
+ i,
2624
+ "Input options excludeInputIds must be non-empty strings."
2625
+ ), o === "all_applicable" && n.includeInputIds !== void 0 && i.push(
2626
+ d(
2627
+ "invalid_input_options_dependencies",
2628
+ "All applicable dependencies cannot specify includeInputIds.",
2629
+ "dependencies.includeInputIds"
2630
+ )
2631
+ ), me(
2632
+ n.omitInputIds,
2633
+ "dependencies.omitInputIds",
2634
+ i,
2635
+ "Input options omitInputIds must be non-empty strings."
2636
+ ), Array.isArray(n.omitInputIds)) {
2637
+ const s = new Set(
2638
+ Array.isArray(n.includeInputIds) ? n.includeInputIds : []
2639
+ );
2640
+ (o !== "explicit" || new Set(n.omitInputIds).size !== n.omitInputIds.length || n.omitInputIds.some((r) => !s.has(r))) && i.push(
2641
+ d(
2642
+ "invalid_input_options_dependencies",
2643
+ "A browse override may only omit unique ids from an explicit includeInputIds list.",
2644
+ "dependencies.omitInputIds"
2645
+ )
2646
+ );
2647
+ }
2648
+ return t === "dashboard" && ea(n, i), { ok: i.length === 0, errors: i, warnings: [] };
2649
+ }
2650
+ function ea(e, t) {
2651
+ const { mode: i, includeInputIds: n, excludeInputIds: o } = e;
2652
+ i === void 0 && t.push(
2653
+ d(
2654
+ "invalid_input_options_dependencies",
2655
+ "Dashboard option dependencies must declare a mode.",
2656
+ "dependencies.mode"
2657
+ )
2658
+ );
2659
+ for (const [s, r] of [
2660
+ ["dependencies.includeInputIds", n],
2661
+ ["dependencies.excludeInputIds", o]
2662
+ ])
2663
+ Array.isArray(r) && new Set(r).size !== r.length && t.push(
2664
+ d(
2665
+ "invalid_input_options_dependencies",
2666
+ "Dashboard option dependency input IDs must be unique.",
2667
+ s
2668
+ )
2669
+ );
2670
+ i === "independent" && (n !== void 0 || o !== void 0) && t.push(
2671
+ d(
2672
+ "invalid_input_options_dependencies",
2673
+ "Independent dashboard dependencies cannot specify input IDs.",
2674
+ "dependencies"
2675
+ )
2676
+ ), i === "explicit" && (!Array.isArray(n) || n.length === 0 || o !== void 0) && t.push(
2677
+ d(
2678
+ "invalid_input_options_dependencies",
2679
+ "Explicit dashboard dependencies require included input IDs and cannot specify exclusions.",
2680
+ "dependencies"
2681
+ )
2682
+ );
2683
+ }
2684
+ function ta(e, t) {
2685
+ var o, s, r;
2686
+ const i = new Set(
2687
+ Array.isArray(e.inputs) ? e.inputs.map((l) => g(l) ? l.inputId : void 0).filter((l) => typeof l == "string") : []
2688
+ ), n = new Set(((o = e.dependencies) == null ? void 0 : o.omitInputIds) || []);
2689
+ for (const l of ((s = e.dependencies) == null ? void 0 : s.includeInputIds) || [])
2690
+ !i.has(l) && !n.has(l) && t.push(
2691
+ d(
2692
+ "invalid_input_options_dependencies",
2693
+ `Input options dependency "${l}" is not declared in inputs.`,
2694
+ "dependencies.includeInputIds"
2695
+ )
2696
+ );
2697
+ for (const l of ((r = e.dependencies) == null ? void 0 : r.excludeInputIds) || [])
2698
+ l !== e.inputId && !i.has(l) && t.push(
2699
+ d(
2700
+ "invalid_input_options_dependencies",
2701
+ `Input options dependency exclusion "${l}" is not the populated inputId and is not declared in inputs.`,
2702
+ "dependencies.excludeInputIds"
2703
+ )
2704
+ );
2705
+ }
2706
+ function me(e, t, i, n) {
2707
+ e !== void 0 && (!Array.isArray(e) || e.some((o) => !h(o))) && i.push(d("invalid_input_options_dependencies", n, t));
2708
+ }
2709
+ new Set(Xt);
2710
+ function ia(e, t) {
2711
+ if (e.analysis === void 0)
2712
+ return;
2713
+ if (!g(e.analysis)) {
2714
+ t.push(
2715
+ d(
2716
+ "invalid_measure_analysis",
2717
+ "Metric analysis must be a structured object.",
2718
+ "analysis"
2719
+ )
2720
+ );
2721
+ return;
2722
+ }
2723
+ if (e.analysis.kind !== "period_change") {
2724
+ t.push(
2725
+ d(
2726
+ "invalid_measure_analysis",
2727
+ "Metric analysis kind is not supported.",
2728
+ "analysis.kind"
2729
+ )
2730
+ );
2731
+ return;
2732
+ }
2733
+ e.dateField || t.push(
2734
+ d(
2735
+ "missing_analysis_date_field",
2736
+ "Period-change analysis needs a dateField.",
2737
+ "dateField"
2738
+ )
2739
+ ), e.timeGrain || t.push(
2740
+ d(
2741
+ "missing_analysis_time_grain",
2742
+ "Period-change analysis needs a timeGrain.",
2743
+ "timeGrain"
2744
+ )
2745
+ ), e.analysis.orderBy !== void 0 && e.analysis.orderBy !== "absolute_change" && e.analysis.orderBy !== "positive_change" && e.analysis.orderBy !== "negative_change" && e.analysis.orderBy !== "period" && t.push(
2746
+ d(
2747
+ "invalid_measure_analysis",
2748
+ "Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.",
2749
+ "analysis.orderBy"
2750
+ )
2751
+ );
2752
+ const { timeWindow: i } = e.analysis;
2753
+ i !== void 0 && ae(i, "analysis.timeWindow", t);
2754
+ }
2755
+ function ae(e, t, i) {
2756
+ const n = Se(e, { use: "analysis" });
2757
+ n.ok || i.push(
2758
+ d(
2759
+ "invalid_time_window",
2760
+ ut(n.refusal),
2761
+ n.refusal.path ? `${t}.${n.refusal.path}` : t
2762
+ )
2763
+ );
2764
+ }
2765
+ function Je(e, t, i) {
2766
+ if (e !== void 0) {
2767
+ if (!Array.isArray(e)) {
2768
+ i.push(
2769
+ d(
2770
+ "invalid_analytics_filters",
2771
+ "Analytics filters must be an array.",
2772
+ t
2773
+ )
2774
+ );
2775
+ return;
2776
+ }
2777
+ e.forEach((n, o) => {
2778
+ var c;
2779
+ const s = `${t}.${o}`;
2780
+ if (!g(n)) {
2781
+ i.push(
2782
+ d(
2783
+ "invalid_analytics_filter",
2784
+ "Analytics filter must be a structured object.",
2785
+ s
2786
+ )
2787
+ );
2788
+ return;
2789
+ }
2790
+ const r = n;
2791
+ I(r.field, `${s}.field`, i, {
2792
+ required: !0
2793
+ }), r.scope !== void 0 && r.scope !== "row" && r.scope !== "aggregate" && i.push(
2794
+ d(
2795
+ "invalid_analytics_filter_scope",
2796
+ "Analytics filter scope must be row or aggregate.",
2797
+ `${s}.scope`
2798
+ )
2799
+ ), r.scope === "aggregate" && ((c = r.field) == null ? void 0 : c.role) !== void 0 && r.field.role !== "measure" && i.push(
2800
+ d(
2801
+ "invalid_analytics_filter_scope",
2802
+ "Aggregate-scope analytics filters must target a measure field.",
2803
+ `${s}.scope`
2804
+ )
2805
+ );
2806
+ const l = r.operator === "is_null" || r.operator === "is_not_null";
2807
+ if (r.operator !== void 0 && r.operator !== "=" && r.operator !== "!=" && r.operator !== "in" && r.operator !== "not_in" && r.operator !== "contains" && r.operator !== "not_contains" && r.operator !== "between" && r.operator !== "not_between" && r.operator !== ">" && r.operator !== ">=" && r.operator !== "<" && r.operator !== "<=" && r.operator !== "is_null" && r.operator !== "is_not_null" && i.push(
2808
+ d(
2809
+ "invalid_analytics_filter_operator",
2810
+ "Analytics filter operator is not supported.",
2811
+ `${s}.operator`
2812
+ )
2813
+ ), r.values === void 0 && !l && i.push(
2814
+ d(
2815
+ "missing_analytics_filter_value",
2816
+ "Analytics filter needs values unless it is a null check.",
2817
+ s
2818
+ )
2819
+ ), l && r.values !== void 0) {
2820
+ i.push(
2821
+ d(
2822
+ "invalid_analytics_filter_values",
2823
+ "Null-check analytics filters must not include values.",
2824
+ `${s}.values`
2825
+ )
2826
+ );
2827
+ return;
2828
+ }
2829
+ if (r.values !== void 0 && !Array.isArray(r.values)) {
2830
+ i.push(
2831
+ d(
2832
+ "invalid_analytics_filter_values",
2833
+ "Analytics filter values must be an array when provided.",
2834
+ `${s}.values`
2835
+ )
2836
+ );
2837
+ return;
2838
+ }
2839
+ if (r.values !== void 0) {
2840
+ const m = r.values.length;
2841
+ if (r.operator === "between" || r.operator === "not_between") {
2842
+ m !== 2 && i.push(
2843
+ d(
2844
+ "invalid_analytics_filter_values",
2845
+ "Between analytics filters must include exactly two values.",
2846
+ `${s}.values`
2847
+ )
2848
+ );
2849
+ return;
2850
+ }
2851
+ (r.operator === "contains" || r.operator === "not_contains" || r.operator === "=" || r.operator === "!=" || r.operator === ">" || r.operator === ">=" || r.operator === "<" || r.operator === "<=" || r.operator === void 0) && m !== 1 && i.push(
2852
+ d(
2853
+ "invalid_analytics_filter_values",
2854
+ "Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",
2855
+ `${s}.values`
2856
+ )
2857
+ );
2858
+ }
2859
+ });
2860
+ }
2861
+ }
2862
+ function Lt(e) {
2863
+ var n;
2864
+ const t = [], i = [];
2865
+ if (!e || typeof e != "object")
2866
+ return {
2867
+ ok: !1,
2868
+ errors: [
2869
+ d(
2870
+ "invalid_analytics_intent",
2871
+ "Analytics intent must be a structured object."
2872
+ )
2873
+ ],
2874
+ warnings: i,
2875
+ repairHints: [
2876
+ {
2877
+ code: "invalid_analytics_intent",
2878
+ recommendedNextStep: "Send one structured analytics intent object with kind, source, and required fields."
2879
+ }
2880
+ ]
2881
+ };
2882
+ if (e.kind === "matrix") {
2883
+ const o = An.safeParse(e);
2884
+ return o.success || t.push(...o.error.issues.map((s) => d("invalid_matrix_intent", s.message, s.path.join(".")))), { ok: t.length === 0, errors: t, warnings: i, repairHints: et(t) };
2885
+ }
2886
+ if (e.version !== void 0 && e.version !== 1 && t.push(
2887
+ d(
2888
+ "invalid_version",
2889
+ "Analytics intent version must be 1.",
2890
+ "version"
2891
+ )
2892
+ ), we(e.source, "source", t), na(e, t), Zn(e, t), "relationshipHint" in e && e.relationshipHint !== void 0 && Ce(
2893
+ e.relationshipHint,
2894
+ "relationshipHint",
2895
+ t
2896
+ ), e.kind === "metric") {
2897
+ const o = Array.isArray(e.measures) ? e.measures.filter(
2898
+ (s) => g(s) && h(s.name)
2899
+ ) : [];
2900
+ if (!Array.isArray(e.measures) || e.measures.length === 0 ? t.push(
2901
+ d(
2902
+ "missing_measure",
2903
+ "Metric intent needs at least one measure.",
2904
+ "measures"
2905
+ )
2906
+ ) : e.measures.some(
2907
+ (s) => !g(s) || !h(s.name)
2908
+ ) && t.push(
2909
+ d(
2910
+ "invalid_measure_list",
2911
+ "Metric intent measures must be an array of field references with names.",
2912
+ "measures"
2913
+ )
2914
+ ), o.forEach((s, r) => {
2915
+ I(s, `measures.${r}`, t, {
2916
+ required: !0
2917
+ });
2918
+ }), o.length > 0 && !Pn(o)) {
2919
+ const s = o.find(
2920
+ (r, l) => o.some(
2921
+ (c, m) => m !== l && Yt(c, r)
2922
+ )
2923
+ );
2924
+ s && t.push(
2925
+ d(
2926
+ "duplicate_measure",
2927
+ qn(s),
2928
+ "measures"
2929
+ )
2930
+ );
2931
+ }
2932
+ if (g(e.primaryMeasure) && h(e.primaryMeasure.name) && je(
2933
+ e.primaryMeasure,
2934
+ o
2935
+ ).length > 1 && t.push(
2936
+ d(
2937
+ "ambiguous_primary_measure",
2938
+ "Metric intent primaryMeasure must identify exactly one selected measure.",
2939
+ "primaryMeasure"
2940
+ )
2941
+ ), e.primaryMeasure !== void 0 && (I(e.primaryMeasure, "primaryMeasure", t, {
2942
+ required: !0
2943
+ }), g(e.primaryMeasure) && h(e.primaryMeasure.name) && o.length > 0 && !Wn(
2944
+ e.primaryMeasure,
2945
+ o
2946
+ ) && t.push(
2947
+ d(
2948
+ "invalid_primary_measure",
2949
+ "Metric intent primaryMeasure must match one measure field reference.",
2950
+ "primaryMeasure"
2951
+ )
2952
+ )), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? t.push(
2953
+ d(
2954
+ "invalid_measure_dimensions",
2955
+ "Metric intent dimensions must be an array of field references.",
2956
+ "dimensions"
2957
+ )
2958
+ ) : Array.isArray(e.dimensions) && e.dimensions.some(
2959
+ (s) => !g(s) || !h(s.name)
2960
+ ) && t.push(
2961
+ d(
2962
+ "invalid_measure_dimensions",
2963
+ "Metric intent dimensions must be an array of field references with names.",
2964
+ "dimensions"
2965
+ )
2966
+ ), e.dateField !== void 0 && I(e.dateField, "dateField", t), e.timeWindow !== void 0 && (ae(e.timeWindow, "timeWindow", t), e.dateField || t.push(
2967
+ d(
2968
+ "missing_time_window_date_field",
2969
+ "Metric timeWindow needs a dateField.",
2970
+ "dateField"
2971
+ )
2972
+ )), Je(e.filters, "filters", t), Array.isArray(e.dimensions) && e.dimensions.forEach((s, r) => {
2973
+ I(s, `dimensions.${r}`, t);
2974
+ }), e.orderBy !== void 0) {
2975
+ if (!g(e.orderBy))
2976
+ t.push(
2977
+ d(
2978
+ "invalid_measure_order_by",
2979
+ "Metric intent orderBy must be a structured object.",
2980
+ "orderBy"
2981
+ )
2982
+ );
2983
+ else if (I(e.orderBy.field, "orderBy.field", t, {
2984
+ required: !0
2985
+ }), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && t.push(
2986
+ d(
2987
+ "invalid_measure_order_direction",
2988
+ "Metric intent orderBy direction must be asc or desc.",
2989
+ "orderBy.direction"
2990
+ )
2991
+ ), g(e.orderBy.field) && h(e.orderBy.field.name)) {
2992
+ const s = [
2993
+ ...o,
2994
+ ...e.timeGrain && e.dateField && g(e.dateField) ? [e.dateField] : [],
2995
+ ...Array.isArray(e.dimensions) ? e.dimensions.filter(
2996
+ (r) => g(r) && h(r.name)
2997
+ ) : []
2998
+ ];
2999
+ s.length > 0 && !Un(
3000
+ e.orderBy.field,
3001
+ s
3002
+ ) && t.push(
3003
+ d(
3004
+ "invalid_measure_order_by",
3005
+ "Metric intent orderBy.field must match one selected measure, grouped dateField, or dimension.",
3006
+ "orderBy.field"
3007
+ )
3008
+ );
3009
+ }
3010
+ }
3011
+ ia(e, t);
3012
+ } else if (e.kind === "records") {
3013
+ if (!Array.isArray(e.fields) || e.fields.length === 0 ? t.push(
3014
+ d(
3015
+ "missing_record_fields",
3016
+ "Records intent needs at least one field.",
3017
+ "fields"
3018
+ )
3019
+ ) : e.fields.some(
3020
+ (o) => !g(o) || !h(o.name)
3021
+ ) && t.push(
3022
+ d(
3023
+ "invalid_record_fields",
3024
+ "Records intent fields must be field references with names.",
3025
+ "fields"
3026
+ )
3027
+ ), Array.isArray(e.fields) && e.fields.forEach((o, s) => {
3028
+ I(o, `fields.${s}`, t);
3029
+ }), e.dateField !== void 0 && I(e.dateField, "dateField", t), Ke(e.pagination, "pagination", t), e.timeWindow !== void 0 && (ae(e.timeWindow, "timeWindow", t), e.dateField || t.push(
3030
+ d(
3031
+ "missing_time_window_date_field",
3032
+ "Records timeWindow needs a dateField.",
3033
+ "dateField"
3034
+ )
3035
+ )), Je(e.filters, "filters", t), Array.isArray(e.filters) && e.filters.forEach((o, s) => {
3036
+ g(o) && o.scope === "aggregate" && t.push(
3037
+ d(
3038
+ "unsupported_record_filter_scope",
3039
+ "Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",
3040
+ `filters.${s}.scope`
3041
+ )
3042
+ );
3043
+ }), e.orderBy !== void 0 && (g(e.orderBy) ? (I(e.orderBy.field, "orderBy.field", t, {
3044
+ required: !0
3045
+ }), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && t.push(
3046
+ d(
3047
+ "invalid_record_order_direction",
3048
+ "Records intent orderBy direction must be asc or desc.",
3049
+ "orderBy.direction"
3050
+ )
3051
+ )) : t.push(
3052
+ d(
3053
+ "invalid_record_order_by",
3054
+ "Records intent orderBy must be a structured object.",
3055
+ "orderBy"
3056
+ )
3057
+ )), e.totals !== void 0)
3058
+ if (!g(e.totals))
3059
+ t.push(
3060
+ d(
3061
+ "invalid_records_totals",
3062
+ "Records totals must be a structured server totals request.",
3063
+ "totals"
3064
+ )
3065
+ );
3066
+ else {
3067
+ e.totals.mode !== "server" && t.push(
3068
+ d(
3069
+ "invalid_records_totals",
3070
+ "Records totals mode must be server.",
3071
+ "totals.mode"
3072
+ )
3073
+ );
3074
+ const o = e.totals.measures;
3075
+ !Array.isArray(o) || o.length === 0 ? t.push(
3076
+ d(
3077
+ "missing_records_totals_measures",
3078
+ "Records server totals need at least one measure.",
3079
+ "totals.measures"
3080
+ )
3081
+ ) : o.forEach((s, r) => {
3082
+ I(s, `totals.measures.${r}`, t, {
3083
+ required: !0
3084
+ }), (!g(s) || s.role !== "measure") && t.push(
3085
+ d(
3086
+ "invalid_records_totals_measure",
3087
+ "Records server totals measures must be measure field references.",
3088
+ `totals.measures.${r}.role`
3089
+ )
3090
+ );
3091
+ });
3092
+ }
3093
+ } else e.kind === "inputOptions" ? Kn(e, t) : e.kind === "sql" ? (((n = e.source) == null ? void 0 : n.kind) !== "sql" && t.push(
3094
+ d(
3095
+ "invalid_sql_source",
3096
+ "SQL analytics intent must use a SQL execution source.",
3097
+ "source"
3098
+ )
3099
+ ), h(e.sql) || t.push(
3100
+ d("missing_sql", "SQL analytics intent needs SQL text.", "sql")
3101
+ ), Bn(
3102
+ e.defaultParameters,
3103
+ "defaultParameters",
3104
+ t
3105
+ ), Array.isArray(e.fields) && e.fields.forEach((o, s) => {
3106
+ I(o, `fields.${s}`, t);
3107
+ }), Ke(e.pagination, "pagination", t)) : t.push(
3108
+ d(
3109
+ "invalid_analytics_kind",
3110
+ "Analytics kind is not supported.",
3111
+ "kind"
3112
+ )
3113
+ );
3114
+ return {
3115
+ ok: t.length === 0,
3116
+ errors: t,
3117
+ warnings: i,
3118
+ repairHints: et(t)
3119
+ };
3120
+ }
3121
+ function na(e, t) {
3122
+ if (!(!("derivedFields" in e) || e.derivedFields === void 0)) {
3123
+ if (!Array.isArray(e.derivedFields)) {
3124
+ t.push(
3125
+ d(
3126
+ "invalid_derived_fields",
3127
+ "Analytics intent derivedFields must be an array of derived field definitions.",
3128
+ "derivedFields"
3129
+ )
3130
+ );
3131
+ return;
3132
+ }
3133
+ e.derivedFields.forEach((i, n) => {
3134
+ Ae(
3135
+ i
3136
+ ).errors.forEach((s) => {
3137
+ t.push({
3138
+ ...s,
3139
+ path: s.path ? `derivedFields.${n}.${s.path}` : `derivedFields.${n}`
3140
+ });
3141
+ });
3142
+ });
3143
+ }
3144
+ }
3145
+ function aa(e) {
3146
+ const t = [], i = [];
3147
+ if (!e || typeof e != "object")
3148
+ return {
3149
+ ok: !1,
3150
+ errors: [
3151
+ d(
3152
+ "invalid_operation_intent",
3153
+ "Operation intent must be a structured object."
3154
+ )
3155
+ ],
3156
+ warnings: i,
3157
+ repairHints: [
3158
+ {
3159
+ code: "invalid_operation_intent",
3160
+ recommendedNextStep: "Send one typed operation intent with version, kind, and required operation fields."
3161
+ }
3162
+ ]
3163
+ };
3164
+ if (e.version !== 1 && t.push(
3165
+ d(
3166
+ "invalid_version",
3167
+ "Operation intent version must be 1.",
3168
+ "version"
3169
+ )
3170
+ ), e.kind === "answer_obligations")
3171
+ !Array.isArray(e.obligations) || e.obligations.length === 0 ? t.push(
3172
+ d(
3173
+ "missing_obligations",
3174
+ "Answer-obligations operation intent needs at least one obligation.",
3175
+ "obligations"
3176
+ )
3177
+ ) : e.obligations.forEach((n, o) => {
3178
+ h(n.id) || t.push(
3179
+ d(
3180
+ "missing_obligation_id",
3181
+ "Each analytics obligation needs an id.",
3182
+ `obligations.${o}.id`
3183
+ )
3184
+ ), n.timeWindow !== void 0 && ae(n.timeWindow, `obligations.${o}.timeWindow`, t), h(n.prompt) || t.push(
3185
+ d(
3186
+ "missing_obligation_prompt",
3187
+ "Each analytics obligation needs a prompt.",
3188
+ `obligations.${o}.prompt`
3189
+ )
3190
+ );
3191
+ });
3192
+ else if (e.kind === "dashboard_change") {
3193
+ if (h(e.instruction) || t.push(
3194
+ d(
3195
+ "missing_instruction",
3196
+ "Change operation intent needs an instruction.",
3197
+ "instruction"
3198
+ )
3199
+ ), e.analyticsIntent) {
3200
+ const n = Lt(
3201
+ e.analyticsIntent
3202
+ );
3203
+ t.push(...n.errors), i.push(...n.warnings);
3204
+ }
3205
+ } else
3206
+ t.push(
3207
+ d(
3208
+ "invalid_operation_kind",
3209
+ "Operation intent kind is not supported.",
3210
+ "kind"
3211
+ )
3212
+ );
3213
+ return {
3214
+ ok: t.length === 0,
3215
+ errors: t,
3216
+ warnings: i,
3217
+ repairHints: Pt(t)
3218
+ };
3219
+ }
3220
+ function Xa(e) {
3221
+ const t = [], i = [];
3222
+ if (!e || typeof e != "object")
3223
+ return {
3224
+ ok: !1,
3225
+ errors: [
3226
+ d(
3227
+ "invalid_recovery_plan",
3228
+ "Analytics recovery plan must be a structured object."
3229
+ )
3230
+ ],
3231
+ warnings: i,
3232
+ repairHints: [
3233
+ {
3234
+ code: "invalid_recovery_plan",
3235
+ recommendedNextStep: "Return a typed recovery plan with operationIntent and plannedToolCalls."
3236
+ }
3237
+ ]
3238
+ };
3239
+ e.version !== 1 && t.push(
3240
+ d("invalid_version", "Recovery plan version must be 1.", "version")
3241
+ ), e.kind !== "analytics_recovery_plan" && t.push(
3242
+ d(
3243
+ "invalid_recovery_plan_kind",
3244
+ "Recovery plan kind must be analytics_recovery_plan.",
3245
+ "kind"
3246
+ )
3247
+ );
3248
+ const n = aa(
3249
+ e.operationIntent
3250
+ );
3251
+ return t.push(...n.errors), i.push(...n.warnings), Array.isArray(e.plannedToolCalls) || t.push(
3252
+ d(
3253
+ "invalid_planned_tool_calls",
3254
+ "Recovery plan plannedToolCalls must be an array.",
3255
+ "plannedToolCalls"
3256
+ )
3257
+ ), {
3258
+ ok: t.length === 0,
3259
+ errors: t,
3260
+ warnings: i,
3261
+ repairHints: Pt(t)
3262
+ };
3263
+ }
3264
+ function Pt(e) {
3265
+ return e.map((t) => ({
3266
+ code: t.code,
3267
+ recommendedNextStep: t.code === "missing_obligations" ? "Normalize the user request into one or more typed analytics obligations before recovery planning." : "Correct the operation/recovery contract shape before planning execution."
3268
+ }));
3269
+ }
3270
+ function et(e) {
3271
+ return e.map((t) => {
3272
+ switch (t.code) {
3273
+ case "invalid_matrix_intent":
3274
+ return {
3275
+ code: t.code,
3276
+ recommendedNextStep: `Correct MatrixSpec at ${t.path || "the definition"}: ${t.message} Keep presentation and matrixWindowRequest outside the intent.`
3277
+ };
3278
+ case "missing_source":
3279
+ return {
3280
+ code: t.code,
3281
+ fieldRole: "source",
3282
+ recommendedNextStep: "Provide a semantic, physical, or SQL source before executing analytics."
3283
+ };
3284
+ case "missing_measure":
3285
+ return {
3286
+ code: t.code,
3287
+ fieldRole: "measure",
3288
+ recommendedNextStep: "Choose one exact measure from the grounded schema candidates."
3289
+ };
3290
+ case "missing_record_fields":
3291
+ return {
3292
+ code: t.code,
3293
+ fieldRole: "dimension",
3294
+ recommendedNextStep: "Provide at least one field for the records intent."
3295
+ };
3296
+ case "missing_matrix_rows":
3297
+ return {
3298
+ code: t.code,
3299
+ fieldRole: "dimension",
3300
+ recommendedNextStep: "Choose at least one row axis level for the matrix table."
3301
+ };
3302
+ case "missing_matrix_values":
3303
+ return {
3304
+ code: t.code,
3305
+ fieldRole: "measure",
3306
+ recommendedNextStep: "Choose at least one value field for the matrix table."
3307
+ };
3308
+ case "unsupported_matrix_sql_source":
3309
+ return {
3310
+ code: t.code,
3311
+ fieldRole: "source",
3312
+ recommendedNextStep: "Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."
3313
+ };
3314
+ case "missing_input_options_input_id":
3315
+ return {
3316
+ code: t.code,
3317
+ fieldRole: "input",
3318
+ recommendedNextStep: "Provide the inputId that these option values populate."
3319
+ };
3320
+ case "missing_input_options_label_field":
3321
+ return {
3322
+ code: t.code,
3323
+ fieldRole: "dimension",
3324
+ recommendedNextStep: "Provide the human-readable field used as option labels."
3325
+ };
3326
+ case "missing_input_options_value_field":
3327
+ return {
3328
+ code: t.code,
3329
+ fieldRole: "dimension",
3330
+ recommendedNextStep: "Provide the stable field used as option values."
3331
+ };
3332
+ case "missing_sql":
3333
+ return {
3334
+ code: t.code,
3335
+ fieldRole: "sql",
3336
+ recommendedNextStep: "Provide bounded read-only SQL with an explicit outer LIMIT."
3337
+ };
3338
+ case "conflicting_sql":
3339
+ return {
3340
+ code: t.code,
3341
+ fieldRole: "sql",
3342
+ recommendedNextStep: "Use one canonical SQL text location for the intent; prefer top-level sql."
3343
+ };
3344
+ case "missing_semantic_domain":
3345
+ case "missing_dataset_name":
3346
+ case "missing_connection_id":
3347
+ case "missing_table_name":
3348
+ return {
3349
+ code: t.code,
3350
+ fieldRole: "source",
3351
+ recommendedNextStep: "Use grounded catalog metadata to fill the missing source reference."
3352
+ };
3353
+ default:
3354
+ return;
3355
+ }
3356
+ }).filter((t) => !!t);
3357
+ }
3358
+ function sa(e, t, i, n) {
3359
+ if (!e || typeof e != "object") {
3360
+ i.push(
3361
+ d("invalid_view", "Dashboard view must be an object.", t)
3362
+ );
3363
+ return;
3364
+ }
3365
+ if (h(e.title) || i.push(
3366
+ d("missing_view_title", "Dashboard view needs a title.", t)
3367
+ ), !e.presentation || typeof e.presentation != "object") {
3368
+ i.push(
3369
+ d(
3370
+ "missing_presentation",
3371
+ "Dashboard view needs a presentation.",
3372
+ `${t}.presentation`
3373
+ )
3374
+ );
3375
+ return;
3376
+ }
3377
+ if (e.presentation.kind === "text") {
3378
+ h(e.text) || n.push(
3379
+ d(
3380
+ "missing_text_content",
3381
+ "Text views should include text content.",
3382
+ `${t}.text`
3383
+ )
3384
+ );
3385
+ return;
3386
+ }
3387
+ if (!e.analytics) {
3388
+ i.push(
3389
+ d(
3390
+ "missing_view_analytics",
3391
+ "Non-text dashboard views need analytics intent.",
3392
+ `${t}.analytics`
3393
+ )
3394
+ );
3395
+ return;
3396
+ }
3397
+ e.presentation.kind === "matrixTable" && e.analytics.kind !== "matrix" && i.push(
3398
+ d(
3399
+ "invalid_matrix_view_analytics",
3400
+ "Matrix table views need matrix analytics intent.",
3401
+ `${t}.analytics.kind`
3402
+ )
3403
+ );
3404
+ const o = Lt(e.analytics);
3405
+ for (const s of o.errors)
3406
+ i.push(
3407
+ d(
3408
+ s.code,
3409
+ s.message,
3410
+ `${t}.analytics${s.path ? `.${s.path}` : ""}`
3411
+ )
3412
+ );
3413
+ for (const s of o.warnings)
3414
+ n.push(
3415
+ d(
3416
+ s.code,
3417
+ s.message,
3418
+ `${t}.analytics${s.path ? `.${s.path}` : ""}`
3419
+ )
3420
+ );
3421
+ }
3422
+ function Ka(e) {
3423
+ const t = [], i = [];
3424
+ if (!e || typeof e != "object")
3425
+ return {
3426
+ ok: !1,
3427
+ errors: [
3428
+ d(
3429
+ "invalid_dashboard_intent",
3430
+ "Dashboard intent must be a structured object."
3431
+ )
3432
+ ],
3433
+ warnings: i
3434
+ };
3435
+ e.version !== 1 && t.push(
3436
+ d("invalid_version", "Dashboard intent version must be 1.")
3437
+ ), e.kind !== "dashboard" && t.push(
3438
+ d("invalid_kind", "Experience intent kind must be dashboard.")
3439
+ ), h(e.title) || t.push(
3440
+ d("missing_title", "Dashboard intent needs a title.", "title")
3441
+ );
3442
+ const n = Array.isArray(e.inputs) ? e.inputs : [], o = Ze(
3443
+ n.filter(g).map((c) => c.id).filter((c) => typeof c == "string")
3444
+ );
3445
+ o && t.push(
3446
+ d(
3447
+ "duplicate_input_id",
3448
+ `Duplicate input id: ${o}.`,
3449
+ "inputs"
3450
+ )
3451
+ );
3452
+ for (const [c, m] of n.entries()) {
3453
+ const u = `inputs.${c}`;
3454
+ if (!g(m)) {
3455
+ t.push(
3456
+ d("invalid_input", "Dashboard input must be an object.", u)
3457
+ );
3458
+ continue;
3459
+ }
3460
+ h(m.id) || t.push(
3461
+ d("missing_input_id", "Input needs an id.", `${u}.id`)
3462
+ ), h(m.label) || t.push(
3463
+ d("missing_input_label", "Input needs a label.", `${u}.label`)
3464
+ ), !m.field || !h(m.field.name) ? t.push(
3465
+ d("missing_input_field", "Input needs a field.", `${u}.field`)
3466
+ ) : I(m.field, `${u}.field`, t);
3467
+ }
3468
+ const s = Array.isArray(e.sections) ? e.sections : [];
3469
+ s.length === 0 && t.push(
3470
+ d(
3471
+ "missing_sections",
3472
+ "Dashboard intent needs at least one section.",
3473
+ "sections"
3474
+ )
3475
+ );
3476
+ const r = s.flatMap(
3477
+ (c) => c && typeof c == "object" && Array.isArray(c.views) ? c.views.filter(g).map((m) => m.id).filter((m) => !!m) : []
3478
+ ), l = Ze(r);
3479
+ l && t.push(
3480
+ d(
3481
+ "duplicate_view_id",
3482
+ `Duplicate dashboard view id: ${l}.`,
3483
+ "sections"
3484
+ )
3485
+ );
3486
+ for (const [c, m] of s.entries()) {
3487
+ const u = `sections.${c}`;
3488
+ if (!m || typeof m != "object") {
3489
+ t.push(
3490
+ d(
3491
+ "invalid_section",
3492
+ "Dashboard section must be an object.",
3493
+ u
3494
+ )
3495
+ );
3496
+ continue;
3497
+ }
3498
+ if (h(m.title) || t.push(
3499
+ d(
3500
+ "missing_section_title",
3501
+ "Dashboard section needs a title.",
3502
+ u
3503
+ )
3504
+ ), !Array.isArray(m.views) || m.views.length === 0) {
3505
+ t.push(
3506
+ d(
3507
+ "missing_section_views",
3508
+ "Dashboard section needs at least one view.",
3509
+ `${u}.views`
3510
+ )
3511
+ );
3512
+ continue;
3513
+ }
3514
+ for (const [p, f] of m.views.entries())
3515
+ sa(
3516
+ f,
3517
+ `${u}.views.${p}`,
3518
+ t,
3519
+ i
3520
+ );
3521
+ }
3522
+ return { ok: t.length === 0, errors: t, warnings: i };
3523
+ }
3524
+ export {
3525
+ Xa as $,
3526
+ N as A,
3527
+ Sa as B,
3528
+ ye as C,
3529
+ Zi as D,
3530
+ _n as E,
3531
+ xt as F,
3532
+ vn as G,
3533
+ In as H,
3534
+ Mt as I,
3535
+ H as J,
3536
+ Ve as K,
3537
+ Xi as L,
3538
+ Dn as M,
3539
+ Te as N,
3540
+ ze as O,
3541
+ se as P,
3542
+ En as Q,
3543
+ Pa as R,
3544
+ Rn as S,
3545
+ Ba as T,
3546
+ De as U,
3547
+ Kt as V,
3548
+ Zt as W,
3549
+ ne as X,
3550
+ Jn as Y,
3551
+ Lt as Z,
3552
+ aa as _,
3553
+ ka as a,
3554
+ _a as a$,
3555
+ Ka as a0,
3556
+ Ae as a1,
3557
+ xe as a2,
3558
+ Oi as a3,
3559
+ Li as a4,
3560
+ Fe as a5,
3561
+ Ui as a6,
3562
+ Vi as a7,
3563
+ ht as a8,
3564
+ gt as a9,
3565
+ jt as aA,
3566
+ Ga as aB,
3567
+ si as aC,
3568
+ st as aD,
3569
+ ui as aE,
3570
+ di as aF,
3571
+ da as aG,
3572
+ M as aH,
3573
+ pi as aI,
3574
+ ii as aJ,
3575
+ G as aK,
3576
+ la as aL,
3577
+ Se as aM,
3578
+ ua as aN,
3579
+ ca as aO,
3580
+ ut as aP,
3581
+ ma as aQ,
3582
+ bt as aR,
3583
+ zi as aS,
3584
+ Gi as aT,
3585
+ ba as aU,
3586
+ va as aV,
3587
+ W as aW,
3588
+ ha as aX,
3589
+ An as aY,
3590
+ ie as aZ,
3591
+ li as a_,
3592
+ Be as aa,
3593
+ _t as ab,
3594
+ pa as ac,
3595
+ fa as ad,
3596
+ en as ae,
3597
+ Ma as af,
3598
+ Ea as ag,
3599
+ Na as ah,
3600
+ St as ai,
3601
+ Ne as aj,
3602
+ Ta as ak,
3603
+ Ra as al,
3604
+ ja as am,
3605
+ nn as an,
3606
+ Ca as ao,
3607
+ Ya as ap,
3608
+ Oa as aq,
3609
+ La as ar,
3610
+ Wa as as,
3611
+ Ua as at,
3612
+ R as au,
3613
+ Tt as av,
3614
+ Re as aw,
3615
+ Rt as ax,
3616
+ Ha as ay,
3617
+ za as az,
3618
+ Ji as b,
3619
+ ya as b0,
3620
+ wn as b1,
3621
+ qa as b2,
3622
+ $e as b3,
3623
+ $i as b4,
3624
+ Ue as b5,
3625
+ ga as b6,
3626
+ Jt as b7,
3627
+ It as c,
3628
+ Da as d,
3629
+ Fa as e,
3630
+ _e as f,
3631
+ Ki as g,
3632
+ xa as h,
3633
+ wa as i,
3634
+ Pe as j,
3635
+ Va as k,
3636
+ On as l,
3637
+ vt as m,
3638
+ Aa as n,
3639
+ ve as o,
3640
+ Qa as p,
3641
+ At as q,
3642
+ F as r,
3643
+ $a as s,
3644
+ Ia as t,
3645
+ Ee as u,
3646
+ fn as v,
3647
+ Dt as w,
3648
+ be as x,
3649
+ $t as y,
3650
+ Qi as z
3651
+ };