@nylas/react 1.0.2-canary.2 → 1.1.0-canary.10

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 (145) hide show
  1. package/dist/add-circle-icon_21.entry-125b87a0.js +1719 -0
  2. package/dist/add-circle-icon_21.entry-1a699a29.cjs +1 -0
  3. package/dist/{archive-icon_7.entry-0e34d6e7.js → archive-icon_7.entry-70efea56.js} +13 -13
  4. package/dist/{archive-icon_7.entry-052ac074.cjs → archive-icon_7.entry-a69d3d98.cjs} +1 -1
  5. package/dist/{arrow-icon.entry-93f21385.cjs → arrow-icon.entry-0a07d7cc.cjs} +1 -1
  6. package/dist/{arrow-icon.entry-2afd9ea9.js → arrow-icon.entry-c9230436.js} +1 -1
  7. package/dist/{bold-icon_3.entry-88ce1d25.js → bold-icon_3.entry-54ff7799.js} +7 -7
  8. package/dist/bold-icon_3.entry-f7df4331.cjs +1 -0
  9. package/dist/{calendar-cancel-icon.entry-574c8aa4.cjs → calendar-cancel-icon.entry-71cc68e2.cjs} +1 -1
  10. package/dist/{calendar-cancel-icon.entry-e9c692fa.js → calendar-cancel-icon.entry-e5157332.js} +1 -1
  11. package/dist/{calendar-check-icon_2.entry-b0476bca.cjs → calendar-check-icon_2.entry-f02bf0fe.cjs} +1 -1
  12. package/dist/{calendar-check-icon_2.entry-d461c713.js → calendar-check-icon_2.entry-f75ef95e.js} +1 -1
  13. package/dist/{calendar-icon.entry-1ca202a4.js → calendar-icon.entry-67aa69f5.js} +1 -1
  14. package/dist/{calendar-icon.entry-98936e6d.cjs → calendar-icon.entry-a164e957.cjs} +1 -1
  15. package/dist/chevron-icon_3.entry-7687ca7a.cjs +1 -0
  16. package/dist/chevron-icon_3.entry-81c68946.js +117 -0
  17. package/dist/{close-icon.entry-8d6e9816.cjs → close-icon.entry-147b4d47.cjs} +1 -1
  18. package/dist/{close-icon.entry-37e8361f.js → close-icon.entry-3325a08e.js} +1 -1
  19. package/dist/{constants-b6bf6671-49a0f1f2.js → constants-f34b9c6e-21ac1910.js} +11 -2
  20. package/dist/{constants-b6bf6671-27e2557d.cjs → constants-f34b9c6e-99030371.cjs} +2 -2
  21. package/dist/{document-refresh-icon.entry-faea08ce.js → document-refresh-icon.entry-1b076630.js} +1 -1
  22. package/dist/{document-refresh-icon.entry-fcb33921.cjs → document-refresh-icon.entry-dea23e07.cjs} +1 -1
  23. package/dist/elements/index.d.ts +8 -0
  24. package/dist/{elements-dc5b338e-81a0319c.cjs → elements-dc5b338e-83c23e9b.cjs} +1 -1
  25. package/dist/{elements-dc5b338e-fb5dbfb5.js → elements-dc5b338e-c69d1f8a.js} +1 -1
  26. package/dist/focus-visible-e8093c16-3082af2c.cjs +1 -0
  27. package/dist/{focus-visible-e8093c16-28fc08a0.js → focus-visible-e8093c16-a6aff071.js} +5 -3
  28. package/dist/{forward-icon_6.entry-8da1f65d.js → forward-icon_6.entry-55fce1ca.js} +9 -11
  29. package/dist/forward-icon_6.entry-59c7a975.cjs +3 -0
  30. package/dist/{globe-icon.entry-4720304b.js → globe-icon.entry-25145785.js} +1 -1
  31. package/dist/{globe-icon.entry-90a0b9c9.cjs → globe-icon.entry-904f180f.cjs} +1 -1
  32. package/dist/google-logo-icon_4.entry-1f7b9522.js +387 -0
  33. package/dist/google-logo-icon_4.entry-feb7a561.cjs +1 -0
  34. package/dist/index-5f0940e0.cjs +37 -0
  35. package/dist/index-fd39ea9d.js +4042 -0
  36. package/dist/index.d.ts +4 -2
  37. package/dist/index.es-be19d2df-9ba9a7a6.cjs +7 -0
  38. package/dist/{index-10914bc1-346f04fa.js → index.es-be19d2df-ff4f0a10.js} +945 -1041
  39. package/dist/{info-icon_2.entry-9307db18.js → info-icon_2.entry-0e2105da.js} +3 -3
  40. package/dist/{info-icon_2.entry-81e95048.cjs → info-icon_2.entry-808e6516.cjs} +1 -1
  41. package/dist/loading-icon.entry-17efa7ca.cjs +1 -0
  42. package/dist/loading-icon.entry-a3b845bf.js +15 -0
  43. package/dist/{mailbox-store-e721b17c-cf9a43dd.js → mailbox-store-76540d24-5f0d1dff.js} +121 -59
  44. package/dist/mailbox-store-76540d24-ad0e366a.cjs +1 -0
  45. package/dist/{nylas-additional-participants.entry-1653dec7.js → nylas-additional-participants.entry-4120ea2e.js} +13 -15
  46. package/dist/nylas-additional-participants.entry-7e2446cb.cjs +1 -0
  47. package/dist/nylas-booked-event-card_10.entry-44812e35.cjs +1 -0
  48. package/dist/{nylas-booked-event-card_10.entry-aa971e8a.js → nylas-booked-event-card_10.entry-5e87b199.js} +294 -273
  49. package/dist/nylas-custom-booking-flow.entry-cbff44c8.js +106 -0
  50. package/dist/nylas-custom-booking-flow.entry-da5e66bb.cjs +1 -0
  51. package/dist/{nylas-form-card.entry-c4e78f88.js → nylas-form-card.entry-1c608edd.js} +13 -15
  52. package/dist/nylas-form-card.entry-2e629e36.cjs +1 -0
  53. package/dist/nylas-if-state.entry-2c0d8724.js +94 -0
  54. package/dist/nylas-if-state.entry-61771f3d.cjs +1 -0
  55. package/dist/{nylas-list-folders.entry-995fa819.js → nylas-list-folders.entry-d6e085b0.js} +6 -8
  56. package/dist/nylas-list-folders.entry-fa8e8ce9.cjs +1 -0
  57. package/dist/{nylas-list-threads.entry-21466eb3.js → nylas-list-threads.entry-4dd2de0a.js} +5 -7
  58. package/dist/nylas-list-threads.entry-99fc0baa.cjs +1 -0
  59. package/dist/nylas-login.entry-0ec0813c.cjs +1 -0
  60. package/dist/nylas-login.entry-6730e226.js +73 -0
  61. package/dist/{nylas-mailbox-pagination.entry-02d40186.js → nylas-mailbox-pagination.entry-5310880c.js} +7 -9
  62. package/dist/nylas-mailbox-pagination.entry-e3e52f42.cjs +1 -0
  63. package/dist/{nylas-mailbox-toolbar-button.entry-dbad44b4.js → nylas-mailbox-toolbar-button.entry-028075db.js} +15 -17
  64. package/dist/nylas-mailbox-toolbar-button.entry-4c377337.cjs +1 -0
  65. package/dist/nylas-mailbox.entry-87304850.cjs +1 -0
  66. package/dist/nylas-mailbox.entry-ab92780c.js +134 -0
  67. package/dist/nylas-provider.entry-3fb60fe4.cjs +1 -0
  68. package/dist/{nylas-provider.entry-bbee8c99.js → nylas-provider.entry-678a9fe7.js} +48 -58
  69. package/dist/nylas-scheduler-editor.entry-a0de0ae6.js +2269 -0
  70. package/dist/nylas-scheduler-editor.entry-cf19391e.cjs +7 -0
  71. package/dist/nylas-scheduling.entry-d8bb2648.cjs +1 -0
  72. package/dist/nylas-scheduling.entry-e38c3870.js +248 -0
  73. package/dist/nylas-threads-refresh.entry-79c8a061.cjs +1 -0
  74. package/dist/{nylas-threads-refresh.entry-414d8740.js → nylas-threads-refresh.entry-fcb2175f.js} +2 -4
  75. package/dist/{nylas-threads-search.entry-a19dc90f.js → nylas-threads-search.entry-7565bdf8.js} +13 -15
  76. package/dist/nylas-threads-search.entry-f2d5d0fb.cjs +1 -0
  77. package/dist/{nylas-view-thread.entry-38149162.js → nylas-view-thread.entry-1772e0c4.js} +10 -12
  78. package/dist/nylas-view-thread.entry-6a2ccece.cjs +1 -0
  79. package/dist/{people-icon.entry-4b682757.cjs → people-icon.entry-3218a267.cjs} +1 -1
  80. package/dist/{people-icon.entry-5c244c8d.js → people-icon.entry-bc2c70cf.js} +5 -5
  81. package/dist/play-icon_2.entry-450a7fa6.cjs +1 -0
  82. package/dist/play-icon_2.entry-b4dc4e6d.js +25 -0
  83. package/dist/react.cjs +1 -1
  84. package/dist/react.js +88 -78
  85. package/dist/{refresh-icon.entry-59fff3d4.cjs → refresh-icon.entry-030dda82.cjs} +1 -1
  86. package/dist/{refresh-icon.entry-63456c9a.js → refresh-icon.entry-d30c7264.js} +5 -5
  87. package/dist/register-component-83e24412-0b25de7f.cjs +1 -0
  88. package/dist/{register-component-d056a880-f3003d6c.js → register-component-83e24412-35c484c4.js} +37 -33
  89. package/dist/scheduler-config-store-ec3b6190-6d8cef0f.cjs +1 -0
  90. package/dist/scheduler-config-store-ec3b6190-d5edbae5.js +23 -0
  91. package/dist/scheduler-store-8ca9003d-38cca5ba.js +321 -0
  92. package/dist/scheduler-store-8ca9003d-c2aa3522.cjs +1 -0
  93. package/dist/time-period-selector.entry-b366ba86.js +76 -0
  94. package/dist/time-period-selector.entry-b3d04e93.cjs +1 -0
  95. package/dist/{translate-icon.entry-1784c18e.cjs → translate-icon.entry-03ab2513.cjs} +1 -1
  96. package/dist/{translate-icon.entry-35999e70.js → translate-icon.entry-b3c21ae9.js} +5 -5
  97. package/dist/warning-icon.entry-602d459b.js +15 -0
  98. package/dist/{warning-icon.entry-3a702d1d.cjs → warning-icon.entry-65ecfdf0.cjs} +1 -1
  99. package/package.json +3 -3
  100. package/dist/_commonjsHelpers-57e89916-4a3ae7d8.cjs +0 -1
  101. package/dist/_commonjsHelpers-57e89916-af061c86.js +0 -19
  102. package/dist/add-circle-icon_18.entry-b66b6343.cjs +0 -1
  103. package/dist/add-circle-icon_18.entry-f86ae88d.js +0 -1527
  104. package/dist/auth-store-69ac49c7-5a0bbb90.cjs +0 -1
  105. package/dist/auth-store-69ac49c7-cbfda055.js +0 -66
  106. package/dist/bold-icon_3.entry-8f55a9e7.cjs +0 -1
  107. package/dist/chevron-icon_3.entry-830f52c2.js +0 -105
  108. package/dist/chevron-icon_3.entry-f7801467.cjs +0 -1
  109. package/dist/focus-visible-e8093c16-f380b705.cjs +0 -1
  110. package/dist/forward-icon_6.entry-c4b37cb1.cjs +0 -3
  111. package/dist/index-10914bc1-c8c3a2f3.cjs +0 -7
  112. package/dist/index-457dcf0b.cjs +0 -30
  113. package/dist/index-ce40ad47.js +0 -1570
  114. package/dist/loading-icon.entry-06d37ef0.cjs +0 -1
  115. package/dist/loading-icon.entry-dc518df4.js +0 -15
  116. package/dist/mailbox-store-e721b17c-4e97e07d.cjs +0 -1
  117. package/dist/nylas-additional-participants.entry-ff8bf378.cjs +0 -1
  118. package/dist/nylas-booked-event-card_10.entry-06bc3c51.cjs +0 -1
  119. package/dist/nylas-editor-tabs.entry-49b5a3ab.cjs +0 -1
  120. package/dist/nylas-editor-tabs.entry-9d0959bf.js +0 -181
  121. package/dist/nylas-form-card.entry-69d2095b.cjs +0 -1
  122. package/dist/nylas-if-state_3.entry-2eb3f385.js +0 -293
  123. package/dist/nylas-if-state_3.entry-5baf6d6f.cjs +0 -1
  124. package/dist/nylas-list-folders.entry-3b24d92d.cjs +0 -1
  125. package/dist/nylas-list-threads.entry-fda42ded.cjs +0 -1
  126. package/dist/nylas-mailbox-pagination.entry-9dcd4901.cjs +0 -1
  127. package/dist/nylas-mailbox-toolbar-button.entry-d1099fab.cjs +0 -1
  128. package/dist/nylas-provider.entry-78e2fa30.cjs +0 -1
  129. package/dist/nylas-scheduler-editor.entry-550d3c59.cjs +0 -1
  130. package/dist/nylas-scheduler-editor.entry-8f7ecf3b.js +0 -111
  131. package/dist/nylas-scheduling.entry-22b5ad07.js +0 -236
  132. package/dist/nylas-scheduling.entry-30a63738.cjs +0 -1
  133. package/dist/nylas-threads-refresh.entry-05258b36.cjs +0 -1
  134. package/dist/nylas-threads-search.entry-ff21fc65.cjs +0 -1
  135. package/dist/nylas-view-thread.entry-5da81e99.cjs +0 -1
  136. package/dist/play-icon_2.entry-ccdc6b9c.cjs +0 -1
  137. package/dist/play-icon_2.entry-f36d6d55.js +0 -25
  138. package/dist/register-component-d056a880-2be11c56.cjs +0 -1
  139. package/dist/scheduler-config-store-4d035001-0256b40c.cjs +0 -1
  140. package/dist/scheduler-config-store-4d035001-db9dc78a.js +0 -33
  141. package/dist/scheduler-store-0fbe642c-14466305.js +0 -293
  142. package/dist/scheduler-store-0fbe642c-410fdbf4.cjs +0 -1
  143. package/dist/utils-0cd66d04-89ab163d.js +0 -2111
  144. package/dist/utils-0cd66d04-94b9c3b6.cjs +0 -8
  145. package/dist/warning-icon.entry-73de08c3.js +0 -15
