@hanzo/crm 0.0.0-stage → 0.1.1

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 (109) hide show
  1. package/LICENSE-MIT +21 -0
  2. package/LICENSE.md +21 -0
  3. package/NOTICE +52 -0
  4. package/README.md +72 -2
  5. package/dist/CrmModule.d.ts +4 -0
  6. package/dist/CrmModule.d.ts.map +1 -0
  7. package/dist/CrmModule.js +78 -0
  8. package/dist/CrmModule.js.map +1 -0
  9. package/dist/crm/Access.d.ts +10 -0
  10. package/dist/crm/Access.d.ts.map +1 -0
  11. package/dist/crm/Access.js +35 -0
  12. package/dist/crm/Access.js.map +1 -0
  13. package/dist/crm/Actions.d.ts +38 -0
  14. package/dist/crm/Actions.d.ts.map +1 -0
  15. package/dist/crm/Actions.js +224 -0
  16. package/dist/crm/Actions.js.map +1 -0
  17. package/dist/crm/Create.d.ts +13 -0
  18. package/dist/crm/Create.d.ts.map +1 -0
  19. package/dist/crm/Create.js +64 -0
  20. package/dist/crm/Create.js.map +1 -0
  21. package/dist/crm/Import.d.ts +7 -0
  22. package/dist/crm/Import.d.ts.map +1 -0
  23. package/dist/crm/Import.js +94 -0
  24. package/dist/crm/Import.js.map +1 -0
  25. package/dist/crm/Record.d.ts +6 -0
  26. package/dist/crm/Record.d.ts.map +1 -0
  27. package/dist/crm/Record.js +257 -0
  28. package/dist/crm/Record.js.map +1 -0
  29. package/dist/crm/Records.d.ts +33 -0
  30. package/dist/crm/Records.d.ts.map +1 -0
  31. package/dist/crm/Records.js +277 -0
  32. package/dist/crm/Records.js.map +1 -0
  33. package/dist/crm/Timeline.d.ts +22 -0
  34. package/dist/crm/Timeline.d.ts.map +1 -0
  35. package/dist/crm/Timeline.js +117 -0
  36. package/dist/crm/Timeline.js.map +1 -0
  37. package/dist/crm/csv.d.ts +75 -0
  38. package/dist/crm/csv.d.ts.map +1 -0
  39. package/dist/crm/csv.js +300 -0
  40. package/dist/crm/csv.js.map +1 -0
  41. package/dist/crm/importer.d.ts +39 -0
  42. package/dist/crm/importer.d.ts.map +1 -0
  43. package/dist/crm/importer.js +147 -0
  44. package/dist/crm/importer.js.map +1 -0
  45. package/dist/crm/objects.d.ts +80 -0
  46. package/dist/crm/objects.d.ts.map +1 -0
  47. package/dist/crm/objects.js +167 -0
  48. package/dist/crm/objects.js.map +1 -0
  49. package/dist/crm/schema.d.ts +58 -0
  50. package/dist/crm/schema.d.ts.map +1 -0
  51. package/dist/crm/schema.js +175 -0
  52. package/dist/crm/schema.js.map +1 -0
  53. package/dist/crm/studio/Sequences.d.ts +4 -0
  54. package/dist/crm/studio/Sequences.d.ts.map +1 -0
  55. package/dist/crm/studio/Sequences.js +114 -0
  56. package/dist/crm/studio/Sequences.js.map +1 -0
  57. package/dist/crm/studio/logic.d.ts +32 -0
  58. package/dist/crm/studio/logic.d.ts.map +1 -0
  59. package/dist/crm/studio/logic.js +59 -0
  60. package/dist/crm/studio/logic.js.map +1 -0
  61. package/dist/crm/studio/style.d.ts +8 -0
  62. package/dist/crm/studio/style.d.ts.map +1 -0
  63. package/dist/crm/studio/style.js +21 -0
  64. package/dist/crm/studio/style.js.map +1 -0
  65. package/dist/crm/suppression.d.ts +11 -0
  66. package/dist/crm/suppression.d.ts.map +1 -0
  67. package/dist/crm/suppression.js +20 -0
  68. package/dist/crm/suppression.js.map +1 -0
  69. package/dist/index.d.ts +12 -0
  70. package/dist/index.d.ts.map +1 -0
  71. package/dist/index.js +19 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/lib/base-data/api.d.ts +48 -0
  74. package/dist/lib/base-data/api.d.ts.map +1 -0
  75. package/dist/lib/base-data/api.js +2 -0
  76. package/dist/lib/base-data/api.js.map +1 -0
  77. package/dist/lib/base-data/client.d.ts +29 -0
  78. package/dist/lib/base-data/client.d.ts.map +1 -0
  79. package/dist/lib/base-data/client.js +76 -0
  80. package/dist/lib/base-data/client.js.map +1 -0
  81. package/dist/lib/base-data/fields.d.ts +103 -0
  82. package/dist/lib/base-data/fields.d.ts.map +1 -0
  83. package/dist/lib/base-data/fields.js +251 -0
  84. package/dist/lib/base-data/fields.js.map +1 -0
  85. package/dist/lib/base-data/html.d.ts +20 -0
  86. package/dist/lib/base-data/html.d.ts.map +1 -0
  87. package/dist/lib/base-data/html.js +49 -0
  88. package/dist/lib/base-data/html.js.map +1 -0
  89. package/dist/lib/base-data/query.d.ts +50 -0
  90. package/dist/lib/base-data/query.d.ts.map +1 -0
  91. package/dist/lib/base-data/query.js +220 -0
  92. package/dist/lib/base-data/query.js.map +1 -0
  93. package/dist/lib/crm.d.ts +374 -0
  94. package/dist/lib/crm.d.ts.map +1 -0
  95. package/dist/lib/crm.js +337 -0
  96. package/dist/lib/crm.js.map +1 -0
  97. package/dist/lib/host.d.ts +117 -0
  98. package/dist/lib/host.d.ts.map +1 -0
  99. package/dist/lib/host.js +43 -0
  100. package/dist/lib/host.js.map +1 -0
  101. package/dist/lib/live.d.ts +5 -0
  102. package/dist/lib/live.d.ts.map +1 -0
  103. package/dist/lib/live.js +63 -0
  104. package/dist/lib/live.js.map +1 -0
  105. package/dist/nav.d.ts +7 -0
  106. package/dist/nav.d.ts.map +1 -0
  107. package/dist/nav.js +18 -0
  108. package/dist/nav.js.map +1 -0
  109. package/package.json +58 -3
