@elevasis/ui 2.33.2 → 2.34.0

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 (73) hide show
  1. package/dist/api/index.d.ts +9 -2
  2. package/dist/api/index.js +1 -1
  3. package/dist/app/index.css +452 -0
  4. package/dist/app/index.d.ts +1250 -3
  5. package/dist/app/index.js +144 -8
  6. package/dist/charts/index.js +2 -3
  7. package/dist/{chunk-VGU4ZFYZ.js → chunk-3AJVNMY5.js} +45 -28
  8. package/dist/chunk-3QXJK5IY.js +25 -0
  9. package/dist/chunk-4O4MII5S.js +4716 -0
  10. package/dist/{chunk-KW7ZNQD7.js → chunk-5EYJ2GIN.js} +4 -8
  11. package/dist/{chunk-OIBHQH5Q.js → chunk-BPQVTIUP.js} +12 -3
  12. package/dist/{chunk-52K5RFDH.js → chunk-DTFKWZ7A.js} +1098 -2280
  13. package/dist/{chunk-EPTHX4VZ.js → chunk-HRWLKKWM.js} +11 -2
  14. package/dist/{chunk-ZMK5Z6KE.js → chunk-IGDYWFNE.js} +2 -2
  15. package/dist/{chunk-44I4LOH6.js → chunk-IVGI4GDL.js} +3 -3
  16. package/dist/{chunk-4DYOXEH6.js → chunk-LAWLB6CT.js} +1 -1
  17. package/dist/{chunk-TGVAIWIL.js → chunk-LRWTWOGP.js} +3 -3
  18. package/dist/{chunk-O56ESZCQ.js → chunk-MP3GPBPX.js} +3 -3
  19. package/dist/{chunk-T3J6U77J.js → chunk-NLBQTDOW.js} +12 -17
  20. package/dist/{chunk-IBWMR4TI.js → chunk-O6JXQ6UQ.js} +1 -2
  21. package/dist/{chunk-TBVLQRXT.js → chunk-OBBQ2JCM.js} +3 -3
  22. package/dist/{chunk-GWGQI6V4.js → chunk-PLP3NYPL.js} +80 -171
  23. package/dist/{chunk-Z2K2EAPL.js → chunk-RIAXZ6AH.js} +5 -6
  24. package/dist/chunk-SDXSB3HN.js +425 -0
  25. package/dist/{chunk-JA5ECJJB.js → chunk-VTXTZXAU.js} +156 -4
  26. package/dist/{chunk-32I2RCGC.js → chunk-W73ZABT6.js} +1 -1
  27. package/dist/{chunk-2ZZ72TAB.js → chunk-WU4FNWCW.js} +3 -3
  28. package/dist/{chunk-A4VDJJCV.js → chunk-YNWZIWJL.js} +4 -5
  29. package/dist/components/index.d.ts +0 -23
  30. package/dist/components/index.js +27 -448
  31. package/dist/components/navigation/index.js +4 -6
  32. package/dist/features/clients/index.js +7 -12
  33. package/dist/features/crm/index.js +9 -14
  34. package/dist/features/dashboard/index.d.ts +0 -23
  35. package/dist/features/dashboard/index.js +9 -14
  36. package/dist/features/delivery/index.js +8 -13
  37. package/dist/features/knowledge/index.js +5 -7
  38. package/dist/features/lead-gen/index.js +9 -14
  39. package/dist/features/monitoring/index.js +10 -15
  40. package/dist/features/monitoring/requests/index.js +7 -12
  41. package/dist/features/operations/index.d.ts +44 -35
  42. package/dist/features/operations/index.js +12 -17
  43. package/dist/features/settings/index.js +8 -13
  44. package/dist/hooks/index.d.ts +20 -27
  45. package/dist/hooks/index.js +7 -12
  46. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +20 -27
  47. package/dist/hooks/published.d.ts +20 -27
  48. package/dist/hooks/published.js +7 -12
  49. package/dist/index.d.ts +53 -38
  50. package/dist/index.js +8 -13
  51. package/dist/knowledge/index.d.ts +30 -38
  52. package/dist/knowledge/index.js +36 -200
  53. package/dist/{knowledge-search-index-VMAW7FLR.js → knowledge-search-index-ORIJCEZX.js} +3 -3
  54. package/dist/organization/index.js +1 -2
  55. package/dist/provider/index.d.ts +24 -31
  56. package/dist/provider/index.js +6 -11
  57. package/dist/provider/published.d.ts +24 -31
  58. package/dist/provider/published.js +5 -9
  59. package/dist/test-utils/index.d.ts +2 -0
  60. package/dist/test-utils/index.js +14 -2
  61. package/dist/test-utils/setup.js +38 -0
  62. package/dist/types/index.d.ts +20 -27
  63. package/dist/utils/index.d.ts +0 -23
  64. package/dist/zustand/index.d.ts +15 -2
  65. package/dist/zustand/index.js +35 -1
  66. package/package.json +4 -4
  67. package/dist/chunk-HUJCU55S.js +0 -159
  68. package/dist/chunk-IOXOPMYS.js +0 -145
  69. package/dist/chunk-J2UD7BOH.js +0 -347
  70. package/dist/chunk-QDFJSUG3.js +0 -13
  71. package/dist/chunk-SZHARWKU.js +0 -15
  72. package/dist/chunk-WKW6B5ID.js +0 -29
  73. package/dist/chunk-XCYKC6OZ.js +0 -1
