@nylas/react 1.1.0-canary.23 → 1.1.0-canary.25

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 (155) hide show
  1. package/README.md +110 -2
  2. package/dist/add-circle-icon_2.entry-7165bd0e.js +25 -0
  3. package/dist/add-circle-icon_2.entry-f1ddca18.cjs +1 -0
  4. package/dist/{archive-icon_7.entry-3dcc4a66.js → archive-icon_7.entry-7411c224.js} +18 -18
  5. package/dist/{archive-icon_7.entry-2ec9b077.cjs → archive-icon_7.entry-e3df60ed.cjs} +1 -1
  6. package/dist/{arrow-icon.entry-175e8181.cjs → arrow-icon.entry-280e18b0.cjs} +1 -1
  7. package/dist/arrow-icon.entry-38949317.js +15 -0
  8. package/dist/{bold-icon_3.entry-9fc74a39.js → bold-icon_3.entry-5963945c.js} +4 -4
  9. package/dist/{bold-icon_3.entry-a3e61ad8.cjs → bold-icon_3.entry-5dffbedd.cjs} +1 -1
  10. package/dist/button-component_2.entry-237733b4.js +26 -0
  11. package/dist/button-component_2.entry-b29d2873.cjs +1 -0
  12. package/dist/{calendar-agenda-fill-icon_39.entry-493e91f6.js → calendar-agenda-fill-icon_48.entry-9afba869.js} +1982 -1420
  13. package/dist/calendar-agenda-fill-icon_48.entry-d3830dbb.cjs +7 -0
  14. package/dist/{calendar-cancel-icon.entry-c9c7e3b3.cjs → calendar-cancel-icon.entry-77ccf227.cjs} +1 -1
  15. package/dist/{calendar-cancel-icon.entry-3ca731f9.js → calendar-cancel-icon.entry-780723a6.js} +5 -5
  16. package/dist/{calendar-check-icon_2.entry-7c409a91.js → calendar-check-icon_2.entry-2c89c230.js} +5 -5
  17. package/dist/{calendar-check-icon_2.entry-5b8f8a75.cjs → calendar-check-icon_2.entry-b37ac7f0.cjs} +1 -1
  18. package/dist/{calendar-icon.entry-0589697f.js → calendar-icon.entry-02dd3990.js} +5 -5
  19. package/dist/{calendar-icon.entry-acd00f6f.cjs → calendar-icon.entry-ffc93569.cjs} +1 -1
  20. package/dist/{checkbox-component_2.entry-0aa252b9.cjs → checkbox-component_2.entry-00b6a1e9.cjs} +1 -1
  21. package/dist/{checkbox-component_2.entry-538fd8ec.js → checkbox-component_2.entry-ee9d0e6c.js} +3 -3
  22. package/dist/{chevron-icon_3.entry-7076e105.cjs → chevron-icon_3.entry-468abc26.cjs} +1 -1
  23. package/dist/{chevron-icon_3.entry-80e03257.js → chevron-icon_3.entry-f62e9ef1.js} +8 -8
  24. package/dist/{clock-icon_4.entry-db3fbda1.js → clock-icon_4.entry-766a1b23.js} +17 -17
  25. package/dist/{clock-icon_4.entry-d6901afd.cjs → clock-icon_4.entry-7dc2cc4a.cjs} +1 -1
  26. package/dist/{constants-12bd3c98-26c75011.js → constants-50c3e067-8a40a5fe.js} +618 -605
  27. package/dist/{constants-12bd3c98-22fd56f2.cjs → constants-50c3e067-9f2a6372.cjs} +5 -5
  28. package/dist/copy-icon.entry-2a841508.js +15 -0
  29. package/dist/copy-icon.entry-e5251410.cjs +1 -0
  30. package/dist/delete-icon_2.entry-1a5c39dc.cjs +1 -0
  31. package/dist/delete-icon_2.entry-64555a2f.js +25 -0
  32. package/dist/document-refresh-icon.entry-4bf6398b.js +15 -0
  33. package/dist/document-refresh-icon.entry-fdc7ddda.cjs +1 -0
  34. package/dist/elements/index.d.ts +9 -1
  35. package/dist/{elements-dc5b338e-e07600d4.js → elements-dc5b338e-2da1fe61.js} +1 -1
  36. package/dist/{elements-dc5b338e-211879a3.cjs → elements-dc5b338e-c8016c3d.cjs} +1 -1
  37. package/dist/{focus-visible-e8093c16-cb97634f.cjs → focus-visible-e8093c16-0a38a184.cjs} +1 -1
  38. package/dist/{focus-visible-e8093c16-284cefe0.js → focus-visible-e8093c16-9d0c98c0.js} +1 -1
  39. package/dist/{forward-icon_6.entry-554b0722.js → forward-icon_6.entry-390ef70a.js} +9 -9
  40. package/dist/{forward-icon_6.entry-751fdd4e.cjs → forward-icon_6.entry-7238ef38.cjs} +3 -3
  41. package/dist/{globe-icon.entry-63eb510d.cjs → globe-icon.entry-81f42f89.cjs} +1 -1
  42. package/dist/{globe-icon.entry-e3dd58bc.js → globe-icon.entry-8d106260.js} +5 -5
  43. package/dist/google-logo-icon_4.entry-aabd3886.js +680 -0
  44. package/dist/google-logo-icon_4.entry-fa2b8999.cjs +1 -0
  45. package/dist/index-53420959-5fc8ad2b.js +5 -0
  46. package/dist/index-53420959-fcf45780.cjs +1 -0
  47. package/dist/index-5ccfd9df.js +7859 -0
  48. package/dist/{index-6d9eeb53-cc42c6f1.js → index-6d9eeb53-58c8980a.js} +2 -2
  49. package/dist/{index-6d9eeb53-81e5b798.cjs → index-6d9eeb53-b2a6d09f.cjs} +1 -1
  50. package/dist/index-eb33703c.cjs +42 -0
  51. package/dist/{index.es-5355a265-f8853ce4.js → index.es-c9454237-00ccd1e6.js} +1 -1
  52. package/dist/{index.es-5355a265-e701a627.cjs → index.es-c9454237-b64161d1.cjs} +1 -1
  53. package/dist/{info-icon_2.entry-9559cf3b.cjs → info-icon_2.entry-b2e11336.cjs} +1 -1
  54. package/dist/{info-icon_2.entry-3b349f01.js → info-icon_2.entry-bb8ed71c.js} +7 -7
  55. package/dist/input-component.entry-378b1ccc.cjs +1 -0
  56. package/dist/{add-circle-icon_3.entry-37a88ff3.js → input-component.entry-cb86170f.js} +19 -33
  57. package/dist/input-dropdown.entry-98954c93.cjs +1 -0
  58. package/dist/{input-dropdown.entry-9bc68630.js → input-dropdown.entry-a76c339e.js} +8 -6
  59. package/dist/{mailbox-store-31d55036-c8618c0b.cjs → mailbox-store-edc386fc-156b7236.cjs} +1 -1
  60. package/dist/{mailbox-store-31d55036-1106efe2.js → mailbox-store-edc386fc-8bc7558b.js} +2 -2
  61. package/dist/{multi-select-dropdown.entry-e5ed9285.cjs → multi-select-dropdown.entry-40b855e1.cjs} +1 -1
  62. package/dist/{multi-select-dropdown.entry-36074a81.js → multi-select-dropdown.entry-6b686695.js} +2 -2
  63. package/dist/nylas-booked-event-card_12.entry-9d693125.cjs +1 -0
  64. package/dist/nylas-booked-event-card_12.entry-e861bb16.js +1134 -0
  65. package/dist/{nylas-form-card.entry-6e45c873.js → nylas-form-card.entry-b158d789.js} +19 -19
  66. package/dist/{nylas-form-card.entry-03a31218.cjs → nylas-form-card.entry-ca4a8746.cjs} +1 -1
  67. package/dist/{nylas-if-state.entry-092f4e1a.js → nylas-if-state.entry-8e4d922c.js} +8 -8
  68. package/dist/{nylas-if-state.entry-61d7ebc5.cjs → nylas-if-state.entry-95fac42d.cjs} +1 -1
  69. package/dist/{nylas-list-folders.entry-ab9e1c2c.js → nylas-list-folders.entry-83c39684.js} +3 -3
  70. package/dist/{nylas-list-folders.entry-1abbb401.cjs → nylas-list-folders.entry-8a22e0c8.cjs} +1 -1
  71. package/dist/{nylas-list-threads.entry-dfc87aca.cjs → nylas-list-threads.entry-54c582af.cjs} +1 -1
  72. package/dist/{nylas-list-threads.entry-2faaa2bb.js → nylas-list-threads.entry-7ea370e1.js} +3 -3
  73. package/dist/{nylas-login.entry-243ae09e.js → nylas-login.entry-9115fd81.js} +3 -3
  74. package/dist/{nylas-login.entry-d1cac0a1.cjs → nylas-login.entry-fb627e40.cjs} +1 -1
  75. package/dist/{nylas-mailbox-pagination.entry-c27af71c.cjs → nylas-mailbox-pagination.entry-04626d27.cjs} +1 -1
  76. package/dist/{nylas-mailbox-pagination.entry-b8225a3e.js → nylas-mailbox-pagination.entry-3ff02cf9.js} +2 -2
  77. package/dist/{nylas-mailbox-toolbar-button.entry-b66d597d.cjs → nylas-mailbox-toolbar-button.entry-8d00c789.cjs} +1 -1
  78. package/dist/{nylas-mailbox-toolbar-button.entry-22347d22.js → nylas-mailbox-toolbar-button.entry-f752e925.js} +7 -7
  79. package/dist/{nylas-mailbox.entry-9e6e1b4d.js → nylas-mailbox.entry-99c27b6c.js} +4 -4
  80. package/dist/{nylas-mailbox.entry-cb80f58c.cjs → nylas-mailbox.entry-b3974f4e.cjs} +1 -1
  81. package/dist/{nylas-provider.entry-28c12448.cjs → nylas-provider.entry-a3ad02a5.cjs} +1 -1
  82. package/dist/{nylas-provider.entry-196dd5da.js → nylas-provider.entry-c206aa32.js} +39 -39
  83. package/dist/{nylas-reminder-emails.entry-b655d888.js → nylas-reminder-emails.entry-414ce6fe.js} +6 -6
  84. package/dist/nylas-reminder-emails.entry-59c07bfe.cjs +4 -0
  85. package/dist/{nylas-reminder-time_2.entry-9d8f7436.js → nylas-reminder-time_2.entry-197d83a0.js} +5 -5
  86. package/dist/{nylas-reminder-time_2.entry-0f3747fb.cjs → nylas-reminder-time_2.entry-d79dcd85.cjs} +1 -1
  87. package/dist/{nylas-scheduler-editor.entry-feb7a7db.js → nylas-scheduler-editor.entry-7f389982.js} +49 -31
  88. package/dist/{nylas-scheduler-editor.entry-504e8ed3.cjs → nylas-scheduler-editor.entry-f1c6964a.cjs} +2 -2
  89. package/dist/nylas-scheduling.entry-1a8bd6fc.cjs +1 -0
  90. package/dist/nylas-scheduling.entry-4fa5381d.js +345 -0
  91. package/dist/{nylas-threads-refresh.entry-91af9af3.js → nylas-threads-refresh.entry-20602e7b.js} +4 -4
  92. package/dist/{nylas-threads-refresh.entry-e637161b.cjs → nylas-threads-refresh.entry-56b53449.cjs} +1 -1
  93. package/dist/{nylas-threads-search.entry-5457dcec.js → nylas-threads-search.entry-8872473c.js} +8 -8
  94. package/dist/{nylas-threads-search.entry-b944f95a.cjs → nylas-threads-search.entry-8e0ec3ae.cjs} +1 -1
  95. package/dist/{nylas-time-window-picker.entry-a6fd216b.js → nylas-time-window-picker.entry-9ac542b7.js} +10 -10
  96. package/dist/{nylas-time-window-picker.entry-134ef726.cjs → nylas-time-window-picker.entry-ca47f721.cjs} +1 -1
  97. package/dist/{nylas-view-thread.entry-9296a505.cjs → nylas-view-thread.entry-1f758e43.cjs} +1 -1
  98. package/dist/{nylas-view-thread.entry-6fdd6cb1.js → nylas-view-thread.entry-dcd3d5be.js} +3 -3
  99. package/dist/{person-icon.entry-1cdb4dc2.cjs → person-icon.entry-63b28ace.cjs} +1 -1
  100. package/dist/{person-icon.entry-4a695727.js → person-icon.entry-93130c05.js} +2 -2
  101. package/dist/play-icon_2.entry-6a99c32d.js +25 -0
  102. package/dist/play-icon_2.entry-b67fb649.cjs +1 -0
  103. package/dist/react.cjs +1 -1
  104. package/dist/react.js +108 -100
  105. package/dist/{refresh-icon.entry-46c92605.js → refresh-icon.entry-84783c91.js} +4 -4
  106. package/dist/{refresh-icon.entry-9dbb04ba.cjs → refresh-icon.entry-b49792fc.cjs} +1 -1
  107. package/dist/{register-component-592986c5-5edf5835.cjs → register-component-887199a9-003f96c5.cjs} +1 -1
  108. package/dist/{register-component-592986c5-d5d210a8.js → register-component-887199a9-b41dfa7a.js} +1 -1
  109. package/dist/{scheduler-config-store-9ccfba4d-b08031b5.js → scheduler-config-store-2a3b403d-73610089.js} +5 -4
  110. package/dist/scheduler-config-store-2a3b403d-a5e3433a.cjs +1 -0
  111. package/dist/{scheduler-store-fd0d11a5-313e8592.js → scheduler-store-fe281404-bddb1b6a.js} +179 -132
  112. package/dist/scheduler-store-fe281404-c3e477f6.cjs +1 -0
  113. package/dist/textarea-component.entry-28c4bc05.cjs +1 -0
  114. package/dist/textarea-component.entry-40e959e5.js +36 -0
  115. package/dist/time-period-selector.entry-af71523a.cjs +1 -0
  116. package/dist/{time-period-selector.entry-112c0b64.js → time-period-selector.entry-da5d8652.js} +41 -41
  117. package/dist/{translate-icon.entry-a4df3c16.js → translate-icon.entry-92b83635.js} +4 -4
  118. package/dist/{translate-icon.entry-c701b391.cjs → translate-icon.entry-a2ed4f76.cjs} +1 -1
  119. package/dist/{warning-icon.entry-d1703715.js → warning-icon.entry-19f721c3.js} +5 -5
  120. package/dist/{warning-icon.entry-bda0aafa.cjs → warning-icon.entry-3ab9a59e.cjs} +1 -1
  121. package/package.json +3 -3
  122. package/dist/add-circle-icon_3.entry-4f8f1cbf.cjs +0 -1
  123. package/dist/arrow-icon.entry-2cf3e94d.js +0 -15
  124. package/dist/button-component.entry-7fdb3bca.cjs +0 -1
  125. package/dist/button-component.entry-861637f2.js +0 -16
  126. package/dist/calendar-agenda-fill-icon_39.entry-3c21a3ec.cjs +0 -7
  127. package/dist/checkmark-icon.entry-0a184b31.cjs +0 -1
  128. package/dist/checkmark-icon.entry-56302db0.js +0 -15
  129. package/dist/copy-icon_3.entry-33e89a37.cjs +0 -1
  130. package/dist/copy-icon_3.entry-9670b9f9.js +0 -35
  131. package/dist/document-refresh-icon.entry-149f2a3b.js +0 -15
  132. package/dist/document-refresh-icon.entry-a3326831.cjs +0 -1
  133. package/dist/google-logo-icon_5.entry-bccce7f4.cjs +0 -1
  134. package/dist/google-logo-icon_5.entry-e462e091.js +0 -748
  135. package/dist/index-53420959-02fe58ef.js +0 -5
  136. package/dist/index-53420959-0b9c205e.cjs +0 -1
  137. package/dist/index-8a536089.cjs +0 -42
  138. package/dist/index-a15916e5.js +0 -7653
  139. package/dist/input-dropdown.entry-d454f6bc.cjs +0 -1
  140. package/dist/loading-icon.entry-1d49e471.js +0 -15
  141. package/dist/loading-icon.entry-a68da48b.cjs +0 -1
  142. package/dist/nylas-booked-event-card_10.entry-38d2fd2e.js +0 -954
  143. package/dist/nylas-booked-event-card_10.entry-e530a8db.cjs +0 -1
  144. package/dist/nylas-booking-confirmation-type.entry-2fea82f9.js +0 -106
  145. package/dist/nylas-booking-confirmation-type.entry-5857a863.cjs +0 -1
  146. package/dist/nylas-reminder-emails.entry-47ef5a9d.cjs +0 -4
  147. package/dist/nylas-scheduling.entry-8c8f8e35.cjs +0 -1
  148. package/dist/nylas-scheduling.entry-d35efa9a.js +0 -286
  149. package/dist/play-icon_2.entry-10fd617e.cjs +0 -1
  150. package/dist/play-icon_2.entry-fb013b17.js +0 -25
  151. package/dist/scheduler-config-store-9ccfba4d-3ec35859.cjs +0 -1
  152. package/dist/scheduler-store-fd0d11a5-b180b3b7.cjs +0 -1
  153. package/dist/textarea-component.entry-0cd3b57f.js +0 -36
  154. package/dist/textarea-component.entry-788eb37a.cjs +0 -1
  155. package/dist/time-period-selector.entry-1e0b720b.cjs +0 -1
