@nylas/react 1.1.0-canary.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) 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-7411c224.js +75 -0
  5. package/dist/archive-icon_7.entry-e3df60ed.cjs +1 -0
  6. package/dist/arrow-icon.entry-280e18b0.cjs +1 -0
  7. package/dist/arrow-icon.entry-38949317.js +15 -0
  8. package/dist/bold-icon_3.entry-5963945c.js +35 -0
  9. package/dist/bold-icon_3.entry-5dffbedd.cjs +1 -0
  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_48.entry-9afba869.js +5105 -0
  13. package/dist/calendar-agenda-fill-icon_48.entry-d3830dbb.cjs +7 -0
  14. package/dist/calendar-cancel-icon.entry-77ccf227.cjs +1 -0
  15. package/dist/calendar-cancel-icon.entry-780723a6.js +15 -0
  16. package/dist/calendar-check-icon_2.entry-2c89c230.js +25 -0
  17. package/dist/calendar-check-icon_2.entry-b37ac7f0.cjs +1 -0
  18. package/dist/calendar-icon.entry-02dd3990.js +15 -0
  19. package/dist/calendar-icon.entry-ffc93569.cjs +1 -0
  20. package/dist/checkbox-component_2.entry-00b6a1e9.cjs +1 -0
  21. package/dist/checkbox-component_2.entry-ee9d0e6c.js +56 -0
  22. package/dist/chevron-icon_3.entry-468abc26.cjs +1 -0
  23. package/dist/chevron-icon_3.entry-f62e9ef1.js +129 -0
  24. package/dist/clock-icon_4.entry-766a1b23.js +45 -0
  25. package/dist/clock-icon_4.entry-7dc2cc4a.cjs +1 -0
  26. package/dist/constants-50c3e067-8a40a5fe.js +3883 -0
  27. package/dist/constants-50c3e067-9f2a6372.cjs +15 -0
  28. package/dist/copy-icon.entry-2a841508.js +15 -0
  29. package/dist/copy-icon.entry-e5251410.cjs +1 -0
  30. package/dist/core-js-38e53e34.cjs +4 -0
  31. package/dist/core-js-a9d3b6e1.js +3297 -0
  32. package/dist/delete-icon_2.entry-1a5c39dc.cjs +1 -0
  33. package/dist/delete-icon_2.entry-64555a2f.js +25 -0
  34. package/dist/document-refresh-icon.entry-4bf6398b.js +15 -0
  35. package/dist/document-refresh-icon.entry-fdc7ddda.cjs +1 -0
  36. package/dist/dom-68f08be9.cjs +15 -0
  37. package/dist/dom-86e17616.js +664 -0
  38. package/dist/{types/elements → elements}/index.d.ts +47 -1
  39. package/dist/elements-dc5b338e-2da1fe61.js +28031 -0
  40. package/dist/elements-dc5b338e-c8016c3d.cjs +16516 -0
  41. package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
  42. package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
  43. package/dist/focus-visible-e8093c16-0a38a184.cjs +1 -0
  44. package/dist/focus-visible-e8093c16-9d0c98c0.js +84 -0
  45. package/dist/forward-icon_6.entry-390ef70a.js +953 -0
  46. package/dist/forward-icon_6.entry-7238ef38.cjs +3 -0
  47. package/dist/globe-icon.entry-81f42f89.cjs +1 -0
  48. package/dist/globe-icon.entry-8d106260.js +15 -0
  49. package/dist/google-logo-icon_4.entry-aabd3886.js +680 -0
  50. package/dist/google-logo-icon_4.entry-fa2b8999.cjs +1 -0
  51. package/dist/index-53420959-5fc8ad2b.js +5 -0
  52. package/dist/index-53420959-fcf45780.cjs +1 -0
  53. package/dist/index-5ccfd9df.js +7859 -0
  54. package/dist/index-6d9eeb53-58c8980a.js +4971 -0
  55. package/dist/index-6d9eeb53-b2a6d09f.cjs +41 -0
  56. package/dist/index-eb33703c.cjs +42 -0
  57. package/dist/index.es-c9454237-00ccd1e6.js +3135 -0
  58. package/dist/index.es-c9454237-b64161d1.cjs +7 -0
  59. package/dist/info-icon_2.entry-b2e11336.cjs +1 -0
  60. package/dist/info-icon_2.entry-bb8ed71c.js +34 -0
  61. package/dist/input-component.entry-378b1ccc.cjs +1 -0
  62. package/dist/input-component.entry-cb86170f.js +65 -0
  63. package/dist/input-dropdown.entry-98954c93.cjs +1 -0
  64. package/dist/input-dropdown.entry-a76c339e.js +134 -0
  65. package/dist/mailbox-store-edc386fc-156b7236.cjs +1 -0
  66. package/dist/mailbox-store-edc386fc-8bc7558b.js +380 -0
  67. package/dist/multi-select-dropdown.entry-40b855e1.cjs +1 -0
  68. package/dist/multi-select-dropdown.entry-6b686695.js +91 -0
  69. package/dist/nylas-booked-event-card_12.entry-9d693125.cjs +1 -0
  70. package/dist/nylas-booked-event-card_12.entry-e861bb16.js +1134 -0
  71. package/dist/nylas-form-card.entry-b158d789.js +57 -0
  72. package/dist/nylas-form-card.entry-ca4a8746.cjs +1 -0
  73. package/dist/nylas-if-state.entry-8e4d922c.js +94 -0
  74. package/dist/nylas-if-state.entry-95fac42d.cjs +1 -0
  75. package/dist/nylas-list-folders.entry-83c39684.js +120 -0
  76. package/dist/nylas-list-folders.entry-8a22e0c8.cjs +1 -0
  77. package/dist/nylas-list-threads.entry-54c582af.cjs +1 -0
  78. package/dist/nylas-list-threads.entry-7ea370e1.js +70 -0
  79. package/dist/nylas-login.entry-9115fd81.js +73 -0
  80. package/dist/nylas-login.entry-fb627e40.cjs +1 -0
  81. package/dist/nylas-mailbox-pagination.entry-04626d27.cjs +1 -0
  82. package/dist/nylas-mailbox-pagination.entry-3ff02cf9.js +101 -0
  83. package/dist/nylas-mailbox-toolbar-button.entry-8d00c789.cjs +1 -0
  84. package/dist/nylas-mailbox-toolbar-button.entry-f752e925.js +82 -0
  85. package/dist/nylas-mailbox.entry-99c27b6c.js +134 -0
  86. package/dist/nylas-mailbox.entry-b3974f4e.cjs +1 -0
  87. package/dist/nylas-provider.entry-a3ad02a5.cjs +1 -0
  88. package/dist/nylas-provider.entry-c206aa32.js +145 -0
  89. package/dist/nylas-reminder-emails.entry-414ce6fe.js +129 -0
  90. package/dist/nylas-reminder-emails.entry-59c07bfe.cjs +4 -0
  91. package/dist/nylas-reminder-time_2.entry-197d83a0.js +105 -0
  92. package/dist/nylas-reminder-time_2.entry-d79dcd85.cjs +1 -0
  93. package/dist/nylas-scheduler-editor.entry-7f389982.js +1447 -0
  94. package/dist/nylas-scheduler-editor.entry-f1c6964a.cjs +2 -0
  95. package/dist/nylas-scheduling.entry-1a8bd6fc.cjs +1 -0
  96. package/dist/nylas-scheduling.entry-4fa5381d.js +345 -0
  97. package/dist/nylas-threads-refresh.entry-20602e7b.js +74 -0
  98. package/dist/nylas-threads-refresh.entry-56b53449.cjs +1 -0
  99. package/dist/nylas-threads-search.entry-8872473c.js +69 -0
  100. package/dist/nylas-threads-search.entry-8e0ec3ae.cjs +1 -0
  101. package/dist/nylas-time-window-picker.entry-9ac542b7.js +316 -0
  102. package/dist/nylas-time-window-picker.entry-ca47f721.cjs +1 -0
  103. package/dist/nylas-view-thread.entry-1f758e43.cjs +1 -0
  104. package/dist/nylas-view-thread.entry-dcd3d5be.js +203 -0
  105. package/dist/person-icon.entry-63b28ace.cjs +1 -0
  106. package/dist/person-icon.entry-93130c05.js +15 -0
  107. package/dist/play-icon_2.entry-6a99c32d.js +25 -0
  108. package/dist/play-icon_2.entry-b67fb649.cjs +1 -0
  109. package/dist/react.cjs +1 -0
  110. package/dist/react.js +144 -0
  111. package/dist/refresh-icon.entry-84783c91.js +15 -0
  112. package/dist/refresh-icon.entry-b49792fc.cjs +1 -0
  113. package/dist/register-component-887199a9-003f96c5.cjs +1 -0
  114. package/dist/register-component-887199a9-b41dfa7a.js +109 -0
  115. package/dist/scheduler-config-store-2a3b403d-73610089.js +27 -0
  116. package/dist/scheduler-config-store-2a3b403d-a5e3433a.cjs +1 -0
  117. package/dist/scheduler-store-fe281404-bddb1b6a.js +469 -0
  118. package/dist/scheduler-store-fe281404-c3e477f6.cjs +1 -0
  119. package/dist/textarea-component.entry-28c4bc05.cjs +1 -0
  120. package/dist/textarea-component.entry-40e959e5.js +36 -0
  121. package/dist/time-period-selector.entry-af71523a.cjs +1 -0
  122. package/dist/time-period-selector.entry-da5d8652.js +93 -0
  123. package/dist/translate-icon.entry-92b83635.js +15 -0
  124. package/dist/translate-icon.entry-a2ed4f76.cjs +1 -0
  125. package/dist/warning-icon.entry-19f721c3.js +15 -0
  126. package/dist/warning-icon.entry-3ab9a59e.cjs +1 -0
  127. package/package.json +12 -8
  128. package/dist/elements/index.js +0 -92
  129. package/dist/elements/index.js.map +0 -1
  130. package/dist/elements/react-component-lib/createComponent.js +0 -65
  131. package/dist/elements/react-component-lib/createComponent.js.map +0 -1
  132. package/dist/elements/react-component-lib/createOverlayComponent.js +0 -98
  133. package/dist/elements/react-component-lib/createOverlayComponent.js.map +0 -1
  134. package/dist/elements/react-component-lib/index.js +0 -3
  135. package/dist/elements/react-component-lib/index.js.map +0 -1
  136. package/dist/elements/react-component-lib/interfaces.js +0 -2
  137. package/dist/elements/react-component-lib/interfaces.js.map +0 -1
  138. package/dist/elements/react-component-lib/utils/attachProps.js +0 -92
  139. package/dist/elements/react-component-lib/utils/attachProps.js.map +0 -1
  140. package/dist/elements/react-component-lib/utils/case.js +0 -7
  141. package/dist/elements/react-component-lib/utils/case.js.map +0 -1
  142. package/dist/elements/react-component-lib/utils/dev.js +0 -13
  143. package/dist/elements/react-component-lib/utils/dev.js.map +0 -1
  144. package/dist/elements/react-component-lib/utils/index.js +0 -31
  145. package/dist/elements/react-component-lib/utils/index.js.map +0 -1
  146. package/dist/index.js +0 -29
  147. package/dist/index.js.map +0 -1
  148. /package/dist/{types/elements → elements}/react-component-lib/createComponent.d.ts +0 -0
  149. /package/dist/{types/elements → elements}/react-component-lib/createOverlayComponent.d.ts +0 -0
  150. /package/dist/{types/elements → elements}/react-component-lib/index.d.ts +0 -0
  151. /package/dist/{types/elements → elements}/react-component-lib/interfaces.d.ts +0 -0
  152. /package/dist/{types/elements → elements}/react-component-lib/utils/attachProps.d.ts +0 -0
  153. /package/dist/{types/elements → elements}/react-component-lib/utils/case.d.ts +0 -0
  154. /package/dist/{types/elements → elements}/react-component-lib/utils/dev.d.ts +0 -0
  155. /package/dist/{types/elements → elements}/react-component-lib/utils/index.d.ts +0 -0
  156. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";var U=Object.defineProperty;var P=(r,t,n)=>t in r?U(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var S=(r,t,n)=>(P(r,typeof t!="symbol"?t+"":t,n),n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const index=require("./index-eb33703c.cjs"),index_esC9454237=require("./index.es-c9454237-b64161d1.cjs"),schedulerConfigStore2a3b403d=require("./scheduler-config-store-2a3b403d-a5e3433a.cjs"),index53420959=require("./index-53420959-fcf45780.cjs");require("react");require("react-dom");class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:n}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=n}async currentUser(){return this.nylasApiRequest?this.nylasApiRequest.currentUser():(console.warn("Nylas API Request is not initialized"),null)}async getCalendars(){var s;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"});const[t,n]=await this.nylasApiRequest.request({method:"GET",path:"calendars"});return n?index.dataResponse(null,{message:"Error fetching calendars: "+n.message}):index_esC9454237.Xr(t)?index.dataResponse(null,{message:"Error fetching calendars: "+((s=t.error)==null?void 0:s.message)}):(this.nylasSchedulerConfigStore.state.calendars=t.data,index.dataResponse(t.data))}async getConfigurationById(t,n=!1){var a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"});if(!n){const l=this.nylasSchedulerConfigStore.state.configurations.find(d=>d.id===t);if(l)return this.nylasSchedulerConfigStore.state.selectedConfiguration=l,index.dataResponse(l)}const[s,c]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${t}`});return c?index.dataResponse(null,{message:"Error fetching configuration: "+c.message}):index_esC9454237.Xr(s)?index.dataResponse(null,{message:"Error fetching configuration: "+((a=s.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=s.data,this.nylasSchedulerConfigStore.state.configurations.find(l=>l.id===t)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(l=>l.id===t?s.data:l):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,s.data],index.dataResponse(s.data))}async getConfigurations(t){var a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"});const n=50,[s,c]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${n}${t?`&page_token=${t}`:""}`});return c?index.dataResponse(null,{message:"Error fetching configurations: "+c.message}):index_esC9454237.Xr(s)?index.dataResponse(null,{message:"Error fetching configurations: "+((a=s.error)==null?void 0:a.message)}):(this.nylasSchedulerConfigStore.state.configurations=s.data,this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=s.next_cursor||null,index.dataResponse(s.data))}async createConfiguration(t){var c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"POST",path:"scheduling/configurations",body:t});return s?index.dataResponse(null,{message:"Error creating configuration: "+s.message}):index_esC9454237.Xr(n)?index.dataResponse(null,{message:"Error creating configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],index.dataResponse(n.data))}async updateConfiguration(t){var c;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${t.id}`,body:t});return s?index.dataResponse(null,{message:"Error updating configuration: "+s.message}):index_esC9454237.Xr(n)?index.dataResponse(null,{message:"Error updating configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data,this.nylasSchedulerConfigStore.state.configurations.find(a=>a.id===t.id)?this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map(a=>a.id===t.id?n.data:a):this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data],index.dataResponse(n.data))}async deleteConfiguration(t){var c,a;if(!this.nylasApiRequest)return console.warn("Nylas API Request is not initialized"),index.dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"});const[n,s]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}`});return s?index.dataResponse(null,{message:"Error deleting configuration: "+s.message}):index_esC9454237.Xr(n)?index.dataResponse(null,{message:"Error deleting configuration: "+((c=n.error)==null?void 0:c.message)}):(this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter(l=>l.id!==t),((a=this.nylasSchedulerConfigStore.state.selectedConfiguration)==null?void 0:a.id)===t&&this.nylasSchedulerConfigStore.resetSelectedConfiguration(),index.dataResponse(n.data))}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:t,nylasSchedulerConfigStore:n}){this.nylasApiRequest=t,this.nylasSchedulerConfigStore=n}init(){index.debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){return this._schedulerConfigConnector?this._schedulerConfigConnector:(this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore}),this._schedulerConfigConnector)}resetStores(){index.debug("NylasSchedulerConfigConnector resetStores"),this.nylasSchedulerConfigStore.reset()}async logout(){index.debug("NylasSchedulerConfigConnector logout"),this.resetStores()}}class LocalStorage{get(t){return new Promise(n=>{const s=window.localStorage.getItem(t);n(s?JSON.parse(s):null)})}async remove(t){return window.localStorage.removeItem(t),new Promise(n=>{n(null)})}set(t,n){return window.localStorage.setItem(t,JSON.stringify(n)),new Promise(s=>{s(null)})}}const PKCE_KEY="pkce",GRANT_KEY="grant",USER_KEY="user";class Storage{constructor(t){S(this,"Storage",new LocalStorage);if(t){this.Storage=t;return}}setPKCE(t){const n=index.Buffer.from(t);this.Storage.set(PKCE_KEY,n.toString("base64"))}async getPKCE(){try{const t=await this.Storage.get(PKCE_KEY);if(t)return index.Buffer.from(t,"base64").toString("utf8")}catch{return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(t,n=!1){const{grant_id:s}=t;this.Storage.set(`${GRANT_KEY}${n?"-"+s:""}`,t)}removeGrant(t,n=!1){this.Storage.remove(`${GRANT_KEY}${n?"-"+t:""}`)}async getGrant(t,n=!1){const s=await this.Storage.get(`${GRANT_KEY}${n?"-"+t:""}`);return s||null}async setUserToken(t){const n=await this.getUserTokens();if(n)if(n.find(c=>c.sub===t.sub)){const c=n.map(a=>(a.sub===t.sub&&(a=t),a));this.Storage.set(USER_KEY,c)}else{const c=[...n,t];this.Storage.set(USER_KEY,c)}else this.Storage.set(USER_KEY,[t])}async getUserToken(t=""){const n=await this.Storage.get(USER_KEY);return n?t===""?n[0]:n.find(c=>c.sub===t):null}async getUserTokens(){const t=await this.Storage.get(USER_KEY);return t||null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(t){const n=await this.getUserTokens(),s=n==null?void 0:n.filter(c=>c.sub!==t);this.Storage.set(USER_KEY,s)}async clearSession(){const t=await this.getUserTokens();t==null||t.forEach(n=>{this.removeGrant(n.sub)}),this.removePKCE(),this.removeUserTokens()}}class IndexedDBStorage{constructor(){S(this,"databaseName","identity-db");S(this,"storeName","identity")}get(t){const n=this;return new Promise((s,c)=>{n.openDatabase().then(function(a){const l=a.transaction(n.storeName,"readwrite"),h=l.objectStore(n.storeName).get(t);h.onsuccess=()=>{s(h.result)},h.onerror=()=>{c(h.error)},l.oncomplete=()=>{a.close()}})})}async remove(t){const n=this;return new Promise((s,c)=>{const a=indexedDB.open(this.databaseName);a.onupgradeneeded=function(l){l.target.result.createObjectStore(n.storeName)},a.onerror=()=>{c(a.error)},a.onsuccess=l=>{const d=l.target.result,h=d.transaction(this.storeName,"readwrite"),p=h.objectStore(this.storeName).delete(t);p.onsuccess=()=>{s(null)},p.onerror=()=>{c(p.error)},h.oncomplete=()=>{d.close()}}})}set(t,n){return new Promise((s,c)=>{const a=indexedDB.open(this.databaseName);a.onerror=()=>{c(a.error)},a.onupgradeneeded=l=>{l.target.result.createObjectStore(this.storeName)},a.onsuccess=l=>{const d=l.target.result,h=d.transaction(this.storeName,"readwrite"),p=h.objectStore(this.storeName).put(n,t);p.onsuccess=()=>{s(n)},p.onerror=()=>{c(p.error)},h.oncomplete=()=>{d.close()}}})}openDatabase(){const t=this;return new Promise(function(n,s){const c=indexedDB.open(t.databaseName,2);c.onupgradeneeded=function(a){a.target.result.createObjectStore(t.storeName)},c.onsuccess=function(a){n(a.target.result)},c.onerror=function(a){s(a.error)}})}}var sha256={exports:{}};(function(module){(function(){var ERROR="input is invalid type",WINDOW=typeof window=="object",root=WINDOW?window:{};root.JS_SHA256_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self=="object",NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof index53420959.process=="object"&&index53420959.process.versions&&index53420959.process.versions.node;NODE_JS?root=index.commonjsGlobal:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&!0&&module.exports,ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",HEX_CHARS="0123456789abcdef".split(""),EXTRA=[-2147483648,8388608,32768,128],SHIFT=[24,16,8,0],K=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],OUTPUT_TYPES=["hex","array","digest","arrayBuffer"],blocks=[];(root.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(r){return Object.prototype.toString.call(r)==="[object Array]"}),ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(r){return typeof r=="object"&&r.buffer&&r.buffer.constructor===ArrayBuffer});var createOutputMethod=function(r,t){return function(n){return new Sha256(t,!0).update(n)[r]()}},createMethod=function(r){var t=createOutputMethod("hex",r);NODE_JS&&(t=nodeWrap(t,r)),t.create=function(){return new Sha256(r)},t.update=function(c){return t.create().update(c)};for(var n=0;n<OUTPUT_TYPES.length;++n){var s=OUTPUT_TYPES[n];t[s]=createOutputMethod(s,r)}return t},nodeWrap=function(method,is224){var crypto=eval("require('crypto')"),Buffer=eval("require('buffer').Buffer"),algorithm=is224?"sha224":"sha256",nodeMethod=function(r){if(typeof r=="string")return crypto.createHash(algorithm).update(r,"utf8").digest("hex");if(r==null)throw new Error(ERROR);return r.constructor===ArrayBuffer&&(r=new Uint8Array(r)),Array.isArray(r)||ArrayBuffer.isView(r)||r.constructor===Buffer?crypto.createHash(algorithm).update(new Buffer(r)).digest("hex"):method(r)};return nodeMethod},createHmacOutputMethod=function(r,t){return function(n,s){return new HmacSha256(n,t,!0).update(s)[r]()}},createHmacMethod=function(r){var t=createHmacOutputMethod("hex",r);t.create=function(c){return new HmacSha256(c,r)},t.update=function(c,a){return t.create(c).update(a)};for(var n=0;n<OUTPUT_TYPES.length;++n){var s=OUTPUT_TYPES[n];t[s]=createHmacOutputMethod(s,r)}return t};function Sha256(r,t){t?(blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=r}Sha256.prototype.update=function(r){if(!this.finalized){var t,n=typeof r;if(n!=="string"){if(n==="object"){if(r===null)throw new Error(ERROR);if(ARRAY_BUFFER&&r.constructor===ArrayBuffer)r=new Uint8Array(r);else if(!Array.isArray(r)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(r)))throw new Error(ERROR)}else throw new Error(ERROR);t=!0}for(var s,c=0,a,l=r.length,d=this.blocks;c<l;){if(this.hashed&&(this.hashed=!1,d[0]=this.block,d[16]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0),t)for(a=this.start;c<l&&a<64;++c)d[a>>2]|=r[c]<<SHIFT[a++&3];else for(a=this.start;c<l&&a<64;++c)s=r.charCodeAt(c),s<128?d[a>>2]|=s<<SHIFT[a++&3]:s<2048?(d[a>>2]|=(192|s>>6)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]):s<55296||s>=57344?(d[a>>2]|=(224|s>>12)<<SHIFT[a++&3],d[a>>2]|=(128|s>>6&63)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]):(s=65536+((s&1023)<<10|r.charCodeAt(++c)&1023),d[a>>2]|=(240|s>>18)<<SHIFT[a++&3],d[a>>2]|=(128|s>>12&63)<<SHIFT[a++&3],d[a>>2]|=(128|s>>6&63)<<SHIFT[a++&3],d[a>>2]|=(128|s&63)<<SHIFT[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.block=d[16],this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},Sha256.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var r=this.blocks,t=this.lastByteIndex;r[16]=this.block,r[t>>2]|=EXTRA[t&3],this.block=r[16],t>=56&&(this.hashed||this.hash(),r[0]=this.block,r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0),r[14]=this.hBytes<<3|this.bytes>>>29,r[15]=this.bytes<<3,this.hash()}},Sha256.prototype.hash=function(){var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=this.blocks,u,p,f,y,g,x,w,m,v,_,R;for(u=16;u<64;++u)g=h[u-15],p=(g>>>7|g<<25)^(g>>>18|g<<14)^g>>>3,g=h[u-2],f=(g>>>17|g<<15)^(g>>>19|g<<13)^g>>>10,h[u]=h[u-16]+p+h[u-7]+f<<0;for(R=t&n,u=0;u<64;u+=4)this.first?(this.is224?(m=300032,g=h[0]-1413257819,d=g-150054599<<0,s=g+24177077<<0):(m=704751109,g=h[0]-210244248,d=g-1521486534<<0,s=g+143694565<<0),this.first=!1):(p=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10),f=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),m=r&t,y=m^r&n^R,w=c&a^~c&l,g=d+f+w+K[u]+h[u],x=p+y,d=s+g<<0,s=g+x<<0),p=(s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10),f=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7),v=s&r,y=v^s&t^m,w=d&c^~d&a,g=l+f+w+K[u+1]+h[u+1],x=p+y,l=n+g<<0,n=g+x<<0,p=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10),f=(l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7),_=n&s,y=_^n&r^v,w=l&d^~l&c,g=a+f+w+K[u+2]+h[u+2],x=p+y,a=t+g<<0,t=g+x<<0,p=(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10),f=(a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7),R=t&n,y=R^t&s^_,w=a&l^~a&d,g=c+f+w+K[u+3]+h[u+3],x=p+y,c=r+g<<0,r=g+x<<0;this.h0=this.h0+r<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+s<<0,this.h4=this.h4+c<<0,this.h5=this.h5+a<<0,this.h6=this.h6+l<<0,this.h7=this.h7+d<<0},Sha256.prototype.hex=function(){this.finalize();var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[s>>28&15]+HEX_CHARS[s>>24&15]+HEX_CHARS[s>>20&15]+HEX_CHARS[s>>16&15]+HEX_CHARS[s>>12&15]+HEX_CHARS[s>>8&15]+HEX_CHARS[s>>4&15]+HEX_CHARS[s&15]+HEX_CHARS[c>>28&15]+HEX_CHARS[c>>24&15]+HEX_CHARS[c>>20&15]+HEX_CHARS[c>>16&15]+HEX_CHARS[c>>12&15]+HEX_CHARS[c>>8&15]+HEX_CHARS[c>>4&15]+HEX_CHARS[c&15]+HEX_CHARS[a>>28&15]+HEX_CHARS[a>>24&15]+HEX_CHARS[a>>20&15]+HEX_CHARS[a>>16&15]+HEX_CHARS[a>>12&15]+HEX_CHARS[a>>8&15]+HEX_CHARS[a>>4&15]+HEX_CHARS[a&15]+HEX_CHARS[l>>28&15]+HEX_CHARS[l>>24&15]+HEX_CHARS[l>>20&15]+HEX_CHARS[l>>16&15]+HEX_CHARS[l>>12&15]+HEX_CHARS[l>>8&15]+HEX_CHARS[l>>4&15]+HEX_CHARS[l&15];return this.is224||(h+=HEX_CHARS[d>>28&15]+HEX_CHARS[d>>24&15]+HEX_CHARS[d>>20&15]+HEX_CHARS[d>>16&15]+HEX_CHARS[d>>12&15]+HEX_CHARS[d>>8&15]+HEX_CHARS[d>>4&15]+HEX_CHARS[d&15]),h},Sha256.prototype.toString=Sha256.prototype.hex,Sha256.prototype.digest=function(){this.finalize();var r=this.h0,t=this.h1,n=this.h2,s=this.h3,c=this.h4,a=this.h5,l=this.h6,d=this.h7,h=[r>>24&255,r>>16&255,r>>8&255,r&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,s>>24&255,s>>16&255,s>>8&255,s&255,c>>24&255,c>>16&255,c>>8&255,c&255,a>>24&255,a>>16&255,a>>8&255,a&255,l>>24&255,l>>16&255,l>>8&255,l&255];return this.is224||h.push(d>>24&255,d>>16&255,d>>8&255,d&255),h},Sha256.prototype.array=Sha256.prototype.digest,Sha256.prototype.arrayBuffer=function(){this.finalize();var r=new ArrayBuffer(this.is224?28:32),t=new DataView(r);return t.setUint32(0,this.h0),t.setUint32(4,this.h1),t.setUint32(8,this.h2),t.setUint32(12,this.h3),t.setUint32(16,this.h4),t.setUint32(20,this.h5),t.setUint32(24,this.h6),this.is224||t.setUint32(28,this.h7),r};function HmacSha256(r,t,n){var s,c=typeof r;if(c==="string"){var a=[],l=r.length,d=0,h;for(s=0;s<l;++s)h=r.charCodeAt(s),h<128?a[d++]=h:h<2048?(a[d++]=192|h>>6,a[d++]=128|h&63):h<55296||h>=57344?(a[d++]=224|h>>12,a[d++]=128|h>>6&63,a[d++]=128|h&63):(h=65536+((h&1023)<<10|r.charCodeAt(++s)&1023),a[d++]=240|h>>18,a[d++]=128|h>>12&63,a[d++]=128|h>>6&63,a[d++]=128|h&63);r=a}else if(c==="object"){if(r===null)throw new Error(ERROR);if(ARRAY_BUFFER&&r.constructor===ArrayBuffer)r=new Uint8Array(r);else if(!Array.isArray(r)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(r)))throw new Error(ERROR)}else throw new Error(ERROR);r.length>64&&(r=new Sha256(t,!0).update(r).array());var u=[],p=[];for(s=0;s<64;++s){var f=r[s]||0;u[s]=92^f,p[s]=54^f}Sha256.call(this,t,n),this.update(p),this.oKeyPad=u,this.inner=!0,this.sharedMemory=n}HmacSha256.prototype=new Sha256,HmacSha256.prototype.finalize=function(){if(Sha256.prototype.finalize.call(this),this.inner){this.inner=!1;var r=this.array();Sha256.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(r),Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports,exports.sha224=createMethod(!0),exports.sha256.hmac=createHmacMethod(),exports.sha224.hmac=createHmacMethod(!0),COMMON_JS?module.exports=exports:(root.sha256=exports.sha256,root.sha224=exports.sha224)})()})(sha256);var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&(getRandomValues=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!getRandomValues))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}const REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(r){return typeof r=="string"&&REGEX.test(r)}var byteToHex=[];for(var i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=(byteToHex[r[t+0]]+byteToHex[r[t+1]]+byteToHex[r[t+2]]+byteToHex[r[t+3]]+"-"+byteToHex[r[t+4]]+byteToHex[r[t+5]]+"-"+byteToHex[r[t+6]]+byteToHex[r[t+7]]+"-"+byteToHex[r[t+8]]+byteToHex[r[t+9]]+"-"+byteToHex[r[t+10]]+byteToHex[r[t+11]]+byteToHex[r[t+12]]+byteToHex[r[t+13]]+byteToHex[r[t+14]]+byteToHex[r[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(r,t,n){r=r||{};var s=r.random||(r.rng||rng)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){n=n||0;for(var c=0;c<16;++c)t[n+c]=s[c];return t}return stringify(s)}async function getBytes(r,t){const n=r.getReader();let s;for(;!(s=await n.read()).done;)t(s.value)}function getLines(r){let t,n,s,c=!1;return function(l){t===void 0?(t=l,n=0,s=-1):t=concat(t,l);const d=t.length;let h=0;for(;n<d;){c&&(t[n]===10&&(h=++n),c=!1);let u=-1;for(;n<d&&u===-1;++n)switch(t[n]){case 58:s===-1&&(s=n-h);break;case 13:c=!0;case 10:u=n;break}if(u===-1)break;r(t.subarray(h,u),s),h=n,s=-1}h===d?t=void 0:h!==0&&(t=t.subarray(h),n-=h)}}function getMessages(r,t,n){let s=newMessage();const c=new TextDecoder;return function(l,d){if(l.length===0)n==null||n(s),s=newMessage();else if(d>0){const h=c.decode(l.subarray(0,d)),u=d+(l[d+1]===32?2:1),p=c.decode(l.subarray(u));switch(h){case"data":s.data=s.data?s.data+`
