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

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 (129) hide show
  1. package/dist/add-circle-icon_22.entry-8d0ac489.cjs +1 -0
  2. package/dist/{add-circle-icon_18.entry-f86ae88d.js → add-circle-icon_22.entry-da31fa71.js} +627 -421
  3. package/dist/{archive-icon_7.entry-052ac074.cjs → archive-icon_7.entry-7aad8104.cjs} +1 -1
  4. package/dist/{archive-icon_7.entry-0e34d6e7.js → archive-icon_7.entry-bc2418f7.js} +20 -20
  5. package/dist/{arrow-icon.entry-93f21385.cjs → arrow-icon.entry-6eba68a9.cjs} +1 -1
  6. package/dist/arrow-icon.entry-9a932082.js +15 -0
  7. package/dist/{bold-icon_3.entry-88ce1d25.js → bold-icon_3.entry-5f7e3755.js} +8 -8
  8. package/dist/bold-icon_3.entry-db17d481.cjs +1 -0
  9. package/dist/{calendar-cancel-icon.entry-e9c692fa.js → calendar-cancel-icon.entry-1ff7845a.js} +5 -5
  10. package/dist/{calendar-cancel-icon.entry-574c8aa4.cjs → calendar-cancel-icon.entry-a5141f82.cjs} +1 -1
  11. package/dist/{calendar-check-icon_2.entry-b0476bca.cjs → calendar-check-icon_2.entry-c3add652.cjs} +1 -1
  12. package/dist/{calendar-check-icon_2.entry-d461c713.js → calendar-check-icon_2.entry-d7421059.js} +6 -6
  13. package/dist/{calendar-icon.entry-1ca202a4.js → calendar-icon.entry-4458997f.js} +5 -5
  14. package/dist/{calendar-icon.entry-98936e6d.cjs → calendar-icon.entry-445d624a.cjs} +1 -1
  15. package/dist/chevron-icon_3.entry-8961e6bb.cjs +1 -0
  16. package/dist/chevron-icon_3.entry-f7f3d487.js +117 -0
  17. package/dist/close-icon.entry-6dd5ff0a.js +15 -0
  18. package/dist/close-icon.entry-ebc527c5.cjs +1 -0
  19. package/dist/{constants-b6bf6671-49a0f1f2.js → constants-6ee60d6d-4cd16450.js} +1 -1
  20. package/dist/{constants-b6bf6671-27e2557d.cjs → constants-6ee60d6d-6c0540db.cjs} +1 -1
  21. package/dist/document-refresh-icon.entry-298b2133.cjs +1 -0
  22. package/dist/{document-refresh-icon.entry-faea08ce.js → document-refresh-icon.entry-bdc323b5.js} +5 -5
  23. package/dist/elements/index.d.ts +7 -0
  24. package/dist/{forward-icon_6.entry-c4b37cb1.cjs → forward-icon_6.entry-15208ea9.cjs} +2 -2
  25. package/dist/{forward-icon_6.entry-8da1f65d.js → forward-icon_6.entry-62759373.js} +63 -63
  26. package/dist/{globe-icon.entry-4720304b.js → globe-icon.entry-9e082178.js} +2 -2
  27. package/dist/{globe-icon.entry-90a0b9c9.cjs → globe-icon.entry-c8302bf5.cjs} +1 -1
  28. package/dist/google-logo-icon_3.entry-0c095209.js +258 -0
  29. package/dist/google-logo-icon_3.entry-f8433ff9.cjs +1 -0
  30. package/dist/index-0f3bd8df.js +1824 -0
  31. package/dist/index-7a55dc33.cjs +30 -0
  32. package/dist/index.d.ts +4 -2
  33. package/dist/index.es-2578c6a5-098d48d0.cjs +7 -0
  34. package/dist/{index-10914bc1-346f04fa.js → index.es-2578c6a5-71441142.js} +833 -933
  35. package/dist/{info-icon_2.entry-9307db18.js → info-icon_2.entry-73106882.js} +5 -5
  36. package/dist/{info-icon_2.entry-81e95048.cjs → info-icon_2.entry-ca224a3b.cjs} +1 -1
  37. package/dist/loading-icon.entry-012644b7.js +15 -0
  38. package/dist/loading-icon.entry-f9f5e66f.cjs +1 -0
  39. package/dist/mailbox-store-bb21512c-045c3ea0.cjs +1 -0
  40. package/dist/{mailbox-store-e721b17c-cf9a43dd.js → mailbox-store-bb21512c-615660ef.js} +125 -62
  41. package/dist/nylas-additional-participants.entry-a50ef8e2.cjs +1 -0
  42. package/dist/{nylas-additional-participants.entry-1653dec7.js → nylas-additional-participants.entry-db85836a.js} +13 -13
  43. package/dist/{nylas-booked-event-card_10.entry-aa971e8a.js → nylas-booked-event-card_10.entry-b49b2369.js} +26 -26
  44. package/dist/nylas-booked-event-card_10.entry-fccb783c.cjs +1 -0
  45. package/dist/nylas-form-card.entry-090a4d3b.js +56 -0
  46. package/dist/nylas-form-card.entry-f5230005.cjs +1 -0
  47. package/dist/nylas-if-state.entry-7924dde0.js +96 -0
  48. package/dist/nylas-if-state.entry-ff9c9a85.cjs +1 -0
  49. package/dist/{nylas-list-folders.entry-995fa819.js → nylas-list-folders.entry-9dd96530.js} +4 -4
  50. package/dist/{nylas-list-folders.entry-3b24d92d.cjs → nylas-list-folders.entry-dbfc2cf8.cjs} +1 -1
  51. package/dist/{nylas-list-threads.entry-fda42ded.cjs → nylas-list-threads.entry-6bcc0328.cjs} +1 -1
  52. package/dist/{nylas-list-threads.entry-21466eb3.js → nylas-list-threads.entry-b435eaae.js} +6 -6
  53. package/dist/nylas-login.entry-1623d309.cjs +1 -0
  54. package/dist/nylas-login.entry-97350c76.js +75 -0
  55. package/dist/{nylas-mailbox-pagination.entry-9dcd4901.cjs → nylas-mailbox-pagination.entry-1776eb16.cjs} +1 -1
  56. package/dist/{nylas-mailbox-pagination.entry-02d40186.js → nylas-mailbox-pagination.entry-ceef8be2.js} +3 -3
  57. package/dist/{nylas-mailbox-toolbar-button.entry-d1099fab.cjs → nylas-mailbox-toolbar-button.entry-7d3f79b9.cjs} +1 -1
  58. package/dist/{nylas-mailbox-toolbar-button.entry-dbad44b4.js → nylas-mailbox-toolbar-button.entry-e6b3d3a4.js} +10 -10
  59. package/dist/nylas-mailbox.entry-06d8014a.js +136 -0
  60. package/dist/nylas-mailbox.entry-ae8da6ff.cjs +1 -0
  61. package/dist/{nylas-provider.entry-bbee8c99.js → nylas-provider.entry-8b9c2b69.js} +50 -58
  62. package/dist/nylas-provider.entry-97c9e272.cjs +1 -0
  63. package/dist/nylas-scheduler-editor.entry-c3791787.js +2181 -0
  64. package/dist/nylas-scheduler-editor.entry-f6cf1cd9.cjs +7 -0
  65. package/dist/nylas-scheduling.entry-08ae840a.cjs +1 -0
  66. package/dist/{nylas-scheduling.entry-22b5ad07.js → nylas-scheduling.entry-6380509a.js} +39 -38
  67. package/dist/{nylas-threads-refresh.entry-05258b36.cjs → nylas-threads-refresh.entry-246e6d77.cjs} +1 -1
  68. package/dist/{nylas-threads-refresh.entry-414d8740.js → nylas-threads-refresh.entry-eaee86fb.js} +5 -5
  69. package/dist/nylas-threads-search.entry-42a2acb1.cjs +1 -0
  70. package/dist/{nylas-threads-search.entry-a19dc90f.js → nylas-threads-search.entry-7e12758e.js} +7 -7
  71. package/dist/{nylas-view-thread.entry-5da81e99.cjs → nylas-view-thread.entry-78e6927a.cjs} +1 -1
  72. package/dist/{nylas-view-thread.entry-38149162.js → nylas-view-thread.entry-b936e76a.js} +4 -4
  73. package/dist/{people-icon.entry-5c244c8d.js → people-icon.entry-5c8ee696.js} +5 -5
  74. package/dist/{people-icon.entry-4b682757.cjs → people-icon.entry-bcf848c0.cjs} +1 -1
  75. package/dist/play-icon_2.entry-356e63cc.js +25 -0
  76. package/dist/play-icon_2.entry-92e78f1b.cjs +1 -0
  77. package/dist/react.cjs +1 -1
  78. package/dist/react.js +84 -75
  79. package/dist/{refresh-icon.entry-63456c9a.js → refresh-icon.entry-77f0c377.js} +2 -2
  80. package/dist/{refresh-icon.entry-59fff3d4.cjs → refresh-icon.entry-bec053b6.cjs} +1 -1
  81. package/dist/{register-component-d056a880-f3003d6c.js → register-component-dc659dc3-0fdb18dc.js} +2 -2
  82. package/dist/{register-component-d056a880-2be11c56.cjs → register-component-dc659dc3-f58bf25b.cjs} +1 -1
  83. package/dist/scheduler-config-store-51ee4f42-ce3a9b0e.cjs +1 -0
  84. package/dist/scheduler-config-store-51ee4f42-e02895da.js +14 -0
  85. package/dist/{scheduler-store-0fbe642c-14466305.js → scheduler-store-72116723-3ba2480c.js} +3 -2
  86. package/dist/scheduler-store-72116723-db9d91f6.cjs +1 -0
  87. package/dist/time-period-selector.entry-decd251b.js +78 -0
  88. package/dist/time-period-selector.entry-f25fad77.cjs +1 -0
  89. package/dist/{translate-icon.entry-35999e70.js → translate-icon.entry-cac02c46.js} +2 -2
  90. package/dist/{translate-icon.entry-1784c18e.cjs → translate-icon.entry-dd5b707c.cjs} +1 -1
  91. package/dist/{warning-icon.entry-73de08c3.js → warning-icon.entry-370b9cf0.js} +4 -4
  92. package/dist/{warning-icon.entry-3a702d1d.cjs → warning-icon.entry-8af8a742.cjs} +1 -1
  93. package/package.json +3 -3
  94. package/dist/add-circle-icon_18.entry-b66b6343.cjs +0 -1
  95. package/dist/arrow-icon.entry-2afd9ea9.js +0 -15
  96. package/dist/auth-store-69ac49c7-5a0bbb90.cjs +0 -1
  97. package/dist/auth-store-69ac49c7-cbfda055.js +0 -66
  98. package/dist/bold-icon_3.entry-8f55a9e7.cjs +0 -1
  99. package/dist/chevron-icon_3.entry-830f52c2.js +0 -105
  100. package/dist/chevron-icon_3.entry-f7801467.cjs +0 -1
  101. package/dist/close-icon.entry-37e8361f.js +0 -15
  102. package/dist/close-icon.entry-8d6e9816.cjs +0 -1
  103. package/dist/document-refresh-icon.entry-fcb33921.cjs +0 -1
  104. package/dist/index-10914bc1-c8c3a2f3.cjs +0 -7
  105. package/dist/index-457dcf0b.cjs +0 -30
  106. package/dist/index-ce40ad47.js +0 -1570
  107. package/dist/loading-icon.entry-06d37ef0.cjs +0 -1
  108. package/dist/loading-icon.entry-dc518df4.js +0 -15
  109. package/dist/mailbox-store-e721b17c-4e97e07d.cjs +0 -1
  110. package/dist/nylas-additional-participants.entry-ff8bf378.cjs +0 -1
  111. package/dist/nylas-booked-event-card_10.entry-06bc3c51.cjs +0 -1
  112. package/dist/nylas-editor-tabs.entry-49b5a3ab.cjs +0 -1
  113. package/dist/nylas-editor-tabs.entry-9d0959bf.js +0 -181
  114. package/dist/nylas-form-card.entry-69d2095b.cjs +0 -1
  115. package/dist/nylas-form-card.entry-c4e78f88.js +0 -56
  116. package/dist/nylas-if-state_3.entry-2eb3f385.js +0 -293
  117. package/dist/nylas-if-state_3.entry-5baf6d6f.cjs +0 -1
  118. package/dist/nylas-provider.entry-78e2fa30.cjs +0 -1
  119. package/dist/nylas-scheduler-editor.entry-550d3c59.cjs +0 -1
  120. package/dist/nylas-scheduler-editor.entry-8f7ecf3b.js +0 -111
  121. package/dist/nylas-scheduling.entry-30a63738.cjs +0 -1
  122. package/dist/nylas-threads-search.entry-ff21fc65.cjs +0 -1
  123. package/dist/play-icon_2.entry-ccdc6b9c.cjs +0 -1
  124. package/dist/play-icon_2.entry-f36d6d55.js +0 -25
  125. package/dist/scheduler-config-store-4d035001-0256b40c.cjs +0 -1
  126. package/dist/scheduler-config-store-4d035001-db9dc78a.js +0 -33
  127. package/dist/scheduler-store-0fbe642c-410fdbf4.cjs +0 -1
  128. /package/dist/{utils-0cd66d04-89ab163d.js → utils-c00bdc3c-89ab163d.js} +0 -0
  129. /package/dist/{utils-0cd66d04-94b9c3b6.cjs → utils-c00bdc3c-94b9c3b6.cjs} +0 -0