@@ -1,20 +1,20 @@
1
- import { d as b, e as z, k as d, m as F } from "./index-a15916e5.js";
2
- var k;
1
+ import { d as b, e as $, k as d, m as R } from "./index-5ccfd9df.js";
2
+ var w;
3
3
  (function(a) {
4
4
  a.Component = "component", a.Api = "api", a.Auth = "auth";
5
- })(k || (k = {}));
6
- var A;
5
+ })(w || (w = {}));
6
+ var D;
7
7
  (function(a) {
8
- a.endtime_not_in_future = "endtime_not_in_future", a.no_booking_info = "no_booking_info", a.no_timeslot_selected = "no_timeslot_selected", a.no_timezone_selected = "no_timezone_selected", a.no_booking_id = "no_booking_id", a.invalid_start_time = "invalid_start_time", a.invalid_end_time = "invalid_end_time", a.invalid_timezone = "invalid_timezone";
9
- })(A || (A = {}));
10
- var L;
8
+ a.endtime_not_in_future = "endtime_not_in_future", a.no_booking_info = "no_booking_info", a.no_timeslot_selected = "no_timeslot_selected", a.no_timezone_selected = "no_timezone_selected", a.no_booking_id = "no_booking_id", a.no_salt = "no_salt", a.invalid_start_time = "invalid_start_time", a.invalid_end_time = "invalid_end_time", a.invalid_timezone = "invalid_timezone";
9
+ })(D || (D = {}));
10
+ var A;
11
11
  (function(a) {
12
12
  a.invalid_session = "invalid_session", a.general_error = "general_error", a.internal_error = "internal_error", a.invalid_request_error = "invalid_request_error", a.timeslot_not_available = "timeslot_not_available", a.provider_error = "provider_error", a.not_found_error = "not_found_error";
13
- })(L || (L = {}));
14
- class R {
13
+ })(A || (A = {}));
14
+ class C {
15
15
  constructor() {
16
16
  this.component = (e) => {
17
- const t = k.Component, s = `${e} Error`;
17
+ const t = w.Component, s = `${e} Error`;
18
18
  return {
19
19
  endtime_not_in_future: (i = '"endtime" can not be in the future') => ({
20
20
  title: s,
@@ -41,6 +41,11 @@ class R {
41
41
  message: i,
42
42
  category: t
43
43
  }),
44
+ no_salt: (i = "No salt provided") => ({
45
+ title: s,
46
+ message: i,
47
+ category: t
48
+ }),
44
49
  invalid_start_time: (i = "Invalid start time") => ({
45
50
  title: s,
46
51
  message: i,
@@ -58,7 +63,7 @@ class R {
58
63
  })
59
64
  };
60
65
  }, this.api = (e) => {
61
- const t = k.Api, s = `${e} Error`;
66
+ const t = w.Api, s = `${e} Error`;
62
67
  return {
63
68
  invalid_session: (i) => ({
64
69
  title: s,
@@ -99,9 +104,9 @@ class R {
99
104
  };
100
105
  }
101
106
  }
102
- class C {
103
- constructor({ schedulerAPIURL: e, schedulerStore: t, sessionId: s, configId: i }) {
104
- this.errors = new R(), this.schedulerStore = t, this.schedulerAPIURL = e, this.sessionId = s, this.configId = i;
107
+ class U {
108
+ constructor({ schedulerAPIURL: e, schedulerStore: t, sessionId: s, configId: i, slug: n, clientId: r }) {
109
+ this.errors = new C(), this.schedulerStore = t, this.schedulerAPIURL = e, this.sessionId = s, this.configId = i, this.slug = n, this.clientId = r;
105
110
  }
106
111
  getHeaders() {
107
112
  return this.sessionId ? {
@@ -110,8 +115,8 @@ class C {
110
115
  }
111
116
  async makeAPIRequest(e, t, s, i = {}) {
112
117
  try {
113
- const r = new URL(this.schedulerAPIURL);
114
- return r.pathname = e, await (await fetch(decodeURIComponent(r.toString()), {
118
+ const n = new URL(this.schedulerAPIURL);
119
+ return n.pathname = e, await (await fetch(decodeURIComponent(n.toString()), {
115
120
  method: t,
116
121
  headers: {
117
122
  "Content-Type": "application/json",
@@ -120,10 +125,10 @@ class C {
120
125
  },
121
126
  body: s
122
127
  })).json();
123
- } catch (r) {
128
+ } catch (n) {
124
129
  return {
125
130
  error: {
126
- message: r.message,
131
+ message: n.message,
127
132
  title: "API request failed",
128
133
  type: "api"
129
134
  }
@@ -131,9 +136,9 @@ class C {
131
136
  }
132
137
  }
133
138
  getErrorMessage(e) {
134
- var s, i, r, n;
139
+ var s, i, n, r;
135
140
  let t = (e == null ? void 0 : e.message) || (e == null ? void 0 : e.title) || "Something went wrong";
136
- return (e == null ? void 0 : e.type) === "provider_error" && (t = ((i = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : i.message) || ((n = (r = e == null ? void 0 : e.provider_error) == null ? void 0 : r.error) == null ? void 0 : n.title) || "Something went wrong"), t;
141
+ return (e == null ? void 0 : e.type) === "provider_error" && (t = ((i = (s = e == null ? void 0 : e.provider_error) == null ? void 0 : s.error) == null ? void 0 : i.message) || ((r = (n = e == null ? void 0 : e.provider_error) == null ? void 0 : n.error) == null ? void 0 : r.title) || "Something went wrong"), t;
137
142
  }
138
143
  setConfigId(e) {
139
144
  this.configId = e;
@@ -178,7 +183,7 @@ class C {
178
183
  return await this.getAvailability(s, i);
179
184
  }
180
185
  async resetStoreStateAndFetchAvailability() {
181
- const e = /* @__PURE__ */ new Date(), t = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((r) => new Date(r.start_time) > /* @__PURE__ */ new Date());
186
+ const e = /* @__PURE__ */ new Date(), t = await this.refetchAvailability(), s = this.schedulerStore.get("availability").find((n) => new Date(n.start_time) > /* @__PURE__ */ new Date());
182
187
  let i = e;
183
188
  return s && (i = s.start_time), this.schedulerStore.set("selectedDate", i), this.schedulerStore.set("eventInfo", null), this.schedulerStore.set("showBookingForm", !1), this.schedulerStore.set("selectedTimeslot", null), t;
184
189
  }
@@ -192,191 +197,233 @@ class C {
192
197
  async setCancel(e) {
193
198
  this.schedulerStore.set("cancelBookingId", e);
194
199
  }
200
+ async setReject(e) {
201
+ this.schedulerStore.set("rejectBookingId", e);
202
+ }
195
203
  async resetCancel() {
196
204
  const e = await this.resetStoreStateAndFetchAvailability();
197
- return this.schedulerStore.set("cancelBookingId", ""), this.schedulerStore.set("cancelledEventInfo", null), e;
205
+ return this.schedulerStore.set("cancelBookingId", ""), this.schedulerStore.set("rejectBookingId", ""), this.schedulerStore.set("cancelledEventInfo", null), e;
206
+ }
207
+ async goBack() {
208
+ this.schedulerStore.set("cancelBookingId", "");
209
+ }
210
+ async resetConfirm() {
211
+ const e = await this.resetStoreStateAndFetchAvailability();
212
+ return this.schedulerStore.set("organizerConfirmationBookingId", ""), this.schedulerStore.set("confirmedEventInfo", void 0), e;
198
213
  }
199
214
  async bookTimeslot(e) {
200
- var m;
215
+ var I;
201
216
  this.schedulerStore.set("isLoading", !0);
202
- const { selectedTimeslot: t, selectedTimezone: s, bookingInfo: i } = this.schedulerStore.state;
217
+ const { selectedTimeslot: t, selectedTimezone: s, bookingInfo: i, selectedLanguage: n } = this.schedulerStore.state;
203
218
  if (!e && !i)
204
219
  return { error: this.errors.component(d.t("createBookingErrorTitle")).no_booking_info() };
205
220
  const r = (e == null ? void 0 : e.timeslot) || t;
206
221
  if (!r)
207
222
  return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timeslot_selected() };
208
- const n = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
209
- if (!n)
223
+ const o = e && (e != null && e.timezone) ? e == null ? void 0 : e.timezone : s;
224
+ if (!o)
210
225
  return { error: this.errors.component(d.t("createBookingErrorTitle")).no_timezone_selected() };
211
- const o = this.schedulerStore.get("availabilityOrderEmails");
212
- let u = "";
213
- if (o.length > 0) {
214
- const g = r.emails;
215
- for (let c = 0; c < o.length; c++)
216
- if (g.includes(o[c])) {
217
- u = o[c];
226
+ const u = this.schedulerStore.get("availabilityOrderEmails");
227
+ let g = "";
228
+ if (u.length > 0) {
229
+ const m = r.emails;
230
+ for (let p = 0; p < u.length; p++)
231
+ if (m.includes(u[p])) {
232
+ g = u[p];
218
233
  break;
219
234
  }
220
235
  }
221
- const _ = e ? e == null ? void 0 : e.primaryParticipant : i == null ? void 0 : i.primaryParticipant, h = e ? (e == null ? void 0 : e.guests) || [] : (i == null ? void 0 : i.guests) || [], y = e ? e == null ? void 0 : e.additionalFields : i == null ? void 0 : i.additionalFields, I = this.getHeaders(), S = `/v3/scheduling/bookings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : ""}`, l = await this.makeAPIRequest(decodeURIComponent(S), "POST", JSON.stringify({
222
- participants: u ? [{ email: u }] : void 0,
223
- additional_fields: y,
224
- additional_guests: h,
225
- guest: { ..._ },
236
+ const l = e ? e == null ? void 0 : e.primaryParticipant : i == null ? void 0 : i.primaryParticipant, v = e ? (e == null ? void 0 : e.guests) || [] : (i == null ? void 0 : i.guests) || [], f = e ? e == null ? void 0 : e.additionalFields : i == null ? void 0 : i.additionalFields, _ = this.getHeaders(), h = `/v3/scheduling/bookings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : ""}`, c = await this.makeAPIRequest(decodeURIComponent(h), "POST", JSON.stringify({
237
+ participants: g ? [{ email: g }] : void 0,
238
+ additional_fields: f,
239
+ additional_guests: v,
240
+ guest: { ...l },
226
241
  start_time: r.start_time.getTime() / 1e3,
227
242
  end_time: r.end_time.getTime() / 1e3,
228
- timezone: n
229
- }), I);
230
- if ("error" in l) {
243
+ timezone: o,
244
+ email_language: this.getTwoLetterLanguageCode(n)
245
+ }), _);
246
+ if ("error" in c) {
231
247
  this.schedulerStore.set("isLoading", !1);
232
- const g = (m = l.error) == null ? void 0 : m.type;
233
- let c = l.error;
234
- if (g && g in this.errors.api("Create Booking")) {
235
- const w = this.getErrorMessage(c);
236
- c = this.errors.api("Create Booking")[g](w);
248
+ const m = (I = c.error) == null ? void 0 : I.type;
249
+ let p = c.error;
250
+ if (m && m in this.errors.api("Create Booking")) {
251
+ const L = this.getErrorMessage(p);
252
+ p = this.errors.api("Create Booking")[m](L);
237
253
  }
238
- return { error: c };
254
+ return { error: p };
239
255
  }
240
- return "data" in l && this.schedulerStore.set("eventInfo", l == null ? void 0 : l.data), this.schedulerStore.set("isLoading", !1), l;
256
+ return "data" in c && this.schedulerStore.set("eventInfo", c == null ? void 0 : c.data), this.schedulerStore.set("isLoading", !1), c;
241
257
  }
242
258
  async getUISettings() {
243
- var r;
259
+ var n;
244
260
  this.schedulerStore.set("isLoading", !0);
245
- const e = this.getHeaders(), s = `/v3/scheduling/ui-settings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : ""}`, i = await this.makeAPIRequest(s, "GET", void 0, e);
261
+ const e = this.getHeaders(), s = `/v3/scheduling/ui-settings${!this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : ""}`, i = await this.makeAPIRequest(s, "GET", void 0, e);
246
262
  if ("error" in i) {
247
263
  this.schedulerStore.set("isLoading", !1);
248
- const n = (r = i.error) == null ? void 0 : r.type;
264
+ const r = (n = i.error) == null ? void 0 : n.type;
249
265
  let o = i.error;
250
- return n && n in this.errors.api(d.t("getUISettingErrorTitle")) && (o = this.errors.api(d.t("getUISettingErrorTitle"))[n]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
266
+ return r && r in this.errors.api(d.t("getUISettingErrorTitle")) && (o = this.errors.api(d.t("getUISettingErrorTitle"))[r]((o == null ? void 0 : o.message) || (o == null ? void 0 : o.title) || "Something went wrong")), { error: o };
251
267
  }
252
268
  return "data" in i && this.schedulerStore.set("configSettings", i.data), this.schedulerStore.set("isLoading", !1), i;
253
269
  }
270
+ getTwoLetterLanguageCode(e) {
271
+ return e.split("-")[0];
272
+ }
254
273
  getStartTimeWithMinBookingNotice(e) {
255
274
  var i;
256
275
  const t = (i = this.schedulerStore.get("configSettings")) == null ? void 0 : i.scheduler, s = t == null ? void 0 : t.min_booking_notice;
257
276
  return s ? e + s * 60 : e;
258
277
  }
259
278
  getEndTimeForAvailableDaysInFuture(e) {
260
- var n, o;
261
- const t = /* @__PURE__ */ new Date(), s = (o = (n = this.schedulerStore.get("configSettings")) == null ? void 0 : n.scheduler) == null ? void 0 : o.available_days_in_future, i = Math.floor(F(t, s).getTime() / 1e3);
279
+ var r, o;
280
+ const t = /* @__PURE__ */ new Date(), s = (o = (r = this.schedulerStore.get("configSettings")) == null ? void 0 : r.scheduler) == null ? void 0 : o.available_days_in_future, i = Math.floor(R(t, s).getTime() / 1e3);
262
281
  return Math.min(i, e);
263
282
  }
264
283
  async getAvailability(e = 0, t = 0) {
265
- var y, I, f, S;
284
+ var v, f, _, S;
266
285
  this.schedulerStore.set("isLoading", !0);
267
- const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), r = i.getTime();
268
- if (t && t < r / 1e3)
286
+ const s = new URLSearchParams(), i = /* @__PURE__ */ new Date(), n = i.getTime();
287
+ if (t && t < n / 1e3)
269
288
  return this.schedulerStore.set("isLoading", !1), { error: this.errors.component(d.t("getAvailabilityErrorTitle")).endtime_not_in_future() };
270
289
  if (!e) {
271
- const l = new Date(i.getFullYear(), i.getMonth(), 1);
272
- e = Math.floor(l.getTime() / 1e3);
290
+ const h = new Date(i.getFullYear(), i.getMonth(), 1);
291
+ e = Math.floor(h.getTime() / 1e3);
273
292
  }
274
293
  if (e = this.getStartTimeWithMinBookingNotice(e), !t) {
275
- const l = new Date(i.getFullYear(), i.getMonth() + 1, 0);
276
- t = Math.floor(l.getTime() / 1e3);
294
+ const h = new Date(i.getFullYear(), i.getMonth() + 1, 0);
295
+ t = Math.floor(h.getTime() / 1e3);
277
296
  }
278
- t = this.getEndTimeForAvailableDaysInFuture(t), s.append("start_time", encodeURIComponent(e.toString())), s.append("end_time", encodeURIComponent(t.toString())), this.configId && !this.sessionId && s.append("configuration_id", encodeURIComponent(this.configId));
279
- const n = this.schedulerStore.get("rescheduleBookingId");
280
- n && s.append("booking_id", encodeURIComponent(n));
281
- const o = s.toString(), u = `/v3/scheduling/availability${o ? `?${o}` : ""}`, _ = this.getHeaders(), h = await this.makeAPIRequest(decodeURIComponent(u), "GET", void 0, _);
282
- if ("error" in h) {
297
+ t = this.getEndTimeForAvailableDaysInFuture(t), s.append("start_time", encodeURIComponent(e.toString())), s.append("end_time", encodeURIComponent(t.toString())), this.configId && !this.sessionId ? s.append("configuration_id", encodeURIComponent(this.configId)) : this.slug && this.clientId && !this.sessionId && (s.append("slug", encodeURIComponent(this.slug)), s.append("client_id", encodeURIComponent(this.clientId)));
298
+ const r = this.schedulerStore.get("rescheduleBookingId");
299
+ r && s.append("booking_id", encodeURIComponent(r));
300
+ const o = s.toString(), u = `/v3/scheduling/availability${o ? `?${o}` : ""}`, g = this.getHeaders(), l = await this.makeAPIRequest(decodeURIComponent(u), "GET", void 0, g);
301
+ if ("error" in l) {
283
302
  this.schedulerStore.set("availability", []), this.schedulerStore.set("isLoading", !1);
284
- const l = (y = h.error) == null ? void 0 : y.type;
285
- let m = h.error;
286
- if (l && l in this.errors.api(d.t("getAvailabilityErrorTitle"))) {
287
- const g = this.getErrorMessage(m);
288
- m = this.errors.api(d.t("getAvailabilityErrorTitle"))[l](g);
303
+ const h = (v = l.error) == null ? void 0 : v.type;
304
+ let c = l.error;
305
+ if (h && h in this.errors.api(d.t("getAvailabilityErrorTitle"))) {
306
+ const I = this.getErrorMessage(c);
307
+ c = this.errors.api(d.t("getAvailabilityErrorTitle"))[h](I);
289
308
  }
290
- return { error: m };
309
+ return { error: c };
291
310
  }
292
- if ("data" in h) {
293
- const m = (((f = (I = h.data) == null ? void 0 : I.time_slots) == null ? void 0 : f.map((c) => ({
294
- ...c,
295
- start_time: new Date(c.start_time * 1e3),
296
- end_time: new Date(c.end_time * 1e3)
297
- }))) || []).filter((c) => c.start_time.getTime() > r);
298
- this.schedulerStore.set("availability", m);
299
- const g = ((S = h.data) == null ? void 0 : S.order) || [];
300
- this.schedulerStore.set("availabilityOrderEmails", g);
311
+ if ("data" in l) {
312
+ const c = (((_ = (f = l.data) == null ? void 0 : f.time_slots) == null ? void 0 : _.map((m) => ({
313
+ ...m,
314
+ start_time: new Date(m.start_time * 1e3),
315
+ end_time: new Date(m.end_time * 1e3)
316
+ }))) || []).filter((m) => m.start_time.getTime() > n);
317
+ this.schedulerStore.set("availability", c);
318
+ const I = ((S = l.data) == null ? void 0 : S.order) || [];
319
+ this.schedulerStore.set("availabilityOrderEmails", I);
301
320
  }
302
- return this.schedulerStore.set("isLoading", !1), h;
321
+ return this.schedulerStore.set("isLoading", !1), l;
303
322
  }
304
323
  async cancelBooking(e, t) {
305
324
  var o;
306
325
  if (this.schedulerStore.set("isLoading", !0), !e)
307
326
  return { error: this.errors.component(d.t("cancelBookingErrorTitle")).no_booking_id() };
308
- const s = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", i = `/v3/scheduling/bookings/${e}${s}`, r = this.getHeaders(), n = await this.makeAPIRequest(decodeURIComponent(i), "DELETE", JSON.stringify({
327
+ const s = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", i = `/v3/scheduling/bookings/${e}${s}`, n = this.getHeaders(), r = await this.makeAPIRequest(decodeURIComponent(i), "DELETE", JSON.stringify({
309
328
  action: "cancel",
310
329
  cancellation_reason: t
311
- }), r);
312
- if ("error" in n) {
330
+ }), n);
331
+ if ("error" in r) {
313
332
  this.schedulerStore.set("isLoading", !1);
314
- const u = (o = n.error) == null ? void 0 : o.type;
315
- let _ = n.error;
333
+ const u = (o = r.error) == null ? void 0 : o.type;
334
+ let g = r.error;
316
335
  if (u && u in this.errors.api(d.t("cancelBookingErrorTitle"))) {
317
- const h = this.getErrorMessage(_);
318
- _ = this.errors.api(d.t("cancelBookingErrorTitle"))[u](h);
336
+ const l = this.getErrorMessage(g);
337
+ g = this.errors.api(d.t("cancelBookingErrorTitle"))[u](l);
319
338
  }
320
- return { error: _ };
339
+ return { error: g };
321
340
  }
322
341
  return this.schedulerStore.set("cancelledEventInfo", {
323
342
  booking_id: e
324
- }), this.schedulerStore.set("rescheduleBookingId", ""), this.schedulerStore.set("isLoading", !1), n;
343
+ }), this.schedulerStore.set("rescheduleBookingId", ""), this.schedulerStore.set("isLoading", !1), r;
325
344
  }
326
345
  async rescheduleBooking(e, t) {
327
346
  var E;
328
347
  if (this.schedulerStore.set("isLoading", !0), !e)
329
348
  return { error: this.errors.component(d.t("rescheduleBookingErrorTitle")).no_booking_id() };
330
- const s = this.errors.api(d.t("rescheduleBookingErrorTitle")), i = this.errors.component(d.t("rescheduleBookingErrorTitle")), { bookingInfo: r, selectedTimeslot: n, selectedTimezone: o } = this.schedulerStore.state, { startTime: u, endTime: _, timezone: h } = t, y = u || (n == null ? void 0 : n.start_time);
331
- if (!y)
349
+ const s = this.errors.api(d.t("rescheduleBookingErrorTitle")), i = this.errors.component(d.t("rescheduleBookingErrorTitle")), { bookingInfo: n, selectedTimeslot: r, selectedTimezone: o, selectedLanguage: u } = this.schedulerStore.state, { startTime: g, endTime: l, timezone: v } = t, f = g || (r == null ? void 0 : r.start_time);
350
+ if (!f)
332
351
  return { error: i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
333
- const I = _ || (n == null ? void 0 : n.end_time);
334
- if (!I)
352
+ const _ = l || (r == null ? void 0 : r.end_time);
353
+ if (!_)
335
354
  return { error: i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.') };
336
- const f = this.schedulerStore.get("availabilityOrderEmails");
337
- let S = "";
338
- if (f.length > 0) {
339
- const T = (n == null ? void 0 : n.emails) || [];
340
- for (let v = 0; v < f.length; v++)
341
- if (T.includes(f[v])) {
342
- S = f[v];
355
+ const S = this.schedulerStore.get("availabilityOrderEmails");
356
+ let h = "";
357
+ if (S.length > 0) {
358
+ const T = (r == null ? void 0 : r.emails) || [];
359
+ for (let k = 0; k < S.length; k++)
360
+ if (T.includes(S[k])) {
361
+ h = S[k];
343
362
  break;
344
363
  }
345
364
  }
346
- const l = h || o;
347
- if (!l)
365
+ const c = v || o;
366
+ if (!c)
348
367
  return { error: i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.') };
349
- const m = t ? t == null ? void 0 : t.primaryParticipant : r == null ? void 0 : r.primaryParticipant, g = t ? (t == null ? void 0 : t.guests) || [] : (r == null ? void 0 : r.guests) || [], c = t ? t == null ? void 0 : t.additionalFields : r == null ? void 0 : r.additionalFields, w = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : "", B = `/v3/scheduling/bookings/${e}${w}`, P = this.getHeaders(), p = await this.makeAPIRequest(decodeURIComponent(B), "PATCH", JSON.stringify({
350
- start_time: y.getTime() / 1e3,
351
- end_time: I.getTime() / 1e3,
352
- time_zone: l,
353
- additional_fields: c,
354
- guest: { ...m },
355
- additional_guests: g,
356
- participants: S ? [{ email: S }] : void 0
357
- }), P);
358
- if ("error" in p) {
368
+ const I = t ? t == null ? void 0 : t.primaryParticipant : n == null ? void 0 : n.primaryParticipant, m = t ? (t == null ? void 0 : t.guests) || [] : (n == null ? void 0 : n.guests) || [], p = t ? t == null ? void 0 : t.additionalFields : n == null ? void 0 : n.additionalFields, L = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", P = `/v3/scheduling/bookings/${e}${L}`, z = this.getHeaders(), y = await this.makeAPIRequest(decodeURIComponent(P), "PATCH", JSON.stringify({
369
+ start_time: f.getTime() / 1e3,
370
+ end_time: _.getTime() / 1e3,
371
+ timezone: c,
372
+ additional_fields: p,
373
+ guest: { ...I },
374
+ additional_guests: m,
375
+ participants: h ? [{ email: h }] : void 0,
376
+ email_language: this.getTwoLetterLanguageCode(u)
377
+ }), z);
378
+ if ("error" in y) {
359
379
  this.schedulerStore.set("isLoading", !1);
360
- const T = (E = p.error) == null ? void 0 : E.type;
361
- let v = p.error;
380
+ const T = (E = y.error) == null ? void 0 : E.type;
381
+ let k = y.error;
362
382
  if (T && T in s) {
363
- const M = this.getErrorMessage(v);
364
- v = s[T](M);
383
+ const M = this.getErrorMessage(k);
384
+ k = s[T](M);
365
385
  }
366
- return { error: v };
386
+ return { error: k };
367
387
  }
368
- const D = this.schedulerStore.get("reschedulingEventInfo");
369
- if ("data" in p)
370
- this.schedulerStore.set("eventInfo", p == null ? void 0 : p.data);
371
- else if (D)
372
- this.schedulerStore.set("eventInfo", D);
388
+ const B = this.schedulerStore.get("reschedulingEventInfo");
389
+ if ("data" in y)
390
+ this.schedulerStore.set("eventInfo", y == null ? void 0 : y.data);
391
+ else if (B)
392
+ this.schedulerStore.set("eventInfo", B);
373
393
  else {
374
394
  const T = {
375
395
  booking_id: e
376
396
  };
377
397
  this.schedulerStore.set("eventInfo", T);
378
398
  }
379
- return this.schedulerStore.set("isLoading", !1), p;
399
+ return this.schedulerStore.set("isLoading", !1), y;
400
+ }
401
+ async updateBooking(e) {
402
+ var v;
403
+ this.schedulerStore.set("isLoading", !0);
404
+ const { bookingId: t, status: s, reason: i } = e, n = this.schedulerStore.get("organizerConfirmationSalt"), r = s === "confirmed" ? d.t("confirmBookingErrorTitle") : d.t("rejectBookingErrorTitle");
405
+ if (!t)
406
+ return { error: this.errors.component(r).no_booking_id() };
407
+ if (!n)
408
+ return { error: this.errors.component(r).no_salt() };
409
+ const o = !this.sessionId && this.configId ? `?configuration_id=${this.configId}` : !this.sessionId && this.slug && this.clientId ? `?slug=${this.slug}&client_id=${this.clientId}` : "", u = `/v3/scheduling/bookings/${t}${o}`, g = this.getHeaders(), l = await this.makeAPIRequest(decodeURIComponent(u), "PUT", JSON.stringify({
410
+ status: s,
411
+ cancellation_reason: i,
412
+ salt: n
413
+ }), g);
414
+ if ("error" in l) {
415
+ this.schedulerStore.set("isLoading", !1);
416
+ const f = (v = l.error) == null ? void 0 : v.type;
417
+ let _ = l.error;
418
+ if (f && f in this.errors.api(r)) {
419
+ const S = this.getErrorMessage(_);
420
+ _ = this.errors.api(r)[f](S);
421
+ }
422
+ return { error: _ };
423
+ }
424
+ return "data" in l && s === "confirmed" ? this.schedulerStore.set("confirmedEventInfo", l == null ? void 0 : l.data) : "request_id" in l && s === "cancelled" && this.schedulerStore.set("cancelledEventInfo", {
425
+ booking_id: t
426
+ }), this.schedulerStore.set("organizerConfirmationBookingId", ""), this.schedulerStore.set("isLoading", !1), l;
380
427
  }
381
428
  }
382
429
  function N(a = {}) {
@@ -398,16 +445,16 @@ function N(a = {}) {
398
445
  ...a
399
446
  };
400
447
  b("[defaultNylasStoreState]: ", e);
401
- const t = z(e);
448
+ const t = $(e);
402
449
  return t.onChange("availability", (s) => {
403
450
  b("[availability]: ", s);
404
451
  const i = s.map((o) => o.start_time);
405
452
  b("[selectableDates]: ", i), t.set("selectableDates", i);
406
- const r = s[0];
407
- if (!r)
453
+ const n = s[0];
454
+ if (!n)
408
455
  return;
409
- const n = Math.floor((r.end_time.getTime() - r.start_time.getTime()) / 6e4);
410
- b("[durationMinutes]: ", n), t.set("eventDuration", n);
456
+ const r = Math.floor((n.end_time.getTime() - n.start_time.getTime()) / 6e4);
457
+ b("[durationMinutes]: ", r), t.set("eventDuration", r);
411
458
  }), t.reset = () => {
412
459
  for (const s in e) {
413
460
  const i = e[s];
@@ -417,6 +464,6 @@ function N(a = {}) {
417
464
  }
418
465
  export {
419
466
  N as C,
420
- k as E,
421
- C as N
467
+ w as E,
468
+ U as N
422
469
  };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./index-eb33703c.cjs");exports.ErrorCategory=void 0;(function(a){a.Component="component",a.Api="api",a.Auth="auth"})(exports.ErrorCategory||(exports.ErrorCategory={}));var E;(function(a){a.endtime_not_in_future="endtime_not_in_future",a.no_booking_info="no_booking_info",a.no_timeslot_selected="no_timeslot_selected",a.no_timezone_selected="no_timezone_selected",a.no_booking_id="no_booking_id",a.no_salt="no_salt",a.invalid_start_time="invalid_start_time",a.invalid_end_time="invalid_end_time",a.invalid_timezone="invalid_timezone"})(E||(E={}));var B;(function(a){a.invalid_session="invalid_session",a.general_error="general_error",a.internal_error="internal_error",a.invalid_request_error="invalid_request_error",a.timeslot_not_available="timeslot_not_available",a.provider_error="provider_error",a.not_found_error="not_found_error"})(B||(B={}));class C{constructor(){this.component=e=>{const t=exports.ErrorCategory.Component,s=`${e} Error`;return{endtime_not_in_future:(i='"endtime" can not be in the future')=>({title:s,message:i,category:t}),no_booking_info:(i="No booking info provided")=>({title:s,message:i,category:t}),no_timeslot_selected:(i="No timeslot selected")=>({title:s,message:i,category:t}),no_timezone_selected:(i="No timezone selected")=>({title:s,message:i,category:t}),no_booking_id:(i="No booking id provided")=>({title:s,message:i,category:t}),no_salt:(i="No salt provided")=>({title:s,message:i,category:t}),invalid_start_time:(i="Invalid start time")=>({title:s,message:i,category:t}),invalid_end_time:(i="Invalid end time")=>({title:s,message:i,category:t}),invalid_timezone:(i="Invalid timezone")=>({title:s,message:i,category:t})}},this.api=e=>{const t=exports.ErrorCategory.Api,s=`${e} Error`;return{invalid_session:i=>({title:s,message:i,category:t}),general_error:i=>({title:s,message:i,category:t}),internal_error:i=>({title:s,message:i,category:t}),invalid_request_error:i=>({title:s,message:i,category:t}),timeslot_not_available:i=>({title:s,message:i,category:t}),provider_error:i=>({title:s,message:i,category:t}),not_found_error:i=>({title:s,message:i,category:t})}}}}class z{constructor({schedulerAPIURL:e,schedulerStore:t,sessionId:s,configId:i,slug:n,clientId:r}){this.errors=new C,this.schedulerStore=t,this.schedulerAPIURL=e,this.sessionId=s,this.configId=i,this.slug=n,this.clientId=r}getHeaders(){return this.sessionId?{Authorization:`Bearer ${this.sessionId}`}:{}}async makeAPIRequest(e,t,s,i={}){try{const n=new URL(this.schedulerAPIURL);return n.pathname=e,await(await fetch(decodeURIComponent(n.toString()),{method:t,headers:{"Content-Type":"application/json",Origin:window.location.origin,...i},body:s})).json()}catch(n){return{error:{message:n.message,title:"API request failed",type:"api"}}}}getErrorMessage(e){var s,i,n,r;let t=(e==null?void 0:e.message)||(e==null?void 0:e.title)||"Something went wrong";return(e==null?void 0:e.type)==="provider_error"&&(t=((i=(s=e==null?void 0:e.provider_error)==null?void 0:s.error)==null?void 0:i.message)||((r=(n=e==null?void 0:e.provider_error)==null?void 0:n.error)==null?void 0:r.title)||"Something went wrong"),t}setConfigId(e){this.configId=e}selectDate(e){this.schedulerStore.set("selectedDate",e),this.schedulerStore.set("selectedTimeslot",null)}selectTime(e){this.schedulerStore.set("selectedTimeslot",e)}selectTimezone(e){this.schedulerStore.set("selectedTimezone",e)}selectLanguage(e){this.schedulerStore.set("selectedLanguage",e),c.instance.changeLanguage(e)}async toggleAdditionalData(e){e||await this.refetchAvailability(),this.schedulerStore.set("showBookingForm",e)}setParticipantName(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,name:e}})}setParticipantEmail(e){const{bookingInfo:t}=this.schedulerStore.state;this.schedulerStore.set("bookingInfo",{...t,primaryParticipant:{...t==null?void 0:t.primaryParticipant,email:e}})}async refetchAvailability(){const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3,s=t<e.getTime()/1e3?Math.floor(e.getTime()/1e3):t,i=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;return await this.getAvailability(s,i)}async resetStoreStateAndFetchAvailability(){const e=new Date,t=await this.refetchAvailability(),s=this.schedulerStore.get("availability").find(n=>new Date(n.start_time)>new Date);let i=e;return s&&(i=s.start_time),this.schedulerStore.set("selectedDate",i),this.schedulerStore.set("eventInfo",null),this.schedulerStore.set("showBookingForm",!1),this.schedulerStore.set("selectedTimeslot",null),t}async setReschedule(e){this.schedulerStore.set("isLoading",!0);const t=this.schedulerStore.state.eventInfo;return t&&this.schedulerStore.set("reschedulingEventInfo",t),this.schedulerStore.set("rescheduleBookingId",e),await this.resetStoreStateAndFetchAvailability().finally(()=>{this.schedulerStore.set("isLoading",!1)})}async setCancel(e){this.schedulerStore.set("cancelBookingId",e)}async setReject(e){this.schedulerStore.set("rejectBookingId",e)}async resetCancel(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("cancelBookingId",""),this.schedulerStore.set("rejectBookingId",""),this.schedulerStore.set("cancelledEventInfo",null),e}async goBack(){this.schedulerStore.set("cancelBookingId","")}async resetConfirm(){const e=await this.resetStoreStateAndFetchAvailability();return this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("confirmedEventInfo",void 0),e}async bookTimeslot(e){var v;this.schedulerStore.set("isLoading",!0);const{selectedTimeslot:t,selectedTimezone:s,bookingInfo:i,selectedLanguage:n}=this.schedulerStore.state;if(!e&&!i)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_booking_info()};const r=(e==null?void 0:e.timeslot)||t;if(!r)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timeslot_selected()};const o=e&&(e!=null&&e.timezone)?e==null?void 0:e.timezone:s;if(!o)return{error:this.errors.component(c.instance.t("createBookingErrorTitle")).no_timezone_selected()};const u=this.schedulerStore.get("availabilityOrderEmails");let g="";if(u.length>0){const m=r.emails;for(let p=0;p<u.length;p++)if(m.includes(u[p])){g=u[p];break}}const l=e?e==null?void 0:e.primaryParticipant:i==null?void 0:i.primaryParticipant,I=e?(e==null?void 0:e.guests)||[]:(i==null?void 0:i.guests)||[],f=e?e==null?void 0:e.additionalFields:i==null?void 0:i.additionalFields,_=this.getHeaders(),h=`/v3/scheduling/bookings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,d=await this.makeAPIRequest(decodeURIComponent(h),"POST",JSON.stringify({participants:g?[{email:g}]:void 0,additional_fields:f,additional_guests:I,guest:{...l},start_time:r.start_time.getTime()/1e3,end_time:r.end_time.getTime()/1e3,timezone:o,email_language:this.getTwoLetterLanguageCode(n)}),_);if("error"in d){this.schedulerStore.set("isLoading",!1);const m=(v=d.error)==null?void 0:v.type;let p=d.error;if(m&&m in this.errors.api("Create Booking")){const b=this.getErrorMessage(p);p=this.errors.api("Create Booking")[m](b)}return{error:p}}return"data"in d&&this.schedulerStore.set("eventInfo",d==null?void 0:d.data),this.schedulerStore.set("isLoading",!1),d}async getUISettings(){var n;this.schedulerStore.set("isLoading",!0);const e=this.getHeaders(),s=`/v3/scheduling/ui-settings${!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:""}`,i=await this.makeAPIRequest(s,"GET",void 0,e);if("error"in i){this.schedulerStore.set("isLoading",!1);const r=(n=i.error)==null?void 0:n.type;let o=i.error;return r&&r in this.errors.api(c.instance.t("getUISettingErrorTitle"))&&(o=this.errors.api(c.instance.t("getUISettingErrorTitle"))[r]((o==null?void 0:o.message)||(o==null?void 0:o.title)||"Something went wrong")),{error:o}}return"data"in i&&this.schedulerStore.set("configSettings",i.data),this.schedulerStore.set("isLoading",!1),i}getTwoLetterLanguageCode(e){return e.split("-")[0]}getStartTimeWithMinBookingNotice(e){var i;const t=(i=this.schedulerStore.get("configSettings"))==null?void 0:i.scheduler,s=t==null?void 0:t.min_booking_notice;return s?e+s*60:e}getEndTimeForAvailableDaysInFuture(e){var r,o;const t=new Date,s=(o=(r=this.schedulerStore.get("configSettings"))==null?void 0:r.scheduler)==null?void 0:o.available_days_in_future,i=Math.floor(c.addDaysToCurrentDate(t,s).getTime()/1e3);return Math.min(i,e)}async getAvailability(e=0,t=0){var I,f,_,S;this.schedulerStore.set("isLoading",!0);const s=new URLSearchParams,i=new Date,n=i.getTime();if(t&&t<n/1e3)return this.schedulerStore.set("isLoading",!1),{error:this.errors.component(c.instance.t("getAvailabilityErrorTitle")).endtime_not_in_future()};if(!e){const h=new Date(i.getFullYear(),i.getMonth(),1);e=Math.floor(h.getTime()/1e3)}if(e=this.getStartTimeWithMinBookingNotice(e),!t){const h=new Date(i.getFullYear(),i.getMonth()+1,0);t=Math.floor(h.getTime()/1e3)}t=this.getEndTimeForAvailableDaysInFuture(t),s.append("start_time",encodeURIComponent(e.toString())),s.append("end_time",encodeURIComponent(t.toString())),this.configId&&!this.sessionId?s.append("configuration_id",encodeURIComponent(this.configId)):this.slug&&this.clientId&&!this.sessionId&&(s.append("slug",encodeURIComponent(this.slug)),s.append("client_id",encodeURIComponent(this.clientId)));const r=this.schedulerStore.get("rescheduleBookingId");r&&s.append("booking_id",encodeURIComponent(r));const o=s.toString(),u=`/v3/scheduling/availability${o?`?${o}`:""}`,g=this.getHeaders(),l=await this.makeAPIRequest(decodeURIComponent(u),"GET",void 0,g);if("error"in l){this.schedulerStore.set("availability",[]),this.schedulerStore.set("isLoading",!1);const h=(I=l.error)==null?void 0:I.type;let d=l.error;if(h&&h in this.errors.api(c.instance.t("getAvailabilityErrorTitle"))){const v=this.getErrorMessage(d);d=this.errors.api(c.instance.t("getAvailabilityErrorTitle"))[h](v)}return{error:d}}if("data"in l){const d=(((_=(f=l.data)==null?void 0:f.time_slots)==null?void 0:_.map(m=>({...m,start_time:new Date(m.start_time*1e3),end_time:new Date(m.end_time*1e3)})))||[]).filter(m=>m.start_time.getTime()>n);this.schedulerStore.set("availability",d);const v=((S=l.data)==null?void 0:S.order)||[];this.schedulerStore.set("availabilityOrderEmails",v)}return this.schedulerStore.set("isLoading",!1),l}async cancelBooking(e,t){var o;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("cancelBookingErrorTitle")).no_booking_id()};const s=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",i=`/v3/scheduling/bookings/${e}${s}`,n=this.getHeaders(),r=await this.makeAPIRequest(decodeURIComponent(i),"DELETE",JSON.stringify({action:"cancel",cancellation_reason:t}),n);if("error"in r){this.schedulerStore.set("isLoading",!1);const u=(o=r.error)==null?void 0:o.type;let g=r.error;if(u&&u in this.errors.api(c.instance.t("cancelBookingErrorTitle"))){const l=this.getErrorMessage(g);g=this.errors.api(c.instance.t("cancelBookingErrorTitle"))[u](l)}return{error:g}}return this.schedulerStore.set("cancelledEventInfo",{booking_id:e}),this.schedulerStore.set("rescheduleBookingId",""),this.schedulerStore.set("isLoading",!1),r}async rescheduleBooking(e,t){var L;if(this.schedulerStore.set("isLoading",!0),!e)return{error:this.errors.component(c.instance.t("rescheduleBookingErrorTitle")).no_booking_id()};const s=this.errors.api(c.instance.t("rescheduleBookingErrorTitle")),i=this.errors.component(c.instance.t("rescheduleBookingErrorTitle")),{bookingInfo:n,selectedTimeslot:r,selectedTimezone:o,selectedLanguage:u}=this.schedulerStore.state,{startTime:g,endTime:l,timezone:I}=t,f=g||(r==null?void 0:r.start_time);if(!f)return{error:i.invalid_start_time('Please pass "startTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const _=l||(r==null?void 0:r.end_time);if(!_)return{error:i.invalid_end_time('Please pass "endTime" in data or set "selectedTimeslot" in the defaultSchedulerState.')};const S=this.schedulerStore.get("availabilityOrderEmails");let h="";if(S.length>0){const T=(r==null?void 0:r.emails)||[];for(let k=0;k<S.length;k++)if(T.includes(S[k])){h=S[k];break}}const d=I||o;if(!d)return{error:i.invalid_timezone('Please pass "timezone" in data or set "selectedTimezone" in the defaultSchedulerState.')};const v=t?t==null?void 0:t.primaryParticipant:n==null?void 0:n.primaryParticipant,m=t?(t==null?void 0:t.guests)||[]:(n==null?void 0:n.guests)||[],p=t?t==null?void 0:t.additionalFields:n==null?void 0:n.additionalFields,b=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",A=`/v3/scheduling/bookings/${e}${b}`,D=this.getHeaders(),y=await this.makeAPIRequest(decodeURIComponent(A),"PATCH",JSON.stringify({start_time:f.getTime()/1e3,end_time:_.getTime()/1e3,timezone:d,additional_fields:p,guest:{...v},additional_guests:m,participants:h?[{email:h}]:void 0,email_language:this.getTwoLetterLanguageCode(u)}),D);if("error"in y){this.schedulerStore.set("isLoading",!1);const T=(L=y.error)==null?void 0:L.type;let k=y.error;if(T&&T in s){const P=this.getErrorMessage(k);k=s[T](P)}return{error:k}}const w=this.schedulerStore.get("reschedulingEventInfo");if("data"in y)this.schedulerStore.set("eventInfo",y==null?void 0:y.data);else if(w)this.schedulerStore.set("eventInfo",w);else{const T={booking_id:e};this.schedulerStore.set("eventInfo",T)}return this.schedulerStore.set("isLoading",!1),y}async updateBooking(e){var I;this.schedulerStore.set("isLoading",!0);const{bookingId:t,status:s,reason:i}=e,n=this.schedulerStore.get("organizerConfirmationSalt"),r=s==="confirmed"?c.instance.t("confirmBookingErrorTitle"):c.instance.t("rejectBookingErrorTitle");if(!t)return{error:this.errors.component(r).no_booking_id()};if(!n)return{error:this.errors.component(r).no_salt()};const o=!this.sessionId&&this.configId?`?configuration_id=${this.configId}`:!this.sessionId&&this.slug&&this.clientId?`?slug=${this.slug}&client_id=${this.clientId}`:"",u=`/v3/scheduling/bookings/${t}${o}`,g=this.getHeaders(),l=await this.makeAPIRequest(decodeURIComponent(u),"PUT",JSON.stringify({status:s,cancellation_reason:i,salt:n}),g);if("error"in l){this.schedulerStore.set("isLoading",!1);const f=(I=l.error)==null?void 0:I.type;let _=l.error;if(f&&f in this.errors.api(r)){const S=this.getErrorMessage(_);_=this.errors.api(r)[f](S)}return{error:_}}return"data"in l&&s==="confirmed"?this.schedulerStore.set("confirmedEventInfo",l==null?void 0:l.data):"request_id"in l&&s==="cancelled"&&this.schedulerStore.set("cancelledEventInfo",{booking_id:t}),this.schedulerStore.set("organizerConfirmationBookingId",""),this.schedulerStore.set("isLoading",!1),l}}function M(a={}){const e={selectedDate:null,selectedLanguage:navigator.language,selectedTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,selectedTimeslot:null,showBookingForm:!1,availabilityOrderEmails:[],selectableDates:null,availability:[],eventDuration:0,state:"ready",eventInfo:null,cancelledEventInfo:null,isLoading:!1,nylasBranding:!0,...a};c.debug("[defaultNylasStoreState]: ",e);const t=c.createStore(e);return t.onChange("availability",s=>{c.debug("[availability]: ",s);const i=s.map(o=>o.start_time);c.debug("[selectableDates]: ",i),t.set("selectableDates",i);const n=s[0];if(!n)return;const r=Math.floor((n.end_time.getTime()-n.start_time.getTime())/6e4);c.debug("[durationMinutes]: ",r),t.set("eventDuration",r)}),t.reset=()=>{for(const s in e){const i=e[s];t.set(s,i)}},t}exports.CreateNylasSchedulerStore=M;exports.NylaSchedulerAPIConnector=z;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-eb33703c.cjs"),r=require("./index-6d9eeb53-b2a6d09f.cjs");require("./index-53420959-fcf45780.cjs");require("react");require("react-dom");const l=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--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-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0;display:flex;gap:4px;align-items:center}label .error{color:var(--nylas-error)}textarea{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}',n=l,t=class{constructor(a){e.registerInstance(this,a),this.nylasFormInputChanged=e.createEvent(this,"nylasFormInputChanged",7),this.name="textarea",this.defaultValue="",this.label="",this.placeholder="",this.required=!1,this.readOnly=!1,this.autoFocus=!1,this.maxLength=255,this.type="multi_line_text",this.tooltip="",this.value="",this.error=""}componentWillLoad(){this.value=r.sanitizeHtml$1(this.defaultValue)}handleBookingFormSubmitted(a){this.validate(this.value),this.error&&a.preventDefault()}handleInput(a){const s=a.target;this.value=r.sanitizeHtml$1(s.value),this.nylasFormInputChanged.emit({value:this.value,name:this.name,error:this.error,label:this.label,type:this.type})}validate(a){this.required&&!a?this.error=`${this.label} is required.`:a.length>this.maxLength?this.error=`${this.label} cannot exceed ${this.maxLength} characters.`:this.error=""}render(){return e.h("label",{key:"b7a5eaff4d1b4b5a5e28ff77be0f355497c63add",part:"tc__label",class:{error:!!this.error}},e.h("p",{key:"3f07cee33052ac9209f2ad5e29d4fe58a53d0cde"},e.h("span",{key:"538f808ae20cd4ec60627d9575e8e3ad486c01db",class:"label"},this.label),this.required&&e.h("span",{class:"required"},"*"),this.tooltip&&e.h("tooltip-component",null,e.h("info-icon",{slot:"tooltip-icon"}),e.h("span",{slot:"tooltip-content"},this.tooltip))),e.h("textarea",{key:"ce6b7cb2b2a024ee259e9cc970f9819bb258645d",name:this.name,placeholder:this.placeholder,readOnly:this.readOnly,autoFocus:this.autoFocus,value:this.value,maxLength:this.maxLength,onInput:a=>this.handleInput(a),class:{error:!!this.error},part:"tc__textarea"}),this.error&&e.h("span",{class:"error help-text"},this.error))}};t.style=n;exports.textarea_component=t;
@@ -0,0 +1,36 @@
1
+ import { r as s, c as l, h as a } from "./index-5ccfd9df.js";
2
+ import { s as r } from "./index-6d9eeb53-58c8980a.js";
3
+ import "./index-53420959-5fc8ad2b.js";
4
+ import "react";
5
+ import "react-dom";
6
+ const n = ':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--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-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;width:100%}label{display:flex;color:var(--nylas-base-800, #293056);font-size:14px;font-style:normal;font-weight:400;line-height:150%;flex-direction:column;gap:4px;font-family:var(--nylas-font-family);font-size:16px;color:var(--nylas-base-800)}label.error{color:var(--nylas-error)}label span.required{color:var(--nylas-error);padding:0 0.25rem}label p{margin:0;display:flex;gap:4px;align-items:center}label .error{color:var(--nylas-error)}textarea{display:flex;height:48px;padding-left:16px;align-items:center;gap:8px;align-self:stretch;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-300);background:var(--nylas-base-0);width:-webkit-fill-available;color:var(--nylas-base-900);font-size:16px;font-style:normal;font-weight:400;line-height:150%;padding:12px 16px;border-width:1;resize:vertical;border-radius:8px;font-family:var(--nylas-font-family);font-size:16px;line-height:24px}textarea:focus{outline-color:var(--nylas-primary)}textarea.error{border-radius:var(--nylas-border-radius-2x);font-weight:600;border-color:var(--nylas-error);border-width:2px}textarea.error::placeholder{font-weight:400}textarea::placeholder{color:var(--nylas-base-300)}textarea::-webkit-resizer{display:none}', i = n, o = class {
7
+ constructor(e) {
8
+ s(this, e), this.nylasFormInputChanged = l(this, "nylasFormInputChanged", 7), this.name = "textarea", this.defaultValue = "", this.label = "", this.placeholder = "", this.required = !1, this.readOnly = !1, this.autoFocus = !1, this.maxLength = 255, this.type = "multi_line_text", this.tooltip = "", this.value = "", this.error = "";
9
+ }
10
+ componentWillLoad() {
11
+ this.value = r(this.defaultValue);
12
+ }
13
+ handleBookingFormSubmitted(e) {
14
+ this.validate(this.value), this.error && e.preventDefault();
15
+ }
16
+ handleInput(e) {
17
+ const t = e.target;
18
+ this.value = r(t.value), this.nylasFormInputChanged.emit({
19
+ value: this.value,
20
+ name: this.name,
21
+ error: this.error,
22
+ label: this.label,
23
+ type: this.type
24
+ });
25
+ }
26
+ validate(e) {
27
+ this.required && !e ? this.error = `${this.label} is required.` : e.length > this.maxLength ? this.error = `${this.label} cannot exceed ${this.maxLength} characters.` : this.error = "";
28
+ }
29
+ render() {
30
+ return a("label", { key: "b7a5eaff4d1b4b5a5e28ff77be0f355497c63add", part: "tc__label", class: { error: !!this.error } }, a("p", { key: "3f07cee33052ac9209f2ad5e29d4fe58a53d0cde" }, a("span", { key: "538f808ae20cd4ec60627d9575e8e3ad486c01db", class: "label" }, this.label), this.required && a("span", { class: "required" }, "*"), this.tooltip && a("tooltip-component", null, a("info-icon", { slot: "tooltip-icon" }), a("span", { slot: "tooltip-content" }, this.tooltip))), a("textarea", { key: "ce6b7cb2b2a024ee259e9cc970f9819bb258645d", name: this.name, placeholder: this.placeholder, readOnly: this.readOnly, autoFocus: this.autoFocus, value: this.value, maxLength: this.maxLength, onInput: (e) => this.handleInput(e), class: { error: !!this.error }, part: "tc__textarea" }), this.error && a("span", { class: "error help-text" }, this.error));
31
+ }
32
+ };
33
+ o.style = i;
34
+ export {
35
+ o as textarea_component
36
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-eb33703c.cjs");require("react");require("react-dom");const s=".time-period-selector.sc-time-period-selector{display:grid;gap:0.5rem;grid-template-columns:auto 1fr}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector,.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector{width:116px}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector{width:84px;display:flex;align-items:center}.time-period-selector.sc-time-period-selector select-dropdown#time-period.sc-time-period-selector::part(sd_dropdown-button){width:100%}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown){width:inherit;height:100%}.time-period-selector.sc-time-period-selector input-dropdown#time-number.sc-time-period-selector::part(id_dropdown-input){border:none;border-radius:var(--nylas-border-radius-2x)}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-input){padding:17px;gap:1rem}.time-period-selector.sc-time-period-selector input-dropdown.sc-time-period-selector::part(id_dropdown-content){width:100%;max-height:200px}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown){width:inherit}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-button){padding:1rem;gap:1rem;justify-content:space-between}.time-period-selector.sc-time-period-selector select-dropdown.sc-time-period-selector::part(sd_dropdown-content){width:100%;max-height:200px}",n=s,l={hours:"hour",days:"day",weeks:"week",months:"month"},o=class{constructor(t){i.registerInstance(this,t),this.timePeriodChanged=i.createEvent(this,"timePeriodChanged",7),this.timePeriods=["hour","day","week","month"],this.defaultSelectedPeriod="hour",this.defaultSelectedNumber=1,this.selectedPeriod=this.defaultSelectedPeriod,this.selectedNumber=this.defaultSelectedNumber,this.numberOptions=this.calculateOptions(this.defaultSelectedPeriod||"hour").map(e=>({label:e.toString(),value:e.toString()})),this.timePeriodOptions=this.timePeriods.map(e=>({label:e,value:e}))}defaultSelectedPeriodChangedHandler(t){this.selectedPeriod=t;const e=l[t]??t;this.updateNumberOptionsAndSelectedNumber(e)}defaultSelectedNumberChangedHandler(t){this.selectedNumber=t}timePeriodsChangedHandler(t){this.timePeriodOptions=t.map(e=>({label:e,value:e}))}calculateOptions(t){switch(t){case"hour":return Array.from({length:23},(e,r)=>r+1);case"minute":return Array.from({length:13},(e,r)=>r*5);case"day":return Array.from({length:30},(e,r)=>r+1);case"week":return Array.from({length:4},(e,r)=>r+1);case"month":return Array.from({length:12},(e,r)=>r+1);default:return[]}}inputOptionChangedHandler(t){i.debug("time-period-selector","inputOptionChangedHandler",t.detail);const{value:e,name:r}=t.detail;r==="time-number"&&(this.selectedNumber=e?parseInt(e):this.defaultSelectedNumber);const d={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(d)}nylasFormDropdownChangedHandler(t){i.debug("time-period-selector","nylasFormDropdownChangedHandler",t.detail);const{value:e,name:r}=t.detail;r==="time-period"?(this.selectedPeriod=e,this.updateNumberOptionsAndSelectedNumber(e)):r==="time-number"&&(this.selectedNumber=parseInt(e));const d={number:this.selectedNumber,period:this.selectedPeriod};this.timePeriodChanged.emit(d)}updateNumberOptionsAndSelectedNumber(t){const e=this.calculateOptions(t);this.numberOptions=e.map(r=>({label:r.toString(),value:r.toString()})),this.selectedNumber=parseInt(this.numberOptions[0].value)}render(){return i.h("div",{key:"2e02e602c84d10f1c2ed8dc8e6a989f7ec4c22f8",class:"time-period-selector"},i.h("input-dropdown",{key:"aaf9b85eb568c308385d41127c91c4e51261cb2f",id:"time-number",name:"time-number",inputValue:this.selectedNumber.toString(),exportparts:"id_dropdown: tps__number-dropdown, id_dropdown-input: tps__number-dropdown-button, id_dropdown-content: tps__number-dropdown-content",options:this.numberOptions,defaultInputOption:this.numberOptions.find(t=>t.value==this.selectedNumber.toString())??this.numberOptions[0]}),i.h("select-dropdown",{key:"5537a3e02a876cbf49f5ace4c8f3bb153ed6b3ce",id:"time-period",name:"time-period",options:this.timePeriodOptions,exportparts:"sd_dropdown: tps__period-dropdown, sd_dropdown-button: tps__period-dropdown-button, sd_dropdown-content: tps__period-dropdown-content",pluralizedLabel:this.selectedNumber>1?"s":"",defaultSelectedOption:this.timePeriodOptions.find(t=>t.value==this.selectedPeriod)??this.timePeriodOptions[0],withSearch:!1}))}get host(){return i.getElement(this)}static get watchers(){return{defaultSelectedPeriod:["defaultSelectedPeriodChangedHandler"],defaultSelectedNumber:["defaultSelectedNumberChangedHandler"],timePeriods:["timePeriodsChangedHandler"]}}};o.style=n;exports.time_period_selector=o;