react-semaphor 0.1.603 → 0.1.605

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 (208) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1491
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +3 -1598
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-CEmZUf9o.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-DMFrDqn_.js +1 -0
  11. package/dist/chunks/appearance-provider-CfoAVQuG.js +608 -0
  12. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-DgUaCE9k.js +51 -0
  15. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
  16. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  17. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  18. package/dist/chunks/bookmark-impact-BAtemeyK.js +1 -0
  19. package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
  20. package/dist/chunks/brand-C9APUFaP.js +1 -0
  21. package/dist/chunks/card-filter-builder-ClWrXB7P.js +11 -0
  22. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  23. package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
  24. package/dist/chunks/context-CntvtZwC.js +2 -0
  25. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  26. package/dist/chunks/dashboard-ChIcbVTx.js +1 -0
  27. package/dist/chunks/dashboard-briefing-launcher-CwMlhkxV.js +42 -0
  28. package/dist/chunks/dashboard-controls-UCSAFCGA.js +42 -0
  29. package/dist/chunks/dashboard-json-B120hYDa.js +1 -0
  30. package/dist/chunks/dashboard-temporal-snapshot-BFJKbp_6.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-DvHp03h_.js +73 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
  34. package/dist/chunks/filter-reach-preview-C5M5_hf_.js +1 -0
  35. package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
  36. package/dist/chunks/index-DViPGDFj.js +1 -0
  37. package/dist/chunks/index-bkP6SnYu.js +1 -0
  38. package/dist/chunks/kpi-trend-rule-B87LNzcz.js +1 -0
  39. package/dist/chunks/layout-grid-CFzqJ7GC.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
  43. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  44. package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
  45. package/dist/chunks/palette-NvEIuXHN.js +6 -0
  46. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
  47. package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
  48. package/dist/chunks/raw-temporal-value-BHQ-ldpW.js +1 -0
  49. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  50. package/dist/chunks/report-preferences-dialog-Bseb2Rlg.js +1 -0
  51. package/dist/chunks/report-runtime-context-Cd1b5pku.js +1 -0
  52. package/dist/chunks/resolve-dashboard-input-context-BDY7KwRe.js +8 -0
  53. package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
  54. package/dist/chunks/saved-dashboard-context-C3lWc4Dx.js +1 -0
  55. package/dist/chunks/schema-O1Y3WTGF.js +4 -0
  56. package/dist/chunks/selection-filter-compiler-kYsRugss.js +1 -0
  57. package/dist/chunks/semaphor-ready-indicator-BQarSo6S.js +612 -0
  58. package/dist/chunks/set-6mOnfQeH.js +1 -0
  59. package/dist/chunks/slider-BPnHdMGq.js +4 -0
  60. package/dist/chunks/stored-dashboard-DfrxDLhR.js +1 -0
  61. package/dist/chunks/table-export-sheet-xaczzWZF.js +2 -0
  62. package/dist/chunks/token-types-1vzMWjI-.js +1 -0
  63. package/dist/chunks/validators-Dg2kyF4_.js +1 -0
  64. package/dist/chunks/variable-draft-B4_xqr4Y.js +1 -0
  65. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  66. package/dist/dashboard/index.js +1 -7
  67. package/dist/dashboard-authoring/index.js +1 -4614
  68. package/dist/format-utils/index.js +1 -425
  69. package/dist/index.js +1 -554
  70. package/dist/layouts/index.js +1 -7
  71. package/dist/live-channel/index.js +1 -124
  72. package/dist/pdf-export-policy/index.js +1 -92
  73. package/dist/pdf-table-layout/index.js +1 -993
  74. package/dist/report-runtime-context/index.js +1 -9
  75. package/dist/shared/index.js +1 -6
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.js +1 -9
  78. package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
  79. package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
  80. package/dist/types/components/index.d.ts +1 -0
  81. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
  82. package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
  83. package/dist/types/index.js +1 -88
  84. package/dist/types/lib/appearance/aliases.d.ts +3 -0
  85. package/dist/types/lib/appearance/index.d.ts +1 -0
  86. package/dist/types/lib/appearance/table-density.d.ts +18 -0
  87. package/dist/types/lib/appearance/types.d.ts +39 -1
  88. package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
  89. package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
  90. package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
  91. package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
  92. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  93. package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
  94. package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
  95. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
  96. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  97. package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
  98. package/dist/types/lib/stores/explorer-actions.d.ts +7 -10
  99. package/dist/types/lib/types/common-types.d.ts +1 -2
  100. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  101. package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
  102. package/dist/types/lib/utils/field-placement.d.ts +17 -0
  103. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  104. package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
  105. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
  106. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  107. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  108. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  109. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  110. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  111. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  112. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +180 -0
  113. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  114. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  115. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  116. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
  117. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  118. package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
  119. package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
  120. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  121. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
  122. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
  123. package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
  124. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
  125. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  126. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
  127. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
  128. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  129. package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
  130. package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
  131. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +116 -0
  132. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  133. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  134. package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
  135. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
  136. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
  137. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
  138. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  139. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  140. package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
  141. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
  142. package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
  143. package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
  144. package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
  145. package/dist/usage-events/index.js +1 -285
  146. package/dist/value-format-preferences/index.js +1 -635
  147. package/package.json +5 -2
  148. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  149. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  150. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  151. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  152. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  153. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  154. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  155. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  156. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  157. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  158. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  159. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  160. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  161. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  162. package/dist/chunks/context-UCQ7sere.js +0 -369
  163. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  164. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  165. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  166. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  167. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  168. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  169. package/dist/chunks/edit-9df1zOWe.js +0 -226
  170. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  171. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  172. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  173. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  174. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  175. package/dist/chunks/index-BVKzKl5d.js +0 -90
  176. package/dist/chunks/index-CV_Kzou0.js +0 -595
  177. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  178. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  179. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  180. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  181. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  182. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  183. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  184. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  185. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  186. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  187. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  188. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  189. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  190. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  191. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  192. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  193. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  194. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  195. package/dist/chunks/save-C5A0JnEV.js +0 -21
  196. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  197. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  198. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  199. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  200. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  201. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  202. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  203. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  204. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  205. package/dist/chunks/upload-H15d7uHK.js +0 -15
  206. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  207. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  208. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,600 +0,0 @@
