react-semaphor 0.1.449 → 0.1.453

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 (134) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +115 -109
  3. package/dist/appearance/index.cjs +1 -1
  4. package/dist/appearance/index.js +1 -1
  5. package/dist/brand-studio/index.cjs +4 -4
  6. package/dist/brand-studio/index.js +15 -13
  7. package/dist/briefings/index.cjs +1 -1
  8. package/dist/briefings/index.js +39 -2131
  9. package/dist/chunks/{analyze-result-contract-BHb7sUUW.cjs → analyze-result-contract-Dxw66nUG.cjs} +1 -1
  10. package/dist/chunks/{analyze-result-contract-T-0Ntzys.js → analyze-result-contract-GHKFwThg.js} +1 -1
  11. package/dist/chunks/canonical-result-keys-Drc2x-lf.cjs +1 -0
  12. package/dist/chunks/canonical-result-keys-KLk__J_O.js +466 -0
  13. package/dist/chunks/color-CJvdlFM_.js +2162 -0
  14. package/dist/chunks/color-CyB5o13F.cjs +4 -0
  15. package/dist/chunks/{common-types-CQ6SHfLk.cjs → common-types-Ci66eflG.cjs} +1 -1
  16. package/dist/chunks/{common-types-B7Jk3Rtj.js → common-types-F6qk6PPS.js} +1 -1
  17. package/dist/chunks/contracts-CoCOpd_i.js +11 -0
  18. package/dist/chunks/contracts-CtB2VONT.cjs +1 -0
  19. package/dist/chunks/{dashboard-briefing-launcher-DCHiEkLE.js → dashboard-briefing-launcher-CFpX0WX3.js} +86 -84
  20. package/dist/chunks/dashboard-briefing-launcher-mUXWuiOZ.cjs +26 -0
  21. package/dist/chunks/{dashboard-controls-DwRFCcHV.js → dashboard-controls-BeYAmOJc.js} +15 -13
  22. package/dist/chunks/{dashboard-controls-CaFioayc.cjs → dashboard-controls-SoNubIu1.cjs} +1 -1
  23. package/dist/chunks/dashboard-json-BublPnQ4.cjs +1 -0
  24. package/dist/chunks/{dashboard-json-WoILbfTe.js → dashboard-json-DeLUagVV.js} +25 -23
  25. package/dist/chunks/edit-dashboard-visual-CrvPcO7A.cjs +172 -0
  26. package/dist/chunks/{edit-dashboard-visual-ciFhxqaI.js → edit-dashboard-visual-Go0h82DR.js} +6925 -6947
  27. package/dist/chunks/editor-action-buttons-1Lo0fIh7.cjs +16 -0
  28. package/dist/chunks/{editor-action-buttons-BPo_45pM.js → editor-action-buttons-BFNtjFzO.js} +41 -39
  29. package/dist/chunks/format-types-CFHQoIuk.js +1350 -0
  30. package/dist/chunks/format-types-PSZZ7hG8.cjs +1 -0
  31. package/dist/chunks/index-B3ZugihZ.js +3713 -0
  32. package/dist/chunks/{index-CPuawpXJ.js → index-BsH32bn1.js} +47472 -47845
  33. package/dist/chunks/index-ByFbacH7.cjs +1 -0
  34. package/dist/chunks/index-CACdoqu3.js +318 -0
  35. package/dist/chunks/index-DSKR3nKn.js +421 -0
  36. package/dist/chunks/index-DjiIh_9n.cjs +4 -0
  37. package/dist/chunks/index-F25jnH0p.cjs +1 -0
  38. package/dist/chunks/index-q12_nNUS.cjs +1392 -0
  39. package/dist/chunks/{metric-comparison-97zHGEx5.js → metric-comparison-D0T0MKRK.js} +1 -1
  40. package/dist/chunks/{metric-comparison-CUAJ8n4y.cjs → metric-comparison-DYR3RXam.cjs} +1 -1
  41. package/dist/chunks/pivot-header-presentation-DcfPaCiy.cjs +4 -0
  42. package/dist/chunks/pivot-header-presentation-nk604qc1.js +557 -0
  43. package/dist/chunks/{pivot-result-identity-CwJWpKI7.js → pivot-result-identity-C43Ai5Kr.js} +1 -1
  44. package/dist/chunks/{pivot-result-identity-CDLRT-YG.cjs → pivot-result-identity-CRUokNgm.cjs} +1 -1
  45. package/dist/chunks/pivot-result-lifecycle-4kSe0Hk1.js +1642 -0
  46. package/dist/chunks/pivot-result-lifecycle-BiJepH5S.cjs +1 -0
  47. package/dist/chunks/raw-temporal-contract-BF7PjBY9.js +64 -0
  48. package/dist/chunks/raw-temporal-contract-CxbRFwnd.cjs +1 -0
  49. package/dist/chunks/report-preferences-dialog-BEVZAE3m.cjs +1 -0
  50. package/dist/chunks/report-preferences-dialog-BNV7qXYH.js +723 -0
  51. package/dist/chunks/{report-runtime-context-bCy3CVzK.js → report-runtime-context-BJQDu2fV.js} +1 -1
  52. package/dist/chunks/{report-runtime-context-C8LZFsqV.cjs → report-runtime-context-DjYqLV-c.cjs} +1 -1
  53. package/dist/chunks/saved-temporal-bucket-format-DiZdQXOL.js +924 -0
  54. package/dist/chunks/saved-temporal-bucket-format-Gfbh4IiP.cjs +1 -0
  55. package/dist/chunks/switch-CjJ6FHYJ.cjs +138 -0
  56. package/dist/chunks/{switch-BXet-Sno.js → switch-DgLwr7O-.js} +4352 -5249
  57. package/dist/chunks/temporal-bucket-Dnj8qT9l.cjs +1 -0
  58. package/dist/chunks/temporal-bucket-FBZGrDCe.js +560 -0
  59. package/dist/chunks/temporal-bucket-authoring-7hv2laOG.cjs +1 -0
  60. package/dist/chunks/temporal-bucket-authoring-FIRnJz0e.js +221 -0
  61. package/dist/chunks/{temporal-bucket-contract-_F6vNhhH.js → temporal-bucket-contract-BQOj6Frl.js} +1 -1
  62. package/dist/chunks/{temporal-bucket-contract-ChDBWX8I.cjs → temporal-bucket-contract-anl4h-vg.cjs} +1 -1
  63. package/dist/chunks/{token-types-BHR58aTy.js → token-types-CRpQJ4kv.js} +1 -1
  64. package/dist/chunks/{token-types-BdQ8kHBm.cjs → token-types-D0i0IUX3.cjs} +1 -1
  65. package/dist/chunks/{update-policy-BxvYMYz0.cjs → update-policy-C1i9bgsy.cjs} +1 -1
  66. package/dist/chunks/{update-policy-g0rCQ9BM.js → update-policy-CaJz9aPG.js} +1 -1
  67. package/dist/chunks/{validators-Cs74WVie.js → validators-DeMXwRON.js} +253 -233
  68. package/dist/chunks/validators-Dm7Kpz6p.cjs +1 -0
  69. package/dist/dashboard/index.cjs +1 -1
  70. package/dist/dashboard/index.js +2 -2
  71. package/dist/dashboard-authoring/index.cjs +3 -3
  72. package/dist/dashboard-authoring/index.js +32 -29
  73. package/dist/data-app-builder/index.cjs +1 -1
  74. package/dist/data-app-builder/index.js +2 -2
  75. package/dist/data-app-codegen/index.cjs +1 -1
  76. package/dist/data-app-codegen/index.js +2 -2
  77. package/dist/data-app-codegen-node/index.cjs +1 -1
  78. package/dist/data-app-codegen-node/index.js +3 -3
  79. package/dist/data-app-sdk/index.cjs +1 -1
  80. package/dist/data-app-sdk/index.js +3 -3
  81. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  82. package/dist/data-app-sdk-adapters/index.js +2 -2
  83. package/dist/data-app-sdk-validation/index.cjs +1 -1
  84. package/dist/data-app-sdk-validation/index.js +3 -3
  85. package/dist/format-utils/index.cjs +3 -3
  86. package/dist/format-utils/index.js +162 -145
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.js +157 -155
  89. package/dist/report-runtime-context/index.cjs +1 -1
  90. package/dist/report-runtime-context/index.js +2 -2
  91. package/dist/style.css +1 -1
  92. package/dist/surfboard/index.cjs +1 -1
  93. package/dist/surfboard/index.js +3 -3
  94. package/dist/types/analytics-protocol.d.ts +37 -0
  95. package/dist/types/briefings.d.ts +718 -7
  96. package/dist/types/dashboard-assistant.d.ts +18 -0
  97. package/dist/types/dashboard-authoring.d.ts +52 -2
  98. package/dist/types/dashboard.d.ts +128 -0
  99. package/dist/types/data-app-sdk-validation.d.ts +13 -0
  100. package/dist/types/data-app-sdk.d.ts +13 -0
  101. package/dist/types/format-utils.d.ts +190 -3
  102. package/dist/types/index.cjs +1 -1
  103. package/dist/types/index.js +4 -4
  104. package/dist/types/main.d.ts +103 -12
  105. package/dist/types/shared.d.ts +5 -0
  106. package/dist/types/surfboard.d.ts +129 -1
  107. package/dist/types/types.d.ts +98 -6
  108. package/dist/types/value-format-preferences.d.ts +3 -0
  109. package/package.json +2 -1
  110. package/dist/chunks/card-config-utils-15sRtebL.cjs +0 -1
  111. package/dist/chunks/card-config-utils-BYZ5MJOh.js +0 -16
  112. package/dist/chunks/dashboard-briefing-launcher-DDgDr2s3.cjs +0 -26
  113. package/dist/chunks/dashboard-json-CYtvwtvj.cjs +0 -1
  114. package/dist/chunks/edit-dashboard-visual-DwKcvlsF.cjs +0 -177
  115. package/dist/chunks/editor-action-buttons-BVmsk0Aj.cjs +0 -16
  116. package/dist/chunks/format-types-CSv0V7mm.cjs +0 -1
  117. package/dist/chunks/format-types-DZGgYj39.js +0 -1663
  118. package/dist/chunks/index-CJdxSyQq.js +0 -2578
  119. package/dist/chunks/index-DPv8_Ild.cjs +0 -1395
  120. package/dist/chunks/index-DRlMUglg.cjs +0 -4
  121. package/dist/chunks/pivot-result-lifecycle-BBabQ_da.js +0 -914
  122. package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +0 -4
  123. package/dist/chunks/presentation-execution-BLfPTGX_.js +0 -637
  124. package/dist/chunks/presentation-execution-BTV-Q43g.cjs +0 -1
  125. package/dist/chunks/report-preferences-dialog-D9ZCGh9l.js +0 -691
  126. package/dist/chunks/report-preferences-dialog-DaqTEcac.cjs +0 -1
  127. package/dist/chunks/switch-Cjk6G06r.cjs +0 -138
  128. package/dist/chunks/temporal-bucket-BnPxGrAi.js +0 -446
  129. package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +0 -1
  130. package/dist/chunks/temporal-bucket-authoring-CgOuakGW.js +0 -205
  131. package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +0 -1
  132. package/dist/chunks/temporal-result-owner-6peubmhU.js +0 -443
  133. package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +0 -1
  134. package/dist/chunks/validators-9D4KBqKD.cjs +0 -1
