@elevasis/ui 2.25.6 → 2.26.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 (105) hide show
  1. package/dist/api/index.js +2 -2
  2. package/dist/app/index.css +15 -5
  3. package/dist/app/index.d.ts +61 -14
  4. package/dist/app/index.js +6 -6
  5. package/dist/charts/index.js +6 -5
  6. package/dist/chunk-3MEXPLWT.js +265 -0
  7. package/dist/{chunk-BDKM56TP.js → chunk-4KTLOK7K.js} +1 -1
  8. package/dist/{chunk-KMAXFJPH.js → chunk-CW3UNAF2.js} +5 -409
  9. package/dist/{chunk-HKBEURCV.js → chunk-G26INIF3.js} +1 -1
  10. package/dist/{chunk-7F3IQMLI.js → chunk-G66QFZXD.js} +11 -214
  11. package/dist/{chunk-QIW6OCEI.js → chunk-HLFFKKT3.js} +27 -373
  12. package/dist/chunk-JDNEWB5F.js +10 -0
  13. package/dist/{chunk-L7D6KNHV.js → chunk-JKBGDFX2.js} +890 -749
  14. package/dist/{chunk-YRKQNPK2.js → chunk-JPGX3533.js} +4 -3
  15. package/dist/chunk-KCGGA36K.js +73 -0
  16. package/dist/chunk-KEFWANZY.js +155 -0
  17. package/dist/chunk-LH4GPYDX.js +448 -0
  18. package/dist/{chunk-JXSBOG2R.js → chunk-LWKZ3BCC.js} +5 -4
  19. package/dist/chunk-OGXKOMUT.js +412 -0
  20. package/dist/chunk-OHXU5WWK.js +3731 -0
  21. package/dist/chunk-ONFKASZI.js +2004 -0
  22. package/dist/{chunk-U36X6NZM.js → chunk-RIFTUOPE.js} +2 -14
  23. package/dist/{chunk-T6INEVX6.js → chunk-SGS4CQ2B.js} +1 -1
  24. package/dist/{chunk-C7IBFI5B.js → chunk-UPMX5GJI.js} +5 -5
  25. package/dist/{chunk-ARJPZ66V.js → chunk-UY5I2KOZ.js} +208 -3124
  26. package/dist/chunk-W2ZTLH7Y.js +662 -0
  27. package/dist/{chunk-KNISO652.js → chunk-WUVR4QY6.js} +9 -9
  28. package/dist/{chunk-Q5BEODAT.js → chunk-X2SUMO3P.js} +2 -1
  29. package/dist/{chunk-SNHGSCKH.js → chunk-XBMCDGHA.js} +1 -1
  30. package/dist/{chunk-N55DVMAG.js → chunk-XQQEKWTL.js} +2 -6
  31. package/dist/{chunk-SBQ4MYQV.js → chunk-XZSEPJZQ.js} +5 -6
  32. package/dist/{chunk-CPAJXBTL.js → chunk-YHBPR67D.js} +490 -676
  33. package/dist/{chunk-QARSVM7Q.js → chunk-YO2YORW4.js} +4 -4
  34. package/dist/{chunk-TAIX4NO3.js → chunk-ZFLM2YVW.js} +2 -2
  35. package/dist/components/index.css +15 -5
  36. package/dist/components/index.d.ts +202 -383
  37. package/dist/components/index.js +43 -429
  38. package/dist/components/navigation/index.css +25 -15
  39. package/dist/execution/index.d.ts +0 -73
  40. package/dist/features/auth/index.css +25 -15
  41. package/dist/features/crm/index.css +25 -15
  42. package/dist/features/crm/index.d.ts +49 -49
  43. package/dist/features/crm/index.js +14 -15
  44. package/dist/features/dashboard/index.css +25 -15
  45. package/dist/features/dashboard/index.js +18 -16
  46. package/dist/features/delivery/index.css +15 -5
  47. package/dist/features/delivery/index.js +14 -15
  48. package/dist/features/knowledge/index.css +611 -0
  49. package/dist/features/knowledge/index.js +375 -72
  50. package/dist/features/lead-gen/index.css +25 -15
  51. package/dist/features/lead-gen/index.d.ts +60 -21
  52. package/dist/features/lead-gen/index.js +16 -16
  53. package/dist/features/monitoring/index.css +15 -5
  54. package/dist/features/monitoring/index.js +17 -17
  55. package/dist/features/monitoring/requests/index.css +25 -15
  56. package/dist/features/monitoring/requests/index.js +13 -14
  57. package/dist/features/operations/index.css +25 -15
  58. package/dist/features/operations/index.d.ts +16 -98
  59. package/dist/features/operations/index.js +26 -22
  60. package/dist/features/settings/index.css +25 -15
  61. package/dist/features/settings/index.d.ts +1 -0
  62. package/dist/features/settings/index.js +15 -16
  63. package/dist/hooks/delivery/index.css +25 -15
  64. package/dist/hooks/delivery/index.js +2 -2
  65. package/dist/hooks/index.css +15 -5
  66. package/dist/hooks/index.d.ts +172 -380
  67. package/dist/hooks/index.js +13 -14
  68. package/dist/hooks/published.css +15 -5
  69. package/dist/hooks/published.d.ts +172 -380
  70. package/dist/hooks/published.js +13 -14
  71. package/dist/index.css +15 -5
  72. package/dist/index.d.ts +988 -403
  73. package/dist/index.js +15 -15
  74. package/dist/initialization/index.d.ts +1 -0
  75. package/dist/knowledge/index.d.ts +981 -41
  76. package/dist/knowledge/index.js +5449 -294
  77. package/dist/layout/index.d.ts +2 -0
  78. package/dist/layout/index.js +3 -2
  79. package/dist/organization/index.css +25 -15
  80. package/dist/organization/index.d.ts +1 -0
  81. package/dist/provider/index.css +25 -15
  82. package/dist/provider/index.d.ts +818 -26
  83. package/dist/provider/index.js +11 -11
  84. package/dist/provider/published.css +25 -15
  85. package/dist/provider/published.d.ts +817 -25
  86. package/dist/provider/published.js +8 -9
  87. package/dist/test-utils/index.js +2 -2
  88. package/dist/test-utils/setup.js +1 -1
  89. package/dist/theme/index.js +3 -2
  90. package/dist/theme/presets/index.d.ts +97 -0
  91. package/dist/theme/presets/index.js +3 -0
  92. package/dist/types/index.d.ts +71 -126
  93. package/dist/utils/index.js +1 -1
  94. package/dist/vite/index.d.ts +7 -0
  95. package/dist/vite/index.js +10 -0
  96. package/dist/vite-plugin-knowledge/index.d.ts +1 -33
  97. package/dist/vite-plugin-knowledge/index.js +1 -66
  98. package/package.json +16 -3
  99. package/src/knowledge/README.md +8 -8
  100. package/src/theme/presets/README.md +19 -0
  101. package/dist/chunk-5RLYII6P.js +0 -314
  102. package/dist/chunk-6U7AIIHF.js +0 -880
  103. package/dist/chunk-HAEJ4M54.js +0 -94
  104. package/dist/chunk-LPM7O6XM.js +0 -293
  105. /package/dist/{chunk-SGXXJE52.js → chunk-QD4X4H5A.js} +0 -0
