react-semaphor 0.1.449 → 0.1.454

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