@@ -0,0 +1,723 @@
1
+ import { jsxs as o, Fragment as j, jsx as t } from "react/jsx-runtime";
2
+ import oe, { useState as S, useRef as X, useEffect as U, useCallback as E, useMemo as _ } from "react";
3
+ import { az as ee, aA as ce, aB as B, aC as $, aD as de, h as ue, i as me, j as fe, k as he, l as M, m as H, aE as ve, aF as V, aG as z, b as ye, aH as pe, aI as ge, aJ as Se, aK as be, aL as Te } from "./index-BsH32bn1.js";
4
+ import { u as ae, c as F, O as W, P as we, a as Ce, B as L, b as ke, d as q, L as te, T as xe, F as Ne, G, I as K } from "./switch-DgLwr7O-.js";
5
+ import { a as Pe } from "./report-runtime-context-BJQDu2fV.js";
6
+ import "./x-CXDkqdur.js";
7
+ import "./saved-temporal-bucket-format-DiZdQXOL.js";
8
+ import "./validators-DeMXwRON.js";
9
+ import "./analyze-result-contract-GHKFwThg.js";
10
+ import { parseValueFormatPreferencesResponse as Ae, canonicalizeSupportedLocale as Ee, canonicalizeSupportedCurrencyCode as ze } from "../value-format-preferences/index.js";
11
+ function Le(e = {}) {
12
+ const { authToken: i, tokenProps: a } = ee(), d = ae(
13
+ (g) => g.actions.applyResolvedCalendarPreferences
14
+ ), r = e.enabled ?? !0, l = (i == null ? void 0 : i.accessToken) ?? null, m = (a == null ? void 0 : a.apiServiceUrl) ?? null, [y, p] = S(!1), [b, w] = S(!1), [u, T] = S(!1), [C, h] = S(null), [k, P] = S(null), f = X(l);
15
+ f.current = l, U(() => {
16
+ P(null), h(null), p(!1), w(!1), T(!1);
17
+ }, [l]);
18
+ const N = E(async (g) => {
19
+ const s = Pe(await g.json());
20
+ if (!s.ok)
21
+ throw new Error("Calendar preferences response is invalid");
22
+ return s.value;
23
+ }, []), x = E(async () => {
24
+ if (!r || !l || !m) return;
25
+ const g = l;
26
+ p(!0), h(null);
27
+ try {
28
+ const s = await fetch(
29
+ `${m}/v1/user-preferences/calendar`,
30
+ {
31
+ method: "GET",
32
+ headers: { Authorization: `Bearer ${l}` }
33
+ }
34
+ );
35
+ if (!s.ok) {
36
+ const v = await s.json().catch(() => ({}));
37
+ throw new Error(v.error || "Failed to fetch preferences");
38
+ }
39
+ const n = await N(s);
40
+ f.current === g && P(n);
41
+ } catch (s) {
42
+ f.current === g && h(s instanceof Error ? s.message : "Unknown error");
43
+ } finally {
44
+ f.current === g && p(!1);
45
+ }
46
+ }, [l, m, r, N]);
47
+ U(() => {
48
+ r && x();
49
+ }, [r, x]);
50
+ const A = E(
51
+ async (g) => {
52
+ if (!l || !m)
53
+ return h("Not authenticated"), !1;
54
+ const s = l;
55
+ w(!0), h(null);
56
+ try {
57
+ const n = await fetch(
58
+ `${m}/v1/user-preferences/calendar`,
59
+ {
60
+ method: "PATCH",
61
+ headers: {
62
+ "Content-Type": "application/json",
63
+ Authorization: `Bearer ${l}`
64
+ },
65
+ body: JSON.stringify(g)
66
+ }
67
+ );
68
+ if (!n.ok) {
69
+ const R = await n.json().catch(() => ({}));
70
+ throw new Error(R.error || "Failed to update preferences");
71
+ }
72
+ const v = await N(n);
73
+ return f.current !== s ? !1 : (P(v), d(v.resolved, v.sources), !0);
74
+ } catch (n) {
75
+ return f.current === s && h(n instanceof Error ? n.message : "Unknown error"), !1;
76
+ } finally {
77
+ f.current === s && w(!1);
78
+ }
79
+ },
80
+ [
81
+ l,
82
+ m,
83
+ d,
84
+ N
85
+ ]
86
+ ), D = E(async () => {
87
+ if (!l || !m)
88
+ return h("Not authenticated"), !1;
89
+ const g = l;
90
+ T(!0), h(null);
91
+ try {
92
+ const s = await fetch(
93
+ `${m}/v1/user-preferences/calendar`,
94
+ {
95
+ method: "DELETE",
96
+ headers: { Authorization: `Bearer ${l}` }
97
+ }
98
+ );
99
+ if (!s.ok) {
100
+ const v = await s.json().catch(() => ({}));
101
+ throw new Error(v.error || "Failed to clear preferences");
102
+ }
103
+ const n = await N(s);
104
+ return f.current !== g ? !1 : (P(n), d(n.resolved, n.sources), !0);
105
+ } catch (s) {
106
+ return f.current === g && h(s instanceof Error ? s.message : "Unknown error"), !1;
107
+ } finally {
108
+ f.current === g && T(!1);
109
+ }
110
+ }, [
111
+ l,
112
+ m,
113
+ d,
114
+ N
115
+ ]);
116
+ return {
117
+ preferences: k,
118
+ isLoading: y,
119
+ isSaving: b,
120
+ isClearing: u,
121
+ error: C,
122
+ updatePreferences: A,
123
+ clearPreferences: D,
124
+ refetch: x
125
+ };
126
+ }
127
+ const I = [
128
+ { value: "America/New_York", label: "Eastern Time (US & Canada)" },
129
+ { value: "America/Chicago", label: "Central Time (US & Canada)" },
130
+ { value: "America/Denver", label: "Mountain Time (US & Canada)" },
131
+ { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
132
+ { value: "America/Phoenix", label: "Arizona" },
133
+ { value: "America/Anchorage", label: "Alaska" },
134
+ { value: "Pacific/Honolulu", label: "Hawaii" },
135
+ { value: "Europe/London", label: "London" },
136
+ { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
137
+ { value: "Asia/Tokyo", label: "Tokyo" },
138
+ { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
139
+ { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
140
+ { value: "Australia/Sydney", label: "Sydney" },
141
+ { value: "UTC", label: "UTC" }
142
+ ], re = [
143
+ { value: 0, label: "Sunday" },
144
+ { value: 1, label: "Monday" },
145
+ { value: 6, label: "Saturday" }
146
+ ], J = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
147
+ function De() {
148
+ try {
149
+ const e = Intl;
150
+ if (e.supportedValuesOf)
151
+ return e.supportedValuesOf("timeZone");
152
+ } catch {
153
+ }
154
+ return I.map((e) => e.value);
155
+ }
156
+ function Fe(e) {
157
+ if (!e) return "default";
158
+ if (e.tz !== e.weekStart) return "inherited";
159
+ switch (e.tz) {
160
+ case "viewer_tenant":
161
+ return "tenant";
162
+ case "viewer_organization":
163
+ return "organization";
164
+ case "system_default":
165
+ return "system";
166
+ case "session_initial":
167
+ return "embedded";
168
+ default:
169
+ return "default";
170
+ }
171
+ }
172
+ function Y(e) {
173
+ const i = I.find((a) => a.value === e);
174
+ return i ? i.label : e;
175
+ }
176
+ function Re(e) {
177
+ const i = re.find((a) => a.value === e);
178
+ return i ? i.label : String(e);
179
+ }
180
+ function je({
181
+ active: e,
182
+ onClose: i
183
+ }) {
184
+ const {
185
+ preferences: a,
186
+ isLoading: d,
187
+ isSaving: r,
188
+ isClearing: l,
189
+ updatePreferences: m,
190
+ clearPreferences: y
191
+ } = Le({ enabled: e }), p = ce(), b = (a == null ? void 0 : a.resolved.tz) || (p == null ? void 0 : p.tz) || "UTC", w = (a == null ? void 0 : a.resolved.weekStart) ?? (p == null ? void 0 : p.weekStart) ?? 1, [u, T] = S((a == null ? void 0 : a.stored) === null), [C, h] = S(!1), [k, P] = S(
192
+ b
193
+ ), [f, N] = S(
194
+ w
195
+ ), [x, A] = S(!1), D = _(() => De(), []), g = _(
196
+ () => D.filter(
197
+ (c) => !I.some((ie) => ie.value === c)
198
+ ),
199
+ [D]
200
+ ), s = _(() => Y(k), [k]), n = a != null && a.inherited ? Y(a.inherited.tz) : "UTC", v = a != null && a.inherited ? Re(a.inherited.weekStart) : "Monday", R = Fe(
201
+ a == null ? void 0 : a.inheritedSources
202
+ );
203
+ oe.useEffect(() => {
204
+ if (!e) {
205
+ h(!1);
206
+ return;
207
+ }
208
+ C || (a && T(a.stored === null), P(b), N(w));
209
+ }, [
210
+ e,
211
+ C,
212
+ a,
213
+ b,
214
+ w
215
+ ]);
216
+ const se = async () => {
217
+ if (d) {
218
+ z.error("Preferences are still loading. Please try again.");
219
+ return;
220
+ }
221
+ u ? await y() ? (z.success("Now using default settings."), i()) : z.error("Failed to save preferences. Please try again.") : await m({
222
+ tz: k,
223
+ weekStart: f
224
+ }) ? (z.success("Preferences saved."), i()) : z.error("Failed to save preferences. Please try again.");
225
+ }, ne = () => {
226
+ i();
227
+ }, O = r || l, le = O || d;
228
+ return /* @__PURE__ */ o(j, { children: [
229
+ /* @__PURE__ */ o("div", { className: "space-y-4 py-1", children: [
230
+ /* @__PURE__ */ o(
231
+ B,
232
+ {
233
+ value: u ? "defaults" : "custom",
234
+ onValueChange: (c) => {
235
+ h(!0), T(c === "defaults");
236
+ },
237
+ className: "space-y-0.5",
238
+ children: [
239
+ /* @__PURE__ */ o(
240
+ "label",
241
+ {
242
+ htmlFor: "mode-defaults",
243
+ className: F(
244
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
245
+ u && "bg-muted/50"
246
+ ),
247
+ onClick: () => {
248
+ h(!0), T(!0);
249
+ },
250
+ children: [
251
+ /* @__PURE__ */ t(
252
+ $,
253
+ {
254
+ value: "defaults",
255
+ id: "mode-defaults",
256
+ className: "mt-0.5"
257
+ }
258
+ ),
259
+ /* @__PURE__ */ o("div", { className: "flex-1 min-w-0", children: [
260
+ /* @__PURE__ */ o("p", { className: "text-[13px] font-medium text-foreground", children: [
261
+ "Use ",
262
+ R,
263
+ " defaults"
264
+ ] }),
265
+ /* @__PURE__ */ o("p", { className: "text-[12px] text-muted-foreground", children: [
266
+ n,
267
+ ", week starts ",
268
+ v
269
+ ] })
270
+ ] })
271
+ ]
272
+ }
273
+ ),
274
+ /* @__PURE__ */ o(
275
+ "label",
276
+ {
277
+ htmlFor: "mode-custom",
278
+ className: F(
279
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
280
+ !u && "bg-muted/50"
281
+ ),
282
+ onClick: () => {
283
+ h(!0), T(!1);
284
+ },
285
+ children: [
286
+ /* @__PURE__ */ t(
287
+ $,
288
+ {
289
+ value: "custom",
290
+ id: "mode-custom",
291
+ className: "mt-0.5"
292
+ }
293
+ ),
294
+ /* @__PURE__ */ t("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
295
+ ]
296
+ }
297
+ )
298
+ ]
299
+ }
300
+ ),
301
+ /* @__PURE__ */ o(
302
+ "div",
303
+ {
304
+ className: F(
305
+ "space-y-4 border-t border-border/60 pt-4 transition-opacity",
306
+ u && "pointer-events-none opacity-50"
307
+ ),
308
+ children: [
309
+ /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
310
+ /* @__PURE__ */ t(W, { className: J, children: "Timezone" }),
311
+ /* @__PURE__ */ o(
312
+ we,
313
+ {
314
+ open: x,
315
+ onOpenChange: A,
316
+ modal: !0,
317
+ children: [
318
+ /* @__PURE__ */ t(Ce, { asChild: !0, children: /* @__PURE__ */ o(
319
+ L,
320
+ {
321
+ variant: "outline",
322
+ size: "xs",
323
+ role: "combobox",
324
+ "aria-expanded": x,
325
+ className: "w-full justify-between text-[12px] font-normal",
326
+ disabled: u,
327
+ children: [
328
+ /* @__PURE__ */ t("span", { className: "truncate", children: s }),
329
+ /* @__PURE__ */ t(de, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
330
+ ]
331
+ }
332
+ ) }),
333
+ /* @__PURE__ */ t(
334
+ ke,
335
+ {
336
+ className: "z-50 w-[--radix-popover-trigger-width] p-0",
337
+ align: "start",
338
+ children: /* @__PURE__ */ o(ue, { className: "overflow-visible", children: [
339
+ /* @__PURE__ */ t(me, { placeholder: "Search timezones…" }),
340
+ /* @__PURE__ */ o(fe, { children: [
341
+ /* @__PURE__ */ t(he, { children: "No timezone found." }),
342
+ /* @__PURE__ */ t(M, { heading: "Common", children: I.map((c) => /* @__PURE__ */ o(
343
+ H,
344
+ {
345
+ value: `${c.value} ${c.label}`,
346
+ onSelect: () => {
347
+ h(!0), P(c.value), A(!1);
348
+ },
349
+ children: [
350
+ /* @__PURE__ */ t(
351
+ q,
352
+ {
353
+ className: F(
354
+ "h-3.5 w-3.5",
355
+ k === c.value ? "opacity-100" : "opacity-0"
356
+ )
357
+ }
358
+ ),
359
+ /* @__PURE__ */ t("span", { className: "flex-1", children: c.label }),
360
+ /* @__PURE__ */ t("span", { className: "text-[11px] text-muted-foreground", children: c.value })
361
+ ]
362
+ },
363
+ c.value
364
+ )) }),
365
+ /* @__PURE__ */ t(ve, {}),
366
+ /* @__PURE__ */ t(M, { heading: "All timezones", children: g.map((c) => /* @__PURE__ */ o(
367
+ H,
368
+ {
369
+ value: c,
370
+ onSelect: () => {
371
+ h(!0), P(c), A(!1);
372
+ },
373
+ children: [
374
+ /* @__PURE__ */ t(
375
+ q,
376
+ {
377
+ className: F(
378
+ "h-3.5 w-3.5",
379
+ k === c ? "opacity-100" : "opacity-0"
380
+ )
381
+ }
382
+ ),
383
+ c
384
+ ]
385
+ },
386
+ c
387
+ )) })
388
+ ] })
389
+ ] })
390
+ }
391
+ )
392
+ ]
393
+ }
394
+ )
395
+ ] }),
396
+ /* @__PURE__ */ o("div", { className: "space-y-1.5", children: [
397
+ /* @__PURE__ */ t(W, { className: J, children: "Week starts on" }),
398
+ /* @__PURE__ */ t(
399
+ B,
400
+ {
401
+ value: String(f),
402
+ onValueChange: (c) => {
403
+ h(!0), N(Number(c));
404
+ },
405
+ className: "flex gap-4",
406
+ disabled: u,
407
+ children: re.map((c) => /* @__PURE__ */ o(
408
+ "label",
409
+ {
410
+ htmlFor: `week-start-${c.value}`,
411
+ className: F(
412
+ "flex cursor-pointer items-center gap-2 text-[13px]",
413
+ u && "cursor-not-allowed"
414
+ ),
415
+ children: [
416
+ /* @__PURE__ */ t(
417
+ $,
418
+ {
419
+ value: String(c.value),
420
+ id: `week-start-${c.value}`,
421
+ disabled: u
422
+ }
423
+ ),
424
+ c.label
425
+ ]
426
+ },
427
+ c.value
428
+ ))
429
+ }
430
+ )
431
+ ] })
432
+ ]
433
+ }
434
+ )
435
+ ] }),
436
+ /* @__PURE__ */ o(V, { children: [
437
+ /* @__PURE__ */ t(
438
+ L,
439
+ {
440
+ variant: "outline",
441
+ size: "xs",
442
+ onClick: ne,
443
+ disabled: O,
444
+ children: "Cancel"
445
+ }
446
+ ),
447
+ /* @__PURE__ */ t(L, { size: "xs", onClick: se, disabled: le, children: O ? /* @__PURE__ */ o(j, { children: [
448
+ /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5 animate-spin" }),
449
+ "Saving…"
450
+ ] }) : "Save" })
451
+ ] })
452
+ ] });
453
+ }
454
+ function Ue(e = {}) {
455
+ const { authToken: i, tokenProps: a } = ee(), d = ae(
456
+ (s) => s.actions.applyResolvedValueFormatPreferences
457
+ ), r = e.enabled ?? !0, l = (i == null ? void 0 : i.accessToken) ?? null, m = (a == null ? void 0 : a.apiServiceUrl) ?? null, y = X(l);
458
+ y.current = l;
459
+ const [p, b] = S(null), [w, u] = S(!1), [T, C] = S(!1), [h, k] = S(!1), [P, f] = S(null);
460
+ U(() => {
461
+ b(null), f(null), u(!1), C(!1), k(!1);
462
+ }, [l]);
463
+ const N = E(async (s) => {
464
+ const n = Ae(await s.json());
465
+ if (!n.ok)
466
+ throw new Error("Value format preferences response is invalid");
467
+ return n.value;
468
+ }, []), x = E(
469
+ async (s, n) => {
470
+ if (!l || !m)
471
+ throw new Error("Not authenticated");
472
+ const v = await fetch(
473
+ `${m}/v1/user-preferences/value-format`,
474
+ {
475
+ method: s,
476
+ headers: {
477
+ Authorization: `Bearer ${l}`,
478
+ ...n ? { "Content-Type": "application/json" } : {}
479
+ },
480
+ body: n ? JSON.stringify(n) : void 0
481
+ }
482
+ );
483
+ if (!v.ok) {
484
+ const R = await v.json().catch(() => ({}));
485
+ throw new Error(R.error || "Failed to update preferences");
486
+ }
487
+ return N(v);
488
+ },
489
+ [l, m, N]
490
+ ), A = E(async () => {
491
+ if (!r || !l || !m) return;
492
+ const s = l;
493
+ u(!0), f(null);
494
+ try {
495
+ const n = await x("GET");
496
+ y.current === s && b(n);
497
+ } catch (n) {
498
+ y.current === s && f(n instanceof Error ? n.message : "Unknown error");
499
+ } finally {
500
+ y.current === s && u(!1);
501
+ }
502
+ }, [l, m, r, x]);
503
+ U(() => {
504
+ r && A();
505
+ }, [r, A]);
506
+ const D = E(
507
+ async (s) => {
508
+ const n = l;
509
+ C(!0), f(null);
510
+ try {
511
+ const v = await x("PATCH", s);
512
+ return y.current !== n ? !1 : (b(v), d(v.resolved, v.sources), !0);
513
+ } catch (v) {
514
+ return y.current === n && f(v instanceof Error ? v.message : "Unknown error"), !1;
515
+ } finally {
516
+ y.current === n && C(!1);
517
+ }
518
+ },
519
+ [l, d, x]
520
+ ), g = E(async () => {
521
+ const s = l;
522
+ k(!0), f(null);
523
+ try {
524
+ const n = await x("DELETE");
525
+ return y.current !== s ? !1 : (b(n), d(n.resolved, n.sources), !0);
526
+ } catch (n) {
527
+ return y.current === s && f(n instanceof Error ? n.message : "Unknown error"), !1;
528
+ } finally {
529
+ y.current === s && k(!1);
530
+ }
531
+ }, [l, d, x]);
532
+ return {
533
+ preferences: p,
534
+ isLoading: w,
535
+ isSaving: T,
536
+ isClearing: h,
537
+ error: P,
538
+ updatePreferences: D,
539
+ clearPreferences: g,
540
+ refetch: A
541
+ };
542
+ }
543
+ const Z = [
544
+ "locale",
545
+ "dateStyle",
546
+ "dateTime.dateStyle",
547
+ "dateTime.timeStyle",
548
+ "defaultCurrency"
549
+ ];
550
+ function Q(e, i) {
551
+ var a, d;
552
+ switch (i) {
553
+ case "locale":
554
+ return e == null ? void 0 : e.locale;
555
+ case "dateStyle":
556
+ return e == null ? void 0 : e.dateStyle;
557
+ case "dateTime.dateStyle":
558
+ return (a = e == null ? void 0 : e.dateTime) == null ? void 0 : a.dateStyle;
559
+ case "dateTime.timeStyle":
560
+ return (d = e == null ? void 0 : e.dateTime) == null ? void 0 : d.timeStyle;
561
+ case "defaultCurrency":
562
+ return e == null ? void 0 : e.defaultCurrency;
563
+ }
564
+ }
565
+ function Ie(e) {
566
+ var d, r;
567
+ const i = (d = e == null ? void 0 : e.dateTime) == null ? void 0 : d.dateStyle, a = (r = e == null ? void 0 : e.dateTime) == null ? void 0 : r.timeStyle;
568
+ return {
569
+ locale: e == null ? void 0 : e.locale,
570
+ dateStyle: e == null ? void 0 : e.dateStyle,
571
+ dateTime: i === void 0 && a === void 0 ? void 0 : { dateStyle: i, timeStyle: a },
572
+ defaultCurrency: e == null ? void 0 : e.defaultCurrency
573
+ };
574
+ }
575
+ function Oe({
576
+ active: e,
577
+ onClose: i
578
+ }) {
579
+ var y, p, b, w, u, T, C;
580
+ const { preferences: a, isLoading: d, isSaving: r, updatePreferences: l } = Ue({ enabled: e });
581
+ if (!e) return null;
582
+ if (!a)
583
+ return /* @__PURE__ */ o(j, { children: [
584
+ /* @__PURE__ */ t("div", { className: "py-2", children: /* @__PURE__ */ t("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: d ? "Loading preferences…" : "Preferences unavailable." }) }),
585
+ /* @__PURE__ */ o(V, { className: "justify-between sm:justify-between", children: [
586
+ /* @__PURE__ */ t(L, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
587
+ /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
588
+ /* @__PURE__ */ t(L, { variant: "outline", size: "xs", onClick: i, children: "Cancel" }),
589
+ /* @__PURE__ */ t(L, { size: "xs", disabled: !0, children: "Save" })
590
+ ] })
591
+ ] })
592
+ ] });
593
+ const m = [
594
+ ((y = a.stored) == null ? void 0 : y.locale) ?? "",
595
+ ((p = a.stored) == null ? void 0 : p.dateStyle) ?? "",
596
+ ((w = (b = a.stored) == null ? void 0 : b.dateTime) == null ? void 0 : w.dateStyle) ?? "",
597
+ ((T = (u = a.stored) == null ? void 0 : u.dateTime) == null ? void 0 : T.timeStyle) ?? "",
598
+ ((C = a.stored) == null ? void 0 : C.defaultCurrency) ?? ""
599
+ ].join(":");
600
+ return /* @__PURE__ */ t(
601
+ _e,
602
+ {
603
+ preferences: a,
604
+ isSaving: r,
605
+ updatePreferences: l,
606
+ onClose: i
607
+ },
608
+ m
609
+ );
610
+ }
611
+ function _e({
612
+ preferences: e,
613
+ isSaving: i,
614
+ updatePreferences: a,
615
+ onClose: d
616
+ }) {
617
+ var b, w;
618
+ const [r, l] = S(
619
+ () => Ie(e.stored)
620
+ ), m = (r.locale === void 0 || Ee(r.locale) !== void 0) && (r.defaultCurrency === void 0 || ze(r.defaultCurrency) !== void 0) && (r.dateStyle === void 0 || ["short", "medium", "long"].includes(r.dateStyle)) && (((b = r.dateTime) == null ? void 0 : b.dateStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.dateStyle)) && (((w = r.dateTime) == null ? void 0 : w.timeStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.timeStyle)), y = async () => {
621
+ const u = {
622
+ ...r.locale !== void 0 ? { locale: r.locale } : {},
623
+ ...r.dateStyle !== void 0 ? { dateStyle: r.dateStyle } : {},
624
+ ...r.dateTime ? { dateTime: { ...r.dateTime } } : {},
625
+ ...r.defaultCurrency !== void 0 ? { defaultCurrency: r.defaultCurrency } : {}
626
+ }, T = Z.filter(
627
+ (k) => Q(r, k) === void 0 && Q(e.stored, k) !== void 0
628
+ ), C = {
629
+ ...Object.keys(u).length > 0 ? { set: u } : {},
630
+ ...T.length > 0 ? { clear: T } : {}
631
+ };
632
+ (Object.keys(C).length === 0 ? !0 : await a(C)) ? (z.success("Display format preferences saved."), d()) : z.error("Failed to save preferences. Please try again.");
633
+ }, p = async () => {
634
+ await a({
635
+ clear: [...Z]
636
+ }) ? (z.success("Display format preferences reset."), d()) : z.error(
637
+ "Failed to reset display format preferences. Please try again."
638
+ );
639
+ };
640
+ return /* @__PURE__ */ o(j, { children: [
641
+ /* @__PURE__ */ t("div", { className: "py-2", children: /* @__PURE__ */ t(
642
+ ye,
643
+ {
644
+ value: r,
645
+ inherited: e.inherited,
646
+ inheritedSources: e.inheritedSources,
647
+ onChange: l,
648
+ disabled: i
649
+ }
650
+ ) }),
651
+ /* @__PURE__ */ o(V, { className: "justify-between sm:justify-between", children: [
652
+ /* @__PURE__ */ t(
653
+ L,
654
+ {
655
+ variant: "ghost",
656
+ size: "xs",
657
+ onClick: p,
658
+ disabled: i || e.stored === null,
659
+ children: "Reset display formats"
660
+ }
661
+ ),
662
+ /* @__PURE__ */ o("div", { className: "flex gap-2", children: [
663
+ /* @__PURE__ */ t(
664
+ L,
665
+ {
666
+ variant: "outline",
667
+ size: "xs",
668
+ onClick: d,
669
+ disabled: i,
670
+ children: "Cancel"
671
+ }
672
+ ),
673
+ /* @__PURE__ */ t(
674
+ L,
675
+ {
676
+ size: "xs",
677
+ onClick: y,
678
+ disabled: i || !m,
679
+ children: i ? /* @__PURE__ */ o(j, { children: [
680
+ /* @__PURE__ */ t(te, { className: "h-3.5 w-3.5 animate-spin" }),
681
+ "Saving…"
682
+ ] }) : "Save"
683
+ }
684
+ )
685
+ ] })
686
+ ] })
687
+ ] });
688
+ }
689
+ function Ye({
690
+ open: e,
691
+ onOpenChange: i
692
+ }) {
693
+ const [a, d] = S("display"), r = () => i(!1);
694
+ return /* @__PURE__ */ t(pe, { open: e, onOpenChange: i, children: /* @__PURE__ */ o(ge, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
695
+ /* @__PURE__ */ o(Se, { children: [
696
+ /* @__PURE__ */ t(be, { className: "text-[15px]", children: "Report preferences" }),
697
+ /* @__PURE__ */ t(Te, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
698
+ ] }),
699
+ /* @__PURE__ */ o(xe, { value: a, onValueChange: d, children: [
700
+ /* @__PURE__ */ o(Ne, { variant: "underline", className: "w-full justify-start", children: [
701
+ /* @__PURE__ */ t(G, { value: "display", children: "Display formats" }),
702
+ /* @__PURE__ */ t(G, { value: "calendar", children: "Calendar" })
703
+ ] }),
704
+ /* @__PURE__ */ t(K, { value: "display", children: /* @__PURE__ */ t(
705
+ Oe,
706
+ {
707
+ active: e && a === "display",
708
+ onClose: r
709
+ }
710
+ ) }),
711
+ /* @__PURE__ */ t(K, { value: "calendar", children: /* @__PURE__ */ t(
712
+ je,
713
+ {
714
+ active: e && a === "calendar",
715
+ onClose: r
716
+ }
717
+ ) })
718
+ ] })
719
+ ] }) });
720
+ }
721
+ export {
722
+ Ye as R
723
+ };