@nylas/web-elements 2.3.0 → 2.3.1-canary-20260108155205

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 (64) hide show
  1. package/dist/cdn/nylas-scheduler-editor/nylas-scheduler-editor.es.js +1 -1
  2. package/dist/cdn/nylas-scheduling/nylas-scheduling.es.js +4941 -4925
  3. package/dist/cjs/google-logo-icon_6.cjs.entry.js +1 -1
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/nylas-booked-event-card_11.cjs.entry.js +8 -0
  6. package/dist/cjs/nylas-booked-event-card_11.cjs.entry.js.map +1 -1
  7. package/dist/cjs/nylas-scheduler-editor.cjs.entry.js +1 -1
  8. package/dist/cjs/nylas-scheduling.cjs.entry.js +16 -3
  9. package/dist/cjs/nylas-scheduling.cjs.entry.js.map +1 -1
  10. package/dist/cjs/nylas-scheduling.entry.cjs.js.map +1 -1
  11. package/dist/cjs/nylas-web-elements.cjs.js +1 -1
  12. package/dist/cjs/{version-DOUE1CF3.js → version-BIKhGgjH.js} +3 -3
  13. package/dist/cjs/{version-DOUE1CF3.js.map → version-BIKhGgjH.js.map} +1 -1
  14. package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js +10 -0
  15. package/dist/collection/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.js.map +1 -1
  16. package/dist/collection/connector/shared/api/scheduler.js +18 -2
  17. package/dist/collection/connector/shared/api/scheduler.js.map +1 -1
  18. package/dist/collection/version.js +1 -1
  19. package/dist/collection/version.js.map +1 -1
  20. package/dist/components/nylas-editor-tabs-group.js +1 -1
  21. package/dist/components/nylas-editor-tabs.js +1 -1
  22. package/dist/components/nylas-scheduler-editor.js +3 -3
  23. package/dist/components/nylas-scheduling.js +18 -5
  24. package/dist/components/nylas-scheduling.js.map +1 -1
  25. package/dist/components/nylas-timeslot-picker.js +1 -1
  26. package/dist/components/{p-Yb-Jmnhb.js → p-CUriRAxu.js} +3 -3
  27. package/dist/components/{p-Yb-Jmnhb.js.map → p-CUriRAxu.js.map} +1 -1
  28. package/dist/components/{p-ne-_OsQh.js → p-D_fU0kvl.js} +11 -2
  29. package/dist/components/p-D_fU0kvl.js.map +1 -0
  30. package/dist/components/{p-OF14LJnh.js → p-DkfG_oE2.js} +3 -3
  31. package/dist/components/{p-OF14LJnh.js.map → p-DkfG_oE2.js.map} +1 -1
  32. package/dist/components/{p-rnP3lTjZ.js → p-DzM_DEIH.js} +3 -3
  33. package/dist/components/{p-rnP3lTjZ.js.map → p-DzM_DEIH.js.map} +1 -1
  34. package/dist/esm/google-logo-icon_6.entry.js +1 -1
  35. package/dist/esm/loader.js +1 -1
  36. package/dist/esm/nylas-booked-event-card_11.entry.js +8 -0
  37. package/dist/esm/nylas-booked-event-card_11.entry.js.map +1 -1
  38. package/dist/esm/nylas-scheduler-editor.entry.js +1 -1
  39. package/dist/esm/nylas-scheduling.entry.js +17 -4
  40. package/dist/esm/nylas-scheduling.entry.js.map +1 -1
  41. package/dist/esm/nylas-web-elements.js +1 -1
  42. package/dist/esm/{version-Vj35JRt4.js → version-CXFvcHg5.js} +3 -3
  43. package/dist/esm/{version-Vj35JRt4.js.map → version-CXFvcHg5.js.map} +1 -1
  44. package/dist/nylas-web-elements/nylas-scheduling.entry.esm.js.map +1 -1
  45. package/dist/nylas-web-elements/nylas-web-elements.esm.js +1 -1
  46. package/dist/nylas-web-elements/{p-2f3336a6.entry.js → p-15e67701.entry.js} +2 -2
  47. package/dist/nylas-web-elements/p-3a989daf.entry.js +2 -0
  48. package/dist/nylas-web-elements/p-3a989daf.entry.js.map +1 -0
  49. package/dist/nylas-web-elements/{p-5ae85f94.entry.js → p-544c4297.entry.js} +2 -2
  50. package/dist/nylas-web-elements/p-544c4297.entry.js.map +1 -0
  51. package/dist/nylas-web-elements/{p-5eb93f5b.entry.js → p-60fb00a8.entry.js} +2 -2
  52. package/dist/nylas-web-elements/p-CXFvcHg5.js +2 -0
  53. package/dist/nylas-web-elements/{p-Vj35JRt4.js.map → p-CXFvcHg5.js.map} +1 -1
  54. package/dist/types/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.d.ts +1 -0
  55. package/dist/types/connector/shared/api/scheduler.d.ts +1 -1
  56. package/dist/types/version.d.ts +1 -1
  57. package/package.json +1 -1
  58. package/dist/components/p-ne-_OsQh.js.map +0 -1
  59. package/dist/nylas-web-elements/p-5ae85f94.entry.js.map +0 -1
  60. package/dist/nylas-web-elements/p-Vj35JRt4.js +0 -2
  61. package/dist/nylas-web-elements/p-f32db1ab.entry.js +0 -2
  62. package/dist/nylas-web-elements/p-f32db1ab.entry.js.map +0 -1
  63. /package/dist/nylas-web-elements/{p-2f3336a6.entry.js.map → p-15e67701.entry.js.map} +0 -0
  64. /package/dist/nylas-web-elements/{p-5eb93f5b.entry.js.map → p-60fb00a8.entry.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N as o}from"./p-BS9pAWHt.js";import{N as a}from"./p-Cb2blKKQ.js";import{d as c,u as l,t as u,a as d,b as h,g as f,e as p,i as g}from"./p-D7AODx4L.js";import{o as y,v as w}from"./p-Vj35JRt4.js";import{c as b}from"./p-_i6H-yQH.js";import{C as m,L as v,a as _}from"./p-COJy29df.js";c.extend(l);c.extend(u);class E{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.groupEventsCache=new Map;this.CACHE_DURATION=1*60*1e3;this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const e=[];let t=null;const n=50;do{const[i,s]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(s){return h(null,{message:"Error fetching calendars: "+s.message})}if(y(i)){return h(null,{message:"Error fetching calendars: "+i.error?.message})}e.push(...i.data);t=i.next_cursor||null}while(t);this.nylasSchedulerConfigStore.state.calendars=e;return h(e)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(t)}}const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(i){return h(null,{message:"Error fetching configuration: "+i.message})}if(y(n)){return h(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 h(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(i){return h(null,{message:"Error fetching configurations: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return h(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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){d("Calendar ID is not present");return h(null,{message:"Error fetching master event: Calendar ID is not present"})}const i=new URLSearchParams;i.append("calendar_id",n);const[s,r]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(r){return h(null,{message:"Error fetching master event: "+r.message})}if(y(s)){return h(null,{message:"Error fetching master event: "+s.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=s.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:s.data}}return h(s.data)}async createConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error creating configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error updating configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error deleting configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,i]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+i.message})}if(y(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const n=new URLSearchParams;n.append("show_all","true");const i=this.nylasSchedulerConfigStore.state.calendarViewDateRange;let s;let r;if(i){s=i.start_time;r=i.end_time}else{const e=f((new Date).toISOString(),"week");s=e.startTime.toString();r=e.endTime.toString()}const o=`${e}-${s}-${r}`;const a=this.groupEventsCache.get(o);if(a&&Date.now()-a.timestamp<this.CACHE_DURATION){this.nylasSchedulerConfigStore.state.groupEvents=a.data;return h(a.data)}n.append("start_time",s);n.append("end_time",r);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,u]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(u){return h(null,{message:"Error fetching group events: "+u.message})}if(y(l)){return h(null,{message:"Error fetching group events: "+l.error?.message})}this.groupEventsCache.set(o,{data:l.data,timestamp:Date.now()});this.cleanupExpiredCache();this.nylasSchedulerConfigStore.state.groupEvents=l.data;return h(l.data)}cleanupExpiredCache(){const e=Date.now();for(const[t,n]of this.groupEventsCache.entries()){if(e-n.timestamp>this.CACHE_DURATION){this.groupEventsCache.delete(t)}}}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[i,s]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+s.message})}if(y(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(i.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:r,recurrence:s?undefined:e.recurrence},n)}else if(t==="future"&&s){const t=await this.createGroupEvent(e,n);const r={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...r,id:s},n);return[r,t]}else if(t==="all"){const t=e?.when;const r=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[s];let a=o?.when;if(t?.start_time!==r?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==r?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==r?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==r?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:s},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const d={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&r){return this.deleteGroupEventById(r,n)}else if(t==="future"&&s&&r){await this.deleteGroupEventById(r,n);return await this.updateGroupEventById({...d,id:s},n)}else if(t==="all"&&s){return this.deleteGroupEventById(s,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.error?.message})}await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.error?.message})}if(s.data?.imported_events?.length>0){await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}}class k{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){d("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new E({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){d("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){d("NylasSchedulerConfigConnector logout");this.resetStores()}}function x(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=b(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));return{...n,resetSelectedConfiguration:i}}class C{get(e){return new Promise((t=>{const n=globalThis.window?.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){globalThis.window?.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){globalThis.window?.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const $="pkce";const S="grant";const T="user";const P=e=>{if(typeof globalThis.btoa==="function"&&typeof TextEncoder!=="undefined"){const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++){n+=String.fromCharCode(t[e])}return globalThis.btoa(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"utf8").toString("base64")}throw new Error("Base64 encoding is not supported in this environment")};const R=e=>{if(typeof globalThis.atob==="function"&&typeof TextDecoder!=="undefined"){const t=globalThis.atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return(new TextDecoder).decode(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"base64").toString("utf8")}throw new Error("Base64 decoding is not supported in this environment")};class I{Storage=new C;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=P(e);this.Storage.set($,t)}async getPKCE(){try{const e=await this.Storage.get($);if(e){return R(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove($)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${S}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${S}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${S}${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(T,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(T,n)}}else{this.Storage.set(T,[e])}}async getUserToken(e=""){const t=await this.Storage.get(T);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(T);if(e){return e}return null}removeUserTokens(){this.Storage.remove(T)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(T,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class q{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(s){const r=s.transaction(t.storeName,"readwrite");const o=r.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};s.onerror=()=>{i(s.error)};s.onsuccess=t=>{const s=t.target.result;const r=s.transaction(this.storeName,"readwrite");const o=r.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}}))}set(e,t){return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onerror=()=>{i(s.error)};s.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};s.onsuccess=s=>{const r=s.target.result;const o=r.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const c=a.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{i(c.error)};o.oncomplete=()=>{r.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const i=indexedDB.open(e.databaseName,2);i.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};i.onsuccess=function(e){t(e.target.result)};i.onerror=function(e){n(e.error)}}))}}var A;var N=new Uint8Array(16);function U(){if(!A){A=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!A){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return A(N)}var L=/^(?:[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 j(e){return typeof e==="string"&&L.test(e)}var z=[];for(var O=0;O<256;++O){z.push((O+256).toString(16).substr(1))}function D(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]).toLowerCase();if(!j(n)){throw TypeError("Stringified UUID is invalid")}return n}function G(e,t,n){e=e||{};var i=e.random||(e.rng||U)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return D(i)}async function H(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function B(e){let t;let n;let i;let s=false;return function r(o){if(t===undefined){t=o;n=0;i=-1}else{t=M(t,o)}const a=t.length;let c=0;while(n<a){if(s){if(t[n]===10){c=++n}s=false}let r=-1;for(;n<a&&r===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:s=true;case 10:r=n;break}}if(r===-1){break}e(t.subarray(c,r),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function F(e,t,n){let i=J();const s=new TextDecoder;return function r(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=J()}else if(a>0){const n=s.decode(o.subarray(0,a));const r=a+(o[a+1]===32?2:1);const c=s.decode(o.subarray(r));switch(n){case"data":i.data=i.data?i.data+"\n"+c:c;break;case"event":i.event=c;break;case"id":e(i.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(i.retry=n)}break}}}}function M(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function J(){return{data:"",event:"",id:"",retry:undefined}}var Y=undefined&&undefined.__rest||function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};const K="text/event-stream";const V=1e3;const W="last-event-id";function Q(e,t){var{signal:n,headers:i,onopen:s,onmessage:r,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,u=Y(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,d)=>{const h=Object.assign({},i);if(!h.accept){h.accept=K}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=V;let y=0;function w(){document.removeEventListener("visibilitychange",p);window.clearTimeout(y);f.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{w();t()}));const b=l!==null&&l!==void 0?l:window.fetch;const m=s!==null&&s!==void 0?s:Z;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:f.signal}));await m(n);await H(n.body,B(F((e=>{if(e){h[W]=e}else{delete h[W]}}),(e=>{g=e}),r)));o===null||o===void 0?void 0:o();w();t()}catch(e){if(!f.signal.aborted){try{const t=(n=a===null||a===void 0?void 0:a(e))!==null&&n!==void 0?n:g;window.clearTimeout(y);y=window.setTimeout(v,t)}catch(e){w();d(e)}}}}v()}))}function Z(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(K))){throw new Error(`Expected content-type to be ${K}, Actual: ${t}`)}}function X(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){return Math.floor(Date.now()/1e3)}async function te(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const s=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return s}function ne(e){this.message=e}ne.prototype=new Error,ne.prototype.name="InvalidCharacterError";var ie="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ne("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,r=0,o="";i=t.charAt(r++);~i&&(n=s%4?64*n+i:i,s++%4)?o+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function se(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(ie(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 ie(t)}}function re(e){this.message=e}function oe(e,t){if("string"!=typeof e)throw new re("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(se(e.split(".")[n]))}catch(e){throw new re("Invalid token specified: "+e.message)}}re.prototype=new Error,re.prototype.name="InvalidTokenError";class ae{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 q;this.Storage=new I(e)}else{this.Storage=new I}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===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.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 i=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){s+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){s+=`&provider=${n.provider}`}if(n?.email){s+=`&login_hint=${n.email}`}if(t){s+=`&scope=${t.join(" ")}`}return s}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=G();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(globalThis.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===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){const e=new URLSearchParams(globalThis.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=await te(e);let n=btoa(unescape(encodeURIComponent(t)));n=X(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.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 i=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}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 i=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}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(globalThis.window?.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const i=t.get("state");const s=t.get("error");const r=t.get("error_description");const o=t.get("error_code");if(s&&r&&o){const e={detail:{error:s,error_description:r,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.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 a=await this.Storage.getPKCE();if(!a){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:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const s=await t.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(s);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(i){e.data.state=i}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(s){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.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 i=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const s=await i.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ee();s.expires_in=t+s.expires_in;this.Storage.setGrant(s,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",i));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=ee();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=oe(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const s=await this.validateIDToken(i.sub);if(!s){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const i=window.screenX+(window.outerWidth-t)/2;const s=window.screenY+(window.outerHeight-n)/2.5;const r=`uas-popup`;const o=e;const a=window.open(o,r,`width=${t},height=${n},left=${i},top=${s}`);if(!a){return}const c=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=ee();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:s}=n;const r=i;if(r){if(s&&s>ee()){const e=s-t;if(e>30){return r}}}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 i=n["Grant-ID"];let s="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}s=await this.getAccessToken(i)}else{s=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${s}`;if(!n["content-type"]){n["content-type"]="application/json"}return Q(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let s="";let r=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();r=e?e.length:1;s=await this.getAccessToken(t.grant_id)}else{s=await this.getAccessToken()}if(!s){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${s}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${s}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const s=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return s}const a=await(s?.json());const c=await this.isAuthenticatedResponse(s.status,a);if(!c){if(r>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 a}catch(e){throw e}}async fetchRequest(e,t,n,i=true,s,r){const o=await this.isLoggedIn();const a=new URL(e,s??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 l=await fetch(a.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:globalThis.window?.location.origin,body:n?JSON.stringify(n):undefined,...r||{}});if(!i){return l.body}const u=await l.json();return u}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:ee(),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 ce={exports:{}};var le={};
1
+ import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N as o}from"./p-BS9pAWHt.js";import{N as a}from"./p-Cb2blKKQ.js";import{d as c,u as l,t as u,a as d,b as h,g as f,e as p,i as g}from"./p-D7AODx4L.js";import{o as y,v as w}from"./p-CXFvcHg5.js";import{c as b}from"./p-_i6H-yQH.js";import{C as m,L as v,a as _}from"./p-COJy29df.js";c.extend(l);c.extend(u);class E{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.groupEventsCache=new Map;this.CACHE_DURATION=1*60*1e3;this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}async currentUser(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return null}return this.nylasApiRequest.currentUser()}async getCalendars(){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching calendars: Nylas API Request is not initialized"})}const e=[];let t=null;const n=50;do{const[i,s]=await this.nylasApiRequest.request({method:"GET",path:`calendars?limit=${n}${t?`&page_token=${t}`:""}`});if(s){return h(null,{message:"Error fetching calendars: "+s.message})}if(y(i)){return h(null,{message:"Error fetching calendars: "+i.error?.message})}e.push(...i.data);t=i.next_cursor||null}while(t);this.nylasSchedulerConfigStore.state.calendars=e;return h(e)}async getConfigurationById(e,t=false){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(t)}}const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}`});if(i){return h(null,{message:"Error fetching configuration: "+i.message})}if(y(n)){return h(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 h(n.data)}async getConfigurations(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching configurations: Nylas API Request is not initialized"})}const t=50;const[n,i]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations?limit=${t}${e?`&page_token=${e}`:""}`});if(i){return h(null,{message:"Error fetching configurations: "+i.message})}if(y(n)){return h(null,{message:"Error fetching configurations: "+n.error?.message})}this.nylasSchedulerConfigStore.state.configurations=n.data;this.nylasSchedulerConfigStore.state.listConfigurationsNextCursor=n.next_cursor||null;return h(n.data)}async getMasterEventById(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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){d("Calendar ID is not present");return h(null,{message:"Error fetching master event: Calendar ID is not present"})}const i=new URLSearchParams;i.append("calendar_id",n);const[s,r]=await this.nylasApiRequest.request({method:"GET",path:`events/${e}?${i.toString()}`});if(r){return h(null,{message:"Error fetching master event: "+r.message})}if(y(s)){return h(null,{message:"Error fetching master event: "+s.error?.message})}const o=this.nylasSchedulerConfigStore.state.masterGroupEvents;if(o[e]){this.nylasSchedulerConfigStore.state.masterGroupEvents[e]=s.data}else{this.nylasSchedulerConfigStore.state.masterGroupEvents={...o,[e]:s.data}}return h(s.data)}async createConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error creating configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async updateConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error updating configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async deleteConfiguration(e){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(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 h(null,{message:"Error deleting configuration: "+n.message})}if(y(t)){return h(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 h(t.data)}async createGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error creating group event: Nylas API Request is not initialized"})}const[n,i]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/group-events`,body:e});if(i){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+i.message})}if(y(n)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error creating group event: "+n.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=n.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(n.data)}async getGroupEvents(e,t){if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error fetching group events: Nylas API Request is not initialized"})}const n=new URLSearchParams;n.append("show_all","true");const i=this.nylasSchedulerConfigStore.state.calendarViewDateRange;let s;let r;if(i){s=i.start_time;r=i.end_time}else{const e=f((new Date).toISOString(),"week");s=e.startTime.toString();r=e.endTime.toString()}const o=`${e}-${s}-${r}`;const a=this.groupEventsCache.get(o);if(a&&Date.now()-a.timestamp<this.CACHE_DURATION){this.nylasSchedulerConfigStore.state.groupEvents=a.data;return h(a.data)}n.append("start_time",s);n.append("end_time",r);const c=t?.group_booking?.calendar_id;if(c){n.append("calendar_id",c)}const[l,u]=await this.nylasApiRequest.request({method:"GET",path:`scheduling/configurations/${e}/group-events?${n.toString()}`});if(u){return h(null,{message:"Error fetching group events: "+u.message})}if(y(l)){return h(null,{message:"Error fetching group events: "+l.error?.message})}this.groupEventsCache.set(o,{data:l.data,timestamp:Date.now()});this.cleanupExpiredCache();this.nylasSchedulerConfigStore.state.groupEvents=l.data;return h(l.data)}cleanupExpiredCache(){const e=Date.now();for(const[t,n]of this.groupEventsCache.entries()){if(e-n.timestamp>this.CACHE_DURATION){this.groupEventsCache.delete(t)}}}async updateGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error updating group event: Nylas API Request is not initialized"})}const n=e.id;delete e.id;const[i,s]=await this.nylasApiRequest.request({method:"PATCH",path:`scheduling/configurations/${t}/group-events/${n}`,body:e});if(s){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+s.message})}if(y(i)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error updating group event: "+i.error?.message})}this.nylasSchedulerConfigStore.state.selectedGroupEvent=i.data;await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(i.data)}async updateGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).subtract(1,"minute").format("YYYYMMDDTHHmmss[Z]"):"";if(t==="this"){return this.updateGroupEventById({...e,id:r,recurrence:s?undefined:e.recurrence},n)}else if(t==="future"&&s){const t=await this.createGroupEvent(e,n);const r={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:FREQ=DAILY;UNTIL=${u}`]};await this.updateGroupEventById({...r,id:s},n);return[r,t]}else if(t==="all"){const t=e?.when;const r=i?.event?.when;const o=this.nylasSchedulerConfigStore.state.masterGroupEvents?.[s];let a=o?.when;if(t?.start_time!==r?.start_time){a={...a,start_time:t?.start_time||a?.start_time}}if(t?.end_time!==r?.end_time){a={...a,end_time:t?.end_time||a?.end_time}}if(t?.start_timezone!==r?.start_timezone){a={...a,start_timezone:t?.start_timezone||a?.start_timezone}}if(t?.end_timezone!==r?.end_timezone){a={...a,end_timezone:t?.end_timezone||a?.end_timezone}}return this.updateGroupEventById({...e,when:a,id:s},n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEvent(e,t,n){this.nylasSchedulerConfigStore.state.isLoading=true;const i=this.nylasSchedulerConfigStore.state.selectedGroupEvent;const s=i?.event?.master_event_id;const r=i?.event?.id;const o=i?.event?.when?.start_time;const a=i?.group_event_info?.rrule?.[0];const l=a?a.split(";").filter((e=>!e.startsWith("UNTIL"))).join(";"):"";const u=o?c(o*1e3).format("YYYYMMDDTHHmmss[Z]"):"";const d={location:i?.event?.location,conferencing:i?.event?.conferencing,title:i?.event?.title,description:i?.event?.description,capacity:i?.group_event_info?.capacity,calendar_id:i?.event?.calendar_id,recurrence:l?[l+";UNTIL="+u]:[`RRULE:UNTIL=${u}`]};if(t==="this"&&r){return this.deleteGroupEventById(r,n)}else if(t==="future"&&s&&r){await this.deleteGroupEventById(r,n);return await this.updateGroupEventById({...d,id:s},n)}else if(t==="all"&&s){return this.deleteGroupEventById(s,n)}this.nylasSchedulerConfigStore.state.isLoading=false;throw new Error("Invalid option")}async deleteGroupEventById(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error deleting group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"DELETE",path:`scheduling/configurations/${t}/group-events/${e}?calendar_id=${i}`});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error deleting group event: "+s.error?.message})}await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration);this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}async importGroupEvent(e,t){this.nylasSchedulerConfigStore.state.isLoading=true;if(!this.nylasApiRequest){d("Nylas API Request is not initialized");return h(null,{message:"Error importing group event: Nylas API Request is not initialized"})}const n=new URLSearchParams;const i=this.nylasSchedulerConfigStore.state.selectedConfiguration?.group_booking?.calendar_id;if(i){n.append("calendar_id",i)}const[s,r]=await this.nylasApiRequest.request({method:"POST",path:`scheduling/configurations/${t}/import-group-events?${n.toString()}`,body:e});if(r){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+r.message})}if(y(s)){this.nylasSchedulerConfigStore.state.isLoading=false;return h(null,{message:"Error importing group event: "+s.error?.message})}if(s.data?.imported_events?.length>0){await this.getGroupEvents(t,this.nylasSchedulerConfigStore.state.selectedConfiguration)}this.nylasSchedulerConfigStore.state.isLoading=false;return h(s.data)}}class k{constructor({nylasApiRequest:e,nylasSchedulerConfigStore:t}){this.nylasApiRequest=e;this.nylasSchedulerConfigStore=t}init(){d("NylasSchedulerConfigConnector init")}get schedulerConfigStore(){return this.nylasSchedulerConfigStore}get schedulerConfig(){if(this._schedulerConfigConnector){return this._schedulerConfigConnector}this._schedulerConfigConnector=new E({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:this.nylasSchedulerConfigStore});return this._schedulerConfigConnector}resetStores(){d("NylasSchedulerConfigConnector resetStores");this.nylasSchedulerConfigStore.reset()}async logout(){d("NylasSchedulerConfigConnector logout");this.resetStores()}}function x(e={}){const t={selectedConfiguration:{},configurations:[],groupEvents:[],listConfigurationsNextCursor:null,calendars:[],currentUser:null,action:null,additionalParticipants:[],requiresSlug:false,masterGroupEvents:{},isLoading:false,...e};const n=b(t);function i(){n.set("selectedConfiguration",{...e["selectedConfiguration"]})}n.onChange("action",(async e=>{if(!e){i()}}));return{...n,resetSelectedConfiguration:i}}class C{get(e){return new Promise((t=>{const n=globalThis.window?.localStorage.getItem(e);if(!n){t(null)}else{t(JSON.parse(n))}}))}async remove(e){globalThis.window?.localStorage.removeItem(e);return new Promise((e=>{e(null)}))}set(e,t){globalThis.window?.localStorage.setItem(e,JSON.stringify(t));return new Promise((e=>{e(null)}))}}const $="pkce";const S="grant";const T="user";const P=e=>{if(typeof globalThis.btoa==="function"&&typeof TextEncoder!=="undefined"){const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++){n+=String.fromCharCode(t[e])}return globalThis.btoa(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"utf8").toString("base64")}throw new Error("Base64 encoding is not supported in this environment")};const R=e=>{if(typeof globalThis.atob==="function"&&typeof TextDecoder!=="undefined"){const t=globalThis.atob(e);const n=new Uint8Array(t.length);for(let e=0;e<t.length;e++){n[e]=t.charCodeAt(e)}return(new TextDecoder).decode(n)}if(typeof globalThis.Buffer!=="undefined"){return globalThis.Buffer.from(e,"base64").toString("utf8")}throw new Error("Base64 decoding is not supported in this environment")};class I{Storage=new C;constructor(e){if(e){this.Storage=e;return}}setPKCE(e){const t=P(e);this.Storage.set($,t)}async getPKCE(){try{const e=await this.Storage.get($);if(e){return R(e)}}catch(e){return null}return null}removePKCE(){this.Storage.remove($)}setGrant(e,t=false){const{grant_id:n}=e;this.Storage.set(`${S}${t?"-"+n:""}`,e)}removeGrant(e,t=false){this.Storage.remove(`${S}${t?"-"+e:""}`)}async getGrant(e,t=false){const n=await this.Storage.get(`${S}${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(T,n)}else{const n=t.map((t=>{if(t.sub===e.sub){t=e}return t}));this.Storage.set(T,n)}}else{this.Storage.set(T,[e])}}async getUserToken(e=""){const t=await this.Storage.get(T);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(T);if(e){return e}return null}removeUserTokens(){this.Storage.remove(T)}async removeUserToken(e){const t=await this.getUserTokens();const n=t?.filter((t=>t.sub!==e));this.Storage.set(T,n)}async clearSession(){const e=await this.getUserTokens();e?.forEach((e=>{this.removeGrant(e.sub)}));this.removePKCE();this.removeUserTokens()}}class q{databaseName="identity-db";storeName="identity";get(e){const t=this;return new Promise(((n,i)=>{t.openDatabase().then((function(s){const r=s.transaction(t.storeName,"readwrite");const o=r.objectStore(t.storeName);const a=o.get(e);a.onsuccess=()=>{n(a.result)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}))}))}async remove(e){const t=this;return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onupgradeneeded=function(e){const n=e.target.result;n.createObjectStore(t.storeName)};s.onerror=()=>{i(s.error)};s.onsuccess=t=>{const s=t.target.result;const r=s.transaction(this.storeName,"readwrite");const o=r.objectStore(this.storeName);const a=o.delete(e);a.onsuccess=()=>{n(null)};a.onerror=()=>{i(a.error)};r.oncomplete=()=>{s.close()}}}))}set(e,t){return new Promise(((n,i)=>{const s=indexedDB.open(this.databaseName);s.onerror=()=>{i(s.error)};s.onupgradeneeded=e=>{const t=e.target.result;t.createObjectStore(this.storeName)};s.onsuccess=s=>{const r=s.target.result;const o=r.transaction(this.storeName,"readwrite");const a=o.objectStore(this.storeName);const c=a.put(t,e);c.onsuccess=()=>{n(t)};c.onerror=()=>{i(c.error)};o.oncomplete=()=>{r.close()}}}))}openDatabase(){const e=this;return new Promise((function(t,n){const i=indexedDB.open(e.databaseName,2);i.onupgradeneeded=function(t){const n=t.target.result;n.createObjectStore(e.storeName)};i.onsuccess=function(e){t(e.target.result)};i.onerror=function(e){n(e.error)}}))}}var A;var N=new Uint8Array(16);function U(){if(!A){A=typeof crypto!=="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto!=="undefined"&&typeof msCrypto.getRandomValues==="function"&&msCrypto.getRandomValues.bind(msCrypto);if(!A){throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported")}}return A(N)}var L=/^(?:[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 j(e){return typeof e==="string"&&L.test(e)}var z=[];for(var O=0;O<256;++O){z.push((O+256).toString(16).substr(1))}function D(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;var n=(z[e[t+0]]+z[e[t+1]]+z[e[t+2]]+z[e[t+3]]+"-"+z[e[t+4]]+z[e[t+5]]+"-"+z[e[t+6]]+z[e[t+7]]+"-"+z[e[t+8]]+z[e[t+9]]+"-"+z[e[t+10]]+z[e[t+11]]+z[e[t+12]]+z[e[t+13]]+z[e[t+14]]+z[e[t+15]]).toLowerCase();if(!j(n)){throw TypeError("Stringified UUID is invalid")}return n}function H(e,t,n){e=e||{};var i=e.random||(e.rng||U)();i[6]=i[6]&15|64;i[8]=i[8]&63|128;return D(i)}async function G(e,t){const n=e.getReader();let i;while(!(i=await n.read()).done){t(i.value)}}function F(e){let t;let n;let i;let s=false;return function r(o){if(t===undefined){t=o;n=0;i=-1}else{t=M(t,o)}const a=t.length;let c=0;while(n<a){if(s){if(t[n]===10){c=++n}s=false}let r=-1;for(;n<a&&r===-1;++n){switch(t[n]){case 58:if(i===-1){i=n-c}break;case 13:s=true;case 10:r=n;break}}if(r===-1){break}e(t.subarray(c,r),i);c=n;i=-1}if(c===a){t=undefined}else if(c!==0){t=t.subarray(c);n-=c}}}function B(e,t,n){let i=J();const s=new TextDecoder;return function r(o,a){if(o.length===0){n===null||n===void 0?void 0:n(i);i=J()}else if(a>0){const n=s.decode(o.subarray(0,a));const r=a+(o[a+1]===32?2:1);const c=s.decode(o.subarray(r));switch(n){case"data":i.data=i.data?i.data+"\n"+c:c;break;case"event":i.event=c;break;case"id":e(i.id=c);break;case"retry":const n=parseInt(c,10);if(!isNaN(n)){t(i.retry=n)}break}}}}function M(e,t){const n=new Uint8Array(e.length+t.length);n.set(e);n.set(t,e.length);return n}function J(){return{data:"",event:"",id:"",retry:undefined}}var Y=undefined&&undefined.__rest||function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};const K="text/event-stream";const W=1e3;const Q="last-event-id";function V(e,t){var{signal:n,headers:i,onopen:s,onmessage:r,onclose:o,onerror:a,openWhenHidden:c,fetch:l}=t,u=Y(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise(((t,d)=>{const h=Object.assign({},i);if(!h.accept){h.accept=K}let f;function p(){f.abort();if(!document.hidden){v()}}if(!c){document.addEventListener("visibilitychange",p)}let g=W;let y=0;function w(){document.removeEventListener("visibilitychange",p);window.clearTimeout(y);f.abort()}n===null||n===void 0?void 0:n.addEventListener("abort",(()=>{w();t()}));const b=l!==null&&l!==void 0?l:window.fetch;const m=s!==null&&s!==void 0?s:Z;async function v(){var n;f=new AbortController;try{const n=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:f.signal}));await m(n);await G(n.body,F(B((e=>{if(e){h[Q]=e}else{delete h[Q]}}),(e=>{g=e}),r)));o===null||o===void 0?void 0:o();w();t()}catch(e){if(!f.signal.aborted){try{const t=(n=a===null||a===void 0?void 0:a(e))!==null&&n!==void 0?n:g;window.clearTimeout(y);y=window.setTimeout(v,t)}catch(e){w();d(e)}}}}v()}))}function Z(e){const t=e.headers.get("content-type");if(!(t===null||t===void 0?void 0:t.startsWith(K))){throw new Error(`Expected content-type to be ${K}, Actual: ${t}`)}}function X(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function ee(){return Math.floor(Date.now()/1e3)}async function te(e){const t=(new TextEncoder).encode(e);const n=await crypto.subtle.digest("SHA-256",t);const i=Array.from(new Uint8Array(n));const s=i.map((e=>e.toString(16).padStart(2,"0"))).join("");return s}function ne(e){this.message=e}ne.prototype=new Error,ne.prototype.name="InvalidCharacterError";var ie="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(e){var t=String(e).replace(/=+$/,"");if(t.length%4==1)throw new ne("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,i,s=0,r=0,o="";i=t.charAt(r++);~i&&(n=s%4?64*n+i:i,s++%4)?o+=String.fromCharCode(255&n>>(-2*s&6)):0)i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(i);return o};function se(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(ie(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 ie(t)}}function re(e){this.message=e}function oe(e,t){if("string"!=typeof e)throw new re("Invalid token specified");var n=true===(t=t||{}).header?0:1;try{return JSON.parse(se(e.split(".")[n]))}catch(e){throw new re("Invalid token specified: "+e.message)}}re.prototype=new Error,re.prototype.name="InvalidTokenError";class ae{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 q;this.Storage=new I(e)}else{this.Storage=new I}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===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.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 i=await this.getCodeChallege();let s=`${this.domain}/connect/auth?client_id=${this.clientId}&redirect_uri=${this.redirectUri}&access_type=${this.accessType}&response_type=code`;if(i){s+=`&code_challenge=${i}&code_challenge_method=S256&options=rotate_refresh_token`}if(n?.provider){s+=`&provider=${n.provider}`}if(n?.email){s+=`&login_hint=${n.email}`}if(t){s+=`&scope=${t.join(" ")}`}return s}async generateCodeChallenge(){const e=await this.Storage.getPKCE();if(e){return}const t=H();this.Storage.setPKCE(t);return}async hostedSetCodeChallenge(){if(!this.hosted){throw console.error("Method only used with hosted flag enabled")}const e=new URLSearchParams(globalThis.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===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.window?.location.origin))){const e=new URLSearchParams(globalThis.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=await te(e);let n=btoa(unescape(encodeURIComponent(t)));n=X(n);return n}return""}async isLoggedIn(){if(this.hosted&&(this.domain===globalThis.window?.location.origin||this.versioned&&this.domain.includes(globalThis.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 i=await fetch(`${this.domain}/connect/login/imap`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}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 i=await fetch(`${this.domain}/connect/login/ews`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(n)});const s=await i.json();return s}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(globalThis.window?.location.search);if(e){t=new URLSearchParams(e)}const n=t.get("code");const i=t.get("state");const s=t.get("error");const r=t.get("error_description");const o=t.get("error_code");if(s&&r&&o){const e={detail:{error:s,error_description:r,error_code:o}};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.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 a=await this.Storage.getPKCE();if(!a){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:a};const t=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(e)});const s=await t.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));return true}const e=await this.handleCodeExchangeResponse(s);if(!e.valid){const t={detail:e.data};window.dispatchEvent(new CustomEvent("onLoginFail",t));return true}else{if(i){e.data.state=i}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(s){const e={detail:s};window.dispatchEvent(new CustomEvent("onLoginFail",e));window.history.pushState({},document.title,globalThis.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 i=await fetch(`${this.domain}/connect/token`,{method:"POST",headers:new Headers({"content-type":"application/json"}),body:JSON.stringify(t)});const s=await i.json();if(s){if(s.error){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const t=ee();s.expires_in=t+s.expires_in;this.Storage.setGrant(s,this.multiAccount);const n=await this.validateIDToken(e);if(!n){const e={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshFail",e));return true}const i={detail:s};window.dispatchEvent(new CustomEvent("onTokenRefreshSuccess",i));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=ee();e.expires_in=n+e.expires_in;this.Storage.setGrant(e,this.multiAccount);const i=oe(e.id_token);i.status="authenticated";this.Storage.setUserToken(i);const s=await this.validateIDToken(i.sub);if(!s){return{data:e,valid:false}}return{data:e,valid:t}}async popUp(e){const t=500;const n=600;const i=window.screenX+(window.outerWidth-t)/2;const s=window.screenY+(window.outerHeight-n)/2.5;const r=`uas-popup`;const o=e;const a=window.open(o,r,`width=${t},height=${n},left=${i},top=${s}`);if(!a){return}const c=setInterval((async()=>{if(a.closed){const e={detail:{error_description:"OAuth provider window closed"}};window.dispatchEvent(new CustomEvent("onLoginFail",e));c&&clearInterval(c);return}try{const e=a.location.href.split("?");if(!e[0]){return}const t=a.location.search;a.history.pushState({},document.title,window.location.pathname);if(e[0]===this.redirectUri&&e.length>1){const e=await this.codeExchange(t);a.close();if(e){location.reload()}c&&clearInterval(c);return}}catch(e){return}}),1e3)}async getAccessToken(e=""){const t=ee();const n=await this.Storage.getGrant(e,this.multiAccount);if(!n){return null}const{access_token:i,expires_in:s}=n;const r=i;if(r){if(s&&s>ee()){const e=s-t;if(e>30){return r}}}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 i=n["Grant-ID"];let s="";if(this.multiAccount){if(!i){this.logout();throw new Error("Grant ID is required for multi account calls")}s=await this.getAccessToken(i)}else{s=await this.getAccessToken()}delete n["Grant-ID"];n["Authorization"]=`Bearer ${s}`;if(!n["content-type"]){n["content-type"]="application/json"}return V(`${this.domain}/${e}`,{...t,headers:n})}async fetch(e,t,n=true,i){let s="";let r=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();r=e?e.length:1;s=await this.getAccessToken(t.grant_id)}else{s=await this.getAccessToken()}if(!s){throw new Error("Access token not found")}let o=t.headers;if(!Headers.prototype.isPrototypeOf(o)){o=new Headers({Authorization:`Bearer ${s}`,"content-type":"application/json"})}else{o.append("Authorization",`Bearer ${s}`);if(!o.has("content-type")){o.append("content-type","application/json")}}try{if(t?.body){t.body=JSON.stringify(t?.body)}const s=await fetch(`${i||this.domain}/${e}`,{...t,headers:o});if(!n){return s}const a=await(s?.json());const c=await this.isAuthenticatedResponse(s.status,a);if(!c){if(r>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 a}catch(e){throw e}}async fetchRequest(e,t,n,i=true,s,r){const o=await this.isLoggedIn();const a=new URL(e,s??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 l=await fetch(a.toString(),{method:t||"GET",headers:c,mode:"cors",referrer:globalThis.window?.location.origin,body:n?JSON.stringify(n):undefined,...r||{}});if(!i){return l.body}const u=await l.json();return u}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:ee(),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 ce={exports:{}};var le={};
2
2
  /**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -8,4 +8,4 @@ import{h as e,F as t,r as n,c as i,H as s,a as r}from"./p-0EQQA0nE.js";import{N
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */var ue;function de(){if(ue)return le;ue=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.iterator;function h(e){if(null===e||"object"!==typeof e)return null;e=d&&e[d]||e["@@iterator"];return"function"===typeof e?e:null}var f={isMounted:function(){return false},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},p=Object.assign,g={};function y(e,t,n){this.props=e;this.context=t;this.refs=g;this.updater=n||f}y.prototype.isReactComponent={};y.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function w(){}w.prototype=y.prototype;function b(e,t,n){this.props=e;this.context=t;this.refs=g;this.updater=n||f}var m=b.prototype=new w;m.constructor=b;p(m,y.prototype);m.isPureReactComponent=true;var v=Array.isArray,_=Object.prototype.hasOwnProperty,E={current:null},k={key:true,ref:true,__self:true,__source:true};function x(t,n,i){var s,r={},o=null,a=null;if(null!=n)for(s in void 0!==n.ref&&(a=n.ref),void 0!==n.key&&(o=""+n.key),n)_.call(n,s)&&!k.hasOwnProperty(s)&&(r[s]=n[s]);var c=arguments.length-2;if(1===c)r.children=i;else if(1<c){for(var l=Array(c),u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}if(t&&t.defaultProps)for(s in c=t.defaultProps,c)void 0===r[s]&&(r[s]=c[s]);return{$$typeof:e,type:t,key:o,ref:a,props:r,_owner:E.current}}function C(t,n){return{$$typeof:e,type:t.type,key:n,ref:t.ref,props:t.props,_owner:t._owner}}function $(t){return"object"===typeof t&&null!==t&&t.$$typeof===e}function S(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}var T=/\/+/g;function P(e,t){return"object"===typeof e&&null!==e&&null!=e.key?S(""+e.key):t.toString(36)}function R(n,i,s,r,o){var a=typeof n;if("undefined"===a||"boolean"===a)n=null;var c=false;if(null===n)c=true;else switch(a){case"string":case"number":c=true;break;case"object":switch(n.$$typeof){case e:case t:c=true}}if(c)return c=n,o=o(c),n=""===r?"."+P(c,0):r,v(o)?(s="",null!=n&&(s=n.replace(T,"$&/")+"/"),R(o,i,s,"",(function(e){return e}))):null!=o&&($(o)&&(o=C(o,s+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(T,"$&/")+"/")+n)),i.push(o)),1;c=0;r=""===r?".":r+":";if(v(n))for(var l=0;l<n.length;l++){a=n[l];var u=r+P(a,l);c+=R(a,i,s,u,o)}else if(u=h(n),"function"===typeof u)for(n=u.call(n),l=0;!(a=n.next()).done;)a=a.value,u=r+P(a,l++),c+=R(a,i,s,u,o);else if("object"===a)throw i=String(n),Error("Objects are not valid as a React child (found: "+("[object Object]"===i?"object with keys {"+Object.keys(n).join(", ")+"}":i)+"). If you meant to render a collection of children, use an array instead.");return c}function I(e,t,n){if(null==e)return e;var i=[],s=0;R(e,i,"","",(function(e){return t.call(n,e,s++)}));return i}function q(e){if(-1===e._status){var t=e._result;t=t();t.then((function(t){if(0===e._status||-1===e._status)e._status=1,e._result=t}),(function(t){if(0===e._status||-1===e._status)e._status=2,e._result=t}));-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var A={current:null},N={transition:null},U={ReactCurrentDispatcher:A,ReactCurrentBatchConfig:N,ReactCurrentOwner:E};le.Children={map:I,forEach:function(e,t,n){I(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;I(e,(function(){t++}));return t},toArray:function(e){return I(e,(function(e){return e}))||[]},only:function(e){if(!$(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};le.Component=y;le.Fragment=n;le.Profiler=s;le.PureComponent=b;le.StrictMode=i;le.Suspense=c;le.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U;le.cloneElement=function(t,n,i){if(null===t||void 0===t)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var s=p({},t.props),r=t.key,o=t.ref,a=t._owner;if(null!=n){void 0!==n.ref&&(o=n.ref,a=E.current);void 0!==n.key&&(r=""+n.key);if(t.type&&t.type.defaultProps)var c=t.type.defaultProps;for(l in n)_.call(n,l)&&!k.hasOwnProperty(l)&&(s[l]=void 0===n[l]&&void 0!==c?c[l]:n[l])}var l=arguments.length-2;if(1===l)s.children=i;else if(1<l){c=Array(l);for(var u=0;u<l;u++)c[u]=arguments[u+2];s.children=c}return{$$typeof:e,type:t.type,key:r,ref:o,props:s,_owner:a}};le.createContext=function(e){e={$$typeof:o,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null};e.Provider={$$typeof:r,_context:e};return e.Consumer=e};le.createElement=x;le.createFactory=function(e){var t=x.bind(null,e);t.type=e;return t};le.createRef=function(){return{current:null}};le.forwardRef=function(e){return{$$typeof:a,render:e}};le.isValidElement=$;le.lazy=function(e){return{$$typeof:u,_payload:{_status:-1,_result:e},_init:q}};le.memo=function(e,t){return{$$typeof:l,type:e,compare:void 0===t?null:t}};le.startTransition=function(e){var t=N.transition;N.transition={};try{e()}finally{N.transition=t}};le.unstable_act=function(){throw Error("act(...) is not supported in production builds of React.")};le.useCallback=function(e,t){return A.current.useCallback(e,t)};le.useContext=function(e){return A.current.useContext(e)};le.useDebugValue=function(){};le.useDeferredValue=function(e){return A.current.useDeferredValue(e)};le.useEffect=function(e,t){return A.current.useEffect(e,t)};le.useId=function(){return A.current.useId()};le.useImperativeHandle=function(e,t,n){return A.current.useImperativeHandle(e,t,n)};le.useInsertionEffect=function(e,t){return A.current.useInsertionEffect(e,t)};le.useLayoutEffect=function(e,t){return A.current.useLayoutEffect(e,t)};le.useMemo=function(e,t){return A.current.useMemo(e,t)};le.useReducer=function(e,t,n){return A.current.useReducer(e,t,n)};le.useRef=function(e){return A.current.useRef(e)};le.useState=function(e){return A.current.useState(e)};le.useSyncExternalStore=function(e,t,n){return A.current.useSyncExternalStore(e,t,n)};le.useTransition=function(){return A.current.useTransition()};le.version="18.2.0";return le}var he;function fe(){if(he)return ce.exports;he=1;{ce.exports=de()}return ce.exports}fe();const pe=({authenticationUrl:t})=>e("div",{class:"login-required",part:"nse__login-required login-component"},e("div",{class:"card",part:"nse__login-required-card"},e("p",{part:"nse__login-required-text"},"Log into your account to use the Scheduler Editor."),e("button",{class:"google-button",part:"nse__login-required-google-button",onClick:async e=>{e.preventDefault();const n=await t("google");if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},e("span",{class:"icon"},e("google-logo-icon",{width:"15",height:"15"})),"Continue with Google"),e("button",{class:"microsoft-button",part:"nse__login-required-microsoft-button",onClick:async e=>{e.preventDefault();const n=await t("microsoft");if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},e("span",{class:"icon"},e("microsoft-logo-icon",{width:"15",height:"15"})),"Continue with Microsoft"),e("button",{class:"other-provider-button",part:"nse__login-required-other-provider-button",onClick:async e=>{e.preventDefault();const n=await t();if(n){window.location.href=n}else{p(`[nylas-scheduler-editor] Unable to get authentication URL.`)}}},"View all providers ",e("chevron-icon",{width:"17",height:"17"})),e("small",{class:"disclaimer-text",part:"nse__login-required-disclaimer-text"},"* You will be redirected to authenticate your account.")));function ge({currentUser:n,calendars:i,selectedEventType:s}){const r=i?.find((e=>e.is_primary))||i?.[0];switch(s){case m.one_on_one:case m.max_availability:case m.max_fairness:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",null),e("nylas-event-duration",null),e("nylas-event-location",{userProvider:n.provider}))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}case m.collective:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",null),e("nylas-event-duration",null),e("nylas-event-location",{userProvider:n.provider}))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}),e("nylas-additional-participants",{name:"participants",eventParticipants:[{name:n?.name||n?.email,email:n?.email||"",is_organizer:true}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}))}case m.group:{return e(t,null,e("nylas-event-info",null,e("div",{slot:"inputs"},e("nylas-event-title",{noTemplates:true}),e("nylas-event-description",{noTemplates:true,hideAutoPopulateButton:true}),e("nylas-event-location",{userProvider:n.provider}),e("nylas-event-timeslot",{name:"event-timeslot"}),e("nylas-event-capacity",null))),e("nylas-booking-calendar-picker",{exportparts:"nbcp, nbcp__header, nbcp__dropdown, nbcp__dropdown-button, nbcp__dropdown-content",expressFlow:true,calendars:i,currentUser:n,defaultBookingCalendar:r?.id}),e("nylas-additional-participants",{name:"participants",eventParticipants:[{name:n?.name||n?.email,email:n?.email||"",is_organizer:true}],exportparts:"nadtnlpart, nadtnlpart__title, nadtnlpart__subtitle, nadtnlpart__content, nadtnlpart__input_group, nadtnlpart__input_wrapper, nadtnlpart__input, nadtnlpart__remove-participant"}),e("nylas-page-name",{requirePageName:true,pageName:"Group events page"}),e("nylas-custom-event-slug",{name:"custom-event-slug",exportparts:"nces, nces__body, nces__header, nces__drawer-toggle--container, nces__input-textfield"}))}}}const ye=':host{display:flex;flex-direction:column;overflow:visible;border-radius:var(--nylas-border-radius-2x);width:fit-content;background:var(--nylas-base-0);position:relative;box-shadow:0px 0px 6px -2px rgba(0, 0, 0, 0.05), 0px 5px 15px -3px rgba(0, 0, 0, 0.1);--nylas-primary:#2563eb;--nylas-error:#cc4841;--nylas-error-50:#ffeae8;--nylas-error-100:#ffc5bf;--nylas-error-200:#fecaca;--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}:host nylas-notification{position:absolute;top:0;right:0}@media screen and (max-width: 768px){:host{width:-moz-available;width:-webkit-fill-available;width:fill-available;min-width:325px}}div.scheduler-editor-content{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content{height:auto}}div.scheduler-editor-content slot[name=login-required]{height:inherit}div.scheduler-editor-content--group{height:800px}@media screen and (max-width: 768px){div.scheduler-editor-content--group{height:auto}}div.scheduler-editor-header{display:grid;grid-template-columns:1fr auto auto;align-items:center;justify-content:space-between;padding:1rem;border-bottom:1px solid var(--nylas-base-200);color:var(--nylas-base-900);min-width:924px}@media screen and (max-width: 768px){div.scheduler-editor-header{width:auto;min-width:calc(325px - 1rem)}}div.scheduler-editor-header h1.scheduler-editor-title{display:flex;align-items:center;gap:0.5rem;margin:0;font-size:18px;line-height:24px;font-weight:600}div.scheduler-editor-header button{background:transparent;border:none;cursor:pointer;color:var(--nylas-base-900)}div.scheduler-editor-header button:hover,div.scheduler-editor-header button:active{color:var(--nylas-primary);background-color:transparent}div.scheduler-editor-header button:disabled{cursor:not-allowed}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button){border:none;padding:4px;margin-right:8px}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-button):hover{outline:none;color:var(--nylas-primary)}div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){min-width:132px}@media screen and (max-width: 768px){div.scheduler-editor-header div.language select-dropdown::part(sd_dropdown-content){width:-webkit-fill-available;width:fill-available;width:-moz-available}}nylas-select-event-type{height:inherit;width:calc(924px + 2rem)}@media screen and (max-width: 768px){nylas-select-event-type{width:auto}}nylas-editor-tabs,nylas-editor-tabs-group{width:auto;height:inherit}nylas-editor-tabs .row,nylas-editor-tabs-group .row{display:flex;gap:1rem}nylas-editor-tabs .composable,nylas-editor-tabs-group .composable{height:inherit;overflow:auto}nylas-editor-tabs nylas-event-info div[slot=inputs],nylas-editor-tabs nylas-event-limits div[slot=inputs],nylas-editor-tabs-group nylas-event-info div[slot=inputs],nylas-editor-tabs-group nylas-event-limits div[slot=inputs]{display:flex;flex-direction:column;gap:1rem}.card{display:flex;flex-direction:column;padding:2rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;color:var(--nylas-base-900);max-width:fit-content;align-self:center}.login-required{height:inherit;overflow-y:auto;display:flex;flex-direction:column;justify-content:center;padding:2rem 1rem;background-color:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}.login-required p{margin:0 0 1rem}.login-required .microsoft-button,.login-required .google-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;margin-bottom:1rem;background-color:var(--nylas-base-0);border:1px solid var(--nylas-base-200);border-radius:5px;justify-content:center;gap:0.5rem;align-items:center;color:var(--nylas-base-900)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .microsoft-button:hover,.login-required .google-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button{height:48px;border:1px solid var(--nylas-base-300);border-radius:var(--nylas-border-radius-2x);font-size:16px;line-height:24px;padding:0 1rem;background-color:var(--nylas-base-0);font-weight:600;cursor:pointer;display:flex;border:0;background-color:var(--nylas-base-0);height:48px;margin-bottom:1rem;font-size:0.95rem;justify-content:center;gap:0.25rem;align-items:center;color:var(--nylas-base-900)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .other-provider-button svg{transform:rotate(180deg)}.login-required .other-provider-button:hover{background-color:var(--nylas-base-25)}.login-required .disclaimer-text{font-size:0.75rem;color:var(--nylas-base-600);align-self:center}@media screen and (max-width: 768px){.login-required{height:auto}}.list-configurations{padding:2rem;height:inherit;background:var(--nylas-base-25);border-radius:var(--nylas-border-radius-2x)}.list-configurations nylas-list-configurations{height:inherit;display:flex;flex-direction:column}@media screen and (max-width: 768px){.list-configurations{height:auto;padding:2rem 1rem}}';const we=class{constructor(e){n(this,e);this.init=i(this,"init",7);this.loggedIn=i(this,"loggedIn",7);this.loggedOut=i(this,"loggedOut",7);this.schedulerConfigCloseClicked=i(this,"schedulerConfigCloseClicked",7);this.eventOverrides={};this.schedulerPreviewLink="";this.mode="app";this.hideEditorTabs=[];this.requiresSlug=false;this.enableUserFeedback=true;this.nylasBranding=true;this.enableNotetaker=false;this.enableEventTypes={one_on_one:true,collective:true,max_fairness:true,max_availability:true,group:true};this.automaticComponentRegistration=true;this.selectedLanguage=this.defaultLanguage||v.en;this.langVersion=0;this.version=w;this.handleSchedulerConfigCloseClicked=e=>{const t=this.schedulerConfigCloseClicked.emit(this.host);if("schedulerConfigCloseClicked"in this.eventOverrides){this.eventOverrides.schedulerConfigCloseClicked(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){localStorage.removeItem("grant");localStorage.removeItem("user");window.location.reload()}};this.authenticationUrl=async e=>{if(!this.nylasApiRequest){p(`[nylas-scheduler-editor] Nylas API Request is not initialized.`);return""}const t=await this.nylasApiRequest.authenticationUrl({provider:e});return t||""}}connectedCallback(){d(`[nylas-scheduler-editor] connectedCallback`);queueMicrotask((()=>{if(this.themeConfig){this.applyThemeConfig(this.themeConfig);this.host.setAttribute("data-themed","")}}))}async componentWillLoad(){d(`[nylas-scheduler-editor] componentWillLoad`);const e=this.additionalParticipants?.filter((e=>{const t=e.calendars?.length>0?e.calendars.filter((e=>e.id&&e.name)):[];if(e.name&&e.email&&t.length>0){return{name:e.name,email:e.email,calendars:t}}}));this.stores={schedulerConfig:x({...this.defaultSchedulerConfigState,additionalParticipants:e,conferenceProviders:this.conferenceProviders,requiresSlug:this.requiresSlug,selectedLanguage:this.defaultLanguage||v.en,nylasBranding:this.nylasBranding,experimentalFeatures:this.experimentalFeatures,enableEventTypes:this.enableEventTypes,themeConfig:this.themeConfig})};if(!this.nylasApiRequest&&this.nylasSessionsConfig){const e=new ae(this.nylasSessionsConfig);await e.isLoggedIn();e.onLoginSuccess((async()=>{const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){const t=this.loggedIn.emit(this.host);if("loggedIn"in this.eventOverrides){await this.eventOverrides.loggedIn(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){await this.loggedInHandler(e)}}}));e.onLoginFail((async()=>{this.stores?.schedulerConfig?.set("currentUser",null);const e=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides){await this.eventOverrides.loggedOut(e,this.nylasSchedulerConfigConnector);if(e.defaultPrevented){return}}}));this.nylasApiRequest=new a(e)}if(this.nylasApiRequest&&this.defaultAuthArgs){this.nylasApiRequest.setDefaultAuthArgs(this.defaultAuthArgs)}this.baseProvider=new o(this.host,this.stores,this.automaticComponentRegistration,this.eventOverrides);const t=this.baseProvider.getStore("schedulerConfig");this.nylasSchedulerConfigConnector=new k({nylasApiRequest:this.nylasApiRequest,nylasSchedulerConfigStore:t});const n=this.init.emit(this.host);if("init"in this.eventOverrides){await this.eventOverrides.init(n,this.nylasSchedulerConfigConnector)}if(!n.defaultPrevented){const e=await(this.nylasSchedulerConfigConnector?.schedulerConfig?.currentUser());if(e){const t=this.loggedIn.emit(this.host);if("loggedIn"in this.eventOverrides){await this.eventOverrides.loggedIn(t,this.nylasSchedulerConfigConnector)}if(!t.defaultPrevented){await this.loggedInHandler(e)}}else{this.stores?.schedulerConfig?.set("currentUser",null);const e=this.loggedOut.emit(this.host);if("loggedOut"in this.eventOverrides){await this.eventOverrides.loggedOut(e,this.nylasSchedulerConfigConnector);if(e.defaultPrevented){return}}}}this.stores?.schedulerConfig?.onChange("selectedConfiguration",(async e=>{if(e&&e.id){this.configurationId=e.id}}));this.baseProvider?.componentWillLoad(this.nylasSchedulerConfigConnector);this.applyThemeConfig(this.themeConfig)}async componentDidLoad(){d(`[nylas-scheduler-editor] componentDidLoad`);await(this.baseProvider?.componentDidLoad());this.updateLocalization(this.localization);this.version=w}async componentDisconnected(){await(this.baseProvider?.componentDisconnected())}async configurationIdChanged(e){if(e){await(this.nylasSchedulerConfigConnector?.schedulerConfig?.getConfigurationById(e));this.stores?.schedulerConfig?.set("action","edit")}else{this.stores?.schedulerConfig?.set("selectedConfiguration",{});this.stores?.schedulerConfig?.set("action",null)}}updateLocalization(e){if(!e){return}Object.keys(e).forEach((t=>{if(!(t in v)){return}g.addResourceBundle(t,"translation",e[t],false,true)}));this.langVersion++}updateNylasBranding(e){this.stores?.schedulerConfig?.set("nylasBranding",e)}updateExperimentalFeatures(e){this.stores?.schedulerConfig?.set("experimentalFeatures",e)}updateEnableEventTypes(e){this.stores?.schedulerConfig?.set("enableEventTypes",e)}themeConfigChanged(e){this.baseProvider?.getStore("schedulerConfig")?.set("themeConfig",e);this.applyThemeConfig(e)}applyThemeConfig(e){if(e){for(const[t,n]of Object.entries(e)){this.host.style.setProperty(`${t}`,n)}}}async store(){return this.stores?.schedulerConfig}async schedulerConnector(){return this.nylasSchedulerConfigConnector}async registerComponentHandler(e){this.baseProvider?.registerComponent(e.detail)}async unregisterComponentHandler(e){this.baseProvider?.unregisterComponent(e.detail)}nylasFormDropdownChangedHandler(e){const{name:t,value:n}=e.detail;if(t==="language"){this.selectedLanguage=v[n];g.changeLanguage(this.selectedLanguage);this.stores?.schedulerConfig?.set("selectedLanguage",this.selectedLanguage)}}async loggedInHandler(e){this.stores?.schedulerConfig?.set("currentUser",e);if(!this.nylasSchedulerConfigConnector){return}await(this.nylasSchedulerConfigConnector.schedulerConfig?.getCalendars());if(this.configurationId){const e=await(this.nylasSchedulerConfigConnector.schedulerConfig?.getConfigurationById(this.configurationId));if(e&&e[0]?.id){this.stores?.schedulerConfig?.set("action","edit")}}}render(){const t=this.host.querySelector('[slot="custom-page-style-inputs"]');const n=this.stores?.schedulerConfig?.state.selectedConfiguration?.id;const i=Object.keys(_).map((e=>({label:_[e],value:e})));const r=this.stores?.schedulerConfig?.state.selectedEventType===m.group||this.stores?.schedulerConfig?.state.selectedConfiguration?.type===m.group;d(`[nylas-scheduler-editor] render mode: ${this.mode}`);return e(s,{key:"e37a7571ffe7059afb5e93f1cca2c024921af54b"},e("div",{key:"db5aeb93fe047834ca08c081e8b60d795a2c8f58",class:"scheduler-editor-header",part:"nse__header"},e("h1",{key:"791b19e3332afe4c9115fcab4bf015075b75fc15",class:"scheduler-editor-title",part:"nse__title"},e("calendar-icon",{key:"c3d2d9a0425636707e11bd0292404454b19d4044",width:"18",height:"18"}),g.t("schedulerEditorTitle"),e("tooltip-component",{key:"32d9bfdd5bd963beaee18ed0c48d148601cad216"},e("info-icon",{key:"0a0a30a5338c8f921012c9b8ac88a2189d5a36d6",slot:"tooltip-icon"}),e("span",{key:"1911350bbae0f9f0882ccb345c71781574d6c712",slot:"tooltip-content"},this.version))),e("div",{key:"58f5c778f07a8ff850fb07d2710b94e3a774ae32",class:{language:true},part:"nse__language"},e("select-dropdown",{key:"dbdab8e8f804aed103cf35729d9b658b17ebf3b2",name:"language",searchPlaceholder:g.t("search"),options:i,withChevron:false,themeConfig:this.themeConfig,defaultSelectedOption:i.find((e=>e.value==this.selectedLanguage)),exportparts:"sd_dropdown: nse__language-dropdown, sd_dropdown-button: nse__language-drop-button, sd_dropdown-content: nse__language-drop-content, sd_dropdown_label: nse__language-drop-label"},e("span",{key:"3fb225a7f41b29ef9cce3b358a5aa608066979af",slot:"select-icon"},e("translate-icon",{key:"f7b625277108767d6522180f4107cc1d7399c0e6",width:"20",height:"20"})))),e("button",{key:"376cbc21a8821ac38eb73043dbf9ae8474158371",class:"scheduler-editor-close",title:"logout",onClick:e=>this.handleSchedulerConfigCloseClicked(e),part:"nse__close-button"},e("close-icon",{key:"637eb1d8e03cd45172c7c113800cce0c7cf70cf3",width:"18",height:"18"}))),e("div",{key:"83239494ea1d4efcdb246abd4e9fb14672f78708",class:{"scheduler-editor-content":true,"scheduler-editor-content--group":r},part:"nse__content"},this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action===null&&e("div",{key:"643485cb3f09c40519259e9b0e4064484854edec",class:"list-configurations",part:"nse__list-configurations"},e("nylas-list-configurations",{key:"e0ad49a6e3c61faf5daefcf0a5dc0025056f7d0c",themeConfig:this.themeConfig,exportparts:"nlc__create-new-cta, actions__dropdown, actions__dropdown-button, actions__dropdown-content, actions-Copy, actions-Preview, actions-Delete"})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create-select"&&e("nylas-select-event-type",{key:"f28c8ed3d230491b1e0046df33574034bcd857b9",themeConfig:this.themeConfig}),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&r&&e("nylas-editor-tabs-group",{key:"fcf0896b06e51d28ccd1dba4fbffae98725d3f24",mode:"composable",themeConfig:this.themeConfig},e(ge,{key:"df9c1a25f521d373a80de410066beff0911cffe3",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||m.one_on_one,currentUser:this.stores?.schedulerConfig?.state.currentUser,calendars:this.stores?.schedulerConfig?.state?.calendars,selectedConfiguration:this.stores?.schedulerConfig?.state?.selectedConfiguration})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="create"&&!r&&e("nylas-editor-tabs",{key:"a9ec4ff97b427a4362b014a478aaf28e7d04b69e",mode:"composable",enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},e(ge,{key:"404caffc73cc2ebd5dda111f80fd0648224a372f",selectedEventType:this.stores?.schedulerConfig?.state?.selectedEventType||m.one_on_one,currentUser:this.stores?.schedulerConfig?.state.currentUser,calendars:this.stores?.schedulerConfig?.state?.calendars,selectedConfiguration:this.stores?.schedulerConfig?.state?.selectedConfiguration})),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&r&&e("nylas-editor-tabs-group",{key:n,mode:this.mode,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"05baa8d7dbe663e237ae2579a12a4ac4bd466626"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"1235b21d00db6d268f4f5767b4de288ecc891094",name:"custom-page-style-inputs"}))),this.stores?.schedulerConfig?.state.currentUser&&this.stores.schedulerConfig.state.action==="edit"&&!r&&e("nylas-editor-tabs",{key:n,mode:this.mode,enableNotetaker:this.enableNotetaker,themeConfig:this.themeConfig},this.mode==="composable"&&e("slot",{key:"f58a18cb12fb723ef52199a5566d4cae06810c5e"}),this.mode==="app"&&t&&e("div",{style:{display:"none"},slot:"custom-page-style-inputs",key:n},e("slot",{key:"2e19ad87225bcbae1dc70079e8511a35607fe60d",name:"custom-page-style-inputs"}))),!this.stores?.schedulerConfig?.state.currentUser&&e("slot",{key:"c7f1283c363e365f7570dd5c84ec8abc3c974b48",name:"login-required"},e(pe,{key:"f16d4489fc8fbf9d452e117e85bc88ec3ecce321",authenticationUrl:this.authenticationUrl}))))}get host(){return r(this)}static get watchers(){return{configurationId:["configurationIdChanged"],localization:["updateLocalization"],nylasBranding:["updateNylasBranding"],experimentalFeatures:["updateExperimentalFeatures"],enableEventTypes:["updateEnableEventTypes"],themeConfig:["themeConfigChanged"]}}};we.style=ye;export{we as nylas_scheduler_editor};
11
- //# sourceMappingURL=p-5eb93f5b.entry.js.map
11
+ //# sourceMappingURL=p-60fb00a8.entry.js.map
@@ -0,0 +1,2 @@
1
+ var r=(r=>(r.Error="error",r.Warning="warning",r.Info="info",r.Success="success",r))(r||{});const n=r=>r!==null&&typeof r=="object"&&"error"in r;const o="2.3.1-canary-20260108155205";export{n as o,r as u,o as v};
2
+ //# sourceMappingURL=p-CXFvcHg5.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"p-Vj35JRt4.js","sources":["../nylas-js-core/dist/index.es.js","src/version.ts"],"sourcesContent":["var t = Object.defineProperty;\nvar c = (r, n, s) => n in r ? t(r, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[n] = s;\nvar a = (r, n, s) => (c(r, typeof n != \"symbol\" ? n + \"\" : n, s), s);\nvar u = /* @__PURE__ */ ((r) => (r.Error = \"error\", r.Warning = \"warning\", r.Info = \"info\", r.Success = \"success\", r))(u || {});\nconst e = (r) => r !== null && typeof r == \"object\" && \"data\" in r, o = (r) => r !== null && typeof r == \"object\" && \"error\" in r;\nclass E extends Error {\n constructor(s) {\n super(s == null ? void 0 : s.message);\n a(this, \"apiError\");\n this.name = \"NylasAPIError\", this.stack = new Error().stack, this.apiError = s;\n }\n}\nexport {\n u as NotificationType,\n E as NylasAPIError,\n o as isNylasErrorResponse,\n e as isNylasSuccessResponse\n};\n","export const version = '2.3.0';\n"],"names":[],"mappings":"AAGG,IAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE;AACzH,MAA+D,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,QAAQ,IAAI,OAAO,IAAI;;ACJzH,MAAM,OAAO,GAAG;;;;"}
1
+ {"version":3,"file":"p-CXFvcHg5.js","sources":["../nylas-js-core/dist/index.es.js","src/version.ts"],"sourcesContent":["var t = Object.defineProperty;\nvar c = (r, n, s) => n in r ? t(r, n, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[n] = s;\nvar a = (r, n, s) => (c(r, typeof n != \"symbol\" ? n + \"\" : n, s), s);\nvar u = /* @__PURE__ */ ((r) => (r.Error = \"error\", r.Warning = \"warning\", r.Info = \"info\", r.Success = \"success\", r))(u || {});\nconst e = (r) => r !== null && typeof r == \"object\" && \"data\" in r, o = (r) => r !== null && typeof r == \"object\" && \"error\" in r;\nclass E extends Error {\n constructor(s) {\n super(s == null ? void 0 : s.message);\n a(this, \"apiError\");\n this.name = \"NylasAPIError\", this.stack = new Error().stack, this.apiError = s;\n }\n}\nexport {\n u as NotificationType,\n E as NylasAPIError,\n o as isNylasErrorResponse,\n e as isNylasSuccessResponse\n};\n","export const version = '2.3.1-canary-20260108155205';\n"],"names":[],"mappings":"AAGG,IAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,GAAG,OAAO,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,IAAI,GAAG,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE;AACzH,MAA+D,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,IAAI,QAAQ,IAAI,OAAO,IAAI;;ACJzH,MAAM,OAAO,GAAG;;;;"}
@@ -27,6 +27,7 @@ export declare class NylasTimeslotPicker {
27
27
  selectedLanguageChanged(newLanguage: LANGUAGE_CODE): void;
28
28
  selectedDateChanged(newVal: Date | null | undefined): void;
29
29
  availabilityChanged(newVal: AvailabilityTimeslot[] | undefined): void;
30
+ selectedTimezoneChanged(newTimezone: string): void;
30
31
  themeConfigChanged(newThemeConfig: ThemeConfig): void;
31
32
  connectedCallback(): void;
32
33
  disconnectedCallback(): void;
@@ -24,7 +24,7 @@ export declare class NylaSchedulerAPIConnector {
24
24
  setConfigId(configId: string): void;
25
25
  selectDate(date: Date): void;
26
26
  selectTime(time: Timeslot): void;
27
- selectTimezone(timezone: string): void;
27
+ selectTimezone(newTimezone: string): void;
28
28
  selectLanguage(language: string): void;
29
29
  toggleAdditionalData(value: boolean): Promise<void>;
30
30
  setParticipantName(name: string): void;
@@ -1 +1 @@
1
- export declare const version = "2.3.0";
1
+ export declare const version = "2.3.1-canary-20260108155205";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylas/web-elements",
3
- "version": "2.3.0",
3
+ "version": "2.3.1-canary-20260108155205",
4
4
  "description": "Nylas Web Elements",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- {"file":"p-ne-_OsQh.js","mappings":";;;;;;;AAAA,MAAM,sBAAsB,GAAG,y5HAAy5H;;;;;;;;;;;;;;;;MC0B36H,mBAAmB,GAAAA,kBAAA,CAAA,MAAA,mBAAA,SAAAC,CAAA,CAAA;AALhC,IAAA,WAAA,GAAA;;;;;;;AAiCqD,QAAA,IAAgB,CAAA,gBAAA,GAAW,IAAI,CAAC,cAAc,EAAE,CAAC,eAAe,EAAE,CAAC,QAAQ;AAI/E,QAAA,IAAA,CAAA,YAAY,GAAU,IAAI,IAAI,EAAE;AAqBtE,QAAA,IAAK,CAAA,KAAA,GAA2B,EAAE;QA2FnC,IAAA,CAAA,uBAAuB,GAAG,OAAO,KAAY,EAAE,QAA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K,CAAC,uBAAuB,EAAE,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC;gBACjE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM;gBACvC,IAAI,QAAQ,IAAI,QAAQ,EAAE,QAAQ,IAAI,QAAQ,EAAE,QAAQ,EAAE;oBACxD,MAAM,MAAM,GAAG,MAAM,uBAAuB,CAAC,SAAS,CAAC,0BAA0B,CAAC,QAAQ,CAAC;AAC3F,oBAAA,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,EAAE;wBAC/B,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,EAAE,OAAO,IAAI,iDAAiD;AAC/F,wBAAA,IAAI,YAAY,KAAK,eAAe,EAAE;AACpC,4BAAA,IAAI,CAAC,yBAAyB,CAAC,YAAY,EAAE,MAAM,CAAC;;6BAC/C;AACL,4BAAA,IAAI,CAAC,yBAAyB,CAAC,YAAY,EAAE,OAAO,CAAC;;;;qBAGpD;AACL,oBAAA,uBAAuB,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC;;aAE/D;AACD,YAAA,qBAAqB,EAAE,OAAO,KAAqC,EAAE,wBAAiD,KAAI;gBACxH,KAAK,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAAC;aACtE;AACF,SAAA;AACD,QAAA,iBAAiB,EAAE,IAAI;KACxB,CAAC;;;;CAiFD,EAAA,mBAAA,CAAA,SAAA,EAAA,QAAA,EAAA,IAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["__stencil_proxyCustomElement","HTMLElement","i18next"],"sources":["src/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.scss?tag=nylas-timeslot-picker&encapsulation=shadow","src/components/scheduler/nylas-timeslot-picker/nylas-timeslot-picker.tsx"],"sourcesContent":["@use '../../../common/styles/variables' as *;\n\n:host {\n display: block;\n height: calc(100% - 48px); //48px is the height of the header\n @include default-css-variables;\n}\n\n.time-picker-wrapper {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n\n.timeslots {\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n align-items: center;\n overflow-y: scroll;\n padding: 0.5rem 1.5rem 1.5rem;\n flex: 1;\n}\n\n.time {\n /* Frame 12 */\n box-sizing: border-box;\n\n /* Auto layout */\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding: 4px 12px;\n gap: 0.5rem;\n font-size: 16px;\n font-weight: 500;\n font-family: inherit;\n\n width: 100%;\n height: 48px;\n\n color: var(--nylas-base-800);\n background: var(--nylas-base-0);\n border: none;\n outline: 1.5px solid var(--nylas-base-200);\n border-radius: var(--nylas-border-radius-2x);\n\n flex: none;\n order: 4;\n align-self: stretch;\n flex-grow: 0;\n\n cursor: pointer;\n\n &:hover,\n &:focus {\n color: var(--nylas-primary);\n outline-color: var(--nylas-primary);\n }\n\n &.selected {\n font-weight: 600;\n color: var(--nylas-primary);\n outline: 2px solid var(--nylas-primary);\n border-color: transparent;\n box-shadow: 0 0 0 2px var(--nylas-primary);\n }\n\n .time-label {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n\n span.spots {\n font-size: 14px;\n font-family: var(--nylas-font-family);\n font-weight: 400;\n color: var(--nylas-base-600);\n }\n }\n}\n\n.empty {\n text-align: center;\n padding: 0 1.5rem;\n color: var(--nylas-base-600);\n font-size: min(max(12px, 2vw), 14px);\n height: 450px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n@keyframes pulsate {\n 0% {\n background-color: var(--nylas-base-50);\n }\n\n 50% {\n background-color: var(--nylas-base-100);\n }\n\n 100% {\n background-color: var(--nylas-base-50);\n }\n}\n\n.loading {\n padding: 0 1.5rem;\n\n .timeslot-skeleton {\n width: 100%;\n height: 4rem;\n background-color: var(--nylas-base-50);\n margin-bottom: 0.5rem;\n border-radius: var(--nylas-border-radius-2x);\n animation: pulsate 1.5s infinite ease-in-out;\n }\n}\n\n.footer {\n width: 100%;\n padding: 14px;\n box-sizing: border-box;\n border-top: 1px solid var(--nylas-base-200);\n}","import { RegisterComponent } from '@/common/register-component';\nimport { debug, isSameDayTimezone } from '@/utils/utils';\nimport { Component, Element, Event, EventEmitter, Host, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { NylasSchedulerConnector } from '../../..';\nimport { NylasScheduling } from '../nylas-scheduling/nylas-scheduling';\nimport { AvailabilityTimeslot } from '@/stores/scheduler-store';\nimport type { ThemeConfig, Timeslot } from '@nylas/core';\nimport i18next from '@/utils/i18n';\nimport { LANGUAGE_CODE, LANGUAGE_CODE_TO_LOCALE_MAP } from '@/common/constants';\n\n/**\n * The `nylas-timeslot-picker` component is a UI component that allows users to select a timeslot from a list of available timeslots.\n *\n * @slot timeslot-picker-cta-label - The label for the timeslot picker CTA. Default is \"Next\".\n * @part ntp - The timeslot picker component.\n * @part ntp__timeslot - The timeslot button.\n * @part ntp__timeslot--selected - The selected timeslot button.\n * @part ntp__button-primary - The timeslot picker CTA.\n * @part ntp__time-picker-wrapper - The timeslot picker wrapper.\n * @part ntp__timeslots - The timeslot picker timeslots.\n */\n@Component({\n tag: 'nylas-timeslot-picker',\n styleUrl: 'nylas-timeslot-picker.scss',\n shadow: true,\n})\nexport class NylasTimeslotPicker {\n /**\n * The host element.\n * Used to manage the host element of the provider.\n */\n @Element() private host!: HTMLNylasTimeslotPickerElement;\n /**\n * @standalone\n * The available timeslots.\n */\n @Prop({ attribute: 'availability' }) readonly availability?: AvailabilityTimeslot[];\n /**\n * @standalone\n * The loading state prop. Used to display loading state when fetching availability.\n */\n @Prop({ attribute: 'loading-state' }) readonly isLoading?: boolean;\n /**\n * @standalone\n * The theme configuration.\n */\n @Prop({ attribute: 'theme-config' }) readonly themeConfig?: any;\n /**\n * The selected timeslot.\n */\n @Prop({ attribute: 'selected-timeslot' }) readonly selectedTimeslot?: Timeslot;\n /**\n * The selected timezone.\n */\n @Prop({ attribute: 'selected-timezone' }) readonly selectedTimezone: string = Intl.DateTimeFormat().resolvedOptions().timeZone;\n /**\n * The selected date.\n */\n @Prop({ attribute: 'selected-date' }) readonly selectedDate?: Date = new Date();\n /**\n * The selected language.\n */\n @Prop() selectedLanguage?: string;\n /**\n * The 12-hour time format.\n */\n @Prop() hour12?: boolean;\n\n /**\n * This event is fired when a timeslot is selected.\n */\n @Event() readonly timeslotSelected!: EventEmitter<Timeslot>;\n /**\n * This event is fired when a timeslot is confirmed. By default, this will proceed to the booking form page.\n */\n @Event() readonly timeslotConfirmed!: EventEmitter<{ timeslot: Timeslot; host: HTMLNylasTimeslotPickerElement }>;\n\n @Event() readonly validateTimeslotError!: EventEmitter<{ error: string; type: 'error' | 'info' }>;\n\n @State() times: AvailabilityTimeslot[] = [];\n @State() hoveredTimeslotIndex?: number;\n @State() selectedTimeslotIndex?: string;\n\n @Watch('selectedLanguage')\n selectedLanguageChanged(newLanguage: LANGUAGE_CODE) {\n i18next.changeLanguage(newLanguage);\n }\n\n @Watch('selectedDate')\n selectedDateChanged(newVal: Date | null | undefined) {\n debug(`[nylas-timeslot-picker] Selected date changed`, { newVal });\n\n if (newVal) {\n this.selectedTimeslotIndex = '';\n if (typeof newVal !== 'undefined') {\n const availableTimes = this.availability?.filter(timeslot => isSameDayTimezone(timeslot.start_time, newVal, this.selectedTimezone)).map(timeslot => timeslot);\n this.times = availableTimes || [];\n }\n }\n }\n\n @Watch('availability')\n availabilityChanged(newVal: AvailabilityTimeslot[] | undefined) {\n debug(`[nylas-timeslot-picker] Available times changed`, { newVal, selectedDate: this.selectedDate });\n if (typeof newVal !== 'undefined') {\n const availableTimes = newVal\n ?.filter(timeslot => this.selectedDate && isSameDayTimezone(timeslot.start_time, this.selectedDate, this.selectedTimezone))\n .map(timeslot => timeslot);\n this.times = availableTimes || [];\n }\n }\n\n @Watch('themeConfig')\n themeConfigChanged(newThemeConfig: ThemeConfig) {\n this.applyThemeConfig(newThemeConfig);\n }\n\n connectedCallback() {\n // Use queueMicrotask to defer theme application until after React has set props.\n // This fixes the timing issue where connectedCallback fires before React sets themeConfig.\n queueMicrotask(() => {\n if (this.themeConfig) {\n this.applyThemeConfig(this.themeConfig);\n this.host.setAttribute('data-themed', '');\n }\n });\n }\n\n disconnectedCallback() {}\n\n async componentWillLoad() {\n debug(`[nylas-timeslot-picker] Component will load`, { selectedDate: this.selectedDate, availability: this.availability, times: this.times });\n }\n\n async componentDidLoad() {\n debug(`[nylas-timeslot-picker] Component did load`);\n const availableTimes = this.availability\n ?.filter(timeslot => this.selectedDate && isSameDayTimezone(timeslot.start_time, this.selectedDate, this.selectedTimezone))\n .map(timeslot => timeslot);\n this.times = availableTimes || [];\n }\n\n applyThemeConfig(themeConfig?: ThemeConfig) {\n if (themeConfig) {\n for (const [key, value] of Object.entries(themeConfig)) {\n this.host.style.setProperty(`${key}`, value);\n }\n }\n }\n\n private getTimeslotId(timeslot: Timeslot, index: number) {\n const date = new Date(timeslot.start_time);\n const eventId = timeslot.event_id;\n return `${date.toLocaleDateString()}-${index}${eventId ? `-${eventId}` : ''}`;\n }\n\n private onClickSelectTime(timeslot: Timeslot, index: number) {\n debug(`[nylas-timeslot-picker] Time selected`, timeslot, index);\n this.selectedTimeslotIndex = this.getTimeslotId(timeslot, index);\n this.timeslotSelected.emit({\n start_time: timeslot.start_time,\n end_time: timeslot.end_time,\n emails: timeslot.emails,\n capacity: timeslot?.capacity,\n event_id: timeslot?.event_id,\n master_id: timeslot?.master_id,\n calendar_id: timeslot?.calendar_id,\n });\n }\n\n private handleConfirmedTimeslot = async (event: Event, timeslot: Timeslot | undefined) => {\n event.preventDefault();\n debug(`[nylas-timeslot-picker] Confirm timeslot`, timeslot);\n if (timeslot) {\n this.timeslotConfirmed.emit({ timeslot, host: this.host });\n }\n };\n\n @Method()\n async emitValidateTimeslotError(error: string, type: 'error' | 'info') {\n this.validateTimeslotError.emit({ error, type });\n }\n\n private handleMouseEnter = (index: number) => {\n this.hoveredTimeslotIndex = index;\n };\n\n private handleMouseLeave = () => {\n this.hoveredTimeslotIndex = -1;\n };\n\n private getTimeSlotLabel(timeslot: Timeslot) {\n const locale = LANGUAGE_CODE_TO_LOCALE_MAP[this.selectedLanguage || 'en'];\n const timeFormat = new Intl.DateTimeFormat(locale, {\n hour: '2-digit',\n minute: '2-digit',\n timeZone: this.selectedTimezone,\n hour12: this.hour12,\n });\n return `${timeFormat.format(timeslot.start_time)} - ${timeFormat.format(timeslot.end_time)}`;\n }\n\n @RegisterComponent<NylasTimeslotPicker, NylasSchedulerConnector, Exclude<NylasScheduling['stores'], undefined>>({\n name: 'nylas-timeslot-picker',\n stateToProps: new Map([\n ['scheduler.selectedDate', 'selectedDate'],\n ['scheduler.availability', 'availability'],\n ['scheduler.selectedTimeslot', 'selectedTimeslot'],\n ['scheduler.selectedTimezone', 'selectedTimezone'],\n ['scheduler.selectedLanguage', 'selectedLanguage'],\n ['scheduler.isLoading', 'isLoading'],\n ['scheduler.themeConfig', 'themeConfig'],\n ['scheduler.hour12', 'hour12'],\n ]),\n eventToProps: {\n timeslotSelected: async (event: CustomEvent<Timeslot>, nylasSchedulerConnector: NylasSchedulerConnector) => {\n debug('nylas-timeslot-picker', 'timeslotSelected', event.detail);\n nylasSchedulerConnector.scheduler.selectTime(event.detail);\n },\n timeslotConfirmed: async (event: CustomEvent<{ timeslot: Timeslot; host: HTMLNylasTimeslotPickerElement }>, nylasSchedulerConnector: NylasSchedulerConnector) => {\n debug('nylas-timeslot-picker', 'timeslotConfirmed', event.detail);\n const { timeslot, host } = event.detail;\n if (timeslot && timeslot?.event_id && timeslot?.capacity) {\n const result = await nylasSchedulerConnector.scheduler.validateGroupEventTimeslot(timeslot);\n if (result && 'error' in result) {\n const errorMessage = result.error?.message || 'An error occurred while validating the timeslot';\n if (errorMessage === 'Event is full') {\n host.emitValidateTimeslotError(errorMessage, 'info');\n } else {\n host.emitValidateTimeslotError(errorMessage, 'error');\n }\n }\n } else {\n nylasSchedulerConnector.scheduler.toggleAdditionalData(true);\n }\n },\n validateTimeslotError: async (event: CustomEvent<{ error: string }>, _nylasSchedulerConnector: NylasSchedulerConnector) => {\n debug('nylas-timeslot-picker', 'validateTimeslotError', event.detail);\n },\n },\n fireRegisterEvent: true,\n })\n render() {\n const locale = LANGUAGE_CODE_TO_LOCALE_MAP[this.selectedLanguage || 'en'];\n if (this.isLoading) {\n return (\n <Host>\n <div class={'loading'}>\n {new Array(6).fill(0).map((_, i) => (\n <div class={'timeslot-skeleton'} style={{ animationDelay: `${i * 20}ms` }} />\n ))}\n </div>\n </Host>\n );\n }\n\n if (this.availability && this.availability.length === 0) {\n return (\n <Host>\n <div class={'empty'}>\n <span>No dates available</span>\n </div>\n </Host>\n );\n }\n\n const filteredTimes = this.times.filter(timeslot => {\n const groupEvent = timeslot?.event_id || timeslot?.master_id;\n const showCapacity = typeof timeslot?.capacity === 'number' && timeslot?.capacity > 0;\n return !(groupEvent && !showCapacity);\n });\n\n if ((!this.times || this.times.length === 0 || filteredTimes.length === 0) && !!this.selectedDate) {\n return (\n <Host>\n <div class={'empty'}>\n <span>No time slots available for selected date</span>\n </div>\n </Host>\n );\n }\n\n if (!this.selectedDate) return <Host></Host>;\n\n return (\n <Host part=\"ntp\">\n <div class={'time-picker-wrapper'} part=\"ntp__time-picker-wrapper\">\n <div class={'timeslots'} part=\"ntp__timeslots\">\n {filteredTimes.map((timeslot, index) => {\n const showCapacity = typeof timeslot?.capacity === 'number' && timeslot?.capacity > 0;\n const isSelected = this.selectedTimeslotIndex == this.getTimeslotId(timeslot, index);\n return (\n <button\n part={`ntp__timeslot ${this.selectedTimeslot?.start_time?.getTime() === timeslot.start_time.getTime() ? 'ntp__timeslot--selected' : ''}`}\n class={{\n time: true,\n selected: typeof this.selectedTimeslot !== 'undefined' && isSelected,\n }}\n onClick={() => this.onClickSelectTime(timeslot, index)}\n onMouseEnter={() => this.handleMouseEnter(index)}\n onMouseLeave={() => this.handleMouseLeave()}\n >\n <div class=\"time-label\" part=\"ntp__time-label\">\n {this.hoveredTimeslotIndex == index || isSelected\n ? this.getTimeSlotLabel(timeslot)\n : timeslot.start_time.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit', timeZone: this.selectedTimezone, hour12: this.hour12 })}\n <span class=\"spots\">{showCapacity ? i18next.t('spotsLeft', { count: timeslot?.capacity }) : null}</span>\n </div>\n </button>\n );\n })}\n </div>\n {this.selectedTimeslot && (\n <div class={'footer'}>\n <button-component variant={'primary'} onClick={(event: Event) => this.handleConfirmedTimeslot(event, this.selectedTimeslot)} part=\"ntp__button-primary\">\n <slot name=\"timeslot-picker-cta-label\">{i18next.t('nextButton')}</slot>\n </button-component>\n </div>\n )}\n </div>\n </Host>\n );\n }\n}\n"],"version":3}