@@ -0,0 +1,425 @@
1
+ import { useAppearance } from './chunk-E565XMTQ.js';
2
+ import { useState, Component } from 'react';
3
+ import { CopyButton, Tooltip } from '@mantine/core';
4
+ import { IconCheck, IconCopy } from '@tabler/icons-react';
5
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
6
+
7
+ var tokens = {
8
+ cardBg: "rgba(16, 16, 20, 0.92)",
9
+ cardBorder: "rgba(255, 255, 255, 0.06)",
10
+ accentRed: "#ff5555",
11
+ accentRedDim: "rgba(255, 85, 85, 0.15)",
12
+ textPrimary: "#e8e8e8",
13
+ textSecondary: "rgba(255, 255, 255, 0.5)",
14
+ textTertiary: "rgba(255, 255, 255, 0.3)",
15
+ codeBg: "rgba(0, 0, 0, 0.35)",
16
+ codeBorder: "rgba(255, 255, 255, 0.05)",
17
+ fileHighlight: "#7dd3fc",
18
+ separator: "rgba(255, 255, 255, 0.06)",
19
+ mono: "'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace",
20
+ sans: "'Inter', -apple-system, system-ui, sans-serif"
21
+ };
22
+ function parseStackFrames(stack) {
23
+ return stack.split("\n").filter((line) => line.trim().startsWith("at ")).map((line) => {
24
+ const trimmed = line.trim();
25
+ const parenMatch = trimmed.match(/^at\s+(.+?)\s+\((.+)\)$/);
26
+ if (parenMatch) {
27
+ return { fn: parenMatch[1], file: parenMatch[2], raw: trimmed };
28
+ }
29
+ const simpleMatch = trimmed.match(/^at\s+(.+)$/);
30
+ if (simpleMatch) {
31
+ return { fn: "", file: simpleMatch[1], raw: trimmed };
32
+ }
33
+ return { fn: "", file: "", raw: trimmed };
34
+ });
35
+ }
36
+ var COMPONENT_NOISE = /* @__PURE__ */ new Set([
37
+ "div",
38
+ "main",
39
+ "span",
40
+ "section",
41
+ "Lazy",
42
+ "Suspense",
43
+ "SafeFragment",
44
+ "MatchImpl",
45
+ "MatchInnerImpl",
46
+ "OutletImpl",
47
+ "CatchBoundaryImpl",
48
+ "CatchBoundary",
49
+ "MatchesInner",
50
+ "Matches",
51
+ "SplitComponent"
52
+ ]);
53
+ function isNoiseComponent(name) {
54
+ if (COMPONENT_NOISE.has(name)) return true;
55
+ if (name.startsWith("@mantine/") || name.startsWith("@tanstack/")) return true;
56
+ return false;
57
+ }
58
+ function parseComponentStack(stack) {
59
+ return stack.trim().split("\n").map((line) => line.trim()).filter((line) => line.startsWith("at ")).map((line) => {
60
+ const match = line.match(/^at\s+(\S+)/);
61
+ return match ? match[1] : line.replace(/^at\s+/, "");
62
+ }).filter((name) => !isNoiseComponent(name));
63
+ }
64
+ function SectionLabel({ children }) {
65
+ return /* @__PURE__ */ jsx(
66
+ "div",
67
+ {
68
+ style: {
69
+ fontSize: 10,
70
+ fontFamily: tokens.sans,
71
+ fontWeight: 600,
72
+ textTransform: "uppercase",
73
+ letterSpacing: "0.08em",
74
+ color: tokens.textTertiary,
75
+ marginBottom: 6
76
+ },
77
+ children
78
+ }
79
+ );
80
+ }
81
+ function CodeBlock({ children, style }) {
82
+ return /* @__PURE__ */ jsx(
83
+ "div",
84
+ {
85
+ style: {
86
+ background: tokens.codeBg,
87
+ border: `1px solid ${tokens.codeBorder}`,
88
+ borderRadius: 6,
89
+ padding: "10px 14px",
90
+ fontFamily: tokens.mono,
91
+ fontSize: 12,
92
+ lineHeight: 1.6,
93
+ color: tokens.textPrimary,
94
+ overflowX: "auto",
95
+ ...style
96
+ },
97
+ children
98
+ }
99
+ );
100
+ }
101
+ function StackFrameRow({ frame }) {
102
+ return /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 8, alignItems: "baseline" }, children: [
103
+ frame.fn && /* @__PURE__ */ jsx("span", { style: { color: tokens.textPrimary, flexShrink: 0 }, children: frame.fn }),
104
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.fileHighlight, opacity: 0.7, fontSize: 11 }, children: frame.file })
105
+ ] });
106
+ }
107
+ function Separator() {
108
+ return /* @__PURE__ */ jsx("div", { style: { height: 1, background: tokens.separator, margin: "4px 0" } });
109
+ }
110
+ function ErrorReportCard({
111
+ errorName,
112
+ errorMessage,
113
+ errorStack,
114
+ componentStack,
115
+ eventId,
116
+ url,
117
+ timestamp,
118
+ reportText,
119
+ appVersion
120
+ }) {
121
+ const [expanded, setExpanded] = useState(true);
122
+ const frames = errorStack ? parseStackFrames(errorStack) : [];
123
+ const components = componentStack ? parseComponentStack(componentStack) : [];
124
+ return /* @__PURE__ */ jsxs(
125
+ "div",
126
+ {
127
+ style: {
128
+ background: tokens.cardBg,
129
+ border: `1px solid ${tokens.cardBorder}`,
130
+ borderTop: `3px solid ${tokens.accentRed}`,
131
+ borderRadius: 10,
132
+ maxWidth: 720,
133
+ width: "100%",
134
+ fontFamily: tokens.sans,
135
+ backdropFilter: "blur(20px)",
136
+ boxShadow: "0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(255, 85, 85, 0.05)"
137
+ },
138
+ children: [
139
+ /* @__PURE__ */ jsxs("div", { style: { padding: "20px 24px 0" }, children: [
140
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", marginBottom: 12 }, children: [
141
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: /* @__PURE__ */ jsx(
142
+ "span",
143
+ {
144
+ style: {
145
+ background: tokens.accentRedDim,
146
+ color: tokens.accentRed,
147
+ fontSize: 12,
148
+ fontWeight: 600,
149
+ fontFamily: tokens.mono,
150
+ padding: "3px 10px",
151
+ borderRadius: 4,
152
+ letterSpacing: "0.02em"
153
+ },
154
+ children: errorName
155
+ }
156
+ ) }),
157
+ /* @__PURE__ */ jsx(CopyButton, { value: reportText, timeout: 2e3, children: ({ copied, copy }) => /* @__PURE__ */ jsx(Tooltip, { label: copied ? "Copied!" : "Copy error report", position: "left", children: /* @__PURE__ */ jsxs(
158
+ "button",
159
+ {
160
+ onClick: copy,
161
+ style: {
162
+ background: copied ? "rgba(45, 212, 191, 0.15)" : "rgba(255, 255, 255, 0.06)",
163
+ border: `1px solid ${copied ? "rgba(45, 212, 191, 0.3)" : "rgba(255, 255, 255, 0.08)"}`,
164
+ borderRadius: 6,
165
+ padding: "5px 12px",
166
+ color: copied ? "#2dd4bf" : tokens.textSecondary,
167
+ cursor: "pointer",
168
+ display: "flex",
169
+ alignItems: "center",
170
+ gap: 6,
171
+ fontSize: 12,
172
+ fontFamily: tokens.sans,
173
+ transition: "all 0.15s ease"
174
+ },
175
+ children: [
176
+ copied ? /* @__PURE__ */ jsx(IconCheck, { size: 13 }) : /* @__PURE__ */ jsx(IconCopy, { size: 13 }),
177
+ copied ? "Copied" : "Copy"
178
+ ]
179
+ }
180
+ ) }) })
181
+ ] }),
182
+ /* @__PURE__ */ jsx(
183
+ "div",
184
+ {
185
+ style: {
186
+ fontSize: 16,
187
+ fontWeight: 500,
188
+ color: tokens.textPrimary,
189
+ lineHeight: 1.5,
190
+ marginBottom: 16
191
+ },
192
+ children: errorMessage
193
+ }
194
+ ),
195
+ /* @__PURE__ */ jsxs(
196
+ "div",
197
+ {
198
+ style: {
199
+ background: tokens.codeBg,
200
+ border: `1px solid ${tokens.codeBorder}`,
201
+ borderRadius: 6,
202
+ padding: "8px 12px",
203
+ fontFamily: tokens.mono,
204
+ fontSize: 12,
205
+ color: tokens.fileHighlight,
206
+ marginBottom: 16,
207
+ display: "flex",
208
+ alignItems: "center",
209
+ gap: 8
210
+ },
211
+ children: [
212
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary, fontSize: 10, flexShrink: 0 }, children: "URL" }),
213
+ /* @__PURE__ */ jsx("span", { style: { opacity: 0.8 }, children: url })
214
+ ]
215
+ }
216
+ )
217
+ ] }),
218
+ /* @__PURE__ */ jsx("div", { style: { padding: "0 24px" }, children: /* @__PURE__ */ jsxs(
219
+ "button",
220
+ {
221
+ onClick: () => setExpanded((v) => !v),
222
+ style: {
223
+ background: "none",
224
+ border: "none",
225
+ color: tokens.textTertiary,
226
+ fontSize: 11,
227
+ fontFamily: tokens.sans,
228
+ cursor: "pointer",
229
+ padding: "4px 0",
230
+ display: "flex",
231
+ alignItems: "center",
232
+ gap: 4,
233
+ letterSpacing: "0.05em",
234
+ textTransform: "uppercase",
235
+ fontWeight: 600
236
+ },
237
+ children: [
238
+ expanded ? "- Hide" : "+ Show",
239
+ " details"
240
+ ]
241
+ }
242
+ ) }),
243
+ expanded && /* @__PURE__ */ jsxs("div", { style: { padding: "8px 24px 20px" }, children: [
244
+ frames.length > 0 && /* @__PURE__ */ jsxs("div", { style: { marginBottom: 16 }, children: [
245
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Stack Trace" }),
246
+ /* @__PURE__ */ jsx(CodeBlock, { style: { maxHeight: 220, overflowY: "auto" }, children: frames.map((frame, i) => /* @__PURE__ */ jsx(StackFrameRow, { frame }, i)) })
247
+ ] }),
248
+ components.length > 0 && /* @__PURE__ */ jsxs("div", { style: { marginBottom: 16 }, children: [
249
+ /* @__PURE__ */ jsx(SectionLabel, { children: "Component Tree" }),
250
+ /* @__PURE__ */ jsx(CodeBlock, { style: { maxHeight: 120, overflowY: "auto" }, children: /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: "2px 0", alignItems: "center" }, children: components.map((name, i) => /* @__PURE__ */ jsxs("span", { style: { display: "inline-flex", alignItems: "center" }, children: [
251
+ /* @__PURE__ */ jsx(
252
+ "span",
253
+ {
254
+ style: {
255
+ color: i === 0 ? tokens.accentRed : tokens.textPrimary,
256
+ fontWeight: i === 0 ? 600 : 400
257
+ },
258
+ children: name
259
+ }
260
+ ),
261
+ i < components.length - 1 && /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary, margin: "0 6px", fontSize: 10 }, children: "\u203A" })
262
+ ] }, i)) }) })
263
+ ] }),
264
+ /* @__PURE__ */ jsx(Separator, {}),
265
+ /* @__PURE__ */ jsxs(
266
+ "div",
267
+ {
268
+ style: {
269
+ display: "grid",
270
+ gridTemplateColumns: "auto 1fr",
271
+ gap: "4px 16px",
272
+ fontSize: 11,
273
+ fontFamily: tokens.mono,
274
+ paddingTop: 12
275
+ },
276
+ children: [
277
+ appVersion && /* @__PURE__ */ jsxs(Fragment, { children: [
278
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary }, children: "version" }),
279
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textSecondary }, children: appVersion })
280
+ ] }),
281
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary }, children: "timestamp" }),
282
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textSecondary }, children: timestamp }),
283
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary }, children: "viewport" }),
284
+ /* @__PURE__ */ jsxs("span", { style: { color: tokens.textSecondary }, children: [
285
+ window.innerWidth,
286
+ "x",
287
+ window.innerHeight
288
+ ] }),
289
+ eventId && /* @__PURE__ */ jsxs(Fragment, { children: [
290
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textTertiary }, children: "sentry" }),
291
+ /* @__PURE__ */ jsx("span", { style: { color: tokens.textSecondary }, children: eventId })
292
+ ] })
293
+ ]
294
+ }
295
+ )
296
+ ] }),
297
+ /* @__PURE__ */ jsx(
298
+ "div",
299
+ {
300
+ style: {
301
+ borderTop: `1px solid ${tokens.separator}`,
302
+ padding: "12px 24px",
303
+ display: "flex",
304
+ justifyContent: "center"
305
+ },
306
+ children: /* @__PURE__ */ jsx(
307
+ "button",
308
+ {
309
+ onClick: () => window.location.reload(),
310
+ style: {
311
+ background: "none",
312
+ border: "none",
313
+ color: tokens.textTertiary,
314
+ fontSize: 12,
315
+ fontFamily: tokens.sans,
316
+ cursor: "pointer",
317
+ padding: "2px 8px",
318
+ textDecoration: "underline",
319
+ textUnderlineOffset: 3
320
+ },
321
+ children: "Reload page"
322
+ }
323
+ )
324
+ }
325
+ )
326
+ ]
327
+ }
328
+ );
329
+ }
330
+ function getErrorName(error) {
331
+ if (error instanceof Error) {
332
+ return error.constructor.name === "Error" ? "Error" : error.constructor.name;
333
+ }
334
+ return "Error";
335
+ }
336
+ function buildErrorReport(opts) {
337
+ const { error, componentStack, eventId } = opts;
338
+ const errorMessage = error instanceof Error ? error.message : String(error);
339
+ const errorStack = error instanceof Error ? error.stack : void 0;
340
+ const url = opts.url ?? window.location.href;
341
+ const sections = [
342
+ `## Error Report`,
343
+ `**Timestamp:** ${(/* @__PURE__ */ new Date()).toISOString()}`,
344
+ `**URL:** ${url}`,
345
+ opts.appVersion && `**App Version:** ${opts.appVersion}`,
346
+ eventId && `**Sentry Event ID:** ${eventId}`,
347
+ `**User Agent:** ${navigator.userAgent}`,
348
+ `**Viewport:** ${window.innerWidth}x${window.innerHeight}`,
349
+ "",
350
+ `### Error`,
351
+ "```",
352
+ `${getErrorName(error)}: ${errorMessage}`,
353
+ "```",
354
+ "",
355
+ errorStack && `### Stack Trace`,
356
+ errorStack && "```",
357
+ errorStack,
358
+ errorStack && "```",
359
+ errorStack && "",
360
+ componentStack && `### Component Stack`,
361
+ componentStack && "```",
362
+ componentStack?.trim(),
363
+ componentStack && "```"
364
+ ];
365
+ return sections.filter(Boolean).join("\n");
366
+ }
367
+ function CrashErrorFallback({ error, componentStack, eventId, appVersion }) {
368
+ const { background } = useAppearance();
369
+ const errorMessage = error instanceof Error ? error.message : String(error);
370
+ const errorStack = error instanceof Error ? error.stack : void 0;
371
+ const errorName = getErrorName(error);
372
+ const reportText = buildErrorReport({ error, componentStack, eventId, appVersion });
373
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
374
+ return /* @__PURE__ */ jsxs(
375
+ "div",
376
+ {
377
+ style: {
378
+ position: "fixed",
379
+ inset: 0,
380
+ overflow: "auto",
381
+ background: "var(--color-background)",
382
+ display: "flex",
383
+ alignItems: "center",
384
+ justifyContent: "center",
385
+ padding: 24
386
+ },
387
+ children: [
388
+ background,
389
+ /* @__PURE__ */ jsx("div", { style: { position: "relative", zIndex: 1, width: "100%", display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsx(
390
+ ErrorReportCard,
391
+ {
392
+ errorName,
393
+ errorMessage,
394
+ errorStack,
395
+ componentStack,
396
+ eventId,
397
+ url: window.location.href,
398
+ timestamp,
399
+ reportText,
400
+ appVersion
401
+ }
402
+ ) })
403
+ ]
404
+ }
405
+ );
406
+ }
407
+ var AppErrorBoundary = class extends Component {
408
+ state = { error: null, componentStack: "" };
409
+ static getDerivedStateFromError(error) {
410
+ return { error };
411
+ }
412
+ componentDidCatch(error, errorInfo) {
413
+ this.setState({ componentStack: errorInfo.componentStack ?? "" });
414
+ this.props.onError?.(error, errorInfo);
415
+ }
416
+ render() {
417
+ if (this.state.error !== null) {
418
+ const props = { error: this.state.error, componentStack: this.state.componentStack };
419
+ return this.props.fallback ? this.props.fallback(props) : /* @__PURE__ */ jsx(CrashErrorFallback, { ...props, appVersion: this.props.appVersion });
420
+ }
421
+ return this.props.children;
422
+ }
423
+ };
424
+
425
+ export { AppErrorBoundary, CrashErrorFallback, ErrorReportCard, buildErrorReport };
@@ -1,12 +1,164 @@
1
- import { useOrganization } from './chunk-DD3CCMCZ.js';
2
- import { useUserProfile } from './chunk-2Q2JQSQO.js';
1
+ import { OrganizationContext, useOrganization } from './chunk-DD3CCMCZ.js';
2
+ import { useProfile, useUserProfile } from './chunk-2Q2JQSQO.js';
3
3
  import { useAuthContext } from './chunk-BRJ3QZ4E.js';
4
- import { useState, useRef, useEffect, useCallback } from 'react';
4
+ import { useState, useRef, useEffect, useCallback, createElement } from 'react';
5
+ import { useQueryClient } from '@tanstack/react-query';
5
6
  import { Badge, Group, Button, Loader, Menu, Text } from '@mantine/core';
6
7
  import { IconLock, IconChevronDown, IconBuilding, IconCheck } from '@tabler/icons-react';
7
8
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
9
  import { useAuth } from '@workos-inc/authkit-react';
9
10
 
11
+ function OrganizationProvider({ apiRequest, children }) {
12
+ const { user, organizationId: workosOrgId } = useAuthContext();
13
+ const { profile, error: profileError } = useProfile();
14
+ const queryClient = useQueryClient();
15
+ const [memberships, setMemberships] = useState([]);
16
+ const [currentWorkOSOrganizationId, setCurrentWorkOSOrganizationId] = useState(null);
17
+ const [currentSupabaseOrganizationId, setCurrentSupabaseOrganizationId] = useState(null);
18
+ const [currentMembership, setCurrentMembership] = useState(null);
19
+ const [isInitializing, setIsInitializing] = useState(true);
20
+ const [isOrgRefreshing, setIsOrgRefreshing] = useState(false);
21
+ const [error, setError] = useState(null);
22
+ const hasInitializedRef = useRef(false);
23
+ const [profileLoaded, setProfileLoaded] = useState(false);
24
+ useEffect(() => {
25
+ if (profile !== void 0 && profile !== null) {
26
+ setProfileLoaded(true);
27
+ }
28
+ }, [profile]);
29
+ useEffect(() => {
30
+ if (profileError && isInitializing && !hasInitializedRef.current) {
31
+ setIsInitializing(false);
32
+ }
33
+ }, [profileError, isInitializing]);
34
+ useEffect(() => {
35
+ if (!user) {
36
+ setMemberships([]);
37
+ setCurrentWorkOSOrganizationId(null);
38
+ setCurrentSupabaseOrganizationId(null);
39
+ setCurrentMembership(null);
40
+ setIsInitializing(false);
41
+ setIsOrgRefreshing(false);
42
+ setError(null);
43
+ hasInitializedRef.current = false;
44
+ setProfileLoaded(false);
45
+ }
46
+ }, [user]);
47
+ const applyMembership = useCallback((membership) => {
48
+ setCurrentMembership(membership);
49
+ setCurrentSupabaseOrganizationId(membership?.organization?.id ?? null);
50
+ setCurrentWorkOSOrganizationId(membership?.organization?.workos_org_id ?? null);
51
+ }, []);
52
+ const selectOrganization = useCallback(
53
+ (data) => {
54
+ let selected = null;
55
+ if (profile?.last_visited_org) {
56
+ selected = data.find((m) => m.organizationId === profile.last_visited_org) ?? null;
57
+ }
58
+ if (!selected && workosOrgId) {
59
+ selected = data.find((m) => m.organization?.workos_org_id === workosOrgId) ?? null;
60
+ }
61
+ if (!selected && data.length > 0) {
62
+ selected = data[0];
63
+ }
64
+ if (selected) {
65
+ applyMembership(selected);
66
+ }
67
+ },
68
+ [profile?.last_visited_org, workosOrgId, applyMembership]
69
+ );
70
+ const fetchAndInitialize = useCallback(async () => {
71
+ if (!user?.id || !profileLoaded) return;
72
+ setError(null);
73
+ if (memberships.length === 0) {
74
+ setIsInitializing(true);
75
+ } else {
76
+ setIsOrgRefreshing(true);
77
+ }
78
+ try {
79
+ const data = await apiRequest("/memberships/my-memberships");
80
+ if (!Array.isArray(data)) {
81
+ throw new Error("Invalid memberships response");
82
+ }
83
+ setMemberships(data);
84
+ if (data.length === 0) {
85
+ hasInitializedRef.current = true;
86
+ return;
87
+ }
88
+ if (!currentWorkOSOrganizationId) {
89
+ selectOrganization(data);
90
+ } else {
91
+ const stillPresent = data.find((m) => m.organization?.workos_org_id === currentWorkOSOrganizationId);
92
+ if (!stillPresent) {
93
+ applyMembership(data[0] ?? null);
94
+ } else if (stillPresent.id !== currentMembership?.id) {
95
+ applyMembership(stillPresent);
96
+ }
97
+ }
98
+ hasInitializedRef.current = true;
99
+ } catch (err) {
100
+ setError(err instanceof Error ? err.message : "Failed to load organizations");
101
+ } finally {
102
+ setIsInitializing(false);
103
+ setIsOrgRefreshing(false);
104
+ }
105
+ }, [
106
+ user?.id,
107
+ profileLoaded,
108
+ memberships.length,
109
+ apiRequest,
110
+ currentWorkOSOrganizationId,
111
+ currentMembership?.id,
112
+ selectOrganization,
113
+ applyMembership
114
+ ]);
115
+ useEffect(() => {
116
+ if (!user?.id || !profileLoaded || hasInitializedRef.current) return;
117
+ fetchAndInitialize();
118
+ }, [user?.id, profileLoaded, fetchAndInitialize]);
119
+ useEffect(() => {
120
+ if (!hasInitializedRef.current) return;
121
+ if (!workosOrgId) return;
122
+ if (workosOrgId === currentWorkOSOrganizationId) return;
123
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId);
124
+ if (!target) return;
125
+ applyMembership(target);
126
+ void queryClient.invalidateQueries();
127
+ }, [workosOrgId, currentWorkOSOrganizationId, memberships, applyMembership, queryClient]);
128
+ const switchOrganization = useCallback(
129
+ (workosOrgId2) => {
130
+ const target = memberships.find((m) => m.organization?.workos_org_id === workosOrgId2);
131
+ if (!target) return;
132
+ applyMembership(target);
133
+ void queryClient.invalidateQueries();
134
+ void apiRequest("/users/me", {
135
+ method: "PATCH",
136
+ headers: { "Content-Type": "application/json" },
137
+ body: JSON.stringify({ last_visited_org: target.organizationId })
138
+ }).catch((err) => {
139
+ console.warn("Failed to persist last_visited_org preference:", err);
140
+ });
141
+ },
142
+ [memberships, applyMembership, queryClient, apiRequest]
143
+ );
144
+ const retry = useCallback(async () => {
145
+ hasInitializedRef.current = false;
146
+ setError(null);
147
+ await fetchAndInitialize();
148
+ }, [fetchAndInitialize]);
149
+ const value = {
150
+ currentWorkOSOrganizationId,
151
+ currentSupabaseOrganizationId,
152
+ currentMembership,
153
+ memberships,
154
+ isInitializing,
155
+ isOrgRefreshing,
156
+ error,
157
+ switchOrganization,
158
+ retry
159
+ };
160
+ return createElement(OrganizationContext.Provider, { value }, children);
161
+ }
10
162
  function RoleBadge({ name, isSystem }) {
11
163
  return /* @__PURE__ */ jsx(Badge, { color: isSystem ? "gray" : "primary", variant: "light", children: /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
12
164
  isSystem && /* @__PURE__ */ jsx(IconLock, { size: 10 }),
@@ -384,4 +536,4 @@ function createUseOrgInitialization(useOrganizations, useApiClient) {
384
536
  };
385
537
  }
386
538
 
387
- export { OrganizationSwitcher, OrganizationSwitcherConnected, RoleBadge, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations };
539
+ export { OrganizationProvider, OrganizationSwitcher, OrganizationSwitcherConnected, RoleBadge, createOrganizationsSlice, createUseOrgInitialization, createUseOrganizations };
@@ -1,4 +1,4 @@
1
- import { useOptionalElevasisSystems } from './chunk-IBWMR4TI.js';
1
+ import { useOptionalElevasisSystems } from './chunk-O6JXQ6UQ.js';
2
2
  import { useRouterContext } from './chunk-Q7DJKLEN.js';
3
3
  import { useMemo } from 'react';
4
4
 
@@ -2,10 +2,10 @@ import { AppShellLoader } from './chunk-RYTEQBAO.js';
2
2
  import { FilterBar } from './chunk-PDHTXPSF.js';
3
3
  import { CustomModal } from './chunk-R66W5UDG.js';
4
4
  import { useAvailablePresets } from './chunk-JFL3GRD4.js';
5
- import { useDeleteCredential, useCreateCredential, useCredentials, MEMBERSHIP_STATUS_COLORS, transformMembershipToTableRow, useUserMemberships, useUpdateWebhookEndpoint, useResources, useDeleteWebhookEndpoint, useCreateWebhookEndpoint, useListWebhookEndpoints, useOrgRoles, useAssignRole, useRevokeRole, useHasPermission, useUpdateMemberConfig, useOrganizationMembers, useUpdateCredential, CredentialSchemas } from './chunk-ZMK5Z6KE.js';
5
+ import { useDeleteCredential, useCreateCredential, useCredentials, MEMBERSHIP_STATUS_COLORS, transformMembershipToTableRow, useUserMemberships, useUpdateWebhookEndpoint, useResources, useDeleteWebhookEndpoint, useCreateWebhookEndpoint, useListWebhookEndpoints, useOrgRoles, useAssignRole, useRevokeRole, useHasPermission, useUpdateMemberConfig, useOrganizationMembers, useUpdateCredential, CredentialSchemas } from './chunk-IGDYWFNE.js';
6
6
  import { showApiErrorNotification, showErrorNotification, showSuccessNotification } from './chunk-XZGSCABI.js';
7
- import { ListSkeleton, EmptyState, PageTitleCaption, CardHeader, APIErrorAlert, StatCard } from './chunk-EPTHX4VZ.js';
8
- import { RoleBadge } from './chunk-JA5ECJJB.js';
7
+ import { ListSkeleton, EmptyState, PageTitleCaption, CardHeader, APIErrorAlert, StatCard } from './chunk-HRWLKKWM.js';
8
+ import { RoleBadge } from './chunk-VTXTZXAU.js';
9
9
  import { isAPIClientError, formatDateTime, OAUTH_FLOW_TIMEOUT } from './chunk-2RJMVWFJ.js';
10
10
  import { useInitialization } from './chunk-533DUEQY.js';
11
11
  import { useOrganization } from './chunk-DD3CCMCZ.js';
@@ -1,15 +1,14 @@
1
- import { SalesSidebar, CrmSidebarMiddle } from './chunk-J2UD7BOH.js';
1
+ import { CRM_PIPELINE_DEFINITION, SalesSidebar, CrmSidebarMiddle, DEFAULT_CRM_PRIORITY_RULE_CONFIG, CRM_PRIORITY_BUCKETS } from './chunk-4O4MII5S.js';
2
2
  import { SubshellSidebarSection } from './chunk-IIMU5YAJ.js';
3
3
  import { PageContainer } from './chunk-BZZCNLT6.js';
4
4
  import { TableSelectionToolbar, SortableHeader } from './chunk-TUMSNGTX.js';
5
5
  import { FilterBar } from './chunk-PDHTXPSF.js';
6
6
  import { CustomModal } from './chunk-R66W5UDG.js';
7
- import { useDealsSummary, useDeleteDeal, usePaginationState, useDeals, useTableSort, sortData, useTableSelection, useDealDetail, useCompany, dealKeys, useContact, useExecuteAction } from './chunk-ZMK5Z6KE.js';
7
+ import { useDealsSummary, useDeleteDeal, usePaginationState, useDeals, useTableSort, sortData, useTableSelection, useDealDetail, useCompany, dealKeys, useContact, useExecuteAction } from './chunk-IGDYWFNE.js';
8
8
  import { showApiErrorNotification, showSuccessNotification } from './chunk-XZGSCABI.js';
9
- import { CenteredErrorState, CardHeader, StatCard, PageTitleCaption, EmptyState, ActivityTimeline } from './chunk-EPTHX4VZ.js';
10
- import { useCrmActions, deriveActions } from './chunk-GWGQI6V4.js';
9
+ import { useCrmActions, deriveActions } from './chunk-PLP3NYPL.js';
10
+ import { CenteredErrorState, CardHeader, StatCard, PageTitleCaption, EmptyState, ActivityTimeline } from './chunk-HRWLKKWM.js';
11
11
  import { SubshellContentContainer } from './chunk-TKAYX2SP.js';
12
- import { CRM_PIPELINE_DEFINITION, DEFAULT_CRM_PRIORITY_RULE_CONFIG, CRM_PRIORITY_BUCKETS } from './chunk-52K5RFDH.js';
13
12
  import { PAGE_SIZE_DEFAULT, formatTimeAgo } from './chunk-2RJMVWFJ.js';
14
13
  import { useElevasisServices } from './chunk-KJ3QUBNU.js';
15
14
  import { Stack, Paper, Center, Loader, Group, Box, Text, Alert, Table, SimpleGrid, Button, Select, TextInput, Tabs, Checkbox, Badge, Tooltip, Pagination, Title, Code, Card, Switch, NumberInput, ColorSwatch, Popover, ActionIcon, Anchor, CopyButton, Divider, Textarea } from '@mantine/core';
@@ -4346,24 +4346,6 @@ interface CostByModelResponse {
4346
4346
  */
4347
4347
  type AIResourceDefinition = SerializedWorkflowDefinition | SerializedAgentDefinition;
4348
4348
 
4349
- /**
4350
- * Placeholder discriminated union for ContentNode (Wave 1A).
4351
- * Wave 2A wires concrete (kind, type) pairs via the registry.
4352
- *
4353
- * Per D2: unregistered (kind, type) pairs are allowed and pass through validation.
4354
- * Per L14: every node carries BOTH `kind` and `type`.
4355
- */
4356
- declare const ContentNodeSchema: z.ZodObject<{
4357
- label: z.ZodString;
4358
- description: z.ZodOptional<z.ZodString>;
4359
- order: z.ZodOptional<z.ZodNumber>;
4360
- parentContentId: z.ZodOptional<z.ZodString>;
4361
- kind: z.ZodString;
4362
- type: z.ZodString;
4363
- data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
4364
- }, z.core.$strip>;
4365
- type ContentNode = z.infer<typeof ContentNodeSchema>;
4366
-
4367
4349
  type JsonPrimitive = string | number | boolean | null;
4368
4350
  type JsonValue = JsonPrimitive | JsonValue[] | {
4369
4351
  [key: string]: JsonValue;
@@ -4405,11 +4387,6 @@ interface SystemEntry {
4405
4387
  config?: Record<string, JsonValue>;
4406
4388
  ontology?: OntologyScope;
4407
4389
  systems?: Record<string, SystemEntry>;
4408
- /**
4409
- * @deprecated Compatibility-only bridge for old tenant data and migration readers.
4410
- * Author new semantic catalogs in `ontology` and local settings in `config`.
4411
- */
4412
- content?: Record<string, ContentNode>;
4413
4390
  subsystems?: Record<string, SystemEntry>;
4414
4391
  }
4415
4392