2
+ `+p:p;break;case"event":s.event=p;break;case"id":r(s.id=p);break;case"retry":const f=parseInt(p,10);isNaN(f)||t(s.retry=f);break}}}}function concat(r,t){const n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),n}function newMessage(){return{data:"",event:"",id:"",retry:void 0}}var __rest=function(r,t){var n={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&t.indexOf(s)<0&&(n[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var c=0,s=Object.getOwnPropertySymbols(r);c<s.length;c++)t.indexOf(s[c])<0&&Object.prototype.propertyIsEnumerable.call(r,s[c])&&(n[s[c]]=r[s[c]]);return n};const EventStreamContentType="text/event-stream",DefaultRetryInterval=1e3,LastEventId="last-event-id";function fetchEventSource(r,t){var{signal:n,headers:s,onopen:c,onmessage:a,onclose:l,onerror:d,openWhenHidden:h,fetch:u}=t,p=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((f,y)=>{const g=Object.assign({},s);g.accept||(g.accept=EventStreamContentType);let x;function w(){x.abort(),document.hidden||T()}h||document.addEventListener("visibilitychange",w);let m=DefaultRetryInterval,v=0;function _(){document.removeEventListener("visibilitychange",w),window.clearTimeout(v),x.abort()}n==null||n.addEventListener("abort",()=>{_(),f()});const R=u??window.fetch,I=c??defaultOnOpen;async function T(){var k;x=new AbortController;try{const A=await R(r,Object.assign(Object.assign({},p),{headers:g,signal:x.signal}));await I(A),await getBytes(A.body,getLines(getMessages(b=>{b?g[LastEventId]=b:delete g[LastEventId]},b=>{m=b},a))),l==null||l(),_(),f()}catch(A){if(!x.signal.aborted)try{const b=(k=d==null?void 0:d(A))!==null&&k!==void 0?k:m;window.clearTimeout(v),v=window.setTimeout(T,b)}catch(b){_(),y(b)}}}T()})}function defaultOnOpen(r){const t=r.headers.get("content-type");if(!(t!=null&&t.startsWith(EventStreamContentType)))throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}function Base64EncodeUrl(r){return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function getTimestamp(){return Math.floor(Date.now()/1e3)}function e(r){this.message=r}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,s,c=0,a=0,l="";s=t.charAt(a++);~s&&(n=c%4?64*n+s:s,c++%4)?l+=String.fromCharCode(255&n>>(-2*c&6)):0)s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(s);return l};function t$1(r){var t=r.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw"Illegal base64url string!"}try{return function(n){return decodeURIComponent(r$1(n).replace(/(.)/g,function(s,c){var a=c.charCodeAt(0).toString(16).toUpperCase();return a.length<2&&(a="0"+a),"%"+a}))}(t)}catch{return r$1(t)}}function n$1(r){this.message=r}function o(r,t){if(typeof r!="string")throw new n$1("Invalid token specified");var n=(t=t||{}).header===!0?0:1;try{return JSON.parse(t$1(r.split(".")[n]))}catch(s){throw new n$1("Invalid token specified: "+s.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{constructor(t){S(this,"clientId");S(this,"redirectUri");S(this,"accessType","online");S(this,"domain","http://api.nylas.com");S(this,"versioned",!1);S(this,"Storage");S(this,"hosted",!1);S(this,"multiAccount",!1);S(this,"loginId","");if(this.clientId=t.clientId,this.redirectUri=t.redirectUri,t.domain&&(this.domain=t.domain,this.domain.substring(this.domain.length-3).includes("/v")&&(this.versioned=!0)),t.multiAccount&&(this.multiAccount=t.multiAccount),t.sw){const n=new IndexedDBStorage;this.Storage=new Storage(n)}else this.Storage=new Storage;t.accessType&&(this.accessType=t.accessType),t.loginId&&(this.loginId=t.loginId),t.hosted&&(this.hosted=t.hosted),this.codeExchange(null)}async validateAccessToken(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const{access_token:s}=n;try{return!!(await(await fetch(`${this.domain}/connect/tokeninfo?access_token=${s}`,{method:"GET"})).json()).data}catch{return!1}}async validateIDToken(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const{id_token:s}=n;try{const c=await fetch(`${this.domain}/connect/tokeninfo?id_token=${s}`,{method:"GET"});return!(c.status!==200||!(await c.json()).data)}catch{return!1}}getDomain(){return this.domain}async auth(t){this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))&&await this.hostedSetCodeChallenge();const n=await this.generateAuthURL(t);if(t.popup){this.popUp(n);return}return n}async generateAuthURL(t){const n=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return n&&(s+=`&code_challenge=${n}&code_challenge_method=S256&options=rotate_refresh_token`),t.provider&&(s+=`&provider=${t.provider}`),t.loginHint&&(s+=`&login_hint=${t.loginHint}`,t.includeGrantScopes&&(s+=`&include_grant_scopes=${t.includeGrantScopes}`)),t.scope&&(s+=`&scope=${t.scope.join(" ")}`),t.prompt&&(s+=`&prompt=${t.prompt}`),t.metadata&&(s+=`&metadata=${t.metadata}`),(t.state||this.loginId)&&(s+=`&state=${this.loginId?this.loginId:t.state}`),s}async generateReauthURL(t,n){if(!t)throw new Error("Grant ID is required");const s=await this.Storage.getUserToken(t),c=await this.getCodeChallege();let a=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;return c&&(a+=`&code_challenge=${c}&code_challenge_method=S256&options=rotate_refresh_token`),s!=null&&s.provider&&(a+=`&provider=${s.provider}`),s!=null&&s.email&&(a+=`&login_hint=${s.email}`),n&&(a+=`&scope=${n.join(" ")}`),a}async generateCodeChallenge(){if(await this.Storage.getPKCE())return;const n=v4();this.Storage.setPKCE(n)}async hostedSetCodeChallenge(){if(!this.hosted)throw console.error("Method only used with hosted flag enabled");const n=new URLSearchParams(window.location.search).get("code_challenge");if(!n){if(await this.Storage.getPKCE())return;console.warn("Code challenge is recomended");return}this.Storage.setPKCE(n)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const s=new URLSearchParams(window.location.search).get("code_challenge");return s||(console.warn("Code challenge is recomended"),"")}const t=await this.Storage.getPKCE();if(t){const n=sha256.exports.sha256(t);let s=index.Buffer.from(n).toString("base64");return s=Base64EncodeUrl(s),s}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin)))return!1;const t=await this.Storage.getUserTokens();return t&&t.length>0?(this.multiAccount&&await this.generateCodeChallenge(),!0):(await this.generateCodeChallenge(),!1)}isMultiAccount(){return this.multiAccount}async logout(){const t=await this.getProfile();await this.Storage.clearSession();const n={detail:t};window.dispatchEvent(new CustomEvent("onLogoutSuccess",n))}async getProfile(t=""){let n;return t?n=await this.Storage.getUserToken(t):n=await this.Storage.getUserToken(),n||null}async getProfiles(){const t=await this.Storage.getUserTokens();return t||null}async removeProfile(t){return await this.Storage.removeUserToken(t),await this.Storage.removeGrant(t),null}async authIMAP(t){const n=await this.getCodeChallege(),s={imap_username:t.username,imap_password:t.password,imap_host:t.hostIMAP,imap_port:t.portIMAP,type:t.type,smtp_host:t.hostSMTP,smtp_port:t.portSMTP,provider:t.provider,redirect_uri:this.redirectUri,state:t.state,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),n!=""&&(s.code_challenge=n,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async authEWS(t){const n=await this.getCodeChallege(),s={...t,redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};return this.loginId&&(s.id=this.loginId),n!=""&&(s.code_challenge=n,s.code_challenge_method="S256"),await(await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(s)})).json()}async detectEmail(t){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${t}`,{method:"POST",headers:new Headers({"content-type":"application/json"})})).json()).data}async applicationInfo(){return(await(await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})})).json()).data}async getAvailableProviders(){const t=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});return t?(await t.json()).data:null}onLoginSuccess(t){window.addEventListener("onLoginSuccess",n=>t(n))}onLogoutSuccess(t){window.addEventListener("onLogoutSuccess",n=>t(n))}onLoginFail(t){window.addEventListener("onLoginFail",n=>t(n))}onTokenRefreshSuccess(t){window.addEventListener("onTokenRefreshSuccess",n=>t(n))}onTokenRefreshFail(t){window.addEventListener("onTokenRefreshFail",n=>t(n))}onSessionExpired(t){window.addEventListener("onSessionExpired",n=>t(n))}async codeExchange(t){let n=new URLSearchParams(window.location.search);t&&(n=new URLSearchParams(t));const s=n.get("code"),c=n.get("state"),a=n.get("error"),l=n.get("error_description"),d=n.get("error_code");if(a&&l&&d){const u={detail:{error:a,error_description:l,error_code:d}};return window.dispatchEvent(new CustomEvent("onLoginFail",u)),window.history.pushState({},document.title,window.location.pathname),!1}if(!s)return console.warn("No code found"),!1;if(window.opener&&window.name==="uas-popup")return console.warn("Popup window detected"),!1;const h=await this.Storage.getPKCE();if(!h)return console.warn("No code verifier found"),!1;try{const u={client_id:this.clientId,redirect_uri:this.redirectUri,code:s,grant_type:"authorization_code",code_verifier:h},f=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(u)})).json();if(f){if(f.error){const g={detail:f};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}const y=await this.handleCodeExchangeResponse(f);if(y.valid){c&&(y.data.state=c);const g={detail:y.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",g)),window.history.pushState({},document.title,window.location.pathname)}else{const g={detail:y.data};return window.dispatchEvent(new CustomEvent("onLoginFail",g)),!0}}return this.Storage.removePKCE(),!0}catch(u){const p={detail:u};return window.dispatchEvent(new CustomEvent("onLoginFail",p)),window.history.pushState({},document.title,window.location.pathname),!1}}async tokenExchange(t=""){const n=await this.Storage.getGrant(t,this.multiAccount);if(!n)return!1;const s=n.refresh_token;try{const c={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:s,grant_type:"refresh_token"},l=await(await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(c)})).json();if(l){if(l.error){const p={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",p)),!0}const d=getTimestamp();if(l.expires_in=d+l.expires_in,this.Storage.setGrant(l,this.multiAccount),!await this.validateIDToken(t)){const p={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",p)),!0}const u={detail:l};return window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",u)),!0}this.Storage.removePKCE()}catch(c){const a={detail:c};return window.dispatchEvent(new CustomEvent("onTokenRefreshFail",a)),!1}}async handleCodeExchangeResponse(t){if(t.error)return{data:t,valid:!1};const s=getTimestamp();t.expires_in=s+t.expires_in,this.Storage.setGrant(t,this.multiAccount);const c=o(t.id_token);return c.status="authenticated",this.Storage.setUserToken(c),await this.validateIDToken(c.sub)?{data:t,valid:!0}:{data:t,valid:!1}}async popUp(t){const c=window.screenX+(window.outerWidth-500)/2,a=window.screenY+(window.outerHeight-600)/2.5,l="uas-popup",d=t,h=window.open(d,l,`width=500,height=600,left=${c},top=${a}`);if(!h)return;const u=setInterval(async()=>{if(h.closed){const p={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",p)),u&&clearInterval(u);return}try{const p=h.location.href.split("?");if(!p[0])return;const f=h.location.search;if(h.history.pushState({},document.title,window.location.pathname),p[0]===this.redirectUri&&p.length>1){const y=await this.codeExchange(f);h.close(),y&&location.reload(),u&&clearInterval(u);return}}catch{return}},1e3)}async getAccessToken(t=""){const n=getTimestamp(),s=await this.Storage.getGrant(t,this.multiAccount);if(!s)return null;const{access_token:c,expires_in:a}=s,l=c;return l&&a&&a>getTimestamp()&&a-n>30?l:(await this.tokenExchange(t),(await this.Storage.getGrant(t,this.multiAccount)).access_token)}async sse(t,n){const s=n.headers||{},c=s["Grant-ID"];let a="";if(this.multiAccount){if(!c)throw this.logout(),new Error("Grant ID is required for multi account calls");a=await this.getAccessToken(c)}else a=await this.getAccessToken();return delete s["Grant-ID"],s.Authorization=`Bearer ${a}`,s["content-type"]||(s["content-type"]="application/json"),fetchEventSource(`${this.domain}/${t}`,{...n,headers:s})}async fetch(t,n,s=!0,c){let a="",l=1;if(this.multiAccount){if(!n.grant_id)throw this.logout(),new Error("Grant ID is required for multi account calls");const h=await this.getProfiles();l=h?h.length:1,a=await this.getAccessToken(n.grant_id)}else a=await this.getAccessToken();if(!a)throw new Error("Access token not found");let d=n.headers;Headers.prototype.isPrototypeOf(d)?(d.append("Authorization",`Bearer ${a}`),d.has("content-type")||d.append("content-type","application/json")):d=new Headers({Authorization:`Bearer ${a}`,"content-type":"application/json"});try{n!=null&&n.body&&(n.body=JSON.stringify(n==null?void 0:n.body));const h=await fetch(`${c||this.domain}/${t}`,{...n,headers:d});if(!s)return h;const u=await(h==null?void 0:h.json());if(!await this.isAuthenticatedResponse(h.status,u)){if(l>1){const f=await this.getProfile(n.grant_id);if(f){f.status="unauthorized",await this.Storage.setUserToken(f);const y={detail:{user:f}};window.dispatchEvent(new CustomEvent("onSessionExpired",y))}}else{const y={detail:{user:await this.Storage.getUserToken()}};window.dispatchEvent(new CustomEvent("onSessionExpired",y))}this.logout();return}return u}catch(h){throw h}}async fetchRequest(t,n,s,c=!0,a,l){const d=await this.isLoggedIn(),h=new URL(t,a??this.domain),u=new Headers;if(u.append("Accept","application/json"),u.append("Content-Type","application/json"),u.append("User-Agent","nylas-identity"),d){const y=await this.getAccessToken();u.append("Authorization",`Bearer ${y}`)}const p=await fetch(h.toString(),{method:n||"GET",headers:u,mode:"cors",referrer:location.origin,body:s?JSON.stringify(s):void 0,...l||{}});return c?await p.json():p.body}async isAuthenticatedResponse(t,n){var s;return!(t==401&&((s=n==null?void 0:n.error)==null?void 0:s.type)=="token.unauthorized_access")}addAPIKey(t,n,s){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:!0,iat:getTimestamp(),iss:"",email:n,provider:"virtual-calendar",status:"authenticated",name:n,sub:t}),this.Storage.setGrant({grant_id:t,access_token:s,expires_in:2e9},this.multiAccount)}}var B={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,D={};function E(r,t,n){this.props=r,this.context=t,this.refs=D,this.updater=n||B}E.prototype.isReactComponent={};E.prototype.setState=function(r,t){if(typeof r!="object"&&typeof r!="function"&&r!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,r,t,"setState")};E.prototype.forceUpdate=function(r){this.updater.enqueueForceUpdate(this,r,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(r,t,n){this.props=r,this.context=t,this.refs=D,this.updater=n||B}var H=G.prototype=new F;H.constructor=G;C(H,E.prototype);H.isPureReactComponent=!0;const LoginRequired=({authenticationUrl:r})=>index.h("div",{class:"login-required",part:"login-component"},index.h("div",{class:"card"},index.h("p",null,"Log into your account to use the Scheduler Editor."),index.h("button",{class:"google-button",onClick:async t=>{t.preventDefault();const n=await r("google");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),index.h("button",{class:"microsoft-button",onClick:async t=>{t.preventDefault();const n=await r("microsoft");n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},index.h("span",{class:"icon"},index.h("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),index.h("button",{class:"other-provider-button",onClick:async t=>{t.preventDefault();const n=await r();n?window.location.href=n:console.error("[nylas-scheduler-editor] Unable to get authentication URL.")}},"View all providers ",index.h("chevron-icon",{width:"17",height:"17"})),index.h("small",{class:"disclaimer-text"},"* You will be redirected to authenticate your account.")));function ExpressFlow({selectedConfiguration:r,currentUser:t,calendars:n}){var c;const s=((c=r.participants)==null?void 0:c.find(a=>a.is_organizer))??t;return index.h(index.Fragment,null,index.h("nylas-event-info",null,index.h("div",{slot:"inputs"},index.h("nylas-event-title",null),index.h("nylas-event-duration",null),index.h("nylas-event-location",{userProvider:t.provider}))),index.h("nylas-booking-calendar-picker",{calendars:n,currentUser:t,defaultBookingCalendar:s==null?void 0:s.email}),index.h("nylas-scheduling-method",{exportparts:"nsm, nsm__header, nsm__input-label, nsm__dropdown, nsm__dropdown-button, nsm__dropdown-content"}),index.h("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}const nylasSchedulerEditorCss=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-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-content{height:610px}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:auto;height:inherit}nylas-editor-tabs .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.login-required{height:auto}}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:1rem;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}@media screen and (max-width: 768px){.list-configurations{height:auto}}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}',NylasSchedulerEditorStyle0=nylasSchedulerEditorCss,NylasSchedulerEditor=class{constructor(r){index.registerInstance(this,r),this.init=index.createEvent(this,"init",7),this.loggedIn=index.createEvent(this,"loggedIn",7),this.loggedOut=index.createEvent(this,"loggedOut",7),this.schedulerConfigCloseClicked=index.createEvent(this,"schedulerConfigCloseClicked",7),this.handleSchedulerConfigCloseClicked=t=>{const n=this.schedulerConfigCloseClicked.emit(this.host);"schedulerConfigCloseClicked"in this.eventOverrides&&this.eventOverrides.schedulerConfigCloseClicked(n,this.nylasSchedulerConfigConnector),n.defaultPrevented||(localStorage.removeItem("grant"),localStorage.removeItem("user"),window.location.reload())},this.authenticationUrl=async t=>this.nylasApiRequest?await this.nylasApiRequest.authenticationUrl({provider:t})||"":(console.error("[nylas-scheduler-editor] Nylas API Request is not initialized."),""),this.configurationId=void 0,this.nylasApiRequest=void 0,this.nylasSessionsConfig=void 0,this.defaultAuthArgs=void 0,this.eventOverrides={},this.schedulerPreviewLink="",this.defaultSchedulerConfigState=void 0,this.mode="app",this.additionalParticipants=void 0,this.hideEditorTabs=[],this.conferenceProviders=void 0,this.requiresSlug=!1,this.automaticComponentRegistration=!0}connectedCallback(){index.debug("[nylas-scheduler-editor] connectedCallback")}async componentWillLoad(){var s,c,a,l,d,h,u,p;index.debug("[nylas-scheduler-editor] componentWillLoad");const r=(s=this.additionalParticipants)==null?void 0:s.filter(f=>{var g;const y=((g=f.calendars)==null?void 0:g.length)>0?f.calendars.filter(x=>x.id&&x.name):[];if(f.name&&f.email&&y.length>0)return{name:f.name,email:f.email,calendars:y}});if(this.stores={schedulerConfig:schedulerConfigStore2a3b403d.CreateNylasSchedulerConfigStore({...this.defaultSchedulerConfigState,additionalParticipants:r,conferenceProviders:this.conferenceProviders,hideEditorTabs:this.hideEditorTabs,requiresSlug:this.requiresSlug})},!this.nylasApiRequest&&this.nylasSessionsConfig){const f=new NylasSessions(this.nylasSessionsConfig);await f.isLoggedIn(),f.onLoginSuccess(async()=>{var g,x;const y=await((x=(g=this.nylasSchedulerConfigConnector)==null?void 0:g.schedulerConfig)==null?void 0:x.currentUser());if(y){const w=this.loggedIn.emit(this.host);"loggedIn"in this.eventOverrides&&await this.eventOverrides.loggedIn(w,this.nylasSchedulerConfigConnector),w.defaultPrevented||await this.loggedInHandler(y)}}),f.onLoginFail(async()=>{var g,x;(x=(g=this.stores)==null?void 0:g.schedulerConfig)==null||x.set("currentUser",null);const y=this.loggedOut.emit(this.host);"loggedOut"in this.eventOverrides&&(await this.eventOverrides.loggedOut(y,this.nylasSchedulerConfigConnector),y.defaultPrevented)}),this.nylasApiRequest=new index.NylasIdentityRequestWrapper(f)}this.nylasApiRequest&&this.defaultAuthArgs&&this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs),this.baseProvider=new index_esC9454237.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const t=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new NylasSchedulerConfigConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:t});const n=this.init.emit(this.host);if("init"in this.eventOverrides&&await this.eventOverrides.init(n,this.nylasSchedulerConfigConnector),!n.defaultPrevented){const f=await((a=(c=this.nylasSchedulerConfigConnector)==null?void 0:c.schedulerConfig)==null?void 0:a.currentUser());if(f){const y=this.loggedIn.emit(this.host);"loggedIn"in this.eventOverrides&&await this.eventOverrides.loggedIn(y,this.nylasSchedulerConfigConnector),y.defaultPrevented||await this.loggedInHandler(f)}else{(d=(l=this.stores)==null?void 0:l.schedulerConfig)==null||d.set("currentUser",null);const y=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides&&(await this.eventOverrides.loggedOut(y,this.nylasSchedulerConfigConnector),y.defaultPrevented))return}}(u=(h=this.stores)==null?void 0:h.schedulerConfig)==null||u.onChange("selectedConfiguration",async f=>{f&&f.id&&(this.configurationId=f.id)}),(p=this.baseProvider)==null||p.componentWillLoad(this.nylasSchedulerConfigConnector)}async componentDidLoad(){var r;index.debug("[nylas-scheduler-editor] componentDidLoad"),(r=this.baseProvider)==null||r.componentDidLoad()}componentDisconnected(){var r;(r=this.baseProvider)==null||r.componentDisconnected()}async configurationIdChanged(r){var t,n,s,c,a,l,d,h;r?(await((n=(t=this.nylasSchedulerConfigConnector)==null?void 0:t.schedulerConfig)==null?void 0:n.getConfigurationById(r)),(c=(s=this.stores)==null?void 0:s.schedulerConfig)==null||c.set("action","edit")):((l=(a=this.stores)==null?void 0:a.schedulerConfig)==null||l.set("selectedConfiguration",{}),(h=(d=this.stores)==null?void 0:d.schedulerConfig)==null||h.set("action",null))}async store(){var r;return(r=this.stores)==null?void 0:r.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(r){var t;(t=this.baseProvider)==null||t.registerComponent(r.detail)}async unregisterComponentHandler(r){var t;(t=this.baseProvider)==null||t.unregisterComponent(r.detail)}async loggedInHandler(r){var t,n,s,c,a,l,d;if((n=(t=this.stores)==null?void 0:t.schedulerConfig)==null||n.set("currentUser",r),!!this.nylasSchedulerConfigConnector&&(await((s=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:s.getCalendars()),this.configurationId)){const h=await((c=this.nylasSchedulerConfigConnector.schedulerConfig)==null?void 0:c.getConfigurationById(this.configurationId));h&&((a=h[0])!=null&&a.id)&&((d=(l=this.stores)==null?void 0:l.schedulerConfig)==null||d.set("action","edit"))}}render(){var r,t,n,s,c,a,l,d,h,u,p,f,y,g,x,w;return index.h(index.Host,{key:"cf37fcf4f16628b3bb60faf53b3ce40ac92abe50"},index.h("div",{key:"964e522aea50d644a1881699ba4ecd0bcc53d39e",class:"scheduler-editor-header",part:"nse__header"},index.h("h1",{key:"0ed5df6275a84f9867658ee595c30636c2be6548",class:"scheduler-editor-title",part:"nse__title"},index.h("calendar-icon",{key:"fa00ebc65af656b81d2e9100b5bed510c0f293c7",width:"18",height:"18"}),"Scheduler Editor"),index.h("button",{key:"c6178921ae812fa73ea16d63c4ad30c323b48e9c",class:"scheduler-editor-close",title:"logout",onClick:m=>this.handleSchedulerConfigCloseClicked(m),part:"nse__close-button"},index.h("close-icon",{key:"08393fce33207f1d468d3b15ddeb53051800a488",width:"18",height:"18"}))),index.h("div",{key:"fac27d5f8f0a46149bf80ebe80ec6c1344d77d23",class:"scheduler-editor-content",part:"nse__content"},((t=(r=this.stores)==null?void 0:r.schedulerConfig)==null?void 0:t.state.currentUser)&&this.stores.schedulerConfig.state.action===null&&index.h("div",{class:"list-configurations"},index.h("nylas-list-configurations",{exportparts:"nlc__create-new-cta"})),((s=(n=this.stores)==null?void 0:n.schedulerConfig)==null?void 0:s.state.currentUser)&&this.stores.schedulerConfig.state.action==="create"&&index.h("nylas-editor-tabs",{mode:"composable"},index.h(ExpressFlow,{currentUser:(a=(c=this.stores)==null?void 0:c.schedulerConfig)==null?void 0:a.state.currentUser,calendars:(h=(d=(l=this.stores)==null?void 0:l.schedulerConfig)==null?void 0:d.state)==null?void 0:h.calendars,selectedConfiguration:(f=(p=(u=this.stores)==null?void 0:u.schedulerConfig)==null?void 0:p.state)==null?void 0:f.selectedConfiguration})),((g=(y=this.stores)==null?void 0:y.schedulerConfig)==null?void 0:g.state.currentUser)&&this.stores.schedulerConfig.state.action==="edit"&&index.h("nylas-editor-tabs",{mode:this.mode},this.mode==="composable"&&index.h("slot",null)),!((w=(x=this.stores)==null?void 0:x.schedulerConfig)!=null&&w.state.currentUser)&&index.h("slot",{name:"login-required"},index.h(LoginRequired,{authenticationUrl:this.authenticationUrl}))))}get host(){return index.getElement(this)}static get watchers(){return{configurationId:["configurationIdChanged"]}}};NylasSchedulerEditor.style=NylasSchedulerEditorStyle0;exports.nylas_scheduler_editor=NylasSchedulerEditor;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-eb33703c.cjs"),I=require("./index.es-c9454237-b64161d1.cjs"),k=require("./scheduler-store-fe281404-c3e477f6.cjs"),w=require("./constants-50c3e067-9f2a6372.cjs");require("react");require("react-dom");class D{constructor({schedulerAPIURL:t,nylasSchedulerStore:i,sessionId:o,configId:s,slug:d,clientId:r}){if(!t)throw new Error("schedulerAPIURL is required");if(!i)throw new Error("nylasSchedulerStore is required");if(!o&&!s&&!(d||r))throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.");t==="/"&&(t=new URL(window.location.href).origin),this.configId=s,this.sessionId=o,this.schedulerAPIURL=t,this.nylasSchedulerStore=i,this.slug=d,this.clientId=r}init(){e.debug("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){return this._schedulerAPIConnector?this._schedulerAPIConnector:(this._schedulerAPIConnector=new k.NylaSchedulerAPIConnector({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId}),this._schedulerAPIConnector)}resetStores(){this.nylasSchedulerStore.reset()}}const v=(n,t)=>{const i=n.isLoading,o=n.showNotification,s=n.nylasBranding;return e.h(e.Fragment,null,o&&e.h("nylas-notification",null),i&&e.h("div",{class:"loading"},e.h("div",{class:"left"},e.h("div",{class:"skeleton"})),e.h("div",{class:"right"},e.h("div",{class:"skeleton"}),e.h("div",{class:"skeleton"}),e.h("div",{class:"skeleton"}),e.h("div",{class:"skeleton"}),e.h("div",{class:"skeleton"}))),!i&&t,e.h("div",{class:"footer"},s&&e.h(e.Fragment,null,"Powered by ",e.h("nylas-logo",null))))},C=(n,t)=>e.h("div",{class:"message-banner"},t),L=':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 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px 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:0}.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,.manual-confirmation-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,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{padding:0.5rem 4px 0;height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;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:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;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:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.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);min-height:24px}.footer svg{fill:var(--nylas-base-500)}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}',T=L,x={title:e.instance.t("genericErrorTitle"),type:I.nr.Error,category:k.ErrorCategory.Component},E=class{constructor(n){e.registerInstance(this,n),this.init=e.createEvent(this,"init",7),this.schedulerWillLoad=e.createEvent(this,"schedulerWillLoad",7),this.schedulerDidLoad=e.createEvent(this,"schedulerDidLoad",7),this.nylasSchedulerError=e.createEvent(this,"nylasSchedulerError",7),this.configSettingsLoaded=e.createEvent(this,"configSettingsLoaded",7),this.bookingRefExtracted=e.createEvent(this,"bookingRefExtracted",7),this.bookedEventInfo=e.createEvent(this,"bookedEventInfo",7),this.mode="app",this.defaultSchedulerState=void 0,this.sessionId=void 0,this.schedulerApiUrl="https://api.us.nylas.com",this.bookingInfo=void 0,this.rescheduleBookingRef=void 0,this.cancelBookingRef=void 0,this.organizerConfirmationBookingRef=void 0,this.configurationId=void 0,this.slug=void 0,this.clientId=void 0,this.nylasBranding=!0,this.eventOverrides={},this.isLoading=void 0,this.themeConfig=void 0,this.localization=void 0,this.showNotification=!0,this.automaticComponentRegistration=!0,this.selectedDateLabel=new Date().toLocaleDateString(void 0,{dateStyle:"full"})||`${e.instance.t("noDateSelected")}`,this.refConfigId=void 0,this.language=navigator.language}connectedCallback(){e.debug("[nylas-scheduler] connectedCallback")}async componentWillLoad(){var s,d;e.debug("[nylas-scheduler] Component will load");const n=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerWillLoad(n,this.nylasSchedulerConnector),n.defaultPrevented))return;this.stores={scheduler:k.CreateNylasSchedulerStore({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,...this.defaultSchedulerState})},this.baseProvider=new I.NylasBaseProvider(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides),this.refConfigId=this.configurationId;let t;if(this.rescheduleBookingRef){const[r,a,l]=e.compactStringToUUIDs(this.rescheduleBookingRef);this.refConfigId=r,this.stores.scheduler.set("rescheduleBookingId",a),t=this.bookingRefExtracted.emit({configurationId:r,bookingId:a})}else if(this.cancelBookingRef){const[r,a,l]=e.compactStringToUUIDs(this.cancelBookingRef);this.refConfigId=r,this.stores.scheduler.set("cancelBookingId",a),t=this.bookingRefExtracted.emit({configurationId:r,bookingId:a})}else if(this.organizerConfirmationBookingRef){const[r,a,l]=e.compactStringToUUIDs(this.organizerConfirmationBookingRef);this.refConfigId=r,this.stores.scheduler.set("organizerConfirmationBookingId",a),this.stores.scheduler.set("organizerConfirmationSalt",l),t=this.bookingRefExtracted.emit({configurationId:r,bookingId:a,salt:l})}if("bookingRefExtracted"in this.eventOverrides&&(await this.eventOverrides.bookingRefExtracted(t,this.nylasSchedulerConnector),t.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;const i=(s=this.baseProvider)==null?void 0:s.getStore("scheduler");this.nylasSchedulerConnector=new D({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:i});const o=this.init.emit(this.host);"init"in this.eventOverrides&&(await this.eventOverrides.init(o,this.nylasSchedulerConnector),o.defaultPrevented)||((d=this.baseProvider)==null||d.componentWillLoad(this.nylasSchedulerConnector),this.applyThemeConfig(this.themeConfig))}async componentDidLoad(){var l,c,u,h,m,f,p,y;(l=this.baseProvider)==null||l.componentDidLoad();const n=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides&&(await this.eventOverrides.schedulerDidLoad(n,this.nylasSchedulerConnector),n.defaultPrevented)||!this.checkIfSessionIdOrConfigIdExists())return;this.localizationChanged(this.localization);const t=await((c=this.nylasSchedulerConnector)==null?void 0:c.scheduler.getUISettings());if(!t||"error"in t)this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t==null?void 0:t.error)},host:this.host});else{"data"in t&&((u=t.data)!=null&&u.appearance)&&console.info("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.");const g=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides&&(await this.eventOverrides.configSettingsLoaded(g,this.nylasSchedulerConnector),g.defaultPrevented))return}const i=(h=this.baseProvider)==null?void 0:h.getStore("scheduler"),o=(f=(m=i==null?void 0:i.get("configSettings"))==null?void 0:m.scheduler)==null?void 0:f.available_days_in_future,s=i==null?void 0:i.get("selectedTimeslot");if(s&&(s!=null&&s.start_time)){if(!this.isTimeslotValid(s))return;if(i!=null&&i.get("showBookingForm")){i==null||i.set("selectedDate",s.start_time);return}}const d=i==null?void 0:i.get("selectedDate"),r=i==null?void 0:i.get("availability");let a;if(!(r&&r.length>0)){if(d){const{startTime:g,endTime:b,endTimeForAvailableDaysInFuture:_}=this.validateAvailableDaysInFuture(d,o||30);d.getTime()<_*1e3&&(a=await((y=this.nylasSchedulerConnector)==null?void 0:y.scheduler.getAvailability(g,b)))}else{const g=new Date,{startTime:b,endTime:_,endTimeForAvailableDaysInFuture:B}=this.validateAvailableDaysInFuture(g,o||30);g.getTime()<B*1e3&&(a=await((p=this.nylasSchedulerConnector)==null?void 0:p.scheduler.getAvailability(b,_)))}if((!a||"error"in a)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(a==null?void 0:a.error)},host:this.host}),!d){let g=new Date;const b=i==null?void 0:i.get("availability").find(_=>new Date(_.start_time)>new Date);b&&(g=b.start_time),i==null||i.set("selectedDate",g)}}}componentDisconnected(){var n;(n=this.baseProvider)==null||n.componentDisconnected()}bookingInfoChanged(n){var t;(t=this.stores)==null||t.scheduler.set("bookingInfo",n)}rescheduleBookingRefChanged(n){var t,i;if(n){const[o,s]=e.compactStringToUUIDs(n);(t=this.stores)==null||t.scheduler.set("rescheduleBookingId",s),this.refConfigId=o,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(o)}}cancelBookingRefChanged(n){var t,i;if(n){const[o,s]=e.compactStringToUUIDs(n);(t=this.stores)==null||t.scheduler.set("cancelBookingId",s),this.refConfigId=o,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(o)}}organizerConfirmationBookingRefChanged(n){var t,i;if(n){const[o,s]=e.compactStringToUUIDs(n);(t=this.stores)==null||t.scheduler.set("organizerConfirmationBookingId",s),this.refConfigId=o,(i=this.nylasSchedulerConnector)==null||i.scheduler.setConfigId(o)}}localizationChanged(n){n&&Object.keys(n).forEach(t=>{t in w.LANGUAGE_CODE&&(e.instance.addResourceBundle(t,"translation",n[t],!1,!0),this.language=this.language)})}themeConfigChanged(n){this.applyThemeConfig(n)}languageChanged(n){const t=n.detail;this.language=t,e.instance.changeLanguage(t)}async registerComponentHandler(n){var t;(t=this.baseProvider)==null||t.registerComponent(n.detail)}async unregisterComponentHandler(n){var t;(t=this.baseProvider)==null||t.unregisterComponent(n.detail)}async monthChangedHandler(n){var r,a,l,c,u,h,m;const t=n.detail,i=(c=(l=(a=(r=this.nylasSchedulerConnector)==null?void 0:r.schedulerStore)==null?void 0:a.get("configSettings"))==null?void 0:l.scheduler)==null?void 0:c.available_days_in_future,{startTime:o,endTime:s,endTimeForAvailableDaysInFuture:d}=this.validateAvailableDaysInFuture(t,i||30);if(o<d&&t.getTime()<d*1e3){const f=await((u=this.nylasSchedulerConnector)==null?void 0:u.scheduler.getAvailability(o,s));(!f||"error"in f)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(f==null?void 0:f.error)},host:this.host});const p=(h=this.stores)==null?void 0:h.scheduler.get("selectableDates");p&&p.length>0&&((m=this.stores)==null||m.scheduler.set("selectedDate",p[0]))}}async bookButtonClickedHandler(n){var d,r,a,l;const i=(r=(d=this.nylasSchedulerConnector)==null?void 0:d.schedulerStore)==null?void 0:r.get("rescheduleBookingId");if(i){const c=await((a=this.nylasSchedulerConnector)==null?void 0:a.scheduler.rescheduleBooking(i,n.detail));(!c||"error"in c)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(c==null?void 0:c.error)},host:this.host});const u=this.bookedEventInfo.emit({...c});"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(u,this.nylasSchedulerConnector);return}const o=await((l=this.nylasSchedulerConnector)==null?void 0:l.scheduler.bookTimeslot(n.detail));(!o||"error"in o)&&this.nylasSchedulerError.emit({notification:{...this.getErrorObject(o==null?void 0:o.error)},host:this.host});const s=this.bookedEventInfo.emit({...o});"bookedEventInfo"in this.eventOverrides&&await this.eventOverrides.bookedEventInfo(s,this.nylasSchedulerConnector)}dateSelectedHandler(n){const t=n.detail;this.selectedDateLabel=t?t.toLocaleDateString(void 0,{dateStyle:"full"}):`${e.instance.t("noDateSelected")}`}cancelBookedEventErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}confirmBookingErrorHandler(n){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(n.detail.error)},host:this.host})}async getNylasSchedulerStore(){var n;return(n=this.baseProvider)==null?void 0:n.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(n){return{title:(n==null?void 0:n.title)||x.title,category:(n==null?void 0:n.category)||x.category,type:I.nr.Error,description:(n==null?void 0:n.message)||"",id:new Date().getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let n="";return this.sessionId||(n+=e.instance.t("sessionIdRequiredErrorMessage")),!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)&&(n=e.instance.t("sessionIdRequiredErrorMessage")+" "+e.instance.t("publicConfigErrorMessage")),this.nylasSchedulerError.emit({notification:{title:e.instance.t("schedulingComponentErrorTitle"),category:k.ErrorCategory.Component,type:I.nr.Error,description:n,id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1}return!0}isTimeslotValid(n){return new Date(n.start_time)<new Date?(this.nylasSchedulerError.emit({notification:{title:e.instance.t("invalidTimeslotErrorTitle"),category:k.ErrorCategory.Component,type:I.nr.Error,description:e.instance.t("invalidTimeslotErrorMessage"),id:new Date().getTime().toString(),ttl:"none"},host:this.host}),!1):!0}validateAvailableDaysInFuture(n,t){const i=new Date,o=new Date(n.getFullYear(),n.getMonth(),1).getTime()/1e3,s=new Date(n.getFullYear(),n.getMonth()+1,1).getTime()/1e3,d=Math.floor(e.addDaysToCurrentDate(i,t).getTime()/1e3),r=Math.min(d,s);return{startTime:o<i.getTime()/1e3?Math.floor(i.getTime()/1e3):o,endTime:r,endTimeForAvailableDaysInFuture:d}}applyThemeConfig(n){if(n)for(const[t,i]of Object.entries(n))this.host.style.setProperty(`${t}`,i)}render(){var p,y,g;const n=this.mode==="app",t=(p=this.baseProvider)==null?void 0:p.getStore("scheduler"),i=t==null?void 0:t.get("eventInfo"),o=t==null?void 0:t.get("showBookingForm"),s=t==null?void 0:t.get("cancelledEventInfo"),d=t==null?void 0:t.get("cancelBookingId"),r=t==null?void 0:t.get("selectedTimeslot"),a=t==null?void 0:t.get("rescheduleBookingId"),l=t==null?void 0:t.get("organizerConfirmationBookingId"),c=t==null?void 0:t.get("rejectBookingId"),u=t==null?void 0:t.get("confirmedEventInfo"),h=(t==null?void 0:t.get("nylasBranding"))||this.nylasBranding,m=t==null?void 0:t.get("selectedDate"),f=(g=(y=t==null?void 0:t.get("configSettings"))==null?void 0:y.scheduler)==null?void 0:g.confirmation_redirect_url;if(this.selectedDateLabel=m&&this.language?e.capitalizeFirstLetter(m.toLocaleDateString(w.LANGUAGE_CODE_MAP[this.language],{dateStyle:"full"})):`${e.instance.t("noDateSelected")}`,n&&(d||c)&&!s)return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},e.h("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e.h("nylas-cancel-booking-form",{selectedTimeslot:r,cancelBookingId:d,rejectBookingId:c,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))));if(n&&l)return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},e.h("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e.h("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:l,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))));if(n&&s)return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},e.h("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e.h("nylas-cancelled-event-card",{cancelledEventInfo:s,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(n&&u)return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},e.h("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e.h("nylas-confirmed-event-card",{confirmedEventInfo:u,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))));if(n&&i&&f){window.location.assign(f);return}if(n&&i)return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},e.h("div",{class:"booked-event-page",part:"booked-event-page"},e.h("nylas-booked-event-card",{selectedTimeslot:r,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))));if(n&&(!i||a)&&!o){const b=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},a&&e.h(C,null,`${e.instance.t("rescheduleTitle")}`),e.h("div",{class:"select-date-page",part:"select-date-page"},e.h("div",{class:"left-panel"},e.h("nylas-date-picker",{exportparts:"ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month"}),e.h("nylas-locale-switch",{exportparts:"nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label"})),e.h("div",{class:`right-panel ${a?"reschedule":""}`},e.h("h2",null,e.h("calendar-icon",null),e.h("span",{id:"selectedDate"},this.selectedDateLabel)),e.h("nylas-timeslot-picker",{exportparts:"ntp, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},b&&e.h("span",{slot:"timeslot-picker-cta-label"},e.h("slot",{name:"timeslot-picker-cta-label"})))))))}return n&&!i&&o?e.h(e.Host,null,e.h(v,{nylasBranding:h,isLoading:this.isLoading,showNotification:this.showNotification},a&&e.h(C,null,`${e.instance.t("rescheduleTitle")}`),e.h("div",{class:"additional-data-page",part:"additional-data-page"},e.h("div",{class:"left-panel"},e.h("div",{class:"wrapper"},e.h("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e.h("div",{class:`right-panel ${a?"reschedule":""}`},e.h("nylas-booking-form",{exportparts:"nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content"}))))):e.h(e.Host,null,e.h("slot",null))}get host(){return e.getElement(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};E.style=T;exports.nylas_scheduling=E;
@@ -0,0 +1,345 @@
1
+ import { k as h, r as z, c as _, d as E, l as I, m as O, n as N, h as n, H as y, g as A, F as D } from "./index-5ccfd9df.js";
2
+ import { n as x, N as P } from "./index.es-c9454237-00ccd1e6.js";
3
+ import { E as B, C as F, N as S } from "./scheduler-store-fe281404-bddb1b6a.js";
4
+ import { L as j, a as M } from "./constants-50c3e067-8a40a5fe.js";
5
+ import "react";
6
+ import "react-dom";
7
+ class H {
8
+ constructor({ schedulerAPIURL: e, nylasSchedulerStore: i, sessionId: o, configId: s, slug: d, clientId: r }) {
9
+ if (!e)
10
+ throw new Error("schedulerAPIURL is required");
11
+ if (!i)
12
+ throw new Error("nylasSchedulerStore is required");
13
+ if (!o && !s && !(d || r))
14
+ throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.");
15
+ e === "/" && (e = new URL(window.location.href).origin), this.configId = s, this.sessionId = o, this.schedulerAPIURL = e, this.nylasSchedulerStore = i, this.slug = d, this.clientId = r;
16
+ }
17
+ init() {
18
+ E("NylasConnector init");
19
+ }
20
+ get schedulerStore() {
21
+ return this.nylasSchedulerStore;
22
+ }
23
+ get scheduler() {
24
+ return this._schedulerAPIConnector ? this._schedulerAPIConnector : (this._schedulerAPIConnector = new S({
25
+ schedulerAPIURL: this.schedulerAPIURL,
26
+ schedulerStore: this.schedulerStore,
27
+ sessionId: this.sessionId,
28
+ configId: this.configId,
29
+ slug: this.slug,
30
+ clientId: this.clientId
31
+ }), this._schedulerAPIConnector);
32
+ }
33
+ resetStores() {
34
+ this.nylasSchedulerStore.reset();
35
+ }
36
+ }
37
+ const k = (t, e) => {
38
+ const i = t.isLoading, o = t.showNotification, s = t.nylasBranding;
39
+ return n(
40
+ D,
41
+ null,
42
+ o && n("nylas-notification", null),
43
+ i && n(
44
+ "div",
45
+ { class: "loading" },
46
+ n(
47
+ "div",
48
+ { class: "left" },
49
+ n("div", { class: "skeleton" })
50
+ ),
51
+ n(
52
+ "div",
53
+ { class: "right" },
54
+ n("div", { class: "skeleton" }),
55
+ n("div", { class: "skeleton" }),
56
+ n("div", { class: "skeleton" }),
57
+ n("div", { class: "skeleton" }),
58
+ n("div", { class: "skeleton" })
59
+ )
60
+ ),
61
+ !i && e,
62
+ n("div", { class: "footer" }, s && n(
63
+ D,
64
+ null,
65
+ "Powered by ",
66
+ n("nylas-logo", null)
67
+ ))
68
+ );
69
+ }, L = (t, e) => n("div", { class: "message-banner" }, e), U = ':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 8px 2px rgba(0, 0, 0, 0.05), 0px 8px 16px -2px 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:0}.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,.manual-confirmation-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,.manual-confirmation-page{background-color:var(--nylas-base-50)}.cancelled-event-page,.manual-confirmation-page,.cancel-flow-page{padding:1rem;height:496px;display:flex;justify-content:center;align-items:center}.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:784px;background:var(--nylas-base-50)}@media screen and (max-width: 768px){.booked-event-page,.manual-confirmation-page,.cancelled-event-page,.cancel-flow-page{min-width:90%}}.left-panel{display:flex;flex-direction:column;min-width:424px;border-top-left-radius:inherit;background:var(--nylas-base-0);position:relative;padding:1rem 0 0 0;height:624px}@media screen and (max-width: 768px){.left-panel{border-top-right-radius:inherit;min-width:unset;height:auto}}@media screen and (max-width: 768px){.select-date-page .left-panel{padding:0.5rem 4px 0;height:624px}}.border{margin-left:-20px;margin-right:-20px;border-top-width:1px;height:0.5px;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:624px;padding-top:16px;border-left:1px solid var(--nylas-base-200);border-top-right-radius:inherit}.right-panel.reschedule{border-top-right-radius:0px}@media screen and (max-width: 768px){.right-panel{border-top-right-radius:0px;width:inherit;min-width:unset;height:auto}}.right-panel h2{display:flex;margin:0;height:48px;gap:0.5rem;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:604px;padding:0 1rem}@media screen and (max-width: 768px){nylas-selected-event-card{height:250px}}.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);min-height:24px}.footer svg{fill:var(--nylas-base-500)}.footer svg{margin-top:1px}nylas-selected-event-card::part(nsec__timezone){position:absolute;bottom:0}nylas-notification{margin:1.5rem;width:-webkit-fill-available;width:-moz-available;position:absolute}nylas-locale-switch{position:absolute;padding:18px 20px;bottom:0;width:-webkit-fill-available;width:-moz-available;border-top:1px solid var(--nylas-base-200)}@media screen and (max-width: 768px){nylas-locale-switch{height:auto}}nylas-date-picker{padding:0 20px}', W = U, T = { title: h.t("genericErrorTitle"), type: x.Error, category: B.Component }, $ = class {
70
+ constructor(t) {
71
+ z(this, t), this.init = _(this, "init", 7), this.schedulerWillLoad = _(this, "schedulerWillLoad", 7), this.schedulerDidLoad = _(this, "schedulerDidLoad", 7), this.nylasSchedulerError = _(this, "nylasSchedulerError", 7), this.configSettingsLoaded = _(this, "configSettingsLoaded", 7), this.bookingRefExtracted = _(this, "bookingRefExtracted", 7), this.bookedEventInfo = _(this, "bookedEventInfo", 7), this.mode = "app", this.defaultSchedulerState = void 0, this.sessionId = void 0, this.schedulerApiUrl = "https://api.us.nylas.com", this.bookingInfo = void 0, this.rescheduleBookingRef = void 0, this.cancelBookingRef = void 0, this.organizerConfirmationBookingRef = void 0, this.configurationId = void 0, this.slug = void 0, this.clientId = void 0, this.nylasBranding = !0, this.eventOverrides = {}, this.isLoading = void 0, this.themeConfig = void 0, this.localization = void 0, this.showNotification = !0, this.automaticComponentRegistration = !0, this.selectedDateLabel = (/* @__PURE__ */ new Date()).toLocaleDateString(void 0, { dateStyle: "full" }) || `${h.t("noDateSelected")}`, this.refConfigId = void 0, this.language = navigator.language;
72
+ }
73
+ connectedCallback() {
74
+ E("[nylas-scheduler] connectedCallback");
75
+ }
76
+ async componentWillLoad() {
77
+ var s, d;
78
+ E("[nylas-scheduler] Component will load");
79
+ const t = this.schedulerWillLoad.emit(this.host);
80
+ if ("schedulerWillLoad" in this.eventOverrides && (await this.eventOverrides.schedulerWillLoad(t, this.nylasSchedulerConnector), t.defaultPrevented))
81
+ return;
82
+ this.stores = {
83
+ scheduler: F({
84
+ bookingInfo: this.bookingInfo,
85
+ nylasBranding: this.nylasBranding,
86
+ ...this.defaultSchedulerState
87
+ })
88
+ }, this.baseProvider = new P(this.host, this.stores, this.automaticComponentRegistration, this.eventOverrides), this.refConfigId = this.configurationId;
89
+ let e;
90
+ if (this.rescheduleBookingRef) {
91
+ const [r, a, l] = I(this.rescheduleBookingRef);
92
+ this.refConfigId = r, this.stores.scheduler.set("rescheduleBookingId", a), e = this.bookingRefExtracted.emit({ configurationId: r, bookingId: a });
93
+ } else if (this.cancelBookingRef) {
94
+ const [r, a, l] = I(this.cancelBookingRef);
95
+ this.refConfigId = r, this.stores.scheduler.set("cancelBookingId", a), e = this.bookingRefExtracted.emit({ configurationId: r, bookingId: a });
96
+ } else if (this.organizerConfirmationBookingRef) {
97
+ const [r, a, l] = I(this.organizerConfirmationBookingRef);
98
+ this.refConfigId = r, this.stores.scheduler.set("organizerConfirmationBookingId", a), this.stores.scheduler.set("organizerConfirmationSalt", l), e = this.bookingRefExtracted.emit({ configurationId: r, bookingId: a, salt: l });
99
+ }
100
+ if ("bookingRefExtracted" in this.eventOverrides && (await this.eventOverrides.bookingRefExtracted(e, this.nylasSchedulerConnector), e.defaultPrevented) || !this.checkIfSessionIdOrConfigIdExists())
101
+ return;
102
+ const i = (s = this.baseProvider) == null ? void 0 : s.getStore("scheduler");
103
+ this.nylasSchedulerConnector = new H({
104
+ schedulerAPIURL: this.schedulerApiUrl,
105
+ sessionId: this.sessionId,
106
+ configId: this.refConfigId,
107
+ slug: this.slug,
108
+ clientId: this.clientId,
109
+ nylasSchedulerStore: i
110
+ });
111
+ const o = this.init.emit(this.host);
112
+ "init" in this.eventOverrides && (await this.eventOverrides.init(o, this.nylasSchedulerConnector), o.defaultPrevented) || ((d = this.baseProvider) == null || d.componentWillLoad(this.nylasSchedulerConnector), this.applyThemeConfig(this.themeConfig));
113
+ }
114
+ async componentDidLoad() {
115
+ var l, c, p, g, b, u, m, w;
116
+ (l = this.baseProvider) == null || l.componentDidLoad();
117
+ const t = this.schedulerDidLoad.emit(this.host);
118
+ if ("schedulerDidLoad" in this.eventOverrides && (await this.eventOverrides.schedulerDidLoad(t, this.nylasSchedulerConnector), t.defaultPrevented) || !this.checkIfSessionIdOrConfigIdExists())
119
+ return;
120
+ this.localizationChanged(this.localization);
121
+ const e = await ((c = this.nylasSchedulerConnector) == null ? void 0 : c.scheduler.getUISettings());
122
+ if (!e || "error" in e)
123
+ this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(e == null ? void 0 : e.error) }, host: this.host });
124
+ else {
125
+ "data" in e && ((p = e.data) != null && p.appearance) && console.info("Appearance settings have been returned from the configuration used byt his scheduling page; please remember to grab them from the configSettingsLoaded event and apply them as desired.");
126
+ const f = this.configSettingsLoaded.emit({ settings: e });
127
+ if ("configSettingsLoaded" in this.eventOverrides && (await this.eventOverrides.configSettingsLoaded(f, this.nylasSchedulerConnector), f.defaultPrevented))
128
+ return;
129
+ }
130
+ const i = (g = this.baseProvider) == null ? void 0 : g.getStore("scheduler"), o = (u = (b = i == null ? void 0 : i.get("configSettings")) == null ? void 0 : b.scheduler) == null ? void 0 : u.available_days_in_future, s = i == null ? void 0 : i.get("selectedTimeslot");
131
+ if (s && (s != null && s.start_time)) {
132
+ if (!this.isTimeslotValid(s))
133
+ return;
134
+ if (i != null && i.get("showBookingForm")) {
135
+ i == null || i.set("selectedDate", s.start_time);
136
+ return;
137
+ }
138
+ }
139
+ const d = i == null ? void 0 : i.get("selectedDate"), r = i == null ? void 0 : i.get("availability");
140
+ let a;
141
+ if (!(r && r.length > 0)) {
142
+ if (d) {
143
+ const { startTime: f, endTime: v, endTimeForAvailableDaysInFuture: C } = this.validateAvailableDaysInFuture(d, o || 30);
144
+ d.getTime() < C * 1e3 && (a = await ((w = this.nylasSchedulerConnector) == null ? void 0 : w.scheduler.getAvailability(f, v)));
145
+ } else {
146
+ const f = /* @__PURE__ */ new Date(), { startTime: v, endTime: C, endTimeForAvailableDaysInFuture: R } = this.validateAvailableDaysInFuture(f, o || 30);
147
+ f.getTime() < R * 1e3 && (a = await ((m = this.nylasSchedulerConnector) == null ? void 0 : m.scheduler.getAvailability(v, C)));
148
+ }
149
+ if ((!a || "error" in a) && this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(a == null ? void 0 : a.error) }, host: this.host }), !d) {
150
+ let f = /* @__PURE__ */ new Date();
151
+ const v = i == null ? void 0 : i.get("availability").find((C) => new Date(C.start_time) > /* @__PURE__ */ new Date());
152
+ v && (f = v.start_time), i == null || i.set("selectedDate", f);
153
+ }
154
+ }
155
+ }
156
+ componentDisconnected() {
157
+ var t;
158
+ (t = this.baseProvider) == null || t.componentDisconnected();
159
+ }
160
+ bookingInfoChanged(t) {
161
+ var e;
162
+ (e = this.stores) == null || e.scheduler.set("bookingInfo", t);
163
+ }
164
+ rescheduleBookingRefChanged(t) {
165
+ var e, i;
166
+ if (t) {
167
+ const [o, s] = I(t);
168
+ (e = this.stores) == null || e.scheduler.set("rescheduleBookingId", s), this.refConfigId = o, (i = this.nylasSchedulerConnector) == null || i.scheduler.setConfigId(o);
169
+ }
170
+ }
171
+ cancelBookingRefChanged(t) {
172
+ var e, i;
173
+ if (t) {
174
+ const [o, s] = I(t);
175
+ (e = this.stores) == null || e.scheduler.set("cancelBookingId", s), this.refConfigId = o, (i = this.nylasSchedulerConnector) == null || i.scheduler.setConfigId(o);
176
+ }
177
+ }
178
+ organizerConfirmationBookingRefChanged(t) {
179
+ var e, i;
180
+ if (t) {
181
+ const [o, s] = I(t);
182
+ (e = this.stores) == null || e.scheduler.set("organizerConfirmationBookingId", s), this.refConfigId = o, (i = this.nylasSchedulerConnector) == null || i.scheduler.setConfigId(o);
183
+ }
184
+ }
185
+ localizationChanged(t) {
186
+ t && Object.keys(t).forEach((e) => {
187
+ e in j && (h.addResourceBundle(e, "translation", t[e], !1, !0), this.language = this.language);
188
+ });
189
+ }
190
+ themeConfigChanged(t) {
191
+ this.applyThemeConfig(t);
192
+ }
193
+ languageChanged(t) {
194
+ const e = t.detail;
195
+ this.language = e, h.changeLanguage(e);
196
+ }
197
+ async registerComponentHandler(t) {
198
+ var e;
199
+ (e = this.baseProvider) == null || e.registerComponent(t.detail);
200
+ }
201
+ async unregisterComponentHandler(t) {
202
+ var e;
203
+ (e = this.baseProvider) == null || e.unregisterComponent(t.detail);
204
+ }
205
+ async monthChangedHandler(t) {
206
+ var r, a, l, c, p, g, b;
207
+ const e = t.detail, i = (c = (l = (a = (r = this.nylasSchedulerConnector) == null ? void 0 : r.schedulerStore) == null ? void 0 : a.get("configSettings")) == null ? void 0 : l.scheduler) == null ? void 0 : c.available_days_in_future, { startTime: o, endTime: s, endTimeForAvailableDaysInFuture: d } = this.validateAvailableDaysInFuture(e, i || 30);
208
+ if (o < d && e.getTime() < d * 1e3) {
209
+ const u = await ((p = this.nylasSchedulerConnector) == null ? void 0 : p.scheduler.getAvailability(o, s));
210
+ (!u || "error" in u) && this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(u == null ? void 0 : u.error) }, host: this.host });
211
+ const m = (g = this.stores) == null ? void 0 : g.scheduler.get("selectableDates");
212
+ m && m.length > 0 && ((b = this.stores) == null || b.scheduler.set("selectedDate", m[0]));
213
+ }
214
+ }
215
+ async bookButtonClickedHandler(t) {
216
+ var d, r, a, l;
217
+ const i = (r = (d = this.nylasSchedulerConnector) == null ? void 0 : d.schedulerStore) == null ? void 0 : r.get("rescheduleBookingId");
218
+ if (i) {
219
+ const c = await ((a = this.nylasSchedulerConnector) == null ? void 0 : a.scheduler.rescheduleBooking(i, t.detail));
220
+ (!c || "error" in c) && this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(c == null ? void 0 : c.error) }, host: this.host });
221
+ const p = this.bookedEventInfo.emit({ ...c });
222
+ "bookedEventInfo" in this.eventOverrides && await this.eventOverrides.bookedEventInfo(p, this.nylasSchedulerConnector);
223
+ return;
224
+ }
225
+ const o = await ((l = this.nylasSchedulerConnector) == null ? void 0 : l.scheduler.bookTimeslot(t.detail));
226
+ (!o || "error" in o) && this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(o == null ? void 0 : o.error) }, host: this.host });
227
+ const s = this.bookedEventInfo.emit({ ...o });
228
+ "bookedEventInfo" in this.eventOverrides && await this.eventOverrides.bookedEventInfo(s, this.nylasSchedulerConnector);
229
+ }
230
+ dateSelectedHandler(t) {
231
+ const e = t.detail;
232
+ this.selectedDateLabel = e ? e.toLocaleDateString(void 0, { dateStyle: "full" }) : `${h.t("noDateSelected")}`;
233
+ }
234
+ cancelBookedEventErrorHandler(t) {
235
+ this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(t.detail.error) }, host: this.host });
236
+ }
237
+ cancelBookedEventValidationErrorHandler(t) {
238
+ this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(t.detail.error) }, host: this.host });
239
+ }
240
+ rescheduleBookedEventErrorHandler(t) {
241
+ this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(t.detail.error) }, host: this.host });
242
+ }
243
+ confirmBookingErrorHandler(t) {
244
+ this.nylasSchedulerError.emit({ notification: { ...this.getErrorObject(t.detail.error) }, host: this.host });
245
+ }
246
+ async getNylasSchedulerStore() {
247
+ var t;
248
+ return (t = this.baseProvider) == null ? void 0 : t.getStore("scheduler");
249
+ }
250
+ async getNylasSchedulerConnector() {
251
+ return this.nylasSchedulerConnector;
252
+ }
253
+ async getRef() {
254
+ return this.host;
255
+ }
256
+ getErrorObject(t) {
257
+ return {
258
+ title: (t == null ? void 0 : t.title) || T.title,
259
+ category: (t == null ? void 0 : t.category) || T.category,
260
+ type: x.Error,
261
+ description: (t == null ? void 0 : t.message) || "",
262
+ id: (/* @__PURE__ */ new Date()).getTime().toString(),
263
+ ttl: "none"
264
+ };
265
+ }
266
+ checkIfSessionIdOrConfigIdExists() {
267
+ if (!this.sessionId && !this.refConfigId && !(this.slug && this.clientId)) {
268
+ let t = "";
269
+ return this.sessionId || (t += h.t("sessionIdRequiredErrorMessage")), !this.sessionId && !this.refConfigId && !(this.slug && this.clientId) && (t = h.t("sessionIdRequiredErrorMessage") + " " + h.t("publicConfigErrorMessage")), this.nylasSchedulerError.emit({
270
+ notification: {
271
+ title: h.t("schedulingComponentErrorTitle"),
272
+ category: B.Component,
273
+ type: x.Error,
274
+ description: t,
275
+ id: (/* @__PURE__ */ new Date()).getTime().toString(),
276
+ ttl: "none"
277
+ },
278
+ host: this.host
279
+ }), !1;
280
+ }
281
+ return !0;
282
+ }
283
+ isTimeslotValid(t) {
284
+ return new Date(t.start_time) < /* @__PURE__ */ new Date() ? (this.nylasSchedulerError.emit({
285
+ notification: {
286
+ title: h.t("invalidTimeslotErrorTitle"),
287
+ category: B.Component,
288
+ type: x.Error,
289
+ description: h.t("invalidTimeslotErrorMessage"),
290
+ id: (/* @__PURE__ */ new Date()).getTime().toString(),
291
+ ttl: "none"
292
+ },
293
+ host: this.host
294
+ }), !1) : !0;
295
+ }
296
+ validateAvailableDaysInFuture(t, e) {
297
+ const i = /* @__PURE__ */ new Date(), o = new Date(t.getFullYear(), t.getMonth(), 1).getTime() / 1e3, s = new Date(t.getFullYear(), t.getMonth() + 1, 1).getTime() / 1e3, d = Math.floor(O(i, e).getTime() / 1e3), r = Math.min(d, s);
298
+ return { startTime: o < i.getTime() / 1e3 ? Math.floor(i.getTime() / 1e3) : o, endTime: r, endTimeForAvailableDaysInFuture: d };
299
+ }
300
+ applyThemeConfig(t) {
301
+ if (t)
302
+ for (const [e, i] of Object.entries(t))
303
+ this.host.style.setProperty(`${e}`, i);
304
+ }
305
+ render() {
306
+ var m, w, f;
307
+ const t = this.mode === "app", e = (m = this.baseProvider) == null ? void 0 : m.getStore("scheduler"), i = e == null ? void 0 : e.get("eventInfo"), o = e == null ? void 0 : e.get("showBookingForm"), s = e == null ? void 0 : e.get("cancelledEventInfo"), d = e == null ? void 0 : e.get("cancelBookingId"), r = e == null ? void 0 : e.get("selectedTimeslot"), a = e == null ? void 0 : e.get("rescheduleBookingId"), l = e == null ? void 0 : e.get("organizerConfirmationBookingId"), c = e == null ? void 0 : e.get("rejectBookingId"), p = e == null ? void 0 : e.get("confirmedEventInfo"), g = (e == null ? void 0 : e.get("nylasBranding")) || this.nylasBranding, b = e == null ? void 0 : e.get("selectedDate"), u = (f = (w = e == null ? void 0 : e.get("configSettings")) == null ? void 0 : w.scheduler) == null ? void 0 : f.confirmation_redirect_url;
308
+ if (this.selectedDateLabel = b && this.language ? N(b.toLocaleDateString(M[this.language], { dateStyle: "full" })) : `${h.t("noDateSelected")}`, t && (d || c) && !s)
309
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, n("div", { class: "cancel-flow-page", part: "cancel-flow-page" }, n("nylas-cancel-booking-form", { selectedTimeslot: r, cancelBookingId: d, rejectBookingId: c, exportparts: "ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card" }))));
310
+ if (t && l)
311
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, n("div", { class: "manual-confirmation-page", part: "manual-confirmation-page" }, n("nylas-organizer-confirmation-card", { organizerConfirmationBookingId: l, exportparts: "nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline" }))));
312
+ if (t && s)
313
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, n("div", { class: "cancelled-event-page", part: "cancelled-event-page" }, n("nylas-cancelled-event-card", { cancelledEventInfo: s, exportparts: "ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card" }))));
314
+ if (t && p)
315
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, n("div", { class: "cancelled-event-page", part: "confirmed-event-page" }, n("nylas-confirmed-event-card", { confirmedEventInfo: p, exportparts: "ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card" }))));
316
+ if (t && i && u) {
317
+ window.location.assign(u);
318
+ return;
319
+ }
320
+ if (t && i)
321
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, n("div", { class: "booked-event-page", part: "booked-event-page" }, n("nylas-booked-event-card", { selectedTimeslot: r, eventInfo: i, exportparts: "nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta" }))));
322
+ if (t && (!i || a) && !o) {
323
+ const v = this.host.querySelector('[slot="timeslot-picker-cta-label"]');
324
+ return n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, a && n(L, null, `${h.t("rescheduleTitle")}`), n("div", { class: "select-date-page", part: "select-date-page" }, n("div", { class: "left-panel" }, n("nylas-date-picker", { exportparts: "ndp, ndp__title, ndp__month-header, ndp__month-button, ndp__day, ndp__date, ndp__date--disabled, ndp__date--selected, ndp__date--current-day, ndp__date--current-month" }), n("nylas-locale-switch", { exportparts: "nls, nls__timezone, nls__timezone-dropdown, nls__timezone-drop-button, nls__timezone-drop-button-selected-label, nls__timezone-drop-content, nls__timezone-drop-label, nls__language, nls__language-dropdown, nls__language-drop-button, nls__language-drop-content, nls__language-drop-label" })), n("div", { class: `right-panel ${a ? "reschedule" : ""}` }, n("h2", null, n("calendar-icon", null), n("span", { id: "selectedDate" }, this.selectedDateLabel)), n("nylas-timeslot-picker", { exportparts: "ntp, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary" }, v && n("span", { slot: "timeslot-picker-cta-label" }, n("slot", { name: "timeslot-picker-cta-label" })))))));
325
+ }
326
+ return t && !i && o ? n(y, null, n(k, { nylasBranding: g, isLoading: this.isLoading, showNotification: this.showNotification }, a && n(L, null, `${h.t("rescheduleTitle")}`), n("div", { class: "additional-data-page", part: "additional-data-page" }, n("div", { class: "left-panel" }, n("div", { class: "wrapper" }, n("nylas-selected-event-card", { exportparts: "nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone" }))), n("div", { class: `right-panel ${a ? "reschedule" : ""}` }, n("nylas-booking-form", { exportparts: "nbf, nbf__input-textfield, nbf__button-ghost, nbf__button-outline, nbf__button-primary, nbf__input-wrapper, nbf__checkbox-component, nbf__radio-button-group, nbf__textarea-component, nbf__dropdown, nbf__dropdown-button, nbf__dropdown-content" }))))) : n(y, null, n("slot", null));
327
+ }
328
+ get host() {
329
+ return A(this);
330
+ }
331
+ static get watchers() {
332
+ return {
333
+ bookingInfo: ["bookingInfoChanged"],
334
+ rescheduleBookingRef: ["rescheduleBookingRefChanged"],
335
+ cancelBookingRef: ["cancelBookingRefChanged"],
336
+ organizerConfirmationBookingRef: ["organizerConfirmationBookingRefChanged"],
337
+ localization: ["localizationChanged"],
338
+ themeConfig: ["themeConfigChanged"]
339
+ };
340
+ }
341
+ };
342
+ $.style = W;
343
+ export {
344
+ $ as nylas_scheduling
345
+ };