@@ -0,0 +1,662 @@
1
+ import { ApiClientProvider, useApiClient } from './chunk-SGS4CQ2B.js';
2
+ import { OrganizationProvider } from './chunk-HOIT677G.js';
3
+ import { getErrorInfo, getErrorTitle, formatErrorMessage } from './chunk-QD4X4H5A.js';
4
+ import { InitializationProvider } from './chunk-WKJ47GIW.js';
5
+ import { useOrganization } from './chunk-DD3CCMCZ.js';
6
+ import { ProfileProvider } from './chunk-XTVZFT7U.js';
7
+ import { ElevasisServiceProvider } from './chunk-5WWZXCS5.js';
8
+ import { useAuthContext } from './chunk-BRJ3QZ4E.js';
9
+ import { createContext, lazy, useContext, Suspense, useRef } from 'react';
10
+ import { jsx } from 'react/jsx-runtime';
11
+ import { z } from 'zod';
12
+ import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
13
+
14
+ var consoleAdapter = {
15
+ success(title, message) {
16
+ console.log(`[Notification][Success] ${title}: ${message}`);
17
+ },
18
+ error(title, message) {
19
+ console.warn(`[Notification][Error] ${title}: ${message}`);
20
+ },
21
+ info(title, message) {
22
+ console.log(`[Notification][Info] ${title}: ${message}`);
23
+ },
24
+ warning(title, message) {
25
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
26
+ },
27
+ apiError(error) {
28
+ const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
29
+ const title = getErrorTitle(code);
30
+ const formatted = formatErrorMessage(message, requestId, fields, retryAfter);
31
+ console.warn(`[Notification][API Error] ${title}: ${formatted}`);
32
+ }
33
+ };
34
+ var NotificationContext = createContext(consoleAdapter);
35
+ function NotificationProvider({ adapter, children }) {
36
+ return /* @__PURE__ */ jsx(NotificationContext.Provider, { value: adapter, children });
37
+ }
38
+ function useNotificationAdapter() {
39
+ return useContext(NotificationContext);
40
+ }
41
+ var ORGANIZATION_MODEL_ICON_TOKENS = [
42
+ "nav.dashboard",
43
+ "nav.sales",
44
+ "nav.crm",
45
+ "nav.lead-gen",
46
+ "nav.projects",
47
+ "nav.operations",
48
+ "nav.monitoring",
49
+ "nav.knowledge",
50
+ "nav.settings",
51
+ "nav.admin",
52
+ "nav.archive",
53
+ "knowledge.playbook",
54
+ "knowledge.strategy",
55
+ "knowledge.reference",
56
+ "feature.dashboard",
57
+ "feature.sales",
58
+ "feature.crm",
59
+ "feature.finance",
60
+ "feature.lead-gen",
61
+ "feature.platform",
62
+ "feature.projects",
63
+ "feature.operations",
64
+ "feature.knowledge",
65
+ "feature.monitoring",
66
+ "feature.settings",
67
+ "feature.admin",
68
+ "feature.archive",
69
+ "feature.seo",
70
+ "resource.agent",
71
+ "resource.workflow",
72
+ "resource.integration",
73
+ "resource.database",
74
+ "resource.user",
75
+ "resource.team",
76
+ "integration.gmail",
77
+ "integration.google-sheets",
78
+ "integration.attio",
79
+ "surface.dashboard",
80
+ "surface.overview",
81
+ "surface.command-view",
82
+ "surface.command-queue",
83
+ "surface.pipeline",
84
+ "surface.lists",
85
+ "surface.resources",
86
+ "surface.settings",
87
+ "status.success",
88
+ "status.error",
89
+ "status.warning",
90
+ "status.info",
91
+ "status.pending",
92
+ "action.approve",
93
+ "action.reject",
94
+ "action.retry",
95
+ "action.edit",
96
+ "action.view",
97
+ "action.launch",
98
+ "action.message",
99
+ "action.escalate",
100
+ "action.promote",
101
+ "action.submit",
102
+ "action.email"
103
+ ];
104
+ var CustomIconTokenSchema = z.string().trim().max(80).regex(/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "Custom icon tokens must start with custom.");
105
+ var OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS);
106
+ var OrganizationModelIconTokenSchema = z.union([
107
+ OrganizationModelBuiltinIconTokenSchema,
108
+ CustomIconTokenSchema
109
+ ]);
110
+
111
+ // ../core/src/organization-model/domains/shared.ts
112
+ var ModelIdSchema = z.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "IDs must be lowercase and use -, _, or . separators");
113
+ var LabelSchema = z.string().trim().min(1).max(120);
114
+ var DescriptionSchema = z.string().trim().min(1).max(2e3);
115
+ var ColorTokenSchema = z.string().trim().min(1).max(50);
116
+ var IconNameSchema = OrganizationModelIconTokenSchema;
117
+ var PathSchema = z.string().trim().startsWith("/").max(300);
118
+ var ReferenceIdsSchema = z.array(ModelIdSchema).default([]);
119
+ var DisplayMetadataSchema = z.object({
120
+ label: LabelSchema,
121
+ description: DescriptionSchema.optional(),
122
+ color: ColorTokenSchema.optional(),
123
+ icon: IconNameSchema.optional()
124
+ });
125
+ var TechStackEntrySchema = z.object({
126
+ /** Name of the external platform (e.g. "HubSpot", "Stripe", "Notion"). */
127
+ platform: z.string().trim().min(1).max(200),
128
+ /** Free-form description of what this integration is used for. */
129
+ purpose: z.string().trim().min(1).max(500),
130
+ /**
131
+ * Health of the credential backing this integration.
132
+ * - configured: credential present and valid
133
+ * - pending: not yet set up
134
+ * - expired: credential existed but has lapsed
135
+ * - missing: expected but not present
136
+ */
137
+ credentialStatus: z.enum(["configured", "pending", "expired", "missing"]),
138
+ /**
139
+ * Whether this integration is the primary system of record for its domain
140
+ * (e.g. HubSpot is SoR for contacts). Defaults to false.
141
+ */
142
+ isSystemOfRecord: z.boolean().default(false)
143
+ });
144
+ DisplayMetadataSchema.extend({
145
+ id: ModelIdSchema,
146
+ resourceId: z.string().trim().min(1).max(255),
147
+ resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]),
148
+ featureIds: ReferenceIdsSchema,
149
+ entityIds: ReferenceIdsSchema,
150
+ surfaceIds: ReferenceIdsSchema,
151
+ capabilityIds: ReferenceIdsSchema,
152
+ /** Optional tech-stack metadata for external-SaaS integrations. */
153
+ techStack: TechStackEntrySchema.optional()
154
+ });
155
+ var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
156
+ var SalesStageSchema = DisplayMetadataSchema.extend({
157
+ id: ModelIdSchema,
158
+ order: z.number().int().min(0),
159
+ semanticClass: SalesStageSemanticClassSchema,
160
+ surfaceIds: ReferenceIdsSchema,
161
+ resourceIds: ReferenceIdsSchema
162
+ });
163
+ var SalesPipelineSchema = z.object({
164
+ id: ModelIdSchema,
165
+ label: z.string().trim().min(1).max(120),
166
+ description: DescriptionSchema.optional(),
167
+ entityId: ModelIdSchema,
168
+ stages: z.array(SalesStageSchema).min(1)
169
+ });
170
+ var OrganizationModelSalesSchema = z.object({
171
+ entityId: ModelIdSchema,
172
+ defaultPipelineId: ModelIdSchema,
173
+ pipelines: z.array(SalesPipelineSchema).min(1)
174
+ });
175
+ var DEFAULT_ORGANIZATION_MODEL_SALES = {
176
+ entityId: "crm.deal",
177
+ defaultPipelineId: "default",
178
+ pipelines: [
179
+ {
180
+ id: "default",
181
+ label: "Default Pipeline",
182
+ entityId: "crm.deal",
183
+ stages: [
184
+ {
185
+ id: "interested",
186
+ label: "Interested",
187
+ color: "blue",
188
+ order: 1,
189
+ semanticClass: "open",
190
+ surfaceIds: ["crm.pipeline"],
191
+ resourceIds: []
192
+ },
193
+ {
194
+ id: "proposal",
195
+ label: "Proposal",
196
+ color: "yellow",
197
+ order: 2,
198
+ semanticClass: "active",
199
+ surfaceIds: ["crm.pipeline"],
200
+ resourceIds: []
201
+ },
202
+ {
203
+ id: "closing",
204
+ label: "Closing",
205
+ color: "lime",
206
+ order: 3,
207
+ semanticClass: "active",
208
+ surfaceIds: ["crm.pipeline"],
209
+ resourceIds: []
210
+ },
211
+ {
212
+ id: "closed_won",
213
+ label: "Closed Won",
214
+ color: "green",
215
+ order: 4,
216
+ semanticClass: "closed_won",
217
+ surfaceIds: ["crm.pipeline"],
218
+ resourceIds: []
219
+ },
220
+ {
221
+ id: "closed_lost",
222
+ label: "Closed Lost",
223
+ color: "red",
224
+ order: 5,
225
+ semanticClass: "closed_lost",
226
+ surfaceIds: ["crm.pipeline"],
227
+ resourceIds: []
228
+ },
229
+ {
230
+ id: "nurturing",
231
+ label: "Nurturing",
232
+ color: "grape",
233
+ order: 6,
234
+ semanticClass: "nurturing",
235
+ surfaceIds: ["crm.pipeline"],
236
+ resourceIds: []
237
+ }
238
+ ]
239
+ }
240
+ ]
241
+ };
242
+ function findPipeline(definitions, pipelineKey) {
243
+ return definitions.find((def) => def.pipelineKey === pipelineKey);
244
+ }
245
+ var CRM_DISCOVERY_REPLIED_STATE = {
246
+ stateKey: "discovery_replied"};
247
+ var CRM_DISCOVERY_LINK_SENT_STATE = {
248
+ stateKey: "discovery_link_sent"};
249
+ var CRM_DISCOVERY_NUDGING_STATE = {
250
+ stateKey: "discovery_nudging"};
251
+ var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
252
+ stateKey: "discovery_booking_cancelled"};
253
+ var CRM_PRIORITY_BUCKETS = [
254
+ { bucketKey: "needs_response", label: "Needs Response", rank: 10, color: "red" },
255
+ { bucketKey: "follow_up_due", label: "Follow-up Due", rank: 20, color: "orange" },
256
+ { bucketKey: "waiting", label: "Waiting", rank: 30, color: "blue" },
257
+ { bucketKey: "stale", label: "Stale", rank: 40, color: "gray" },
258
+ { bucketKey: "closed_low", label: "Closed", rank: 50, color: "dark" }
259
+ ];
260
+ var DEFAULT_CRM_PRIORITY_RULE_CONFIG = {
261
+ buckets: CRM_PRIORITY_BUCKETS,
262
+ closedStageKeys: ["closed_won", "closed_lost"],
263
+ followUpAfterDaysByStateKey: {
264
+ discovery_link_sent: 3,
265
+ discovery_nudging: 2,
266
+ reply_sent: 3,
267
+ followup_1_sent: 3,
268
+ followup_2_sent: 5,
269
+ followup_3_sent: 7
270
+ },
271
+ staleAfterDays: 14
272
+ };
273
+ var PENDING_STATE = { stateKey: "pending", label: "Pending" };
274
+ var ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE = {
275
+ pipelineKey: "lead-gen",
276
+ label: "Lead Generation",
277
+ entityKey: "acq.list-member",
278
+ stages: [
279
+ {
280
+ stageKey: "outreach",
281
+ label: "Outreach",
282
+ states: [
283
+ PENDING_STATE,
284
+ { stateKey: "personalized", label: "Personalized" },
285
+ { stateKey: "uploaded", label: "Uploaded" },
286
+ { stateKey: "interested", label: "Interested" }
287
+ ]
288
+ },
289
+ {
290
+ stageKey: "prospecting",
291
+ label: "Prospecting",
292
+ states: [
293
+ PENDING_STATE,
294
+ { stateKey: "discovered", label: "Discovered" },
295
+ { stateKey: "verified", label: "Verified" }
296
+ ]
297
+ },
298
+ {
299
+ stageKey: "qualification",
300
+ label: "Qualification",
301
+ states: [PENDING_STATE]
302
+ }
303
+ ]
304
+ };
305
+ var ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE = {
306
+ pipelineKey: "lead-gen",
307
+ label: "Lead Generation",
308
+ entityKey: "acq.list-company",
309
+ stages: [
310
+ {
311
+ stageKey: "outreach",
312
+ label: "Outreach",
313
+ states: [PENDING_STATE]
314
+ },
315
+ {
316
+ stageKey: "prospecting",
317
+ label: "Prospecting",
318
+ states: [
319
+ PENDING_STATE,
320
+ { stateKey: "populated", label: "Populated" },
321
+ { stateKey: "extracted", label: "Extracted" }
322
+ ]
323
+ },
324
+ {
325
+ stageKey: "qualification",
326
+ label: "Qualification",
327
+ states: [PENDING_STATE, { stateKey: "qualified", label: "Qualified" }]
328
+ }
329
+ ]
330
+ };
331
+ var LEAD_GEN_PIPELINE_DEFINITIONS = {
332
+ "acq.list-member": [ACQ_LIST_MEMBERS_LEAD_GEN_PIPELINE],
333
+ "acq.list-company": [ACQ_LIST_COMPANIES_LEAD_GEN_PIPELINE]
334
+ };
335
+ var LEAD_GEN_STAGE_CATALOG = {
336
+ // Prospecting — company population
337
+ scraped: {
338
+ key: "scraped",
339
+ label: "Scraped",
340
+ description: "Company was scraped from a source directory (Apify actor run).",
341
+ order: 1,
342
+ entity: "company"
343
+ },
344
+ populated: {
345
+ key: "populated",
346
+ label: "Populated",
347
+ description: "Company record populated with structured data from scrape results.",
348
+ order: 2,
349
+ entity: "company"
350
+ },
351
+ extracted: {
352
+ key: "extracted",
353
+ label: "Extracted",
354
+ description: "Website content extracted and parsed for company intelligence.",
355
+ order: 3,
356
+ entity: "company"
357
+ },
358
+ enriched: {
359
+ key: "enriched",
360
+ label: "Enriched",
361
+ description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
362
+ order: 4,
363
+ entity: "company"
364
+ },
365
+ // Prospecting — contact discovery
366
+ discovered: {
367
+ key: "discovered",
368
+ label: "Discovered",
369
+ description: "Contact email address discovered via an email-discovery workflow.",
370
+ order: 5,
371
+ entity: "contact"
372
+ },
373
+ verified: {
374
+ key: "verified",
375
+ label: "Verified",
376
+ description: "Contact email address verified as deliverable (email verification workflow).",
377
+ order: 6,
378
+ entity: "contact"
379
+ },
380
+ // Qualification
381
+ qualified: {
382
+ key: "qualified",
383
+ label: "Qualified",
384
+ description: "Company passed the ICP qualification rubric (company-qualification workflow).",
385
+ order: 7,
386
+ entity: "company"
387
+ },
388
+ // Outreach
389
+ personalized: {
390
+ key: "personalized",
391
+ label: "Personalized",
392
+ description: "Outreach message personalized for the contact (Instantly personalization workflow).",
393
+ order: 8,
394
+ entity: "contact"
395
+ },
396
+ uploaded: {
397
+ key: "uploaded",
398
+ label: "Uploaded",
399
+ description: "Contact uploaded to an Instantly campaign for outreach.",
400
+ order: 9,
401
+ entity: "contact"
402
+ },
403
+ interested: {
404
+ key: "interested",
405
+ label: "Interested",
406
+ description: "Contact replied with a positive signal (Instantly reply-handler transition).",
407
+ order: 10,
408
+ entity: "contact"
409
+ }
410
+ };
411
+
412
+ // ../core/src/business/acquisition/deal-ownership.ts
413
+ var INBOUND_EVENT_TYPES = ["reply_received"];
414
+ var OUTBOUND_EVENT_TYPES = [
415
+ "reply_sent_to_lead",
416
+ "booking_nudge_sent",
417
+ "reminder_sent",
418
+ "rebook_sent",
419
+ "followup_email_sent",
420
+ "reply_followup_sent",
421
+ "lead_deferred_next_step"
422
+ ];
423
+ var INBOUND_SET = new Set(INBOUND_EVENT_TYPES);
424
+ var OUTBOUND_SET = new Set(OUTBOUND_EVENT_TYPES);
425
+ function getDealOwnership(deal) {
426
+ if (deal.state_key === "closed_won" || deal.state_key === "closed_lost") {
427
+ return null;
428
+ }
429
+ if (!Array.isArray(deal.activity_log)) return null;
430
+ let latestInboundMs = null;
431
+ let latestOutboundMs = null;
432
+ for (const entry of deal.activity_log) {
433
+ if (!entry || typeof entry !== "object" || Array.isArray(entry)) continue;
434
+ const record = entry;
435
+ const type = typeof record.type === "string" ? record.type : null;
436
+ if (!type) continue;
437
+ const isInbound = INBOUND_SET.has(type);
438
+ const isOutbound = OUTBOUND_SET.has(type);
439
+ if (!isInbound && !isOutbound) continue;
440
+ const occurredAt = resolveTimestamp(record);
441
+ if (occurredAt === null) continue;
442
+ if (isInbound && (latestInboundMs === null || occurredAt > latestInboundMs)) {
443
+ latestInboundMs = occurredAt;
444
+ }
445
+ if (isOutbound && (latestOutboundMs === null || occurredAt > latestOutboundMs)) {
446
+ latestOutboundMs = occurredAt;
447
+ }
448
+ }
449
+ if (latestInboundMs === null && latestOutboundMs === null) return null;
450
+ if (latestOutboundMs !== null && (latestInboundMs === null || latestOutboundMs >= latestInboundMs)) {
451
+ return "them";
452
+ }
453
+ return "us";
454
+ }
455
+ function resolveTimestamp(record) {
456
+ return parseMs(record.timestamp) ?? parseMs(record.occurredAt) ?? parseMs(record.createdAt) ?? parseMs(record.updatedAt) ?? parseMs(record.sentAt) ?? null;
457
+ }
458
+ function parseMs(value) {
459
+ if (value instanceof Date) {
460
+ const ms2 = value.getTime();
461
+ return Number.isNaN(ms2) ? null : ms2;
462
+ }
463
+ if (typeof value !== "string") return null;
464
+ const ms = new Date(value).getTime();
465
+ return Number.isNaN(ms) ? null : ms;
466
+ }
467
+
468
+ // ../core/src/business/acquisition/derive-actions.ts
469
+ var SendReplyActionPayloadSchema = z.object({
470
+ replyBody: z.string().trim().min(1).max(1e4)
471
+ }).strict();
472
+ var DEFAULT_CRM_ACTIONS = [
473
+ {
474
+ key: "move_to_proposal",
475
+ label: "Move to Proposal",
476
+ isAvailableFor: (deal) => deal.stage_key === "interested",
477
+ workflowId: "move_to_proposal-workflow"
478
+ },
479
+ {
480
+ key: "move_to_closing",
481
+ label: "Move to Closing",
482
+ isAvailableFor: (deal) => deal.stage_key === "proposal",
483
+ workflowId: "move_to_closing-workflow"
484
+ },
485
+ {
486
+ key: "move_to_closed_won",
487
+ label: "Close Won",
488
+ isAvailableFor: (deal) => deal.stage_key === "closing",
489
+ workflowId: "move_to_closed_won-workflow"
490
+ },
491
+ {
492
+ key: "move_to_closed_lost",
493
+ label: "Close Lost",
494
+ isAvailableFor: (deal) => deal.stage_key === "interested" || deal.stage_key === "proposal" || deal.stage_key === "closing",
495
+ workflowId: "move_to_closed_lost-workflow"
496
+ },
497
+ {
498
+ key: "move_to_nurturing",
499
+ label: "Move to Nurturing",
500
+ isAvailableFor: (deal) => deal.stage_key === "interested" || deal.stage_key === "proposal" || deal.stage_key === "closing",
501
+ workflowId: "move_to_nurturing-workflow"
502
+ },
503
+ {
504
+ key: "send_reply",
505
+ label: "Send Reply",
506
+ isAvailableFor: (deal) => deal.stage_key === "interested" && isOurReplyAction(deal) && (deal.state_key === CRM_DISCOVERY_REPLIED_STATE.stateKey || deal.state_key === CRM_DISCOVERY_LINK_SENT_STATE.stateKey || deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey),
507
+ workflowId: "crm-send-reply-workflow",
508
+ payloadSchema: SendReplyActionPayloadSchema
509
+ },
510
+ {
511
+ key: "send_link",
512
+ label: "Send Booking Link",
513
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === CRM_DISCOVERY_REPLIED_STATE.stateKey,
514
+ workflowId: "crm-send-booking-link-workflow"
515
+ },
516
+ {
517
+ key: "send_nudge",
518
+ label: "Send Nudge",
519
+ isAvailableFor: (deal) => deal.stage_key === "interested" && (deal.state_key === CRM_DISCOVERY_LINK_SENT_STATE.stateKey || deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey),
520
+ workflowId: "crm-send-nudge-workflow"
521
+ },
522
+ {
523
+ key: "mark_no_show",
524
+ label: "Mark No-Show",
525
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === CRM_DISCOVERY_NUDGING_STATE.stateKey,
526
+ // Mirrors the auto-timeout precedent in operations/sales/crm/pipeline/timeout-actions.ts:
527
+ // both manual-click and timeout move the deal to closed_lost. The action_taken activity
528
+ // event captures operator intent and distinguishes the manual variant from the timed one.
529
+ workflowId: "mark_no_show-workflow"
530
+ },
531
+ {
532
+ key: "rebook",
533
+ label: "Rebook",
534
+ isAvailableFor: (deal) => deal.stage_key === "interested" && deal.state_key === CRM_DISCOVERY_BOOKING_CANCELLED_STATE.stateKey,
535
+ workflowId: "crm-rebook-workflow"
536
+ }
537
+ ];
538
+ function deriveActions(deal, actions = DEFAULT_CRM_ACTIONS) {
539
+ return actions.filter((a) => a.isAvailableFor(deal)).map(({ key, label, payloadSchema }) => ({ key, label, payloadSchema }));
540
+ }
541
+ function isOurReplyAction(deal) {
542
+ if (Object.prototype.hasOwnProperty.call(deal, "nextAction")) {
543
+ return deal.nextAction === "send_reply";
544
+ }
545
+ return (deal.ownership ?? getDealOwnership(deal)) === "us";
546
+ }
547
+ var CrmActionsContext = createContext(DEFAULT_CRM_ACTIONS);
548
+ function CrmActionsProvider({ actions, children }) {
549
+ return /* @__PURE__ */ jsx(CrmActionsContext.Provider, { value: actions, children });
550
+ }
551
+ function useCrmActions() {
552
+ return useContext(CrmActionsContext);
553
+ }
554
+ var EMPTY_LIST_ACTIONS = Object.freeze([]);
555
+ var ListActionsContext = createContext(EMPTY_LIST_ACTIONS);
556
+ function ListActionsProvider({
557
+ registry = EMPTY_LIST_ACTIONS,
558
+ children
559
+ }) {
560
+ return /* @__PURE__ */ jsx(ListActionsContext.Provider, { value: registry, children });
561
+ }
562
+ function useListActions() {
563
+ return useContext(ListActionsContext);
564
+ }
565
+ function findListActionByCapability(registry, capabilityKey) {
566
+ return registry.find((action) => action.capabilityKey === capabilityKey);
567
+ }
568
+ function getListActionWorkflowId(action) {
569
+ return action.workflowId ?? action.resourceId;
570
+ }
571
+ var LazyCoreAuthKitInner = lazy(() => import('./CoreAuthKitInner-QC62UHTZ.js').then((m) => ({ default: m.CoreAuthKitInner })));
572
+ var defaultQueryClient = null;
573
+ function getDefaultQueryClient() {
574
+ if (!defaultQueryClient) {
575
+ defaultQueryClient = new QueryClient({
576
+ defaultOptions: { queries: { retry: 1 } }
577
+ });
578
+ }
579
+ return defaultQueryClient;
580
+ }
581
+ var consoleNotificationAdapter = {
582
+ success(title, message) {
583
+ console.log(`[Notification][Success] ${title}: ${message}`);
584
+ },
585
+ error(title, message) {
586
+ console.warn(`[Notification][Error] ${title}: ${message}`);
587
+ },
588
+ info(title, message) {
589
+ console.log(`[Notification][Info] ${title}: ${message}`);
590
+ },
591
+ warning(title, message) {
592
+ console.warn(`[Notification][Warning] ${title}: ${message}`);
593
+ },
594
+ apiError(error) {
595
+ console.warn(`[Notification][API Error]`, error);
596
+ }
597
+ };
598
+ function ElevasisCoreProvider({
599
+ auth,
600
+ queryClient,
601
+ apiUrl,
602
+ onError,
603
+ notifications,
604
+ crmActions,
605
+ listActions,
606
+ children
607
+ }) {
608
+ if (auth.mode === "apiKey") {
609
+ throw new Error(
610
+ `ElevasisCoreProvider: auth mode 'apiKey' is not yet implemented. Only 'authkit' mode is supported.`
611
+ );
612
+ }
613
+ const resolvedQueryClient = queryClient ?? getDefaultQueryClient();
614
+ const resolvedCrmActions = crmActions ?? DEFAULT_CRM_ACTIONS;
615
+ const resolvedListActions = listActions ?? EMPTY_LIST_ACTIONS;
616
+ const content = apiUrl ? /* @__PURE__ */ jsx(ServiceStack, { apiUrl, onError, notifications, children }) : children;
617
+ const AuthInner = /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyCoreAuthKitInner, { auth, children: content }) });
618
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: resolvedQueryClient, children: /* @__PURE__ */ jsx(CrmActionsProvider, { actions: resolvedCrmActions, children: /* @__PURE__ */ jsx(ListActionsProvider, { registry: resolvedListActions, children: AuthInner }) }) });
619
+ }
620
+ function ServiceStack({
621
+ apiUrl,
622
+ onError,
623
+ notifications,
624
+ children
625
+ }) {
626
+ const { getAccessToken } = useAuthContext();
627
+ const orgIdRef = useRef(null);
628
+ const getOrganizationId = useRef(() => orgIdRef.current).current;
629
+ return /* @__PURE__ */ jsx(
630
+ ApiClientProvider,
631
+ {
632
+ getAccessToken,
633
+ getOrganizationId,
634
+ isOrganizationReady: false,
635
+ onError,
636
+ children: /* @__PURE__ */ jsx(ServiceStackInner, { apiUrl, orgIdRef, notifications, children })
637
+ }
638
+ );
639
+ }
640
+ function ServiceStackInner({
641
+ apiUrl,
642
+ orgIdRef,
643
+ notifications,
644
+ children
645
+ }) {
646
+ const { apiRequest } = useApiClient(apiUrl);
647
+ const resolvedNotifications = notifications ?? consoleNotificationAdapter;
648
+ return /* @__PURE__ */ jsx(ProfileProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrganizationProvider, { apiRequest, children: /* @__PURE__ */ jsx(OrgServiceBridge, { orgIdRef, apiRequest, notifications: resolvedNotifications, children }) }) });
649
+ }
650
+ function OrgServiceBridge({
651
+ orgIdRef,
652
+ apiRequest,
653
+ notifications,
654
+ children
655
+ }) {
656
+ const { currentWorkOSOrganizationId, isInitializing, isOrgRefreshing } = useOrganization();
657
+ orgIdRef.current = currentWorkOSOrganizationId;
658
+ const isReady = !!currentWorkOSOrganizationId && !isInitializing && !isOrgRefreshing;
659
+ return /* @__PURE__ */ jsx(ElevasisServiceProvider, { apiRequest, organizationId: currentWorkOSOrganizationId, isReady, children: /* @__PURE__ */ jsx(NotificationProvider, { adapter: notifications, children: /* @__PURE__ */ jsx(InitializationProvider, { children }) }) });
660
+ }
661
+
662
+ export { CRM_PRIORITY_BUCKETS, ColorTokenSchema, CrmActionsProvider, DEFAULT_CRM_PRIORITY_RULE_CONFIG, DEFAULT_ORGANIZATION_MODEL_SALES, DescriptionSchema, DisplayMetadataSchema, EMPTY_LIST_ACTIONS, ElevasisCoreProvider, IconNameSchema, LEAD_GEN_PIPELINE_DEFINITIONS, LEAD_GEN_STAGE_CATALOG, LabelSchema, ListActionsProvider, ModelIdSchema, NotificationProvider, OrganizationModelSalesSchema, PathSchema, ReferenceIdsSchema, deriveActions, findListActionByCapability, findPipeline, getListActionWorkflowId, useCrmActions, useListActions, useNotificationAdapter };