@@ -1,293 +0,0 @@
1
- import { d as y } from "./utils-0cd66d04-89ab163d.js";
2
- import { c as R } from "./index-10914bc1-346f04fa.js";
3
- var S;
4
- (function(r) {
5
- r.Component = "component", r.Api = "api", r.Auth = "auth";
6
- })(S || (S = {}));
7
- var I;
8
- (function(r) {
9
- r.endtime_not_in_future = "endtime_not_in_future", r.no_booking_info = "no_booking_info", r.no_timeslot_selected = "no_timeslot_selected", r.no_booking_id = "no_booking_id", r.invalid_start_time = "invalid_start_time", r.invalid_end_time = "invalid_end_time", r.invalid_timezone = "invalid_timezone";
10
- })(I || (I = {}));
11
- var P;
12
- (function(r) {
13
- r.invalid_session = "invalid_session", r.general_error = "general_error", r.internal_error = "internal_error", r.invalid_request_error = "invalid_request_error", r.timeslot_not_available = "timeslot_not_available";
14
- })(P || (P = {}));
15
- class L {
16
- constructor() {
17
- this.component = (t) => {
18
- const e = S.Component, s = `${t} error`;
19
- return {
20
- endtime_not_in_future: (i = '"endtime" can not be in the future') => ({
21
- title: s,
22
- message: i,
23
- category: e
24
- }),
25
- no_booking_info: (i = "No booking info provided") => ({
26
- title: s,
27
- message: i,
28
- category: e
29
- }),
30
- no_timeslot_selected: (i = "No timeslot selected") => ({
31
- title: s,
32
- message: i,
33
- category: e
34
- }),
35
- no_booking_id: (i = "No booking id provided") => ({
36
- title: s,
37
- message: i,
38
- category: e
39
- }),
40
- invalid_start_time: (i = "Invalid start time") => ({
41
- title: s,
42
- message: i,
43
- category: e
44
- }),
45
- invalid_end_time: (i = "Invalid end time") => ({
46
- title: s,
47
- message: i,
48
- category: e
49
- }),
50
- invalid_timezone: (i = "Invalid timezone") => ({
51
- title: s,
52
- message: i,
53
- category: e
54
- })
55
- };
56
- }, this.api = (t) => {
57
- const e = S.Api, s = `${t} error`;
58
- return {
59
- invalid_session: (i) => ({
60
- title: s,
61
- message: i,
62
- category: e
63
- }),
64
- general_error: (i) => ({
65
- title: s,
66
- message: i,
67
- category: e
68
- }),
69
- internal_error: (i) => ({
70
- title: s,
71
- message: i,
72
- category: e
73
- }),
74
- invalid_request_error: (i) => ({
75
- title: s,
76
- message: i,
77
- category: e
78
- }),
79
- timeslot_not_available: (i) => ({
80
- title: s,
81
- message: i,
82
- category: e
83
- })
84
- };
85
- };
86
- }
87
- }
88
- class C {
89
- constructor({ schedulerAPIURL: t, schedulerStore: e, sessionId: s, configId: i }) {
90
- this.errors = new L(), this.schedulerStore = e, this.schedulerAPIURL = t, this.sessionId = s, this.configId = i;
91
- }
92
- getHeaders() {
93
- return this.configId ? {} : {
94
- Authorization: `Bearer ${this.sessionId}`
95
- };
96
- }
97
- async makeAPIRequest(t, e, s, i = {}) {
98
- try {
99
- const n = new URL(this.schedulerAPIURL);
100
- return n.pathname = t, await (await fetch(decodeURIComponent(n.toString()), {
101
- method: e,
102
- headers: {
103
- "Content-Type": "application/json",
104
- ...i
105
- },
106
- body: s
107
- })).json();
108
- } catch (n) {
109
- return {
110
- error: {
111
- message: n.message,
112
- title: "API request failed",
113
- type: "api"
114
- }
115
- };
116
- }
117
- }
118
- selectDate(t) {
119
- this.schedulerStore.set("selectedDate", t), this.schedulerStore.set("selectedTimeslot", null);
120
- }
121
- selectTime(t) {
122
- this.schedulerStore.set("selectedTimeslot", t);
123
- }
124
- selectTimezone(t) {
125
- this.schedulerStore.set("selectedTimezone", t);
126
- }
127
- toggleAdditionalData(t) {
128
- this.schedulerStore.set("showBookingForm", t);
129
- }
130
- setParticipantName(t) {
131
- const { bookingInfo: e } = this.schedulerStore.state;
132
- this.schedulerStore.set("bookingInfo", {
133
- ...e,
134
- primaryParticipant: {
135
- ...e == null ? void 0 : e.primaryParticipant,
136
- name: t
137
- }
138
- });
139
- }
140
- setParticipantEmail(t) {
141
- const { bookingInfo: e } = this.schedulerStore.state;
142
- this.schedulerStore.set("bookingInfo", {
143
- ...e,
144
- primaryParticipant: {
145
- ...e == null ? void 0 : e.primaryParticipant,
146
- email: t
147
- }
148
- });
149
- }
150
- async setReschedule(t) {
151
- const e = /* @__PURE__ */ new Date();
152
- this.schedulerStore.set("rescheduleBookingId", t), this.schedulerStore.set("selectedTimeslot", null), this.schedulerStore.set("eventInfo", null), this.schedulerStore.set("showBookingForm", !1);
153
- const s = new Date(e.getFullYear(), e.getMonth(), 1).getTime() / 1e3, i = new Date(e.getFullYear(), e.getMonth() + 1, 1).getTime() / 1e3, n = await this.getAvailability(s, i), a = this.schedulerStore.get("availability").find((l) => new Date(l.start_time) > /* @__PURE__ */ new Date());
154
- let h = e;
155
- return a && (h = a.start_time), this.schedulerStore.set("selectedDate", h), n;
156
- }
157
- async setCancel(t) {
158
- this.schedulerStore.set("cancelBookingId", t);
159
- }
160
- async bookTimeslot(t) {
161
- var m;
162
- this.schedulerStore.set("isLoading", !0);
163
- const { selectedTimeslot: e, bookingInfo: s } = this.schedulerStore.state;
164
- if (!t && !s)
165
- return { error: this.errors.component("Booking").no_booking_info() };
166
- const i = (t == null ? void 0 : t.timeslot) || e;
167
- if (!i)
168
- return { error: this.errors.component("Create Booking").no_timeslot_selected() };
169
- const n = t ? t == null ? void 0 : t.primaryParticipant : s == null ? void 0 : s.primaryParticipant, a = t ? (t == null ? void 0 : t.guests) || [] : (s == null ? void 0 : s.guests) || [], h = t ? { ...t == null ? void 0 : t.additionalFields, guests: a } : { ...s == null ? void 0 : s.additionalFields, guests: a }, l = this.getHeaders(), p = `/v3/scheduling/bookings${this.configId ? `?configuration_id=${this.configId}` : ""}`, d = await this.makeAPIRequest(decodeURIComponent(p), "POST", JSON.stringify({
170
- additional_fields: h,
171
- guest: { ...n },
172
- start_time: i.start_time.getTime() / 1e3,
173
- end_time: i.end_time.getTime() / 1e3
174
- }), l);
175
- if ("error" in d) {
176
- this.schedulerStore.set("isLoading", !1);
177
- const c = (m = d.error) == null ? void 0 : m.type;
178
- let o = d.error;
179
- return c && c in this.errors.api("Create Booking") && (o = this.errors.api("Create Booking")[c]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
180
- }
181
- return "data" in d && this.schedulerStore.set("eventInfo", d == null ? void 0 : d.data), this.schedulerStore.set("isLoading", !1), d;
182
- }
183
- async getAvailability(t = 0, e = 0) {
184
- var p, d, m;
185
- this.schedulerStore.set("isLoading", !0);
186
- const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), n = i.getTime();
187
- if (e && e < n / 1e3)
188
- return this.schedulerStore.set("isLoading", !1), { error: this.errors.component("Get Availability").endtime_not_in_future() };
189
- if (!t) {
190
- const c = new Date(i.getFullYear(), i.getMonth(), 1);
191
- t = Math.floor(c.getTime() / 1e3);
192
- }
193
- if (!e) {
194
- const c = new Date(i.getFullYear(), i.getMonth() + 1, 0);
195
- e = Math.floor(c.getTime() / 1e3);
196
- }
197
- s.append("start_time", encodeURIComponent(t.toString())), s.append("end_time", encodeURIComponent(e.toString())), this.configId && s.append("configuration_id", encodeURIComponent(this.configId));
198
- const a = s.toString(), h = `/v3/scheduling/availability${a ? `?${a}` : ""}`, l = this.getHeaders(), u = await this.makeAPIRequest(decodeURIComponent(h), "GET", void 0, l);
199
- if ("error" in u) {
200
- this.schedulerStore.set("availability", []), this.schedulerStore.set("isLoading", !1);
201
- const c = (p = u.error) == null ? void 0 : p.type;
202
- let o = u.error;
203
- return c && c in this.errors.api("Get Availability") && (o = this.errors.api("Get Availability")[c]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
204
- }
205
- if ("data" in u) {
206
- const o = (((m = (d = u.data) == null ? void 0 : d.time_slots) == null ? void 0 : m.map((g) => ({
207
- ...g,
208
- start_time: new Date(g.start_time * 1e3),
209
- end_time: new Date(g.end_time * 1e3)
210
- }))) || []).filter((g) => g.start_time.getTime() > n);
211
- this.schedulerStore.set("availability", o);
212
- }
213
- return this.schedulerStore.set("isLoading", !1), u;
214
- }
215
- async cancelBooking(t) {
216
- var a;
217
- if (this.schedulerStore.set("isLoading", !0), !t)
218
- return { error: this.errors.component("Cancel Booking").no_booking_id() };
219
- const e = this.configId ? `?configuration_id=${this.configId}` : "", s = `/v3/scheduling/bookings/${t}${e}`, i = this.getHeaders(), n = await this.makeAPIRequest(decodeURIComponent(s), "DELETE", JSON.stringify({
220
- action: "cancel"
221
- }), i);
222
- if ("error" in n) {
223
- this.schedulerStore.set("isLoading", !1);
224
- const h = (a = n.error) == null ? void 0 : a.type;
225
- let l = n.error;
226
- return h && h in this.errors.api("Cancel Booking") && (l = this.errors.api("Cancel Booking")[h]((l == null ? void 0 : l.message) || (l == null ? void 0 : l.title) || "Something went wrong")), { error: l };
227
- }
228
- return this.schedulerStore.set("cancelledEventInfo", {
229
- booking_id: t
230
- }), this.schedulerStore.set("isLoading", !1), n;
231
- }
232
- async rescheduleBooking(t, e) {
233
- var w;
234
- if (this.schedulerStore.set("isLoading", !0), !t)
235
- return { error: this.errors.component("Reschedule Booking").no_booking_id() };
236
- const s = this.errors.api("Reschedule Booking"), i = this.errors.component("Reschedule Booking"), { bookingInfo: n, selectedTimeslot: a, selectedTimezone: h } = this.schedulerStore.state, { startTime: l, endTime: u, timezone: p } = e, d = l || (a == null ? void 0 : a.start_time);
237
- if (!d)
238
- return { error: i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
239
- const m = u || (a == null ? void 0 : a.end_time);
240
- if (!m)
241
- return { error: i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
242
- const c = p || h;
243
- if (!c)
244
- return { error: i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.') };
245
- const o = e ? e == null ? void 0 : e.primaryParticipant : n == null ? void 0 : n.primaryParticipant, g = e ? (e == null ? void 0 : e.guests) || [] : (n == null ? void 0 : n.guests) || [], b = e ? { ...e == null ? void 0 : e.additionalFields, guests: g } : { ...n == null ? void 0 : n.additionalFields, guests: g }, k = this.configId ? `?configuration_id=${this.configId}` : "", T = `/v3/scheduling/bookings/${t}${k}`, D = this.getHeaders(), _ = await this.makeAPIRequest(decodeURIComponent(T), "PATCH", JSON.stringify({
246
- start_time: d.getTime() / 1e3,
247
- end_time: m.getTime() / 1e3,
248
- time_zone: c,
249
- additional_fields: b,
250
- guest: { ...o }
251
- }), D);
252
- if ("error" in _) {
253
- this.schedulerStore.set("isLoading", !1);
254
- const v = (w = _.error) == null ? void 0 : w.type;
255
- let f = _.error;
256
- v && v in s && (f = s[v]((f == null ? void 0 : f.message) || (f == null ? void 0 : f.title) || "Something went wrong"));
257
- }
258
- return "data" in _ && this.schedulerStore.set("eventInfo", _ == null ? void 0 : _.data), this.schedulerStore.set("isLoading", !1), _;
259
- }
260
- }
261
- function z(r = {}) {
262
- const t = {
263
- selectedDate: null,
264
- selectedLanguage: navigator.language,
265
- selectedTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
266
- selectedTimeslot: null,
267
- showBookingForm: !1,
268
- selectableDates: null,
269
- availability: [],
270
- state: "ready",
271
- eventInfo: null,
272
- cancelledEventInfo: null,
273
- isLoading: !1,
274
- ...r
275
- };
276
- y("[defaultNylasStoreState]: ", t);
277
- const e = R(t);
278
- return e.onChange("availability", (s) => {
279
- y("[availability]: ", s);
280
- const i = s.map((n) => n.start_time);
281
- y("[selectableDates]: ", i), e.set("selectableDates", i);
282
- }), e.reset = () => {
283
- for (const s in t) {
284
- const i = t[s];
285
- e.set(s, i);
286
- }
287
- }, e;
288
- }
289
- export {
290
- z as C,
291
- S as E,
292
- C as N
293
- };
@@ -1 +0,0 @@
1
- "use strict";const v=require("./utils-0cd66d04-94b9c3b6.cjs"),D=require("./index-10914bc1-c8c3a2f3.cjs");exports.ErrorCategory=void 0;(function(n){n.Component="component",n.Api="api",n.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var w;(function(n){n.endtime_not_in_future="endtime_not_in_future",n.no_booking_info="no_booking_info",n.no_timeslot_selected="no_timeslot_selected",n.no_booking_id="no_booking_id",n.invalid_start_time="invalid_start_time",n.invalid_end_time="invalid_end_time",n.invalid_timezone="invalid_timezone"})(w||(w={}));var b;(function(n){n.invalid_session="invalid_session",n.general_error="general_error",n.internal_error="internal_error",n.invalid_request_error="invalid_request_error",n.timeslot_not_available="timeslot_not_available"})(b||(b={}));class C{constructor(){this.component=t=>{const e=exports.ErrorCategory.Component,s=`${t} error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:e}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:e}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:e}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:e}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:e}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:e}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:e})}},this.api=t=>{const e=exports.ErrorCategory.Api,s=`${t} error`;return{invalid_session:i=>({title:s,message:i,category:e}),general_error:i=>({title:s,message:i,category:e}),internal_error:i=>({title:s,message:i,category:e}),invalid_request_error:i=>({title:s,message:i,category:e}),timeslot_not_available:i=>({title:s,message:i,category:e})}}}}class R{constructor({schedulerAPIURL:t,schedulerStore:e,sessionId:s,configId:i}){this.errors=new C,this.schedulerStore=e,this.schedulerAPIURL=t,this.sessionId=s,this.configId=i}getHeaders(){return this.configId?{}:{Authorization:`Bearer ${this.sessionId}`}}async makeAPIRequest(t,e,s,i={}){try{const r=new URL(this.schedulerAPIURL);return r.pathname=t,await(await fetch(decodeURIComponent(r.toString()),{method:e,headers:{"Content-Type":"application/json",...i},body:s})).json()}catch(r){return{error:{message:r.message,title:"API request failed",type:"api"}}}}selectDate(t){this.schedulerStore.set("selectedDate",t),this.schedulerStore.set("selectedTimeslot",null)}selectTime(t){this.schedulerStore.set("selectedTimeslot",t)}selectTimezone(t){this.schedulerStore.set("selectedTimezone",t)}toggleAdditionalData(t){this.schedulerStore.set("showBookingForm",t)}setParticipantName(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e==null?void 0:e.primaryParticipant,name:t}})}setParticipantEmail(t){const{bookingInfo:e}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...e,primaryParticipant:{...e==null?void 0:e.primaryParticipant,email:t}})}async setReschedule(t){const e=new Date;this.schedulerStore.set("rescheduleBookingId",t),this.schedulerStore.set("selectedTimeslot",null),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1);const s=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3,r=await this.getAvailability(s,i),a=this.schedulerStore.get("availability").find(l=>new Date(l.start_time)>new Date);let u=e;return a&&(u=a.start_time),this.schedulerStore.set("selectedDate",u),r}async setCancel(t){this.schedulerStore.set("cancelBookingId",t)}async bookTimeslot(t){var m;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:e,bookingInfo:s}=this.schedulerStore.state;if(!t&&!s)return{error:this.errors.component("Booking").no_booking_info()};const i=(t==null?void 0:t.timeslot)||e;if(!i)return{error:this.errors.component("Create Booking").no_timeslot_selected()};const r=t?t==null?void 0:t.primaryParticipant:s==null?void 0:s.primaryParticipant,a=t?(t==null?void 0:t.guests)||[]:(s==null?void 0:s.guests)||[],u=t?{...t==null?void 0:t.additionalFields,guests:a}:{...s==null?void 0:s.additionalFields,guests:a},l=this.getHeaders(),p=`/v3/scheduling/bookings${this.configId?`?configuration_id=${this.configId}`:""}`,d=await this.makeAPIRequest(decodeURIComponent(p),"POST",JSON.stringify({additional_fields:u,guest:{...r},start_time:i.start_time.getTime()/1e3,end_time:i.end_time.getTime()/1e3}),l);if("error"in d){this.schedulerStore.set("isLoading",!1);const c=(m=d.error)==null?void 0:m.type;let o=d.error;return c&&c in this.errors.api("Create Booking")&&(o=this.errors.api("Create Booking")[c]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}return"data"in d&&this.schedulerStore.set("eventInfo",d==null?void 0:d.data),this.schedulerStore.set("isLoading",!1),d}async getAvailability(t=0,e=0){var p,d,m;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,r=i.getTime();if(e&&e<r/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component("Get Availability").endtime_not_in_future()};if(!t){const c=new Date(i.getFullYear(),i.getMonth(),1);t=Math.floor(c.getTime()/1e3)}if(!e){const c=new Date(i.getFullYear(),i.getMonth()+1,0);e=Math.floor(c.getTime()/1e3)}s.append("start_time",encodeURIComponent(t.toString())),s.append("end_time",encodeURIComponent(e.toString())),this.configId&&s.append("configuration_id",encodeURIComponent(this.configId));const a=s.toString(),u=`/v3/scheduling/availability${a?`?${a}`:""}`,l=this.getHeaders(),h=await this.makeAPIRequest(decodeURIComponent(u),"GET",void 0,l);if("error"in h){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const c=(p=h.error)==null?void 0:p.type;let o=h.error;return c&&c in this.errors.api("Get Availability")&&(o=this.errors.api("Get Availability")[c]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}if("data"in h){const o=(((m=(d=h.data)==null?void 0:d.time_slots)==null?void 0:m.map(g=>({...g,start_time:new Date(g.start_time*1e3),end_time:new Date(g.end_time*1e3)})))||[]).filter(g=>g.start_time.getTime()>r);this.schedulerStore.set("availability",o)}return this.schedulerStore.set("isLoading",!1),h}async cancelBooking(t){var a;if(this.schedulerStore.set("isLoading",!0),!t)return{error:this.errors.component("Cancel Booking").no_booking_id()};const e=this.configId?`?configuration_id=${this.configId}`:"",s=`/v3/scheduling/bookings/${t}${e}`,i=this.getHeaders(),r=await this.makeAPIRequest(decodeURIComponent(s),"DELETE",JSON.stringify({action:"cancel"}),i);if("error"in r){this.schedulerStore.set("isLoading",!1);const u=(a=r.error)==null?void 0:a.type;let l=r.error;return u&&u in this.errors.api("Cancel Booking")&&(l=this.errors.api("Cancel Booking")[u]((l==null?void 0:l.message)||(l==null?void 0:l.title)||"Something went wrong")),{error:l}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:t}),this.schedulerStore.set("isLoading",!1),r}async rescheduleBooking(t,e){var y;if(this.schedulerStore.set("isLoading",!0),!t)return{error:this.errors.component("Reschedule Booking").no_booking_id()};const s=this.errors.api("Reschedule Booking"),i=this.errors.component("Reschedule Booking"),{bookingInfo:r,selectedTimeslot:a,selectedTimezone:u}=this.schedulerStore.state,{startTime:l,endTime:h,timezone:p}=e,d=l||(a==null?void 0:a.start_time);if(!d)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const m=h||(a==null?void 0:a.end_time);if(!m)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const c=p||u;if(!c)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const o=e?e==null?void 0:e.primaryParticipant:r==null?void 0:r.primaryParticipant,g=e?(e==null?void 0:e.guests)||[]:(r==null?void 0:r.guests)||[],I=e?{...e==null?void 0:e.additionalFields,guests:g}:{...r==null?void 0:r.additionalFields,guests:g},P=this.configId?`?configuration_id=${this.configId}`:"",k=`/v3/scheduling/bookings/${t}${P}`,T=this.getHeaders(),_=await this.makeAPIRequest(decodeURIComponent(k),"PATCH",JSON.stringify({start_time:d.getTime()/1e3,end_time:m.getTime()/1e3,time_zone:c,additional_fields:I,guest:{...o}}),T);if("error"in _){this.schedulerStore.set("isLoading",!1);const S=(y=_.error)==null?void 0:y.type;let f=_.error;S&&S in s&&(f=s[S]((f==null?void 0:f.message)||(f==null?void 0:f.title)||"Something went wrong"))}return"data"in _&&this.schedulerStore.set("eventInfo",_==null?void 0:_.data),this.schedulerStore.set("isLoading",!1),_}}function L(n={}){const t={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,selectableDates:null,availability:[],state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,...n};v.debug("[defaultNylasStoreState]: ",t);const e=D.createStore(t);return e.onChange("availability",s=>{v.debug("[availability]: ",s);const i=s.map(r=>r.start_time);v.debug("[selectableDates]: ",i),e.set("selectableDates",i)}),e.reset=()=>{for(const s in t){const i=t[s];e.set(s,i)}},e}exports.CreateNylasSchedulerStore=L;exports.NylaSchedulerAPIConnector=R;