@@ -1,293 +0,0 @@
1
- import { r as p, h as i, H as b, c as m, g as N } from "./index-ce40ad47.js";
2
- import { R as A } from "./register-component-d056a880-f3003d6c.js";
3
- import { d as h } from "./utils-0cd66d04-89ab163d.js";
4
- import { N as P, e as L } from "./index-10914bc1-346f04fa.js";
5
- import { C as T, N as O } from "./auth-store-69ac49c7-cbfda055.js";
6
- import { C as I, H, N as E, a as B, b as $ } from "./mailbox-store-e721b17c-cf9a43dd.js";
7
- import "react";
8
- import "react-dom";
9
- import "./_commonjsHelpers-57e89916-af061c86.js";
10
- const D = ":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}", F = D;
11
- var U = function(e, t, o, n) {
12
- var s = arguments.length, a = s < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, o) : n, r;
13
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
14
- a = Reflect.decorate(e, t, o, n);
15
- else
16
- for (var l = e.length - 1; l >= 0; l--)
17
- (r = e[l]) && (a = (s < 3 ? r(a) : s > 3 ? r(t, o, a) : r(t, o)) || a);
18
- return s > 3 && a && Object.defineProperty(t, o, a), a;
19
- }, y = function(e, t) {
20
- if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
21
- return Reflect.metadata(e, t);
22
- };
23
- const M = class {
24
- constructor(e) {
25
- p(this, e), this.state = void 0, this.isStateSet = void 0, this.isBoolean = void 0, this.getStore = void 0, this.transition = "none", this.show = !1, this.classes = {}, this.initTransition = this.initTransition.bind(this);
26
- }
27
- connectedCallback() {
28
- }
29
- disconnectedCallback() {
30
- }
31
- async componentWillLoad() {
32
- h("[nylas-if-state] Component will load"), this.watchStore(!0);
33
- }
34
- async componentDidLoad() {
35
- h("[nylas-if-state] Component did load");
36
- }
37
- shouldRender() {
38
- const [e, t] = this.state ? this.state.split(".") : ["", ""], o = this.getStore;
39
- if (typeof o > "u")
40
- return h(`[nylas-if-state] Store name: ${e} | State name: ${t}`, { getStore: o }), !1;
41
- const n = o(e);
42
- if (typeof n > "u")
43
- return h(`[nylas-if-state] Store name: ${e} | State name: ${t}`, { store: n }), !1;
44
- const s = n.state[t];
45
- return typeof this.isStateSet == "boolean" ? this.isStateSet === !1 && (typeof s > "u" || s === null || s.length === 0) || this.isStateSet === !0 && typeof s < "u" && s !== null : typeof this.isBoolean == "boolean" ? this.isBoolean === !0 && typeof s < "u" && s === !0 || this.isBoolean === !1 && typeof s < "u" && s === !1 : !1;
46
- }
47
- onGetStoreChange() {
48
- this.watchStore(!0);
49
- }
50
- watchStore(e = !1) {
51
- const [t, o] = this.state ? this.state.split(".") : ["", ""], n = this.getStore;
52
- if (typeof n > "u")
53
- return h(`[nylas-if-state] Store name: ${t} | State name: ${o}`, { getStore: n }), null;
54
- const s = n(t);
55
- if (typeof s > "u")
56
- return h(`[nylas-if-state] Store name: ${t} | State name: ${o}`, { store: s }), null;
57
- e === !0 && this.initTransition(), s.onChange(o, this.initTransition);
58
- }
59
- initTransition() {
60
- const e = this.shouldRender();
61
- switch (this.transition) {
62
- case "fade":
63
- case "slide":
64
- case "swipe":
65
- this.classes = {
66
- [`${this.transition}-in`]: e,
67
- [`${this.transition}-out`]: !e
68
- }, setTimeout(() => {
69
- this.show = e;
70
- }, 150);
71
- break;
72
- default:
73
- this.show = this.shouldRender();
74
- break;
75
- }
76
- }
77
- render() {
78
- return i(b, { key: "91d17bc89a09742106ef3bd9365c5ce48cf14e86" }, i("div", { key: "9d0070be4bf5d9a5f405fc4a0733e6d832fa669a", class: this.classes }, this.show && i("slot", null)));
79
- }
80
- static get watchers() {
81
- return {
82
- getStore: ["onGetStoreChange"]
83
- };
84
- }
85
- };
86
- U([
87
- A({
88
- name: "nylas-if-state",
89
- getStoresToProp: "getStore",
90
- fireRegisterEvent: !0
91
- }),
92
- y("design:type", Function),
93
- y("design:paramtypes", []),
94
- y("design:returntype", void 0)
95
- ], M.prototype, "render", null);
96
- M.style = F;
97
- const j = ":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}", z = j;
98
- var W = function(e, t, o, n) {
99
- var s = arguments.length, a = s < 3 ? t : n === null ? n = Object.getOwnPropertyDescriptor(t, o) : n, r;
100
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function")
101
- a = Reflect.decorate(e, t, o, n);
102
- else
103
- for (var l = e.length - 1; l >= 0; l--)
104
- (r = e[l]) && (a = (s < 3 ? r(a) : s > 3 ? r(t, o, a) : r(t, o)) || a);
105
- return s > 3 && a && Object.defineProperty(t, o, a), a;
106
- }, g = function(e, t) {
107
- if (typeof Reflect == "object" && typeof Reflect.metadata == "function")
108
- return Reflect.metadata(e, t);
109
- };
110
- const _ = class {
111
- constructor(e) {
112
- p(this, e), this.buttonClick = m(this, "buttonClick", 7), this._handleLoginRedirect = async () => {
113
- var n;
114
- const t = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes));
115
- this.buttonClick.emit({ url: t }).defaultPrevented || t && (window.location.href = t);
116
- }, this._onGoogleButtonClick = async (t) => {
117
- var n;
118
- t.preventDefault();
119
- const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, void 0, "google"));
120
- o && (window.location.href = o);
121
- }, this._onMicrosoftButtonClick = async (t) => {
122
- var n;
123
- t.preventDefault();
124
- const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, void 0, "microsoft"));
125
- o && (window.location.href = o);
126
- }, this._onFormSubmit = async (t) => {
127
- var n;
128
- t.preventDefault();
129
- const o = await ((n = this.nylasConnector) == null ? void 0 : n.auth.getHostedAuthRedirectURL(this.scopes, this.email));
130
- o && (window.location.href = o);
131
- }, this.isAuthenticated = !1, this.nylasConnector = void 0, this.scopes = void 0, this.loginMethod = "redirect", this.companyName = "Nylas", this.logoUrl = "https://www.nylas.com/wp-content/uploads/main-logo.svg", this.logoWidth = "min-content", this.providers = "google,microsoft", this.buttonText = "Login", this.email = "";
132
- }
133
- connectedCallback() {
134
- }
135
- disconnectedCallback() {
136
- }
137
- componentWillLoad() {
138
- }
139
- async componentDidLoad() {
140
- var t;
141
- await ((t = this.nylasConnector) == null ? void 0 : t.auth.manageHostedAuthCodeExchange(window.location.href)) && window.history.replaceState({}, document.title, window.location.pathname);
142
- }
143
- render() {
144
- var t;
145
- const e = ((t = this.providers) == null ? void 0 : t.split(",")) || [];
146
- return i(b, { key: "2dc6992f3244d7af9e06b5a1ea8c2c83bed2dbb4" }, this.loginMethod === "redirect" && i("div", { class: "redirect-container" }, !this.isAuthenticated && i("sp-button", { part: "button", onClick: this._handleLoginRedirect }, this.buttonText)), this.loginMethod === "emebded" && i("main", { class: "login-container" }, i("section", { class: "login-box" }, i("header", null, i("img", { src: this.logoUrl, alt: `${this.companyName} logo`, width: "100%", style: {
147
- minWidth: this.logoWidth
148
- } }), i("h1", null, "Welcome")), i("p", null, "Log in to your account to continue to ", this.companyName), i("div", { class: "login-methods" }, e.includes("google") && i("button", { class: "login-google", onClick: this._onGoogleButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 256 262" }, i("path", { fill: "#4285F4", d: "M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z" }), i("path", { fill: "#34A853", d: "M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z" }), i("path", { fill: "#FBBC05", d: "M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z" }), i("path", { fill: "#EA4335", d: "M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z" })), "Continue with Google"), e.includes("microsoft") && i("button", { class: "login-microsoft", onClick: this._onMicrosoftButtonClick }, i("svg", { xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", role: "img", width: "18", height: "18", preserveAspectRatio: "xMidYMid meet", viewBox: "0 0 448 512" }, i("path", { fill: "#F3F3F3", d: "M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z" })), "Continue with Microsoft")), i("form", { class: "login-form", method: "POST", onSubmit: this._onFormSubmit }, i("label", { htmlFor: "email" }, "Email"), i("input", { type: "email", id: "email", name: "email", required: !0, value: this.email }), i("button", { type: "submit" }, "Next")))));
149
- }
150
- };
151
- W([
152
- A({
153
- name: "nylas-login",
154
- connectorToProp: "nylasConnector",
155
- stateToProps: /* @__PURE__ */ new Map([["auth.isAuthenticated", "isAuthenticated"]]),
156
- fireRegisterEvent: !0
157
- }),
158
- g("design:type", Function),
159
- g("design:paramtypes", []),
160
- g("design:returntype", void 0)
161
- ], _.prototype, "render", null);
162
- _.style = z;
163
- class Y {
164
- constructor(t, o, n, s) {
165
- this.router = t, this.nylasAuth = o, this.nylasAuthStore = n, this.nylasMailboxStore = s;
166
- }
167
- init() {
168
- h("NylasMailboxConnector init");
169
- }
170
- get mailboxStore() {
171
- return this.nylasMailboxStore;
172
- }
173
- get authStore() {
174
- return this.nylasAuthStore;
175
- }
176
- get auth() {
177
- return this._authConnector ? this._authConnector : (this._authConnector = new O(this.nylasAuth, this.nylasAuthStore), this._authConnector);
178
- }
179
- get threads() {
180
- return this._threadConnector ? this._threadConnector : (this._threadConnector = new E(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore, this.router), this._threadConnector);
181
- }
182
- get messages() {
183
- return this._messageConnector ? this._messageConnector : (this._messageConnector = new B(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._messageConnector);
184
- }
185
- get folders() {
186
- return this._foldersConnector ? this._foldersConnector : (this._foldersConnector = new $(this.nylasAuth, this.nylasAuthStore, this.nylasMailboxStore), this._foldersConnector);
187
- }
188
- getAuth() {
189
- return this.nylasAuth;
190
- }
191
- resetStores() {
192
- this.nylasMailboxStore.reset(), this.nylasAuthStore.reset();
193
- }
194
- async logout() {
195
- await this.nylasAuth.logout(), this.resetStores();
196
- }
197
- }
198
- const G = ":host{display:contents}", V = G, q = class {
199
- constructor(e) {
200
- p(this, e), this.init = m(this, "init", 7), this.loggedIn = m(this, "loggedIn", 7), this.loggedOut = m(this, "loggedOut", 7), this.handleAuthChange = async (t) => {
201
- var o;
202
- t ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host).defaultPrevented || await ((o = this.nylasMailboxConnector) == null ? void 0 : o.logout());
203
- }, this.automaticComponentRegistration = !0, this.eventOverrides = {}, this.authConfig = void 0, this.defaultAuthStoreState = void 0, this.defaultMailboxStoreState = void 0;
204
- }
205
- connectedCallback() {
206
- h("[nylas-mailbox] connectedCallback");
207
- }
208
- async componentWillLoad() {
209
- var n, s, a, r, l, C, v;
210
- this.stores = {
211
- auth: T(this.defaultAuthStoreState),
212
- mailbox: I(this.defaultMailboxStoreState)
213
- }, this.baseProvider = new P(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides), this.router = new H(), this.nylasAuth = L({
214
- apiUri: "https://api.us.nylas.com",
215
- elementsApiUri: "https://elements.us.nylas.com",
216
- storageType: "indexeddb",
217
- clientId: "YOUR_CLIENT_ID",
218
- defaultScopes: [],
219
- redirectURI: "/",
220
- ...this.authConfig
221
- });
222
- const e = (n = this.baseProvider) == null ? void 0 : n.getStore("auth");
223
- if (!e)
224
- throw new Error("Auth store is not defined");
225
- const t = (s = this.baseProvider) == null ? void 0 : s.getStore("mailbox");
226
- if (!t)
227
- throw new Error("Mailbox store is not defined");
228
- this.nylasMailboxConnector = new Y(this.router, this.nylasAuth, e, t), this.init.emit(this.host).defaultPrevented || await ((a = this.nylasMailboxConnector) == null ? void 0 : a.auth.validateSession()), (r = this.router) == null || r.addRouteChangeListener("/thread/:threadId", async (R, k, w) => {
229
- var c, u;
230
- const f = w.threadId, d = await ((c = this.nylasMailboxConnector) == null ? void 0 : c.threads.getThread(f));
231
- d && ((u = this.nylasMailboxConnector) == null || u.mailboxStore.set("selectedThread", d));
232
- }), (l = this.router) == null || l.addRouteChangeListener("/", async (R, k, w) => {
233
- var d, c, u, S;
234
- if (!e.state.isAuthenticated)
235
- return;
236
- (d = this.nylasMailboxConnector) == null || d.threads.unSelectThread(), (c = this.nylasMailboxConnector) == null || c.folders.getFolders();
237
- const f = window.location.hash.split("?")[1];
238
- if (f) {
239
- const x = new URLSearchParams(f).get("query");
240
- x && await ((u = this.nylasMailboxConnector) == null ? void 0 : u.threads.getThreads({
241
- search_query_native: x,
242
- page_token: void 0
243
- }));
244
- } else
245
- (S = this.nylasMailboxConnector) == null || S.threads.getThreads();
246
- }), (C = this.router) == null || C.init(), this.handleAuthChange(e.state.isAuthenticated), (v = this.baseProvider) == null || v.componentWillLoad(this.nylasMailboxConnector);
247
- }
248
- async componentDidLoad() {
249
- var t, o;
250
- const e = (t = this.baseProvider) == null ? void 0 : t.getStore("auth");
251
- if (!e)
252
- throw new Error("Auth store is not defined");
253
- e.onChange("isAuthenticated", this.handleAuthChange), (o = this.baseProvider) == null || o.componentDidLoad();
254
- }
255
- componentDisconnected() {
256
- var e;
257
- (e = this.baseProvider) == null || e.componentDisconnected();
258
- }
259
- async registerComponentHandler(e) {
260
- var t;
261
- (t = this.baseProvider) == null || t.registerComponent(e.detail);
262
- }
263
- async unregisterComponentHandler(e) {
264
- var t;
265
- (t = this.baseProvider) == null || t.unregisterComponent(e.detail);
266
- }
267
- async getMailboxStore() {
268
- var e;
269
- return (e = this.baseProvider) == null ? void 0 : e.getStore("mailbox");
270
- }
271
- async getAuthStore() {
272
- var e;
273
- return (e = this.baseProvider) == null ? void 0 : e.getStore("auth");
274
- }
275
- async getNylasAuth() {
276
- return this.nylasAuth;
277
- }
278
- async getNylasMailboxConnector() {
279
- return this.nylasMailboxConnector;
280
- }
281
- render() {
282
- return i(b, { key: "662c4d3f763c5cf9db31c4d2ba26bcdf47ead164" }, i("slot", { key: "5c2b75a569779dd2af6388648a4304721e82ba76" }));
283
- }
284
- get host() {
285
- return N(this);
286
- }
287
- };
288
- q.style = V;
289
- export {
290
- M as nylas_if_state,
291
- _ as nylas_login,
292
- q as nylas_mailbox
293
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-457dcf0b.cjs"),M=require("./register-component-d056a880-2be11c56.cjs"),h=require("./utils-0cd66d04-94b9c3b6.cjs"),A=require("./index-10914bc1-c8c3a2f3.cjs"),_=require("./auth-store-69ac49c7-5a0bbb90.cjs"),f=require("./mailbox-store-e721b17c-4e97e07d.cjs");require("react");require("react-dom");require("./_commonjsHelpers-57e89916-4a3ae7d8.cjs");const N=":host{display:block}div{height:inherit}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}@keyframes fadeOut{0%{opacity:1}100%{opacity:0}}.fade-in{animation:fadeIn 1.5s}.fade-out{animation:fadeOut 1.5s}@keyframes slideIn{0%{transform:translateY(100%)}100%{transform:translateY(0)}}@keyframes slideOut{0%{transform:translateY(0)}100%{transform:translateY(100%)}}.slide-in{animation:slideIn 1.5s}.slide-out{animation:slideOut 1.5s}@keyframes swipeIn{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes swipeOut{0%{transform:translateX(0)}100%{transform:translateX(100%)}}.swipe-in{animation:swipeIn 1.5s}.swipe-out{animation:swipeOut 1.5s}",L=N;var T=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},y=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const p=class{constructor(e){o.registerInstance(this,e),this.state=void 0,this.isStateSet=void 0,this.isBoolean=void 0,this.getStore=void 0,this.transition="none",this.show=!1,this.classes={},this.initTransition=this.initTransition.bind(this)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){h.debug("[nylas-if-state] Component will load"),this.watchStore(!0)}async componentDidLoad(){h.debug("[nylas-if-state] Component did load")}shouldRender(){const[e,t]=this.state?this.state.split("."):["",""],n=this.getStore;if(typeof n>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{getStore:n}),!1;const s=n(e);if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${e} | State name: ${t}`,{store:s}),!1;const i=s.state[t];return typeof this.isStateSet=="boolean"?this.isStateSet===!1&&(typeof i>"u"||i===null||i.length===0)||this.isStateSet===!0&&typeof i<"u"&&i!==null:typeof this.isBoolean=="boolean"?this.isBoolean===!0&&typeof i<"u"&&i===!0||this.isBoolean===!1&&typeof i<"u"&&i===!1:!1}onGetStoreChange(){this.watchStore(!0)}watchStore(e=!1){const[t,n]=this.state?this.state.split("."):["",""],s=this.getStore;if(typeof s>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{getStore:s}),null;const i=s(t);if(typeof i>"u")return h.debug(`[nylas-if-state] Store name: ${t} | State name: ${n}`,{store:i}),null;e===!0&&this.initTransition(),i.onChange(n,this.initTransition)}initTransition(){const e=this.shouldRender();switch(this.transition){case"fade":case"slide":case"swipe":this.classes={[`${this.transition}-in`]:e,[`${this.transition}-out`]:!e},setTimeout(()=>{this.show=e},150);break;default:this.show=this.shouldRender();break}}render(){return o.h(o.Host,{key:"91d17bc89a09742106ef3bd9365c5ce48cf14e86"},o.h("div",{key:"9d0070be4bf5d9a5f405fc4a0733e6d832fa669a",class:this.classes},this.show&&o.h("slot",null)))}static get watchers(){return{getStore:["onGetStoreChange"]}}};T([M.RegisterComponent({name:"nylas-if-state",getStoresToProp:"getStore",fireRegisterEvent:!0}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],p.prototype,"render",null);p.style=L;const I=":host{font-family:'Arial', sans-serif;background:var(--nylas-color-primary-50);color:var(--nylas-color-primary-800);margin:0;display:contents}input{box-sizing:border-box}.login-container{display:flex;justify-content:center;align-items:center;height:100%}.login-box{width:300px;padding:20px;box-shadow:0 4px 8px rgba(0, 0, 0, 0.1);border-radius:var(--nylas-border-radius-2x);background:var(--nylas-color-primary-50);text-align:center}.login-box h1{margin-top:0;margin-bottom:0.5em}.login-box p{margin-bottom:1em}.login-methods button{display:block;width:100%;padding:10px 10px 10px 50px;margin-bottom:10px;border:none;border-radius:var(--nylas-border-radius);border:1px solid var(--nylas-color-primary-300);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-600);cursor:pointer;transition:background 0.3s ease;position:relative;text-align:left}.login-methods button svg{position:absolute;left:16px;top:50%;transform:translateY(-50%)}.login-methods button:hover{background:var(--nylas-color-primary-200);}.login-form label{display:block;margin-bottom:5px;text-align:left}.login-form input{width:100%;padding:10px;margin-bottom:10px;border:1px solid var(--nylas-color-primary-200);border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-100);color:var(--nylas-color-primary-800);}.login-form button{width:100%;padding:10px;border:none;border-radius:var(--nylas-border-radius);background:var(--nylas-color-primary-500);color:var(--nylas-color-primary-50);cursor:pointer;transition:background 0.3s ease}.login-form button:hover{background:var(--nylas-color-primary-600);}",O=I;var E=function(e,t,n,s){var i=arguments.length,a=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,n):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,n,s);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(a=(i<3?r(a):i>3?r(t,n,a):r(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},m=function(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)};const b=class{constructor(e){o.registerInstance(this,e),this.buttonClick=o.createEvent(this,"buttonClick",7),this._handleLoginRedirect=async()=>{var s;const t=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes));this.buttonClick.emit({url:t}).defaultPrevented||t&&(window.location.href=t)},this._onGoogleButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"google"));n&&(window.location.href=n)},this._onMicrosoftButtonClick=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,void 0,"microsoft"));n&&(window.location.href=n)},this._onFormSubmit=async t=>{var s;t.preventDefault();const n=await((s=this.nylasConnector)==null?void 0:s.auth.getHostedAuthRedirectURL(this.scopes,this.email));n&&(window.location.href=n)},this.isAuthenticated=!1,this.nylasConnector=void 0,this.scopes=void 0,this.loginMethod="redirect",this.companyName="Nylas",this.logoUrl="https://www.nylas.com/wp-content/uploads/main-logo.svg",this.logoWidth="min-content",this.providers="google,microsoft",this.buttonText="Login",this.email=""}connectedCallback(){}disconnectedCallback(){}componentWillLoad(){}async componentDidLoad(){var t;await((t=this.nylasConnector)==null?void 0:t.auth.manageHostedAuthCodeExchange(window.location.href))&&window.history.replaceState({},document.title,window.location.pathname)}render(){var t;const e=((t=this.providers)==null?void 0:t.split(","))||[];return o.h(o.Host,{key:"2dc6992f3244d7af9e06b5a1ea8c2c83bed2dbb4"},this.loginMethod==="redirect"&&o.h("div",{class:"redirect-container"},!this.isAuthenticated&&o.h("sp-button",{part:"button",onClick:this._handleLoginRedirect},this.buttonText)),this.loginMethod==="emebded"&&o.h("main",{class:"login-container"},o.h("section",{class:"login-box"},o.h("header",null,o.h("img",{src:this.logoUrl,alt:`${this.companyName} logo`,width:"100%",style:{minWidth:this.logoWidth}}),o.h("h1",null,"Welcome")),o.h("p",null,"Log in to your account to continue to ",this.companyName),o.h("div",{class:"login-methods"},e.includes("google")&&o.h("button",{class:"login-google",onClick:this._onGoogleButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 256 262"},o.h("path",{fill:"#4285F4",d:"M255.6 131.6c0-8.2-.8-16.2-2.2-23.9H130v45.3h70.3c-3 16.1-12.4 29.7-26.3 38.9v32.4h42.6c25-23 39.4-56.7 39.4-97.7z"}),o.h("path",{fill:"#34A853",d:"M130 262c35.3 0 64.9-11.7 86.5-31.7l-42.6-32.4c-11.7 7.9-26.7 12.6-43.9 12.6-33.7 0-62.3-22.7-72.5-53.4H14.5v33.3A130.3 130.3 0 00130 262z"}),o.h("path",{fill:"#FBBC05",d:"M57.5 158.1a72.7 72.7 0 010-54.2V70.6H14.5a130.4 130.4 0 000 120.8l43-33.3z"}),o.h("path",{fill:"#EA4335",d:"M130 51.6c19 0 36 6.5 49.4 19.2l37-36C195 13.1 165.2 0 130 0A130.3 130.3 0 0014.5 70.6l43 33.3c10.2-30.7 38.8-53.3 72.5-53.3z"})),"Continue with Google"),e.includes("microsoft")&&o.h("button",{class:"login-microsoft",onClick:this._onMicrosoftButtonClick},o.h("svg",{xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"18",height:"18",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 448 512"},o.h("path",{fill:"#F3F3F3",d:"M0 32v192h192V32H0zm256 0v192h192V32H256zm192 256v192h-192V288h192zM0 224v192h192V224H0z"})),"Continue with Microsoft")),o.h("form",{class:"login-form",method:"POST",onSubmit:this._onFormSubmit},o.h("label",{htmlFor:"email"},"Email"),o.h("input",{type:"email",id:"email",name:"email",required:!0,value:this.email}),o.h("button",{type:"submit"},"Next")))))}};E([M.RegisterComponent({name:"nylas-login",connectorToProp:"nylasConnector",stateToProps:new Map([["auth.isAuthenticated","isAuthenticated"]]),fireRegisterEvent:!0}),m("design:type",Function),m("design:paramtypes",[]),m("design:returntype",void 0)],b.prototype,"render",null);b.style=O;class H{constructor(t,n,s,i){this.router=t,this.nylasAuth=n,this.nylasAuthStore=s,this.nylasMailboxStore=i}init(){h.debug("NylasMailboxConnector init")}get mailboxStore(){return this.nylasMailboxStore}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new _.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new f.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new f.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new f.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasMailboxStore.reset(),this.nylasAuthStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const q=":host{display:contents}",B=q,R=class{constructor(e){o.registerInstance(this,e),this.init=o.createEvent(this,"init",7),this.loggedIn=o.createEvent(this,"loggedIn",7),this.loggedOut=o.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{var n;t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((n=this.nylasMailboxConnector)==null?void 0:n.logout())},this.automaticComponentRegistration=!0,this.eventOverrides={},this.authConfig=void 0,this.defaultAuthStoreState=void 0,this.defaultMailboxStoreState=void 0}connectedCallback(){h.debug("[nylas-mailbox] connectedCallback")}async componentWillLoad(){var s,i,a,r,l,v,C;this.stores={auth:_.CreateNylasAuthStore(this.defaultAuthStoreState),mailbox:f.CreateNylasMailboxStore(this.defaultMailboxStoreState)},this.baseProvider=new A.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.router=new f.HashRouter,this.nylasAuth=A.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const e=(s=this.baseProvider)==null?void 0:s.getStore("auth");if(!e)throw new Error("Auth store is not defined");const t=(i=this.baseProvider)==null?void 0:i.getStore("mailbox");if(!t)throw new Error("Mailbox store is not defined");this.nylasMailboxConnector=new H(this.router,this.nylasAuth,e,t),this.init.emit(this.host).defaultPrevented||await((a=this.nylasMailboxConnector)==null?void 0:a.auth.validateSession()),(r=this.router)==null||r.addRouteChangeListener("/thread/:threadId",async(k,P,S)=>{var d,u;const g=S.threadId,c=await((d=this.nylasMailboxConnector)==null?void 0:d.threads.getThread(g));c&&((u=this.nylasMailboxConnector)==null||u.mailboxStore.set("selectedThread",c))}),(l=this.router)==null||l.addRouteChangeListener("/",async(k,P,S)=>{var c,d,u,w;if(!e.state.isAuthenticated)return;(c=this.nylasMailboxConnector)==null||c.threads.unSelectThread(),(d=this.nylasMailboxConnector)==null||d.folders.getFolders();const g=window.location.hash.split("?")[1];if(g){const x=new URLSearchParams(g).get("query");x&&await((u=this.nylasMailboxConnector)==null?void 0:u.threads.getThreads({search_query_native:x,page_token:void 0}))}else(w=this.nylasMailboxConnector)==null||w.threads.getThreads()}),(v=this.router)==null||v.init(),this.handleAuthChange(e.state.isAuthenticated),(C=this.baseProvider)==null||C.componentWillLoad(this.nylasMailboxConnector)}async componentDidLoad(){var t,n;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");if(!e)throw new Error("Auth store is not defined");e.onChange("isAuthenticated",this.handleAuthChange),(n=this.baseProvider)==null||n.componentDidLoad()}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}async registerComponentHandler(e){var t;(t=this.baseProvider)==null||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;(t=this.baseProvider)==null||t.unregisterComponent(e.detail)}async getMailboxStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("mailbox")}async getAuthStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("auth")}async getNylasAuth(){return this.nylasAuth}async getNylasMailboxConnector(){return this.nylasMailboxConnector}render(){return o.h(o.Host,{key:"662c4d3f763c5cf9db31c4d2ba26bcdf47ead164"},o.h("slot",{key:"5c2b75a569779dd2af6388648a4304721e82ba76"}))}get host(){return o.getElement(this)}};R.style=B;exports.nylas_if_state=p;exports.nylas_login=b;exports.nylas_mailbox=R;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-457dcf0b.cjs"),C=require("./index-10914bc1-c8c3a2f3.cjs"),l=require("./utils-0cd66d04-94b9c3b6.cjs"),S=require("./auth-store-69ac49c7-5a0bbb90.cjs"),o=require("./mailbox-store-e721b17c-4e97e07d.cjs"),f=require("./scheduler-store-0fbe642c-410fdbf4.cjs"),b=require("./scheduler-config-store-4d035001-0256b40c.cjs");require("react");require("react-dom");require("./_commonjsHelpers-57e89916-4a3ae7d8.cjs");class m{constructor(t,s,n,i,c,h,a="https://api.us.nylas.com"){this.router=t,this.schedulerAPIURL=a,this.nylasAuth=s,this.nylasAuthStore=n,this.nylasMailboxStore=i,this.nylasSchedulerStore=c,this.nylasSchedulerConfigStore=h}init(){l.debug("NylasConnector init")}get authStore(){return this.nylasAuthStore}get mailboxStore(){return this.nylasMailboxStore}get schedulerStore(){return this.nylasSchedulerStore}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new S.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get threads(){return this._threadConnector?this._threadConnector:(this._threadConnector=new o.NylasThreadsConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore,this.router),this._threadConnector)}get messages(){return this._messageConnector?this._messageConnector:(this._messageConnector=new o.NylasMessagesConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._messageConnector)}get folders(){return this._foldersConnector?this._foldersConnector:(this._foldersConnector=new o.NylasFoldersConnector(this.nylasAuth,this.nylasAuthStore,this.nylasMailboxStore),this._foldersConnector)}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new f.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore}),this._schedulerAPIConnector)}get schedulerConfig(){return this._schedulerConfigConnector?this._schedulerConfigConnector:(this._schedulerConfigConnector=new b.NylasSchedulerConfigAPIConnector({nylasAuth:this.nylasAuth,nylasAuthStore:this.nylasAuthStore,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore}),this._schedulerConfigConnector)}getAuth(){return this.nylasAuth}resetStores(){this.nylasAuthStore.reset(),this.nylasMailboxStore.reset()}async logout(){await this.nylasAuth.logout(),this.resetStores()}}const v=":host{display:contents}",P=v,A=class{constructor(e){r.registerInstance(this,e),this.init=r.createEvent(this,"init",7),this.loggedIn=r.createEvent(this,"loggedIn",7),this.loggedOut=r.createEvent(this,"loggedOut",7),this.handleAuthChange=async t=>{t?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host)},this.authConfig=void 0,this.eventOverrides={},this.automaticComponentRegistration=!0}connectedCallback(){l.debug("[nylas-provider] connectedCallback")}async componentWillLoad(){var h,a,u,d,g,y;l.debug("[nylas-provider] componentWillLoad"),this.stores={auth:S.CreateNylasAuthStore(),mailbox:o.CreateNylasMailboxStore(),scheduler:f.CreateNylasSchedulerStore(),schedulerConfig:b.CreateNylasSchedulerConfigStore()},this.baseProvider=new C.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const e=new o.HashRouter;this.nylasAuth=C.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const t=(h=this.baseProvider)==null?void 0:h.getStore("mailbox");if(!t)throw new Error("The mailbox store is not set");const s=(a=this.baseProvider)==null?void 0:a.getStore("auth");if(!s)throw new Error("The auth store is not set");const n=(u=this.baseProvider)==null?void 0:u.getStore("scheduler");if(!n)throw new Error("The scheduler store is not set");const i=(d=this.baseProvider)==null?void 0:d.getStore("schedulerConfig");if(!i)throw new Error("The scheduler config store is not set");this.nylasConnector=new m(e,this.nylasAuth,s,t,n,i),this.init.emit(this.host).defaultPrevented||await((g=this.nylasConnector)==null?void 0:g.auth.validateSession()),this.handleAuthChange(s.state.isAuthenticated),(y=this.baseProvider)==null||y.componentWillLoad(this.nylasConnector)}componentDidLoad(){var t,s;const e=(t=this.baseProvider)==null?void 0:t.getStore("auth");e==null||e.onChange("isAuthenticated",this.handleAuthChange),(s=this.baseProvider)==null||s.componentDidLoad()}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}async registerComponentHandler(e){var t;(t=this.baseProvider)==null||t.registerComponent(e.detail)}async unregisterComponentHandler(e){var t;(t=this.baseProvider)==null||t.unregisterComponent(e.detail)}async getNylasAuth(){return this.nylasAuth}async getNylasConnector(){return this.nylasConnector}async getMailboxStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("mailbox")}async getAuthStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("auth")}async getNylasSchedulerStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("scheduler")}async getNylasSchedulerConfigStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("schedulerConfig")}render(){return r.h(r.Host,{key:"c70dbacf5502b79a6306f27b969dd9a9f841f5a0"},r.h("slot",{key:"031e85b2e755d2e4b7f925982a47e32daa5f8200"}))}get host(){return r.getElement(this)}};A.style=P;exports.nylas_provider=A;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-457dcf0b.cjs"),d=require("./index-10914bc1-c8c3a2f3.cjs"),c=require("./auth-store-69ac49c7-5a0bbb90.cjs"),r=require("./utils-0cd66d04-94b9c3b6.cjs"),u=require("./scheduler-config-store-4d035001-0256b40c.cjs");require("react");require("react-dom");require("./_commonjsHelpers-57e89916-4a3ae7d8.cjs");class y{constructor({nylasAuth:e,nylasAuthStore:n,nylasSchedulerConfigStore:o}){this.nylasAuth=e,this.nylasAuthStore=n,this.nylasSchedulerConfigStore=o}init(){r.debug("NylasSchedulerConfigConnector init")}get authStore(){return this.nylasAuthStore}get auth(){return this._authConnector?this._authConnector:(this._authConnector=new c.NylasAuthConnector(this.nylasAuth,this.nylasAuthStore),this._authConnector)}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){return this._schedulerConfigConnector?this._schedulerConfigConnector:(this._schedulerConfigConnector=new u.NylasSchedulerConfigAPIConnector({nylasAuth:this.nylasAuth,nylasAuthStore:this.nylasAuthStore,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore}),this._schedulerConfigConnector)}getAuth(){return this.nylasAuth}getTokenInfo(){return this.nylasAuth.getTokenInfo()}resetStores(){r.debug("NylasSchedulerConfigConnector resetStores"),this.nylasAuthStore.reset(),this.nylasSchedulerConfigStore.reset()}async logout(){r.debug("NylasSchedulerConfigConnector logout"),await this.auth.logout(),this.resetStores()}}const f=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--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}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:100%}',C=f,g=class{constructor(s){t.registerInstance(this,s),this.init=t.createEvent(this,"init",7),this.loggedIn=t.createEvent(this,"loggedIn",7),this.loggedOut=t.createEvent(this,"loggedOut",7),this.schedulerConfigCloseClicked=t.createEvent(this,"schedulerConfigCloseClicked",7),this.handleAuthChange=async e=>{var n;e?this.loggedIn.emit(this.host):this.loggedOut.emit(this.host).defaultPrevented||await((n=this.nylasSchedulerConfigConnector)==null?void 0:n.logout())},this.handleSchedulerConfigCloseClicked=e=>{this.schedulerConfigCloseClicked.emit(this.host)},this.authConfig=void 0,this.eventOverrides={},this.defaultAuthStoreState=void 0,this.defaultSchedulerConfigStoreState=void 0,this.mode="app",this.automaticComponentRegistration=!0,this.loggedInUser=""}connectedCallback(){r.debug("[nylas-scheduler-editor] connectedCallback")}async componentWillLoad(){var o,i,a,l;r.debug("[nylas-scheduler-editor] componentWillLoad"),this.stores={auth:c.CreateNylasAuthStore(this.defaultAuthStoreState),schedulerConfig:u.CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigStoreState})},this.baseProvider=new d.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.nylasAuth=d.es({apiUri:"https://api.us.nylas.com",elementsApiUri:"https://elements.us.nylas.com",storageType:"indexeddb",clientId:"YOUR_CLIENT_ID",defaultScopes:[],redirectURI:"/",...this.authConfig});const s=(o=this.baseProvider)==null?void 0:o.getStore("auth"),e=this.baseProvider.getStore("schedulerConfig");if(this.nylasSchedulerConfigConnector=new y({nylasAuth:this.nylasAuth,nylasAuthStore:this.stores.auth,nylasSchedulerConfigStore:e}),!this.init.emit(this.host).defaultPrevented){await((i=this.nylasSchedulerConfigConnector)==null?void 0:i.auth.validateSession());const h=await((a=this.nylasSchedulerConfigConnector)==null?void 0:a.auth.getTokenInfo());h&&(this.loggedInUser=h.email)}this.handleAuthChange(s.state.isAuthenticated),(l=this.baseProvider)==null||l.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){var s,e,n;r.debug("[nylas-scheduler-editor] componentDidLoad"),(s=this.baseProvider)==null||s.componentDidLoad(),await((n=(e=this.nylasSchedulerConfigConnector)==null?void 0:e.schedulerConfig)==null?void 0:n.getCalendars())}componentDisconnected(){var s;(s=this.baseProvider)==null||s.componentDisconnected()}async registerComponentHandler(s){var e;(e=this.baseProvider)==null||e.registerComponent(s.detail)}async unregisterComponentHandler(s){var e;(e=this.baseProvider)==null||e.unregisterComponent(s.detail)}render(){return this.mode==="app"?t.h(t.Host,null,t.h("div",{class:"scheduler-editor-header"},t.h("h1",{class:"scheduler-editor-title"},t.h("calendar-icon",{width:"18",height:"18"}),"Schedule editor"),t.h("button",{class:"scheduler-editor-close",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nsc-close-button"},t.h("close-icon",{width:"18",height:"18"}))),t.h("nylas-editor-tabs",null)):t.h(t.Host,null,t.h("slot",null))}get host(){return t.getElement(this)}};g.style=C;exports.nylas_scheduler_editor=g;
@@ -1,111 +0,0 @@
1
- import { r as u, c as i, h as s, H as c, g } from "./index-ce40ad47.js";
2
- import { N as f, e as y } from "./index-10914bc1-346f04fa.js";
3
- import { C, N as p } from "./auth-store-69ac49c7-cbfda055.js";
4
- import { d as o } from "./utils-0cd66d04-89ab163d.js";
5
- import { C as S, N as b } from "./scheduler-config-store-4d035001-db9dc78a.js";
6
- import "react";
7
- import "react-dom";
8
- import "./_commonjsHelpers-57e89916-af061c86.js";
9
- class m {
10
- constructor({ nylasAuth: e, nylasAuthStore: n, nylasSchedulerConfigStore: r }) {
11
- this.nylasAuth = e, this.nylasAuthStore = n, this.nylasSchedulerConfigStore = r;
12
- }
13
- init() {
14
- o("NylasSchedulerConfigConnector init");
15
- }
16
- get authStore() {
17
- return this.nylasAuthStore;
18
- }
19
- get auth() {
20
- return this._authConnector ? this._authConnector : (this._authConnector = new p(this.nylasAuth, this.nylasAuthStore), this._authConnector);
21
- }
22
- get schedulerConfigStore() {
23
- return this.nylasSchedulerConfigStore;
24
- }
25
- get schedulerConfig() {
26
- return this._schedulerConfigConnector ? this._schedulerConfigConnector : (this._schedulerConfigConnector = new b({
27
- nylasAuth: this.nylasAuth,
28
- nylasAuthStore: this.nylasAuthStore,
29
- nylasSchedulerConfigStore: this.nylasSchedulerConfigStore
30
- }), this._schedulerConfigConnector);
31
- }
32
- getAuth() {
33
- return this.nylasAuth;
34
- }
35
- getTokenInfo() {
36
- return this.nylasAuth.getTokenInfo();
37
- }
38
- resetStores() {
39
- o("NylasSchedulerConfigConnector resetStores"), this.nylasAuthStore.reset(), this.nylasSchedulerConfigStore.reset();
40
- }
41
- async logout() {
42
- o("NylasSchedulerConfigConnector logout"), await this.auth.logout(), this.resetStores();
43
- }
44
- }
45
- const v = ':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--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}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}div.scheduler-editor-header{display:flex;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900)}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;width:858px;margin:0;font-size:18px;line-height:24px;font-weight:600}@media screen and (max-width: 768px){div.scheduler-editor-header h1.scheduler-editor-title{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary)}div.scheduler-editor-header button:disabled{cursor:not-allowed}nylas-editor-tabs{width:100%}', x = v, w = class {
46
- constructor(t) {
47
- u(this, t), this.init = i(this, "init", 7), this.loggedIn = i(this, "loggedIn", 7), this.loggedOut = i(this, "loggedOut", 7), this.schedulerConfigCloseClicked = i(this, "schedulerConfigCloseClicked", 7), this.handleAuthChange = async (e) => {
48
- var n;
49
- e ? this.loggedIn.emit(this.host) : this.loggedOut.emit(this.host).defaultPrevented || await ((n = this.nylasSchedulerConfigConnector) == null ? void 0 : n.logout());
50
- }, this.handleSchedulerConfigCloseClicked = (e) => {
51
- this.schedulerConfigCloseClicked.emit(this.host);
52
- }, this.authConfig = void 0, this.eventOverrides = {}, this.defaultAuthStoreState = void 0, this.defaultSchedulerConfigStoreState = void 0, this.mode = "app", this.automaticComponentRegistration = !0, this.loggedInUser = "";
53
- }
54
- connectedCallback() {
55
- o("[nylas-scheduler-editor] connectedCallback");
56
- }
57
- async componentWillLoad() {
58
- var r, a, l, h;
59
- o("[nylas-scheduler-editor] componentWillLoad"), this.stores = {
60
- auth: C(this.defaultAuthStoreState),
61
- schedulerConfig: S({
62
- ...this.defaultSchedulerConfigStoreState
63
- })
64
- }, this.baseProvider = new f(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides), this.nylasAuth = y({
65
- apiUri: "https://api.us.nylas.com",
66
- elementsApiUri: "https://elements.us.nylas.com",
67
- storageType: "indexeddb",
68
- clientId: "YOUR_CLIENT_ID",
69
- defaultScopes: [],
70
- redirectURI: "/",
71
- ...this.authConfig
72
- });
73
- const t = (r = this.baseProvider) == null ? void 0 : r.getStore("auth"), e = this.baseProvider.getStore("schedulerConfig");
74
- if (this.nylasSchedulerConfigConnector = new m({
75
- nylasAuth: this.nylasAuth,
76
- nylasAuthStore: this.stores.auth,
77
- nylasSchedulerConfigStore: e
78
- }), !this.init.emit(this.host).defaultPrevented) {
79
- await ((a = this.nylasSchedulerConfigConnector) == null ? void 0 : a.auth.validateSession());
80
- const d = await ((l = this.nylasSchedulerConfigConnector) == null ? void 0 : l.auth.getTokenInfo());
81
- d && (this.loggedInUser = d.email);
82
- }
83
- this.handleAuthChange(t.state.isAuthenticated), (h = this.baseProvider) == null || h.componentWillLoad(this.nylasSchedulerConfigConnector);
84
- }
85
- async componentDidLoad() {
86
- var t, e, n;
87
- o("[nylas-scheduler-editor] componentDidLoad"), (t = this.baseProvider) == null || t.componentDidLoad(), await ((n = (e = this.nylasSchedulerConfigConnector) == null ? void 0 : e.schedulerConfig) == null ? void 0 : n.getCalendars());
88
- }
89
- componentDisconnected() {
90
- var t;
91
- (t = this.baseProvider) == null || t.componentDisconnected();
92
- }
93
- async registerComponentHandler(t) {
94
- var e;
95
- (e = this.baseProvider) == null || e.registerComponent(t.detail);
96
- }
97
- async unregisterComponentHandler(t) {
98
- var e;
99
- (e = this.baseProvider) == null || e.unregisterComponent(t.detail);
100
- }
101
- render() {
102
- return this.mode === "app" ? s(c, null, s("div", { class: "scheduler-editor-header" }, s("h1", { class: "scheduler-editor-title" }, s("calendar-icon", { width: "18", height: "18" }), "Schedule editor"), s("button", { class: "scheduler-editor-close", onClick: (e) => this.handleSchedulerConfigCloseClicked(e), part: "nsc-close-button" }, s("close-icon", { width: "18", height: "18" }))), s("nylas-editor-tabs", null)) : s(c, null, s("slot", null));
103
- }
104
- get host() {
105
- return g(this);
106
- }
107
- };
108
- w.style = x;
109
- export {
110
- w as nylas_scheduler_editor
111
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-457dcf0b.cjs"),h=require("./index-10914bc1-c8c3a2f3.cjs"),f=require("./utils-0cd66d04-94b9c3b6.cjs"),g=require("./scheduler-store-0fbe642c-410fdbf4.cjs");require("react");require("react-dom");require("./_commonjsHelpers-57e89916-4a3ae7d8.cjs");class w{constructor({schedulerAPIURL:n,nylasSchedulerStore:s,sessionId:o,configId:i}){if(!n)throw new Error("schedulerAPIURL is required");if(!s)throw new Error("nylasSchedulerStore is required");if(!o&&!i)throw new Error("sessionId is required for private configs, if not config id is required for public configs");n==="/"&&(n=new URL(window.location.href).origin),this.configId=i,this.sessionId=o,this.schedulerAPIURL=n,this.nylasSchedulerStore=s}init(){f.debug("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new g.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId}),this._schedulerAPIConnector)}resetStores(){this.nylasSchedulerStore.reset()}}const c=(e,n)=>{const s=e.isLoading,o=e.showNotification;return t.h(t.Fragment,null,o&&t.h("nylas-notification",null),s&&t.h("div",{class:"loading"},t.h("div",{class:"left"},t.h("div",{class:"skeleton"})),t.h("div",{class:"right"},t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}),t.h("div",{class:"skeleton"}))),!s&&n,t.h("div",{class:"footer"},"Powered by  ",t.h("nylas-logo",null)))},m=(e,n)=>t.h("div",{class:"message-banner"},n),x=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 4px 6px -2px rgba(0, 0, 0, 0.05), 0px 10px 15px -3px rgba(0, 0, 0, 0.1);--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;font-family:var(--nylas-font-family);font-optical-sizing:auto;font-style:normal;font-variation-settings:"slnt" 0}@media screen and (max-width: 768px){:host{width:auto;min-width:325px}}:root{font-family:inherit}.error{padding:8rem 12rem;color:var(--nylas-base-0);background-color:var(--nylas-error);margin:1.5rem;border-radius:var(--nylas-border-radius-2x)}.message-banner{text-align:right;color:var(--nylas-base-800);padding:1rem;border-bottom:1px solid var(--nylas-color-primary-200);margin-top:1rem}.loading{margin:1.5rem;display:flex;gap:1rem}.loading .skeleton{border-radius:var(--nylas-border-radius-2x);animation:pulsate 1.5s infinite}.loading .skeleton:nth-child(2){animation-delay:-100ms}.loading .skeleton:nth-child(3){animation-delay:-200ms}.loading .skeleton:nth-child(4){animation-delay:-300ms}.loading .skeleton:nth-child(5){animation-delay:-400ms}.loading .left .skeleton{height:100%;width:400px}.loading .right .skeleton{height:5rem;width:300px;margin-bottom:1rem}.loading .right .skeleton:last-child{margin-bottom:0}@keyframes pulsate{0%{background-color:var(--nylas-base-50)}50%{background-color:var(--nylas-base-100)}100%{background-color:var(--nylas-base-50)}}.select-date-page,.additional-data-page,.booked-event-page,.cancelled-event-page,.cancel-flow-page{border-top-left-radius:var(--nylas-border-radius-2x);border-top-right-radius:var(--nylas-border-radius-2x)}.select-date-page,.additional-data-page{display:flex}@media screen and (max-width: 768px){.select-date-page,.additional-data-page{flex-direction:column}}.booked-event-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.cancelled-event-page,.cancel-flow-page{min-width:784px}@media screen and (max-width: 768px){.booked-event-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{padding:1rem 20px 0;gap:1rem;height:512px;min-width:384px;border-top-left-radius:inherit}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset}}@media screen and (max-width: 768px){.additional-data-page .left-panel{height:325px}}@media screen and (max-width: 768px){.select-date-page .left-panel{padding:0.5rem 4px 0}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:1px;background-color:var(--nylas-base-200)}@media screen and (max-width: 768px){.border{display:none}}.right-panel{min-width:360px;width:360px;background-color:var(--nylas-base-50);height:512px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.25rem;justify-content:center;align-items:center;width:auto;font-size:1.125rem;line-height:1.5rem;font-weight:500;text-align:center;color:var(--nylas-base-800)}.additional-data-page .left-panel{background-color:var(--nylas-base-50)}.additional-data-page .right-panel{background-color:var(--nylas-base-0)}nylas-selected-event-card{height:496px}@media screen and (max-width: 768px){nylas-selected-event-card{height:325px}}.footer{display:flex;justify-content:flex-end;align-items:center;padding:16px;font-size:14px;font-weight:300;color:var(--nylas-base-500);border-top:1px solid var(--nylas-base-200)}.footer svg{fill:var(--nylas-base-500)}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}',_=x,b={title:"Something went wrong...",type:h.nr.Error,category:g.ErrorCategory.Component},y=class{constructor(e){t.registerInstance(this,e),this.init=t.createEvent(this,"init",7),this.schedulerWillLoad=t.createEvent(this,"schedulerWillLoad",7),this.schedulerDidLoad=t.createEvent(this,"schedulerDidLoad",7),this.nylasSchedulerError=t.createEvent(this,"nylasSchedulerError",7),this.mode="app",this.defaultSchedulerState=void 0,this.sessionId=void 0,this.schedulerApiUrl="https://api.us.nylas.com",this.bookingInfo=void 0,this.rescheduleBookingId=void 0,this.cancelBookingId=void 0,this.configId=void 0,this.eventOverrides={},this.isLoading=void 0,this.themeConfig=void 0,this.showNotification=!0,this.automaticComponentRegistration=!0,this.selectedDateLabel=new Date().toLocaleDateString(void 0,{dateStyle:"full"})||"No date selected"}connectedCallback(){f.debug("[nylas-scheduler] connectedCallback")}async componentWillLoad(){var s,o;if(f.debug("[nylas-scheduler] Component will load"),this.schedulerWillLoad.emit(this.host).defaultPrevented||!this.checkIfSessionIdOrConfigIdExists())return;this.stores={scheduler:g.CreateNylasSchedulerStore({bookingInfo:this.bookingInfo,...this.defaultSchedulerState})},this.baseProvider=new h.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const n=(s=this.baseProvider)==null?void 0:s.getStore("scheduler");if(this.nylasSchedulerConnector=new w({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.configId,nylasSchedulerStore:n}),this.init.emit(this.host),(o=this.baseProvider)==null||o.componentWillLoad(this.nylasSchedulerConnector),this.themeConfig)for(const[i,a]of Object.entries(this.themeConfig))this.host.style.setProperty(`${i}`,a)}async componentDidLoad(){var a,u,l,d;if((a=this.baseProvider)==null||a.componentDidLoad(),!this.checkIfSessionIdOrConfigIdExists())return;const e=(u=this.baseProvider)==null?void 0:u.getStore("scheduler"),n=e==null?void 0:e.get("selectedTimeslot");if(n&&(n!=null&&n.start_time)){if(!this.isTimeslotValid(n))return;if(e!=null&&e.get("showBookingForm")){e==null||e.set("selectedDate",n.start_time);return}}const s=e==null?void 0:e.get("selectedDate"),o=e==null?void 0:e.get("availability");let i;if(!(o&&o.length>0)){if(!s)i=await((l=this.nylasSchedulerConnector)==null?void 0:l.scheduler.getAvailability());else{const r=new Date(s.getFullYear(),s.getMonth(),1).getTime()/1e3,p=new Date(s.getFullYear(),s.getMonth()+1,1).getTime()/1e3;i=await((d=this.nylasSchedulerConnector)==null?void 0:d.scheduler.getAvailability(r,p))}if((!i||"error"in i)&&this.nylasSchedulerError.emit({...this.getErrorObject(i==null?void 0:i.error)}),!s){let r=new Date;const p=e==null?void 0:e.get("availability").find(v=>new Date(v.start_time)>new Date);p&&(r=p.start_time),e==null||e.set("selectedDate",r)}}}componentDisconnected(){var e;(e=this.baseProvider)==null||e.componentDisconnected()}bookingInfoChanged(e){var n;(n=this.stores)==null||n.scheduler.set("bookingInfo",e)}async registerComponentHandler(e){var n;(n=this.baseProvider)==null||n.registerComponent(e.detail)}async unregisterComponentHandler(e){var n;(n=this.baseProvider)==null||n.unregisterComponent(e.detail)}async monthChangedHandler(e){var a;const n=e.detail,s=new Date(n.getFullYear(),n.getMonth(),1).getTime()/1e3,o=new Date(n.getFullYear(),n.getMonth()+1,1).getTime()/1e3,i=await((a=this.nylasSchedulerConnector)==null?void 0:a.scheduler.getAvailability(s,o));(!i||"error"in i)&&this.nylasSchedulerError.emit({...this.getErrorObject(i==null?void 0:i.error)})}async bookButtonClickedHandler(e){var s,o;if(this.rescheduleBookingId){const i=await((s=this.nylasSchedulerConnector)==null?void 0:s.scheduler.rescheduleBooking(this.rescheduleBookingId,e.detail));(!i||"error"in i)&&this.nylasSchedulerError.emit({...this.getErrorObject(i==null?void 0:i.error)});return}const n=await((o=this.nylasSchedulerConnector)==null?void 0:o.scheduler.bookTimeslot(e.detail));(!n||"error"in n)&&this.nylasSchedulerError.emit({...this.getErrorObject(n==null?void 0:n.error)})}dateSelectedHandler(e){const n=e.detail;this.selectedDateLabel=n?n.toLocaleDateString(void 0,{dateStyle:"full"}):"No date selected"}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({...this.getErrorObject(e.detail.error)})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({...this.getErrorObject(e.detail.error)})}async getNylasSchedulerStore(){var e;return(e=this.baseProvider)==null?void 0:e.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:(e==null?void 0:e.title)||b.title,category:(e==null?void 0:e.category)||b.category,type:h.nr.Error,description:(e==null?void 0:e.message)||"",id:new Date().getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){return!this.sessionId&&!this.configId?(this.nylasSchedulerError.emit({title:"No sessionId!",category:g.ErrorCategory.Component,type:h.nr.Error,description:"Session ID is required",id:new Date().getTime().toString(),ttl:"none"}),!1):!0}isTimeslotValid(e){return new Date(e.start_time)<new Date?(this.nylasSchedulerError.emit({title:"Invalid tiemslot!",category:g.ErrorCategory.Component,type:h.nr.Error,description:"The selected timeslot is invalid.",id:new Date().getTime().toString(),ttl:"none"}),!1):!0}render(){var d;const e=this.mode==="app",n=(d=this.baseProvider)==null?void 0:d.getStore("scheduler"),s=n==null?void 0:n.get("eventInfo"),o=n==null?void 0:n.get("showBookingForm"),i=n==null?void 0:n.get("cancelledEventInfo"),a=(n==null?void 0:n.get("cancelBookingId"))||this.cancelBookingId,u=n==null?void 0:n.get("selectedTimeslot"),l=(n==null?void 0:n.get("rescheduleBookingId"))||this.rescheduleBookingId;if(e&&a&&!i)return t.h(t.Host,null,t.h(c,{isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancel-flow-page",part:"cancel-flow-page"},t.h("nylas-cancel-booking-form",{cancelBookingId:a,exportparts:"ncbf, ncbf__input-textfield, ncbf__button-cta, ncbf__button-outline, ncbf__input-label"}))));if(e&&i)return t.h(t.Host,null,t.h(c,{isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"cancelled-event-page",part:"cancelled-event-page"},t.h("nylas-cancelled-event-card",{cancelledEventInfo:i,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(e&&s)return t.h(t.Host,null,t.h(c,{isLoading:this.isLoading,showNotification:this.showNotification},t.h("div",{class:"booked-event-page",part:"booked-event-page"},t.h("nylas-booked-event-card",{selectedTimeslot:u,eventInfo:s,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))));if(e&&(!s||l)&&!o){const r=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return t.h(t.Host,null,t.h(c,{isLoading:this.isLoading,showNotification:this.showNotification},l&&t.h(m,null,"Choose another time slot to reschedule your meeting"),t.h("div",{class:"select-date-page",part:"select-date-page"},t.h("div",{class:"left-panel"},t.h("nylas-date-picker",{exportparts:"ndp, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),t.h("div",{class:"border"}),t.h("nylas-locale-switch",null)),t.h("div",{class:"right-panel"},t.h("h2",null,t.h("calendar-icon",null),t.h("span",{id:"selectedDate"},this.selectedDateLabel)),t.h("nylas-timeslot-picker",{exportparts:"ntp, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},r&&t.h("span",{slot:"timeslot-picker-cta-label"},t.h("slot",{name:"timeslot-picker-cta-label"})))))))}if(e&&!s&&o){const r=this.host.querySelector('[slot="custom-booking-form"]');return t.h(t.Host,null,t.h(c,{isLoading:this.isLoading,showNotification:this.showNotification},l&&t.h(m,null,"Choose another time slot to reschedule your meeting"),t.h("div",{class:"additional-data-page",part:"additional-data-page"},t.h("div",{class:"left-panel"},t.h("div",{class:"wrapper"},t.h("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time"}))),t.h("div",{class:"right-panel"},t.h("nylas-booking-form",{exportparts:"nbf, nbf__input-label, nbf__input-textfield, nbf__button-ghost, nbf__button-primary, nbf__button-outline"},r&&t.h("div",{slot:"custom-booking-form"},t.h("slot",{name:"custom-booking-form"})))))))}return t.h(t.Host,null,t.h("slot",null))}get host(){return t.getElement(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"]}}};y.style=_;exports.nylas_scheduling=y;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index-457dcf0b.cjs"),h=require("./register-component-d056a880-2be11c56.cjs"),u=require("./utils-0cd66d04-94b9c3b6.cjs");require("react");require("react-dom");require("./_commonjsHelpers-57e89916-4a3ae7d8.cjs");const y=":host{display:block}sp-search{width:100%;border:0}",f=y;var p=function(t,e,n,a){var o=arguments.length,r=o<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,n):a,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(t,e,n,a);else for(var c=t.length-1;c>=0;c--)(i=t[c])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},l=function(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)};const d=class{constructor(t){s.registerInstance(this,t),this.search=s.createEvent(this,"search",7),this.onSearch=async e=>{e.preventDefault(),e.stopPropagation();const a=e.target.value;a!==this.internalQuery&&(this.internalQuery=a,this.search.emit(this.internalQuery))},this.query="",this.internalQuery=""}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){u.debug("[nylas-threads-search] Component will load")}async componentDidLoad(){u.debug("[nylas-threads-search] Component did load")}onQueryChange(){this.internalQuery=this.query}render(){return s.h(s.Host,{key:"a01f03e26d8aa4b60e5e72ada49134edd7b95879"},s.h("sp-theme",{key:"2e4a2b409756725bfef6aece91cb12f75d286d7d",scale:"medium",color:"dark"},s.h("sp-search",{key:"a71de13c8634f5127d85bfbc555ef363a08e8f25",quiet:!0,onSubmit:this.onSearch,onBlur:this.onSearch,value:this.internalQuery})))}static get watchers(){return{query:["onQueryChange"]}}};p([h.RegisterComponent({name:"nylas-pagination",stateToProps:new Map([["mailbox.searchQuery","query"]]),eventToProps:{search:async(t,e)=>{await e.threads.getThreads({search_query_native:t.detail||void 0,page_token:void 0})}},fireRegisterEvent:!0}),l("design:type",Function),l("design:paramtypes",[]),l("design:returntype",void 0)],d.prototype,"render",null);d.style=f;exports.nylas_threads_search=d;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-457dcf0b.cjs");require("react");require("react-dom");const o=".sc-play-icon-h{display:flex}",n=o,s=class{constructor(e){t.registerInstance(this,e),this.width="15",this.height="15"}render(){return t.h("svg",{key:"b98c1644be51eeb0eaaf3adbdae2dff1f384c342",width:this.width,height:this.height,viewBox:"0 0 24 24",fill:"auto",xmlns:"http://www.w3.org/2000/svg"},t.h("path",{key:"74ec4ca9b3177a5e06e5255f7a14f58b95866360",d:"M21 12L3 21V3L21 12Z",stroke:"auto","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))}};s.style=n;const h=".sc-stop-icon-h{display:flex}",r=h,i=class{constructor(e){t.registerInstance(this,e),this.width="15",this.height="15"}render(){return t.h("svg",{key:"8c22503dbd156abdd1749ce70a906054f470d078",width:this.width,height:this.height,viewBox:"0 0 24 24",fill:"auto",xmlns:"http://www.w3.org/2000/svg"},t.h("path",{key:"eaea1d0090ec37b0b649456df67dde1170e9c741",d:"M4 4H20V20H4V4Z",stroke:"auto","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}))}};i.style=r;exports.play_icon=s;exports.stop_icon=i;
@@ -1,25 +0,0 @@
1
- import { r as s, h as t } from "./index-ce40ad47.js";
2
- import "react";
3
- import "react-dom";
4
- const o = ".sc-play-icon-h{display:flex}", i = o, h = class {
5
- constructor(e) {
6
- s(this, e), this.width = "15", this.height = "15";
7
- }
8
- render() {
9
- return t("svg", { key: "b98c1644be51eeb0eaaf3adbdae2dff1f384c342", width: this.width, height: this.height, viewBox: "0 0 24 24", fill: "auto", xmlns: "http://www.w3.org/2000/svg" }, t("path", { key: "74ec4ca9b3177a5e06e5255f7a14f58b95866360", d: "M21 12L3 21V3L21 12Z", stroke: "auto", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }));
10
- }
11
- };
12
- h.style = i;
13
- const n = ".sc-stop-icon-h{display:flex}", c = n, r = class {
14
- constructor(e) {
15
- s(this, e), this.width = "15", this.height = "15";
16
- }
17
- render() {
18
- return t("svg", { key: "8c22503dbd156abdd1749ce70a906054f470d078", width: this.width, height: this.height, viewBox: "0 0 24 24", fill: "auto", xmlns: "http://www.w3.org/2000/svg" }, t("path", { key: "eaea1d0090ec37b0b649456df67dde1170e9c741", d: "M4 4H20V20H4V4Z", stroke: "auto", "stroke-width": "1.5", "stroke-linecap": "round", "stroke-linejoin": "round" }));
19
- }
20
- };
21
- r.style = c;
22
- export {
23
- h as play_icon,
24
- r as stop_icon
25
- };
@@ -1 +0,0 @@
1
- "use strict";const a=require("./index-10914bc1-c8c3a2f3.cjs");class s{constructor({nylasAuth:e,nylasAuthStore:r,nylasSchedulerConfigStore:n}){this.nylasAuth=e,this.nylasAuthStore=r,this.nylasSchedulerConfigStore=n}async getCalendars(){var r;if(!this.nylasAuthStore.state.isAuthenticated)return{error:"Not authenticated"};if(!this.nylasAuth.hasScope("calendar:read_only"))return{error:"Missing calendar:read_only scope"};const e=await this.nylasAuth.nylasAPIRequest("/v3/grants/me/calendars");return a.Xr(e)?{error:"Error fetching calendars: "+((r=e.error)==null?void 0:r.message)}:(this.nylasSchedulerConfigStore.state.calendars=e.data,e==null?void 0:e.data)}}function o(t={}){const e={config:{},calendars:[],...t};return a.createStore(e)}exports.CreateNylasSchedulerConfigStore=o;exports.NylasSchedulerConfigAPIConnector=s;
@@ -1,33 +0,0 @@
1
- import { c as s, X as n } from "./index-10914bc1-346f04fa.js";
2
- class c {
3
- constructor({ nylasAuth: e, nylasAuthStore: t, nylasSchedulerConfigStore: a }) {
4
- this.nylasAuth = e, this.nylasAuthStore = t, this.nylasSchedulerConfigStore = a;
5
- }
6
- async getCalendars() {
7
- var t;
8
- if (!this.nylasAuthStore.state.isAuthenticated)
9
- return {
10
- error: "Not authenticated"
11
- };
12
- if (!this.nylasAuth.hasScope("calendar:read_only"))
13
- return {
14
- error: "Missing calendar:read_only scope"
15
- };
16
- const e = await this.nylasAuth.nylasAPIRequest("/v3/grants/me/calendars");
17
- return n(e) ? {
18
- error: "Error fetching calendars: " + ((t = e.error) == null ? void 0 : t.message)
19
- } : (this.nylasSchedulerConfigStore.state.calendars = e.data, e == null ? void 0 : e.data);
20
- }
21
- }
22
- function l(r = {}) {
23
- const e = {
24
- config: {},
25
- calendars: [],
26
- ...r
27
- };
28
- return s(e);
29
- }
30
- export {
31
- l as C,
32
- c as N
33
- };
@@ -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;