@@ -0,0 +1,167 @@
1
+ /** Until inbound mail is filed, a reply is the team's to mark. */
2
+ export const REPLIED_BY_HAND = 'Replies are not read from the inbox yet: when someone answers, open them and press Mark replied.';
3
+ /** A customer is a person the team marked one: nothing outside the CRM writes the type. */
4
+ export const CUSTOMER_BY_HAND = 'A customer here is a person whose Type is Customer. Store orders and billing plans are not copied into the CRM yet, so set Type on the person, or in an import.';
5
+ /** A sale's stages, and a round's. Both end in lost. */
6
+ export const SALES_STAGES = ['new', 'screening', 'meeting', 'proposal', 'customer', 'lost'];
7
+ export const ROUND_STAGES = ['intro', 'meeting', 'diligence', 'term_sheet', 'closed', 'lost'];
8
+ const recent = [{ field: 'created', dir: 'desc' }];
9
+ export const OBJECTS = {
10
+ people: {
11
+ id: 'people',
12
+ collection: 'people',
13
+ label: 'Person',
14
+ plural: 'People',
15
+ title: 'name',
16
+ columns: ['name', 'emails', 'company', 'type', 'job_title', 'outreach', 'contacted', 'lifecycle', 'created'],
17
+ create: ['name', 'emails', 'company', 'type', 'job_title', 'phones'],
18
+ importable: true,
19
+ views: [
20
+ { id: 'all', name: 'All people', sorts: recent },
21
+ { id: 'investors', name: 'Investors', filters: [{ field: 'type', op: 'is', value: 'investor' }], sorts: [{ field: 'contacted', dir: 'asc' }] },
22
+ { id: 'customers', name: 'Customers', filters: [{ field: 'type', op: 'is', value: 'customer' }], sorts: recent, note: CUSTOMER_BY_HAND },
23
+ { id: 'inbound', name: 'Inbound', scope: 'activities_via_person.kind ?= "form"', sorts: recent },
24
+ { id: 'support', name: 'Support & Help Chat', scope: 'activities_via_person.data.program ?= "support"', sorts: recent },
25
+ { id: 'sales_chat', name: 'Sales Chat', scope: 'activities_via_person.data.program ?= "chat"', sorts: recent },
26
+ { id: 'feedback', name: 'Product Feedback', scope: 'activities_via_person.data.program ?= "feedback"', sorts: recent },
27
+ { id: 'replied', name: 'Replied', filters: [{ field: 'outreach', op: 'is', value: 'replied' }], sorts: [{ field: 'contacted', dir: 'desc' }], note: REPLIED_BY_HAND },
28
+ { id: 'unreachable', name: 'Bounced or opted out', filters: [{ field: 'outreach', op: 'isAnyOf', value: ['bounced', 'unsubscribed'] }], sorts: recent },
29
+ ],
30
+ },
31
+ companies: {
32
+ id: 'companies',
33
+ collection: 'companies',
34
+ label: 'Company',
35
+ plural: 'Companies',
36
+ title: 'name',
37
+ columns: ['name', 'domain', 'type', 'employees', 'annual_revenue', 'owner', 'created'],
38
+ create: ['name', 'domain', 'type', 'employees'],
39
+ importable: true,
40
+ views: [
41
+ { id: 'all', name: 'All companies', sorts: recent },
42
+ { id: 'investors', name: 'Investors', filters: [{ field: 'type', op: 'is', value: 'investor' }], sorts: [{ field: 'name', dir: 'asc' }] },
43
+ { id: 'customers', name: 'Customers', filters: [{ field: 'type', op: 'is', value: 'customer' }], sorts: [{ field: 'name', dir: 'asc' }] },
44
+ ],
45
+ },
46
+ deals: {
47
+ id: 'deals',
48
+ collection: 'opportunities',
49
+ label: 'Deal',
50
+ plural: 'Pipeline',
51
+ title: 'name',
52
+ scope: '(pipeline = "sales" || pipeline = "")',
53
+ defaults: { pipeline: 'sales', stage: 'new' },
54
+ columns: ['name', 'company', 'contact', 'stage', 'amount', 'close_date', 'owner', 'next_step', 'contacted'],
55
+ create: ['name', 'company', 'contact', 'stage', 'amount', 'close_date'],
56
+ board: { field: 'stage', lanes: SALES_STAGES },
57
+ boardFirst: true,
58
+ views: [
59
+ { id: 'all', name: 'All deals', sorts: [{ field: 'close_date', dir: 'asc' }] },
60
+ { id: 'open', name: 'Open', filters: [{ field: 'stage', op: 'isAnyOf', value: ['new', 'screening', 'meeting', 'proposal'] }], sorts: [{ field: 'close_date', dir: 'asc' }] },
61
+ { id: 'won', name: 'Won', filters: [{ field: 'stage', op: 'is', value: 'customer' }], sorts: [{ field: 'close_date', dir: 'desc' }] },
62
+ ],
63
+ },
64
+ fundraising: {
65
+ id: 'fundraising',
66
+ collection: 'opportunities',
67
+ label: 'Investor deal',
68
+ plural: 'Fundraising',
69
+ title: 'name',
70
+ scope: 'pipeline = "fundraising"',
71
+ defaults: { pipeline: 'fundraising', stage: 'intro' },
72
+ columns: ['name', 'company', 'contact', 'stage', 'amount', 'next_step', 'contacted', 'close_date', 'owner'],
73
+ create: ['name', 'company', 'contact', 'stage', 'amount', 'next_step'],
74
+ board: { field: 'stage', lanes: ROUND_STAGES },
75
+ boardFirst: true,
76
+ views: [
77
+ { id: 'all', name: 'All investors', sorts: [{ field: 'contacted', dir: 'asc' }] },
78
+ { id: 'active', name: 'In progress', filters: [{ field: 'stage', op: 'isAnyOf', value: ['intro', 'meeting', 'diligence', 'term_sheet'] }], sorts: [{ field: 'contacted', dir: 'asc' }] },
79
+ { id: 'closing', name: 'Term sheet and closed', filters: [{ field: 'stage', op: 'isAnyOf', value: ['term_sheet', 'closed'] }], sorts: [{ field: 'amount', dir: 'desc' }] },
80
+ ],
81
+ },
82
+ tasks: {
83
+ id: 'tasks',
84
+ collection: 'tasks',
85
+ label: 'Task',
86
+ plural: 'Tasks',
87
+ title: 'title',
88
+ defaults: { status: 'todo' },
89
+ columns: ['title', 'status', 'due', 'assignee', 'people', 'companies', 'opportunities'],
90
+ create: ['title', 'due', 'assignee', 'status'],
91
+ board: { field: 'status' },
92
+ views: [
93
+ { id: 'open', name: 'Open', filters: [{ field: 'status', op: 'isAnyOf', value: ['todo', 'in_progress'] }], sorts: [{ field: 'due', dir: 'asc' }] },
94
+ { id: 'all', name: 'All tasks', sorts: recent },
95
+ { id: 'done', name: 'Done', filters: [{ field: 'status', op: 'is', value: 'done' }], sorts: [{ field: 'updated', dir: 'desc' }] },
96
+ ],
97
+ },
98
+ lists: {
99
+ id: 'lists',
100
+ collection: 'lists',
101
+ label: 'List',
102
+ plural: 'Lists',
103
+ title: 'name',
104
+ defaults: { object: 'people' },
105
+ columns: ['name', 'description', 'purpose', 'owner', 'created'],
106
+ create: ['name', 'description', 'purpose'],
107
+ views: [{ id: 'all', name: 'All lists', sorts: recent }],
108
+ },
109
+ candidates: {
110
+ id: 'candidates',
111
+ collection: 'candidates',
112
+ label: 'Candidate',
113
+ plural: 'Candidates',
114
+ title: 'name',
115
+ columns: ['name', 'emails', 'role', 'job', 'stage', 'location', 'applied', 'source'],
116
+ create: ['name', 'emails', 'role', 'job'],
117
+ board: { field: 'stage' },
118
+ views: [
119
+ { id: 'all', name: 'All candidates', sorts: [{ field: 'applied', dir: 'desc' }] },
120
+ { id: 'open', name: 'In process', filters: [{ field: 'stage', op: 'isAnyOf', value: ['new', 'screening', 'interview', 'offer'] }], sorts: [{ field: 'applied', dir: 'desc' }] },
121
+ ],
122
+ },
123
+ };
124
+ /** The tabs in the order the rail lists them; the first is the CRM's index. */
125
+ export const TABS = ['people', 'companies', 'deals', 'fundraising', 'tasks', 'lists', 'candidates'];
126
+ /** A tab by its address segment; the index is People. Old addresses land on what replaced them. */
127
+ export function objectOf(tab) {
128
+ const t = (tab ?? '').toLowerCase();
129
+ if (!t)
130
+ return OBJECTS.people;
131
+ const moved = {
132
+ leads: 'people', contacts: 'people', investors: 'fundraising', funds: 'companies', customers: 'people',
133
+ opportunities: 'deals', outreach: 'lists',
134
+ };
135
+ const id = (t in OBJECTS ? t : moved[t]);
136
+ return id ? OBJECTS[id] : null;
137
+ }
138
+ /**
139
+ * The view an old address opens on the tab that replaced it: /crm/customers was a
140
+ * table of customers, and is now People's Customers view, not everyone in People.
141
+ */
142
+ export function movedView(tab) {
143
+ const views = { customers: 'customers' };
144
+ return views[(tab ?? '').toLowerCase()];
145
+ }
146
+ /** The view a table opens on: the one the address names, if the table has it, or its first. */
147
+ export function openingView(starters, named) {
148
+ return (named && starters.find((s) => s.config.id === `starter:${named}`)) || starters[0];
149
+ }
150
+ /** Whether a starter view can run on the fields this org's CRM has. */
151
+ export function viewFits(view, fields) {
152
+ return [...(view.filters ?? []), ...(view.sorts ?? [])].every((r) => fields.has(r.field));
153
+ }
154
+ /** A starter view as the table holds it. */
155
+ export function starter(obj, v) {
156
+ return {
157
+ id: `starter:${v.id}`,
158
+ name: v.name,
159
+ kind: v.kind ?? (obj.boardFirst ? 'board' : 'table'),
160
+ filters: v.filters ?? [],
161
+ match: v.match,
162
+ sorts: v.sorts ?? [],
163
+ groupField: obj.board?.field,
164
+ pageSize: 50,
165
+ };
166
+ }
167
+ //# sourceMappingURL=objects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objects.js","sourceRoot":"","sources":["../../src/crm/objects.ts"],"names":[],"mappings":"AA6BA,kEAAkE;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,kGAAkG,CAAA;AAEjI,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,iKAAiK,CAAA;AA0BjM,wDAAwD;AACx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UAAU,OAAO,CAAC,GAAc,EAAE,CAAc;IACpD,OAAO;QACL,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,EAAE;QACrB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QACpD,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;QACxB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;QACpB,UAAU,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK;QAC5B,QAAQ,EAAE,EAAE;KACb,CAAA;AACH,CAAC"}
@@ -0,0 +1,58 @@
1
+ import type { FieldDefinition, SelectOption } from '@hanzo/data';
2
+ import { baseFieldsOf, type BaseField } from '../lib/base-data/fields.js';
3
+ import type { BaseRecord } from '../lib/base-data/api.js';
4
+ import type { CrmObject } from './objects.js';
5
+ /** What a relation field points at, by its name in module crm. */
6
+ export declare const TARGET: Record<string, string>;
7
+ export interface Schema {
8
+ /** Base's own fields, by which values cross (fromBase / toBase) and queries compile. */
9
+ base: BaseField[];
10
+ /** The fields as the table draws them. */
11
+ fields: FieldDefinition[];
12
+ /** The names of every field the org's CRM has. */
13
+ names: Set<string>;
14
+ }
15
+ /** A schema for one object: its pipeline's stages as the stage's lanes, its quiet fields left out. */
16
+ export declare function shape(obj: CrmObject, collection: Parameters<typeof baseFieldsOf>[0]): Schema;
17
+ export type Load<T> = {
18
+ state: 'loading';
19
+ } | {
20
+ state: 'error';
21
+ error: unknown;
22
+ } | {
23
+ state: 'ready';
24
+ value: T;
25
+ };
26
+ /** An object's schema, read once per page. */
27
+ export declare function useSchema(obj: CrmObject, round?: number): Load<Schema>;
28
+ /** How a record of a collection reads as one option: a person by name, else their address. */
29
+ export declare function optionOf(collection: string, r: Record<string, unknown>): SelectOption;
30
+ /**
31
+ * A Base record as the table draws it: each value in @hanzo/data's shape, and each
32
+ * relation as the record it names, a person by their name and a company by its own.
33
+ * A relation to many reads as their names together.
34
+ */
35
+ export declare function rowOf(schema: Schema, r: BaseRecord): Record<string, unknown>;
36
+ /** The relations a schema's visible fields name, for `expand`. */
37
+ export declare const expandOf: (schema: Schema) => string;
38
+ /** The first records of a collection, by name, as the options a relation's editor and filter offer. */
39
+ export declare function relationOptions(collection: string): Promise<SelectOption[]>;
40
+ /** Forget what a relation offers, after a record of it was made or removed. */
41
+ export declare const forgetOptions: (collection: string) => void;
42
+ /** The options of every relation a schema has, keyed by field name. */
43
+ export declare function useRelationOptions(schema: Schema | null): Map<string, SelectOption[]>;
44
+ /** Whether this account administers the org it is working in (or is a SuperAdmin). */
45
+ export declare function useAdmin(): boolean;
46
+ /**
47
+ * Run `fn` over `items`, `width` at a time, reporting each one done. One that
48
+ * fails is counted, never retried, and the rest go on.
49
+ */
50
+ export declare function pool<T>(items: T[], width: number, fn: (item: T) => Promise<void>, done?: (n: number, failed: number) => void): Promise<{
51
+ failed: number;
52
+ errors: string[];
53
+ }>;
54
+ /** Hand the browser a file to save. */
55
+ export declare function save(name: string, text: string, type?: string): void;
56
+ /** A thrown error's words. */
57
+ export declare const words: (e: unknown, fallback: string) => string;
58
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/crm/schema.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEhE,OAAO,EAA0B,YAAY,EAAkB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,kEAAkE;AAClE,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,MAA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ACvE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAcrF;AAED,sFAAsF;AACtF,wBAAgB,QAAQ,IAAI,OAAO,CAIlC;AAED;;;GAGG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAmBlL;AAED,uCAAuC;AACvC,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,SAA2B,GAAG,IAAI,CAStF;AAED,8BAA8B;AAC9B,eAAO,MAAM,KAAK,MAAO,OAAO,YAAY,MAAM,KAAG,MAAkE,CAAA"}
@@ -0,0 +1,175 @@
1
+ 'use client';
2
+ /**
3
+ * A CRM object's schema as the table and the record page read it, and the small
4
+ * helpers both use: who may change the org's CRM, many writes at once, a file to
5
+ * save.
6
+ */
7
+ import { useEffect, useState } from 'react';
8
+ import { CrmApi } from '../lib/crm.js';
9
+ import { baseCollectionToFields, baseFieldsOf, recordFromBase } from '../lib/base-data/fields.js';
10
+ import { currentOrg, useSession } from '../lib/host.js';
11
+ /** What a relation field points at, by its name in module crm. */
12
+ export const TARGET = {
13
+ company: 'companies',
14
+ companies: 'companies',
15
+ promoted_company: 'companies',
16
+ contact: 'people',
17
+ person: 'people',
18
+ people: 'people',
19
+ promoted_contact: 'people',
20
+ opportunity: 'opportunities',
21
+ opportunities: 'opportunities',
22
+ candidate: 'candidates',
23
+ candidates: 'candidates',
24
+ list: 'lists',
25
+ segment: 'segments',
26
+ note: 'notes',
27
+ task: 'tasks',
28
+ };
29
+ /** Fields the table never offers: bookkeeping a person does not sort or edit by. */
30
+ const QUIET = new Set(['position', 'consent', 'avatar', 'public_ref', 'answers', 'metadata', 'screen', 'events']);
31
+ /** A schema for one object: its pipeline's stages as the stage's lanes, its quiet fields left out. */
32
+ export function shape(obj, collection) {
33
+ const base = baseFieldsOf(collection);
34
+ const names = new Set(base.map((f) => f.name));
35
+ const targets = new Map(base.filter((f) => f.collectionId).map((f) => [f.collectionId, TARGET[f.name] ?? f.name]));
36
+ const fields = baseCollectionToFields(collection, { names: targets })
37
+ .filter((f) => !QUIET.has(f.name) && f.name !== 'id' && !(obj.scope && f.name === 'pipeline'))
38
+ .map((f) => {
39
+ if (!obj.board?.lanes || f.name !== obj.board.field)
40
+ return f;
41
+ const options = (f.metadata?.options ?? []).filter((o) => obj.board.lanes.includes(o.value));
42
+ options.sort((a, b) => obj.board.lanes.indexOf(a.value) - obj.board.lanes.indexOf(b.value));
43
+ return { ...f, metadata: { options } };
44
+ });
45
+ return { base, fields, names };
46
+ }
47
+ /** An object's schema, read once per page. */
48
+ export function useSchema(obj, round = 0) {
49
+ const [s, setS] = useState({ state: 'loading' });
50
+ useEffect(() => {
51
+ let live = true;
52
+ setS({ state: 'loading' });
53
+ CrmApi.schema(obj.collection, round > 0)
54
+ .then((c) => live && setS({ state: 'ready', value: shape(obj, c) }))
55
+ .catch((error) => live && setS({ state: 'error', error }));
56
+ return () => {
57
+ live = false;
58
+ };
59
+ }, [obj, round]);
60
+ return s;
61
+ }
62
+ /** How a record of a collection reads as one option: a person by name, else their address. */
63
+ export function optionOf(collection, r) {
64
+ const o = (v) => (v && typeof v === 'object' ? v : {});
65
+ if (collection === 'people' || collection === 'candidates') {
66
+ const n = o(r.name);
67
+ const name = [n.firstName, n.lastName].filter(Boolean).join(' ');
68
+ return { value: String(r.id), label: name || String(o(r.emails).primaryEmail ?? '') || String(r.id) };
69
+ }
70
+ return { value: String(r.id), label: String(r.name ?? r.title ?? r.id) };
71
+ }
72
+ const candidates = new Map();
73
+ /**
74
+ * A Base record as the table draws it: each value in @hanzo/data's shape, and each
75
+ * relation as the record it names, a person by their name and a company by its own.
76
+ * A relation to many reads as their names together.
77
+ */
78
+ export function rowOf(schema, r) {
79
+ const out = recordFromBase(schema.base, r);
80
+ const expand = (r.expand ?? {});
81
+ for (const f of schema.base) {
82
+ if (f.type !== 'relation')
83
+ continue;
84
+ const target = TARGET[f.name] ?? f.name;
85
+ const v = out[f.name];
86
+ if (Array.isArray(v)) {
87
+ const recs = Array.isArray(expand[f.name]) ? expand[f.name] : [];
88
+ out[f.name] = recs.length ? { id: recs.map((x) => x.id).join(','), name: recs.map((x) => optionOf(target, x).label).join(', ') } : '';
89
+ }
90
+ else if (v && typeof v === 'object') {
91
+ const o = optionOf(target, v);
92
+ out[f.name] = { id: o.value, name: o.label };
93
+ }
94
+ }
95
+ return out;
96
+ }
97
+ /** The relations a schema's visible fields name, for `expand`. */
98
+ export const expandOf = (schema) => schema.base.filter((f) => f.type === 'relation' && schema.fields.some((d) => d.name === f.name)).map((f) => f.name).join(',');
99
+ /** The first records of a collection, by name, as the options a relation's editor and filter offer. */
100
+ export function relationOptions(collection) {
101
+ const held = candidates.get(collection);
102
+ if (held)
103
+ return held;
104
+ const sort = collection === 'people' || collection === 'candidates' ? 'name.firstName' : collection === 'tasks' ? 'title' : 'name';
105
+ const p = CrmApi.list(collection, { perPage: 300, sort, skipTotal: true })
106
+ .then((r) => r.items.map((x) => optionOf(collection, x)))
107
+ .catch(() => []);
108
+ candidates.set(collection, p);
109
+ return p;
110
+ }
111
+ /** Forget what a relation offers, after a record of it was made or removed. */
112
+ export const forgetOptions = (collection) => {
113
+ candidates.delete(collection);
114
+ };
115
+ /** The options of every relation a schema has, keyed by field name. */
116
+ export function useRelationOptions(schema) {
117
+ const [opts, setOpts] = useState(new Map());
118
+ useEffect(() => {
119
+ if (!schema)
120
+ return;
121
+ let live = true;
122
+ const rels = schema.fields.filter((f) => f.type === 'relation');
123
+ Promise.all(rels.map((f) => relationOptions(f.metadata?.objectName ?? TARGET[f.name] ?? f.name).then((o) => [f.name, o]))).then((pairs) => live && setOpts(new Map(pairs)));
124
+ return () => {
125
+ live = false;
126
+ };
127
+ }, [schema]);
128
+ return opts;
129
+ }
130
+ /** Whether this account administers the org it is working in (or is a SuperAdmin). */
131
+ export function useAdmin() {
132
+ const { account } = useSession();
133
+ const org = currentOrg();
134
+ return account?.superAdmin === true || (account?.adminOrgs ?? []).includes(org);
135
+ }
136
+ /**
137
+ * Run `fn` over `items`, `width` at a time, reporting each one done. One that
138
+ * fails is counted, never retried, and the rest go on.
139
+ */
140
+ export async function pool(items, width, fn, done) {
141
+ let next = 0;
142
+ let n = 0;
143
+ let failed = 0;
144
+ const errors = [];
145
+ const worker = async () => {
146
+ while (next < items.length) {
147
+ const item = items[next++];
148
+ try {
149
+ await fn(item);
150
+ }
151
+ catch (e) {
152
+ failed++;
153
+ if (errors.length < 5)
154
+ errors.push(e instanceof Error ? e.message : String(e));
155
+ }
156
+ done?.(++n, failed);
157
+ }
158
+ };
159
+ await Promise.all(Array.from({ length: Math.min(width, items.length) }, worker));
160
+ return { failed, errors };
161
+ }
162
+ /** Hand the browser a file to save. */
163
+ export function save(name, text, type = 'text/csv;charset=utf-8') {
164
+ const url = URL.createObjectURL(new Blob([text], { type }));
165
+ const a = document.createElement('a');
166
+ a.href = url;
167
+ a.download = name;
168
+ document.body.appendChild(a);
169
+ a.click();
170
+ a.remove();
171
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
172
+ }
173
+ /** A thrown error's words. */
174
+ export const words = (e, fallback) => (e instanceof Error && e.message ? e.message : fallback);
175
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/crm/schema.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ;;;;GAIG;AACH,OAAO,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C5B,CAAC,CAAC,KAAK,EAAE,CAAA;IACT,CAAC,CAAC,MAAM,EAAE,CAAA;IACV,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;AAClD,CAAC;AAED,8BAA8B;AAC9B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAU,EAAE,QAAgB,EAAU,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ export declare function Sequences({ openId }: {
2
+ openId?: string | null;
3
+ }): import("react").JSX.Element;
4
+ //# sourceMappingURL=Sequences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sequences.d.ts","sourceRoot":"","sources":["../../../src/crm/studio/Sequences.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,+BAgG/D"}
@@ -0,0 +1,114 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * Sends and sequences, as cloud apps/marketing keeps them. An audience send is a
5
+ * one-step sequence with the audience enrolled; a drip is a sequence of several. The
6
+ * list is the org's sequences; opening one shows its steps, its state, and every
7
+ * person it enrolled with where their walk stands, read again while anyone is due.
8
+ * Nothing here is counted in the browser: every figure is the cloud's.
9
+ */
10
+ import { useCallback, useEffect, useState } from 'react';
11
+ import { Button, Text, XStack, YStack } from '@hanzo/gui';
12
+ import { CrmApi } from '../../lib/crm.js';
13
+ import { cardBoxStyle, inputStyle, labelStyle } from './style.js';
14
+ import { delayText, tally, walkState } from './logic.js';
15
+ const when = (s) => (s > 0 ? new Date(s * 1000).toLocaleString() : '—');
16
+ const message = (e, fallback) => (e instanceof Error ? e.message : fallback);
17
+ export function Sequences({ openId }) {
18
+ const [list, setList] = useState(null);
19
+ const [listError, setListError] = useState(null);
20
+ const [selected, setSelected] = useState(openId ?? null);
21
+ const [open, setOpen] = useState(null);
22
+ const [openError, setOpenError] = useState(null);
23
+ const [newName, setNewName] = useState('');
24
+ const [notice, setNotice] = useState(null);
25
+ const loadList = useCallback(() => {
26
+ setListError(null);
27
+ CrmApi.marketing
28
+ .listSequences()
29
+ .then(setList)
30
+ .catch((e) => setListError(message(e, 'The sequences could not be read.')));
31
+ }, []);
32
+ const loadOpen = useCallback(async (id) => {
33
+ setOpenError(null);
34
+ try {
35
+ const [view, enrollments] = await Promise.all([CrmApi.marketing.getSequence(id), CrmApi.marketing.listEnrollments(id)]);
36
+ setOpen({ ...view, enrollments });
37
+ }
38
+ catch (e) {
39
+ setOpenError(message(e, 'This sequence could not be read.'));
40
+ }
41
+ }, []);
42
+ useEffect(loadList, [loadList]);
43
+ useEffect(() => {
44
+ if (openId)
45
+ setSelected(openId);
46
+ }, [openId]);
47
+ useEffect(() => {
48
+ setOpen(null);
49
+ if (selected)
50
+ void loadOpen(selected);
51
+ }, [selected, loadOpen]);
52
+ // While anyone is still due, read the walk again: results arrive as the drip takes each step.
53
+ const due = open ? tally(open.enrollments).due : 0;
54
+ useEffect(() => {
55
+ if (!selected || due === 0)
56
+ return;
57
+ const t = window.setInterval(() => void loadOpen(selected), 15_000);
58
+ return () => window.clearInterval(t);
59
+ }, [selected, due, loadOpen]);
60
+ const create = async () => {
61
+ const name = newName.trim();
62
+ if (!name)
63
+ return;
64
+ setNotice(null);
65
+ try {
66
+ const s = await CrmApi.marketing.createSequence(name);
67
+ setNewName('');
68
+ loadList();
69
+ setSelected(s.id);
70
+ }
71
+ catch (e) {
72
+ setNotice(message(e, 'The sequence was not created.'));
73
+ }
74
+ };
75
+ return (_jsxs(XStack, { gap: "$3", flexWrap: "wrap", items: "flex-start", children: [_jsxs(YStack, { gap: "$2", flex: 1, minW: 260, maxW: 380, children: [_jsxs("div", { style: cardBoxStyle, children: [_jsx("label", { style: labelStyle, children: "New sequence" }), _jsxs(XStack, { gap: "$2", children: [_jsx("input", { "aria-label": "New sequence name", style: inputStyle, placeholder: "Name", value: newName, onChange: (e) => setNewName(e.target.value) }), _jsx(Button, { size: "$2", disabled: !newName.trim(), onPress: () => void create(), children: _jsx(Text, { fontSize: "$2", children: "Create" }) })] }), notice ? _jsx(Text, { fontSize: "$2", color: "$red11", mt: "$2", children: notice }) : null] }), listError ? (_jsx(Text, { fontSize: "$2", color: "$red11", children: listError })) : list === null ? (_jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading\u2026" })) : list.length === 0 ? (_jsx(Text, { fontSize: "$2", color: "$color10", children: "No sends or sequences yet." })) : (list.map((s) => (_jsx(Button, { "data-slot": "sequence-row", size: "$3", bg: s.id === selected ? '$color4' : '$color2', borderWidth: 1, borderColor: "$borderColor", onPress: () => setSelected(s.id), children: _jsxs(XStack, { flex: 1, justify: "space-between", items: "center", gap: "$2", children: [_jsx(Text, { fontSize: "$2", fontWeight: "600", color: "$color12", numberOfLines: 1, children: s.name }), _jsx(Text, { fontSize: "$1", color: "$color10", children: s.status })] }) }, s.id))))] }), _jsxs(YStack, { flex: 2, minW: 320, gap: "$3", children: [openError ? _jsx(Text, { fontSize: "$2", color: "$red11", children: openError }) : null, !selected ? _jsx(Text, { fontSize: "$2", color: "$color10", children: "Open a send or sequence to see who it reached." }) : null, selected && !open && !openError ? _jsx(Text, { fontSize: "$2", color: "$color10", children: "Loading\u2026" }) : null, open ? _jsx(SequenceDetail, { open: open, reload: () => { void loadOpen(open.sequence.id); loadList(); } }, open.sequence.id) : null] })] }));
76
+ }
77
+ function SequenceDetail({ open, reload }) {
78
+ const { sequence, steps, enrollments } = open;
79
+ const t = tally(enrollments);
80
+ const now = Math.floor(Date.now() / 1000);
81
+ const [busy, setBusy] = useState(false);
82
+ const [notice, setNotice] = useState(null);
83
+ const [step, setStep] = useState({ subject: '', body: '', hours: '0' });
84
+ const [address, setAddress] = useState('');
85
+ const [audiences, setAudiences] = useState([]);
86
+ const [audienceId, setAudienceId] = useState('');
87
+ useEffect(() => {
88
+ CrmApi.marketing.listAudiences().then(setAudiences).catch(() => setAudiences([]));
89
+ }, []);
90
+ const run = async (work, failed) => {
91
+ setBusy(true);
92
+ setNotice(null);
93
+ try {
94
+ setNotice({ ok: true, text: await work() });
95
+ reload();
96
+ }
97
+ catch (e) {
98
+ setNotice({ ok: false, text: message(e, failed) });
99
+ }
100
+ finally {
101
+ setBusy(false);
102
+ }
103
+ };
104
+ const enrolled = (r) => `Enrolled ${r.enrolled} of ${r.resolved}${r.alreadyEnrolled ? `; ${r.alreadyEnrolled} already were` : ''}.`;
105
+ return (_jsxs(YStack, { gap: "$3", children: [_jsxs("div", { style: cardBoxStyle, children: [_jsxs(XStack, { justify: "space-between", items: "center", flexWrap: "wrap", gap: "$2", children: [_jsxs(YStack, { children: [_jsx(Text, { fontSize: "$4", fontWeight: "700", color: "$color12", children: sequence.name }), _jsxs(Text, { fontSize: "$1", color: "$color10", children: ["Created ", when(sequence.createdAt), " \u00B7 ", sequence.status] })] }), _jsx(XStack, { gap: "$2", children: ['draft', 'active', 'archived']
106
+ .filter((st) => st !== sequence.status)
107
+ .map((st) => (_jsx(Button, { size: "$2", disabled: busy, onPress: () => void run(async () => { await CrmApi.marketing.setSequenceStatus(sequence.id, st); return `Now ${st}.`; }, 'The status was not changed.'), children: _jsx(Text, { fontSize: "$2", children: st === 'active' ? 'Activate' : st === 'archived' ? 'Archive' : 'Back to draft' }) }, st))) })] }), _jsxs(XStack, { gap: "$4", mt: "$3", flexWrap: "wrap", "data-slot": "sequence-tally", children: [_jsxs(Text, { fontSize: "$2", color: "$color11", children: ["Enrolled ", _jsx("b", { children: t.enrolled })] }), _jsxs(Text, { fontSize: "$2", color: "$color11", children: ["Due ", _jsx("b", { children: t.due })] }), _jsxs(Text, { fontSize: "$2", color: "$color11", children: ["Taken ", _jsx("b", { children: t.taken })] }), _jsxs(Text, { fontSize: "$2", color: "$color11", children: ["Canceled ", _jsx("b", { children: t.canceled })] }), _jsxs(Text, { fontSize: "$2", color: "$color11", children: ["Opens \u00B7 clicks \u00B7 replies ", _jsx("b", { children: "\u2014" })] })] }), notice ? _jsx(Text, { fontSize: "$2", mt: "$2", color: notice.ok ? '$green11' : '$red11', children: notice.text }) : null] }), _jsxs("div", { style: cardBoxStyle, children: [_jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: "Steps" }), steps.length === 0 ? (_jsx(Text, { fontSize: "$2", color: "$color10", mt: "$1", children: "No message yet: an enrollment completes at once and sends nothing." })) : (steps.map((s) => (_jsxs(YStack, { mt: "$2", gap: "$0.5", "data-slot": "sequence-step", children: [_jsxs(Text, { fontSize: "$2", fontWeight: "600", color: "$color12", children: [s.idx + 1, ". ", s.subject || '(no subject)'] }), _jsx(Text, { fontSize: "$1", color: "$color10", children: delayText(s) })] }, s.id)))), _jsxs(YStack, { gap: "$2", mt: "$3", children: [_jsx("label", { style: labelStyle, children: "Add a step" }), _jsx("input", { "aria-label": "Step subject", style: inputStyle, placeholder: "Subject", value: step.subject, onChange: (e) => setStep({ ...step, subject: e.target.value }) }), _jsx("textarea", { "aria-label": "Step message", style: { ...inputStyle, minHeight: 90 }, placeholder: "Message (plain text; the unsubscribe footer is added by the cloud)", value: step.body, onChange: (e) => setStep({ ...step, body: e.target.value }) }), _jsxs(XStack, { gap: "$2", items: "center", children: [_jsxs("label", { style: { ...labelStyle, marginBottom: 0 }, children: ["Hours after ", steps.length === 0 ? 'enrollment' : 'the previous step'] }), _jsx("input", { "aria-label": "Step delay in hours", style: { ...inputStyle, width: 90 }, type: "number", min: 0, value: step.hours, onChange: (e) => setStep({ ...step, hours: e.target.value }) }), _jsx(Button, { size: "$2", disabled: busy || !step.body.trim(), onPress: () => void run(async () => {
108
+ const hours = Math.max(0, Number(step.hours) || 0);
109
+ await CrmApi.marketing.addStep(sequence.id, { delaySeconds: Math.round(hours * 3600), subject: step.subject.trim(), body: step.body });
110
+ setStep({ subject: '', body: '', hours: '0' });
111
+ return 'Step added.';
112
+ }, 'The step was not added.'), children: _jsx(Text, { fontSize: "$2", children: "Add step" }) })] })] })] }), _jsxs("div", { style: cardBoxStyle, children: [_jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: "Enroll" }), sequence.status !== 'active' ? _jsx(Text, { fontSize: "$2", color: "$color10", mt: "$1", children: "Only an active sequence takes enrollments." }) : null, _jsxs(XStack, { gap: "$2", mt: "$2", flexWrap: "wrap", children: [_jsx("input", { "aria-label": "Enroll address", style: { ...inputStyle, flex: 1, minWidth: 200 }, placeholder: "person@company.com", value: address, onChange: (e) => setAddress(e.target.value) }), _jsx(Button, { size: "$2", disabled: busy || sequence.status !== 'active' || !address.trim(), onPress: () => void run(async () => { const r = await CrmApi.marketing.enroll(sequence.id, { address: address.trim() }); setAddress(''); return enrolled(r); }, 'The address was not enrolled.'), children: _jsx(Text, { fontSize: "$2", children: "Enroll address" }) })] }), _jsxs(XStack, { gap: "$2", mt: "$2", flexWrap: "wrap", children: [_jsxs("select", { "aria-label": "Enroll audience", style: { ...inputStyle, flex: 1, minWidth: 200 }, value: audienceId, onChange: (e) => setAudienceId(e.target.value), children: [_jsx("option", { value: "", children: "Choose an audience\u2026" }), audiences.map((a) => (_jsx("option", { value: a.id, children: a.name }, a.id)))] }), _jsx(Button, { size: "$2", disabled: busy || sequence.status !== 'active' || !audienceId, onPress: () => void run(async () => enrolled(await CrmApi.marketing.enroll(sequence.id, { audienceId })), 'The audience was not enrolled.'), children: _jsx(Text, { fontSize: "$2", children: "Enroll audience" }) })] })] }), _jsxs("div", { style: cardBoxStyle, children: [_jsx(Text, { fontSize: "$3", fontWeight: "700", color: "$color12", children: "Who it reached" }), _jsx(Text, { fontSize: "$1", color: "$color10", mt: "$0.5", children: "A walk is due until its step is taken. Whether a taken step was sent, suppressed or failed is recorded by the cloud but not reported here yet." }), enrollments.length === 0 ? (_jsx(Text, { fontSize: "$2", color: "$color10", mt: "$2", children: "Nobody enrolled yet." })) : (_jsxs("table", { style: { width: '100%', borderCollapse: 'collapse', fontSize: 12, marginTop: 8 }, children: [_jsx("thead", { children: _jsxs("tr", { style: { color: '#a1a1aa', textAlign: 'left' }, children: [_jsx("th", { style: { padding: '4px 6px' }, children: "Address" }), _jsx("th", { style: { padding: '4px 6px' }, children: "State" }), _jsx("th", { style: { padding: '4px 6px' }, children: "Enrolled" }), _jsx("th", {})] }) }), _jsx("tbody", { children: enrollments.map((e) => (_jsxs("tr", { "data-slot": "enrollment-row", style: { borderTop: '1px solid rgba(255,255,255,0.06)', color: '#e4e4e7' }, children: [_jsx("td", { style: { padding: '6px', fontFamily: 'monospace' }, children: e.address }), _jsx("td", { style: { padding: '6px' }, children: walkState(e, now) }), _jsx("td", { style: { padding: '6px' }, children: when(e.enrolledAt) }), _jsx("td", { style: { padding: '6px', textAlign: 'right' }, children: e.status === 'active' ? (_jsx(Button, { size: "$1", disabled: busy, onPress: () => void run(async () => { await CrmApi.marketing.cancelEnrollment(sequence.id, e.id); return `Canceled for ${e.address}.`; }, 'The walk was not canceled.'), children: _jsx(Text, { fontSize: "$1", children: "Cancel" }) })) : null })] }, e.id))) })] }))] })] }));
113
+ }
114
+ //# sourceMappingURL=Sequences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sequences.js","sourceRoot":"","sources":["../../../src/crm/studio/Sequences.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,MAAM,EAAoE,MAAM,eAAe,CAAA;AACxG,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAA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