react-semaphor 0.1.544 → 0.1.546

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 (179) hide show
  1. package/dist/analytics-protocol/index.js +405 -441
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +100 -76
  4. package/dist/brand-studio/index.js +5 -5
  5. package/dist/briefings/index.js +55 -52
  6. package/dist/chunks/{class-utils-Df1OVOT1.js → _commonjsHelpers-DimLPMtv.js} +124 -98
  7. package/dist/chunks/{add-to-dashboard-BuAqfA2Y.js → add-to-dashboard-BQRAAnc3.js} +55 -33
  8. package/dist/chunks/{analytics-base-schemas-BFAoRlkU.js → analytics-base-schemas-BKs3flFS.js} +2 -2
  9. package/dist/chunks/{assistant-chat-BNLkCDml.js → assistant-chat-BPXhulAx.js} +2792 -2562
  10. package/dist/chunks/{bookmark-state-CXw7lZ50.js → bookmark-state-C4vetoa0.js} +7 -8
  11. package/dist/chunks/column-catalog-BYnochWQ.js +3363 -0
  12. package/dist/chunks/comparison-window-caption-C2xF-eWw.js +1433 -0
  13. package/dist/chunks/{context-ClREvqCZ.js → context-BerEBuFR.js} +11 -6
  14. package/dist/chunks/custom-visual-inputs-CkJW9pBS.js +295 -0
  15. package/dist/chunks/{dashboard-g5a4DKWq.js → dashboard-C3CoKbGY.js} +1 -1
  16. package/dist/chunks/dashboard-briefing-launcher-Be4h-7My.js +3734 -0
  17. package/dist/chunks/dashboard-controls-bxPrlSyp.js +2307 -0
  18. package/dist/chunks/{dashboard-json-7qT9jmfL.js → dashboard-json-BrjxIiRt.js} +6 -6
  19. package/dist/chunks/document-dashboard-inputs-CRVHpIHp.js +3010 -0
  20. package/dist/chunks/{edit-dashboard-visual-BfJwnRIZ.js → edit-dashboard-visual-DYYYDjY6.js} +5986 -6063
  21. package/dist/chunks/{filter-value-text-CYsVYPuD.js → filter-value-text-Ddf55Ku1.js} +8 -8
  22. package/dist/chunks/global-date-filter-utils-9d6m9-FE.js +11859 -0
  23. package/dist/chunks/index-CtoK1Lgu.js +586 -0
  24. package/dist/chunks/{index-DkAyQvC6.js → index-DkQkMKa1.js} +385 -339
  25. package/dist/chunks/list-filter-DsaTbM3J.js +15 -0
  26. package/dist/chunks/matrix-analytical-definition-B9vW-osb.js +717 -0
  27. package/dist/chunks/{matrix-card-DjwWcCo8.js → matrix-card-LiMEipvq.js} +3 -3
  28. package/dist/chunks/{matrix-formatter-CxJLkztA.js → matrix-formatter-DWEeC0_c.js} +55 -55
  29. package/dist/chunks/{matrix-member-presentation-CQGdVks6.js → matrix-member-presentation-DqzG-UhQ.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-8OIO4gob.js → matrix-operation-contract-D6vYkZK4.js} +72 -72
  31. package/dist/chunks/{metric-comparison-DEwi9uc2.js → metric-comparison-zpGw4lD6.js} +2 -2
  32. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  33. package/dist/chunks/{pivot-header-presentation-DHcx1XGQ.js → pivot-header-presentation-CQnIDtUv.js} +1 -1
  34. package/dist/chunks/{pivot-result-identity-DJhXXcns.js → pivot-result-identity-C-Q1j1Wb.js} +1 -1
  35. package/dist/chunks/{pivot-result-lifecycle-DM4CyGKs.js → pivot-result-lifecycle-pwq3b7LC.js} +571 -380
  36. package/dist/chunks/{raw-temporal-contract-C51YG48G.js → raw-temporal-contract-WuXA8jBP.js} +1 -1
  37. package/dist/chunks/{raw-temporal-presentation-CLiVi90c.js → raw-temporal-presentation-CBzrDOjM.js} +8 -8
  38. package/dist/chunks/rendered-file-D8xEuVVx.js +108 -0
  39. package/dist/chunks/{report-preferences-dialog-Df7VpRVW.js → report-preferences-dialog-4QEZWe5U.js} +637 -610
  40. package/dist/chunks/{report-runtime-context-Dq8XyODK.js → report-runtime-context-hWiTCzFV.js} +2 -2
  41. package/dist/chunks/resolve-dashboard-input-context-UpK_LBpL.js +5677 -0
  42. package/dist/chunks/{saved-dashboard-context-B-mQ--nV.js → saved-dashboard-context-D_I3Lxk0.js} +184 -212
  43. package/dist/chunks/selection-filter-compiler-BKXmyLrS.js +79 -0
  44. package/dist/chunks/{selection-reducer-Dj_8xD69.js → selection-reducer-CJzkTZio.js} +15 -15
  45. package/dist/chunks/{semaphor-ready-indicator-DDAxk8us.js → semaphor-ready-indicator-4zpRHE-X.js} +56832 -59068
  46. package/dist/chunks/{shelf-drop-preview-context-BSRPwaED.js → shelf-drop-preview-context-Cfw7TRAx.js} +890 -871
  47. package/dist/chunks/{source-entity-resolution-BYn9giz3.js → source-entity-resolution-BIGRvtbG.js} +13 -13
  48. package/dist/chunks/{switch-C3jLxlG0.js → switch-CEBOR4n7.js} +47 -48
  49. package/dist/chunks/{table-export-sheet-CPfGAQ9X.js → table-export-sheet-4X9mAG3V.js} +1 -1
  50. package/dist/chunks/table-settings-CunhoDUi.js +605 -0
  51. package/dist/chunks/{temporal-bucket-D7NBrrtL.js → temporal-bucket-CQOSbv9-.js} +26 -26
  52. package/dist/chunks/{token-types-DBbZVQsm.js → token-types-BMqRmT-C.js} +1 -1
  53. package/dist/chunks/{use-create-flow-overlay-state-BxzFviM-.js → use-create-flow-overlay-state-DZBZiiD-.js} +83 -83
  54. package/dist/chunks/{validators-DMHTpf7a.js → validators-C-aOQlTB.js} +713 -658
  55. package/dist/dashboard/index.js +2 -2
  56. package/dist/dashboard-authoring/index.js +1800 -1135
  57. package/dist/data-app-sdk/index.js +6 -6
  58. package/dist/data-app-sdk-adapters/index.js +3 -3
  59. package/dist/data-app-sdk-validation/index.js +14 -14
  60. package/dist/format-utils/index.js +198 -187
  61. package/dist/index.js +359 -325
  62. package/dist/layouts/index.js +5 -242
  63. package/dist/report-runtime-context/index.js +2 -2
  64. package/dist/shared/index.js +4 -5
  65. package/dist/style.css +1 -1
  66. package/dist/surfboard/index.js +2 -2
  67. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  68. package/dist/types/briefings/attachments.d.ts +33 -6
  69. package/dist/types/briefings/index.d.ts +6 -5
  70. package/dist/types/components/index.d.ts +2 -0
  71. package/dist/types/components/surfboard/arrange-layout-button.d.ts +8 -0
  72. package/dist/types/components/surfboard/filter/types.d.ts +0 -14
  73. package/dist/types/components/surfboard/screen-size-preview-button.d.ts +7 -0
  74. package/dist/types/index.js +6 -6
  75. package/dist/types/lib/charts/table-chart-types.d.ts +4 -0
  76. package/dist/types/lib/charts/types.d.ts +2 -2
  77. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +68 -82
  78. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +0 -8
  79. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +41 -1
  80. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +201 -0
  81. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +15 -0
  82. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +7 -2
  83. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +1 -1
  84. package/dist/types/lib/dashboard-viewer/captured-runtime-values.d.ts +40 -0
  85. package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +16 -16
  86. package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +11 -9
  87. package/dist/types/lib/download-pdf.d.ts +75 -1
  88. package/dist/types/lib/hooks/use-date-filter.d.ts +5 -0
  89. package/dist/types/lib/hooks/use-text-filter.d.ts +5 -0
  90. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +5 -4
  91. package/dist/types/lib/matrix-table/matrix-editor.d.ts +52 -0
  92. package/dist/types/lib/query-context/assemble-card-query.d.ts +158 -0
  93. package/dist/types/lib/query-context/build-card-query-context.d.ts +3 -3
  94. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +15 -6
  95. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +11 -13
  96. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +22 -12
  97. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +69 -0
  98. package/dist/types/lib/stores/dashboard-store.d.ts +159 -56
  99. package/dist/types/lib/stores/editor-store.d.ts +0 -3
  100. package/dist/types/lib/types/common-types.d.ts +29 -6
  101. package/dist/types/lib/types/explorer-types.d.ts +10 -0
  102. package/dist/types/lib/types/semantic-types.d.ts +84 -0
  103. package/dist/types/lib/utils/build-saved-editor-card.d.ts +20 -0
  104. package/dist/types/lib/utils/card-type-change.d.ts +16 -0
  105. package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
  106. package/dist/types/lib/utils/field-placement.d.ts +96 -0
  107. package/dist/types/lib/utils/field-state-calculator.d.ts +161 -0
  108. package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
  109. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +89 -0
  110. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  111. package/dist/types/shared/analytics-protocol/query-policies.d.ts +52 -0
  112. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +1 -1
  113. package/dist/types/shared/analytics-protocol/time-window.d.ts +40 -1
  114. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +8 -12
  115. package/dist/types/shared/assistant-protocol/answer-text.d.ts +20 -0
  116. package/dist/types/shared/assistant-protocol/context.d.ts +21 -21
  117. package/dist/types/shared/assistant-protocol/index.d.ts +1 -0
  118. package/dist/types/shared/assistant-protocol/limits.d.ts +6 -1
  119. package/dist/types/shared/assistant-protocol/parts.d.ts +43 -3
  120. package/dist/types/shared/assistant-protocol/request.d.ts +14 -2
  121. package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +3 -0
  122. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +487 -0
  123. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +34 -0
  124. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +7886 -0
  125. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +43 -0
  126. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +54 -0
  127. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +89 -0
  128. package/dist/types/shared/dashboard-authoring/column-catalog.d.ts +32 -0
  129. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -55
  130. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -6
  131. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +9 -1
  132. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +7 -0
  133. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +118 -0
  134. package/dist/types/shared/dashboard-authoring/filter-applicability.d.ts +75 -0
  135. package/dist/types/shared/dashboard-authoring/filter-model/ad-hoc-filter-values.d.ts +10 -0
  136. package/dist/types/shared/dashboard-authoring/filter-model/filter-definitions.d.ts +29 -0
  137. package/dist/types/shared/dashboard-authoring/filter-model/filter-values.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +7 -0
  139. package/dist/types/shared/dashboard-authoring/filter-model/prototype-document-inputs.d.ts +15 -0
  140. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +78 -0
  141. package/dist/types/shared/dashboard-authoring/filter-model/stored-dashboard.d.ts +18 -0
  142. package/dist/types/shared/dashboard-authoring/filter-model/toolbar-filter-reach.d.ts +23 -0
  143. package/dist/types/shared/dashboard-authoring/index.d.ts +20 -2
  144. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +10 -37
  145. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +189 -0
  146. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +94 -0
  147. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +78 -0
  148. package/dist/types/shared/dashboard-authoring/validators.d.ts +1 -2
  149. package/dist/types/shared/format-utils/exporters/index.d.ts +2 -0
  150. package/dist/types/shared/format-utils/exporters/rendered-file.d.ts +106 -0
  151. package/dist/types/shared/layouts/engine/grid.d.ts +25 -0
  152. package/dist/types/shared/layouts/engine/index.d.ts +4 -0
  153. package/dist/types/shared/layouts/engine/sheet-layout.d.ts +7 -0
  154. package/dist/types/shared/layouts/engine/types.d.ts +125 -0
  155. package/dist/types/shared/layouts/index.d.ts +1 -2
  156. package/package.json +2 -2
  157. package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +0 -28
  158. package/dist/chunks/apply-dashboard-operations-Bz4n1Lq6.js +0 -2260
  159. package/dist/chunks/calendar-day-equality-BmJAWduY.js +0 -460
  160. package/dist/chunks/comparison-window-caption-BTkrN3W4.js +0 -1623
  161. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +0 -323
  162. package/dist/chunks/dashboard-briefing-launcher-DQ_8O_e2.js +0 -3725
  163. package/dist/chunks/dashboard-controls-8RyBTQUO.js +0 -2315
  164. package/dist/chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js +0 -108
  165. package/dist/chunks/document-dashboard-inputs-BC6p-ESg.js +0 -8087
  166. package/dist/chunks/document-sheet-utils-Duo9uLoH.js +0 -3619
  167. package/dist/chunks/matrix-analytical-definition-C7Gb0e12.js +0 -117
  168. package/dist/chunks/normalize-dashboard-for-dirty-check-Bk3VYv_q.js +0 -67
  169. package/dist/chunks/numeric-presentation-DESvLiu9.js +0 -5227
  170. package/dist/chunks/sort-target-MT1WK1vX.js +0 -29
  171. package/dist/chunks/stable-serialize-CfqXeiBP.js +0 -6
  172. package/dist/chunks/table-settings-CLZocegs.js +0 -501
  173. package/dist/chunks/use-debounced-dirty-check-BwAbnX_5.js +0 -59
  174. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +0 -88
  175. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +0 -10
  176. package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +0 -7
  177. package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +0 -2
  178. package/dist/types/shared/layouts/create-frame-layouts.d.ts +0 -27
  179. package/dist/types/shared/layouts/frame-layouts.d.ts +0 -23
