@nylas/react 2.0.6 → 2.2.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 (148) hide show
  1. package/dist/cjs/connect.js +1 -0
  2. package/dist/cjs/elements.js +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/notetaker.js +62 -0
  5. package/dist/cjs/utils.js +11 -0
  6. package/dist/connect.d.ts +1 -0
  7. package/dist/elements.d.ts +1 -0
  8. package/dist/es/connect.js +279 -0
  9. package/dist/es/elements.js +1319 -0
  10. package/dist/es/index.js +281 -0
  11. package/dist/es/notetaker.js +5784 -0
  12. package/dist/es/utils.js +12396 -0
  13. package/dist/lib/connect/index.d.ts +6 -0
  14. package/dist/lib/connect/types.d.ts +2 -0
  15. package/dist/lib/connect/useNylasConnect.d.ts +28 -0
  16. package/dist/lib/connect/useNylasConnect.test.d.ts +1 -0
  17. package/dist/lib/connect.d.ts +1 -0
  18. package/dist/lib/elements/components.d.ts +975 -0
  19. package/dist/lib/elements.d.ts +1 -0
  20. package/dist/lib/index.d.ts +3 -5
  21. package/dist/lib/notetaker.d.ts +1 -0
  22. package/dist/lib/utils.d.ts +2 -0
  23. package/dist/notetaker.d.ts +1 -0
  24. package/dist/utils.d.ts +1 -0
  25. package/package.json +37 -16
  26. package/dist/abstract-provider-45ada3b4-31e3ed72.cjs +0 -1
  27. package/dist/abstract-provider-45ada3b4-abd3105d.js +0 -187
  28. package/dist/add-circle-icon_2.entry-48953f9c.cjs +0 -1
  29. package/dist/add-circle-icon_2.entry-f6f8b5e5.js +0 -26
  30. package/dist/archive-icon.entry-b3a76711.js +0 -16
  31. package/dist/archive-icon.entry-e2880dc7.cjs +0 -1
  32. package/dist/arrow-icon.entry-84d1e26c.cjs +0 -1
  33. package/dist/arrow-icon.entry-9b3441aa.js +0 -16
  34. package/dist/bold-icon.entry-0749a116.js +0 -16
  35. package/dist/bold-icon.entry-e1d8ab5e.cjs +0 -1
  36. package/dist/button-component_2.entry-1a817230.cjs +0 -1
  37. package/dist/button-component_2.entry-6eb55e97.js +0 -27
  38. package/dist/calendar-agenda-fill-icon_37.entry-0ca8b9f4.cjs +0 -6
  39. package/dist/calendar-agenda-fill-icon_37.entry-4adf73a2.js +0 -5231
  40. package/dist/calendar-cancel-icon.entry-2a29cb3f.js +0 -16
  41. package/dist/calendar-cancel-icon.entry-e0dee585.cjs +0 -1
  42. package/dist/calendar-check-icon.entry-7f96d456.cjs +0 -1
  43. package/dist/calendar-check-icon.entry-c12b63ea.js +0 -16
  44. package/dist/calendar-icon.entry-a2d19ff2.cjs +0 -1
  45. package/dist/calendar-icon.entry-e82a5169.js +0 -16
  46. package/dist/checkbox-component.entry-59612a67.js +0 -52
  47. package/dist/checkbox-component.entry-ddce70bc.cjs +0 -1
  48. package/dist/checkbox-group_4.entry-3311da64.cjs +0 -28
  49. package/dist/checkbox-group_4.entry-7df47ad4.js +0 -10011
  50. package/dist/checkmark-circle-icon.entry-677b0def.js +0 -16
  51. package/dist/checkmark-circle-icon.entry-67df713b.cjs +0 -1
  52. package/dist/checkmark-icon_15.entry-2121e1b7.cjs +0 -5
  53. package/dist/checkmark-icon_15.entry-9fd0ec58.js +0 -1412
  54. package/dist/chevron-icon_3.entry-1a42235c.cjs +0 -1
  55. package/dist/chevron-icon_3.entry-f0ad71d9.js +0 -157
  56. package/dist/clock-icon_4.entry-88822a84.cjs +0 -1
  57. package/dist/clock-icon_4.entry-e7472d5f.js +0 -46
  58. package/dist/constants-f51538ef-cd2a67c4.cjs +0 -1
  59. package/dist/constants-f51538ef-e0a5f026.js +0 -876
  60. package/dist/customParseFormat-eeec04f5-3ad26beb.js +0 -135
  61. package/dist/customParseFormat-eeec04f5-d5957784.cjs +0 -1
  62. package/dist/delete-icon.entry-3cb58910.cjs +0 -1
  63. package/dist/delete-icon.entry-813429d7.js +0 -16
  64. package/dist/document-refresh-icon.entry-ae361b0b.cjs +0 -1
  65. package/dist/document-refresh-icon.entry-c224c778.js +0 -16
  66. package/dist/feedbackSync-0ebd0eda-803c3ebe.js +0 -6048
  67. package/dist/feedbackSync-0ebd0eda-e12b00d5.cjs +0 -448
  68. package/dist/folder-icon.entry-107841af.cjs +0 -1
  69. package/dist/folder-icon.entry-9c1f7c41.js +0 -16
  70. package/dist/forward-icon.entry-4ac22c16.js +0 -16
  71. package/dist/forward-icon.entry-6cec1f94.cjs +0 -1
  72. package/dist/globe-icon.entry-7798c93b.js +0 -16
  73. package/dist/globe-icon.entry-909c1382.cjs +0 -1
  74. package/dist/google-logo-icon_6.entry-1f4ad364.cjs +0 -2
  75. package/dist/google-logo-icon_6.entry-b198c90a.js +0 -1762
  76. package/dist/google-meet-icon_5.entry-82d87e77.cjs +0 -1
  77. package/dist/google-meet-icon_5.entry-fa6dc1dc.js +0 -56
  78. package/dist/inbox-icon.entry-1b123e64.js +0 -16
  79. package/dist/inbox-icon.entry-84f96d31.cjs +0 -1
  80. package/dist/index-140eb219.js +0 -24953
  81. package/dist/index-d8a42c15.cjs +0 -118
  82. package/dist/index.es-57d4a08f-184cbc01.js +0 -2724
  83. package/dist/index.es-57d4a08f-b0a2ca19.cjs +0 -7
  84. package/dist/info-icon_2.entry-f09e7dae.cjs +0 -1
  85. package/dist/info-icon_2.entry-f8b72d08.js +0 -35
  86. package/dist/input-component.entry-44607977.js +0 -93
  87. package/dist/input-component.entry-fd38953d.cjs +0 -1
  88. package/dist/input-dropdown_2.entry-4c2e5e1a.cjs +0 -1
  89. package/dist/input-dropdown_2.entry-6898b420.js +0 -252
  90. package/dist/italic-icon.entry-16aa1ada.js +0 -16
  91. package/dist/italic-icon.entry-beef2254.cjs +0 -1
  92. package/dist/lib/elements/index.d.ts +0 -133
  93. package/dist/lib/elements/react-component-lib/createComponent.d.ts +0 -10
  94. package/dist/lib/elements/react-component-lib/createOverlayComponent.d.ts +0 -21
  95. package/dist/lib/elements/react-component-lib/index.d.ts +0 -2
  96. package/dist/lib/elements/react-component-lib/interfaces.d.ts +0 -29
  97. package/dist/lib/elements/react-component-lib/utils/attachProps.d.ts +0 -9
  98. package/dist/lib/elements/react-component-lib/utils/case.d.ts +0 -2
  99. package/dist/lib/elements/react-component-lib/utils/dev.d.ts +0 -2
  100. package/dist/lib/elements/react-component-lib/utils/index.d.ts +0 -10
  101. package/dist/multi-select-dropdown.entry-50133d29.js +0 -130
  102. package/dist/multi-select-dropdown.entry-c82cd6d4.cjs +0 -1
  103. package/dist/nylas-booked-event-card_11.entry-56768a09.js +0 -1407
  104. package/dist/nylas-booked-event-card_11.entry-eb4b3c5c.cjs +0 -1
  105. package/dist/nylas-date-component_2.entry-93f2f352.cjs +0 -1
  106. package/dist/nylas-date-component_2.entry-df957150.js +0 -307
  107. package/dist/nylas-form-card.entry-4d95a4ad.cjs +0 -1
  108. package/dist/nylas-form-card.entry-7724e61f.js +0 -72
  109. package/dist/nylas-notification_2.entry-448c2cb8.cjs +0 -1
  110. package/dist/nylas-notification_2.entry-af763b6c.js +0 -85
  111. package/dist/nylas-scheduler-editor.entry-0e4ba46d.js +0 -1796
  112. package/dist/nylas-scheduler-editor.entry-e36cdd9d.cjs +0 -2
  113. package/dist/nylas-scheduling.entry-1b207e91.js +0 -999
  114. package/dist/nylas-scheduling.entry-904dd10e.cjs +0 -1
  115. package/dist/person-icon.entry-70d46ca6.cjs +0 -1
  116. package/dist/person-icon.entry-f2979577.js +0 -16
  117. package/dist/play-icon.entry-c2cf0b12.cjs +0 -1
  118. package/dist/play-icon.entry-d387df5d.js +0 -16
  119. package/dist/radio-button-group.entry-45dbd2df.js +0 -56
  120. package/dist/radio-button-group.entry-94e06176.cjs +0 -1
  121. package/dist/react.cjs +0 -1
  122. package/dist/react.js +0 -149
  123. package/dist/refresh-icon.entry-5ab20f26.cjs +0 -1
  124. package/dist/refresh-icon.entry-777cff27.js +0 -16
  125. package/dist/register-component-0aad9e3d-b395364a.js +0 -109
  126. package/dist/register-component-0aad9e3d-d2f2e543.cjs +0 -1
  127. package/dist/reply-all-icon.entry-3c90510e.cjs +0 -1
  128. package/dist/reply-all-icon.entry-e2dd6da9.js +0 -16
  129. package/dist/reply-icon.entry-00a97d9f.js +0 -16
  130. package/dist/reply-icon.entry-d96478be.cjs +0 -1
  131. package/dist/sent-icon.entry-2d16da4e.cjs +0 -1
  132. package/dist/sent-icon.entry-949cf214.js +0 -16
  133. package/dist/spam-icon.entry-3baf9e79.js +0 -16
  134. package/dist/spam-icon.entry-7ee61730.cjs +0 -1
  135. package/dist/star-icon.entry-9fdb278b.js +0 -16
  136. package/dist/star-icon.entry-dc702d73.cjs +0 -1
  137. package/dist/stop-icon.entry-b5ae7e55.cjs +0 -1
  138. package/dist/stop-icon.entry-efa1ea66.js +0 -16
  139. package/dist/textarea-component.entry-247aca42.cjs +0 -1
  140. package/dist/textarea-component.entry-7c6fc4d8.js +0 -55
  141. package/dist/toggle-switch.entry-a0295d17.js +0 -49
  142. package/dist/toggle-switch.entry-d52b0338.cjs +0 -1
  143. package/dist/translate-icon.entry-219cab17.js +0 -16
  144. package/dist/translate-icon.entry-985b3b29.cjs +0 -1
  145. package/dist/trash-fill-icon.entry-03c90559.js +0 -16
  146. package/dist/trash-fill-icon.entry-4dfd7d24.cjs +0 -1
  147. package/dist/underline-icon.entry-58fa18b5.js +0 -16
  148. package/dist/underline-icon.entry-c60b77a6.cjs +0 -1
