react-semaphor 0.1.603 → 0.1.604

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 (167) 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 +4 -1594
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-DeHEBEqG.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-BREc5WGv.js +1 -0
  11. package/dist/chunks/appearance-context-BqBZrijL.js +1 -0
  12. package/dist/chunks/appearance-runtime-provider-DmbCrOOG.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-CjYrwVDa.js +56 -0
  15. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  16. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  17. package/dist/chunks/bookmark-impact-C89zBLq3.js +1 -0
  18. package/dist/chunks/bookmark-state-69YYnRql.js +1 -0
  19. package/dist/chunks/brand-DCaZyRt6.js +1 -0
  20. package/dist/chunks/card-filter-builder-CTp6RAz1.js +17 -0
  21. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  22. package/dist/chunks/comparison-window-caption-C312mn3s.js +1 -0
  23. package/dist/chunks/context-ALdccLHw.js +2 -0
  24. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  25. package/dist/chunks/dashboard-BX28ld6s.js +1 -0
  26. package/dist/chunks/dashboard-briefing-launcher-qo7GH4EO.js +37 -0
  27. package/dist/chunks/dashboard-controls-DhRjB7MA.js +42 -0
  28. package/dist/chunks/dashboard-json-9cHzhSjC.js +1 -0
  29. package/dist/chunks/dates-D-KP8G-z.js +1 -0
  30. package/dist/chunks/edit-DEAK0UZo.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-Duq_QkB_.js +93 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-CwQrqORc.js +1 -0
  34. package/dist/chunks/filter-reach-preview-gixPFlZj.js +1 -0
  35. package/dist/chunks/filter-value-text-B3tXakhd.js +1 -0
  36. package/dist/chunks/index-B-VF1ogs.js +1 -0
  37. package/dist/chunks/index-BE1DfxNs.js +1 -0
  38. package/dist/chunks/index-DViPGDFj.js +1 -0
  39. package/dist/chunks/layout-grid-BWtlgw0T.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-CtFqWyCK.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-Q0MCJ-YK.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-D1RC1bfi.js +1 -0
  43. package/dist/chunks/metric-comparison-DEZYXROZ.js +1 -0
  44. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  45. package/dist/chunks/paintbrush-BjS3SbrH.js +6 -0
  46. package/dist/chunks/palette-BzC-CGOc.js +6 -0
  47. package/dist/chunks/pickers-DuBrUht0.js +1 -0
  48. package/dist/chunks/pivot-result-contract-expectations-DTQAgr4n.js +1 -0
  49. package/dist/chunks/pivot-result-identity-DTNCB--h.js +1 -0
  50. package/dist/chunks/raw-temporal-value-DeyEhL0S.js +1 -0
  51. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  52. package/dist/chunks/report-preferences-dialog-B_gUmCzG.js +1 -0
  53. package/dist/chunks/report-runtime-context-BWzIHCKK.js +1 -0
  54. package/dist/chunks/resolve-dashboard-input-context-B-TtRqxu.js +8 -0
  55. package/dist/chunks/resolver-AN9ChBfZ.js +1 -0
  56. package/dist/chunks/save-DdFUZcbi.js +6 -0
  57. package/dist/chunks/saved-dashboard-context-BAJ5tWiq.js +1 -0
  58. package/dist/chunks/schema-MC0cQSAb.js +4 -0
  59. package/dist/chunks/selection-filter-compiler-CCoCD25M.js +1 -0
  60. package/dist/chunks/semaphor-ready-indicator-DzjorP3t.js +999 -0
  61. package/dist/chunks/set-DuJfGkbY.js +1 -0
  62. package/dist/chunks/shelf-drop-preview-context-BlLJ5RsT.js +6 -0
  63. package/dist/chunks/stored-dashboard-Ctcpkllg.js +1 -0
  64. package/dist/chunks/style-sheet-parts-BRGt9O05.js +178 -0
  65. package/dist/chunks/table-export-sheet-rC5pKmXg.js +2 -0
  66. package/dist/chunks/token-types-Bj9iMy0w.js +1 -0
  67. package/dist/chunks/validators-CqV3Yka1.js +1 -0
  68. package/dist/chunks/variable-draft-DJrfUyhv.js +1 -0
  69. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  70. package/dist/dashboard/index.js +1 -7
  71. package/dist/dashboard-authoring/index.js +1 -4614
  72. package/dist/format-utils/index.js +1 -425
  73. package/dist/index.js +1 -554
  74. package/dist/layouts/index.js +1 -7
  75. package/dist/live-channel/index.js +1 -124
  76. package/dist/pdf-export-policy/index.js +1 -92
  77. package/dist/pdf-table-layout/index.js +1 -993
  78. package/dist/report-runtime-context/index.js +1 -9
  79. package/dist/shared/index.js +1 -6
  80. package/dist/style.css +1 -1
  81. package/dist/surfboard/index.js +1 -9
  82. package/dist/types/index.js +1 -88
  83. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  84. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  85. package/dist/types/lib/stores/explorer-actions.d.ts +7 -6
  86. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  87. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  88. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  89. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  90. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  91. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  92. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  93. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  94. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +132 -0
  95. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  96. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  97. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  98. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +115 -0
  99. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  100. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  101. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -1
  102. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  103. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  104. package/dist/usage-events/index.js +1 -285
  105. package/dist/value-format-preferences/index.js +1 -635
  106. package/package.json +4 -1
  107. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  108. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  109. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  110. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  111. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  112. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  113. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  114. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  115. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  116. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  117. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  118. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  119. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  120. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  121. package/dist/chunks/context-UCQ7sere.js +0 -369
  122. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  123. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  124. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  125. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  126. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  127. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  128. package/dist/chunks/edit-9df1zOWe.js +0 -226
  129. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  130. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  131. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  132. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  133. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  134. package/dist/chunks/index-BVKzKl5d.js +0 -90
  135. package/dist/chunks/index-CV_Kzou0.js +0 -595
  136. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  137. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  138. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  139. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  140. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  141. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  142. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  143. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  144. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  145. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  146. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  147. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  148. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  149. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  150. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  151. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  152. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  153. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  154. package/dist/chunks/save-C5A0JnEV.js +0 -21
  155. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  156. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  157. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  158. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  159. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  160. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  161. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  162. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  163. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  164. package/dist/chunks/upload-H15d7uHK.js +0 -15
  165. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  166. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  167. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,1651 +0,0 @@