@@ -1,210 +1,212 @@
1
- var q = Object.defineProperty;
2
- var B = (e, t, o) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var p = (e, t, o) => B(e, typeof t != "symbol" ? t + "" : t, o);
4
- import { N, O, P as y, q as Y, H as L, E as X, i as Z } from "./temporal-bucket-D7NBrrtL.js";
1
+ var G = Object.defineProperty;
2
+ var Q = (e, t, o) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var h = (e, t, o) => Q(e, typeof t != "symbol" ? t + "" : t, o);
4
+ import { N as q, O as L, P as y, q as ee, H as te, E as oe, i as re, Q as K, f as ne, F as ae, r as ie, M as se, v as ce } from "./temporal-bucket-CQOSbv9-.js";
5
5
  import { z as d } from "zod";
6
- import { E as U, l as P } from "./export-file-format-C-tJsxsf.js";
7
- import { aG as G, r as H, a7 as J, o as b, t as W } from "./validators-DMHTpf7a.js";
8
- import { b as V } from "./report-runtime-context-Dq8XyODK.js";
9
- import { S as Q } from "./analytics-base-schemas-BFAoRlkU.js";
10
- import "./matrix-operation-contract-8OIO4gob.js";
11
- import { r as ee, i as te } from "./metric-comparison-DEwi9uc2.js";
12
- import { d as oe, P as re } from "./pivot-result-identity-DJhXXcns.js";
13
- function nt(e, t) {
14
- const r = ae(e);
6
+ import { E as B, l as Y } from "./export-file-format-C-tJsxsf.js";
7
+ import { aM as le, l as de, X as me, O as T, o as ue } from "./validators-C-aOQlTB.js";
8
+ import { b as fe } from "./report-runtime-context-hWiTCzFV.js";
9
+ import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as pe } from "../value-format-preferences/index.js";
10
+ import { z as ye } from "./zoned-wall-clock-MulfA26h.js";
11
+ import { S as he } from "./analytics-base-schemas-BKs3flFS.js";
12
+ import "./matrix-operation-contract-D6vYkZK4.js";
13
+ import { r as we, i as ge } from "./metric-comparison-zpGw4lD6.js";
14
+ import { d as ve, P as be } from "./pivot-result-identity-C-Q1j1Wb.js";
15
+ function Ot(e, t) {
16
+ const r = Ie(e);
15
17
  let n;
16
18
  if (r.date) {
17
- const l = ce(r.date, 2);
18
- n = le(l.restDateString, l.year);
19
+ const c = Se(r.date, 2);
20
+ n = Ee(c.restDateString, c.year);
19
21
  }
20
22
  if (!n || isNaN(n.getTime()))
21
23
  return /* @__PURE__ */ new Date(NaN);
22
- const i = n.getTime();
23
- let s = 0, a;
24
- if (r.time && (s = de(r.time), isNaN(s)))
24
+ const a = n.getTime();
25
+ let i = 0, s;
26
+ if (r.time && (i = Re(r.time), isNaN(i)))
25
27
  return /* @__PURE__ */ new Date(NaN);
26
28
  if (r.timezone) {
27
- if (a = me(r.timezone), isNaN(a))
29
+ if (s = Ae(r.timezone), isNaN(s))
28
30
  return /* @__PURE__ */ new Date(NaN);
29
31
  } else {
30
- const l = new Date(i + s), m = /* @__PURE__ */ new Date(0);
32
+ const c = new Date(a + i), m = /* @__PURE__ */ new Date(0);
31
33
  return m.setFullYear(
32
- l.getUTCFullYear(),
33
- l.getUTCMonth(),
34
- l.getUTCDate()
34
+ c.getUTCFullYear(),
35
+ c.getUTCMonth(),
36
+ c.getUTCDate()
35
37
  ), m.setHours(
36
- l.getUTCHours(),
37
- l.getUTCMinutes(),
38
- l.getUTCSeconds(),
39
- l.getUTCMilliseconds()
38
+ c.getUTCHours(),
39
+ c.getUTCMinutes(),
40
+ c.getUTCSeconds(),
41
+ c.getUTCMilliseconds()
40
42
  ), m;
41
43
  }
42
- return new Date(i + s + a);
44
+ return new Date(a + i + s);
43
45
  }
