@nylas/web-elements 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/nylas-web-elements/{index-95193d9b.js → index-212258bf.js} +2 -2
  2. package/dist/nylas-web-elements/{index.es-69f2eefb.js → index.es-82b6efae.js} +2 -2
  3. package/dist/nylas-web-elements/index.esm.js +1 -1
  4. package/dist/nylas-web-elements/input-component.entry.js +1 -1
  5. package/dist/nylas-web-elements/input-component.entry.js.map +1 -1
  6. package/dist/nylas-web-elements/input-image-url.entry.js +1 -1
  7. package/dist/nylas-web-elements/multi-select-dropdown.entry.js +1 -1
  8. package/dist/nylas-web-elements/nylas-additional-participants.entry.js +1 -1
  9. package/dist/nylas-web-elements/{nylas-api-request-d8eb4c91.js → nylas-api-request-51129e10.js} +2 -2
  10. package/dist/nylas-web-elements/nylas-availability-picker.entry.js +1 -1
  11. package/dist/nylas-web-elements/nylas-booked-event-card.entry.js +1 -1
  12. package/dist/nylas-web-elements/nylas-booking-calendar-picker.entry.js +1 -1
  13. package/dist/nylas-web-elements/nylas-booking-confirmation-redirect.entry.js +1 -1
  14. package/dist/nylas-web-elements/nylas-booking-confirmation-type.entry.js +1 -1
  15. package/dist/nylas-web-elements/nylas-booking-form-config.entry.js +1 -1
  16. package/dist/nylas-web-elements/nylas-booking-form.entry.js +1 -1
  17. package/dist/nylas-web-elements/nylas-buffer-time.entry.js +1 -1
  18. package/dist/nylas-web-elements/nylas-calendar-picker.entry.js +1 -1
  19. package/dist/nylas-web-elements/nylas-cancel-booking-form.entry.js +1 -1
  20. package/dist/nylas-web-elements/nylas-cancellation-policy.entry.js +1 -1
  21. package/dist/nylas-web-elements/nylas-cancelled-event-card.entry.js +1 -1
  22. package/dist/nylas-web-elements/nylas-confirmation-email.entry.js +1 -1
  23. package/dist/nylas-web-elements/nylas-confirmed-event-card.entry.js +1 -1
  24. package/dist/nylas-web-elements/nylas-connected-calendars.entry.js +1 -1
  25. package/dist/nylas-web-elements/nylas-custom-booking-flow.entry.js +1 -1
  26. package/dist/nylas-web-elements/nylas-custom-event-slug.entry.js +1 -1
  27. package/dist/nylas-web-elements/nylas-customize-booking-settings.entry.js +1 -1
  28. package/dist/nylas-web-elements/nylas-date-component.entry.js +1 -1
  29. package/dist/nylas-web-elements/nylas-date-picker.entry.js +1 -1
  30. package/dist/nylas-web-elements/nylas-date-picker.entry.js.map +1 -1
  31. package/dist/nylas-web-elements/nylas-disable-emails.entry.js +1 -1
  32. package/dist/nylas-web-elements/nylas-editor-tabs-group.entry.js +1 -1
  33. package/dist/nylas-web-elements/nylas-editor-tabs.entry.js +1 -1
  34. package/dist/nylas-web-elements/nylas-event-calendar.entry.js +1 -1
  35. package/dist/nylas-web-elements/nylas-event-calendar.entry.js.map +1 -1
  36. package/dist/nylas-web-elements/nylas-event-capacity.entry.js +1 -1
  37. package/dist/nylas-web-elements/nylas-event-capacity.entry.js.map +1 -1
  38. package/dist/nylas-web-elements/nylas-event-description.entry.js +1 -1
  39. package/dist/nylas-web-elements/nylas-event-duration.entry.js +1 -1
  40. package/dist/nylas-web-elements/nylas-event-info.entry.js +1 -1
  41. package/dist/nylas-web-elements/nylas-event-limits.entry.js +1 -1
  42. package/dist/nylas-web-elements/nylas-event-location.entry.js +1 -1
  43. package/dist/nylas-web-elements/nylas-event-timeslot.entry.js +1 -1
  44. package/dist/nylas-web-elements/nylas-event-timeslot.entry.js.map +1 -1
  45. package/dist/nylas-web-elements/nylas-event-title.entry.js +1 -1
  46. package/dist/nylas-web-elements/nylas-event-title.entry.js.map +1 -1
  47. package/dist/nylas-web-elements/nylas-feedback-form.entry.js +1 -1
  48. package/dist/nylas-web-elements/nylas-form-card.entry.js +1 -1
  49. package/dist/nylas-web-elements/nylas-if-state.entry.js +1 -1
  50. package/dist/nylas-web-elements/nylas-limit-future-bookings.entry.js +1 -1
  51. package/dist/nylas-web-elements/nylas-list-configurations.entry.js +1 -1
  52. package/dist/nylas-web-elements/nylas-locale-switch.entry.js +1 -1
  53. package/dist/nylas-web-elements/nylas-login.entry.js +1 -1
  54. package/dist/nylas-web-elements/nylas-min-booking-notice.entry.js +1 -1
  55. package/dist/nylas-web-elements/nylas-min-cancellation-notice.entry.js +1 -1
  56. package/dist/nylas-web-elements/nylas-notification.entry.js +1 -1
  57. package/dist/nylas-web-elements/nylas-organizer-confirmation-card.entry.js +1 -1
  58. package/dist/nylas-web-elements/nylas-page-name.entry.js +1 -1
  59. package/dist/nylas-web-elements/nylas-page-styling.entry.js +1 -1
  60. package/dist/nylas-web-elements/nylas-participant-booking-calendars.entry.js +1 -1
  61. package/dist/nylas-web-elements/nylas-participants-custom-availability.entry.js +1 -1
  62. package/dist/nylas-web-elements/nylas-provider.entry.js +1 -1
  63. package/dist/nylas-web-elements/nylas-reminder-emails.entry.js +1 -1
  64. package/dist/nylas-web-elements/nylas-reminder-time.entry.js +1 -1
  65. package/dist/nylas-web-elements/nylas-scheduler-editor.entry.js +1 -1
  66. package/dist/nylas-web-elements/nylas-scheduling-method.entry.js +1 -1
  67. package/dist/nylas-web-elements/nylas-scheduling.entry.js +1 -1
  68. package/dist/nylas-web-elements/nylas-select-event-type.entry.js +1 -1
  69. package/dist/nylas-web-elements/nylas-selected-event-card.entry.js +1 -1
  70. package/dist/nylas-web-elements/nylas-time-window-picker.entry.js +1 -1
  71. package/dist/nylas-web-elements/nylas-timeslot-interval.entry.js +1 -1
  72. package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js +1 -1
  73. package/dist/nylas-web-elements/nylas-timeslot-picker.entry.js.map +1 -1
  74. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  75. package/dist/nylas-web-elements/nylas-web-elements.esm.js.map +1 -1
  76. package/dist/nylas-web-elements/{register-component-3d439a88.js → register-component-8b5587d5.js} +2 -2
  77. package/dist/nylas-web-elements/{scheduler-store-0acc5e0f.js → scheduler-store-36b93b74.js} +2 -2
  78. package/dist/nylas-web-elements/textarea-component.entry.js +1 -1
  79. package/dist/nylas-web-elements/time-period-selector.entry.js +1 -1
  80. package/dist/nylas-web-elements/{utils-3fdf2c83.js → utils-ac8fef1e.js} +2 -2
  81. package/dist/types/components/scheduler/nylas-date-picker/nylas-date-picker.d.ts +4 -0
  82. package/dist/types/components/scheduler-editor/nylas-event-capacity/nylas-event-capacity.d.ts +1 -0
  83. package/package.json +2 -3
  84. package/CHANGELOG.md +0 -872
  85. /package/dist/nylas-web-elements/{index-95193d9b.js.map → index-212258bf.js.map} +0 -0
  86. /package/dist/nylas-web-elements/{index.es-69f2eefb.js.map → index.es-82b6efae.js.map} +0 -0
  87. /package/dist/nylas-web-elements/{nylas-api-request-d8eb4c91.js.map → nylas-api-request-51129e10.js.map} +0 -0
  88. /package/dist/nylas-web-elements/{register-component-3d439a88.js.map → register-component-8b5587d5.js.map} +0 -0
  89. /package/dist/nylas-web-elements/{scheduler-store-0acc5e0f.js.map → scheduler-store-36b93b74.js.map} +0 -0
  90. /package/dist/nylas-web-elements/{utils-3fdf2c83.js.map → utils-ac8fef1e.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{h,F as Fragment$1,r as registerInstance,i as createEvent,a as Host,e as getElement}from"./index-3e0d6890.js";import{X as Xr,N as NylasBaseProvider}from"./index.es-69f2eefb.js";import{N as NylasIdentityRequestWrapper}from"./nylas-api-request-d8eb4c91.js";import{t as timezone,d as dataResponse,c as getCalendarRange,a as debug,B as Buffer,p as process,i as instance}from"./utils-3fdf2c83.js";import{b as dayjs,u as utc,c as commonjsGlobal}from"./utc-290d564f.js";import{C as CreateNylasSchedulerConfigStore}from"./scheduler-config-store-95963877.js";import{E as EXPERIMENTAL_FEATURES,C as CONFIGURATION_EVENT_TYPE,L as LANGUAGE_CODE,a as LANGUAGE_MAP}from"./constants-794fe173.js";import"./index-89ee2ce0.js";dayjs.extend(utc);dayjs.extend(timezone);class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`calendars`});if(t){return dataResponse(null,{message:"Error fetching calendars: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching calendars: "+e.error?.message})}this.nylasSchedulerConfigStore.state.calendars=e.data;return dataResponse(e.data)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return dataResponse(t)}}const[n,r]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(r){return dataResponse(null,{message:"Error fetching configuration: "+r.message})}if(Xr(n)){return dataResponse(null,{message:"Error fetching configuration: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?n.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data]}return dataResponse(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,r]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(r){return dataResponse(null,{message:"Error fetching configurations: "+r.message})}if(Xr(n)){return dataResponse(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return dataResponse(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching master event: Nylas API Request is not initialized"})}const t=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const n=t?.event?.calendar_id;if(!n){console.warn("Calendar ID is not present");return dataResponse(null,{message:"Error fetching master event: Calendar ID is not present"})}const r=new URLSearchParams;r.append("calendar_id",n);const[i,a]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${r.toString()}`});if(a){return dataResponse(null,{message:"Error fetching master event: "+a.message})}if(Xr(i)){return dataResponse(null,{message:"Error fetching master event: "+i.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=i.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:i.data}}return dataResponse(i.data)}async createConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(n){return dataResponse(null,{message:"Error creating configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return dataResponse(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(n){return dataResponse(null,{message:"Error updating configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((n=>n.id===e.id?t.data:n))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return dataResponse(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(n){return dataResponse(null,{message:"Error deleting configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return dataResponse(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error creating group event: "+r.message})}if(Xr(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(n.data)}async getGroupEvents(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const t=new URLSearchParams;t.append("show_all","true");const n=this.nylasSchedulerConfigStore.state.calendarViewDateRange;if(n){t.append("start_time",n.start_time);t.append("end_time",n.end_time)}else{const{startTime:e,endTime:n}=getCalendarRange((new Date).toISOString(),"week");t.append("start_time",e.toString());t.append("end_time",n.toString())}const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){t.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${t.toString()}`});if(a){return dataResponse(null,{message:"Error fetching group events: "+a.message})}if(Xr(i)){return dataResponse(null,{message:"Error fetching group events: "+i.error?.message})}this.nylasSchedulerConfigStore.state.groupEvents=i.data;return dataResponse(i.data)}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[r,i]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error updating group event: "+i.message})}if(Xr(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error updating group event: "+r.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=r.data;await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(r.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const r=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const i=r?.event?.master_event_id;const a=r?.event?.id;const o=r?.event?.when?.start_time;const s=r?.group_event_info?.rrule?.[0];const c=s?s.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?dayjs(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:a,recurrence:i?undefined:e.recurrence},n)}else if(t==="future"&&i){const t=await this.createGroupEvent(e,n);const a={location:r?.event?.location,conferencing:r?.event?.conferencing,title:r?.event?.title,description:r?.event?.description,capacity:r?.group_event_info?.capacity,calendar_id:r?.event?.calendar_id,recurrence:c?[c+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...a,id:i},n);return[a,t]}else if(t==="all"){const t=e?.when;const a=r?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[i];let s=o?.when;if(t?.start_time!==a?.start_time){s={...s,start_time:t?.start_time||s?.start_time}}if(t?.end_time!==a?.end_time){s={...s,end_time:t?.end_time||s?.end_time}}if(t?.start_timezone!==a?.start_timezone){s={...s,start_timezone:t?.start_timezone||s?.start_timezone}}if(t?.end_timezone!==a?.end_timezone){s={...s,end_timezone:t?.end_timezone||s?.end_timezone}}return this.updateGroupEventById({...e,when:s,id:i},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const r=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const i=r?.event?.master_event_id;const a=r?.event?.id;const o=r?.event?.when?.start_time;const s=r?.group_event_info?.rrule?.[0];const c=s?s.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?dayjs(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const l={location:r?.event?.location,conferencing:r?.event?.conferencing,title:r?.event?.title,description:r?.event?.description,capacity:r?.group_event_info?.capacity,calendar_id:r?.event?.calendar_id,recurrence:c?[c+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&a){return this.deleteGroupEventById(a,n)}else if(t==="future"&&i&&a){await this.deleteGroupEventById(a,n);return await this.updateGroupEventById({...l,id:i},n)}else if(t==="all"&&i){return this.deleteGroupEventById(i,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){n.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${r}`});if(a){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error deleting group event: "+a.message})}if(Xr(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error deleting group event: "+i.error?.message})}await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(i.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){n.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(a){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error importing group event: "+a.message})}if(Xr(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error importing group event: "+i.error?.message})}if(i.data?.imported_events?.length>0){await this.getGroupEvents(t)}this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(i.data)}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){debug("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){debug("NylasSchedulerConfigConnector logout");this.resetStores()}}class LocalStorage{get(e){return new Promise((t=>{const n=window.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){window.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){window.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const PKCE_KEY="pkce";const GRANT_KEY="grant";const USER_KEY="user";class Storage{Storage=new LocalStorage;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=Buffer.from(e);this.Storage.set(PKCE_KEY,t.toString("base64"))}async getPKCE(){try{const e=await this.Storage.get(PKCE_KEY);if(e){const t=Buffer.from(e,"base64");return t.toString("utf8")}}catch(e){return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${GRANT_KEY}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${GRANT_KEY}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${GRANT_KEY}${t?"-"+e:""}`);if(n){return n}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const n=t.find((t=>t.sub===e.sub));if(!n){const n=[...t,e];this.Storage.set(USER_KEY,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(USER_KEY,n)}}else{this.Storage.set(USER_KEY,[e])}}async getUserToken(e=""){const t=await this.Storage.get(USER_KEY);if(t){if(e===""){return t[0]}const n=t.find((t=>t.sub===e));return n}return null}async getUserTokens(){const e=await this.Storage.get(USER_KEY);if(e){return e}return null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(USER_KEY,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class IndexedDBStorage{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,r)=>{t.openDatabase().then((function(i){const a=i.transaction(t.storeName,"readwrite");const o=a.objectStore(t.storeName);const s=o.get(e);s.onsuccess=()=>{n(s.result)};s.onerror=()=>{r(s.error)};a.oncomplete=()=>{i.close()}}))}))}async remove(e){const t=this;return new Promise(((n,r)=>{const i=indexedDB.open(this.databaseName);i.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};i.onerror=()=>{r(i.error)};i.onsuccess=t=>{const i=t.target.result;const a=i.transaction(this.storeName,"readwrite");const o=a.objectStore(this.storeName);const s=o.delete(e);s.onsuccess=()=>{n(null)};s.onerror=()=>{r(s.error)};a.oncomplete=()=>{i.close()}}}))}set(e,t){return new Promise(((n,r)=>{const i=indexedDB.open(this.databaseName);i.onerror=()=>{r(i.error)};i.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};i.onsuccess=i=>{const a=i.target.result;const o=a.transaction(this.storeName,"readwrite");const s=o.objectStore(this.storeName);const c=s.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{r(c.error)};o.oncomplete=()=>{a.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const r=indexedDB.open(e.databaseName,2);r.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};r.onsuccess=function(e){t(e.target.result)};r.onerror=function(e){n(e.error)}}))}}var sha256$2={exports:{}};(function(module){(function(){"use strict";var ERROR="input is invalid type";var WINDOW=typeof window==="object";var root=WINDOW?window:{};if(root.JS_SHA256_NO_WINDOW){WINDOW=false}var WEB_WORKER=!WINDOW&&typeof self==="object";var NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process==="object"&&process.versions&&process.versions.node;if(NODE_JS){root=commonjsGlobal}else if(WEB_WORKER){root=self}var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&"object"==="object"&&module.exports;var AMD=typeof undefined==="function"&&undefined.amd;var ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer!=="undefined";var HEX_CHARS="0123456789abcdef".split("");var EXTRA=[-2147483648,8388608,32768,128];var SHIFT=[24,16,8,0];var 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];var OUTPUT_TYPES=["hex","array","digest","arrayBuffer"];var blocks=[];if(root.JS_SHA256_NO_NODE_JS||!Array.isArray){Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}if(ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)){ArrayBuffer.isView=function(e){return typeof e==="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer}}var createOutputMethod=function(e,t){return function(n){return new Sha256(t,true).update(n)[e]()}};var createMethod=function(e){var t=createOutputMethod("hex",e);if(NODE_JS){t=nodeWrap(t,e)}t.create=function(){return new Sha256(e)};t.update=function(e){return t.create().update(e)};for(var n=0;n<OUTPUT_TYPES.length;++n){var r=OUTPUT_TYPES[n];t[r]=createOutputMethod(r,e)}return t};var nodeWrap=function(method,is224){var crypto=eval("require('crypto')");var Buffer=eval("require('buffer').Buffer");var algorithm=is224?"sha224":"sha256";var nodeMethod=function(e){if(typeof e==="string"){return crypto.createHash(algorithm).update(e,"utf8").digest("hex")}else{if(e===null||e===undefined){throw new Error(ERROR)}else if(e.constructor===ArrayBuffer){e=new Uint8Array(e)}}if(Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer){return crypto.createHash(algorithm).update(new Buffer(e)).digest("hex")}else{return method(e)}};return nodeMethod};var createHmacOutputMethod=function(e,t){return function(n,r){return new HmacSha256(n,t,true).update(r)[e]()}};var createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)};t.update=function(e,n){return t.create(e).update(n)};for(var n=0;n<OUTPUT_TYPES.length;++n){var r=OUTPUT_TYPES[n];t[r]=createHmacOutputMethod(r,e)}return t};function Sha256(e,t){if(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}else{this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}if(e){this.h0=3238371032;this.h1=914150663;this.h2=812702999;this.h3=4144912697;this.h4=4290775857;this.h5=1750603025;this.h6=1694076839;this.h7=3204075428}else{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=false;this.first=true;this.is224=e}Sha256.prototype.update=function(e){if(this.finalized){return}var t,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}t=true}var r,i=0,a,o=e.length,s=this.blocks;while(i<o){if(this.hashed){this.hashed=false;s[0]=this.block;s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0}if(t){for(a=this.start;i<o&&a<64;++i){s[a>>2]|=e[i]<<SHIFT[a++&3]}}else{for(a=this.start;i<o&&a<64;++i){r=e.charCodeAt(i);if(r<128){s[a>>2]|=r<<SHIFT[a++&3]}else if(r<2048){s[a>>2]|=(192|r>>6)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}else if(r<55296||r>=57344){s[a>>2]|=(224|r>>12)<<SHIFT[a++&3];s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}else{r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023);s[a>>2]|=(240|r>>18)<<SHIFT[a++&3];s[a>>2]|=(128|r>>12&63)<<SHIFT[a++&3];s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}}}this.lastByteIndex=a;this.bytes+=a-this.start;if(a>=64){this.block=s[16];this.start=a-64;this.hash();this.hashed=true}else{this.start=a}}if(this.bytes>4294967295){this.hBytes+=this.bytes/4294967296<<0;this.bytes=this.bytes%4294967296}return this};Sha256.prototype.finalize=function(){if(this.finalized){return}this.finalized=true;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block;e[t>>2]|=EXTRA[t&3];this.block=e[16];if(t>=56){if(!this.hashed){this.hash()}e[0]=this.block;e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0}e[14]=this.hBytes<<3|this.bytes>>>29;e[15]=this.bytes<<3;this.hash()};Sha256.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,u,l,f,d,h,p,y,v,g,m,w;for(u=16;u<64;++u){h=c[u-15];l=(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3;h=c[u-2];f=(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10;c[u]=c[u-16]+l+c[u-7]+f<<0}w=t&n;for(u=0;u<64;u+=4){if(this.first){if(this.is224){v=300032;h=c[0]-1413257819;s=h-150054599<<0;r=h+24177077<<0}else{v=704751109;h=c[0]-210244248;s=h-1521486534<<0;r=h+143694565<<0}this.first=false}else{l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10);f=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7);v=e&t;d=v^e&n^w;y=i&a^~i&o;h=s+f+y+K[u]+c[u];p=l+d;s=r+h<<0;r=h+p<<0}l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10);f=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7);g=r&e;d=g^r&t^v;y=s&i^~s&a;h=o+f+y+K[u+1]+c[u+1];p=l+d;o=n+h<<0;n=h+p<<0;l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10);f=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7);m=n&r;d=m^n&e^g;y=o&s^~o&i;h=a+f+y+K[u+2]+c[u+2];p=l+d;a=t+h<<0;t=h+p<<0;l=(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);w=t&n;d=w^t&r^m;y=a&o^~a&s;h=i+f+y+K[u+3]+c[u+3];p=l+d;i=e+h<<0;e=h+p<<0}this.h0=this.h0+e<<0;this.h1=this.h1+t<<0;this.h2=this.h2+n<<0;this.h3=this.h3+r<<0;this.h4=this.h4+i<<0;this.h5=this.h5+a<<0;this.h6=this.h6+o<<0;this.h7=this.h7+s<<0};Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7;var c=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&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[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[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&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[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[o&15];if(!this.is224){c+=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]}return c};Sha256.prototype.toString=Sha256.prototype.hex;Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7;var c=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,i>>24&255,i>>16&255,i>>8&255,i&255,a>>24&255,a>>16&255,a>>8&255,a&255,o>>24&255,o>>16&255,o>>8&255,o&255];if(!this.is224){c.push(s>>24&255,s>>16&255,s>>8&255,s&255)}return c};Sha256.prototype.array=Sha256.prototype.digest;Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32);var t=new DataView(e);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);if(!this.is224){t.setUint32(28,this.h7)}return e};function HmacSha256(e,t,n){var r,i=typeof e;if(i==="string"){var a=[],o=e.length,s=0,c;for(r=0;r<o;++r){c=e.charCodeAt(r);if(c<128){a[s++]=c}else if(c<2048){a[s++]=192|c>>6;a[s++]=128|c&63}else if(c<55296||c>=57344){a[s++]=224|c>>12;a[s++]=128|c>>6&63;a[s++]=128|c&63}else{c=65536+((c&1023)<<10|e.charCodeAt(++r)&1023);a[s++]=240|c>>18;a[s++]=128|c>>12&63;a[s++]=128|c>>6&63;a[s++]=128|c&63}}e=a}else{if(i==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}}if(e.length>64){e=new Sha256(t,true).update(e).array()}var u=[],l=[];for(r=0;r<64;++r){var f=e[r]||0;u[r]=92^f;l[r]=54^f}Sha256.call(this,t,n);this.update(l);this.oKeyPad=u;this.inner=true;this.sharedMemory=n}HmacSha256.prototype=new Sha256;HmacSha256.prototype.finalize=function(){Sha256.prototype.finalize.call(this);if(this.inner){this.inner=false;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory);this.update(this.oKeyPad);this.update(e);Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports;exports.sha224=createMethod(true);exports.sha256.hmac=createHmacMethod();exports.sha224.hmac=createHmacMethod(true);if(COMMON_JS){module.exports=exports}else{root.sha256=exports.sha256;root.sha224=exports.sha224;if(AMD){undefined((function(){return exports}))}}})()})(sha256$2);const sha256$1=sha256$2.exports;var getRandomValues;var rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){getRandomValues=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!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(e){return typeof e==="string"&&REGEX.test(e)}var byteToHex=[];for(var i=0;i<256;++i){byteToHex.push((i+256).toString(16).substr(1))}function stringify(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(n)){throw TypeError("Stringified UUID is invalid")}return n}var _nodeId;var _clockseq;var _lastMSecs=0;var _lastNSecs=0;function v1(e,t,n){var r=t&&n||0;var i=t||new Array(16);e=e||{};var a=e.node||_nodeId;var o=e.clockseq!==undefined?e.clockseq:_clockseq;if(a==null||o==null){var s=e.random||(e.rng||rng)();if(a==null){a=_nodeId=[s[0]|1,s[1],s[2],s[3],s[4],s[5]]}if(o==null){o=_clockseq=(s[6]<<8|s[7])&16383}}var c=e.msecs!==undefined?e.msecs:Date.now();var u=e.nsecs!==undefined?e.nsecs:_lastNSecs+1;var l=c-_lastMSecs+(u-_lastNSecs)/1e4;if(l<0&&e.clockseq===undefined){o=o+1&16383}if((l<0||c>_lastMSecs)&&e.nsecs===undefined){u=0}if(u>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}_lastMSecs=c;_lastNSecs=u;_clockseq=o;c+=122192928e5;var f=((c&268435455)*1e4+u)%4294967296;i[r++]=f>>>24&255;i[r++]=f>>>16&255;i[r++]=f>>>8&255;i[r++]=f&255;var d=c/4294967296*1e4&268435455;i[r++]=d>>>8&255;i[r++]=d&255;i[r++]=d>>>24&15|16;i[r++]=d>>>16&255;i[r++]=o>>>8|128;i[r++]=o&255;for(var h=0;h<6;++h){i[r+h]=a[h]}return t||stringify(i)}function parse(e){if(!validate(e)){throw TypeError("Invalid UUID")}var t;var n=new Uint8Array(16);n[0]=(t=parseInt(e.slice(0,8),16))>>>24;n[1]=t>>>16&255;n[2]=t>>>8&255;n[3]=t&255;n[4]=(t=parseInt(e.slice(9,13),16))>>>8;n[5]=t&255;n[6]=(t=parseInt(e.slice(14,18),16))>>>8;n[7]=t&255;n[8]=(t=parseInt(e.slice(19,23),16))>>>8;n[9]=t&255;n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255;n[11]=t/4294967296&255;n[12]=t>>>24&255;n[13]=t>>>16&255;n[14]=t>>>8&255;n[15]=t&255;return n}function stringToBytes(e){e=unescape(encodeURIComponent(e));var t=[];for(var n=0;n<e.length;++n){t.push(e.charCodeAt(n))}return t}var DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";var URL$1="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function v35(e,t,n){function r(e,r,i,a){if(typeof e==="string"){e=stringToBytes(e)}if(typeof r==="string"){r=parse(r)}if(r.length!==16){throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)")}var o=new Uint8Array(16+e.length);o.set(r);o.set(e,r.length);o=n(o);o[6]=o[6]&15|t;o[8]=o[8]&63|128;if(i){a=a||0;for(var s=0;s<16;++s){i[a+s]=o[s]}return i}return stringify(o)}try{r.name=e}catch(e){}r.DNS=DNS;r.URL=URL$1;return r}function md5(e){if(typeof e==="string"){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n){e[n]=t.charCodeAt(n)}}return md5ToHexEncodedArray(wordsToMd5(bytesToWords(e),e.length*8))}function md5ToHexEncodedArray(e){var t=[];var n=e.length*32;var r="0123456789abcdef";for(var i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255;var o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function getOutputLength(e){return(e+64>>>9<<4)+14+1}function wordsToMd5(e,t){e[t>>5]|=128<<t%32;e[getOutputLength(t)-1]=t;var n=1732584193;var r=-271733879;var i=-1732584194;var a=271733878;for(var o=0;o<e.length;o+=16){var s=n;var c=r;var u=i;var l=a;n=md5ff(n,r,i,a,e[o],7,-680876936);a=md5ff(a,n,r,i,e[o+1],12,-389564586);i=md5ff(i,a,n,r,e[o+2],17,606105819);r=md5ff(r,i,a,n,e[o+3],22,-1044525330);n=md5ff(n,r,i,a,e[o+4],7,-176418897);a=md5ff(a,n,r,i,e[o+5],12,1200080426);i=md5ff(i,a,n,r,e[o+6],17,-1473231341);r=md5ff(r,i,a,n,e[o+7],22,-45705983);n=md5ff(n,r,i,a,e[o+8],7,1770035416);a=md5ff(a,n,r,i,e[o+9],12,-1958414417);i=md5ff(i,a,n,r,e[o+10],17,-42063);r=md5ff(r,i,a,n,e[o+11],22,-1990404162);n=md5ff(n,r,i,a,e[o+12],7,1804603682);a=md5ff(a,n,r,i,e[o+13],12,-40341101);i=md5ff(i,a,n,r,e[o+14],17,-1502002290);r=md5ff(r,i,a,n,e[o+15],22,1236535329);n=md5gg(n,r,i,a,e[o+1],5,-165796510);a=md5gg(a,n,r,i,e[o+6],9,-1069501632);i=md5gg(i,a,n,r,e[o+11],14,643717713);r=md5gg(r,i,a,n,e[o],20,-373897302);n=md5gg(n,r,i,a,e[o+5],5,-701558691);a=md5gg(a,n,r,i,e[o+10],9,38016083);i=md5gg(i,a,n,r,e[o+15],14,-660478335);r=md5gg(r,i,a,n,e[o+4],20,-405537848);n=md5gg(n,r,i,a,e[o+9],5,568446438);a=md5gg(a,n,r,i,e[o+14],9,-1019803690);i=md5gg(i,a,n,r,e[o+3],14,-187363961);r=md5gg(r,i,a,n,e[o+8],20,1163531501);n=md5gg(n,r,i,a,e[o+13],5,-1444681467);a=md5gg(a,n,r,i,e[o+2],9,-51403784);i=md5gg(i,a,n,r,e[o+7],14,1735328473);r=md5gg(r,i,a,n,e[o+12],20,-1926607734);n=md5hh(n,r,i,a,e[o+5],4,-378558);a=md5hh(a,n,r,i,e[o+8],11,-2022574463);i=md5hh(i,a,n,r,e[o+11],16,1839030562);r=md5hh(r,i,a,n,e[o+14],23,-35309556);n=md5hh(n,r,i,a,e[o+1],4,-1530992060);a=md5hh(a,n,r,i,e[o+4],11,1272893353);i=md5hh(i,a,n,r,e[o+7],16,-155497632);r=md5hh(r,i,a,n,e[o+10],23,-1094730640);n=md5hh(n,r,i,a,e[o+13],4,681279174);a=md5hh(a,n,r,i,e[o],11,-358537222);i=md5hh(i,a,n,r,e[o+3],16,-722521979);r=md5hh(r,i,a,n,e[o+6],23,76029189);n=md5hh(n,r,i,a,e[o+9],4,-640364487);a=md5hh(a,n,r,i,e[o+12],11,-421815835);i=md5hh(i,a,n,r,e[o+15],16,530742520);r=md5hh(r,i,a,n,e[o+2],23,-995338651);n=md5ii(n,r,i,a,e[o],6,-198630844);a=md5ii(a,n,r,i,e[o+7],10,1126891415);i=md5ii(i,a,n,r,e[o+14],15,-1416354905);r=md5ii(r,i,a,n,e[o+5],21,-57434055);n=md5ii(n,r,i,a,e[o+12],6,1700485571);a=md5ii(a,n,r,i,e[o+3],10,-1894986606);i=md5ii(i,a,n,r,e[o+10],15,-1051523);r=md5ii(r,i,a,n,e[o+1],21,-2054922799);n=md5ii(n,r,i,a,e[o+8],6,1873313359);a=md5ii(a,n,r,i,e[o+15],10,-30611744);i=md5ii(i,a,n,r,e[o+6],15,-1560198380);r=md5ii(r,i,a,n,e[o+13],21,1309151649);n=md5ii(n,r,i,a,e[o+4],6,-145523070);a=md5ii(a,n,r,i,e[o+11],10,-1120210379);i=md5ii(i,a,n,r,e[o+2],15,718787259);r=md5ii(r,i,a,n,e[o+9],21,-343485551);n=safeAdd(n,s);r=safeAdd(r,c);i=safeAdd(i,u);a=safeAdd(a,l)}return[n,r,i,a]}function bytesToWords(e){if(e.length===0){return[]}var t=e.length*8;var n=new Uint32Array(getOutputLength(t));for(var r=0;r<t;r+=8){n[r>>5]|=(e[r/8]&255)<<r%32}return n}function safeAdd(e,t){var n=(e&65535)+(t&65535);var r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function bitRotateLeft(e,t){return e<<t|e>>>32-t}function md5cmn(e,t,n,r,i,a){return safeAdd(bitRotateLeft(safeAdd(safeAdd(t,e),safeAdd(r,a)),i),n)}function md5ff(e,t,n,r,i,a,o){return md5cmn(t&n|~t&r,e,t,i,a,o)}function md5gg(e,t,n,r,i,a,o){return md5cmn(t&r|n&~r,e,t,i,a,o)}function md5hh(e,t,n,r,i,a,o){return md5cmn(t^n^r,e,t,i,a,o)}function md5ii(e,t,n,r,i,a,o){return md5cmn(n^(t|~r),e,t,i,a,o)}var v3=v35("v3",48,md5);function v4(e,t,n){e=e||{};var r=e.random||(e.rng||rng)();r[6]=r[6]&15|64;r[8]=r[8]&63|128;if(t){n=n||0;for(var i=0;i<16;++i){t[n+i]=r[i]}return t}return stringify(r)}function f(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ROTL(e,t){return e<<t|e>>>32-t}function sha1(e){var t=[1518500249,1859775393,2400959708,3395469782];var n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==="string"){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i){e.push(r.charCodeAt(i))}}else if(!Array.isArray(e)){e=Array.prototype.slice.call(e)}e.push(128);var a=e.length/4+2;var o=Math.ceil(a/16);var s=new Array(o);for(var c=0;c<o;++c){var u=new Uint32Array(16);for(var l=0;l<16;++l){u[l]=e[c*64+l*4]<<24|e[c*64+l*4+1]<<16|e[c*64+l*4+2]<<8|e[c*64+l*4+3]}s[c]=u}s[o-1][14]=(e.length-1)*8/Math.pow(2,32);s[o-1][14]=Math.floor(s[o-1][14]);s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){var h=new Uint32Array(80);for(var p=0;p<16;++p){h[p]=s[d][p]}for(var y=16;y<80;++y){h[y]=ROTL(h[y-3]^h[y-8]^h[y-14]^h[y-16],1)}var v=n[0];var g=n[1];var m=n[2];var w=n[3];var _=n[4];for(var b=0;b<80;++b){var E=Math.floor(b/20);var R=ROTL(v,5)+f(E,g,m,w)+_+t[E]+h[b]>>>0;_=w;w=m;m=ROTL(g,30)>>>0;g=v;v=R}n[0]=n[0]+v>>>0;n[1]=n[1]+g>>>0;n[2]=n[2]+m>>>0;n[3]=n[3]+w>>>0;n[4]=n[4]+_>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var v5=v35("v5",80,sha1);const nil="00000000-0000-0000-0000-000000000000";function version$1(e){if(!validate(e)){throw TypeError("Invalid UUID")}return parseInt(e.substr(14,1),16)}async function getBytes(e,t){const n=e.getReader();let r;while(!(r=await n.read()).done){t(r.value)}}function getLines(e){let t;let n;let r;let i=false;return function a(o){if(t===undefined){t=o;n=0;r=-1}else{t=concat(t,o)}const s=t.length;let c=0;while(n<s){if(i){if(t[n]===10){c=++n}i=false}let a=-1;for(;n<s&&a===-1;++n){switch(t[n]){case 58:if(r===-1){r=n-c}break;case 13:i=true;case 10:a=n;break}}if(a===-1){break}e(t.subarray(c,a),r);c=n;r=-1}if(c===s){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function getMessages(e,t,n){let r=newMessage();const i=new TextDecoder;return function a(o,s){if(o.length===0){n===null||n===void 0?void 0:n(r);r=newMessage()}else if(s>0){const n=i.decode(o.subarray(0,s));const a=s+(o[s+1]===32?2:1);const c=i.decode(o.subarray(a));switch(n){case"data":r.data=r.data?r.data+"\n"+c:c;break;case"event":r.event=c;break;case"id":e(r.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(r.retry=n)}break}}}}function concat(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function newMessage(){return{data:"",event:"",id:"",retry:undefined}}var __rest=undefined&&undefined.__rest||function(e,t){var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0)n[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++){if(t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i]))n[r[i]]=e[r[i]]}return n};const EventStreamContentType="text/event-stream";const DefaultRetryInterval=1e3;const LastEventId="last-event-id";function fetchEventSource(e,t){var{signal:n,headers:r,onopen:i,onmessage:a,onclose:o,onerror:s,openWhenHidden:c,fetch:u}=t,l=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,f)=>{const d=Object.assign({},r);if(!d.accept){d.accept=EventStreamContentType}let h;function p(){h.abort();if(!document.hidden){_()}}if(!c){document.addEventListener("visibilitychange",p)}let y=DefaultRetryInterval;let v=0;function g(){document.removeEventListener("visibilitychange",p);window.clearTimeout(v);h.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{g();t()}));const m=u!==null&&u!==void 0?u:window.fetch;const w=i!==null&&i!==void 0?i:defaultOnOpen;async function _(){var n;h=new AbortController;try{const n=await m(e,Object.assign(Object.assign({},l),{headers:d,signal:h.signal}));await w(n);await getBytes(n.body,getLines(getMessages((e=>{if(e){d[LastEventId]=e}else{delete d[LastEventId]}}),(e=>{y=e}),a)));o===null||o===void 0?void 0:o();g();t()}catch(e){if(!h.signal.aborted){try{const t=(n=s===null||s===void 0?void 0:s(e))!==null&&n!==void 0?n:y;window.clearTimeout(v);v=window.setTimeout(_,t)}catch(e){g();f(e)}}}}_()}))}function defaultOnOpen(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(EventStreamContentType))){throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}}function Base64EncodeUrl(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Base64DecodeUrl(e){e=(e+"===").slice(0,e.length+e.length%4);return e.replace(/-/g,"+").replace(/_/g,"/")}function getTimestamp(){return Math.floor(Date.now()/1e3)}async function sha256(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const r=Array.from(new Uint8Array(n));const i=r.map((e=>e.toString(16).padStart(2,"0"))).join("");return i}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,a=0,o=0,s="";i=n.charAt(o++);~i&&(r=a%4?64*r+i:i,a++%4)?s+=String.fromCharCode(255&r>>(-2*a&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function t$1(e){var t=e.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(e){return decodeURIComponent(r$1(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return r$1(t)}}function n$1(e){this.message=e}function o(e,t){if("string"!=typeof e)throw new n$1("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(t$1(e.split(".")[n]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new IndexedDBStorage;this.Storage=new Storage(e)}else{this.Storage=new Storage}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}if(e.disableInitCodeExchange!==true){this.codeExchange(null)}}async validateAccessToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{access_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${n}`,{method:"GET"});const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{id_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${n}`,{method:"GET"});if(e.status!==200){return false}const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let n=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){n+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){n+=`&provider=${e.provider}`}if(e.loginHint){n+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){n+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){n+=`&scope=${e.scope.join(" ")}`}if(e.prompt){n+=`&prompt=${e.prompt}`}if(e.metadata){n+=`&metadata=${e.metadata}`}if(e.state||this.loginId){n+=`&state=${this.loginId?this.loginId:e.state}`}return n}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const n=await this.Storage.getUserToken(e);const r=await this.getCodeChallege();let i=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(r){i+=`&code_challenge=${r}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){i+=`&provider=${n.provider}`}if(n?.email){i+=`&login_hint=${n.email}`}if(t){i+=`&scope=${t.join(" ")}`}return i}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=v4();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=sha256$2.exports.sha256(e);let n=Buffer.from(t).toString("base64");n=Base64EncodeUrl(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const n={imap_username:e.imap_username,imap_password:e.imap_password,imap_host:e.imap_host,imap_port:e.imap_port,type:e.type,smtp_host:e.smtp_host,smtp_port:e.smtp_port,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(e.smtp_username&&e.smtp_password){n.smtp_username=e.smtp_username;n.smtp_password=e.smtp_password}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const r=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const i=await r.json();return i}async authEWS(e){const t=await this.getCodeChallege();const n={...e,provider:"ews",redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const r=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const i=await r.json();return i}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const n=await t.json();return n}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const n=t.data;return n}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(window.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const r=t.get("state");const i=t.get("error");const a=t.get("error_description");const o=t.get("error_code");if(i&&a&&o){const e={detail:{error:i,error_description:a,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}if(!n){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const s=await this.Storage.getPKCE();if(!s){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:n,grant_type:"authorization_code",code_verifier:s};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const i=await t.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(i);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(r){e.data.state=r}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(i){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}}async tokenExchange(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const n=t.refresh_token;try{const t={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:n,grant_type:"refresh_token"};const r=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const i=await r.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=getTimestamp();i.expires_in=t+i.expires_in;this.Storage.setGrant(i,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const r={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",r));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const n=getTimestamp();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const r=o(e.id_token);r.status="authenticated";this.Storage.setUserToken(r);const i=await this.validateIDToken(r.sub);if(!i){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const r=window.screenX+(window.outerWidth-t)/2;const i=window.screenY+(window.outerHeight-n)/2.5;const a=`uas-popup`;const o=e;const s=window.open(o,a,`width=${t},height=${n},left=${r},top=${i}`);if(!s){return}const c=setInterval((async()=>{if(s.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=s.location.href.split("?");if(!e[0]){return}const t=s.location.search;s.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);s.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=getTimestamp();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:r,expires_in:i}=n;const a=r;if(a){if(i&&i>getTimestamp()){const e=i-t;if(e>30){return a}}}await this.tokenExchange(e);const o=await this.Storage.getGrant(e,this.multiAccount);return o.access_token}async sse(e,t){const n=t.headers||{};const r=n["Grant-ID"];let i="";if(this.multiAccount){if(!r){this.logout();throw new Error("Grant ID is required for multi account calls")}i=await this.getAccessToken(r)}else{i=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${i}`;if(!n["content-type"]){n["content-type"]="application/json"}return fetchEventSource(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,r){let i="";let a=1;if(this.multiAccount){if(!t.grant_id){this.logout();throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();a=e?e.length:1;i=await this.getAccessToken(t.grant_id)}else{i=await this.getAccessToken()}if(!i){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${i}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${i}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const i=await fetch(`${r||this.domain}/${e}`,{...t,headers:o});if(!n){return i}const s=await(i?.json());const c=await this.isAuthenticatedResponse(i.status,s);if(!c){if(a>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}this.logout();return}return s}catch(e){throw e}}async fetchRequest(e,t,n,r=true,i,a){const o=await this.isLoggedIn();const s=new URL(e,i??this.domain);const c=new Headers;c.append("Accept","application/json");c.append("Content-Type","application/json");c.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();c.append("Authorization",`Bearer ${e}`)}const u=await fetch(s.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:location.origin,body:n?JSON.stringify(n):undefined,...a||{}});if(!r){return u.body}const l=await u.json();return l}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,n){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:getTimestamp(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:n,expires_in:2e9},this.multiAccount)}}var react$1={exports:{}};var react_production_min={};
1
+ import{h,F as Fragment$1,r as registerInstance,i as createEvent,a as Host,e as getElement}from"./index-3e0d6890.js";import{X as Xr,N as NylasBaseProvider}from"./index.es-82b6efae.js";import{N as NylasIdentityRequestWrapper}from"./nylas-api-request-51129e10.js";import{t as timezone,d as dataResponse,c as getCalendarRange,a as debug,B as Buffer,p as process,i as instance}from"./utils-ac8fef1e.js";import{b as dayjs,u as utc,c as commonjsGlobal}from"./utc-290d564f.js";import{C as CreateNylasSchedulerConfigStore}from"./scheduler-config-store-95963877.js";import{E as EXPERIMENTAL_FEATURES,C as CONFIGURATION_EVENT_TYPE,L as LANGUAGE_CODE,a as LANGUAGE_MAP}from"./constants-794fe173.js";import"./index-89ee2ce0.js";dayjs.extend(utc);dayjs.extend(timezone);class NylasSchedulerConfigAPIConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const[e,t]=await this.nylasApiRequest.request({method:"GET",path:`calendars`});if(t){return dataResponse(null,{message:"Error fetching calendars: "+t.message})}if(Xr(e)){return dataResponse(null,{message:"Error fetching calendars: "+e.error?.message})}this.nylasSchedulerConfigStore.state.calendars=e.data;return dataResponse(e.data)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configuration: Nylas API Request is not initialized"})}if(!t){const t=this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e));if(t){this.nylasSchedulerConfigStore.state.selectedConfiguration=t;return dataResponse(t)}}const[n,r]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(r){return dataResponse(null,{message:"Error fetching configuration: "+r.message})}if(Xr(n)){return dataResponse(null,{message:"Error fetching configuration: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=n.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((t=>t.id===e?n.data:t))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,n.data]}return dataResponse(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,r]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(r){return dataResponse(null,{message:"Error fetching configurations: "+r.message})}if(Xr(n)){return dataResponse(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return dataResponse(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching master event: Nylas API Request is not initialized"})}const t=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const n=t?.event?.calendar_id;if(!n){console.warn("Calendar ID is not present");return dataResponse(null,{message:"Error fetching master event: Calendar ID is not present"})}const r=new URLSearchParams;r.append("calendar_id",n);const[i,a]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${r.toString()}`});if(a){return dataResponse(null,{message:"Error fetching master event: "+a.message})}if(Xr(i)){return dataResponse(null,{message:"Error fetching master event: "+i.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=i.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:i.data}}return dataResponse(i.data)}async createConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations`,body:e});if(n){return dataResponse(null,{message:"Error creating configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error creating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data];return dataResponse(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"PUT",path:`scheduling/configurations/${e.id}`,body:e});if(n){return dataResponse(null,{message:"Error updating configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error updating configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.selectedConfiguration=t.data;if(this.nylasSchedulerConfigStore.state.configurations.find((t=>t.id===e.id))){this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.map((n=>n.id===e.id?t.data:n))}else{this.nylasSchedulerConfigStore.state.configurations=[...this.nylasSchedulerConfigStore.state.configurations,t.data]}return dataResponse(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting configuration: Nylas API Request is not initialized"})}const[t,n]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${e}`});if(n){return dataResponse(null,{message:"Error deleting configuration: "+n.message})}if(Xr(t)){return dataResponse(null,{message:"Error deleting configuration: "+t.error?.message})}this.nylasSchedulerConfigStore.state.configurations=this.nylasSchedulerConfigStore.state.configurations.filter((t=>t.id!==e));if(this.nylasSchedulerConfigStore.state.selectedConfiguration?.id===e){this.nylasSchedulerConfigStore.resetSelectedConfiguration()}return dataResponse(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error creating group event: "+r.message})}if(Xr(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(n.data)}async getGroupEvents(e){if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const t=new URLSearchParams;t.append("show_all","true");const n=this.nylasSchedulerConfigStore.state.calendarViewDateRange;if(n){t.append("start_time",n.start_time);t.append("end_time",n.end_time)}else{const{startTime:e,endTime:n}=getCalendarRange((new Date).toISOString(),"week");t.append("start_time",e.toString());t.append("end_time",n.toString())}const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){t.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${t.toString()}`});if(a){return dataResponse(null,{message:"Error fetching group events: "+a.message})}if(Xr(i)){return dataResponse(null,{message:"Error fetching group events: "+i.error?.message})}this.nylasSchedulerConfigStore.state.groupEvents=i.data;return dataResponse(i.data)}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[r,i]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error updating group event: "+i.message})}if(Xr(r)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error updating group event: "+r.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=r.data;await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(r.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const r=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const i=r?.event?.master_event_id;const a=r?.event?.id;const o=r?.event?.when?.start_time;const s=r?.group_event_info?.rrule?.[0];const c=s?s.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?dayjs(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:a,recurrence:i?undefined:e.recurrence},n)}else if(t==="future"&&i){const t=await this.createGroupEvent(e,n);const a={location:r?.event?.location,conferencing:r?.event?.conferencing,title:r?.event?.title,description:r?.event?.description,capacity:r?.group_event_info?.capacity,calendar_id:r?.event?.calendar_id,recurrence:c?[c+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...a,id:i},n);return[a,t]}else if(t==="all"){const t=e?.when;const a=r?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[i];let s=o?.when;if(t?.start_time!==a?.start_time){s={...s,start_time:t?.start_time||s?.start_time}}if(t?.end_time!==a?.end_time){s={...s,end_time:t?.end_time||s?.end_time}}if(t?.start_timezone!==a?.start_timezone){s={...s,start_timezone:t?.start_timezone||s?.start_timezone}}if(t?.end_timezone!==a?.end_timezone){s={...s,end_timezone:t?.end_timezone||s?.end_timezone}}return this.updateGroupEventById({...e,when:s,id:i},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const r=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const i=r?.event?.master_event_id;const a=r?.event?.id;const o=r?.event?.when?.start_time;const s=r?.group_event_info?.rrule?.[0];const c=s?s.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?dayjs(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const l={location:r?.event?.location,conferencing:r?.event?.conferencing,title:r?.event?.title,description:r?.event?.description,capacity:r?.group_event_info?.capacity,calendar_id:r?.event?.calendar_id,recurrence:c?[c+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&a){return this.deleteGroupEventById(a,n)}else if(t==="future"&&i&&a){await this.deleteGroupEventById(a,n);return await this.updateGroupEventById({...l,id:i},n)}else if(t==="all"&&i){return this.deleteGroupEventById(i,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){n.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${r}`});if(a){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error deleting group event: "+a.message})}if(Xr(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error deleting group event: "+i.error?.message})}await this.getGroupEvents(t);this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(i.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){console.warn("Nylas API Request is not initialized");return dataResponse(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const r=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(r){n.append("calendar_id",r)}const[i,a]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(a){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error importing group event: "+a.message})}if(Xr(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(null,{message:"Error importing group event: "+i.error?.message})}if(i.data?.imported_events?.length>0){await this.getGroupEvents(t)}this.nylasSchedulerConfigStore.state.isLoading=false;return dataResponse(i.data)}}class NylasSchedulerConfigConnector{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){debug("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new NylasSchedulerConfigAPIConnector({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){debug("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){debug("NylasSchedulerConfigConnector logout");this.resetStores()}}class LocalStorage{get(e){return new Promise((t=>{const n=window.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){window.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){window.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const PKCE_KEY="pkce";const GRANT_KEY="grant";const USER_KEY="user";class Storage{Storage=new LocalStorage;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=Buffer.from(e);this.Storage.set(PKCE_KEY,t.toString("base64"))}async getPKCE(){try{const e=await this.Storage.get(PKCE_KEY);if(e){const t=Buffer.from(e,"base64");return t.toString("utf8")}}catch(e){return null}return null}removePKCE(){this.Storage.remove(PKCE_KEY)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${GRANT_KEY}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${GRANT_KEY}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${GRANT_KEY}${t?"-"+e:""}`);if(n){return n}return null}async setUserToken(e){const t=await this.getUserTokens();if(t){const n=t.find((t=>t.sub===e.sub));if(!n){const n=[...t,e];this.Storage.set(USER_KEY,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(USER_KEY,n)}}else{this.Storage.set(USER_KEY,[e])}}async getUserToken(e=""){const t=await this.Storage.get(USER_KEY);if(t){if(e===""){return t[0]}const n=t.find((t=>t.sub===e));return n}return null}async getUserTokens(){const e=await this.Storage.get(USER_KEY);if(e){return e}return null}removeUserTokens(){this.Storage.remove(USER_KEY)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(USER_KEY,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class IndexedDBStorage{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,r)=>{t.openDatabase().then((function(i){const a=i.transaction(t.storeName,"readwrite");const o=a.objectStore(t.storeName);const s=o.get(e);s.onsuccess=()=>{n(s.result)};s.onerror=()=>{r(s.error)};a.oncomplete=()=>{i.close()}}))}))}async remove(e){const t=this;return new Promise(((n,r)=>{const i=indexedDB.open(this.databaseName);i.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};i.onerror=()=>{r(i.error)};i.onsuccess=t=>{const i=t.target.result;const a=i.transaction(this.storeName,"readwrite");const o=a.objectStore(this.storeName);const s=o.delete(e);s.onsuccess=()=>{n(null)};s.onerror=()=>{r(s.error)};a.oncomplete=()=>{i.close()}}}))}set(e,t){return new Promise(((n,r)=>{const i=indexedDB.open(this.databaseName);i.onerror=()=>{r(i.error)};i.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};i.onsuccess=i=>{const a=i.target.result;const o=a.transaction(this.storeName,"readwrite");const s=o.objectStore(this.storeName);const c=s.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{r(c.error)};o.oncomplete=()=>{a.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const r=indexedDB.open(e.databaseName,2);r.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};r.onsuccess=function(e){t(e.target.result)};r.onerror=function(e){n(e.error)}}))}}var sha256$2={exports:{}};(function(module){(function(){"use strict";var ERROR="input is invalid type";var WINDOW=typeof window==="object";var root=WINDOW?window:{};if(root.JS_SHA256_NO_WINDOW){WINDOW=false}var WEB_WORKER=!WINDOW&&typeof self==="object";var NODE_JS=!root.JS_SHA256_NO_NODE_JS&&typeof process==="object"&&process.versions&&process.versions.node;if(NODE_JS){root=commonjsGlobal}else if(WEB_WORKER){root=self}var COMMON_JS=!root.JS_SHA256_NO_COMMON_JS&&"object"==="object"&&module.exports;var AMD=typeof undefined==="function"&&undefined.amd;var ARRAY_BUFFER=!root.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer!=="undefined";var HEX_CHARS="0123456789abcdef".split("");var EXTRA=[-2147483648,8388608,32768,128];var SHIFT=[24,16,8,0];var 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];var OUTPUT_TYPES=["hex","array","digest","arrayBuffer"];var blocks=[];if(root.JS_SHA256_NO_NODE_JS||!Array.isArray){Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}}if(ARRAY_BUFFER&&(root.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)){ArrayBuffer.isView=function(e){return typeof e==="object"&&e.buffer&&e.buffer.constructor===ArrayBuffer}}var createOutputMethod=function(e,t){return function(n){return new Sha256(t,true).update(n)[e]()}};var createMethod=function(e){var t=createOutputMethod("hex",e);if(NODE_JS){t=nodeWrap(t,e)}t.create=function(){return new Sha256(e)};t.update=function(e){return t.create().update(e)};for(var n=0;n<OUTPUT_TYPES.length;++n){var r=OUTPUT_TYPES[n];t[r]=createOutputMethod(r,e)}return t};var nodeWrap=function(method,is224){var crypto=eval("require('crypto')");var Buffer=eval("require('buffer').Buffer");var algorithm=is224?"sha224":"sha256";var nodeMethod=function(e){if(typeof e==="string"){return crypto.createHash(algorithm).update(e,"utf8").digest("hex")}else{if(e===null||e===undefined){throw new Error(ERROR)}else if(e.constructor===ArrayBuffer){e=new Uint8Array(e)}}if(Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer){return crypto.createHash(algorithm).update(new Buffer(e)).digest("hex")}else{return method(e)}};return nodeMethod};var createHmacOutputMethod=function(e,t){return function(n,r){return new HmacSha256(n,t,true).update(r)[e]()}};var createHmacMethod=function(e){var t=createHmacOutputMethod("hex",e);t.create=function(t){return new HmacSha256(t,e)};t.update=function(e,n){return t.create(e).update(n)};for(var n=0;n<OUTPUT_TYPES.length;++n){var r=OUTPUT_TYPES[n];t[r]=createHmacOutputMethod(r,e)}return t};function Sha256(e,t){if(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}else{this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}if(e){this.h0=3238371032;this.h1=914150663;this.h2=812702999;this.h3=4144912697;this.h4=4290775857;this.h5=1750603025;this.h6=1694076839;this.h7=3204075428}else{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=false;this.first=true;this.is224=e}Sha256.prototype.update=function(e){if(this.finalized){return}var t,n=typeof e;if(n!=="string"){if(n==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}t=true}var r,i=0,a,o=e.length,s=this.blocks;while(i<o){if(this.hashed){this.hashed=false;s[0]=this.block;s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0}if(t){for(a=this.start;i<o&&a<64;++i){s[a>>2]|=e[i]<<SHIFT[a++&3]}}else{for(a=this.start;i<o&&a<64;++i){r=e.charCodeAt(i);if(r<128){s[a>>2]|=r<<SHIFT[a++&3]}else if(r<2048){s[a>>2]|=(192|r>>6)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}else if(r<55296||r>=57344){s[a>>2]|=(224|r>>12)<<SHIFT[a++&3];s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}else{r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023);s[a>>2]|=(240|r>>18)<<SHIFT[a++&3];s[a>>2]|=(128|r>>12&63)<<SHIFT[a++&3];s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3];s[a>>2]|=(128|r&63)<<SHIFT[a++&3]}}}this.lastByteIndex=a;this.bytes+=a-this.start;if(a>=64){this.block=s[16];this.start=a-64;this.hash();this.hashed=true}else{this.start=a}}if(this.bytes>4294967295){this.hBytes+=this.bytes/4294967296<<0;this.bytes=this.bytes%4294967296}return this};Sha256.prototype.finalize=function(){if(this.finalized){return}this.finalized=true;var e=this.blocks,t=this.lastByteIndex;e[16]=this.block;e[t>>2]|=EXTRA[t&3];this.block=e[16];if(t>=56){if(!this.hashed){this.hash()}e[0]=this.block;e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0}e[14]=this.hBytes<<3|this.bytes>>>29;e[15]=this.bytes<<3;this.hash()};Sha256.prototype.hash=function(){var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7,c=this.blocks,u,l,f,d,h,p,y,v,g,m,w;for(u=16;u<64;++u){h=c[u-15];l=(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3;h=c[u-2];f=(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10;c[u]=c[u-16]+l+c[u-7]+f<<0}w=t&n;for(u=0;u<64;u+=4){if(this.first){if(this.is224){v=300032;h=c[0]-1413257819;s=h-150054599<<0;r=h+24177077<<0}else{v=704751109;h=c[0]-210244248;s=h-1521486534<<0;r=h+143694565<<0}this.first=false}else{l=(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10);f=(i>>>6|i<<26)^(i>>>11|i<<21)^(i>>>25|i<<7);v=e&t;d=v^e&n^w;y=i&a^~i&o;h=s+f+y+K[u]+c[u];p=l+d;s=r+h<<0;r=h+p<<0}l=(r>>>2|r<<30)^(r>>>13|r<<19)^(r>>>22|r<<10);f=(s>>>6|s<<26)^(s>>>11|s<<21)^(s>>>25|s<<7);g=r&e;d=g^r&t^v;y=s&i^~s&a;h=o+f+y+K[u+1]+c[u+1];p=l+d;o=n+h<<0;n=h+p<<0;l=(n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10);f=(o>>>6|o<<26)^(o>>>11|o<<21)^(o>>>25|o<<7);m=n&r;d=m^n&e^g;y=o&s^~o&i;h=a+f+y+K[u+2]+c[u+2];p=l+d;a=t+h<<0;t=h+p<<0;l=(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);w=t&n;d=w^t&r^m;y=a&o^~a&s;h=i+f+y+K[u+3]+c[u+3];p=l+d;i=e+h<<0;e=h+p<<0}this.h0=this.h0+e<<0;this.h1=this.h1+t<<0;this.h2=this.h2+n<<0;this.h3=this.h3+r<<0;this.h4=this.h4+i<<0;this.h5=this.h5+a<<0;this.h6=this.h6+o<<0;this.h7=this.h7+s<<0};Sha256.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7;var c=HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>4&15]+HEX_CHARS[e&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[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[i>>28&15]+HEX_CHARS[i>>24&15]+HEX_CHARS[i>>20&15]+HEX_CHARS[i>>16&15]+HEX_CHARS[i>>12&15]+HEX_CHARS[i>>8&15]+HEX_CHARS[i>>4&15]+HEX_CHARS[i&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[o>>28&15]+HEX_CHARS[o>>24&15]+HEX_CHARS[o>>20&15]+HEX_CHARS[o>>16&15]+HEX_CHARS[o>>12&15]+HEX_CHARS[o>>8&15]+HEX_CHARS[o>>4&15]+HEX_CHARS[o&15];if(!this.is224){c+=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]}return c};Sha256.prototype.toString=Sha256.prototype.hex;Sha256.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3,i=this.h4,a=this.h5,o=this.h6,s=this.h7;var c=[e>>24&255,e>>16&255,e>>8&255,e&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,r>>24&255,r>>16&255,r>>8&255,r&255,i>>24&255,i>>16&255,i>>8&255,i&255,a>>24&255,a>>16&255,a>>8&255,a&255,o>>24&255,o>>16&255,o>>8&255,o&255];if(!this.is224){c.push(s>>24&255,s>>16&255,s>>8&255,s&255)}return c};Sha256.prototype.array=Sha256.prototype.digest;Sha256.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(this.is224?28:32);var t=new DataView(e);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);if(!this.is224){t.setUint32(28,this.h7)}return e};function HmacSha256(e,t,n){var r,i=typeof e;if(i==="string"){var a=[],o=e.length,s=0,c;for(r=0;r<o;++r){c=e.charCodeAt(r);if(c<128){a[s++]=c}else if(c<2048){a[s++]=192|c>>6;a[s++]=128|c&63}else if(c<55296||c>=57344){a[s++]=224|c>>12;a[s++]=128|c>>6&63;a[s++]=128|c&63}else{c=65536+((c&1023)<<10|e.charCodeAt(++r)&1023);a[s++]=240|c>>18;a[s++]=128|c>>12&63;a[s++]=128|c>>6&63;a[s++]=128|c&63}}e=a}else{if(i==="object"){if(e===null){throw new Error(ERROR)}else if(ARRAY_BUFFER&&e.constructor===ArrayBuffer){e=new Uint8Array(e)}else if(!Array.isArray(e)){if(!ARRAY_BUFFER||!ArrayBuffer.isView(e)){throw new Error(ERROR)}}}else{throw new Error(ERROR)}}if(e.length>64){e=new Sha256(t,true).update(e).array()}var u=[],l=[];for(r=0;r<64;++r){var f=e[r]||0;u[r]=92^f;l[r]=54^f}Sha256.call(this,t,n);this.update(l);this.oKeyPad=u;this.inner=true;this.sharedMemory=n}HmacSha256.prototype=new Sha256;HmacSha256.prototype.finalize=function(){Sha256.prototype.finalize.call(this);if(this.inner){this.inner=false;var e=this.array();Sha256.call(this,this.is224,this.sharedMemory);this.update(this.oKeyPad);this.update(e);Sha256.prototype.finalize.call(this)}};var exports=createMethod();exports.sha256=exports;exports.sha224=createMethod(true);exports.sha256.hmac=createHmacMethod();exports.sha224.hmac=createHmacMethod(true);if(COMMON_JS){module.exports=exports}else{root.sha256=exports.sha256;root.sha224=exports.sha224;if(AMD){undefined((function(){return exports}))}}})()})(sha256$2);const sha256$1=sha256$2.exports;var getRandomValues;var rnds8=new Uint8Array(16);function rng(){if(!getRandomValues){getRandomValues=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!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(e){return typeof e==="string"&&REGEX.test(e)}var byteToHex=[];for(var i=0;i<256;++i){byteToHex.push((i+256).toString(16).substr(1))}function stringify(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(n)){throw TypeError("Stringified UUID is invalid")}return n}var _nodeId;var _clockseq;var _lastMSecs=0;var _lastNSecs=0;function v1(e,t,n){var r=t&&n||0;var i=t||new Array(16);e=e||{};var a=e.node||_nodeId;var o=e.clockseq!==undefined?e.clockseq:_clockseq;if(a==null||o==null){var s=e.random||(e.rng||rng)();if(a==null){a=_nodeId=[s[0]|1,s[1],s[2],s[3],s[4],s[5]]}if(o==null){o=_clockseq=(s[6]<<8|s[7])&16383}}var c=e.msecs!==undefined?e.msecs:Date.now();var u=e.nsecs!==undefined?e.nsecs:_lastNSecs+1;var l=c-_lastMSecs+(u-_lastNSecs)/1e4;if(l<0&&e.clockseq===undefined){o=o+1&16383}if((l<0||c>_lastMSecs)&&e.nsecs===undefined){u=0}if(u>=1e4){throw new Error("uuid.v1(): Can't create more than 10M uuids/sec")}_lastMSecs=c;_lastNSecs=u;_clockseq=o;c+=122192928e5;var f=((c&268435455)*1e4+u)%4294967296;i[r++]=f>>>24&255;i[r++]=f>>>16&255;i[r++]=f>>>8&255;i[r++]=f&255;var d=c/4294967296*1e4&268435455;i[r++]=d>>>8&255;i[r++]=d&255;i[r++]=d>>>24&15|16;i[r++]=d>>>16&255;i[r++]=o>>>8|128;i[r++]=o&255;for(var h=0;h<6;++h){i[r+h]=a[h]}return t||stringify(i)}function parse(e){if(!validate(e)){throw TypeError("Invalid UUID")}var t;var n=new Uint8Array(16);n[0]=(t=parseInt(e.slice(0,8),16))>>>24;n[1]=t>>>16&255;n[2]=t>>>8&255;n[3]=t&255;n[4]=(t=parseInt(e.slice(9,13),16))>>>8;n[5]=t&255;n[6]=(t=parseInt(e.slice(14,18),16))>>>8;n[7]=t&255;n[8]=(t=parseInt(e.slice(19,23),16))>>>8;n[9]=t&255;n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255;n[11]=t/4294967296&255;n[12]=t>>>24&255;n[13]=t>>>16&255;n[14]=t>>>8&255;n[15]=t&255;return n}function stringToBytes(e){e=unescape(encodeURIComponent(e));var t=[];for(var n=0;n<e.length;++n){t.push(e.charCodeAt(n))}return t}var DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8";var URL$1="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function v35(e,t,n){function r(e,r,i,a){if(typeof e==="string"){e=stringToBytes(e)}if(typeof r==="string"){r=parse(r)}if(r.length!==16){throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)")}var o=new Uint8Array(16+e.length);o.set(r);o.set(e,r.length);o=n(o);o[6]=o[6]&15|t;o[8]=o[8]&63|128;if(i){a=a||0;for(var s=0;s<16;++s){i[a+s]=o[s]}return i}return stringify(o)}try{r.name=e}catch(e){}r.DNS=DNS;r.URL=URL$1;return r}function md5(e){if(typeof e==="string"){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n){e[n]=t.charCodeAt(n)}}return md5ToHexEncodedArray(wordsToMd5(bytesToWords(e),e.length*8))}function md5ToHexEncodedArray(e){var t=[];var n=e.length*32;var r="0123456789abcdef";for(var i=0;i<n;i+=8){var a=e[i>>5]>>>i%32&255;var o=parseInt(r.charAt(a>>>4&15)+r.charAt(a&15),16);t.push(o)}return t}function getOutputLength(e){return(e+64>>>9<<4)+14+1}function wordsToMd5(e,t){e[t>>5]|=128<<t%32;e[getOutputLength(t)-1]=t;var n=1732584193;var r=-271733879;var i=-1732584194;var a=271733878;for(var o=0;o<e.length;o+=16){var s=n;var c=r;var u=i;var l=a;n=md5ff(n,r,i,a,e[o],7,-680876936);a=md5ff(a,n,r,i,e[o+1],12,-389564586);i=md5ff(i,a,n,r,e[o+2],17,606105819);r=md5ff(r,i,a,n,e[o+3],22,-1044525330);n=md5ff(n,r,i,a,e[o+4],7,-176418897);a=md5ff(a,n,r,i,e[o+5],12,1200080426);i=md5ff(i,a,n,r,e[o+6],17,-1473231341);r=md5ff(r,i,a,n,e[o+7],22,-45705983);n=md5ff(n,r,i,a,e[o+8],7,1770035416);a=md5ff(a,n,r,i,e[o+9],12,-1958414417);i=md5ff(i,a,n,r,e[o+10],17,-42063);r=md5ff(r,i,a,n,e[o+11],22,-1990404162);n=md5ff(n,r,i,a,e[o+12],7,1804603682);a=md5ff(a,n,r,i,e[o+13],12,-40341101);i=md5ff(i,a,n,r,e[o+14],17,-1502002290);r=md5ff(r,i,a,n,e[o+15],22,1236535329);n=md5gg(n,r,i,a,e[o+1],5,-165796510);a=md5gg(a,n,r,i,e[o+6],9,-1069501632);i=md5gg(i,a,n,r,e[o+11],14,643717713);r=md5gg(r,i,a,n,e[o],20,-373897302);n=md5gg(n,r,i,a,e[o+5],5,-701558691);a=md5gg(a,n,r,i,e[o+10],9,38016083);i=md5gg(i,a,n,r,e[o+15],14,-660478335);r=md5gg(r,i,a,n,e[o+4],20,-405537848);n=md5gg(n,r,i,a,e[o+9],5,568446438);a=md5gg(a,n,r,i,e[o+14],9,-1019803690);i=md5gg(i,a,n,r,e[o+3],14,-187363961);r=md5gg(r,i,a,n,e[o+8],20,1163531501);n=md5gg(n,r,i,a,e[o+13],5,-1444681467);a=md5gg(a,n,r,i,e[o+2],9,-51403784);i=md5gg(i,a,n,r,e[o+7],14,1735328473);r=md5gg(r,i,a,n,e[o+12],20,-1926607734);n=md5hh(n,r,i,a,e[o+5],4,-378558);a=md5hh(a,n,r,i,e[o+8],11,-2022574463);i=md5hh(i,a,n,r,e[o+11],16,1839030562);r=md5hh(r,i,a,n,e[o+14],23,-35309556);n=md5hh(n,r,i,a,e[o+1],4,-1530992060);a=md5hh(a,n,r,i,e[o+4],11,1272893353);i=md5hh(i,a,n,r,e[o+7],16,-155497632);r=md5hh(r,i,a,n,e[o+10],23,-1094730640);n=md5hh(n,r,i,a,e[o+13],4,681279174);a=md5hh(a,n,r,i,e[o],11,-358537222);i=md5hh(i,a,n,r,e[o+3],16,-722521979);r=md5hh(r,i,a,n,e[o+6],23,76029189);n=md5hh(n,r,i,a,e[o+9],4,-640364487);a=md5hh(a,n,r,i,e[o+12],11,-421815835);i=md5hh(i,a,n,r,e[o+15],16,530742520);r=md5hh(r,i,a,n,e[o+2],23,-995338651);n=md5ii(n,r,i,a,e[o],6,-198630844);a=md5ii(a,n,r,i,e[o+7],10,1126891415);i=md5ii(i,a,n,r,e[o+14],15,-1416354905);r=md5ii(r,i,a,n,e[o+5],21,-57434055);n=md5ii(n,r,i,a,e[o+12],6,1700485571);a=md5ii(a,n,r,i,e[o+3],10,-1894986606);i=md5ii(i,a,n,r,e[o+10],15,-1051523);r=md5ii(r,i,a,n,e[o+1],21,-2054922799);n=md5ii(n,r,i,a,e[o+8],6,1873313359);a=md5ii(a,n,r,i,e[o+15],10,-30611744);i=md5ii(i,a,n,r,e[o+6],15,-1560198380);r=md5ii(r,i,a,n,e[o+13],21,1309151649);n=md5ii(n,r,i,a,e[o+4],6,-145523070);a=md5ii(a,n,r,i,e[o+11],10,-1120210379);i=md5ii(i,a,n,r,e[o+2],15,718787259);r=md5ii(r,i,a,n,e[o+9],21,-343485551);n=safeAdd(n,s);r=safeAdd(r,c);i=safeAdd(i,u);a=safeAdd(a,l)}return[n,r,i,a]}function bytesToWords(e){if(e.length===0){return[]}var t=e.length*8;var n=new Uint32Array(getOutputLength(t));for(var r=0;r<t;r+=8){n[r>>5]|=(e[r/8]&255)<<r%32}return n}function safeAdd(e,t){var n=(e&65535)+(t&65535);var r=(e>>16)+(t>>16)+(n>>16);return r<<16|n&65535}function bitRotateLeft(e,t){return e<<t|e>>>32-t}function md5cmn(e,t,n,r,i,a){return safeAdd(bitRotateLeft(safeAdd(safeAdd(t,e),safeAdd(r,a)),i),n)}function md5ff(e,t,n,r,i,a,o){return md5cmn(t&n|~t&r,e,t,i,a,o)}function md5gg(e,t,n,r,i,a,o){return md5cmn(t&r|n&~r,e,t,i,a,o)}function md5hh(e,t,n,r,i,a,o){return md5cmn(t^n^r,e,t,i,a,o)}function md5ii(e,t,n,r,i,a,o){return md5cmn(n^(t|~r),e,t,i,a,o)}var v3=v35("v3",48,md5);function v4(e,t,n){e=e||{};var r=e.random||(e.rng||rng)();r[6]=r[6]&15|64;r[8]=r[8]&63|128;if(t){n=n||0;for(var i=0;i<16;++i){t[n+i]=r[i]}return t}return stringify(r)}function f(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:return t^n^r;case 2:return t&n^t&r^n&r;case 3:return t^n^r}}function ROTL(e,t){return e<<t|e>>>32-t}function sha1(e){var t=[1518500249,1859775393,2400959708,3395469782];var n=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof e==="string"){var r=unescape(encodeURIComponent(e));e=[];for(var i=0;i<r.length;++i){e.push(r.charCodeAt(i))}}else if(!Array.isArray(e)){e=Array.prototype.slice.call(e)}e.push(128);var a=e.length/4+2;var o=Math.ceil(a/16);var s=new Array(o);for(var c=0;c<o;++c){var u=new Uint32Array(16);for(var l=0;l<16;++l){u[l]=e[c*64+l*4]<<24|e[c*64+l*4+1]<<16|e[c*64+l*4+2]<<8|e[c*64+l*4+3]}s[c]=u}s[o-1][14]=(e.length-1)*8/Math.pow(2,32);s[o-1][14]=Math.floor(s[o-1][14]);s[o-1][15]=(e.length-1)*8&4294967295;for(var d=0;d<o;++d){var h=new Uint32Array(80);for(var p=0;p<16;++p){h[p]=s[d][p]}for(var y=16;y<80;++y){h[y]=ROTL(h[y-3]^h[y-8]^h[y-14]^h[y-16],1)}var v=n[0];var g=n[1];var m=n[2];var w=n[3];var _=n[4];for(var b=0;b<80;++b){var E=Math.floor(b/20);var R=ROTL(v,5)+f(E,g,m,w)+_+t[E]+h[b]>>>0;_=w;w=m;m=ROTL(g,30)>>>0;g=v;v=R}n[0]=n[0]+v>>>0;n[1]=n[1]+g>>>0;n[2]=n[2]+m>>>0;n[3]=n[3]+w>>>0;n[4]=n[4]+_>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,n[0]&255,n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,n[1]&255,n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,n[2]&255,n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,n[3]&255,n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,n[4]&255]}var v5=v35("v5",80,sha1);const nil="00000000-0000-0000-0000-000000000000";function version$1(e){if(!validate(e)){throw TypeError("Invalid UUID")}return parseInt(e.substr(14,1),16)}async function getBytes(e,t){const n=e.getReader();let r;while(!(r=await n.read()).done){t(r.value)}}function getLines(e){let t;let n;let r;let i=false;return function a(o){if(t===undefined){t=o;n=0;r=-1}else{t=concat(t,o)}const s=t.length;let c=0;while(n<s){if(i){if(t[n]===10){c=++n}i=false}let a=-1;for(;n<s&&a===-1;++n){switch(t[n]){case 58:if(r===-1){r=n-c}break;case 13:i=true;case 10:a=n;break}}if(a===-1){break}e(t.subarray(c,a),r);c=n;r=-1}if(c===s){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function getMessages(e,t,n){let r=newMessage();const i=new TextDecoder;return function a(o,s){if(o.length===0){n===null||n===void 0?void 0:n(r);r=newMessage()}else if(s>0){const n=i.decode(o.subarray(0,s));const a=s+(o[s+1]===32?2:1);const c=i.decode(o.subarray(a));switch(n){case"data":r.data=r.data?r.data+"\n"+c:c;break;case"event":r.event=c;break;case"id":e(r.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(r.retry=n)}break}}}}function concat(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function newMessage(){return{data:"",event:"",id:"",retry:undefined}}var __rest=undefined&&undefined.__rest||function(e,t){var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0)n[r]=e[r];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++){if(t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i]))n[r[i]]=e[r[i]]}return n};const EventStreamContentType="text/event-stream";const DefaultRetryInterval=1e3;const LastEventId="last-event-id";function fetchEventSource(e,t){var{signal:n,headers:r,onopen:i,onmessage:a,onclose:o,onerror:s,openWhenHidden:c,fetch:u}=t,l=__rest(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,f)=>{const d=Object.assign({},r);if(!d.accept){d.accept=EventStreamContentType}let h;function p(){h.abort();if(!document.hidden){_()}}if(!c){document.addEventListener("visibilitychange",p)}let y=DefaultRetryInterval;let v=0;function g(){document.removeEventListener("visibilitychange",p);window.clearTimeout(v);h.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{g();t()}));const m=u!==null&&u!==void 0?u:window.fetch;const w=i!==null&&i!==void 0?i:defaultOnOpen;async function _(){var n;h=new AbortController;try{const n=await m(e,Object.assign(Object.assign({},l),{headers:d,signal:h.signal}));await w(n);await getBytes(n.body,getLines(getMessages((e=>{if(e){d[LastEventId]=e}else{delete d[LastEventId]}}),(e=>{y=e}),a)));o===null||o===void 0?void 0:o();g();t()}catch(e){if(!h.signal.aborted){try{const t=(n=s===null||s===void 0?void 0:s(e))!==null&&n!==void 0?n:y;window.clearTimeout(v);v=window.setTimeout(_,t)}catch(e){g();f(e)}}}}_()}))}function defaultOnOpen(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(EventStreamContentType))){throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${t}`)}}function Base64EncodeUrl(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Base64DecodeUrl(e){e=(e+"===").slice(0,e.length+e.length%4);return e.replace(/-/g,"+").replace(/_/g,"/")}function getTimestamp(){return Math.floor(Date.now()/1e3)}async function sha256(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const r=Array.from(new Uint8Array(n));const i=r.map((e=>e.toString(16).padStart(2,"0"))).join("");return i}function e(e){this.message=e}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r$1="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var n=String(t).replace(/=+$/,"");if(n.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,i,a=0,o=0,s="";i=n.charAt(o++);~i&&(r=a%4?64*r+i:i,a++%4)?s+=String.fromCharCode(255&r>>(-2*a&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return s};function t$1(e){var t=e.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(e){return decodeURIComponent(r$1(e).replace(/(.)/g,(function(e,t){var n=t.charCodeAt(0).toString(16).toUpperCase();return n.length<2&&(n="0"+n),"%"+n})))}(t)}catch(e){return r$1(t)}}function n$1(e){this.message=e}function o(e,t){if("string"!=typeof e)throw new n$1("Invalid token specified");var n=!0===(t=t||{}).header?0:1;try{return JSON.parse(t$1(e.split(".")[n]))}catch(e){throw new n$1("Invalid token specified: "+e.message)}}n$1.prototype=new Error,n$1.prototype.name="InvalidTokenError";class NylasSessions{clientId;redirectUri;accessType="online";domain="http://api.nylas.com";versioned=false;Storage;hosted=false;multiAccount=false;loginId="";constructor(e){this.clientId=e.clientId;this.redirectUri=e.redirectUri;if(e.domain){this.domain=e.domain;const t=this.domain.substring(this.domain.length-3);if(t.includes("/v")){this.versioned=true}}if(e.multiAccount){this.multiAccount=e.multiAccount}if(e.sw){const e=new IndexedDBStorage;this.Storage=new Storage(e)}else{this.Storage=new Storage}if(e.accessType){this.accessType=e.accessType}if(e.loginId){this.loginId=e.loginId}if(e.hosted){this.hosted=e.hosted}if(e.disableInitCodeExchange!==true){this.codeExchange(null)}}async validateAccessToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{access_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?access_token=${n}`,{method:"GET"});const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}async validateIDToken(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const{id_token:n}=t;try{const e=await fetch(`${this.domain}/connect/tokeninfo?id_token=${n}`,{method:"GET"});if(e.status!==200){return false}const t=await e.json();if(!t.data){return false}return true}catch(e){return false}}getDomain(){return this.domain}async auth(e){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){await this.hostedSetCodeChallenge()}const t=await this.generateAuthURL(e);if(e.popup){this.popUp(t);return}return t}async generateAuthURL(e){const t=await this.getCodeChallege();let n=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(t){n+=`&code_challenge=${t}&code_challenge_method=S256&options=rotate_refresh_token`}if(e.provider){n+=`&provider=${e.provider}`}if(e.loginHint){n+=`&login_hint=${e.loginHint}`;if(e.includeGrantScopes){n+=`&include_grant_scopes=${e.includeGrantScopes}`}}if(e.scope){n+=`&scope=${e.scope.join(" ")}`}if(e.prompt){n+=`&prompt=${e.prompt}`}if(e.metadata){n+=`&metadata=${e.metadata}`}if(e.state||this.loginId){n+=`&state=${this.loginId?this.loginId:e.state}`}return n}async generateReauthURL(e,t){if(!e){throw new Error("Grant ID is required")}const n=await this.Storage.getUserToken(e);const r=await this.getCodeChallege();let i=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(r){i+=`&code_challenge=${r}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){i+=`&provider=${n.provider}`}if(n?.email){i+=`&login_hint=${n.email}`}if(t){i+=`&scope=${t.join(" ")}`}return i}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=v4();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){const e=await this.Storage.getPKCE();if(e){return}console.warn("Code challenge is recomended");return}this.Storage.setPKCE(t)}async getCodeChallege(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){const e=new URLSearchParams(window.location.search);const t=e.get("code_challenge");if(!t){console.warn("Code challenge is recomended");return""}return t}const e=await this.Storage.getPKCE();if(e){const t=sha256$2.exports.sha256(e);let n=Buffer.from(t).toString("base64");n=Base64EncodeUrl(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===window.location.origin||this.versioned&&this.domain.includes(window.location.origin))){return false}const e=await this.Storage.getUserTokens();if(e&&e.length>0){if(this.multiAccount){await this.generateCodeChallenge()}return true}await this.generateCodeChallenge();return false}isMultiAccount(){return this.multiAccount}async logout(){const e=await this.getProfile();await this.Storage.clearSession();const t={detail:e};window.dispatchEvent(new CustomEvent("onLogoutSuccess",t))}async getProfile(e=""){let t;if(e){t=await this.Storage.getUserToken(e)}else{t=await this.Storage.getUserToken()}if(t){return t}return null}async getProfiles(){const e=await this.Storage.getUserTokens();if(e){return e}return null}async removeProfile(e){await this.Storage.removeUserToken(e);await this.Storage.removeGrant(e);return null}async authIMAP(e){const t=await this.getCodeChallege();const n={imap_username:e.imap_username,imap_password:e.imap_password,imap_host:e.imap_host,imap_port:e.imap_port,type:e.type,smtp_host:e.smtp_host,smtp_port:e.smtp_port,provider:e.provider,redirect_uri:this.redirectUri,state:e.state,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(e.smtp_username&&e.smtp_password){n.smtp_username=e.smtp_username;n.smtp_password=e.smtp_password}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const r=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const i=await r.json();return i}async authEWS(e){const t=await this.getCodeChallege();const n={...e,provider:"ews",redirect_uri:this.redirectUri,public_application_id:this.clientId,access_type:this.accessType};if(this.loginId){n.id=this.loginId}if(t!=""){n.code_challenge=t;n.code_challenge_method="S256"}const r=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const i=await r.json();return i}async detectEmail(e){const t=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/providers/detect?client_id=${this.clientId}&email=${e}`,{method:"POST",headers:new Headers({"content-type":"application/json"})});const n=await t.json();return n}async applicationInfo(){const e=await fetch(`${this.versioned?this.domain:this.domain+"/connect"}/applications?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});const t=await e.json();return t.data}async getAvailableProviders(){const e=await fetch(`${this.domain}/connect/providers/find?client_id=${this.clientId}`,{method:"GET",headers:new Headers({"content-type":"application/json"})});if(e){const t=await e.json();const n=t.data;return n}return null}onLoginSuccess(e){window.addEventListener("onLoginSuccess",(t=>e(t)))}onLogoutSuccess(e){window.addEventListener("onLogoutSuccess",(t=>e(t)))}onLoginFail(e){window.addEventListener("onLoginFail",(t=>e(t)))}onTokenRefreshSuccess(e){window.addEventListener("onTokenRefreshSuccess",(t=>e(t)))}onTokenRefreshFail(e){window.addEventListener("onTokenRefreshFail",(t=>e(t)))}onSessionExpired(e){window.addEventListener("onSessionExpired",(t=>e(t)))}async codeExchange(e){let t=new URLSearchParams(window.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const r=t.get("state");const i=t.get("error");const a=t.get("error_description");const o=t.get("error_code");if(i&&a&&o){const e={detail:{error:i,error_description:a,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}if(!n){console.warn("No code found");return false}if(window.opener&&window.name==="uas-popup"){console.warn("Popup window detected");return false}const s=await this.Storage.getPKCE();if(!s){console.warn("No code verifier found");return false}try{const e={client_id:this.clientId,redirect_uri:this.redirectUri,code:n,grant_type:"authorization_code",code_verifier:s};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const i=await t.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(i);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(r){e.data.state=r}const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginSuccess",t));window.history.pushState({},document.title,window.location.pathname)}}this.Storage.removePKCE();return true}catch(i){const e={detail:i};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,window.location.pathname);return false}}async tokenExchange(e=""){const t=await this.Storage.getGrant(e,this.multiAccount);if(!t){return false}const n=t.refresh_token;try{const t={client_id:this.clientId,redirect_uri:this.redirectUri,refresh_token:n,grant_type:"refresh_token"};const r=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const i=await r.json();if(i){if(i.error){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=getTimestamp();i.expires_in=t+i.expires_in;this.Storage.setGrant(i,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const r={detail:i};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",r));return true}this.Storage.removePKCE()}catch(e){const t={detail:e};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",t));return false}}async handleCodeExchangeResponse(e){const t=true;if(e.error){return{data:e,valid:false}}const n=getTimestamp();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const r=o(e.id_token);r.status="authenticated";this.Storage.setUserToken(r);const i=await this.validateIDToken(r.sub);if(!i){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const r=window.screenX+(window.outerWidth-t)/2;const i=window.screenY+(window.outerHeight-n)/2.5;const a=`uas-popup`;const o=e;const s=window.open(o,a,`width=${t},height=${n},left=${r},top=${i}`);if(!s){return}const c=setInterval((async()=>{if(s.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=s.location.href.split("?");if(!e[0]){return}const t=s.location.search;s.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);s.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=getTimestamp();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:r,expires_in:i}=n;const a=r;if(a){if(i&&i>getTimestamp()){const e=i-t;if(e>30){return a}}}await this.tokenExchange(e);const o=await this.Storage.getGrant(e,this.multiAccount);return o.access_token}async sse(e,t){const n=t.headers||{};const r=n["Grant-ID"];let i="";if(this.multiAccount){if(!r){this.logout();throw new Error("Grant ID is required for multi account calls")}i=await this.getAccessToken(r)}else{i=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${i}`;if(!n["content-type"]){n["content-type"]="application/json"}return fetchEventSource(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,r){let i="";let a=1;if(this.multiAccount){if(!t.grant_id){this.logout();throw new Error("Grant ID is required for multi account calls")}const e=await this.getProfiles();a=e?e.length:1;i=await this.getAccessToken(t.grant_id)}else{i=await this.getAccessToken()}if(!i){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${i}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${i}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const i=await fetch(`${r||this.domain}/${e}`,{...t,headers:o});if(!n){return i}const s=await(i?.json());const c=await this.isAuthenticatedResponse(i.status,s);if(!c){if(a>1){const e=await this.getProfile(t.grant_id);if(e){e.status="unauthorized";await this.Storage.setUserToken(e);const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}}else{const e=await this.Storage.getUserToken();const t={detail:{user:e}};window.dispatchEvent(new CustomEvent("onSessionExpired",t))}this.logout();return}return s}catch(e){throw e}}async fetchRequest(e,t,n,r=true,i,a){const o=await this.isLoggedIn();const s=new URL(e,i??this.domain);const c=new Headers;c.append("Accept","application/json");c.append("Content-Type","application/json");c.append("User-Agent","nylas-identity");if(o){const e=await this.getAccessToken();c.append("Authorization",`Bearer ${e}`)}const u=await fetch(s.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:location.origin,body:n?JSON.stringify(n):undefined,...a||{}});if(!r){return u.body}const l=await u.json();return l}async isAuthenticatedResponse(e,t){if(e==401&&t?.error?.type=="token.unauthorized_access"){return false}return true}addAPIKey(e,t,n){this.Storage.setUserToken({aud:"https://api-staging.us.nylas.com/",exp:2e9,email_verified:true,iat:getTimestamp(),iss:"",email:t,provider:"virtual-calendar",status:"authenticated",name:t,sub:e});this.Storage.setGrant({grant_id:e,access_token:n,expires_in:2e9},this.multiAccount)}}var react$1={exports:{}};var react_production_min={};
2
2
  /**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -1,2 +1,2 @@
1
- import{r as e,i as n,h as l,a as o,e as a}from"./index-3e0d6890.js";import{R as s}from"./register-component-3d439a88.js";import{a as t,i as d}from"./utils-3fdf2c83.js";import"./utc-290d564f.js";const r=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:inherit}.nylas-scheduling-method{width:inherit;display:flex;flex-direction:column;margin:1rem;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-200)}.nylas-scheduling-method .header{padding:1rem;border-bottom:1px solid var(--nylas-base-200)}.nylas-scheduling-method .header h3{margin:0;font-size:16px;font-weight:600;line-height:20px;color:var(--nylas-base-900);text-align:left}.nylas-scheduling-method .nylas-scheduling-method__dropdown{padding:1rem;display:flex;flex-direction:column;gap:4px}.nylas-scheduling-method .nylas-scheduling-method__dropdown span.nylas-scheduling-method__dropdown-label{display:flex;align-items:center;gap:4px;color:var(--nylas-base-800);margin:0.25rem 0 0 0;font-size:14px;font-weight:400;line-height:20px;text-align:left}.nylas-scheduling-method .nylas-scheduling-method__dropdown span.nylas-scheduling-method__dropdown-label tooltip-component{display:flex}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown){width:100%}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-content){width:100%;max-width:unset}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-button){width:100%;display:flex;justify-content:space-between;align-items:center;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-button-selected-label){max-width:calc(100% - 2rem);font-family:var(--nylas-font-family);font-size:16px;line-height:24px}.nylas-scheduling-method .nylas-scheduling-method__dropdown input-component::part(ic__input){background:var(--nylas-base-50);outline:none;cursor:not-allowed}';var i=undefined&&undefined.__decorate||function(e,n,l,o){var a=arguments.length,s=a<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,l):o,t;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(e,n,l,o);else for(var d=e.length-1;d>=0;d--)if(t=e[d])s=(a<3?t(s):a>3?t(n,l,s):t(n,l))||s;return a>3&&s&&Object.defineProperty(n,l,s),s};var c=undefined&&undefined.__metadata||function(e,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,n)};const h=class{constructor(l){e(this,l);this.valueChanged=n(this,"valueChanged",7);if(l.$hostElement$["s-ei"]){this.internals=l.$hostElement$["s-ei"]}else{this.internals=l.$hostElement$.attachInternals();l.$hostElement$["s-ei"]=this.internals}this.selectedConfiguration=undefined;this.name="availability-method";this.participantOptions=undefined;this.readOnly=false;this.selectedLanguage=undefined;this.selectedBookingType=""}connectedCallback(){t("nylas-scheduling-method","connectedCallback")}disconnectedCallback(){t("nylas-scheduling-method","disconnectedCallback")}componentWillLoad(){t("nylas-scheduling-method","componentWillLoad");this.host.setAttribute("name",this.name)}componentDidLoad(){t("nylas-scheduling-method","componentDidLoad");const e=this.selectedConfiguration?.availability?.availability_rules?.availability_method?.toString();if(e&&typeof this.internals.setFormValue==="function"){this.internals.setFormValue(e,this.name)}this.selectedBookingType=e||"collective"}componentWillUpdate(){t("nylas-scheduling-method","componentWillUpdate")}componentDidUpdate(){t("nylas-scheduling-method","componentDidUpdate")}componentWillRender(){t("nylas-scheduling-method","componentWillRender")}componentDidRender(){t("nylas-scheduling-method","componentDidRender")}elementNameChangedHandler(e){t("nylas-scheduling-method","elementNameChangedHandler",e);this.host.setAttribute("name",e)}selectedLanguageChangedHandler(e,n){if(e===n)return;d.changeLanguage(e)}selectedConfigurationChangedHandler(e,n){const l=e?.availability?.availability_rules?.availability_method??"collective";this.internals.setFormValue(l,this.name);this.selectedBookingType=l||"collective"}nylasFormDropdownChangedHandler(e){t("nylas-scheduling-method","nylasFormDropdownChangedHandler",e.detail);const n=e=>{const{value:n}=e.detail;if(n){this.selectedBookingType=n;this.internals.setFormValue(n,this.name)}};this.valueChanged.emit({value:e.detail.value,name:this.name,valueChanged:n})}render(){const e=[{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"collective"}),value:"collective"},{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"maxFairness"}),value:"max-fairness"},{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"maxAvailability"}),value:"max-availability"}];const n=this.selectedConfiguration?.availability?.availability_rules?.availability_method?.toString();const a=this.participantOptions&&this.participantOptions?.length>0&&!!this.participantOptions[0].email&&!!this.participantOptions[0].name&&!!this.participantOptions[0].calendars&&this.participantOptions[0].calendars.length>0;if((n||!a)&&!this.readOnly){return null}return l(o,null,l("div",{class:"nylas-scheduling-method",part:"nsm"},l("div",{class:"header",part:"nsm__header"},l("h3",null,d.t("nylasSchedulingMethod.headerTitle"))),l("div",{class:"nylas-scheduling-method__dropdown"},l("span",{class:"nylas-scheduling-method__dropdown-label"},d.t("nylasSchedulingMethod.headerSubTitle"),l("tooltip-component",null,l("info-icon",{slot:"tooltip-icon"}),l("span",{slot:"tooltip-content"},l("strong",null,d.t("nylasSchedulingMethod.tooltip.standard.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.standard.desc"),l("br",null),l("br",null),l("strong",null,d.t("nylasSchedulingMethod.tooltip.maxFairness.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.maxFairness.desc"),l("br",null),l("br",null),l("strong",null,d.t("nylasSchedulingMethod.tooltip.maxAvailability.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.maxAvailability.desc"),l("br",null)))),this.readOnly?l("input-component",{name:"availability-method-read-only",type:"text",exportparts:"ic__label: nsm__input-label, ic__input: nsm__input, ic__input_wrapper: nsm__input_wrapper",readOnly:true,defaultValue:e.find((e=>e.value==n))?.label??e[0].label}):l("select-dropdown",{name:this.name,options:e,withSearch:false,exportparts:"sd_dropdown: nsm__dropdown, sd_dropdown-button: nsm__dropdown-button, sd_dropdown-content: nsm__dropdown-content",defaultSelectedOption:e.find((e=>e.value==n))??e[0]}))))}static get formAssociated(){return true}get host(){return a(this)}static get watchers(){return{name:["elementNameChangedHandler"],selectedLanguage:["selectedLanguageChangedHandler"],selectedConfiguration:["selectedConfigurationChangedHandler"]}}};i([s({name:"nylas-scheduling-method",stateToProps:new Map([["schedulerConfig.selectedConfiguration","selectedConfiguration"],["schedulerConfig.selectedLanguage","selectedLanguage"]]),localPropsToProp:new Map([["additionalParticipants","participantOptions"]]),eventToProps:{valueChanged:async(e,n)=>{const{valueChanged:l}=e.detail;if(l){l(e)}}},fireRegisterEvent:true}),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],h.prototype,"render",null);h.style=r;export{h as nylas_scheduling_method};
1
+ import{r as e,i as n,h as l,a as o,e as a}from"./index-3e0d6890.js";import{R as s}from"./register-component-8b5587d5.js";import{a as t,i as d}from"./utils-ac8fef1e.js";import"./utc-290d564f.js";const r=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:inherit}.nylas-scheduling-method{width:inherit;display:flex;flex-direction:column;margin:1rem;border-radius:var(--nylas-border-radius-2x);border:1px solid var(--nylas-base-200)}.nylas-scheduling-method .header{padding:1rem;border-bottom:1px solid var(--nylas-base-200)}.nylas-scheduling-method .header h3{margin:0;font-size:16px;font-weight:600;line-height:20px;color:var(--nylas-base-900);text-align:left}.nylas-scheduling-method .nylas-scheduling-method__dropdown{padding:1rem;display:flex;flex-direction:column;gap:4px}.nylas-scheduling-method .nylas-scheduling-method__dropdown span.nylas-scheduling-method__dropdown-label{display:flex;align-items:center;gap:4px;color:var(--nylas-base-800);margin:0.25rem 0 0 0;font-size:14px;font-weight:400;line-height:20px;text-align:left}.nylas-scheduling-method .nylas-scheduling-method__dropdown span.nylas-scheduling-method__dropdown-label tooltip-component{display:flex}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown){width:100%}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-content){width:100%;max-width:unset}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-button){width:100%;display:flex;justify-content:space-between;align-items:center;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-2x)}.nylas-scheduling-method .nylas-scheduling-method__dropdown select-dropdown::part(sd_dropdown-button-selected-label){max-width:calc(100% - 2rem);font-family:var(--nylas-font-family);font-size:16px;line-height:24px}.nylas-scheduling-method .nylas-scheduling-method__dropdown input-component::part(ic__input){background:var(--nylas-base-50);outline:none;cursor:not-allowed}';var i=undefined&&undefined.__decorate||function(e,n,l,o){var a=arguments.length,s=a<3?n:o===null?o=Object.getOwnPropertyDescriptor(n,l):o,t;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(e,n,l,o);else for(var d=e.length-1;d>=0;d--)if(t=e[d])s=(a<3?t(s):a>3?t(n,l,s):t(n,l))||s;return a>3&&s&&Object.defineProperty(n,l,s),s};var c=undefined&&undefined.__metadata||function(e,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,n)};const h=class{constructor(l){e(this,l);this.valueChanged=n(this,"valueChanged",7);if(l.$hostElement$["s-ei"]){this.internals=l.$hostElement$["s-ei"]}else{this.internals=l.$hostElement$.attachInternals();l.$hostElement$["s-ei"]=this.internals}this.selectedConfiguration=undefined;this.name="availability-method";this.participantOptions=undefined;this.readOnly=false;this.selectedLanguage=undefined;this.selectedBookingType=""}connectedCallback(){t("nylas-scheduling-method","connectedCallback")}disconnectedCallback(){t("nylas-scheduling-method","disconnectedCallback")}componentWillLoad(){t("nylas-scheduling-method","componentWillLoad");this.host.setAttribute("name",this.name)}componentDidLoad(){t("nylas-scheduling-method","componentDidLoad");const e=this.selectedConfiguration?.availability?.availability_rules?.availability_method?.toString();if(e&&typeof this.internals.setFormValue==="function"){this.internals.setFormValue(e,this.name)}this.selectedBookingType=e||"collective"}componentWillUpdate(){t("nylas-scheduling-method","componentWillUpdate")}componentDidUpdate(){t("nylas-scheduling-method","componentDidUpdate")}componentWillRender(){t("nylas-scheduling-method","componentWillRender")}componentDidRender(){t("nylas-scheduling-method","componentDidRender")}elementNameChangedHandler(e){t("nylas-scheduling-method","elementNameChangedHandler",e);this.host.setAttribute("name",e)}selectedLanguageChangedHandler(e,n){if(e===n)return;d.changeLanguage(e)}selectedConfigurationChangedHandler(e,n){const l=e?.availability?.availability_rules?.availability_method??"collective";this.internals.setFormValue(l,this.name);this.selectedBookingType=l||"collective"}nylasFormDropdownChangedHandler(e){t("nylas-scheduling-method","nylasFormDropdownChangedHandler",e.detail);const n=e=>{const{value:n}=e.detail;if(n){this.selectedBookingType=n;this.internals.setFormValue(n,this.name)}};this.valueChanged.emit({value:e.detail.value,name:this.name,valueChanged:n})}render(){const e=[{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"collective"}),value:"collective"},{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"maxFairness"}),value:"max-fairness"},{label:d.t("nylasSchedulingMethod.schedulingMethodOptions",{context:"maxAvailability"}),value:"max-availability"}];const n=this.selectedConfiguration?.availability?.availability_rules?.availability_method?.toString();const a=this.participantOptions&&this.participantOptions?.length>0&&!!this.participantOptions[0].email&&!!this.participantOptions[0].name&&!!this.participantOptions[0].calendars&&this.participantOptions[0].calendars.length>0;if((n||!a)&&!this.readOnly){return null}return l(o,null,l("div",{class:"nylas-scheduling-method",part:"nsm"},l("div",{class:"header",part:"nsm__header"},l("h3",null,d.t("nylasSchedulingMethod.headerTitle"))),l("div",{class:"nylas-scheduling-method__dropdown"},l("span",{class:"nylas-scheduling-method__dropdown-label"},d.t("nylasSchedulingMethod.headerSubTitle"),l("tooltip-component",null,l("info-icon",{slot:"tooltip-icon"}),l("span",{slot:"tooltip-content"},l("strong",null,d.t("nylasSchedulingMethod.tooltip.standard.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.standard.desc"),l("br",null),l("br",null),l("strong",null,d.t("nylasSchedulingMethod.tooltip.maxFairness.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.maxFairness.desc"),l("br",null),l("br",null),l("strong",null,d.t("nylasSchedulingMethod.tooltip.maxAvailability.label")),l("br",null),"- ",d.t("nylasSchedulingMethod.tooltip.maxAvailability.desc"),l("br",null)))),this.readOnly?l("input-component",{name:"availability-method-read-only",type:"text",exportparts:"ic__label: nsm__input-label, ic__input: nsm__input, ic__input_wrapper: nsm__input_wrapper",readOnly:true,defaultValue:e.find((e=>e.value==n))?.label??e[0].label}):l("select-dropdown",{name:this.name,options:e,withSearch:false,exportparts:"sd_dropdown: nsm__dropdown, sd_dropdown-button: nsm__dropdown-button, sd_dropdown-content: nsm__dropdown-content",defaultSelectedOption:e.find((e=>e.value==n))??e[0]}))))}static get formAssociated(){return true}get host(){return a(this)}static get watchers(){return{name:["elementNameChangedHandler"],selectedLanguage:["selectedLanguageChangedHandler"],selectedConfiguration:["selectedConfigurationChangedHandler"]}}};i([s({name:"nylas-scheduling-method",stateToProps:new Map([["schedulerConfig.selectedConfiguration","selectedConfiguration"],["schedulerConfig.selectedLanguage","selectedLanguage"]]),localPropsToProp:new Map([["additionalParticipants","participantOptions"]]),eventToProps:{valueChanged:async(e,n)=>{const{valueChanged:l}=e.detail;if(l){l(e)}}},fireRegisterEvent:true}),c("design:type",Function),c("design:paramtypes",[]),c("design:returntype",void 0)],h.prototype,"render",null);h.style=r;export{h as nylas_scheduling_method};
2
2
  //# sourceMappingURL=nylas-scheduling-method.entry.js.map
@@ -1,2 +1,2 @@
1
- import{h as e,F as t,r as n,i,a as s,e as a}from"./index-3e0d6890.js";import{n as o,N as r}from"./index.es-69f2eefb.js";import{a as l,i as c,h as d,b as h,j as f}from"./utils-3fdf2c83.js";import{N as g,E as p,C as u}from"./scheduler-store-0acc5e0f.js";import{L as b}from"./constants-794fe173.js";import{i as y,a as m,f as _,c as k,b as w}from"./index-95193d9b.js";import"./utc-290d564f.js";import"./index-89ee2ce0.js";class v{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:n,configId:i,slug:s,clientId:a}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!n&&!i&&!(s||a)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=i;this.sessionId=n;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=a}init(){l("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new g({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}const x=(n,i)=>{const s=n.isLoading;const a=n.showNotification;const o=n.nylasBranding;return e(t,null,a&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&i,e("div",{class:"footer"},o&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true}))))};const I=(t,n)=>e("div",{class:"message-banner"},n);const C=':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-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;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{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;border-left:none}}.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 .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.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}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const B={title:c.t("genericErrorTitle"),type:o.Error,category:p.Component};const D=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.schedulerWillLoad=i(this,"schedulerWillLoad",7);this.schedulerDidLoad=i(this,"schedulerDidLoad",7);this.nylasSchedulerError=i(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=i(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=i(this,"configSettingsLoaded",7);this.bookingRefExtracted=i(this,"bookingRefExtracted",7);this.bookedEventInfo=i(this,"bookedEventInfo",7);this.mode="app";this.defaultSchedulerState=undefined;this.sessionId=undefined;this.schedulerApiUrl="https://api.us.nylas.com";this.bookingInfo=undefined;this.rescheduleBookingRef=undefined;this.cancelBookingRef=undefined;this.organizerConfirmationBookingRef=undefined;this.configurationId=undefined;this.slug=undefined;this.clientId=undefined;this.nylasBranding=true;this.eventOverrides={};this.isLoading=undefined;this.themeConfig=undefined;this.localization=undefined;this.showNotification=true;this.enableUserFeedback=true;this.hour12=undefined;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(navigator.language,{dateStyle:"full"})||`${c.t("noDateSelected")}`;this.refConfigId=undefined;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null}connectedCallback(){l(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){l(`[nylas-scheduler] Component will load`);if(this.enableUserFeedback&&!y()){m({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:"1.4.1",integrations:e=>[...e.filter((e=>false)),_({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}this.stores={scheduler:u({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,...this.defaultSchedulerState})};this.baseProvider=new r(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let t;if(this.rescheduleBookingRef){const[e,n,i]=d(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.cancelBookingRef){const[e,n,i]=d(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.organizerConfirmationBookingRef){const[e,n,i]=d(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",n);this.stores.scheduler.set("organizerConfirmationSalt",i);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n,salt:i})}if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}const n=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new v({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:n});const i=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){this.baseProvider?.componentDidLoad();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings());if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.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 e=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}}const n=this.baseProvider?.getStore("scheduler");const i=n?.get("configSettings")?.scheduler?.available_days_in_future;const s=n?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(n?.get("showBookingForm")){n?.set("selectedDate",s.start_time);return}}const a=n?.get("selectedDate");const o=n?.get("availability");let r;if(o&&o.length>0){return}if(!a){const e=new Date;const{startTime:t,endTime:n,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(e,i||30);if(e.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,n))}}else{const{startTime:e,endTime:t,endTimeForAvailableDaysInFuture:n}=this.validateAvailableDaysInFuture(a,i||30);if(a.getTime()<n*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(e,t))}}if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!a){let e=new Date;const t=n?.get("availability").find((e=>new Date(e.start_time)>new Date));if(t){e=t.start_time}n?.set("selectedDate",e)}}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e)}rescheduleBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}cancelBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}organizerConfirmationBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in b)){return}c.addResourceBundle(t,"translation",e[t],false,true)}))}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;c.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const n=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:a}=this.validateAvailableDaysInFuture(t,n||30);if(e.defaultPrevented){return}if(i<a&&t.getTime()<a*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const n=this.stores?.scheduler.get("selectedLanguage");const i=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const a=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:a,email_language:n,timezone:i}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const n=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const i=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=i;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const i=e?.data;const a=this.bookedEventInfo.emit({...e,data:{...i,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...i};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(a,this.nylasSchedulerConnector)}return}const a=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!a||"error"in a){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(a?.error)},host:this.host})}const o=a?.data;const r=this.bookedEventInfo.emit({...a,data:{...o,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...o};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=e.detail;this.selectedDateLabel=t?t.toLocaleDateString(this.language,{dateStyle:"full"}):`${c.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const n=e.detail.type;if(n==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:p.Component,type:o.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){const t=k("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const n={eventId:t,message:e.detail.feedback};w(n,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":"1.4.1","nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||B.title,category:e?.category||B.category,type:o.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let e="";if(!this.sessionId){e+=c.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=c.t("sessionIdRequiredErrorMessage")+" "+c.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:c.t("schedulingComponentErrorTitle"),category:p.Component,type:o.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:c.t("invalidTimeslotErrorTitle"),category:p.Component,type:o.Error,description:c.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const n=new Date;const i=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const a=Math.floor(h(n,t).getTime()/1e3);const o=Math.min(a,s);const r=i<n.getTime()/1e3?Math.floor(n.getTime()/1e3):i;return{startTime:r,endTime:o,endTimeForAvailableDaysInFuture:a}}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}render(){const t=this.mode==="app";const n=this.baseProvider?.getStore("scheduler");const i=n?.get("eventInfo");const a=n?.get("showBookingForm");const o=n?.get("cancelledEventInfo");const r=n?.get("cancelBookingId");const l=n?.get("selectedTimeslot");const d=n?.get("rescheduleBookingId");const h=n?.get("organizerConfirmationBookingId");const g=n?.get("rejectBookingId");const p=n?.get("confirmedEventInfo");const u=n?.get("nylasBranding")||this.nylasBranding;const b=n?.get("selectedDate");const y=n?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=b&&this.language?f(b.toLocaleDateString(this.language,{dateStyle:"full"})):`${c.t("noDateSelected")}`;if(t&&(r||g)&&!o){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:l,cancelBookingId:r,rejectBookingId:g,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&h){return e(s,null,e(x,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:h,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&o){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:o,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&p){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:p,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&i&&y){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const n=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const a=this.stores?.scheduler.get("selectedTimeslot");const o=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",i.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);a?.start_time&&h.set("start_time",(new Date(a.start_time).getTime()/1e3).toString());a?.end_time&&h.set("end_time",(new Date(a.end_time).getTime()/1e3).toString());o&&h.set("tz",o);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);n&&h.set("booking_ref",n);this.redirectToCustomUrl(`${y}?${h.toString()}`);return}if(t&&i){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:l,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!i||!!d)&&!a){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(I,null,`${c.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("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("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("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!i&&a){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(I,null,`${c.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("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"})))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return a(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};D.style=C;export{D as nylas_scheduling};
1
+ import{h as e,F as t,r as n,i,a as s,e as a}from"./index-3e0d6890.js";import{n as o,N as r}from"./index.es-82b6efae.js";import{a as l,i as c,h as d,b as h,j as f}from"./utils-ac8fef1e.js";import{N as g,E as p,C as u}from"./scheduler-store-36b93b74.js";import{L as b}from"./constants-794fe173.js";import{i as y,a as m,f as _,c as k,b as w}from"./index-212258bf.js";import"./utc-290d564f.js";import"./index-89ee2ce0.js";class v{constructor({schedulerAPIURL:e,nylasSchedulerStore:t,sessionId:n,configId:i,slug:s,clientId:a}){if(!e){throw new Error("schedulerAPIURL is required")}if(!t){throw new Error("nylasSchedulerStore is required")}if(!n&&!i&&!(s||a)){throw new Error("sessionId is required for private configs. If using public config either pass a configurationId or a combination of slug and clientId.")}if(e==="/"){const t=new URL(window.location.href);e=t.origin}this.configId=i;this.sessionId=n;this.schedulerAPIURL=e;this.nylasSchedulerStore=t;this.slug=s;this.clientId=a}init(){l("NylasConnector init")}get schedulerStore(){return this.nylasSchedulerStore}get scheduler(){if(this._schedulerAPIConnector){return this._schedulerAPIConnector}this._schedulerAPIConnector=new g({schedulerAPIURL:this.schedulerAPIURL,schedulerStore:this.schedulerStore,sessionId:this.sessionId,configId:this.configId,slug:this.slug,clientId:this.clientId});return this._schedulerAPIConnector}resetStores(){this.nylasSchedulerStore.reset()}}const x=(n,i)=>{const s=n.isLoading;const a=n.showNotification;const o=n.nylasBranding;return e(t,null,a&&e("nylas-notification",null),s&&e("div",{class:"loading"},e("div",{class:"left"},e("div",{class:"skeleton"})),e("div",{class:"right"},e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}),e("div",{class:"skeleton"}))),!s&&i,e("div",{class:"footer"},o&&e("a",{href:"https://scheduler.nylas.com?utm_source=powered-by-nylas-logoutm_medium=link&utm_campaign=get-scheduler&utm_id=get-scheduler",class:"powered-by-nylas",target:"_blank",rel:"noreferrer noopener"},"Powered by ",e("span",{class:"sr-only"},"Nylas"),e("nylas-logo",{"aria-hidden":true}))))};const I=(t,n)=>e("div",{class:"message-banner"},n);const C=':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-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;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{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;border-left:none}}.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 .powered-by-nylas{display:flex;align-items:center;text-decoration:none;color:var(--nylas-base-500)}.footer .powered-by-nylas:hover{color:var(--nylas-base-800)}.footer svg{fill:var(--nylas-base-500)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.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}button-component#report-issue{width:auto;position:absolute;bottom:4px;left:16px}nylas-feedback-form{position:absolute;top:0;height:100%;width:100%;display:flex;flex-direction:column;justify-content:center;align-items:center;background:rgba(0, 0, 0, 0.6);z-index:2;border-radius:inherit}';const B={title:c.t("genericErrorTitle"),type:o.Error,category:p.Component};const D=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.schedulerWillLoad=i(this,"schedulerWillLoad",7);this.schedulerDidLoad=i(this,"schedulerDidLoad",7);this.nylasSchedulerError=i(this,"nylasSchedulerError",7);this.nylasSchedulerInfo=i(this,"nylasSchedulerInfo",7);this.configSettingsLoaded=i(this,"configSettingsLoaded",7);this.bookingRefExtracted=i(this,"bookingRefExtracted",7);this.bookedEventInfo=i(this,"bookedEventInfo",7);this.mode="app";this.defaultSchedulerState=undefined;this.sessionId=undefined;this.schedulerApiUrl="https://api.us.nylas.com";this.bookingInfo=undefined;this.rescheduleBookingRef=undefined;this.cancelBookingRef=undefined;this.organizerConfirmationBookingRef=undefined;this.configurationId=undefined;this.slug=undefined;this.clientId=undefined;this.nylasBranding=true;this.eventOverrides={};this.isLoading=undefined;this.themeConfig=undefined;this.localization=undefined;this.showNotification=true;this.enableUserFeedback=true;this.hour12=undefined;this.automaticComponentRegistration=true;this.selectedDateLabel=(new Date).toLocaleDateString(navigator.language,{dateStyle:"full"})||`${c.t("noDateSelected")}`;this.refConfigId=undefined;this.language=navigator.language;this.showFeedbackModal=false;this.bookingInfoConfirmed=null}connectedCallback(){l(`[nylas-scheduler] connectedCallback`)}async componentWillLoad(){l(`[nylas-scheduler] Component will load`);if(this.enableUserFeedback&&!y()){m({dsn:"https://9d5731f1c77ca84c9ed3fb9b3ccf7ee1@o74852.ingest.us.sentry.io/4507889638178816",release:"1.4.3",integrations:e=>[...e.filter((e=>false)),_({colorScheme:"system",autoInject:false})],autoSessionTracking:false,beforeSend:()=>null})}const e=this.schedulerWillLoad.emit(this.host);if("schedulerWillLoad"in this.eventOverrides){await this.eventOverrides.schedulerWillLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}this.stores={scheduler:u({bookingInfo:this.bookingInfo,nylasBranding:this.nylasBranding,themeConfig:this.themeConfig,hour12:this.hour12,...this.defaultSchedulerState})};this.baseProvider=new r(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);this.refConfigId=this.configurationId;let t;if(this.rescheduleBookingRef){const[e,n,i]=d(this.rescheduleBookingRef);this.refConfigId=e;this.stores.scheduler.set("rescheduleBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.cancelBookingRef){const[e,n,i]=d(this.cancelBookingRef);this.refConfigId=e;this.stores.scheduler.set("cancelBookingId",n);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n})}else if(this.organizerConfirmationBookingRef){const[e,n,i]=d(this.organizerConfirmationBookingRef);this.refConfigId=e;this.stores.scheduler.set("organizerConfirmationBookingId",n);this.stores.scheduler.set("organizerConfirmationSalt",i);t=this.bookingRefExtracted.emit({configurationId:e,bookingId:n,salt:i})}if("bookingRefExtracted"in this.eventOverrides){await this.eventOverrides.bookingRefExtracted(t,this.nylasSchedulerConnector);if(t.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}const n=this.baseProvider?.getStore("scheduler");this.nylasSchedulerConnector=new v({schedulerAPIURL:this.schedulerApiUrl,sessionId:this.sessionId,configId:this.refConfigId,slug:this.slug,clientId:this.clientId,nylasSchedulerStore:n});const i=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(i,this.nylasSchedulerConnector);if(i.defaultPrevented){return}}this.baseProvider?.componentWillLoad(this.nylasSchedulerConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){this.baseProvider?.componentDidLoad();const e=this.schedulerDidLoad.emit(this.host);if("schedulerDidLoad"in this.eventOverrides){await this.eventOverrides.schedulerDidLoad(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}if(!this.checkIfSessionIdOrConfigIdExists()){return}this.localizationChanged(this.localization);const t=await(this.nylasSchedulerConnector?.scheduler.getUISettings());if(!t||"error"in t){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(t?.error)},host:this.host});return}else{if("data"in t&&t.data?.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 e=this.configSettingsLoaded.emit({settings:t});if("configSettingsLoaded"in this.eventOverrides){await this.eventOverrides.configSettingsLoaded(e,this.nylasSchedulerConnector);if(e.defaultPrevented){return}}}const n=this.baseProvider?.getStore("scheduler");const i=n?.get("configSettings")?.scheduler?.available_days_in_future;const s=n?.get("selectedTimeslot");if(s&&s?.start_time){if(!this.isTimeslotValid(s)){return}if(n?.get("showBookingForm")){n?.set("selectedDate",s.start_time);return}}const a=n?.get("selectedDate");const o=n?.get("availability");let r;if(o&&o.length>0){return}if(!a){const e=new Date;const{startTime:t,endTime:n,endTimeForAvailableDaysInFuture:s}=this.validateAvailableDaysInFuture(e,i||30);if(e.getTime()<s*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(t,n))}}else{const{startTime:e,endTime:t,endTimeForAvailableDaysInFuture:n}=this.validateAvailableDaysInFuture(a,i||30);if(a.getTime()<n*1e3){r=await(this.nylasSchedulerConnector?.scheduler.getAvailability(e,t))}}if(!r||"error"in r){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(r?.error)},host:this.host})}if(!a){let e=new Date;const t=n?.get("availability").find((e=>new Date(e.start_time)>new Date));if(t){e=t.start_time}n?.set("selectedDate",e)}}componentDisconnected(){this.baseProvider?.componentDisconnected()}bookingInfoChanged(e){this.stores?.scheduler.set("bookingInfo",e)}rescheduleBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("rescheduleBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}cancelBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("cancelBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}organizerConfirmationBookingRefChanged(e){if(e){const[t,n]=d(e);this.stores?.scheduler.set("organizerConfirmationBookingId",n);this.refConfigId=t;this.nylasSchedulerConnector?.scheduler.setConfigId(t)}}localizationChanged(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in b)){return}c.addResourceBundle(t,"translation",e[t],false,true)}))}themeConfigChanged(e){this.baseProvider?.getStore("scheduler")?.set("themeConfig",e);this.applyThemeConfig(e)}languageChanged(e){const t=e.detail;this.language=t;c.changeLanguage(t)}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}async monthChangedHandler(e){const t=e.detail;const n=this.nylasSchedulerConnector?.schedulerStore?.get("configSettings")?.scheduler?.available_days_in_future;const{startTime:i,endTime:s,endTimeForAvailableDaysInFuture:a}=this.validateAvailableDaysInFuture(t,n||30);if(e.defaultPrevented){return}if(i<a&&t.getTime()<a*1e3){const e=await(this.nylasSchedulerConnector?.scheduler.getAvailability(i,s));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const t=this.stores?.scheduler.get("selectableDates");if(t&&t.length>0){this.stores?.scheduler.set("selectedDate",t[0])}}}mapToBookingData(e){const t=this.stores?.scheduler.get("selectedTimeslot");const n=this.stores?.scheduler.get("selectedLanguage");const i=this.stores?.scheduler.get("selectedTimezone");const s=t?.start_time?new Date(t?.start_time).getTime()/1e3:"";const a=t?.end_time?new Date(t?.end_time).getTime()/1e3:"";return{additional_guests:e.guests,guest:{...e.primaryParticipant},additional_fields:{...e.additionalFields},start_time:s,end_time:a,email_language:n,timezone:i}}async bookButtonClickedHandler(e){if(e.defaultPrevented){return}const t=e.detail;const n=this.mapToBookingData(t);this.bookingInfoConfirmed=t;const i=this.nylasSchedulerConnector?.schedulerStore?.get("rescheduleBookingId");const s=i;if(s){const e=await(this.nylasSchedulerConnector?.scheduler.rescheduleBooking(s,t));if(!e||"error"in e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e?.error)},host:this.host})}const i=e?.data;const a=this.bookedEventInfo.emit({...e,data:{...i,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...i};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(a,this.nylasSchedulerConnector)}return}const a=await(this.nylasSchedulerConnector?.scheduler.bookTimeslot(t));if(!a||"error"in a){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(a?.error)},host:this.host})}const o=a?.data;const r=this.bookedEventInfo.emit({...a,data:{...o,...n}});this.bookingInfoConfirmed={...this.bookingInfoConfirmed,...o};if("bookedEventInfo"in this.eventOverrides){await this.eventOverrides.bookedEventInfo(r,this.nylasSchedulerConnector)}}dateSelectedHandler(e){const t=e.detail;this.selectedDateLabel=t?t.toLocaleDateString(this.language,{dateStyle:"full"}):`${c.t("noDateSelected")}`}cancelBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}cancelBookedEventValidationErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}rescheduleBookedEventErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}confirmBookingErrorHandler(e){this.nylasSchedulerError.emit({notification:{...this.getErrorObject(e.detail.error)},host:this.host})}feedbackModalClosedHandler(){this.showFeedbackModal=false}eventIsFullHandler(e){const t=e.detail.error;const n=e.detail.type;if(n==="error"){this.nylasSchedulerError.emit({notification:{...this.getErrorObject({message:t})},host:this.host})}else{this.nylasSchedulerInfo.emit({notification:{title:"Event is full",category:p.Component,type:o.Info,description:"The event you selected is full. Please try a different time.",id:(new Date).getTime().toString(),ttl:3e3},host:this.host})}}feedbackSubmittedHandler(e){const t=k("Scheduling Page User Feedback",{extra:{configId:this.configurationId,slug:this.slug}});const n={eventId:t,message:e.detail.feedback};w(n,{includeReplay:true,captureContext:{tags:{"nylas-web-element":"nylas-scheduling","nylas-web-element-version":"1.4.3","nylas-config-id":this.configurationId,"nylas-slug":this.slug,"host-url":window.location.href},extra:{configId:this.configurationId,slug:this.slug}}});this.showFeedbackModal=false}async getNylasSchedulerStore(){return this.baseProvider?.getStore("scheduler")}async getNylasSchedulerConnector(){return this.nylasSchedulerConnector}async getRef(){return this.host}getErrorObject(e){return{title:e?.title||B.title,category:e?.category||B.category,type:o.Error,description:e?.message||"",id:(new Date).getTime().toString(),ttl:"none"}}checkIfSessionIdOrConfigIdExists(){if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){let e="";if(!this.sessionId){e+=c.t("sessionIdRequiredErrorMessage")}if(!this.sessionId&&!this.refConfigId&&!(this.slug&&this.clientId)){e=c.t("sessionIdRequiredErrorMessage")+" "+c.t("publicConfigErrorMessage")}this.nylasSchedulerError.emit({notification:{title:c.t("schedulingComponentErrorTitle"),category:p.Component,type:o.Error,description:e,id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}isTimeslotValid(e){const t=new Date(e.start_time);if(t<new Date){this.nylasSchedulerError.emit({notification:{title:c.t("invalidTimeslotErrorTitle"),category:p.Component,type:o.Error,description:c.t("invalidTimeslotErrorMessage"),id:(new Date).getTime().toString(),ttl:"none"},host:this.host});return false}return true}validateAvailableDaysInFuture(e,t){const n=new Date;const i=new Date(e.getFullYear(),e.getMonth(),1).getTime()/1e3;const s=new Date(e.getFullYear(),e.getMonth()+1,1).getTime()/1e3;const a=Math.floor(h(n,t).getTime()/1e3);const o=Math.min(a,s);const r=i<n.getTime()/1e3?Math.floor(n.getTime()/1e3):i;return{startTime:r,endTime:o,endTimeForAvailableDaysInFuture:a}}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}onFeedbackClick(e){e.preventDefault();this.showFeedbackModal=true}redirectToCustomUrl(e){window.location.assign(e)}render(){const t=this.mode==="app";const n=this.baseProvider?.getStore("scheduler");const i=n?.get("eventInfo");const a=n?.get("showBookingForm");const o=n?.get("cancelledEventInfo");const r=n?.get("cancelBookingId");const l=n?.get("selectedTimeslot");const d=n?.get("rescheduleBookingId");const h=n?.get("organizerConfirmationBookingId");const g=n?.get("rejectBookingId");const p=n?.get("confirmedEventInfo");const u=n?.get("nylasBranding")||this.nylasBranding;const b=n?.get("selectedDate");const y=n?.get("configSettings")?.scheduler?.confirmation_redirect_url;this.selectedDateLabel=b&&this.language?f(b.toLocaleDateString(this.language,{dateStyle:"full"})):`${c.t("noDateSelected")}`;if(t&&(r||g)&&!o){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancel-flow-page",part:"cancel-flow-page"},e("nylas-cancel-booking-form",{selectedTimeslot:l,cancelBookingId:r,rejectBookingId:g,exportparts:"ncbf, ncbf__icon, ncbf__title, ncbf__description, ncbf__reason-textarea, ncbf__button-cta, ncbf__button-outline, ncbf__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&h){return e(s,null,e(x,null,e("div",{class:"manual-confirmation-page",part:"manual-confirmation-page"},e("nylas-organizer-confirmation-card",{organizerConfirmationBookingId:h,exportparts:"nmcc, nmcc__title, nmcc__description, nmcc__button-cta, nmcc__button-outline"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&o){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"cancelled-event-page"},e("nylas-cancelled-event-card",{cancelledEventInfo:o,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&p){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"cancelled-event-page",part:"confirmed-event-page"},e("nylas-confirmed-event-card",{confirmedEventInfo:p,exportparts:"ncec, ncec__icon, ncec__title, ncec__description, ncec__button-outline, ncec__card"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&i&&y){const e=this.bookingInfoConfirmed?.primaryParticipant;const t=this.bookingInfoConfirmed?.location;const n=this.bookingInfoConfirmed?.booking_ref;const s=this.bookingInfoConfirmed?.additionalFields||{};if(this.bookingInfo&&typeof this.bookingInfo?.additionalFields!=="undefined"){const e=this.bookingInfo.additionalFields;Object.keys(e).forEach((t=>{if(!s[t]&&e?.[t]){s[t]=e[t].value}}))}const a=this.stores?.scheduler.get("selectedTimeslot");const o=this.stores?.scheduler.get("selectedTimezone");const r=this.stores?.scheduler.get("selectedLanguage");const l=this.stores?.scheduler.get("configSettings");const c=this.configurationId?this.configurationId:l?.configuration_id;const d=window.location.search;const h=new URLSearchParams(d);h.set("booking_id",i.booking_id);e?.name&&h.set("name",e.name);e?.email&&h.set("email",e.email);a?.start_time&&h.set("start_time",(new Date(a.start_time).getTime()/1e3).toString());a?.end_time&&h.set("end_time",(new Date(a.end_time).getTime()/1e3).toString());o&&h.set("tz",o);r&&h.set("language",r);s&&h.set("additional_values",JSON.stringify(s));this.slug&&h.set("page_slug",this.slug);c&&h.set("config_id",c);t&&h.set("location",t);n&&h.set("booking_ref",n);this.redirectToCustomUrl(`${y}?${h.toString()}`);return}if(t&&i){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},e("div",{class:"booked-event-page",part:"booked-event-page ns_booked-event-page"},e("nylas-booked-event-card",{selectedTimeslot:l,eventInfo:i,exportparts:"nbec, nbec__title, nbec__card, nbec__description, nbec__button-outline, nbec__cancel-cta, nbec__reschedule-cta"}))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&(!i||!!d)&&!a){const t=this.host.querySelector('[slot="timeslot-picker-cta-label"]');return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(I,null,`${c.t("rescheduleTitle")}`),e("div",{class:"select-date-page",part:"select-date-page ns_select-date-page"},e("div",{class:"left-panel",part:"ns_left-panel"},e("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("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("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("h2",{part:"ns_right-panel__title"},e("calendar-icon",{part:"ns_right-panel__calendar-icon"}),e("span",{id:"selectedDate",part:"ns_right-panel__selected-date"},this.selectedDateLabel)),e("nylas-timeslot-picker",{exportparts:"ntp, ntp__time-picker-wrapper, ntp__timeslots, ntp__timeslot, ntp__timeslot--selected, ntp__button-primary"},t&&e("span",{slot:"timeslot-picker-cta-label"},e("slot",{name:"timeslot-picker-cta-label"})))))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}if(t&&!i&&a){return e(s,null,e(x,{nylasBranding:u,isLoading:this.isLoading,showNotification:this.showNotification},d&&e(I,null,`${c.t("rescheduleTitle")}`),e("div",{class:"additional-data-page",part:"additional-data-page ns_additional-data-page"},e("div",{class:"left-panel ns_left-panel",part:"ns_left-panel"},e("div",{class:"wrapper",part:"ns_left-panel__wrapper"},e("nylas-selected-event-card",{exportparts:"nsec, nsec__card, nsec__icon, nsec__date, nsec__time, nsec__timezone"}))),e("div",{class:`right-panel ${d?"reschedule":""}`,part:`ns_right-panel ${d?"ns_reschedule":""}`},e("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"})))),this.enableUserFeedback&&e("button-component",{id:"report-issue",variant:"basic",onClick:e=>this.onFeedbackClick(e)},e("feedback-icon",null)),this.showFeedbackModal&&e("nylas-feedback-form",null))}return e(s,null,e("slot",null))}get host(){return a(this)}static get watchers(){return{bookingInfo:["bookingInfoChanged"],rescheduleBookingRef:["rescheduleBookingRefChanged"],cancelBookingRef:["cancelBookingRefChanged"],organizerConfirmationBookingRef:["organizerConfirmationBookingRefChanged"],localization:["localizationChanged"],themeConfig:["themeConfigChanged"]}}};D.style=C;export{D as nylas_scheduling};
2
2
  //# sourceMappingURL=nylas-scheduling.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,i as n,h as t,a,e as l}from"./index-3e0d6890.js";import{R as s}from"./register-component-3d439a88.js";import{a as o,i as r}from"./utils-3fdf2c83.js";import{C as c}from"./constants-794fe173.js";import"./utc-290d564f.js";const i=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:inherit}.nylas-select-event-type{height:inherit;overflow-y:auto}.nylas-select-event-type div.header{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--nylas-base-200)}.nylas-select-event-type div.header h2{font-size:18px;padding:0 24px;line-height:24px;margin:0;font-weight:600;color:var(--nylas-base-800)}.nylas-select-event-type div.header button-component button{background:transparent;border:none;cursor:pointer}.nylas-select-event-type div.header button-component button:hover,.nylas-select-event-type div.header button-component button:active{color:var(--nylas-primary);background-color:transparent}.nylas-select-event-type div.header button-component button:disabled{cursor:not-allowed}.nylas-select-event-type div.content{padding:40px}.nylas-select-event-type div.content h3{margin:0 0 32px 0;font-size:18px;line-height:24px;font-weight:600}.nylas-select-event-type div.content div.event-type{display:flex;flex-direction:column;gap:8px}.nylas-select-event-type div.content div.event-type div.event-type-option{padding:16px;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-3x);width:inherit;cursor:pointer;display:flex;flex-direction:column;gap:8px}.nylas-select-event-type div.content div.event-type div.event-type-option h4{margin:0;font-size:16px;line-height:24px;font-weight:600;color:var(--nylas-base-900)}.nylas-select-event-type div.content div.event-type div.event-type-option p{margin:0;font-size:14px;line-height:21px;font-weight:400;color:var(--nylas-base-800)}';var d=undefined&&undefined.__decorate||function(e,n,t,a){var l=arguments.length,s=l<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,t):a,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(e,n,t,a);else for(var r=e.length-1;r>=0;r--)if(o=e[r])s=(l<3?o(s):l>3?o(n,t,s):o(n,t))||s;return l>3&&s&&Object.defineProperty(n,t,s),s};var y=undefined&&undefined.__metadata||function(e,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,n)};const f=class{constructor(t){e(this,t);this.returnToAllSchedulingPagesEvent=n(this,"returnToAllSchedulingPagesEvent",7);this.createEventTypeSelected=n(this,"createEventTypeSelected",7);this.participantOptions=undefined;this.name="select-event-type";this.selectedLanguage=undefined}connectedCallback(){o("nylas-select-event-type","connectedCallback")}disconnectedCallback(){o("nylas-select-event-type","disconnectedCallback")}componentWillLoad(){o("nylas-select-event-type","componentWillLoad");this.host.setAttribute("name",this.name)}componentDidLoad(){o("nylas-select-event-type","componentDidLoad")}elementNameChangedHandler(e){o("nylas-select-event-type","elementNameChangedHandler",e);this.host.setAttribute("name",e)}selectedLanguageChangedHandler(e,n){if(e===n)return;r.changeLanguage(e)}render(){const e=[{label:"1:1",value:c.one_on_one,description:"Allows 1:1 bookings"},{label:"Collective",value:c.collective,description:"Allows n:1 bookings with additional participants"},{label:"Round-Robin Maximize Fairness",value:c.max_fairness,description:"Rotates through the list of participants you select, displaying the participant with the fewest recent bookings."},{label:"Round-Robin Maximize Availability",value:c.max_availability,description:"Rotates through the list of participants you select, prioritizing participants with the fewest recent bookings, but making as many time-slots available as possible."},{label:"Group / Class",value:c.group,description:"These are events which generally have one organizer and multiple participants"}];const n=this.participantOptions&&this.participantOptions?.length>0&&!!this.participantOptions[0].email&&!!this.participantOptions[0].name&&!!this.participantOptions[0].calendars&&this.participantOptions[0].calendars.length>0;const l=[c.collective,c.max_availability,c.max_fairness];const s=[c.one_on_one,c.group];return t(a,{key:"d5aed715d0b33063596b250da816b617301f16f0"},t("div",{key:"679668eaf49d2f68f4338fd1c83f9a27875dec79",class:"nylas-select-event-type",part:"nset"},t("div",{key:"0fa60b4547433bd2e4395c2d05942693eae00ce8",class:"header",part:"nset__header"},t("h2",{key:"348d27d9e2398ef6cda24e53cc9127c7f7b627fe"},"Create an event"),t("button-component",{key:"c4420cd4d2be87567c82178620fe14dbbe3babeb",variant:"invisible",part:"nset__header__back-button",onClick:e=>{this.returnToAllSchedulingPagesEvent.emit()}},t("chevron-icon",{key:"4d7c919f04de328e5ad064eb802f6faa86c67c97",width:"16",height:"16"}),t("span",{key:"40204db0d92e8d1a6458ac8ce23c25222345e8de"},"Return to all scheduling pages"))),t("div",{key:"1bf550eefbb9819f85da9884365c29120d4fa5ab",class:"content",part:"nset__content"},t("h3",{key:"5391f331fe9ffc538ffee32af02e8be056b9eb3b"},"Event type"),t("div",{key:"fe6612a8ee555df7bdaabb0d500a4d6671b03192",class:"event-type",part:"nset__content__event-type"},e.filter((e=>s.includes(e.value)||n&&l.includes(e.value))).map((e=>t("div",{class:"event-type-option",onClick:n=>{this.createEventTypeSelected.emit({eventType:e.value})},part:`nset__content__event-type-option-${e.value}`},t("h4",null,e.label),t("p",null,e.description))))))))}get host(){return l(this)}static get watchers(){return{name:["elementNameChangedHandler"],selectedLanguage:["selectedLanguageChangedHandler"]}}};d([s({name:"nylas-select-event-type",stateToProps:new Map([["schedulerConfig.selectedLanguage","selectedLanguage"],["schedulerConfig.additionalParticipants","participantOptions"]]),eventToProps:{returnToAllSchedulingPagesEvent:async(e,n)=>{n.schedulerConfigStore.state.action=null;n.schedulerConfigStore.set("selectedEventType",undefined)},createEventTypeSelected:async(e,n)=>{const{eventType:t}=e.detail;n.schedulerConfigStore.state.action="create";n.schedulerConfigStore.state.selectedEventType=t}},fireRegisterEvent:true}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],f.prototype,"render",null);f.style=i;export{f as nylas_select_event_type};
1
+ import{r as e,i as n,h as t,a,e as l}from"./index-3e0d6890.js";import{R as s}from"./register-component-8b5587d5.js";import{a as o,i as r}from"./utils-ac8fef1e.js";import{C as c}from"./constants-794fe173.js";import"./utc-290d564f.js";const i=':host{display:block;--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-pressed:#992222;--nylas-wraning:#f06c00;--nylas-success:#16a392;--nylas-info:#2b8fc2;--nylas-base-0:#ffffff;--nylas-base-25:#fcfcfd;--nylas-base-50:#f8f9fc;--nylas-base-100:#eaecf5;--nylas-base-200:#d5d9eb;--nylas-base-300:#b3b8d8;--nylas-base-400:#717bbc;--nylas-base-500:#4e5ba6;--nylas-base-600:#3e4784;--nylas-base-700:#263f72;--nylas-base-800:#293056;--nylas-base-900:#101323;--nylas-base-950:#0e101b;--nylas-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;width:inherit}.nylas-select-event-type{height:inherit;overflow-y:auto}.nylas-select-event-type div.header{display:flex;justify-content:space-between;align-items:center;border-bottom:1px solid var(--nylas-base-200)}.nylas-select-event-type div.header h2{font-size:18px;padding:0 24px;line-height:24px;margin:0;font-weight:600;color:var(--nylas-base-800)}.nylas-select-event-type div.header button-component button{background:transparent;border:none;cursor:pointer}.nylas-select-event-type div.header button-component button:hover,.nylas-select-event-type div.header button-component button:active{color:var(--nylas-primary);background-color:transparent}.nylas-select-event-type div.header button-component button:disabled{cursor:not-allowed}.nylas-select-event-type div.content{padding:40px}.nylas-select-event-type div.content h3{margin:0 0 32px 0;font-size:18px;line-height:24px;font-weight:600}.nylas-select-event-type div.content div.event-type{display:flex;flex-direction:column;gap:8px}.nylas-select-event-type div.content div.event-type div.event-type-option{padding:16px;border:1px solid var(--nylas-base-200);border-radius:var(--nylas-border-radius-3x);width:inherit;cursor:pointer;display:flex;flex-direction:column;gap:8px}.nylas-select-event-type div.content div.event-type div.event-type-option h4{margin:0;font-size:16px;line-height:24px;font-weight:600;color:var(--nylas-base-900)}.nylas-select-event-type div.content div.event-type div.event-type-option p{margin:0;font-size:14px;line-height:21px;font-weight:400;color:var(--nylas-base-800)}';var d=undefined&&undefined.__decorate||function(e,n,t,a){var l=arguments.length,s=l<3?n:a===null?a=Object.getOwnPropertyDescriptor(n,t):a,o;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(e,n,t,a);else for(var r=e.length-1;r>=0;r--)if(o=e[r])s=(l<3?o(s):l>3?o(n,t,s):o(n,t))||s;return l>3&&s&&Object.defineProperty(n,t,s),s};var y=undefined&&undefined.__metadata||function(e,n){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,n)};const f=class{constructor(t){e(this,t);this.returnToAllSchedulingPagesEvent=n(this,"returnToAllSchedulingPagesEvent",7);this.createEventTypeSelected=n(this,"createEventTypeSelected",7);this.participantOptions=undefined;this.name="select-event-type";this.selectedLanguage=undefined}connectedCallback(){o("nylas-select-event-type","connectedCallback")}disconnectedCallback(){o("nylas-select-event-type","disconnectedCallback")}componentWillLoad(){o("nylas-select-event-type","componentWillLoad");this.host.setAttribute("name",this.name)}componentDidLoad(){o("nylas-select-event-type","componentDidLoad")}elementNameChangedHandler(e){o("nylas-select-event-type","elementNameChangedHandler",e);this.host.setAttribute("name",e)}selectedLanguageChangedHandler(e,n){if(e===n)return;r.changeLanguage(e)}render(){const e=[{label:"1:1",value:c.one_on_one,description:"Allows 1:1 bookings"},{label:"Collective",value:c.collective,description:"Allows n:1 bookings with additional participants"},{label:"Round-Robin Maximize Fairness",value:c.max_fairness,description:"Rotates through the list of participants you select, displaying the participant with the fewest recent bookings."},{label:"Round-Robin Maximize Availability",value:c.max_availability,description:"Rotates through the list of participants you select, prioritizing participants with the fewest recent bookings, but making as many time-slots available as possible."},{label:"Group / Class",value:c.group,description:"These are events which generally have one organizer and multiple participants"}];const n=this.participantOptions&&this.participantOptions?.length>0&&!!this.participantOptions[0].email&&!!this.participantOptions[0].name&&!!this.participantOptions[0].calendars&&this.participantOptions[0].calendars.length>0;const l=[c.collective,c.max_availability,c.max_fairness];const s=[c.one_on_one,c.group];return t(a,{key:"d5aed715d0b33063596b250da816b617301f16f0"},t("div",{key:"679668eaf49d2f68f4338fd1c83f9a27875dec79",class:"nylas-select-event-type",part:"nset"},t("div",{key:"0fa60b4547433bd2e4395c2d05942693eae00ce8",class:"header",part:"nset__header"},t("h2",{key:"348d27d9e2398ef6cda24e53cc9127c7f7b627fe"},"Create an event"),t("button-component",{key:"c4420cd4d2be87567c82178620fe14dbbe3babeb",variant:"invisible",part:"nset__header__back-button",onClick:e=>{this.returnToAllSchedulingPagesEvent.emit()}},t("chevron-icon",{key:"4d7c919f04de328e5ad064eb802f6faa86c67c97",width:"16",height:"16"}),t("span",{key:"40204db0d92e8d1a6458ac8ce23c25222345e8de"},"Return to all scheduling pages"))),t("div",{key:"1bf550eefbb9819f85da9884365c29120d4fa5ab",class:"content",part:"nset__content"},t("h3",{key:"5391f331fe9ffc538ffee32af02e8be056b9eb3b"},"Event type"),t("div",{key:"fe6612a8ee555df7bdaabb0d500a4d6671b03192",class:"event-type",part:"nset__content__event-type"},e.filter((e=>s.includes(e.value)||n&&l.includes(e.value))).map((e=>t("div",{class:"event-type-option",onClick:n=>{this.createEventTypeSelected.emit({eventType:e.value})},part:`nset__content__event-type-option-${e.value}`},t("h4",null,e.label),t("p",null,e.description))))))))}get host(){return l(this)}static get watchers(){return{name:["elementNameChangedHandler"],selectedLanguage:["selectedLanguageChangedHandler"]}}};d([s({name:"nylas-select-event-type",stateToProps:new Map([["schedulerConfig.selectedLanguage","selectedLanguage"],["schedulerConfig.additionalParticipants","participantOptions"]]),eventToProps:{returnToAllSchedulingPagesEvent:async(e,n)=>{n.schedulerConfigStore.state.action=null;n.schedulerConfigStore.set("selectedEventType",undefined)},createEventTypeSelected:async(e,n)=>{const{eventType:t}=e.detail;n.schedulerConfigStore.state.action="create";n.schedulerConfigStore.state.selectedEventType=t}},fireRegisterEvent:true}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],f.prototype,"render",null);f.style=i;export{f as nylas_select_event_type};
2
2
  //# sourceMappingURL=nylas-select-event-type.entry.js.map
@@ -1,2 +1,2 @@
1
- import{r as e,h as a,a as n,e as s}from"./index-3e0d6890.js";import{R as l}from"./register-component-3d439a88.js";import{a as o,j as r,k as c}from"./utils-3fdf2c83.js";import{b as t,T as d}from"./constants-794fe173.js";import"./utc-290d564f.js";const i=':host{--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-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;display:block;position:relative;height:inherit;display:flex;flex-direction:column;justify-content:center;align-items:center;font-family:var(--nylas-font-family)}.event-card{display:flex;align-items:center;flex-direction:column;gap:4px;width:calc(100% - 3rem);background-color:var(--nylas-base-0);color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);padding:3rem 1.5rem 1.5rem 1.5rem;position:relative;box-shadow:0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)}@media screen and (max-width: 768px){.event-card{margin-bottom:2rem}}.nylas-selected-event-card__date{font-size:min(max(16px, 3vw), 18px);font-weight:600}.nylas-selected-event-card__time{font-size:16px;font-weight:500}.calendar-icon{width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200)}calendar-icon{display:flex;align-items:center;justify-content:center;height:100%}.event-timezone{display:flex;color:var(--nylas-base-600);margin-bottom:8px;gap:4px;align-items:center}@media screen and (max-width: 768px){.event-timezone{margin-bottom:16px}}';var f=undefined&&undefined.__decorate||function(e,a,n,s){var l=arguments.length,o=l<3?a:s===null?s=Object.getOwnPropertyDescriptor(a,n):s,r;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,a,n,s);else for(var c=e.length-1;c>=0;c--)if(r=e[c])o=(l<3?r(o):l>3?r(a,n,o):r(a,n))||o;return l>3&&o&&Object.defineProperty(a,n,o),o};var y=undefined&&undefined.__metadata||function(e,a){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,a)};const b=class{constructor(a){e(this,a);this.themeConfig=undefined;this.selectedDate=undefined;this.selectedTimeslot=undefined;this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone;this.selectedLanguage=undefined;this.hour12=undefined;this.startTime="";this.endTime=""}themeConfigChanged(e){this.applyThemeConfig(e)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){o(`[nylas-selected-event-card] Component will load`)}async componentDidLoad(){o(`[nylas-selected-event-card] Component did load`);if(!this.selectedDate){console.warn('[nylas-selected-event-card] "selectedDate" prop is not provided.')}if(!this.selectedTimeslot){console.warn('[nylas-selected-event-card] "selectedTimeslot" prop is not provided.')}this.applyThemeConfig(this.themeConfig);const e=t[this.selectedLanguage||"en"];const a=new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit",timeZone:this.selectedTimezone,hour12:this.hour12});this.startTime=a.format(new Date(this.selectedTimeslot?.start_time));this.endTime=a.format(new Date(this.selectedTimeslot?.end_time))}applyThemeConfig(e){if(e){for(const[a,n]of Object.entries(e)){this.host.style.setProperty(`${a}`,n)}}}render(){return a(n,{key:"22b7e4f0f55d7a75188ebd3e8cc009497ad5a598",part:"nsec"},a("div",{key:"0082bd129fe4704e4bf9bcc82ab401f7c50237fe",class:"event-card",part:"nsec__card"},a("div",{key:"37093be5b192f8a8a533cb677b432df2cec80d14",class:"calendar-icon",part:"nsec__icon"},a("calendar-icon",{key:"253a63fa567065c7a12f6fc8b82333568b52b777"})),a("div",{key:"a2d5218bd85c6f94652b0f24a11e68f53a8920d3",class:"nylas-selected-event-card__date",part:"nsec__date"},this.selectedDate?r(c(this.selectedTimeslot?.start_time,this.selectedTimezone,t[this.selectedLanguage||"en"])):"-"),a("div",{key:"2f11d6deedb50cb0d7b3e9791088266e06cdca1e",class:"nylas-selected-event-card__time",part:"nsec__time"},this.startTime," - ",this.endTime)),a("div",{key:"634bd96488b5b1a51064c9bf015b054648f43011",class:"event-timezone",part:"nsec__timezone"},a("globe-icon",{key:"b327dfa7747116da0ab29ddebcb6d20c82a0a80b"}),d[this.selectedTimezone]))}get host(){return s(this)}static get watchers(){return{themeConfig:["themeConfigChanged"]}}};f([l({name:"nylas-selected-event-card",stateToProps:new Map([["scheduler.selectedDate","selectedDate"],["scheduler.selectedTimeslot","selectedTimeslot"],["scheduler.selectedTimezone","selectedTimezone"],["scheduler.selectedLanguage","selectedLanguage"],["scheduler.themeConfig","themeConfig"],["scheduler.hour12","hour12"]]),eventToProps:{},fireRegisterEvent:true}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],b.prototype,"render",null);b.style=i;export{b as nylas_selected_event_card};
1
+ import{r as e,h as a,a as n,e as s}from"./index-3e0d6890.js";import{R as l}from"./register-component-8b5587d5.js";import{a as o,j as r,k as c}from"./utils-ac8fef1e.js";import{b as t,T as d}from"./constants-794fe173.js";import"./utc-290d564f.js";const i=':host{--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-color-blue-100:#e0e6f9;--nylas-border-radius:0.25rem;--nylas-border-radius-2x:0.5rem;--nylas-border-radius-3x:0.75rem;--nylas-font-family:"Inter", sans-serif;--nylas-color-black:#000000;--nylas-color-grey-900:#2c2c2c;--nylas-color-grey-800:#4b4b4b;--nylas-color-grey-700:#6e6e6e;--nylas-color-grey-600:#8e8e8e;--nylas-color-grey-500:#b3b3b3;--nylas-color-grey-400:#cacaca;--nylas-color-grey-300:#e1e1e1;--nylas-color-grey-200:#eaeaea;--nylas-color-grey-100:#f5f5f5;--nylas-color-grey-50:#fbfcfe;--nylas-color-white:#ffffff;--nylas-color-red-900:#992222;--nylas-color-red-700:#cc4841;--nylas-color-red-500:#ff786a;--nylas-color-red-300:#ffa79e;--nylas-color-red-100:#ffc5bf;--nylas-color-red-50:#ffeae8;--nylas-color-blue-900:#213571;--nylas-color-blue-700:#314fa9;--nylas-color-blue-500:#4169e1;--nylas-color-blue-300:#bdccf9;--nylas-color-blue-100:#e0e6f9;--nylas-color-blue-50:#f6f8fd;--nylas-color-yellow-900:#7c6506;--nylas-color-yellow-700:#c29f09;--nylas-color-yellow-500:#f7c90b;--nylas-color-yellow-300:#f9de70;--nylas-color-yellow-100:#fceba9;--nylas-color-yellow-50:#fdf4ce;--nylas-color-green-900:#0e6b60;--nylas-color-green-700:#16a392;--nylas-color-green-500:#17c3b2;--nylas-color-green-300:#74dbd1;--nylas-color-green-100:#a2e7e0;--nylas-color-green-50:#d1f3f0;--nylas-color-purple-900:#643554;--nylas-color-purple-700:#954f7d;--nylas-color-purple-500:#c769a7;--nylas-color-purple-300:#dda5ca;--nylas-color-purple-100:#e0bdd6;--nylas-color-purple-50:#e9dde5;--nylas-color-sky-900:#20698f;--nylas-color-sky-700:#2b8fc2;--nylas-color-sky-500:#6dceff;--nylas-color-sky-300:#8fdaff;--nylas-color-sky-100:#b8e7ff;--nylas-color-sky-50:#d9f2ff;display:block;position:relative;height:inherit;display:flex;flex-direction:column;justify-content:center;align-items:center;font-family:var(--nylas-font-family)}.event-card{display:flex;align-items:center;flex-direction:column;gap:4px;width:calc(100% - 3rem);background-color:var(--nylas-base-0);color:var(--nylas-base-800);border-radius:var(--nylas-border-radius-2x);padding:3rem 1.5rem 1.5rem 1.5rem;position:relative;box-shadow:0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 1px 2px 0px rgba(0, 0, 0, 0.06)}@media screen and (max-width: 768px){.event-card{margin-bottom:2rem}}.nylas-selected-event-card__date{font-size:min(max(16px, 3vw), 18px);font-weight:600}.nylas-selected-event-card__time{font-size:16px;font-weight:500}.calendar-icon{width:3rem;height:3rem;border-radius:50%;position:absolute;top:-1.25rem;left:50%;transform:translateX(-50%);background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200)}calendar-icon{display:flex;align-items:center;justify-content:center;height:100%}.event-timezone{display:flex;color:var(--nylas-base-600);margin-bottom:8px;gap:4px;align-items:center}@media screen and (max-width: 768px){.event-timezone{margin-bottom:16px}}';var f=undefined&&undefined.__decorate||function(e,a,n,s){var l=arguments.length,o=l<3?a:s===null?s=Object.getOwnPropertyDescriptor(a,n):s,r;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,a,n,s);else for(var c=e.length-1;c>=0;c--)if(r=e[c])o=(l<3?r(o):l>3?r(a,n,o):r(a,n))||o;return l>3&&o&&Object.defineProperty(a,n,o),o};var y=undefined&&undefined.__metadata||function(e,a){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,a)};const b=class{constructor(a){e(this,a);this.themeConfig=undefined;this.selectedDate=undefined;this.selectedTimeslot=undefined;this.selectedTimezone=Intl.DateTimeFormat().resolvedOptions().timeZone;this.selectedLanguage=undefined;this.hour12=undefined;this.startTime="";this.endTime=""}themeConfigChanged(e){this.applyThemeConfig(e)}connectedCallback(){}disconnectedCallback(){}async componentWillLoad(){o(`[nylas-selected-event-card] Component will load`)}async componentDidLoad(){o(`[nylas-selected-event-card] Component did load`);if(!this.selectedDate){console.warn('[nylas-selected-event-card] "selectedDate" prop is not provided.')}if(!this.selectedTimeslot){console.warn('[nylas-selected-event-card] "selectedTimeslot" prop is not provided.')}this.applyThemeConfig(this.themeConfig);const e=t[this.selectedLanguage||"en"];const a=new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit",timeZone:this.selectedTimezone,hour12:this.hour12});this.startTime=a.format(new Date(this.selectedTimeslot?.start_time));this.endTime=a.format(new Date(this.selectedTimeslot?.end_time))}applyThemeConfig(e){if(e){for(const[a,n]of Object.entries(e)){this.host.style.setProperty(`${a}`,n)}}}render(){return a(n,{key:"22b7e4f0f55d7a75188ebd3e8cc009497ad5a598",part:"nsec"},a("div",{key:"0082bd129fe4704e4bf9bcc82ab401f7c50237fe",class:"event-card",part:"nsec__card"},a("div",{key:"37093be5b192f8a8a533cb677b432df2cec80d14",class:"calendar-icon",part:"nsec__icon"},a("calendar-icon",{key:"253a63fa567065c7a12f6fc8b82333568b52b777"})),a("div",{key:"a2d5218bd85c6f94652b0f24a11e68f53a8920d3",class:"nylas-selected-event-card__date",part:"nsec__date"},this.selectedDate?r(c(this.selectedTimeslot?.start_time,this.selectedTimezone,t[this.selectedLanguage||"en"])):"-"),a("div",{key:"2f11d6deedb50cb0d7b3e9791088266e06cdca1e",class:"nylas-selected-event-card__time",part:"nsec__time"},this.startTime," - ",this.endTime)),a("div",{key:"634bd96488b5b1a51064c9bf015b054648f43011",class:"event-timezone",part:"nsec__timezone"},a("globe-icon",{key:"b327dfa7747116da0ab29ddebcb6d20c82a0a80b"}),d[this.selectedTimezone]))}get host(){return s(this)}static get watchers(){return{themeConfig:["themeConfigChanged"]}}};f([l({name:"nylas-selected-event-card",stateToProps:new Map([["scheduler.selectedDate","selectedDate"],["scheduler.selectedTimeslot","selectedTimeslot"],["scheduler.selectedTimezone","selectedTimezone"],["scheduler.selectedLanguage","selectedLanguage"],["scheduler.themeConfig","themeConfig"],["scheduler.hour12","hour12"]]),eventToProps:{},fireRegisterEvent:true}),y("design:type",Function),y("design:paramtypes",[]),y("design:returntype",void 0)],b.prototype,"render",null);b.style=i;export{b as nylas_selected_event_card};
2
2
  //# sourceMappingURL=nylas-selected-event-card.entry.js.map