@@ -1,1796 +0,0 @@
1
- var le = Object.defineProperty;
2
- var ce = (r, t, n) => t in r ? le(r, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[t] = n;
3
- var P = (r, t, n) => (ce(r, typeof t != "symbol" ? t + "" : t, n), n);
4
- import { d as dayjs, u as utc, t as timezone, p as process, c as commonjsGlobal, r as registerInstance, a as createEvent, b as debug, N as NylasIdentityRequestWrapper, i as instance, h, H as Host, g as getElement, e as createStore, B as Buffer, F as Fragment, f as dataResponse, j as getCalendarRange } from "./index-140eb219.js";
5
- import { N as NylasBaseProvider } from "./abstract-provider-45ada3b4-abd3105d.js";
6
- import { X as Xr } from "./index.es-57d4a08f-184cbc01.js";
7
- import { L as LANGUAGE_CODE, a as LANGUAGE_MAP, C as CONFIGURATION_EVENT_TYPE } from "./constants-f51538ef-e0a5f026.js";
8
- import "react";
9
- import "react/jsx-runtime";
10
- import "react-dom";
11
- dayjs.extend(utc);
12
- dayjs.extend(timezone);
13
- class NylasSchedulerConfigAPIConnector {
14
- constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
15
- this.groupEventsCache = /* @__PURE__ */ new Map(), this.CACHE_DURATION = 1 * 60 * 1e3, this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
16
- }
17
- async currentUser() {
18
- return this.nylasApiRequest ? this.nylasApiRequest.currentUser() : (console.warn("Nylas API Request is not initialized"), null);
19
- }
20
- async getCalendars() {
21
- var a;
22
- if (!this.nylasApiRequest)
23
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
24
- message: "Error fetching calendars: Nylas API Request is not initialized"
25
- });
26
- const t = [];
27
- let n = null;
28
- const s = 50;
29
- do {
30
- const [l, d] = await this.nylasApiRequest.request({
31
- method: "GET",
32
- path: `calendars?limit=${s}${n ? `&page_token=${n}` : ""}`
33
- });
34
- if (d)
35
- return dataResponse(null, {
36
- message: "Error fetching calendars: " + d.message
37
- });
38
- if (Xr(l))
39
- return dataResponse(null, {
40
- message: "Error fetching calendars: " + ((a = l.error) == null ? void 0 : a.message)
41
- });
42
- t.push(...l.data), n = l.next_cursor || null;
43
- } while (n);
44
- return this.nylasSchedulerConfigStore.state.calendars = t, dataResponse(t);
45
- }
46
- async getConfigurationById(t, n = !1) {
47
- var l;
48
- if (!this.nylasApiRequest)
49
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
50
- message: "Error fetching configuration: Nylas API Request is not initialized"
51
- });
52
- if (!n) {
53
- const d = this.nylasSchedulerConfigStore.state.configurations.find((c) => c.id === t);
54
- if (d)
55
- return this.nylasSchedulerConfigStore.state.selectedConfiguration = d, dataResponse(d);
56
- }
57
- const [s, a] = await this.nylasApiRequest.request({
58
- method: "GET",
59
- path: `scheduling/configurations/${t}`
60
- });
61
- return a ? dataResponse(null, {
62
- message: "Error fetching configuration: " + a.message
63
- }) : Xr(s) ? dataResponse(null, {
64
- message: "Error fetching configuration: " + ((l = s.error) == null ? void 0 : l.message)
65
- }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = s.data, this.nylasSchedulerConfigStore.state.configurations.find((d) => d.id === t) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((d) => d.id === t ? s.data : d) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, s.data], dataResponse(s.data));
66
- }
67
- async getConfigurations(t) {
68
- var l;
69
- if (!this.nylasApiRequest)
70
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
71
- message: "Error fetching configurations: Nylas API Request is not initialized"
72
- });
73
- const n = 50, [s, a] = await this.nylasApiRequest.request({
74
- method: "GET",
75
- path: `scheduling/configurations?limit=${n}${t ? `&page_token=${t}` : ""}`
76
- });
77
- return a ? dataResponse(null, {
78
- message: "Error fetching configurations: " + a.message
79
- }) : Xr(s) ? dataResponse(null, {
80
- message: "Error fetching configurations: " + ((l = s.error) == null ? void 0 : l.message)
81
- }) : (this.nylasSchedulerConfigStore.state.configurations = s.data, this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor = s.next_cursor || null, dataResponse(s.data));
82
- }
83
- async getMasterEventById(t) {
84
- var u, f;
85
- if (!this.nylasApiRequest)
86
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
87
- message: "Error fetching master event: Nylas API Request is not initialized"
88
- });
89
- const n = this.nylasSchedulerConfigStore.state.selectedGroupEvent, s = (u = n == null ? void 0 : n.event) == null ? void 0 : u.calendar_id;
90
- if (!s)
91
- return console.warn("Calendar ID is not present"), dataResponse(null, {
92
- message: "Error fetching master event: Calendar ID is not present"
93
- });
94
- const a = new URLSearchParams();
95
- a.append("calendar_id", s);
96
- const [l, d] = await this.nylasApiRequest.request({
97
- method: "GET",
98
- path: `events/${t}?${a.toString()}`
99
- });
100
- if (d)
101
- return dataResponse(null, {
102
- message: "Error fetching master event: " + d.message
103
- });
104
- if (Xr(l))
105
- return dataResponse(null, {
106
- message: "Error fetching master event: " + ((f = l.error) == null ? void 0 : f.message)
107
- });
108
- const c = this.nylasSchedulerConfigStore.state.masterGroupEvents;
109
- return c[t] ? this.nylasSchedulerConfigStore.state.masterGroupEvents[t] = l.data : this.nylasSchedulerConfigStore.state.masterGroupEvents = { ...c, [t]: l.data }, dataResponse(l.data);
110
- }
111
- async createConfiguration(t) {
112
- var a;
113
- if (!this.nylasApiRequest)
114
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
115
- message: "Error creating configuration: Nylas API Request is not initialized"
116
- });
117
- const [n, s] = await this.nylasApiRequest.request({
118
- method: "POST",
119
- path: "scheduling/configurations",
120
- body: t
121
- });
122
- return s ? dataResponse(null, {
123
- message: "Error creating configuration: " + s.message
124
- }) : Xr(n) ? dataResponse(null, {
125
- message: "Error creating configuration: " + ((a = n.error) == null ? void 0 : a.message)
126
- }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
127
- }
128
- async updateConfiguration(t) {
129
- var a;
130
- if (!this.nylasApiRequest)
131
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
132
- message: "Error updating configuration: Nylas API Request is not initialized"
133
- });
134
- const [n, s] = await this.nylasApiRequest.request({
135
- method: "PUT",
136
- path: `scheduling/configurations/${t.id}`,
137
- body: t
138
- });
139
- return s ? dataResponse(null, {
140
- message: "Error updating configuration: " + s.message
141
- }) : Xr(n) ? dataResponse(null, {
142
- message: "Error updating configuration: " + ((a = n.error) == null ? void 0 : a.message)
143
- }) : (this.nylasSchedulerConfigStore.state.selectedConfiguration = n.data, this.nylasSchedulerConfigStore.state.configurations.find((l) => l.id === t.id) ? this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.map((l) => l.id === t.id ? n.data : l) : this.nylasSchedulerConfigStore.state.configurations = [...this.nylasSchedulerConfigStore.state.configurations, n.data], dataResponse(n.data));
144
- }
145
- async deleteConfiguration(t) {
146
- var a, l;
147
- if (!this.nylasApiRequest)
148
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
149
- message: "Error deleting configuration: Nylas API Request is not initialized"
150
- });
151
- const [n, s] = await this.nylasApiRequest.request({
152
- method: "DELETE",
153
- path: `scheduling/configurations/${t}`
154
- });
155
- return s ? dataResponse(null, {
156
- message: "Error deleting configuration: " + s.message
157
- }) : Xr(n) ? dataResponse(null, {
158
- message: "Error deleting configuration: " + ((a = n.error) == null ? void 0 : a.message)
159
- }) : (this.nylasSchedulerConfigStore.state.configurations = this.nylasSchedulerConfigStore.state.configurations.filter((d) => d.id !== t), ((l = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : l.id) === t && this.nylasSchedulerConfigStore.resetSelectedConfiguration(), dataResponse(n.data));
160
- }
161
- async createGroupEvent(t, n) {
162
- var l;
163
- if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
164
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
165
- message: "Error creating group event: Nylas API Request is not initialized"
166
- });
167
- const [s, a] = await this.nylasApiRequest.request({
168
- method: "POST",
169
- path: `scheduling/configurations/${n}/group-events`,
170
- body: t
171
- });
172
- return a ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
173
- message: "Error creating group event: " + a.message
174
- })) : Xr(s) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
175
- message: "Error creating group event: " + ((l = s.error) == null ? void 0 : l.message)
176
- })) : (this.nylasSchedulerConfigStore.state.selectedGroupEvent = s.data, await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(s.data));
177
- }
178
- async getGroupEvents(t, n) {
179
- var m, y;
180
- if (!this.nylasApiRequest)
181
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
182
- message: "Error fetching group events: Nylas API Request is not initialized"
183
- });
184
- const s = new URLSearchParams();
185
- s.append("show_all", "true");
186
- const a = this.nylasSchedulerConfigStore.state.calendarViewDateRange;
187
- let l, d;
188
- if (a)
189
- l = a.start_time, d = a.end_time;
190
- else {
191
- const w = getCalendarRange((/* @__PURE__ */ new Date()).toISOString(), "week");
192
- l = w.startTime.toString(), d = w.endTime.toString();
193
- }
194
- const c = `${t}-${l}-${d}`, u = this.groupEventsCache.get(c);
195
- if (u && Date.now() - u.timestamp < this.CACHE_DURATION)
196
- return this.nylasSchedulerConfigStore.state.groupEvents = u.data, dataResponse(u.data);
197
- s.append("start_time", l), s.append("end_time", d);
198
- const f = (m = n == null ? void 0 : n.group_booking) == null ? void 0 : m.calendar_id;
199
- f && s.append("calendar_id", f);
200
- const [g, p] = await this.nylasApiRequest.request({
201
- method: "GET",
202
- path: `scheduling/configurations/${t}/group-events?${s.toString()}`
203
- });
204
- return p ? dataResponse(null, {
205
- message: "Error fetching group events: " + p.message
206
- }) : Xr(g) ? dataResponse(null, {
207
- message: "Error fetching group events: " + ((y = g.error) == null ? void 0 : y.message)
208
- }) : (this.groupEventsCache.set(c, {
209
- data: g.data,
210
- timestamp: Date.now()
211
- }), this.cleanupExpiredCache(), this.nylasSchedulerConfigStore.state.groupEvents = g.data, dataResponse(g.data));
212
- }
213
- cleanupExpiredCache() {
214
- const t = Date.now();
215
- for (const [n, s] of this.groupEventsCache.entries())
216
- t - s.timestamp > this.CACHE_DURATION && this.groupEventsCache.delete(n);
217
- }
218
- async updateGroupEventById(t, n) {
219
- var d;
220
- if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
221
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
222
- message: "Error updating group event: Nylas API Request is not initialized"
223
- });
224
- const s = t.id;
225
- delete t.id;
226
- const [a, l] = await this.nylasApiRequest.request({
227
- method: "PATCH",
228
- path: `scheduling/configurations/${n}/group-events/${s}`,
229
- body: t
230
- });
231
- return l ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
232
- message: "Error updating group event: " + l.message
233
- })) : Xr(a) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
234
- message: "Error updating group event: " + ((d = a.error) == null ? void 0 : d.message)
235
- })) : (this.nylasSchedulerConfigStore.state.selectedGroupEvent = a.data, await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(a.data));
236
- }
237
- async updateGroupEvent(t, n, s) {
238
- var p, m, y, w, _, x, R, A, k, U, N, O, I, T;
239
- this.nylasSchedulerConfigStore.state.isLoading = !0;
240
- const a = this.nylasSchedulerConfigStore.state.selectedGroupEvent, l = (p = a == null ? void 0 : a.event) == null ? void 0 : p.master_event_id, d = (m = a == null ? void 0 : a.event) == null ? void 0 : m.id, c = (w = (y = a == null ? void 0 : a.event) == null ? void 0 : y.when) == null ? void 0 : w.start_time, u = (x = (_ = a == null ? void 0 : a.group_event_info) == null ? void 0 : _.rrule) == null ? void 0 : x[0], f = u ? u.split(";").filter((S) => !S.startsWith("UNTIL")).join(";") : "", g = c ? dayjs(c * 1e3).subtract(1, "minute").format("YYYYMMDDTHHmmss[Z]") : "";
241
- if (n === "this")
242
- return this.updateGroupEventById({
243
- ...t,
244
- id: d,
245
- recurrence: l ? void 0 : t.recurrence
246
- }, s);
247
- if (n === "future" && l) {
248
- const S = await this.createGroupEvent(t, s), v = {
249
- location: (R = a == null ? void 0 : a.event) == null ? void 0 : R.location,
250
- conferencing: (A = a == null ? void 0 : a.event) == null ? void 0 : A.conferencing,
251
- title: (k = a == null ? void 0 : a.event) == null ? void 0 : k.title,
252
- description: (U = a == null ? void 0 : a.event) == null ? void 0 : U.description,
253
- capacity: (N = a == null ? void 0 : a.group_event_info) == null ? void 0 : N.capacity,
254
- calendar_id: (O = a == null ? void 0 : a.event) == null ? void 0 : O.calendar_id,
255
- recurrence: f ? [f + ";UNTIL=" + g] : [`RRULE:FREQ=DAILY;UNTIL=${g}`]
256
- };
257
- return await this.updateGroupEventById({
258
- ...v,
259
- id: l
260
- }, s), [v, S];
261
- } else if (n === "all") {
262
- const S = t == null ? void 0 : t.when, v = (I = a == null ? void 0 : a.event) == null ? void 0 : I.when, L = (T = this.nylasSchedulerConfigStore.state.masterGroupEvents) == null ? void 0 : T[l];
263
- let b = L == null ? void 0 : L.when;
264
- return (S == null ? void 0 : S.start_time) !== (v == null ? void 0 : v.start_time) && (b = {
265
- ...b,
266
- start_time: (S == null ? void 0 : S.start_time) || (b == null ? void 0 : b.start_time)
267
- }), (S == null ? void 0 : S.end_time) !== (v == null ? void 0 : v.end_time) && (b = {
268
- ...b,
269
- end_time: (S == null ? void 0 : S.end_time) || (b == null ? void 0 : b.end_time)
270
- }), (S == null ? void 0 : S.start_timezone) !== (v == null ? void 0 : v.start_timezone) && (b = {
271
- ...b,
272
- start_timezone: (S == null ? void 0 : S.start_timezone) || (b == null ? void 0 : b.start_timezone)
273
- }), (S == null ? void 0 : S.end_timezone) !== (v == null ? void 0 : v.end_timezone) && (b = {
274
- ...b,
275
- end_timezone: (S == null ? void 0 : S.end_timezone) || (b == null ? void 0 : b.end_timezone)
276
- }), this.updateGroupEventById({
277
- ...t,
278
- when: b,
279
- id: l
280
- }, s);
281
- }
282
- throw this.nylasSchedulerConfigStore.state.isLoading = !1, new Error("Invalid option");
283
- }
284
- async deleteGroupEvent(t, n, s) {
285
- var m, y, w, _, x, R, A, k, U, N, O, I;
286
- this.nylasSchedulerConfigStore.state.isLoading = !0;
287
- const a = this.nylasSchedulerConfigStore.state.selectedGroupEvent, l = (m = a == null ? void 0 : a.event) == null ? void 0 : m.master_event_id, d = (y = a == null ? void 0 : a.event) == null ? void 0 : y.id, c = (_ = (w = a == null ? void 0 : a.event) == null ? void 0 : w.when) == null ? void 0 : _.start_time, u = (R = (x = a == null ? void 0 : a.group_event_info) == null ? void 0 : x.rrule) == null ? void 0 : R[0], f = u ? u.split(";").filter((T) => !T.startsWith("UNTIL")).join(";") : "", g = c ? dayjs(c * 1e3).format("YYYYMMDDTHHmmss[Z]") : "", p = {
288
- location: (A = a == null ? void 0 : a.event) == null ? void 0 : A.location,
289
- conferencing: (k = a == null ? void 0 : a.event) == null ? void 0 : k.conferencing,
290
- title: (U = a == null ? void 0 : a.event) == null ? void 0 : U.title,
291
- description: (N = a == null ? void 0 : a.event) == null ? void 0 : N.description,
292
- capacity: (O = a == null ? void 0 : a.group_event_info) == null ? void 0 : O.capacity,
293
- calendar_id: (I = a == null ? void 0 : a.event) == null ? void 0 : I.calendar_id,
294
- recurrence: f ? [f + ";UNTIL=" + g] : [`RRULE:UNTIL=${g}`]
295
- };
296
- if (n === "this" && d)
297
- return this.deleteGroupEventById(d, s);
298
- if (n === "future" && l && d)
299
- return await this.deleteGroupEventById(d, s), await this.updateGroupEventById({
300
- ...p,
301
- id: l
302
- }, s);
303
- if (n === "all" && l)
304
- return this.deleteGroupEventById(l, s);
305
- throw this.nylasSchedulerConfigStore.state.isLoading = !1, new Error("Invalid option");
306
- }
307
- async deleteGroupEventById(t, n) {
308
- var c, u, f;
309
- if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
310
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
311
- message: "Error deleting group event: Nylas API Request is not initialized"
312
- });
313
- const s = new URLSearchParams(), a = (u = (c = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : c.group_booking) == null ? void 0 : u.calendar_id;
314
- a && s.append("calendar_id", a);
315
- const [l, d] = await this.nylasApiRequest.request({
316
- method: "DELETE",
317
- path: `scheduling/configurations/${n}/group-events/${t}?calendar_id=${a}`
318
- });
319
- return d ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
320
- message: "Error deleting group event: " + d.message
321
- })) : Xr(l) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
322
- message: "Error deleting group event: " + ((f = l.error) == null ? void 0 : f.message)
323
- })) : (await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(l.data));
324
- }
325
- async importGroupEvent(t, n) {
326
- var c, u, f, g, p;
327
- if (this.nylasSchedulerConfigStore.state.isLoading = !0, !this.nylasApiRequest)
328
- return console.warn("Nylas API Request is not initialized"), dataResponse(null, {
329
- message: "Error importing group event: Nylas API Request is not initialized"
330
- });
331
- const s = new URLSearchParams(), a = (u = (c = this.nylasSchedulerConfigStore.state.selectedConfiguration) == null ? void 0 : c.group_booking) == null ? void 0 : u.calendar_id;
332
- a && s.append("calendar_id", a);
333
- const [l, d] = await this.nylasApiRequest.request({
334
- method: "POST",
335
- path: `scheduling/configurations/${n}/import-group-events?${s.toString()}`,
336
- body: t
337
- });
338
- return d ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
339
- message: "Error importing group event: " + d.message
340
- })) : Xr(l) ? (this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(null, {
341
- message: "Error importing group event: " + ((f = l.error) == null ? void 0 : f.message)
342
- })) : (((p = (g = l.data) == null ? void 0 : g.imported_events) == null ? void 0 : p.length) > 0 && await this.getGroupEvents(n, this.nylasSchedulerConfigStore.state.selectedConfiguration), this.nylasSchedulerConfigStore.state.isLoading = !1, dataResponse(l.data));
343
- }
344
- }
345
- class NylasSchedulerConfigConnector {
346
- constructor({ nylasApiRequest: t, nylasSchedulerConfigStore: n }) {
347
- this.nylasApiRequest = t, this.nylasSchedulerConfigStore = n;
348
- }
349
- init() {
350
- debug("NylasSchedulerConfigConnector init");
351
- }
352
- get schedulerConfigStore() {
353
- return this.nylasSchedulerConfigStore;
354
- }
355
- get schedulerConfig() {
356
- return this._schedulerConfigConnector ? this._schedulerConfigConnector : (this._schedulerConfigConnector = new NylasSchedulerConfigAPIConnector({
357
- nylasApiRequest: this.nylasApiRequest,
358
- nylasSchedulerConfigStore: this.nylasSchedulerConfigStore
359
- }), this._schedulerConfigConnector);
360
- }
361
- resetStores() {
362
- debug("NylasSchedulerConfigConnector resetStores"), this.nylasSchedulerConfigStore.reset();
363
- }
364
- async logout() {
365
- debug("NylasSchedulerConfigConnector logout"), this.resetStores();
366
- }
367
- }
368
- function CreateNylasSchedulerConfigStore(r = {}) {
369
- const t = {
370
- selectedConfiguration: {},
371
- configurations: [],
372
- groupEvents: [],
373
- listConfigurationsNextCursor: null,
374
- calendars: [],
375
- currentUser: null,
376
- action: null,
377
- additionalParticipants: [],
378
- requiresSlug: !1,
379
- masterGroupEvents: {},
380
- isLoading: !1,
381
- ...r
382
- }, n = createStore(t);
383
- function s() {
384
- n.set("selectedConfiguration", { ...r.selectedConfiguration });
385
- }
386
- return n.onChange("action", async (a) => {
387
- a || s();
388
- }), {
389
- ...n,
390
- resetSelectedConfiguration: s
391
- };
392
- }
393
- class LocalStorage {
394
- get(t) {
395
- return new Promise((n) => {
396
- const s = window.localStorage.getItem(t);
397
- n(s ? JSON.parse(s) : null);
398
- });
399
- }
400
- async remove(t) {
401
- return window.localStorage.removeItem(t), new Promise((n) => {
402
- n(null);
403
- });
404
- }
405
- set(t, n) {
406
- return window.localStorage.setItem(t, JSON.stringify(n)), new Promise((s) => {
407
- s(null);
408
- });
409
- }
410
- }
411
- const PKCE_KEY = "pkce", GRANT_KEY = "grant", USER_KEY = "user";
412
- class Storage {
413
- constructor(t) {
414
- P(this, "Storage", new LocalStorage());
415
- if (t) {
416
- this.Storage = t;
417
- return;
418
- }
419
- }
420
- setPKCE(t) {
421
- const n = Buffer.from(t);
422
- this.Storage.set(PKCE_KEY, n.toString("base64"));
423
- }
424
- async getPKCE() {
425
- try {
426
- const t = await this.Storage.get(PKCE_KEY);
427
- if (t)
428
- return Buffer.from(t, "base64").toString("utf8");
429
- } catch {
430
- return null;
431
- }
432
- return null;
433
- }
434
- removePKCE() {
435
- this.Storage.remove(PKCE_KEY);
436
- }
437
- setGrant(t, n = !1) {
438
- const { grant_id: s } = t;
439
- this.Storage.set(`${GRANT_KEY}${n ? "-" + s : ""}`, t);
440
- }
441
- removeGrant(t, n = !1) {
442
- this.Storage.remove(`${GRANT_KEY}${n ? "-" + t : ""}`);
443
- }
444
- async getGrant(t, n = !1) {
445
- const s = await this.Storage.get(`${GRANT_KEY}${n ? "-" + t : ""}`);
446
- return s || null;
447
- }
448
- // setUserToken is used to store the IDToken in storage
449
- async setUserToken(t) {
450
- const n = await this.getUserTokens();
451
- if (n)
452
- if (n.find((a) => a.sub === t.sub)) {
453
- const a = n.map((l) => (l.sub === t.sub && (l = t), l));
454
- this.Storage.set(USER_KEY, a);
455
- } else {
456
- const a = [...n, t];
457
- this.Storage.set(USER_KEY, a);
458
- }
459
- else
460
- this.Storage.set(USER_KEY, [t]);
461
- }
462
- // getUserToken is used to retrieve a specific IDToken from storage
463
- async getUserToken(t = "") {
464
- const n = await this.Storage.get(USER_KEY);
465
- return n ? t === "" ? n[0] : n.find((a) => a.sub === t) : null;
466
- }
467
- // getUserTokens is used to retrieve all IDTokens from storage
468
- async getUserTokens() {
469
- const t = await this.Storage.get(USER_KEY);
470
- return t || null;
471
- }
472
- // removeUserTokens is used to remove all IDTokens from storage
473
- removeUserTokens() {
474
- this.Storage.remove(USER_KEY);
475
- }
476
- // removeUserToken is used to remove a specific IDToken from storage
477
- async removeUserToken(t) {
478
- const n = await this.getUserTokens(), s = n == null ? void 0 : n.filter((a) => a.sub !== t);
479
- this.Storage.set(USER_KEY, s);
480
- }
481
- async clearSession() {
482
- const t = await this.getUserTokens();
483
- t == null || t.forEach((n) => {
484
- this.removeGrant(n.sub);
485
- }), this.removePKCE(), this.removeUserTokens();
486
- }
487
- }
488
- class IndexedDBStorage {
489
- constructor() {
490
- P(this, "databaseName", "identity-db");
491
- P(this, "storeName", "identity");
492
- }
493
- get(t) {
494
- const n = this;
495
- return new Promise((s, a) => {
496
- n.openDatabase().then(function(l) {
497
- const d = l.transaction(n.storeName, "readwrite"), u = d.objectStore(n.storeName).get(t);
498
- u.onsuccess = () => {
499
- s(u.result);
500
- }, u.onerror = () => {
501
- a(u.error);
502
- }, d.oncomplete = () => {
503
- l.close();
504
- };
505
- });
506
- });
507
- }
508
- async remove(t) {
509
- const n = this;
510
- return new Promise((s, a) => {
511
- const l = indexedDB.open(this.databaseName);
512
- l.onupgradeneeded = function(d) {
513
- d.target.result.createObjectStore(n.storeName);
514
- }, l.onerror = () => {
515
- a(l.error);
516
- }, l.onsuccess = (d) => {
517
- const c = d.target.result, u = c.transaction(this.storeName, "readwrite"), g = u.objectStore(this.storeName).delete(t);
518
- g.onsuccess = () => {
519
- s(null);
520
- }, g.onerror = () => {
521
- a(g.error);
522
- }, u.oncomplete = () => {
523
- c.close();
524
- };
525
- };
526
- });
527
- }
528
- set(t, n) {
529
- return new Promise((s, a) => {
530
- const l = indexedDB.open(this.databaseName);
531
- l.onerror = () => {
532
- a(l.error);
533
- }, l.onupgradeneeded = (d) => {
534
- d.target.result.createObjectStore(this.storeName);
535
- }, l.onsuccess = (d) => {
536
- const c = d.target.result, u = c.transaction(this.storeName, "readwrite"), g = u.objectStore(this.storeName).put(n, t);
537
- g.onsuccess = () => {
538
- s(n);
539
- }, g.onerror = () => {
540
- a(g.error);
541
- }, u.oncomplete = () => {
542
- c.close();
543
- };
544
- };
545
- });
546
- }
547
- openDatabase() {
548
- const t = this;
549
- return new Promise(function(n, s) {
550
- const a = indexedDB.open(t.databaseName, 2);
551
- a.onupgradeneeded = function(l) {
552
- l.target.result.createObjectStore(t.storeName);
553
- }, a.onsuccess = function(l) {
554
- n(l.target.result);
555
- }, a.onerror = function(l) {
556
- s(l.error);
557
- };
558
- });
559
- }
560
- }
561
- var sha256 = { exports: {} };
562
- (function(module) {
563
- (function() {
564
- var ERROR = "input is invalid type", WINDOW = typeof window == "object", root = WINDOW ? window : {};
565
- root.JS_SHA256_NO_WINDOW && (WINDOW = !1);
566
- var WEB_WORKER = !WINDOW && typeof self == "object", NODE_JS = !root.JS_SHA256_NO_NODE_JS && typeof process == "object" && process.versions && process.versions.node;
567
- NODE_JS ? root = commonjsGlobal : WEB_WORKER && (root = self);
568
- var COMMON_JS = !root.JS_SHA256_NO_COMMON_JS && !0 && module.exports, ARRAY_BUFFER = !root.JS_SHA256_NO_ARRAY_BUFFER && typeof ArrayBuffer < "u", HEX_CHARS = "0123456789abcdef".split(""), EXTRA = [-2147483648, 8388608, 32768, 128], SHIFT = [24, 16, 8, 0], K = [
569
- 1116352408,
570
- 1899447441,
571
- 3049323471,
572
- 3921009573,
573
- 961987163,
574
- 1508970993,
575
- 2453635748,
576
- 2870763221,
577
- 3624381080,
578
- 310598401,
579
- 607225278,
580
- 1426881987,
581
- 1925078388,
582
- 2162078206,
583
- 2614888103,
584
- 3248222580,
585
- 3835390401,
586
- 4022224774,
587
- 264347078,
588
- 604807628,
589
- 770255983,
590
- 1249150122,
591
- 1555081692,
592
- 1996064986,
593
- 2554220882,
594
- 2821834349,
595
- 2952996808,
596
- 3210313671,
597
- 3336571891,
598
- 3584528711,
599
- 113926993,
600
- 338241895,
601
- 666307205,
602
- 773529912,
603
- 1294757372,
604
- 1396182291,
605
- 1695183700,
606
- 1986661051,
607
- 2177026350,
608
- 2456956037,
609
- 2730485921,
610
- 2820302411,
611
- 3259730800,
612
- 3345764771,
613
- 3516065817,
614
- 3600352804,
615
- 4094571909,
616
- 275423344,
617
- 430227734,
618
- 506948616,
619
- 659060556,
620
- 883997877,
621
- 958139571,
622
- 1322822218,
623
- 1537002063,
624
- 1747873779,
625
- 1955562222,
626
- 2024104815,
627
- 2227730452,
628
- 2361852424,
629
- 2428436474,
630
- 2756734187,
631
- 3204031479,
632
- 3329325298
633
- ], OUTPUT_TYPES = ["hex", "array", "digest", "arrayBuffer"], blocks = [];
634
- (root.JS_SHA256_NO_NODE_JS || !Array.isArray) && (Array.isArray = function(r) {
635
- return Object.prototype.toString.call(r) === "[object Array]";
636
- }), ARRAY_BUFFER && (root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView) && (ArrayBuffer.isView = function(r) {
637
- return typeof r == "object" && r.buffer && r.buffer.constructor === ArrayBuffer;
638
- });
639
- var createOutputMethod = function(r, t) {
640
- return function(n) {
641
- return new Sha256(t, !0).update(n)[r]();
642
- };
643
- }, createMethod = function(r) {
644
- var t = createOutputMethod("hex", r);
645
- NODE_JS && (t = nodeWrap(t, r)), t.create = function() {
646
- return new Sha256(r);
647
- }, t.update = function(a) {
648
- return t.create().update(a);
649
- };
650
- for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
651
- var s = OUTPUT_TYPES[n];
652
- t[s] = createOutputMethod(s, r);
653
- }
654
- return t;
655
- }, nodeWrap = function(method, is224) {
656
- var crypto = eval("require('crypto')"), Buffer = eval("require('buffer').Buffer"), algorithm = is224 ? "sha224" : "sha256", nodeMethod = function(r) {
657
- if (typeof r == "string")
658
- return crypto.createHash(algorithm).update(r, "utf8").digest("hex");
659
- if (r == null)
660
- throw new Error(ERROR);
661
- return r.constructor === ArrayBuffer && (r = new Uint8Array(r)), Array.isArray(r) || ArrayBuffer.isView(r) || r.constructor === Buffer ? crypto.createHash(algorithm).update(new Buffer(r)).digest("hex") : method(r);
662
- };
663
- return nodeMethod;
664
- }, createHmacOutputMethod = function(r, t) {
665
- return function(n, s) {
666
- return new HmacSha256(n, t, !0).update(s)[r]();
667
- };
668
- }, createHmacMethod = function(r) {
669
- var t = createHmacOutputMethod("hex", r);
670
- t.create = function(a) {
671
- return new HmacSha256(a, r);
672
- }, t.update = function(a, l) {
673
- return t.create(a).update(l);
674
- };
675
- for (var n = 0; n < OUTPUT_TYPES.length; ++n) {
676
- var s = OUTPUT_TYPES[n];
677
- t[s] = createHmacOutputMethod(s, r);
678
- }
679
- return t;
680
- };
681
- function Sha256(r, t) {
682
- t ? (blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] = blocks[4] = blocks[5] = blocks[6] = blocks[7] = blocks[8] = blocks[9] = blocks[10] = blocks[11] = blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0, this.blocks = blocks) : this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], r ? (this.h0 = 3238371032, this.h1 = 914150663, this.h2 = 812702999, this.h3 = 4144912697, this.h4 = 4290775857, this.h5 = 1750603025, this.h6 = 1694076839, this.h7 = 3204075428) : (this.h0 = 1779033703, this.h1 = 3144134277, this.h2 = 1013904242, this.h3 = 2773480762, this.h4 = 1359893119, this.h5 = 2600822924, this.h6 = 528734635, this.h7 = 1541459225), this.block = this.start = this.bytes = this.hBytes = 0, this.finalized = this.hashed = !1, this.first = !0, this.is224 = r;
683
- }
684
- Sha256.prototype.update = function(r) {
685
- if (!this.finalized) {
686
- var t, n = typeof r;
687
- if (n !== "string") {
688
- if (n === "object") {
689
- if (r === null)
690
- throw new Error(ERROR);
691
- if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
692
- r = new Uint8Array(r);
693
- else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
694
- throw new Error(ERROR);
695
- } else
696
- throw new Error(ERROR);
697
- t = !0;
698
- }
699
- for (var s, a = 0, l, d = r.length, c = this.blocks; a < d; ) {
700
- if (this.hashed && (this.hashed = !1, c[0] = this.block, c[16] = c[1] = c[2] = c[3] = c[4] = c[5] = c[6] = c[7] = c[8] = c[9] = c[10] = c[11] = c[12] = c[13] = c[14] = c[15] = 0), t)
701
- for (l = this.start; a < d && l < 64; ++a)
702
- c[l >> 2] |= r[a] << SHIFT[l++ & 3];
703
- else
704
- for (l = this.start; a < d && l < 64; ++a)
705
- s = r.charCodeAt(a), s < 128 ? c[l >> 2] |= s << SHIFT[l++ & 3] : s < 2048 ? (c[l >> 2] |= (192 | s >> 6) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]) : s < 55296 || s >= 57344 ? (c[l >> 2] |= (224 | s >> 12) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 6 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]) : (s = 65536 + ((s & 1023) << 10 | r.charCodeAt(++a) & 1023), c[l >> 2] |= (240 | s >> 18) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 12 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s >> 6 & 63) << SHIFT[l++ & 3], c[l >> 2] |= (128 | s & 63) << SHIFT[l++ & 3]);
706
- this.lastByteIndex = l, this.bytes += l - this.start, l >= 64 ? (this.block = c[16], this.start = l - 64, this.hash(), this.hashed = !0) : this.start = l;
707
- }
708
- return this.bytes > 4294967295 && (this.hBytes += this.bytes / 4294967296 << 0, this.bytes = this.bytes % 4294967296), this;
709
- }
710
- }, Sha256.prototype.finalize = function() {
711
- if (!this.finalized) {
712
- this.finalized = !0;
713
- var r = this.blocks, t = this.lastByteIndex;
714
- r[16] = this.block, r[t >> 2] |= EXTRA[t & 3], this.block = r[16], t >= 56 && (this.hashed || this.hash(), r[0] = this.block, r[16] = r[1] = r[2] = r[3] = r[4] = r[5] = r[6] = r[7] = r[8] = r[9] = r[10] = r[11] = r[12] = r[13] = r[14] = r[15] = 0), r[14] = this.hBytes << 3 | this.bytes >>> 29, r[15] = this.bytes << 3, this.hash();
715
- }
716
- }, Sha256.prototype.hash = function() {
717
- var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = this.h7, u = this.blocks, f, g, p, m, y, w, _, x, R, A, k;
718
- for (f = 16; f < 64; ++f)
719
- y = u[f - 15], g = (y >>> 7 | y << 25) ^ (y >>> 18 | y << 14) ^ y >>> 3, y = u[f - 2], p = (y >>> 17 | y << 15) ^ (y >>> 19 | y << 13) ^ y >>> 10, u[f] = u[f - 16] + g + u[f - 7] + p << 0;
720
- for (k = t & n, f = 0; f < 64; f += 4)
721
- this.first ? (this.is224 ? (x = 300032, y = u[0] - 1413257819, c = y - 150054599 << 0, s = y + 24177077 << 0) : (x = 704751109, y = u[0] - 210244248, c = y - 1521486534 << 0, s = y + 143694565 << 0), this.first = !1) : (g = (r >>> 2 | r << 30) ^ (r >>> 13 | r << 19) ^ (r >>> 22 | r << 10), p = (a >>> 6 | a << 26) ^ (a >>> 11 | a << 21) ^ (a >>> 25 | a << 7), x = r & t, m = x ^ r & n ^ k, _ = a & l ^ ~a & d, y = c + p + _ + K[f] + u[f], w = g + m, c = s + y << 0, s = y + w << 0), g = (s >>> 2 | s << 30) ^ (s >>> 13 | s << 19) ^ (s >>> 22 | s << 10), p = (c >>> 6 | c << 26) ^ (c >>> 11 | c << 21) ^ (c >>> 25 | c << 7), R = s & r, m = R ^ s & t ^ x, _ = c & a ^ ~c & l, y = d + p + _ + K[f + 1] + u[f + 1], w = g + m, d = n + y << 0, n = y + w << 0, g = (n >>> 2 | n << 30) ^ (n >>> 13 | n << 19) ^ (n >>> 22 | n << 10), p = (d >>> 6 | d << 26) ^ (d >>> 11 | d << 21) ^ (d >>> 25 | d << 7), A = n & s, m = A ^ n & r ^ R, _ = d & c ^ ~d & a, y = l + p + _ + K[f + 2] + u[f + 2], w = g + m, l = t + y << 0, t = y + w << 0, g = (t >>> 2 | t << 30) ^ (t >>> 13 | t << 19) ^ (t >>> 22 | t << 10), p = (l >>> 6 | l << 26) ^ (l >>> 11 | l << 21) ^ (l >>> 25 | l << 7), k = t & n, m = k ^ t & s ^ A, _ = l & d ^ ~l & c, y = a + p + _ + K[f + 3] + u[f + 3], w = g + m, a = r + y << 0, r = y + w << 0;
722
- this.h0 = this.h0 + r << 0, this.h1 = this.h1 + t << 0, this.h2 = this.h2 + n << 0, this.h3 = this.h3 + s << 0, this.h4 = this.h4 + a << 0, this.h5 = this.h5 + l << 0, this.h6 = this.h6 + d << 0, this.h7 = this.h7 + c << 0;
723
- }, Sha256.prototype.hex = function() {
724
- this.finalize();
725
- var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = this.h7, u = HEX_CHARS[r >> 28 & 15] + HEX_CHARS[r >> 24 & 15] + HEX_CHARS[r >> 20 & 15] + HEX_CHARS[r >> 16 & 15] + HEX_CHARS[r >> 12 & 15] + HEX_CHARS[r >> 8 & 15] + HEX_CHARS[r >> 4 & 15] + HEX_CHARS[r & 15] + HEX_CHARS[t >> 28 & 15] + HEX_CHARS[t >> 24 & 15] + HEX_CHARS[t >> 20 & 15] + HEX_CHARS[t >> 16 & 15] + HEX_CHARS[t >> 12 & 15] + HEX_CHARS[t >> 8 & 15] + HEX_CHARS[t >> 4 & 15] + HEX_CHARS[t & 15] + HEX_CHARS[n >> 28 & 15] + HEX_CHARS[n >> 24 & 15] + HEX_CHARS[n >> 20 & 15] + HEX_CHARS[n >> 16 & 15] + HEX_CHARS[n >> 12 & 15] + HEX_CHARS[n >> 8 & 15] + HEX_CHARS[n >> 4 & 15] + HEX_CHARS[n & 15] + HEX_CHARS[s >> 28 & 15] + HEX_CHARS[s >> 24 & 15] + HEX_CHARS[s >> 20 & 15] + HEX_CHARS[s >> 16 & 15] + HEX_CHARS[s >> 12 & 15] + HEX_CHARS[s >> 8 & 15] + HEX_CHARS[s >> 4 & 15] + HEX_CHARS[s & 15] + HEX_CHARS[a >> 28 & 15] + HEX_CHARS[a >> 24 & 15] + HEX_CHARS[a >> 20 & 15] + HEX_CHARS[a >> 16 & 15] + HEX_CHARS[a >> 12 & 15] + HEX_CHARS[a >> 8 & 15] + HEX_CHARS[a >> 4 & 15] + HEX_CHARS[a & 15] + HEX_CHARS[l >> 28 & 15] + HEX_CHARS[l >> 24 & 15] + HEX_CHARS[l >> 20 & 15] + HEX_CHARS[l >> 16 & 15] + HEX_CHARS[l >> 12 & 15] + HEX_CHARS[l >> 8 & 15] + HEX_CHARS[l >> 4 & 15] + HEX_CHARS[l & 15] + HEX_CHARS[d >> 28 & 15] + HEX_CHARS[d >> 24 & 15] + HEX_CHARS[d >> 20 & 15] + HEX_CHARS[d >> 16 & 15] + HEX_CHARS[d >> 12 & 15] + HEX_CHARS[d >> 8 & 15] + HEX_CHARS[d >> 4 & 15] + HEX_CHARS[d & 15];
726
- return this.is224 || (u += HEX_CHARS[c >> 28 & 15] + HEX_CHARS[c >> 24 & 15] + HEX_CHARS[c >> 20 & 15] + HEX_CHARS[c >> 16 & 15] + HEX_CHARS[c >> 12 & 15] + HEX_CHARS[c >> 8 & 15] + HEX_CHARS[c >> 4 & 15] + HEX_CHARS[c & 15]), u;
727
- }, Sha256.prototype.toString = Sha256.prototype.hex, Sha256.prototype.digest = function() {
728
- this.finalize();
729
- var r = this.h0, t = this.h1, n = this.h2, s = this.h3, a = this.h4, l = this.h5, d = this.h6, c = this.h7, u = [
730
- r >> 24 & 255,
731
- r >> 16 & 255,
732
- r >> 8 & 255,
733
- r & 255,
734
- t >> 24 & 255,
735
- t >> 16 & 255,
736
- t >> 8 & 255,
737
- t & 255,
738
- n >> 24 & 255,
739
- n >> 16 & 255,
740
- n >> 8 & 255,
741
- n & 255,
742
- s >> 24 & 255,
743
- s >> 16 & 255,
744
- s >> 8 & 255,
745
- s & 255,
746
- a >> 24 & 255,
747
- a >> 16 & 255,
748
- a >> 8 & 255,
749
- a & 255,
750
- l >> 24 & 255,
751
- l >> 16 & 255,
752
- l >> 8 & 255,
753
- l & 255,
754
- d >> 24 & 255,
755
- d >> 16 & 255,
756
- d >> 8 & 255,
757
- d & 255
758
- ];
759
- return this.is224 || u.push(c >> 24 & 255, c >> 16 & 255, c >> 8 & 255, c & 255), u;
760
- }, Sha256.prototype.array = Sha256.prototype.digest, Sha256.prototype.arrayBuffer = function() {
761
- this.finalize();
762
- var r = new ArrayBuffer(this.is224 ? 28 : 32), t = new DataView(r);
763
- return t.setUint32(0, this.h0), t.setUint32(4, this.h1), t.setUint32(8, this.h2), t.setUint32(12, this.h3), t.setUint32(16, this.h4), t.setUint32(20, this.h5), t.setUint32(24, this.h6), this.is224 || t.setUint32(28, this.h7), r;
764
- };
765
- function HmacSha256(r, t, n) {
766
- var s, a = typeof r;
767
- if (a === "string") {
768
- var l = [], d = r.length, c = 0, u;
769
- for (s = 0; s < d; ++s)
770
- u = r.charCodeAt(s), u < 128 ? l[c++] = u : u < 2048 ? (l[c++] = 192 | u >> 6, l[c++] = 128 | u & 63) : u < 55296 || u >= 57344 ? (l[c++] = 224 | u >> 12, l[c++] = 128 | u >> 6 & 63, l[c++] = 128 | u & 63) : (u = 65536 + ((u & 1023) << 10 | r.charCodeAt(++s) & 1023), l[c++] = 240 | u >> 18, l[c++] = 128 | u >> 12 & 63, l[c++] = 128 | u >> 6 & 63, l[c++] = 128 | u & 63);
771
- r = l;
772
- } else if (a === "object") {
773
- if (r === null)
774
- throw new Error(ERROR);
775
- if (ARRAY_BUFFER && r.constructor === ArrayBuffer)
776
- r = new Uint8Array(r);
777
- else if (!Array.isArray(r) && (!ARRAY_BUFFER || !ArrayBuffer.isView(r)))
778
- throw new Error(ERROR);
779
- } else
780
- throw new Error(ERROR);
781
- r.length > 64 && (r = new Sha256(t, !0).update(r).array());
782
- var f = [], g = [];
783
- for (s = 0; s < 64; ++s) {
784
- var p = r[s] || 0;
785
- f[s] = 92 ^ p, g[s] = 54 ^ p;
786
- }
787
- Sha256.call(this, t, n), this.update(g), this.oKeyPad = f, this.inner = !0, this.sharedMemory = n;
788
- }
789
- HmacSha256.prototype = new Sha256(), HmacSha256.prototype.finalize = function() {
790
- if (Sha256.prototype.finalize.call(this), this.inner) {
791
- this.inner = !1;
792
- var r = this.array();
793
- Sha256.call(this, this.is224, this.sharedMemory), this.update(this.oKeyPad), this.update(r), Sha256.prototype.finalize.call(this);
794
- }
795
- };
796
- var exports = createMethod();
797
- exports.sha256 = exports, exports.sha224 = createMethod(!0), exports.sha256.hmac = createHmacMethod(), exports.sha224.hmac = createHmacMethod(!0), COMMON_JS ? module.exports = exports : (root.sha256 = exports.sha256, root.sha224 = exports.sha224);
798
- })();
799
- })(sha256);
800
- var getRandomValues, rnds8 = new Uint8Array(16);
801
- function rng() {
802
- if (!getRandomValues && (getRandomValues = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), !getRandomValues))
803
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
804
- return getRandomValues(rnds8);
805
- }
806
- const REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
807
- function validate(r) {
808
- return typeof r == "string" && REGEX.test(r);
809
- }
810
- var byteToHex = [];
811
- for (var i = 0; i < 256; ++i)
812
- byteToHex.push((i + 256).toString(16).substr(1));
813
- function stringify(r) {
814
- var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, n = (byteToHex[r[t + 0]] + byteToHex[r[t + 1]] + byteToHex[r[t + 2]] + byteToHex[r[t + 3]] + "-" + byteToHex[r[t + 4]] + byteToHex[r[t + 5]] + "-" + byteToHex[r[t + 6]] + byteToHex[r[t + 7]] + "-" + byteToHex[r[t + 8]] + byteToHex[r[t + 9]] + "-" + byteToHex[r[t + 10]] + byteToHex[r[t + 11]] + byteToHex[r[t + 12]] + byteToHex[r[t + 13]] + byteToHex[r[t + 14]] + byteToHex[r[t + 15]]).toLowerCase();
815
- if (!validate(n))
816
- throw TypeError("Stringified UUID is invalid");
817
- return n;
818
- }
819
- function v4(r, t, n) {
820
- r = r || {};
821
- var s = r.random || (r.rng || rng)();
822
- if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
823
- n = n || 0;
824
- for (var a = 0; a < 16; ++a)
825
- t[n + a] = s[a];
826
- return t;
827
- }
828
- return stringify(s);
829
- }
830
- async function getBytes(r, t) {
831
- const n = r.getReader();
832
- let s;
833
- for (; !(s = await n.read()).done; )
834
- t(s.value);
835
- }
836
- function getLines(r) {
837
- let t, n, s, a = !1;
838
- return function(d) {
839
- t === void 0 ? (t = d, n = 0, s = -1) : t = concat(t, d);
840
- const c = t.length;
841
- let u = 0;
842
- for (; n < c; ) {
843
- a && (t[n] === 10 && (u = ++n), a = !1);
844
- let f = -1;
845
- for (; n < c && f === -1; ++n)
846
- switch (t[n]) {
847
- case 58:
848
- s === -1 && (s = n - u);
849
- break;
850
- case 13:
851
- a = !0;
852
- case 10:
853
- f = n;
854
- break;
855
- }
856
- if (f === -1)
857
- break;
858
- r(t.subarray(u, f), s), u = n, s = -1;
859
- }
860
- u === c ? t = void 0 : u !== 0 && (t = t.subarray(u), n -= u);
861
- };
862
- }
863
- function getMessages(r, t, n) {
864
- let s = newMessage();
865
- const a = new TextDecoder();
866
- return function(d, c) {
867
- if (d.length === 0)
868
- n == null || n(s), s = newMessage();
869
- else if (c > 0) {
870
- const u = a.decode(d.subarray(0, c)), f = c + (d[c + 1] === 32 ? 2 : 1), g = a.decode(d.subarray(f));
871
- switch (u) {
872
- case "data":
873
- s.data = s.data ? s.data + `
874
- ` + g : g;
875
- break;
876
- case "event":
877
- s.event = g;
878
- break;
879
- case "id":
880
- r(s.id = g);
881
- break;
882
- case "retry":
883
- const p = parseInt(g, 10);
884
- isNaN(p) || t(s.retry = p);
885
- break;
886
- }
887
- }
888
- };
889
- }
890
- function concat(r, t) {
891
- const n = new Uint8Array(r.length + t.length);
892
- return n.set(r), n.set(t, r.length), n;
893
- }
894
- function newMessage() {
895
- return {
896
- data: "",
897
- event: "",
898
- id: "",
899
- retry: void 0
900
- };
901
- }
902
- var __rest = function(r, t) {
903
- var n = {};
904
- for (var s in r)
905
- Object.prototype.hasOwnProperty.call(r, s) && t.indexOf(s) < 0 && (n[s] = r[s]);
906
- if (r != null && typeof Object.getOwnPropertySymbols == "function")
907
- for (var a = 0, s = Object.getOwnPropertySymbols(r); a < s.length; a++)
908
- t.indexOf(s[a]) < 0 && Object.prototype.propertyIsEnumerable.call(r, s[a]) && (n[s[a]] = r[s[a]]);
909
- return n;
910
- };
911
- const EventStreamContentType = "text/event-stream", DefaultRetryInterval = 1e3, LastEventId = "last-event-id";
912
- function fetchEventSource(r, t) {
913
- var { signal: n, headers: s, onopen: a, onmessage: l, onclose: d, onerror: c, openWhenHidden: u, fetch: f } = t, g = __rest(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
914
- return new Promise((p, m) => {
915
- const y = Object.assign({}, s);
916
- y.accept || (y.accept = EventStreamContentType);
917
- let w;
918
- function _() {
919
- w.abort(), document.hidden || N();
920
- }
921
- u || document.addEventListener("visibilitychange", _);
922
- let x = DefaultRetryInterval, R = 0;
923
- function A() {
924
- document.removeEventListener("visibilitychange", _), window.clearTimeout(R), w.abort();
925
- }
926
- n == null || n.addEventListener("abort", () => {
927
- A(), p();
928
- });
929
- const k = f ?? window.fetch, U = a ?? defaultOnOpen;
930
- async function N() {
931
- var O;
932
- w = new AbortController();
933
- try {
934
- const I = await k(r, Object.assign(Object.assign({}, g), { headers: y, signal: w.signal }));
935
- await U(I), await getBytes(I.body, getLines(getMessages((T) => {
936
- T ? y[LastEventId] = T : delete y[LastEventId];
937
- }, (T) => {
938
- x = T;
939
- }, l))), d == null || d(), A(), p();
940
- } catch (I) {
941
- if (!w.signal.aborted)
942
- try {
943
- const T = (O = c == null ? void 0 : c(I)) !== null && O !== void 0 ? O : x;
944
- window.clearTimeout(R), R = window.setTimeout(N, T);
945
- } catch (T) {
946
- A(), m(T);
947
- }
948
- }
949
- }
950
- N();
951
- });
952
- }
953
- function defaultOnOpen(r) {
954
- const t = r.headers.get("content-type");
955
- if (!(t != null && t.startsWith(EventStreamContentType)))
956
- throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`);
957
- }
958
- function Base64EncodeUrl(r) {
959
- return r.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
960
- }
961
- function getTimestamp() {
962
- return Math.floor(Date.now() / 1e3);
963
- }
964
- function e(r) {
965
- this.message = r;
966
- }
967
- e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
968
- var r$1 = typeof window < "u" && window.atob && window.atob.bind(window) || function(r) {
969
- var t = String(r).replace(/=+$/, "");
970
- if (t.length % 4 == 1)
971
- throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
972
- for (var n, s, a = 0, l = 0, d = ""; s = t.charAt(l++); ~s && (n = a % 4 ? 64 * n + s : s, a++ % 4) ? d += String.fromCharCode(255 & n >> (-2 * a & 6)) : 0)
973
- s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);
974
- return d;
975
- };
976
- function t$1(r) {
977
- var t = r.replace(/-/g, "+").replace(/_/g, "/");
978
- switch (t.length % 4) {
979
- case 0:
980
- break;
981
- case 2:
982
- t += "==";
983
- break;
984
- case 3:
985
- t += "=";
986
- break;
987
- default:
988
- throw "Illegal base64url string!";
989
- }
990
- try {
991
- return function(n) {
992
- return decodeURIComponent(r$1(n).replace(/(.)/g, function(s, a) {
993
- var l = a.charCodeAt(0).toString(16).toUpperCase();
994
- return l.length < 2 && (l = "0" + l), "%" + l;
995
- }));
996
- }(t);
997
- } catch {
998
- return r$1(t);
999
- }
1000
- }
1001
- function n$1(r) {
1002
- this.message = r;
1003
- }
1004
- function o(r, t) {
1005
- if (typeof r != "string")
1006
- throw new n$1("Invalid token specified");
1007
- var n = (t = t || {}).header === !0 ? 0 : 1;
1008
- try {
1009
- return JSON.parse(t$1(r.split(".")[n]));
1010
- } catch (s) {
1011
- throw new n$1("Invalid token specified: " + s.message);
1012
- }
1013
- }
1014
- n$1.prototype = new Error(), n$1.prototype.name = "InvalidTokenError";
1015
- class NylasSessions {
1016
- constructor(t) {
1017
- P(this, "clientId");
1018
- P(this, "redirectUri");
1019
- P(this, "accessType", "online");
1020
- P(this, "domain", "http://api.nylas.com");
1021
- P(this, "versioned", !1);
1022
- P(this, "Storage");
1023
- P(this, "hosted", !1);
1024
- P(this, "multiAccount", !1);
1025
- P(this, "loginId", "");
1026
- if (this.clientId = t.clientId, this.redirectUri = t.redirectUri, t.domain && (this.domain = t.domain, this.domain.substring(this.domain.length - 3).includes("/v") && (this.versioned = !0)), t.multiAccount && (this.multiAccount = t.multiAccount), t.sw) {
1027
- const n = new IndexedDBStorage();
1028
- this.Storage = new Storage(n);
1029
- } else
1030
- this.Storage = new Storage();
1031
- t.accessType && (this.accessType = t.accessType), t.loginId && (this.loginId = t.loginId), t.hosted && (this.hosted = t.hosted), t.disableInitCodeExchange !== !0 && this.codeExchange(null);
1032
- }
1033
- // Validates access token
1034
- async validateAccessToken(t = "") {
1035
- const n = await this.Storage.getGrant(t, this.multiAccount);
1036
- if (!n)
1037
- return !1;
1038
- const { access_token: s } = n;
1039
- try {
1040
- return !!(await (await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`, {
1041
- method: "GET"
1042
- })).json()).data;
1043
- } catch {
1044
- return !1;
1045
- }
1046
- }
1047
- // Validates id token
1048
- async validateIDToken(t = "") {
1049
- const n = await this.Storage.getGrant(t, this.multiAccount);
1050
- if (!n)
1051
- return !1;
1052
- const { id_token: s } = n;
1053
- try {
1054
- const a = await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`, {
1055
- method: "GET"
1056
- });
1057
- return !(a.status !== 200 || !(await a.json()).data);
1058
- } catch {
1059
- return !1;
1060
- }
1061
- }
1062
- // Gets domain of UAS
1063
- getDomain() {
1064
- return this.domain;
1065
- }
1066
- // Gets auth link
1067
- async auth(t) {
1068
- this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)) && await this.hostedSetCodeChallenge();
1069
- const n = await this.generateAuthURL(t);
1070
- if (t.popup) {
1071
- this.popUp(n);
1072
- return;
1073
- }
1074
- return n;
1075
- }
1076
- // Generates auth URL
1077
- async generateAuthURL(t) {
1078
- const n = await this.getCodeChallege();
1079
- let s = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
1080
- return n && (s += `&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`), t.provider && (s += `&provider=${t.provider}`), t.loginHint && (s += `&login_hint=${t.loginHint}`, t.includeGrantScopes && (s += `&include_grant_scopes=${t.includeGrantScopes}`)), t.scope && (s += `&scope=${t.scope.join(" ")}`), t.prompt && (s += `&prompt=${t.prompt}`), t.metadata && (s += `&metadata=${t.metadata}`), (t.state || this.loginId) && (s += `&state=${this.loginId ? this.loginId : t.state}`), s;
1081
- }
1082
- // Generates auth URL
1083
- async generateReauthURL(t, n) {
1084
- if (!t)
1085
- throw new Error("Grant ID is required");
1086
- const s = await this.Storage.getUserToken(t), a = await this.getCodeChallege();
1087
- let l = `${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;
1088
- return a && (l += `&code_challenge=${a}&code_challenge_method=S256&options=rotate_refresh_token`), s != null && s.provider && (l += `&provider=${s.provider}`), s != null && s.email && (l += `&login_hint=${s.email}`), n && (l += `&scope=${n.join(" ")}`), l;
1089
- }
1090
- // Generates UUID code challenge
1091
- async generateCodeChallenge() {
1092
- if (await this.Storage.getPKCE())
1093
- return;
1094
- const n = v4();
1095
- this.Storage.setPKCE(n);
1096
- }
1097
- // Gets code challenge from URL query params
1098
- async hostedSetCodeChallenge() {
1099
- if (!this.hosted)
1100
- throw console.error("Method only used with hosted flag enabled");
1101
- const n = new URLSearchParams(window.location.search).get("code_challenge");
1102
- if (!n) {
1103
- if (await this.Storage.getPKCE())
1104
- return;
1105
- console.warn("Code challenge is recomended");
1106
- return;
1107
- }
1108
- this.Storage.setPKCE(n);
1109
- }
1110
- // Gets code challenge from store
1111
- async getCodeChallege() {
1112
- if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin))) {
1113
- const s = new URLSearchParams(window.location.search).get("code_challenge");
1114
- return s || (console.warn("Code challenge is recomended"), "");
1115
- }
1116
- const t = await this.Storage.getPKCE();
1117
- if (t) {
1118
- const n = sha256.exports.sha256(t);
1119
- let s = Buffer.from(n).toString("base64");
1120
- return s = Base64EncodeUrl(s), s;
1121
- }
1122
- return "";
1123
- }
1124
- // checks if user is logged in
1125
- async isLoggedIn() {
1126
- if (this.hosted && (this.domain === window.location.origin || this.versioned && this.domain.includes(window.location.origin)))
1127
- return !1;
1128
- const t = await this.Storage.getUserTokens();
1129
- return t && t.length > 0 ? (this.multiAccount && await this.generateCodeChallenge(), !0) : (await this.generateCodeChallenge(), !1);
1130
- }
1131
- // Checks if user is multi account
1132
- isMultiAccount() {
1133
- return this.multiAccount;
1134
- }
1135
- // Logs user out
1136
- async logout() {
1137
- const t = await this.getProfile();
1138
- await this.Storage.clearSession();
1139
- const n = { detail: t };
1140
- window.dispatchEvent(new CustomEvent("onLogoutSuccess", n));
1141
- }
1142
- // Gets profile info from ID token
1143
- async getProfile(t = "") {
1144
- let n;
1145
- return t ? n = await this.Storage.getUserToken(t) : n = await this.Storage.getUserToken(), n || null;
1146
- }
1147
- // Gets profile info from ID tokens
1148
- async getProfiles() {
1149
- const t = await this.Storage.getUserTokens();
1150
- return t || null;
1151
- }
1152
- // Remove a specific profile
1153
- async removeProfile(t) {
1154
- return await this.Storage.removeUserToken(t), await this.Storage.removeGrant(t), null;
1155
- }
1156
- // IMAP authentication
1157
- async authIMAP(t) {
1158
- const n = await this.getCodeChallege(), s = {
1159
- imap_username: t.imap_username,
1160
- imap_password: t.imap_password,
1161
- imap_host: t.imap_host,
1162
- imap_port: t.imap_port,
1163
- type: t.type,
1164
- smtp_host: t.smtp_host,
1165
- smtp_port: t.smtp_port,
1166
- provider: t.provider,
1167
- redirect_uri: this.redirectUri,
1168
- state: t.state,
1169
- public_application_id: this.clientId,
1170
- access_type: this.accessType
1171
- };
1172
- return this.loginId && (s.id = this.loginId), t.smtp_username && t.smtp_password && (s.smtp_username = t.smtp_username, s.smtp_password = t.smtp_password), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/imap`, {
1173
- method: "POST",
1174
- headers: new Headers({ "content-type": "application/json" }),
1175
- body: JSON.stringify(s)
1176
- })).json();
1177
- }
1178
- // EWS authentication
1179
- async authEWS(t) {
1180
- const n = await this.getCodeChallege(), s = {
1181
- ...t,
1182
- provider: "ews",
1183
- redirect_uri: this.redirectUri,
1184
- public_application_id: this.clientId,
1185
- access_type: this.accessType
1186
- };
1187
- return this.loginId && (s.id = this.loginId), n != "" && (s.code_challenge = n, s.code_challenge_method = "S256"), await (await fetch(`${this.domain}/connect/login/ews`, {
1188
- method: "POST",
1189
- headers: new Headers({ "content-type": "application/json" }),
1190
- body: JSON.stringify(s)
1191
- })).json();
1192
- }
1193
- // Detects email
1194
- async detectEmail(t) {
1195
- return await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`, {
1196
- method: "POST",
1197
- headers: new Headers({ "content-type": "application/json" })
1198
- })).json();
1199
- }
1200
- // Gets app info from UAS
1201
- async applicationInfo() {
1202
- return (await (await fetch(`${this.versioned ? this.domain : this.domain + "/connect"}/applications?client_id=${this.clientId}`, {
1203
- method: "GET",
1204
- headers: new Headers({ "content-type": "application/json" })
1205
- })).json()).data;
1206
- }
1207
- // Gets providers form UAS
1208
- async getAvailableProviders() {
1209
- const t = await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`, {
1210
- method: "GET",
1211
- headers: new Headers({ "content-type": "application/json" })
1212
- });
1213
- return t ? (await t.json()).data : null;
1214
- }
1215
- // EVENT HOOKS
1216
- onLoginSuccess(t) {
1217
- window.addEventListener("onLoginSuccess", (n) => t(n));
1218
- }
1219
- onLogoutSuccess(t) {
1220
- window.addEventListener("onLogoutSuccess", (n) => t(n));
1221
- }
1222
- onLoginFail(t) {
1223
- window.addEventListener("onLoginFail", (n) => t(n));
1224
- }
1225
- onTokenRefreshSuccess(t) {
1226
- window.addEventListener("onTokenRefreshSuccess", (n) => t(n));
1227
- }
1228
- onTokenRefreshFail(t) {
1229
- window.addEventListener("onTokenRefreshFail", (n) => t(n));
1230
- }
1231
- onSessionExpired(t) {
1232
- window.addEventListener("onSessionExpired", (n) => t(n));
1233
- }
1234
- // Exchanges code for ID token and refresh and access tokens
1235
- async codeExchange(t) {
1236
- let n = new URLSearchParams(window.location.search);
1237
- t && (n = new URLSearchParams(t));
1238
- const s = n.get("code"), a = n.get("state"), l = n.get("error"), d = n.get("error_description"), c = n.get("error_code");
1239
- if (l && d && c) {
1240
- const f = {
1241
- detail: { error: l, error_description: d, error_code: c }
1242
- };
1243
- return window.dispatchEvent(new CustomEvent("onLoginFail", f)), window.history.pushState({}, document.title, window.location.pathname), !1;
1244
- }
1245
- if (!s)
1246
- return console.warn("No code found"), !1;
1247
- if (window.opener && window.name === "uas-popup")
1248
- return console.warn("Popup window detected"), !1;
1249
- const u = await this.Storage.getPKCE();
1250
- if (!u)
1251
- return console.warn("No code verifier found"), !1;
1252
- try {
1253
- const f = {
1254
- client_id: this.clientId,
1255
- redirect_uri: this.redirectUri,
1256
- code: s,
1257
- grant_type: "authorization_code",
1258
- code_verifier: u
1259
- }, p = await (await fetch(`${this.domain}/connect/token`, {
1260
- method: "POST",
1261
- headers: new Headers({ "content-type": "application/json" }),
1262
- body: JSON.stringify(f)
1263
- })).json();
1264
- if (p) {
1265
- if (p.error) {
1266
- const y = { detail: p };
1267
- return window.dispatchEvent(new CustomEvent("onLoginFail", y)), !0;
1268
- }
1269
- const m = await this.handleCodeExchangeResponse(p);
1270
- if (m.valid) {
1271
- a && (m.data.state = a);
1272
- const y = { detail: m.data };
1273
- window.dispatchEvent(new CustomEvent("onLoginSuccess", y)), window.history.pushState({}, document.title, window.location.pathname);
1274
- } else {
1275
- const y = { detail: m.data };
1276
- return window.dispatchEvent(new CustomEvent("onLoginFail", y)), !0;
1277
- }
1278
- }
1279
- return this.Storage.removePKCE(), !0;
1280
- } catch (f) {
1281
- const g = { detail: f };
1282
- return window.dispatchEvent(new CustomEvent("onLoginFail", g)), window.history.pushState({}, document.title, window.location.pathname), !1;
1283
- }
1284
- }
1285
- // Token Exchange for session maintenece
1286
- async tokenExchange(t = "") {
1287
- const n = await this.Storage.getGrant(t, this.multiAccount);
1288
- if (!n)
1289
- return !1;
1290
- const s = n.refresh_token;
1291
- try {
1292
- const a = {
1293
- client_id: this.clientId,
1294
- redirect_uri: this.redirectUri,
1295
- refresh_token: s,
1296
- grant_type: "refresh_token"
1297
- }, d = await (await fetch(`${this.domain}/connect/token`, {
1298
- method: "POST",
1299
- headers: new Headers({ "content-type": "application/json" }),
1300
- body: JSON.stringify(a)
1301
- })).json();
1302
- if (d) {
1303
- if (d.error) {
1304
- const g = { detail: d };
1305
- return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", g)), !0;
1306
- }
1307
- const c = getTimestamp();
1308
- if (d.expires_in = c + d.expires_in, this.Storage.setGrant(d, this.multiAccount), !await this.validateIDToken(t)) {
1309
- const g = { detail: d };
1310
- return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", g)), !0;
1311
- }
1312
- const f = { detail: d };
1313
- return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess", f)), !0;
1314
- }
1315
- this.Storage.removePKCE();
1316
- } catch (a) {
1317
- const l = { detail: a };
1318
- return window.dispatchEvent(new CustomEvent("onTokenRefreshFail", l)), !1;
1319
- }
1320
- }
1321
- // Handles the response of code exchange
1322
- async handleCodeExchangeResponse(t) {
1323
- if (t.error)
1324
- return {
1325
- data: t,
1326
- valid: !1
1327
- };
1328
- const s = getTimestamp();
1329
- t.expires_in = s + t.expires_in, this.Storage.setGrant(t, this.multiAccount);
1330
- const a = o(t.id_token);
1331
- return a.status = "authenticated", this.Storage.setUserToken(a), await this.validateIDToken(a.sub) ? {
1332
- data: t,
1333
- valid: !0
1334
- } : {
1335
- data: t,
1336
- valid: !1
1337
- };
1338
- }
1339
- // Regulates POPUP behaivior
1340
- async popUp(t) {
1341
- const a = window.screenX + (window.outerWidth - 500) / 2, l = window.screenY + (window.outerHeight - 600) / 2.5, d = "uas-popup", c = t, u = window.open(c, d, `width=500,height=600,left=${a},top=${l}`);
1342
- if (!u)
1343
- return;
1344
- const f = setInterval(async () => {
1345
- if (u.closed) {
1346
- const g = {
1347
- detail: { error_description: "OAuth provider window closed" }
1348
- };
1349
- window.dispatchEvent(new CustomEvent("onLoginFail", g)), f && clearInterval(f);
1350
- return;
1351
- }
1352
- try {
1353
- const g = u.location.href.split("?");
1354
- if (!g[0])
1355
- return;
1356
- const p = u.location.search;
1357
- if (u.history.pushState({}, document.title, window.location.pathname), g[0] === this.redirectUri && g.length > 1) {
1358
- const m = await this.codeExchange(p);
1359
- u.close(), m && location.reload(), f && clearInterval(f);
1360
- return;
1361
- }
1362
- } catch {
1363
- return;
1364
- }
1365
- }, 1e3);
1366
- }
1367
- // Returns access token
1368
- async getAccessToken(t = "") {
1369
- const n = getTimestamp(), s = await this.Storage.getGrant(t, this.multiAccount);
1370
- if (!s)
1371
- return null;
1372
- const { access_token: a, expires_in: l } = s, d = a;
1373
- return d && l && l > getTimestamp() && l - n > 30 ? d : (await this.tokenExchange(t), (await this.Storage.getGrant(t, this.multiAccount)).access_token);
1374
- }
1375
- async sse(t, n) {
1376
- const s = n.headers || {}, a = s["Grant-ID"];
1377
- let l = "";
1378
- if (this.multiAccount) {
1379
- if (!a)
1380
- throw this.logout(), new Error("Grant ID is required for multi account calls");
1381
- l = await this.getAccessToken(a);
1382
- } else
1383
- l = await this.getAccessToken();
1384
- return delete s["Grant-ID"], s.Authorization = `Bearer ${l}`, s["content-type"] || (s["content-type"] = "application/json"), fetchEventSource(`${this.domain}/${t}`, {
1385
- ...n,
1386
- headers: s
1387
- });
1388
- }
1389
- // Used to call Nylas API endpoints
1390
- async fetch(t, n, s = !0, a) {
1391
- let l = "", d = 1;
1392
- if (this.multiAccount) {
1393
- if (!n.grant_id)
1394
- throw this.logout(), new Error("Grant ID is required for multi account calls");
1395
- const u = await this.getProfiles();
1396
- d = u ? u.length : 1, l = await this.getAccessToken(n.grant_id);
1397
- } else
1398
- l = await this.getAccessToken();
1399
- if (!l)
1400
- throw new Error("Access token not found");
1401
- let c = n.headers;
1402
- Headers.prototype.isPrototypeOf(c) ? (c.append("Authorization", `Bearer ${l}`), c.has("content-type") || c.append("content-type", "application/json")) : c = new Headers({
1403
- Authorization: `Bearer ${l}`,
1404
- "content-type": "application/json"
1405
- });
1406
- try {
1407
- n != null && n.body && (n.body = JSON.stringify(n == null ? void 0 : n.body));
1408
- const u = await fetch(`${a || this.domain}/${t}`, {
1409
- ...n,
1410
- headers: c
1411
- });
1412
- if (!s)
1413
- return u;
1414
- const f = await (u == null ? void 0 : u.json());
1415
- if (!await this.isAuthenticatedResponse(u.status, f)) {
1416
- if (d > 1) {
1417
- const p = await this.getProfile(n.grant_id);
1418
- if (p) {
1419
- p.status = "unauthorized", await this.Storage.setUserToken(p);
1420
- const m = {
1421
- detail: { user: p }
1422
- };
1423
- window.dispatchEvent(new CustomEvent("onSessionExpired", m));
1424
- }
1425
- } else {
1426
- const m = {
1427
- detail: { user: await this.Storage.getUserToken() }
1428
- };
1429
- window.dispatchEvent(new CustomEvent("onSessionExpired", m));
1430
- }
1431
- this.logout();
1432
- return;
1433
- }
1434
- return f;
1435
- } catch (u) {
1436
- throw u;
1437
- }
1438
- }
1439
- async fetchRequest(t, n, s, a = !0, l, d) {
1440
- const c = await this.isLoggedIn(), u = new URL(t, l ?? this.domain), f = new Headers();
1441
- if (f.append("Accept", "application/json"), f.append("Content-Type", "application/json"), f.append("User-Agent", "nylas-identity"), c) {
1442
- const m = await this.getAccessToken();
1443
- f.append("Authorization", `Bearer ${m}`);
1444
- }
1445
- const g = await fetch(u.toString(), {
1446
- method: n || "GET",
1447
- headers: f,
1448
- mode: "cors",
1449
- referrer: location.origin,
1450
- body: s ? JSON.stringify(s) : void 0,
1451
- ...d || {}
1452
- });
1453
- return a ? await g.json() : g.body;
1454
- }
1455
- // Checks if the response is not 401
1456
- async isAuthenticatedResponse(t, n) {
1457
- var s;
1458
- return !(t == 401 && ((s = n == null ? void 0 : n.error) == null ? void 0 : s.type) == "token.unauthorized_access");
1459
- }
1460
- addAPIKey(t, n, s) {
1461
- this.Storage.setUserToken({
1462
- aud: "https://api-staging.us.nylas.com/",
1463
- exp: 2e9,
1464
- email_verified: !0,
1465
- iat: getTimestamp(),
1466
- iss: "",
1467
- email: n,
1468
- provider: "virtual-calendar",
1469
- status: "authenticated",
1470
- name: n,
1471
- sub: t
1472
- }), this.Storage.setGrant({
1473
- grant_id: t,
1474
- access_token: s,
1475
- expires_in: 2e9
1476
- }, this.multiAccount);
1477
- }
1478
- }
1479
- var B = { isMounted: function() {
1480
- return !1;
1481
- }, enqueueForceUpdate: function() {
1482
- }, enqueueReplaceState: function() {
1483
- }, enqueueSetState: function() {
1484
- } }, C = Object.assign, D = {};
1485
- function E(r, t, n) {
1486
- this.props = r, this.context = t, this.refs = D, this.updater = n || B;
1487
- }
1488
- E.prototype.isReactComponent = {};
1489
- E.prototype.setState = function(r, t) {
1490
- if (typeof r != "object" && typeof r != "function" && r != null)
1491
- throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
1492
- this.updater.enqueueSetState(this, r, t, "setState");
1493
- };
1494
- E.prototype.forceUpdate = function(r) {
1495
- this.updater.enqueueForceUpdate(this, r, "forceUpdate");
1496
- };
1497
- function F() {
1498
- }
1499
- F.prototype = E.prototype;
1500
- function G(r, t, n) {
1501
- this.props = r, this.context = t, this.refs = D, this.updater = n || B;
1502
- }
1503
- var H = G.prototype = new F();
1504
- H.constructor = G;
1505
- C(H, E.prototype);
1506
- H.isPureReactComponent = !0;
1507
- const LoginRequired = ({ authenticationUrl: r }) => h(
1508
- "div",
1509
- { class: "login-required", part: "nse__login-required login-component" },
1510
- h(
1511
- "div",
1512
- { class: "card", part: "nse__login-required-card" },
1513
- h("p", { part: "nse__login-required-text" }, "Log into your account to use the Scheduler Editor."),
1514
- h(
1515
- "button",
1516
- { class: "google-button", part: "nse__login-required-google-button", onClick: async (t) => {
1517
- t.preventDefault();
1518
- const n = await r("google");
1519
- n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1520
- } },
1521
- h(
1522
- "span",
1523
- { class: "icon" },
1524
- h("google-logo-icon", { width: "15", height: "15" })
1525
- ),
1526
- "Continue with Google"
1527
- ),
1528
- h(
1529
- "button",
1530
- { class: "microsoft-button", part: "nse__login-required-microsoft-button", onClick: async (t) => {
1531
- t.preventDefault();
1532
- const n = await r("microsoft");
1533
- n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1534
- } },
1535
- h(
1536
- "span",
1537
- { class: "icon" },
1538
- h("microsoft-logo-icon", { width: "15", height: "15" })
1539
- ),
1540
- "Continue with Microsoft"
1541
- ),
1542
- h(
1543
- "button",
1544
- { class: "other-provider-button", part: "nse__login-required-other-provider-button", onClick: async (t) => {
1545
- t.preventDefault();
1546
- const n = await r();
1547
- n ? window.location.href = n : console.error("[nylas-scheduler-editor] Unable to get authentication URL.");
1548
- } },
1549
- "View all providers ",
1550
- h("chevron-icon", { width: "17", height: "17" })
1551
- ),
1552
- h("small", { class: "disclaimer-text", part: "nse__login-required-disclaimer-text" }, "* You will be redirected to authenticate your account.")
1553
- )
1554
- );
1555
- function ExpressFlow({ currentUser: r, calendars: t, selectedEventType: n }) {
1556
- const s = (t == null ? void 0 : t.find((a) => a.is_primary)) || (t == null ? void 0 : t[0]);
1557
- switch (n) {
1558
- case CONFIGURATION_EVENT_TYPE.one_on_one:
1559
- case CONFIGURATION_EVENT_TYPE.max_availability:
1560
- case CONFIGURATION_EVENT_TYPE.max_fairness:
1561
- return h(
1562
- Fragment,
1563
- null,
1564
- h(
1565
- "nylas-event-info",
1566
- null,
1567
- h(
1568
- "div",
1569
- { slot: "inputs" },
1570
- h("nylas-event-title", null),
1571
- h("nylas-event-duration", null),
1572
- h("nylas-event-location", { userProvider: r.provider })
1573
- )
1574
- ),
1575
- h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
1576
- h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
1577
- );
1578
- case CONFIGURATION_EVENT_TYPE.collective:
1579
- return h(
1580
- Fragment,
1581
- null,
1582
- h(
1583
- "nylas-event-info",
1584
- null,
1585
- h(
1586
- "div",
1587
- { slot: "inputs" },
1588
- h("nylas-event-title", null),
1589
- h("nylas-event-duration", null),
1590
- h("nylas-event-location", { userProvider: r.provider })
1591
- )
1592
- ),
1593
- h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
1594
- h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" }),
1595
- h("nylas-additional-participants", { name: "participants", eventParticipants: [{ name: (r == null ? void 0 : r.name) || (r == null ? void 0 : r.email), email: (r == null ? void 0 : r.email) || "", is_organizer: !0 }], exportparts: "nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant" })
1596
- );
1597
- case CONFIGURATION_EVENT_TYPE.group:
1598
- return h(
1599
- Fragment,
1600
- null,
1601
- h(
1602
- "nylas-event-info",
1603
- null,
1604
- h(
1605
- "div",
1606
- { slot: "inputs" },
1607
- h("nylas-event-title", { noTemplates: !0 }),
1608
- h("nylas-event-description", { noTemplates: !0, hideAutoPopulateButton: !0 }),
1609
- h("nylas-event-location", { userProvider: r.provider }),
1610
- h("nylas-event-timeslot", { name: "event-timeslot" }),
1611
- h("nylas-event-capacity", null)
1612
- )
1613
- ),
1614
- h("nylas-booking-calendar-picker", { exportparts: "nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content", expressFlow: !0, calendars: t, currentUser: r, defaultBookingCalendar: s == null ? void 0 : s.id }),
1615
- h("nylas-additional-participants", { name: "participants", eventParticipants: [{ name: (r == null ? void 0 : r.name) || (r == null ? void 0 : r.email), email: (r == null ? void 0 : r.email) || "", is_organizer: !0 }], exportparts: "nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant" }),
1616
- h("nylas-page-name", { requirePageName: !0, pageName: "Group events page" }),
1617
- h("nylas-custom-event-slug", { name: "custom-event-slug", exportparts: "nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield" })
1618
- );
1619
- }
1620
- }
1621
- const nylasSchedulerEditorCss = ':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff}@media screen and (max-width: 768px){:host{width:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}:host nylas-notification{position:absolute;top:0;right:0}div.scheduler-editor-content{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}div.scheduler-editor-content slot[name=login-required]{height:inherit}div.scheduler-editor-content--group{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content--group{height:auto}}div.scheduler-editor-header{display:grid;grid-template-columns:1fr auto auto;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900);min-width:924px}@media screen and (max-width: 768px){div.scheduler-editor-header{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;margin:0;font-size:18px;line-height:24px;font-weight:600}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer;color:var(--nylas-base-900)}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary);background-color:transparent}div.scheduler-editor-header button:disabled{cursor:not-allowed}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button){border:none;padding:4px;margin-right:8px}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button):hover{outline:none;color:var(--nylas-primary)}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){min-width:132px}@media screen and (max-width: 768px){div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){width:-webkit-fill-available;width:fill-available;width:-moz-available}}nylas-select-event-type{height:inherit;width:calc(924px + 2rem)}@media screen and (max-width: 768px){nylas-select-event-type{width:auto}}nylas-editor-tabs,nylas-editor-tabs-group{width:auto;height:inherit}nylas-editor-tabs .row,nylas-editor-tabs-group .row{display:flex;gap:1rem}nylas-editor-tabs .composable,nylas-editor-tabs-group .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs],nylas-editor-tabs-group nylas-event-info div[slot=inputs],nylas-editor-tabs-group nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;color:var(--nylas-base-900);max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center;color:var(--nylas-base-900)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center;color:var(--nylas-base-900)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto;padding:2rem 1rem}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}', NylasSchedulerEditorStyle0 = nylasSchedulerEditorCss, NylasSchedulerEditor = class {
1622
- constructor(r) {
1623
- registerInstance(this, r), this.init = createEvent(this, "init", 7), this.loggedIn = createEvent(this, "loggedIn", 7), this.loggedOut = createEvent(this, "loggedOut", 7), this.schedulerConfigCloseClicked = createEvent(this, "schedulerConfigCloseClicked", 7), this.handleSchedulerConfigCloseClicked = (t) => {
1624
- const n = this.schedulerConfigCloseClicked.emit(this.host);
1625
- "schedulerConfigCloseClicked" in this.eventOverrides && this.eventOverrides.schedulerConfigCloseClicked(n, this.nylasSchedulerConfigConnector), n.defaultPrevented || (localStorage.removeItem("grant"), localStorage.removeItem("user"), window.location.reload());
1626
- }, this.authenticationUrl = async (t) => this.nylasApiRequest ? await this.nylasApiRequest.authenticationUrl({ provider: t }) || "" : (console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."), ""), this.configurationId = void 0, this.nylasApiRequest = void 0, this.nylasSessionsConfig = void 0, this.defaultAuthArgs = void 0, this.eventOverrides = {}, this.schedulerPreviewLink = "", this.defaultSchedulerConfigState = void 0, this.mode = "app", this.additionalParticipants = void 0, this.hideEditorTabs = [], this.conferenceProviders = void 0, this.requiresSlug = !1, this.enableUserFeedback = !0, this.defaultLanguage = void 0, this.localization = void 0, this.nylasBranding = !0, this.experimentalFeatures = void 0, this.enableEventTypes = {
1627
- one_on_one: !0,
1628
- collective: !0,
1629
- max_fairness: !0,
1630
- max_availability: !0,
1631
- group: !0
1632
- }, this.themeConfig = void 0, this.automaticComponentRegistration = !0, this.selectedLanguage = this.defaultLanguage || LANGUAGE_CODE.en, this.langVersion = 0, this.version = "2.0.6";
1633
- }
1634
- connectedCallback() {
1635
- debug("[nylas-scheduler-editor] connectedCallback");
1636
- }
1637
- async componentWillLoad() {
1638
- var s, a, l, d, c, u, f, g;
1639
- debug("[nylas-scheduler-editor] componentWillLoad");
1640
- const r = (s = this.additionalParticipants) == null ? void 0 : s.filter((p) => {
1641
- var y;
1642
- const m = ((y = p.calendars) == null ? void 0 : y.length) > 0 ? p.calendars.filter((w) => w.id && w.name) : [];
1643
- if (p.name && p.email && m.length > 0)
1644
- return {
1645
- name: p.name,
1646
- email: p.email,
1647
- calendars: m
1648
- };
1649
- });
1650
- if (this.stores = {
1651
- schedulerConfig: CreateNylasSchedulerConfigStore({
1652
- ...this.defaultSchedulerConfigState,
1653
- additionalParticipants: r,
1654
- conferenceProviders: this.conferenceProviders,
1655
- requiresSlug: this.requiresSlug,
1656
- selectedLanguage: this.defaultLanguage || LANGUAGE_CODE.en,
1657
- nylasBranding: this.nylasBranding,
1658
- experimentalFeatures: this.experimentalFeatures,
1659
- enableEventTypes: this.enableEventTypes,
1660
- themeConfig: this.themeConfig
1661
- })
1662
- }, !this.nylasApiRequest && this.nylasSessionsConfig) {
1663
- const p = new NylasSessions(this.nylasSessionsConfig);
1664
- await p.isLoggedIn(), p.onLoginSuccess(async () => {
1665
- var y, w;
1666
- const m = await ((w = (y = this.nylasSchedulerConfigConnector) == null ? void 0 : y.schedulerConfig) == null ? void 0 : w.currentUser());
1667
- if (m) {
1668
- const _ = this.loggedIn.emit(this.host);
1669
- "loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(_, this.nylasSchedulerConfigConnector), _.defaultPrevented || await this.loggedInHandler(m);
1670
- }
1671
- }), p.onLoginFail(async () => {
1672
- var y, w;
1673
- (w = (y = this.stores) == null ? void 0 : y.schedulerConfig) == null || w.set("currentUser", null);
1674
- const m = this.loggedOut.emit(this.host);
1675
- "loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented);
1676
- }), this.nylasApiRequest = new NylasIdentityRequestWrapper(p);
1677
- }
1678
- this.nylasApiRequest && this.defaultAuthArgs && this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs), this.baseProvider = new NylasBaseProvider(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides);
1679
- const t = this.baseProvider.getStore("schedulerConfig");
1680
- this.nylasSchedulerConfigConnector = new NylasSchedulerConfigConnector({
1681
- nylasApiRequest: this.nylasApiRequest,
1682
- nylasSchedulerConfigStore: t
1683
- });
1684
- const n = this.init.emit(this.host);
1685
- if ("init" in this.eventOverrides && await this.eventOverrides.init(n, this.nylasSchedulerConfigConnector), !n.defaultPrevented) {
1686
- const p = await ((l = (a = this.nylasSchedulerConfigConnector) == null ? void 0 : a.schedulerConfig) == null ? void 0 : l.currentUser());
1687
- if (p) {
1688
- const m = this.loggedIn.emit(this.host);
1689
- "loggedIn" in this.eventOverrides && await this.eventOverrides.loggedIn(m, this.nylasSchedulerConfigConnector), m.defaultPrevented || await this.loggedInHandler(p);
1690
- } else {
1691
- (c = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || c.set("currentUser", null);
1692
- const m = this.loggedOut.emit(this.host);
1693
- if ("loggedOut" in this.eventOverrides && (await this.eventOverrides.loggedOut(m, this.nylasSchedulerConfigConnector), m.defaultPrevented))
1694
- return;
1695
- }
1696
- }
1697
- (f = (u = this.stores) == null ? void 0 : u.schedulerConfig) == null || f.onChange("selectedConfiguration", async (p) => {
1698
- p && p.id && (this.configurationId = p.id);
1699
- }), (g = this.baseProvider) == null || g.componentWillLoad(this.nylasSchedulerConfigConnector), this.applyThemeConfig(this.themeConfig);
1700
- }
1701
- async componentDidLoad() {
1702
- var r;
1703
- debug("[nylas-scheduler-editor] componentDidLoad"), await ((r = this.baseProvider) == null ? void 0 : r.componentDidLoad()), this.updateLocalization(this.localization), this.version = "2.0.6";
1704
- }
1705
- async componentDisconnected() {
1706
- var r;
1707
- await ((r = this.baseProvider) == null ? void 0 : r.componentDisconnected());
1708
- }
1709
- async configurationIdChanged(r) {
1710
- var t, n, s, a, l, d, c, u;
1711
- r ? (await ((n = (t = this.nylasSchedulerConfigConnector) == null ? void 0 : t.schedulerConfig) == null ? void 0 : n.getConfigurationById(r)), (a = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || a.set("action", "edit")) : ((d = (l = this.stores) == null ? void 0 : l.schedulerConfig) == null || d.set("selectedConfiguration", {}), (u = (c = this.stores) == null ? void 0 : c.schedulerConfig) == null || u.set("action", null));
1712
- }
1713
- updateLocalization(r) {
1714
- r && (Object.keys(r).forEach((t) => {
1715
- t in LANGUAGE_CODE && instance.addResourceBundle(t, "translation", r[t], !1, !0);
1716
- }), this.langVersion++);
1717
- }
1718
- updateNylasBranding(r) {
1719
- var t, n;
1720
- (n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("nylasBranding", r);
1721
- }
1722
- updateExperimentalFeatures(r) {
1723
- var t, n;
1724
- (n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("experimentalFeatures", r);
1725
- }
1726
- updateEnableEventTypes(r) {
1727
- var t, n;
1728
- (n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("enableEventTypes", r);
1729
- }
1730
- themeConfigChanged(r) {
1731
- var t, n;
1732
- (n = (t = this.baseProvider) == null ? void 0 : t.getStore("schedulerConfig")) == null || n.set("themeConfig", r), this.applyThemeConfig(r);
1733
- }
1734
- applyThemeConfig(r) {
1735
- if (r)
1736
- for (const [t, n] of Object.entries(r))
1737
- this.host.style.setProperty(`${t}`, n);
1738
- }
1739
- async store() {
1740
- var r;
1741
- return (r = this.stores) == null ? void 0 : r.schedulerConfig;
1742
- }
1743
- async schedulerConnector() {
1744
- return this.nylasSchedulerConfigConnector;
1745
- }
1746
- async registerComponentHandler(r) {
1747
- var t;
1748
- (t = this.baseProvider) == null || t.registerComponent(r.detail);
1749
- }
1750
- async unregisterComponentHandler(r) {
1751
- var t;
1752
- (t = this.baseProvider) == null || t.unregisterComponent(r.detail);
1753
- }
1754
- nylasFormDropdownChangedHandler(r) {
1755
- var s, a;
1756
- const { name: t, value: n } = r.detail;
1757
- t === "language" && (this.selectedLanguage = LANGUAGE_CODE[n], instance.changeLanguage(this.selectedLanguage), (a = (s = this.stores) == null ? void 0 : s.schedulerConfig) == null || a.set("selectedLanguage", this.selectedLanguage));
1758
- }
1759
- async loggedInHandler(r) {
1760
- var t, n, s, a, l, d, c;
1761
- if ((n = (t = this.stores) == null ? void 0 : t.schedulerConfig) == null || n.set("currentUser", r), !!this.nylasSchedulerConfigConnector && (await ((s = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : s.getCalendars()), this.configurationId)) {
1762
- const u = await ((a = this.nylasSchedulerConfigConnector.schedulerConfig) == null ? void 0 : a.getConfigurationById(this.configurationId));
1763
- u && ((l = u[0]) != null && l.id) && ((c = (d = this.stores) == null ? void 0 : d.schedulerConfig) == null || c.set("action", "edit"));
1764
- }
1765
- }
1766
- render() {
1767
- var a, l, d, c, u, f, g, p, m, y, w, _, x, R, A, k, U, N, O, I, T, S, v, L, b, $, X, j, z, Y, M, V, J, W, Z, Q, ee, te, ne, se, re, oe, ie, ae;
1768
- const r = this.host.querySelector('[slot="custom-page-style-inputs"]'), t = (d = (l = (a = this.stores) == null ? void 0 : a.schedulerConfig) == null ? void 0 : l.state.selectedConfiguration) == null ? void 0 : d.id, n = Object.keys(LANGUAGE_MAP).map((q) => ({
1769
- label: LANGUAGE_MAP[q],
1770
- value: q
1771
- })), s = ((u = (c = this.stores) == null ? void 0 : c.schedulerConfig) == null ? void 0 : u.state.selectedEventType) === CONFIGURATION_EVENT_TYPE.group || ((p = (g = (f = this.stores) == null ? void 0 : f.schedulerConfig) == null ? void 0 : g.state.selectedConfiguration) == null ? void 0 : p.type) === CONFIGURATION_EVENT_TYPE.group;
1772
- return h(Host, { key: "8125ba9d8bbd8c1604ec4e57d769882137c7a6c5" }, h("div", { key: "51222baddda6bd200080440ac46c390b5c754734", class: "scheduler-editor-header", part: "nse__header" }, h("h1", { key: "91e8379a5068634421d8f272a5251ab578496e05", class: "scheduler-editor-title", part: "nse__title" }, h("calendar-icon", { key: "1c040d10dff4fc86d257e446c8228033b9a02032", width: "18", height: "18" }), instance.t("schedulerEditorTitle"), h("tooltip-component", { key: "1e6c30c0958fbc8dde357d03c597eb70ce35271f" }, h("info-icon", { key: "4ebd6aea27a62c33849659066860c5de75c0b7c7", slot: "tooltip-icon" }), h("span", { key: "4ddc14ba968a1d0053f5a5fb07473333186a8476", slot: "tooltip-content" }, this.version))), h("div", { key: "679bbc03e8d3e155f843ae86af0ec037ee8c2d05", class: {
1773
- language: !0
1774
- }, part: "nse__language" }, h("select-dropdown", { key: "9f788d9d39f2a190ef388cacca206374e19da11c", name: "language", searchPlaceholder: instance.t("search"), options: n, withChevron: !1, themeConfig: this.themeConfig, defaultSelectedOption: n.find((q) => q.value == this.selectedLanguage), exportparts: "sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label" }, h("span", { key: "76aa9b5b9adea974e1e8a7ac1f47faee3fc8a320", slot: "select-icon" }, h("translate-icon", { key: "9dd3b210004d04b42c3d0209db60414c6c86c54c", width: "20", height: "20" })))), h("button", { key: "fa401a8ffb5f77caae60852e7a7be15f21868002", class: "scheduler-editor-close", title: "logout", onClick: (q) => this.handleSchedulerConfigCloseClicked(q), part: "nse__close-button" }, h("close-icon", { key: "96135ba113ecdad2d3223cc8df293d46b62565e5", width: "18", height: "18" }))), h("div", { key: "48970044629cfeafd07b4ccdb34e8d3ab67e0076", class: {
1775
- "scheduler-editor-content": !0,
1776
- "scheduler-editor-content--group": s
1777
- }, part: "nse__content" }, ((y = (m = this.stores) == null ? void 0 : m.schedulerConfig) == null ? void 0 : y.state.currentUser) && this.stores.schedulerConfig.state.action === null && h("div", { class: "list-configurations", part: "nse__list-configurations" }, h("nylas-list-configurations", { exportparts: "nlc__create-new-cta, actions__dropdown, actions__dropdown-button, actions__dropdown-content, actions-Copy, actions-Preview, actions-Delete" })), ((_ = (w = this.stores) == null ? void 0 : w.schedulerConfig) == null ? void 0 : _.state.currentUser) && this.stores.schedulerConfig.state.action === "create-select" && h("nylas-select-event-type", null), ((R = (x = this.stores) == null ? void 0 : x.schedulerConfig) == null ? void 0 : R.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && s && h("nylas-editor-tabs-group", { mode: "composable" }, h(ExpressFlow, { selectedEventType: ((U = (k = (A = this.stores) == null ? void 0 : A.schedulerConfig) == null ? void 0 : k.state) == null ? void 0 : U.selectedEventType) || CONFIGURATION_EVENT_TYPE.one_on_one, currentUser: (O = (N = this.stores) == null ? void 0 : N.schedulerConfig) == null ? void 0 : O.state.currentUser, calendars: (S = (T = (I = this.stores) == null ? void 0 : I.schedulerConfig) == null ? void 0 : T.state) == null ? void 0 : S.calendars, selectedConfiguration: (b = (L = (v = this.stores) == null ? void 0 : v.schedulerConfig) == null ? void 0 : L.state) == null ? void 0 : b.selectedConfiguration })), ((X = ($ = this.stores) == null ? void 0 : $.schedulerConfig) == null ? void 0 : X.state.currentUser) && this.stores.schedulerConfig.state.action === "create" && !s && h("nylas-editor-tabs", { mode: "composable" }, h(ExpressFlow, { selectedEventType: ((Y = (z = (j = this.stores) == null ? void 0 : j.schedulerConfig) == null ? void 0 : z.state) == null ? void 0 : Y.selectedEventType) || CONFIGURATION_EVENT_TYPE.one_on_one, currentUser: (V = (M = this.stores) == null ? void 0 : M.schedulerConfig) == null ? void 0 : V.state.currentUser, calendars: (Z = (W = (J = this.stores) == null ? void 0 : J.schedulerConfig) == null ? void 0 : W.state) == null ? void 0 : Z.calendars, selectedConfiguration: (te = (ee = (Q = this.stores) == null ? void 0 : Q.schedulerConfig) == null ? void 0 : ee.state) == null ? void 0 : te.selectedConfiguration })), ((se = (ne = this.stores) == null ? void 0 : ne.schedulerConfig) == null ? void 0 : se.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && s && h("nylas-editor-tabs-group", { key: t, mode: this.mode }, this.mode === "composable" && h("slot", null), this.mode === "app" && r && h("div", { style: { display: "none" }, slot: "custom-page-style-inputs", key: t }, h("slot", { name: "custom-page-style-inputs" }))), ((oe = (re = this.stores) == null ? void 0 : re.schedulerConfig) == null ? void 0 : oe.state.currentUser) && this.stores.schedulerConfig.state.action === "edit" && !s && h("nylas-editor-tabs", { key: t, mode: this.mode }, this.mode === "composable" && h("slot", null), this.mode === "app" && r && h("div", { style: { display: "none" }, slot: "custom-page-style-inputs", key: t }, h("slot", { name: "custom-page-style-inputs" }))), !((ae = (ie = this.stores) == null ? void 0 : ie.schedulerConfig) != null && ae.state.currentUser) && h("slot", { name: "login-required" }, h(LoginRequired, { authenticationUrl: this.authenticationUrl }))));
1778
- }
1779
- get host() {
1780
- return getElement(this);
1781
- }
1782
- static get watchers() {
1783
- return {
1784
- configurationId: ["configurationIdChanged"],
1785
- localization: ["updateLocalization"],
1786
- nylasBranding: ["updateNylasBranding"],
1787
- experimentalFeatures: ["updateExperimentalFeatures"],
1788
- enableEventTypes: ["updateEnableEventTypes"],
1789
- themeConfig: ["themeConfigChanged"]
1790
- };
1791
- }
1792
- };
1793
- NylasSchedulerEditor.style = NylasSchedulerEditorStyle0;
1794
- export {
1795
- NylasSchedulerEditor as nylas_scheduler_editor
1796
- };