44
- const x = {
46
+ const k = {
45
47
  dateTimeDelimiter: /[T ]/,
46
48
  timeZoneDelimiter: /[Z ]/i,
47
49
  timezone: /([Z+-].*)$/
48
- }, ne = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, ie = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, se = /^([+-])(\d{2})(?::?(\d{2}))?$/;
49
- function ae(e) {
50
- const t = {}, o = e.split(x.dateTimeDelimiter);
50
+ }, xe = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, Te = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, ke = /^([+-])(\d{2})(?::?(\d{2}))?$/;
51
+ function Ie(e) {
52
+ const t = {}, o = e.split(k.dateTimeDelimiter);
51
53
  let r;
52
54
  if (o.length > 2)
53
55
  return t;
54
- if (/:/.test(o[0]) ? r = o[0] : (t.date = o[0], r = o[1], x.timeZoneDelimiter.test(t.date) && (t.date = e.split(x.timeZoneDelimiter)[0], r = e.substr(
56
+ if (/:/.test(o[0]) ? r = o[0] : (t.date = o[0], r = o[1], k.timeZoneDelimiter.test(t.date) && (t.date = e.split(k.timeZoneDelimiter)[0], r = e.substr(
55
57
  t.date.length,
56
58
  e.length
57
59
  ))), r) {
58
- const n = x.timezone.exec(r);
60
+ const n = k.timezone.exec(r);
59
61
  n ? (t.time = r.replace(n[1], ""), t.timezone = n[1]) : t.time = r;
60
62
  }
61
63
  return t;
62
64
  }
63
- function ce(e, t) {
65
+ function Se(e, t) {
64
66
  const o = new RegExp(
65
67
  "^(?:(\\d{4}|[+-]\\d{" + (4 + t) + "})|(\\d{2}|[+-]\\d{" + (2 + t) + "})$)"
66
68
  ), r = e.match(o);
67
69
  if (!r) return { year: NaN, restDateString: "" };
68
- const n = r[1] ? parseInt(r[1]) : null, i = r[2] ? parseInt(r[2]) : null;
70
+ const n = r[1] ? parseInt(r[1]) : null, a = r[2] ? parseInt(r[2]) : null;
69
71
  return {
70
- year: i === null ? n : i * 100,
72
+ year: a === null ? n : a * 100,
71
73
  restDateString: e.slice((r[1] || r[2]).length)
72
74
  };
73
75
  }
74
- function le(e, t) {
76
+ function Ee(e, t) {
75
77
  if (t === null) return /* @__PURE__ */ new Date(NaN);
76
- const o = e.match(ne);
78
+ const o = e.match(xe);
77
79
  if (!o) return /* @__PURE__ */ new Date(NaN);
78
- const r = !!o[4], n = g(o[1]), i = g(o[2]) - 1, s = g(o[3]), a = g(o[4]), l = g(o[5]) - 1;
80
+ const r = !!o[4], n = x(o[1]), a = x(o[2]) - 1, i = x(o[3]), s = x(o[4]), c = x(o[5]) - 1;
79
81
  if (r)
80
- return he(t, a, l) ? fe(t, a, l) : /* @__PURE__ */ new Date(NaN);
82
+ return Fe(t, s, c) ? Ce(t, s, c) : /* @__PURE__ */ new Date(NaN);
81
83
  {
82
84
  const m = /* @__PURE__ */ new Date(0);
83
- return !pe(t, i, s) || !ye(t, n) ? /* @__PURE__ */ new Date(NaN) : (m.setUTCFullYear(t, i, Math.max(n, s)), m);
85
+ return !$e(t, a, i) || !Me(t, n) ? /* @__PURE__ */ new Date(NaN) : (m.setUTCFullYear(t, a, Math.max(n, i)), m);
84
86
  }
85
87
  }
86
- function g(e) {
88
+ function x(e) {
87
89
  return e ? parseInt(e) : 1;
88
90
  }
89
- function de(e) {
90
- const t = e.match(ie);
91
+ function Re(e) {
92
+ const t = e.match(Te);
91
93
  if (!t) return NaN;
92
- const o = C(t[1]), r = C(t[2]), n = C(t[3]);
93
- return we(o, r, n) ? o * N + r * O + n * 1e3 : NaN;
94
+ const o = M(t[1]), r = M(t[2]), n = M(t[3]);
95
+ return De(o, r, n) ? o * q + r * L + n * 1e3 : NaN;
94
96
  }
95
- function C(e) {
97
+ function M(e) {
96
98
  return e && parseFloat(e.replace(",", ".")) || 0;
97
99
  }
98
- function me(e) {
100
+ function Ae(e) {
99
101
  if (e === "Z") return 0;
100
- const t = e.match(se);
102
+ const t = e.match(ke);
101
103
  if (!t) return 0;
102
104
  const o = t[1] === "+" ? -1 : 1, r = parseInt(t[2]), n = t[3] && parseInt(t[3]) || 0;
103
- return ve(r, n) ? o * (r * N + n * O) : NaN;
105
+ return Ke(r, n) ? o * (r * q + n * L) : NaN;
104
106
  }
105
- function fe(e, t, o) {
107
+ function Ce(e, t, o) {
106
108
  const r = /* @__PURE__ */ new Date(0);
107
109
  r.setUTCFullYear(e, 0, 4);
108
- const n = r.getUTCDay() || 7, i = (t - 1) * 7 + o + 1 - n;
109
- return r.setUTCDate(r.getUTCDate() + i), r;
110
+ const n = r.getUTCDay() || 7, a = (t - 1) * 7 + o + 1 - n;
111
+ return r.setUTCDate(r.getUTCDate() + a), r;
110
112
  }
111
- const ue = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
112
- function z(e) {
113
+ const _e = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
114
+ function Z(e) {
113
115
  return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
114
116
  }
115
- function pe(e, t, o) {
116
- return t >= 0 && t <= 11 && o >= 1 && o <= (ue[t] || (z(e) ? 29 : 28));
117
+ function $e(e, t, o) {
118
+ return t >= 0 && t <= 11 && o >= 1 && o <= (_e[t] || (Z(e) ? 29 : 28));
117
119
  }
118
- function ye(e, t) {
119
- return t >= 1 && t <= (z(e) ? 366 : 365);
120
+ function Me(e, t) {
121
+ return t >= 1 && t <= (Z(e) ? 366 : 365);
120
122
  }
121
- function he(e, t, o) {
123
+ function Fe(e, t, o) {
122
124
  return t >= 1 && t <= 53 && o >= 0 && o <= 6;
123
125
  }
124
- function we(e, t, o) {
126
+ function De(e, t, o) {
125
127
  return e === 24 ? t === 0 && o === 0 : o >= 0 && o < 60 && t >= 0 && t < 60 && e >= 0 && e < 25;
126
128
  }
127
- function ve(e, t) {
129
+ function Ke(e, t) {
128
130
  return t >= 0 && t <= 59;
129
131
  }
130
- const ge = 5 * 1024 * 1024, it = 64 * 1024 * 1024, E = d.number().int().positive().max(Number.MAX_SAFE_INTEGER), k = d.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), A = k.refine((e) => e > 0), be = (e) => !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
131
- function w(e, t) {
132
+ const je = 5 * 1024 * 1024, Pt = 64 * 1024 * 1024, R = d.number().int().positive().max(Number.MAX_SAFE_INTEGER), S = d.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), A = S.refine((e) => e > 0), Ne = (e) => !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
133
+ function v(e, t) {
132
134
  const o = t.split("/");
133
- if (o.length !== 5 || o[0] !== "exports" || o[1] !== e || o[2] !== "attempts" || !o.every(be))
135
+ if (o.length !== 5 || o[0] !== "exports" || o[1] !== e || o[2] !== "attempts" || !o.every(Ne))
134
136
  throw new Error("Invalid Matrix export artifact namespace.");
135
137
  return { attemptId: o[3], filename: o[4] };
136
138
  }
137
- function st(e, t, o) {
139
+ function zt(e, t, o) {
138
140
  const r = `exports/${e}/attempts/${t}/${o}`;
139
- return w(e, r), r;
141
+ return v(e, r), r;
140
142
  }
141
- const at = d.object({
143
+ const qt = d.object({
142
144
  acquisition: d.literal("continuation"),
143
145
  jobId: d.string().min(1),
144
146
  sequence: A,
145
- deadlineAt: E
146
- }), xe = [
147
+ deadlineAt: R
148
+ }), Ue = [
147
149
  "application/json",
148
- ...U.map((e) => P(e).partContentType)
149
- ], Ie = d.object({
150
+ ...B.map((e) => Y(e).partContentType)
151
+ ], Oe = d.object({
150
152
  key: d.string(),
151
153
  content: d.string(),
152
- contentType: d.enum(xe),
154
+ contentType: d.enum(Ue),
153
155
  encoding: d.literal("gzip-base64").optional()
154
156
  // Transport-only compression: JSON (layout, sheet layout) and Excel rows. CSV travels as it always has.
155
- }).refine((e) => !e.encoding || e.contentType === "application/json" || e.contentType === P("xlsx").partContentType, "Unsupported Matrix artifact encoding."), ke = d.discriminatedUnion("kind", [
156
- d.object({ kind: d.literal("work"), sequence: A, checkpointKey: d.string(), objects: d.array(Ie).min(2).max(4), deadlineAt: E }),
157
- d.object({ kind: d.literal("committed"), sequence: A, done: d.boolean(), deadlineAt: E })
157
+ }).refine((e) => !e.encoding || e.contentType === "application/json" || e.contentType === Y("xlsx").partContentType, "Unsupported Matrix artifact encoding."), Pe = d.discriminatedUnion("kind", [
158
+ d.object({ kind: d.literal("work"), sequence: A, checkpointKey: d.string(), objects: d.array(Oe).min(2).max(4), deadlineAt: R }),
159
+ d.object({ kind: d.literal("committed"), sequence: A, done: d.boolean(), deadlineAt: R })
158
160
  ]);
159
- function Ee(e) {
161
+ function ze(e) {
160
162
  const t = JSON.stringify(e);
161
- if (t === void 0 || new TextEncoder().encode(t).byteLength > ge)
163
+ if (t === void 0 || new TextEncoder().encode(t).byteLength > je)
162
164
  throw new RangeError("Matrix export batch exceeds its transport byte limit.");
163
165
  }
164
- function ct(e, t) {
165
- const o = ke.parse(e);
166
- if (Ee(e), o.deadlineAt !== t.deadlineAt) throw new Error("Matrix deadline does not match the job.");
166
+ function Lt(e, t) {
167
+ const o = Pe.parse(e);
168
+ if (ze(e), o.deadlineAt !== t.deadlineAt) throw new Error("Matrix deadline does not match the job.");
167
169
  if (o.sequence !== t.sequence + (o.kind === "committed" ? 1 : 0))
168
170
  throw new Error("Invalid Matrix batch sequence.");
169
171
  if (o.kind === "work") {
170
- w(t.jobId, o.checkpointKey);
172
+ v(t.jobId, o.checkpointKey);
171
173
  for (const r of o.objects)
172
- w(t.jobId, r.key);
174
+ v(t.jobId, r.key);
173
175
  }
174
176
  return o;
175
177
  }
176
- const Ae = d.object({
178
+ const qe = d.object({
177
179
  acquisition: d.literal("continuation"),
178
- deadlineAt: E,
180
+ deadlineAt: R,
179
181
  chunks: d.array(d.object({ chunkNumber: A, dataKey: d.string() })).min(1),
180
- totalRows: k,
181
- totalBytes: k,
182
+ totalRows: S,
183
+ totalBytes: S,
182
184
  fileKey: d.string().min(1).optional(),
183
- fileSize: k.optional(),
185
+ fileSize: S.optional(),
184
186
  /** The file the job writes; absent means CSV (manifests from before Excel). */
185
- format: d.enum(U).optional(),
187
+ format: d.enum(B).optional(),
186
188
  /** Excel only: the sheet layout the layout batch stored, which compaction wraps the rows in. */
187
189
  sheetKey: d.string().min(1).optional()
188
190
  }).refine((e) => e.fileKey === void 0 == (e.fileSize === void 0), "Incomplete published Matrix artifact.").refine((e) => e.format === "xlsx" == (e.sheetKey !== void 0), "An Excel Matrix manifest names its sheet layout, and only it does.");
189
- function lt(e, t, o) {
190
- const r = Ae.parse(e);
191
+ function Bt(e, t, o) {
192
+ const r = qe.parse(e);
191
193
  if (r.deadlineAt !== o) throw new Error("Matrix deadline does not match the job.");
192
- return r.chunks.forEach((n, i) => {
193
- if (n.chunkNumber !== i + 1) throw new Error("Invalid committed Matrix chunk order.");
194
- w(t, n.dataKey);
195
- }), r.fileKey !== void 0 && w(t, r.fileKey), r.sheetKey !== void 0 && w(t, r.sheetKey), r;
194
+ return r.chunks.forEach((n, a) => {
195
+ if (n.chunkNumber !== a + 1) throw new Error("Invalid committed Matrix chunk order.");
196
+ v(t, n.dataKey);
197
+ }), r.fileKey !== void 0 && v(t, r.fileKey), r.sheetKey !== void 0 && v(t, r.sheetKey), r;
196
198
  }
197
- function dt(e, t) {
199
+ function Yt(e, t) {
198
200
  return t.levelLabels[e.id] ?? e.field.label ?? e.field.name;
199
201
  }
200
- function mt(e, t) {
202
+ function Zt(e, t) {
201
203
  return t.measureLabels[e.id] ?? (e.kind === "aggregate" ? e.field.label ?? e.field.name : e.definition.label);
202
204
  }
203
- function ft(e) {
204
- return W.parse(Re(e));
205
+ function Ht(e) {
206
+ return ue.parse(Le(e));
205
207
  }
206
- function Re(e) {
207
- const t = G.parse(e), o = (r) => ({
208
+ function Le(e) {
209
+ const t = le.parse(e), o = (r) => ({
208
210
  grand: { visible: !0, position: "after" },
209
211
  levels: Object.fromEntries(
210
212
  r.map((n) => [
@@ -213,7 +215,7 @@ function Re(e) {
213
215
  ])
214
216
  )
215
217
  });
216
- return H.parse({
218
+ return de.parse({
217
219
  version: 1,
218
220
  spec: t,
219
221
  presentation: {
@@ -231,40 +233,40 @@ function Re(e) {
231
233
  }
232
234
  });
233
235
  }
234
- function Te(e, t) {
235
- const o = new Map(e.map((r) => [b(r), r]));
236
- for (const r of t ?? []) o.set(b(r), r);
236
+ function Be(e, t) {
237
+ const o = new Map(e.map((r) => [T(r), r]));
238
+ for (const r of t ?? []) o.set(T(r), r);
237
239
  return [...o.values()];
238
240
  }
239
- function ut(e) {
240
- const { spec: t, presentation: o, defaults: r, session: n } = J.parse(e), i = new Map(
241
- Te(t.sorts, n == null ? void 0 : n.sorts).map((a) => [b(a), a])
241
+ function Vt(e) {
242
+ const { spec: t, presentation: o, defaults: r, session: n } = me.parse(e), a = new Map(
243
+ Be(t.sorts, n == null ? void 0 : n.sorts).map((s) => [T(s), s])
242
244
  );
243
- for (const a of ["rows", "columns"])
244
- for (const l of t[a]) {
245
+ for (const s of ["rows", "columns"])
246
+ for (const c of t[s]) {
245
247
  const m = {
246
- axis: a,
247
- levelId: l.id,
248
+ axis: s,
249
+ levelId: c.id,
248
250
  scope: { kind: "level" },
249
251
  target: { kind: "member" },
250
252
  direction: "asc",
251
253
  nulls: "last"
252
254
  };
253
- i.has(b(m)) || i.set(b(m), m);
255
+ a.has(T(m)) || a.set(T(m), m);
254
256
  }
255
- const s = (a, l) => ({
256
- depth: Math.min(a.depth, Math.max(0, l - 1)),
257
+ const i = (s, c) => ({
258
+ depth: Math.min(s.depth, Math.max(0, c - 1)),
257
259
  // Leaf toggles are valid but have no effect. Collapsed ancestors retain dormant overrides.
258
- overrides: a.overrides.filter(
259
- (m) => m.path.length < l
260
+ overrides: s.overrides.filter(
261
+ (m) => m.path.length < c
260
262
  )
261
263
  });
262
264
  return {
263
- spec: { ...t, sorts: [...i.values()] },
265
+ spec: { ...t, sorts: [...a.values()] },
264
266
  presentation: o,
265
267
  view: {
266
- rows: s((n == null ? void 0 : n.rows) ?? r.rows, t.rows.length),
267
- columns: s(
268
+ rows: i((n == null ? void 0 : n.rows) ?? r.rows, t.rows.length),
269
+ columns: i(
268
270
  (n == null ? void 0 : n.columns) ?? r.columns,
269
271
  t.columns.length
270
272
  ),
@@ -272,35 +274,35 @@ function ut(e) {
272
274
  }
273
275
  };
274
276
  }
275
- class _ extends Error {
277
+ class N extends Error {
276
278
  constructor(o) {
277
279
  super(
278
280
  `invalid_presentation_execution_snapshot: ${o} Resave this report before running it again.`
279
281
  );
280
- p(this, "code", "invalid_presentation_execution_snapshot");
281
- p(this, "deliveryBlocking", !0);
282
+ h(this, "code", "invalid_presentation_execution_snapshot");
283
+ h(this, "deliveryBlocking", !0);
282
284
  this.name = "PresentationExecutionSnapshotError";
283
285
  }
284
286
  }
285
- class pt extends Error {
287
+ class Xt extends Error {
286
288
  constructor(o) {
287
289
  super(
288
290
  `missing_resolved_raw_temporal_format: Column "${o}" has no captured presentation. Resave this report before running it again.`
289
291
  );
290
- p(this, "code", "missing_resolved_raw_temporal_format");
291
- p(this, "deliveryBlocking", !0);
292
+ h(this, "code", "missing_resolved_raw_temporal_format");
293
+ h(this, "deliveryBlocking", !0);
292
294
  this.name = "MissingResolvedRawTemporalFormatError";
293
295
  }
294
296
  }
295
- function h(e, t, o) {
296
- const r = new Set(t), n = Object.keys(e).find((i) => !r.has(i));
297
+ function w(e, t, o) {
298
+ const r = new Set(t), n = Object.keys(e).find((a) => !r.has(a));
297
299
  if (n)
298
300
  throw new Error(`${o} contains unknown property "${n}"`);
299
301
  }
300
- function $e(e, t = "scope") {
302
+ function Ye(e, t = "scope") {
301
303
  if (!y(e))
302
304
  throw new Error(`${t} must be an object`);
303
- h(
305
+ w(
304
306
  e,
305
307
  ["dashboardId", "cardId", "attachmentIndex"],
306
308
  t
@@ -322,22 +324,22 @@ function $e(e, t = "scope") {
322
324
  ...typeof n == "number" ? { attachmentIndex: n } : {}
323
325
  };
324
326
  }
325
- function v(e, t, o, r) {
327
+ function b(e, t, o, r) {
326
328
  if (e.kind !== t) return;
327
- h(e, ["kind", o], r);
329
+ w(e, ["kind", o], r);
328
330
  const n = e[o];
329
331
  if (typeof n != "string" || !n.trim())
330
332
  throw new Error(`${r}.${o} is required`);
331
333
  return n;
332
334
  }
333
- function S(e, t) {
335
+ function F(e, t) {
334
336
  if (!y(e))
335
337
  throw new Error(`${t} must be an object`);
336
- const o = v(e, "metric", "metricId", t);
338
+ const o = b(e, "metric", "metricId", t);
337
339
  if (o) return { kind: "metric", metricId: o };
338
- const r = v(e, "column", "columnKey", t);
340
+ const r = b(e, "column", "columnKey", t);
339
341
  if (r) return { kind: "column", columnKey: r };
340
- const n = v(
342
+ const n = b(
341
343
  e,
342
344
  "matrix_measure",
343
345
  "measureId",
@@ -346,7 +348,7 @@ function S(e, t) {
346
348
  if (n) return { kind: "matrix_measure", measureId: n };
347
349
  throw new Error(`${t} is not a valid numeric presentation target`);
348
350
  }
349
- const Ce = [
351
+ const Ze = [
350
352
  "type",
351
353
  "inputUnit",
352
354
  "outputStyle",
@@ -357,12 +359,12 @@ const Ce = [
357
359
  "suffix",
358
360
  "negativeStyle"
359
361
  ];
360
- function Se(e) {
362
+ function He(e) {
361
363
  return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
362
364
  }
363
- const Me = ["type", "locale", "pattern", "timezone", "sourceTimezone"];
364
- function _e(e, t) {
365
- if (h(e, Me, t), typeof e.locale != "string" || !e.locale.trim())
365
+ const Ve = ["type", "locale", "pattern", "timezone", "sourceTimezone"];
366
+ function Xe(e, t) {
367
+ if (w(e, Ve, t), typeof e.locale != "string" || !e.locale.trim())
366
368
  throw new Error(`${t}.locale must be a non-empty string`);
367
369
  for (const o of ["pattern", "timezone", "sourceTimezone"])
368
370
  if (e[o] !== void 0 && typeof e[o] != "string")
@@ -375,20 +377,20 @@ function _e(e, t) {
375
377
  ...typeof e.sourceTimezone == "string" ? { sourceTimezone: e.sourceTimezone } : {}
376
378
  };
377
379
  }
378
- function Ke(e, t) {
379
- h(e, Ce, t);
380
- for (const i of ["inputUnit", "largestUnit", "smallestUnit"])
381
- if (e[i] !== void 0 && !Se(e[i]))
382
- throw new Error(`${t}.${i} must be a duration unit`);
380
+ function We(e, t) {
381
+ w(e, Ze, t);
382
+ for (const a of ["inputUnit", "largestUnit", "smallestUnit"])
383
+ if (e[a] !== void 0 && !He(e[a]))
384
+ throw new Error(`${t}.${a} must be a duration unit`);
383
385
  const o = e.outputStyle;
384
386
  if (o !== void 0 && o !== "compact" && o !== "digital" && o !== "long")
385
387
  throw new Error(`${t}.outputStyle must be compact, digital, or long`);
386
388
  const r = e.maxUnits;
387
389
  if (r !== void 0 && (typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 10))
388
390
  throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);
389
- for (const i of ["prefix", "suffix"])
390
- if (e[i] !== void 0 && typeof e[i] != "string")
391
- throw new Error(`${t}.${i} must be a string`);
391
+ for (const a of ["prefix", "suffix"])
392
+ if (e[a] !== void 0 && typeof e[a] != "string")
393
+ throw new Error(`${t}.${a} must be a string`);
392
394
  const n = e.negativeStyle;
393
395
  if (n !== void 0 && n !== "minus" && n !== "parentheses")
394
396
  throw new Error(`${t}.negativeStyle must be minus or parentheses`);
@@ -404,26 +406,26 @@ function Ke(e, t) {
404
406
  ...n !== void 0 ? { negativeStyle: n } : {}
405
407
  };
406
408
  }
407
- function Fe(e, t) {
409
+ function Je(e, t) {
408
410
  if (!y(e))
409
411
  throw new Error(`${t} must be an object`);
410
412
  if (e.kind === "field") {
411
- h(e, ["kind", "fieldId", "role"], t);
413
+ w(e, ["kind", "fieldId", "role"], t);
412
414
  const n = typeof e.fieldId == "string" ? e.fieldId.trim() : "";
413
415
  if (!n)
414
416
  throw new Error(`${t}.fieldId is required`);
415
- const i = e.role;
416
- if (i !== void 0 && i !== "groupby" && i !== "pivotby")
417
+ const a = e.role;
418
+ if (a !== void 0 && a !== "groupby" && a !== "pivotby")
417
419
  throw new Error(`${t}.role must be groupby or pivotby`);
418
420
  return {
419
421
  kind: "field",
420
422
  fieldId: n,
421
- ...i ? { role: i } : {}
423
+ ...a ? { role: a } : {}
422
424
  };
423
425
  }
424
- const o = v(e, "column", "columnKey", t);
426
+ const o = b(e, "column", "columnKey", t);
425
427
  if (o) return { kind: "column", columnKey: o };
426
- const r = v(
428
+ const r = b(
427
429
  e,
428
430
  "matrix_axis",
429
431
  "axisInstanceId",
@@ -432,22 +434,22 @@ function Fe(e, t) {
432
434
  if (r) return { kind: "matrix_axis", axisInstanceId: r };
433
435
  throw new Error(`${t} is not a valid temporal bucket presentation target`);
434
436
  }
435
- function je(e, t) {
437
+ function Ge(e, t) {
436
438
  if (!y(e))
437
439
  throw new Error(`${t} must be an object`);
438
- const o = v(e, "column", "columnKey", t);
440
+ const o = b(e, "column", "columnKey", t);
439
441
  if (!o)
440
442
  throw new Error(`${t} must identify a column`);
441
443
  return { kind: "column", columnKey: o };
442
444
  }
443
- function De(e) {
445
+ function Qe(e) {
444
446
  return [
445
447
  e.dashboardId,
446
448
  e.cardId ?? null,
447
449
  e.attachmentIndex ?? null
448
450
  ];
449
451
  }
450
- function R(e) {
452
+ function C(e) {
451
453
  switch (e.kind) {
452
454
  case "metric":
453
455
  return [e.kind, e.metricId];
@@ -461,80 +463,80 @@ function R(e) {
461
463
  return [e.kind, e.axisInstanceId];
462
464
  }
463
465
  }
464
- function T(e, t) {
466
+ function _(e, t) {
465
467
  return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === t.attachmentIndex;
466
468
  }
467
469
  function $(e, t) {
468
- const o = R(e), r = R(t);
469
- return o.length === r.length && o.every((n, i) => n === r[i]);
470
+ const o = C(e), r = C(t);
471
+ return o.length === r.length && o.every((n, a) => n === r[a]);
470
472
  }
471
- function Ne(e) {
473
+ function et(e) {
472
474
  if (!Array.isArray(e))
473
475
  throw new Error("resolvedFormats must be an array");
474
476
  const t = /* @__PURE__ */ new Set();
475
477
  return e.map((o, r) => {
476
- var l, m;
478
+ var c, m;
477
479
  const n = `resolvedFormats.${r}`;
478
480
  if (!y(o))
479
481
  throw new Error(`${n} must be an object`);
480
- h(o, ["scope", "target", "format"], n);
481
- const i = $e(o.scope, `${n}.scope`);
482
+ w(o, ["scope", "target", "format"], n);
483
+ const a = Ye(o.scope, `${n}.scope`);
482
484
  if (!y(o.format))
483
485
  throw new Error(`${n}.format must be an object`);
484
- let s;
486
+ let i;
485
487
  switch (o.format.type) {
486
488
  case "temporal_bucket": {
487
- const f = X(o.format);
488
- if (!f.ok)
489
+ const u = oe(o.format);
490
+ if (!u.ok)
489
491
  throw new Error(
490
- `${n}.format is invalid: ${((l = f.issues[0]) == null ? void 0 : l.message) ?? "invalid value"}`
492
+ `${n}.format is invalid: ${((c = u.issues[0]) == null ? void 0 : c.message) ?? "invalid value"}`
491
493
  );
492
- s = {
493
- scope: i,
494
- target: Fe(o.target, `${n}.target`),
495
- format: f.value
494
+ i = {
495
+ scope: a,
496
+ target: Je(o.target, `${n}.target`),
497
+ format: u.value
496
498
  };
497
499
  break;
498
500
  }
499
501
  case "raw_temporal":
500
- s = {
501
- scope: i,
502
- target: je(o.target, `${n}.target`),
503
- format: L(o.format)
502
+ i = {
503
+ scope: a,
504
+ target: Ge(o.target, `${n}.target`),
505
+ format: te(o.format)
504
506
  };
505
507
  break;
506
508
  case "number":
507
509
  case "currency":
508
510
  case "percent":
509
511
  case "scientific": {
510
- const f = Y(o.format);
511
- if (!f.ok)
512
+ const u = ee(o.format);
513
+ if (!u.ok)
512
514
  throw new Error(
513
- `${n}.format is invalid: ${((m = f.issues[0]) == null ? void 0 : m.message) ?? "invalid value"}`
515
+ `${n}.format is invalid: ${((m = u.issues[0]) == null ? void 0 : m.message) ?? "invalid value"}`
514
516
  );
515
- s = {
516
- scope: i,
517
- target: S(o.target, `${n}.target`),
518
- format: f.value
517
+ i = {
518
+ scope: a,
519
+ target: F(o.target, `${n}.target`),
520
+ format: u.value
519
521
  };
520
522
  break;
521
523
  }
522
524
  case "date": {
523
- const f = S(o.target, `${n}.target`);
524
- if (f.kind !== "column")
525
+ const u = F(o.target, `${n}.target`);
526
+ if (u.kind !== "column")
525
527
  throw new Error(`${n}.target must identify a column for a date format`);
526
- s = {
527
- scope: i,
528
- target: f,
529
- format: _e(o.format, `${n}.format`)
528
+ i = {
529
+ scope: a,
530
+ target: u,
531
+ format: Xe(o.format, `${n}.format`)
530
532
  };
531
533
  break;
532
534
  }
533
535
  case "duration":
534
- s = {
535
- scope: i,
536
- target: S(o.target, `${n}.target`),
537
- format: Ke(
536
+ i = {
537
+ scope: a,
538
+ target: F(o.target, `${n}.target`),
539
+ format: We(
538
540
  o.format,
539
541
  `${n}.format`
540
542
  )
@@ -543,28 +545,28 @@ function Ne(e) {
543
545
  default:
544
546
  throw new Error(`${n}.format.type is unsupported`);
545
547
  }
546
- const a = JSON.stringify([
547
- ...De(s.scope),
548
- ...R(s.target)
548
+ const s = JSON.stringify([
549
+ ...Qe(i.scope),
550
+ ...C(i.target)
549
551
  ]);
550
- if (t.has(a))
552
+ if (t.has(s))
551
553
  throw new Error(
552
554
  `${n} duplicates a scoped presentation target`
553
555
  );
554
- return t.add(a), s;
556
+ return t.add(s), i;
555
557
  });
556
558
  }
557
- function Oe(e) {
559
+ function tt(e) {
558
560
  try {
559
561
  if (!y(e))
560
562
  throw new Error("presentation execution snapshot must be an object");
561
- if (h(
563
+ if (w(
562
564
  e,
563
565
  ["version", "reportContext", "resolvedFormats"],
564
566
  "presentation execution snapshot"
565
567
  ), e.version !== 1)
566
568
  throw new Error("presentation execution snapshot version must be 1");
567
- const t = V(e.reportContext);
569
+ const t = fe(e.reportContext);
568
570
  if (!t.ok) {
569
571
  const o = t.issues[0];
570
572
  throw new Error(
@@ -574,90 +576,276 @@ function Oe(e) {
574
576
  return {
575
577
  version: 1,
576
578
  reportContext: t.value,
577
- resolvedFormats: Ne(e.resolvedFormats)
579
+ resolvedFormats: et(e.resolvedFormats)
578
580
  };
579
581
  } catch (t) {
580
- throw t instanceof _ ? t : new _(
582
+ throw t instanceof N ? t : new N(
581
583
  t instanceof Error ? t.message : "Snapshot is invalid."
582
584
  );
583
585
  }
584
586
  }
585
- function yt(e) {
586
- return Oe({
587
+ function Wt(e) {
588
+ return tt({
587
589
  version: 1,
588
590
  reportContext: e.reportContext,
589
591
  resolvedFormats: [...e.resolvedFormats]
590
592
  });
591
593
  }
592
- function ht(e) {
593
- const t = Ue(e);
594
- return Z(t) ? t : void 0;
594
+ function Jt(e) {
595
+ const t = ot(e);
596
+ return re(t) ? t : void 0;
595
597
  }
596
- function Ue(e) {
598
+ function ot(e) {
597
599
  const t = e.snapshot.resolvedFormats.find(
598
- (o) => o.format.type !== "temporal_bucket" && o.format.type !== "raw_temporal" && o.format.type !== "date" && T(o.scope, e.scope) && $(o.target, e.target)
600
+ (o) => o.format.type !== "temporal_bucket" && o.format.type !== "raw_temporal" && o.format.type !== "date" && _(o.scope, e.scope) && $(o.target, e.target)
599
601
  );
600
602
  return t == null ? void 0 : t.format;
601
603
  }
602
- function wt(e) {
604
+ function Gt(e) {
603
605
  const t = e.snapshot.resolvedFormats.find(
604
- (o) => o.format.type === "date" && T(o.scope, e.scope) && $(o.target, e.target)
606
+ (o) => o.format.type === "date" && _(o.scope, e.scope) && $(o.target, e.target)
605
607
  );
606
608
  return t == null ? void 0 : t.format;
607
609
  }
608
- function vt(e) {
610
+ function Qt(e) {
609
611
  const t = e.snapshot.resolvedFormats.find(
610
- (o) => o.format.type === "raw_temporal" && T(o.scope, e.scope) && $(o.target, e.target)
612
+ (o) => o.format.type === "raw_temporal" && _(o.scope, e.scope) && $(o.target, e.target)
611
613
  );
612
614
  return t == null ? void 0 : t.format;
613
615
  }
614
- function gt(e) {
616
+ function eo(e) {
615
617
  const t = e.snapshot.resolvedFormats.find(
616
- (o) => o.format.type === "temporal_bucket" && T(o.scope, e.scope) && $(o.target, e.target)
618
+ (o) => o.format.type === "temporal_bucket" && _(o.scope, e.scope) && $(o.target, e.target)
617
619
  );
618
620
  return t == null ? void 0 : t.format;
619
621
  }
620
- function bt(e) {
622
+ function to(e) {
621
623
  var n;
622
624
  const t = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
623
- if (e.snapshot.resolvedFormats.forEach((i, s) => {
624
- if (i.scope.attachmentIndex !== void 0)
625
+ if (e.snapshot.resolvedFormats.forEach((a, i) => {
626
+ if (a.scope.attachmentIndex !== void 0)
625
627
  throw new Error(
626
- `resolvedFormats.${s}.scope.attachmentIndex is not valid for a card export`
628
+ `resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`
627
629
  );
628
- if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
630
+ if (a.scope.dashboardId !== e.expectedScope.dashboardId || a.scope.cardId !== e.expectedScope.cardId)
629
631
  throw new Error(
630
- `resolvedFormats.${s}.scope must match the executing dashboard/card`
632
+ `resolvedFormats.${i}.scope must match the executing dashboard/card`
631
633
  );
632
- if (i.target.kind === "field" && i.format.type === "temporal_bucket") {
633
- const a = JSON.stringify(R(i.target));
634
- if (o.has(a))
634
+ if (a.target.kind === "field" && a.format.type === "temporal_bucket") {
635
+ const s = JSON.stringify(C(a.target));
636
+ if (o.has(s))
635
637
  throw new Error(
636
- `resolvedFormats.${s} duplicates export field "${i.target.fieldId}"`
638
+ `resolvedFormats.${i} duplicates export field "${a.target.fieldId}"`
637
639
  );
638
- o.add(a);
640
+ o.add(s);
639
641
  return;
640
642
  }
641
- if (i.target.kind !== "column")
643
+ if (a.target.kind !== "column")
642
644
  throw new Error(
643
- `resolvedFormats.${s}.target must identify an export column or temporal pivot field`
645
+ `resolvedFormats.${i}.target must identify an export column or temporal pivot field`
644
646
  );
645
- if (t.has(i.target.columnKey))
647
+ if (t.has(a.target.columnKey))
646
648
  throw new Error(
647
- `resolvedFormats.${s} duplicates export column "${i.target.columnKey}"`
649
+ `resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`
648
650
  );
649
- t.add(i.target.columnKey);
651
+ t.add(a.target.columnKey);
650
652
  }), !e.useFormattedValues) return;
651
653
  if (!((n = e.visibleColumns) != null && n.length))
652
654
  throw new Error("visibleColumns must identify every formatted export column");
653
655
  const r = e.visibleColumns.find(
654
- (i) => !t.has(i)
656
+ (a) => !t.has(a)
655
657
  );
656
658
  if (r)
657
659
  throw new Error(
658
660
  `resolvedFormats is missing visible export column "${r}"`
659
661
  );
660
662
  }
663
+ const rt = /* @__PURE__ */ new Set(["short", "medium", "long"]), nt = /^(\d{4})-(\d{2})-(\d{2})$/, at = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, it = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, j = " – ";
664
+ function oo(e) {
665
+ if (!y(e)) return;
666
+ const t = Object.keys(e);
667
+ if (e.mode === "period_label" && t.length === 1)
668
+ return { mode: "period_label" };
669
+ if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && rt.has(e.dateStyle))
670
+ return { mode: "style", dateStyle: e.dateStyle };
671
+ if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && st(e.pattern) === null)
672
+ return {
673
+ mode: "pattern",
674
+ dialect: "semaphor_tokens",
675
+ pattern: e.pattern
676
+ };
677
+ }
678
+ function st(e) {
679
+ try {
680
+ return ce({ dialect: "semaphor_tokens", pattern: e }), null;
681
+ } catch (t) {
682
+ return t instanceof Error ? t.message : "The pattern is invalid.";
683
+ }
684
+ }
685
+ function ro(e) {
686
+ const { value: t, part: o, presentation: r, preferences: n, calendar: a } = e;
687
+ if ((r == null ? void 0 : r.mode) === "period_label" && t.periodLabel && o === "range")
688
+ return { ok: !0, text: t.periodLabel };
689
+ const [i, s] = t.bounds, m = s === void 0 || o === "start" ? [{ raw: i, role: "start" }] : o === "end" ? [{ raw: s, role: "end" }] : [
690
+ { raw: i, role: "start" },
691
+ { raw: s, role: "end" }
692
+ ], u = m.map(({ raw: p }) => mt(p, a.tz));
693
+ if (u.some((p) => p === null))
694
+ return {
695
+ ok: !1,
696
+ text: m.map(({ raw: p }) => p).join(j),
697
+ diagnostic: {
698
+ code: "invalid_temporal_input_value",
699
+ message: "A date input bound is not a date or an instant."
700
+ }
701
+ };
702
+ const g = t.precision === "day" ? u.map(
703
+ (p, J) => ft(p, m[J].role, a.tz)
704
+ ) : [], f = g.length > 0 && g.every((p) => p !== null) ? g : null;
705
+ return { ok: !0, text: f ? ct(f, r, n, a) : lt(
706
+ u.map((p) => ut(p, a.tz)),
707
+ r,
708
+ n,
709
+ a
710
+ ) };
711
+ }
712
+ function ct(e, t, o, r) {
713
+ const [n, a = n] = e;
714
+ if ((t == null ? void 0 : t.mode) === "pattern")
715
+ return X(
716
+ e.map(
717
+ (c) => V(D(c), "date", t.pattern, o, r)
718
+ )
719
+ );
720
+ const i = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : o.dateStyle;
721
+ if (!t || t.mode === "period_label") {
722
+ const c = pt(n, a, r);
723
+ if (c)
724
+ return ne({
725
+ value: D(n),
726
+ metadata: {
727
+ kind: "temporal_bucket",
728
+ granularity: c,
729
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
730
+ },
731
+ format: ae({
732
+ metadata: {
733
+ kind: "temporal_bucket",
734
+ granularity: c,
735
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
736
+ },
737
+ locale: o.locale,
738
+ styles: { dateStyle: i, dateTime: { ...o.dateTime } }
739
+ }).format
740
+ });
741
+ }
742
+ const s = new Intl.DateTimeFormat(o.locale, {
743
+ calendar: "gregory",
744
+ timeZone: "UTC",
745
+ dateStyle: i
746
+ });
747
+ return ht(n, a) ? s.format(E(n)) : H(s, E(n), E(a));
748
+ }
749
+ function lt(e, t, o, r) {
750
+ if ((t == null ? void 0 : t.mode) === "pattern")
751
+ return X(
752
+ e.map(
753
+ (s) => V(
754
+ s.toISOString(),
755
+ "instant",
756
+ t.pattern,
757
+ o,
758
+ r
759
+ )
760
+ )
761
+ );
762
+ const n = new Intl.DateTimeFormat(o.locale, {
763
+ calendar: "gregory",
764
+ timeZone: r.tz,
765
+ dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : o.dateTime.dateStyle,
766
+ timeStyle: o.dateTime.timeStyle
767
+ }), [a, i] = e;
768
+ return i && i.getTime() !== a.getTime() ? H(n, a, i) : n.format(a);
769
+ }
770
+ function H(e, t, o) {
771
+ const r = e;
772
+ return typeof r.formatRange == "function" ? r.formatRange(t, o) : `${e.format(t)}${j}${e.format(o)}`;
773
+ }
774
+ function V(e, t, o, r, n) {
775
+ const a = ie({
776
+ format: {
777
+ type: "raw_temporal",
778
+ presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: o }
779
+ },
780
+ // Temporal formatting reads no currency.
781
+ preferences: {
782
+ ...r,
783
+ defaultCurrency: pe.defaultCurrency
784
+ },
785
+ calendar: { tz: n.tz }
786
+ }), i = t === "date" && dt(o) ? "instant" : t;
787
+ return se({
788
+ value: i === t ? e : K(`${e}T00:00:00`, n.tz).toISOString(),
789
+ metadata: { kind: "raw_temporal", valueKind: i },
790
+ format: a
791
+ }).text;
792
+ }
793
+ function dt(e) {
794
+ return /HH|mm|ss/.test(e);
795
+ }
796
+ function X(e) {
797
+ return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(j);
798
+ }
799
+ function mt(e, t) {
800
+ const o = nt.exec(e);
801
+ if (o) {
802
+ const n = {
803
+ year: Number(o[1]),
804
+ month: Number(o[2]),
805
+ day: Number(o[3])
806
+ };
807
+ return wt(n) ? { kind: "date", date: n } : null;
808
+ }
809
+ const r = it.test(e) ? new Date(e.replace(" ", "T")) : at.test(e) ? K(e.replace(" ", "T"), t) : null;
810
+ return r && !Number.isNaN(r.getTime()) ? { kind: "instant", instant: r } : null;
811
+ }
812
+ function ut(e, t) {
813
+ return e.kind === "instant" ? e.instant : K(`${D(e.date)}T00:00:00`, t);
814
+ }
815
+ function ft(e, t, o) {
816
+ if (e.kind === "date") return e.date;
817
+ const r = ye(e.instant, o), n = { year: r.year, month: r.month, day: r.day };
818
+ if (r.hour === 0 && r.minute === 0 && r.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? n : yt(n, -1);
819
+ const i = r.hour === 23 && r.minute === 59 && r.second === 59;
820
+ return t === "end" && i ? n : null;
821
+ }
822
+ function pt(e, t, o) {
823
+ return o.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== W(t.year, t.month) ? null : e.month === t.month ? "month" : e.month % 3 === 1 && t.month === e.month + 2 ? "quarter" : e.month === 1 && t.month === 12 ? "year" : null;
824
+ }
825
+ function D(e) {
826
+ return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
827
+ }
828
+ function E(e) {
829
+ const t = /* @__PURE__ */ new Date(0);
830
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
831
+ }
832
+ function yt(e, t) {
833
+ const o = E(e);
834
+ return o.setUTCDate(o.getUTCDate() + t), {
835
+ year: o.getUTCFullYear(),
836
+ month: o.getUTCMonth() + 1,
837
+ day: o.getUTCDate()
838
+ };
839
+ }
840
+ function ht(e, t) {
841
+ return e.year === t.year && e.month === t.month && e.day === t.day;
842
+ }
843
+ function W(e, t) {
844
+ return new Date(Date.UTC(e, t, 0)).getUTCDate();
845
+ }
846
+ function wt(e) {
847
+ return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= W(e.year, e.month);
848
+ }
661
849
  function I(e) {
662
850
  return Array.from(
663
851
  new Set(
@@ -667,310 +855,310 @@ function I(e) {
667
855
  )
668
856
  );
669
857
  }
670
- function Pe(e) {
858
+ function gt(e) {
671
859
  const t = /* @__PURE__ */ new Map();
672
860
  return e.forEach((o) => {
673
861
  o.id && t.set(o.id, (t.get(o.id) ?? 0) + 1);
674
862
  }), e.flatMap(
675
- (o) => o.id && (t.get(o.id) ?? 0) > 1 ? [ee(o)] : []
863
+ (o) => o.id && (t.get(o.id) ?? 0) > 1 ? [we(o)] : []
676
864
  );
677
865
  }
678
- function xt(e) {
866
+ function no(e) {
679
867
  const t = e.metricFields ?? [], o = I(t);
680
868
  return {
681
869
  expectedRoleFieldIds: {
682
870
  groupby: I(e.groupByFields),
683
- metric: o.length > 0 ? o : [Q],
871
+ metric: o.length > 0 ? o : [he],
684
872
  pivotby: I(e.pivotByFields),
685
873
  detail: I(e.detailFields)
686
874
  },
687
- expectedMetricAliases: Pe(t)
875
+ expectedMetricAliases: gt(t)
688
876
  };
689
877
  }
690
- class c extends Error {
878
+ class l extends Error {
691
879
  constructor(o, r) {
692
880
  super(`invalid_pivot_result_lifecycle: ${o}`);
693
- p(this, "code", "invalid_pivot_result_lifecycle");
694
- p(this, "deliveryBlocking", !0);
881
+ h(this, "code", "invalid_pivot_result_lifecycle");
882
+ h(this, "deliveryBlocking", !0);
695
883
  this.cause = r, this.name = "PivotResultLifecycleError";
696
884
  }
697
885
  }
698
- function ze(e) {
886
+ function vt(e) {
699
887
  if (!Array.isArray(e) || e.some(
700
888
  (o) => !o || typeof o != "object" || Array.isArray(o) || typeof o.key != "string" || !o.key || typeof o.name != "string" || typeof o.label != "string"
701
889
  ))
702
- throw new c(
890
+ throw new l(
703
891
  "Canonical pivot columns must be an array of keyed, named result descriptors."
704
892
  );
705
893
  const t = e;
706
894
  if (new Set(t.map((o) => o.key)).size !== t.length)
707
- throw new c(
895
+ throw new l(
708
896
  "Canonical pivot column keys must be unique."
709
897
  );
710
898
  for (const o of t) {
711
- const r = te(o, {
899
+ const r = ge(o, {
712
900
  metadataRequired: !1
713
901
  });
714
902
  if (!r.ok)
715
- throw new c(
903
+ throw new l(
716
904
  `Canonical pivot column "${o.key}" has invalid temporal metadata: ${r.error.message}`
717
905
  );
718
906
  }
719
907
  return t;
720
908
  }
721
- function K(e) {
909
+ function U(e) {
722
910
  if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1 || e.source !== "explorer" || !e.byRole || typeof e.byRole != "object" || Array.isArray(e.byRole))
723
- throw new c(
911
+ throw new l(
724
912
  "A loaded canonical pivot result requires its role-scoped column key map."
725
913
  );
726
914
  const t = e, o = /* @__PURE__ */ new Set(["groupby", "metric", "pivotby", "detail"]);
727
915
  for (const [r, n] of Object.entries(t.byRole)) {
728
916
  if (!o.has(r) || !n || typeof n != "object" || Array.isArray(n))
729
- throw new c(
917
+ throw new l(
730
918
  `Canonical pivot role map contains invalid "${r}" bindings.`
731
919
  );
732
- for (const [i, s] of Object.entries(n))
733
- if (!i || !s || typeof s != "object" || Array.isArray(s) || s.role !== r || typeof s.rawKey != "string" || !s.rawKey || s.outputKey !== void 0 && (typeof s.outputKey != "string" || !s.outputKey))
734
- throw new c(
735
- `Canonical pivot role map contains an invalid "${r}:${i}" binding.`
920
+ for (const [a, i] of Object.entries(n))
921
+ if (!a || !i || typeof i != "object" || Array.isArray(i) || i.role !== r || typeof i.rawKey != "string" || !i.rawKey || i.outputKey !== void 0 && (typeof i.outputKey != "string" || !i.outputKey))
922
+ throw new l(
923
+ `Canonical pivot role map contains an invalid "${r}:${a}" binding.`
736
924
  );
737
925
  }
738
926
  if (t.byMetricAlias !== void 0) {
739
927
  if (!t.byMetricAlias || typeof t.byMetricAlias != "object" || Array.isArray(t.byMetricAlias))
740
- throw new c(
928
+ throw new l(
741
929
  "Canonical pivot metric-alias bindings must be an object."
742
930
  );
743
931
  for (const [r, n] of Object.entries(
744
932
  t.byMetricAlias
745
933
  ))
746
934
  if (!r || !n || typeof n != "object" || Array.isArray(n) || n.role !== "metric" || typeof n.rawKey != "string" || !n.rawKey || n.outputKey !== void 0 && (typeof n.outputKey != "string" || !n.outputKey))
747
- throw new c(
935
+ throw new l(
748
936
  `Canonical pivot metric-alias map contains an invalid "${r}" binding.`
749
937
  );
750
938
  }
751
939
  return t;
752
940
  }
753
- function qe(e) {
941
+ function bt(e) {
754
942
  if (e === void 0) return {};
755
943
  if (!e || typeof e != "object" || Array.isArray(e))
756
- throw new c(
944
+ throw new l(
757
945
  "Canonical pivot column metadata must be an object."
758
946
  );
759
947
  for (const [t, o] of Object.entries(e)) {
760
948
  if (!t || !o || typeof o != "object" || Array.isArray(o))
761
- throw new c(
949
+ throw new l(
762
950
  `Canonical pivot column metadata contains an invalid "${t}" classification.`
763
951
  );
764
952
  const { isSubtotal: r, subtotalScope: n } = o;
765
953
  if (r !== void 0 && typeof r != "boolean" || n !== void 0 && n !== "base" && n !== "pivot-value" && n !== "grand-total" || r === !0 && n !== "pivot-value" && n !== "grand-total" || (n === "pivot-value" || n === "grand-total") && r !== !0 || n === "base" && r === !0)
766
- throw new c(
954
+ throw new l(
767
955
  `Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`
768
956
  );
769
957
  }
770
958
  return e;
771
959
  }
772
- function F(e, t) {
960
+ function O(e, t) {
773
961
  if (!Array.isArray(e) || e.some((o) => typeof o != "string" || !o) || new Set(e).size !== e.length)
774
- throw new c(
962
+ throw new l(
775
963
  `Canonical pivot contract ${t} must be an array of unique field identities.`
776
964
  );
777
965
  return e;
778
966
  }
779
- function Be(e, t) {
967
+ function xt(e, t) {
780
968
  if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1)
781
- throw new c(
969
+ throw new l(
782
970
  "A canonical pivot result requires its versioned result contract."
783
971
  );
784
972
  const o = e, r = o.expectedRoleFieldIds;
785
973
  if (!r || typeof r != "object" || Array.isArray(r))
786
- throw new c(
974
+ throw new l(
787
975
  "Canonical pivot contract role identities must be an object."
788
976
  );
789
- const i = Object.fromEntries(
977
+ const a = Object.fromEntries(
790
978
  [
791
979
  "groupby",
792
980
  "metric",
793
981
  "pivotby",
794
982
  "detail"
795
- ].map((u) => [
796
- u,
797
- F(
798
- r[u],
799
- `expectedRoleFieldIds.${u}`
983
+ ].map((f) => [
984
+ f,
985
+ O(
986
+ r[f],
987
+ `expectedRoleFieldIds.${f}`
800
988
  )
801
989
  ])
802
- ), s = F(
990
+ ), i = O(
803
991
  o.expectedMetricAliases,
804
992
  "expectedMetricAliases"
805
- ), a = o.columnKinds;
806
- if (!a || typeof a != "object" || Array.isArray(a))
807
- throw new c(
993
+ ), s = o.columnKinds;
994
+ if (!s || typeof s != "object" || Array.isArray(s))
995
+ throw new l(
808
996
  "Canonical pivot contract column kinds must be an object."
809
997
  );
810
- const l = /* @__PURE__ */ new Set([
998
+ const c = /* @__PURE__ */ new Set([
811
999
  "row",
812
1000
  "pivot_metric",
813
1001
  "value"
814
- ]), m = t.map((u) => u.key), f = Object.keys(a);
815
- if (f.length !== m.length || f.some(
816
- (u) => !m.includes(u) || !l.has(
817
- a[u]
1002
+ ]), m = t.map((f) => f.key), u = Object.keys(s);
1003
+ if (u.length !== m.length || u.some(
1004
+ (f) => !m.includes(f) || !c.has(
1005
+ s[f]
818
1006
  )
819
1007
  ))
820
- throw new c(
1008
+ throw new l(
821
1009
  "Canonical pivot contract must classify every authoritative result column exactly once."
822
1010
  );
823
- const M = qe(
1011
+ const g = bt(
824
1012
  o.columnClassifications
825
1013
  );
826
- if (Object.keys(M).some(
827
- (u) => !m.includes(u)
1014
+ if (Object.keys(g).some(
1015
+ (f) => !m.includes(f)
828
1016
  ))
829
- throw new c(
1017
+ throw new l(
830
1018
  "Canonical pivot contract contains a classification for an unknown result column."
831
1019
  );
832
1020
  return {
833
1021
  version: 1,
834
- expectedRoleFieldIds: i,
835
- expectedMetricAliases: s,
836
- columnKinds: a,
837
- columnClassifications: M
1022
+ expectedRoleFieldIds: a,
1023
+ expectedMetricAliases: i,
1024
+ columnKinds: s,
1025
+ columnClassifications: g
838
1026
  };
839
1027
  }
840
- function j(e, t) {
1028
+ function P(e, t) {
841
1029
  const o = [
842
1030
  "groupby",
843
1031
  "metric",
844
1032
  "pivotby",
845
1033
  "detail"
846
1034
  ];
847
- for (const i of o) {
848
- const s = new Set(t.expectedRoleFieldIds[i] ?? []), a = Object.keys(e.byRole[i] ?? {});
849
- if (a.length !== s.size || a.some((l) => !s.has(l)))
850
- throw new c(
851
- `The role-scoped ${i} bindings do not match the authored result fields.`
1035
+ for (const a of o) {
1036
+ const i = new Set(t.expectedRoleFieldIds[a] ?? []), s = Object.keys(e.byRole[a] ?? {});
1037
+ if (s.length !== i.size || s.some((c) => !i.has(c)))
1038
+ throw new l(
1039
+ `The role-scoped ${a} bindings do not match the authored result fields.`
852
1040
  );
853
1041
  }
854
1042
  const r = new Set(t.expectedMetricAliases), n = Object.keys(e.byMetricAlias ?? {});
855
- if (n.length !== r.size || n.some((i) => !r.has(i)))
856
- throw new c(
1043
+ if (n.length !== r.size || n.some((a) => !r.has(a)))
1044
+ throw new l(
857
1045
  "The metric-alias bindings do not match the authored metric instances."
858
1046
  );
859
1047
  }
860
- function Ye(e) {
1048
+ function Tt(e) {
861
1049
  if (!Array.isArray(e) || e.some(
862
1050
  (t) => !t || typeof t != "object" || Array.isArray(t)
863
1051
  ))
864
- throw new c(
1052
+ throw new l(
865
1053
  "Canonical pivot records must be an array of row objects."
866
1054
  );
867
1055
  return e;
868
1056
  }
869
- function Le(e, t) {
1057
+ function kt(e, t) {
870
1058
  e.forEach((o, r) => {
871
1059
  t.forEach((n) => {
872
1060
  if (!Object.prototype.hasOwnProperty.call(o, n.key) || o[n.key] === void 0)
873
- throw new c(
1061
+ throw new l(
874
1062
  `Canonical pivot column "${n.key}" is absent from row ${r}.`
875
1063
  );
876
1064
  });
877
1065
  });
878
1066
  }
879
- function Xe(e, t, o) {
1067
+ function It(e, t, o) {
880
1068
  const r = new Set(t.map((n) => n.key));
881
1069
  ["groupby", "detail"].forEach((n) => {
882
1070
  Object.entries(e.byRole[n] ?? {}).forEach(
883
- ([i, s]) => {
884
- const a = s.outputKey || s.rawKey;
885
- if (!r.has(a) || o.columnKinds[a] !== "row")
886
- throw new c(
887
- `The role-scoped ${n} binding for "${i}" does not name an authoritative result column.`
1071
+ ([a, i]) => {
1072
+ const s = i.outputKey || i.rawKey;
1073
+ if (!r.has(s) || o.columnKinds[s] !== "row")
1074
+ throw new l(
1075
+ `The role-scoped ${n} binding for "${a}" does not name an authoritative result column.`
888
1076
  );
889
1077
  }
890
1078
  );
891
1079
  });
892
1080
  }
893
- function D(e, t) {
1081
+ function z(e, t) {
894
1082
  t.forEach((o) => {
895
1083
  const r = e.columnKinds[o.key];
896
1084
  if (r === "pivot_metric" && o.pivotIdentity === void 0)
897
- throw new c(
1085
+ throw new l(
898
1086
  `Physical pivot result column "${o.key}" is missing its identity.`
899
1087
  );
900
1088
  if (r !== "pivot_metric" && o.pivotIdentity !== void 0)
901
- throw new c(
1089
+ throw new l(
902
1090
  `Canonical pivot result column "${o.key}" carries pivot identity outside the physical pivot projection.`
903
1091
  );
904
1092
  });
905
1093
  }
906
- function Ze(e) {
907
- const t = Ye(e.records), o = ze(e.columns), r = Be(
1094
+ function St(e) {
1095
+ const t = Tt(e.records), o = vt(e.columns), r = xt(
908
1096
  e.pivotResultContract,
909
1097
  o
910
1098
  ), n = r.expectedRoleFieldIds.pivotby ?? [];
911
1099
  if (e.pivotResultState === "loaded_empty") {
912
1100
  if (t.length !== 0)
913
- throw new c(
1101
+ throw new l(
914
1102
  "A loaded_empty pivot result cannot carry records."
915
1103
  );
916
1104
  if (o.some(
917
- (l) => r.columnKinds[l.key] === "pivot_metric"
1105
+ (c) => r.columnKinds[c.key] === "pivot_metric"
918
1106
  ))
919
- throw new c(
1107
+ throw new l(
920
1108
  "A loaded_empty pivot result cannot carry physical pivot columns."
921
1109
  );
922
- D(r, o);
923
- const a = K(e.columnKeyMap);
924
- return j(a, r), {
1110
+ z(r, o);
1111
+ const s = U(e.columnKeyMap);
1112
+ return P(s, r), {
925
1113
  pivotResultState: "loaded_empty",
926
1114
  records: [],
927
1115
  columns: o,
928
- columnKeyMap: a,
1116
+ columnKeyMap: s,
929
1117
  pivotResultContract: r
930
1118
  };
931
1119
  }
932
1120
  if (e.pivotResultState !== "loaded_valid")
933
- throw new c(
1121
+ throw new l(
934
1122
  "A canonical pivot result must declare loaded_empty or loaded_valid."
935
1123
  );
936
1124
  if (t.length === 0)
937
- throw new c(
1125
+ throw new l(
938
1126
  "A loaded_valid pivot result must carry at least one record."
939
1127
  );
940
- const i = K(e.columnKeyMap);
941
- j(i, r), Xe(i, o, r), D(r, o);
942
- const s = o.filter(
943
- (a) => r.columnKinds[a.key] === "pivot_metric"
1128
+ const a = U(e.columnKeyMap);
1129
+ P(a, r), It(a, o, r), z(r, o);
1130
+ const i = o.filter(
1131
+ (s) => r.columnKinds[s.key] === "pivot_metric"
944
1132
  );
945
- if (n.length > 0 && s.length === 0)
946
- throw new c(
1133
+ if (n.length > 0 && i.length === 0)
1134
+ throw new l(
947
1135
  "A loaded_valid pivot result is missing its physical pivot columns."
948
1136
  );
949
1137
  try {
950
- oe(s, {
1138
+ ve(i, {
951
1139
  expectedPivotFieldIds: n,
952
1140
  columnClassifications: r.columnClassifications
953
1141
  });
954
- } catch (a) {
955
- throw a instanceof re ? new c(a.message, a) : a;
1142
+ } catch (s) {
1143
+ throw s instanceof be ? new l(s.message, s) : s;
956
1144
  }
957
- return Le(t, o), {
1145
+ return kt(t, o), {
958
1146
  pivotResultState: "loaded_valid",
959
1147
  records: t,
960
1148
  columns: o,
961
- columnKeyMap: i,
1149
+ columnKeyMap: a,
962
1150
  pivotResultContract: r
963
1151
  };
964
1152
  }
965
- function It(e) {
1153
+ function ao(e) {
966
1154
  const t = /* @__PURE__ */ new Set();
967
- ["groupby", "detail"].forEach((i) => {
968
- Object.values(e.columnKeyMap.byRole[i] ?? {}).forEach((s) => {
969
- t.add(s.outputKey || s.rawKey);
1155
+ ["groupby", "detail"].forEach((a) => {
1156
+ Object.values(e.columnKeyMap.byRole[a] ?? {}).forEach((i) => {
1157
+ t.add(i.outputKey || i.rawKey);
970
1158
  });
971
1159
  });
972
1160
  const o = new Set(e.physicalPivotColumnKeys), r = new Set(
973
- e.columns.map((i) => i.key)
1161
+ e.columns.map((a) => a.key)
974
1162
  ), n = {
975
1163
  version: 1,
976
1164
  expectedRoleFieldIds: {
@@ -989,18 +1177,18 @@ function It(e) {
989
1177
  },
990
1178
  expectedMetricAliases: [...e.expectedMetricAliases ?? []],
991
1179
  columnKinds: Object.fromEntries(
992
- e.columns.map((i) => [
993
- i.key,
994
- t.has(i.key) ? "row" : o.has(i.key) ? "pivot_metric" : "value"
1180
+ e.columns.map((a) => [
1181
+ a.key,
1182
+ t.has(a.key) ? "row" : o.has(a.key) ? "pivot_metric" : "value"
995
1183
  ])
996
1184
  ),
997
1185
  columnClassifications: Object.fromEntries(
998
1186
  Object.entries(e.columnMetadata ?? {}).filter(
999
- ([i]) => r.has(i)
1187
+ ([a]) => r.has(a)
1000
1188
  )
1001
1189
  )
1002
1190
  };
1003
- return Ze({
1191
+ return St({
1004
1192
  pivotResultState: e.records.length === 0 ? "loaded_empty" : "loaded_valid",
1005
1193
  pivotResultContract: n,
1006
1194
  records: e.records,
@@ -1009,39 +1197,42 @@ function It(e) {
1009
1197
  });
1010
1198
  }
1011
1199
  export {
1012
- dt as A,
1013
- mt as B,
1014
- ft as C,
1015
- Re as D,
1016
- Te as E,
1017
- ut as F,
1018
- nt as G,
1019
- pt as M,
1020
- _ as P,
1021
- Ue as a,
1022
- ge as b,
1023
- it as c,
1024
- st as d,
1025
- at as e,
1026
- vt as f,
1027
- ke as g,
1028
- Ee as h,
1029
- ct as i,
1030
- Ae as j,
1031
- lt as k,
1032
- $e as l,
1033
- E as m,
1034
- Ne as n,
1035
- Oe as o,
1036
- w as p,
1037
- yt as q,
1038
- ht as r,
1039
- wt as s,
1040
- gt as t,
1041
- Pe as u,
1042
- bt as v,
1043
- xt as w,
1044
- c as x,
1045
- Ze as y,
1046
- It as z
1200
+ l as A,
1201
+ St as B,
1202
+ ao as C,
1203
+ Yt as D,
1204
+ Zt as E,
1205
+ Ht as F,
1206
+ Le as G,
1207
+ Be as H,
1208
+ Vt as I,
1209
+ Ot as J,
1210
+ Xt as M,
1211
+ N as P,
1212
+ ot as a,
1213
+ je as b,
1214
+ Pt as c,
1215
+ zt as d,
1216
+ qt as e,
1217
+ Qt as f,
1218
+ Pe as g,
1219
+ ze as h,
1220
+ Lt as i,
1221
+ qe as j,
1222
+ Bt as k,
1223
+ Ye as l,
1224
+ R as m,
1225
+ et as n,
1226
+ tt as o,
1227
+ v as p,
1228
+ Wt as q,
1229
+ Jt as r,
1230
+ Gt as s,
1231
+ eo as t,
1232
+ oo as u,
1233
+ to as v,
1234
+ st as w,
1235
+ ro as x,
1236
+ gt as y,
1237
+ no as z
1047
1238
  };