1
- import { jsx as r, Fragment as M, jsxs as d } from "react/jsx-runtime";
2
- import He, { useMemo as B, useState as I, useEffect as j, lazy as ae, Suspense as Q, useRef as L, useLayoutEffect as ee, useCallback as P, useId as $ } from "react";
3
- import { b as Ke, b8 as be, bk as qe, bl as Ge, u as D, bm as ze, Y as Je, W as Xe, bn as Ze, bo as Ye, bp as Qe, bq as et, br as J, bs as Le, bt as ge, bu as tt, ad as X, ac as at, bv as rt, bw as nt, ae as ve, af as st, bx as lt, E as it, F as ot, S as dt, B as ct, a as ut, U as mt, by as ht, D as ft, A as bt, C as pt, bz as gt, bA as vt, bB as ye, bC as ne, bD as yt, i as St, j as wt, k as xt, l as Ct, m as Se, n as we, bE as Tt, bF as pe, bG as F, bH as Nt, bI as Et, bJ as It, bK as At, bL as Dt } from "./semaphor-ready-indicator-FBvunj6S.js";
4
- import { j as kt, c as U } from "./pickers-DkqmtnTL.js";
5
- import { L as _t } from "./bookmark-state-n7AaNzR_.js";
6
- import { r as Pt, a as Re } from "./availability-Bp5Gfu1I.js";
7
- import { s as zt } from "./resolve-dashboard-input-context-Rtl1ffmE.js";
8
- import { B as z, Z as Lt, _ as Rt, $ as Ut, a0 as Ft, a1 as Ot, a2 as Bt, s as G, e as jt, f as Mt, h as Vt, j as xe, L as Ue, y as de, z as ce, A as ue, D as me, E as O, T as Wt, k as $t, l as Ce, n as Te } from "./style-sheet-parts-CDCG-8Ej.js";
9
- import "./validators-Baf3VIf5.js";
10
- import "./matrix-operation-contract-DPBj69D8.js";
11
- import "./analytics-base-schemas-DsUh5Q3C.js";
12
- import { parseValueFormatPreferencesResponse as Ht, canonicalizeSupportedLocale as Fe, getSupportedCurrencyCodes as Kt, canonicalizeSupportedCurrencyCode as qt } from "../value-format-preferences/index.js";
13
- import { a as Gt } from "./filter-reach-copy-CE_ZX147.js";
14
- import { a as Jt } from "./report-runtime-context-c77_KF9v.js";
15
- import { at as Z, aA as H } from "./pivot-result-contract-expectations-BYqAmG9n.js";
16
- function Xt() {
17
- return /* @__PURE__ */ r(
18
- "div",
19
- {
20
- role: "dashboard-plus-main",
21
- className: "flex min-h-0 grow basis-0 overflow-hidden",
22
- children: /* @__PURE__ */ r("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: /* @__PURE__ */ r(Ke, {}) })
23
- }
24
- );
25
- }
26
- const Zt = /* @__PURE__ */ new Set(["iat", "exp", "nbf", "jti"]);
27
- function Yt(e) {
28
- return zt(
29
- Object.fromEntries(
30
- Object.entries(e ?? {}).filter(([a]) => !Zt.has(a))
31
- )
32
- );
33
- }
34
- function Qt(e) {
35
- var t;
36
- const a = e == null ? void 0 : e.config;
37
- return Pt({
38
- features: ((t = a == null ? void 0 : a.projectFeatures) == null ? void 0 : t.features) ?? {},
39
- config: { enabled: Re(a).enabled },
40
- identity: {
41
- orgUserId: e == null ? void 0 : e.orgUserId,
42
- tenantId: e == null ? void 0 : e.tenantId,
43
- endUserId: e == null ? void 0 : e.endUserId
44
- },
45
- modelConfigured: !0
46
- });
47
- }
48
- let Ne = 0;
49
- function Ee(e, a) {
50
- Ne += 1;
51
- const { name: t, layout: n } = Re(a == null ? void 0 : a.config);
52
- return { ...Ge(n), id: Ne, callerKey: e, assistantName: t };
53
- }
54
- function ea({
55
- children: e,
56
- authToken: a
57
- }) {
58
- const t = be(), n = B(
59
- () => a === void 0 ? t.tokenProps : aa(a),
60
- [a, t.tokenProps]
61
- ), s = B(() => Yt(n), [n]), i = B(
62
- () => Qt(n).available,
63
- [n]
64
- ), [l, o] = I(() => Ee(s, n));
65
- l.callerKey !== s && o(Ee(s, n)), ra(l);
66
- const h = B(() => ({ instance: l, available: i }), [l, i]);
67
- return /* @__PURE__ */ r(qe.Provider, { value: h, children: e });
68
- }
69
- function ta({ children: e }) {
70
- return ze() ? /* @__PURE__ */ r(M, { children: e }) : /* @__PURE__ */ r(ea, { children: e });
71
- }
72
- function aa(e) {
73
- if (!(e != null && e.accessToken)) return {};
74
- try {
75
- return kt(e.accessToken);
76
- } catch {
77
- return {};
78
- }
79
- }
80
- function ra(e) {
81
- j(() => {
82
- const a = (n, s) => {
83
- const i = e.store.getState().focus;
84
- i && !na(i, n, s) && e.clearFocus();
85
- }, t = D.getState();
86
- return a(t.selectedSheetId, t.dashboard), D.subscribe((n, s) => {
87
- (n.selectedSheetId !== s.selectedSheetId || n.dashboard !== s.dashboard) && a(n.selectedSheetId, n.dashboard), n.isVisualEditing && !s.isVisualEditing && e.leaveBeside();
88
- });
89
- }, [e]);
90
- }
91
- function na(e, a, t) {
92
- if ((a ?? null) !== e.sheetId) return !1;
93
- const n = t ? _t(t, e.cardId) : void 0;
94
- return !!n && n.sheet.id === e.sheetId;
95
- }
96
- const sa = ae(() => import("./assistant-chat-B6hNQI1t.js"));
97
- function Qa() {
98
- const e = Je(), a = Xe();
99
- if (!e.available) return null;
100
- const t = a !== "lg";
101
- return /* @__PURE__ */ d(
102
- z,
103
- {
104
- variant: e.isOpen ? "secondary" : "outline",
105
- size: "xs",
106
- "aria-pressed": e.isOpen,
107
- "aria-label": e.assistantName,
108
- title: t ? e.assistantName : void 0,
109
- onClick: e.toggle,
110
- className: t ? "w-7 px-0" : void 0,
111
- children: [
112
- /* @__PURE__ */ r(Ze, { className: "h-3.5 w-3.5" }),
113
- !t && e.assistantName
114
- ]
115
- }
116
- );
117
- }
118
- const la = {
119
- // Docked widths are the viewer's (the resize handle), applied as a style.
120
- "docked-right": "relative shrink-0 border-l border-border",
121
- "docked-left": "relative order-first shrink-0 border-r border-border",
122
- centered: "absolute left-1/2 top-1/2 z-30 h-[min(80%,760px)] w-[min(640px,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-card border border-border shadow-lg",
123
- "full-page": "absolute inset-0 z-30"
124
- }, ia = "absolute left-0 top-0 z-30 max-h-[var(--assistant-beside-max-h)] max-w-[var(--assistant-beside-max-w)] rounded-card border border-border shadow-lg", oa = 640, q = 8;
125
- function da({ surface: e = "dashboard" } = {}) {
126
- const a = ze(), { isOpen: t, mounted: n, storedLayout: s, width: i, beside: l, besideSize: o, focusCardId: h, askCount: w } = Ye(
127
- (a == null ? void 0 : a.instance.store) ?? et,
128
- Qe((f) => {
129
- var v;
130
- return {
131
- isOpen: f.isOpen,
132
- mounted: f.mounted,
133
- storedLayout: f.layout,
134
- width: f.width,
135
- beside: f.beside,
136
- besideSize: f.besideSize,
137
- focusCardId: (v = f.focus) == null ? void 0 : v.cardId,
138
- askCount: f.askCount
139
- };
140
- })
141
- ), x = e === "none", u = D(
142
- (f) => l && t && h && !x ? ca(f.dashboard, f.selectedSheetId, h) : void 0
143
- ), b = ua(u, w);
144
- if (!(a != null && a.available) || !n && !x) return null;
145
- const c = x ? "full-page" : b.shown ? "beside-card" : s, S = x || t, m = c === "docked-right" || c === "docked-left";
146
- return /* @__PURE__ */ d(
147
- "aside",
148
- {
149
- ref: b.setFloating,
150
- "aria-label": a.instance.assistantName,
151
- "data-testid": "assistant-panel",
152
- "data-layout": c,
153
- "data-beside-frame": c === "beside-card" ? u : void 0,
154
- "data-beside-side": c === "beside-card" ? b.side : void 0,
155
- className: U(
156
- "flex-col bg-background",
157
- c === "beside-card" ? ia : la[c],
158
- S ? "flex" : "hidden"
159
- ),
160
- style: c === "beside-card" ? { ...b.style, width: o.width, height: o.height } : (
161
- // The saved width, never more than the share of the dashboard's area the
162
- // handle allows, however the area is sized now or later (P4-10).
163
- m ? { width: i, maxWidth: `${Oe * 100}%` } : void 0
164
- ),
165
- onKeyDown: c === "beside-card" ? (f) => {
166
- if (f.key !== "Escape" || f.defaultPrevented || !(f.target instanceof Node) || !f.currentTarget.contains(f.target)) return;
167
- f.preventDefault();
168
- const v = b.cardActions();
169
- a.instance.close(), v == null || v.focus();
170
- } : void 0,
171
- children: [
172
- m ? /* @__PURE__ */ r(fa, { instance: a.instance, side: c === "docked-left" ? "right" : "left", width: i }) : null,
173
- c === "beside-card" ? /* @__PURE__ */ r(ha, { instance: a.instance, size: o, side: b.handleSide }) : null,
174
- /* @__PURE__ */ r(Q, { fallback: null, children: /* @__PURE__ */ r(sa, { instance: a.instance, surface: e, placement: c }, a.instance.id) })
175
- ]
176
- }
177
- );
178
- }
179
- function ca(e, a, t) {
180
- var s, i, l;
181
- const n = (s = e.sheets) == null ? void 0 : s.find((o) => o.id === a);
182
- return (l = (i = n == null ? void 0 : n.frames) == null ? void 0 : i.find((o) => {
183
- var h;
184
- return (h = o.cards) == null ? void 0 : h.some((w) => w.id === t);
185
- })) == null ? void 0 : l.id;
186
- }
187
- function ua(e, a) {
188
- var S;
189
- const [t, n] = I(void 0), [s, i] = I(void 0), l = L(a);
190
- ee(() => {
191
- l.current = a;
192
- });
193
- const o = s === a ? null : t, { refs: h, elements: w, floatingStyles: x, middlewareData: u, isPositioned: b } = Lt({
194
- strategy: "absolute",
195
- placement: o ?? "right-start",
196
- middleware: [
197
- Rt(q),
198
- Ut({ padding: q }),
199
- Ft({
200
- padding: q,
201
- apply: ({ availableWidth: m, availableHeight: f, elements: v }) => {
202
- v.floating.style.setProperty("--assistant-beside-max-w", `${Math.max(0, m)}px`), v.floating.style.setProperty("--assistant-beside-max-h", `${Math.max(0, f)}px`);
203
- }
204
- }),
205
- Ot()
206
- ],
207
- whileElementsMounted: (m, f, v) => Bt(m, f, () => {
208
- const E = ma(m, f);
209
- n(E), E === null && i(l.current), v();
210
- })
211
- }), c = w.floating;
212
- return ee(() => {
213
- h.setReference(e ? Ie(c == null ? void 0 : c.parentElement, e) : null);
214
- }, [e, c, h]), {
215
- shown: e !== void 0 && o !== null && w.reference !== null,
216
- setFloating: h.setFloating,
217
- style: {
218
- ...x,
219
- // Not before it is placed (its side is chosen first): never a flash at
220
- // the row's corner. With the card wholly out of view, it goes with the card.
221
- ...!b || (S = u.hide) != null && S.referenceHidden ? { visibility: "hidden" } : {}
222
- },
223
- /** The side the conversation took; the size handle sits on the corner away from the card. */
224
- side: o ?? void 0,
225
- handleSide: o === "left-start" ? "left" : "right",
226
- /** The card's ··· menu, where Ask lives and focus returns on Escape. */
227
- cardActions: () => {
228
- var m;
229
- return e ? (m = Ie(c == null ? void 0 : c.parentElement, e)) == null ? void 0 : m.querySelector("[data-card-actions]") : null;
230
- }
231
- };
232
- }
233
- function Ie(e, a) {
234
- return e ? Array.from(e.querySelectorAll("[data-frame-id]")).find((t) => t.dataset.frameId === a) ?? null : null;
235
- }
236
- function ma(e, a) {
237
- const t = a.parentElement;
238
- if (!t || !e.isConnected) return null;
239
- const n = t.getBoundingClientRect();
240
- if (n.width < oa) return null;
241
- const s = e.getBoundingClientRect(), { min: i } = Le, l = (o, h) => o >= i.width + 2 * q && h >= i.height + 2 * q;
242
- return l(n.right - s.right, n.height) ? "right-start" : l(s.left - n.left, n.height) ? "left-start" : l(n.width, n.bottom - s.bottom) ? "bottom-start" : null;
243
- }
244
- function ha({
245
- instance: e,
246
- size: a,
247
- side: t
248
- }) {
249
- const n = L(void 0), s = t === "left" ? -1 : 1, i = (l) => {
250
- const o = n.current;
251
- return {
252
- width: o.start.width + s * (l.clientX - o.x),
253
- height: o.start.height + (l.clientY - o.y)
254
- };
255
- };
256
- return /* @__PURE__ */ r(
257
- "div",
258
- {
259
- role: "separator",
260
- "aria-label": "Resize assistant",
261
- tabIndex: 0,
262
- title: "Drag to resize. Double-click to reset.",
263
- onPointerDown: (l) => {
264
- var o, h;
265
- l.preventDefault(), (h = (o = l.currentTarget).setPointerCapture) == null || h.call(o, l.pointerId), n.current = { x: l.clientX, y: l.clientY, start: a };
266
- },
267
- onPointerMove: (l) => {
268
- n.current && e.setBesideSize(i(l));
269
- },
270
- onPointerUp: (l) => {
271
- n.current && (e.setBesideSize(i(l), { save: !0 }), n.current = void 0);
272
- },
273
- onPointerCancel: () => {
274
- n.current = void 0;
275
- },
276
- onKeyDown: (l) => {
277
- const o = {
278
- ArrowLeft: { width: -s * W, height: 0 },
279
- ArrowRight: { width: s * W, height: 0 },
280
- ArrowUp: { width: 0, height: -W },
281
- ArrowDown: { width: 0, height: W }
282
- }[l.key];
283
- o && (l.preventDefault(), e.setBesideSize({ width: a.width + o.width, height: a.height + o.height }, { save: !0 }));
284
- },
285
- onDoubleClick: () => e.setBesideSize(Le.default, { save: !0 }),
286
- className: U(
287
- "absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
288
- t === "left" ? "left-0 cursor-nesw-resize rounded-bl-card" : "right-0 cursor-nwse-resize rounded-br-card"
289
- )
290
- }
291
- );
292
- }
293
- const W = 16, Oe = 0.6;
294
- function fa({ instance: e, side: a, width: t }) {
295
- const n = L(void 0), s = (u) => {
296
- var c, S;
297
- const b = (S = (c = u.closest("aside")) == null ? void 0 : c.parentElement) == null ? void 0 : S.clientWidth;
298
- return b ? b * Oe : J.max;
299
- }, i = (u) => {
300
- var b;
301
- return ((b = u.closest("aside")) == null ? void 0 : b.getBoundingClientRect().width) || t;
302
- }, l = (u) => {
303
- const b = n.current;
304
- if (!b) return t;
305
- const c = u - b.startX;
306
- return ge(b.startWidth + (a === "left" ? -c : c), b.maxForArea);
307
- }, o = (u) => {
308
- var b, c;
309
- u.preventDefault(), (c = (b = u.currentTarget).setPointerCapture) == null || c.call(b, u.pointerId), n.current = { startX: u.clientX, startWidth: i(u.currentTarget), maxForArea: s(u.currentTarget) };
310
- }, h = (u) => {
311
- n.current && e.setWidth(l(u.clientX));
312
- }, w = (u) => {
313
- n.current && (e.setWidth(l(u.clientX), { save: !0 }), n.current = void 0);
314
- }, x = (u) => {
315
- if (u.key !== "ArrowLeft" && u.key !== "ArrowRight") return;
316
- u.preventDefault();
317
- const b = u.key === "ArrowLeft" == (a === "left");
318
- e.setWidth(ge(i(u.currentTarget) + (b ? W : -W), s(u.currentTarget)), { save: !0 });
319
- };
320
- return /* @__PURE__ */ r(
321
- "div",
322
- {
323
- role: "separator",
324
- "aria-orientation": "vertical",
325
- "aria-label": "Resize assistant",
326
- "aria-valuenow": t,
327
- "aria-valuemin": J.min,
328
- "aria-valuemax": J.max,
329
- tabIndex: 0,
330
- title: "Drag to resize. Double-click to reset.",
331
- onPointerDown: o,
332
- onPointerMove: h,
333
- onPointerUp: w,
334
- onPointerCancel: w,
335
- onKeyDown: x,
336
- onDoubleClick: () => e.setWidth(J.default, { save: !0 }),
337
- className: U(
338
- "absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
339
- a === "left" ? "-left-[3px]" : "-right-[3px]"
340
- )
341
- }
342
- );
343
- }
344
- function ba(e) {
345
- const a = tt();
346
- return P(
347
- async (t, n) => {
348
- const s = D.getState();
349
- if (s.isVisualEditing)
350
- return { ok: !1, reason: "not_editable", message: X.not_editable };
351
- if (!e()) return { ok: !1, reason: "not_editable", message: X.no_save };
352
- if (s.dashboard !== t.basedOn)
353
- return { ok: !1, reason: "dashboard_changed", message: X.dashboard_changed };
354
- const i = Gt(t.basedOn, t.operations, t.context);
355
- if (!i.ok) return { ok: !1, reason: "refused", message: i.failedAt.message };
356
- const l = { domainsById: {} };
357
- for (const o of i.queryFrames) {
358
- const h = await a(o, { reuseLoaded: !0 }).catch((w) => {
359
- console.warn("Applying the change without refreshed semantic metadata:", w);
360
- });
361
- at(l, h);
362
- }
363
- return n != null && n.stillWanted && !n.stillWanted() ? { ok: !1, reason: "dropped" } : e() ? D.getState().actions.applyProposal({ ...t, semanticExecutionPayload: l }) : { ok: !1, reason: "not_editable", message: X.no_save };
364
- },
365
- [e, a]
366
- );
367
- }
368
- function pa(e) {
369
- const { canEditDashboard: a, isInspectionMode: t } = rt(), n = nt(), s = D(ve), i = e && n && a === !0 && !t, l = L(i);
370
- ee(() => {
371
- l.current = i;
372
- });
373
- const o = P(
374
- () => l.current && ve(D.getState()),
375
- []
376
- );
377
- return { canChange: i && s, canChangeNow: o };
378
- }
379
- const Be = {
380
- dashboard_changed: "Not applied: the dashboard on screen changed after this change was prepared.",
381
- not_editable: "Not applied: the dashboard can't be changed on screen right now (the editor is open, or Save isn't shown).",
382
- expired: "Not applied: it arrived after the time it had to land.",
383
- refused: "Not applied: the change no longer fits the dashboard."
384
- }, K = {
385
- changed: "Changed by your assistant",
386
- undo: "Undo",
387
- changedSince: "Changed since. Cancel discards every unsaved change.",
388
- closeEditorToUndo: "Close the editor to undo."
389
- };
390
- function ga({
391
- port: e,
392
- onLifecycleEvent: a
393
- }) {
394
- const { canChange: t, canChangeNow: n } = pa(!0), s = D((c) => {
395
- var S;
396
- return (S = c.dashboard) == null ? void 0 : S.id;
397
- }), i = ba(n), [l, o] = I(null), h = L(/* @__PURE__ */ new Map()), w = L(/* @__PURE__ */ new Map()), x = L(Promise.resolve()), u = L({ apply: i, onLifecycleEvent: a });
398
- ee(() => {
399
- u.current = { apply: i, onLifecycleEvent: a };
400
- }), j(() => {
401
- e.setScreenState({ eligible: t, ...s ? { dashboardId: s } : {} });
402
- }, [e, t, s]), j(
403
- () => D.subscribe((c, S) => {
404
- if (c.editSessionEpoch !== S.editSessionEpoch) {
405
- h.current.clear(), o(null);
406
- return;
407
- }
408
- if (c.dashboard !== S.dashboard)
409
- for (const [m, f] of h.current)
410
- f !== c.dashboard && h.current.delete(m);
411
- }),
412
- []
413
- ), j(() => {
414
- const c = (m) => {
415
- const f = D.getState().dashboard;
416
- if (!f || f.id !== m.dashboardId) return;
417
- const v = Sa();
418
- h.current.set(v, f), e.answerCopyRequest({
419
- kind: "uploaded",
420
- screenId: e.screenId,
421
- requestId: m.requestId,
422
- revisionId: v,
423
- dashboard: f
424
- });
425
- }, S = async (m, f) => {
426
- var p, y, T;
427
- const v = w.current.get(m.deliveryId);
428
- if (v) {
429
- e.reportOutcome({ screenId: e.screenId, deliveryId: m.deliveryId, outcome: v });
430
- return;
431
- }
432
- const E = h.current.get(m.revisionId), A = () => !E || h.current.get(m.revisionId) !== E ? "dashboard_changed" : performance.now() < f + m.applyWithinMs ? null : "expired", _ = A();
433
- let k;
434
- if (_ || !E)
435
- k = Y(_ ?? "dashboard_changed");
436
- else {
437
- let g = "expired";
438
- const V = await u.current.apply(
439
- { proposalId: m.proposalId, operations: m.operations, context: m.context, basedOn: E },
440
- {
441
- stillWanted: () => {
442
- const R = A();
443
- return R && (g = R), R === null;
444
- }
445
- }
446
- );
447
- k = ya(V, g);
448
- }
449
- if (w.current.set(m.deliveryId, k), e.reportOutcome({ screenId: e.screenId, deliveryId: m.deliveryId, outcome: k }), k.status !== "applied") return;
450
- const N = ((p = D.getState().dashboard) == null ? void 0 : p.id) ?? "";
451
- o({ deliveryId: m.deliveryId, proposalId: m.proposalId, summary: m.summary, dashboardId: N, words: null }), (T = (y = u.current).onLifecycleEvent) == null || T.call(y, {
452
- type: "dashboard:change-applied",
453
- dashboardId: N,
454
- payload: { deliveryId: m.deliveryId, summary: m.summary }
455
- });
456
- };
457
- return e.subscribe((m) => {
458
- if (m.type === "copy_request") {
459
- c(m);
460
- return;
461
- }
462
- const f = performance.now();
463
- x.current = x.current.then(
464
- () => S(m, f).catch((v) => console.error("[live-screen] a delivery failed", v))
465
- );
466
- });
467
- }, [e]);
468
- const b = P(() => {
469
- var S, m;
470
- if (!l) return;
471
- const c = D.getState().actions.undoProposal(l.proposalId);
472
- c.ok ? ((m = (S = u.current).onLifecycleEvent) == null || m.call(S, {
473
- type: "dashboard:change-undone",
474
- dashboardId: l.dashboardId,
475
- payload: { deliveryId: l.deliveryId, summary: l.summary }
476
- }), o(null)) : c.reason === "changed_since" ? o({ ...l, words: "changed_since" }) : c.reason === "not_editable" ? o({ ...l, words: "not_editable" }) : o(null);
477
- }, [l]);
478
- return l ? /* @__PURE__ */ r(va, { note: l, onUndo: b }) : null;
479
- }
480
- function va({ note: e, onUndo: a }) {
481
- const t = D((l) => st(l, e.proposalId)), n = D((l) => l.isVisualEditing);
482
- if (t === "none" && e.words === null) return null;
483
- const s = e.words === "changed_since" || t === "changed_since", i = s ? "changed_since" : e.words === "not_editable" ? "not_editable" : t;
484
- return /* @__PURE__ */ d(
485
- "div",
486
- {
487
- className: "flex min-h-8 items-center gap-2 border-b border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground",
488
- "data-testid": "live-change-note",
489
- "data-note-state": i,
490
- role: "status",
491
- children: [
492
- /* @__PURE__ */ d("span", { className: "truncate", title: e.summary.join(" "), children: [
493
- K.changed,
494
- s ? `. ${K.changedSince}` : e.words === "not_editable" ? `. ${K.closeEditorToUndo}` : ""
495
- ] }),
496
- !s && t === "undoable" ? /* @__PURE__ */ d(M, { children: [
497
- /* @__PURE__ */ r("span", { "aria-hidden": "true", children: "·" }),
498
- /* @__PURE__ */ d(
499
- z,
500
- {
501
- variant: "outline",
502
- size: "xs",
503
- className: "h-6 gap-1 px-2 text-[11.5px]",
504
- disabled: n,
505
- title: n ? K.closeEditorToUndo : void 0,
506
- onClick: a,
507
- children: [
508
- /* @__PURE__ */ r(lt, { className: "h-3 w-3" }),
509
- K.undo
510
- ]
511
- }
512
- )
513
- ] }) : null
514
- ]
515
- }
516
- );
517
- }
518
- function ya(e, a) {
519
- if (e.ok) return { status: "applied" };
520
- switch (e.reason) {
521
- case "dashboard_changed":
522
- case "not_editable":
523
- return Y(e.reason);
524
- case "refused":
525
- return { status: "not_applied", reason: "refused", message: (e.message || Be.refused).slice(0, 500) };
526
- case "dropped":
527
- return Y(a);
528
- case "previous_not_applied":
529
- return Y("refused");
530
- }
531
- }
532
- function Y(e) {
533
- return { status: "not_applied", reason: e, message: Be[e] };
534
- }
535
- function Sa() {
536
- return globalThis.crypto.randomUUID();
537
- }
538
- const wa = ae(() => import("./dashboard-controls-CtFXlyjV.js")), xa = ae(
539
- () => import("./edit-dashboard-visual-oxt3x1wb.js")
540
- ), Ca = ae(() => import("./dashboard-json-DfGBUtCd.js"));
541
- function er({
542
- showControls: e = !1,
543
- showFooter: a = !0,
544
- liveScreen: t,
545
- ...n
546
- }) {
547
- const s = D(
548
- (o) => o.showDashboardJSON
549
- ), { appearance: i, preferences: l } = n;
550
- return /* @__PURE__ */ r(it, { FallbackComponent: ot, children: /* @__PURE__ */ r(dt, { dashboardProps: n, children: /* @__PURE__ */ d(ct, { children: [
551
- /* @__PURE__ */ r(ut, { componentType: "surfboard", componentId: n.id }),
552
- /* @__PURE__ */ d(mt, { appearance: i, children: [
553
- /* @__PURE__ */ r(
554
- ht,
555
- {
556
- toastOptions: {
557
- classNames: {
558
- toast: "max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",
559
- content: "min-w-0 flex-1",
560
- icon: "mt-0.5 shrink-0",
561
- title: "max-w-full break-words pr-8",
562
- description: "max-w-full break-words",
563
- closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
564
- }
565
- }
566
- }
567
- ),
568
- /* @__PURE__ */ d(ft, { preferences: l, children: [
569
- s && /* @__PURE__ */ r(Q, { fallback: null, children: /* @__PURE__ */ r(Ca, {}) }),
570
- /* @__PURE__ */ r(bt, { children: /* @__PURE__ */ r(ta, { children: /* @__PURE__ */ d("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
571
- e && /* @__PURE__ */ r(Q, { fallback: null, children: /* @__PURE__ */ r(wa, {}) }),
572
- t && /* @__PURE__ */ r(ga, { port: t, onLifecycleEvent: n.onDashboardLifecycleEvent }),
573
- /* @__PURE__ */ d("div", { className: "relative flex grow overflow-hidden", children: [
574
- /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ r(pt, { ...n, type: "dashboard", children: /* @__PURE__ */ r(Ta, {}) }) }),
575
- /* @__PURE__ */ r(da, {})
576
- ] })
577
- ] }) }) })
578
- ] })
579
- ] })
580
- ] }) }) });
581
- }
582
- function Ta() {
583
- const e = D((t) => t.isVisualEditing), a = B(() => /* @__PURE__ */ r(gt.Provider, { value: !0, children: /* @__PURE__ */ r(Xt, {}) }), []);
584
- return /* @__PURE__ */ d("div", { className: "relative flex min-h-0 min-w-0 grow basis-0 flex-col", children: [
585
- /* @__PURE__ */ r(
586
- "div",
587
- {
588
- className: "flex min-h-0 grow basis-0 flex-col",
589
- style: e ? { visibility: "hidden" } : void 0,
590
- inert: e || void 0,
591
- "aria-hidden": e || void 0,
592
- "data-dashboard-hidden": e || void 0,
593
- children: a
594
- }
595
- ),
596
- e && /* @__PURE__ */ r("div", { className: "absolute inset-0 z-10 flex flex-col", children: /* @__PURE__ */ r(Q, { fallback: null, children: /* @__PURE__ */ r(xa, {}) }) })
597
- ] });
598
- }
599
- function Na(e = {}) {
600
- const { authToken: a, tokenProps: t } = be(), n = D(
601
- (N) => N.actions.applyResolvedCalendarPreferences
602
- ), s = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, l = (t == null ? void 0 : t.apiServiceUrl) ?? null, [o, h] = I(!1), [w, x] = I(!1), [u, b] = I(!1), [c, S] = I(null), [m, f] = I(null), v = L(i);
603
- v.current = i, j(() => {
604
- f(null), S(null), h(!1), x(!1), b(!1);
605
- }, [i]);
606
- const E = P(async (N) => {
607
- const p = Jt(await N.json());
608
- if (!p.ok)
609
- throw new Error("Calendar preferences response is invalid");
610
- return p.value;
611
- }, []), A = P(async () => {
612
- if (!s || !i || !l) return;
613
- const N = i;
614
- h(!0), S(null);
615
- try {
616
- const p = await fetch(
617
- `${l}/v1/user-preferences/calendar`,
618
- {
619
- method: "GET",
620
- headers: { Authorization: `Bearer ${i}` }
621
- }
622
- );
623
- if (!p.ok) {
624
- const T = await p.json().catch(() => ({}));
625
- throw new Error(T.error || "Failed to fetch preferences");
626
- }
627
- const y = await E(p);
628
- v.current === N && f(y);
629
- } catch (p) {
630
- v.current === N && S(p instanceof Error ? p.message : "Unknown error");
631
- } finally {
632
- v.current === N && h(!1);
633
- }
634
- }, [i, l, s, E]);
635
- j(() => {
636
- s && A();
637
- }, [s, A]);
638
- const _ = P(
639
- async (N) => {
640
- if (!i || !l)
641
- return S("Not authenticated"), !1;
642
- const p = i;
643
- x(!0), S(null);
644
- try {
645
- const y = await fetch(
646
- `${l}/v1/user-preferences/calendar`,
647
- {
648
- method: "PATCH",
649
- headers: {
650
- "Content-Type": "application/json",
651
- Authorization: `Bearer ${i}`
652
- },
653
- body: JSON.stringify(N)
654
- }
655
- );
656
- if (!y.ok) {
657
- const g = await y.json().catch(() => ({}));
658
- throw new Error(g.error || "Failed to update preferences");
659
- }
660
- const T = await E(y);
661
- return v.current !== p ? !1 : (f(T), n(T.resolved, T.sources), !0);
662
- } catch (y) {
663
- return v.current === p && S(y instanceof Error ? y.message : "Unknown error"), !1;
664
- } finally {
665
- v.current === p && x(!1);
666
- }
667
- },
668
- [
669
- i,
670
- l,
671
- n,
672
- E
673
- ]
674
- ), k = P(async () => {
675
- if (!i || !l)
676
- return S("Not authenticated"), !1;
677
- const N = i;
678
- b(!0), S(null);
679
- try {
680
- const p = await fetch(
681
- `${l}/v1/user-preferences/calendar`,
682
- {
683
- method: "DELETE",
684
- headers: { Authorization: `Bearer ${i}` }
685
- }
686
- );
687
- if (!p.ok) {
688
- const T = await p.json().catch(() => ({}));
689
- throw new Error(T.error || "Failed to clear preferences");
690
- }
691
- const y = await E(p);
692
- return v.current !== N ? !1 : (f(y), n(y.resolved, y.sources), !0);
693
- } catch (p) {
694
- return v.current === N && S(p instanceof Error ? p.message : "Unknown error"), !1;
695
- } finally {
696
- v.current === N && b(!1);
697
- }
698
- }, [
699
- i,
700
- l,
701
- n,
702
- E
703
- ]);
704
- return {
705
- preferences: m,
706
- isLoading: o,
707
- isSaving: w,
708
- isClearing: u,
709
- error: c,
710
- updatePreferences: _,
711
- clearPreferences: k,
712
- refetch: A
713
- };
714
- }
715
- const te = [
716
- { value: "America/New_York", label: "Eastern Time (US & Canada)" },
717
- { value: "America/Chicago", label: "Central Time (US & Canada)" },
718
- { value: "America/Denver", label: "Mountain Time (US & Canada)" },
719
- { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
720
- { value: "America/Phoenix", label: "Arizona" },
721
- { value: "America/Anchorage", label: "Alaska" },
722
- { value: "Pacific/Honolulu", label: "Hawaii" },
723
- { value: "Europe/London", label: "London" },
724
- { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
725
- { value: "Asia/Tokyo", label: "Tokyo" },
726
- { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
727
- { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
728
- { value: "Australia/Sydney", label: "Sydney" },
729
- { value: "UTC", label: "UTC" }
730
- ], je = [
731
- { value: 0, label: "Sunday" },
732
- { value: 1, label: "Monday" },
733
- { value: 6, label: "Saturday" }
734
- ], Ae = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
735
- function Ea() {
736
- try {
737
- const e = Intl;
738
- if (e.supportedValuesOf)
739
- return e.supportedValuesOf("timeZone");
740
- } catch {
741
- }
742
- return te.map((e) => e.value);
743
- }
744
- function Ia(e) {
745
- if (!e) return "default";
746
- if (e.tz !== e.weekStart) return "inherited";
747
- switch (e.tz) {
748
- case "viewer_tenant":
749
- return "tenant";
750
- case "viewer_organization":
751
- return "organization";
752
- case "system_default":
753
- return "system";
754
- case "session_initial":
755
- return "embedded";
756
- default:
757
- return "default";
758
- }
759
- }
760
- function De(e) {
761
- const a = te.find((t) => t.value === e);
762
- return a ? a.label : e;
763
- }
764
- function Aa(e) {
765
- const a = je.find((t) => t.value === e);
766
- return a ? a.label : String(e);
767
- }
768
- function Da({
769
- active: e,
770
- onClose: a
771
- }) {
772
- const {
773
- preferences: t,
774
- isLoading: n,
775
- isSaving: s,
776
- isClearing: i,
777
- updatePreferences: l,
778
- clearPreferences: o
779
- } = Na({ enabled: e }), h = vt(), w = (t == null ? void 0 : t.resolved.tz) || (h == null ? void 0 : h.tz) || "UTC", x = (t == null ? void 0 : t.resolved.weekStart) ?? (h == null ? void 0 : h.weekStart) ?? 1, [u, b] = I((t == null ? void 0 : t.stored) === null), [c, S] = I(!1), [m, f] = I(
780
- w
781
- ), [v, E] = I(
782
- x
783
- ), [A, _] = I(!1), k = B(() => Ea(), []), N = B(
784
- () => k.filter(
785
- (C) => !te.some(($e) => $e.value === C)
786
- ),
787
- [k]
788
- ), p = B(() => De(m), [m]), y = t != null && t.inherited ? De(t.inherited.tz) : "UTC", T = t != null && t.inherited ? Aa(t.inherited.weekStart) : "Monday", g = Ia(
789
- t == null ? void 0 : t.inheritedSources
790
- );
791
- He.useEffect(() => {
792
- if (!e) {
793
- S(!1);
794
- return;
795
- }
796
- c || (t && b(t.stored === null), f(w), E(x));
797
- }, [
798
- e,
799
- c,
800
- t,
801
- w,
802
- x
803
- ]);
804
- const V = async () => {
805
- if (n) {
806
- F.error("Preferences are still loading. Please try again.");
807
- return;
808
- }
809
- u ? await o() ? (F.success("Now using default settings."), a()) : F.error("Failed to save preferences. Please try again.") : await l({
810
- tz: m,
811
- weekStart: v
812
- }) ? (F.success("Preferences saved."), a()) : F.error("Failed to save preferences. Please try again.");
813
- }, R = () => {
814
- a();
815
- }, re = s || i, We = re || n;
816
- return /* @__PURE__ */ d(M, { children: [
817
- /* @__PURE__ */ d("div", { className: "space-y-4 py-1", children: [
818
- /* @__PURE__ */ d(
819
- ye,
820
- {
821
- value: u ? "defaults" : "custom",
822
- onValueChange: (C) => {
823
- S(!0), b(C === "defaults");
824
- },
825
- className: "space-y-0.5",
826
- children: [
827
- /* @__PURE__ */ d(
828
- "label",
829
- {
830
- htmlFor: "mode-defaults",
831
- className: U(
832
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
833
- u && "bg-muted/50"
834
- ),
835
- onClick: () => {
836
- S(!0), b(!0);
837
- },
838
- children: [
839
- /* @__PURE__ */ r(
840
- ne,
841
- {
842
- value: "defaults",
843
- id: "mode-defaults",
844
- className: "mt-0.5"
845
- }
846
- ),
847
- /* @__PURE__ */ d("div", { className: "flex-1 min-w-0", children: [
848
- /* @__PURE__ */ d("p", { className: "text-[13px] font-medium text-foreground", children: [
849
- "Use ",
850
- g,
851
- " defaults"
852
- ] }),
853
- /* @__PURE__ */ d("p", { className: "text-[12px] text-muted-foreground", children: [
854
- y,
855
- ", week starts ",
856
- T
857
- ] })
858
- ] })
859
- ]
860
- }
861
- ),
862
- /* @__PURE__ */ d(
863
- "label",
864
- {
865
- htmlFor: "mode-custom",
866
- className: U(
867
- "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
868
- !u && "bg-muted/50"
869
- ),
870
- onClick: () => {
871
- S(!0), b(!1);
872
- },
873
- children: [
874
- /* @__PURE__ */ r(
875
- ne,
876
- {
877
- value: "custom",
878
- id: "mode-custom",
879
- className: "mt-0.5"
880
- }
881
- ),
882
- /* @__PURE__ */ r("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
883
- ]
884
- }
885
- )
886
- ]
887
- }
888
- ),
889
- /* @__PURE__ */ d(
890
- "div",
891
- {
892
- className: U(
893
- "space-y-4 border-t border-border/60 pt-4 transition-opacity",
894
- u && "pointer-events-none opacity-50"
895
- ),
896
- children: [
897
- /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
898
- /* @__PURE__ */ r(G, { className: Ae, children: "Timezone" }),
899
- /* @__PURE__ */ d(
900
- jt,
901
- {
902
- open: A,
903
- onOpenChange: _,
904
- modal: !0,
905
- children: [
906
- /* @__PURE__ */ r(Mt, { asChild: !0, children: /* @__PURE__ */ d(
907
- z,
908
- {
909
- variant: "outline",
910
- size: "xs",
911
- role: "combobox",
912
- "aria-expanded": A,
913
- className: "w-full justify-between text-[12px] font-normal",
914
- disabled: u,
915
- children: [
916
- /* @__PURE__ */ r("span", { className: "truncate", children: p }),
917
- /* @__PURE__ */ r(yt, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
918
- ]
919
- }
920
- ) }),
921
- /* @__PURE__ */ r(
922
- Vt,
923
- {
924
- className: "z-50 w-[--radix-popover-trigger-width] p-0",
925
- align: "start",
926
- children: /* @__PURE__ */ d(St, { className: "overflow-visible", children: [
927
- /* @__PURE__ */ r(wt, { placeholder: "Search timezones…" }),
928
- /* @__PURE__ */ d(xt, { children: [
929
- /* @__PURE__ */ r(Ct, { children: "No timezone found." }),
930
- /* @__PURE__ */ r(Se, { heading: "Common", children: te.map((C) => /* @__PURE__ */ d(
931
- we,
932
- {
933
- value: `${C.value} ${C.label}`,
934
- onSelect: () => {
935
- S(!0), f(C.value), _(!1);
936
- },
937
- children: [
938
- /* @__PURE__ */ r(
939
- xe,
940
- {
941
- className: U(
942
- "h-3.5 w-3.5",
943
- m === C.value ? "opacity-100" : "opacity-0"
944
- )
945
- }
946
- ),
947
- /* @__PURE__ */ r("span", { className: "flex-1", children: C.label }),
948
- /* @__PURE__ */ r("span", { className: "text-[11px] text-muted-foreground", children: C.value })
949
- ]
950
- },
951
- C.value
952
- )) }),
953
- /* @__PURE__ */ r(Tt, {}),
954
- /* @__PURE__ */ r(Se, { heading: "All timezones", children: N.map((C) => /* @__PURE__ */ d(
955
- we,
956
- {
957
- value: C,
958
- onSelect: () => {
959
- S(!0), f(C), _(!1);
960
- },
961
- children: [
962
- /* @__PURE__ */ r(
963
- xe,
964
- {
965
- className: U(
966
- "h-3.5 w-3.5",
967
- m === C ? "opacity-100" : "opacity-0"
968
- )
969
- }
970
- ),
971
- C
972
- ]
973
- },
974
- C
975
- )) })
976
- ] })
977
- ] })
978
- }
979
- )
980
- ]
981
- }
982
- )
983
- ] }),
984
- /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
985
- /* @__PURE__ */ r(G, { className: Ae, children: "Week starts on" }),
986
- /* @__PURE__ */ r(
987
- ye,
988
- {
989
- value: String(v),
990
- onValueChange: (C) => {
991
- S(!0), E(Number(C));
992
- },
993
- className: "flex gap-4",
994
- disabled: u,
995
- children: je.map((C) => /* @__PURE__ */ d(
996
- "label",
997
- {
998
- htmlFor: `week-start-${C.value}`,
999
- className: U(
1000
- "flex cursor-pointer items-center gap-2 text-[13px]",
1001
- u && "cursor-not-allowed"
1002
- ),
1003
- children: [
1004
- /* @__PURE__ */ r(
1005
- ne,
1006
- {
1007
- value: String(C.value),
1008
- id: `week-start-${C.value}`,
1009
- disabled: u
1010
- }
1011
- ),
1012
- C.label
1013
- ]
1014
- },
1015
- C.value
1016
- ))
1017
- }
1018
- )
1019
- ] })
1020
- ]
1021
- }
1022
- )
1023
- ] }),
1024
- /* @__PURE__ */ d(pe, { children: [
1025
- /* @__PURE__ */ r(
1026
- z,
1027
- {
1028
- variant: "outline",
1029
- size: "xs",
1030
- onClick: R,
1031
- disabled: re,
1032
- children: "Cancel"
1033
- }
1034
- ),
1035
- /* @__PURE__ */ r(z, { size: "xs", onClick: V, disabled: We, children: re ? /* @__PURE__ */ d(M, { children: [
1036
- /* @__PURE__ */ r(Ue, { className: "h-3.5 w-3.5 animate-spin" }),
1037
- "Saving…"
1038
- ] }) : "Save" })
1039
- ] })
1040
- ] });
1041
- }
1042
- function ka(e = {}) {
1043
- const { authToken: a, tokenProps: t } = be(), n = D(
1044
- (p) => p.actions.applyResolvedValueFormatPreferences
1045
- ), s = e.enabled ?? !0, i = (a == null ? void 0 : a.accessToken) ?? null, l = (t == null ? void 0 : t.apiServiceUrl) ?? null, o = L(i);
1046
- o.current = i;
1047
- const [h, w] = I(null), [x, u] = I(!1), [b, c] = I(!1), [S, m] = I(!1), [f, v] = I(null);
1048
- j(() => {
1049
- w(null), v(null), u(!1), c(!1), m(!1);
1050
- }, [i]);
1051
- const E = P(async (p) => {
1052
- const y = Ht(await p.json());
1053
- if (!y.ok)
1054
- throw new Error("Value format preferences response is invalid");
1055
- return y.value;
1056
- }, []), A = P(
1057
- async (p, y) => {
1058
- if (!i || !l)
1059
- throw new Error("Not authenticated");
1060
- const T = await fetch(
1061
- `${l}/v1/user-preferences/value-format`,
1062
- {
1063
- method: p,
1064
- headers: {
1065
- Authorization: `Bearer ${i}`,
1066
- ...y ? { "Content-Type": "application/json" } : {}
1067
- },
1068
- body: y ? JSON.stringify(y) : void 0
1069
- }
1070
- );
1071
- if (!T.ok) {
1072
- const g = await T.json().catch(() => ({}));
1073
- throw new Error(g.error || "Failed to update preferences");
1074
- }
1075
- return E(T);
1076
- },
1077
- [i, l, E]
1078
- ), _ = P(async () => {
1079
- if (!s || !i || !l) return;
1080
- const p = i;
1081
- u(!0), v(null);
1082
- try {
1083
- const y = await A("GET");
1084
- o.current === p && w(y);
1085
- } catch (y) {
1086
- o.current === p && v(y instanceof Error ? y.message : "Unknown error");
1087
- } finally {
1088
- o.current === p && u(!1);
1089
- }
1090
- }, [i, l, s, A]);
1091
- j(() => {
1092
- s && _();
1093
- }, [s, _]);
1094
- const k = P(
1095
- async (p) => {
1096
- const y = i;
1097
- c(!0), v(null);
1098
- try {
1099
- const T = await A("PATCH", p);
1100
- return o.current !== y ? !1 : (w(T), n(T.resolved, T.sources), !0);
1101
- } catch (T) {
1102
- return o.current === y && v(T instanceof Error ? T.message : "Unknown error"), !1;
1103
- } finally {
1104
- o.current === y && c(!1);
1105
- }
1106
- },
1107
- [i, n, A]
1108
- ), N = P(async () => {
1109
- const p = i;
1110
- m(!0), v(null);
1111
- try {
1112
- const y = await A("DELETE");
1113
- return o.current !== p ? !1 : (w(y), n(y.resolved, y.sources), !0);
1114
- } catch (y) {
1115
- return o.current === p && v(y instanceof Error ? y.message : "Unknown error"), !1;
1116
- } finally {
1117
- o.current === p && m(!1);
1118
- }
1119
- }, [i, n, A]);
1120
- return {
1121
- preferences: h,
1122
- isLoading: x,
1123
- isSaving: b,
1124
- isClearing: S,
1125
- error: f,
1126
- updatePreferences: k,
1127
- clearPreferences: N,
1128
- refetch: _
1129
- };
1130
- }
1131
- const he = [
1132
- { value: "en-US", label: "English (United States)" },
1133
- { value: "en-GB", label: "English (United Kingdom)" },
1134
- { value: "de-DE", label: "German (Germany)" },
1135
- { value: "fr-FR", label: "French (France)" },
1136
- { value: "es-ES", label: "Spanish (Spain)" },
1137
- { value: "it-IT", label: "Italian (Italy)" },
1138
- { value: "nl-NL", label: "Dutch (Netherlands)" },
1139
- { value: "pt-BR", label: "Portuguese (Brazil)" },
1140
- { value: "ja-JP", label: "Japanese (Japan)" },
1141
- { value: "en-IN", label: "English (India)" },
1142
- { value: "en-AU", label: "English (Australia)" },
1143
- { value: "en-NZ", label: "English (New Zealand)" },
1144
- { value: "mi-NZ", label: "Māori (New Zealand)" }
1145
- ], Me = /* @__PURE__ */ new Set([
1146
- "USD",
1147
- "EUR",
1148
- "GBP",
1149
- "CAD",
1150
- "AUD",
1151
- "JPY",
1152
- "CHF",
1153
- "INR",
1154
- "BRL",
1155
- "KWD"
1156
- ]), _a = Kt(), Pa = _a.filter(
1157
- (e) => !Me.has(e)
1158
- ), Ve = [
1159
- { value: "short", label: "Short" },
1160
- { value: "medium", label: "Medium" },
1161
- { value: "long", label: "Long" }
1162
- ], ke = "2026-07-31", se = "2026-07-31T14:30:45";
1163
- function fe(e) {
1164
- switch (e) {
1165
- case "viewer_user":
1166
- return "user";
1167
- case "viewer_tenant_user":
1168
- return "tenant user";
1169
- case "viewer_tenant":
1170
- return "tenant";
1171
- case "viewer_organization":
1172
- return "organization";
1173
- case "session_initial":
1174
- return "embedded session";
1175
- case "system_default":
1176
- return "system";
1177
- default:
1178
- return "another preference level";
1179
- }
1180
- }
1181
- function le(e) {
1182
- var a;
1183
- return ((a = Ve.find((t) => t.value === e)) == null ? void 0 : a.label) ?? e;
1184
- }
1185
- function za(e) {
1186
- const a = he.find((t) => t.value === e);
1187
- return a ? `${a.label} — ${a.value}` : e;
1188
- }
1189
- function ie(e) {
1190
- return {
1191
- short: e("short"),
1192
- medium: e("medium"),
1193
- long: e("long")
1194
- };
1195
- }
1196
- function oe({
1197
- id: e,
1198
- label: a,
1199
- value: t,
1200
- inherited: n,
1201
- inheritedSource: s,
1202
- examples: i,
1203
- disabled: l,
1204
- onValueChange: o
1205
- }) {
1206
- const h = t === void 0 ? `Inherited · ${le(n)}` : le(t);
1207
- return /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1208
- /* @__PURE__ */ r(G, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: a }),
1209
- /* @__PURE__ */ d(
1210
- de,
1211
- {
1212
- value: t ?? "inherit",
1213
- disabled: l,
1214
- onValueChange: o,
1215
- children: [
1216
- /* @__PURE__ */ r(ce, { id: e, size: "xs", children: /* @__PURE__ */ r(ue, { children: h }) }),
1217
- /* @__PURE__ */ d(me, { children: [
1218
- /* @__PURE__ */ r(O, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ d("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1219
- /* @__PURE__ */ d("span", { children: [
1220
- "Inherited from ",
1221
- fe(s),
1222
- " ·",
1223
- " ",
1224
- le(n)
1225
- ] }),
1226
- /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[n] })
1227
- ] }) }),
1228
- Ve.map((w) => /* @__PURE__ */ r(
1229
- O,
1230
- {
1231
- value: w.value,
1232
- className: "[&>span:last-child]:w-full",
1233
- children: /* @__PURE__ */ d("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1234
- /* @__PURE__ */ r("span", { children: w.label }),
1235
- /* @__PURE__ */ r("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[w.value] })
1236
- ] })
1237
- },
1238
- w.value
1239
- ))
1240
- ] })
1241
- ]
1242
- }
1243
- )
1244
- ] });
1245
- }
1246
- function La({
1247
- value: e,
1248
- inherited: a,
1249
- inheritedSources: t,
1250
- onChange: n,
1251
- disabled: s
1252
- }) {
1253
- var N, p, y, T;
1254
- const i = $(), l = $(), o = $(), h = $(), w = $(), u = (e.locale === void 0 ? void 0 : Fe(e.locale)) ?? a.locale, b = e.defaultCurrency ?? a.defaultCurrency, c = {
1255
- locale: u,
1256
- dateStyle: e.dateStyle ?? a.dateStyle,
1257
- dateTime: {
1258
- dateStyle: ((N = e.dateTime) == null ? void 0 : N.dateStyle) ?? a.dateTime.dateStyle,
1259
- timeStyle: ((p = e.dateTime) == null ? void 0 : p.timeStyle) ?? a.dateTime.timeStyle
1260
- },
1261
- defaultCurrency: b
1262
- }, S = new Intl.NumberFormat(u, {
1263
- style: "currency",
1264
- currency: b
1265
- }).format(1e3), m = Z({
1266
- preferences: c,
1267
- calendar: { tz: "UTC" }
1268
- }), f = H({
1269
- value: ke,
1270
- metadata: { kind: "raw_temporal", valueKind: "date" },
1271
- format: m
1272
- }).text, v = H({
1273
- value: se,
1274
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1275
- format: m
1276
- }).text, E = ie(
1277
- (g) => H({
1278
- value: ke,
1279
- metadata: { kind: "raw_temporal", valueKind: "date" },
1280
- format: Z({
1281
- preferences: { ...c, dateStyle: g },
1282
- calendar: { tz: "UTC" }
1283
- })
1284
- }).text
1285
- ), A = ie(
1286
- (g) => H({
1287
- value: se,
1288
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1289
- format: Z({
1290
- preferences: {
1291
- ...c,
1292
- dateTime: { ...c.dateTime, dateStyle: g }
1293
- },
1294
- calendar: { tz: "UTC" }
1295
- })
1296
- }).text
1297
- ), _ = ie(
1298
- (g) => H({
1299
- value: se,
1300
- metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1301
- format: Z({
1302
- preferences: {
1303
- ...c,
1304
- dateTime: { ...c.dateTime, timeStyle: g }
1305
- },
1306
- calendar: { tz: "UTC" }
1307
- })
1308
- }).text
1309
- ), k = (g, V) => {
1310
- const R = {
1311
- ...e.dateTime,
1312
- [g]: V === "inherit" ? void 0 : V
1313
- };
1314
- n({
1315
- ...e,
1316
- dateTime: R.dateStyle === void 0 && R.timeStyle === void 0 ? void 0 : R
1317
- });
1318
- };
1319
- return /* @__PURE__ */ d("div", { className: "space-y-4", children: [
1320
- /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1321
- /* @__PURE__ */ r(
1322
- G,
1323
- {
1324
- htmlFor: i,
1325
- className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1326
- children: "Locale"
1327
- }
1328
- ),
1329
- /* @__PURE__ */ d(
1330
- de,
1331
- {
1332
- value: e.locale ?? "inherit",
1333
- disabled: s,
1334
- onValueChange: (g) => n({
1335
- ...e,
1336
- locale: g === "inherit" ? void 0 : g
1337
- }),
1338
- children: [
1339
- /* @__PURE__ */ r(ce, { id: i, size: "xs", children: /* @__PURE__ */ r(ue, { children: e.locale === void 0 ? `Inherited · ${a.locale}` : za(e.locale) }) }),
1340
- /* @__PURE__ */ d(me, { children: [
1341
- /* @__PURE__ */ d(O, { value: "inherit", children: [
1342
- "Inherited from ",
1343
- fe(t.locale),
1344
- " ·",
1345
- " ",
1346
- a.locale
1347
- ] }),
1348
- e.locale && !he.some(
1349
- (g) => g.value === e.locale
1350
- ) && /* @__PURE__ */ r(O, { value: e.locale, children: e.locale }),
1351
- he.map((g) => /* @__PURE__ */ d(O, { value: g.value, children: [
1352
- g.label,
1353
- " — ",
1354
- g.value
1355
- ] }, g.value))
1356
- ] })
1357
- ]
1358
- }
1359
- )
1360
- ] }),
1361
- /* @__PURE__ */ d("fieldset", { className: "space-y-2", children: [
1362
- /* @__PURE__ */ r("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
1363
- /* @__PURE__ */ r(
1364
- oe,
1365
- {
1366
- id: o,
1367
- label: "Format",
1368
- value: e.dateStyle,
1369
- inherited: a.dateStyle,
1370
- inheritedSource: t.dateStyle,
1371
- examples: E,
1372
- disabled: s,
1373
- onValueChange: (g) => n({
1374
- ...e,
1375
- dateStyle: g === "inherit" ? void 0 : g
1376
- })
1377
- }
1378
- )
1379
- ] }),
1380
- /* @__PURE__ */ d("fieldset", { className: "space-y-2", children: [
1381
- /* @__PURE__ */ r("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
1382
- /* @__PURE__ */ r(
1383
- oe,
1384
- {
1385
- id: h,
1386
- label: "Date",
1387
- value: (y = e.dateTime) == null ? void 0 : y.dateStyle,
1388
- inherited: a.dateTime.dateStyle,
1389
- inheritedSource: t.dateTime.dateStyle,
1390
- examples: A,
1391
- disabled: s,
1392
- onValueChange: (g) => k("dateStyle", g)
1393
- }
1394
- ),
1395
- /* @__PURE__ */ r(
1396
- oe,
1397
- {
1398
- id: w,
1399
- label: "Time",
1400
- value: (T = e.dateTime) == null ? void 0 : T.timeStyle,
1401
- inherited: a.dateTime.timeStyle,
1402
- inheritedSource: t.dateTime.timeStyle,
1403
- examples: _,
1404
- disabled: s,
1405
- onValueChange: (g) => k("timeStyle", g)
1406
- }
1407
- )
1408
- ] }),
1409
- /* @__PURE__ */ d("div", { className: "space-y-1.5", children: [
1410
- /* @__PURE__ */ r(
1411
- G,
1412
- {
1413
- htmlFor: l,
1414
- className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1415
- children: "Default currency"
1416
- }
1417
- ),
1418
- /* @__PURE__ */ d(
1419
- de,
1420
- {
1421
- value: e.defaultCurrency ?? "inherit",
1422
- disabled: s,
1423
- onValueChange: (g) => n({
1424
- ...e,
1425
- defaultCurrency: g === "inherit" ? void 0 : g
1426
- }),
1427
- children: [
1428
- /* @__PURE__ */ r(ce, { id: l, size: "xs", children: /* @__PURE__ */ r(ue, { children: e.defaultCurrency === void 0 ? `Inherited · ${a.defaultCurrency}` : e.defaultCurrency }) }),
1429
- /* @__PURE__ */ d(me, { children: [
1430
- /* @__PURE__ */ d(O, { value: "inherit", children: [
1431
- "Inherited from ",
1432
- fe(t.defaultCurrency),
1433
- " ·",
1434
- " ",
1435
- a.defaultCurrency
1436
- ] }),
1437
- [...Me].map((g) => /* @__PURE__ */ r(O, { value: g, children: g }, g)),
1438
- Pa.map((g) => /* @__PURE__ */ r(O, { value: g, children: g }, g))
1439
- ] })
1440
- ]
1441
- }
1442
- )
1443
- ] }),
1444
- /* @__PURE__ */ d("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1445
- /* @__PURE__ */ r("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1446
- /* @__PURE__ */ d("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1447
- /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1448
- /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Date" }),
1449
- /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: f })
1450
- ] }),
1451
- /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1452
- /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Date & time" }),
1453
- /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: v })
1454
- ] }),
1455
- /* @__PURE__ */ d("div", { className: "flex items-baseline justify-between gap-4", children: [
1456
- /* @__PURE__ */ r("dt", { className: "text-muted-foreground", children: "Currency" }),
1457
- /* @__PURE__ */ r("dd", { className: "text-right font-medium text-foreground", children: S })
1458
- ] })
1459
- ] })
1460
- ] }),
1461
- /* @__PURE__ */ r("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1462
- ] });
1463
- }
1464
- const _e = [
1465
- "locale",
1466
- "dateStyle",
1467
- "dateTime.dateStyle",
1468
- "dateTime.timeStyle",
1469
- "defaultCurrency"
1470
- ];
1471
- function Pe(e, a) {
1472
- var t, n;
1473
- switch (a) {
1474
- case "locale":
1475
- return e == null ? void 0 : e.locale;
1476
- case "dateStyle":
1477
- return e == null ? void 0 : e.dateStyle;
1478
- case "dateTime.dateStyle":
1479
- return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1480
- case "dateTime.timeStyle":
1481
- return (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1482
- case "defaultCurrency":
1483
- return e == null ? void 0 : e.defaultCurrency;
1484
- }
1485
- }
1486
- function Ra(e) {
1487
- var n, s;
1488
- const a = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.dateStyle, t = (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.timeStyle;
1489
- return {
1490
- locale: e == null ? void 0 : e.locale,
1491
- dateStyle: e == null ? void 0 : e.dateStyle,
1492
- dateTime: a === void 0 && t === void 0 ? void 0 : { dateStyle: a, timeStyle: t },
1493
- defaultCurrency: e == null ? void 0 : e.defaultCurrency
1494
- };
1495
- }
1496
- function Ua({
1497
- active: e,
1498
- onClose: a
1499
- }) {
1500
- var o, h, w, x, u, b, c;
1501
- const { preferences: t, isLoading: n, isSaving: s, updatePreferences: i } = ka({ enabled: e });
1502
- if (!e) return null;
1503
- if (!t)
1504
- return /* @__PURE__ */ d(M, { children: [
1505
- /* @__PURE__ */ r("div", { className: "py-2", children: /* @__PURE__ */ r("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: n ? "Loading preferences…" : "Preferences unavailable." }) }),
1506
- /* @__PURE__ */ d(pe, { className: "justify-between sm:justify-between", children: [
1507
- /* @__PURE__ */ r(z, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1508
- /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
1509
- /* @__PURE__ */ r(z, { variant: "outline", size: "xs", onClick: a, children: "Cancel" }),
1510
- /* @__PURE__ */ r(z, { size: "xs", disabled: !0, children: "Save" })
1511
- ] })
1512
- ] })
1513
- ] });
1514
- const l = [
1515
- ((o = t.stored) == null ? void 0 : o.locale) ?? "",
1516
- ((h = t.stored) == null ? void 0 : h.dateStyle) ?? "",
1517
- ((x = (w = t.stored) == null ? void 0 : w.dateTime) == null ? void 0 : x.dateStyle) ?? "",
1518
- ((b = (u = t.stored) == null ? void 0 : u.dateTime) == null ? void 0 : b.timeStyle) ?? "",
1519
- ((c = t.stored) == null ? void 0 : c.defaultCurrency) ?? ""
1520
- ].join(":");
1521
- return /* @__PURE__ */ r(
1522
- Fa,
1523
- {
1524
- preferences: t,
1525
- isSaving: s,
1526
- updatePreferences: i,
1527
- onClose: a
1528
- },
1529
- l
1530
- );
1531
- }
1532
- function Fa({
1533
- preferences: e,
1534
- isSaving: a,
1535
- updatePreferences: t,
1536
- onClose: n
1537
- }) {
1538
- var w, x;
1539
- const [s, i] = I(
1540
- () => Ra(e.stored)
1541
- ), l = (s.locale === void 0 || Fe(s.locale) !== void 0) && (s.defaultCurrency === void 0 || qt(s.defaultCurrency) !== void 0) && (s.dateStyle === void 0 || ["short", "medium", "long"].includes(s.dateStyle)) && (((w = s.dateTime) == null ? void 0 : w.dateStyle) === void 0 || ["short", "medium", "long"].includes(s.dateTime.dateStyle)) && (((x = s.dateTime) == null ? void 0 : x.timeStyle) === void 0 || ["short", "medium", "long"].includes(s.dateTime.timeStyle)), o = async () => {
1542
- const u = {
1543
- ...s.locale !== void 0 ? { locale: s.locale } : {},
1544
- ...s.dateStyle !== void 0 ? { dateStyle: s.dateStyle } : {},
1545
- ...s.dateTime ? { dateTime: { ...s.dateTime } } : {},
1546
- ...s.defaultCurrency !== void 0 ? { defaultCurrency: s.defaultCurrency } : {}
1547
- }, b = _e.filter(
1548
- (m) => Pe(s, m) === void 0 && Pe(e.stored, m) !== void 0
1549
- ), c = {
1550
- ...Object.keys(u).length > 0 ? { set: u } : {},
1551
- ...b.length > 0 ? { clear: b } : {}
1552
- };
1553
- (Object.keys(c).length === 0 ? !0 : await t(c)) ? (F.success("Display format preferences saved."), n()) : F.error("Failed to save preferences. Please try again.");
1554
- }, h = async () => {
1555
- await t({
1556
- clear: [..._e]
1557
- }) ? (F.success("Display format preferences reset."), n()) : F.error(
1558
- "Failed to reset display format preferences. Please try again."
1559
- );
1560
- };
1561
- return /* @__PURE__ */ d(M, { children: [
1562
- /* @__PURE__ */ r("div", { className: "py-2", children: /* @__PURE__ */ r(
1563
- La,
1564
- {
1565
- value: s,
1566
- inherited: e.inherited,
1567
- inheritedSources: e.inheritedSources,
1568
- onChange: i,
1569
- disabled: a
1570
- }
1571
- ) }),
1572
- /* @__PURE__ */ d(pe, { className: "justify-between sm:justify-between", children: [
1573
- /* @__PURE__ */ r(
1574
- z,
1575
- {
1576
- variant: "ghost",
1577
- size: "xs",
1578
- onClick: h,
1579
- disabled: a || e.stored === null,
1580
- children: "Reset display formats"
1581
- }
1582
- ),
1583
- /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
1584
- /* @__PURE__ */ r(
1585
- z,
1586
- {
1587
- variant: "outline",
1588
- size: "xs",
1589
- onClick: n,
1590
- disabled: a,
1591
- children: "Cancel"
1592
- }
1593
- ),
1594
- /* @__PURE__ */ r(
1595
- z,
1596
- {
1597
- size: "xs",
1598
- onClick: o,
1599
- disabled: a || !l,
1600
- children: a ? /* @__PURE__ */ d(M, { children: [
1601
- /* @__PURE__ */ r(Ue, { className: "h-3.5 w-3.5 animate-spin" }),
1602
- "Saving…"
1603
- ] }) : "Save"
1604
- }
1605
- )
1606
- ] })
1607
- ] })
1608
- ] });
1609
- }
1610
- function tr({
1611
- open: e,
1612
- onOpenChange: a
1613
- }) {
1614
- const [t, n] = I("display"), s = () => a(!1);
1615
- return /* @__PURE__ */ r(Nt, { open: e, onOpenChange: a, children: /* @__PURE__ */ d(Et, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1616
- /* @__PURE__ */ d(It, { children: [
1617
- /* @__PURE__ */ r(At, { className: "text-[15px]", children: "Report preferences" }),
1618
- /* @__PURE__ */ r(Dt, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
1619
- ] }),
1620
- /* @__PURE__ */ d(Wt, { value: t, onValueChange: n, children: [
1621
- /* @__PURE__ */ d($t, { variant: "underline", className: "w-full justify-start", children: [
1622
- /* @__PURE__ */ r(Ce, { value: "display", children: "Display formats" }),
1623
- /* @__PURE__ */ r(Ce, { value: "calendar", children: "Calendar" })
1624
- ] }),
1625
- /* @__PURE__ */ r(Te, { value: "display", children: /* @__PURE__ */ r(
1626
- Ua,
1627
- {
1628
- active: e && t === "display",
1629
- onClose: s
1630
- }
1631
- ) }),
1632
- /* @__PURE__ */ r(Te, { value: "calendar", children: /* @__PURE__ */ r(
1633
- Da,
1634
- {
1635
- active: e && t === "calendar",
1636
- onClose: s
1637
- }
1638
- ) })
1639
- ] })
1640
- ] }) });
1641
- }
1642
- export {
1643
- ea as A,
1644
- er as D,
1645
- tr as R,
1646
- La as a,
1647
- da as b,
1648
- Qa as c,
1649
- ba as d,
1650
- pa as u
1651
- };