1
- import { T as f, a as h, b as y } from "./analytics-base-schemas-DsUh5Q3C.js";
2
- import { p as C } from "./validators-Baf3VIf5.js";
3
- function P(e) {
4
- switch (e.kind) {
5
- case "monthDay":
6
- return {
7
- subDay: !1,
8
- dataAnchored: !1,
9
- bounds: { start: "day", end: "day" },
10
- comparesBySpan: !1,
11
- printsByName: !1,
12
- dayPickerDefault: !0,
13
- monthPickerDefault: !1
14
- };
15
- case "rolling": {
16
- const r = e.unit === "minute" || e.unit === "hour", o = e.anchor === "latest_data";
17
- return {
18
- subDay: r,
19
- dataAnchored: o,
20
- bounds: { start: "instant", end: "instant" },
21
- comparesBySpan: !1,
22
- printsByName: o || e.unit === "quarter" || e.unit === "year",
23
- dayPickerDefault: !1,
24
- monthPickerDefault: !1,
25
- span: { unit: e.unit, n: e.n, complete: !1 }
26
- };
27
- }
28
- case "periods": {
29
- const { unit: r, from: o, to: n, toDate: i } = e, a = e.anchor === "latest_data", s = e.anchor === "now", l = !!i && s, d = o === n;
30
- return {
31
- subDay: !1,
32
- dataAnchored: a,
33
- ...l && o === 0 ? { periodToDate: r } : {},
34
- // Measured from the end of a complete period, a "to date" window ends on a whole day.
35
- bounds: { start: "day", end: l ? "instant" : "day" },
36
- comparesBySpan: typeof e.anchor == "object",
37
- printsByName: a || r === "quarter" || r === "year",
38
- dayPickerDefault: r === "day" && d && s,
39
- monthPickerDefault: r === "month" && d && (o === 0 || o === -1) && s && !i,
40
- span: { unit: r, n: n - o + 1, complete: n < 0 }
41
- };
42
- }
43
- }
44
- }
45
- function $(e) {
46
- const r = y.safeParse(e);
47
- return r.success ? { ok: !0, value: r.data } : {
48
- ok: !1,
49
- error: {
50
- code: f.invalidMetadata,
51
- message: "Temporal bucket metadata is invalid.",
52
- path: "temporalBucket"
53
- }
54
- };
55
- }
56
- function b(e, r) {
57
- if (!e.temporalBucket)
58
- return r.metadataRequired ? {
59
- ok: !1,
60
- error: {
61
- code: f.missingMetadata,
62
- message: "Activated temporal bucket result is missing metadata.",
63
- path: "temporalBucket"
64
- }
65
- } : { ok: !0 };
66
- const o = $(
67
- e.temporalBucket
68
- );
69
- if (!o.ok || !o.value)
70
- return o;
71
- const n = h(
72
- o.value.granularity
73
- );
74
- return e.dataType !== n ? {
75
- ok: !1,
76
- error: {
77
- code: f.invalidMetadata,
78
- message: `${o.value.granularity} temporal buckets require dataType ${n}.`,
79
- path: "dataType"
80
- }
81
- } : o;
82
- }
83
- function w(e, r) {
84
- var o, n, i, a;
85
- return e.granularity === r.granularity && e.calendar.tz === r.calendar.tz && e.calendar.weekStart === r.calendar.weekStart && ((o = e.calendar.fiscalCalendar) == null ? void 0 : o.kind) === ((n = r.calendar.fiscalCalendar) == null ? void 0 : n.kind) && ((i = e.calendar.fiscalCalendar) == null ? void 0 : i.yearStartMonth) === ((a = r.calendar.fiscalCalendar) == null ? void 0 : a.yearStartMonth);
86
- }
87
- function O(e, r) {
88
- const o = /* @__PURE__ */ new Map();
89
- for (const n of e) {
90
- if (o.has(n.key))
91
- return {
92
- ok: !1,
93
- error: {
94
- code: f.invalidMetadata,
95
- message: `Canonical result contains duplicate column key "${n.key}".`,
96
- path: "columns"
97
- }
98
- };
99
- if (o.set(n.key, n), n.temporalBucket) {
100
- const i = b(n, {
101
- metadataRequired: !1
102
- });
103
- if (!i.ok)
104
- return {
105
- ok: !1,
106
- error: {
107
- ...i.error,
108
- path: `columns.${n.key}.${i.error.path || "temporalBucket"}`
109
- }
110
- };
111
- }
112
- }
113
- for (const n of r) {
114
- const i = o.get(n.key);
115
- if (!i)
116
- return {
117
- ok: !1,
118
- error: {
119
- code: f.missingMetadata,
120
- message: `Activated temporal bucket result is missing column "${n.key}".`,
121
- path: `columns.${n.key}`
122
- }
123
- };
124
- const a = b(i, {
125
- metadataRequired: !0
126
- });
127
- if (!a.ok)
128
- return {
129
- ok: !1,
130
- error: {
131
- ...a.error,
132
- path: `columns.${n.key}.${a.error.path || "temporalBucket"}`
133
- }
134
- };
135
- if (!a.value || !w(a.value, n.metadata))
136
- return {
137
- ok: !1,
138
- error: {
139
- code: f.invalidMetadata,
140
- message: `Temporal bucket metadata for column "${n.key}" contradicts the governed query context.`,
141
- path: `columns.${n.key}.temporalBucket`
142
- }
143
- };
144
- }
145
- return { ok: !0, value: e };
146
- }
147
- const _ = ["period", "day", "week", "month", "quarter", "year"];
148
- function u(e) {
149
- const r = (o) => o !== void 0 && o !== 1 ? { offset: o } : {};
150
- switch (e.kind) {
151
- case "target":
152
- return { kind: "target", targetValue: e.targetValue };
153
- case "shift":
154
- return {
155
- kind: "shift",
156
- unit: e.unit,
157
- ...r(e.offset),
158
- ...e.matchWeekdays && e.unit === "year" ? { matchWeekdays: !0 } : {}
159
- };
160
- case "previous_period":
161
- return { kind: "shift", unit: "period", ...r(e.offsetPeriods) };
162
- case "previous_year":
163
- return {
164
- kind: "shift",
165
- unit: "year",
166
- ...r(e.offsetYears),
167
- ...e.alignment === "weekday" ? { matchWeekdays: !0 } : {}
168
- };
169
- }
170
- }
171
- function R(e) {
172
- const r = u(e);
173
- return r.kind === "target" ? "target" : r.unit === "year" ? "previous_year" : "previous_period";
174
- }
175
- function B(e) {
176
- return e.offset ?? 1;
177
- }
178
- const D = "higher_is_better", E = {
179
- displayMode: "difference",
180
- showComparison: !0,
181
- indicatorStyle: "arrow_badge",
182
- showColor: !0,
183
- conditionalLabel: !1
184
- };
185
- function T(e) {
186
- return C(e) !== null;
187
- }
188
- function M(e) {
189
- var r, o;
190
- return e.hidden || ((r = e.metricComparison) == null ? void 0 : r.mode) === "off" ? { state: "off" } : ((o = e.metricComparison) == null ? void 0 : o.mode) === "explicit" ? { state: "pinned", spec: u(e.metricComparison.spec) } : e.inheritGlobalComparison === !1 ? { state: "off" } : { state: "follow" };
191
- }
192
- function G(e) {
193
- return (e == null ? void 0 : e.showComparison) === !1;
194
- }
195
- function j(e) {
196
- var o, n;
197
- const r = M({
198
- metricComparison: e.metricComparison,
199
- inheritGlobalComparison: e.inheritGlobalComparison ?? ((o = e.globalDateComparison) == null ? void 0 : o.inheritGlobalComparison)
200
- });
201
- if (r.state !== "off") {
202
- if (r.state === "pinned") return { source: "explicit", spec: r.spec };
203
- if (((n = e.globalDateComparison) == null ? void 0 : n.selection.mode) === "period")
204
- return {
205
- source: "inherited",
206
- spec: u(e.globalDateComparison.selection.spec),
207
- ...e.globalDateComparison.owner ? { owner: e.globalDateComparison.owner } : {}
208
- };
209
- }
210
- }
211
- function L(e) {
212
- if (e.alias) return e.alias;
213
- const r = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0, o = r && r !== e.name ? `${r}_` : "";
214
- if (e.role !== "metric") return `${o}${e.name}`;
215
- let n = e.aggregate || "metric";
216
- if (e.expression) {
217
- const i = e.expression.match(
218
- /^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
219
- );
220
- n = i ? i[1].toLowerCase() : "expr";
221
- } else
222
- n = n.toLowerCase();
223
- return `${o}${e.name}_${n}`;
224
- }
225
- function t(e, r, o) {
226
- return o ? { code: e, message: r, path: o } : { code: e, message: r };
227
- }
228
- function m(e) {
229
- return !!e && typeof e == "object" && !Array.isArray(e);
230
- }
231
- function c(e, r, o, n) {
232
- Object.keys(e).forEach((i) => {
233
- r.includes(i) || n.push(
234
- t(
235
- "invalid_comparison_spec",
236
- `Comparison kind does not accept field "${i}".`,
237
- `${o}.${i}`
238
- )
239
- );
240
- });
241
- }
242
- function g(e, r, o) {
243
- e.alignment !== void 0 && e.alignment !== "calendar" && e.alignment !== "weekday" && o.push(
244
- t(
245
- "invalid_comparison_spec",
246
- 'Comparison alignment must be "calendar" or "weekday".',
247
- `${r}.alignment`
248
- )
249
- ), e.toDate !== void 0 && typeof e.toDate != "boolean" && o.push(
250
- t(
251
- "invalid_comparison_spec",
252
- "Comparison toDate must be a boolean.",
253
- `${r}.toDate`
254
- )
255
- );
256
- }
257
- function p(e, r, o) {
258
- e !== void 0 && (typeof e != "number" || !Number.isSafeInteger(e) || e <= 0) && o.push(
259
- t(
260
- "invalid_comparison_spec",
261
- "Comparison offset must be a positive safe integer.",
262
- r
263
- )
264
- );
265
- }
266
- function k(e, r = "comparison") {
267
- const o = [];
268
- return m(e) ? (e.kind === "shift" ? (c(e, ["kind", "unit", "offset", "matchWeekdays"], r, o), _.includes(e.unit) || o.push(
269
- t(
270
- "invalid_comparison_spec",
271
- `Comparison unit must be one of ${_.join(", ")}.`,
272
- `${r}.unit`
273
- )
274
- ), p(e.offset, `${r}.offset`, o), e.matchWeekdays !== void 0 && (e.matchWeekdays !== !0 || e.unit !== "year") && o.push(
275
- t(
276
- "invalid_comparison_spec",
277
- "matchWeekdays is true only on a step by years (52 weeks a year back).",
278
- `${r}.matchWeekdays`
279
- )
280
- )) : e.kind === "previous_period" ? (c(
281
- e,
282
- ["kind", "offsetPeriods", "alignment", "toDate"],
283
- r,
284
- o
285
- ), p(e.offsetPeriods, `${r}.offsetPeriods`, o), g(e, r, o)) : e.kind === "previous_year" ? (c(
286
- e,
287
- ["kind", "offsetYears", "alignment", "toDate"],
288
- r,
289
- o
290
- ), p(e.offsetYears, `${r}.offsetYears`, o), g(e, r, o)) : e.kind === "target" ? (c(e, ["kind", "targetValue"], r, o), (typeof e.targetValue != "number" || !Number.isFinite(e.targetValue)) && o.push(
291
- t(
292
- "invalid_comparison_spec",
293
- "Target comparison requires a finite targetValue.",
294
- `${r}.targetValue`
295
- )
296
- )) : o.push(
297
- t(
298
- "invalid_comparison_spec",
299
- "Comparison kind must be shift or target.",
300
- `${r}.kind`
301
- )
302
- ), { ok: o.length === 0, errors: o, warnings: [] }) : {
303
- ok: !1,
304
- errors: [
305
- t(
306
- "invalid_comparison_spec",
307
- "Comparison spec must be an object.",
308
- r
309
- )
310
- ],
311
- warnings: []
312
- };
313
- }
314
- function V(e, r = "comparison") {
315
- if (!m(e))
316
- return {
317
- ok: !1,
318
- errors: [
319
- t(
320
- "invalid_comparison_config",
321
- "Comparison config must be an object.",
322
- r
323
- )
324
- ],
325
- warnings: []
326
- };
327
- const o = [];
328
- return e.mode === "off" ? c(e, ["mode"], r, o) : e.mode === "explicit" ? (c(e, ["mode", "spec"], r, o), o.push(...k(e.spec, `${r}.spec`).errors)) : o.push(
329
- t(
330
- "invalid_comparison_config",
331
- "Comparison mode must be off or explicit.",
332
- `${r}.mode`
333
- )
334
- ), { ok: o.length === 0, errors: o, warnings: [] };
335
- }
336
- function S(e, r = "comparisonSelection") {
337
- if (!m(e))
338
- return {
339
- ok: !1,
340
- errors: [
341
- t(
342
- "invalid_global_date_comparison",
343
- "Global Date comparison selection must be an object.",
344
- r
345
- )
346
- ],
347
- warnings: []
348
- };
349
- const o = [];
350
- if (e.mode === "off")
351
- c(e, ["mode"], r, o);
352
- else if (e.mode === "period") {
353
- c(e, ["mode", "spec"], r, o);
354
- const n = k(e.spec, `${r}.spec`);
355
- o.push(...n.errors), m(e.spec) && e.spec.kind === "target" && o.push(
356
- t(
357
- "invalid_global_date_comparison",
358
- "A dashboard date comparison is a step back (shift), not a target.",
359
- `${r}.spec.kind`
360
- )
361
- );
362
- } else
363
- o.push(
364
- t(
365
- "invalid_global_date_comparison",
366
- "Global Date comparison mode must be off or period.",
367
- `${r}.mode`
368
- )
369
- );
370
- return { ok: o.length === 0, errors: o, warnings: [] };
371
- }
372
- function q(e, r = "globalDateComparison") {
373
- if (!m(e))
374
- return {
375
- ok: !1,
376
- errors: [
377
- t(
378
- "invalid_global_date_comparison",
379
- "Global Date comparison context must be an object.",
380
- r
381
- )
382
- ],
383
- warnings: []
384
- };
385
- const o = [];
386
- return c(
387
- e,
388
- ["selection", "inheritGlobalComparison", "owner", "referenceTime"],
389
- r,
390
- o
391
- ), o.push(
392
- ...S(
393
- e.selection,
394
- `${r}.selection`
395
- ).errors
396
- ), e.inheritGlobalComparison !== void 0 && e.inheritGlobalComparison !== !1 && o.push(
397
- t(
398
- "invalid_global_date_comparison",
399
- "inheritGlobalComparison may only be false when present.",
400
- `${r}.inheritGlobalComparison`
401
- )
402
- ), e.owner !== void 0 && (m(e.owner) ? e.owner.kind === "global_date" ? c(e.owner, ["kind"], `${r}.owner`, o) : e.owner.kind === "field_date" ? (c(
403
- e.owner,
404
- ["kind", "filterId", "label"],
405
- `${r}.owner`,
406
- o
407
- ), (typeof e.owner.filterId != "string" || !e.owner.filterId.trim()) && o.push(
408
- t(
409
- "invalid_global_date_comparison",
410
- "Field Date comparison owner requires a non-empty filterId.",
411
- `${r}.owner.filterId`
412
- )
413
- ), (typeof e.owner.label != "string" || !e.owner.label.trim()) && o.push(
414
- t(
415
- "invalid_global_date_comparison",
416
- "Field Date comparison owner requires a non-empty label.",
417
- `${r}.owner.label`
418
- )
419
- )) : o.push(
420
- t(
421
- "invalid_global_date_comparison",
422
- "Comparison owner kind must be global_date or field_date.",
423
- `${r}.owner.kind`
424
- )
425
- ) : o.push(
426
- t(
427
- "invalid_global_date_comparison",
428
- "Comparison owner must be an object.",
429
- `${r}.owner`
430
- )
431
- )), e.referenceTime !== void 0 && (typeof e.referenceTime != "string" || !T(e.referenceTime)) && o.push(
432
- t(
433
- "invalid_global_date_comparison",
434
- "referenceTime must be a valid ISO date-time string when present.",
435
- `${r}.referenceTime`
436
- )
437
- ), { ok: o.length === 0, errors: o, warnings: [] };
438
- }
439
- function x(e) {
440
- const { referenceTime: r, ...o } = e;
441
- return o;
442
- }
443
- function F(e, r = "comparisonPolarity") {
444
- return e === "higher_is_better" || e === "lower_is_better" || e === "neutral" ? { ok: !0, errors: [], warnings: [] } : {
445
- ok: !1,
446
- errors: [
447
- t(
448
- "invalid_comparison_polarity",
449
- "Comparison polarity must be higher_is_better, lower_is_better, or neutral.",
450
- r
451
- )
452
- ],
453
- warnings: []
454
- };
455
- }
456
- function W(e, r = "comparisonPresentation") {
457
- if (!m(e))
458
- return {
459
- ok: !1,
460
- errors: [
461
- t(
462
- "invalid_comparison_presentation",
463
- "Comparison presentation must be an object.",
464
- r
465
- )
466
- ],
467
- warnings: []
468
- };
469
- const o = [], n = [
470
- "displayMode",
471
- "showComparison",
472
- "precision",
473
- "indicatorStyle",
474
- "showColor",
475
- "position",
476
- "conditionalLabel",
477
- "labelName",
478
- "conditionalLabels",
479
- "colors"
480
- ];
481
- return Object.keys(e).forEach((a) => {
482
- n.includes(a) || o.push(
483
- t(
484
- "invalid_comparison_presentation",
485
- `Comparison presentation does not accept field "${a}".`,
486
- `${r}.${a}`
487
- )
488
- );
489
- }), [
490
- ["displayMode", ["difference", "percent_change", "both", "ratio"]],
491
- ["indicatorStyle", ["arrow_badge", "arrow", "badge", "none"]],
492
- ["position", ["left", "right", "top"]]
493
- ].forEach(([a, s]) => {
494
- e[a] !== void 0 && !s.includes(e[a]) && o.push(
495
- t(
496
- "invalid_comparison_presentation",
497
- `Comparison presentation ${a} is invalid.`,
498
- `${r}.${a}`
499
- )
500
- );
501
- }), ["showComparison", "showColor", "conditionalLabel"].forEach((a) => {
502
- e[a] !== void 0 && typeof e[a] != "boolean" && o.push(
503
- t(
504
- "invalid_comparison_presentation",
505
- `Comparison presentation ${a} must be a boolean.`,
506
- `${r}.${a}`
507
- )
508
- );
509
- }), e.precision !== void 0 && (typeof e.precision != "number" || !Number.isInteger(e.precision) || e.precision < 0 || e.precision > 6) && o.push(
510
- t(
511
- "invalid_comparison_presentation",
512
- "Comparison presentation precision must be an integer from 0 through 6.",
513
- `${r}.precision`
514
- )
515
- ), e.labelName !== void 0 && typeof e.labelName != "string" && o.push(
516
- t(
517
- "invalid_comparison_presentation",
518
- "Comparison presentation labelName must be a string.",
519
- `${r}.labelName`
520
- )
521
- ), ["conditionalLabels", "colors"].forEach((a) => {
522
- const s = e[a];
523
- if (s !== void 0) {
524
- if (!m(s)) {
525
- o.push(
526
- t(
527
- "invalid_comparison_presentation",
528
- `Comparison presentation ${a} must be an object.`,
529
- `${r}.${a}`
530
- )
531
- );
532
- return;
533
- }
534
- Object.keys(s).forEach((l) => {
535
- ["increase", "decrease", "neutral"].includes(l) || o.push(
536
- t(
537
- "invalid_comparison_presentation",
538
- `Comparison presentation ${a} does not accept field "${l}".`,
539
- `${r}.${a}.${l}`
540
- )
541
- );
542
- }), Object.entries(s).forEach(([l, d]) => {
543
- d !== void 0 && typeof d != "string" && o.push(
544
- t(
545
- "invalid_comparison_presentation",
546
- `Comparison presentation ${a}.${l} must be a string.`,
547
- `${r}.${a}.${l}`
548
- )
549
- );
550
- });
551
- }
552
- }), { ok: o.length === 0, errors: o, warnings: [] };
553
- }
554
- function v(e) {
555
- return e === null ? "unknown" : e > 0 ? "increase" : e < 0 ? "decrease" : "no_change";
556
- }
557
- function N(e, r) {
558
- return e === "unknown" || e === "no_change" || r === "neutral" ? "neutral" : r === "higher_is_better" && e === "increase" || r === "lower_is_better" && e === "decrease" ? "favorable" : "unfavorable";
559
- }
560
- function U(e) {
561
- const {
562
- currentValue: r,
563
- comparisonValue: o,
564
- polarity: n = D
565
- } = e, a = r !== null && o !== null ? r - o : null, s = a !== null && o !== null && o !== 0 ? a / Math.abs(o) : null, l = r !== null && o !== null && o !== 0 ? r / o : null, d = v(a);
566
- return {
567
- status: o === null ? "insufficient_history" : "available",
568
- currentValue: r,
569
- comparisonValue: o,
570
- delta: a,
571
- percentChange: s,
572
- ratio: l,
573
- direction: d,
574
- sentiment: N(d, n)
575
- };
576
- }
577
- export {
578
- _ as C,
579
- D,
580
- P as a,
581
- u as b,
582
- R as c,
583
- B as d,
584
- E as e,
585
- M as f,
586
- G as g,
587
- j as h,
588
- k as i,
589
- V as j,
590
- S as k,
591
- q as l,
592
- F as m,
593
- W as n,
594
- U as o,
595
- b as p,
596
- O as q,
597
- L as r,
598
- $ as v,
599
- x as w
600
- };
@@ -1,119 +0,0 @@
1
- import { useState as D, useRef as y, useEffect as h, useCallback as x } from "react";
2
- const L = (n) => JSON.stringify(n, (e, r) => !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((t, i) => (t[i] = r[i], t), {}));
3
- function F(n, e, r = 300, t = 1e3, i) {
4
- const [C, f] = D(!1), [I, c] = D(!1), a = y(null), o = y(0), T = y(n), g = y(e), l = i || L;
5
- h(() => {
6
- o.current += 1;
7
- const m = o.current, w = T.current !== n, N = g.current !== e;
8
- if (T.current = n, g.current = e, e === null) {
9
- const u = window.setTimeout(() => {
10
- m === o.current && (f(!1), c(!1));
11
- }, 0);
12
- return () => clearTimeout(u);
13
- }
14
- if (N && !w) {
15
- const u = window.setTimeout(() => {
16
- if (m === o.current) {
17
- const s = l(n), d = l(e);
18
- f(s !== d), c(!1);
19
- }
20
- }, 0);
21
- return () => clearTimeout(u);
22
- }
23
- const k = w ? window.setTimeout(() => {
24
- m === o.current && c(!0);
25
- }, 0) : null, R = setTimeout(() => {
26
- const u = window.requestIdleCallback || ((s) => window.setTimeout(
27
- () => s({
28
- didTimeout: !1,
29
- timeRemaining: () => 50
30
- }),
31
- 1
32
- ));
33
- a.current = u(
34
- (s) => {
35
- if (s.timeRemaining() > 0 || s.didTimeout) {
36
- if (m !== o.current) return;
37
- const d = l(n), p = l(e);
38
- f(d !== p), c(!1);
39
- }
40
- },
41
- { timeout: t }
42
- );
43
- }, r);
44
- return () => {
45
- k !== null && clearTimeout(k), clearTimeout(R), a.current !== null && ((window.cancelIdleCallback || window.clearTimeout)(a.current), a.current = null);
46
- };
47
- }, [n, e, r, t, l]);
48
- const A = x(() => {
49
- f(!1), c(!1);
50
- }, []);
51
- return {
52
- isDirty: e === null ? !1 : C,
53
- isDirtyPending: e === null ? !1 : I,
54
- resetDirty: A
55
- };
56
- }
57
- const O = [
58
- "i",
59
- "x",
60
- "y",
61
- "w",
62
- "h",
63
- "minW",
64
- "minH",
65
- "maxW",
66
- "maxH",
67
- "static",
68
- "isResizable",
69
- "isDraggable"
70
- ];
71
- function P(n, e, r) {
72
- n[e] = r;
73
- }
74
- function j(n) {
75
- const e = {};
76
- for (const r of O) {
77
- const t = n[r];
78
- t !== void 0 && ((r === "isResizable" || r === "isDraggable") && t === !0 || P(e, r, t));
79
- }
80
- return e;
81
- }
82
- function b(n) {
83
- return n ? n.map(j).sort((e, r) => {
84
- const t = String(e.i ?? ""), i = String(r.i ?? "");
85
- return t !== i ? t.localeCompare(i) : Number(e.y ?? 0) - Number(r.y ?? 0) || Number(e.x ?? 0) - Number(r.x ?? 0) || Number(e.h ?? 0) - Number(r.h ?? 0) || Number(e.w ?? 0) - Number(r.w ?? 0);
86
- }) : [];
87
- }
88
- function z(n) {
89
- if (!n) return;
90
- const e = {};
91
- for (const r of Object.keys(n).sort()) {
92
- const t = n[r];
93
- t && (e[r] = b(t));
94
- }
95
- return e;
96
- }
97
- function S(n) {
98
- var e;
99
- return n ? {
100
- ...n,
101
- sheets: (e = n.sheets) == null ? void 0 : e.map((r) => {
102
- if (!r) return r;
103
- const t = {
104
- ...r
105
- };
106
- return r.layout && (t.layout = b(r.layout)), r.layouts && (t.layouts = z(r.layouts)), t;
107
- })
108
- } : null;
109
- }
110
- function _(n) {
111
- return JSON.stringify(n ?? null, function(e, r) {
112
- return e === "layout" && Array.isArray(r) ? b(r) : e === "layouts" && r && typeof r == "object" && !Array.isArray(r) ? z(r) : !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((t, i) => (t[i] = r[i], t), {});
113
- });
114
- }
115
- export {
116
- S as n,
117
- _ as s,
118
- F as u
119
- };